Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bugs #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline void tick() { PPU::step(); PPU::step(); PPU::step(); remainingCycles--; }
inline void upd_cv(u8 x, u8 y, s16 r) { P[C] = (r>0xFF); P[V] = ~(x^y) & (x^r) & 0x80; }
inline void upd_nz(u8 x) { P[N] = x & 0x80; P[Z] = (x == 0); }
// Does adding I to A cross a page?
inline bool cross(u16 a, u8 i) { return ((a+i) & 0xFF00) != ((a & 0xFF00)); }
template<typename Offset> inline bool cross(u16 a, Offset i) { return ((a+i) & 0xFF00) != ((a & 0xFF00)); }

/* Memory access */
void dma_oam(u8 bank);
Expand Down Expand Up @@ -141,7 +141,7 @@ void RTI() { PLP(); PC = pop() | (pop() << 8); }
template<Flag f, bool v> void flag() { P[f] = v; T; } // Clear and set flags.
template<IntType t> void INT()
{
T; if (t != BRK) T; // BRK already performed the fetch.
T; if (t != BRK) T; else PC++; // BRK already performed the fetch.
if (t != RESET) // Writes on stack are inhibited on RESET.
{
push(PC >> 8); push(PC & 0xFF);
Expand Down
17 changes: 10 additions & 7 deletions src/ppu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,16 @@ void eval_sprites()
// If the sprite is in the scanline, copy its properties into secondary OAM:
if (line >= 0 and line < spr_height())
{
secOam[n].id = i;
secOam[n].y = oamMem[i*4 + 0];
secOam[n].tile = oamMem[i*4 + 1];
secOam[n].attr = oamMem[i*4 + 2];
secOam[n].x = oamMem[i*4 + 3];

if (++n >= 8)
if (n < 8)
{
secOam[n].id = i;
secOam[n].y = oamMem[i * 4 + 0];
secOam[n].tile = oamMem[i * 4 + 1];
secOam[n].attr = oamMem[i * 4 + 2];
secOam[n].x = oamMem[i * 4 + 3];
n++;
}
else
{
status.sprOvf = true;
break;
Expand Down