+ return retval;
+}
+
+static void SetBootRegs(u32 pc, u32 gp, u32 sp)
+{
+ //printf("%s %08x %08x %08x\n", __func__, pc, gp, sp);
+ psxCpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL);
+
+ psxRegs.pc = pc;
+ psxRegs.GPR.n.gp = gp;
+ psxRegs.GPR.n.sp = sp ? sp : 0x801fff00;
+ psxRegs.GPR.n.fp = psxRegs.GPR.n.sp;
+
+ psxRegs.GPR.n.t0 = psxRegs.GPR.n.sp; // mimic A(43)
+ psxRegs.GPR.n.t3 = pc;
+
+ psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL);
+}
+
+int BiosBootBypass() {
+ struct CdrStat stat = { 0, 0, };
+ assert(psxRegs.pc == 0x80030000);
+
+ // no bypass if the lid is open
+ CDR__getStatus(&stat);
+ if (stat.Status & 0x10)
+ return 0;
+
+ // skip BIOS logos and region check
+ psxCpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL);
+ psxRegs.pc = psxRegs.GPR.n.ra;
+ return 1;
+}
+
+static void getFromCnf(char *buf, const char *key, u32 *val)
+{
+ buf = strstr(buf, key);
+ if (buf)
+ buf = strchr(buf, '=');
+ if (buf) {
+ unsigned long v;
+ errno = 0;
+ v = strtoul(buf + 1, NULL, 16);
+ if (errno == 0)
+ *val = v;
+ }