From f6f3a910397afb769f84d1332014c4eda1fedebe Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Mon, 22 Mar 2021 21:45:52 +0100 Subject: 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). --- cpu.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'cpu.c') 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; -- cgit v1.2.3