purified the sons of levi

This commit is contained in:
malloc 2018-08-03 09:58:08 -05:00
parent f6ba8ad878
commit 77d092f459
26 changed files with 0 additions and 1290 deletions

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Basilio</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/Byte.js"></script>
<script type="text/javascript" src="js/LCD.js"></script>
<script type="text/javascript" src="js/Memory.js"></script>
<script type="text/javascript" src="js/Registers.js"></script>
<script type="text/javascript" src="js/TI.js"></script>
<script type="text/javascript" src="js/ops/0x0.js"></script>
</head>
<body onload="TI.Init();">
<table id="lcd" border="0">
</table>
</body>
</html>

View file

@ -1,164 +0,0 @@
var Byte = (function () {
function Byte(init) {
if (typeof init === "undefined") { init = 0; }
this.value = init & 0xFF | (init < 0 ? 0x80 : 0);
}
Byte.prototype.Add = function (val) {
val = typeof val == "number" ? new Byte(val) : val;
var hold = this.value + val.Get();
this.value = hold & 0xFF;
return new Byte(hold > 255 ? hold - 255 : 0);
};
Byte.prototype.Sub = function (val) {
val = typeof val == "number" ? new Byte(val) : val;
return this.Add(val.Neg());
};
Byte.prototype.Get = function () {
return this.value;
};
Byte.prototype.Set = function (val) {
this.value = typeof val == "number" ? val & 0xFF : val.Get();
};
Byte.prototype.Neg = function (bind) {
if (typeof bind === "undefined") { bind = false; }
var tmp = new Byte(~this.value + 1);
this.value = bind ? tmp.Get() : this.value;
return tmp;
};
Byte.prototype.And = function (val) {
val = typeof val == "number" ? new Byte(val) : val;
this.value = this.value & val.Get();
};
Byte.prototype.Or = function (val) {
val = typeof val == "number" ? new Byte(val) : val;
this.value = this.value | val.Get();
};
Byte.prototype.Xor = function (val) {
val = typeof val == "number" ? new Byte(val) : val;
this.value = this.value ^ val.Get();
};
Byte.prototype.Not = function () {
this.value = ~this.value;
};
Byte.prototype.Bit = function (pos, val) {
pos = pos % 8;
this.Set(val ? (this.value | Math.pow(2, pos)) : (this.value & ~Math.pow(2, pos)));
};
Byte.prototype.Test = function (pos) {
pos = pos % 8;
return (this.value & Math.pow(2, pos)) != 0;
};
Byte.prototype.ShiftLeft = function (carry, value) {
if (typeof carry === "undefined") { carry = false; }
if (typeof value === "undefined") { value = false; }
var ret = (this.value & 0x80) != 0;
this.Set(this.value << 1);
this.Bit(0, carry ? ret : value);
return ret;
};
Byte.prototype.ShiftRight = function (carry, value) {
if (typeof carry === "undefined") { carry = false; }
if (typeof value === "undefined") { value = false; }
var ret = (this.value & 0x80) != 0;
this.Set(this.value >>> 1);
this.Bit(7, carry ? ret : value);
return ret;
};
return Byte;
})();
var Word = (function () {
function Word(high, low) {
this.Set(high, low);
}
Word.prototype.Get = function () {
return (this.value[0].Get() << 8) | this.value[1].Get();
};
Word.prototype.High = function () {
return this.value[0];
};
Word.prototype.Low = function () {
return this.value[1];
};
Word.prototype.Set = function (high, low) {
this.value = typeof high == "number" ? [new Byte((high & ~0xFF) >> 8), new Byte(high & 0xFF)] : [high, low];
};
Word.prototype.SetHigh = function (value) {
this.value[0] = typeof value == "number" ? new Byte(value) : value;
};
Word.prototype.SetLow = function (value) {
this.value[1] = typeof value == "number" ? new Byte(value) : value;
};
Word.prototype.Add = function (value) {
value = typeof value == "number" ? new Word(value) : value;
var hold = this.Get() + value.Get();
this.Set(hold);
return new Word(hold > 0xFFFF ? hold - 0xFFFF : 0);
//var overflow = [this.value[0].Add(value.High()), this.value[1].Add(value.Low())];
//return new Word(overflow[0].Get() + this.value[0].Add(overflow[1]).Get());
};
Word.prototype.Sub = function (value) {
value = typeof value == "number" ? new Word(value) : value;
return this.Add(value.Neg());
};
Word.prototype.AddByte = function (value, signed) {
if (typeof signed === "undefined") { signed = false; }
value = typeof value != "number" ? new Word((value.Test(7) && signed ? 0xFF00 : 0x0000) | value.Get()) : new Word(value);
return this.Add(value);
};
Word.prototype.SubByte = function (value) {
value = typeof value != "number" ? new Byte(value) : value;
return this.AddByte(value.Neg(), true);
};
Word.prototype.Not = function () {
this.value[0].Not();
this.value[1].Not();
};
Word.prototype.And = function (value) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].And(value.High());
this.value[1].And(value.Low());
};
Word.prototype.Or = function (value) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Or(value.High());
this.value[1].Or(value.Low());
};
Word.prototype.Xor = function (value) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Xor(value.High());
this.value[1].Xor(value.Low());
};
Word.prototype.Neg = function () {
this.Not();
this.Add(1);
};
return Word;
})();
//# sourceMappingURL=Byte.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,194 +0,0 @@
class Byte {
private value: number;
public constructor(init: number = 0) {
this.value = init & 0xFF | (init < 0 ? 0x80 : 0);
}
public Add(val: Byte): Byte;
public Add(val: number): Byte;
public Add(val: any): Byte {
val = typeof val == "number" ? new Byte(val) : val;
var hold = this.value + val.Get();
this.value = hold & 0xFF;
return new Byte(hold > 255 ? hold - 255 : 0);
}
public Sub(val: Byte): Byte;
public Sub(val: number): Byte;
public Sub(val: any): Byte {
val = typeof val == "number" ? new Byte(val) : val;
return this.Add(val.Neg());
}
public Get(): number {
return this.value;
}
public Set(val: Byte);
public Set(val: number);
public Set(val: any) {
this.value = typeof val == "number" ? val & 0xFF : val.Get();
}
public Neg(bind: boolean = false) {
var tmp = new Byte(~this.value + 1);
this.value = bind ? tmp.Get() : this.value;
return tmp;
}
public And(val: Byte);
public And(val: number);
public And(val: any) {
val = typeof val == "number" ? new Byte(val) : val;
this.value = this.value & val.Get();
}
public Or(val: Byte);
public Or(val: number);
public Or(val: any) {
val = typeof val == "number" ? new Byte(val) : val;
this.value = this.value | val.Get();
}
public Xor(val: Byte);
public Xor(val: number);
public Xor(val: any) {
val = typeof val == "number" ? new Byte(val) : val;
this.value = this.value ^ val.Get();
}
public Not() {
this.value = ~this.value;
}
public Bit(pos: number, val: boolean) {
pos = pos % 8;
this.Set(val ? (this.value | Math.pow(2, pos)) : (this.value & ~Math.pow(2, pos)));
}
public Test(pos: number): boolean {
pos = pos % 8;
return (this.value & Math.pow(2, pos)) != 0;
}
public ShiftLeft(carry: boolean = false, value: boolean = false): boolean {
var ret = (this.value & 0x80) != 0;
this.Set(this.value << 1);
this.Bit(0, carry ? ret : value);
return ret;
}
public ShiftRight(carry: boolean = false, value: boolean = false): boolean {
var ret = (this.value & 0x80) != 0;
this.Set(this.value >>> 1);
this.Bit(7, carry ? ret : value);
return ret;
}
}
class Word {
private value: Byte[];
public constructor(high: number);
public constructor(high: Byte, low: Byte);
public constructor(high: any, low?: Byte) {
this.Set(high, low);
}
public Get(): number {
return (this.value[0].Get() << 8) | this.value[1].Get();
}
public High(): Byte {
return this.value[0];
}
public Low(): Byte {
return this.value[1];
}
public Set(high: number);
public Set(high: Byte, low: Byte);
public Set(high: any, low?: Byte) {
this.value = typeof high == "number" ? [new Byte((high & ~0xFF) >> 8), new Byte(high & 0xFF)] : [high, low];
}
public SetHigh(value: number);
public SetHigh(value: Byte);
public SetHigh(value: any) {
this.value[0] = typeof value == "number" ? new Byte(value) : value;
}
public SetLow(value: number);
public SetLow(value: Byte);
public SetLow(value: any) {
this.value[1] = typeof value == "number" ? new Byte(value) : value;
}
public Add(value: number): Word;
public Add(value: Word): Word;
public Add(value: any): Word {
value = typeof value == "number" ? new Word(value) : value;
var hold = this.Get() + value.Get();
this.Set(hold);
return new Word(hold > 0xFFFF ? hold - 0xFFFF : 0);
//var overflow = [this.value[0].Add(value.High()), this.value[1].Add(value.Low())];
//return new Word(overflow[0].Get() + this.value[0].Add(overflow[1]).Get());
}
public Sub(value: number): Word;
public Sub(value: Word): Word;
public Sub(value: any): Word {
value = typeof value == "number" ? new Word(value) : value;
return this.Add(value.Neg());
}
public AddByte(value: number, signed: boolean): Word;
public AddByte(value: Byte, signed: boolean): Word;
public AddByte(value: any, signed: boolean = false): Word {
value = typeof value != "number" ? new Word((value.Test(7) && signed ? 0xFF00 : 0x0000) | value.Get()) : new Word(value);
return this.Add(value);
}
public SubByte(value: number): Word;
public SubByte(value: Byte): Word;
public SubByte(value: any): Word {
value = typeof value != "number" ? new Byte(value) : value;
return this.AddByte(value.Neg(), true);
}
public Not() {
this.value[0].Not();
this.value[1].Not();
}
public And(value: number);
public And(value: Word);
public And(value: any) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].And(value.High());
this.value[1].And(value.Low());
}
public Or(value: number);
public Or(value: Word);
public Or(value: any) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Or(value.High());
this.value[1].Or(value.Low());
}
public Xor(value: number);
public Xor(value: Word);
public Xor(value: any) {
value = typeof value == "number" ? new Word(value) : value;
this.value[0].Xor(value.High());
this.value[1].Xor(value.Low());
}
public Neg() {
this.Not();
this.Add(1);
}
}

