|
resonance 1.0.1
|
The game's frame loop. More...
#include <mainloop.h>


Public Member Functions | |
| MainLoop (int nInCharge, Sch::Scheduler *pWatchdog, GameManagerImpl *pGameManager) | |
| Create the frame loop and take over the long-operation callbacks. | |
| virtual | ~MainLoop () |
| Drop the instance pointer and remove the poll callback. | |
| void | Run () |
| Pump the frame loop until it stops. | |
| void | Callback (long long nNowNs) |
| Fire every timer whose deadline has passed, then recompute the next deadline. | |
| void | UpdateCallbackTime () |
| Recompute the earliest of the two timer deadlines. | |
| void | Resume () |
| Write the watchdog's readings out now and disarm the scheduled write. | |
| void | Step (int nFrames) |
| Schedule the watchdog's readings to be written out after a further run of frames. | |
| Public Member Functions inherited from Task | |
| Task () | |
| Task (const Task &other) | |
| Construct a task with its own fresh node. | |
| virtual | ~Task () |
| Unlink the task and release its node. | |
| Task & | operator= (const Task &other) |
| Reset the task to kTaskStateIdle. | |
| int | Start (int bBlocking) |
| Begin running the task. | |
| int | Suspend () |
| Unlink the task and retain its position. | |
| int | Reset () |
| Return the task to kTaskStateIdle so that it can be started again. | |
| int | Finish () |
| Retire the task. | |
| int | State () const |
| Read the task's lifecycle position. | |
| int | InProgress () const |
| Test whether the task has been started and has not yet finished. | |
| float | GetProgress () |
| Read how far the task has progressed. | |
| HxStr | GetStatus () const |
| Read the task's display title. | |
| int | GetQuiet () |
| Test whether the task suppresses its progress report. | |
| Public Member Functions inherited from Attachment | |
| Attachment () | |
| virtual | ~Attachment () |
| int | Release () |
| Give back one reference and destroy the object once the last one is gone. | |
| virtual void | Destroy () |
| Destroy the object. | |
Static Public Member Functions | |
| static void | PumpTimers () |
| Drive the two periodic timers while the frame loop is blocked. | |
| static void | KeepAliveDraw () |
| Redraw the display during a long operation. | |
| Static Public Member Functions inherited from Task | |
| static int | PollTasks () |
| Poll every running task once. | |
| Static Public Member Functions inherited from Attachment | |
| static void | ReleaseIfSet (Attachment *pAttachment) |
| Give back one reference to an object that may be null. | |
Protected Member Functions | |
| virtual float | Progress () |
| Report no progress, because the frame loop never finishes. | |
| virtual HxStr | Name () const |
| Report an empty title. | |
| virtual int | Poll () |
| Run one frame. | |
| Protected Member Functions inherited from Task | |
| virtual int | Quiet () |
| Report whether the task suppresses its progress report. | |
| virtual int | CheckStateChange (int nFrom, int nTo) |
| Approve or refuse a lifecycle change. | |
Additional Inherited Members | |
| Public Attributes inherited from Attachment | |
| int | mRefs |
The game's frame loop.
Its RTTI descriptor is at 0x00901f80. It derives from Task. The declared members occupy +0x0c through +0x37, and the virtual Attachment base closes the object at +0x38. The allocation is 0x40 bytes. The MainLoop table is at 0x007e7ce0.
Globals::Init() creates the single instance and Globals::RunMainLoop() drives it. Every member below is private, because the only code that reads one is a member of this class.
Run() pumps Poll() until mRunning is cleared. Nothing in the image clears it, so the loop is where the whole game runs and Run() never returns. Poll() samples the profiler clock, advances the asynchronous loader and the synth stream, recomputes the frames-per-second reading once a second, and then requests one frame from the game manager.
Two periodic timers run alongside the frame, each with a four-millisecond period. One polls the game manager and the other services the long-operation watchdog. Callback() is what a blocked long operation calls back into through the poll callback the constructor installs, so both timers continue to run while the frame loop itself is stalled.
| MainLoop::MainLoop | ( | int | nInCharge, |
| Sch::Scheduler * | pWatchdog, | ||
| GameManagerImpl * | pGameManager ) |
Create the frame loop and take over the long-operation callbacks.
| nInCharge | The call site always passes 1. The flag selects virtual-base setup the compiler emits. The body does not use the flag. |
| pWatchdog | The long-operation watchdog to service. |
| pGameManager | The game manager to draw through. |
|
virtual |
Drop the instance pointer and remove the poll callback.
The redraw callback the constructor installed is not removed.
| void MainLoop::Run | ( | ) |
Pump the frame loop until it stops.
Nothing in the image clears mRunning, so the routine does not return.
| void MainLoop::Callback | ( | long long | nNowNs | ) |
Fire every timer whose deadline has passed, then recompute the next deadline.
| nNowNs | The current reading of the frame clock in nanoseconds. |
| void MainLoop::UpdateCallbackTime | ( | ) |
Recompute the earliest of the two timer deadlines.
| void MainLoop::Resume | ( | ) |
Write the watchdog's readings out now and disarm the scheduled write.
The routine is unreferenced in the image.
| void MainLoop::Step | ( | int | nFrames | ) |
Schedule the watchdog's readings to be written out after a further run of frames.
The routine is unreferenced in the image.
| nFrames | The number of frames to wait. |
|
static |
Drive the two periodic timers while the frame loop is blocked.
The long-operation poll callback. Renderer's constructor also calls it directly, at 0x0042c3bc, before it waits for the common loads.
|
static |
Redraw the display during a long operation.
Refreshes the display at most once every 18 milliseconds of the profiler clock, or every 21 milliseconds in the PAL build. Public because GrooveWorld::EndLevel() at 0x0018eb70 installs it as the bank-load progress hook.
|
protectedvirtual |
Report no progress, because the frame loop never finishes.
Implements Task.
|
protectedvirtual |
Report an empty title.
Implements Task.
|
protectedvirtual |
Run one frame.
Implements Task.