8-bit write to IO

This commit is contained in:
Jeffrey Pfau 2013-07-18 02:13:49 -07:00
parent 8215afcee6
commit 6a1afbda50
3 changed files with 17 additions and 8 deletions

View File

@ -109,14 +109,6 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
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;
@ -125,6 +117,21 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
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) {
switch (address) {
case REG_DMA0SAD_LO:

View File

@ -143,6 +143,7 @@ enum GBAIORegisters {
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);

View File

@ -385,6 +385,7 @@ void GBAStore8(struct ARMMemory* memory, uint32_t address, int8_t value, int* cy
((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;