147
js/LCD.js
View file

@ -1,147 +0,0 @@
/// <reference path="Byte.ts" />
var Direction;
(function (Direction) {
Direction[Direction["UP"] = 0] = "UP";
Direction[Direction["RIGHT"] = 1] = "RIGHT";
Direction[Direction["DOWN"] = 2] = "DOWN";
Direction[Direction["LEFT"] = 3] = "LEFT";
})(Direction || (Direction = {}));
var LCD = (function () {
function LCD() {
}
LCD.Init = function () {
LCD.screen = document.getElementById("lcd");
for (var y = 0; y < 64; y++) {
var row = LCD.screen.insertRow(0);
for (var x = 0; x < 120; x++) {
var cell = row.insertCell(x);
cell.style.backgroundPosition = "-" + (LCD.contrast * 2) + "px 0px";
if (x == 95)
cell.style.borderRight = "4px solid white";
}
LCD.vram[y] = [];
for (var x = 0; x < 15; x++)
LCD.vram[y][x] = new Byte(0);
}
};
LCD.GetCell = function (x, y) {
return LCD.screen.rows[y % 64].cells[x % 120];
};
LCD.SetCellX = function (cell, x) {
cell.style.backgroundPosition = -x + "px " + cell.style.backgroundPosition.split(" ")[1];
};
LCD.SetCellY = function (cell, y) {
cell.style.backgroundPosition = cell.style.backgroundPosition.split(" ")[0] + " " + -y + "px";
};
LCD.SetPixel = function (x, y, value) {
if (typeof value === "undefined") { value = true; }
if (LCD.enabled)
LCD.SetCellY(LCD.GetCell(x, y), value ? 2 : 0);
};
LCD.IncrementCursor = function () {
switch (LCD.inc) {
case 0 /* UP */:
LCD.cursor[0] = (LCD.cursor[0] - 1) % 64;
break;
case 2 /* DOWN */:
LCD.cursor[0] = (LCD.cursor[0] + 1) % 64;
break;
case 1 /* RIGHT */:
LCD.cursor[1] = (LCD.cursor[1] + 1) % (LCD.cursor[1] < (LCD.mode ? 15 : 20) ? (LCD.mode ? 15 : 20) : 32);
break;
case 3 /* LEFT */:
LCD.cursor[1] = LCD.cursor[1] > 0 ? LCD.cursor[1] - 1 : (LCD.mode ? 14 : 19);
break;
}
};
LCD.SetContrast = function (value) {
LCD.contrast = Math.floor((value % 64) * (23 / 64));
for (var y = 0; y < 64; y++) {
for (var x = 0; x < 120; x++)
LCD.SetCellX(LCD.GetCell(x, y), LCD.contrast * 2);
}
};
LCD.Disable = function () {
LCD.enabled = false;
for (var y = 0; y < 64; y++) {
for (var x = 0; x < 120; x++)
LCD.SetCellY(LCD.GetCell(x, y), 4);
}
};
LCD.Enable = function () {
LCD.enabled = true;
for (var y = 0; y < 64; y++) {
for (var x = 0; x < 15; x++) {
for (var bit = 0; bit < 8; bit++)
LCD.SetPixel(x * 8 + (bit), y, LCD.vram[y][x].Test(7 - bit));
}
}
};
LCD.Read = function () {
var value = new Byte(0);
if ((LCD.mode && LCD.cursor[1] < 15) || (!LCD.mode && LCD.cursor[1] < 20)) {
if (LCD.mode)
value = LCD.vram[LCD.cursor[0]][LCD.cursor[1]];
else {
value = new Byte(0);
for (var bit = 0; bit < 6; bit++)
value.Bit(5 - bit, LCD.vram[LCD.cursor[0]][Math.floor((6 * LCD.cursor[1] + bit) / 8)].Test(7 - ((6 * LCD.cursor[1] + bit) % 8)));
}
}
LCD.IncrementCursor();
return value;
};
LCD.Write = function (value) {
if ((LCD.mode && LCD.cursor[1] < 15) || (!LCD.mode && LCD.cursor[1] < 20)) {
if (LCD.mode) {
LCD.vram[LCD.cursor[0]][LCD.cursor[1]] = value;
for (var bit = 0; bit < 8; bit++)
LCD.SetPixel(8 * LCD.cursor[1] + bit, LCD.cursor[0], value.Test(7 - bit));
} else {
for (var bit = 0; bit < 6; bit++) {
LCD.SetPixel(6 * LCD.cursor[1] + bit, LCD.cursor[0], value.Test(5 - bit));
LCD.vram[LCD.cursor[0]][Math.floor((6 * LCD.cursor[1] + bit) / 8)].Bit(7 - ((6 * LCD.cursor[1] + bit) % 8), value.Test(5 - bit));
}
}
}
LCD.IncrementCursor();
};
LCD.SetRow = function (row) {
LCD.cursor[0] = row % 64;
};
LCD.SetColumn = function (col) {
LCD.cursor[1] = col % 32;
};
LCD.SetMode = function (mode) {
LCD.mode = mode;
};
LCD.SetDirection = function (dir) {
LCD.inc = dir;
};
LCD.contrast = 12;
LCD.vram = [];
LCD.cursor = [0, 0];
LCD.mode = true;
LCD.inc = 2 /* DOWN */;
LCD.enabled = true;
return LCD;
})();
//# sourceMappingURL=LCD.js.map

