Sly 1:Executable: Difference between revisions

Added infobox
(add c++ abi/libgcc2)
(Added infobox)
 
(4 intermediate revisions by 2 users not shown)
Line 1:
{{Infobox file
{{DISPLAYTITLE:SCUS_971.98}}
|name=SCUS_971.98
'''SCUS_971.98''' is the [[executable]] for {{Sly 1}}. It is an ELF binary compiled for the PS2’s [[Wikipedia:Emotion Engine|Emotion Engine]] processor. The compiler is GCC v2.9-ee-991111b.<ref>Based on strings found in the May 2002 demo build</ref>
|type=MIPS r5900 ELF
}}
 
'''SCUS_971.98''' is the [[executable]] for {{Sly 1}}. It is an ELF binary compiled for the PS2’s [[Wikipedia:Emotion Engine|Emotion Engine]] processor. The compiler is GCC<tt>ee-gcc v2.9-ee-991111b</tt>.<ref>Based on strings found in the May 2002 demo build</ref>
 
== Libraries ==
{{Hatnote|This section contains educated guesses based on available information and context clues, and may be inaccurate or incomplete.}}
 
=== IOP module librariesmodules ===
These library filesmodules are included on the disc alongside the game executable, and are loaded on the IOP core by it.
 
* '''sio2man.irx''' – Manager Interface for joypads, multitaps and memory cards<ref name=":0">[https://www.retroreversing.com/irx-ps2 IRX Files for Playstation 2] - Retro Reversing, 29 March 2021</ref>
Line 38 ⟶ 42:
* '''libipu  2400''' – Image data Processor (IPU) library<ref name=":1" />
 
== Initialization and main loop ==
=== _start ===
The entry point for the executable is <code>_start</code>, which is provided by the PS2 SDK's <code>crt0.s</code>. It sets up the main thread, initializes the main thread's heap, and calls <code>main</code>.
 
=== main ===
It sets up the main thread, initializes the main thread's heap, and calls <code>main</code>. The <code>main</code> function takes two arguments, <code>int cphzArgs</code> (the number of arguments) and <code>char** apchzArgs</code> (the array of arguments). It performs some initialization and begins the main game loop.
The <code>main</code> function takes two parameters, <code>int cphzArgs</code> (the number of arguments) and <code>char** apchzArgs</code> (an array of arguments), which it stores as the the global variables <code>g_cphzArgs</code> and <code>g_apchzArgs</code> respectively. It calls <code>__main</code> and <code>Startup</code> to initialize the game engine, then begins the main loop.
 
==== Initialization__main ====
<code>main</code> starts by calling <code>__main</code>,is a libgcc function that iterates through a generated table of initialization functions which initialize global variables and construct global objects, calling them all.
 
==== Startup ====
Execution then returns to <code>main</code> which stores the passed parameters in <code>g_cphzArgs</code> and <code>g_apchzArgs</code> respectively. It then calls <code>Startup</code>, a function which initializes even more game variables.
<code>Startup</code> begins by calling <code>SetPhase</code>, setting <code>g_phase</code> to <code>PHASE::Startup</code>. It then iterates over an array of function pointers, called <code>StartupSampler</code>, and calls each one. The startup sampler includes the startup functions for many game subsystems, such as DMA, Thread, Codes, Screen, and Clock, and more.
{{Investigate|Investigate and expand on what <code>Startup</code> does.}}
 
=== Game loop ===
Line 53 ⟶ 59:
 
* First, check if <code>g_mpeg</code> has an [[MPEG]] queued to be played. If so:
** <code>FlushFrames(1)</code> – CallsCall some graphics functions and swap the graphics synthesizer buffers
** <code>CTransitiong_transition::Execute(&g_transition)</code> – ExecutesExecute the MPEG on the global [[Sly 1:Transition|transitionCTransition]] instance
* Check if <code>g_transition</code> has a pending transition (i.e. <code>m_fPending != 0</code>). If so:
** <code>FlushFrames(1)</code>
** Call a function that calls <code>CMpeg::Execute</code> on the <code>g_transition</code> instance.
* Check '''again''' if <code>g_mpeg</code> has an MPEG queued to be played (this happens if two MPEGs were queued to play back-to-back). If so:
** <code>FlushFrames(1)</code>
** <code>CTransitiong_transition::Execute(&g_transition)</code>
* <code>UpdateJoy(&g_joy)</code> – Handles [[Sly 1:Input|controller input]]
* <code>UpdateCodes()</code> – WatchesWatche for [[Sly 1:Cheat codes|cheat code]] inputs
* Call an unknown function that handles saving the game.
* <code>UpdateUi(&g_ui)</code> – UpdatesUpdate the state of the [[Sly 1:Screen|GUI]]
* <code>UpdateGameState(g_clock.dt)</code> – UpdatesUpdate the running timers on the [[Sly 1:GS|game state]] structs
* <code>if (g_psw != NULLPTR)</code> – If g_psw is nothas nullbeen initialized..
** <code>SetupCm(g_pcm)</code> – SetsSet up some [[Sly 1:Camera|camera]] values to render the next frame
** <code>OpenFrame()</code> – PreparesPrepare to render the next frame
** <code>MarkClockTick(&g_clock)</code> – UpdatesUpdate the global [[Sly 1:Clock|clock]] values
** Grab a particular function pointer from the <code>g_psw</code> struct and execute it if it is not NULL. The function's purpose is unknown but it takes <code>g_clock.dt</code> as an argument, so it's probably an Update function.
** <code>RenderSw(g_psw, g_pcm)</code> – RendersRender [[Sly 1:SW|game objects]] from the given camera perspective
** <code>RenderUi()</code> – RendersRender the GUIUI [[Sly 1:BLOT|blots]] on the current frame
** <code>DrawSw(g_psw, g_pcm)</code> – DrawsDraw the game objects from the given camera perspective
** <code>DrawUi()</code> – DrawsDraw the GUIUI elements on the frame
** <code>CloseFrame()</code> – FinishesFinish rendering the frame
* Increment the global frame counter, <code>g_cframe</code>.