Sly 1:Executable: Difference between revisions

→‎Initialization and main loop: Fixed typos, tweaked wording
(→‎Libraries: Tweaked wording)
Tags: Mobile edit Mobile web edit
(→‎Initialization and main loop: Fixed typos, tweaked wording)
Tags: Mobile edit Mobile web edit
Line 27:
 
==Initialization and main loop==
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.
 
=== Initialization ===
Line 37:
 
* 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>CTransition::Execute(&g_transition);</code> – Execute the MPEG on the global transition instance
* Check if <code>g_transition</code> has a pending transition (<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>CTransition::Execute(&g_transition);</code>
* <code>UpdateJoy(&g_joy);</code> – Handle controller input
* <code>UpdateCodes();</code> – Watch for [[Cheat codes|cheat code]] inputs
* <code>unk_save_related(&g_save_related_as4);</code> – This function is not well understood, but [[Saving#Sly 1|saving]] the game is not possibleimpossible without it.
* <code>UpdateUi(&g_ui);</code> – Update the state of GUI [[BLOT|blots]]
* <code>UpdateGameState(g_clock.dt);</code> – Update the running timers on the [[GS|game state]] structs
Line 54:
** <code>OpenFrame();</code> – Prepare to render the next frame
** <code>MarkClockTick(&g_clock);</code> – Update the global [[clock]] values
** Grab a function pointer from the <code>g_psw</code> struct and execute it if it is not NULL (the function takes <code>g_clock.dt</code> as an argument).
** <code>RenderSw(g_psw,g_pcm);</code> – Render gameobjects on the current frame
** <code>RenderUi();</code> – Render the gui elements on the current frame