summaryrefslogtreecommitdiff
path: root/cpu.c
diff options
context:
space:
mode:
authorDavid Guillen Fandos2021-03-22 21:45:52 +0100
committerDavid Guillen Fandos2021-03-22 21:45:52 +0100
commitf6f3a910397afb769f84d1332014c4eda1fedebe (patch)
treeb8885300d4e020da90d4308df2e9dba03d46fde5 /cpu.c
parenteab44b9e0b9dcb5cf7fa7b6851fa5454041da930 (diff)
downloadpicogpsp-f6f3a910397afb769f84d1332014c4eda1fedebe.tar.gz
picogpsp-f6f3a910397afb769f84d1332014c4eda1fedebe.tar.bz2
picogpsp-f6f3a910397afb769f84d1332014c4eda1fedebe.zip
Adding Normmatt's BIOS as a built-in BIOS
Add options to select whether to boot from BIOS (default is no, as it is now) and whether to use the original bios or the builtin one (default is auto, which tries to use the official but falls back to the builtin if not found).
Diffstat (limited to 'cpu.c')
-rw-r--r--cpu.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/cpu.c b/cpu.c
index 2c93f38..11c947f 100644
--- a/cpu.c
+++ b/cpu.c
@@ -4297,13 +4297,23 @@ void init_cpu(void)
for(i = 0; i < 16; i++)
reg[i] = 0;
- reg[REG_SP] = 0x03007F00;
- reg[REG_PC] = 0x08000000;
- reg[REG_CPSR] = 0x0000001F;
reg[CPU_HALT_STATE] = CPU_ACTIVE;
- reg[CPU_MODE] = MODE_USER;
reg[CHANGED_PC_STATUS] = 0;
+ if (selected_boot_mode == boot_game) {
+ reg[REG_SP] = 0x03007F00;
+ reg[REG_PC] = 0x08000000;
+ reg[REG_CPSR] = 0x0000001F; // system mode
+ reg[CPU_MODE] = MODE_USER;
+ } else {
+ reg[REG_SP] = 0x03007F00;
+ reg[REG_PC] = 0x00000000;
+ reg[REG_CPSR] = 0x00000013 | 0xC0; // supervisor
+ reg[CPU_MODE] = MODE_SUPERVISOR;
+ }
+
+ // Stack pointers are set by BIOS, we set them
+ // nevertheless, should we not boot from BIOS
reg_mode[MODE_USER][5] = 0x03007F00;
reg_mode[MODE_IRQ][5] = 0x03007FA0;
reg_mode[MODE_FIQ][5] = 0x03007FA0;