File diff suppressed because one or more lines are too long

136
js/LCD.ts
View file

@ -1,136 +0,0 @@
/// <reference path="Byte.ts" />
enum Direction { UP, RIGHT, DOWN, LEFT }
class LCD {
private static screen: HTMLTableElement;
private static contrast: number = 12;
private static vram: Byte[][] = [];
private static cursor: number[] = [0,0]; // row ; column
private static mode: boolean = true; // false: 6 bit ; true: 8 bit
private static inc: Direction = Direction.DOWN;
private static enabled: boolean = true;
static Init() {
LCD.screen = <HTMLTableElement>document.getElementById("lcd");
for(var y = 0; y < 64; y++) {
var row = <HTMLTableRowElement>LCD.screen.insertRow(0);
for(var x = 0; x < 120; x++) {
var cell = row.insertCell(x);
cell.style.backgroundPosition = "-"+ (LCD.contrast * 2) +"px 0px";
if(x == 95) cell.style.borderRight = "4px solid white";
}
LCD.vram[y] = [];
for(var x = 0; x < 15; x++)
LCD.vram[y][x] = new Byte(0);
}
}
private static GetCell(x: number, y: number): HTMLTableCellElement {
return <HTMLTableCellElement>(<HTMLTableRowElement>LCD.screen.rows[y % 64]).cells[x % 120];
}
private static SetCellX(cell: HTMLTableCellElement, x: number) {
cell.style.backgroundPosition = -x +"px "+ cell.style.backgroundPosition.split(" ")[1];
}
private static SetCellY(cell: HTMLTableCellElement, y: number) {
cell.style.backgroundPosition = cell.style.backgroundPosition.split(" ")[0] +" "+ -y +"px";
}
private static SetPixel(x: number, y: number, value: boolean = true) {
if(LCD.enabled) LCD.SetCellY(LCD.GetCell(x, y), value ? 2 : 0);
}
private static IncrementCursor() {
switch(LCD.inc) {
case Direction.UP:
LCD.cursor[0] = (LCD.cursor[0] - 1) % 64;
break;
case Direction.DOWN:
LCD.cursor[0] = (LCD.cursor[0] + 1) % 64;
break;
case Direction.RIGHT:
LCD.cursor[1] = (LCD.cursor[1] + 1) % (LCD.cursor[1] < (LCD.mode ? 15 : 20) ? (LCD.mode ? 15 : 20) : 32);
break;
case Direction.LEFT:
LCD.cursor[1] = LCD.cursor[1] > 0 ? LCD.cursor[1] - 1 : (LCD.mode ? 14 : 19);
break;
}
}
public static SetContrast(value: number) {
LCD.contrast = Math.floor((value % 64) * (23/64));
for(var y = 0; y < 64; y++) {
for(var x = 0; x < 120; x++)
LCD.SetCellX(LCD.GetCell(x, y), LCD.contrast * 2);
}
}
public static Disable() {
LCD.enabled = false;
for(var y = 0; y < 64; y++) {
for(var x = 0; x < 120; x++)
LCD.SetCellY(LCD.GetCell(x, y), 4);
}
}
public static Enable() {
LCD.enabled = true;
for(var y = 0; y < 64; y++) {
for(var x = 0; x < 15; x++) {
for(var bit = 0; bit < 8; bit++)
LCD.SetPixel(x*8 + (bit), y, LCD.vram[y][x].Test(7-bit));
}
}
}
public static Read(): Byte {
var value = new Byte(0);
if((LCD.mode && LCD.cursor[1] < 15) || (!LCD.mode && LCD.cursor[1] < 20)) {
if (LCD.mode) value = LCD.vram[LCD.cursor[0]][LCD.cursor[1]];
else {
value = new Byte(0);
for (var bit = 0; bit < 6; bit++)
value.Bit(5 - bit, LCD.vram[LCD.cursor[0]][Math.floor((6 * LCD.cursor[1] + bit) / 8)].Test(7 - ((6 * LCD.cursor[1] + bit) % 8)));
}
}
LCD.IncrementCursor();
return value;
}
public static Write(value: Byte) {
if((LCD.mode && LCD.cursor[1] < 15) || (!LCD.mode && LCD.cursor[1] < 20)) {
if (LCD.mode) {
LCD.vram[LCD.cursor[0]][LCD.cursor[1]] = value;
for (var bit = 0; bit < 8; bit++)
LCD.SetPixel(8 * LCD.cursor[1] + bit, LCD.cursor[0], value.Test(7 - bit));
} else {
for (var bit = 0; bit < 6; bit++) {
LCD.SetPixel(6 * LCD.cursor[1] + bit, LCD.cursor[0], value.Test(5 - bit));
LCD.vram[LCD.cursor[0]][Math.floor((6 * LCD.cursor[1] + bit) / 8)].Bit(7 - ((6 * LCD.cursor[1] + bit) % 8), value.Test(5 - bit));
}
}
}
LCD.IncrementCursor();
}
public static SetRow(row: number) {
LCD.cursor[0] = row % 64;
}
public static SetColumn(col: number) {
LCD.cursor[1] = col % 32;
}
public static SetMode(mode: boolean) {
LCD.mode = mode;
}
public static SetDirection(dir: Direction) {
LCD.inc = dir;
}
}

