Boot
Boot is the path from the BIOS handoff to the first title frame. A C runtime stub prepares the CPU, SYS_Main initializes the console, LOGO.EXE plays the Capcom movie, and two callbacks load the first two archives and start the title. The frame loop then runs until power-off. Title states: game phases. Loader steps: loading.
Executable header and C runtime
Section titled “Executable header and C runtime”The BIOS reads SYSTEM.CNF, loads SLUS_004.22 and jumps to its entry address (copies t_size bytes to t_addr, then jumps to the start address; BIOS behavior [inferred]). Header fields: executables and boot files.
The payload is far larger than the resident code; the rest is zero fill that reserves RAM for later loads (memory map).
Three stubs prepare the CPU and start the game. The header’s start address is stup2.
| Stub | What it does |
|---|---|
stup2 (exe/slus_004_22@0x8014AA0C) |
zero-fills 0x8018B2B8..0x80190C60, the BSS (memory map), then falls into stup1 |
stup1 (exe/slus_004_22@0x8014AA30) |
sets sp to 0x80200000, gp to 0x8018B2B4, copies sp to fp, calls InitHeap(0x80190C64, 0x673A0) |
stup0 (exe/slus_004_22@0x8014AAAC) |
jal SYS_Main, followed by a break that is never reached |
stup1 sets the stack top to 0x80200000 (top of RAM) and ends the heap 32,768 bytes below it, at 0x801F8004. The heap range overlaps the resident game program at 0x80195800 and the overlay arena at 0x801CE000. The executable has no malloc, free, calloc or realloc, so the heap is declared and never used. [inferred] __main (exe/slus_004_22@0x8014AA04) is a bare jr $ra.
SYS_Main sequence
Section titled “SYS_Main sequence”SYS_Main initializes, then enters the permanent loop:
__main, then clearg_SysHardwareInitialized.SYS_InitRuntime (exe/slus_004_22@0x8014ACA0):SYS_InitHardware,SYS_InitDisplay, reset both render records,CallbackInitThreads, clear all of VRAM,DrawSync(0),SetDispMask(1)andSYS_PrepareFrame.SYS_StartLogo: run the logo program, described below.- Install
SYS_CaptureDrawTimeas theDrawSynccallback andCallbackRegister(0, SYS_StartFrontend). - Enter the permanent loop. The first
CallbackRunopens slot 0.
SYS_InitHardware (exe/slus_004_22@0x8014AD28) runs twice, once before the logo and once after it. It does this in order:
ResetCallback, thenEMI_Init (exe/slus_004_22@0x80161F58). The loader init loops onCdInituntil the drive answers, waitsVSync(3)and clears the 24 loader slot states.- On the first call:
VSync(0),ResetGraph(0),SetVideoMode(MODE_NTSC), setg_SysHardwareInitializedand enable the CPU trap event withSYS_ShowExceptionas its handler. On the second call:VSync(0)andResetGraph(3), which keeps the display. InitGeom,SetGeomScreen(0x3E8),SetGeomOffset(0xA0, 0x78).PadInit(0),SYS_InitCard(seven card events,InitCARD(1),StartCARD,_bu_init) andChangeClearPAD(0).
SYS_ShowException (exe/slus_004_22@0x8014B3C4) draws a register dump on a double-buffered screen and never returns. Sound is not initialized here. SYS_StartFrontend does it after the logo.
SYS_InitDisplay (exe/slus_004_22@0x8014AE08) sets up two draw and display environment pairs of 320 x 240. One draws at y = 0 and displays y = 0xF0, and the other draws at y = 0xF0 and displays y = 0. The frame loop alternates between them.
The logo program
Section titled “The logo program”SYS_StartLogo (exe/slus_004_22@0x8014AEE0) loads LOGO.EXE and runs it as a separate PlayStation program:
SYS_LoadExec (exe/slus_004_22@0x8014E0FC)finds the file withCdSearchFile, reads its header sector into the buffer at0x800E4800, copies the ten header words toD_80143E70, then readst_sizebytes from the next sector tot_addr(executable load).- It sets the stack address of the exec block at
0x80143E80(D_80143EA0) to0x801FF000, stops the callback, pad and card services, and callsExecinside a critical section. - When
Execreturns, it runsSYS_InitHardwareagain, clears the display and the VRAM, and turns the display on.
LOGO.EXE loads at 0x801CE000 and runs to 0x801ECEC0 with its BSS. The payload of the main executable is zero over that range, apart from two stamp words, so the logo overwrites no resident byte. No overlay is loaded yet.
exe/logo starts at __SN_ENTRY_POINT (exe/logo@0x801CE724), which zeroes its BSS (0x801EB430..0x801ECEC0), sets gp and jumps to Logo_Main (exe/logo@0x801CEDFC). The logo carries its own copy of the PsyQ libraries. Logo_Main calls CdInit and Logo_Init, then loops until the stream ends or the Start button is held. At the end it fades the audio out, stops the stream, the callbacks and the pad, and returns to SYS_StartLogo per the BIOS Exec contract. [inferred]
The movie is read by sector number. Logo_Init receives the literal LBA 0x2D78C, the start of disc file slot 0x373; slot 0x374 starts 1,155 sectors later, so the file is 2,365,440 bytes, the size of LOGO/CAPCOM30.STR. Slots: disc and files. Movie code: loading.
The first two callbacks
Section titled “The first two callbacks”After the logo, the first pass of the loop opens slot 0, which runs SYS_StartFrontend (exe/slus_004_22@0x8014EA80). It does this in order:
- Clear VRAM, then
CallbackWait(1)to yield one frame. SND_Init,SND_SetBankLayout(0).- Stream
FIRST.EMI(slot0x261) and wait withCallbackWait(1)untilEMI_IsReady. Loading explains the stream. - Set reverb depth, call
SND_Start. - Clear 4,272 bytes of game state from
D_801448D8. Reset the game flags, the walk flags andg_EmiLoadedCharacterIndex(to0xFF), and copy nine halfwords fromD_8017F56Cintog_InputMasks. - Reset the panel tasks, palette fades, palette slots, draw flags and script table. Set the area draw mode to 6 and request a palette upload.
CallbackRegister(1, SYS_EnterFrontend), thenCallbackExit, which ends slot 0’s own thread.
SYS_EnterFrontend (exe/slus_004_22@0x8014EC64) starts in slot 1 in the pass where slot 0 registers it. It streams GAME.EMI (slot 0x262), waits for EMI_IsReady, and calls Game_UpdateTitle (emi/etc/game/01@0x801D0C04). Entry 0 of GAME.EMI is the resident game program at 0x80195800; entry 1 is the title overlay at 0x801D0C00, which holds Game_UpdateTitle.
Game_UpdateTitle clears its state and loops forever on slot 1’s thread. Each pass it yields with CallbackWait(1), handles the Start button, runs one of eight title handlers that g_UiTitleState selects, and updates the banner and fades. The first handler, Game_BeginTitle (emi/etc/game/01@0x801D0C90), selects sound bank layout 2, streams DEMO (slot 0x25F), resets the palette stage and starts music cue 0x8D. Title exits: phases.
sequenceDiagram
autonumber
participant B as BIOS
participant M as SYS_Main
participant L as LOGO.EXE
participant S as callback slots
participant E as EMI loader
participant T as title overlay
B->>M: stup2, stup1, stup0
M->>M: SYS_InitRuntime
M->>L: SYS_StartLogo: load,<br/>Exec
L-->>M: movie ends, return
M->>M: SYS_InitHardware again
M->>S: CallbackRegister(0,<br/>SYS_StartFrontend)
M->>S: CallbackRun<br/>(every pass)
S->>E: slot 0: stream FIRST,<br/>poll until ready
S->>S: CallbackRegister(1,<br/>SYS_EnterFrontend),<br/>CallbackExit
S->>E: slot 1: stream GAME,<br/>poll until ready
S->>T: call Game_UpdateTitle
T->>E: Game_BeginTitle:<br/>stream DEMO
The first frame with the title drawn and input enabled is the first playable frame (phases).
Open questions
Section titled “Open questions”| Question | What would settle it |
|---|---|
How the BIOS loads the executable and returns from Exec |
A trace of a run, or the BIOS source; the game files do not show it |
Whether PsyQ library code uses the InitHeap memory |
Search the linked PsyQ objects for heap users |
Other readers of D_80143EFC, the DrawSync callback value |
Area_CanStartEncounter is the only reader found; search the overlays |
Why the soft reset waits for EMI_IsReady |
Read the loader state machine in loading |
Sources and confidence
Section titled “Sources and confidence”- Confidence: medium. The boot steps are read in the executable, the title overlay and
LOGO.EXE; the BIOS behavior at load and atExec, and the heap use, are[inferred]or[unknown]. - Evidence: the code of
stup2,stup1,stup0,SYS_Main,SYS_InitRuntime,SYS_InitHardware,SYS_StartLogo,SYS_LoadExec,SYS_StartFrontend,SYS_EnterFrontendandGame_UpdateTitle; the entry code ofLOGO.EXE; the logo’s literal movie LBA against the disc file table.
Related
Section titled “Related”- Frame loop: the loop that
SYS_Mainenters. - Scheduler and tasks: the callback slots that carry the first two callbacks.
- Loading: how
FIRST.EMIandGAME.EMIstream. - Game phases: the title, the start menu and the path to the field.
- Executables and boot files: the header fields and the disc file table.