Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/mem.c b/mem.c
- index 8e28680..8530f4d 100644
- --- a/mem.c
- +++ b/mem.c
- @@ -26,6 +26,9 @@ unsigned char readb_unsafe(unsigned int addr)
- case 0x2002:
- return ppu_read_reg2();
- break;
- + case 0x2007:
- + return ppu_read_buffered();
- + break;
- case 0x4016:
- return joypad_read();
- break;
- diff --git a/ppu.c b/ppu.c
- index 70c9652..c4879fe 100644
- --- a/ppu.c
- +++ b/ppu.c
- @@ -24,6 +24,7 @@ struct PPU {
- unsigned int addr_count;
- unsigned int bg;
- unsigned int vblank; /* NMI ACK bit, 0x2000 bit 7 */
- + unsigned char readbuf;
- };
- static struct PPU p;
- @@ -93,6 +94,17 @@ void ppu_write_addr(unsigned int val)
- }
- }
- +unsigned int ppu_read_buffered(void)
- +{
- + unsigned char temp = p.readbuf;
- +
- + p.readbuf = ppu_readb(p.addr);
- +
- + p.addr += p.increment;
- +
- + return temp;
- +}
- +
- unsigned int ppu_read_reg2(void)
- {
- int t = 0;
- diff --git a/ppu.h b/ppu.h
- index 08f88e4..17ca3cc 100644
- --- a/ppu.h
- +++ b/ppu.h
- @@ -5,6 +5,7 @@ void ppu(unsigned int);
- void ppu_write_addr(unsigned int);
- void ppu_write_data(unsigned int);
- void ppu_addr_reset_count(void);
- +unsigned int ppu_read_buffered(void);
- unsigned int ppu_read_reg2(void);
- void ppu_set_bank(unsigned int, unsigned int);
- void ppu_writeb_unsafe(unsigned int, unsigned char);
Add Comment
Please, Sign In to add comment