mirror of https://github.com/mgba-emu/mgba.git
GBA: Kill GBALog
This commit is contained in:
parent
74fc29fc68
commit
ff637c84d1
|
@ -15,6 +15,8 @@ const uint32_t DEBUGGER_ID = 0xDEADBEEF;
|
|||
DEFINE_VECTOR(DebugBreakpointList, struct DebugBreakpoint);
|
||||
DEFINE_VECTOR(DebugWatchpointList, struct DebugWatchpoint);
|
||||
|
||||
mLOG_DEFINE_CATEGORY(DEBUGGER, "Debugger");
|
||||
|
||||
static struct DebugBreakpoint* _lookupBreakpoint(struct DebugBreakpointList* breakpoints, uint32_t address) {
|
||||
size_t i;
|
||||
for (i = 0; i < DebugBreakpointListSize(breakpoints); ++i) {
|
||||
|
|
|
@ -9,8 +9,11 @@
|
|||
#include "util/common.h"
|
||||
|
||||
#include "arm/arm.h"
|
||||
#include "core/log.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
mLOG_DECLARE_CATEGORY(DEBUGGER);
|
||||
|
||||
extern const uint32_t DEBUGGER_ID;
|
||||
|
||||
enum DebuggerType {
|
||||
|
@ -105,9 +108,6 @@ struct Debugger {
|
|||
|
||||
bool (*setSoftwareBreakpoint)(struct Debugger*, uint32_t address, enum ExecutionMode mode, uint32_t* opcode);
|
||||
bool (*clearSoftwareBreakpoint)(struct Debugger*, uint32_t address, enum ExecutionMode mode, uint32_t opcode);
|
||||
|
||||
ATTRIBUTE_FORMAT(printf, 3, 4)
|
||||
void (*log)(struct Debugger*, enum DebuggerLogLevel, const char* format, ...);
|
||||
};
|
||||
|
||||
void DebuggerCreate(struct Debugger*);
|
||||
|
|
|
@ -100,9 +100,7 @@ static void _ack(struct GDBStub* stub) {
|
|||
|
||||
static void _nak(struct GDBStub* stub) {
|
||||
char nak = '-';
|
||||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_WARN, "Packet error");
|
||||
}
|
||||
mLOG(DEBUGGER, WARN, "Packet error");
|
||||
SocketSend(stub->connection, &nak, 1);
|
||||
}
|
||||
|
||||
|
@ -181,9 +179,7 @@ static void _sendMessage(struct GDBStub* stub) {
|
|||
stub->outgoing[i] = '#';
|
||||
_int2hex8(checksum, &stub->outgoing[i + 1]);
|
||||
stub->outgoing[i + 3] = 0;
|
||||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_DEBUG, "> %s", stub->outgoing);
|
||||
}
|
||||
mLOG(DEBUGGER, DEBUG, "> %s", stub->outgoing);
|
||||
SocketSend(stub->connection, stub->outgoing, i + 3);
|
||||
}
|
||||
|
||||
|
@ -408,9 +404,7 @@ size_t _parseGDBMessage(struct GDBStub* stub, const char* message) {
|
|||
parsed += 2;
|
||||
int networkChecksum = _hex2int(&message[i], 2);
|
||||
if (networkChecksum != checksum) {
|
||||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_WARN, "Checksum error: expected %02x, got %02x", checksum, networkChecksum);
|
||||
}
|
||||
mLOG(DEBUGGER, WARN, "Checksum error: expected %02x, got %02x", checksum, networkChecksum);
|
||||
_nak(stub);
|
||||
return parsed;
|
||||
}
|
||||
|
@ -476,7 +470,6 @@ void GDBStubCreate(struct GDBStub* stub) {
|
|||
stub->d.paused = _gdbStubWait;
|
||||
stub->d.entered = _gdbStubEntered;
|
||||
stub->d.custom = _gdbStubPoll;
|
||||
stub->d.log = 0;
|
||||
stub->untilPoll = GDB_STUB_INTERVAL;
|
||||
stub->lineAck = GDB_ACK_PENDING;
|
||||
stub->shouldBlock = false;
|
||||
|
@ -488,9 +481,7 @@ bool GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAdd
|
|||
}
|
||||
stub->socket = SocketOpenTCP(port, bindAddress);
|
||||
if (SOCKET_FAILED(stub->socket)) {
|
||||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_ERROR, "Couldn't open socket");
|
||||
}
|
||||
mLOG(DEBUGGER, ERROR, "Couldn't open socket");
|
||||
return false;
|
||||
}
|
||||
if (!SocketSetBlocking(stub->socket, false)) {
|
||||
|
@ -504,9 +495,7 @@ bool GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAdd
|
|||
return true;
|
||||
|
||||
cleanup:
|
||||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_ERROR, "Couldn't listen on port");
|
||||
}
|
||||
mLOG(DEBUGGER, ERROR, "Couldn't listen on port");
|
||||
SocketClose(stub->socket);
|
||||
stub->socket = INVALID_SOCKET;
|
||||
return false;
|
||||
|
@ -570,9 +559,7 @@ void GDBStubUpdate(struct GDBStub* stub) {
|
|||
goto connectionLost;
|
||||
}
|
||||
stub->line[messageLen] = '\0';
|
||||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_DEBUG, "< %s", stub->line);
|
||||
}
|
||||
mLOG(DEBUGGER, DEBUG, "< %s", stub->line);
|
||||
ssize_t position = 0;
|
||||
while (position < messageLen) {
|
||||
position += _parseGDBMessage(stub, &stub->line[position]);
|
||||
|
@ -580,8 +567,6 @@ void GDBStubUpdate(struct GDBStub* stub) {
|
|||
}
|
||||
|
||||
connectionLost:
|
||||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_INFO, "Connection lost");
|
||||
}
|
||||
mLOG(DEBUGGER, WARN, "Connection lost");
|
||||
GDBStubHangup(stub);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "gba/serialize.h"
|
||||
#include "gba/video.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_AUDIO, "GBA Audio");
|
||||
|
||||
const unsigned GBA_AUDIO_SAMPLES = 2048;
|
||||
const unsigned GBA_AUDIO_FIFO_SIZE = 8 * sizeof(int32_t);
|
||||
const int GBA_AUDIO_VOLUME_MAX = 0x100;
|
||||
|
@ -118,7 +120,7 @@ void GBAAudioScheduleFifoDma(struct GBAAudio* audio, int number, struct GBADMA*
|
|||
audio->chB.dmaSource = number;
|
||||
break;
|
||||
default:
|
||||
GBALog(audio->p, GBA_LOG_GAME_ERROR, "Invalid FIFO destination: 0x%08X", info->dest);
|
||||
mLOG(GBA_AUDIO, GAME_ERROR, "Invalid FIFO destination: 0x%08X", info->dest);
|
||||
return;
|
||||
}
|
||||
info->reg = GBADMARegisterSetDestControl(info->reg, DMA_FIXED);
|
||||
|
@ -220,7 +222,7 @@ void GBAAudioWriteFIFO(struct GBAAudio* audio, int address, uint32_t value) {
|
|||
fifo = &audio->chB.fifo;
|
||||
break;
|
||||
default:
|
||||
GBALog(audio->p, GBA_LOG_ERROR, "Bad FIFO write to address 0x%03x", address);
|
||||
mLOG(GBA_AUDIO, ERROR, "Bad FIFO write to address 0x%03x", address);
|
||||
return;
|
||||
}
|
||||
int i;
|
||||
|
@ -239,7 +241,7 @@ void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles) {
|
|||
} else if (fifoId == 1) {
|
||||
channel = &audio->chB;
|
||||
} else {
|
||||
GBALog(audio->p, GBA_LOG_ERROR, "Bad FIFO write to address 0x%03x", fifoId);
|
||||
mLOG(GBA_AUDIO, ERROR, "Bad FIFO write to address 0x%03x", fifoId);
|
||||
return;
|
||||
}
|
||||
if (CircleBufferSize(&channel->fifo) <= 4 * sizeof(int32_t) && channel->dmaSource > 0) {
|
||||
|
|
|
@ -9,9 +9,12 @@
|
|||
#include "util/common.h"
|
||||
#include "macros.h"
|
||||
|
||||
#include "core/log.h"
|
||||
#include "gb/audio.h"
|
||||
#include "util/circle-buffer.h"
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_AUDIO);
|
||||
|
||||
struct GBADMA;
|
||||
|
||||
extern const unsigned GBA_AUDIO_SAMPLES;
|
||||
|
|
|
@ -508,11 +508,11 @@ static void _unHuffman(struct GBA* gba) {
|
|||
int remaining = header >> 8;
|
||||
int bits = header & 0xF;
|
||||
if (bits == 0) {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Invalid Huffman bits");
|
||||
mLOG(GBA_BIOS, GAME_ERROR, "Invalid Huffman bits");
|
||||
bits = 8;
|
||||
}
|
||||
if (32 % bits || bits == 1) {
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented unaligned Huffman");
|
||||
mLOG(GBA_BIOS, STUB, "Unimplemented unaligned Huffman");
|
||||
return;
|
||||
}
|
||||
// We assume the signature byte (0x20) is correct
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
const uint32_t GBA_CHEAT_DEVICE_ID = 0xABADC0DE;
|
||||
|
||||
mLOG_DEFINE_CATEGORY(CHEATS, "Cheats");
|
||||
|
||||
DEFINE_VECTOR(GBACheatList, struct GBACheat);
|
||||
DEFINE_VECTOR(GBACheatSets, struct GBACheatSet*);
|
||||
DEFINE_VECTOR(StringList, char*);
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "arm.h"
|
||||
#include "arm/arm.h"
|
||||
#include "core/log.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
#define MAX_ROM_PATCHES 4
|
||||
|
@ -151,6 +152,8 @@ struct GBACheatHook {
|
|||
size_t reentries;
|
||||
};
|
||||
|
||||
mLOG_DECLARE_CATEGORY(CHEATS);
|
||||
|
||||
DECLARE_VECTOR(GBACheatList, struct GBACheat);
|
||||
DECLARE_VECTOR(StringList, char*);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ bool GBACheatAddCodeBreaker(struct GBACheatSet* cheats, uint32_t op1, uint16_t o
|
|||
cheats->incompleteCheat = cheat;
|
||||
break;
|
||||
case CB_FILL_8:
|
||||
GBALog(0, GBA_LOG_STUB, "[Cheat] CodeBreaker code %08X %04X not supported", op1, op2);
|
||||
mLOG(CHEATS, STUB, "CodeBreaker code %08X %04X not supported", op1, op2);
|
||||
return false;
|
||||
case CB_AND_2:
|
||||
cheat = GBACheatListAppend(&cheats->list);
|
||||
|
@ -75,7 +75,7 @@ bool GBACheatAddCodeBreaker(struct GBACheatSet* cheats, uint32_t op1, uint16_t o
|
|||
cheat->width = 2;
|
||||
break;
|
||||
case CB_ENCRYPT:
|
||||
GBALog(0, GBA_LOG_STUB, "[Cheat] CodeBreaker encryption not supported");
|
||||
mLOG(CHEATS, STUB, "CodeBreaker encryption not supported");
|
||||
return false;
|
||||
case CB_IF_NE:
|
||||
cheat = GBACheatListAppend(&cheats->list);
|
||||
|
@ -103,7 +103,7 @@ bool GBACheatAddCodeBreaker(struct GBACheatSet* cheats, uint32_t op1, uint16_t o
|
|||
cheat->repeat = 1;
|
||||
return true;
|
||||
default:
|
||||
GBALog(0, GBA_LOG_STUB, "[Cheat] CodeBreaker code %08X %04X not supported", op1, op2);
|
||||
mLOG(CHEATS, STUB, "CodeBreaker code %08X %04X not supported", op1, op2);
|
||||
return false;
|
||||
}
|
||||
case CB_ADD_2:
|
||||
|
|
|
@ -152,7 +152,7 @@ bool GBACheatAddGameSharkRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t
|
|||
return true;
|
||||
case GSA_BUTTON:
|
||||
// TODO: Implement button
|
||||
GBALog(0, GBA_LOG_STUB, "GameShark button unimplemented");
|
||||
mLOG(CHEATS, STUB, "GameShark button unimplemented");
|
||||
return false;
|
||||
case GSA_IF_EQ:
|
||||
if (op1 == 0xDEADFACE) {
|
||||
|
|
|
@ -109,7 +109,7 @@ static bool _addPAR3Cond(struct GBACheatSet* cheats, uint32_t op1, uint32_t op2)
|
|||
switch (condition) {
|
||||
case PAR3_COND_OTHER:
|
||||
// We shouldn't be able to get here
|
||||
GBALog(0, GBA_LOG_ERROR, "Unexpectedly created 'other' PARv3 code");
|
||||
mLOG(CHEATS, ERROR, "Unexpectedly created 'other' PARv3 code");
|
||||
cheat->type = CHEAT_IF_LAND;
|
||||
cheat->operand = 0;
|
||||
break;
|
||||
|
@ -148,7 +148,7 @@ static bool _addPAR3Special(struct GBACheatSet* cheats, uint32_t op2) {
|
|||
case PAR3_OTHER_BUTTON_2:
|
||||
case PAR3_OTHER_BUTTON_4:
|
||||
// TODO: Button
|
||||
GBALog(0, GBA_LOG_STUB, "GameShark button unimplemented");
|
||||
mLOG(CHEATS, STUB, "GameShark button unimplemented");
|
||||
return false;
|
||||
// TODO: Fix overriding existing patches
|
||||
case PAR3_OTHER_PATCH_1:
|
||||
|
|
|
@ -225,7 +225,7 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
|||
int32_t testEvent;
|
||||
#ifndef NDEBUG
|
||||
if (cycles < 0) {
|
||||
GBALog(gba, GBA_LOG_FATAL, "Negative cycles passed: %i", cycles);
|
||||
mLOG(GBA, FATAL, "Negative cycles passed: %i", cycles);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -434,7 +434,7 @@ bool GBALoadMB(struct GBA* gba, struct VFile* vf, const char* fname) {
|
|||
gba->pristineRom = vf->map(vf, gba->pristineRomSize, MAP_READ);
|
||||
#endif
|
||||
if (!gba->pristineRom) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM");
|
||||
mLOG(GBA, WARN, "Couldn't map ROM");
|
||||
return false;
|
||||
}
|
||||
gba->yankedRomSize = 0;
|
||||
|
@ -463,7 +463,7 @@ bool GBALoadROM2(struct GBA* gba, struct VFile* vf) {
|
|||
gba->pristineRom = vf->map(vf, gba->pristineRomSize, MAP_READ);
|
||||
#endif
|
||||
if (!gba->pristineRom) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM");
|
||||
mLOG(GBA, WARN, "Couldn't map ROM");
|
||||
return false;
|
||||
}
|
||||
gba->yankedRomSize = 0;
|
||||
|
@ -476,15 +476,6 @@ bool GBALoadROM2(struct GBA* gba, struct VFile* vf) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname) {
|
||||
if (!GBALoadROM2(gba, vf)) {
|
||||
return false;
|
||||
}
|
||||
gba->activeFile = fname;
|
||||
GBALoadSave(gba, sav);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GBALoadSave(struct GBA* gba, struct VFile* sav) {
|
||||
GBASavedataInit(&gba->memory.savedata, sav);
|
||||
return true;
|
||||
|
@ -501,19 +492,19 @@ void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {
|
|||
gba->biosVf = vf;
|
||||
uint32_t* bios = vf->map(vf, SIZE_BIOS, MAP_READ);
|
||||
if (!bios) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Couldn't map BIOS");
|
||||
mLOG(GBA, WARN, "Couldn't map BIOS");
|
||||
return;
|
||||
}
|
||||
gba->memory.bios = bios;
|
||||
gba->memory.fullBios = 1;
|
||||
uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
|
||||
GBALog(gba, GBA_LOG_DEBUG, "BIOS Checksum: 0x%X", checksum);
|
||||
mLOG(GBA, DEBUG, "BIOS Checksum: 0x%X", checksum);
|
||||
if (checksum == GBA_BIOS_CHECKSUM) {
|
||||
GBALog(gba, GBA_LOG_INFO, "Official GBA BIOS detected");
|
||||
mLOG(GBA, INFO, "Official GBA BIOS detected");
|
||||
} else if (checksum == GBA_DS_BIOS_CHECKSUM) {
|
||||
GBALog(gba, GBA_LOG_INFO, "Official GBA (DS) BIOS detected");
|
||||
mLOG(GBA, INFO, "Official GBA (DS) BIOS detected");
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_WARN, "BIOS checksum incorrect");
|
||||
mLOG(GBA, WARN, "BIOS checksum incorrect");
|
||||
}
|
||||
gba->biosChecksum = checksum;
|
||||
if (gba->memory.activeRegion == REGION_BIOS) {
|
||||
|
@ -606,7 +597,7 @@ void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t control) {
|
|||
|
||||
void GBAWriteIE(struct GBA* gba, uint16_t value) {
|
||||
if (value & (1 << IRQ_KEYPAD)) {
|
||||
GBALog(gba, GBA_LOG_STUB, "Keypad interrupts not implemented");
|
||||
mLOG(GBA, STUB, "Keypad interrupts not implemented");
|
||||
}
|
||||
|
||||
if (gba->memory.io[REG_IME >> 1] && value & gba->memory.io[REG_IF >> 1]) {
|
||||
|
@ -650,14 +641,6 @@ void GBAStop(struct GBA* gba) {
|
|||
gba->stopCallback->stop(gba->stopCallback);
|
||||
}
|
||||
|
||||
void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...) {
|
||||
// TODO: Kill GBALog
|
||||
}
|
||||
|
||||
void GBADebuggerLogShim(struct Debugger* debugger, enum DebuggerLogLevel level, const char* format, ...) {
|
||||
// TODO: Kill GBADebuggerLogShim
|
||||
}
|
||||
|
||||
bool GBAIsROM(struct VFile* vf) {
|
||||
if (vf->seek(vf, GBA_ROM_MAGIC_OFFSET, SEEK_SET) < 0) {
|
||||
return false;
|
||||
|
@ -744,22 +727,22 @@ void GBAGetGameTitle(struct GBA* gba, char* out) {
|
|||
|
||||
void GBAHitStub(struct ARMCore* cpu, uint32_t opcode) {
|
||||
struct GBA* gba = (struct GBA*) cpu->master;
|
||||
enum GBALogLevel level = GBA_LOG_ERROR;
|
||||
if (gba->debugger) {
|
||||
level = GBA_LOG_STUB;
|
||||
struct DebuggerEntryInfo info = {
|
||||
.address = _ARMPCAddress(cpu),
|
||||
.opcode = opcode
|
||||
};
|
||||
DebuggerEnter(gba->debugger, DEBUGGER_ENTER_ILLEGAL_OP, &info);
|
||||
}
|
||||
GBALog(gba, level, "Stub opcode: %08x", opcode);
|
||||
// TODO: More sensible category?
|
||||
mLOG(GBA, ERROR, "Stub opcode: %08x", opcode);
|
||||
}
|
||||
|
||||
void GBAIllegal(struct ARMCore* cpu, uint32_t opcode) {
|
||||
struct GBA* gba = (struct GBA*) cpu->master;
|
||||
if (!gba->yankedRomSize) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Illegal opcode: %08x", opcode);
|
||||
// TODO: More sensible category?
|
||||
mLOG(GBA, WARN, "Illegal opcode: %08x", opcode);
|
||||
}
|
||||
if (gba->debugger) {
|
||||
struct DebuggerEntryInfo info = {
|
||||
|
|
|
@ -170,7 +170,6 @@ void GBASetBreakpoint(struct GBA* gba, struct mCPUComponent* component, uint32_t
|
|||
uint32_t* opcode);
|
||||
void GBAClearBreakpoint(struct GBA* gba, uint32_t address, enum ExecutionMode mode, uint32_t opcode);
|
||||
|
||||
bool GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname);
|
||||
bool GBALoadROM2(struct GBA* gba, struct VFile* vf);
|
||||
bool GBALoadSave(struct GBA* gba, struct VFile* sav);
|
||||
void GBAYankROM(struct GBA* gba);
|
||||
|
@ -189,10 +188,4 @@ void GBAGetGameTitle(struct GBA* gba, char* out);
|
|||
void GBAFrameStarted(struct GBA* gba);
|
||||
void GBAFrameEnded(struct GBA* gba);
|
||||
|
||||
ATTRIBUTE_FORMAT(printf, 3, 4)
|
||||
void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...);
|
||||
|
||||
ATTRIBUTE_FORMAT(printf, 3, 4)
|
||||
void GBADebuggerLogShim(struct Debugger* debugger, enum DebuggerLogLevel level, const char* format, ...);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "util/formatting.h"
|
||||
#include "util/hash.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_HW, "GBA Pak Hardware");
|
||||
|
||||
const int GBA_LUX_LEVELS[10] = { 5, 11, 18, 27, 42, 62, 84, 109, 139, 183 };
|
||||
|
||||
static void _readPins(struct GBACartridgeHardware* hw);
|
||||
|
@ -84,7 +86,7 @@ void GBAHardwareGPIOWrite(struct GBACartridgeHardware* hw, uint32_t address, uin
|
|||
hw->readWrite = value;
|
||||
break;
|
||||
default:
|
||||
GBALog(hw->p, GBA_LOG_WARN, "Invalid GPIO address");
|
||||
mLOG(GBA_HW, WARN, "Invalid GPIO address");
|
||||
}
|
||||
if (hw->readWrite) {
|
||||
uint16_t old;
|
||||
|
@ -173,7 +175,7 @@ void _rtcReadPins(struct GBACartridgeHardware* hw) {
|
|||
// GPIO direction should always != reading
|
||||
if (hw->direction & 2) {
|
||||
if (RTCCommandDataIsReading(hw->rtc.command)) {
|
||||
GBALog(hw->p, GBA_LOG_GAME_ERROR, "Attempting to write to RTC while in read mode");
|
||||
mLOG(GBA_HW, GAME_ERROR, "Attempting to write to RTC while in read mode");
|
||||
}
|
||||
++hw->rtc.bitsRead;
|
||||
if (hw->rtc.bitsRead == 8) {
|
||||
|
@ -226,7 +228,7 @@ void _rtcProcessByte(struct GBACartridgeHardware* hw) {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
GBALog(hw->p, GBA_LOG_WARN, "Invalid RTC command byte: %02X", hw->rtc.bits);
|
||||
mLOG(GBA_HW, WARN, "Invalid RTC command byte: %02X", hw->rtc.bits);
|
||||
}
|
||||
} else {
|
||||
switch (RTCCommandDataGetCommand(hw->rtc.command)) {
|
||||
|
@ -234,7 +236,7 @@ void _rtcProcessByte(struct GBACartridgeHardware* hw) {
|
|||
hw->rtc.control = hw->rtc.bits;
|
||||
break;
|
||||
case RTC_FORCE_IRQ:
|
||||
GBALog(hw->p, GBA_LOG_STUB, "Unimplemented RTC command %u", RTCCommandDataGetCommand(hw->rtc.command));
|
||||
mLOG(GBA_HW, STUB, "Unimplemented RTC command %u", RTCCommandDataGetCommand(hw->rtc.command));
|
||||
break;
|
||||
case RTC_RESET:
|
||||
case RTC_DATETIME:
|
||||
|
@ -388,7 +390,7 @@ void _lightReadPins(struct GBACartridgeHardware* hw) {
|
|||
}
|
||||
if (hw->pinState & 2) {
|
||||
struct GBALuminanceSource* lux = hw->p->luminanceSource;
|
||||
GBALog(hw->p, GBA_LOG_DEBUG, "[SOLAR] Got reset");
|
||||
mLOG(GBA_HW, DEBUG, "[SOLAR] Got reset");
|
||||
hw->lightCounter = 0;
|
||||
if (lux) {
|
||||
lux->sample(lux);
|
||||
|
@ -404,7 +406,7 @@ void _lightReadPins(struct GBACartridgeHardware* hw) {
|
|||
|
||||
bool sendBit = hw->lightCounter >= hw->lightSample;
|
||||
_outputPins(hw, sendBit << 3);
|
||||
GBALog(hw->p, GBA_LOG_DEBUG, "[SOLAR] Output %u with pins %u", hw->lightCounter, hw->pinState);
|
||||
mLOG(GBA_HW, DEBUG, "[SOLAR] Output %u with pins %u", hw->lightCounter, hw->pinState);
|
||||
}
|
||||
|
||||
// == Tilt
|
||||
|
@ -422,7 +424,7 @@ void GBAHardwareTiltWrite(struct GBACartridgeHardware* hw, uint32_t address, uin
|
|||
if (value == 0x55) {
|
||||
hw->tiltState = 1;
|
||||
} else {
|
||||
GBALog(hw->p, GBA_LOG_GAME_ERROR, "Tilt sensor wrote wrong byte to %04x: %02x", address, value);
|
||||
mLOG(GBA_HW, GAME_ERROR, "Tilt sensor wrote wrong byte to %04x: %02x", address, value);
|
||||
}
|
||||
break;
|
||||
case 0x8100:
|
||||
|
@ -441,11 +443,11 @@ void GBAHardwareTiltWrite(struct GBACartridgeHardware* hw, uint32_t address, uin
|
|||
hw->tiltX = (x >> 21) + 0x3A0; // Crop off an extra bit so that we can't go negative
|
||||
hw->tiltY = (y >> 21) + 0x3A0;
|
||||
} else {
|
||||
GBALog(hw->p, GBA_LOG_GAME_ERROR, "Tilt sensor wrote wrong byte to %04x: %02x", address, value);
|
||||
mLOG(GBA_HW, GAME_ERROR, "Tilt sensor wrote wrong byte to %04x: %02x", address, value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GBALog(hw->p, GBA_LOG_GAME_ERROR, "Invalid tilt sensor write to %04x: %02x", address, value);
|
||||
mLOG(GBA_HW, GAME_ERROR, "Invalid tilt sensor write to %04x: %02x", address, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -461,7 +463,7 @@ uint8_t GBAHardwareTiltRead(struct GBACartridgeHardware* hw, uint32_t address) {
|
|||
case 0x8500:
|
||||
return (hw->tiltY >> 8) & 0xF;
|
||||
default:
|
||||
GBALog(hw->p, GBA_LOG_GAME_ERROR, "Invalid tilt sensor read from %04x", address);
|
||||
mLOG(GBA_HW, GAME_ERROR, "Invalid tilt sensor read from %04x", address);
|
||||
break;
|
||||
}
|
||||
return 0xFF;
|
||||
|
|
|
@ -7,12 +7,16 @@
|
|||
#define GBA_HARDWARE_H
|
||||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
#include "gba/interface.h"
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_HW);
|
||||
|
||||
#define IS_GPIO_REGISTER(reg) ((reg) == GPIO_REG_DATA || (reg) == GPIO_REG_DIRECTION || (reg) == GPIO_REG_CONTROL)
|
||||
|
||||
struct GBARTCGenericSource {
|
||||
|
|
|
@ -10,21 +10,6 @@
|
|||
|
||||
#include "core/interface.h"
|
||||
|
||||
enum GBALogLevel {
|
||||
GBA_LOG_FATAL = 0x01,
|
||||
GBA_LOG_ERROR = 0x02,
|
||||
GBA_LOG_WARN = 0x04,
|
||||
GBA_LOG_INFO = 0x08,
|
||||
GBA_LOG_DEBUG = 0x10,
|
||||
GBA_LOG_STUB = 0x20,
|
||||
|
||||
GBA_LOG_GAME_ERROR = 0x100,
|
||||
GBA_LOG_STATUS = 0x400,
|
||||
GBA_LOG_SIO = 0x800,
|
||||
|
||||
GBA_LOG_ALL = 0xF3F,
|
||||
};
|
||||
|
||||
enum GBASIOMode {
|
||||
SIO_NORMAL_8 = 0,
|
||||
SIO_NORMAL_32 = 1,
|
||||
|
|
12
src/gba/io.c
12
src/gba/io.c
|
@ -10,6 +10,8 @@
|
|||
#include "gba/sio.h"
|
||||
#include "gba/video.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_IO, "GBA I/O");
|
||||
|
||||
const char* GBAIORegisterNames[] = {
|
||||
// Video
|
||||
"DISPCNT",
|
||||
|
@ -533,9 +535,9 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
|
|||
// Some bad interrupt libraries will write to this
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_STUB, "Stub I/O register write: %03X", address);
|
||||
mLOG(GBA_IO, STUB, "Stub I/O register write: %03X", address);
|
||||
if (address >= REG_MAX) {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Write to unused I/O register: %03X", address);
|
||||
mLOG(GBA_IO, GAME_ERROR, "Write to unused I/O register: %03X", address);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -751,7 +753,7 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) {
|
|||
case REG_DMA3DAD_HI:
|
||||
case REG_DMA3CNT_LO:
|
||||
// Write-only register
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Read from write-only I/O register: %03X", address);
|
||||
mLOG(GBA_IO, GAME_ERROR, "Read from write-only I/O register: %03X", address);
|
||||
return GBALoadBad(gba->cpu);
|
||||
|
||||
case REG_SOUNDBIAS:
|
||||
|
@ -760,7 +762,7 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) {
|
|||
case REG_JOY_TRANS:
|
||||
case REG_KEYCNT:
|
||||
case REG_POSTFLG:
|
||||
GBALog(gba, GBA_LOG_STUB, "Stub I/O register read: %03x", address);
|
||||
mLOG(GBA_IO, STUB, "Stub I/O register read: %03x", address);
|
||||
break;
|
||||
case REG_SOUND1CNT_LO:
|
||||
case REG_SOUND1CNT_HI:
|
||||
|
@ -822,7 +824,7 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) {
|
|||
// Some bad interrupt libraries will read from this
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Read from unused I/O register: %03X", address);
|
||||
mLOG(GBA_IO, GAME_ERROR, "Read from unused I/O register: %03X", address);
|
||||
return GBALoadBad(gba->cpu);
|
||||
}
|
||||
return gba->memory.io[address >> 1];
|
||||
|
|
|
@ -151,6 +151,8 @@ enum GBAIORegisters {
|
|||
REG_HALTCNT = 0x301
|
||||
};
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_IO);
|
||||
|
||||
extern const char* GBAIORegisterNames[];
|
||||
|
||||
void GBAIOInit(struct GBA* gba);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#define IDLE_LOOP_THRESHOLD 10000
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_MEM, "GBA Memory");
|
||||
|
||||
static void _pristineCow(struct GBA* gba);
|
||||
static uint32_t _deadbeef[1] = { 0xE710B710 }; // Illegal instruction on both ARM and Thumb
|
||||
|
||||
|
@ -123,7 +125,7 @@ void GBAMemoryReset(struct GBA* gba) {
|
|||
|
||||
if (!gba->memory.wram || !gba->memory.iwram) {
|
||||
GBAMemoryDeinit(gba);
|
||||
GBALog(gba, GBA_LOG_FATAL, "Could not map memory");
|
||||
mLOG(GBA_MEM, FATAL, "Could not map memory");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,11 +293,11 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
|||
memory->activeRegion = -1;
|
||||
cpu->memory.activeRegion = _deadbeef;
|
||||
cpu->memory.activeMask = 0;
|
||||
enum GBALogLevel errorLevel = GBA_LOG_FATAL;
|
||||
if (gba->yankedRomSize || !gba->hardCrash) {
|
||||
errorLevel = GBA_LOG_GAME_ERROR;
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Jumped to invalid address: %08X", address);
|
||||
} else {
|
||||
mLOG(GBA_MEM, FATAL, "Jumped to invalid address: %08X", address);
|
||||
}
|
||||
GBALog(gba, errorLevel, "Jumped to invalid address: %08X", address);
|
||||
return;
|
||||
}
|
||||
cpu->memory.activeSeqCycles32 = memory->waitstatesSeq32[memory->activeRegion];
|
||||
|
@ -337,11 +339,11 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
|||
if (memory->activeRegion == REGION_BIOS) { \
|
||||
LOAD_32(value, address, memory->bios); \
|
||||
} else { \
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load32: 0x%08X", address); \
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad BIOS Load32: 0x%08X", address); \
|
||||
value = memory->biosPrefetch; \
|
||||
} \
|
||||
} else { \
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load32: 0x%08X", address); \
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Load32: 0x%08X", address); \
|
||||
LOAD_BAD; \
|
||||
}
|
||||
|
||||
|
@ -371,7 +373,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
|||
if ((address & (SIZE_CART0 - 1)) < memory->romSize) { \
|
||||
LOAD_32(value, address & (SIZE_CART0 - 4), memory->rom); \
|
||||
} else { \
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Out of bounds ROM Load32: 0x%08X", address); \
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Out of bounds ROM Load32: 0x%08X", address); \
|
||||
value = ((address & ~3) >> 1) & 0xFFFF; \
|
||||
value |= (((address & ~3) + 2) >> 1) << 16; \
|
||||
}
|
||||
|
@ -431,7 +433,7 @@ uint32_t GBALoad32(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
LOAD_SRAM;
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load32: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Load32: 0x%08X", address);
|
||||
LOAD_BAD;
|
||||
break;
|
||||
}
|
||||
|
@ -460,11 +462,11 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
if (memory->activeRegion == REGION_BIOS) {
|
||||
LOAD_16(value, address, memory->bios);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad BIOS Load16: 0x%08X", address);
|
||||
value = (memory->biosPrefetch >> ((address & 2) * 8)) & 0xFFFF;
|
||||
}
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Load16: 0x%08X", address);
|
||||
LOAD_BAD;
|
||||
value = (value >> ((address & 2) * 8)) & 0xFFFF;
|
||||
}
|
||||
|
@ -501,7 +503,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
if ((address & (SIZE_CART0 - 1)) < memory->romSize) {
|
||||
LOAD_16(value, address & (SIZE_CART0 - 2), memory->rom);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Out of bounds ROM Load16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Out of bounds ROM Load16: 0x%08X", address);
|
||||
value = (address >> 1) & 0xFFFF;
|
||||
}
|
||||
break;
|
||||
|
@ -512,7 +514,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
} else if ((address & (SIZE_CART0 - 1)) < memory->romSize) {
|
||||
LOAD_16(value, address & (SIZE_CART0 - 2), memory->rom);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Out of bounds ROM Load16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Out of bounds ROM Load16: 0x%08X", address);
|
||||
value = (address >> 1) & 0xFFFF;
|
||||
}
|
||||
break;
|
||||
|
@ -523,7 +525,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
value |= value << 8;
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Load16: 0x%08X", address);
|
||||
LOAD_BAD;
|
||||
value = (value >> ((address & 2) * 8)) & 0xFFFF;
|
||||
break;
|
||||
|
@ -553,11 +555,11 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
if (memory->activeRegion == REGION_BIOS) {
|
||||
value = ((uint8_t*) memory->bios)[address];
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad BIOS Load8: 0x%08X", address);
|
||||
value = (memory->biosPrefetch >> ((address & 3) * 8)) & 0xFF;
|
||||
}
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load8: 0x%08x", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Load8: 0x%08x", address);
|
||||
LOAD_BAD;
|
||||
value = (value >> ((address & 3) * 8)) & 0xFF;
|
||||
}
|
||||
|
@ -595,7 +597,7 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
if ((address & (SIZE_CART0 - 1)) < memory->romSize) {
|
||||
value = ((uint8_t*) memory->rom)[address & (SIZE_CART0 - 1)];
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Out of bounds ROM Load8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Out of bounds ROM Load8: 0x%08X", address);
|
||||
value = (address >> 1) & 0xFF;
|
||||
}
|
||||
break;
|
||||
|
@ -603,7 +605,7 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
case REGION_CART_SRAM_MIRROR:
|
||||
wait = memory->waitstatesNonseq16[address >> BASE_OFFSET];
|
||||
if (memory->savedata.type == SAVEDATA_AUTODETECT) {
|
||||
GBALog(gba, GBA_LOG_INFO, "Detected SRAM savegame");
|
||||
mLOG(GBA_MEM, INFO, "Detected SRAM savegame");
|
||||
GBASavedataInitSRAM(&memory->savedata);
|
||||
}
|
||||
if (gba->performingDMA == 1) {
|
||||
|
@ -616,13 +618,13 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
} else if (memory->hw.devices & HW_TILT) {
|
||||
value = GBAHardwareTiltRead(&memory->hw, address & OFFSET_MASK);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Reading from non-existent SRAM: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Reading from non-existent SRAM: 0x%08X", address);
|
||||
value = 0xFF;
|
||||
}
|
||||
value &= 0xFF;
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load8: 0x%08x", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Load8: 0x%08x", address);
|
||||
LOAD_BAD;
|
||||
value = (value >> ((address & 3) * 8)) & 0xFF;
|
||||
break;
|
||||
|
@ -673,11 +675,11 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
|
||||
#define STORE_CART \
|
||||
wait += waitstatesRegion[address >> BASE_OFFSET]; \
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Store32: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Store32: 0x%08X", address);
|
||||
|
||||
#define STORE_SRAM \
|
||||
if (address & 0x3) { \
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Unaligned SRAM Store32: 0x%08X", address); \
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Unaligned SRAM Store32: 0x%08X", address); \
|
||||
value = 0; \
|
||||
} \
|
||||
GBAStore8(cpu, address & ~0x3, value, cycleCounter); \
|
||||
|
@ -686,7 +688,7 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
GBAStore8(cpu, (address & ~0x3) | 3, value, cycleCounter);
|
||||
|
||||
#define STORE_BAD \
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Store32: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Store32: 0x%08X", address);
|
||||
|
||||
void GBAStore32(struct ARMCore* cpu, uint32_t address, int32_t value, int* cycleCounter) {
|
||||
struct GBA* gba = (struct GBA*) cpu->master;
|
||||
|
@ -777,12 +779,12 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
|
|||
uint32_t reg = address & 0xFFFFFE;
|
||||
GBAHardwareGPIOWrite(&memory->hw, reg, value);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad cartridge Store16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad cartridge Store16: 0x%08X", address);
|
||||
}
|
||||
break;
|
||||
case REGION_CART2_EX:
|
||||
if (memory->savedata.type == SAVEDATA_AUTODETECT) {
|
||||
GBALog(gba, GBA_LOG_INFO, "Detected EEPROM savegame");
|
||||
mLOG(GBA_MEM, INFO, "Detected EEPROM savegame");
|
||||
GBASavedataInitEEPROM(&memory->savedata);
|
||||
}
|
||||
GBASavedataWriteEEPROM(&memory->savedata, value, 1);
|
||||
|
@ -793,7 +795,7 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
|
|||
GBAStore8(cpu, (address & ~0x1) | 1, value, cycleCounter);
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Store16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Store16: 0x%08X", address);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -828,26 +830,26 @@ void GBAStore8(struct ARMCore* cpu, uint32_t address, int8_t value, int* cycleCo
|
|||
case REGION_VRAM:
|
||||
if ((address & 0x0001FFFF) >= ((GBARegisterDISPCNTGetMode(gba->memory.io[REG_DISPCNT >> 1]) == 4) ? 0x00014000 : 0x00010000)) {
|
||||
// TODO: check BG mode
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Cannot Store8 to OBJ: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Cannot Store8 to OBJ: 0x%08X", address);
|
||||
break;
|
||||
}
|
||||
gba->video.renderer->vram[(address & 0x1FFFE) >> 1] = ((uint8_t) value) | (value << 8);
|
||||
gba->video.renderer->writeVRAM(gba->video.renderer, address & 0x0001FFFE);
|
||||
break;
|
||||
case REGION_OAM:
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Cannot Store8 to OAM: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Cannot Store8 to OAM: 0x%08X", address);
|
||||
break;
|
||||
case REGION_CART0:
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Store8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Store8: 0x%08X", address);
|
||||
break;
|
||||
case REGION_CART_SRAM:
|
||||
case REGION_CART_SRAM_MIRROR:
|
||||
if (memory->savedata.type == SAVEDATA_AUTODETECT) {
|
||||
if (address == SAVEDATA_FLASH_BASE) {
|
||||
GBALog(gba, GBA_LOG_INFO, "Detected Flash savegame");
|
||||
mLOG(GBA_MEM, INFO, "Detected Flash savegame");
|
||||
GBASavedataInitFlash(&memory->savedata, gba->realisticTiming);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_INFO, "Detected SRAM savegame");
|
||||
mLOG(GBA_MEM, INFO, "Detected SRAM savegame");
|
||||
GBASavedataInitSRAM(&memory->savedata);
|
||||
}
|
||||
}
|
||||
|
@ -859,12 +861,12 @@ void GBAStore8(struct ARMCore* cpu, uint32_t address, int8_t value, int* cycleCo
|
|||
} else if (memory->hw.devices & HW_TILT) {
|
||||
GBAHardwareTiltWrite(&memory->hw, address & OFFSET_MASK, value);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
}
|
||||
wait = memory->waitstatesNonseq16[REGION_CART_SRAM];
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Store8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Store8: 0x%08X", address);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1003,7 +1005,7 @@ void GBAPatch32(struct ARMCore* cpu, uint32_t address, int32_t value, int32_t* o
|
|||
STORE_32(value, address & (SIZE_WORKING_IRAM - 4), memory->iwram);
|
||||
break;
|
||||
case REGION_IO:
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Patch32: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Patch32: 0x%08X", address);
|
||||
break;
|
||||
case REGION_PALETTE_RAM:
|
||||
LOAD_32(oldValue, address & (SIZE_PALETTE_RAM - 1), gba->video.palette);
|
||||
|
@ -1046,11 +1048,11 @@ void GBAPatch32(struct ARMCore* cpu, uint32_t address, int32_t value, int32_t* o
|
|||
LOAD_32(oldValue, address & (SIZE_CART_SRAM - 4), memory->savedata.data);
|
||||
STORE_32(value, address & (SIZE_CART_SRAM - 4), memory->savedata.data);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_WARN, "Bad memory Patch16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, WARN, "Bad memory Patch16: 0x%08X", address);
|
||||
break;
|
||||
}
|
||||
if (old) {
|
||||
|
@ -1073,7 +1075,7 @@ void GBAPatch16(struct ARMCore* cpu, uint32_t address, int16_t value, int16_t* o
|
|||
STORE_16(value, address & (SIZE_WORKING_IRAM - 2), memory->iwram);
|
||||
break;
|
||||
case REGION_IO:
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Patch16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Patch16: 0x%08X", address);
|
||||
break;
|
||||
case REGION_PALETTE_RAM:
|
||||
LOAD_16(oldValue, address & (SIZE_PALETTE_RAM - 2), gba->video.palette);
|
||||
|
@ -1114,11 +1116,11 @@ void GBAPatch16(struct ARMCore* cpu, uint32_t address, int16_t value, int16_t* o
|
|||
LOAD_16(oldValue, address & (SIZE_CART_SRAM - 2), memory->savedata.data);
|
||||
STORE_16(value, address & (SIZE_CART_SRAM - 2), memory->savedata.data);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_WARN, "Bad memory Patch16: 0x%08X", address);
|
||||
mLOG(GBA_MEM, WARN, "Bad memory Patch16: 0x%08X", address);
|
||||
break;
|
||||
}
|
||||
if (old) {
|
||||
|
@ -1141,16 +1143,16 @@ void GBAPatch8(struct ARMCore* cpu, uint32_t address, int8_t value, int8_t* old)
|
|||
((int8_t*) memory->iwram)[address & (SIZE_WORKING_IRAM - 1)] = value;
|
||||
break;
|
||||
case REGION_IO:
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
break;
|
||||
case REGION_PALETTE_RAM:
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
break;
|
||||
case REGION_VRAM:
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
break;
|
||||
case REGION_OAM:
|
||||
GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, STUB, "Unimplemented memory Patch8: 0x%08X", address);
|
||||
break;
|
||||
case REGION_CART0:
|
||||
case REGION_CART0_EX:
|
||||
|
@ -1172,11 +1174,11 @@ void GBAPatch8(struct ARMCore* cpu, uint32_t address, int8_t value, int8_t* old)
|
|||
oldValue = ((int8_t*) memory->savedata.data)[address & (SIZE_CART_SRAM - 1)];
|
||||
((int8_t*) memory->savedata.data)[address & (SIZE_CART_SRAM - 1)] = value;
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
mLOG(GBA_MEM, GAME_ERROR, "Writing to non-existent SRAM: 0x%08X", address);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GBALog(gba, GBA_LOG_WARN, "Bad memory Patch8: 0x%08X", address);
|
||||
mLOG(GBA_MEM, WARN, "Bad memory Patch8: 0x%08X", address);
|
||||
break;
|
||||
}
|
||||
if (old) {
|
||||
|
@ -1498,7 +1500,7 @@ uint16_t GBAMemoryWriteDMACNT_HI(struct GBA* gba, int dma, uint16_t control) {
|
|||
currentDma->reg = control;
|
||||
|
||||
if (GBADMARegisterIsDRQ(currentDma->reg)) {
|
||||
GBALog(gba, GBA_LOG_STUB, "DRQ not implemented");
|
||||
mLOG(GBA_MEM, STUB, "DRQ not implemented");
|
||||
}
|
||||
|
||||
if (!wasEnabled && GBADMARegisterIsEnable(currentDma->reg)) {
|
||||
|
@ -1530,7 +1532,7 @@ void GBAMemoryScheduleDMA(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
info->nextEvent = INT_MAX;
|
||||
switch (number) {
|
||||
case 0:
|
||||
GBALog(gba, GBA_LOG_WARN, "Discarding invalid DMA0 scheduling");
|
||||
mLOG(GBA_MEM, WARN, "Discarding invalid DMA0 scheduling");
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
|
@ -1657,7 +1659,7 @@ void GBAMemoryServiceDMA(struct GBA* gba, int number, struct GBADMA* info) {
|
|||
--wordsRemaining;
|
||||
} else if (destRegion == REGION_CART2_EX) {
|
||||
if (memory->savedata.type == SAVEDATA_AUTODETECT) {
|
||||
GBALog(gba, GBA_LOG_INFO, "Detected EEPROM savegame");
|
||||
mLOG(GBA_MEM, INFO, "Detected EEPROM savegame");
|
||||
GBASavedataInitEEPROM(&memory->savedata);
|
||||
}
|
||||
word = cpu->memory.load16(cpu, source, 0);
|
||||
|
|
|
@ -86,6 +86,8 @@ enum DMATiming {
|
|||
DMA_TIMING_CUSTOM = 3
|
||||
};
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_MEM);
|
||||
|
||||
DECL_BITFIELD(GBADMARegister, uint16_t);
|
||||
DECL_BITS(GBADMARegister, DestControl, 5, 2);
|
||||
DECL_BITS(GBADMARegister, SrcControl, 7, 2);
|
||||
|
|
|
@ -406,7 +406,7 @@
|
|||
return; \
|
||||
} \
|
||||
if (UNLIKELY(end < outX)) { \
|
||||
GBALog(0, GBA_LOG_FATAL, "Out of bounds background draw!"); \
|
||||
mLOG(GBA_VIDEO, FATAL, "Out of bounds background draw!"); \
|
||||
return; \
|
||||
} \
|
||||
DRAW_BACKGROUND_MODE_0_TILE_SUFFIX_ ## BPP (BLEND, OBJWIN) \
|
||||
|
@ -414,7 +414,7 @@
|
|||
if (tileX < tileEnd) { \
|
||||
++tileX; \
|
||||
} else if (VIDEO_CHECKS && UNLIKELY(tileX > tileEnd)) { \
|
||||
GBALog(0, GBA_LOG_FATAL, "Invariant doesn't hold in background draw! tileX (%u) > tileEnd (%u)", tileX, tileEnd); \
|
||||
mLOG(GBA_VIDEO, FATAL, "Invariant doesn't hold in background draw! tileX (%u) > tileEnd (%u)", tileX, tileEnd); \
|
||||
return; \
|
||||
} \
|
||||
length -= end - renderer->start; \
|
||||
|
@ -423,7 +423,7 @@
|
|||
/*!*/ pixel = &renderer->row[outX]; \
|
||||
outX += (tileEnd - tileX) * 8; \
|
||||
/*!*/ if (VIDEO_CHECKS && UNLIKELY(outX > VIDEO_HORIZONTAL_PIXELS)) { \
|
||||
/*!*/ GBALog(0, GBA_LOG_FATAL, "Out of bounds background draw would occur!"); \
|
||||
/*!*/ mLOG(GBA_VIDEO, FATAL, "Out of bounds background draw would occur!"); \
|
||||
/*!*/ return; \
|
||||
/*!*/ } \
|
||||
DRAW_BACKGROUND_MODE_0_TILES_ ## BPP (BLEND, OBJWIN) \
|
||||
|
@ -432,16 +432,16 @@
|
|||
\
|
||||
int mod8 = length & 0x7; \
|
||||
if (VIDEO_CHECKS && UNLIKELY(outX + mod8 != renderer->end)) { \
|
||||
GBALog(0, GBA_LOG_FATAL, "Invariant doesn't hold in background draw!"); \
|
||||
mLOG(GBA_VIDEO, FATAL, "Invariant doesn't hold in background draw!"); \
|
||||
return; \
|
||||
} \
|
||||
DRAW_BACKGROUND_MODE_0_TILE_PREFIX_ ## BPP (BLEND, OBJWIN) \
|
||||
} \
|
||||
if (VIDEO_CHECKS && UNLIKELY(&renderer->row[outX] != pixel)) { \
|
||||
GBALog(0, GBA_LOG_FATAL, "Background draw ended in the wrong place! Diff: %" PRIXPTR, &renderer->row[outX] - pixel); \
|
||||
mLOG(GBA_VIDEO, FATAL, "Background draw ended in the wrong place! Diff: %" PRIXPTR, &renderer->row[outX] - pixel); \
|
||||
} \
|
||||
if (VIDEO_CHECKS && UNLIKELY(outX > VIDEO_HORIZONTAL_PIXELS)) { \
|
||||
GBALog(0, GBA_LOG_FATAL, "Out of bounds background draw occurred!"); \
|
||||
mLOG(GBA_VIDEO, FATAL, "Out of bounds background draw occurred!"); \
|
||||
return; \
|
||||
}
|
||||
|
||||
|
|
|
@ -328,10 +328,10 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
|
|||
softwareRenderer->mosaic = value;
|
||||
break;
|
||||
case REG_GREENSWP:
|
||||
GBALog(0, GBA_LOG_STUB, "Stub video register write: 0x%03X", address);
|
||||
mLOG(GBA_VIDEO, STUB, "Stub video register write: 0x%03X", address);
|
||||
break;
|
||||
default:
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Invalid video register: 0x%03X", address);
|
||||
mLOG(GBA_VIDEO, GAME_ERROR, "Invalid video register: 0x%03X", address);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ static void _breakWindowInner(struct GBAVideoSoftwareRenderer* softwareRenderer,
|
|||
// Trim off extra windows we've overwritten
|
||||
for (++activeWindow; softwareRenderer->nWindows > activeWindow + 1 && win->h.end >= softwareRenderer->windows[activeWindow].endX; ++activeWindow) {
|
||||
if (VIDEO_CHECKS && activeWindow >= MAX_WINDOW) {
|
||||
GBALog(0, GBA_LOG_FATAL, "Out of bounds window write will occur");
|
||||
mLOG(GBA_VIDEO, FATAL, "Out of bounds window write will occur");
|
||||
return;
|
||||
}
|
||||
softwareRenderer->windows[activeWindow] = softwareRenderer->windows[activeWindow + 1];
|
||||
|
@ -440,7 +440,7 @@ static void _breakWindowInner(struct GBAVideoSoftwareRenderer* softwareRenderer,
|
|||
}
|
||||
#ifdef DEBUG
|
||||
if (softwareRenderer->nWindows > MAX_WINDOW) {
|
||||
GBALog(0, GBA_LOG_FATAL, "Out of bounds window write occurred!");
|
||||
mLOG(GBA_VIDEO, FATAL, "Out of bounds window write occurred!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ bool _loadStream(struct GBAMGMContext* mgm, uint32_t streamId) {
|
|||
mgm->d.stopPlaying(&mgm->d);
|
||||
}
|
||||
}
|
||||
GBALog(0, GBA_LOG_DEBUG, "[RR] Loading segment: %u", streamId);
|
||||
mLOG(GBA_RR, DEBUG, "Loading segment: %u", streamId);
|
||||
mgm->d.frames = 0;
|
||||
mgm->d.lagFrames = 0;
|
||||
return true;
|
||||
|
@ -174,7 +174,7 @@ bool _incrementStream(struct GBAMGMContext* mgm, bool recursive) {
|
|||
if (!_loadStream(mgm, newStreamId)) {
|
||||
return false;
|
||||
}
|
||||
GBALog(0, GBA_LOG_DEBUG, "[RR] New segment: %u", newStreamId);
|
||||
mLOG(GBA_RR, DEBUG, "New segment: %u", newStreamId);
|
||||
_emitMagic(mgm, mgm->movieStream);
|
||||
mgm->maxStreamId = newStreamId;
|
||||
_emitTag(mgm, mgm->movieStream, TAG_PREVIOUSLY);
|
||||
|
@ -264,21 +264,21 @@ void GBAMGMNextFrame(struct GBARRContext* rr) {
|
|||
if (rr->isPlaying(rr)) {
|
||||
while (mgm->peekedTag == TAG_INPUT) {
|
||||
_readTag(mgm, mgm->movieStream);
|
||||
GBALog(0, GBA_LOG_WARN, "[RR] Desync detected!");
|
||||
mLOG(GBA_RR, WARN, "Desync detected!");
|
||||
}
|
||||
if (mgm->peekedTag == TAG_LAG) {
|
||||
GBALog(0, GBA_LOG_DEBUG, "[RR] Lag frame marked in stream");
|
||||
mLOG(GBA_RR, DEBUG, "Lag frame marked in stream");
|
||||
if (mgm->inputThisFrame) {
|
||||
GBALog(0, GBA_LOG_WARN, "[RR] Lag frame in stream does not match movie");
|
||||
mLOG(GBA_RR, WARN, "Lag frame in stream does not match movie");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++mgm->d.frames;
|
||||
GBALog(0, GBA_LOG_DEBUG, "[RR] Frame: %u", mgm->d.frames);
|
||||
mLOG(GBA_RR, DEBUG, "Frame: %u", mgm->d.frames);
|
||||
if (!mgm->inputThisFrame) {
|
||||
++mgm->d.lagFrames;
|
||||
GBALog(0, GBA_LOG_DEBUG, "[RR] Lag frame: %u", mgm->d.lagFrames);
|
||||
mLOG(GBA_RR, DEBUG, "Lag frame: %u", mgm->d.lagFrames);
|
||||
}
|
||||
|
||||
if (rr->isRecording(rr)) {
|
||||
|
@ -305,7 +305,7 @@ void GBAMGMLogInput(struct GBARRContext* rr, uint16_t keys) {
|
|||
mgm->movieStream->write(mgm->movieStream, &keys, sizeof(keys));
|
||||
mgm->currentInput = keys;
|
||||
}
|
||||
GBALog(0, GBA_LOG_DEBUG, "[RR] Input log: %03X", mgm->currentInput);
|
||||
mLOG(GBA_RR, DEBUG, "Input log: %03X", mgm->currentInput);
|
||||
mgm->inputThisFrame = true;
|
||||
}
|
||||
|
||||
|
@ -320,9 +320,9 @@ uint16_t GBAMGMQueryInput(struct GBARRContext* rr) {
|
|||
}
|
||||
mgm->inputThisFrame = true;
|
||||
if (mgm->currentInput == INVALID_INPUT) {
|
||||
GBALog(0, GBA_LOG_WARN, "[RR] Stream did not specify input");
|
||||
mLOG(GBA_RR, WARN, "Stream did not specify input");
|
||||
}
|
||||
GBALog(0, GBA_LOG_DEBUG, "[RR] Input replay: %03X", mgm->currentInput);
|
||||
mLOG(GBA_RR, DEBUG, "Input replay: %03X", mgm->currentInput);
|
||||
return mgm->currentInput;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "util/vfs.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_RR, "GBA RR");
|
||||
|
||||
void GBARRInitRecord(struct GBA* gba) {
|
||||
if (!gba || !gba->rr) {
|
||||
return;
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
#include "gba/serialize.h"
|
||||
|
||||
struct VFile;
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_RR);
|
||||
|
||||
enum GBARRInitFrom {
|
||||
INIT_EX_NIHILO = 0,
|
||||
INIT_FROM_SAVEGAME = 1,
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#define FLASH_SETTLE_CYCLES 18000
|
||||
#define CLEANUP_THRESHOLD 15
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_SAVE, "GBA Savedata");
|
||||
|
||||
static void _flashSwitchBank(struct GBASavedata* savedata, int bank);
|
||||
static void _flashErase(struct GBASavedata* savedata);
|
||||
static void _flashEraseSector(struct GBASavedata* savedata, uint16_t sectorStart);
|
||||
|
@ -181,7 +183,7 @@ void GBASavedataInitFlash(struct GBASavedata* savedata, bool realisticTiming) {
|
|||
savedata->type = SAVEDATA_FLASH512;
|
||||
}
|
||||
if (savedata->type != SAVEDATA_FLASH512 && savedata->type != SAVEDATA_FLASH1M) {
|
||||
GBALog(0, GBA_LOG_WARN, "Can't re-initialize savedata");
|
||||
mLOG(GBA_SAVE, WARN, "Can't re-initialize savedata");
|
||||
return;
|
||||
}
|
||||
int32_t flashSize = SIZE_CART_FLASH512;
|
||||
|
@ -213,7 +215,7 @@ void GBASavedataInitEEPROM(struct GBASavedata* savedata) {
|
|||
if (savedata->type == SAVEDATA_AUTODETECT) {
|
||||
savedata->type = SAVEDATA_EEPROM;
|
||||
} else {
|
||||
GBALog(0, GBA_LOG_WARN, "Can't re-initialize savedata");
|
||||
mLOG(GBA_SAVE, WARN, "Can't re-initialize savedata");
|
||||
return;
|
||||
}
|
||||
off_t end;
|
||||
|
@ -236,7 +238,7 @@ void GBASavedataInitSRAM(struct GBASavedata* savedata) {
|
|||
if (savedata->type == SAVEDATA_AUTODETECT) {
|
||||
savedata->type = SAVEDATA_SRAM;
|
||||
} else {
|
||||
GBALog(0, GBA_LOG_WARN, "Can't re-initialize savedata");
|
||||
mLOG(GBA_SAVE, WARN, "Can't re-initialize savedata");
|
||||
return;
|
||||
}
|
||||
off_t end;
|
||||
|
@ -290,7 +292,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
|
|||
if (address == 0 && value < 2) {
|
||||
_flashSwitchBank(savedata, value);
|
||||
} else {
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Bad flash bank switch");
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Bad flash bank switch");
|
||||
savedata->command = FLASH_COMMAND_NONE;
|
||||
}
|
||||
savedata->command = FLASH_COMMAND_NONE;
|
||||
|
@ -299,7 +301,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
|
|||
if (address == FLASH_BASE_HI && value == FLASH_COMMAND_START) {
|
||||
savedata->flashState = FLASH_STATE_START;
|
||||
} else {
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Bad flash write: %#04x = %#02x", address, value);
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Bad flash write: %#04x = %#02x", address, value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -308,7 +310,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
|
|||
if (address == FLASH_BASE_LO && value == FLASH_COMMAND_CONTINUE) {
|
||||
savedata->flashState = FLASH_STATE_CONTINUE;
|
||||
} else {
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Bad flash write: %#04x = %#02x", address, value);
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Bad flash write: %#04x = %#02x", address, value);
|
||||
savedata->flashState = FLASH_STATE_RAW;
|
||||
}
|
||||
break;
|
||||
|
@ -325,7 +327,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
|
|||
savedata->command = value;
|
||||
break;
|
||||
default:
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Unsupported flash operation: %#02x", value);
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Unsupported flash operation: %#02x", value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -335,7 +337,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
|
|||
_flashErase(savedata);
|
||||
break;
|
||||
default:
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Unsupported flash erase operation: %#02x", value);
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Unsupported flash erase operation: %#02x", value);
|
||||
break;
|
||||
}
|
||||
savedata->command = FLASH_COMMAND_NONE;
|
||||
|
@ -346,7 +348,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
|
|||
}
|
||||
break;
|
||||
default:
|
||||
GBALog(0, GBA_LOG_ERROR, "Flash entered bad state: %#02x", savedata->command);
|
||||
mLOG(GBA_SAVE, ERROR, "Flash entered bad state: %#02x", savedata->command);
|
||||
savedata->command = FLASH_COMMAND_NONE;
|
||||
break;
|
||||
}
|
||||
|
@ -355,7 +357,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
|
|||
_flashEraseSector(savedata, address);
|
||||
savedata->command = FLASH_COMMAND_NONE;
|
||||
} else {
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Unsupported flash erase operation: %#02x", value);
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Unsupported flash erase operation: %#02x", value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -394,7 +396,7 @@ void GBASavedataWriteEEPROM(struct GBASavedata* savedata, uint16_t value, uint32
|
|||
savedata->data[savedata->writeAddress >> 3] = current;
|
||||
++savedata->writeAddress;
|
||||
} else {
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Writing beyond end of EEPROM: %08X", (savedata->writeAddress >> 3));
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Writing beyond end of EEPROM: %08X", (savedata->writeAddress >> 3));
|
||||
}
|
||||
break;
|
||||
case EEPROM_COMMAND_READ_PENDING:
|
||||
|
@ -421,7 +423,7 @@ uint16_t GBASavedataReadEEPROM(struct GBASavedata* savedata) {
|
|||
int step = 63 - savedata->readBitsRemaining;
|
||||
uint32_t address = (savedata->readAddress + step) >> 3;
|
||||
if (address >= SIZE_CART_EEPROM) {
|
||||
GBALog(0, GBA_LOG_GAME_ERROR, "Reading beyond end of EEPROM: %08X", address);
|
||||
mLOG(GBA_SAVE, GAME_ERROR, "Reading beyond end of EEPROM: %08X", address);
|
||||
return 0xFF;
|
||||
}
|
||||
uint8_t data = savedata->data[address] >> (0x7 - (step & 0x7));
|
||||
|
@ -464,7 +466,7 @@ void GBASavedataClean(struct GBASavedata* savedata, uint32_t frameCount) {
|
|||
}
|
||||
savedata->vf->sync(savedata->vf, savedata->data, size);
|
||||
savedata->dirty = 0;
|
||||
GBALog(0, GBA_LOG_INFO, "Savedata synced");
|
||||
mLOG(GBA_SAVE, INFO, "Savedata synced");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -504,7 +506,7 @@ void GBASavedataDeserialize(struct GBASavedata* savedata, const struct GBASerial
|
|||
}
|
||||
|
||||
void _flashSwitchBank(struct GBASavedata* savedata, int bank) {
|
||||
GBALog(0, GBA_LOG_DEBUG, "Performing flash bank switch to bank %i", bank);
|
||||
mLOG(GBA_SAVE, DEBUG, "Performing flash bank switch to bank %i", bank);
|
||||
savedata->currentBank = &savedata->data[bank << 16];
|
||||
if (bank > 0 && savedata->type == SAVEDATA_FLASH512) {
|
||||
savedata->type = SAVEDATA_FLASH1M;
|
||||
|
@ -516,7 +518,7 @@ void _flashSwitchBank(struct GBASavedata* savedata, int bank) {
|
|||
}
|
||||
|
||||
void _flashErase(struct GBASavedata* savedata) {
|
||||
GBALog(0, GBA_LOG_DEBUG, "Performing flash chip erase");
|
||||
mLOG(GBA_SAVE, DEBUG, "Performing flash chip erase");
|
||||
savedata->dirty |= SAVEDATA_DIRT_NEW;
|
||||
size_t size = SIZE_CART_FLASH512;
|
||||
if (savedata->type == SAVEDATA_FLASH1M) {
|
||||
|
@ -526,11 +528,11 @@ void _flashErase(struct GBASavedata* savedata) {
|
|||
}
|
||||
|
||||
void _flashEraseSector(struct GBASavedata* savedata, uint16_t sectorStart) {
|
||||
GBALog(0, GBA_LOG_DEBUG, "Performing flash sector erase at 0x%04x", sectorStart);
|
||||
mLOG(GBA_SAVE, DEBUG, "Performing flash sector erase at 0x%04x", sectorStart);
|
||||
savedata->dirty |= SAVEDATA_DIRT_NEW;
|
||||
size_t size = 0x1000;
|
||||
if (savedata->type == SAVEDATA_FLASH1M) {
|
||||
GBALog(0, GBA_LOG_DEBUG, "Performing unknown sector-size erase at 0x%04x", sectorStart);
|
||||
mLOG(GBA_SAVE, DEBUG, "Performing unknown sector-size erase at 0x%04x", sectorStart);
|
||||
}
|
||||
savedata->settling = sectorStart >> 12;
|
||||
if (savedata->realisticTiming) {
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_SAVE);
|
||||
|
||||
struct VFile;
|
||||
|
||||
enum SavedataType {
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
const uint32_t GBA_SAVESTATE_MAGIC = 0x01000000;
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_STATE, "GBA Savestate");
|
||||
|
||||
struct GBABundledState {
|
||||
struct GBASerializedState* state;
|
||||
struct GBAExtdata* extdata;
|
||||
|
@ -96,12 +98,12 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
|
|||
uint32_t ucheck;
|
||||
LOAD_32(ucheck, 0, &state->versionMagic);
|
||||
if (ucheck != GBA_SAVESTATE_MAGIC) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Invalid or too new savestate: expected %08X, got %08X", GBA_SAVESTATE_MAGIC, ucheck);
|
||||
mLOG(GBA_STATE, WARN, "Invalid or too new savestate: expected %08X, got %08X", GBA_SAVESTATE_MAGIC, ucheck);
|
||||
error = true;
|
||||
}
|
||||
LOAD_32(ucheck, 0, &state->biosChecksum);
|
||||
if (ucheck != gba->biosChecksum) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate created using a different version of the BIOS: expected %08X, got %08X", gba->biosChecksum, ucheck);
|
||||
mLOG(GBA_STATE, WARN, "Savestate created using a different version of the BIOS: expected %08X, got %08X", gba->biosChecksum, ucheck);
|
||||
uint32_t pc;
|
||||
LOAD_32(pc, ARM_PC * sizeof(state->cpu.gprs[0]), state->cpu.gprs);
|
||||
if (pc < SIZE_BIOS && pc >= 0x20) {
|
||||
|
@ -109,34 +111,34 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
|
|||
}
|
||||
}
|
||||
if (gba->memory.rom && (state->id != ((struct GBACartridge*) gba->memory.rom)->id || memcmp(state->title, ((struct GBACartridge*) gba->memory.rom)->title, sizeof(state->title)))) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate is for a different game");
|
||||
mLOG(GBA_STATE, WARN, "Savestate is for a different game");
|
||||
error = true;
|
||||
} else if (!gba->memory.rom && state->id != 0) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate is for a game, but no game loaded");
|
||||
mLOG(GBA_STATE, WARN, "Savestate is for a game, but no game loaded");
|
||||
error = true;
|
||||
}
|
||||
LOAD_32(ucheck, 0, &state->romCrc32);
|
||||
if (ucheck != gba->romCrc32) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate is for a different version of the game");
|
||||
mLOG(GBA_STATE, WARN, "Savestate is for a different version of the game");
|
||||
}
|
||||
LOAD_32(check, 0, &state->cpu.cycles);
|
||||
if (check < 0) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: CPU cycles are negative");
|
||||
mLOG(GBA_STATE, WARN, "Savestate is corrupted: CPU cycles are negative");
|
||||
error = true;
|
||||
}
|
||||
if (check >= (int32_t) GBA_ARM7TDMI_FREQUENCY) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: CPU cycles are too high");
|
||||
mLOG(GBA_STATE, WARN, "Savestate is corrupted: CPU cycles are too high");
|
||||
error = true;
|
||||
}
|
||||
LOAD_32(check, 0, &state->video.eventDiff);
|
||||
if (check < 0) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: video eventDiff is negative");
|
||||
mLOG(GBA_STATE, WARN, "Savestate is corrupted: video eventDiff is negative");
|
||||
error = true;
|
||||
}
|
||||
LOAD_32(check, ARM_PC * sizeof(state->cpu.gprs[0]), state->cpu.gprs);
|
||||
int region = (check >> BASE_OFFSET);
|
||||
if ((region == REGION_CART0 || region == REGION_CART1 || region == REGION_CART2) && ((check - WORD_SIZE_ARM) & SIZE_CART0) >= gba->memory.romSize - WORD_SIZE_ARM) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate created using a differently sized version of the ROM");
|
||||
mLOG(GBA_STATE, WARN, "Savestate created using a differently sized version of the ROM");
|
||||
error = true;
|
||||
}
|
||||
if (error) {
|
||||
|
@ -461,7 +463,7 @@ bool GBALoadStateNamed(struct GBA* gba, struct VFile* vf, int flags) {
|
|||
gba->video.renderer->putPixels(gba->video.renderer, VIDEO_HORIZONTAL_PIXELS, item.data);
|
||||
mCoreSyncForceFrame(gba->sync);
|
||||
} else {
|
||||
GBALog(gba, GBA_LOG_WARN, "Savestate includes invalid screenshot");
|
||||
mLOG(GBA_STATE, WARN, "Savestate includes invalid screenshot");
|
||||
}
|
||||
}
|
||||
if (flags & SAVESTATE_SAVEDATA && GBAExtdataGet(&extdata, EXTDATA_SAVEDATA, &item)) {
|
||||
|
@ -630,11 +632,11 @@ void GBATakeScreenshot(struct GBA* gba, struct VDir* dir) {
|
|||
vf->close(vf);
|
||||
}
|
||||
if (success) {
|
||||
GBALog(gba, GBA_LOG_STATUS, "Screenshot saved");
|
||||
mLOG(STATUS, INFO, "Screenshot saved");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
UNUSED(dir);
|
||||
#endif
|
||||
GBALog(gba, GBA_LOG_STATUS, "Failed to take screenshot");
|
||||
mLOG(STATUS, WARN, "Failed to take screenshot");
|
||||
}
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/core.h"
|
||||
#include "gba/gba.h"
|
||||
|
||||
extern const uint32_t GBA_SAVESTATE_MAGIC;
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_STATE);
|
||||
|
||||
/* Savestate format:
|
||||
* 0x00000 - 0x00003: Version Magic (0x01000000)
|
||||
* 0x00004 - 0x00007: BIOS checksum (e.g. 0xBAAE187F for official BIOS)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "gba/io.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_SIO, "GBA Serial I/O");
|
||||
|
||||
const int GBASIOCyclesPerTransfer[4][MAX_GBAS] = {
|
||||
{ 38326, 73003, 107680, 142356 },
|
||||
{ 9582, 18251, 26920, 35589 },
|
||||
|
@ -98,7 +100,7 @@ void GBASIOSetDriver(struct GBASIO* sio, struct GBASIODriver* driver, enum GBASI
|
|||
driverLoc = &sio->drivers.joybus;
|
||||
break;
|
||||
default:
|
||||
GBALog(sio->p, GBA_LOG_ERROR, "Setting an unsupported SIO driver: %x", mode);
|
||||
mLOG(GBA_SIO, ERROR, "Setting an unsupported SIO driver: %x", mode);
|
||||
return;
|
||||
}
|
||||
if (*driverLoc) {
|
||||
|
@ -115,7 +117,7 @@ void GBASIOSetDriver(struct GBASIO* sio, struct GBASIODriver* driver, enum GBASI
|
|||
if (driver->init) {
|
||||
if (!driver->init(driver)) {
|
||||
driver->deinit(driver);
|
||||
GBALog(sio->p, GBA_LOG_ERROR, "Could not initialize SIO driver");
|
||||
mLOG(GBA_SIO, ERROR, "Could not initialize SIO driver");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
#include "gba/interface.h"
|
||||
|
||||
#define MAX_GBAS 4
|
||||
|
||||
extern const int GBASIOCyclesPerTransfer[4][MAX_GBAS];
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_SIO);
|
||||
|
||||
enum {
|
||||
RCNT_INITIAL = 0x8000
|
||||
};
|
||||
|
|
|
@ -85,7 +85,7 @@ bool GBASIOLockstepNodeInit(struct GBASIODriver* driver) {
|
|||
struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver;
|
||||
node->nextEvent = LOCKSTEP_INCREMENT;
|
||||
node->d.p->multiplayerControl.slave = node->id > 0;
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: Node init", node->id);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: Node init", node->id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -142,10 +142,10 @@ bool GBASIOLockstepNodeUnload(struct GBASIODriver* driver) {
|
|||
static uint16_t GBASIOLockstepNodeMultiWriteRegister(struct GBASIODriver* driver, uint32_t address, uint16_t value) {
|
||||
struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver;
|
||||
if (address == REG_SIOCNT) {
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: SIOCNT <- %04x", node->id, value);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: SIOCNT <- %04x", node->id, value);
|
||||
if (value & 0x0080) {
|
||||
if (!node->id) {
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: Transfer initiated", node->id);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: Transfer initiated", node->id);
|
||||
MutexLock(&node->p->mutex);
|
||||
node->p->transferActive = true;
|
||||
node->p->transferCycles = GBASIOCyclesPerTransfer[node->d.p->multiplayerControl.baud][node->p->attached - 1];
|
||||
|
@ -158,7 +158,7 @@ static uint16_t GBASIOLockstepNodeMultiWriteRegister(struct GBASIODriver* driver
|
|||
value &= 0xFF83;
|
||||
value |= driver->p->siocnt & 0x00FC;
|
||||
} else if (address == REG_SIOMLT_SEND) {
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: SIOMLT_SEND <- %04x", node->id, value);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: SIOMLT_SEND <- %04x", node->id, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ static int32_t GBASIOLockstepNodeMultiProcessEvents(struct GBASIODriver* driver,
|
|||
ConditionWake(&node->p->barrier);
|
||||
}
|
||||
if (node->state == LOCKSTEP_FINISHED) {
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: Finishing transfer: %04x %04x %04x %04x", node->id, node->p->multiRecv[0], node->p->multiRecv[1], node->p->multiRecv[2], node->p->multiRecv[3]);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: Finishing transfer: %04x %04x %04x %04x", node->id, node->p->multiRecv[0], node->p->multiRecv[1], node->p->multiRecv[2], node->p->multiRecv[3]);
|
||||
node->d.p->p->memory.io[REG_SIOMULTI0 >> 1] = node->p->multiRecv[0];
|
||||
node->d.p->p->memory.io[REG_SIOMULTI1 >> 1] = node->p->multiRecv[1];
|
||||
node->d.p->p->memory.io[REG_SIOMULTI2 >> 1] = node->p->multiRecv[2];
|
||||
|
@ -229,7 +229,7 @@ static int32_t GBASIOLockstepNodeMultiProcessEvents(struct GBASIODriver* driver,
|
|||
static uint16_t GBASIOLockstepNodeNormalWriteRegister(struct GBASIODriver* driver, uint32_t address, uint16_t value) {
|
||||
struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver;
|
||||
if (address == REG_SIOCNT) {
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: SIOCNT <- %04x", node->id, value);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: SIOCNT <- %04x", node->id, value);
|
||||
value &= 0xFF8B;
|
||||
MutexLock(&node->p->mutex);
|
||||
if (value & 0x0080) {
|
||||
|
@ -251,9 +251,9 @@ static uint16_t GBASIOLockstepNodeNormalWriteRegister(struct GBASIODriver* drive
|
|||
}
|
||||
MutexUnlock(&node->p->mutex);
|
||||
} else if (address == REG_SIODATA32_LO) {
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: SIODATA32_LO <- %04x", node->id, value);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: SIODATA32_LO <- %04x", node->id, value);
|
||||
} else if (address == REG_SIODATA32_HI) {
|
||||
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: SIODATA32_HI <- %04x", node->id, value);
|
||||
mLOG(GBA_SIO, DEBUG, "Lockstep %i: SIODATA32_HI <- %04x", node->id, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "util/memory.h"
|
||||
|
||||
mLOG_DEFINE_CATEGORY(GBA_VIDEO, "GBA Video");
|
||||
|
||||
static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer);
|
||||
static void GBAVideoDummyRendererReset(struct GBAVideoRenderer* renderer);
|
||||
static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer);
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#define GBA_G8(X) (((X) >> 2) & 0xF8)
|
||||
#define GBA_B8(X) (((X) >> 7) & 0xF8)
|
||||
|
||||
mLOG_DECLARE_CATEGORY(GBA_VIDEO);
|
||||
|
||||
enum {
|
||||
VIDEO_HORIZONTAL_PIXELS = 240,
|
||||
VIDEO_HBLANK_PIXELS = 68,
|
||||
|
|
|
@ -110,7 +110,7 @@ ConfigController::ConfigController(QObject* parent)
|
|||
m_opts.audioBuffers = 1536;
|
||||
m_opts.sampleRate = 44100;
|
||||
m_opts.volume = 0x100;
|
||||
m_opts.logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS;
|
||||
m_opts.logLevel = mLOG_WARN | mLOG_ERROR | mLOG_FATAL;
|
||||
m_opts.rewindEnable = false;
|
||||
m_opts.rewindBufferInterval = 0;
|
||||
m_opts.rewindBufferCapacity = 0;
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
|
||||
#define BUFFER_SIZE (GBA_AUDIO_SAMPLES >> 2)
|
||||
|
||||
mLOG_DEFINE_CATEGORY(SDL_AUDIO, "SDL Audio");
|
||||
|
||||
static void _mSDLAudioCallback(void* context, Uint8* data, int len);
|
||||
|
||||
bool mSDLInitAudio(struct mSDLAudio* context, struct mCoreThread* threadContext) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
|
||||
GBALog(0, GBA_LOG_ERROR, "Could not initialize SDL sound system: %s", SDL_GetError());
|
||||
mLOG(SDL_AUDIO, ERROR, "Could not initialize SDL sound system: %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -33,7 +35,7 @@ bool mSDLInitAudio(struct mSDLAudio* context, struct mCoreThread* threadContext)
|
|||
#else
|
||||
if (SDL_OpenAudio(&context->desiredSpec, &context->obtainedSpec) < 0) {
|
||||
#endif
|
||||
GBALog(0, GBA_LOG_ERROR, "Could not open SDL sound system");
|
||||
mLOG(SDL_AUDIO, ERROR, "Could not open SDL sound system");
|
||||
return false;
|
||||
}
|
||||
context->samples = context->obtainedSpec.samples;
|
||||
|
|
|
@ -8,8 +8,12 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
mLOG_DECLARE_CATEGORY(SDL_AUDIO);
|
||||
|
||||
struct mSDLAudio {
|
||||
// Input
|
||||
size_t samples;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#define GYRO_STEPS 100
|
||||
#define RUMBLE_PWM 20
|
||||
|
||||
mLOG_DEFINE_CATEGORY(SDL_EVENTS, "SDL Events");
|
||||
|
||||
DEFINE_VECTOR(SDL_JoystickList, struct SDL_JoystickCombo);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
|
@ -42,16 +44,16 @@ bool mSDLInitEvents(struct mSDLEvents* context) {
|
|||
SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1");
|
||||
#endif
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
|
||||
GBALog(0, GBA_LOG_ERROR, "SDL joystick initialization failed: %s", SDL_GetError());
|
||||
mLOG(SDL_EVENTS, ERROR, "SDL joystick initialization failed: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) < 0) {
|
||||
GBALog(0, GBA_LOG_ERROR, "SDL haptic initialization failed: %s", SDL_GetError());
|
||||
mLOG(SDL_EVENTS, ERROR, "SDL haptic initialization failed: %s", SDL_GetError());
|
||||
}
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
|
||||
GBALog(0, GBA_LOG_ERROR, "SDL video initialization failed: %s", SDL_GetError());
|
||||
mLOG(SDL_EVENTS, ERROR, "SDL video initialization failed: %s", SDL_GetError());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -9,11 +9,14 @@
|
|||
#include "util/common.h"
|
||||
|
||||
#include "core/interface.h"
|
||||
#include "core/log.h"
|
||||
#include "util/circle-buffer.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
mLOG_DECLARE_CATEGORY(SDL_EVENTS);
|
||||
|
||||
#define SDL_BINDING_KEY 0x53444C4BU
|
||||
#define SDL_BINDING_BUTTON 0x53444C42U
|
||||
|
||||
|
|
Loading…
Reference in New Issue