Mercurial > repos > blastem
comparison transz80.c @ 235:d9bf8e61c33c
Get Z80 core working for simple programs
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 25 Apr 2013 21:01:11 -0700 |
parents | |
children | df8a36bf5e1d |
comparison
equal
deleted
inserted
replaced
234:f456ee23d372 | 235:d9bf8e61c33c |
---|---|
1 #include "z80inst.h" | |
2 #include "z80_to_x86.h" | |
3 #include "mem.h" | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 | |
7 uint8_t z80_ram[0x2000]; | |
8 | |
9 int main(int argc, char ** argv) | |
10 { | |
11 long filesize; | |
12 uint8_t *filebuf; | |
13 x86_z80_options opts; | |
14 z80_context context; | |
15 FILE * f = fopen(argv[1], "rb"); | |
16 fseek(f, 0, SEEK_END); | |
17 filesize = ftell(f); | |
18 fseek(f, 0, SEEK_SET); | |
19 fread(z80_ram, 1, filesize < sizeof(z80_ram) ? filesize : sizeof(z80_ram), f); | |
20 fclose(f); | |
21 init_x86_z80_opts(&opts); | |
22 init_z80_context(&context, &opts); | |
23 //cartridge ROM | |
24 context.mem_pointers[0] = z80_ram; | |
25 context.target_cycle = 0x7FFFFFFF; | |
26 //work RAM | |
27 context.mem_pointers[1] = context.mem_pointers[2] = NULL; | |
28 z80_reset(&context); | |
29 z80_run(&context); | |
30 return 0; | |
31 } |