diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-04-25 21:01:11 -0700 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-04-25 21:01:11 -0700 |
commit | 46db74a053d7fca9dee69e8737a435e65b538577 (patch) | |
tree | fa645a9997fac9f040b6664ffbaf9b0733fdc71e /transz80.c | |
parent | 68be5ac1a6452de7333d77b91d5a9634aac05b5b (diff) |
Get Z80 core working for simple programs
Diffstat (limited to 'transz80.c')
-rw-r--r-- | transz80.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/transz80.c b/transz80.c new file mode 100644 index 0000000..3465efb --- /dev/null +++ b/transz80.c @@ -0,0 +1,31 @@ +#include "z80inst.h" +#include "z80_to_x86.h" +#include "mem.h" +#include <stdio.h> +#include <stdlib.h> + +uint8_t z80_ram[0x2000]; + +int main(int argc, char ** argv) +{ + long filesize; + uint8_t *filebuf; + x86_z80_options opts; + z80_context context; + FILE * f = fopen(argv[1], "rb"); + fseek(f, 0, SEEK_END); + filesize = ftell(f); + fseek(f, 0, SEEK_SET); + fread(z80_ram, 1, filesize < sizeof(z80_ram) ? filesize : sizeof(z80_ram), f); + fclose(f); + init_x86_z80_opts(&opts); + init_z80_context(&context, &opts); + //cartridge ROM + context.mem_pointers[0] = z80_ram; + context.target_cycle = 0x7FFFFFFF; + //work RAM + context.mem_pointers[1] = context.mem_pointers[2] = NULL; + z80_reset(&context); + z80_run(&context); + return 0; +} |