project12 - complete

This commit is contained in:
2025-12-07 23:31:41 -05:00
parent 6bafaa8443
commit 4e8169508a
8 changed files with 551 additions and 4 deletions

View File

@@ -10,18 +10,49 @@ class Sys {
/** Performs all the initializations required by the OS. */
function void init() {
do Memory.init();
do Math.init();
do Screen.init();
do Output.init();
do Keyboard.init();
do Main.main();
do Sys.halt();
return;
}
/** Halts the program execution. */
function void halt() {
while (true) {}
return;
}
/** Waits approximately duration milliseconds and returns. */
function void wait(int duration) {
var int i, j;
let i = 0;
while (i < duration) {
let j = 0;
// Calibration: loop count determines delay.
// On typical VM emulator settings (Fast), ~50-100 loops might be 1ms?
// User requested 2 seconds wait in test.
// "WaitWithInput" sample in Snake used loop for waiting.
// Standard N2T value is roughly 50-100.
while (j < 50) {
let j = j + 1;
}
let i = i + 1;
}
return;
}
/** Displays the given error code in the form "ERR<errorCode>",
* and halts the program's execution. */
function void error(int errorCode) {
do Output.printString("ERR");
do Output.printInt(errorCode);
do Sys.halt();
return;
}
}