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 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)};` 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)); } } } diff --git a/js/ui/apple2.js b/js/ui/apple2.js index 3309e817..60e1131e 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(); } }; @@ -399,7 +400,7 @@ function updateLocalStorage() { document.querySelector('#manage-modal-content').innerHTML = '' + name + - ' Delete
'; }); @@ -549,15 +550,17 @@ 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 keyboard.commandKey(true); } else if (evt.keyCode == 18) { // Alt if (evt.location == 1) { - keyboard.commandKey(true); - } else { keyboard.optionKey(true); + } else { + keyboard.commandKey(true); } } } @@ -574,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); } } } @@ -715,6 +718,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; }); }); diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 43995b55..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], // , - < @@ -199,6 +200,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 +216,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 +284,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 +376,7 @@ export default function KeyBoard(cpu, io, e) { break; case 'CAPS': case 'LOCK': - self.capslockKey(!capslocked); + self.capslockKey(undefined); break; case 'POW': case 'POWER':