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>
|
|
|
|
#include <atf-c.h>
|
|
|
|
|
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
|
|
|
|
|
|
|
rompath = 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;
|
|
|
|
}
|