GBA BIOS: Implement Stop

This commit is contained in:
Jeffrey Pfau 2015-07-19 18:12:56 -07:00
parent 7a9e97ca52
commit d588b8c462
6 changed files with 20 additions and 1 deletions

View File

@ -28,6 +28,7 @@ Features:
- Controller profiles now store shortcut settings
- Default controller profiles for several common controllers
- Libretro now supports BIOS and rumble
- Implement BIOS call Stop, for sleep mode
Bugfixes:
- ARM7: Fix SWI and IRQ timings
- GBA Audio: Force audio FIFOs to 32-bit

View File

@ -191,6 +191,9 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
case 0x2:
GBAHalt(gba);
break;
case 0x3:
GBAStop(gba);
break;
case 0x05:
// VBlankIntrWait
// Fall through:

View File

@ -82,6 +82,7 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
gba->logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL;
gba->stream = 0;
gba->keyCallback = 0;
gba->stopCallback = 0;
gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
@ -553,6 +554,14 @@ void GBAHalt(struct GBA* gba) {
gba->cpu->halted = 1;
}
void GBAStop(struct GBA* gba) {
if (!gba->stopCallback) {
return;
}
gba->cpu->nextEvent = 0;
gba->stopCallback->stop(gba->stopCallback);
}
static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) {
struct GBAThread* threadContext = GBAThreadGetContext();
enum GBALogLevel logLevel = GBA_LOG_ALL;

View File

@ -112,6 +112,7 @@ struct GBA {
enum GBALogLevel logLevel;
struct GBAAVStream* stream;
struct GBAKeyCallback* keyCallback;
struct GBAStopCallback* stopCallback;
enum GBAIdleLoopOptimization idleOptimization;
uint32_t idleLoop;
@ -155,6 +156,7 @@ void GBAWriteIME(struct GBA* gba, uint16_t value);
void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq);
void GBATestIRQ(struct ARMCore* cpu);
void GBAHalt(struct GBA* gba);
void GBAStop(struct GBA* gba);
void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger);
void GBADetachDebugger(struct GBA* gba);

View File

@ -66,6 +66,10 @@ struct GBAKeyCallback {
uint16_t (*readKeys)(struct GBAKeyCallback*);
};
struct GBAStopCallback {
void (*stop)(struct GBAStopCallback*);
};
struct GBARotationSource {
void (*sample)(struct GBARotationSource*);

View File

@ -505,7 +505,7 @@ void GBAIOWrite8(struct GBA* gba, uint32_t address, uint8_t value) {
if (!value) {
GBAHalt(gba);
} else {
GBALog(gba, GBA_LOG_STUB, "Stop unimplemented");
GBAStop(gba);
}
return;
}