8-bit write to IO
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Jul 2013 02:13:49 -0700
3 files changed,
17 insertions(+),
8 deletions(-)
M
src/gba/gba-io.c
→
src/gba/gba-io.c
@@ -109,20 +109,27 @@ break;
case REG_IME: GBAWriteIME(gba, value); break; - case REG_HALTCNT: - value &= 0x80; - if (!value) { - GBAHalt(gba); - } else { - GBALog(GBA_LOG_STUB, "Stop unimplemented"); - } - return; default: GBALog(GBA_LOG_STUB, "Stub I/O register write: %03x", address); break; } } gba->memory.io[address >> 1] = value; +} + +void GBAIOWrite8(struct GBA* gba, uint32_t address, uint8_t value) { + if (address == REG_HALTCNT) { + value &= 0x80; + if (!value) { + GBAHalt(gba); + } else { + GBALog(GBA_LOG_STUB, "Stop unimplemented"); + } + return; + } + value <<= 8 * (address & 1); + value |= (gba->memory.io[(address & (SIZE_IO - 1)) >> 1]) & ~(0xFF << (8 * (address & 1))); + GBAIOWrite(gba, address, value); } void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value) {
M
src/gba/gba-io.h
→
src/gba/gba-io.h
@@ -143,6 +143,7 @@ };
void GBAIOInit(struct GBA* gba); void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value); +void GBAIOWrite8(struct GBA* gba, uint32_t address, uint8_t value); void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value); uint16_t GBAIORead(struct GBA* gba, uint32_t address);
M
src/gba/gba-memory.c
→
src/gba/gba-memory.c
@@ -385,6 +385,7 @@ case BASE_WORKING_IRAM:
((int8_t*) gbaMemory->iwram)[address & (SIZE_WORKING_IRAM - 1)] = value; break; case BASE_IO: + GBAIOWrite8(gbaMemory->p, address & (SIZE_IO - 1), value); break; case BASE_PALETTE_RAM: break;