From 1f32eee70c8099d71e7f51f00be868e18e6240ea Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 23 Aug 2018 20:53:37 -0400 Subject: [PATCH] fixed apple keys, kbd, unreadable memory --- presets/apple2/keyboardtest.c | 16 ++++++++++++++++ src/platform/apple2.ts | 11 +++++++++-- src/ui.ts | 2 +- src/views.ts | 3 ++- test/cli/testplatforms.js | 4 ++++ 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 presets/apple2/keyboardtest.c diff --git a/presets/apple2/keyboardtest.c b/presets/apple2/keyboardtest.c new file mode 100644 index 00000000..59892fbf --- /dev/null +++ b/presets/apple2/keyboardtest.c @@ -0,0 +1,16 @@ + +#include +#include +#include +#include + +int main (void) +{ + printf("\nKeyboard Test\n"); + while (1) { + char ch = cgetc(); + printf("%3d ($%2x) = %c\n", ch, ch, ch); + } + return EXIT_SUCCESS; +} + diff --git a/src/platform/apple2.ts b/src/platform/apple2.ts index 45fa707e..1027cac4 100644 --- a/src/platform/apple2.ts +++ b/src/platform/apple2.ts @@ -9,6 +9,7 @@ declare var jt; // 6502 const APPLE2_PRESETS = [ {id:'sieve.c', name:'Sieve'}, + {id:'keyboardtest.c', name:'Keyboard Test'}, {id:'mandel.c', name:'Mandelbrot'}, {id:'tgidemo.c', name:'TGI Graphics Demo'}, {id:'siegegame.c', name:'Siege Game'}, @@ -170,11 +171,17 @@ const _Apple2Platform = function(mainElement) { kbdlatch = (code | 0x80) & 0xff; } else if (key) { switch (key) { + case 16: return; // shift + case 17: return; // ctrl + case 18: return; // alt case 37: key=8; break; // left case 39: key=21; break; // right case 38: key=11; break; // up case 40: key=10; break; // down } + if (key >= 65 && key < 65+26) { + if (flags & 5) key -= 64; // ctrl + } kbdlatch = (key | 0x80) & 0xff; } } @@ -242,8 +249,8 @@ const _Apple2Platform = function(mainElement) { } } } - readAddress(addr) { - return bus.read(addr); + readAddress(addr : number) { + return ((addr & 0xf000) != 0xc000) ? bus.read(addr) : null; // ignore I/O space } loadState(state) { diff --git a/src/ui.ts b/src/ui.ts index da260b02..d1e73acf 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -170,7 +170,7 @@ function refreshWindowList() { return new Views.DisassemblerView(); }); } - if (platform.readAddress && platform_id != 'vcs') { + if (platform.readAddress) { addWindowItem("#memory", "Memory Browser", function() { return new Views.MemoryView(); }); diff --git a/src/views.ts b/src/views.ts index 3b759738..5c53d8f1 100644 --- a/src/views.ts +++ b/src/views.ts @@ -528,6 +528,7 @@ export class ListingView extends DisassemblerView implements ProjectView { /// // TODO: make it use debug state +// TODO: make it safe (load/restore state?) export class MemoryView implements ProjectView { memorylist; dumplines; @@ -613,7 +614,7 @@ export class MemoryView implements ProjectView { for (var i=n1; i=0?hex(read,2):'??'); + s += ' ' + (read!==null?hex(read,2):'??'); } for (var i=n2; i<16; i++) s += ' '; if (sym) s += ' ' + sym; diff --git a/test/cli/testplatforms.js b/test/cli/testplatforms.js index 1af02ab0..9862d3ca 100644 --- a/test/cli/testplatforms.js +++ b/test/cli/testplatforms.js @@ -97,6 +97,10 @@ function testPlatform(platid, romname, maxframes, callback) { for (var i=0; i