# HG changeset patch # User Mike Pavone # Date 1366129881 25200 # Node ID 464513050c856a492c0e566745fcf6847b4de833 # Parent 4beaad3a9a505bdcb6ce7c0bfc2faae58a870a45 Small bit of cleanup diff -r 4beaad3a9a50 -r 464513050c85 blastem.c --- a/blastem.c Sun Jan 27 13:07:26 2013 -0800 +++ b/blastem.c Tue Apr 16 09:31:21 2013 -0700 @@ -796,6 +796,35 @@ return context; } +void init_run_cpu(vdp_context * vcontext, int debug, FILE * address_log) +{ + m68k_context context; + x86_68k_options opts; + init_x86_68k_opts(&opts); + opts.address_log = address_log; + init_68k_context(&context, opts.native_code_map, &opts); + + context.next_context = vcontext; + //cartridge ROM + context.mem_pointers[0] = cart; + context.target_cycle = context.sync_cycle = MCLKS_PER_FRAME/MCLKS_PER_68K; + //work RAM + context.mem_pointers[1] = ram; + uint32_t address; + /*address = cart[0x68/2] << 16 | cart[0x6A/2]; + translate_m68k_stream(address, &context); + address = cart[0x70/2] << 16 | cart[0x72/2]; + translate_m68k_stream(address, &context); + address = cart[0x78/2] << 16 | cart[0x7A/2]; + translate_m68k_stream(address, &context);*/ + address = cart[2] << 16 | cart[3]; + translate_m68k_stream(address, &context); + if (debug) { + insert_breakpoint(&context, address, (uint8_t *)debugger); + } + m68k_reset(&context); +} + int main(int argc, char ** argv) { if (argc < 2) { @@ -832,33 +861,9 @@ width = width < 320 ? 320 : width; height = height < 240 ? (width/320) * 240 : height; render_init(width, height); - - x86_68k_options opts; - m68k_context context; vdp_context v_context; - init_x86_68k_opts(&opts); - opts.address_log = address_log; - init_68k_context(&context, opts.native_code_map, &opts); init_vdp_context(&v_context); - context.next_context = &v_context; - //cartridge ROM - context.mem_pointers[0] = cart; - context.target_cycle = context.sync_cycle = MCLKS_PER_FRAME/MCLKS_PER_68K; - //work RAM - context.mem_pointers[1] = ram; - uint32_t address; - /*address = cart[0x68/2] << 16 | cart[0x6A/2]; - translate_m68k_stream(address, &context); - address = cart[0x70/2] << 16 | cart[0x72/2]; - translate_m68k_stream(address, &context); - address = cart[0x78/2] << 16 | cart[0x7A/2]; - translate_m68k_stream(address, &context);*/ - address = cart[2] << 16 | cart[3]; - translate_m68k_stream(address, &context); - if (debug) { - insert_breakpoint(&context, address, (uint8_t *)debugger); - } - m68k_reset(&context); + init_run_cpu(&v_context, debug, address_log); return 0; } diff -r 4beaad3a9a50 -r 464513050c85 m68k_to_x86.c --- a/m68k_to_x86.c Sun Jan 27 13:07:26 2013 -0800 +++ b/m68k_to_x86.c Tue Apr 16 09:31:21 2013 -0700 @@ -2,6 +2,7 @@ #include "m68k_to_x86.h" #include "68kinst.h" #include "mem.h" +#include "x86_backend.h" #include #include #include @@ -20,14 +21,6 @@ #define FLAG_Z RDX #define FLAG_C DH -typedef struct { - int32_t disp; - uint8_t mode; - uint8_t base; - uint8_t index; - uint8_t cycles; -} x86_ea; - char disasm_buf[1024]; void handle_cycle_limit_int(); diff -r 4beaad3a9a50 -r 464513050c85 m68k_to_x86.h --- a/m68k_to_x86.h Sun Jan 27 13:07:26 2013 -0800 +++ b/m68k_to_x86.h Tue Apr 16 09:31:21 2013 -0700 @@ -2,6 +2,7 @@ #define M68K_TO_X86_H_ #include #include +#include "x86_backend.h" //#include "68kinst.h" struct m68kinst; @@ -13,11 +14,6 @@ #define MAX_NATIVE_SIZE 255 #define OPT_NATIVE_CALL_STACK 0x1 - -typedef struct { - uint8_t *base; - int32_t *offsets; -} native_map_slot; typedef struct deferred_addr { struct deferred_addr *next; diff -r 4beaad3a9a50 -r 464513050c85 x86_backend.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/x86_backend.h Tue Apr 16 09:31:21 2013 -0700 @@ -0,0 +1,18 @@ +#ifndef X86_BACKEND_H_ +#define X86_BACKEND_H_ + +typedef struct { + int32_t disp; + uint8_t mode; + uint8_t base; + uint8_t index; + uint8_t cycles; +} x86_ea; + +typedef struct { + uint8_t *base; + int32_t *offsets; +} native_map_slot; + +#endif //X86_BACKEND_H_ +