games/nes: SUROM support, subtle NMI timing bug fixed
This commit is contained in:
parent
88405371b1
commit
142858b176
4 changed files with 17 additions and 10 deletions
|
@ -244,11 +244,12 @@ step(void)
|
|||
u16int a, v;
|
||||
int c;
|
||||
|
||||
if(nmi){
|
||||
interrupt(1, 0);
|
||||
nmi = 0;
|
||||
return 7;
|
||||
}
|
||||
if(nmi)
|
||||
if(--nmi == 0){
|
||||
interrupt(1, 0);
|
||||
nmi = 0;
|
||||
return 7;
|
||||
}
|
||||
if(irq && (rP & 4) == 0){
|
||||
interrupt(0, 0);
|
||||
return 7;
|
||||
|
@ -256,7 +257,7 @@ step(void)
|
|||
curpc = pc;
|
||||
op = fetch8();
|
||||
if(trace)
|
||||
print("%x %x %x %x %x %x %x %x\n", curpc, op, rA, rX, rY, rS, rP, memread(0x2c));
|
||||
print("%x %x %x %x %x %x %x\n", curpc, op, rA, rX, rY, rS, rP);
|
||||
switch(op){
|
||||
case 0x00: pc++; interrupt(0, 1); return 7;
|
||||
case 0x01: nz(rA |= indX()); return 6;
|
||||
|
|
|
@ -54,6 +54,8 @@ mmc1(int v, u8int p)
|
|||
if(v < 0){
|
||||
switch(v){
|
||||
case INIT:
|
||||
if(nprg > 32)
|
||||
sysfatal("bad rom, too much prg rom for mmc1");
|
||||
mode = 0x0C;
|
||||
prgsh = 14;
|
||||
chrsh = 12;
|
||||
|
@ -99,6 +101,10 @@ mmc1(int v, u8int p)
|
|||
mirr = mirrs[mode & 3];
|
||||
break;
|
||||
case 0xA000:
|
||||
if(nprg > 16){
|
||||
pr = s & 0x10 | pr & 0x0f;
|
||||
pr %= nprg;
|
||||
}
|
||||
c0 = s & 0x1f;
|
||||
c0 %= 2*nchr;
|
||||
break;
|
||||
|
@ -107,7 +113,7 @@ mmc1(int v, u8int p)
|
|||
c1 %= 2*nchr;
|
||||
break;
|
||||
case 0xE000:
|
||||
pr = s & 0x0f;
|
||||
pr = pr & 0x10 | s & 0x0f;
|
||||
pr %= nprg;
|
||||
break;
|
||||
}
|
||||
|
@ -121,7 +127,7 @@ t:
|
|||
break;
|
||||
case 0x0C:
|
||||
prgb[0] = prg + pr * 0x4000;
|
||||
prgb[1] = prg + (0x0f % nprg) * 0x4000;
|
||||
prgb[1] = prg + ((pr & 0x10 | 0x0f) % nprg) * 0x4000;
|
||||
break;
|
||||
default:
|
||||
prgb[0] = prg + (pr & 0xfe) * 0x4000;
|
||||
|
|
|
@ -93,7 +93,7 @@ loadrom(char *file, int sflag)
|
|||
if(readn(fd, chr, nchr * CHRSZ) < nchr * CHRSZ)
|
||||
sysfatal("read: %r");
|
||||
}else{
|
||||
nchr = 16;
|
||||
nchr = 1;
|
||||
chr = malloc(nchr * CHRSZ);
|
||||
if(chr == nil)
|
||||
sysfatal("malloc: %r");
|
||||
|
|
|
@ -326,7 +326,7 @@ ppustep(void)
|
|||
if(ppux == 1){
|
||||
mem[PPUSTATUS] |= PPUVBLANK;
|
||||
if((mem[PPUCTRL] & PPUNMI) != 0)
|
||||
nmi = 1;
|
||||
nmi = 2;
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue