summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-07-16 23:16:50 -0700
committerMike Pavone <pavone@retrodev.com>2013-07-16 23:16:50 -0700
commitb1c5ca7410c3eb512cf51e1f4d0be0ffdcd24ffd (patch)
treef89c79280d01632770ad1e5b269a74e0c7984b17
parentee8dd1c801e8aba14b1c0edafd18c5305d05154e (diff)
Fix 68K test harness
-rwxr-xr-xcomparetests.py2
-rw-r--r--m68k_to_x86.c2
-rw-r--r--trans.c34
3 files changed, 29 insertions, 9 deletions
diff --git a/comparetests.py b/comparetests.py
index 5156895..ce62ae2 100755
--- a/comparetests.py
+++ b/comparetests.py
@@ -31,7 +31,7 @@ for path in glob('generated_tests/*/*.bin'):
if not good:
continue
try:
- b = subprocess.check_output(['./blastem', path, '-v'])
+ b = subprocess.check_output(['./trans', path])
try:
m = subprocess.check_output(['musashi/mustrans', path])
#_,_,b = b.partition('\n')
diff --git a/m68k_to_x86.c b/m68k_to_x86.c
index 6ebc96d..f7e4d02 100644
--- a/m68k_to_x86.c
+++ b/m68k_to_x86.c
@@ -4333,7 +4333,7 @@ uint8_t * gen_mem_fun(x86_68k_options * opts, memmap_chunk * memmap, uint32_t nu
void init_x86_68k_opts(x86_68k_options * opts, memmap_chunk * memmap, uint32_t num_chunks)
{
- opts->flags = 0;
+ memset(opts, 0, sizeof(*opts));
for (int i = 0; i < 8; i++)
opts->dregs[i] = opts->aregs[i] = -1;
opts->dregs[0] = R10;
diff --git a/trans.c b/trans.c
index 357a5f7..33f4dd5 100644
--- a/trans.c
+++ b/trans.c
@@ -3,6 +3,15 @@
#include "mem.h"
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
+m68k_context * sync_components(m68k_context * context, uint32_t address)
+{
+ if (context->current_cycle > 0x80000000) {
+ context->current_cycle -= 0x80000000;
+ }
+ return context;
+}
int main(int argc, char ** argv)
{
@@ -16,23 +25,34 @@ int main(int argc, char ** argv)
fseek(f, 0, SEEK_END);
filesize = ftell(f);
fseek(f, 0, SEEK_SET);
- filebuf = malloc(filesize);
+ filebuf = malloc(filesize > 0x400000 ? filesize : 0x400000);
fread(filebuf, 2, filesize/2, f);
fclose(f);
for(cur = filebuf; cur - filebuf < (filesize/2); ++cur)
{
*cur = (*cur >> 8) | (*cur << 8);
}
- init_x86_68k_opts(&opts);
+ memmap_chunk memmap[2];
+ memset(memmap, 0, sizeof(memmap_chunk)*2);
+ memmap[0].end = 0x400000;
+ memmap[0].mask = 0xFFFFFF;
+ memmap[0].flags = MMAP_READ;
+ memmap[0].buffer = filebuf;
+
+ memmap[1].start = 0xE00000;
+ memmap[1].end = 0x1000000;
+ memmap[1].mask = 0xFFFF;
+ memmap[1].flags = MMAP_READ | MMAP_WRITE | MMAP_CODE;
+ memmap[1].buffer = malloc(64 * 1024);
+ init_x86_68k_opts(&opts, memmap, 2);
init_68k_context(&context, opts.native_code_map, &opts);
- //cartridge ROM
- context.mem_pointers[0] = filebuf;
- context.target_cycle = 0x7FFFFFFF;
- //work RAM
- context.mem_pointers[1] = malloc(64 * 1024);
+ context.mem_pointers[0] = memmap[0].buffer;
+ context.mem_pointers[1] = memmap[1].buffer;
+ context.target_cycle = context.sync_cycle = 0x80000000;
uint32_t address;
address = filebuf[2] << 16 | filebuf[3];
translate_m68k_stream(address, &context);
m68k_reset(&context);
return 0;
}
+