Mercurial > repos > blastem
comparison trans.c @ 18:3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 04 Dec 2012 19:13:12 -0800 |
parents | |
children | 4717146a7606 |
comparison
equal
deleted
inserted
replaced
17:de0085d4ea40 | 18:3e7bfde7606e |
---|---|
1 #include "68kinst.h" | |
2 #include "m68k_to_x86.h" | |
3 #include "mem.h" | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 | |
7 int main(int argc, char ** argv) | |
8 { | |
9 long filesize; | |
10 unsigned short *filebuf; | |
11 char disbuf[1024]; | |
12 size_t size = 1024 * 1024; | |
13 uint8_t * transbuf = alloc_code(&size); | |
14 uint8_t *trans_cur, *end; | |
15 unsigned short * cur; | |
16 x86_68k_options opts; | |
17 m68k_context context; | |
18 FILE * f = fopen(argv[1], "rb"); | |
19 fseek(f, 0, SEEK_END); | |
20 filesize = ftell(f); | |
21 fseek(f, 0, SEEK_SET); | |
22 filebuf = malloc(filesize); | |
23 fread(filebuf, 2, filesize/2, f); | |
24 fclose(f); | |
25 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur) | |
26 { | |
27 *cur = (*cur >> 8) | (*cur << 8); | |
28 } | |
29 init_x86_68k_opts(&opts); | |
30 init_68k_context(&context, opts.native_code_map, &opts); | |
31 //cartridge ROM | |
32 context.mem_pointers[0] = filebuf; | |
33 context.target_cycle = 0x7FFFFFFF; | |
34 //work RAM | |
35 context.mem_pointers[1] = malloc(64 * 1024); | |
36 translate_m68k_stream(transbuf, transbuf + size, 0, &context); | |
37 start_68k_context(&context, 0); | |
38 return 0; | |
39 } |