Null video driver: Add driver parameter to run until exit

This commit is contained in:
Jonathan G Rennison
2019-10-02 19:15:04 +01:00
parent 170e71787b
commit 33f5e00700
2 changed files with 15 additions and 6 deletions

View File

@@ -19,6 +19,8 @@
/** Factory for the null video driver. */ /** Factory for the null video driver. */
static FVideoDriver_Null iFVideoDriver_Null; static FVideoDriver_Null iFVideoDriver_Null;
extern bool _exit_game;
const char *VideoDriver_Null::Start(const char * const *parm) const char *VideoDriver_Null::Start(const char * const *parm)
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
@@ -27,6 +29,7 @@ const char *VideoDriver_Null::Start(const char * const *parm)
#endif #endif
this->ticks = GetDriverParamInt(parm, "ticks", 1000); this->ticks = GetDriverParamInt(parm, "ticks", 1000);
this->until_exit = GetDriverParamBool(parm, "until_exit");
_screen.width = _screen.pitch = _cur_resolution.width; _screen.width = _screen.pitch = _cur_resolution.width;
_screen.height = _cur_resolution.height; _screen.height = _cur_resolution.height;
_screen.dst_ptr = nullptr; _screen.dst_ptr = nullptr;
@@ -44,12 +47,17 @@ void VideoDriver_Null::MakeDirty(int left, int top, int width, int height) {}
void VideoDriver_Null::MainLoop() void VideoDriver_Null::MainLoop()
{ {
uint i; if (this->until_exit) {
while (!_exit_game) {
for (i = 0; i < this->ticks; i++) {
GameLoop(); GameLoop();
UpdateWindows(); UpdateWindows();
} }
} else {
for (int i = 0; i < this->ticks; i++) {
GameLoop();
UpdateWindows();
}
}
} }
bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; } bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; }

View File

@@ -17,7 +17,8 @@
/** The null video driver. */ /** The null video driver. */
class VideoDriver_Null : public VideoDriver { class VideoDriver_Null : public VideoDriver {
private: private:
uint ticks; ///< Amount of ticks to run. int ticks; ///< Amount of ticks to run.
bool until_exit;
public: public:
const char *Start(const char * const *param) override; const char *Start(const char * const *param) override;