mirror of
https://github.com/libretro/mgba.git
synced 2024-11-30 19:50:34 +00:00
GB: Add basic logging support
This commit is contained in:
parent
487c54f0ac
commit
61e7cc9556
@ -40,7 +40,7 @@ file(GLOB GBA_CHEATS_SRC ${CMAKE_SOURCE_DIR}/src/gba/cheats/*.c)
|
||||
file(GLOB GBA_RR_SRC ${CMAKE_SOURCE_DIR}/src/gba/rr/*.c)
|
||||
file(GLOB GBA_SV_SRC ${CMAKE_SOURCE_DIR}/src/gba/supervisor/*.c)
|
||||
file(GLOB GBA_CTX_SRC ${CMAKE_SOURCE_DIR}/src/gba/context/*.c)
|
||||
file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cSs])
|
||||
file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cSs] ${CMAKE_SOURCE_DIR}/src/core/*.c)
|
||||
file(GLOB GUI_SRC ${CMAKE_SOURCE_DIR}/src/util/gui/*.c ${CMAKE_SOURCE_DIR}/src/gba/gui/*.c)
|
||||
file(GLOB GBA_RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/*.c)
|
||||
file(GLOB SIO_SRC ${CMAKE_SOURCE_DIR}/src/gba/sio/lockstep.c)
|
||||
|
@ -19,6 +19,8 @@ const uint32_t SGB_LR35902_FREQUENCY = 0x418B1E;
|
||||
|
||||
const uint32_t GB_COMPONENT_MAGIC = 0x400000;
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GB);
|
||||
|
||||
static void GBInit(struct LR35902Core* cpu, struct LR35902Component* component);
|
||||
static void GBInterruptHandlerInit(struct LR35902InterruptHandler* irqh);
|
||||
static void GBProcessEvents(struct LR35902Core* cpu);
|
||||
@ -229,7 +231,7 @@ void GBHalt(struct LR35902Core* cpu) {
|
||||
|
||||
void GBHitStub(struct LR35902Core* cpu) {
|
||||
// TODO
|
||||
//printf("Hit stub at address %04X\n", cpu->pc);
|
||||
mLOG(GB, STUB, "Hit stub at address %04X:%02X\n", cpu->pc, cpu->bus);
|
||||
}
|
||||
|
||||
bool GBIsROM(struct VFile* vf) {
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "lr35902/lr35902.h"
|
||||
|
||||
#include "gb/memory.h"
|
||||
@ -18,6 +20,8 @@ extern const uint32_t DMG_LR35902_FREQUENCY;
|
||||
extern const uint32_t CGB_LR35902_FREQUENCY;
|
||||
extern const uint32_t SGB_LR35902_FREQUENCY;
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GB);
|
||||
|
||||
// TODO: Prefix GBAIRQ
|
||||
enum GBIRQ {
|
||||
GB_IRQ_VBLANK = 0x0,
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "gb/gb.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GB_IO);
|
||||
|
||||
void GBIOInit(struct GB* gb) {
|
||||
memset(gb->memory.io, 0, sizeof(gb->memory.io));
|
||||
}
|
||||
|
@ -8,6 +8,10 @@
|
||||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GB_IO);
|
||||
|
||||
enum GBIORegisters {
|
||||
REG_JOYP = 0x00,
|
||||
REG_SB = 0x01,
|
||||
|
@ -10,11 +10,15 @@
|
||||
|
||||
#include "util/memory.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GB_MBC);
|
||||
mLOG_DEFINE_CATEGORY(GB_MEM);
|
||||
|
||||
static void _GBMBCNone(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
// TODO: Log game error
|
||||
UNUSED(memory);
|
||||
UNUSED(address);
|
||||
UNUSED(value);
|
||||
|
||||
mLOG(GB_MBC, GAME_ERROR, "Wrote to invalid MBC");
|
||||
}
|
||||
|
||||
static void _GBMBC1(struct GBMemory*, uint16_t address, uint8_t value);
|
||||
@ -106,7 +110,7 @@ void GBMemoryReset(struct GB* gb) {
|
||||
gb->memory.mbcType = GB_MBC4;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log
|
||||
mLOG(GB_MBC, WARN, "Unknown MBC type: %02X", cart->type);
|
||||
case 0x19:
|
||||
case 0x1A:
|
||||
case 0x1B:
|
||||
@ -166,6 +170,7 @@ uint8_t GBLoad8(struct LR35902Core* cpu, uint16_t address) {
|
||||
return 0xFF;
|
||||
}
|
||||
if (address < GB_BASE_IO) {
|
||||
mLOG(GB_MEM, GAME_ERROR, "Attempt to read from unusable memory: %04X", address);
|
||||
return 0xFF;
|
||||
}
|
||||
if (address < GB_BASE_HRAM) {
|
||||
@ -220,7 +225,7 @@ void GBStore8(struct LR35902Core* cpu, uint16_t address, int8_t value) {
|
||||
gb->video.renderer->writeOAM(gb->video.renderer, address & 0xFF);
|
||||
}
|
||||
} else if (address < GB_BASE_IO) {
|
||||
// TODO: Log
|
||||
mLOG(GB_MEM, GAME_ERROR, "Attempt to write to unusable memory: %04X:%02X", address, value);
|
||||
} else if (address < GB_BASE_HRAM) {
|
||||
GBIOWrite(gb, address & (GB_SIZE_IO - 1), value);
|
||||
} else if (address < GB_BASE_IE) {
|
||||
@ -297,7 +302,7 @@ void GBPatch8(struct LR35902Core* cpu, uint16_t address, int8_t value, int8_t* o
|
||||
static void _switchBank(struct GBMemory* memory, int bank) {
|
||||
size_t bankStart = bank * GB_SIZE_CART_BANK0;
|
||||
if (bankStart + GB_SIZE_CART_BANK0 > memory->romSize) {
|
||||
// TODO: Log
|
||||
mLOG(GB_MBC, GAME_ERROR, "Attempting to switch to an invalid ROM bank: %0X", bank);
|
||||
return;
|
||||
}
|
||||
memory->romBank = &memory->rom[bankStart];
|
||||
@ -324,6 +329,7 @@ void _GBMBC1(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
break;
|
||||
default:
|
||||
// TODO
|
||||
mLOG(GB_MBC, STUB, "MBC1 unknown value %02X", value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -338,7 +344,7 @@ void _GBMBC1(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
}
|
||||
|
||||
void _GBMBC2(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
// TODO
|
||||
mLOG(GB_MBC, STUB, "MBC2 unimplemented");
|
||||
}
|
||||
|
||||
void _GBMBC3(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
@ -355,6 +361,7 @@ void _GBMBC3(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
break;
|
||||
default:
|
||||
// TODO
|
||||
mLOG(GB_MBC, STUB, "MBC3 unknown value %02X", value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -374,6 +381,7 @@ void _GBMBC3(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
|
||||
void _GBMBC4(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
// TODO
|
||||
mLOG(GB_MBC, STUB, "MBC4 unimplemented");
|
||||
}
|
||||
|
||||
void _GBMBC5(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
@ -390,6 +398,7 @@ void _GBMBC5(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
break;
|
||||
default:
|
||||
// TODO
|
||||
mLOG(GB_MBC, STUB, "MBC5 unknown value %02X", value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -402,4 +411,5 @@ void _GBMBC5(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
|
||||
void _GBMBC7(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||
// TODO
|
||||
mLOG(GB_MBC, STUB, "MBC7 unimplemented");
|
||||
}
|
||||
|
@ -8,8 +8,13 @@
|
||||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include "lr35902/lr35902.h"
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GB_MBC);
|
||||
mLOG_DECLARE_CATEGORY(GB_MEM);
|
||||
|
||||
struct GB;
|
||||
|
||||
enum {
|
||||
|
Loading…
Reference in New Issue
Block a user