Skip to content
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
8 changes: 6 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ The `package.json` can install an HTTP server, just do:

npm install

Download [`theloop.2.rom`](https://github.com/kervinck/gigatron-rom/raw/master/theloop.2.rom) into the `src` directory.
Pick and download a [`*.rom`](https://github.com/kervinck/gigatron-rom/) file into the `src/` directory and rename it as `gigatron.rom`

Direct links:
[`ROM v1`](https://github.com/kervinck/gigatron-rom/raw/master/ROMv1.rom)
[`ROM v2`](https://github.com/kervinck/gigatron-rom/raw/master/ROMv2.rom)

Start the HTTP server

Expand All @@ -19,4 +23,4 @@ Use the cursor keys for the D-pad.

## GT1 Files

GT1 files can be loaded by starting the `Loader` and dropping a `.gt1` file onto the VGA display from File Explorer or Finder.
GT1 files can be loaded by dropping a `.gt1` file onto the VGA display from File Explorer or Finder.
32 changes: 31 additions & 1 deletion src/gamepad.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ export class Gamepad {
this.keyMap[key] = buttonMap[button];
}
}

/* build map of ASCII codes that the Gigatron understands as well */
this.asciiMap = {
'Tab': 9,
'Enter': 10,
'Escape': 27,
'Esc': 27,
'Delete': 127,
'Backspace': 127,
};
for (let ascii=32; ascii<127; ascii++) {
this.asciiMap[String.fromCharCode(ascii)] = ascii;
}
for (let fnKey=1; fnKey<=12; fnKey++) {
this.asciiMap['F' + fnKey] = 0xc0 + fnKey;
}
}

/** start handling key events */
Expand All @@ -70,14 +86,28 @@ export class Gamepad {
if (bit) {
this.pressed |= bit;
event.preventDefault();
} else {
let ascii = this.asciiMap[event.key];
if (ascii) {
if (event.ctrlKey) {
// Control codes (e.g. Ctrl-C for ETX or BREAK)
if (ascii == 63 /*'?'*/) ascii = 127;
else if (ascii == 32 /*' '*/) ascii = 0;
else ascii &= 31;
}
this.pressed = ascii ^ 0xff; /// will be inverted again in tick()
event.preventDefault();
}
}
})
.on('keyup', (event) => {
let bit = this.keyMap[event.key];
if (bit) {
this.pressed &= ~bit;
event.preventDefault();
} else {
this.pressed = 0;
}
event.preventDefault();
});
this.enabled = true;
}
Expand Down
Loading