woah a code name

creativity at its finest
This commit is contained in:
Alec Obradovich 2015-01-23 00:05:27 -06:00
parent 5a9b22aedc
commit a98b4bb92b
10 changed files with 195 additions and 34 deletions

BIN
basilio.webm Normal file

Binary file not shown.

View file

@ -1,31 +1,71 @@
var Byte = (function () { var Byte = (function () {
function Byte(init) { function Byte(init) {
if (typeof init === "undefined") { init = 0; } if (init === void 0) { init = 0; }
this.value = init & 0xFF; this.value = init & 0xFF | (init < 0 ? 0x80 : 0);
} }
Byte.prototype.Add = function (val) { Byte.prototype.Add = function (val) {
var ret = new Byte(((this.value + val.Get()) & ~0xFF) >> 8); val = typeof val == "number" ? new Byte(val) : val;
this.value = (this.value + val.Get()) & 0xFF; var hold = this.value + val.Get();
alert(this.value + val.Get()); this.value = hold & 0xFF;
return ret; return new Byte(hold > 255 ? hold - 255 : 0);
}; };
Byte.prototype.Sub = function (val) { Byte.prototype.Sub = function (val) {
return this.Add(new Byte(-val.Get())); val = typeof val == "number" ? new Byte(val) : val;
return this.Add(val.Neg());
}; };
Byte.prototype.Get = function () { Byte.prototype.Get = function () {
return this.value; return this.value;
}; };
Byte.prototype.Set = function (val) { Byte.prototype.Set = function (val) {
this.value = val & 0xFF; this.value = typeof val == "number" ? val & 0xFF : val.Get();
};
Byte.prototype.Neg = function (bind) {
if (bind === void 0) { 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.ShiftLeft = function (carry, value) {
if (carry === void 0) { carry = false; }
if (value === void 0) { 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 (carry === void 0) { carry = false; }
if (value === void 0) { value = false; }
var ret = (this.value & 0x80) != 0;
this.Set(this.value >>> 1);
this.Bit(7, carry ? ret : value);
return ret;
}; };
return Byte; return Byte;
})(); })();
var Word = (function () { var Word = (function () {
function Word() { function Word(init) {
if (init === void 0) { init = 0; }
this.value = [new Byte((init & ~0xFF) >> 8), new Byte(init & 0xFF)];
} }
return Word; return Word;
})(); })();

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","Word","Word.constructor"],"mappings":"AAAA;IAGIA,cAAmBA,IAAgBA;QAAhBC,mCAAAA,IAAIA,GAAWA,CAACA;AAAAA,QAC/BA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,GAAGA,IAAIA;IAC5BA,CAACA;IAEDD,qBAAAA,UAAWA,GAASA;QAChBE,IAAIA,GAAGA,GAAGA,IAAIA,IAAIA,CAACA,CAACA,CAACA,IAAIA,CAACA,KAAKA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA,GAAGA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA;QAC3DA,IAAIA,CAACA,KAAKA,GAAGA,CAACA,IAAIA,CAACA,KAAKA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA,GAAGA,IAAIA;QAC5CA,KAAKA,CAACA,IAAIA,CAACA,KAAKA,GAAGA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA;QAC7BA,OAAOA,GAAGA;IACdA,CAACA;;IAEDF,qBAAAA,UAAWA,GAASA;QAChBG,OAAOA,IAAIA,CAACA,GAAGA,CAACA,IAAIA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA;IACzCA,CAACA;;IAEDH,qBAAAA;QACII,OAAOA,IAAIA,CAACA,KAAKA;IACrBA,CAACA;;IAEDJ,qBAAAA,UAAWA,GAAWA;QAClBK,IAAIA,CAACA,KAAKA,GAAGA,GAAGA,GAAGA,IAAIA;IAC3BA,CAACA;IACLL,YAACA;AAADA,CAACA,IAAA;;AAED;IAAAM;IAIAC,CAACA;AAAAD,IAADA,YAACA;AAADA,CAACA,IAAA"} {"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.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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CAACA;IACfA,CAACA;IAEMZ,yBAAUA,GAAjBA,UAAkBA,KAAsBA,EAAEA,KAAsBA;QAA9Ca,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;IACLb,WAACA;AAADA,CAACA,AAlFD,IAkFC;AAED,IAAM,IAAI;IAINc,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"}

View file

@ -2,26 +2,83 @@ class Byte {
private value: number; private value: number;
public constructor(init: number = 0) { public constructor(init: number = 0) {
this.value = init & 0xFF; this.value = init & 0xFF | (init < 0 ? 0x80 : 0);
} }
public Add(val: Byte): Byte { public Add(val: Byte): Byte;
var ret = new Byte(((this.value + val.Get()) & ~0xFF) >> 8); public Add(val: number): Byte;
this.value = (this.value + val.Get()) & 0xFF; public Add(val: any): Byte {
alert(this.value + val.Get()); val = typeof val == "number" ? new Byte(val) : val;
return ret; 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: Byte): Byte;
return this.Add(new Byte(-val.Get())); 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 { public Get(): number {
return this.value; return this.value;
} }
public Set(val: number) { public Set(val: Byte);
this.value = val & 0xFF; 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 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;
} }
} }
@ -29,4 +86,7 @@ class Word {
private value: Byte[]; private value: Byte[];
public constructor(init: number = 0) {
this.value = [new Byte((init & ~0xFF) >> 8), new Byte(init & 0xFF)];
}
} }

26
js/Memory.js Normal file
View file

@ -0,0 +1,26 @@
/// <reference path="Byte.ts" />
var Bank = (function () {
function Bank(fill) {
if (fill === void 0) { fill = 0; }
}
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.romLock = true;
return Memory;
})();
//# sourceMappingURL=Memory.js.map

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

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

33
js/Memory.ts Normal file
View file

@ -0,0 +1,33 @@
/// <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() {
}
}

