Mercurial > repos > blastem
comparison z80_to_x86.c @ 2418:cc07f544c620
Fix uninitialized base cycle count in Z80 interp path and do a little other interp path cleanup. Fixes issue with 3x3 Eyes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 17 Jan 2024 23:51:37 -0800 |
parents | ed7b4d869989 |
children | 767ec72acca7 |
comparison
equal
deleted
inserted
replaced
2417:9f3008f91bec | 2418:cc07f544c620 |
---|---|
323 exit(0); | 323 exit(0); |
324 } | 324 } |
325 | 325 |
326 void translate_z80inst(z80inst * inst, z80_context * context, uint16_t address, uint8_t interp) | 326 void translate_z80inst(z80inst * inst, z80_context * context, uint16_t address, uint8_t interp) |
327 { | 327 { |
328 uint32_t num_cycles; | 328 uint32_t num_cycles = 0; |
329 host_ea src_op, dst_op; | 329 host_ea src_op, dst_op; |
330 uint8_t size; | 330 uint8_t size; |
331 z80_options *opts = context->options; | 331 z80_options *opts = context->options; |
332 uint8_t * start = opts->gen.code.cur; | 332 uint8_t * start = opts->gen.code.cur; |
333 code_info *code = &opts->gen.code; | 333 code_info *code = &opts->gen.code; |
2859 | 2859 |
2860 code_info z80_make_interp_stub(z80_context * context, uint16_t address) | 2860 code_info z80_make_interp_stub(z80_context * context, uint16_t address) |
2861 { | 2861 { |
2862 z80_options *opts = context->options; | 2862 z80_options *opts = context->options; |
2863 code_info * code = &opts->gen.code; | 2863 code_info * code = &opts->gen.code; |
2864 check_alloc_code(code, 32); | 2864 check_alloc_code(code, 64); |
2865 code_info stub = {code->cur, NULL}; | 2865 code_info stub = {code->cur, NULL}; |
2866 //TODO: make this play well with the breakpoint code | 2866 |
2867 check_cycles_int(&opts->gen, address); | |
2868 if (context->breakpoint_flags[address / 8] & (1 << (address % 8))) { | |
2869 zbreakpoint_patch(context, address, stub.cur); | |
2870 } | |
2871 add_ir(code, 1, opts->regs[Z80_R], SZ_B); | |
2872 #ifdef Z80_LOG_ADDRESS | |
2873 log_address(&opts->gen, address, "Z80: %X @ %d\n"); | |
2874 #endif | |
2867 mov_ir(code, address, opts->gen.scratch1, SZ_W); | 2875 mov_ir(code, address, opts->gen.scratch1, SZ_W); |
2868 call(code, opts->read_8); | 2876 call(code, opts->read_8); |
2869 //opcode fetch M-cycles have one extra T-state | 2877 //opcode fetch M-cycles have one extra T-state |
2870 cycles(&opts->gen, 1); | 2878 cycles(&opts->gen, 1); |
2871 //TODO: increment R | |
2872 check_cycles_int(&opts->gen, address); | |
2873 call(code, opts->gen.save_context); | 2879 call(code, opts->gen.save_context); |
2874 mov_irdisp(code, address, opts->gen.context_reg, offsetof(z80_context, pc), SZ_W); | 2880 mov_irdisp(code, address, opts->gen.context_reg, offsetof(z80_context, pc), SZ_W); |
2875 push_r(code, opts->gen.context_reg); | 2881 push_r(code, opts->gen.context_reg); |
2876 call_args(code, (code_ptr)z80_interp_handler, 2, opts->gen.scratch1, opts->gen.context_reg); | 2882 call_args(code, (code_ptr)z80_interp_handler, 2, opts->gen.scratch1, opts->gen.context_reg); |
2877 mov_rr(code, RAX, opts->gen.scratch1, SZ_PTR); | 2883 mov_rr(code, RAX, opts->gen.scratch1, SZ_PTR); |