games/snes: hirom support and register 2180 fix
This commit is contained in:
parent
8d11fd6d27
commit
08e433f31d
|
@ -5,8 +5,8 @@ extern u32int hdma;
|
|||
extern int trace;
|
||||
|
||||
extern uchar *prg, *sram;
|
||||
extern int nprg, nsram, keys;
|
||||
extern u32int keylatch, lastkeys;
|
||||
extern int nprg, nsram, hirom;
|
||||
extern u32int keys, keylatch, lastkeys;
|
||||
extern u8int reg[32768], spcmem[65536], vram[65536], oam[544];
|
||||
extern u16int cgram[256];
|
||||
|
||||
|
|
|
@ -47,6 +47,14 @@ incvram(int i, int r)
|
|||
reg[0x2117] = (a >> 8) & 0x7f;
|
||||
}
|
||||
|
||||
static void
|
||||
incwram(void)
|
||||
{
|
||||
if(++reg[0x2181] == 0)
|
||||
if(++reg[0x2182] == 0)
|
||||
reg[0x2183] ^= 1;
|
||||
}
|
||||
|
||||
static void
|
||||
hvlatch(void)
|
||||
{
|
||||
|
@ -146,8 +154,8 @@ regread(u16int p)
|
|||
reg[OPCTLATCH] &= ~3;
|
||||
return v;
|
||||
case 0x2180:
|
||||
v = memread(reg[0x2181] | reg[0x2182] << 8 | reg[0x2183] << 16);
|
||||
reg[0x2181]++;
|
||||
v = memread(0x7e0000 | reg[0x2181] | reg[0x2182] << 8 | (reg[0x2183] & 1) << 16);
|
||||
incwram();
|
||||
return v;
|
||||
case 0x4016:
|
||||
if((reg[0x4016] & 1) != 0){
|
||||
|
@ -261,8 +269,8 @@ regwrite(u16int p, u8int v)
|
|||
if((v & 0x20) != 0) subcolor = subcolor & 0x03ff | (v & 0x1f) << 10;
|
||||
return;
|
||||
case 0x2180:
|
||||
memwrite(reg[0x2181] | reg[0x2182] << 8 | reg[0x2183] << 16, v);
|
||||
reg[0x2181]++;
|
||||
memwrite(0x7e0000 | reg[0x2181] | reg[0x2182] << 8 | (reg[0x2183] & 1) << 16, v);
|
||||
incwram();
|
||||
return;
|
||||
case 0x213e:
|
||||
return;
|
||||
|
@ -342,11 +350,13 @@ memread(u32int a)
|
|||
if(al < 0x8000){
|
||||
if(b < 0x40)
|
||||
return regread(al);
|
||||
if(b >= 0x70 && b < 0x78 && nsram != 0)
|
||||
return sram[((a & 0x7fffff) - 0x700000) & (nsram - 1)];
|
||||
if((b & 0xf8) == (hirom ? 0x20 : 0x70) && nsram != 0)
|
||||
return sram[a & 0x07ffff & (nsram - 1)];
|
||||
}
|
||||
if(b >= 0x7e && (a & (1<<23)) == 0)
|
||||
return mem[a - 0x7e0000];
|
||||
if(hirom)
|
||||
return prg[((b & 0x3f) % nprg) << 16 | al];
|
||||
return prg[(b%nprg) << 15 | al & 0x7fff];
|
||||
}
|
||||
|
||||
|
@ -365,8 +375,8 @@ memwrite(u32int a, u8int v)
|
|||
regwrite(a, v);
|
||||
return;
|
||||
}
|
||||
if(b >= 0x70 && b < 0x78 && nsram != 0){
|
||||
sram[((a & 0x7fffff) - 0x700000) & (nsram - 1)] = v;
|
||||
if((b & 0xf8) == (hirom ? 0x20 : 0x70) && nsram != 0){
|
||||
sram[a & 0x07ffff & (nsram - 1)] = v;
|
||||
if(saveclock == 0)
|
||||
saveclock = SAVEFREQ;
|
||||
return;
|
||||
|
|
|
@ -14,8 +14,8 @@ int nprg, nsram, hirom, battery;
|
|||
int ppuclock, spcclock, stimerclock, saveclock, msgclock, paused, perfclock;
|
||||
Mousectl *mc;
|
||||
QLock pauselock;
|
||||
int keys, savefd;
|
||||
int scale, profile, mouse;
|
||||
u32int keys;
|
||||
int savefd, scale, profile, mouse;
|
||||
Rectangle picr;
|
||||
Image *tmp, *bg;
|
||||
|
||||
|
@ -57,6 +57,13 @@ loadrom(char *file)
|
|||
if(readn(fd, prg, size) < size)
|
||||
sysfatal("read: %r");
|
||||
close(fd);
|
||||
if((memread(0xffd5) & ~0x10) != 0x20)
|
||||
if((memread(0x1ffd5) & ~0x10) == 0x21)
|
||||
hirom = 1;
|
||||
else
|
||||
sysfatal("invalid rom (neither hirom nor lorom)");
|
||||
if(hirom)
|
||||
nprg >>= 1;
|
||||
switch(memread(0xffd6)){
|
||||
case 0:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue