Skip to content

Commit

Permalink
gb: replace IO_BANK with IO_BOOT
Browse files Browse the repository at this point in the history
Removes duplicate IO define and fixes issue #111.

Signed-off-by: Mahyar Koshkouei <[email protected]>
  • Loading branch information
deltabeard committed Jun 13, 2024
1 parent 4776151 commit 288f018
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions peanut_gb.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ struct gb_s
#define IO_TMA 0x06
#define IO_TAC 0x07
#define IO_IF 0x0F
#define IO_BOOT 0x50
#define IO_LCDC 0x40
#define IO_STAT 0x41
#define IO_SCY 0x42
Expand All @@ -727,7 +726,7 @@ struct gb_s
#define IO_OBP1 0x49
#define IO_WY 0x4A
#define IO_WX 0x4B
#define IO_BANK 0x50
#define IO_BOOT 0x50
#define IO_IE 0xFF

#define IO_TAC_RATE_MASK 0x3
Expand All @@ -749,9 +748,9 @@ uint8_t __gb_read(struct gb_s *gb, uint16_t addr)
switch(PEANUT_GB_GET_MSN16(addr))
{
case 0x0:
/* IO_BANK is only set to 1 if gb->gb_bootrom_read was not NULL
/* IO_BOOT is only set to 1 if gb->gb_bootrom_read was not NULL
* on reset. */
if(gb->hram_io[IO_BANK] == 0 && addr < 0x0100)
if(gb->hram_io[IO_BOOT] == 0 && addr < 0x0100)
{
return gb->gb_bootrom_read(gb, addr);
}
Expand Down Expand Up @@ -1180,7 +1179,7 @@ void __gb_write(struct gb_s *gb, uint_fast16_t addr, uint8_t val)

/* Turn off boot ROM */
case 0x50:
gb->hram_io[IO_BANK] = val;
gb->hram_io[IO_BOOT] = val;
return;

/* Interrupt Enable Register */
Expand Down Expand Up @@ -3547,7 +3546,7 @@ void gb_reset(struct gb_s *gb)
gb->hram_io[IO_DIV ] = 0xAB;
gb->hram_io[IO_LCDC] = 0x91;
gb->hram_io[IO_STAT] = 0x85;
gb->hram_io[IO_BANK] = 0x01;
gb->hram_io[IO_BOOT] = 0x01;

memset(gb->vram, 0x00, VRAM_SIZE);
}
Expand All @@ -3559,7 +3558,7 @@ void gb_reset(struct gb_s *gb)
gb->hram_io[IO_DIV ] = 0x00;
gb->hram_io[IO_LCDC] = 0x00;
gb->hram_io[IO_STAT] = 0x84;
gb->hram_io[IO_BANK] = 0x00;
gb->hram_io[IO_BOOT] = 0x00;
}

gb->counter.lcd_count = 0;
Expand Down

0 comments on commit 288f018

Please sign in to comment.