Sly 1:Executable: Difference between revisions

Added infobox
(→‎Libraries: Tweaked wording)
Tags: Mobile edit Mobile web edit
(Added infobox)
 
(14 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 a PS2 [[Wikipedia:ELF|ELF]] compiled for the [[Wikipedia:Emotion Engine|Emotion Engine]] processor. The compiler is GCC v2.9-ee-991111b.
|type=MIPS r5900 ELF
}}
 
'''SCUS_971.98''' is the [[executable]] for {{Sly 1}}. It is aan PS2 [[Wikipedia:ELF|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.}}
 
=== SharedIOP librariesmodules ===
These libary filesmodules are included on the disc alongside the game executable, and are loaded on the IOP core.
 
* '''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 16 ⟶ 20:
 
=== Static libraries ===
These libraries are bundled with the executable and some are only referenced by name in some strings.
 
==== Standard libraries ====
* '''libkernl''' – PlayStation kernel library
These libraries are shipped either by the Cygnus ee-gcc toolchain or provided as a part of gcc directly.
 
* '''libgcc''' – GCC internal runtime library
* '''libgcc2''' - GCC internal runtime library (provides C++ ABI routines and other misc. runtime functions)
* '''newlib''' – Embedded C standard library implementation
* '''libio –''' GNU implementation of C++ IO streams
* '''libstdc++ –''' GNU C++ standard library
 
==== PS2 SDK libraries ====
These libraries are part of the PS2 SDK and written by SCEI.
 
* '''libkernel''' – Interface to the EE Kernel (syscall wrappers/etc.)
* '''libmc 2430''' – Memory card library
* '''libgraph 2400''' – [[Wikipedia:PlayStation 2 technical specifications#Graphics%20processing%20unit|Graphics synthesizerSynthesizer]] library<ref name=":1">[https://www.retroreversing.com/static-libraries-ps2 Static Libraries (.A) for Playstation 2 Emotion Engine] - Retro Reversing, 9 July 2022</ref>
* '''libdma  2400''' – ''Unknown''Direct Memory Access (DMA) library
* '''libcdvd 2420''' – CD/DVD library
* '''libpad  2410''' – DualShock gamepad library
* '''libipu  2400''' – Image data Processor (IPU) library<ref name=":1" />
 
== Initialization and main loop ==
=== _start ===
The entry point for the executable is the <code>_start</code>. 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 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>.
 
=== Initializationmain ===
The <code>main</code> startsfunction bytakes callingtwo parameters, <code>__mainint cphzArgs</code>, a(the functionnumber that iterates over a functionof tablearguments) and calls each function to initialize several game variables. Exeuction then returns to <code>mainchar** apchzArgs</code> (an array of arguments), which it stores as the passedthe parametersglobal invariables <code>g_cphzArgs</code> and <code>g_apchzArgs</code> respectively. It then calls <code>__main</code> and <code>Startup</code>, ato functioninitialize whichthe intializesgame evenengine, morethen gamebegins variables.the main loop.
 
{{Todo|Investigate and expand on what <code>__main</code> and <code>Startup</code> do}}
==== __main ====
<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 ====
<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.
 
=== Game loop ===
Line 37 ⟶ 59:
 
* First, check if <code>g_mpeg</code> has an [[MPEG]] queued to be played. If so:
** <code>FlushFrames(1);</code> – Call some graphics functions and swap the GSgraphics synthesizer buffers
** <code>CTransitiong_transition::Execute(&g_transition);</code> – Execute the MPEG on the global transition[[Sly 1:Transition|CTransition]] instance
* Check if <code>g_transition</code> has a pending transition (i.e. <code>m_fPending != 0</code>). If so:
** 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 (histhis 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> – HandleHandles [[Sly 1:Input|controller input]]
* <code>UpdateCodes();</code> – WatchWatche for [[Sly 1:Cheat codes|cheat code]] inputs
* Call an unknown function that handles saving the game.
* <code>unk_save_related(&g_save_related_as4);</code> – This function is not well understood, but [[Saving#Sly 1|saving]] the game is not possible without it.
* <code>UpdateUi(&g_ui);</code> – Update the state of GUIthe [[BLOTSly 1:Screen|blotsGUI]]
* <code>UpdateGameState(g_clock.dt);</code> – Update the running timers on the [[Sly 1:GS|game state]] structs
* <code>if (g_psw != (SW *)0x0NULLPTR)</code> – If g_psw is nothas been NULL.initialized..
** <code>SetupCm(g_pcm);</code> – SetupSet up some [[Sly 1:Camera|camera]] values to render the next frame
** <code>OpenFrame();</code> – Prepare to render the next frame
** <code>MarkClockTick(&g_clock);</code> – Update 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. (theThe 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> – Render gameobjects[[Sly on1:SW|game objects]] from the currentgiven camera frameperspective
** <code>RenderUi();</code> – Render the guiUI elements[[Sly 1:BLOT|blots]] on the current frame
** <code>DrawSw(g_psw, g_pcm);</code> – Draw the gameobjectsgame onobjects from the framegiven camera perspective
** <code>DrawUi();</code> – Draw the guiUI elements on the frame
** <code>CloseFrame();</code> – Finish rendering the frame
* Increment the global frame counter, <code>g_cframe</code>.
* <code>g_cframe = g_cframe + 1;</code> – Update the global frame counter
 
This looproutine continues infinitelyin an infinite loop unless <code>Exit</code> is called or a handled exception causes execution to halt, in which case you are immediately booted back to the PS2 BIOS.
 
==Build strings==
Line 69 ⟶ 91:
<code>g_achzBuildUser</code>
<pre>jojo</pre>
 
 
<code>g_achzBuildDateLong</code>
<pre>08/24/02 22:06</pre>
 
 
<code>g_achzBuildDateShort</code>
Line 80 ⟶ 100:
== References ==
<references />
 
{{Navbox Sly 1}}