update 0.8.0
This commit is contained in:
parent
6c1dd199b1
commit
eda41a625b
20 changed files with 9833 additions and 4280 deletions
206
sae/amiga.js
206
sae/amiga.js
|
|
@ -12,6 +12,14 @@ function set_special(x) { AMIGA.spcflags |= x; }
|
|||
function clr_special(x) { AMIGA.spcflags &= ~x; }
|
||||
|
||||
function Amiga() {
|
||||
this.info = {
|
||||
version: SAEV_Version+'.'+SAEV_Revision+'.'+SAEV_Revision_Sub,
|
||||
browser_name: BrowserDetect.browser,
|
||||
browser_version: BrowserDetect.version,
|
||||
os: BrowserDetect.OS,
|
||||
video:0,
|
||||
audio:0
|
||||
};
|
||||
this.config = new Config();
|
||||
this.mem = new Memory();
|
||||
this.expansion = new Expansion();
|
||||
|
|
@ -29,35 +37,31 @@ function Amiga() {
|
|||
this.audio = new Audi0();
|
||||
this.cpu = new CPU();
|
||||
|
||||
this.state = CMD_STOP;
|
||||
this.state = ST_STOP;
|
||||
this.delay = 0;
|
||||
this.spcflags = 0;
|
||||
//this.loading = 0;
|
||||
|
||||
this.intena = 0;
|
||||
this.intena_internal = 0;
|
||||
this.intreq = 0;
|
||||
this.intreq_internal = 0;
|
||||
this.dmacon = 0;
|
||||
this.adkcon = 0;
|
||||
|
||||
configSetDefaults(this.config);
|
||||
this.info.video = this.video.available;
|
||||
this.info.audio = this.audio.available;
|
||||
|
||||
/*---------------------------------*/
|
||||
|
||||
this.setup = function() {
|
||||
if (this.config.chipset.type == SAEV_Config_Chipset_Type_OCS)
|
||||
this.config.chipset.agnus = this.config.video.ntsc ? AGNUS_8370 : AGNUS_8371;
|
||||
|
||||
this.mem.setup();
|
||||
this.expansion.setup();
|
||||
this.events.setup();
|
||||
this.playfield.setup();
|
||||
this.video.setup();
|
||||
this.cia.setup();
|
||||
this.rtc.setup();
|
||||
this.input.setup();
|
||||
this.disk.setup();
|
||||
this.playfield.setup();
|
||||
this.video.setup();
|
||||
this.audio.setup();
|
||||
this.custom.setup();
|
||||
this.cpu.setup();
|
||||
|
|
@ -72,26 +76,25 @@ function Amiga() {
|
|||
|
||||
this.reset = function() {
|
||||
BUG.info('Amiga.reset()');
|
||||
|
||||
|
||||
this.delay = 0;
|
||||
this.spcflags = 0;
|
||||
//this.loading = 0;
|
||||
|
||||
|
||||
this.intena = 0;
|
||||
this.intena_internal = 0;
|
||||
this.intreq = 0;
|
||||
this.intreq_internal = 0;
|
||||
this.dmacon = 0;
|
||||
this.adkcon = 0;
|
||||
|
||||
|
||||
this.expansion.reset();
|
||||
this.events.reset();
|
||||
this.playfield.reset();
|
||||
this.cia.reset();
|
||||
this.disk.reset();
|
||||
this.input.reset();
|
||||
this.serial.reset();
|
||||
this.blitter.reset();
|
||||
this.copper.reset();
|
||||
this.playfield.reset();
|
||||
this.audio.reset();
|
||||
this.custom.reset();
|
||||
this.cpu.reset(this.mem.rom.lower);
|
||||
|
|
@ -109,7 +112,7 @@ function Amiga() {
|
|||
setTimeout('AMIGA.waitForStart()', 10);
|
||||
else {
|
||||
this.reset();
|
||||
this.state = CMD_CYCLE;
|
||||
this.state = ST_CYCLE;
|
||||
setTimeout('AMIGA.cycle()', 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -120,24 +123,24 @@ function Amiga() {
|
|||
|
||||
|
||||
this.start = function() {
|
||||
if (this.state == CMD_STOP) {
|
||||
if (this.state == ST_STOP) {
|
||||
this.setup();
|
||||
this.reset();
|
||||
this.state = CMD_CYCLE;
|
||||
this.state = ST_CYCLE;
|
||||
setTimeout('AMIGA.cycle()', 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.stop = function() {
|
||||
if (this.state != CMD_STOP) {
|
||||
this.state = CMD_STOP;
|
||||
if (this.state != ST_STOP) {
|
||||
this.state = ST_STOP;
|
||||
this.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
this.pause = function(state) {
|
||||
if (this.state != CMD_STOP) {
|
||||
this.state = state ? CMD_PAUSE : CMD_CYCLE;
|
||||
if (this.state != ST_STOP) {
|
||||
this.state = state ? ST_PAUSE : ST_CYCLE;
|
||||
this.audio.pauseResume(state);
|
||||
}
|
||||
}
|
||||
|
|
@ -159,97 +162,100 @@ function Amiga() {
|
|||
*/
|
||||
|
||||
this.insert = function(unit) {
|
||||
if (this.state != CMD_STOP)
|
||||
if (this.state != ST_STOP)
|
||||
this.disk.insert(unit);
|
||||
}
|
||||
|
||||
this.eject = function(unit) {
|
||||
if (this.state != CMD_STOP)
|
||||
if (this.state != ST_STOP)
|
||||
this.disk.eject(unit);
|
||||
}
|
||||
|
||||
/*---------------------------------*/
|
||||
/* mainloop */
|
||||
/* mainloop */
|
||||
|
||||
this.cycle = function() {
|
||||
try {
|
||||
while (this.state == CMD_CYCLE)
|
||||
this.cpu.cycle();
|
||||
this.cpu.cycle();
|
||||
} catch (e) {
|
||||
if (e instanceof VSync) {
|
||||
//console.log(e.error, e.message);
|
||||
this.state = ST_IDLE;
|
||||
} else
|
||||
if (e instanceof FatalError) {
|
||||
this.state = ST_STOP;
|
||||
this.stop();
|
||||
this.config.hooks.error(e.error, e.message);
|
||||
} else
|
||||
} else /* normal exception */ {
|
||||
this.state = ST_STOP;
|
||||
this.stop();
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.state == CMD_IDLE) {
|
||||
this.state = CMD_CYCLE;
|
||||
if (this.state == ST_IDLE) {
|
||||
this.state = ST_CYCLE;
|
||||
setTimeout('AMIGA.cycle()', this.delay);
|
||||
}
|
||||
else if (this.state == CMD_PAUSE)
|
||||
setTimeout('AMIGA.cyclePause()', 0);
|
||||
else if (this.state == ST_PAUSE)
|
||||
AMIGA.cyclePause();
|
||||
else
|
||||
setTimeout('AMIGA.cycleExit()', 0);
|
||||
AMIGA.cycleExit();
|
||||
}
|
||||
|
||||
this.cyclePause = function() {
|
||||
if (this.state == CMD_CYCLE)
|
||||
if (this.state == ST_CYCLE)
|
||||
setTimeout('AMIGA.cycle()', 0);
|
||||
else if (this.state == CMD_PAUSE)
|
||||
else if (this.state == ST_PAUSE)
|
||||
setTimeout('AMIGA.cyclePause()', 500);
|
||||
else
|
||||
setTimeout('AMIGA.cycleExit()', 0);
|
||||
AMIGA.cycleExit();
|
||||
}
|
||||
|
||||
this.cycleExit = function() {
|
||||
this.dump();
|
||||
//this.cia.dump();
|
||||
}
|
||||
|
||||
/*---------------------------------*/
|
||||
|
||||
this.dmaen = function (dmamask) {
|
||||
return ((this.dmacon & DMAF_DMAEN) && (this.dmacon & dmamask));
|
||||
return ((this.dmacon & DMAF_DMAEN) != 0 && (this.dmacon & dmamask) != 0);
|
||||
}
|
||||
|
||||
this.DMACONR = function(hpos) {
|
||||
this.playfield.decide_line(hpos);
|
||||
this.playfield.decide_fetch(hpos);
|
||||
this.dmacon &= ~(0x4000 | 0x2000);
|
||||
//this.dmacon |= (this.blitter.state == BLT_STOP ? 0 : 0x4000) | (this.blitter.zero ? 0x2000 : 0); //old
|
||||
//this.dmacon |= ((blit_interrupt || (!blit_interrupt && currprefs.cs_agnusbltbusybug && !blt_info.got_cycle)) ? 0 : 0x4000) | (blt_info.blitzero ? 0x2000 : 0); //new org
|
||||
var iz = this.blitter.getIntZero();
|
||||
this.dmacon |= (iz[0] ? 0 : 0x4000) | (iz[1] ? 0x2000 : 0);
|
||||
this.dmacon |= ((iz[0] ? 0 : 0x4000) | (iz[1] ? 0x2000 : 0));
|
||||
return this.dmacon;
|
||||
}
|
||||
|
||||
this.DMACON = function (v, hpos) {
|
||||
var oldcon = this.dmacon;
|
||||
|
||||
this.playfield.decide_line(hpos);
|
||||
this.playfield.decide_fetch(hpos);
|
||||
|
||||
if (v & INTF_SETCLR)
|
||||
this.dmacon |= v & ~INTF_SETCLR;
|
||||
else
|
||||
this.dmacon &= ~v;
|
||||
|
||||
|
||||
this.dmacon &= 0x1fff;
|
||||
|
||||
var changed = this.dmacon ^ oldcon;
|
||||
|
||||
var oldcop = (oldcon & DMAF_COPEN) && (oldcon & DMAF_DMAEN);
|
||||
var newcop = (this.dmacon & DMAF_COPEN) && (this.dmacon & DMAF_DMAEN);
|
||||
var oldcop = (oldcon & DMAF_COPEN) != 0 && (oldcon & DMAF_DMAEN) != 0;
|
||||
var newcop = (this.dmacon & DMAF_COPEN) != 0 && (this.dmacon & DMAF_DMAEN) != 0;
|
||||
if (oldcop != newcop) {
|
||||
if (newcop && !oldcop) {
|
||||
this.copper.compute_spcflag_copper(this.events.hpos());
|
||||
} else if (!newcop) {
|
||||
this.copper.enabled_thisline = false;
|
||||
clr_special (SPCFLAG_COPPER);
|
||||
clr_special(SPCFLAG_COPPER);
|
||||
}
|
||||
}
|
||||
//if ((this.dmacon & DMAF_COPEN) > (oldcon & DMAF_COPEN))
|
||||
//this.copper.COPJMP(1, 0);
|
||||
|
||||
if ((this.dmacon & DMAF_SPREN) > (oldcon & DMAF_SPREN)) {
|
||||
for (var i = 0; i < 8; i++)
|
||||
this.playfield.sprites.sprite[i].dmastate = 1;
|
||||
}
|
||||
if ((this.dmacon & DMAF_BLTPRI) > (oldcon & DMAF_BLTPRI) && this.blitter.getState() != BLT_done)
|
||||
set_special(SPCFLAG_BLTNASTY);
|
||||
if (this.dmaen(DMAF_BLTEN) && this.blitter.getState() == BLT_init)
|
||||
|
|
@ -260,12 +266,12 @@ function Amiga() {
|
|||
if (changed & (DMAF_DMAEN | 0x0f))
|
||||
this.audio.state_machine();
|
||||
|
||||
/*if (this.copper.active && !this.events.eventtab[EV_COPPER].active) {
|
||||
this.events.eventtab[EV_COPPER].active = true;
|
||||
this.events.eventtab[EV_COPPER].oldcycles = this.events.currcycle;
|
||||
this.events.eventtab[EV_COPPER].evtime = 1 * CYCLE_UNIT + this.events.currcycle;
|
||||
this.events.schedule();
|
||||
}*/
|
||||
if (changed & (DMAF_DMAEN | DMAF_BPLEN)) {
|
||||
this.playfield.update_ddf_change();
|
||||
if (this.dmaen(DMAF_BPLEN))
|
||||
this.playfield.maybe_start_bpl_dma(hpos);
|
||||
}
|
||||
this.events.schedule();
|
||||
}
|
||||
|
||||
/*---------------------------------*/
|
||||
|
|
@ -296,27 +302,13 @@ function Amiga() {
|
|||
}
|
||||
|
||||
this.INTENA = function(v) {
|
||||
var old = this.intena;
|
||||
|
||||
if (v & INTF_SETCLR)
|
||||
this.intena |= v & ~INTF_SETCLR;
|
||||
else
|
||||
this.intena &= ~v;
|
||||
|
||||
if (!(v & INTF_SETCLR) && old == this.intena)
|
||||
return;
|
||||
|
||||
if (AMIGA.config.cpu.exact) {
|
||||
this.events.event2_newevent_xx(-1, INT_PROCESSING_DELAY, this.intena, function(v) {
|
||||
//console.log('INTENA()', v);
|
||||
AMIGA.intena_internal = v;
|
||||
AMIGA.doint();
|
||||
});
|
||||
} else {
|
||||
this.intena_internal = this.intena;
|
||||
if (v & INTF_SETCLR)
|
||||
this.doint();
|
||||
}
|
||||
if (v & INTF_SETCLR)
|
||||
this.doint();
|
||||
}
|
||||
|
||||
/*---------------------------------*/
|
||||
|
|
@ -333,64 +325,36 @@ function Amiga() {
|
|||
else
|
||||
this.intreq &= ~v;
|
||||
|
||||
if (AMIGA.config.cpu.exact) {
|
||||
if (old == this.intreq && this.intreq_internal == this.intreq)
|
||||
return;
|
||||
|
||||
this.events.event2_newevent_xx(-1, INT_PROCESSING_DELAY, this.intreq, function(v) {
|
||||
//console.log('INTREQ_0()', v);
|
||||
AMIGA.intreq_internal = v;
|
||||
AMIGA.doint();
|
||||
});
|
||||
} else {
|
||||
this.intreq_internal = this.intreq;
|
||||
if (this.intreq == old)
|
||||
return;
|
||||
if (v & INTF_SETCLR)
|
||||
this.doint();
|
||||
}
|
||||
if ((v & INTF_SETCLR) && this.intreq != old)
|
||||
this.doint();
|
||||
}
|
||||
|
||||
this.INTREQ = function(v) {
|
||||
this.INTREQ_0(v);
|
||||
this.cia.reThink();
|
||||
this.cia.rethink();
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------*/
|
||||
|
||||
this.intlev = function() {
|
||||
var imask = this.intreq_internal & this.intena_internal;
|
||||
|
||||
if (imask && (this.intena_internal & INTF_INTEN)) {
|
||||
var imask = this.intreq & this.intena;
|
||||
|
||||
if (imask && (this.intena & INTF_INTEN)) {
|
||||
if (imask & 0x2000) return 6;
|
||||
if (imask & (0x1000 | 0x0800)) return 5;
|
||||
if (imask & (0x0400 | 0x0200 | 0x0100 | 0x0080)) return 4;
|
||||
if (imask & (0x0040 | 0x0020 | 0x0010)) return 3;
|
||||
if (imask & 0x1800) return 5;
|
||||
if (imask & 0x0780) return 4;
|
||||
if (imask & 0x0070) return 3;
|
||||
if (imask & 0x0008) return 2;
|
||||
if (imask & (0x0001 | 0x0002 | 0x0004)) return 1;
|
||||
if (imask & 0x0007) return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
this.doint = function() {
|
||||
if (AMIGA.config.cpu.exact) {
|
||||
this.cpu.setIPL(this.intlev());
|
||||
clr_special(SPCFLAG_INT);
|
||||
return;
|
||||
}
|
||||
if (AMIGA.config.cpu.compatible)
|
||||
set_special(SPCFLAG_INT);
|
||||
else
|
||||
set_special(SPCFLAG_DOINT);
|
||||
}
|
||||
|
||||
this.send_interrupt = function(num, delay) {
|
||||
if (AMIGA.config.cpu.exact && delay > 0) {
|
||||
if (!(this.intreq & (1 << num))) {
|
||||
this.events.event2_newevent_xx(-1, delay, num, function(v) {
|
||||
AMIGA.INTREQ_0(INTF_SETCLR | (1 << v));
|
||||
});
|
||||
}
|
||||
} else
|
||||
this.INTREQ_0(INTF_SETCLR | (1 << num));
|
||||
set_special(SPCFLAG_DOINT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -405,7 +369,8 @@ function SAE(x) {
|
|||
BUG.info('API.init() SEA %d.%d.%d', SAEV_Version, SAEV_Revision, SAEV_Revision_Sub);
|
||||
|
||||
AMIGA = new Amiga();
|
||||
return AMIGA.config;
|
||||
//return AMIGA.config;
|
||||
break;
|
||||
case 'reset':
|
||||
BUG.info('API.reset()');
|
||||
AMIGA.reset();
|
||||
|
|
@ -438,10 +403,13 @@ function SAE(x) {
|
|||
BUG.info('API.eject() DF%d', x.unit);
|
||||
AMIGA.eject(x.unit);
|
||||
break;
|
||||
/*case 'getConfig':
|
||||
case 'getInfo':
|
||||
BUG.info('API.getInfo()');
|
||||
return AMIGA.info;
|
||||
case 'getConfig':
|
||||
BUG.info('API.getConfig()');
|
||||
return AMIGA.config;
|
||||
case 'setConfig':
|
||||
/*case 'setConfig':
|
||||
BUG.info('API.setConfig() size '+x.data.ext.size);
|
||||
AMIGA.config = x.data;
|
||||
break;*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue