diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-05-03 20:18:28 -0700 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-05-03 20:18:28 -0700 |
commit | 1c9074ad5bbade02fa7b31056d97c39b32478f6a (patch) | |
tree | 14620a1bf2b05761030386ee0ad2bee3c940cc77 | |
parent | 20fa900f979ba887d49cd42a59495ca337964f96 (diff) |
Fix native address lookup in bannked memory area
-rw-r--r-- | blastem.c | 14 | ||||
-rw-r--r-- | z80_to_x86.c | 6 | ||||
-rw-r--r-- | zruntime.S | 1 |
3 files changed, 17 insertions, 4 deletions
@@ -133,7 +133,7 @@ uint8_t busreq = 0; uint8_t busack = 0; uint32_t busack_cycle = CYCLE_NEVER; uint8_t new_busack = 0; -//#define DO_DEBUG_PRINT +#define DO_DEBUG_PRINT #ifdef DO_DEBUG_PRINT #define dprintf printf #define dputs puts @@ -350,6 +350,8 @@ void io_data_read(io_port * pad, m68k_context * context) }*/ } +uint32_t zram_counter = 0; + m68k_context * io_write(uint32_t location, m68k_context * context, uint8_t value) { if (location < 0x10000) { @@ -401,6 +403,11 @@ m68k_context * io_write(uint32_t location, m68k_context * context, uint8_t value } else { if (busreq) { dputs("releasing z80 bus"); + char fname[20]; + sprintf(fname, "zram-%d", zram_counter++); + FILE * f = fopen(fname, "wb"); + fwrite(z80_ram, 1, sizeof(z80_ram), f); + fclose(f); z80_context * z_context = context->next_cpu; //TODO: Add necessary delay between release of busreq and resumption of execution z_context->current_cycle = (context->current_cycle * MCLKS_PER_68K) / MCLKS_PER_Z80; @@ -485,6 +492,11 @@ m68k_context * io_write_w(uint32_t location, m68k_context * context, uint16_t va } else { if (busreq) { dprintf("releasing Z80 bus @ %d\n", (context->current_cycle * MCLKS_PER_68K) / MCLKS_PER_Z80); + char fname[20]; + sprintf(fname, "zram-%d", zram_counter++); + FILE * f = fopen(fname, "wb"); + fwrite(z80_ram, 1, sizeof(z80_ram), f); + fclose(f); z80_context * z_context = context->next_cpu; //TODO: Add necessary delay between release of busreq and resumption of execution z_context->current_cycle = (context->current_cycle * MCLKS_PER_68K) / MCLKS_PER_Z80; diff --git a/z80_to_x86.c b/z80_to_x86.c index e693bbe..7cb6eef 100644 --- a/z80_to_x86.c +++ b/z80_to_x86.c @@ -1421,7 +1421,7 @@ uint8_t * z80_get_native_address(z80_context * context, uint32_t address) map = context->static_code_map; } else if (address >= 0x8000) { address &= 0x7FFF; - map = context->banked_code_map + (context->bank_reg << 15); + map = context->banked_code_map + context->bank_reg; } else { dprintf("z80_get_native_address: %X NULL\n", address); return NULL; @@ -1455,7 +1455,7 @@ void z80_map_native_address(z80_context * context, uint32_t address, uint8_t * n context->ram_code_flags[((address + size) & 0x1C00) >> 10] |= 1 << (((address + size) & 0x380) >> 7); } else if (address >= 0x8000) { address &= 0x7FFF; - map = context->banked_code_map + (context->bank_reg << 15); + map = context->banked_code_map + context->bank_reg; if (!map->offsets) { map->offsets = malloc(sizeof(int32_t) * 0x8000); memset(map->offsets, 0xFF, sizeof(int32_t) * 0x8000); @@ -1474,7 +1474,7 @@ void z80_map_native_address(z80_context * context, uint32_t address, uint8_t * n map = context->static_code_map; } else if (address >= 0x8000) { address &= 0x7FFF; - map = context->banked_code_map + (context->bank_reg << 15); + map = context->banked_code_map + context->bank_reg; } else { return; } @@ -68,6 +68,7 @@ z80_read_byte_noinc: cmp $0x8000, %r13w jae z80_read_bank /* TODO: Bank reg, YM-2612, PSG/VDP */ + mov $FF, $r13b ret z80_read_ram: and $0x1FFF, %r13 |