Sly 1:Executable: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(→‎Initialization and main loop: Fixed typos, tweaked wording)
Tags: Mobile edit Mobile web edit
Line 37: Line 37:


* First, check if <code>g_mpeg</code> has an [[MPEG]] queued to be played. If so:
* 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 graphics synthesizer buffers
** <code>FlushFrames(1)</code> – Call some graphics functions and swap the graphics synthesizer buffers
** <code>CTransition::Execute(&g_transition);</code> – Execute the MPEG on the global transition instance
** <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:
* Check if <code>g_transition</code> has a pending transition (<code>m_fPending != 0</code>). If so:
** <code>FlushFrames(1);</code>
** <code>FlushFrames(1)</code>
** Call a function that calls <code>CMpeg::Execute</code> on the <code>g_transition</code> instance
** 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:
* 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>FlushFrames(1)</code>
** <code>CTransition::Execute(&g_transition);</code>
** <code>CTransition::Execute(&g_transition)</code>
* <code>UpdateJoy(&g_joy);</code> – Handle controller input
* <code>UpdateJoy(&g_joy)</code> – Handle controller input
* <code>UpdateCodes();</code> – Watch for [[Cheat codes|cheat code]] inputs
* <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 impossible without it
* <code>unk_save_related(&g_save_related_as4)</code> – This function is not well understood, but [[Saving#Sly 1|saving]] the game is impossible without it
* <code>UpdateUi(&g_ui);</code> – Update the state of GUI [[BLOT|blots]]
* <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
* <code>UpdateGameState(g_clock.dt)</code> – Update the running timers on the [[GS|game state]] structs
* <code>if (g_psw != (SW *)0x0)</code> – If g_psw is not NULL...
* <code>if (g_psw != (SW *)0x0)</code> – If g_psw is not NULL...
** <code>SetupCm(g_pcm);</code> – Setup some camera values to render the next frame
** <code>SetupCm(g_pcm)</code> – Setup some camera values to render the next frame
** <code>OpenFrame();</code> – Prepare to render the next frame
** <code>OpenFrame()</code> – Prepare to render the next frame
** <code>MarkClockTick(&g_clock);</code> – Update the global [[clock]] values
** <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)
** 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>RenderSw(g_psw,g_pcm)</code> – Render gameobjects on the current frame
** <code>RenderUi();</code> – Render the gui elements on the current frame
** <code>RenderUi()</code> – Render the gui elements on the current frame
** <code>DrawSw(g_psw,g_pcm);</code> – Draw the gameobjects on the frame
** <code>DrawSw(g_psw,g_pcm)</code> – Draw the gameobjects on the frame
** <code>DrawUi();</code> – Draw the gui elements on the frame
** <code>DrawUi()</code> – Draw the gui elements on the frame
** <code>CloseFrame();</code> – Finish rendering the frame
** <code>CloseFrame()</code> – Finish rendering the frame
* <code>g_cframe = g_cframe + 1;</code> – Update the global frame counter
* <code>g_cframe++</code> – Increment the global frame counter


This loop continues infinitely 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.
This loop continues infinitely 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.