View file

@ -1,36 +0,0 @@
/// <reference path="Byte.ts" />
var Bank = (function () {
function Bank(fill) {
if (typeof fill === "undefined") { fill = 0; }
this.data = [];
}
return Bank;
})();
var MemoryMap = (function () {
function MemoryMap(type, index) {
this.Set(type, index);
}
MemoryMap.prototype.Set = function (type, index) {
this.type = type;
this.index = index;
};
return MemoryMap;
})();
var Memory = (function () {
function Memory() {
}
Memory.Init = function () {
};
Memory.Get = function (location) {
return new Byte(0);
};
Memory.Set = function (location, value) {
};
Memory.romLock = true;
return Memory;
})();
//# sourceMappingURL=Memory.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Memory.js","sourceRoot":"","sources":["Memory.ts"],"names":["Bank","Bank.constructor","MemoryMap","MemoryMap.constructor","MemoryMap.Set","Memory","Memory.constructor","Memory.Init","Memory.Get","Memory.Set"],"mappings":"AAAA,gCAAgC;AAEhC;IAGIA,cAAmBA,IAAgBA;QAAhBC,mCAAAA,IAAIA,GAAWA,CAACA;AAAAA,QAFnCA,KAAOA,IAAIA,GAAWA,EAAEA,CAACA;IAIzBA,CAACA;IACLD,YAACA;AAADA,CAACA,IAAA;;AAED;IASIE,mBAAmBA,IAAaA,EAAEA,KAAaA;QAC3CC,IAAIA,CAACA,GAAGA,CAACA,IAAIA,EAAEA,KAAKA,CAACA;IACzBA,CAACA;IAPDD,0BAAAA,UAAWA,IAAaA,EAAEA,KAAaA;QACnCE,IAAIA,CAACA,IAAIA,GAAGA,IAAIA;QAChBA,IAAIA,CAACA,KAAKA,GAAGA,KAAKA;IACtBA,CAACA;IAKLF,iBAACA;AAADA,CAACA,IAAA;;AAED;IAAAG;IAgBAC,CAACA;AAAAD,IAXGA,cAAAA;IAEAE,CAACA;;IAEDF,aAAAA,UAAWA,QAAcA;QACrBG,OAAOA,IAAIA,IAAIA,CAACA,CAACA,CAACA;IACtBA,CAACA;;IAEDH,aAAAA,UAAWA,QAAcA,EAAEA,KAAWA;IAEtCI,CAACA;IAZDJ,iBAA0BA,IAAIA;IAalCA,cAACA;AAADA,CAACA,IAAA"}

View file

@ -1,41 +0,0 @@
/// <reference path="Byte.ts" />
class Bank {
public data: Byte[] = [];
public constructor(fill: number = 0) {
}
}
class MemoryMap {
public type: boolean; // false - ROM ; true - RAM
public index: number; // page index
public Set(type: boolean, index: number) {
this.type = type;
this.index = index;
}
public constructor(type: boolean, index: number) {
this.Set(type, index);
}
}
class Memory {
static rom: Bank[];
static ram: Bank[];
static romLock: boolean = true;
static Init() {
}
static Get(location: Word): Byte {
return new Byte(0);
}
static Set(location: Word, value: Byte) {
}
}

