op code time

nowow
This commit is contained in:
Alec Obradovich 2015-01-25 14:06:11 -06:00
parent 77aa05a06c
commit 56b52fbb8b
19 changed files with 332 additions and 62 deletions

View file

@ -7,7 +7,9 @@
<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">

View file

@ -67,10 +67,20 @@ var Byte = (function () {
return Byte;
})();
var Word = (function () {
function Word(init) {
if (init === void 0) { init = 0; }
this.value = [new Byte((init & ~0xFF) >> 8), new Byte(init & 0xFF)];
function Word(high, low) {
this.Set(high, low);
}
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) {
};
return Word;
})();
//# sourceMappingURL=Byte.js.map

View file

@ -1 +1 @@
{"version":3,"file":"Byte.js","sourceRoot":"","sources":["Byte.ts"],"names":["Byte","Byte.constructor","Byte.Add","Byte.Sub","Byte.Get","Byte.Set","Byte.Neg","Byte.And","Byte.Or","Byte.Xor","Byte.Not","Byte.Bit","Byte.Test","Byte.ShiftLeft","Byte.ShiftRight","Word","Word.constructor"],"mappings":"AAAA,IAAM,IAAI;IAGNA,SAHEA,IAAIA,CAGaA,IAAgBA;QAAhBC,oBAAgBA,GAAhBA,QAAgBA;QAC/BA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,GAAGA,IAAIA,GAAGA,CAACA,IAAIA,GAAGA,CAACA,GAAGA,IAAIA,GAAGA,CAACA,CAACA,CAACA;IACrDA,CAACA;IAIMD,kBAAGA,GAAVA,UAAWA,GAAQA;QACfE,GAAGA,GAAGA,OAAOA,GAAGA,I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BA,IAAIA,CAACA,KAAKA,GAAGA,CAACA,IAAIA,IAAIA,CAACA,CAACA,IAAIA,GAAGA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA,EAAEA,IAAIA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,CAACA,CAACA;IACxEA,CAACA;IACLD,WAACA;AAADA,CAACA,AAPD,IAOC"}
{"version":3,"file":"Byte.js","sourceRoot":"","sources":["Byte.ts"],"names":["Byte","Byte.constructor","Byte.Add","Byte.Sub","Byte.Get","Byte.Set","Byte.Neg","Byte.And","Byte.Or","Byte.Xor","Byte.Not","Byte.Bit","Byte.Test","Byte.ShiftLeft","Byte.ShiftRight","Word","Word.constructor","Word.High","Word.Low","Word.Set","Word.SetHigh"],"mappings":"AAAA,IAAM,IAAI;IAGNA,SAHEA,IAAIA,CAGaA,IAAgBA;QAAhBC,oBAAgBA,GAAhBA,QAAgBA;QAC/BA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,GAAGA,IAAIA,GAAGA,CAACA,IAAIA,GAAGA,CAACA,GAAGA,IAAIA,GAAGA,CAACA,CAACA,CAACA;IACrDA,CAACA;IAIMD,kBAAGA,GAAVA,UAAWA,GAAQA;QACfE,GAAGA,GAAGA,OAAOA,GAAGA,IAAIA,QAAQA,GAAGA,IAAIA,IAAIA,CAACA,GAAGA,CAACA,GAAGA,GAAGA,CAACA;QACnDA,IAAIA,IAAIA,GAAGA,IAAIA,CAACA,KAAKA,GAAGA,GAAGA,CAACA,GAAGA,EAAEA,CAACA;QAClCA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,GAAGA,IAAIA,CAACA;QACzBA,MAAMA,CAACA,IAAIA,IAAIA,CAACA,IAAIA,GAAGA,GAAGA,GAAGA,IAAIA,GAAGA,GAAGA,GAAGA,CAACA,CAACA,CAACA;IACjDA,CAACA;IAIMF,kBAAGA,GAAVA,UAAWA,GAAQA;QACfG,GAAGA,GAAGA,OAAOA,GAAGA,IAAIA,QAAQA,GAAG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CAACA,CAACA,EAAEA,IAAIA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,CAACA,IAAIA,EAAEA,GAAGA,CAACA,CAACA;IAChHA,CAACA;IAEMJ,sBAAOA,GAAdA,UAAeA,KAAWA;IAE1BK,CAACA;IACLL,WAACA;AAADA,CAACA,AA1BD,IA0BC"}

View file