View file

@ -3,9 +3,11 @@ var TI = (function () {
function TI() { function TI() {
} }
TI.Init = function () { TI.Init = function () {
var a = new Byte(40); var a = new Byte(10);
var b = new Byte(40); var b = new Byte(40);
alert(a.Get()); //a.Add(b);
//a.Sub(b);
alert(a.Neg().Get());
}; };
return TI; return TI;
})(); })();

View file

@ -1 +1 @@
{"version":3,"file":"TI.js","sourceRoot":"","sources":["TI.ts"],"names":["TI","TI.constructor","TI.Init"],"mappings":"AAAA,gCAAgC;AAEhC;IAAAA;IAYAC,CAACA;AAAAD,IALGA,UAAAA;QACIE,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA;QACpBA,IAAIA,CAACA,GAAGA,IAAIA,IAAIA,CAACA,EAAEA,CAACA;QACpBA,KAAKA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA;IAClBA,CAACA;IACLF,UAACA;AAADA,CAACA,IAAA"} {"version":3,"file":"TI.js","sourceRoot":"","sources":["TI.ts"],"names":["TI","TI.constructor","TI.Init"],"mappings":"AAAA,gCAAgC;AAEhC,IAAM,EAAE;IAARA,SAAMA,EAAEA;IAWRC,CAACA;IAPUD,OAAIA,GAAXA;QACIE,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"}

View file

@ -1,15 +1,14 @@
/// <reference path="Byte.ts" /> /// <reference path="Byte.ts" />
class TI { class TI {
static rom: Byte[][];
static ram: Byte[][];
static mmap: any[];
static registers: any[]; static registers: any[];
static Init() { static Init() {
var a = new Byte(40); var a = new Byte(10);
var b = new Byte(40); var b = new Byte(40);
alert(a.Get()); //a.Add(b);
//a.Sub(b);
alert(a.Neg().Get());
} }
} }