View file

@ -1,73 +0,0 @@
/// <reference path="Byte.ts" />
var Flags;
(function (Flags) {
Flags[Flags["CARRY"] = 0] = "CARRY";
Flags[Flags["ADDSUB"] = 1] = "ADDSUB";
Flags[Flags["PARITY"] = 2] = "PARITY";
Flags[Flags["UNUSED1"] = 3] = "UNUSED1";
Flags[Flags["HALF"] = 4] = "HALF";
Flags[Flags["UNUSED2"] = 5] = "UNUSED2";
Flags[Flags["ZERO"] = 6] = "ZERO";
Flags[Flags["SIGN"] = 7] = "SIGN";
})(Flags || (Flags = {}));
var Registers = (function () {
function Registers() {
}
Registers.Init = function () {
Registers.byteRegisters["IXH"] = new Byte(0);
Registers.byteRegisters["IXL"] = new Byte(0);
Registers.byteRegisters["IYH"] = new Byte(0);
Registers.byteRegisters["IYL"] = new Byte(0);
var tmp = "ABCDEFHLIR";
for (var i; i < tmp.length; i++)
Registers.byteRegisters[tmp[i]] = new Byte(0);
Registers.shadowRegisters["AF"] = new Word(0);
Registers.shadowRegisters["BC"] = new Word(0);
Registers.shadowRegisters["DE"] = new Word(0);
Registers.shadowRegisters["HL"] = new Word(0);
};
Registers.GenerateWord = function (high, low) {
return new Word(Registers.byteRegisters[high], Registers.byteRegisters[low]);
};
Registers.SetFlag = function (flag, value) {
if (flag != 3 /* UNUSED1 */ && flag != 5 /* UNUSED2 */)
Registers.byteRegisters["F"].Bit(flag, value);
};
Registers.GetFlag = function (flag) {
return Registers.byteRegisters["F"].Test(flag);
};
Registers.ExchangeAFShadow = function () {
var tmp = Registers.shadowRegisters["AF"];
Registers.shadowRegisters["AF"].Set(Registers.byteRegisters["A"], Registers.byteRegisters["F"]);
Registers.byteRegisters["A"] = tmp.High();
Registers.byteRegisters["F"] = tmp.Low();
};
Registers.ExchangeShadow = function () {
var regs = ["BC", "DE", "HL"];
for (var reg in regs) {
var tmp = Registers.shadowRegisters[regs[reg]];
Registers.shadowRegisters[regs[reg]].Set(Registers.byteRegisters[regs[reg][0]], Registers.byteRegisters[regs[reg][1]]);
Registers.byteRegisters[regs[reg][0]] = tmp.High();
Registers.byteRegisters[regs[reg][1]] = tmp.Low();
}
};
Registers.SetRegisterPair = function (pair, value) {
Registers.byteRegisters[pair[0]] = value.High();
Registers.byteRegisters[pair[1]] = value.Low();
};
Registers.byteRegisters = [];
Registers.shadowRegisters = [];
Registers.programCounter = new Word(0);
Registers.stackPointer = new Word(0);
return Registers;
})();
//# sourceMappingURL=Registers.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Registers.js","sourceRoot":"","sources":["Registers.ts"],"names":["Flags","Registers","Registers.constructor","Registers.Init","Registers.GenerateWord","Registers.SetFlag","Registers.GetFlag","Registers.ExchangeAFShadow","Registers.ExchangeShadow","Registers.SetRegisterPair"],"mappings":"AAAA,gCAAgC;AAEhC,IAAK,KAAK;AAA8D,CAAxE,UAAK,KAAK;IAAGA,mCAAKA;IAAEA,qCAAMA;IAAEA,qCAAMA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,iCAAIA;0BAAE;;AAExE;IAAAC;IAwDAC,CAACA;AAAAD,IAlDGA,iBAAAA;QACIE,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC5CA,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC5CA,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC5CA,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;;QAE5CA,IAAIA,GAAGA,GAAGA,YAAYA;QACtBA,KAAIA,IAAIA,CAACA,EAAEA,CAACA,GAAGA,GAAGA,CAACA,MAAMA,EAAEA,CAACA,EAAEA;YAC1BA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;;QAElDA,SAASA,CAACA,eAAeA,CAACA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC7CA,SAASA,CAACA,eAAeA,CAACA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA;QAC7CA,SAASA,CAACA,eA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A,KAAIA,IAAIA,GAAGA,IAAIA,IAAIA,CAAEA;YACjBA,IAAIA,GAAGA,GAAGA,SAASA,CAACA,eAAeA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA;YAC9CA,SAASA,CAACA,eAAeA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,GAAGA,CAACA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,EAAEA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;YACtHA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,CAACA;YAClDA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA;SACpDA;IACLA,CAACA;;IAEDP,4BAAAA,UAA8BA,IAAYA,EAAEA,KAAWA;QACnDQ,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,GAAGA,KAAKA,CAACA,IAAIA,CAACA,CAACA;QAC/CA,SAASA,CAACA,aAAaA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,GAAGA,KAAKA,CAACA,GAAGA,CAACA,CAACA;IAClDA,CAACA;IAtDDR,0BAAsCA,EAAEA;IACxCA,4BAAwCA,EAAEA;IAC1CA,2BAAqCA,IAAIA,IAAIA,CAACA,CAACA,CAACA;IAChDA,yBAAmCA,IAAIA,IAAIA,CAACA,CAACA,CAACA;IAoDlDA,iBAACA;AAADA,CAACA,IAAA"}

View file

