Skip to content

Commit

Permalink
Implemented IO open bus, mask out unused/write only IO bits, made sou…
Browse files Browse the repository at this point in the history
…nd louder and other tweaks
  • Loading branch information
gdkchan committed Jan 20, 2017
1 parent cd07835 commit 1eec3f1
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 162 deletions.
44 changes: 28 additions & 16 deletions arm_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,39 @@ static uint8_t arm_read_(uint32_t address) {
#define IS_OPEN_BUS(a) (((a) >> 28) || ((a) >= 0x00004000 && (a) < 0x02000000))

uint8_t arm_readb(uint32_t address) {
if (IS_OPEN_BUS(address))
return arm_read_(arm_r.r[15]);
else
return arm_read_(address);
}
uint8_t value = arm_read_(address);

uint32_t arm_readh(uint32_t address) {
if (address < 0x4000 && arm_r.r[15] >= 0x4000)
return bios_op & 0xffff;
if (!(address & 0x08000000)) {
io_open_bus &= ((address >> 24) == 4);

if (IS_OPEN_BUS(address) || io_open_bus)
value = arm_pipe[1];
}

if (IS_OPEN_BUS(address))
return arm_pipe[1] & 0xffff;
return value;
}

uint32_t arm_readh(uint32_t address) {
uint32_t a = address & ~1;
uint8_t s = address & 1;

uint32_t value =
arm_read_(a | 0) << 0 |
arm_read_(a | 1) << 8;

if (!(a & 0x08000000)) {
io_open_bus &= ((a >> 24) == 4);

if (a < 0x4000 && arm_r.r[15] >= 0x4000)
value = bios_op & 0xffff;
else if (IS_OPEN_BUS(a) || io_open_bus)
value = arm_pipe[1] & 0xffff;
}

return ROR(value, s << 3);
}

uint32_t arm_read(uint32_t address) {
if (address < 0x4000 && arm_r.r[15] >= 0x4000)
return bios_op;

if (IS_OPEN_BUS(address))
return arm_pipe[1];

uint32_t a = address & ~3;
uint8_t s = address & 3;

Expand All @@ -177,6 +180,15 @@ uint32_t arm_read(uint32_t address) {
arm_read_(a | 2) << 16 |
arm_read_(a | 3) << 24;

if (!(a & 0x08000000)) {
io_open_bus &= ((a >> 24) == 4);

if (a < 0x4000 && arm_r.r[15] >= 0x4000)
value = bios_op;
else if (IS_OPEN_BUS(a) || io_open_bus)
value = arm_pipe[1];
}

return ROR(value, s << 3);
}

Expand Down
Loading

0 comments on commit 1eec3f1

Please sign in to comment.