yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
apu.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EMU_APU_H_
2#define YAZE_APP_EMU_APU_H_
3
4#include <cstdint>
5#include <vector>
6#include <array>
7
8#include "app/emu/audio/dsp.h"
11
12namespace yaze {
13namespace emu {
14
15typedef struct Timer {
16 uint8_t cycles;
17 uint8_t divider;
18 uint8_t target;
19 uint8_t counter;
20 bool enabled;
22
48class Apu {
49 public:
50 Apu(MemoryImpl &memory) : memory_(memory) {}
51
52 void Init();
53 void Reset();
54
55 void RunCycles(uint64_t cycles);
56 uint8_t SpcRead(uint16_t address);
57 void SpcWrite(uint16_t address, uint8_t data);
58 void SpcIdle(bool waiting);
59
60 void Cycle();
61
62 uint8_t Read(uint16_t address);
63 void Write(uint16_t address, uint8_t data);
64
65 auto dsp() -> Dsp & { return dsp_; }
66 auto spc700() -> Spc700 & { return spc700_; }
67
68 // Port buffers (equivalent to $2140 to $2143 for the main CPU)
69 std::array<uint8_t, 6> in_ports_; // includes 2 bytes of ram
70 std::array<uint8_t, 4> out_ports_;
71 std::vector<uint8_t> ram = std::vector<uint8_t>(0x10000, 0);
72
73 private:
74 bool rom_readable_ = false;
75
76 uint8_t dsp_adr_ = 0;
77 uint32_t cycles_ = 0;
78
80 std::array<Timer, 3> timer_;
81
83 [&](uint16_t adr, uint8_t val) { SpcWrite(adr, val); },
84 [&](uint16_t adr) { return SpcRead(adr); },
85 [&](bool waiting) { SpcIdle(waiting); },
86 };
89};
90
91} // namespace emu
92} // namespace yaze
93
94#endif
std::array< Timer, 3 > timer_
Definition apu.h:80
uint8_t SpcRead(uint16_t address)
Definition apu.cc:187
uint8_t Read(uint16_t address)
Definition apu.cc:96
uint32_t cycles_
Definition apu.h:77
ApuCallbacks callbacks_
Definition apu.h:82
auto dsp() -> Dsp &
Definition apu.h:65
MemoryImpl & memory_
Definition apu.h:79
void Write(uint16_t address, uint8_t data)
Definition apu.cc:133
void SpcIdle(bool waiting)
Definition apu.cc:197
uint8_t dsp_adr_
Definition apu.h:76
auto spc700() -> Spc700 &
Definition apu.h:66
void Init()
Definition apu.cc:26
void Reset()
Definition apu.cc:37
void RunCycles(uint64_t cycles)
Definition apu.cc:61
Spc700 spc700_
Definition apu.h:88
void SpcWrite(uint16_t address, uint8_t data)
Definition apu.cc:192
Dsp dsp_
Definition apu.h:87
std::vector< uint8_t > ram
Definition apu.h:71
std::array< uint8_t, 4 > out_ports_
Definition apu.h:70
Apu(MemoryImpl &memory)
Definition apu.h:50
bool rom_readable_
Definition apu.h:74
std::array< uint8_t, 6 > in_ports_
Definition apu.h:69
void Cycle()
Definition apu.cc:71
Implementation of the Memory interface for emulating memory in a SNES system.
Definition memory.h:118
The Spc700 class represents the SPC700 processor.
Definition spc700.h:69
SNES Emulation and debugging tools.
Definition apu.cc:13
struct yaze::emu::Timer Timer
Main namespace for the application.
Definition controller.cc:18
bool enabled
Definition apu.h:20
uint8_t counter
Definition apu.h:19
uint8_t divider
Definition apu.h:17
uint8_t target
Definition apu.h:18
uint8_t cycles
Definition apu.h:16