summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-04-16 09:31:21 -0700
committerMike Pavone <pavone@retrodev.com>2013-04-16 09:31:21 -0700
commit6d83bfe89548daa312e40efda6c1200993d24523 (patch)
treefc1b454f7beda74f18d49776ad3bf17c2e18f555
parente73320f72e5d2a10714672bdbc59e87849100585 (diff)
Small bit of cleanup
-rw-r--r--blastem.c55
-rw-r--r--m68k_to_x86.c9
-rw-r--r--m68k_to_x86.h6
-rw-r--r--x86_backend.h18
4 files changed, 50 insertions, 38 deletions
diff --git a/blastem.c b/blastem.c
index 8946e13..24d56c9 100644
--- a/blastem.c
+++ b/blastem.c
@@ -796,6 +796,35 @@ m68k_context * debugger(m68k_context * context, uint32_t address)
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 @@ int main(int argc, char ** argv)
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 --git a/m68k_to_x86.c b/m68k_to_x86.c
index ab87751..cb29a83 100644
--- a/m68k_to_x86.c
+++ b/m68k_to_x86.c
@@ -2,6 +2,7 @@
#include "m68k_to_x86.h"
#include "68kinst.h"
#include "mem.h"
+#include "x86_backend.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@ -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 --git a/m68k_to_x86.h b/m68k_to_x86.h
index c2711db..9da12be 100644
--- a/m68k_to_x86.h
+++ b/m68k_to_x86.h
@@ -2,6 +2,7 @@
#define M68K_TO_X86_H_
#include <stdint.h>
#include <stdio.h>
+#include "x86_backend.h"
//#include "68kinst.h"
struct m68kinst;
@@ -13,11 +14,6 @@ struct m68kinst;
#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 --git a/x86_backend.h b/x86_backend.h
new file mode 100644
index 0000000..2bfac7e
--- /dev/null
+++ b/x86_backend.h
@@ -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_
+