u32 PC = reg[15].I; bool savedArmState = armState; CPUSwitchMode(0x13, true, false); reg[14].I = PC - (savedArmState ? 4 : 2); reg[15].I = 0x08; armState = true; armIrqEnable = false; armNextPC = 0x08; reg[15].I += 4;
static bool disableMessage = false; if(armState) comment >>= 16; #ifdef BKPT_SUPPORT if(comment == 0xff) { extern void (*dbgOutput)(char *, u32); dbgOutput(NULL, reg[0].I); return; } #endif #ifdef PROFILING if(comment == 0xfe) { profStartup(reg[0].I, reg[1].I); return; } if(comment == 0xfd) { profControl(reg[0].I); return; } if(comment == 0xfc) { profCleanup(); return; } if(comment == 0xfb) { profCount(); return; } #endif if(comment == 0xfa) { agbPrintFlush(); return; } if(useBios) { #ifdef DEV_VERSION if(systemVerbose & VERBOSE_SWI) { log("SWI: %08x at %08x (0x%08x,0x%08x,0x%08x,VCOUNT = %2d)\n", comment, armState ? armNextPC - 4: armNextPC -2, reg[0].I, reg[1].I, reg[2].I, VCOUNT); } #endif CPUSoftwareInterrupt(); return; }      switch(comment) { case 0x00: BIOS_SoftReset(); break; case 0x01: BIOS_RegisterRamReset(); break; case 0x02: #ifdef DEV_VERSION if(systemVerbose & VERBOSE_SWI) { log("Halt: (VCOUNT = %2d)\n", VCOUNT); } #endif holdState = true; holdType = -1; break; case 0x03: #ifdef DEV_VERSION if(systemVerbose & VERBOSE_SWI) { log("Stop: (VCOUNT = %2d)\n", VCOUNT); } #endif holdState = true; holdType = -1; stopState = true; break; case 0x04: #ifdef DEV_VERSION if(systemVerbose & VERBOSE_SWI) { log("IntrWait: 0x%08x,0x%08x (VCOUNT = %2d)\n", reg[0].I, reg[1].I, VCOUNT); } #endif CPUSoftwareInterrupt(); break; case 0x05: #ifdef DEV_VERSION if(systemVerbose & VERBOSE_SWI) { log("VBlankIntrWait: (VCOUNT = %2d)\n", VCOUNT); } #endif CPUSoftwareInterrupt(); break; case 0x06: CPUSoftwareInterrupt(); break; case 0x07: CPUSoftwareInterrupt(); break; case 0x08: BIOS_Sqrt(); break; case 0x09: BIOS_ArcTan(); break; case 0x0A: BIOS_ArcTan2(); break; case 0x0B: BIOS_CpuSet(); break; case 0x0C: BIOS_CpuFastSet(); break; case 0x0E: BIOS_BgAffineSet(); break; case 0x0F: BIOS_ObjAffineSet(); break; case 0x10: BIOS_BitUnPack(); break; case 0x11: BIOS_LZ77UnCompWram(); break; case 0x12: BIOS_LZ77UnCompVram(); break; case 0x13: BIOS_HuffUnComp(); break; case 0x14: BIOS_RLUnCompWram(); break; case 0x15: BIOS_RLUnCompVram(); break; case 0x16: BIOS_Diff8bitUnFilterWram(); break; case 0x17: BIOS_Diff8bitUnFilterVram(); break; case 0x18: BIOS_Diff16bitUnFilter(); break; case 0x19: #ifdef DEV_VERSION if(systemVerbose & VERBOSE_SWI) { log("SoundBiasSet: 0x%08x (VCOUNT = %2d)\n", reg[0].I, VCOUNT); } #endif if(reg[0].I) systemSoundPause(); else systemSoundResume(); break; case 0x1F: BIOS_MidiKey2Freq(); break; case 0x2A: BIOS_SndDriverJmpTableCopy();  default: #ifdef DEV_VERSION if(systemVerbose & VERBOSE_SWI) { log("SWI: %08x at %08x (0x%08x,0x%08x,0x%08x,VCOUNT = %2d)\n", comment, armState ? armNextPC - 4: armNextPC -2, reg[0].I, reg[1].I, reg[2].I, VCOUNT); } #endif  if(!disableMessage) { systemMessage(MSG_UNSUPPORTED_BIOS_FUNCTION, "Unsupported BIOS function %02x called from %08x. A BIOS file is needed in order to get correct behaviour.", comment, armMode ? armNextPC - 4: armNextPC - 2); disableMessage = true; } break; }
void CPUSoftwareInterrupt(){  u32 PC = reg[15].I;  bool savedArmState = armState;  CPUSwitchMode(0x13, true, false);  reg[14].I = PC - (savedArmState ? 4 : 2);  reg[15].I = 0x08;  armState = true;  armIrqEnable = false;  armNextPC = 0x08;  reg[15].I += 4;}