Fix missing sdl init

This commit is contained in:
Miloslav Číž 2020-09-25 22:03:46 +02:00
parent 0c18fcc905
commit b8a0edc9de
2 changed files with 15 additions and 2 deletions

3
game.h
View File

@ -3852,7 +3852,8 @@ void SFG_fillRectangle(
static inline void SFG_clearScreen(uint8_t color)
{
SFG_fillRectangle(0,0,SFG_GAME_RESOLUTION_X,SFG_GAME_RESOLUTION_Y,color);
SFG_fillRectangle(0,0,SFG_GAME_RESOLUTION_X - 1,
SFG_GAME_RESOLUTION_Y - 1,color);
}
/**

View File

@ -39,6 +39,10 @@
#define MUSIC_VOLUME 4
#ifdef __EMSCRIPTEN__
#define SFG_CAN_EXIT 0
#endif
#include <stdio.h>
#include <SDL2/SDL.h>
@ -85,6 +89,7 @@ void SFG_save(uint8_t data[SFG_SAVE_SIZE])
uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE])
{
#ifndef __EMSCRIPTEN__
FILE *f = fopen("anarch.sav","rb");
puts("SDL: opening and reading save file");
@ -100,6 +105,9 @@ uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE])
}
return 1;
#else
return 0;
#endif
}
void SFG_sleepMs(uint16_t timeMs)
@ -111,6 +119,7 @@ void SFG_sleepMs(uint16_t timeMs)
void SFG_getMouseOffset(int16_t *x, int16_t *y)
{
#ifndef __EMSCRIPTEN__
int mX, mY;
SDL_GetMouseState(&mX,&mY);
@ -120,6 +129,7 @@ void SFG_getMouseOffset(int16_t *x, int16_t *y)
SDL_WarpMouseInWindow(window,
SFG_SCREEN_RESOLUTION_X / 2, SFG_SCREEN_RESOLUTION_Y / 2);
#endif
}
int8_t SFG_keyPressed(uint8_t key)
@ -357,7 +367,9 @@ int main(int argc, char *argv[])
SDL_ShowCursor(0);
SFG_init(SDL_INIT_AUDIO);
SFG_init();
SDL_Init(SDL_INIT_AUDIO);
SDL_AudioSpec audioSpec;