Skip to content

Gh pages #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: Project-1-Branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions distrib/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ var _KernelBuffers = null; // when clearly 'any' is not what we want. There is l
// Standard input and output
var _StdIn; // Same "to null or not to null" issue as above.
var _StdOut;
// var _MemoryArrayUser = new TSOS.memory();
var _MemoryArrayIndex = null;
var _MainMemoryElement = null;
var _MemoryArray = Array.apply(null, new Array(256).map)(String.prototype.valueOf(), "00");
// UI
var _Console;
var _OsShell;
Expand Down
140 changes: 139 additions & 1 deletion distrib/host/cpu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
///<reference path="../globals.ts" />
///<reference path="../globals.ts"/>
///<reference path="memory.ts"/>
/* ------------
CPU.ts

Expand Down Expand Up @@ -42,6 +43,143 @@ var TSOS;
_Kernel.krnTrace('CPU cycle');
// TODO: Accumulate CPU usage and profiling statistics here.
// Do the real work here. Be sure to set this.isExecuting appropriately.
this.OPCommands(_MemoryArray[this.PC]);
};
Cpu.prototype.updateConsole = function () {
_MainMemoryElement = _MainMemoryElement + "\n" + "\n";
_MainMemoryElement = _MainMemoryElement + "PC: " + this.PC + "\n";
_MainMemoryElement = _MainMemoryElement + "Acc: " + this.Acc + "\n";
_MainMemoryElement = _MainMemoryElement + "Xreg: " + this.Xreg + "\n";
_MainMemoryElement = _MainMemoryElement + "Yreg: " + this.Yreg + "\n";
_MainMemoryElement = _MainMemoryElement + "Zflag: " + this.Zflag + "\n";
};
Cpu.prototype.loadInits = function (PC, Acc, Xreg, Yreg, Zflag) {
this.PC = PC;
this.Acc = Acc;
this.Xreg = Yreg;
this.Zflag = Zflag;
};
Cpu.prototype.OPCommands = function (givenCommand) {
switch (givenCommand) {
case "A9": {
this.Acc = parseInt("0x" + (_MemoryArray[this.PC + 1]));
this.PC = this.PC + 2;
_MemoryArrayUser.memoryUpdater();
break;
}
case "AD": {
var PreOP = this.PC;
this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
this.Acc = parseInt("0x" + _MemoryArray[this.PC]);
this.PC = PreOP + 3;
_MemoryArrayUser.memoryUpdater();
break;
}
case "8D": {
var memoryPointer = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
if (this.Acc < 16) {
_MemoryArray[memoryPointer] = "0" + this.Acc;
}
else {
_MemoryArray[memoryPointer] = this.Acc;
}
this.PC = this.PC + 3;
_MemoryArrayUser.memoryUpdater();
break;
}
case "6D": {
var PreOP = this.PC;
this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
this.Acc = this.Acc + parseInt("0x" + _MemoryArray[this.PC]);
this.PC = PreOP + 3;
_MemoryArrayUser.memoryUpdater();
break;
}
case "A2": {
this.Xreg = parseInt("0x" + (_MemoryArray[this.PC + 1]));
this.PC = this.PC + 2;
_MemoryArrayUser.memoryUpdater();
break;
}
case "AE": {
var PreOP = this.PC;
this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
this.Xreg = parseInt("0x" + _MemoryArray[this.PC]);
_MemoryArrayUser.memoryUpdater();
break;
}
case "A0": {
this.Yreg = parseInt("0x" + (_MemoryArray[this.PC + 1]));
this.PC = this.PC + 2;
_MemoryArrayUser.memoryUpdater();
break;
}
case "AC": {
var PreOP = this.PC;
this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
this.Yreg = parseInt("0x" + _MemoryArray[this.PC]);
this.PC = PreOP + 3;
_MemoryArrayUser.memoryUpdater();
break;
}
case "EA": {
this.PC = this.PC + 1;
break;
}
case "00": {
this.isExecuting = false;
_MemoryArrayUser.memoryUpdater();
break;
}
case "EC": {
var PreOP = this.PC;
this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
var CompareVar = parseInt("0x" + _MemoryArray[this.PC]);
if (CompareVar = this.Xreg) {
this.Zflag = 1;
}
this.PC = PreOP + 3;
_MemoryArrayUser.memoryUpdater();
break;
}
case "D0": {
if (this.Zflag == 0) {
this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
}
else {
this.PC = this.PC + 1;
}
_MemoryArrayUser.memoryUpdater();
break;
}
case "EE": {
var PreOP = this.PC;
this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]);
var adder = parseInt("0x" + _MemoryArray[this.PC]);
adder = adder + 0x0001;
_MemoryArray[this.PC] = adder.toString().replace("0x", "");
_MemoryArrayUser.memoryUpdater();
break;
}
case "FF": {
if (this.Xreg == 0x01) {
_DrawingContext.putText(this.Yreg);
_DrawingContext.advanceLine();
}
if (this.Xreg == 0x02) {
_DrawingContext.putText(this.Yreg.toString());
_DrawingContext.advanceLine();
}
_MemoryArrayUser.memoryUpdater();
break;
}
default: {
_StdOut.putText("This does not work " + _MemoryArray[this.PC]);
this.isExecuting = false;
_MemoryArrayUser.memoryUpdater();
break;
}
}
};
return Cpu;
})();
Expand Down
28 changes: 28 additions & 0 deletions distrib/host/memory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Created by thorwald on 10/17/15.
*/
///<reference path="../globals.ts"/>
var TSOS;
(function (TSOS) {
var memory = (function () {
function memory() {
}
memory.prototype.memory = function () {
var plusone = 0;
};
memory.prototype.load = function (memoryItem) {
_MemoryArray[_MemoryArrayIndex] = memoryItem;
_MemoryArrayIndex++;
this.memoryUpdater();
};
memory.prototype.memoryUpdater = function () {
var i = 0;
_MainMemoryElement = "";
for (i = 0; i < _MemoryArray.length; i++) {
_MainMemoryElement = _MainMemoryElement + _MemoryArray[i] + " ";
}
};
return memory;
})();
TSOS.memory = memory;
})(TSOS || (TSOS = {}));
13 changes: 13 additions & 0 deletions distrib/os/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ var TSOS;
tabIncrease = tabIncrease + 4;
alert(chr);
}
else if (chr === String.fromCharCode(8)) {
var characterRemoval = this.buffer.charAt(this.buffer.length - 1);
this.buffer = this.buffer.charAt(this.buffer.length - 1);
this.Backspace(characterRemoval);
}
else {
// This is a "normal" character, so ...
// ... draw it on the screen...
Expand Down Expand Up @@ -96,6 +101,14 @@ var TSOS;
_FontHeightMargin;
}
};
Console.prototype.Backspace = function (char) {
var characterLength = _DrawingContext.measureText(this.currentFont, this.currentFontSize, char);
var verticalHeight = _DefaultFontSize + _FontHeightMargin;
_DrawingContext.clearRect(this.currentXPosition - characterLength, ((this.currentYPosition - verticalHeight) + 5), characterLength, verticalHeight);
if (this.currentXPosition > 0) {
this.currentXPosition = this.currentXPosition - characterLength;
}
};
return Console;
})();
TSOS.Console = Console;
Expand Down
4 changes: 4 additions & 0 deletions distrib/os/deviceDriverKeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ var TSOS;
_Kernel.krnTrace("Key code:" + keyCode + " shifted:" + isShifted);
var chr = "";
// Check to see if we even want to deal with the key that was pressed.
if (keyCode == 8) {
chr = String.fromCharCode(keyCode);
_KernelInputQueue.enqueue(chr);
}
if (((keyCode >= 65) && (keyCode <= 90)) ||
((keyCode >= 97) && (keyCode <= 123))) {
// Determine the character we want to display.
Expand Down
27 changes: 27 additions & 0 deletions distrib/os/memory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Created by thorwald on 10/17/15.
*/
var TSOS;
(function (TSOS) {
var memory = (function () {
function memory() {
}
memory.prototype.memory = function () {
var plusone = 0;
};
memory.prototype.load = function (memoryItem) {
_MemoryArray[_MemoryArrayIndex] = memoryItem;
_MemoryArrayIndex++;
this.memoryUpdater();
};
memory.prototype.memoryUpdater = function () {
var i = 0;
_MainMemoryElement = "";
for (i = 0; i < _MemoryArray.length; i++) {
_MainMemoryElement = _MainMemoryElement + _MemoryArray[i] + " ";
}
};
return memory;
})();
TSOS.memory = memory;
})(TSOS || (TSOS = {}));
34 changes: 33 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,34 @@
}
}
</script>
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<!--Uncomment this line below to enable GLaDOS testing
<comment> <script type="text/javascript" src="http://www.labouseur.com/courses/os/projects/glados.js"></script>
</head> </comment>
-->
=======
<!-- Uncomment this line below to enable GLaDOS testing -->
<comment> <script type="text/javascript" src="http://www.labouseur.com/courses/os/projects/glados.js"></script>
</head> </comment>
>>>>>>> parent of 982fe96... load
=======
<!-- Uncomment this line below to enable GLaDOS testing -->
<comment> <script type="text/javascript" src="http://www.labouseur.com/courses/os/projects/glados.js"></script>
</head> </comment>
>>>>>>> parent of 982fe96... load
=======
<!-- Uncomment this line below to enable GLaDOS testing -->
<comment> <script type="text/javascript" src="http://www.labouseur.com/courses/os/projects/glados.js"></script>
</head> </comment>
>>>>>>> parent of 982fe96... load
=======
<!-- Uncomment this line below to enable GLaDOS testing -->
<comment> <script type="text/javascript" src="http://www.labouseur.com/courses/os/projects/glados.js"></script>
</head> </comment>
>>>>>>> parent of 982fe96... load

