From 56b52fbb8ba0c2c40ede18ae90f14a460bbc858e Mon Sep 17 00:00:00 2001 From: Alec Obradovich Date: Sun, 25 Jan 2015 14:06:11 -0600 Subject: [PATCH] op code time nowow --- index.html | 2 ++ js/Byte.js | 16 ++++++++++--- js/Byte.js.map | 2 +- js/Byte.ts | 23 ++++++++++++++++-- js/LCD.js | 52 +++++++++++++++++++++++----------------- js/LCD.js.map | 2 +- js/LCD.ts | 47 ++++++++++++++++++++---------------- js/Memory.js | 6 +++++ js/Memory.js.map | 2 +- js/Memory.ts | 10 +++++++- js/Registers.js | 43 +++++++++++++++++++++++++++++++++ js/Registers.js.map | 1 + js/Registers.ts | 40 +++++++++++++++++++++++++++++++ js/TI.js | 13 ++++++---- js/TI.js.map | 2 +- js/TI.ts | 25 ++++++++++++++----- js/ops/0x0.js | 49 ++++++++++++++++++++++++++++++++++++++ js/ops/0x0.js.map | 1 + js/ops/0x0.ts | 58 +++++++++++++++++++++++++++++++++++++++++++++ 19 files changed, 332 insertions(+), 62 deletions(-) create mode 100644 js/Registers.js create mode 100644 js/Registers.js.map create mode 100644 js/Registers.ts create mode 100644 js/ops/0x0.js create mode 100644 js/ops/0x0.js.map create mode 100644 js/ops/0x0.ts diff --git a/index.html b/index.html index 7537504..e657a2e 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,9 @@ + + diff --git a/js/Byte.js b/js/Byte.js index 85dc786..b6ad4ab 100644 --- a/js/Byte.js +++ b/js/Byte.js @@ -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 \ No newline at end of file diff --git a/js/Byte.js.map b/js/Byte.js.map index a614b8a..3ddf005 100644 --- a/js/Byte.js.map +++ b/js/Byte.js.map @@ -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,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,GAAGA,IAAIA,IAAIA,CAACA,GAAGA,CAACA,GAAGA,GAAGA,CAACA;QACnDA,MAAMA,CAACA,IAAIA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,E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GA,GAAGA,GAAGA,KAAKA,CAACA,CAACA;QACjCA,MAAMA,CAACA,GAAGA,CAACA;IACfA,CAACA;IAEMb,yBAAUA,GAAjBA,UAAkBA,KAAsBA,EAAEA,KAAsBA;QAA9Cc,qBAAsBA,GAAtBA,aAAsBA;QAAEA,qBAAsBA,GAAtBA,aAAsBA;QAC5DA,IAAIA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,CAACA,IAAIA,CAACA,CAACA;QACnCA,IAAIA,CAACA,GAAGA,CAACA,IAAIA,CAACA,KAAKA,KAAKA,CAACA,CAACA,CAACA;QAC3BA,IAAIA,CAACA,GAAGA,CAACA,CAACA,EAAEA,KAAKA,GAAGA,GAAGA,GAAGA,KAAKA,CAACA,CAACA;QACjCA,MAAMA,CAACA,GAAGA,CAACA;IACfA,CAACA;IACLd,WAACA;AAADA,CAACA,AAvFD,IAuFC;AAED,IAAM,IAAI;IAINe,SAJEA,IAAIA,CAIaA,IAAgBA;QAAhBC,oBAAgBA,GAAhBA,QAAgBA;QAC/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"} \ No newline at end of file +{"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,QAAgB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A,GAAGA,GAAGA,GAAGA,KAAKA,CAACA,CAACA;QACjCA,MAAMA,CAACA,GAAGA,CAACA;IACfA,CAACA;IACLd,WAACA;AAADA,CAACA,AAvFD,IAuFC;AAED,IAAM,IAAI;IAKNe,SALEA,IAAIA,CAKaA,IAASA,EAAEA,GAAUA;QACpCC,IAAIA,CAACA,GAAGA,CAACA,IAAIA,EAAEA,GAAGA,CAACA,CAACA;IACxBA,CAACA;IAEMD,mBAAIA,GAAXA;QACIE,MAAMA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA,CAACA,CAACA;IACzBA,CAACA;IAEMF,kBAAGA,GAAVA;QACIG,MAAMA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA,CAACA,CAACA;IACzBA,CAACA;IAIMH,kBAAGA,GAAVA,UAAWA,IAASA,EAAEA,GAAUA;QAC5BI,IAAIA,CAACA,KAAKA,GAAGA,OAAOA,IAAIA,IAAIA,QAAQA,GAAGA,CAACA,IAAIA,IAAIA,CAACA,CAACA,IAAIA,GAAGA,CAACA,IAAIA,CAACA,IAAIA,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"} \ No newline at end of file diff --git a/js/Byte.ts b/js/Byte.ts index 61a155c..66d9ab9 100644 --- a/js/Byte.ts +++ b/js/Byte.ts @@ -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) { + } } \ No newline at end of file diff --git a/js/LCD.js b/js/LCD.js index e383668..c1a6871 100644 --- a/js/LCD.js +++ b/js/LCD.js @@ -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 = []; diff --git a/js/LCD.js.map b/js/LCD.js.map index 058d8c1..985bd1a 100644 --- a/js/LCD.js.map +++ b/js/LCD.js.map @@ -1 +1 @@ -{"version":3,"file":"LCD.js","sourceRoot":"","sources":["LCD.ts"],"names":["Direction","LCD","LCD.constructor","LCD.Init","LCD.GetCell","LCD.SetCellX","LCD.SetCellY","LCD.SetPixel","LCD.IncrementCursor","LCD.SetContrast","LCD.Disable","LCD.Enable","LCD.Read","LCD.Write","LCD.SetRow","LCD.SetColumn","LCD.SetMode"],"mappings":"AAAA,gCAAgC;AAEhC,IAAK,SAAmC;AAAxC,WAAK,SAAS;IAAGA,qCAAEA;IAAEA,2CAAKA;IAAEA,yCAAIA;IAAEA,yCAAIA;AAACA,CAACA,EAAnC,SAAS,KAAT,SAAS,QAA0B;AAExC,IAAM,GAAG;IAATC,SAAMA,GAAGA;IA4HTC,CAACA;IAnHUD,QAAIA,GAAXA;QACIE,GAAGA,CAACA,MAAMA,GAAqBA,QAAQA,CAACA,cAAcA,CAACA,KAAKA,CAACA,CAACA;QAC9DA,GAAGA,CAAAA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,EAAEA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;YACzBA,IAAIA,GAAGA,GAAwBA,GAAGA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA,CAACA,CAACA;YACnDA,GAAGA,CAAAA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,GAAGA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;gBAC9BA,IAAIA,IAAIA,GAAGA,GAAGA,CAACA,UAAUA,CAACA,CAACA,CAACA,CAACA;gBAC7BA,IAAIA,CAACA,KAAKA,CAACA,kBAAkBA,GAAGA,GAAGA,GAAEA,CAACA,GAAGA,CAACA,QAAQA,GAAGA,CAACA,CAACA,GAAEA,QAAQA,CAACA;gBAClEA,EAAEA,CAAAA,CAACA,CAACA,IAAIA,EAAEA,CAACA;oBAACA,IAAIA,CAACA,KAAKA,CAACA,WAAWA,GAAGA,iBAAiBA,CAACA;YAC3DA,CAACA;YAEDA,GAAGA,CAAC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GAAGA,CAACA,GAAGA,CAACA,EAAEA,CAACA,EAAEA,GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAACA,GAAGA,CAACA,CAACA,CAACA;YACjEA,CAACA;QACLA,CAACA;IACLA,CAACA;IAEaV,QAAIA,GAAlBA;QACIW,IAAIA,KAAKA,CAACA;QACVA,EAAEA,CAAAA,CAACA,GAAGA,CAACA,IAAIA,CAACA;YAACA,KAAKA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,CAACA,CAACA;QAC5DA,IAAIA,CAACA,CAACA;YACFA,KAAKA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;YACpBA,GAAGA,CAAAA,CAACA,GAAGA,CAACA,GAAGA,GAAGA,CAACA,EAAEA,GAAGA,GAAGA,CAACA,EAAEA,GAAGA,EAAEA;gBAC3BA,KAAKA,CAACA,GAAGA,CAACA,CAACA,GAACA,GAAGA,EAAEA,GAAGA,CAACA,IAAIA,CAACA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACvIA,CAACA;QACDA,GAAGA,CAACA,eAAeA,EAAEA,CAACA;QACtBA,MAAMA,CAACA,KAAKA,CAACA;IACjBA,CAACA;IAEaX,SAAKA,GAAnBA,UAAoBA,KAAWA;QAC3BY,EAAEA,CAAAA,CA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ACA,CAACA,CAACA,CAACA,GAACA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAACA,GAAGA,CAACA,GAACA,CAACA,CAACA,EAAEA,KAAKA,CAACA,IAAIA,CAACA,CAACA,GAACA,GAAGA,CAACA,CAACA,CAACA;YACrHA,CAACA;QACLA,CAACA;QACDA,GAAGA,CAACA,eAAeA,EAAEA,CAACA;IAC1BA,CAACA;IAEaZ,UAAMA,GAApBA,UAAqBA,GAAWA;QAC5Ba,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAAGA,GAAGA,GAAGA,EAAEA,CAACA;IAC7BA,CAACA;IAEab,aAASA,GAAvBA,UAAwBA,GAAWA;QAC/Bc,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAAGA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,IAAIA,GAAGA,EAAEA,GAAGA,EAAEA,CAACA,CAACA;IAC/CA,CAACA;IAEad,WAAOA,GAArBA;IAEAe,CAACA;IAzHcf,YAAQA,GAAWA,EAAEA,CAACA;IACtBA,QAAIA,GAAaA,EAAEA,CAACA;IACpBA,UAAMA,GAAaA,CAACA,CAACA,EAACA,CAACA,CAACA,CAACA,CAACA,eAAeA;IACzCA,QAAIA,GAAYA,IAAIA,CAACA,CAACA,6BAA6BA;IACnDA,OAAGA,GAAcA,YAAcA,CAACA;IAChCA,WAAOA,GAAYA,IAAIA,CAACA;IAqH3CA,UAACA;AAADA,CAACA,AA5HD,IA4HC"} \ No newline at end of file +{"version":3,"file":"LCD.js","sourceRoot":"","sources":["LCD.ts"],"names":["Direction","LCD","LCD.constructor","LCD.Init","LCD.GetCell","LCD.SetCellX","LCD.SetCellY","LCD.SetPixel","LCD.IncrementCursor","LCD.SetContrast","LCD.Disable","LCD.Enable","LCD.Read","LCD.Write","LCD.SetRow","LCD.SetColumn","LCD.SetMode","LCD.SetDirection"],"mappings":"AAAA,gCAAgC;AAEhC,IAAK,SAAmC;AAAxC,WAAK,SAAS;IAAGA,q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GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAACA,GAAGA,CAACA,CAACA,CAACA;YACjEA,CAACA;QACLA,CAACA;IACLA,CAACA;IAEaV,QAAIA,GAAlBA;QACIW,IAAIA,KAAKA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;QACxBA,EAAEA,CAAAA,CAACA,CAACA,GAAGA,CAACA,IAAIA,IAAIA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,IAAIA,IAAIA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA,CAACA;YACvEA,EAAEA,CAACA,CAACA,GAAGA,CAACA,IAAIA,CAACA;gBAACA,KAAKA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,CAACA,CAACA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,CAACA,CAACA;YAC7DA,IAAIA,CAACA,CAACA;gBACFA,KAAKA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;gBACpBA,GAAGA,CAACA,CAACA,GAAGA,CAACA,GAAGA,GAAGA,CAACA,EAAEA,GAAGA,GAAGA,CAACA,EAAEA,GAAGA,EAAEA;oBAC5BA,KAAKA,CAACA,GAAGA,CAACA,CAACA,GAAGA,GAAGA,EAAEA,GAAGA,CAACA,IAAIA,CAACA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,MAAMA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,GAAGA,GAAGA,CAACA,MAAMA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A,UAAMA,GAAaA,CAACA,CAACA,EAACA,CAACA,CAACA,CAACA,CAACA,eAAeA;IACzCA,QAAIA,GAAYA,IAAIA,CAACA,CAACA,6BAA6BA;IACnDA,OAAGA,GAAcA,YAAcA,CAACA;IAChCA,WAAOA,GAAYA,IAAIA,CAACA;IA4H3CA,UAACA;AAADA,CAACA,AAnID,IAmIC"} \ No newline at end of file diff --git a/js/LCD.ts b/js/LCD.ts index 66e879d..3e9f8df 100644 --- a/js/LCD.ts +++ b/js/LCD.ts @@ -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; } } \ No newline at end of file diff --git a/js/Memory.js b/js/Memory.js index 2e96e00..e845241 100644 --- a/js/Memory.js +++ b/js/Memory.js @@ -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; })(); diff --git a/js/Memory.js.map b/js/Memory.js.map index 4cddaf8..c96a843 100644 --- a/js/Memory.js.map +++ b/js/Memory.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/js/Memory.ts b/js/Memory.ts index 0100262..89d9ba0 100644 --- a/js/Memory.ts +++ b/js/Memory.ts @@ -1,7 +1,7 @@ /// 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) { + + } } \ No newline at end of file diff --git a/js/Registers.js b/js/Registers.js new file mode 100644 index 0000000..a84c003 --- /dev/null +++ b/js/Registers.js @@ -0,0 +1,43 @@ +/// +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 \ No newline at end of file diff --git a/js/Registers.js.map b/js/Registers.js.map new file mode 100644 index 0000000..f31a9f4 --- /dev/null +++ b/js/Registers.js.map @@ -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;I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A,CAACA,GAAGA,CAACA,IAAIA,EAAEA,KAAKA,CAACA,CAACA;IACtDA,CAACA;IAEaJ,iBAAOA,GAArBA,UAAsBA,IAAWA;QAC7BK,MAAMA,CAACA,SAASA,CAACA,aAAaA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA;IACnDA,CAACA;IAEaL,iCAAuBA,GAArCA;IAEAM,CAACA;IAjCaN,uBAAaA,GAAWA,EAAEA,CAACA;IAC3BA,yBAAeA,GAAWA,EAAEA,CAACA;IAC7BA,wBAAcA,GAASA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;IACnCA,sBAAYA,GAASA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;IA+BnDA,gBAACA;AAADA,CAACA,AAnCD,IAmCC"} \ No newline at end of file diff --git a/js/Registers.ts b/js/Registers.ts new file mode 100644 index 0000000..d6b07bc --- /dev/null +++ b/js/Registers.ts @@ -0,0 +1,40 @@ +/// + +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() { + + } +} \ No newline at end of file diff --git a/js/TI.js b/js/TI.js index 13f0e9d..f49b7de 100644 --- a/js/TI.js +++ b/js/TI.js @@ -1,16 +1,21 @@ /// /// +/// +/// +/// 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 \ No newline at end of file diff --git a/js/TI.js.map b/js/TI.js.map index 819d19c..a958156 100644 --- a/js/TI.js.map +++ b/js/TI.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/js/TI.ts b/js/TI.ts index 0f3e085..ccf3e52 100644 --- a/js/TI.ts +++ b/js/TI.ts @@ -1,15 +1,28 @@ /// /// +/// +/// +/// + +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()); } -} \ No newline at end of file +} + diff --git a/js/ops/0x0.js b/js/ops/0x0.js new file mode 100644 index 0000000..5f2969b --- /dev/null +++ b/js/ops/0x0.js @@ -0,0 +1,49 @@ +/// +/// +/// +/// +/// +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 \ No newline at end of file diff --git a/js/ops/0x0.js.map b/js/ops/0x0.js.map new file mode 100644 index 0000000..9601aa9 --- /dev/null +++ b/js/ops/0x0.js.map @@ -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;IAC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G,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IACnE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IAEpC,AADA,QAAQ;IACR,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,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,IAAY;IACpC,SAAS,CAAC,OAAO,CAAC,aAAW,EAAE,SAAS,CAAC,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"} \ No newline at end of file diff --git a/js/ops/0x0.ts b/js/ops/0x0.ts new file mode 100644 index 0000000..964cdfd --- /dev/null +++ b/js/ops/0x0.ts @@ -0,0 +1,58 @@ +/// +/// +/// +/// +/// + +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 [] +}; \ No newline at end of file