diff --git a/test/Makefile b/test/Makefile index 3e7da83..6bc4530 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,16 +3,17 @@ LDFLAGS=-latf-c RK6502LIB=../src/librk65c02.a VASM=vasm6502_std VASMFLAGS=-Fbin -c02 +UTILS=utils.o TESTS=test_bus test_emulation TESTROMS:=$(addsuffix .rom,$(basename $(wildcard *.s))) all : $(TESTS) $(TESTROMS) -test_bus : test_bus.o $(RK6502LIB) +test_bus : test_bus.o $(UTILS) $(RK6502LIB) $(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB) -test_emulation : test_emulation.o $(RK6502LIB) +test_emulation : test_emulation.o $(UTILS) $(RK6502LIB) $(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB) %.rom : %.s diff --git a/test/test_emulation.c b/test/test_emulation.c index 3d59293..82b55a5 100644 --- a/test/test_emulation.c +++ b/test/test_emulation.c @@ -6,21 +6,7 @@ #include "bus.h" #include "rk65c02.h" - -#define ROM_LOAD_ADDR 0xC000 - -bool rom_start(rk65c02emu_t *, const char *); - -bool -rom_start(rk65c02emu_t *e, const char *name) -{ - e->regs.PC = ROM_LOAD_ADDR; - if(!bus_load_file(e->bus, ROM_LOAD_ADDR, name)) - return false; - rk65c02_start(e); - - return true; -} +#include "utils.h" ATF_TC_WITHOUT_HEAD(emul_bit); ATF_TC_BODY(emul_bit, tc) diff --git a/test/utils.c b/test/utils.c new file mode 100644 index 0000000..c40d9b0 --- /dev/null +++ b/test/utils.c @@ -0,0 +1,16 @@ +#include "bus.h" +#include "rk65c02.h" + +#include "utils.h" + +bool +rom_start(rk65c02emu_t *e, const char *name) +{ + e->regs.PC = ROM_LOAD_ADDR; + if(!bus_load_file(e->bus, ROM_LOAD_ADDR, name)) + return false; + rk65c02_start(e); + + return true; +} + diff --git a/test/utils.h b/test/utils.h new file mode 100644 index 0000000..4094978 --- /dev/null +++ b/test/utils.h @@ -0,0 +1,7 @@ +#ifndef _UTILS_H_ +#define _UTILS_H_ + +#define ROM_LOAD_ADDR 0xC000 + +bool rom_start(rk65c02emu_t *, const char *); +#endif /* _UTILS_H_ */