yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
apu_debugger.h
Go to the documentation of this file.
1// apu_debugger.h - APU Handshake and Transfer Debugging
2
3#ifndef YAZE_APP_EMU_DEBUG_APU_DEBUGGER_H
4#define YAZE_APP_EMU_DEBUG_APU_DEBUGGER_H
5
6#include <cstdint>
7#include <string>
8#include <vector>
9#include <deque>
10
11namespace yaze {
12namespace emu {
13namespace debug {
14
22 public:
23 enum class Phase {
24 RESET, // Initial state
25 IPL_BOOT, // SPC700 executing IPL ROM
26 WAITING_BBAA, // CPU waiting for SPC ready signal ($BBAA)
27 HANDSHAKE_CC, // CPU sent $CC acknowledge
28 TRANSFER_ACTIVE, // Data transfer in progress
29 TRANSFER_DONE, // Audio driver uploaded
30 RUNNING // SPC executing audio driver
31 };
32
33 struct PortWrite {
34 uint64_t timestamp;
35 uint16_t pc; // CPU or SPC program counter
36 uint8_t port; // 0-3 (F4-F7)
37 uint8_t value;
38 bool is_cpu; // true = CPU write, false = SPC write
39 std::string description;
40 };
41
43 uint16_t size;
44 uint16_t dest_address;
47 };
48
50
51 // Event tracking
52 void OnCpuPortWrite(uint8_t port, uint8_t value, uint32_t pc);
53 void OnSpcPortWrite(uint8_t port, uint8_t value, uint16_t pc);
54 void OnSpcPCChange(uint16_t old_pc, uint16_t new_pc);
55
56 // State queries
57 Phase GetPhase() const { return phase_; }
61 int GetBlockCount() const { return blocks_.size(); }
62
63 // Get port write history
64 const std::deque<PortWrite>& GetPortHistory() const { return port_history_; }
65 const std::vector<TransferBlock>& GetBlocks() const { return blocks_; }
66
67 // Visualization
68 std::string GetPhaseString() const;
69 std::string GetStatusSummary() const;
70 std::string GetTransferProgress() const; // Returns progress bar string
71
72 // Reset tracking
73 void Reset();
74
75 private:
76 void UpdatePhase(Phase new_phase);
77 void LogPortWrite(bool is_cpu, uint8_t port, uint8_t value, uint32_t pc,
78 const std::string& desc);
79
81 bool handshake_complete_ = false;
82 bool ipl_rom_enabled_ = true;
83
84 uint8_t cpu_ports_[4] = {0}; // CPU → SPC (in_ports from SPC perspective)
85 uint8_t spc_ports_[4] = {0}; // SPC → CPU (out_ports from SPC perspective)
86
89
90 std::vector<TransferBlock> blocks_;
91 std::deque<PortWrite> port_history_; // Keep last 1000 writes
92
93 static constexpr size_t kMaxHistorySize = 1000;
94};
95
96} // namespace debug
97} // namespace emu
98} // namespace yaze
99
100#endif // YAZE_APP_EMU_DEBUG_APU_DEBUGGER_H
101
IPL ROM handshake tracker.
const std::deque< PortWrite > & GetPortHistory() const
const std::vector< TransferBlock > & GetBlocks() const
void OnCpuPortWrite(uint8_t port, uint8_t value, uint32_t pc)
void OnSpcPCChange(uint16_t old_pc, uint16_t new_pc)
void LogPortWrite(bool is_cpu, uint8_t port, uint8_t value, uint32_t pc, const std::string &desc)
std::vector< TransferBlock > blocks_
static constexpr size_t kMaxHistorySize
void OnSpcPortWrite(uint8_t port, uint8_t value, uint16_t pc)
std::deque< PortWrite > port_history_
Main namespace for the application.