Various fixes (#23)
* Sort disks in category order * Fix saving disk * Fix keyboard not working after modal * Make caps lock key on keyboard work, while keeping caps lock on virtual keyboard working too * Fix delete local storage * Fix minus key on Mac * Remove backtick * Credit. Co-authored-by: Matthew Hebley <Matthew.Hebley@navico.com>
This commit is contained in:
parent
8af8cdbbca
commit
bb6e36f964
|
@ -37,7 +37,7 @@ To add additional disk images, use
|
|||
then
|
||||
|
||||
```sh
|
||||
./bin/index`
|
||||
./bin/index
|
||||
```
|
||||
|
||||
## Updates
|
||||
|
@ -170,3 +170,6 @@ then
|
|||
* [Gil Megidish](http://www.megidish.net/apple2js/), for the kick in the pants to finally post my version, once I realized there was, in fact, another apple2js in the world.
|
||||
* [AppleWin](https://github.com/AppleWin/AppleWin/), whose source code is a goldmine of useful references.
|
||||
* [Zellyn Hunter](https://github.com/zellyn/a2audit) and a2audit, for allowing me to get really nitpicky in my memory emulation.
|
||||
|
||||
* Contributors
|
||||
* [Snapperfish](http://github.com/Snapperfish) Various fixes
|
||||
|
|
19
bin/index
19
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)};`
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,11 +262,13 @@ function doLoadLocalDisk(drive, file) {
|
|||
if (this.result.byteLength >= 800 * 1024) {
|
||||
if (_cffa.setBinary(drive, name, ext, this.result)) {
|
||||
driveLights.label(drive, name);
|
||||
focused = false;
|
||||
initGamepad();
|
||||
}
|
||||
} else {
|
||||
if (_disk2.setBinary(drive, name, ext, this.result)) {
|
||||
driveLights.label(drive, name);
|
||||
focused = false;
|
||||
initGamepad();
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +488,7 @@ function updateLocalStorage() {
|
|||
document.querySelector('#manage-modal-content').innerHTML =
|
||||
'<span class="local_save">' +
|
||||
name +
|
||||
' <a href="#" onclick="doDelete(\'' +
|
||||
' <a href="#" onclick="Apple2.doDelete(\'' +
|
||||
name +
|
||||
'\')">Delete</a><br /></span>';
|
||||
});
|
||||
|
@ -630,6 +632,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
|
||||
|
@ -814,6 +818,7 @@ export function initUI(apple2, disk2, cffa, 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; });
|
||||
});
|
||||
|
||||
|
|
|
@ -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':
|
||||
|
|
Loading…
Reference in New Issue