enforce indent case like vscode prefers

This commit is contained in:
Will Scullin 2020-11-25 17:28:37 -08:00
parent 1e58e2c1b8
commit 1aaa94a8ed
No known key found for this signature in database
GPG Key ID: 9092A5C0A673416B
21 changed files with 1350 additions and 1347 deletions

View File

@ -4,7 +4,10 @@
"rules": { "rules": {
"indent": [ "indent": [
"error", "error",
4 4,
{
"SwitchCase": 1
}
], ],
"quotes": [ "quotes": [
"error", "error",

View File

@ -141,148 +141,148 @@ export default class Apple2IO implements PageHandler {
const now = this.cpu.getCycles(); const now = this.cpu.getCycles();
const delta = now - this._trigger; const delta = now - this._trigger;
switch (off) { switch (off) {
case LOC.CLRTEXT: case LOC.CLRTEXT:
this._debug('Graphics Mode'); this._debug('Graphics Mode');
this.vm.text(false); this.vm.text(false);
break; break;
case LOC.SETTEXT: case LOC.SETTEXT:
this._debug('Text Mode'); this._debug('Text Mode');
this.vm.text(true); this.vm.text(true);
break; break;
case LOC.CLRMIXED: case LOC.CLRMIXED:
this._debug('Mixed Mode off'); this._debug('Mixed Mode off');
this.vm.mixed(false); this.vm.mixed(false);
break; break;
case LOC.SETMIXED: case LOC.SETMIXED:
this._debug('Mixed Mode on'); this._debug('Mixed Mode on');
this.vm.mixed(true); this.vm.mixed(true);
break; break;
case LOC.CLRHIRES: case LOC.CLRHIRES:
this._debug('LoRes Mode'); this._debug('LoRes Mode');
this.vm.hires(false); this.vm.hires(false);
break; break;
case LOC.SETHIRES: case LOC.SETHIRES:
this._debug('HiRes Mode'); this._debug('HiRes Mode');
this.vm.hires(true); this.vm.hires(true);
break; break;
case LOC.PAGE1: case LOC.PAGE1:
this.vm.page(1); this.vm.page(1);
break; break;
case LOC.PAGE2: case LOC.PAGE2:
this.vm.page(2); this.vm.page(2);
break; break;
case LOC.SETAN0: case LOC.SETAN0:
this._debug('Annunciator 0 on'); this._debug('Annunciator 0 on');
this._annunciators[0] = true; this._annunciators[0] = true;
break; break;
case LOC.SETAN1: case LOC.SETAN1:
this._debug('Annunciator 1 on'); this._debug('Annunciator 1 on');
this._annunciators[1] = true; this._annunciators[1] = true;
break; break;
case LOC.SETAN2: case LOC.SETAN2:
this._debug('Annunciator 2 on'); this._debug('Annunciator 2 on');
this._annunciators[2] = true; this._annunciators[2] = true;
break; break;
case LOC.SETAN3: case LOC.SETAN3:
this._debug('Annunciator 3 on'); this._debug('Annunciator 3 on');
this._annunciators[3] = true; this._annunciators[3] = true;
break; break;
case LOC.CLRAN0: case LOC.CLRAN0:
this._debug('Annunciator 0 off'); this._debug('Annunciator 0 off');
this._annunciators[0] = false; this._annunciators[0] = false;
break; break;
case LOC.CLRAN1: case LOC.CLRAN1:
this._debug('Annunciator 1 off'); this._debug('Annunciator 1 off');
this._annunciators[1] = false; this._annunciators[1] = false;
break; break;
case LOC.CLRAN2: case LOC.CLRAN2:
this._debug('Annunciator 2 off'); this._debug('Annunciator 2 off');
this._annunciators[2] = false; this._annunciators[2] = false;
break; break;
case LOC.CLRAN3: case LOC.CLRAN3:
this._debug('Annunciator 3 off'); this._debug('Annunciator 3 off');
this._annunciators[3] = false; this._annunciators[3] = false;
break; break;
case LOC.PB0: case LOC.PB0:
result = this._button[0] ? 0x80 : 0; result = this._button[0] ? 0x80 : 0;
break; break;
case LOC.PB1: case LOC.PB1:
result = this._button[1] ? 0x80 : 0; result = this._button[1] ? 0x80 : 0;
break; break;
case LOC.PB2: case LOC.PB2:
result = this._button[2] ? 0x80 : 0; result = this._button[2] ? 0x80 : 0;
break; break;
case LOC.PADDLE0: case LOC.PADDLE0:
result = (delta < (this._paddle[0] * 2756) ? 0x80 : 0x00); result = (delta < (this._paddle[0] * 2756) ? 0x80 : 0x00);
break; break;
case LOC.PADDLE1: case LOC.PADDLE1:
result = (delta < (this._paddle[1] * 2756) ? 0x80 : 0x00); result = (delta < (this._paddle[1] * 2756) ? 0x80 : 0x00);
break; break;
case LOC.PADDLE2: case LOC.PADDLE2:
result = (delta < (this._paddle[2] * 2756) ? 0x80 : 0x00); result = (delta < (this._paddle[2] * 2756) ? 0x80 : 0x00);
break; break;
case LOC.PADDLE3: case LOC.PADDLE3:
result = (delta < (this._paddle[3] * 2756) ? 0x80 : 0x00); result = (delta < (this._paddle[3] * 2756) ? 0x80 : 0x00);
break; break;
case LOC.ACCEL: case LOC.ACCEL:
if (val !== undefined) { if (val !== undefined) {
this._updateKHz(val & 0x01 ? 1023 : 4096); this._updateKHz(val & 0x01 ? 1023 : 4096);
} }
break; break;
case LOC.TAPEIN: case LOC.TAPEIN:
if (this._tapeOffset == -1) { if (this._tapeOffset == -1) {
this._tapeOffset = 0; this._tapeOffset = 0;
this._tapeNext = now; this._tapeNext = now;
} }
if (this._tapeOffset < this._tape.length) { if (this._tapeOffset < this._tape.length) {
this._tapeCurrent = this._tape[this._tapeOffset][1];
while (now >= this._tapeNext) {
if ((this._tapeOffset % 1000) === 0) {
debug('Read ' + (this._tapeOffset / 1000));
}
this._tapeCurrent = this._tape[this._tapeOffset][1]; this._tapeCurrent = this._tape[this._tapeOffset][1];
this._tapeNext += this._tape[this._tapeOffset++][0]; while (now >= this._tapeNext) {
} if ((this._tapeOffset % 1000) === 0) {
debug('Read ' + (this._tapeOffset / 1000));
} }
this._tapeCurrent = this._tape[this._tapeOffset][1];
result = this._tapeCurrent ? 0x80 : 0x00; this._tapeNext += this._tape[this._tapeOffset++][0];
break;
default:
switch (off & 0xf0) {
case LOC.KEYBOARD: // C00x
result = this._key;
break;
case LOC.STROBE: // C01x
this._key &= 0x7f;
if (this._buffer.length > 0) {
let val = this._buffer.shift() as string;
if (val == '\n') {
val = '\r';
} }
this._key = val.charCodeAt(0) | 0x80;
} }
result = (this._keyDown ? 0x80 : 0x00) | this._key;
result = this._tapeCurrent ? 0x80 : 0x00;
break; break;
case LOC.TAPEOUT: // C02x
this._phase = -this._phase; default:
this._didAudio = true; switch (off & 0xf0) {
this._tick(); case LOC.KEYBOARD: // C00x
break; result = this._key;
case LOC.SPEAKER: // C03x break;
this._phase = -this._phase; case LOC.STROBE: // C01x
this._didAudio = true; this._key &= 0x7f;
this._tick(); if (this._buffer.length > 0) {
break; let val = this._buffer.shift() as string;
case LOC.C040STB: // C04x if (val == '\n') {
// I/O Strobe val = '\r';
break; }
case LOC.PDLTRIG: // C07x this._key = val.charCodeAt(0) | 0x80;
this._trigger = this.cpu.getCycles(); }
break; result = (this._keyDown ? 0x80 : 0x00) | this._key;
} break;
case LOC.TAPEOUT: // C02x
this._phase = -this._phase;
this._didAudio = true;
this._tick();
break;
case LOC.SPEAKER: // C03x
this._phase = -this._phase;
this._didAudio = true;
this._tick();
break;
case LOC.C040STB: // C04x
// I/O Strobe
break;
case LOC.PDLTRIG: // C07x
this._trigger = this.cpu.getCycles();
break;
}
} }
if (val !== undefined) { if (val !== undefined) {
@ -339,31 +339,31 @@ export default class Apple2IO implements PageHandler {
let card; let card;
switch (page) { switch (page) {
case 0xc0: case 0xc0:
result = this.ioSwitch(off, undefined); result = this.ioSwitch(off, undefined);
break; break;
case 0xc1: case 0xc1:
case 0xc2: case 0xc2:
case 0xc3: case 0xc3:
case 0xc4: case 0xc4:
case 0xc5: case 0xc5:
case 0xc6: case 0xc6:
case 0xc7: case 0xc7:
slot = page & 0x0f; slot = page & 0x0f;
card = this._slot[slot]; card = this._slot[slot];
if (this._auxRom != card) { if (this._auxRom != card) {
// _debug('Setting auxRom to slot', slot); // _debug('Setting auxRom to slot', slot);
this._auxRom = card; this._auxRom = card;
} }
if (card) { if (card) {
result = card.read(page, off); result = card.read(page, off);
} }
break; break;
default: default:
if (this._auxRom) { if (this._auxRom) {
result = this._auxRom.read(page, off); result = this._auxRom.read(page, off);
} }
break; break;
} }
return result; return result;
} }
@ -373,31 +373,31 @@ export default class Apple2IO implements PageHandler {
let card; let card;
switch (page) { switch (page) {
case 0xc0: case 0xc0:
this.ioSwitch(off, val); this.ioSwitch(off, val);
break; break;
case 0xc1: case 0xc1:
case 0xc2: case 0xc2:
case 0xc3: case 0xc3:
case 0xc4: case 0xc4:
case 0xc5: case 0xc5:
case 0xc6: case 0xc6:
case 0xc7: case 0xc7:
slot = page & 0x0f; slot = page & 0x0f;
card = this._slot[slot]; card = this._slot[slot];
if (this._auxRom != card) { if (this._auxRom != card) {
// _debug('Setting auxRom to slot', slot); // _debug('Setting auxRom to slot', slot);
this._auxRom = card; this._auxRom = card;
} }
if (card) { if (card) {
card.write(page, off, val); card.write(page, off, val);
} }
break; break;
default: default:
if (this._auxRom) { if (this._auxRom) {
this._auxRom.write(page, off, val); this._auxRom.write(page, off, val);
} }
break; break;
} }
} }

View File

@ -167,76 +167,76 @@ export default function ApplesoftCompiler(mem)
while (curChar < line.length) { while (curChar < line.length) {
character = line.charAt(curChar).toUpperCase(); character = line.charAt(curChar).toUpperCase();
switch (state) { switch (state) {
case STATES.NORMAL: case STATES.NORMAL:
if (character !== ' ') { if (character !== ' ') {
if (character === '"') { if (character === '"') {
result.push(character.charCodeAt(0)); result.push(character.charCodeAt(0));
state = STATES.STRING; state = STATES.STRING;
curChar++; curChar++;
} else { } else {
var foundToken = ''; var foundToken = '';
for (var possibleToken in TOKENS) { for (var possibleToken in TOKENS) {
if (possibleToken.charAt(0) == character) { if (possibleToken.charAt(0) == character) {
var tokenIdx = curChar + 1; var tokenIdx = curChar + 1;
var idx = 1; var idx = 1;
while (idx < possibleToken.length) { while (idx < possibleToken.length) {
if (line.charAt(tokenIdx) !== ' ') { if (line.charAt(tokenIdx) !== ' ') {
if (line.charAt(tokenIdx).toUpperCase() !== possibleToken.charAt(idx)) { if (line.charAt(tokenIdx).toUpperCase() !== possibleToken.charAt(idx)) {
break; break;
}
idx++;
} }
idx++; tokenIdx++;
} }
tokenIdx++; if (idx === possibleToken.length) {
}
if (idx === possibleToken.length) {
// Found a token // Found a token
if (possibleToken === 'AT') { if (possibleToken === 'AT') {
var lookAhead = line.charAt(tokenIdx + 1).toUpperCase(); var lookAhead = line.charAt(tokenIdx + 1).toUpperCase();
// ATN takes precedence over AT // ATN takes precedence over AT
if (lookAhead === 'N') { if (lookAhead === 'N') {
foundToken = 'ATN'; foundToken = 'ATN';
tokenIdx++; tokenIdx++;
} }
// TO takes precedence over AT // TO takes precedence over AT
if (lookAhead === 'O') { if (lookAhead === 'O') {
result.push(lookAhead.charCodeAt(0)); result.push(lookAhead.charCodeAt(0));
foundToken = 'TO'; foundToken = 'TO';
tokenIdx++; tokenIdx++;
}
} }
foundToken = possibleToken;
} }
foundToken = possibleToken; }
if (foundToken) {
break;
} }
} }
if (foundToken) { if (foundToken) {
break; result.push(TOKENS[foundToken]);
curChar = tokenIdx;
if (foundToken === 'REM') {
state = STATES.COMMENT;
}
} else {
result.push(character.charCodeAt(0));
curChar++;
} }
} }
if (foundToken) { } else {
result.push(TOKENS[foundToken]); curChar++;
curChar = tokenIdx;
if (foundToken === 'REM') {
state = STATES.COMMENT;
}
} else {
result.push(character.charCodeAt(0));
curChar++;
}
} }
} else { break;
case STATES.COMMENT:
result.push(character.charCodeAt(0));
curChar++; curChar++;
} break;
break; case STATES.STRING:
case STATES.COMMENT: result.push(character.charCodeAt(0));
result.push(character.charCodeAt(0)); if (character == '"') {
curChar++; state = STATES.NORMAL;
break; }
case STATES.STRING: curChar++;
result.push(character.charCodeAt(0)); break;
if (character == '"') {
state = STATES.NORMAL;
}
curChar++;
break;
} }
} }

View File

@ -50,12 +50,12 @@ export function base64_encode(data: memory) {
enc = tmp_arr.join(''); enc = tmp_arr.join('');
switch (data.length % 3) { switch (data.length % 3) {
case 1: case 1:
enc = enc.slice(0, -2) + '=='; enc = enc.slice(0, -2) + '==';
break; break;
case 2: case 2:
enc = enc.slice(0, -1) + '='; enc = enc.slice(0, -1) + '=';
break; break;
} }
return enc; return enc;

View File

@ -209,55 +209,55 @@ export default function CFFA() {
if (readMode) { if (readMode) {
switch (off & 0x8f) { switch (off & 0x8f) {
case LOC.ATADataHigh: // 0x00 case LOC.ATADataHigh: // 0x00
retVal = _dataHigh; retVal = _dataHigh;
break; break;
case LOC.SetCSMask: // 0x01 case LOC.SetCSMask: // 0x01
_disableSignalling = true; _disableSignalling = true;
break; break;
case LOC.ClearCSMask: // 0x02 case LOC.ClearCSMask: // 0x02
_disableSignalling = false; _disableSignalling = false;
break; break;
case LOC.WriteEEPROM: // 0x03 case LOC.WriteEEPROM: // 0x03
_writeEEPROM = true; _writeEEPROM = true;
break; break;
case LOC.NoWriteEEPROM: // 0x04 case LOC.NoWriteEEPROM: // 0x04
_writeEEPROM = false; _writeEEPROM = false;
break; break;
case LOC.ATAAltStatus: // 0x06 case LOC.ATAAltStatus: // 0x06
retVal = _altStatus; retVal = _altStatus;
break; break;
case LOC.ATADataLow: // 0x08 case LOC.ATADataLow: // 0x08
_dataHigh = _curSector[_curWord] >> 8; _dataHigh = _curSector[_curWord] >> 8;
retVal = _curSector[_curWord] & 0xff; retVal = _curSector[_curWord] & 0xff;
if (!_disableSignalling) { if (!_disableSignalling) {
_curWord++; _curWord++;
} }
break; break;
case LOC.AError: // 0x09 case LOC.AError: // 0x09
retVal = _error; retVal = _error;
break; break;
case LOC.ASectorCnt: // 0x0A case LOC.ASectorCnt: // 0x0A
retVal = _sectorCnt; retVal = _sectorCnt;
break; break;
case LOC.ASector: // 0x0B case LOC.ASector: // 0x0B
retVal = _sector; retVal = _sector;
break; break;
case LOC.ATACylinder: // 0x0C case LOC.ATACylinder: // 0x0C
retVal = _cylinder; retVal = _cylinder;
break; break;
case LOC.ATACylinderH: // 0x0D case LOC.ATACylinderH: // 0x0D
retVal = _cylinderH; retVal = _cylinderH;
break; break;
case LOC.ATAHead: // 0x0E case LOC.ATAHead: // 0x0E
retVal = _head | (_lba ? 0x40 : 0) | (_drive ? 0x10 : 0) | 0xA0; retVal = _head | (_lba ? 0x40 : 0) | (_drive ? 0x10 : 0) | 0xA0;
break; break;
case LOC.ATAStatus: // 0x0F case LOC.ATAStatus: // 0x0F
retVal = _sectors[_drive].length > 0 ? STATUS.DRDY | STATUS.DSC : 0; retVal = _sectors[_drive].length > 0 ? STATUS.DRDY | STATUS.DSC : 0;
_debug('returning status', _statusString(retVal)); _debug('returning status', _statusString(retVal));
break; break;
default: default:
debug('read unknown soft switch', toHex(off)); debug('read unknown soft switch', toHex(off));
} }
if (off & 0x7) { // Anything but data high/low if (off & 0x7) { // Anything but data high/low
@ -269,85 +269,85 @@ export default function CFFA() {
} }
switch (off & 0x8f) { switch (off & 0x8f) {
case LOC.ATADataHigh: // 0x00 case LOC.ATADataHigh: // 0x00
_dataHigh = val; _dataHigh = val;
break; break;
case LOC.SetCSMask: // 0x01 case LOC.SetCSMask: // 0x01
_disableSignalling = true; _disableSignalling = true;
break; break;
case LOC.ClearCSMask: // 0x02 case LOC.ClearCSMask: // 0x02
_disableSignalling = false; _disableSignalling = false;
break; break;
case LOC.WriteEEPROM: // 0x03 case LOC.WriteEEPROM: // 0x03
_writeEEPROM = true; _writeEEPROM = true;
break; break;
case LOC.NoWriteEEPROM: // 0x04 case LOC.NoWriteEEPROM: // 0x04
_writeEEPROM = false; _writeEEPROM = false;
break; break;
case LOC.ATADevCtrl: // 0x06 case LOC.ATADevCtrl: // 0x06
_debug('devCtrl:', toHex(val)); _debug('devCtrl:', toHex(val));
_interruptsEnabled = (val & 0x04) ? true : false; _interruptsEnabled = (val & 0x04) ? true : false;
_debug('Interrupts', _interruptsEnabled ? 'enabled' : 'disabled'); _debug('Interrupts', _interruptsEnabled ? 'enabled' : 'disabled');
if (val & 0x02) { if (val & 0x02) {
_reset(); _reset();
} }
break; break;
case LOC.ATADataLow: // 0x08 case LOC.ATADataLow: // 0x08
_curSector[_curWord] = _dataHigh << 8 | val; _curSector[_curWord] = _dataHigh << 8 | val;
_curWord++; _curWord++;
break; break;
case LOC.ASectorCnt: // 0x0a case LOC.ASectorCnt: // 0x0a
_debug('setting sector count', val); _debug('setting sector count', val);
_sectorCnt = val; _sectorCnt = val;
break; break;
case LOC.ASector: // 0x0b case LOC.ASector: // 0x0b
_debug('setting sector', toHex(val)); _debug('setting sector', toHex(val));
_sector = val; _sector = val;
break; break;
case LOC.ATACylinder: // 0x0c case LOC.ATACylinder: // 0x0c
_debug('setting cylinder', toHex(val)); _debug('setting cylinder', toHex(val));
_cylinder = val; _cylinder = val;
break; break;
case LOC.ATACylinderH: // 0x0d case LOC.ATACylinderH: // 0x0d
_debug('setting cylinder high', toHex(val)); _debug('setting cylinder high', toHex(val));
_cylinderH = val; _cylinderH = val;
break; break;
case LOC.ATAHead: case LOC.ATAHead:
_head = val & 0xf; _head = val & 0xf;
_lba = val & 0x40 ? true : false; _lba = val & 0x40 ? true : false;
_drive = val & 0x10 ? 1 : 0; _drive = val & 0x10 ? 1 : 0;
_debug('setting head', toHex(val & 0xf), 'drive', _drive); _debug('setting head', toHex(val & 0xf), 'drive', _drive);
if (!_lba) { if (!_lba) {
console.error('CHS mode not supported'); console.error('CHS mode not supported');
} }
break; break;
case LOC.ATACommand: // 0x0f case LOC.ATACommand: // 0x0f
_debug('command:', toHex(val)); _debug('command:', toHex(val));
sector = _head << 24 | _cylinderH << 16 | _cylinder << 8 | _sector; sector = _head << 24 | _cylinderH << 16 | _cylinder << 8 | _sector;
_dumpSector(sector); _dumpSector(sector);
switch (val) { switch (val) {
case COMMANDS.ATAIdentify: case COMMANDS.ATAIdentify:
_debug('ATA identify'); _debug('ATA identify');
_curSector = _identity[_drive]; _curSector = _identity[_drive];
_curWord = 0; _curWord = 0;
break; break;
case COMMANDS.ATACRead: case COMMANDS.ATACRead:
_debug('ATA read sector', toHex(_cylinderH), toHex(_cylinder), toHex(_sector), sector); _debug('ATA read sector', toHex(_cylinderH), toHex(_cylinder), toHex(_sector), sector);
_curSector = _sectors[_drive][sector]; _curSector = _sectors[_drive][sector];
_curWord = 0; _curWord = 0;
break; break;
case COMMANDS.ATACWrite: case COMMANDS.ATACWrite:
_debug('ATA write sector', toHex(_cylinderH), toHex(_cylinder), toHex(_sector), sector); _debug('ATA write sector', toHex(_cylinderH), toHex(_cylinder), toHex(_sector), sector);
_curSector = _sectors[_drive][sector]; _curSector = _sectors[_drive][sector];
_curWord = 0; _curWord = 0;
break;
default:
debug('unknown command', toHex(val));
}
break; break;
default: default:
debug('unknown command', toHex(val)); debug('write unknown soft switch', toHex(off), toHex(val));
}
break;
default:
debug('write unknown soft switch', toHex(off), toHex(val));
} }
} }

View File

@ -179,27 +179,27 @@ export default function DiskII(io, callbacks, sectors = 16)
} }
switch (command & 0xf) { switch (command & 0xf) {
case 0x0: // CLR case 0x0: // CLR
_latch = 0; _latch = 0;
break; break;
case 0x8: // NOP case 0x8: // NOP
break; break;
case 0x9: // SL0 case 0x9: // SL0
_latch = (_latch << 1) & 0xff; _latch = (_latch << 1) & 0xff;
break; break;
case 0xA: // SR case 0xA: // SR
_latch >>= 1; _latch >>= 1;
if (_cur.readOnly) { if (_cur.readOnly) {
_latch |= 0x80; _latch |= 0x80;
} }
break; break;
case 0xB: // LD case 0xB: // LD
_latch = _bus; _latch = _bus;
debug('Loading', toHex(_latch), 'from bus'); debug('Loading', toHex(_latch), 'from bus');
break; break;
case 0xD: // SL1 case 0xD: // SL1
_latch = ((_latch << 1) | 0x01) & 0xff; _latch = ((_latch << 1) | 0x01) & 0xff;
break; break;
} }
_state = command >> 4; _state = command >> 4;
@ -295,115 +295,115 @@ export default function DiskII(io, callbacks, sectors = 16)
var readMode = val === undefined; var readMode = val === undefined;
switch (off & 0x8f) { switch (off & 0x8f) {
case LOC.PHASE0OFF: // 0x00 case LOC.PHASE0OFF: // 0x00
setPhase(0, false); setPhase(0, false);
break; break;
case LOC.PHASE0ON: // 0x01 case LOC.PHASE0ON: // 0x01
setPhase(0, true); setPhase(0, true);
break; break;
case LOC.PHASE1OFF: // 0x02 case LOC.PHASE1OFF: // 0x02
setPhase(1, false); setPhase(1, false);
break; break;
case LOC.PHASE1ON: // 0x03 case LOC.PHASE1ON: // 0x03
setPhase(1, true); setPhase(1, true);
break; break;
case LOC.PHASE2OFF: // 0x04 case LOC.PHASE2OFF: // 0x04
setPhase(2, false); setPhase(2, false);
break; break;
case LOC.PHASE2ON: // 0x05 case LOC.PHASE2ON: // 0x05
setPhase(2, true); setPhase(2, true);
break; break;
case LOC.PHASE3OFF: // 0x06 case LOC.PHASE3OFF: // 0x06
setPhase(3, false); setPhase(3, false);
break; break;
case LOC.PHASE3ON: // 0x07 case LOC.PHASE3ON: // 0x07
setPhase(3, true); setPhase(3, true);
break; break;
case LOC.DRIVEOFF: // 0x08 case LOC.DRIVEOFF: // 0x08
if (!_offTimeout) { if (!_offTimeout) {
if (_on) { if (_on) {
_offTimeout = window.setTimeout(function() { _offTimeout = window.setTimeout(function() {
_debug('Drive Off'); _debug('Drive Off');
_on = false; _on = false;
if (callbacks.driveLight) { callbacks.driveLight(_drive, false); } if (callbacks.driveLight) { callbacks.driveLight(_drive, false); }
}, 1000); }, 1000);
}
}
break;
case LOC.DRIVEON: // 0x09
if (_offTimeout) {
window.clearTimeout(_offTimeout);
_offTimeout = null;
}
if (!_on) {
_debug('Drive On');
_on = true;
_lastCycles = io.cycles();
if (callbacks.driveLight) { callbacks.driveLight(_drive, true); }
}
break;
case LOC.DRIVE1: // 0x0a
_debug('Disk 1');
_drive = 1;
_cur = _drives[_drive - 1];
if (_on && callbacks.driveLight) {
callbacks.driveLight(2, false);
callbacks.driveLight(1, true);
}
break;
case LOC.DRIVE2: // 0x0b
_debug('Disk 2');
_drive = 2;
_cur = _drives[_drive - 1];
if (_on && callbacks.driveLight) {
callbacks.driveLight(1, false);
callbacks.driveLight(2, true);
}
break;
case LOC.DRIVEREAD: // 0x0c (Q6L) Shift
_q6 = 0;
if (_writeMode) {
_debug('clearing _q6/SHIFT');
}
if (!_cur.rawTracks) {
_readWriteNext();
}
break;
case LOC.DRIVEWRITE: // 0x0d (Q6H) LOAD
_q6 = 1;
if (_writeMode) {
_debug('setting _q6/LOAD');
}
if (!_cur.rawTracks) {
if (readMode && !_writeMode) {
if (_cur.readOnly) {
_latch = 0xff;
_debug('Setting readOnly');
} else {
_latch = _latch >> 1;
_debug('Clearing readOnly');
} }
} }
} break;
break; case LOC.DRIVEON: // 0x09
if (_offTimeout) {
window.clearTimeout(_offTimeout);
_offTimeout = null;
}
if (!_on) {
_debug('Drive On');
_on = true;
_lastCycles = io.cycles();
if (callbacks.driveLight) { callbacks.driveLight(_drive, true); }
}
break;
case LOC.DRIVEREADMODE: // 0x0e (Q7L) case LOC.DRIVE1: // 0x0a
_debug('Read Mode'); _debug('Disk 1');
_q7 = 0; _drive = 1;
_writeMode = false; _cur = _drives[_drive - 1];
break; if (_on && callbacks.driveLight) {
case LOC.DRIVEWRITEMODE: // 0x0f (Q7H) callbacks.driveLight(2, false);
_debug('Write Mode'); callbacks.driveLight(1, true);
_q7 = 1; }
_writeMode = true; break;
break; case LOC.DRIVE2: // 0x0b
_debug('Disk 2');
_drive = 2;
_cur = _drives[_drive - 1];
if (_on && callbacks.driveLight) {
callbacks.driveLight(1, false);
callbacks.driveLight(2, true);
}
break;
default: case LOC.DRIVEREAD: // 0x0c (Q6L) Shift
break; _q6 = 0;
if (_writeMode) {
_debug('clearing _q6/SHIFT');
}
if (!_cur.rawTracks) {
_readWriteNext();
}
break;
case LOC.DRIVEWRITE: // 0x0d (Q6H) LOAD
_q6 = 1;
if (_writeMode) {
_debug('setting _q6/LOAD');
}
if (!_cur.rawTracks) {
if (readMode && !_writeMode) {
if (_cur.readOnly) {
_latch = 0xff;
_debug('Setting readOnly');
} else {
_latch = _latch >> 1;
_debug('Clearing readOnly');
}
}
}
break;
case LOC.DRIVEREADMODE: // 0x0e (Q7L)
_debug('Read Mode');
_q7 = 0;
_writeMode = false;
break;
case LOC.DRIVEWRITEMODE: // 0x0f (Q7H)
_debug('Write Mode');
_q7 = 1;
_writeMode = true;
break;
default:
break;
} }
_moveHead(); _moveHead();
@ -576,21 +576,21 @@ export default function DiskII(io, callbacks, sectors = 16)
}; };
switch (fmt) { switch (fmt) {
case 'd13': case 'd13':
disk = new D13(options); disk = new D13(options);
break; break;
case 'do': case 'do':
case 'dsk': case 'dsk':
disk = new DOS(options); disk = new DOS(options);
break; break;
case 'nib': case 'nib':
disk = new Nibble(options); disk = new Nibble(options);
break; break;
case 'po': case 'po':
disk = new ProDOS(options); disk = new ProDOS(options);
break; break;
default: default:
return false; return false;
} }
Object.assign(cur, disk); Object.assign(cur, disk);
@ -621,27 +621,27 @@ export default function DiskII(io, callbacks, sectors = 16)
}; };
switch (fmt) { switch (fmt) {
case '2mg': case '2mg':
disk = new _2MG(options); disk = new _2MG(options);
break; break;
case 'd13': case 'd13':
disk = new D13(options); disk = new D13(options);
break; break;
case 'do': case 'do':
case 'dsk': case 'dsk':
disk = new DOS(options); disk = new DOS(options);
break; break;
case 'nib': case 'nib':
disk = new Nibble(options); disk = new Nibble(options);
break; break;
case 'po': case 'po':
disk = new ProDOS(options); disk = new ProDOS(options);
break; break;
case 'woz': case 'woz':
disk = new Woz(options); disk = new Woz(options);
break; break;
default: default:
return false; return false;
} }
Object.assign(cur, disk); Object.assign(cur, disk);

