Skip to content

Commit

Permalink
Fix Burai Fighter (U) status area
Browse files Browse the repository at this point in the history
  • Loading branch information
perilsensitive committed Aug 6, 2014
1 parent 0cb6284 commit 43a831c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
61 changes: 24 additions & 37 deletions source/core/NstPpu.cpp
Expand Up @@ -658,41 +658,12 @@ namespace Nes
io.line.Toggle( io.address, GetCycles() );
}

NST_FORCE_INLINE void Ppu::UpdateScrollAddressLine()
{
if (io.line)
{
//io.line.Toggle( scroll.address & 0x3FFF, cpu.GetCycles() ); // Original
int a12_mask = ~((scroll.address & 0x2000) >> 1);
io.line.Toggle( (scroll.address & a12_mask) & 0x3FFF, cpu.GetCycles() );
}
}

NST_FORCE_INLINE void Ppu::UpdateVramAddress()
{
if ((scanline != SCANLINE_VBLANK ) && (regs.ctrl[1] & Regs::CTRL1_BG_SP_ENABLED))
{
if ( regs.ctrl[0] & Regs::CTRL0_INC32 )
{
if((scroll.address & 0x7000) == 0x7000)
{
scroll.address &= 0x0FFF;
switch(scroll.address & 0x03E0)
{
case 0x03A0: scroll.address ^= 0x0800; break;
case 0x03E0: scroll.address &= 0x7C1F; break;
default: scroll.address += 0x20;
}
}
else
{
scroll.address += 0x1000;
}
}
else
{
scroll.address++;
}
scroll.ClockX();
scroll.ClockY();
}
else
{
Expand Down Expand Up @@ -813,7 +784,7 @@ namespace Nes
oam.mask = oam.show[pos];

if ((regs.ctrl[1] & Regs::CTRL1_BG_SP_ENABLED) && !(data & Regs::CTRL1_BG_SP_ENABLED))
UpdateScrollAddressLine();
UpdateAddressLine(scroll.address & 0x3fff);
}

io.latch = data;
Expand Down Expand Up @@ -957,7 +928,10 @@ namespace Nes
{
scroll.latch = (scroll.latch & 0x7F00) | data;
scroll.address = scroll.latch;
UpdateScrollAddressLine();
if (!(regs.ctrl[1] & Regs::CTRL1_BG_SP_ENABLED) ||
(scanline == SCANLINE_VBLANK)) {
UpdateAddressLine(scroll.address & 0x3fff);
}
}
}
}
Expand All @@ -969,7 +943,10 @@ namespace Nes
uint address = scroll.address;

UpdateVramAddress();
UpdateScrollAddressLine();
if (!(regs.ctrl[1] & Regs::CTRL1_BG_SP_ENABLED) ||
(scanline == SCANLINE_VBLANK)) {
UpdateAddressLine(scroll.address & 0x3fff);
}

io.latch = data;

Expand Down Expand Up @@ -1007,7 +984,10 @@ namespace Nes

address = scroll.address & 0x3FFF;
UpdateVramAddress();
UpdateScrollAddressLine();
if (!(regs.ctrl[1] & Regs::CTRL1_BG_SP_ENABLED) ||
(scanline == SCANLINE_VBLANK)) {
UpdateAddressLine(scroll.address & 0x3fff);
}

io.latch = (address & 0x3F00) != 0x3F00 ? io.buffer : palette.ram[address & 0x1F] & Coloring();
io.buffer = (address >= 0x2000 ? nmt.FetchName( address ) : chr.FetchPattern( address ));
Expand Down Expand Up @@ -2107,12 +2087,19 @@ namespace Nes
}
else
{
cycles.hClock = HCLOCK_VBLANK_0;
cycles.hClock = HCLOCK_POSTRENDER;

if (cycles.count <= HCLOCK_VBLANK_0)
if (cycles.count <= HCLOCK_POSTRENDER)
break;
}

case HCLOCK_POSTRENDER:
UpdateAddressLine(scroll.address & 0x3fff);
cycles.hClock = HCLOCK_VBLANK_0;

if (cycles.count <= HCLOCK_VBLANK_0)
break;

case HCLOCK_VBLANK_0:
VBlank0:

Expand Down
2 changes: 1 addition & 1 deletion source/core/NstPpu.hpp
Expand Up @@ -139,6 +139,7 @@ namespace Nes

enum
{
HCLOCK_POSTRENDER = 340,
HCLOCK_DUMMY = 341,
HCLOCK_VBLANK_0 = 681,
HCLOCK_VBLANK_1 = 682,
Expand Down Expand Up @@ -175,7 +176,6 @@ namespace Nes
NST_FORCE_INLINE uint Emphasis() const;

NST_FORCE_INLINE void UpdateAddressLine(uint);
NST_FORCE_INLINE void UpdateScrollAddressLine();
NST_FORCE_INLINE void UpdateVramAddress();

NST_FORCE_INLINE void OpenName();
Expand Down

0 comments on commit 43a831c

Please sign in to comment.