<body onload="onDocumentLoad()">

Expand Down Expand Up @@ -90,7 +115,6 @@
fillstyle="Blue">
</canvas>
</div>

<div id="divLog" style="margin-left:520px;">
<label>
Host Log
Expand All @@ -102,6 +126,14 @@
></textarea>
</label>
</div>
<label>
Memory
<br>
<textarea name = "memoryTextarea"
id = "memoryTextarea"
rows = "25"
cols = "25"></textarea>
</label>

<div id="divUserProgramInput" style="margin-left:520px;">
<label>
Expand Down
8 changes: 6 additions & 2 deletions source/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// Global CONSTANTS (TypeScript 1.5 introduced const. Very cool.)
//
const APP_NAME: string = "Daniel Craig is Smexy"; // 'cause Bob and I were at a loss for a better name.
const APP_VERSION: string = "|0.07|"; // What did you expect?
const APP_VERSION: string = "|2|"; // What did you expect?

const CPU_CLOCK_INTERVAL: number = 100; // This is in ms (milliseconds) so 1000 = 1 second.

Expand All @@ -29,6 +29,7 @@ var globalCanvasChangeBoolean = false;
// Global Variables
// TODO: Make a global object and use that instead of the "_" naming convention in the global namespace.
//

var _CPU: TSOS.Cpu; // Utilize TypeScript's type annotation system to ensure that _CPU is an instance of the Cpu class.

var _OSclock: number = 0; // Page 23.
Expand All @@ -52,7 +53,10 @@ var _KernelBuffers: any[] = null; // when clearly 'any' is not what we want. T
// Standard input and output
var _StdIn; // Same "to null or not to null" issue as above.
var _StdOut;

var _MemoryArrayUser = new TSOS.memory();
var _MemoryArrayIndex = null;
var _MainMemoryElement = null;
var _MemoryArray = Array.apply(null, new Array(256).map)(String.prototype.valueOf(),"00");
// UI
var _Console: TSOS.Console;
var _OsShell: TSOS.Shell;
Expand Down
Loading