mirror of https://github.com/inolen/redream.git
get tests back running
This commit is contained in:
parent
f729894480
commit
a039b60d52
|
@ -324,8 +324,8 @@ list(REMOVE_ITEM DREAVM_TEST_SOURCES src/main.cc)
|
|||
# assign source groups for visual studio projects
|
||||
source_group_by_dir(DREAVM_TEST_SOURCES)
|
||||
|
||||
#add_executable(dreavm_test ${DREAVM_TEST_SOURCES})
|
||||
#target_include_directories(dreavm_test PUBLIC deps/gtest-1.7.0/include src/ test/ ${DREAVM_INCLUDE_DIRS})
|
||||
#target_link_libraries(dreavm_test gtest gtest_main ${DREAVM_LIBS})
|
||||
#target_compile_definitions(dreavm_test PRIVATE ${DREAVM_DEFS})
|
||||
#target_compile_options(dreavm_test PRIVATE ${DREAVM_COMPILE_FLAGS})
|
||||
add_executable(dreavm_test ${DREAVM_TEST_SOURCES})
|
||||
target_include_directories(dreavm_test PUBLIC deps/gtest-1.7.0/include src/ test/ ${DREAVM_INCLUDE_DIRS})
|
||||
target_link_libraries(dreavm_test gtest gtest_main ${DREAVM_LIBS})
|
||||
target_compile_definitions(dreavm_test PRIVATE DREAVM_TEST=1 ${DREAVM_DEFS})
|
||||
target_compile_options(dreavm_test PRIVATE ${DREAVM_COMPILE_FLAGS})
|
||||
|
|
|
@ -137,29 +137,17 @@ enum {
|
|||
};
|
||||
|
||||
struct Dreamcast {
|
||||
Dreamcast() {
|
||||
#define HOLLY_REG(addr, name, flags, default, type) \
|
||||
holly_regs[name##_OFFSET] = {flags, default};
|
||||
#include "hw/holly/holly_regs.inc"
|
||||
#undef HOLLY_REG
|
||||
|
||||
#define PVR_REG(addr, name, flags, default, type) \
|
||||
pvr_regs[name##_OFFSET] = {flags, default};
|
||||
#include "hw/holly/pvr2_regs.inc"
|
||||
#undef PVR_REG
|
||||
}
|
||||
|
||||
// uint8_t *aica_regs;
|
||||
Register holly_regs[HOLLY_REG_SIZE >> 2];
|
||||
Register pvr_regs[PVR_REG_SIZE >> 2];
|
||||
|
||||
#define HOLLY_REG(offset, name, flags, default, type) \
|
||||
type &name{reinterpret_cast<type &>(holly_regs[name##_OFFSET].value)};
|
||||
type &name = reinterpret_cast<type &>(holly_regs[name##_OFFSET].value);
|
||||
#include "hw/holly/holly_regs.inc"
|
||||
#undef HOLLY_REG
|
||||
|
||||
#define PVR_REG(offset, name, flags, default, type) \
|
||||
type &name{reinterpret_cast<type &>(pvr_regs[name##_OFFSET].value)};
|
||||
type &name = reinterpret_cast<type &>(pvr_regs[name##_OFFSET].value);
|
||||
#include "hw/holly/pvr2_regs.inc"
|
||||
#undef PVR_REG
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ bool Holly::Init() {
|
|||
maple_ = dc_->maple;
|
||||
sh4_ = dc_->sh4;
|
||||
|
||||
// initialize registers
|
||||
#define HOLLY_REG(addr, name, flags, default, type) \
|
||||
holly_regs_[name##_OFFSET] = {flags, default};
|
||||
#include "hw/holly/holly_regs.inc"
|
||||
#undef HOLLY_REG
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ bool PVR2::Init() {
|
|||
palette_ram_ = dc_->palette_ram;
|
||||
video_ram_ = dc_->video_ram;
|
||||
|
||||
// initialize registers
|
||||
#define PVR_REG(addr, name, flags, default, type) \
|
||||
pvr_regs_[name##_OFFSET] = {flags, default};
|
||||
#include "hw/holly/pvr2_regs.inc"
|
||||
#undef PVR_REG
|
||||
|
||||
ReconfigureSPG();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -80,7 +80,8 @@ void SH4::SetPC(uint32_t pc) { ctx_.pc = pc; }
|
|||
void SH4::Run(const std::chrono::nanoseconds &period) {
|
||||
PROFILER_RUNTIME("SH4::Execute");
|
||||
|
||||
int64_t cycles = NANO_TO_CYCLES(period, SH4_CLOCK_FREQ);
|
||||
// execute at least 1 cycle. the tests rely on this to step block by block
|
||||
int64_t cycles = std::max(NANO_TO_CYCLES(period, SH4_CLOCK_FREQ), 1ll);
|
||||
|
||||
// set current sh4 instance for CompilePC
|
||||
s_current_cpu = this;
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "core/core.h"
|
||||
#include "hw/sh4/sh4.h"
|
||||
#include "hw/dreamcast.h"
|
||||
#include "hw/memory.h"
|
||||
#include "hw/scheduler.h"
|
||||
|
||||
using namespace dvm;
|
||||
using namespace dvm::hw;
|
||||
|
@ -97,7 +99,7 @@ int sh4_num_test_regs =
|
|||
xf12, xf13, xf14, xf15) \
|
||||
SH4Context { \
|
||||
nullptr, nullptr, nullptr, nullptr, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
{r0, r1, r2, r3, r4, r5, r6, r7, \
|
||||
r8, r9, r10, r11, r12, r13, r14, r15}, \
|
||||
{0, 0, 0, 0, 0, 0, 0, 0}, 0, \
|
||||
|
@ -164,8 +166,16 @@ void RunSH4Test(const SH4Test &test) {
|
|||
memmap.Mount(code_handle, code_size, code_address);
|
||||
CHECK(memory.Map(memmap));
|
||||
|
||||
// fake scheduler
|
||||
Scheduler scheduler;
|
||||
|
||||
// initialize fake dreamcast device
|
||||
std::unique_ptr<Dreamcast> dc(new Dreamcast());
|
||||
dc->memory = &memory;
|
||||
dc->scheduler = &scheduler;
|
||||
|
||||
// initialize cpu
|
||||
SH4 sh4(memory);
|
||||
SH4 sh4(dc.get());
|
||||
CHECK(sh4.Init());
|
||||
|
||||
// setup in registers
|
||||
|
@ -193,7 +203,7 @@ void RunSH4Test(const SH4Test &test) {
|
|||
|
||||
// run until the function returns
|
||||
while (sh4.ctx_.pc) {
|
||||
sh4.Run(1);
|
||||
sh4.Run(std::chrono::nanoseconds(1));
|
||||
}
|
||||
|
||||
// validate out registers
|
||||
|
|
Loading…
Reference in New Issue