@ -90,8 +90,27 @@ class Byte {
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 constructor(init: number = 0) {
this.value = [new Byte((init & ~0xFF) >> 8), new Byte(init & 0xFF)];
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: Byte) {
}
}

View file

@ -35,7 +35,8 @@ var LCD = (function () {
};
LCD.SetPixel = function (x, y, value) {
if (value === void 0) { value = true; }
LCD.SetCellY(LCD.GetCell(x, y), value ? 2 : 0);
if (LCD.enabled)
LCD.SetCellY(LCD.GetCell(x, y), value ? 2 : 0);
};
LCD.IncrementCursor = function () {
switch (LCD.inc) {
@ -46,10 +47,10 @@ var LCD = (function () {
LCD.cursor[0] = (LCD.cursor[0] + 1) % 64;
break;
case 1 /* RIGHT */:
LCD.cursor[1] = (LCD.cursor[1] + 1) % (LCD.mode ? 15 : 20);
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] - 1) % (LCD.mode ? 15 : 20);
LCD.cursor[1] = LCD.cursor[1] > 0 ? LCD.cursor[1] - 1 : (LCD.mode ? 14 : 19);
break;
}
};
@ -77,28 +78,31 @@ var LCD = (function () {
}
};
LCD.Read = function () {
var value;
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)));
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.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++) {
console.log(value.Test(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));
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();
@ -107,9 +111,13 @@ var LCD = (function () {
LCD.cursor[0] = row % 64;
};
LCD.SetColumn = function (col) {
LCD.cursor[1] = col % (LCD.mode ? 15 : 20);
LCD.cursor[1] = col % 32;
};
LCD.SetMode = function () {
LCD.SetMode = function (mode) {
LCD.mode = mode;
};
LCD.SetDirection = function (dir) {
LCD.inc = dir;
};
LCD.contrast = 12;
LCD.vram = [];

File diff suppressed because one or more lines are too long

View file

@ -40,7 +40,7 @@ class LCD {
}
private static SetPixel(x: number, y: number, value: boolean = true) {
LCD.SetCellY(LCD.GetCell(x, y), value ? 2 : 0);
if(LCD.enabled) LCD.SetCellY(LCD.GetCell(x, y), value ? 2 : 0);
}
private static IncrementCursor() {
@ -52,10 +52,10 @@ class LCD {
LCD.cursor[0] = (LCD.cursor[0] + 1) % 64;
break;
case Direction.RIGHT:
LCD.cursor[1] = (LCD.cursor[1] + 1) % (LCD.mode ? 15 : 20);
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] - 1) % (LCD.mode ? 15 : 20);
LCD.cursor[1] = LCD.cursor[1] > 0 ? LCD.cursor[1] - 1 : (LCD.mode ? 14 : 19);
break;
}
}
@ -89,27 +89,30 @@ class LCD {
}
public static Read(): Byte {
var value;
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)));
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.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++) {
console.log(value.Test(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));
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();
@ -120,10 +123,14 @@ class LCD {
}
public static SetColumn(col: number) {
LCD.cursor[1] = col % (LCD.mode ? 15 : 20);
LCD.cursor[1] = col % 32;
}
public static SetMode() {
public static SetMode(mode: boolean) {
LCD.mode = mode;
}
public static SetDirection(dir: Direction) {
LCD.inc = dir;
}
}

View file

@ -2,6 +2,7 @@
var Bank = (function () {
function Bank(fill) {
if (fill === void 0) { fill = 0; }
this.data = [];
}
return Bank;
})();
@ -20,6 +21,11 @@ var Memory = (function () {
}
Memory.Init = function () {
};
Memory.Get = function (location) {
return new Byte(0);
};
Memory.Set = function (location, value) {
};
Memory.romLock = true;
return Memory;
})();

View file

