comparison trans.c @ 440:306986209cba

Fix 68K test harness
author Mike Pavone <pavone@retrodev.com>
date Tue, 16 Jul 2013 23:16:50 -0700
parents e657a99b5abf
children 140af5509ce7
comparison
equal deleted inserted replaced
439:bfbb8613efb4 440:306986209cba
1 #include "68kinst.h" 1 #include "68kinst.h"
2 #include "m68k_to_x86.h" 2 #include "m68k_to_x86.h"
3 #include "mem.h" 3 #include "mem.h"
4 #include <stdio.h> 4 #include <stdio.h>
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h>
7
8 m68k_context * sync_components(m68k_context * context, uint32_t address)
9 {
10 if (context->current_cycle > 0x80000000) {
11 context->current_cycle -= 0x80000000;
12 }
13 return context;
14 }
6 15
7 int main(int argc, char ** argv) 16 int main(int argc, char ** argv)
8 { 17 {
9 long filesize; 18 long filesize;
10 unsigned short *filebuf; 19 unsigned short *filebuf;
14 m68k_context context; 23 m68k_context context;
15 FILE * f = fopen(argv[1], "rb"); 24 FILE * f = fopen(argv[1], "rb");
16 fseek(f, 0, SEEK_END); 25 fseek(f, 0, SEEK_END);
17 filesize = ftell(f); 26 filesize = ftell(f);
18 fseek(f, 0, SEEK_SET); 27 fseek(f, 0, SEEK_SET);
19 filebuf = malloc(filesize); 28 filebuf = malloc(filesize > 0x400000 ? filesize : 0x400000);
20 fread(filebuf, 2, filesize/2, f); 29 fread(filebuf, 2, filesize/2, f);
21 fclose(f); 30 fclose(f);
22 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur) 31 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur)
23 { 32 {
24 *cur = (*cur >> 8) | (*cur << 8); 33 *cur = (*cur >> 8) | (*cur << 8);
25 } 34 }
26 init_x86_68k_opts(&opts); 35 memmap_chunk memmap[2];
36 memset(memmap, 0, sizeof(memmap_chunk)*2);
37 memmap[0].end = 0x400000;
38 memmap[0].mask = 0xFFFFFF;
39 memmap[0].flags = MMAP_READ;
40 memmap[0].buffer = filebuf;
41
42 memmap[1].start = 0xE00000;
43 memmap[1].end = 0x1000000;
44 memmap[1].mask = 0xFFFF;
45 memmap[1].flags = MMAP_READ | MMAP_WRITE | MMAP_CODE;
46 memmap[1].buffer = malloc(64 * 1024);
47 init_x86_68k_opts(&opts, memmap, 2);
27 init_68k_context(&context, opts.native_code_map, &opts); 48 init_68k_context(&context, opts.native_code_map, &opts);
28 //cartridge ROM 49 context.mem_pointers[0] = memmap[0].buffer;
29 context.mem_pointers[0] = filebuf; 50 context.mem_pointers[1] = memmap[1].buffer;
30 context.target_cycle = 0x7FFFFFFF; 51 context.target_cycle = context.sync_cycle = 0x80000000;
31 //work RAM
32 context.mem_pointers[1] = malloc(64 * 1024);
33 uint32_t address; 52 uint32_t address;
34 address = filebuf[2] << 16 | filebuf[3]; 53 address = filebuf[2] << 16 | filebuf[3];
35 translate_m68k_stream(address, &context); 54 translate_m68k_stream(address, &context);
36 m68k_reset(&context); 55 m68k_reset(&context);
37 return 0; 56 return 0;
38 } 57 }
58