mirror of
https://github.com/rkujawa/rk65c02.git
synced 2025-03-03 14:29:23 +00:00
Split function determining full path to ROM.
Adjust bus tests to this change.
This commit is contained in:
parent
ca291b0336
commit
9122615df4
@ -3,7 +3,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "rk65c02.h"
|
||||||
#include "bus.h"
|
#include "bus.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
ATF_TC_WITHOUT_HEAD(bus_init);
|
ATF_TC_WITHOUT_HEAD(bus_init);
|
||||||
ATF_TC_BODY(bus_init, tc)
|
ATF_TC_BODY(bus_init, tc)
|
||||||
@ -21,10 +23,13 @@ ATF_TC_WITHOUT_HEAD(bus_load_file);
|
|||||||
ATF_TC_BODY(bus_load_file, tc)
|
ATF_TC_BODY(bus_load_file, tc)
|
||||||
{
|
{
|
||||||
bus_t b;
|
bus_t b;
|
||||||
|
const char *rompath;
|
||||||
|
|
||||||
b = bus_init();
|
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);
|
ATF_CHECK(b.space[0xC000] == 0xEA);
|
||||||
|
|
||||||
|
26
test/utils.c
26
test/utils.c
@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <atf-c.h>
|
#include <atf-c.h>
|
||||||
|
|
||||||
@ -7,24 +8,33 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
bool
|
const char *
|
||||||
rom_start(rk65c02emu_t *e, const char *name, const atf_tc_t *tc)
|
rom_path(const char *name, const atf_tc_t *tc)
|
||||||
{
|
{
|
||||||
char rompath[PATH_MAX];
|
char *rompath;
|
||||||
const char *srcdir;
|
const char *srcdir;
|
||||||
|
|
||||||
|
rompath = malloc(PATH_MAX);
|
||||||
srcdir = atf_tc_get_config_var(tc, "srcdir");
|
srcdir = atf_tc_get_config_var(tc, "srcdir");
|
||||||
|
|
||||||
strcpy(rompath, srcdir);
|
strcpy(rompath, srcdir);
|
||||||
strcat(rompath, "/");
|
strcat(rompath, "/");
|
||||||
strcat(rompath, name);
|
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;
|
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;
|
return false;
|
||||||
rk65c02_start(e);
|
rk65c02_start(e);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,4 +4,5 @@
|
|||||||
#define ROM_LOAD_ADDR 0xC000
|
#define ROM_LOAD_ADDR 0xC000
|
||||||
|
|
||||||
bool rom_start(rk65c02emu_t *, const char *, const atf_tc_t *);
|
bool rom_start(rk65c02emu_t *, const char *, const atf_tc_t *);
|
||||||
|
const char * rom_path(const char *, const atf_tc_t *);
|
||||||
#endif /* _UTILS_H_ */
|
#endif /* _UTILS_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user