@ -1 +1 @@
{"version":3,"file":"Memory.js","sourceRoot":"","sources":["Memory.ts"],"names":["Bank","Bank.constructor","MemoryMap","MemoryMap.constructor","MemoryMap.Set","Memory","Memory.constructor","Memory.Init"],"mappings":"AAAA,gCAAgC;AAEhC,IAAM,IAAI;IAGNA,SAHEA,IAAIA,CAGaA,IAAgBA;QAAhBC,oBAAgBA,GAAhBA,QAAgBA;IAEnCA,CAACA;IACLD,WAACA;AAADA,CAACA,AAND,IAMC;AAED,IAAM,SAAS;IASXE,SATEA,SAASA,CASQA,IAAaA,EAAEA,KAAaA;QAC3CC,IAAIA,CAACA,GAAGA,CAACA,IAAIA,EAAEA,KAAKA,CAACA,CAACA;IAC1BA,CAACA;IAPMD,uBAAGA,GAAVA,UAAWA,IAAaA,EAAEA,KAAaA;QACnCE,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,CAACA;QACjBA,IAAIA,CAACA,KAAKA,GAAGA,KAAKA,CAACA;IACvBA,CAACA;IAKLF,gBAACA;AAADA,CAACA,AAZD,IAYC;AAED,IAAM,MAAM;IAAZG,SAAMA,MAAMA;IAQZC,CAACA;IAHUD,WAAIA,GAAXA;IAEAE,CAACA;IAJMF,cAAOA,GAAYA,IAAIA,CAACA;IAKnCA,aAACA;AAADA,CAACA,AARD,IAQC"}
{"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,IAAM,IAAI;IAGNA,SAHEA,IAAIA,CAGaA,IAAgBA;QAAhBC,oBAAgBA,GAAhBA,QAAgBA;QAF5BA,SAAIA,GAAWA,EAAEA,CAACA;IAIzBA,CAACA;IACLD,WAACA;AAADA,CAACA,AAND,IAMC;AAED,IAAM,SAAS;IASXE,SATEA,SAASA,CASQA,IAAaA,EAAEA,KAAaA;QAC3CC,IAAIA,CAACA,GAAGA,CAACA,IAAIA,EAAEA,KAAKA,CAACA,CAACA;IAC1BA,CAACA;IAPMD,uBAAGA,GAAVA,UAAWA,IAAaA,EAAEA,KAAaA;QACnCE,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,CAACA;QACjBA,IAAIA,CAACA,KAAKA,GAAGA,KAAKA,CAACA;IACvBA,CAACA;IAKLF,gBAACA;AAADA,CAACA,AAZD,IAYC;AAED,IAAM,MAAM;IAAZG,SAAMA,MAAMA;IAgBZC,CAACA;IAXUD,WAAIA,GAAXA;IAEAE,CAACA;IAEMF,UAAGA,GAAVA,UAAWA,QAAcA;QACrBG,MAAMA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;IACvBA,CAACA;IAEMH,UAAGA,GAAVA,UAAWA,QAAcA,EAAEA,KAAWA;IAEtCI,CAACA;IAZMJ,cAAOA,GAAYA,IAAIA,CAACA;IAanCA,aAACA;AAADA,CAACA,AAhBD,IAgBC"}

View file

@ -1,7 +1,7 @@
/// <reference path="Byte.ts" />
class Bank {
public data: Byte[];
public data: Byte[] = [];
public constructor(fill: number = 0) {
@ -30,4 +30,12 @@ class Memory {
static Init() {
}
static Get(location: Word): Byte {
return new Byte(0);
}
static Set(location: Word, value: Byte) {
}
}

43
js/Registers.js Normal file
View file

@ -0,0 +1,43 @@
/// <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.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.ExchangeAccumlatorFlags = function () {
};
Registers.byteRegisters = [];
Registers.shadowRegisters = [];
Registers.programCounter = new Word(0);
Registers.stackPointer = new Word(0);
return Registers;
})();
//# sourceMappingURL=Registers.js.map

1
js/Registers.js.map Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"Registers.js","sourceRoot":"","sources":["Registers.ts"],"names":["Flags","Registers","Registers.constructor","Registers.Init","Registers.GenerateWord","Registers.SetFlag","Registers.GetFlag","Registers.ExchangeAccumlatorFlags"],"mappings":"AAAA,gCAAgC;AAEhC,IAAK,KAAmE;AAAxE,WAAK,KAAK;IAAGA,mCAAKA;IAAEA,qCAAMA;IAAEA,qCAAMA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,uCAAOA;IAAEA,iCAAIA;IAAEA,iCAAIA;AAACA,CAACA,EAAnE,KAAK,KAAL,KAAK,QAA8D;AAExE,IAAM,SAAS;IAAfC,SAAMA,SAASA;IAmCfC,CAACA;IA7BiBD,cAAIA,GAAlBA;QACIE,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;QAC7CA,SAASA,CAACA,aAAaA,CAACA,KAAKA,CAACA,GAAGA,I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cA,GAASA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;IACnCA,sBAAYA,GAASA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;IA+BnDA,gBAACA;AAADA,CAACA,AAnCD,IAmCC"}

