From e5ebc7679e8b864dee30e7651867fceacbf069b1 Mon Sep 17 00:00:00 2001 From: Abaresk Date: Tue, 9 Jan 2024 12:40:58 -0500 Subject: [PATCH] Print r0 to terminal on 'swi 0xFC' --- src/ARMInterpreter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ARMInterpreter.cpp b/src/ARMInterpreter.cpp index ff73e230..f58b1f4c 100644 --- a/src/ARMInterpreter.cpp +++ b/src/ARMInterpreter.cpp @@ -278,6 +278,20 @@ void A_SVC(ARM* cpu) void T_SVC(ARM* cpu) { + // Print from game. Execute `svc 0xFC` with the null-terminated string address in `r0`. + if ((cpu->CurInstr & 0xFF) == 0xFC) + { + u32 addr = cpu->R[0]; + for (;;) + { + u32 c; + cpu->DataRead8(addr++, &c); + if (!c) break; + printf("%c", c); + } + return; + } + u32 oldcpsr = cpu->CPSR; cpu->CPSR &= ~0xBF; cpu->CPSR |= 0x93;