yaze
0.3.2
Link to the Past ROM Editor
Loading...
Searching...
No Matches
apu_dsp_test.cc
Go to the documentation of this file.
1
#include <gtest/gtest.h>
2
3
#include "
app/emu/audio/apu.h
"
4
#include "
app/emu/memory/memory.h
"
5
6
namespace
yaze
{
7
namespace
emu {
8
9
class
ApuDspTest
:
public
::testing::Test {
10
protected
:
11
MemoryImpl
mem
;
12
Apu
*
apu
;
13
14
void
SetUp
()
override
{
15
std::vector<uint8_t> dummy_rom(0x200000, 0);
16
mem
.
Initialize
(dummy_rom);
17
apu
=
new
Apu
(
mem
);
18
apu
->
Init
();
19
apu
->
Reset
();
20
}
21
22
void
TearDown
()
override
{
delete
apu
; }
23
};
24
25
TEST_F
(
ApuDspTest
, DspRegistersReadWriteMirror) {
26
// Select register 0x0C (MVOLL)
27
apu->
Write
(0xF2, 0x0C);
28
apu->Write(0xF3, 0x7F);
29
// Read back
30
apu->Write(0xF2, 0x0C);
31
uint8_t mvoll = apu->Read(0xF3);
32
EXPECT_EQ(mvoll, 0x7F);
33
34
// Select register 0x1C (MVOLR)
35
apu->Write(0xF2, 0x1C);
36
apu->Write(0xF3, 0x40);
37
apu->Write(0xF2, 0x1C);
38
uint8_t mvolr = apu->Read(0xF3);
39
EXPECT_EQ(mvolr, 0x40);
40
}
41
42
TEST_F
(
ApuDspTest
, TimersEnableAndReadback) {
43
// Enable timers 0 and 1, clear in-ports, map IPL off for RAM access
44
apu->Write(0xF1, 0x03);
45
46
// Set timer targets
47
apu->Write(0xFA, 0x04);
// timer0 target
48
apu->Write(0xFB, 0x02);
// timer1 target
49
50
// Run enough SPC cycles via APU cycle stepping
51
for
(
int
i = 0; i < 10000; ++i) {
52
apu->Cycle();
53
}
54
55
// Read counters (auto-clears)
56
uint8_t t0 = apu->Read(0xFD);
57
uint8_t t1 = apu->Read(0xFE);
58
// Should be within 0..15 and non-zero under these cycles
59
EXPECT_LE(t0, 0x0F);
60
EXPECT_LE(t1, 0x0F);
61
}
62
63
TEST_F
(
ApuDspTest
, GetSamplesReturnsSilenceAfterReset) {
64
int16_t buffer[2 * 256]{};
65
apu->dsp().GetSamples(buffer, 256,
/*pal=*/
false
);
66
for
(
int
i = 0; i < 256; ++i) {
67
EXPECT_EQ(buffer[i * 2 + 0], 0);
68
EXPECT_EQ(buffer[i * 2 + 1], 0);
69
}
70
}
71
72
}
// namespace emu
73
}
// namespace yaze
74
apu.h
yaze::emu::ApuDspTest
Definition
apu_dsp_test.cc:9
yaze::emu::ApuDspTest::mem
MemoryImpl mem
Definition
apu_dsp_test.cc:11
yaze::emu::ApuDspTest::TearDown
void TearDown() override
Definition
apu_dsp_test.cc:22
yaze::emu::ApuDspTest::apu
Apu * apu
Definition
apu_dsp_test.cc:12
yaze::emu::ApuDspTest::SetUp
void SetUp() override
Definition
apu_dsp_test.cc:14
yaze::emu::Apu
The Apu class represents the Audio Processing Unit (APU) of a system.
Definition
apu.h:53
yaze::emu::Apu::Write
void Write(uint16_t address, uint8_t data)
Definition
apu.cc:233
yaze::emu::Apu::Init
void Init()
Definition
apu.cc:45
yaze::emu::Apu::Reset
void Reset()
Definition
apu.cc:52
yaze::emu::MemoryImpl
Implementation of the Memory interface for emulating memory in a SNES system.
Definition
memory.h:118
yaze::emu::MemoryImpl::Initialize
void Initialize(const std::vector< uint8_t > &romData, bool verbose=false)
Definition
memory.cc:12
memory.h
yaze::emu::TEST_F
TEST_F(ApuDspTest, DspRegistersReadWriteMirror)
Definition
apu_dsp_test.cc:25
yaze
Main namespace for the application.
Definition
asar_wrapper.cc:14
test
unit
emu
apu_dsp_test.cc
Generated by
1.9.8