mirror of
https://github.com/n64dev/cen64.git
synced 2024-06-22 22:12:45 -04:00
bus: Perform open bus reads for unmapped addresses.
Fixes F-Zero X (cartridge version).
This commit is contained in:
parent
d8f264eb09
commit
3900be4776
|
@ -34,6 +34,10 @@ struct bus_controller_mapping {
|
|||
uint32_t length;
|
||||
};
|
||||
|
||||
static int bus_open_read(void *opaque, uint32_t address, uint32_t *word);
|
||||
static int bus_dead_write(void *opaque, uint32_t address, uint32_t word,
|
||||
uint32_t dqm);
|
||||
|
||||
// Initializes the bus component.
|
||||
int bus_init(struct bus_controller *bus) {
|
||||
unsigned i;
|
||||
|
@ -82,11 +86,33 @@ int bus_init(struct bus_controller *bus) {
|
|||
|
||||
create_memory_map(&bus->map);
|
||||
|
||||
for (i = 0; i < NUM_MAPPINGS; i++)
|
||||
if (map_address_range(&bus->map, mappings[i].address, mappings[i].length,
|
||||
instances[i], mappings[i].read, mappings[i].write))
|
||||
return 1;
|
||||
for (i = 0; i < NUM_MAPPINGS; i++) {
|
||||
memory_rd_function rd = mappings[i].read;
|
||||
memory_wr_function wr = mappings[i].write;
|
||||
void *instance = instances[i];
|
||||
|
||||
if (instance == bus->dd && bus->dd->ipl_rom == NULL) {
|
||||
rd = bus_open_read;
|
||||
wr = bus_dead_write;
|
||||
instance = NULL;
|
||||
}
|
||||
|
||||
if (map_address_range(&bus->map, mappings[i].address, mappings[i].length,
|
||||
instances[i], rd, wr))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Open read (happens for non-mapped addresses)
|
||||
static int bus_open_read(void *opaque, uint32_t address, uint32_t *word) {
|
||||
*word = (address >> 16) | (address & 0xFFFF0000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bus_dead_write(void *opaque, uint32_t address, uint32_t word,
|
||||
uint32_t dqm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -103,7 +129,7 @@ int bus_read_word(void *component, uint32_t address, uint32_t *word) {
|
|||
else if ((node = resolve_mapped_address(&bus->map, address)) == NULL) {
|
||||
debug("bus_read_word: Failed to access: 0x%.8X\n", address);
|
||||
|
||||
*word = 0x00000000U;
|
||||
*word = (address >> 16) | (address & 0xFFFF0000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,8 +130,17 @@ static int pi_dma_write(struct pi_controller *pi) {
|
|||
|
||||
else if (pi->rom) {
|
||||
if (source + length > pi->rom_size) {
|
||||
unsigned i;
|
||||
|
||||
// TODO: Check for correctness against hardware.
|
||||
// Is this the right address to use for open bus?
|
||||
for (i = (pi->regs[PI_CART_ADDR_REG] + pi->rom_size + 3) & ~0x3;
|
||||
i < pi->regs[PI_CART_ADDR_REG] + length; i += 4) {
|
||||
uint32_t word = (i >> 16) | (i & 0xFFFF0000);
|
||||
memcpy(pi->bus->ri->ram + dest + i, &word, sizeof(word));
|
||||
}
|
||||
|
||||
length = pi->rom_size - source;
|
||||
//assert(0);
|
||||
}
|
||||
|
||||
// TODO: Very hacky.
|
||||
|
@ -164,8 +173,8 @@ int read_cart_rom(void *opaque, uint32_t address, uint32_t *word) {
|
|||
|
||||
// TODO: Need to figure out correct behaviour.
|
||||
// Should this even happen to begin with?
|
||||
if (pi->rom == NULL || offset > pi->rom_size - sizeof(*word)) {
|
||||
*word = 0;
|
||||
if (pi->rom == NULL || offset > (pi->rom_size - sizeof(*word))) {
|
||||
*word = (address >> 16) | (address & 0xFFFF0000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue