Sly 1:Executable: Difference between revisions

Expanded on main and Startup functions, other minor tweaks
(→‎Game loop: Tweaked main game loop)
(Expanded on main and Startup functions, other minor tweaks)
Line 1:
'''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>
{{DISPLAYTITLE: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>
 
== Libraries ==
Line 38 ⟶ 37:
* '''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 sampled contains the startup functions for many game subsystems, such as DMA, Thread, Codes, Screen, and Clock, and many more.
{{Investigate|Investigate and expand on what <code>Startup</code> does.}}
 
=== Game loop ===