Split SDL2 code from Game.cpp

This commit is contained in:
Clownacy 2020-03-31 16:32:50 +01:00
parent 584ea57c5d
commit 63e75089d6
3 changed files with 16 additions and 10 deletions

View file

@ -11,3 +11,5 @@ void PlatformBackend_GetBasePath(char *string_buffer);
BOOL PlatformBackend_SystemTask(void); BOOL PlatformBackend_SystemTask(void);
void PlatformBackend_ShowMessageBox(const char *title, const char *message); void PlatformBackend_ShowMessageBox(const char *title, const char *message);
unsigned long PlatformBackend_GetTicks(void);

View file

@ -257,3 +257,8 @@ void PlatformBackend_ShowMessageBox(const char *title, const char *message)
{ {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, NULL); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, NULL);
} }
unsigned long PlatformBackend_GetTicks(void)
{
return SDL_GetTicks();
}

View file

@ -4,10 +4,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "SDL.h"
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Backends/Platform.h"
#include "ArmsItem.h" #include "ArmsItem.h"
#include "Back.h" #include "Back.h"
#include "Boss.h" #include "Boss.h"
@ -215,8 +214,8 @@ int ModeOpening(void)
++gCounter; ++gCounter;
} }
wait = SDL_GetTicks(); wait = PlatformBackend_GetTicks();
while (SDL_GetTicks() < wait + 500) while (PlatformBackend_GetTicks() < wait + 500)
{ {
CortBox(&grcGame, 0x000000); CortBox(&grcGame, 0x000000);
PutFramePerSecound(); PutFramePerSecound();
@ -461,8 +460,8 @@ int ModeTitle(void)
ChangeMusic(MUS_SILENCE); ChangeMusic(MUS_SILENCE);
// Black screen when option is selected // Black screen when option is selected
wait = SDL_GetTicks(); wait = PlatformBackend_GetTicks();
while (SDL_GetTicks() < wait + 1000) while (PlatformBackend_GetTicks() < wait + 1000)
{ {
CortBox(&grcGame, 0); CortBox(&grcGame, 0);
PutFramePerSecound(); PutFramePerSecound();
@ -692,9 +691,9 @@ BOOL Game(void)
if (!LoadGenericData()) if (!LoadGenericData())
{ {
#ifdef JAPANESE #ifdef JAPANESE
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "汎用ファイルが読めない", NULL); PlatformBackend_ShowMessageBox("エラー", "汎用ファイルが読めない");
#else #else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Couldn't read general purpose files", NULL); PlatformBackend_ShowMessageBox("Error", "Couldn't read general purpose files");
#endif #endif
return FALSE; return FALSE;
@ -708,9 +707,9 @@ BOOL Game(void)
if (!LoadNpcTable(path)) if (!LoadNpcTable(path))
{ {
#ifdef JAPANESE #ifdef JAPANESE
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "NPCテーブルが読めない", NULL); PlatformBackend_ShowMessageBox("エラー", "NPCテーブルが読めない");
#else #else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Couldn't read the NPC table", NULL); PlatformBackend_ShowMessageBox("Error", "Couldn't read the NPC table");
#endif #endif
return FALSE; return FALSE;