From 7d314d09f9bc2718d9f4e83125e1ea92f3be560f Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 20:46:06 +1300 Subject: [PATCH 1/8] Sort disks in category order --- bin/index | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/index b/bin/index index caf472fe..44324f88 100755 --- a/bin/index +++ b/bin/index @@ -26,6 +26,25 @@ for (const fileName of dir.sort()) { } } +index.sort((x,y) => { + const xc = x.category.toLowerCase(); + const yc = y.category.toLowerCase(); + const xn = x.name.toLowerCase(); + const yn = y.name.toLowerCase(); + + if (xc < yc) { + return -1; + } else if (xc > yc) { + return 1; + } else if (xn < yn) { + return -1; + } else if (xn > yn) { + return 1; + } else { + return 0; + } +}); + fs.writeFileSync( path.resolve(diskPath, 'index.js'), `disk_index = ${JSON.stringify(index, null, 2)};` From dd465eb416c3374b17dd472e6183c46893df1e79 Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 21:40:17 +1300 Subject: [PATCH 2/8] Fix saving disk --- js/cards/disk2.js | 4 ++-- js/formats/format_utils.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/cards/disk2.js b/js/cards/disk2.js index 6cc5fefa..c6f28e65 100644 --- a/js/cards/disk2.js +++ b/js/cards/disk2.js @@ -659,7 +659,7 @@ export default function DiskII(io, callbacks, sectors = 16) data[idx++] = cur.tracks[t]; } else { for (var s = 0; s < 0x10; s++) { - var sector = readSector(cur, t); + var sector = readSector(cur, t, s); for (var b = 0; b < 256; b++) { data[idx++] = sector[b]; } @@ -679,7 +679,7 @@ export default function DiskII(io, callbacks, sectors = 16) data += base64_encode(cur.tracks[t]); } else { for (var s = 0; s < 0x10; s++) { - data += base64_encode(readSector(cur, t)); + data += base64_encode(readSector(cur, t, s)); } } } diff --git a/js/formats/format_utils.js b/js/formats/format_utils.js index aea44961..9a745f95 100644 --- a/js/formats/format_utils.js +++ b/js/formats/format_utils.js @@ -390,7 +390,7 @@ export function jsonEncode(cur, pretty) { data[t] = base64_encode(cur.tracks[t]); } else { for (var s = 0; s < 0x10; s++) { - data[t][s] = base64_encode(readSector(cur, t)); + data[t][s] = base64_encode(readSector(cur, t, s)); } } } From 90d9b493c1e766b5ae556282983fb1202fe8e5d8 Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 21:41:12 +1300 Subject: [PATCH 3/8] Fix keyboard not working after modal --- js/ui/apple2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/ui/apple2.js b/js/ui/apple2.js index 3309e817..7ee69e52 100644 --- a/js/ui/apple2.js +++ b/js/ui/apple2.js @@ -224,6 +224,7 @@ function doLoadLocalDisk(drive, file) { if (_disk2.setBinary(drive, name, ext, this.result)) { driveLights.label(drive, name); MicroModal.close('loading-modal'); + focused = false; initGamepad(); } }; @@ -715,6 +716,7 @@ export function initUI(apple2, disk2, e) { document.querySelectorAll('input,textarea').forEach(function(input) { input.addEventListener('input', function() { focused = true; }); + input.addEventListener('focus', function() { focused = true; }); input.addEventListener('blur', function() { focused = false; }); }); From b3bffea863e178ca61f86181f4007b75d5616634 Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 21:44:22 +1300 Subject: [PATCH 4/8] Make caps lock key on keyboard work, while keeping caps lock on virtual keyboard working too --- js/ui/apple2.js | 2 ++ js/ui/keyboard.js | 31 ++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/js/ui/apple2.js b/js/ui/apple2.js index 7ee69e52..36935809 100644 --- a/js/ui/apple2.js +++ b/js/ui/apple2.js @@ -550,6 +550,8 @@ function _keydown(evt) { _apple2.restoreState(); } else if (evt.keyCode == 16) { // Shift keyboard.shiftKey(true); + } else if (evt.keyCode == 20) { // Caps lock + keyboard.capslockKey(); } else if (evt.keyCode == 17) { // Control keyboard.controlKey(true); } else if (evt.keyCode == 91 || evt.keyCode == 93) { // Command diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 43995b55..8e734d20 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -199,6 +199,9 @@ export default function KeyBoard(cpu, io, e) { var shifted = false; var controlled = false; var capslocked = true; + // Initially caps lock on physical keyboard is assumed to be off, + // but on emulated keyboard it is on. + var capslockKeyUsed = false; var optioned = false; var commanded = false; @@ -212,8 +215,14 @@ export default function KeyBoard(cpu, io, e) { key = uiKitMap[evt.key]; } else if (code in keymap) { key = keymap[code][evt.shiftKey ? 2 : (evt.ctrlKey ? 1 : 0)]; - if (capslocked && key >= 0x61 && key <= 0x7A) + + if (code != 20 && capslockKeyUsed) { + this.capslockKey(evt.getModifierState("CapsLock")); + } + + if (capslocked && key >= 0x61 && key <= 0x7A) { key -= 0x20; + } } else { debug('Unhandled key = ' + toHex(code)); } @@ -274,13 +283,25 @@ export default function KeyBoard(cpu, io, e) { capslockKey: function keyboard_caplockKey(down) { var capsLock = kb.querySelector('.key-LOCK'); - capslocked = down; - if (down) { + + if (arguments.length == 0) { + if (capslockKeyUsed) { + capslocked = !capslocked; + } else { + capslockKeyUsed = true; + } + } else if (down === undefined) { + capslocked = !capslocked; + capslockKeyUsed = false; + } else { + capslocked = down; + } + + if (capslocked) { capsLock.classList.add('active'); } else { capsLock.classList.remove('active'); } - }, reset: function keyboard_reset(event) { @@ -354,7 +375,7 @@ export default function KeyBoard(cpu, io, e) { break; case 'CAPS': case 'LOCK': - self.capslockKey(!capslocked); + self.capslockKey(undefined); break; case 'POW': case 'POWER': From 6002f33fe60620ddedd479b6750e44a9cf187f33 Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 21:45:09 +1300 Subject: [PATCH 5/8] Fix delete local storage --- js/ui/apple2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/ui/apple2.js b/js/ui/apple2.js index 36935809..13760997 100644 --- a/js/ui/apple2.js +++ b/js/ui/apple2.js @@ -400,7 +400,7 @@ function updateLocalStorage() { document.querySelector('#manage-modal-content').innerHTML = '' + name + - ' Delete
'; }); From 21cb5d7d8e6cb0b49240b951ea1a1fedfa00c8d2 Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 21:45:57 +1300 Subject: [PATCH 6/8] Fix minus key on Mac --- js/ui/keyboard.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 8e734d20..b9416945 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -138,6 +138,7 @@ export default function KeyBoard(cpu, io, e) { 0x6F: [0x2F, 0x2F, 0x39], // / // Stray keys + 0xAD: [0x2D, 0x2D, 0x5F], // - - _ 0xBA: [0x3B, 0x3B, 0x3A], // ; - : 0xBB: [0x3D, 0x3D, 0x2B], // = - + 0xBC: [0x2C, 0x2C, 0x3C], // , - < From 97691fbed9bb35db5939db85fbba4208d801f418 Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 21:47:47 +1300 Subject: [PATCH 7/8] Swap open apple and apple keys to match Mac keyboard sides --- js/ui/apple2.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/ui/apple2.js b/js/ui/apple2.js index 13760997..60e1131e 100644 --- a/js/ui/apple2.js +++ b/js/ui/apple2.js @@ -558,9 +558,9 @@ function _keydown(evt) { keyboard.commandKey(true); } else if (evt.keyCode == 18) { // Alt if (evt.location == 1) { - keyboard.commandKey(true); - } else { keyboard.optionKey(true); + } else { + keyboard.commandKey(true); } } } @@ -577,9 +577,9 @@ function _keyup(evt) { keyboard.commandKey(false); } else if (evt.keyCode == 18) { // Alt if (evt.location == 1) { - keyboard.commandKey(false); - } else { keyboard.optionKey(false); + } else { + keyboard.commandKey(false); } } } From cc1c0f6d5e571bcef89e101f744e49546f26af8b Mon Sep 17 00:00:00 2001 From: Matthew Hebley Date: Mon, 30 Dec 2019 21:48:28 +1300 Subject: [PATCH 8/8] Remove backtick --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce82ff06..e5c456de 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ To add additional disk images, use then ```sh -./bin/index` +./bin/index ``` ## Updates