mirror of https://github.com/mgba-emu/mgba.git
GBA BIOS: Implement SoftReset
This commit is contained in:
parent
afc0a9df57
commit
f2e24f9c55
2
CHANGES
2
CHANGES
|
@ -14,7 +14,7 @@ Features:
|
||||||
- Support for games using the tilt sensor
|
- Support for games using the tilt sensor
|
||||||
- Remappable shortcuts for keyboard and gamepad
|
- Remappable shortcuts for keyboard and gamepad
|
||||||
- Rewinding of emulation
|
- Rewinding of emulation
|
||||||
- Implemented BIOS routines RegisterRamReset, Diff8bitUnFilterWram, Diff8bitUnFilterVram, and Diff16bitUnFilter
|
- Implemented BIOS routines SoftReset, RegisterRamReset, Diff8bitUnFilterWram, Diff8bitUnFilterVram, and Diff16bitUnFilter
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- Qt: Fix issue with set frame sizes being the wrong height
|
- Qt: Fix issue with set frame sizes being the wrong height
|
||||||
- Qt: Fix emulator crashing when full screen if a game is not running
|
- Qt: Fix emulator crashing when full screen if a game is not running
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "gba.h"
|
#include "gba.h"
|
||||||
#include "gba-io.h"
|
#include "gba-io.h"
|
||||||
#include "gba-memory.h"
|
#include "gba-memory.h"
|
||||||
|
#include "isa-inlines.h"
|
||||||
|
|
||||||
const uint32_t GBA_BIOS_CHECKSUM = 0xBAAE187F;
|
const uint32_t GBA_BIOS_CHECKSUM = 0xBAAE187F;
|
||||||
const uint32_t GBA_DS_BIOS_CHECKSUM = 0xBAAE1880;
|
const uint32_t GBA_DS_BIOS_CHECKSUM = 0xBAAE1880;
|
||||||
|
@ -17,6 +18,31 @@ static void _unHuffman(struct GBA* gba);
|
||||||
static void _unRl(struct GBA* gba, int width);
|
static void _unRl(struct GBA* gba, int width);
|
||||||
static void _unFilter(struct GBA* gba, int inwidth, int outwidth);
|
static void _unFilter(struct GBA* gba, int inwidth, int outwidth);
|
||||||
|
|
||||||
|
static void _SoftReset(struct GBA* gba) {
|
||||||
|
struct ARMCore* cpu = gba->cpu;
|
||||||
|
ARMSetPrivilegeMode(cpu, MODE_IRQ);
|
||||||
|
cpu->spsr.packed = 0;
|
||||||
|
cpu->gprs[ARM_LR] = 0;
|
||||||
|
cpu->gprs[ARM_SP] = SP_BASE_IRQ;
|
||||||
|
ARMSetPrivilegeMode(cpu, MODE_SUPERVISOR);
|
||||||
|
cpu->spsr.packed = 0;
|
||||||
|
cpu->gprs[ARM_LR] = 0;
|
||||||
|
cpu->gprs[ARM_SP] = SP_BASE_SUPERVISOR;
|
||||||
|
ARMSetPrivilegeMode(cpu, MODE_SYSTEM);
|
||||||
|
cpu->gprs[ARM_LR] = 0;
|
||||||
|
cpu->gprs[ARM_SP] = SP_BASE_SYSTEM;
|
||||||
|
int8_t flag = ((int8_t*) gba->memory.iwram)[0x7FFA];
|
||||||
|
memset(((int8_t*) gba->memory.iwram) + SIZE_WORKING_IRAM - 0x200, 0, 0x200);
|
||||||
|
if (flag) {
|
||||||
|
cpu->gprs[ARM_PC] = BASE_WORKING_RAM;
|
||||||
|
} else {
|
||||||
|
cpu->gprs[ARM_PC] = BASE_CART0;
|
||||||
|
}
|
||||||
|
_ARMSetMode(cpu, MODE_ARM);
|
||||||
|
int currentCycles = 0;
|
||||||
|
ARM_WRITE_PC;
|
||||||
|
}
|
||||||
|
|
||||||
static void _RegisterRamReset(struct GBA* gba) {
|
static void _RegisterRamReset(struct GBA* gba) {
|
||||||
uint32_t registers = gba->cpu->gprs[0];
|
uint32_t registers = gba->cpu->gprs[0];
|
||||||
struct ARMCore* cpu = gba->cpu;
|
struct ARMCore* cpu = gba->cpu;
|
||||||
|
@ -156,6 +182,9 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (immediate) {
|
switch (immediate) {
|
||||||
|
case 0x0:
|
||||||
|
_SoftReset(gba);
|
||||||
|
break;
|
||||||
case 0x1:
|
case 0x1:
|
||||||
_RegisterRamReset(gba);
|
_RegisterRamReset(gba);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,12 +24,6 @@ const uint32_t GBA_COMPONENT_MAGIC = 0x1000000;
|
||||||
static const size_t GBA_ROM_MAGIC_OFFSET = 2;
|
static const size_t GBA_ROM_MAGIC_OFFSET = 2;
|
||||||
static const uint8_t GBA_ROM_MAGIC[] = { 0x00, 0xEA };
|
static const uint8_t GBA_ROM_MAGIC[] = { 0x00, 0xEA };
|
||||||
|
|
||||||
enum {
|
|
||||||
SP_BASE_SYSTEM = 0x03FFFF00,
|
|
||||||
SP_BASE_IRQ = 0x03FFFFA0,
|
|
||||||
SP_BASE_SUPERVISOR = 0x03FFFFE0
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GBACartridgeOverride {
|
struct GBACartridgeOverride {
|
||||||
const char id[4];
|
const char id[4];
|
||||||
enum SavedataType type;
|
enum SavedataType type;
|
||||||
|
|
|
@ -75,6 +75,12 @@ enum GBAComponent {
|
||||||
GBA_COMPONENT_MAX
|
GBA_COMPONENT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SP_BASE_SYSTEM = 0x03007F00,
|
||||||
|
SP_BASE_IRQ = 0x03007FA0,
|
||||||
|
SP_BASE_SUPERVISOR = 0x03007FE0
|
||||||
|
};
|
||||||
|
|
||||||
struct GBA;
|
struct GBA;
|
||||||
struct GBARotationSource;
|
struct GBARotationSource;
|
||||||
struct Patch;
|
struct Patch;
|
||||||
|
|
Loading…
Reference in New Issue