2017-01-27 11:12:00 +00:00
|
|
|
#include <stdio.h>
|
2017-01-27 11:32:12 +00:00
|
|
|
#include <stdlib.h>
|
2017-01-27 11:12:00 +00:00
|
|
|
#include <limits.h>
|
2018-03-20 11:06:40 +00:00
|
|
|
#include <string.h>
|
2018-03-26 10:36:47 +00:00
|
|
|
|
2017-01-27 11:12:00 +00:00
|
|
|
#include <atf-c.h>
|
2018-03-26 10:36:47 +00:00
|
|
|
#include <gc/gc.h>
|
2017-01-27 11:12:00 +00:00
|
|
|
|
2017-01-26 12:11:37 +00:00
|
|
|
#include "bus.h"
|
|
|
|
#include "rk65c02.h"
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
2017-01-27 11:32:12 +00:00
|
|
|
const char *
|
|
|
|
rom_path(const char *name, const atf_tc_t *tc)
|
2017-01-26 12:11:37 +00:00
|
|
|
{
|
2017-01-27 11:32:12 +00:00
|
|
|
char *rompath;
|
2017-01-27 11:12:00 +00:00
|
|
|
const char *srcdir;
|
2017-01-27 11:32:12 +00:00
|
|
|
|
2018-03-26 10:36:47 +00:00
|
|
|
rompath = GC_MALLOC(PATH_MAX);
|
2017-01-27 11:12:00 +00:00
|
|
|
srcdir = atf_tc_get_config_var(tc, "srcdir");
|
2017-01-27 11:32:12 +00:00
|
|
|
|
2017-01-27 11:12:00 +00:00
|
|
|
strcpy(rompath, srcdir);
|
|
|
|
strcat(rompath, "/");
|
|
|
|
strcat(rompath, name);
|
|
|
|
|
2017-01-27 11:32:12 +00:00
|
|
|
return rompath;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
rom_start(rk65c02emu_t *e, const char *name, const atf_tc_t *tc)
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
path = rom_path(name, tc);
|
|
|
|
printf("%s\n", path);
|
2017-01-26 12:11:37 +00:00
|
|
|
e->regs.PC = ROM_LOAD_ADDR;
|
2017-01-27 11:32:12 +00:00
|
|
|
if(!bus_load_file(e->bus, ROM_LOAD_ADDR, path))
|
2017-01-26 12:11:37 +00:00
|
|
|
return false;
|
|
|
|
rk65c02_start(e);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|