@ -1,61 +0,0 @@
/// <reference path="Byte.ts" />
enum Flags { CARRY, ADDSUB, PARITY, UNUSED1, HALF, UNUSED2, ZERO, SIGN }
class Registers {
public static byteRegisters: Byte[] = [];
public static shadowRegisters: Word[] = [];
public static programCounter: Word = new Word(0);
public static stackPointer: Word = new Word(0);
public static Init() {
Registers.byteRegisters["IXH"] = new Byte(0);
Registers.byteRegisters["IXL"] = new Byte(0);
Registers.byteRegisters["IYH"] = new Byte(0);
Registers.byteRegisters["IYL"] = new Byte(0);
var tmp = "ABCDEFHLIR";
for(var i; i < tmp.length; i++)
Registers.byteRegisters[tmp[i]] = new Byte(0);
Registers.shadowRegisters["AF"] = new Word(0);
Registers.shadowRegisters["BC"] = new Word(0);
Registers.shadowRegisters["DE"] = new Word(0);
Registers.shadowRegisters["HL"] = new Word(0);
}
public static GenerateWord(high: string, low: string): Word {
return new Word(Registers.byteRegisters[high], Registers.byteRegisters[low]);
}
public static SetFlag(flag: Flags, value: boolean) {
if(flag != Flags.UNUSED1 && flag != Flags.UNUSED2)
Registers.byteRegisters["F"].Bit(flag, value);
}
public static GetFlag(flag: Flags): boolean {
return Registers.byteRegisters["F"].Test(flag);
}
public static ExchangeAFShadow() {
var tmp = Registers.shadowRegisters["AF"];
Registers.shadowRegisters["AF"].Set(Registers.byteRegisters["A"], Registers.byteRegisters["F"]);
Registers.byteRegisters["A"] = tmp.High();
Registers.byteRegisters["F"] = tmp.Low();
}
public static ExchangeShadow() {
var regs = ["BC", "DE", "HL"];
for(var reg in regs) {
var tmp = Registers.shadowRegisters[regs[reg]];
Registers.shadowRegisters[regs[reg]].Set(Registers.byteRegisters[regs[reg][0]], Registers.byteRegisters[regs[reg][1]]);
Registers.byteRegisters[regs[reg][0]] = tmp.High();
Registers.byteRegisters[regs[reg][1]] = tmp.Low();
}
}
public static SetRegisterPair(pair: string, value: Word) {
Registers.byteRegisters[pair[0]] = value.High();
Registers.byteRegisters[pair[1]] = value.Low();
}
}

View file

@ -1,29 +0,0 @@
/// <reference path="Byte.ts" />
/// <reference path="LCD.ts" />
/// <reference path="Memory.ts" />
/// <reference path="Registers.ts" />
/// <reference path="ops/0x0.ts" />
var TI = (function () {
function TI() {
}
TI.PerformOperation = function (data) {
this.Opcodes[data[0].Get()](data);
};
TI.Init = function () {
Registers.Init();
LCD.Init();
Memory.Init();
var a = new Byte(0xF0);
var b = new Byte(10);
//a.Sub(b);
//alert(a.Get());
a.ShiftLeft(true);
//alert(a.Get());
};
TI.Opcodes = [];
return TI;
})();
//# sourceMappingURL=TI.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"TI.js","sourceRoot":"","sources":["TI.ts"],"names":["TI","TI.constructor","TI.PerformOperation","TI.Init"],"mappings":"AAAA,gCAAgC;AAChC,+BAA+B;AAC/B,kCAAkC;AAClC,qCAAqC;AACrC,mCAAmC;;AAUnC;IAAAA;IAkBAC,CAACA;AAAAD,IAfGA,sBAAAA,UAAwBA,IAAYA;QAChCE,IAAIA,CAACA,OAAOA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA;IACrCA,CAACA;;IAEDF,UAAAA;QACIG,SAASA,CAACA,IAAIA,CAACA,CAACA;QAChBA,GAAGA,CAACA,IAAIA,CAACA,CAACA;QACVA,MAAMA,CAACA,IAAIA,CAACA,CAACA;QACbA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,CAACA;QACtBA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA;;QACpBA,WAAWA;QACXA,iBAAiBA;QACjBA,CAACA,CAACA,SAASA,CAACA,IAAIA,CAACA;QACjBA,iBAAiBA;IACrBA,CAACA;IAhBDH,aAAkCA,EAAEA;IAiBxCA,UAACA;AAADA,CAACA,IAAA"}

View file

@ -1,34 +0,0 @@
/// <reference path="Byte.ts" />
/// <reference path="LCD.ts" />
/// <reference path="Memory.ts" />
/// <reference path="Registers.ts" />
/// <reference path="ops/0x0.ts" />
interface opcode {
(args: Byte[]): number[];
// opcodes receive an array of four bytes from memory starting at the point of the program counter
// opcodes return an array,
// first value is the program counter increment (size of instruction)
// second value is the number of T-States taken by the instruction
}
class TI {
public static Opcodes: opcode[] = [];
static PerformOperation(data: Byte[]) {
this.Opcodes[data[0].Get()](data);
}
static Init() {
Registers.Init();
LCD.Init();
Memory.Init();
var a = new Byte(0xF0);
var b = new Byte(10);
//a.Sub(b);
//alert(a.Get());
a.ShiftLeft(true);
//alert(a.Get());
}
}

View file

