From 905c8e53a73940a7d7dfeebc2857f97b692be5c6 Mon Sep 17 00:00:00 2001 From: squall_leonhart69r Date: Wed, 27 Feb 2008 21:51:16 +0000 Subject: [PATCH] added files D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\agbprint.cpp D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBA.cpp D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBA-arm.cpp D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\gbafilter.cpp D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBAGfx.cpp D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBALink.cpp D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBA-thumb.cpp D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\agbprint.h D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBA.h D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBAcpu.h D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\gbafilter.h D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBAGfx.h D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBAinline.h D:\Projects\VisualBoy Advance-M-1.8.0 source\src\agb\GBALink.h git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@396 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/agb/agbprint.cpp | 99 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/agb/agbprint.cpp diff --git a/src/agb/agbprint.cpp b/src/agb/agbprint.cpp new file mode 100644 index 00000000..8b2db30e --- /dev/null +++ b/src/agb/agbprint.cpp @@ -0,0 +1,99 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include + +#include "GBA.h" +#include "../Globals.h" +#include "../Port.h" + +#define debuggerWriteHalfWord(addr, value) \ + WRITE16LE((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], (value)) + +#define debuggerReadHalfWord(addr) \ + READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +static bool agbPrintEnabled = false; +static bool agbPrintProtect = false; + +bool agbPrintWrite(u32 address, u16 value) +{ + if(agbPrintEnabled) { + if(address == 0x9fe2ffe) { // protect + agbPrintProtect = (value != 0); + debuggerWriteHalfWord(address, value); + return true; + } else { + if(agbPrintProtect && + ((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure + || (address >= 0x8fd0000 && address <= 0x8fdffff) + || (address >= 0x9fd0000 && address <= 0x9fdffff))) { + debuggerWriteHalfWord(address, value); + return true; + } + } + } + return false; +} + +void agbPrintReset() +{ + agbPrintProtect = false; +} + +void agbPrintEnable(bool enable) +{ + agbPrintEnabled = enable; +} + +bool agbPrintIsEnabled() +{ + return agbPrintEnabled; +} + +extern void (*dbgOutput)(const char *, u32); + +void agbPrintFlush() +{ + u16 get = debuggerReadHalfWord(0x9fe20fc); + u16 put = debuggerReadHalfWord(0x9fe20fe); + + u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16); + if(address != 0xfd0000 && address != 0x1fd0000) { + dbgOutput("Did you forget to call AGBPrintInit?\n", 0); + // get rid of the text otherwise we will continue to be called + debuggerWriteHalfWord(0x9fe20fc, put); + return; + } + + u8 *data = &rom[address]; + + while(get != put) { + char c = data[get++]; + char s[2]; + s[0] = c; + s[1] = 0; + + if(systemVerbose & VERBOSE_AGBPRINT) + dbgOutput(s, 0); + if(c == '\n') + break; + } + debuggerWriteHalfWord(0x9fe20fc, get); +}