From 63e75089d6e61504ee9ad56200dde1eb937b1cd4 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 31 Mar 2020 16:32:50 +0100 Subject: [PATCH] Split SDL2 code from Game.cpp --- src/Backends/Platform.h | 2 ++ src/Backends/Platform/SDL2.cpp | 5 +++++ src/Game.cpp | 19 +++++++++---------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Backends/Platform.h b/src/Backends/Platform.h index 541e414b..6e693047 100644 --- a/src/Backends/Platform.h +++ b/src/Backends/Platform.h @@ -11,3 +11,5 @@ void PlatformBackend_GetBasePath(char *string_buffer); BOOL PlatformBackend_SystemTask(void); void PlatformBackend_ShowMessageBox(const char *title, const char *message); + +unsigned long PlatformBackend_GetTicks(void); diff --git a/src/Backends/Platform/SDL2.cpp b/src/Backends/Platform/SDL2.cpp index 711cb1f3..702b5d16 100644 --- a/src/Backends/Platform/SDL2.cpp +++ b/src/Backends/Platform/SDL2.cpp @@ -257,3 +257,8 @@ void PlatformBackend_ShowMessageBox(const char *title, const char *message) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, NULL); } + +unsigned long PlatformBackend_GetTicks(void) +{ + return SDL_GetTicks(); +} diff --git a/src/Game.cpp b/src/Game.cpp index 32feef26..8ef8b97a 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -4,10 +4,9 @@ #include #include -#include "SDL.h" - #include "WindowsWrapper.h" +#include "Backends/Platform.h" #include "ArmsItem.h" #include "Back.h" #include "Boss.h" @@ -215,8 +214,8 @@ int ModeOpening(void) ++gCounter; } - wait = SDL_GetTicks(); - while (SDL_GetTicks() < wait + 500) + wait = PlatformBackend_GetTicks(); + while (PlatformBackend_GetTicks() < wait + 500) { CortBox(&grcGame, 0x000000); PutFramePerSecound(); @@ -461,8 +460,8 @@ int ModeTitle(void) ChangeMusic(MUS_SILENCE); // Black screen when option is selected - wait = SDL_GetTicks(); - while (SDL_GetTicks() < wait + 1000) + wait = PlatformBackend_GetTicks(); + while (PlatformBackend_GetTicks() < wait + 1000) { CortBox(&grcGame, 0); PutFramePerSecound(); @@ -692,9 +691,9 @@ BOOL Game(void) if (!LoadGenericData()) { #ifdef JAPANESE - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "汎用ファイルが読めない", NULL); + PlatformBackend_ShowMessageBox("エラー", "汎用ファイルが読めない"); #else - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Couldn't read general purpose files", NULL); + PlatformBackend_ShowMessageBox("Error", "Couldn't read general purpose files"); #endif return FALSE; @@ -708,9 +707,9 @@ BOOL Game(void) if (!LoadNpcTable(path)) { #ifdef JAPANESE - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "NPCテーブルが読めない", NULL); + PlatformBackend_ShowMessageBox("エラー", "NPCテーブルが読めない"); #else - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Couldn't read the NPC table", NULL); + PlatformBackend_ShowMessageBox("Error", "Couldn't read the NPC table"); #endif return FALSE;