5#include "absl/strings/str_format.h"
29 LOG_DEBUG(
"APU_DEBUG",
"Handshake tracker reset");
41 LogPortWrite(
true, port, value, pc,
"HANDSHAKE ACKNOWLEDGE");
42 LOG_INFO(
"APU_DEBUG",
"✓ CPU sent handshake $CC at PC=$%06X", pc);
53 }
else if (port == 1) {
55 bool is_final = (value & 0x01) != 0;
57 is_final ?
"FINAL BLOCK" :
"More blocks");
58 }
else if (port == 2 || port == 3) {
76 LogPortWrite(
false, port, value, pc,
"READY SIGNAL $BBAA");
77 LOG_INFO(
"APU_DEBUG",
"✓ SPC ready signal: F4=$AA F5=$BB at PC=$%04X", pc);
85 LogPortWrite(
false, port, value, pc,
"READY SIGNAL $BBAA");
86 LOG_INFO(
"APU_DEBUG",
"✓ SPC ready signal: F4=$AA F5=$BB at PC=$%04X", pc);
93 int echoed_counter = value;
97 absl::StrFormat(
"Echo counter=%d (byte %d)",
101 absl::StrFormat(
"Counter mismatch! Expected=%d Got=%d",
103 LOG_WARN(
"APU_DEBUG",
"Counter mismatch at PC=$%04X: expected %d, got %d",
115 LOG_INFO(
"APU_DEBUG",
"✓ SPC entered IPL ROM at PC=$%04X", new_pc);
123 LOG_INFO(
"APU_DEBUG",
"✓ Transfer complete! SPC jumped to $%04X (audio driver entry)",
131 if (
phase_ != new_phase) {
132 LOG_DEBUG(
"APU_DEBUG",
"Phase change: %s → %s",
143 default:
return "UNKNOWN";
151 uint32_t pc,
const std::string& desc) {
154 entry.
pc =
static_cast<uint16_t
>(pc & 0xFFFF);
177 default:
return "UNKNOWN";
182 return absl::StrFormat(
183 "Phase: %s | Handshake: %s | Bytes: %d | Blocks: %d",
196 int estimated_total = 8192;
198 percent = std::min(percent, 100);
201 int filled = (percent * bar_width) / 100;
203 std::string bar =
"[";
204 for (
int i = 0; i < bar_width; ++i) {
205 bar += (i < filled) ?
"█" :
"░";
207 bar += absl::StrFormat(
"] %d%%", percent);
std::string GetStatusSummary() const
std::string GetPhaseString() const
void OnCpuPortWrite(uint8_t port, uint8_t value, uint32_t pc)
int total_bytes_transferred_
void UpdatePhase(Phase new_phase)
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_
std::string GetTransferProgress() const
static constexpr size_t kMaxHistorySize
void OnSpcPortWrite(uint8_t port, uint8_t value, uint16_t pc)
std::deque< PortWrite > port_history_
#define LOG_DEBUG(category, format,...)
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
Main namespace for the application.