aboutsummaryrefslogtreecommitdiff
path: root/src/GBACart.cpp
diff options
context:
space:
mode:
authorJesse Talavera-Greenberg <jesse@jesse.tg>2023-03-23 13:04:38 -0400
committerGitHub <noreply@github.com>2023-03-23 18:04:38 +0100
commit79dfb8dc8f356834f0b6cf7baf73f77552b08923 (patch)
tree9a2a139617b8e178edd153ac68d56f2d0e48e3ed /src/GBACart.cpp
parent19280cff2d3d618f032d0e6ef4b1d4414fa02f58 (diff)
Introduce `Platform::Log` (#1640)
* Add Platform::Log and Platform::LogLevel * Replace most printf calls with Platform::Log calls * Move a brace down * Move some log entries to one Log call - Some implementations of Log may assume a full line * Log the MAC address as LogLevel::Info
Diffstat (limited to 'src/GBACart.cpp')
-rw-r--r--src/GBACart.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/GBACart.cpp b/src/GBACart.cpp
index 68507bc..3f42326 100644
--- a/src/GBACart.cpp
+++ b/src/GBACart.cpp
@@ -23,6 +23,8 @@
#include "CRC32.h"
#include "Platform.h"
+using Platform::Log;
+using Platform::LogLevel;
namespace GBACart
{
@@ -210,7 +212,7 @@ void CartGame::SetupSave(u32 type)
SRAMType = S_NULL;
break;
default:
- printf("!! BAD GBA SAVE LENGTH %d\n", SRAMLength);
+ Log(LogLevel::Warn, "!! BAD GBA SAVE LENGTH %d\n", SRAMLength);
}
if (SRAMType == S_FLASH512K)
@@ -283,7 +285,7 @@ void CartGame::ROMWrite(u32 addr, u16 val)
break;
default:
- printf("Unknown GBA GPIO write 0x%02X @ 0x%04X\n", val, addr);
+ Log(LogLevel::Warn, "Unknown GBA GPIO write 0x%02X @ 0x%04X\n", val, addr);
break;
}
}
@@ -369,7 +371,7 @@ u8 CartGame::SRAMRead_FLASH(u32 addr)
case 0xB0: // bank switching (128K only)
break; // ignore here, handled in Write_Flash()
default:
- printf("GBACart_SRAM::Read_Flash: unknown command 0x%02X @ 0x%04X\n", SRAMFlashState.cmd, addr);
+ Log(LogLevel::Warn, "GBACart_SRAM::Read_Flash: unknown command 0x%02X @ 0x%04X\n", SRAMFlashState.cmd, addr);
break;
}
@@ -502,7 +504,7 @@ void CartGame::SRAMWrite_FLASH(u32 addr, u8 val)
return;
}
- printf("GBACart_SRAM::Write_Flash: unknown write 0x%02X @ 0x%04X (state: 0x%02X)\n",
+ Log(LogLevel::Warn, "GBACart_SRAM::Write_Flash: unknown write 0x%02X @ 0x%04X (state: 0x%02X)\n",
val, addr, SRAMFlashState.state);
}
@@ -586,7 +588,7 @@ void CartGameSolarSensor::ProcessGPIO()
u8 prev = LightSample;
LightCounter = 0;
LightSample = (0xFF - (0x16 + kLuxLevels[LightLevel]));
- printf("Solar sensor reset (sample: 0x%02X -> 0x%02X)\n", prev, LightSample);
+ Log(LogLevel::Debug, "Solar sensor reset (sample: 0x%02X -> 0x%02X)\n", prev, LightSample);
}
if (GPIO.data & 1 && LightEdge) LightCounter++;
@@ -750,7 +752,7 @@ bool LoadROM(const u8* romdata, u32 romlen)
}
catch (const std::bad_alloc& e)
{
- printf("GBACart: failed to allocate memory for ROM (%d bytes)\n", CartROMSize);
+ Log(LogLevel::Error, "GBACart: failed to allocate memory for ROM (%d bytes)\n", CartROMSize);
return false;
}
@@ -759,7 +761,7 @@ bool LoadROM(const u8* romdata, u32 romlen)
char gamecode[5] = { '\0' };
memcpy(&gamecode, CartROM + 0xAC, 4);
- printf("GBA game code: %s\n", gamecode);
+ Log(LogLevel::Info, "GBA game code: %s\n", gamecode);
bool solarsensor = false;
for (size_t i = 0; i < sizeof(SOLAR_SENSOR_GAMECODES)/sizeof(SOLAR_SENSOR_GAMECODES[0]); i++)
@@ -770,7 +772,7 @@ bool LoadROM(const u8* romdata, u32 romlen)
if (solarsensor)
{
- printf("GBA solar sensor support detected!\n");
+ Log(LogLevel::Info, "GBA solar sensor support detected!\n");
}
CartInserted = true;
@@ -817,7 +819,7 @@ void LoadAddon(int type)
break;
default:
- printf("GBACart: !! invalid addon type %d\n", type);
+ Log(LogLevel::Warn, "GBACart: !! invalid addon type %d\n", type);
return;
}