Guest User

Untitled

a guest
May 19th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.31 KB | None | 0 0
  1. diff --git a/mem.c b/mem.c
  2. index 8e28680..8530f4d 100644
  3. --- a/mem.c
  4. +++ b/mem.c
  5. @@ -26,6 +26,9 @@ unsigned char readb_unsafe(unsigned int addr)
  6.         case 0x2002:
  7.             return ppu_read_reg2();
  8.         break;
  9. +        case 0x2007:
  10. +            return ppu_read_buffered();
  11. +       break;
  12.         case 0x4016:
  13.             return joypad_read();
  14.         break;
  15. diff --git a/ppu.c b/ppu.c
  16. index 70c9652..c4879fe 100644
  17. --- a/ppu.c
  18. +++ b/ppu.c
  19. @@ -24,6 +24,7 @@ struct PPU {
  20.     unsigned int addr_count;
  21.     unsigned int bg;
  22.     unsigned int vblank;    /* NMI ACK bit, 0x2000 bit 7 */
  23. +    unsigned char readbuf;
  24.  };
  25.  
  26.  static struct PPU p;
  27. @@ -93,6 +94,17 @@ void ppu_write_addr(unsigned int val)
  28.     }
  29.  }
  30.  
  31. +unsigned int ppu_read_buffered(void)
  32. +{
  33. +    unsigned char temp = p.readbuf;
  34. +    
  35. +    p.readbuf = ppu_readb(p.addr);
  36. +
  37. +   p.addr += p.increment;
  38. +
  39. +    return temp;
  40. +}
  41. +
  42.  unsigned int ppu_read_reg2(void)
  43.  {
  44.     int t = 0;
  45. diff --git a/ppu.h b/ppu.h
  46. index 08f88e4..17ca3cc 100644
  47. --- a/ppu.h
  48. +++ b/ppu.h
  49. @@ -5,6 +5,7 @@ void ppu(unsigned int);
  50.  void ppu_write_addr(unsigned int);
  51.  void ppu_write_data(unsigned int);
  52.  void ppu_addr_reset_count(void);
  53. +unsigned int ppu_read_buffered(void);
  54.  unsigned int ppu_read_reg2(void);
  55.  void ppu_set_bank(unsigned int, unsigned int);
  56.  void ppu_writeb_unsafe(unsigned int, unsigned char);
Add Comment
Please, Sign In to add comment