View File

@ -85,73 +85,73 @@ export default function LanguageCard(io, rom) {
var readMode = val === undefined; var readMode = val === undefined;
var result = 0; var result = 0;
switch (off & 0x8B) { switch (off & 0x8B) {
case LOC.READBSR2: // 0xC080 case LOC.READBSR2: // 0xC080
_readbsr = true; _readbsr = true;
_writebsr = false; _writebsr = false;
_bsr2 = true; _bsr2 = true;
_prewrite = false; _prewrite = false;
_debug('Bank 2 Read'); _debug('Bank 2 Read');
break; break;
case LOC.WRITEBSR2: // 0xC081 case LOC.WRITEBSR2: // 0xC081
_readbsr = false; _readbsr = false;
if (readMode) { if (readMode) {
_writebsr = _prewrite; _writebsr = _prewrite;
} }
_bsr2 = true; _bsr2 = true;
_prewrite = readMode; _prewrite = readMode;
_debug('Bank 2 Write'); _debug('Bank 2 Write');
break; break;
case LOC.OFFBSR2: // 0xC082 case LOC.OFFBSR2: // 0xC082
_readbsr = false; _readbsr = false;
_writebsr = false; _writebsr = false;
_bsr2 = true; _bsr2 = true;
_prewrite = false; _prewrite = false;
_debug('Bank 2 Off'); _debug('Bank 2 Off');
break; break;
case LOC.READWRBSR2: // 0xC083 case LOC.READWRBSR2: // 0xC083
_readbsr = true; _readbsr = true;
if (readMode) { if (readMode) {
_writebsr = _prewrite; _writebsr = _prewrite;
} }
_bsr2 = true; _bsr2 = true;
_prewrite = readMode; _prewrite = readMode;
_debug('Bank 2 Read/Write'); _debug('Bank 2 Read/Write');
break; break;
case LOC.READBSR1: // 0xC088 case LOC.READBSR1: // 0xC088
_readbsr = true; _readbsr = true;
_writebsr = false; _writebsr = false;
_bsr2 = false; _bsr2 = false;
_prewrite = false; _prewrite = false;
_debug('Bank 1 Read'); _debug('Bank 1 Read');
break; break;
case LOC.WRITEBSR1: // 0xC089 case LOC.WRITEBSR1: // 0xC089
_readbsr = false; _readbsr = false;
if (readMode) { if (readMode) {
_writebsr = _prewrite; _writebsr = _prewrite;
} }
_bsr2 = false; _bsr2 = false;
_prewrite = readMode; _prewrite = readMode;
_debug('Bank 1 Write'); _debug('Bank 1 Write');
break; break;
case LOC.OFFBSR1: // 0xC08A case LOC.OFFBSR1: // 0xC08A
_readbsr = false; _readbsr = false;
_writebsr = false; _writebsr = false;
_bsr2 = false; _bsr2 = false;
_prewrite = false; _prewrite = false;
_debug('Bank 1 Off'); _debug('Bank 1 Off');
break; break;
case LOC.READWRBSR1: // 0xC08B case LOC.READWRBSR1: // 0xC08B
_readbsr = true; _readbsr = true;
if (readMode) { if (readMode) {
_writebsr = _prewrite; _writebsr = _prewrite;
} }
_bsr2 = false; _bsr2 = false;
_prewrite = readMode; _prewrite = readMode;
_debug('Bank 1 Read/Write'); _debug('Bank 1 Read/Write');
break; break;
default: default:
break; break;
} }
_updateBanks(); _updateBanks();

View File

@ -22,13 +22,13 @@ export default function Parallel(io, cbs) {
function _access(off, val) { function _access(off, val) {
switch (off & 0x8f) { switch (off & 0x8f) {
case LOC.IOREG: case LOC.IOREG:
if (cbs.putChar && val) { if (cbs.putChar && val) {
cbs.putChar(val); cbs.putChar(val);
} }
break; break;
default: default:
debug('Parallel card unknown softswitch', off); debug('Parallel card unknown softswitch', off);
} }
} }

View File

@ -66,49 +66,49 @@ export default function RAMFactor(io, size) {
function _access(off, val) { function _access(off, val) {
var result = 0; var result = 0;
switch (off & 0x8f) { switch (off & 0x8f) {
case LOC.RAMLO: case LOC.RAMLO:
case LOC._RAMLO: case LOC._RAMLO:
if (val !== undefined) { if (val !== undefined) {
_setlo(val); _setlo(val);
} else { } else {
result = _ramlo; result = _ramlo;
} }
break; break;
case LOC.RAMMID: case LOC.RAMMID:
case LOC._RAMMID: case LOC._RAMMID:
if (val !== undefined) { if (val !== undefined) {
_setmid(val); _setmid(val);
} else { } else {
result = _rammid; result = _rammid;
} }
break; break;
case LOC.RAMHI: case LOC.RAMHI:
case LOC._RAMHI: case LOC._RAMHI:
if (val !== undefined) { if (val !== undefined) {
_sethi(val); _sethi(val);
} else { } else {
result = _ramhi; result = _ramhi;
result |= 0xf0; result |= 0xf0;
} }
break; break;
case LOC.RAMDATA: case LOC.RAMDATA:
case LOC._RAMDATA: case LOC._RAMDATA:
if (val !== undefined) { if (val !== undefined) {
mem[_loc % mem.length] = val; mem[_loc % mem.length] = val;
} else { } else {
result = mem[_loc % mem.length]; result = mem[_loc % mem.length];
} }
_setlo(_ramlo + 1); _setlo(_ramlo + 1);
break; break;
case LOC.BANK: case LOC.BANK:
if (val !== undefined) { if (val !== undefined) {
_firmware = val & 0x01; _firmware = val & 0x01;
} else { } else {
result = _firmware; result = _firmware;
} }
break; break;
default: default:
break; break;
} }
_loc = (_ramhi << 16) | (_rammid << 8) | (_ramlo); _loc = (_ramhi << 16) | (_rammid << 8) | (_ramlo);

View File

@ -230,17 +230,17 @@ export default function SmartPort(io, cpu, options ) {
var readMode = val === undefined; var readMode = val === undefined;
switch (off & 0x8f) { switch (off & 0x8f) {
case 0x80: case 0x80:
if (readMode) { if (readMode) {
result = 0; result = 0;
for (var idx = 0; idx < disks.length; idx++) { for (var idx = 0; idx < disks.length; idx++) {
result <<= 1; result <<= 1;
if (disks[idx]) { if (disks[idx]) {
result |= 0x01; result |= 0x01;
}
} }
} }
} break;
break;
} }
return result; return result;
@ -285,21 +285,21 @@ export default function SmartPort(io, cpu, options ) {
_debug('buffer=' + toHex(buffer) + ' block=' + toHex(block)); _debug('buffer=' + toHex(buffer) + ' block=' + toHex(block));
switch (cmd) { switch (cmd) {
case 0: // INFO case 0: // INFO
getDeviceInfo(state, drive); getDeviceInfo(state, drive);
break; break;
case 1: // READ case 1: // READ
readBlock(state, drive, block, buffer); readBlock(state, drive, block, buffer);
break; break;
case 2: // WRITE case 2: // WRITE
writeBlock(state, drive, block, buffer); writeBlock(state, drive, block, buffer);
break; break;
case 3: // FORMAT case 3: // FORMAT
formatDevice(state, unit); formatDevice(state, unit);
break; break;
} }
} else if (off == smartOff && cpu.getSync()) { } else if (off == smartOff && cpu.getSync()) {
_debug('smartport entry'); _debug('smartport entry');
@ -326,81 +326,81 @@ export default function SmartPort(io, cpu, options ) {
_debug('parameterCount=' + parameterCount); _debug('parameterCount=' + parameterCount);
switch (cmd) { switch (cmd) {
case 0x00: // INFO case 0x00: // INFO
status = cmdListAddr.inc(4).readByte(); status = cmdListAddr.inc(4).readByte();
_debug('info unit=' + unit); _debug('info unit=' + unit);
_debug('info buffer=' + buffer); _debug('info buffer=' + buffer);
_debug('info status=' + status); _debug('info status=' + status);
switch (unit) { switch (unit) {
case 0: case 0:
switch (status) { switch (status) {
case 0: case 0:
buffer.writeByte(1); // one device buffer.writeByte(1); // one device
buffer.inc(1).writeByte(1 << 6); // no interrupts buffer.inc(1).writeByte(1 << 6); // no interrupts
buffer.inc(2).writeByte(0); // reserved buffer.inc(2).writeByte(0); // reserved
buffer.inc(3).writeByte(0); // reserved buffer.inc(3).writeByte(0); // reserved
buffer.inc(4).writeByte(0); // reserved buffer.inc(4).writeByte(0); // reserved
buffer.inc(5).writeByte(0); // reserved buffer.inc(5).writeByte(0); // reserved
buffer.inc(6).writeByte(0); // reserved buffer.inc(6).writeByte(0); // reserved
buffer.inc(7).writeByte(0); // reserved buffer.inc(7).writeByte(0); // reserved
state.x = 8; state.x = 8;
state.y = 0; state.y = 0;
state.a = 0; state.a = 0;
state.s &= 0xfe; state.s &= 0xfe;
break; break;
}
break;
default: // Unit 1
switch (status) {
case 0:
var blocks = disks[unit].length;
buffer.writeByte(0xf0); // W/R Block device in drive
buffer.inc(1).writeByte(blocks & 0xff); // 1600 blocks
buffer.inc(2).writeByte((blocks & 0xff00) >> 8);
buffer.inc(3).writeByte((blocks & 0xff0000) >> 16);
state.x = 4;
state.y = 0;
state.a = 0;
state.s &= 0xfe;
break;
}
break;
} }
state.a = 0;
state.s &= 0xfe;
break; break;
default: // Unit 1
switch (status) { case 0x01: // READ BLOCK
case 0: block = cmdListAddr.inc(4).readWord();
var blocks = disks[unit].length; readBlock(state, unit, block, buffer);
buffer.writeByte(0xf0); // W/R Block device in drive
buffer.inc(1).writeByte(blocks & 0xff); // 1600 blocks
buffer.inc(2).writeByte((blocks & 0xff00) >> 8);
buffer.inc(3).writeByte((blocks & 0xff0000) >> 16);
state.x = 4;
state.y = 0;
state.a = 0;
state.s &= 0xfe;
break;
}
break; break;
}
state.a = 0;
state.s &= 0xfe;
break;
case 0x01: // READ BLOCK case 0x02: // WRITE BLOCK
block = cmdListAddr.inc(4).readWord(); block = cmdListAddr.inc(4).readWord();
readBlock(state, unit, block, buffer); writeBlock(state, unit, block, buffer);
break; break;
case 0x02: // WRITE BLOCK case 0x03: // FORMAT
block = cmdListAddr.inc(4).readWord(); formatDevice(state, unit);
writeBlock(state, unit, block, buffer); break;
break;
case 0x03: // FORMAT case 0x04: // CONTROL
formatDevice(state, unit); break;
break;
case 0x04: // CONTROL case 0x05: // INIT
break; break;
case 0x05: // INIT case 0x06: // OPEN
break; break;
case 0x06: // OPEN case 0x07: // CLOSE
break; break;
case 0x07: // CLOSE case 0x08: // READ
break; break;
case 0x08: // READ case 0x09: // WRITE
break; break;
case 0x09: // WRITE
break;
} }
} }

View File

@ -90,46 +90,46 @@ export default function Thunderclock()
function _access(off, val) { function _access(off, val) {
switch (off & 0x8F) { switch (off & 0x8F) {
case LOC.CONTROL: case LOC.CONTROL:
if (val !== undefined) { if (val !== undefined) {
var strobe = val & FLAGS.STROBE ? true : false; var strobe = val & FLAGS.STROBE ? true : false;
if (strobe !== _strobe) { if (strobe !== _strobe) {
_debug('strobe', _strobe ? 'high' : 'low'); _debug('strobe', _strobe ? 'high' : 'low');
if (strobe) { if (strobe) {
_command = val & COMMANDS.MASK; _command = val & COMMANDS.MASK;
switch (_command) { switch (_command) {
case COMMANDS.TIMED: case COMMANDS.TIMED:
_debug('TIMED'); _debug('TIMED');
_calcBits(); _calcBits();
break; break;
case COMMANDS.REGSHIFT: case COMMANDS.REGSHIFT:
_debug('REGSHIFT'); _debug('REGSHIFT');
_shiftMode = true; _shiftMode = true;
_shift();
break;
case COMMANDS.REGHOLD:
_debug('REGHOLD');
_shiftMode = false;
break;
default:
_debug('Unknown command', toHex(_command));
}
}
}
var clock = val & FLAGS.CLOCK ? true : false;
if (clock !== _clock) {
_clock = clock;
_debug('clock', _clock ? 'high' : 'low');
if (clock) {
_shift(); _shift();
break;
case COMMANDS.REGHOLD:
_debug('REGHOLD');
_shiftMode = false;
break;
default:
_debug('Unknown command', toHex(_command));
} }
} }
} }
break;
var clock = val & FLAGS.CLOCK ? true : false; case LOC.AUX:
break;
if (clock !== _clock) {
_clock = clock;
_debug('clock', _clock ? 'high' : 'low');
if (clock) {
_shift();
}
}
}
break;
case LOC.AUX:
break;
} }
return _register; return _register;
} }

View File

@ -190,34 +190,34 @@ export default function Videoterm(io, context) {
var writeMode = val !== undefined; var writeMode = val !== undefined;
var result = undefined; var result = undefined;
switch (off & 0x81) { switch (off & 0x81) {
case LOC.IOREG: case LOC.IOREG:
if (writeMode) { if (writeMode) {
_curReg = val; _curReg = val;
} else { } else {
result = _curReg; result = _curReg;
}
break;
case LOC.IOVAL:
if (writeMode) {
_regs[_curReg] = val;
switch (_curReg) {
case REGS.CURSOR_UPPER:
case REGS.CURSOR_LOWER:
_refreshCursor(true);
break;
case REGS.CURSOR_HI:
case REGS.CURSOR_LO:
_refreshCursor(true);
break;
case REGS.STARTPOS_HI:
case REGS.STARTPOS_LO:
_updateStartPos();
break;
} }
} else { break;
result = _regs[_curReg]; case LOC.IOVAL:
} if (writeMode) {
break; _regs[_curReg] = val;
switch (_curReg) {
case REGS.CURSOR_UPPER:
case REGS.CURSOR_LOWER:
_refreshCursor(true);
break;
case REGS.CURSOR_HI:
case REGS.CURSOR_LO:
_refreshCursor(true);
break;
case REGS.STARTPOS_HI:
case REGS.STARTPOS_LO:
_updateStartPos();
break;
}
} else {
result = _regs[_curReg];
}
break;
} }
_bank = (off & 0x0C) >> 2; _bank = (off & 0x0C) >> 2;
return result; return result;

View File

@ -1008,68 +1008,68 @@ export default class CPU6502 {
let off, val; let off, val;
let result = ''; let result = '';
switch (m) { switch (m) {
case 'implied': case 'implied':
break; break;
case 'immediate': case 'immediate':
result = '#' + toHexOrSymbol(this.readByteDebug(addr)); result = '#' + toHexOrSymbol(this.readByteDebug(addr));
break; break;
case 'absolute': case 'absolute':
result = '' + toHexOrSymbol(this.readWordDebug(addr), 4); result = '' + toHexOrSymbol(this.readWordDebug(addr), 4);
break; break;
case 'zeroPage': case 'zeroPage':
result = '' + toHexOrSymbol(this.readByteDebug(addr)); result = '' + toHexOrSymbol(this.readByteDebug(addr));
break; break;
case 'relative': case 'relative':
{ {
let off = this.readByteDebug(addr); let off = this.readByteDebug(addr);
if (off > 127) {
off -= 256;
}
addr += off + 1;
result = '' + toHexOrSymbol(addr, 4) + ' (' + off + ')';
}
break;
case 'absoluteX':
result = '' + toHexOrSymbol(this.readWordDebug(addr), 4) + ',X';
break;
case 'absoluteY':
result = '' + toHexOrSymbol(this.readWordDebug(addr), 4) + ',Y';
break;
case 'zeroPageX':
result = '' + toHexOrSymbol(this.readByteDebug(addr)) + ',X';
break;
case 'zeroPageY':
result = '' + toHexOrSymbol(this.readByteDebug(addr)) + ',Y';
break;
case 'absoluteIndirect':
result = '(' + toHexOrSymbol(this.readWordDebug(addr), 4) + ')';
break;
case 'zeroPageXIndirect':
result = '(' + toHexOrSymbol(this.readByteDebug(addr)) + ',X)';
break;
case 'zeroPageIndirectY':
result = '(' + toHexOrSymbol(this.readByteDebug(addr)) + '),Y';
break;
case 'accumulator':
result = 'A';
break;
case 'zeroPageIndirect':
result = '(' + toHexOrSymbol(this.readByteDebug(addr)) + ')';
break;
case 'absoluteXIndirect':
result = '(' + toHexOrSymbol(this.readWordDebug(addr), 4) + ',X)';
break;
case 'zeroPage_relative':
val = this.readByteDebug(addr);
off = this.readByteDebug(addr + 1);
if (off > 127) { if (off > 127) {
off -= 256; off -= 256;
} }
addr += off + 1; addr += off + 2;
result = '' + toHexOrSymbol(addr, 4) + ' (' + off + ')'; result = '' + toHexOrSymbol(val) + ',' + toHexOrSymbol(addr, 4) + ' (' + off + ')';
} break;
break; default:
case 'absoluteX': break;
result = '' + toHexOrSymbol(this.readWordDebug(addr), 4) + ',X';
break;
case 'absoluteY':
result = '' + toHexOrSymbol(this.readWordDebug(addr), 4) + ',Y';
break;
case 'zeroPageX':
result = '' + toHexOrSymbol(this.readByteDebug(addr)) + ',X';
break;
case 'zeroPageY':
result = '' + toHexOrSymbol(this.readByteDebug(addr)) + ',Y';
break;
case 'absoluteIndirect':
result = '(' + toHexOrSymbol(this.readWordDebug(addr), 4) + ')';
break;
case 'zeroPageXIndirect':
result = '(' + toHexOrSymbol(this.readByteDebug(addr)) + ',X)';
break;
case 'zeroPageIndirectY':
result = '(' + toHexOrSymbol(this.readByteDebug(addr)) + '),Y';
break;
case 'accumulator':
result = 'A';
break;
case 'zeroPageIndirect':
result = '(' + toHexOrSymbol(this.readByteDebug(addr)) + ')';
break;
case 'absoluteXIndirect':
result = '(' + toHexOrSymbol(this.readWordDebug(addr), 4) + ',X)';
break;
case 'zeroPage_relative':
val = this.readByteDebug(addr);
off = this.readByteDebug(addr + 1);
if (off > 127) {
off -= 256;
}
addr += off + 2;
result = '' + toHexOrSymbol(val) + ',' + toHexOrSymbol(addr, 4) + ' (' + off + ')';
break;
default:
break;
} }
return result; return result;
} }

View File

@ -65,16 +65,16 @@ export default function _2MG(options) {
// Check image format. // Check image format.
// Sure, it's really 64 bits. But only 2 are actually used. // Sure, it's really 64 bits. But only 2 are actually used.
switch (format) { switch (format) {
case 1: // PO case 1: // PO
disk = new ProDOS(options); disk = new ProDOS(options);
break; break;
case 2: // NIB case 2: // NIB
disk = new Nibble(options); disk = new Nibble(options);
break; break;
case 0: // dsk case 0: // dsk
default: // Something hinky, assume 'dsk' default: // Something hinky, assume 'dsk'
disk = new DOS(options); disk = new DOS(options);
break; break;
} }
} }

View File

@ -319,70 +319,70 @@ export function readSector(drive: Drive, track: byte, sector: byte) {
const data = []; const data = [];
while (retry < 4) { while (retry < 4) {
switch (state) { switch (state) {
case 0: case 0:
val = _readNext(); val = _readNext();
state = (val === 0xd5) ? 1 : 0; state = (val === 0xd5) ? 1 : 0;
break; break;
case 1: case 1:
val = _readNext(); val = _readNext();
state = (val === 0xaa) ? 2 : 0; state = (val === 0xaa) ? 2 : 0;
break; break;
case 2: case 2:
val = _readNext(); val = _readNext();
state = (val === 0x96) ? 3 : (val === 0xad ? 4 : 0); state = (val === 0x96) ? 3 : (val === 0xad ? 4 : 0);
break; break;
case 3: // Address case 3: // Address
v = defourXfour(_readNext(), _readNext()); // Volume v = defourXfour(_readNext(), _readNext()); // Volume
t = defourXfour(_readNext(), _readNext()); t = defourXfour(_readNext(), _readNext());
s = defourXfour(_readNext(), _readNext()); s = defourXfour(_readNext(), _readNext());
checkSum = defourXfour(_readNext(), _readNext()); checkSum = defourXfour(_readNext(), _readNext());
if (checkSum != (v ^ t ^ s)) { if (checkSum != (v ^ t ^ s)) {
debug('Invalid header checksum:', toHex(v), toHex(t), toHex(s), toHex(checkSum)); debug('Invalid header checksum:', toHex(v), toHex(t), toHex(s), toHex(checkSum));
}
_skipBytes(3); // Skip footer
state = 0;
break;
case 4: // Data
if (s === _sector && t === track) {
const data2 = [];
let last = 0;
for (let jdx = 0x55; jdx >= 0; jdx--) {
val = detrans62[_readNext() - 0x80] ^ last;
data2[jdx] = val;
last = val;
} }
for (let jdx = 0; jdx < 0x100; jdx++) { _skipBytes(3); // Skip footer
val = detrans62[_readNext() - 0x80] ^ last; state = 0;
data[jdx] = val; break;
last = val; case 4: // Data
} if (s === _sector && t === track) {
checkSum = detrans62[_readNext() - 0x80] ^ last; const data2 = [];
if (checkSum) { let last = 0;
debug('Invalid data checksum:', toHex(v), toHex(t), toHex(s), toHex(checkSum)); for (let jdx = 0x55; jdx >= 0; jdx--) {
} val = detrans62[_readNext() - 0x80] ^ last;
for (let kdx = 0, jdx = 0x55; kdx < 0x100; kdx++) { data2[jdx] = val;
data[kdx] <<= 1; last = val;
if ((data2[jdx] & 0x01) !== 0) {
data[kdx] |= 0x01;
} }
data2[jdx] >>= 1; for (let jdx = 0; jdx < 0x100; jdx++) {
val = detrans62[_readNext() - 0x80] ^ last;
data[kdx] <<= 1; data[jdx] = val;
if ((data2[jdx] & 0x01) !== 0) { last = val;
data[kdx] |= 0x01;
} }
data2[jdx] >>= 1; checkSum = detrans62[_readNext() - 0x80] ^ last;
if (checkSum) {
debug('Invalid data checksum:', toHex(v), toHex(t), toHex(s), toHex(checkSum));
}
for (let kdx = 0, jdx = 0x55; kdx < 0x100; kdx++) {
data[kdx] <<= 1;
if ((data2[jdx] & 0x01) !== 0) {
data[kdx] |= 0x01;
}
data2[jdx] >>= 1;
if (--jdx < 0) jdx = 0x55; data[kdx] <<= 1;
if ((data2[jdx] & 0x01) !== 0) {
data[kdx] |= 0x01;
}
data2[jdx] >>= 1;
if (--jdx < 0) jdx = 0x55;
}
return data;
} }
return data; else
} _skipBytes(0x159); // Skip data, checksum and footer
else state = 0;
_skipBytes(0x159); // Skip data, checksum and footer break;
state = 0; default:
break; break;
default:
break;
} }
} }
return []; return [];

View File

@ -199,14 +199,14 @@ export default function Woz(options) {
var wozSignature = dv.getUint32(WOZ_HEADER_START + 0, true); var wozSignature = dv.getUint32(WOZ_HEADER_START + 0, true);
switch (wozSignature) { switch (wozSignature) {
case WOZ1_SIGNATURE: case WOZ1_SIGNATURE:
wozVersion = 1; wozVersion = 1;
break; break;
case WOZ2_SIGNATURE: case WOZ2_SIGNATURE:
wozVersion = 2; wozVersion = 2;
break; break;
default: default:
return false; return false;
} }
if (dv.getUint32(WOZ_HEADER_START + 4, true) !== WOZ_INTEGRITY_CHECK) { if (dv.getUint32(WOZ_HEADER_START + 4, true) !== WOZ_INTEGRITY_CHECK) {
@ -238,27 +238,27 @@ export default function Woz(options) {
var chunk = readChunk(); var chunk = readChunk();
while (chunk) { while (chunk) {
switch (chunk.type) { switch (chunk.type) {
case 0x4F464E49: // INFO case 0x4F464E49: // INFO
chunks.info = new InfoChunk(chunk.data); chunks.info = new InfoChunk(chunk.data);
break; break;
case 0x50414D54: // TMAP case 0x50414D54: // TMAP
chunks.tmap = new TMapChunk(chunk.data); chunks.tmap = new TMapChunk(chunk.data);
break; break;
case 0x534B5254: // TRKS case 0x534B5254: // TRKS
if (wozVersion === 1) { if (wozVersion === 1) {
chunks.trks = new TrksChunk(chunk.data); chunks.trks = new TrksChunk(chunk.data);
} else { } else {
chunks.trks = new TrksChunk2(chunk.data); chunks.trks = new TrksChunk2(chunk.data);
} }
break; break;
case 0x4154454D: // META case 0x4154454D: // META
chunks.meta = new MetaChunk(chunk.data); chunks.meta = new MetaChunk(chunk.data);
break; break;
case 0x54495257: // WRIT case 0x54495257: // WRIT
// Ignore // Ignore
break; break;
default: default:
debug('Unsupported chunk', toHex(chunk.type, 8)); debug('Unsupported chunk', toHex(chunk.type, 8));
} }
chunk = readChunk(); chunk = readChunk();
} }

View File

@ -32,30 +32,30 @@ var characterRom = apple2_charset;
var sectors = 16; var sectors = 16;
switch (romVersion) { switch (romVersion) {
case 'apple2': case 'apple2':
rom = new IntBASIC(); rom = new IntBASIC();
break; break;
case 'apple213': case 'apple213':
rom = new IntBASIC(); rom = new IntBASIC();
sectors = 13; sectors = 13;
break; break;
case 'original': case 'original':
rom = new OriginalROM(); rom = new OriginalROM();
break; break;
case 'apple2jplus': case 'apple2jplus':
rom = new Apple2jROM(); rom = new Apple2jROM();
characterRom = apple2j_charset; characterRom = apple2j_charset;
break; break;
case 'apple2pig': case 'apple2pig':
rom = new Apple2ROM(); rom = new Apple2ROM();
characterRom = pigfont_charset; characterRom = pigfont_charset;
break; break;
case 'apple2lc': case 'apple2lc':
rom = new Apple2ROM(); rom = new Apple2ROM();
characterRom = apple2lc_charset; characterRom = apple2lc_charset;
break; break;
default: default:
rom = new Apple2ROM(); rom = new Apple2ROM();
} }
var options = { var options = {

View File

@ -27,18 +27,18 @@ var rom;
var characterRom = apple2e_charset; var characterRom = apple2e_charset;
switch (romVersion) { switch (romVersion) {
case 'apple2e': case 'apple2e':
rom = new Apple2eROM(); rom = new Apple2eROM();
break; break;
case 'apple2rm': case 'apple2rm':
rom = new Apple2eEnhancedROM(); rom = new Apple2eEnhancedROM();
characterRom = rmfont_charset; characterRom = rmfont_charset;
enhanced = true; enhanced = true;
break; break;
default: default:
rom = new Apple2eEnhancedROM(); rom = new Apple2eEnhancedROM();
characterRom = apple2enh_charset; characterRom = apple2enh_charset;
enhanced = true; enhanced = true;
} }
var options = { var options = {

560
js/mmu.ts
View File

@ -486,302 +486,302 @@ export default class MMU implements Memory {
const writeMode = val !== undefined; const writeMode = val !== undefined;
switch (off) { switch (off) {
// Apple //e memory management // Apple //e memory management
case LOC._80STOREOFF: case LOC._80STOREOFF:
if (writeMode) { if (writeMode) {
this._80store = false; this._80store = false;
this._debug('80 Store Off'); this._debug('80 Store Off');
this.vm.page(this._page2 ? 2 : 1); this.vm.page(this._page2 ? 2 : 1);
} else { } else {
// Chain to io for keyboard // Chain to io for keyboard
result = this.io.ioSwitch(off, val);
}
break;
case LOC._80STOREON:
if (writeMode) {
this._80store = true;
this._debug('80 Store On');
} else
result = 0;
break;
case LOC.RAMRDOFF:
if (writeMode) {
this._auxRamRead = false;
this._debug('Aux RAM Read Off');
} else
result = 0;
break;
case LOC.RAMRDON:
if (writeMode) {
this._auxRamRead = true;
this._debug('Aux RAM Read On');
} else
result = 0;
break;
case LOC.RAMWROFF:
if (writeMode) {
this._auxRamWrite = false;
this._debug('Aux RAM Write Off');
} else
result = 0;
break;
case LOC.RAMWRON:
if (writeMode) {
this._auxRamWrite = true;
this._debug('Aux RAM Write On');
} else
result = 0;
break;
case LOC.INTCXROMOFF:
if (writeMode) {
this._intcxrom = false;
this._intc8rom = false;
this._debug('Int CX ROM Off');
}
break;
case LOC.INTCXROMON:
if (writeMode) {
this._intcxrom = true;
this._debug('Int CX ROM On');
}
break;
case LOC.ALTZPOFF: // 0x08
if (writeMode) {
this._altzp = false;
this._debug('Alt ZP Off');
}
break;
case LOC.ALTZPON: // 0x09
if (writeMode) {
this._altzp = true;
this._debug('Alt ZP On');
}
break;
case LOC.SLOTC3ROMOFF: // 0x0A
if (writeMode) {
this._slot3rom = false;
this._debug('Slot 3 ROM Off');
}
break;
case LOC.SLOTC3ROMON: // 0x0B
if (writeMode) {
this._slot3rom = true;
this._debug('Slot 3 ROM On');
}
break;
// Graphics Switches
case LOC.CLR80VID:
if (writeMode) {
this._debug('80 Column Mode off');
this.vm._80col(false);
}
break;
case LOC.SET80VID:
if (writeMode) {
this._debug('80 Column Mode on');
this.vm._80col(true);
}
break;
case LOC.CLRALTCH:
if (writeMode) {
this._debug('Alt Char off');
this.vm.altchar(false);
}
break;
case LOC.SETALTCH:
if (writeMode) {
this._debug('Alt Char on');
this.vm.altchar(true);
}
break;
case LOC.PAGE1:
this._page2 = false;
if (!this._80store) {
result = this.io.ioSwitch(off, val);
}
this._debug('Page 2 off');
break;
case LOC.PAGE2:
this._page2 = true;
if (!this._80store) {
result = this.io.ioSwitch(off, val);
}
this._debug('Page 2 on');
break;
case LOC.RESET_HIRES:
this._hires = false;
result = this.io.ioSwitch(off, val); result = this.io.ioSwitch(off, val);
} this._debug('Hires off');
break; break;
case LOC._80STOREON:
if (writeMode) {
this._80store = true;
this._debug('80 Store On');
} else
result = 0;
break;
case LOC.RAMRDOFF:
if (writeMode) {
this._auxRamRead = false;
this._debug('Aux RAM Read Off');
} else
result = 0;
break;
case LOC.RAMRDON:
if (writeMode) {
this._auxRamRead = true;
this._debug('Aux RAM Read On');
} else
result = 0;
break;
case LOC.RAMWROFF:
if (writeMode) {
this._auxRamWrite = false;
this._debug('Aux RAM Write Off');
} else
result = 0;
break;
case LOC.RAMWRON:
if (writeMode) {
this._auxRamWrite = true;
this._debug('Aux RAM Write On');
} else
result = 0;
break;
case LOC.INTCXROMOFF: case LOC.DHIRESON:
if (writeMode) { if (this._iouDisable) {
this._intcxrom = false; this.vm.doubleHires(true);
this._intc8rom = false; } else {
this._debug('Int CX ROM Off'); result = this.io.ioSwitch(off, val); // an3
} }
break; break;
case LOC.INTCXROMON:
if (writeMode) {
this._intcxrom = true;
this._debug('Int CX ROM On');
}
break;
case LOC.ALTZPOFF: // 0x08
if (writeMode) {
this._altzp = false;
this._debug('Alt ZP Off');
}
break;
case LOC.ALTZPON: // 0x09
if (writeMode) {
this._altzp = true;
this._debug('Alt ZP On');
}
break;
case LOC.SLOTC3ROMOFF: // 0x0A
if (writeMode) {
this._slot3rom = false;
this._debug('Slot 3 ROM Off');
}
break;
case LOC.SLOTC3ROMON: // 0x0B
if (writeMode) {
this._slot3rom = true;
this._debug('Slot 3 ROM On');
}
break;
// Graphics Switches case LOC.DHIRESOFF:
if (this._iouDisable) {
this.vm.doubleHires(false);
} else {
result = this.io.ioSwitch(off, val); // an3
}
break;
case LOC.CLR80VID: case LOC.SET_HIRES:
if (writeMode) { this._hires = true;
this._debug('80 Column Mode off');
this.vm._80col(false);
}
break;
case LOC.SET80VID:
if (writeMode) {
this._debug('80 Column Mode on');
this.vm._80col(true);
}
break;
case LOC.CLRALTCH:
if (writeMode) {
this._debug('Alt Char off');
this.vm.altchar(false);
}
break;
case LOC.SETALTCH:
if (writeMode) {
this._debug('Alt Char on');
this.vm.altchar(true);
}
break;
case LOC.PAGE1:
this._page2 = false;
if (!this._80store) {
result = this.io.ioSwitch(off, val); result = this.io.ioSwitch(off, val);
} this._debug('Hires on');
this._debug('Page 2 off'); break;
break;
case LOC.PAGE2:
this._page2 = true;
if (!this._80store) {
result = this.io.ioSwitch(off, val);
}
this._debug('Page 2 on');
break;
case LOC.RESET_HIRES: case LOC.IOUDISON:
this._hires = false; if (writeMode) {
result = this.io.ioSwitch(off, val); this._iouDisable = true;
this._debug('Hires off'); }
break; result = this._iouDisable ? 0x00 : 0x80;
break;
case LOC.DHIRESON: case LOC.IOUDISOFF:
if (this._iouDisable) { if (writeMode) {
this.vm.doubleHires(true); this._iouDisable = false;
} else { }
result = this.io.ioSwitch(off, val); // an3 result = this.vm.isDoubleHires() ? 0x80 : 0x00;
} break;
break;
case LOC.DHIRESOFF: // Language Card Switches
if (this._iouDisable) {
this.vm.doubleHires(false);
} else {
result = this.io.ioSwitch(off, val); // an3
}
break;
case LOC.SET_HIRES: case LOC.READBSR2: // 0xC080
this._hires = true; case LOC._READBSR2: // 0xC084
result = this.io.ioSwitch(off, val); this._bank1 = false;
this._debug('Hires on'); this._readbsr = true;
break; this._writebsr = false;
this._prewrite = false;
// _debug('Bank 2 Read');
break;
case LOC.WRITEBSR2: // 0xC081
case LOC._WRITEBSR2: // 0xC085
this._bank1 = false;
this._readbsr = false;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
// _debug('Bank 2 Write');
break;
case LOC.OFFBSR2: // 0xC082
case LOC._OFFBSR2: // 0xC086
this._bank1 = false;
this._readbsr = false;
this._writebsr = false;
this._prewrite = false;
// _debug('Bank 2 Off');
break;
case LOC.READWRBSR2: // 0xC083
case LOC._READWRBSR2: // 0xC087
this._bank1 = false;
this._readbsr = true;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
// _debug('Bank 2 Read/Write');
break;
case LOC.READBSR1: // 0xC088
case LOC._READBSR1: // 0xC08c
this._bank1 = true;
this._readbsr = true;
this._writebsr = false;
this._prewrite = false;
// _debug('Bank 1 Read');
break;
case LOC.WRITEBSR1: // 0xC089
case LOC._WRITEBSR1: // 0xC08D
this._bank1 = true;
this._readbsr = false;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
// _debug('Bank 1 Write');
break;
case LOC.OFFBSR1: // 0xC08A
case LOC._OFFBSR1: // 0xC08E
this._bank1 = true;
this._readbsr = false;
this._writebsr = false;
this._prewrite = false;
// _debug('Bank 1 Off');
break;
case LOC.READWRBSR1: // 0xC08B
case LOC._READWRBSR1: // 0xC08F
this._bank1 = true;
this._readbsr = true;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
//_debug('Bank 1 Read/Write');
break;
case LOC.IOUDISON: // Status registers
if (writeMode) {
this._iouDisable = true;
}
result = this._iouDisable ? 0x00 : 0x80;
break;
case LOC.IOUDISOFF: case LOC.BSRBANK2:
if (writeMode) { this._debug('Bank 2 Read ' + !this._bank1);
this._iouDisable = false; result = !this._bank1 ? 0x80 : 0x00;
} break;
result = this.vm.isDoubleHires() ? 0x80 : 0x00; case LOC.BSRREADRAM:
break; this._debug('Bank SW RAM Read ' + this._readbsr);
result = this._readbsr ? 0x80 : 0x00;
// Language Card Switches break;
case LOC.RAMRD: // 0xC013
case LOC.READBSR2: // 0xC080 this._debug('Aux RAM Read ' + this._auxRamRead);
case LOC._READBSR2: // 0xC084 result = this._auxRamRead ? 0x80 : 0x0;
this._bank1 = false; break;
this._readbsr = true; case LOC.RAMWRT: // 0xC014
this._writebsr = false; this._debug('Aux RAM Write ' + this._auxRamWrite);
this._prewrite = false; result = this._auxRamWrite ? 0x80 : 0x0;
// _debug('Bank 2 Read'); break;
break; case LOC.INTCXROM: // 0xC015
case LOC.WRITEBSR2: // 0xC081
case LOC._WRITEBSR2: // 0xC085
this._bank1 = false;
this._readbsr = false;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
// _debug('Bank 2 Write');
break;
case LOC.OFFBSR2: // 0xC082
case LOC._OFFBSR2: // 0xC086
this._bank1 = false;
this._readbsr = false;
this._writebsr = false;
this._prewrite = false;
// _debug('Bank 2 Off');
break;
case LOC.READWRBSR2: // 0xC083
case LOC._READWRBSR2: // 0xC087
this._bank1 = false;
this._readbsr = true;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
// _debug('Bank 2 Read/Write');
break;
case LOC.READBSR1: // 0xC088
case LOC._READBSR1: // 0xC08c
this._bank1 = true;
this._readbsr = true;
this._writebsr = false;
this._prewrite = false;
// _debug('Bank 1 Read');
break;
case LOC.WRITEBSR1: // 0xC089
case LOC._WRITEBSR1: // 0xC08D
this._bank1 = true;
this._readbsr = false;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
// _debug('Bank 1 Write');
break;
case LOC.OFFBSR1: // 0xC08A
case LOC._OFFBSR1: // 0xC08E
this._bank1 = true;
this._readbsr = false;
this._writebsr = false;
this._prewrite = false;
// _debug('Bank 1 Off');
break;
case LOC.READWRBSR1: // 0xC08B
case LOC._READWRBSR1: // 0xC08F
this._bank1 = true;
this._readbsr = true;
if (readMode) { this._writebsr = this._prewrite; }
this._prewrite = readMode;
//_debug('Bank 1 Read/Write');
break;
// Status registers
case LOC.BSRBANK2:
this._debug('Bank 2 Read ' + !this._bank1);
result = !this._bank1 ? 0x80 : 0x00;
break;
case LOC.BSRREADRAM:
this._debug('Bank SW RAM Read ' + this._readbsr);
result = this._readbsr ? 0x80 : 0x00;
break;
case LOC.RAMRD: // 0xC013
this._debug('Aux RAM Read ' + this._auxRamRead);
result = this._auxRamRead ? 0x80 : 0x0;
break;
case LOC.RAMWRT: // 0xC014
this._debug('Aux RAM Write ' + this._auxRamWrite);
result = this._auxRamWrite ? 0x80 : 0x0;
break;
case LOC.INTCXROM: // 0xC015
// _debug('Int CX ROM ' + _intcxrom); // _debug('Int CX ROM ' + _intcxrom);
result = this._intcxrom ? 0x80 : 0x00; result = this._intcxrom ? 0x80 : 0x00;
break; break;
case LOC.ALTZP: // 0xC016 case LOC.ALTZP: // 0xC016
this._debug('Alt ZP ' + this._altzp); this._debug('Alt ZP ' + this._altzp);
result = this._altzp ? 0x80 : 0x0; result = this._altzp ? 0x80 : 0x0;
break; break;
case LOC.SLOTC3ROM: // 0xC017 case LOC.SLOTC3ROM: // 0xC017
this._debug('Slot C3 ROM ' + this._slot3rom); this._debug('Slot C3 ROM ' + this._slot3rom);
result = this._slot3rom ? 0x80 : 0x00; result = this._slot3rom ? 0x80 : 0x00;
break; break;
case LOC._80STORE: // 0xC018 case LOC._80STORE: // 0xC018
this._debug('80 Store ' + this._80store); this._debug('80 Store ' + this._80store);
result = this._80store ? 0x80 : 0x00; result = this._80store ? 0x80 : 0x00;
break; break;
case LOC.VERTBLANK: // 0xC019 case LOC.VERTBLANK: // 0xC019
// result = cpu.getCycles() % 20 < 5 ? 0x80 : 0x00; // result = cpu.getCycles() % 20 < 5 ? 0x80 : 0x00;
result = (this.cpu.getCycles() < this._vbEnd) ? 0x80 : 0x00; result = (this.cpu.getCycles() < this._vbEnd) ? 0x80 : 0x00;
break; break;
case LOC.RDTEXT: case LOC.RDTEXT:
result = this.vm.isText() ? 0x80 : 0x0; result = this.vm.isText() ? 0x80 : 0x0;
break; break;
case LOC.RDMIXED: case LOC.RDMIXED:
result = this.vm.isMixed() ? 0x80 : 0x0; result = this.vm.isMixed() ? 0x80 : 0x0;
break; break;
case LOC.RDPAGE2: case LOC.RDPAGE2:
result = this.vm.isPage2() ? 0x80 : 0x0; result = this.vm.isPage2() ? 0x80 : 0x0;
break; break;
case LOC.RDHIRES: case LOC.RDHIRES:
result = this.vm.isHires() ? 0x80 : 0x0; result = this.vm.isHires() ? 0x80 : 0x0;
break; break;
case LOC.RD80VID: case LOC.RD80VID:
result = this.vm.is80Col() ? 0x80 : 0x0; result = this.vm.is80Col() ? 0x80 : 0x0;
break; break;
case LOC.RDALTCH: case LOC.RDALTCH:
result = this.vm.isAltChar() ? 0x80 : 0x0; result = this.vm.isAltChar() ? 0x80 : 0x0;
break; break;
default: default:
debug('MMU missing register ' + toHex(off)); debug('MMU missing register ' + toHex(off));
break; break;
} }
if (result !== undefined) if (result !== undefined)

View File

@ -362,23 +362,23 @@ export function updateKHz() {
var khz; var khz;
switch (showStats) { switch (showStats) {
case 0: { case 0: {
delta = cycles - lastCycles; delta = cycles - lastCycles;
khz = parseInt(delta/ms); khz = parseInt(delta/ms);
document.querySelector('#khz').innerText = khz + ' kHz'; document.querySelector('#khz').innerText = khz + ' kHz';
break; break;
} }
case 1: { case 1: {
delta = stats.renderedFrames - lastRenderedFrames; delta = stats.renderedFrames - lastRenderedFrames;
fps = parseInt(delta/(ms/1000), 10); fps = parseInt(delta/(ms/1000), 10);
document.querySelector('#khz').innerText = fps + ' rps'; document.querySelector('#khz').innerText = fps + ' rps';
break; break;
} }
default: { default: {
delta = stats.frames - lastFrames; delta = stats.frames - lastFrames;
fps = parseInt(delta/(ms/1000), 10); fps = parseInt(delta/(ms/1000), 10);
document.querySelector('#khz').innerText = fps + ' fps'; document.querySelector('#khz').innerText = fps + ' fps';
} }
} }
startTime = now; startTime = now;

View File

@ -338,68 +338,68 @@ export default function KeyBoard(cpu, io, e) {
this.classList.add('pressed'); this.classList.add('pressed');
var key = this.dataset[shifted ? 'key2' : 'key1']; var key = this.dataset[shifted ? 'key2' : 'key1'];
switch (key) { switch (key) {
case 'BELL': case 'BELL':
key = 'G'; key = 'G';
break; break;
case 'RETURN': case 'RETURN':
key = '\r'; key = '\r';
break; break;
case 'TAB': case 'TAB':
key = '\t'; key = '\t';
break; break;
case 'DELETE': case 'DELETE':
key = '\x7F'; key = '\x7F';
break; break;
case '&larr;': case '&larr;':
key = '\x08'; key = '\x08';
break; break;
case '&rarr;': case '&rarr;':
key = '\x15'; key = '\x15';
break; break;
case '&darr;': case '&darr;':
key = '\x0A'; key = '\x0A';
break; break;
case '&uarr;': case '&uarr;':
key = '\x0B'; key = '\x0B';
break; break;
case '&nbsp;': case '&nbsp;':
key = ' '; key = ' ';
break; break;
case 'ESC': case 'ESC':
key = '\x1B'; key = '\x1B';
break; break;
default: default:
break; break;
} }
if (key.length > 1) { if (key.length > 1) {
switch (key) { switch (key) {
case 'SHIFT': case 'SHIFT':
self.shiftKey(!shifted); self.shiftKey(!shifted);
break; break;
case 'CTRL': case 'CTRL':
self.controlKey(!controlled); self.controlKey(!controlled);
break; break;
case 'CAPS': case 'CAPS':
case 'LOCK': case 'LOCK':
self.capslockKey(undefined); self.capslockKey(undefined);
break; break;
case 'POW': case 'POW':
case 'POWER': case 'POWER':
if (window.confirm('Power Cycle?')) if (window.confirm('Power Cycle?'))
window.location.reload(); window.location.reload();
break; break;
case 'RESET': case 'RESET':
cpu.reset(); cpu.reset();
break; break;
case 'OPEN_APPLE': case 'OPEN_APPLE':
self.commandKey(!commanded); self.commandKey(!commanded);
break; break;
case 'CLOSED_APPLE': case 'CLOSED_APPLE':
self.optionKey(!optioned); self.optionKey(!optioned);
break; break;
default: default:
break; break;
} }
} else { } else {
if (controlled && key >= '@' && key <= '_') { if (controlled && key >= '@' && key <= '_') {