Split function determining full path to ROM.

Adjust bus tests to this change.
This commit is contained in:
Radosław Kujawa 2017-01-27 12:32:12 +01:00
parent ca291b0336
commit 9122615df4
3 changed files with 25 additions and 9 deletions

View File

@ -3,7 +3,9 @@
#include <stdio.h>
#include <string.h>
#include "rk65c02.h"
#include "bus.h"
#include "utils.h"
ATF_TC_WITHOUT_HEAD(bus_init);
ATF_TC_BODY(bus_init, tc)
@ -21,10 +23,13 @@ ATF_TC_WITHOUT_HEAD(bus_load_file);
ATF_TC_BODY(bus_load_file, tc)
{
bus_t b;
const char *rompath;
b = bus_init();
ATF_REQUIRE(bus_load_file(&b, 0xC000, "test_emulation_nop.rom"));
rompath = rom_path("test_emulation_nop.rom", tc);
ATF_REQUIRE(bus_load_file(&b, 0xC000, rompath));
ATF_CHECK(b.space[0xC000] == 0xEA);

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <atf-c.h>
@ -7,24 +8,33 @@
#include "utils.h"
bool
rom_start(rk65c02emu_t *e, const char *name, const atf_tc_t *tc)
const char *
rom_path(const char *name, const atf_tc_t *tc)
{
char rompath[PATH_MAX];
char *rompath;
const char *srcdir;
rompath = malloc(PATH_MAX);
srcdir = atf_tc_get_config_var(tc, "srcdir");
strcpy(rompath, srcdir);
strcat(rompath, "/");
strcat(rompath, name);
printf("%s\n", rompath);
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);
e->regs.PC = ROM_LOAD_ADDR;
if(!bus_load_file(e->bus, ROM_LOAD_ADDR, rompath))
if(!bus_load_file(e->bus, ROM_LOAD_ADDR, path))
return false;
rk65c02_start(e);
return true;
}

View File

@ -4,4 +4,5 @@
#define ROM_LOAD_ADDR 0xC000
bool rom_start(rk65c02emu_t *, const char *, const atf_tc_t *);
const char * rom_path(const char *, const atf_tc_t *);
#endif /* _UTILS_H_ */