@ -1,110 +0,0 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
TI.Opcodes[0x00] = function (args) {
return [1, 4];
};
TI.Opcodes[0x01] = function (args) {
Registers.SetRegisterPair("BC", new Word(args[2], args[1]));
return [3, 10];
};
TI.Opcodes[0x02] = function (args) {
Memory.Set(Registers.GenerateWord("B", "C"), Registers.byteRegisters["A"]);
return [1, 7];
};
TI.Opcodes[0x03] = function (args) {
var tmp = Registers.GenerateWord("B", "C");
tmp.Add(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
};
TI.Opcodes[0x04] = function (args) {
var tmp = Registers.byteRegisters["B"];
var over = Registers.byteRegisters["B"].Add(1);
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(6 /* ZERO */, over.Get() != 0);
Registers.SetFlag(2 /* PARITY */, tmp.Test(7) == false && Registers.byteRegisters["B"].Test(7) == true);
Registers.SetFlag(4 /* HALF */, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(7 /* SIGN */, Registers.byteRegisters["B"].Test(7));
return [1, 4];
};
TI.Opcodes[0x05] = function (args) {
// dec b
return [1, 4];
};
TI.Opcodes[0x06] = function (args) {
Registers.byteRegisters["B"] = args[1];
return [1, 7];
};
TI.Opcodes[0x07] = function (args) {
Registers.SetFlag(0 /* CARRY */, Registers.byteRegisters["A"].ShiftLeft(true));
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(4 /* HALF */, false);
return [1, 4];
};
TI.Opcodes[0x08] = function (args) {
Registers.ExchangeAFShadow();
return [1, 4];
};
TI.Opcodes[0x09] = function (args) {
var tmp = [Registers.GenerateWord("H", "L"), Registers.GenerateWord("B", "C")];
var overflow = tmp[0].Add(tmp[1]);
Registers.SetRegisterPair("HL", tmp[0]);
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(0 /* CARRY */, overflow.Get() != 0);
// todo check if flags are set correctly
return [1, 11];
};
TI.Opcodes[0x0A] = function (args) {
Registers.byteRegisters["A"] = Memory.Get(Registers.GenerateWord("B", "C"));
return [1, 7];
};
TI.Opcodes[0x0B] = function (args) {
var tmp = Registers.GenerateWord("B", "C");
tmp.Sub(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
};
TI.Opcodes[0x0C] = function (args) {
var tmp = Registers.byteRegisters["C"];
var over = Registers.byteRegisters["C"].Add(1);
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(6 /* ZERO */, over.Get() != 0);
Registers.SetFlag(2 /* PARITY */, tmp.Test(7) == false && Registers.byteRegisters["C"].Test(7) == true);
Registers.SetFlag(4 /* HALF */, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(7 /* SIGN */, Registers.byteRegisters["C"].Test(7));
return [1, 4];
};
TI.Opcodes[0x0D] = function (args) {
// dec c
return [1, 4];
};
TI.Opcodes[0x0E] = function (args) {
Registers.byteRegisters["A"] = args[1];
return [2, 7];
};
TI.Opcodes[0x0F] = function (args) {
Registers.SetFlag(0 /* CARRY */, Registers.byteRegisters["A"].ShiftRight(true));
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(4 /* HALF */, false);
return [1, 4];
};
//# sourceMappingURL=0x0.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"0x0.js","sourceRoot":"","sources":["0x0.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kCAAkC;AAClC,qCAAqC;AACrC,wCAAwC;AACxC,iCAAiC;AAEjC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC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C,OAAO,CAAC,YAAU,EAAE,KAAK,CAAC;IACpC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC"}

View file

@ -1,109 +0,0 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
TI.Opcodes[0x00] = function(args: Byte[]): number[] {
return [1, 4];
};
TI.Opcodes[0x01] = function(args: Byte[]): number[] {
Registers.SetRegisterPair("BC", new Word(args[2], args[1]));
return [3, 10];
};
TI.Opcodes[0x02] = function(args: Byte[]): number[] {
Memory.Set(Registers.GenerateWord("B","C"), Registers.byteRegisters["A"]);
return [1, 7];
};
TI.Opcodes[0x03] = function(args: Byte[]): number[] {
var tmp = Registers.GenerateWord("B", "C");
tmp.Add(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
};
TI.Opcodes[0x04] = function(args: Byte[]): number[] {
var tmp = Registers.byteRegisters["B"];
var over = Registers.byteRegisters["B"].Add(1);
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.ZERO, over.Get() != 0);
Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters["B"].Test(7) == true);
Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(Flags.SIGN, Registers.byteRegisters["B"].Test(7));
return [1, 4];
};
TI.Opcodes[0x05] = function(args: Byte[]): number[] {
// dec b
return [1, 4];
};
TI.Opcodes[0x06] = function(args: Byte[]): number[] {
Registers.byteRegisters["B"] = args[1];
return [1, 7];
};
TI.Opcodes[0x07] = function(args: Byte[]): number[] {
Registers.SetFlag(Flags.CARRY, Registers.byteRegisters["A"].ShiftLeft(true));
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.HALF, false);
return [1, 4];
};
TI.Opcodes[0x08] = function(args: Byte[]): number[] {
Registers.ExchangeAFShadow();
return [1,4];
};
TI.Opcodes[0x09] = function(args: Byte[]): number[] {
var tmp = [Registers.GenerateWord("H", "L"), Registers.GenerateWord("B","C")];
var overflow = tmp[0].Add(tmp[1]);
Registers.SetRegisterPair("HL", tmp[0]);
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.CARRY, overflow.Get() != 0);
// todo check if flags are set correctly
return [1, 11];
};
TI.Opcodes[0x0A] = function(args: Byte[]): number[] {
Registers.byteRegisters["A"] = Memory.Get(Registers.GenerateWord("B","C"));
return [1, 7];
};
TI.Opcodes[0x0B] = function(args: Byte[]): number[] {
var tmp = Registers.GenerateWord("B", "C");
tmp.Sub(1);
Registers.SetRegisterPair("BC", tmp);
return [1, 6];
};
TI.Opcodes[0x0C] = function(args: Byte[]): number[] {
var tmp = Registers.byteRegisters["C"];
var over = Registers.byteRegisters["C"].Add(1);
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.ZERO, over.Get() != 0);
Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters["C"].Test(7) == true);
Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(Flags.SIGN, Registers.byteRegisters["C"].Test(7));
return [1, 4];
};
TI.Opcodes[0x0D] = function(args: Byte[]): number[] {
// dec c
return [1, 4];
};
TI.Opcodes[0x0E] = function(args: Byte[]): number[] {
Registers.byteRegisters["A"] = args[1];
return [2, 7];
};
TI.Opcodes[0x0F] = function(args: Byte[]): number[] {
Registers.SetFlag(Flags.CARRY, Registers.byteRegisters["A"].ShiftRight(true));
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.HALF, false);
return [1, 4];
};

View file