40
js/Registers.ts Normal file
View file

@ -0,0 +1,40 @@
/// <reference path="Byte.ts" />
enum Flags { CARRY, ADDSUB, PARITY, UNUSED1, HALF, UNUSED2, ZERO, SIGN }
class Registers {
public static byteRegisters: Byte[] = [];
public static shadowRegisters: Byte[] = [];
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);
}
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 ExchangeAccumlatorFlags() {
}
}

View file

@ -1,16 +1,21 @@
/// <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.Init = function () {
LCD.Init();
var a = new Byte(10);
var b = new Byte(40);
//a.Add(b);
var a = new Byte(0xF0);
var b = new Byte(10);
//a.Sub(b);
alert(a.Neg().Get());
alert(a.Get());
a.ShiftLeft(true);
alert(a.Get());
};
TI.Opcodes = [];
return TI;
})();
//# sourceMappingURL=TI.js.map

View file

@ -1 +1 @@
{"version":3,"file":"TI.js","sourceRoot":"","sources":["TI.ts"],"names":["TI","TI.constructor","TI.Init"],"mappings":"AAAA,gCAAgC;AAChC,+BAA+B;AAE/B,IAAM,EAAE;IAARA,SAAMA,EAAEA;IAWRC,CAACA;IARUD,OAAIA,GAAXA;QACIE,GAAGA,CAACA,IAAIA,EAAEA,CAACA;QACXA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA,CAACA;QACrBA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA,CAACA;QAGrBA,AAFAA,WAAWA;QACXA,WAAWA;QACXA,KAAKA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,GAAGA,EAAEA,CAACA,CAACA;IACzBA,CAACA;IACLF,SAACA;AAADA,CAACA,AAXD,IAWC"}
{"version":3,"file":"TI.js","sourceRoot":"","sources":["TI.ts"],"names":["TI","TI.constructor","TI.Init"],"mappings":"AAAA,gCAAgC;AAChC,+BAA+B;AAC/B,kCAAkC;AAClC,qCAAqC;AACrC,mCAAmC;AAUnC,IAAM,EAAE;IAARA,SAAMA,EAAEA;IAYRC,CAACA;IATUD,OAAIA,GAAXA;QACIE,GAAGA,CAACA,IAAIA,EAAEA,CAACA;QACXA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,IAAIA,CAACA,CAACA;QACvBA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA,CAACA;QAErBA,AADAA,WAAWA;QACXA,KAAKA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA;QACfA,CAACA,CAACA,SAASA,CAACA,IAAIA,CAACA,CAACA;QAClBA,KAAKA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA;IACnBA,CAACA;IAVaF,UAAOA,GAAaA,EAAEA,CAACA;IAWzCA,SAACA;AAADA,CAACA,AAZD,IAYC"}

View file

@ -1,15 +1,28 @@
/// <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 {
static registers: any[];
public static Opcodes: opcode[] = [];
static Init() {
LCD.Init();
var a = new Byte(10);
var b = new Byte(40);
//a.Add(b);
var a = new Byte(0xF0);
var b = new Byte(10);
//a.Sub(b);
alert(a.Neg().Get());
alert(a.Get());
a.ShiftLeft(true);
alert(a.Get());
}
}
}

49
js/ops/0x0.js Normal file
View file

@ -0,0 +1,49 @@
/// <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.byteRegisters["B"] = args[2];
Registers.byteRegisters["C"] = 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) {
// inc bc
return [1, 4];
};
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) {
return [];
};
//# sourceMappingURL=0x0.js.map

1
js/ops/0x0.js.map Normal file
View file

@ -0,0 +1 @@
{"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,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACvC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAC,GAAG,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1E,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IAEpC,AADA,SAAS;IACT,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,IAAI,GAAG,GAAG,SAAS,CAAC,aAAa,CAAC,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AAC,aAAa,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,SAAS,CAAC,OAAO,CAAC,cAAY,EAAE,KAAK,CAAC,CAAC;IACvC,SAAS,CAAC,OAAO,CAAC,YAAU,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IAEpC,MAAM,CAAC,EAAE,CAAA;AACb,CAAC,CAAC"}

58
js/ops/0x0.ts Normal file
View file

@ -0,0 +1,58 @@
/// <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.byteRegisters["B"] = args[2];
Registers.byteRegisters["C"] = 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[] {
// inc bc
return [1, 4];
};
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[] {
return []
};