resonance 1.0.1
Loading...
Searching...
No Matches
mainloop.h
Go to the documentation of this file.
1#pragma once
2
3#include "app/task.h"
4#include "os/hxstr.h"
5
7
8namespace Sch {
9class Scheduler;
10} // namespace Sch
11
32class MainLoop : public Task {
33public:
44 MainLoop(int nInCharge, Sch::Scheduler *pWatchdog, GameManagerImpl *pGameManager);
45
54 virtual ~MainLoop();
55
64 void Run();
65
66#ifdef VIDEO_STANDARD_PAL
72 void Stop() {
73 mRunning = 0;
74 }
75#endif
76
84 void Callback(long long nNowNs);
85
93
102 void Resume();
103
113 void Step(int nFrames);
114
124 static void PumpTimers();
125
136 static void KeepAliveDraw();
137
138protected:
146 virtual float Progress();
147
155 virtual HxStr Name() const;
156
164 virtual int Poll();
165
166private:
178 void FirePollTimer(long long nNowNs);
179
186 void SchCallback(long long nNowNs);
187
194 void PostDraw();
195
196 int mRunning; // +0x0c
197 long long mNextBankPollNs; // +0x10
198 long long mNextWatchdogPollNs; // +0x18
199 long long mNextDeadlineNs; // +0x20
200 int mFrameCount; // +0x28
201 int mFlushFrame; // +0x2c
202 Sch::Scheduler *mWatchdog; // +0x30
203 GameManagerImpl *mGameManager; // +0x34
204 // The virtual Attachment base closes the object at `+0x38`; the compiler constructs the base
205 // with one reference and the base table. The constructor's flag-gated stores perform the
206 // construction in the image. No member is declared for the base here.
207};
208
215extern MainLoop *g_pMainLoop;
Owner of the running game.
Definition gamemanagerimpl.h:111
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
The game's frame loop.
Definition mainloop.h:32
void Step(int nFrames)
Schedule the watchdog's readings to be written out after a further run of frames.
virtual float Progress()
Report no progress, because the frame loop never finishes.
void Resume()
Write the watchdog's readings out now and disarm the scheduled write.
virtual HxStr Name() const
Report an empty title.
void Callback(long long nNowNs)
Fire every timer whose deadline has passed, then recompute the next deadline.
static void PumpTimers()
Drive the two periodic timers while the frame loop is blocked.
void UpdateCallbackTime()
Recompute the earliest of the two timer deadlines.
virtual ~MainLoop()
Drop the instance pointer and remove the poll callback.
MainLoop(int nInCharge, Sch::Scheduler *pWatchdog, GameManagerImpl *pGameManager)
Create the frame loop and take over the long-operation callbacks.
static void KeepAliveDraw()
Redraw the display during a long operation.
void Run()
Pump the frame loop until it stops.
virtual int Poll()
Run one frame.
Scheduler that runs queued commands when their due time arrives.
Definition scheduler.h:45
MainLoop * g_pMainLoop
The single frame loop, or null before Globals::Init() and after the loop is destroyed.
Scheduling of timed commands.
Definition activefilter.h:9