mirror of
https://github.com/soconnor0919/eceg431.git
synced 2025-12-11 22:54:43 -05:00
Remove trailing whitespace and clean up comments
This commit is contained in:
@@ -5,18 +5,18 @@
|
||||
/**
|
||||
* A library of functions for writing text on the screen.
|
||||
* The Hack physical screen consists of 512 rows of 256 pixels each.
|
||||
* The library uses a fixed font, in which each character is displayed
|
||||
* within a frame which is 11 pixels high (including 1 pixel for inter-line
|
||||
* The library uses a fixed font, in which each character is displayed
|
||||
* within a frame which is 11 pixels high (including 1 pixel for inter-line
|
||||
* spacing) and 8 pixels wide (including 2 pixels for inter-character spacing).
|
||||
* The resulting grid accommodates 23 rows (indexed 0..22, top to bottom)
|
||||
* of 64 characters each (indexed 0..63, left to right). The top left
|
||||
* of 64 characters each (indexed 0..63, left to right). The top left
|
||||
* character position on the screen is indexed (0,0). A cursor, implemented
|
||||
* as a small filled square, indicates where the next character will be displayed.
|
||||
*/
|
||||
class Output {
|
||||
|
||||
// Character map for displaying characters
|
||||
static Array charMaps;
|
||||
static Array charMaps;
|
||||
static int cursorRow, cursorCol;
|
||||
|
||||
/** Initializes the screen, and locates the cursor at the screen's top-left. */
|
||||
@@ -29,9 +29,9 @@ class Output {
|
||||
// Initializes the character map array
|
||||
function void initMap() {
|
||||
var int i;
|
||||
|
||||
|
||||
let charMaps = Array.new(127);
|
||||
|
||||
|
||||
// Black square, used for displaying non-printable characters.
|
||||
do Output.create(0,63,63,63,63,63,63,63,63,63,0,0);
|
||||
|
||||
@@ -52,9 +52,9 @@ class Output {
|
||||
do Output.create(43,0,0,0,12,12,63,12,12,0,0,0); // +
|
||||
do Output.create(44,0,0,0,0,0,0,0,12,12,6,0); // ,
|
||||
do Output.create(45,0,0,0,0,0,63,0,0,0,0,0); // -
|
||||
do Output.create(46,0,0,0,0,0,0,0,12,12,0,0); // .
|
||||
do Output.create(46,0,0,0,0,0,0,0,12,12,0,0); // .
|
||||
do Output.create(47,0,0,32,48,24,12,6,3,1,0,0); // /
|
||||
|
||||
|
||||
do Output.create(48,12,30,51,51,51,51,51,30,12,0,0); // 0
|
||||
do Output.create(49,12,14,15,12,12,12,12,12,63,0,0); // 1
|
||||
do Output.create(50,30,51,48,24,12,6,3,51,63,0,0); // 2
|
||||
@@ -65,7 +65,7 @@ class Output {
|
||||
do Output.create(55,63,49,48,48,24,12,12,12,12,0,0); // 7
|
||||
do Output.create(56,30,51,51,51,30,51,51,51,30,0,0); // 8
|
||||
do Output.create(57,30,51,51,51,62,48,48,24,14,0,0); // 9
|
||||
|
||||
|
||||
do Output.create(58,0,0,12,12,0,0,12,12,0,0,0); // :
|
||||
do Output.create(59,0,0,12,12,0,0,12,12,6,0,0); // ;
|
||||
do Output.create(60,0,0,24,12,6,3,6,12,24,0,0); // <
|
||||
@@ -132,7 +132,7 @@ class Output {
|
||||
do Output.create(120,0,0,0,51,30,12,12,30,51,0,0); // x
|
||||
do Output.create(121,0,0,0,51,51,51,62,48,24,15,0); // y
|
||||
do Output.create(122,0,0,0,63,27,12,6,51,63,0,0); // z
|
||||
|
||||
|
||||
do Output.create(123,56,12,12,12,7,12,12,12,56,0,0); // {
|
||||
do Output.create(124,12,12,12,12,12,12,12,12,12,0,0); // |
|
||||
do Output.create(125,7,12,12,12,56,12,12,12,7,0,0); // }
|
||||
@@ -163,7 +163,7 @@ class Output {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Returns the character map (array of size 11) of the given character.
|
||||
// If the given character is invalid or non-printable, returns the
|
||||
// character map of a black square.
|
||||
@@ -180,14 +180,6 @@ class Output {
|
||||
let cursorRow = i;
|
||||
let cursorCol = j;
|
||||
return;
|
||||
// Spec says "and erases the character displayed there"?
|
||||
// Usually moveCursor just moves it. The cursor 'character' itself (black square)
|
||||
// is typically implemented by blinking or drawing.
|
||||
// Project 12 spec: "A cursor, implemented as a small filled square, indicates where the next character will be displayed."
|
||||
// And "erases the character displayed there"? Maybe erases the *cursor* from old location?
|
||||
// Or erases the *content*? "Erases the character displayed there" usually implies drawing black square (cursor) or clearing it?
|
||||
// Wait, standard implementation usually just updates coordinates.
|
||||
// I will assume simple update.
|
||||
}
|
||||
|
||||
/** Displays the given character at the cursor location,
|
||||
@@ -195,18 +187,18 @@ class Output {
|
||||
function void printChar(char c) {
|
||||
var Array map;
|
||||
var int i, val, address;
|
||||
|
||||
|
||||
let map = Output.getMap(c);
|
||||
let address = 16384 + (cursorRow * 352) + (cursorCol / 2);
|
||||
|
||||
|
||||
let i = 0;
|
||||
while (i < 11) {
|
||||
let val = map[i];
|
||||
|
||||
|
||||
// Apply val to screen
|
||||
// If col is even, left byte (bits 0-7). If odd, right byte (8-15).
|
||||
// LSB is left.
|
||||
|
||||
|
||||
if ((cursorCol & 1) = 0) { // Even col
|
||||
// Mask out low byte (0x00FF), keep high byte
|
||||
// Keep high byte: value & -256 (0xFF00)
|
||||
@@ -218,12 +210,12 @@ class Output {
|
||||
// Set high byte: val << 8
|
||||
let val = (Memory.peek(address + (i * 32)) & 255) | (val * 256);
|
||||
}
|
||||
|
||||
|
||||
do Memory.poke(address + (i * 32), val);
|
||||
|
||||
|
||||
let i = i + 1;
|
||||
}
|
||||
|
||||
|
||||
// Advance cursor
|
||||
let cursorCol = cursorCol + 1;
|
||||
if (cursorCol > 63) {
|
||||
@@ -233,7 +225,7 @@ class Output {
|
||||
let cursorRow = 0; // Wrap to top?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user