# HG changeset patch # User Mike Pavone # Date 1367307560 25200 # Node ID d9417261366fe75b81ececbcc4e42eae32283190 # Parent 852b8765bba66538e140fb5d52a991608de8696b Fix a remaining z80_write reg swap bug. Properly initialize the native map slots. Reset appropriate regs when z80_reset is called. diff -r 852b8765bba6 -r d9417261366f z80_to_x86.c --- a/z80_to_x86.c Tue Apr 30 00:37:30 2013 -0700 +++ b/z80_to_x86.c Tue Apr 30 00:39:20 2013 -0700 @@ -70,7 +70,7 @@ dst = cmp_rr(dst, ZCYCLES, ZLIMIT, SZ_D); uint8_t * jmp_off = dst+1; dst = jcc(dst, CC_NC, dst + 7); - dst = mov_ir(dst, address, SCRATCH2, SZ_W); + dst = mov_ir(dst, address, SCRATCH1, SZ_W); dst = call(dst, (uint8_t *)z80_handle_cycle_limit_int); *jmp_off = dst - (jmp_off+1); return dst; @@ -1166,6 +1166,9 @@ char disbuf[80]; z80_disasm(inst, disbuf); fprintf(stderr, "unimplemented instruction: %s\n", disbuf); + FILE * f = fopen("zram.bin", "wb"); + fwrite(context->mem_pointers[0], 1, 8 * 1024, f); + fclose(f); exit(1); } } @@ -1436,14 +1439,18 @@ { memset(context, 0, sizeof(*context)); context->static_code_map = malloc(sizeof(context->static_code_map)); + context->static_code_map->base = NULL; context->static_code_map->offsets = malloc(sizeof(int32_t) * 0x2000); memset(context->static_code_map->offsets, 0xFF, sizeof(int32_t) * 0x2000); context->banked_code_map = malloc(sizeof(native_map_slot) * (1 << 9)); + memset(context->banked_code_map, 0, sizeof(native_map_slot) * (1 << 9)); context->options = options; } void z80_reset(z80_context * context) { + context->im = 0; + context->iff1 = context->iff2 = 0; context->native_pc = z80_get_native_address_trans(context, 0); } diff -r 852b8765bba6 -r d9417261366f zruntime.S --- a/zruntime.S Tue Apr 30 00:37:30 2013 -0700 +++ b/zruntime.S Tue Apr 30 00:39:20 2013 -0700 @@ -28,14 +28,14 @@ mov 112(%rsi), %ebp /* set cycle limit to sync cycle */ add $7, %ebp sub $2, %r9w - mov %r9w, %r13w + mov %r9w, %r14w call z_inccycles - push %r14 + push %r13 call z80_write_byte_noinc - pop %r14 - mov %r9w, %r13w - add $1, %r13w - shr $8, %r14w + pop %r13 + mov %r9w, %r14w + add $1, %r14w + shr $8, %r13w call z_inccycles call z80_write_byte_noinc /* TODO: Support interrupt mode 0 and 2 */