Mercurial > repos > blastem
annotate trans.c @ 459:c49ecf575784
Revert change to VBLANK flag timing based on new direct color DMA test
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 08 Sep 2013 20:48:33 -0700 |
parents | 306986209cba |
children | 140af5509ce7 |
rev | line source |
---|---|
18
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "68kinst.h" |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include "m68k_to_x86.h" |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include "mem.h" |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <stdio.h> |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include <stdlib.h> |
440 | 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 } | |
18
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 int main(int argc, char ** argv) |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 { |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 long filesize; |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 unsigned short *filebuf; |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 char disbuf[1024]; |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 unsigned short * cur; |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 x86_68k_options opts; |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 m68k_context context; |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 FILE * f = fopen(argv[1], "rb"); |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 fseek(f, 0, SEEK_END); |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 filesize = ftell(f); |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 fseek(f, 0, SEEK_SET); |
440 | 28 filebuf = malloc(filesize > 0x400000 ? filesize : 0x400000); |
18
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 fread(filebuf, 2, filesize/2, f); |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 fclose(f); |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur) |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 { |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 *cur = (*cur >> 8) | (*cur << 8); |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 } |
440 | 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); | |
18
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 init_68k_context(&context, opts.native_code_map, &opts); |
440 | 49 context.mem_pointers[0] = memmap[0].buffer; |
50 context.mem_pointers[1] = memmap[1].buffer; | |
51 context.target_cycle = context.sync_cycle = 0x80000000; | |
212
e657a99b5abf
Fixed up trans for changes to translate_m68k_stream, but still need to deal with missing callbacks.
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
52 uint32_t address; |
e657a99b5abf
Fixed up trans for changes to translate_m68k_stream, but still need to deal with missing callbacks.
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
53 address = filebuf[2] << 16 | filebuf[3]; |
e657a99b5abf
Fixed up trans for changes to translate_m68k_stream, but still need to deal with missing callbacks.
Mike Pavone <pavone@retrodev.com>
parents:
19
diff
changeset
|
54 translate_m68k_stream(address, &context); |
19
4717146a7606
Initial support for M68k reset vector, rather than starting at an arbitrary address
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
55 m68k_reset(&context); |
18
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 return 0; |
3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 } |
440 | 58 |