nes-fix mapper 64 and some minor details of ppu data bus management; fixes klax and chu chu rocket

This commit is contained in:
zeromus 2012-04-17 06:50:23 +00:00
parent 68a8dd5f74
commit 06239e1aa3
4 changed files with 31 additions and 24 deletions

View File

@ -25,6 +25,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
bool irq_pending, irq_enable; bool irq_pending, irq_enable;
bool irq_mode; bool irq_mode;
bool irq_reload_pending; bool irq_reload_pending;
int separator_counter;
public override void Dispose() public override void Dispose()
@ -51,6 +52,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
ser.Sync("irq_enable", ref irq_enable); ser.Sync("irq_enable", ref irq_enable);
ser.Sync("irq_mode", ref irq_mode); ser.Sync("irq_mode", ref irq_mode);
ser.Sync("irq_reload_pending", ref irq_reload_pending); ser.Sync("irq_reload_pending", ref irq_reload_pending);
ser.Sync("separator_counter", ref separator_counter);
if (ser.IsReader) if (ser.IsReader)
Sync(); Sync();
@ -63,7 +65,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
case "MAPPER064": case "MAPPER064":
break; break;
case "TENGEN-800032": case "TENGEN-800032":
AssertPrg(64,128); AssertChr(64,128); AssertVram(0); AssertWram(00); AssertPrg(64, 128); AssertChr(64, 128); AssertVram(0); AssertWram(00);
break; break;
default: default:
return false; return false;
@ -170,7 +172,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
case 0x4001: case 0x4001:
irq_mode = value.Bit(0); irq_mode = value.Bit(0);
if(irq_mode) irq_countdown = 12; if (irq_mode) irq_countdown = 12;
irq_reload_pending = true; irq_reload_pending = true;
break; break;
@ -241,27 +243,34 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public override void ClockPPU() public override void ClockPPU()
{ {
if (separator_counter > 0)
separator_counter--;
if (irq_countdown > 0) if (irq_countdown > 0)
{ {
irq_countdown--; irq_countdown--;
if (irq_countdown == 0) if (irq_countdown == 0)
{ {
ClockIRQ(); ClockIRQ();
if (irq_mode) }
irq_countdown = 12;
}
} }
} }
public override void AddressPPU(int addr) public override void AddressPPU(int addr)
{ {
int a12 = (addr >> 12) & 1; int a12 = (addr >> 12) & 1;
bool rising_edge = (a12 == 1 && a12_old == 0); bool rising_edge = (a12 == 1 && a12_old == 0);
if (rising_edge) if (rising_edge)
{ {
//this number is totally guessed to make klax work if (separator_counter > 0)
irq_countdown = 25; {
separator_counter = 15;
}
else
{
separator_counter = 15;
irq_countdown = 11;
}
} }
a12_old = a12; a12_old = a12;

View File

@ -39,7 +39,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
return 0xFF; return 0xFF;
nes.board.AddressPPU(addr); nes.board.AddressPPU(addr);
return nes.board.ReadPPU(addr); return nes.board.ReadPPU(addr);
} }

View File

@ -436,16 +436,13 @@ namespace BizHawk.Emulation.Consoles.Nintendo
ppur.install_latches(); ppur.install_latches();
//nes.LogLine("addr wrote vt = {0}, ht = {1}", ppur._vt, ppur._ht); //nes.LogLine("addr wrote vt = {0}, ht = {1}", ppur._vt, ppur._ht);
//zero 03-mar-2012 - this broke chu chu rocket. //normally the address isnt observed by the board till it gets clocked by a read or write.
//its actually a terrible idea, so dont put it back. //but maybe thats just because a ppu read/write shoves it on the address bus
//the address isnt observed by the board till it gets clocked by a read or write. //apparently this shoves it on the address bus, too, or else blargg's mmc3 tests dont pass
//nes.board.AddressPPU(ppur.get_2007access()); nes.board.AddressPPU(ppur.get_2007access());
} }
vtoggle ^= true; vtoggle ^= true;
int addr = ppur.get_2007access() & 0x3FFF;
nes.board.AddressPPU(addr);
} }
byte read_2006() { return PPUGenLatch; } byte read_2006() { return PPUGenLatch; }
@ -477,8 +474,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
ppur.increment2007(ppur.status.rendering && reg_2001.PPUON, reg_2000.vram_incr32 != 0); ppur.increment2007(ppur.status.rendering && reg_2001.PPUON, reg_2000.vram_incr32 != 0);
addr = ppur.get_2007access() & 0x3FFF; //see comments in $2006
nes.board.AddressPPU(addr); nes.board.AddressPPU(ppur.get_2007access());
} }
byte read_2007() byte read_2007()
{ {
@ -499,8 +496,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
ppur.increment2007(ppur.status.rendering && reg_2001.PPUON, reg_2000.vram_incr32 != 0); ppur.increment2007(ppur.status.rendering && reg_2001.PPUON, reg_2000.vram_incr32 != 0);
addr = ppur.get_2007access() & 0x3FFF; //see comments in $2006
nes.board.AddressPPU(addr); nes.board.AddressPPU(ppur.get_2007access());
return ret; return ret;
} }

View File

@ -413,6 +413,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//garbage nametable fetches + scroll resets //garbage nametable fetches + scroll resets
int garbage_todo = 2; int garbage_todo = 2;
ppubus_read(ppur.get_ntread(),true);
if (reg_2001.PPUON) if (reg_2001.PPUON)
{ {
if (sl == 0 && ppur.status.cycle == 304) if (sl == 0 && ppur.status.cycle == 304)
@ -433,6 +434,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
} }
if (realSprite) runppu(garbage_todo); if (realSprite) runppu(garbage_todo);
ppubus_read(ppur.get_atread(), true); //at or nt?
if (realSprite) runppu(kFetchTime); if (realSprite) runppu(kFetchTime);
//TODO - fake sprites should not come through ppubus_read but rather peek it //TODO - fake sprites should not come through ppubus_read but rather peek it