@ -1,34 +0,0 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
TI.Opcodes[0x10] = function (args) {
Registers.byteRegisters["B"].Sub(1);
if (Registers.byteRegisters["B"].Get() != 0) {
Registers.programCounter.AddByte(args[1], true);
return [0, 13];
} else
return [2, 8];
};
TI.Opcodes[0x11] = function (args) {
Registers.SetRegisterPair("DE", new Word(args[2], args[1]));
return [3, 10];
};
TI.Opcodes[0x12] = function (args) {
Memory.Set(Registers.GenerateWord("D", "E"), Registers.byteRegisters["A"]);
return [1, 7];
};
TI.Opcodes[0x13] = function (args) {
var tmp = Registers.GenerateWord("D", "E");
tmp.Add(1);
Registers.SetRegisterPair("DE", tmp);
return [1, 6];
};
TI.Opcodes[0x13] = function (args) {
};
//# sourceMappingURL=0x1.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"0x1.js","sourceRoot":"","sources":["0x1.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kCAAkC;AAClC,qCAAqC;AACrC,wCAAwC;AACxC,iCAAiC;AAEjC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,IAAG,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAE;QACxC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QAC/C,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;KACjB;QAAM,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzB,CAAC;;AAED,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;AAClB,CAAC;;AAED,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1E,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC;;AAED,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,IAAI,GAAG,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,EAAC,GAAG,CAAC;IACzC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACV,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC;IACpC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC;;AAED,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;AAExC,CAAC"}

View file

@ -1,34 +0,0 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
TI.Opcodes[0x10] = function(args: Byte[]): number[] {
Registers.byteRegisters["B"].Sub(1);
if(Registers.byteRegisters["B"].Get() != 0) {
Registers.programCounter.AddByte(args[1], true);
return [0, 13];
} else return [2, 8];
};
TI.Opcodes[0x11] = function(args: Byte[]): number[] {
Registers.SetRegisterPair("DE", new Word(args[2], args[1]));
return [3, 10];
};
TI.Opcodes[0x12] = function(args: Byte[]): number[] {
Memory.Set(Registers.GenerateWord("D", "E"), Registers.byteRegisters["A"]);
return [1, 7];
};
TI.Opcodes[0x13] = function(args: Byte[]): number[] {
var tmp = Registers.GenerateWord("D","E");
tmp.Add(1);
Registers.SetRegisterPair("DE", tmp);
return [1, 6];
};
TI.Opcodes[0x13] = function(args: Byte[]): number[] {
};

View file

@ -1,21 +0,0 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
function IncrementRegister(reg) {
if (reg.length == 1) {
var tmp = Registers.byteRegisters[reg];
var over = Registers.byteRegisters[reg].Add(1);
Registers.SetFlag(1 /* ADDSUB */, false);
Registers.SetFlag(6 /* ZERO */, over.Get() != 0);
Registers.SetFlag(2 /* PARITY */, tmp.Test(7) == false && Registers.byteRegisters[reg].Test(7) == true);
Registers.SetFlag(4 /* HALF */, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(7 /* SIGN */, Registers.byteRegisters[reg].Test(7));
} else {
var tmp = Registers.GenerateWord(reg[0], reg[1]);
tmp.Add(1);
Registers.SetRegisterPair(reg, tmp);
}
}
//# sourceMappingURL=generic.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"generic.js","sourceRoot":"","sources":["generic.ts"],"names":["IncrementRegister"],"mappings":"AAAA,mCAAmC;AACnC,kCAAkC;AAClC,qCAAqC;AACrC,wCAAwC;AACxC,iCAAiC;AAEjC,SAAS,iBAAiB,CAAC,GAAW;IAClCA,IAAGA,GAAGA,CAACA,MAAMA,IAAIA,CAACA,CAAEA;QAChBA,IAAIA,GAAGA,GAAGA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA;QACtCA,IAAIA,IAAIA,GAAGA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA;QAC9CA,SAASA,CAACA,OAAOA,CAACA,cAAYA,EAAEA,KAAKA,CAACA;QACtCA,SAASA,CAACA,OAAOA,CAACA,YAAUA,EAAEA,IAAIA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA;QAC9CA,SAASA,CAACA,OAAOA,CAACA,cAAYA,EAAEA,GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA,IAAIA,KAAKA,IAAIA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,IAAIA,IAAIA,CAACA;QACrGA,SAASA,CAACA,OAAOA,CAACA,YAAUA,EAAEA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,IAAIA,IAAIA,CAACA;QACzDA,SAASA,CAACA,OAAOA,CAACA,YAAUA,EAAEA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;KACtEA,KAAMA;QACHA,IAAIA,GAAGA,GAAGA,SAASA,CAACA,YAAYA,CAACA,GAAGA,CAACA,CAACA,CAACA,EAACA,GAAGA,CAACA,CAACA,CAACA,CAACA;QAC/CA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA;QACVA,SAASA,CAACA,eAAeA,CAACA,GAAGA,EAAEA,GAAGA,CAACA;KACtCA;AACLA,CAACA"}

View file

@ -1,21 +0,0 @@
/// <reference path="../Byte.ts" />
/// <reference path="../LCD.ts" />
/// <reference path="../Memory.ts" />
/// <reference path="../Registers.ts" />
/// <reference path="../TI.ts" />
function IncrementRegister(reg: string) {
if(reg.length == 1) {
var tmp = Registers.byteRegisters[reg];
var over = Registers.byteRegisters[reg].Add(1);
Registers.SetFlag(Flags.ADDSUB, false);
Registers.SetFlag(Flags.ZERO, over.Get() != 0);
Registers.SetFlag(Flags.PARITY, tmp.Test(7) == false && Registers.byteRegisters[reg].Test(7) == true);
Registers.SetFlag(Flags.HALF, (tmp.Get() & 0x0F) == 0x0F);
Registers.SetFlag(Flags.SIGN, Registers.byteRegisters[reg].Test(7));
} else {
var tmp = Registers.GenerateWord(reg[0],reg[1]);
tmp.Add(1);
Registers.SetRegisterPair(reg, tmp);
}
}

View file

@ -1,20 +0,0 @@
#lcd {
border-spacing: 0;
border-collapse: collapse;
}
#lcd tr {
height: 2px;
padding: 0;
margin: 0;
border: 0;
}
#lcd td {
width: 2px;
height: 2px;
padding: 0;
margin: 0;
border: 0;
background: url(img/pixel.png);
}