Cleanup and refactor I/O behavior.

This commit is contained in:
Will Scullin 2016-12-05 21:16:21 -08:00 committed by Will Scullin
parent e021c692ce
commit 0e80761a4d
14 changed files with 159 additions and 191 deletions

View File

@ -94,7 +94,7 @@ function Apple2IO(cpu, callbacks)
}; };
function _debug() { function _debug() {
debug.apply(arguments); // debug.apply(this, arguments);
} }
function _tick() { function _tick() {
@ -302,6 +302,7 @@ function Apple2IO(cpu, callbacks)
start: function apple2io_start() { start: function apple2io_start() {
return 0xc0; return 0xc0;
}, },
end: function apple2io_end() { end: function apple2io_end() {
return 0xcf; return 0xcf;
}, },
@ -312,17 +313,29 @@ function Apple2IO(cpu, callbacks)
result = _access(off, val); result = _access(off, val);
} else { } else {
var slot = (off & 0x70) >> 4; var slot = (off & 0x70) >> 4;
if (_slot[slot]) { var card = _slot[slot];
result = _slot[slot].ioSwitch(off, val); if (card && card.ioSwitch) {
result = card.ioSwitch(off, val);
} }
} }
return result; return result;
}, },
reset: function apple2io_reset() {
for (var slot = 0; slot < 8; slot++) {
var card = _slot[slot];
if (card && card.reset) {
card.reset();
}
}
},
read: function apple2io_read(page, off) { read: function apple2io_read(page, off) {
var result = 0; var result = 0;
var slot; var slot;
var card;
switch (page) { switch (page) {
case 0xc0: case 0xc0:
result = this.ioSwitch(off); result = this.ioSwitch(off);
@ -335,9 +348,13 @@ function Apple2IO(cpu, callbacks)
case 0xc6: case 0xc6:
case 0xc7: case 0xc7:
slot = page & 0x0f; slot = page & 0x0f;
_auxRom = _slot[slot]; card = _slot[slot];
if (_slot[slot]) { if (_auxRom != card) {
result = _slot[slot].read(page, off); // _debug('Setting auxRom to slot', slot);
_auxRom = card;
}
if (card) {
result = card.read(page, off);
} }
break; break;
default: default:
@ -351,6 +368,8 @@ function Apple2IO(cpu, callbacks)
write: function apple2io_write(page, off, val) { write: function apple2io_write(page, off, val) {
var slot; var slot;
var card;
switch (page) { switch (page) {
case 0xc0: case 0xc0:
this.ioSwitch(off); this.ioSwitch(off);
@ -363,9 +382,13 @@ function Apple2IO(cpu, callbacks)
case 0xc6: case 0xc6:
case 0xc7: case 0xc7:
slot = page & 0x0f; slot = page & 0x0f;
_auxRom = _slot[slot]; card = _slot[slot];
if (_slot[slot]) { if (_auxRom != card) {
_slot[slot].write(page, off, val); // _debug('Setting auxRom to slot', slot);
_auxRom = card;
}
if (card) {
card.write(page, off, val);
} }
break; break;
default: default:
@ -379,7 +402,7 @@ function Apple2IO(cpu, callbacks)
getState: function apple2io_getState() { return {}; }, getState: function apple2io_getState() { return {}; },
setState: function apple2io_setState() { }, setState: function apple2io_setState() { },
addSlot: function apple2io_addSlot(slot, card) { setSlot: function apple2io_setSlot(slot, card) {
_slot[slot] = card; _slot[slot] = card;
}, },

View File

@ -9,13 +9,9 @@
* implied warranty. * implied warranty.
*/ */
/* /*globals allocMemPages: false,
* Text Page 1 Drawing base64_encode: false, base64_decode: false */
*/ /*exported LoresPage, HiresPage, VideoModes*/
/*globals allocMemPages: false,
base64_encode: false, base64_decode: false */
/*exported LoresPage, HiresPage, VideoModes*/
var textMode = true; var textMode = true;
var mixedMode = true; var mixedMode = true;
@ -486,6 +482,10 @@ function VideoModes(gr,hgr,gr2,hgr2) {
_grs[1].green(on); _grs[1].green(on);
_hgrs[0].green(on); _hgrs[0].green(on);
_hgrs[1].green(on); _hgrs[1].green(on);
},
scanlines: function(on) {
scanlines = on;
_refresh();
} }
}; };
} }

View File

@ -15,7 +15,6 @@
enhanced: false */ enhanced: false */
/*exported LoresPage, HiresPage, VideoModes */ /*exported LoresPage, HiresPage, VideoModes */
var textMode = true; var textMode = true;
var mixedMode = false; var mixedMode = false;
var hiresMode = false; var hiresMode = false;
@ -586,7 +585,7 @@ function HiresPage(page)
b2 & 0x80, // 4 b2 & 0x80, // 4
b3 & 0x80, // 5 b3 & 0x80, // 5
b3 & 0x80, // 6 b3 & 0x80, // 6
0]; // 7 0]; // 7
if (col > 0) { if (col > 0) {
c[0] = (bz & 0x78) >> 3; c[0] = (bz & 0x78) >> 3;
hb[0] = bz & 0x80; hb[0] = bz & 0x80;
@ -948,6 +947,10 @@ function VideoModes(gr,hgr,gr2,hgr2) {
_grs[1].green(on); _grs[1].green(on);
_hgrs[0].green(on); _hgrs[0].green(on);
_hgrs[1].green(on); _hgrs[1].green(on);
},
scanlines: function(on) {
scanlines = on;
_refresh();
} }
}; };
} }

