summaryrefslogtreecommitdiff
path: root/transz80.c
blob: 3465efbf412bfd3a19910089d2dcdd0bd7c73a3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}