Reorganize emu folder, update S-SMP system infra

This commit is contained in:
scawful
2023-08-26 01:59:57 -04:00
parent 758056dc98
commit 3d793c452d
19 changed files with 1054 additions and 238 deletions

View File

@@ -15,12 +15,17 @@ add_executable(
yaze_test.cc
z3ed_test.cc
cpu_test.cc
spc700_test.cc
../src/cli/patch.cc
../src/cli/command_handler.cc
compression_test.cc
snes_palette_test.cc
../src/app/rom.cc
../src/app/emu/cpu.cc
../src/app/emu/audio/apu.cc
../src/app/emu/video/ppu.cc
../src/app/emu/audio/dsp.cc
../src/app/emu/audio/spc700.cc
../src/app/gfx/bitmap.cc
../src/app/gfx/snes_tile.cc
../src/app/gfx/snes_palette.cc

View File

@@ -10,7 +10,7 @@ namespace yaze {
namespace app {
namespace emu {
class MockClock : public VirtualClock {
class MockClock : public Clock {
public:
MOCK_METHOD(void, UpdateClock, (double delta), (override));
MOCK_METHOD(unsigned long long, GetCycleCount, (), (const, override));
@@ -150,6 +150,24 @@ class CPUTest : public ::testing::Test {
using ::testing::_;
using ::testing::Return;
TEST_F(CPUTest, CPURunTest) {
// Arrange
EXPECT_CALL(mock_clock, UpdateClock(_)).Times(1);
EXPECT_CALL(mock_clock, GetCycleCount()).WillOnce(Return(1));
EXPECT_CALL(mock_clock, ResetAccumulatedTime()).Times(1);
mock_memory.InsertMemory(0x00, {0x69, 0x01, 0xEA, 0xEA});
// Act
mock_clock.UpdateClock(1.0);
cpu.Update();
mock_clock.ResetAccumulatedTime();
// Assert
// Google Mock will automatically check the expectations
ASSERT_THAT(cpu.A, ::testing::Eq(0x01));
}
// ============================================================================
// Infrastructure
// ============================================================================

26
test/spc700_test.cc Normal file
View File

@@ -0,0 +1,26 @@
#include "app/emu/audio/spc700.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace yaze {
namespace app {
namespace emu {
class MockAudioRAM : public AudioRam {
public:
MOCK_METHOD(uint8_t, read, (uint16_t address), (const, override));
MOCK_METHOD(void, write, (uint16_t address, uint8_t value), (override));
};
class SPC700Test : public ::testing::Test {
protected:
SPC700Test() = default;
MockAudioRAM audioRAM;
SPC700 spc700{audioRAM};
};
} // namespace emu
} // namespace app
} // namespace yaze