Mercurial > repos > blastem
comparison trans.c @ 487:c08a4efeee7f opengl
Update opengl branch from default. Fix build breakage unrelated to merge
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 26 Oct 2013 22:38:47 -0700 |
parents | 140af5509ce7 |
children | 8e395210f50f |
comparison
equal
deleted
inserted
replaced
449:7696d824489d | 487:c08a4efeee7f |
---|---|
1 /* | |
2 Copyright 2013 Michael Pavone | |
3 This file is part of BlastEm. | |
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. | |
5 */ | |
1 #include "68kinst.h" | 6 #include "68kinst.h" |
2 #include "m68k_to_x86.h" | 7 #include "m68k_to_x86.h" |
3 #include "mem.h" | 8 #include "mem.h" |
4 #include <stdio.h> | 9 #include <stdio.h> |
5 #include <stdlib.h> | 10 #include <stdlib.h> |
11 #include <string.h> | |
12 | |
13 m68k_context * sync_components(m68k_context * context, uint32_t address) | |
14 { | |
15 if (context->current_cycle > 0x80000000) { | |
16 context->current_cycle -= 0x80000000; | |
17 } | |
18 return context; | |
19 } | |
6 | 20 |
7 int main(int argc, char ** argv) | 21 int main(int argc, char ** argv) |
8 { | 22 { |
9 long filesize; | 23 long filesize; |
10 unsigned short *filebuf; | 24 unsigned short *filebuf; |
14 m68k_context context; | 28 m68k_context context; |
15 FILE * f = fopen(argv[1], "rb"); | 29 FILE * f = fopen(argv[1], "rb"); |
16 fseek(f, 0, SEEK_END); | 30 fseek(f, 0, SEEK_END); |
17 filesize = ftell(f); | 31 filesize = ftell(f); |
18 fseek(f, 0, SEEK_SET); | 32 fseek(f, 0, SEEK_SET); |
19 filebuf = malloc(filesize); | 33 filebuf = malloc(filesize > 0x400000 ? filesize : 0x400000); |
20 fread(filebuf, 2, filesize/2, f); | 34 fread(filebuf, 2, filesize/2, f); |
21 fclose(f); | 35 fclose(f); |
22 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur) | 36 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur) |
23 { | 37 { |
24 *cur = (*cur >> 8) | (*cur << 8); | 38 *cur = (*cur >> 8) | (*cur << 8); |
25 } | 39 } |
26 init_x86_68k_opts(&opts); | 40 memmap_chunk memmap[2]; |
41 memset(memmap, 0, sizeof(memmap_chunk)*2); | |
42 memmap[0].end = 0x400000; | |
43 memmap[0].mask = 0xFFFFFF; | |
44 memmap[0].flags = MMAP_READ; | |
45 memmap[0].buffer = filebuf; | |
46 | |
47 memmap[1].start = 0xE00000; | |
48 memmap[1].end = 0x1000000; | |
49 memmap[1].mask = 0xFFFF; | |
50 memmap[1].flags = MMAP_READ | MMAP_WRITE | MMAP_CODE; | |
51 memmap[1].buffer = malloc(64 * 1024); | |
52 init_x86_68k_opts(&opts, memmap, 2); | |
27 init_68k_context(&context, opts.native_code_map, &opts); | 53 init_68k_context(&context, opts.native_code_map, &opts); |
28 //cartridge ROM | 54 context.mem_pointers[0] = memmap[0].buffer; |
29 context.mem_pointers[0] = filebuf; | 55 context.mem_pointers[1] = memmap[1].buffer; |
30 context.target_cycle = 0x7FFFFFFF; | 56 context.target_cycle = context.sync_cycle = 0x80000000; |
31 //work RAM | |
32 context.mem_pointers[1] = malloc(64 * 1024); | |
33 uint32_t address; | 57 uint32_t address; |
34 address = filebuf[2] << 16 | filebuf[3]; | 58 address = filebuf[2] << 16 | filebuf[3]; |
35 translate_m68k_stream(address, &context); | 59 translate_m68k_stream(address, &context); |
36 m68k_reset(&context); | 60 m68k_reset(&context); |
37 return 0; | 61 return 0; |
38 } | 62 } |
63 |