View File

@ -10,7 +10,7 @@
*/ */
/*exported DiskII */ /*exported DiskII */
/*globals bytify: false, each: false, extend: false, debug: false /*globals bytify: false, debug: false
base64_decode: false, base64_encode: false base64_decode: false, base64_encode: false
Uint8Array: false Uint8Array: false
*/ */
@ -112,9 +112,6 @@ function DiskII(io, slot, callbacks)
function _init() { function _init() {
debug('Disk ][ in slot', slot); debug('Disk ][ in slot', slot);
each(LOC, function(key) {
LOC[key] += slot * 0x10;
});
} }
/** /**
@ -162,12 +159,12 @@ function DiskII(io, slot, callbacks)
*/ */
checksum = volume ^ track ^ sector; checksum = volume ^ track ^ sector;
extend(buf, [0xd5, 0xaa, 0x96]); // Address Prolog D5 AA 96 buf = buf.concat([0xd5, 0xaa, 0x96]); // Address Prolog D5 AA 96
extend(buf, _fourXfour(volume)); buf = buf.concat(_fourXfour(volume));
extend(buf, _fourXfour(track)); buf = buf.concat(_fourXfour(track));
extend(buf, _fourXfour(sector)); buf = buf.concat(_fourXfour(sector));
extend(buf, _fourXfour(checksum)); buf = buf.concat(_fourXfour(checksum));
extend(buf, [0xde, 0xaa, 0xeb]); // Epilog DE AA EB buf = buf.concat([0xde, 0xaa, 0xeb]); // Epilog DE AA EB
/* /*
* Gap 2 (5 bytes) * Gap 2 (5 bytes)
@ -181,7 +178,7 @@ function DiskII(io, slot, callbacks)
* Data Field * Data Field
*/ */
extend(buf, [0xd5, 0xaa, 0xad]); // Data Prolog D5 AA AD buf = buf.concat([0xd5, 0xaa, 0xad]); // Data Prolog D5 AA AD
var nibbles = []; var nibbles = [];
var ptr2 = 0; var ptr2 = 0;
@ -217,7 +214,7 @@ function DiskII(io, slot, callbacks)
} }
buf.push(_trans[last]); buf.push(_trans[last]);
extend(buf, [0xde, 0xaa, 0xeb]); // Epilog DE AA EB buf = buf.concat([0xde, 0xaa, 0xeb]); // Epilog DE AA EB
/* /*
* Gap 3 * Gap 3
@ -261,7 +258,7 @@ function DiskII(io, slot, callbacks)
for (var s = 0; s < json.data[t].length; s++) { for (var s = 0; s < json.data[t].length; s++) {
var _s = 15 - s; var _s = 15 - s;
var d = base64_decode(json.data[t][_s]); var d = base64_decode(json.data[t][_s]);
extend(track, _explodeSector(v, t, _DO[_s], d)); track = track.concat(_explodeSector(v, t, _DO[_s], d));
} }
tracks[t] = bytify(track); tracks[t] = bytify(track);
} }
@ -410,7 +407,7 @@ function DiskII(io, slot, callbacks)
function _access(off, val) { function _access(off, val) {
var result = 0; var result = 0;
switch (off) { switch (off & 0x8f) {
case LOC.PHASE0OFF: case LOC.PHASE0OFF:
setPhase(0, false); setPhase(0, false);
break; break;
@ -570,14 +567,6 @@ function DiskII(io, slot, callbacks)
_init(); _init();
return { return {
start: function disk2_start() {
return 0xc0 + slot;
},
end: function disk2_end() {
return 0xc0 + slot;
},
ioSwitch: function disk2_ioSwitch(off, val) { ioSwitch: function disk2_ioSwitch(off, val) {
return _access(off, val); return _access(off, val);
}, },
@ -697,14 +686,17 @@ function DiskII(io, slot, callbacks)
for (s = 0; s < data[t].length; s++) { for (s = 0; s < data[t].length; s++) {
var _s = 15 - s; var _s = 15 - s;
if (fmt === 'po') { // ProDOS Order if (fmt === 'po') { // ProDOS Order
extend(track, track = track.concat(
_explodeSector(v, t, _PO[s], data[t][s])); _explodeSector(v, t, _PO[s], data[t][s])
);
} else if (fmt === 'dsk') { // DOS Order } else if (fmt === 'dsk') { // DOS Order
extend(track, track = track.concat(
_explodeSector(v, t, _DO[_s], data[t][_s])); _explodeSector(v, t, _DO[_s], data[t][_s])
);
} else { // flat } else { // flat
extend(track, track = track.concat(
_explodeSector(v, t, s, data[t][s])); _explodeSector(v, t, s, data[t][s])
);
} }
} }
} }
@ -771,13 +763,15 @@ function DiskII(io, slot, callbacks)
if (fmt == 'po') { // ProDOS Order if (fmt == 'po') { // ProDOS Order
off = (16 * t + s) * 256; off = (16 * t + s) * 256;
d = new Uint8Array(data.slice(off, off + 256)); d = new Uint8Array(data.slice(off, off + 256));
extend(track, track = track.concat(
_explodeSector(v, t, _PO[s], d)); _explodeSector(v, t, _PO[s], d)
);
} else if (fmt == 'dsk') { // DOS Order } else if (fmt == 'dsk') { // DOS Order
off = (16 * t + _s) * 256; off = (16 * t + _s) * 256;
d = new Uint8Array(data.slice(off, off + 256)); d = new Uint8Array(data.slice(off, off + 256));
extend(track, track = track.concat(
_explodeSector(v, t, _DO[_s], d)); _explodeSector(v, t, _DO[_s], d)
);
} else { } else {
return false; return false;
} }

View File

@ -5,8 +5,7 @@
apple2_charset: false, apple2_charset: false,
Apple2IO: false Apple2IO: false
LoresPage: false, HiresPage: false, VideoModes: false LoresPage: false, HiresPage: false, VideoModes: false
scanlines: true, KeyBoard2: false,
KeyBoard: false,
Parallel: false, Parallel: false,
DiskII: false, DiskII: false,
Printer: false, Printer: false,
@ -376,7 +375,7 @@ var dumper = new ApplesoftDump(cpu);
var drivelights = new DriveLights(); var drivelights = new DriveLights();
var io = new Apple2IO(cpu, vm); var io = new Apple2IO(cpu, vm);
var keyboard = new KeyBoard(io); var keyboard = new KeyBoard2(io);
var lc = new LanguageCard(io, 0, rom); var lc = new LanguageCard(io, 0, rom);
var parallel = new Parallel(io, 1, new Printer()); var parallel = new Parallel(io, 1, new Printer());
var slinky = new RAMFactor(io, 2, 1024 * 1024); var slinky = new RAMFactor(io, 2, 1024 * 1024);
@ -393,11 +392,11 @@ cpu.addPageHandler(ram3);
cpu.addPageHandler(io); cpu.addPageHandler(io);
cpu.addPageHandler(lc); cpu.addPageHandler(lc);
io.addSlot(0, lc); io.setSlot(0, lc);
io.addSlot(1, parallel); io.setSlot(1, parallel);
io.addSlot(2, slinky); io.setSlot(2, slinky);
io.addSlot(6, disk2); io.setSlot(6, disk2);
io.addSlot(7, clock); io.setSlot(7, clock);
var showFPS = false; var showFPS = false;
@ -805,8 +804,9 @@ function _keyup(evt) {
function updateScreen() { function updateScreen() {
var green = $('#green_screen').prop('checked'); var green = $('#green_screen').prop('checked');
scanlines = $('#show_scanlines').prop('checked'); var scanlines = $('#show_scanlines').prop('checked');
vm.scanlines(scanlines);
vm.green(green); vm.green(green);
} }

View File

@ -4,13 +4,11 @@
apple2e_charset: false, apple2e_charset: false,
Apple2IO: false Apple2IO: false
LoresPage: false, HiresPage: false, VideoModes: false, LoresPage: false, HiresPage: false, VideoModes: false,
scanlines: true, KeyBoard2e: false,
KeyBoard: false,
Parallel: false, Parallel: false,
DiskII: false, DiskII: false,
Printer: false, Printer: false,
MMU: false, MMU: false,
Slot3: false,
RAMFactor: false, RAMFactor: false,
Thunderclock: false, Thunderclock: false,
Prefs: false, Prefs: false,
@ -371,7 +369,7 @@ var dumper = new ApplesoftDump(cpu);
var drivelights = new DriveLights(); var drivelights = new DriveLights();
var io = new Apple2IO(cpu, vm); var io = new Apple2IO(cpu, vm);
var keyboard = new KeyBoard(io); var keyboard = new KeyBoard2e(io);
var mmu = new MMU(cpu, gr, gr2, hgr, hgr2, io, rom); var mmu = new MMU(cpu, gr, gr2, hgr, hgr2, io, rom);
@ -379,15 +377,13 @@ cpu.addPageHandler(mmu);
var parallel = new Parallel(io, 1, new Printer()); var parallel = new Parallel(io, 1, new Printer());
var slinky = new RAMFactor(io, 2, 1024 * 1024); var slinky = new RAMFactor(io, 2, 1024 * 1024);
var slot3 = new Slot3(io, 3, rom);
var disk2 = new DiskII(io, 6, drivelights); var disk2 = new DiskII(io, 6, drivelights);
var clock = new Thunderclock(io, 7); var clock = new Thunderclock(io, 7);
io.addSlot(1, parallel); io.setSlot(1, parallel);
io.addSlot(2, slinky); io.setSlot(2, slinky);
io.addSlot(3, slot3); io.setSlot(6, disk2);
io.addSlot(6, disk2); io.setSlot(7, clock);
io.addSlot(7, clock);
var showFPS = false; var showFPS = false;
@ -798,9 +794,10 @@ function _keyup(evt) {
function updateScreen() { function updateScreen() {
var green = $('#green_screen').prop('checked'); var green = $('#green_screen').prop('checked');
scanlines = $('#show_scanlines').prop('checked'); var scanlines = $('#show_scanlines').prop('checked');
vm.green(green); vm.green(green);
vm.scanlines(scanlines);
} }
var disableMouseJoystick = false; var disableMouseJoystick = false;

118
js/mmu.js
View File

@ -125,7 +125,7 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
} }
function _debug() { function _debug() {
debug.apply(arguments); // debug.apply(this, arguments);
} }
var _last = 0x00; var _last = 0x00;
@ -167,20 +167,8 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
function AuxRom() { function AuxRom() {
return { return {
start: function() {
return 0xC1;
},
end: function() {
return 0xCF;
},
read: function(page, off) { read: function(page, off) {
var result; return rom.read(page, off);
if (page == 0xc3) {
result = io.read(page, off);
} else {
result = rom.read(page, off);
}
return result;
}, },
write: function() {} write: function() {}
}; };
@ -204,6 +192,8 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
new RAM(0xD0,0xDF), new RAM(0xD0,0xDF)]; new RAM(0xD0,0xDF), new RAM(0xD0,0xDF)];
var memE0_FF = [rom, new RAM(0xE0,0xFF), new RAM(0xE0,0xFF)]; var memE0_FF = [rom, new RAM(0xE0,0xFF), new RAM(0xE0,0xFF)];
io.setSlot(3, auxRom);
/* /*
* Initialize read/write banks * Initialize read/write banks
*/ */
@ -335,11 +325,6 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
for (idx = 0xc1; idx < 0xd0; idx++) { for (idx = 0xc1; idx < 0xd0; idx++) {
_readPages[idx] = _pages[idx][0]; _readPages[idx] = _pages[idx][0];
} }
if (_slot3rom) {
_readPages[0xc3] = _pages[0xc3][1];
} else {
_readPages[0xc3] = _pages[0xc3][0];
}
} }
if (_altzp) { if (_altzp) {
@ -404,84 +389,84 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
// Apple //e memory management // Apple //e memory management
case LOC._80STOREOFF: case LOC._80STOREOFF:
if (typeof val != 'undefined') { if (val !== undefined) {
_80store = false; _80store = false;
// _debug("80 Store Off"); // _debug('80 Store Off');
} else { } else {
// Chain to io for keyboard // Chain to io for keyboard
result = io.ioSwitch(off, val); result = io.ioSwitch(off, val);
} }
break; break;
case LOC._80STOREON: case LOC._80STOREON:
if (typeof val != 'undefined') { if (val !== undefined) {
_80store = true; _80store = true;
// _debug("80 Store On"); // _debug('80 Store On');
} else } else
result = 0; result = 0;
break; break;
case LOC.RAMRDOFF: case LOC.RAMRDOFF:
if (typeof val != 'undefined') { if (val !== undefined) {
_auxRamRead = false; _auxRamRead = false;
_debug("Aux RAM Read Off"); _debug('Aux RAM Read Off');
} else } else
result = 0; result = 0;
break; break;
case LOC.RAMRDON: case LOC.RAMRDON:
if (typeof val != 'undefined') { if (val !== undefined) {
_auxRamRead = true; _auxRamRead = true;
_debug("Aux RAM Read On"); _debug('Aux RAM Read On');
} else } else
result = 0; result = 0;
break; break;
case LOC.RAMWROFF: case LOC.RAMWROFF:
if (typeof val != 'undefined') { if (val !== undefined) {
_auxRamWrite = false; _auxRamWrite = false;
_debug("Aux RAM Write Off"); _debug('Aux RAM Write Off');
} else } else
result = 0; result = 0;
break; break;
case LOC.RAMWRON: case LOC.RAMWRON:
if (typeof val != 'undefined') { if (val !== undefined) {
_auxRamWrite = true; _auxRamWrite = true;
_debug("Aux RAM Write On"); _debug('Aux RAM Write On');
} else } else
result = 0; result = 0;
break; break;
case LOC.INTCXROMOFF: case LOC.INTCXROMOFF:
if (typeof val != 'undefined') { if (val !== undefined) {
_intcxrom = false; _intcxrom = false;
// _debug("Int CX ROM Off"); // _debug('Int CX ROM Off');
} }
break; break;
case LOC.INTCXROMON: case LOC.INTCXROMON:
if (typeof val != 'undefined') { if (val !== undefined) {
_intcxrom = true; _intcxrom = true;
// _debug("Int CX ROM On"); // _debug('Int CX ROM On');
} }
break; break;
case LOC.ALTZPOFF: // 0x08 case LOC.ALTZPOFF: // 0x08
if (typeof val != 'undefined') { if (val !== undefined) {
_altzp = false; _altzp = false;
_debug("Alt ZP Off"); _debug('Alt ZP Off');
} }
break; break;
case LOC.ALTZPON: // 0x09 case LOC.ALTZPON: // 0x09
if (typeof val != 'undefined') { if (val !== undefined) {
_altzp = true; _altzp = true;
_debug("Alt ZP On"); _debug('Alt ZP On');
} }
break; break;
case LOC.SLOTC3ROMOFF: case LOC.SLOTC3ROMOFF:
if (typeof val != 'undefined') { if (typeof val != 'undefined') {
_slot3rom = false; _slot3rom = false;
_debug("Slot 3 ROM Off"); _debug('Slot 3 ROM Off');
} }
break; break;
case LOC.SLOTC3ROMON: case LOC.SLOTC3ROMON:
if (typeof val != 'undefined') { if (val !== undefined) {
_slot3rom = true; _slot3rom = true;
_debug("Slot 3 ROM On"); _debug('Slot 3 ROM On');
} }
break; break;
@ -489,11 +474,15 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
case LOC.PAGE1: case LOC.PAGE1:
_page2 = false; _page2 = false;
if (!_80store) result = io.ioSwitch(off, val); if (!_80store) {
result = io.ioSwitch(off, val);
}
break; break;
case LOC.PAGE2: case LOC.PAGE2:
_page2 = true; _page2 = true;
if (!_80store) result = io.ioSwitch(off, val); if (!_80store) {
result = io.ioSwitch(off, val);
}
break; break;
// Language Card Switches // Language Card Switches
@ -503,89 +492,90 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
_bank1 = false; _bank1 = false;
_readbsr = true; _readbsr = true;
_writebsr = false; _writebsr = false;
_debug("Bank 2 Read"); _debug('Bank 2 Read');
break; break;
case LOC.WRITEBSR2: // 0xC081 case LOC.WRITEBSR2: // 0xC081
case LOC._WRITEBSR2: case LOC._WRITEBSR2:
_bank1 = false; _bank1 = false;
_readbsr = false; _readbsr = false;
_writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3)); _writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3));
_debug("Bank 2 Write"); _debug('Bank 2 Write');
break; break;
case LOC.OFFBSR2: // 0xC082 case LOC.OFFBSR2: // 0xC082
case LOC._OFFBSR2: case LOC._OFFBSR2:
_bank1 = false; _bank1 = false;
_readbsr = false; _readbsr = false;
_writebsr = false; _writebsr = false;
_debug("Bank 2 Off"); _debug('Bank 2 Off');
break; break;
case LOC.READWRBSR2: // 0xC083 case LOC.READWRBSR2: // 0xC083
case LOC._READWRBSR2: case LOC._READWRBSR2:
_bank1 = false; _bank1 = false;
_readbsr = true; _readbsr = true;
_writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3)); _writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3));
_debug("Bank 2 Read/Write"); _debug('Bank 2 Read/Write');
break; break;
case LOC.READBSR1: // 0xC088 case LOC.READBSR1: // 0xC088
case LOC._READBSR1: case LOC._READBSR1:
_bank1 = true; _bank1 = true;
_readbsr = true; _readbsr = true;
_writebsr = false; _writebsr = false;
_debug("Bank 1 Read"); _debug('Bank 1 Read');
break; break;
case LOC.WRITEBSR1: // 0xC089 case LOC.WRITEBSR1: // 0xC089
case LOC._WRITEBSR1: case LOC._WRITEBSR1:
_bank1 = true; _bank1 = true;
_readbsr = false; _readbsr = false;
_writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3)); _writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3));
_debug("Bank 1 Write"); _debug('Bank 1 Write');
break; break;
case LOC.OFFBSR1: // 0xC08A case LOC.OFFBSR1: // 0xC08A
case LOC._OFFBSR1: case LOC._OFFBSR1:
_bank1 = true; _bank1 = true;
_readbsr = false; _readbsr = false;
_writebsr = false; _writebsr = false;
_debug("Bank 1 Off"); _debug('Bank 1 Off');
break; break;
case LOC.READWRBSR1: // 0xC08B case LOC.READWRBSR1: // 0xC08B
case LOC._READWRBSR1: case LOC._READWRBSR1:
_bank1 = true; _bank1 = true;
_readbsr = true; _readbsr = true;
_writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3)); _writebsr = _writebsr || ((_last & 0xF3) == (off & 0xF3));
_debug("Bank 1 Read/Write"); _debug('Bank 1 Read/Write');
break; break;
// Status registers // Status registers
case LOC.BSRBANK2: case LOC.BSRBANK2:
_debug("Bank 2 Read " + !_bank1); _debug('Bank 2 Read ' + !_bank1);
result = !_bank1 ? 0x80 : 0x00; result = !_bank1 ? 0x80 : 0x00;
break; break;
case LOC.BSRREADRAM: case LOC.BSRREADRAM:
_debug("Bank SW RAM Read " + _readbsr); _debug('Bank SW RAM Read ' + _readbsr);
result = _readbsr ? 0x80 : 0x00; result = _readbsr ? 0x80 : 0x00;
break; break;
case LOC.RAMRD: // 0xC013 case LOC.RAMRD: // 0xC013
_debug("Aux RAM Read " + _auxRamRead); _debug('Aux RAM Read ' + _auxRamRead);
result = _auxRamRead ? 0x80 : 0x0; result = _auxRamRead ? 0x80 : 0x0;
break; break;
case LOC.RAMWRT: // 0xC014 case LOC.RAMWRT: // 0xC014
_debug("Aux RAM Write " + _auxRamWrite); _debug('Aux RAM Write ' + _auxRamWrite);
result = _auxRamWrite ? 0x80 : 0x0; result = _auxRamWrite ? 0x80 : 0x0;
break; break;
case LOC.INTCXROM: // 0xC015 case LOC.INTCXROM: // 0xC015
// _debug("Int CX ROM " + _intcxrom); // _debug('Int CX ROM ' + _intcxrom);
result = _intcxrom ? 0x80 : 0x00; result = _intcxrom ? 0x80 : 0x00;
break; break;
case LOC.ALTZP: // 0xC016 case LOC.ALTZP: // 0xC016
_debug("Alt ZP " + _altzp); _debug('Alt ZP ' + _altzp);
result = _altzp ? 0x80 : 0x0; result = _altzp ? 0x80 : 0x0;
break; break;
case LOC.SLOTC3ROM: // 0xC017 case LOC.SLOTC3ROM: // 0xC017
_debug("Slot C3 ROM " + _slot3rom); _debug('Slot C3 ROM ' + _slot3rom);
result = _slot3rom ? 0x00 : 0x80; result = _slot3rom ? 0x80 : 0x00;
break; break;
case LOC._80STORE: // 0xC018 case LOC._80STORE: // 0xC018
_debug('80 Store ' + _80store);
result = _80store ? 0x80 : 0x00; result = _80store ? 0x80 : 0x00;
break; break;
case LOC.VERTBLANK: // 0xC019 case LOC.VERTBLANK: // 0xC019
@ -594,7 +584,7 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
break; break;
default: default:
debug("MMU missing register " + toHex(off)); debug('MMU missing register ' + toHex(off));
break; break;
} }
_last = off; _last = off;
@ -622,13 +612,9 @@ function MMU(cpu, lores1, lores2, hires1, hires2, io, rom)
return 0xff; return 0xff;
}, },
reset: function() { reset: function() {
debug('reset');
_initSwitches(); _initSwitches();
_updateBanks(); _updateBanks();
for (idx = 0xc1; idx < 0xc8; idx++) {
if ('reset' in _pages[idx][0]) {
_pages[idx][0].reset();
}
}
}, },
read: function mmu_read(page, off, debug) { read: function mmu_read(page, off, debug) {
return _readPages[page].read(page, off, debug); return _readPages[page].read(page, off, debug);

View File

@ -58,21 +58,17 @@ function Parallel(io, slot, cbs) {
0xff,0xf0,0x03,0xfe,0x38,0x07,0x70,0x84 0xff,0xf0,0x03,0xfe,0x38,0x07,0x70,0x84
]; ];
LOC.IOREG += 0x10 * slot;
function _access(off, val) { function _access(off, val) {
if (off == LOC.IOREG && val && 'putChar' in cbs) { switch (off) {
cbs.putChar(val); case LOC.IOREG:
if (val && 'putChar' in cbs) {
cbs.putChar(val);
}
break;
} }
} }
return { return {
start: function() {
return 0xc0 + slot;
},
end: function() {
return 0xc0 + slot;
},
ioSwitch: function (off, val) { ioSwitch: function (off, val) {
return _access(off, val); return _access(off, val);
}, },

View File

@ -10,7 +10,7 @@
*/ */
/*exported RAMFactor */ /*exported RAMFactor */
/*globals allocMem: false, bytify: false, debug: false, each: false, /*globals allocMem: false, bytify: false, debug: false,
base64_encode: false, base64_decode: false base64_encode: false, base64_decode: false
*/ */
function RAMFactor(io, slot, size) { function RAMFactor(io, slot, size) {
@ -1068,9 +1068,6 @@ function RAMFactor(io, slot, size) {
function _init() { function _init() {
debug('RAMFactor card in slot', slot); debug('RAMFactor card in slot', slot);
each(LOC, function(key) {
LOC[key] += slot * 0x10;
});
mem = allocMem(size); mem = allocMem(size);
for (var off = 0; off < size; off++) { for (var off = 0; off < size; off++) {
mem[off] = 0; mem[off] = 0;
@ -1098,7 +1095,7 @@ function RAMFactor(io, slot, size) {
function _access(off, val) { function _access(off, val) {
var result = 0; var result = 0;
switch (off) { switch (off & 0x8f) {
case LOC.RAMLO: case LOC.RAMLO:
case LOC._RAMLO: case LOC._RAMLO:
if (val !== undefined) { if (val !== undefined) {
@ -1159,13 +1156,6 @@ function RAMFactor(io, slot, size) {
_init(); _init();
return { return {
start: function ramfactor_start() {
io.registerSwitches(this, LOC);
return 0xc0 + slot;
},
end: function ramfactor_end() {
return 0xc0 + slot;
},
ioSwitch: function (off, val) { ioSwitch: function (off, val) {
return _access(off, val); return _access(off, val);
}, },

View File

@ -10,7 +10,7 @@
*/ */
/*exported Thunderclock */ /*exported Thunderclock */
/*global debug: false, each: false */ /*global debug: false */
function Thunderclock(io, slot) function Thunderclock(io, slot)
{ {
@ -288,10 +288,6 @@ function Thunderclock(io, slot)
function _init() { function _init() {
debug('Thunderclock card in slot', slot); debug('Thunderclock card in slot', slot);
each(LOC, function(key) {
LOC[key] += slot * 0x10;
});
} }
var _command = 0; var _command = 0;
@ -327,7 +323,7 @@ function Thunderclock(io, slot)
} }
function _access(off, val) { function _access(off, val) {
switch (off) { switch (off & 0x8F) {
case LOC.CONTROL: case LOC.CONTROL:
if (val !== undefined) { if (val !== undefined) {
if ((val & FLAGS.STROBE) !== 0) { if ((val & FLAGS.STROBE) !== 0) {
@ -360,18 +356,12 @@ function Thunderclock(io, slot)
_init(); _init();
return { return {
start: function thunderclock_start() {
return 0xc0 + slot;
},
end: function thunderclock_end() {
return 0xc0 + slot;
},
read: function thunderclock_read(page, off) { read: function thunderclock_read(page, off) {
var result; var result;
if (page < 0xc8) { if (page < 0xc8) {
result = rom[off]; result = rom[off];
} else { } else {
result = rom[(page - 0xc8) * 256 + off]; result = rom[(page - 0xc8) << 8 | off];
} }
return result; return result;
}, },

View File

@ -10,9 +10,9 @@
*/ */
/*globals debug: false, toHex: false, reset: false */ /*globals debug: false, toHex: false, reset: false */
/*exported KeyBoard */ /*exported KeyBoard2 */
function KeyBoard(io) { function KeyBoard2(io) {
// keycode: [plain, cntl, shift] // keycode: [plain, cntl, shift]
var keymap = { var keymap = {
// Most of these won't happen // Most of these won't happen

View File

@ -1,4 +1,3 @@
/* Copyright 2010-2016 Will Scullin <scullin@scullinsteel.com> /* Copyright 2010-2016 Will Scullin <scullin@scullinsteel.com>
* *
* Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
@ -12,9 +11,9 @@
/*jshint jquery: true, browser: true */ /*jshint jquery: true, browser: true */
/*globals debug: false, toHex: false */ /*globals debug: false, toHex: false */
/*exported KeyBoard */ /*exported KeyBoard2e */
function KeyBoard(io) { function KeyBoard2e(io) {
// keycode: [plain, cntl, shift] // keycode: [plain, cntl, shift]
var keymap = { var keymap = {
// Most of these won't happen // Most of these won't happen

View File

@ -10,7 +10,7 @@
*/ */
/*eslint no-console: 0*/ /*eslint no-console: 0*/
/*exported allocMemPages, bytify, debug, each extend, gup, hup, toBinary, toHex /*exported allocMemPages, bytify, debug, each, gup, hup, toBinary, toHex
*/ */
/*global Uint8Array: false */ /*global Uint8Array: false */
@ -45,13 +45,6 @@ function bytify(ary) {
return result; return result;
} }
function extend(ary1, ary2) {
ary2.forEach(function(val) {
ary1.push(val);
});
return ary1;
}
function debug() { function debug() {
if (typeof console != 'undefined' && 'log' in console) { if (typeof console != 'undefined' && 'log' in console) {
console.log.apply(console, arguments); console.log.apply(console, arguments);

View File

@ -1,6 +1,6 @@
#!/usr/bin/env perl -w #!/usr/bin/env perl -w
# Copyright 2010-2016 Will Scullin <scullin@scullinsteel.com> # Copyright 2010-2016 Will Scullin <scullin@scullinsteel.com>
# #
# Permission to use, copy, modify, distribute, and sell this software and its # Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that # documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that # the above copyright notice appear in all copies and that both that
@ -27,14 +27,11 @@ while (<json/disks/*.json>) {
open(DISK, $fn) or die $!; open(DISK, $fn) or die $!;
while (<DISK>) { while (<DISK>) {
my $line = $_; my $line = $_;
$line =~ s/^loadJSON\(//;
$line =~ s/\);$//;
$json .= $line; $json .= $line;
} }
close(DISK); close(DISK);
$disk = from_json($json); $disk = from_json($json);
$disk->{'filename'} = $fn; $disk->{'filename'} = $fn;
$disk->{'data'} = NULL; $disk->{'data'} = NULL;