From 5a0f4d989a03ef6b76e866b422f7c3347faeb7d7 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 1 Jul 2009 01:27:45 +0000 Subject: [PATCH] add ideas-style debug console printing commands --- desmume/src/arm_instructions.cpp | 10 +++++++++- desmume/src/debug.cpp | 16 ++++++++++++++++ desmume/src/debug.h | 4 ++++ desmume/src/thumb_instructions.cpp | 11 ++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/desmume/src/arm_instructions.cpp b/desmume/src/arm_instructions.cpp index a377189e7..a0b19d056 100644 --- a/desmume/src/arm_instructions.cpp +++ b/desmume/src/arm_instructions.cpp @@ -7726,8 +7726,16 @@ TEMPLATE static u32 FASTCALL OP_MRC() //--------------SWI------------------------------- TEMPLATE static u32 FASTCALL OP_SWI() { + u32 swinum = (cpu->instruction>>16)&0xFF; + + //ideas-style debug prints + if(swinum==0xFC) { + IdeasLog(cpu); + return 0; + } + if(cpu->swi_tab) { - u32 swinum = (cpu->instruction>>16)&0x1F; + swinum &= 0x1F; return cpu->swi_tab[swinum]() + 3; } else { /* TODO (#1#): translocated SWI vectors */ diff --git a/desmume/src/debug.cpp b/desmume/src/debug.cpp index 93f3625a6..36b6bc820 100644 --- a/desmume/src/debug.cpp +++ b/desmume/src/debug.cpp @@ -21,6 +21,8 @@ #include #include +#include "MMU.h" +#include "armcpu.h" std::vector Logger::channels; @@ -99,3 +101,17 @@ void Logger::log(unsigned int channel, const char * file, unsigned int line, voi channels[channel]->setCallback(callback); } + +void IdeasLog(armcpu_t* cpu) +{ + u32 adr = cpu->R[0]; + printf("EMULOG%c: ",cpu->proc_ID==0?'9':'7'); + for(;;) { + u8 c = MMU_read8(cpu->proc_ID,adr); + adr++; + if(!c) break; + printf("%c",c); + } + printf("\n"); +} + diff --git a/desmume/src/debug.h b/desmume/src/debug.h index 99dea52fc..71a74d4fc 100644 --- a/desmume/src/debug.h +++ b/desmume/src/debug.h @@ -24,6 +24,8 @@ #include #include +struct armcpu_t; + class Logger { protected: void (*callback)(const Logger& logger, const char * format); @@ -112,4 +114,6 @@ public: #define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) #define INFO(...) INFOC(10, __VA_ARGS__) +void IdeasLog(armcpu_t* cpu); + #endif diff --git a/desmume/src/thumb_instructions.cpp b/desmume/src/thumb_instructions.cpp index dfea7e859..0113ce115 100644 --- a/desmume/src/thumb_instructions.cpp +++ b/desmume/src/thumb_instructions.cpp @@ -893,11 +893,20 @@ TEMPLATE static u32 FASTCALL OP_B_COND() TEMPLATE static u32 FASTCALL OP_SWI_THUMB() { + u32 swinum = cpu->instruction & 0xFF; + + //ideas-style debug prints + if(swinum==0xFC) { + IdeasLog(cpu); + return 0; + } + if(cpu->swi_tab) { //zero 25-dec-2008 - in arm, we were masking to 0x1F. //this is probably safer since an invalid opcode could crash the emu + //zero 30-jun-2009 - but they say that the ideas 0xFF should crash the device... //u32 swinum = cpu->instruction & 0xFF; - u32 swinum = cpu->instruction & 0x1F; + swinum &= 0x1F; return cpu->swi_tab[swinum]() + 3; } else {