summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-05-03 21:09:48 -0700
committerMike Pavone <pavone@retrodev.com>2013-05-03 21:09:48 -0700
commit9946025bd5f18d216eadf5abb6a6d75e9f007bc2 (patch)
treeb36ba0702ecc74bf38f27872e659271d4e8c7d8b
parent1c9074ad5bbade02fa7b31056d97c39b32478f6a (diff)
Fix bank register update
-rw-r--r--blastem.c6
-rw-r--r--zruntime.S7
2 files changed, 9 insertions, 4 deletions
diff --git a/blastem.c b/blastem.c
index 371fe22..0697712 100644
--- a/blastem.c
+++ b/blastem.c
@@ -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
@@ -403,11 +403,13 @@ m68k_context * io_write(uint32_t location, m68k_context * context, uint8_t value
} else {
if (busreq) {
dputs("releasing z80 bus");
+ #ifdef DO_DEBUG_PRINT
char fname[20];
sprintf(fname, "zram-%d", zram_counter++);
FILE * f = fopen(fname, "wb");
fwrite(z80_ram, 1, sizeof(z80_ram), f);
fclose(f);
+ #endif
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;
@@ -492,11 +494,13 @@ 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);
+ #ifdef DO_DEBUG_PRINT
char fname[20];
sprintf(fname, "zram-%d", zram_counter++);
FILE * f = fopen(fname, "wb");
fwrite(z80_ram, 1, sizeof(z80_ram), f);
fclose(f);
+ #endif
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/zruntime.S b/zruntime.S
index 07953d8..6731a6f 100644
--- a/zruntime.S
+++ b/zruntime.S
@@ -68,7 +68,7 @@ z80_read_byte_noinc:
cmp $0x8000, %r13w
jae z80_read_bank
/* TODO: Bank reg, YM-2612, PSG/VDP */
- mov $FF, $r13b
+ mov $0xFF, %r13b
ret
z80_read_ram:
and $0x1FFF, %r13
@@ -125,10 +125,11 @@ slow_bank_write:
ret
z80_write_bank_reg:
and $1, %r13w
- shl %r15w
+ shr %r15w
+ shl $8, %r13w
+ xor %r12, %r12
or %r13w, %r15w
and $0x1FF, %r15w
- xor %r12, %r12
cmp $0x80, %r15w
jb update_bank_ptr
ret