diff options
author | ptitSeb | 2017-12-02 11:20:03 +0100 |
---|---|---|
committer | ptitSeb | 2017-12-02 11:20:03 +0100 |
commit | 8b0a7091f58ee0b5ff68af9e4b14afc0ea6d6fe8 (patch) | |
tree | af63204f1872a8e66e9578f588aacfb450d869f4 /src | |
parent | ba427aba2f50a9ec34befc8369af8e9f71758554 (diff) | |
download | hydracastlelabyrinth-8b0a7091f58ee0b5ff68af9e4b14afc0ea6d6fe8.tar.gz hydracastlelabyrinth-8b0a7091f58ee0b5ff68af9e4b14afc0ea6d6fe8.tar.bz2 hydracastlelabyrinth-8b0a7091f58ee0b5ff68af9e4b14afc0ea6d6fe8.zip |
Added option for Fullscreen and various screen scalling (from x1 to x4, default to x2)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 25 | ||||
-rwxr-xr-x | src/sdl/graphics.c | 40 | ||||
-rw-r--r-- | src/sdl/graphics.h | 3 | ||||
-rw-r--r-- | src/text.c | 2 |
4 files changed, 50 insertions, 20 deletions
@@ -38,6 +38,31 @@ int main(int argc, char **argv) sdmcInit(); osSetSpeedupEnable(false); #endif + #ifdef _SDL + #ifdef PANDORA + wantFullscreen = 1; + #else + wantFullscreen = 0; + #endif + screenScale = 2; + // get command line arguments + for (int i=1; i<argc; i++) + { + if(!strcmp(argv[i], "-f")) + wantFullscreen = 1; + if(!strcmp(argv[i], "--fullscreen")) + wantFullscreen = 1; + if(!strcmp(argv[i], "-x1")) + screenScale = 1; + if(!strcmp(argv[i], "-x2")) + screenScale = 2; + if(!strcmp(argv[i], "-x3")) + screenScale = 3; + if(!strcmp(argv[i], "-x4")) + screenScale = 4; + } + printf("Hydra Caslte Labyrinth, %s scale=x%d\n", wantFullscreen?"Fullscreen":"Windowed", screenScale); + #endif srand(time(NULL)); createSaveLocations(); diff --git a/src/sdl/graphics.c b/src/sdl/graphics.c index dd65bd3..b25d081 100755 --- a/src/sdl/graphics.c +++ b/src/sdl/graphics.c @@ -8,6 +8,9 @@ SDL_Surface* screen = NULL; SDL_Surface* drawbuffer = NULL; SDL_Surface* backbuffer = NULL; +int wantFullscreen = 0; +int screenScale = 2; + static uint32_t tframe; SDL_Color PHL_NewRGB(uint8_t r, uint8_t g, uint8_t b) @@ -27,12 +30,11 @@ void PHL_GraphicsInit() SDL_ShowCursor(SDL_DISABLE); uint32_t flags = SDL_HWSURFACE|SDL_DOUBLEBUF; - #ifdef PANDORA - flags |= SDL_FULLSCREEN; - #endif - screen = SDL_SetVideoMode(640, 480, 0, flags); + if(wantFullscreen) + flags |= SDL_FULLSCREEN; + screen = SDL_SetVideoMode(320*screenScale, 240*screenScale, 0, flags); drawbuffer = screen; - backbuffer = PHL_NewSurface(640, 480); + backbuffer = PHL_NewSurface(320*screenScale, 240*screenScale); tframe = SDL_GetTicks(); } @@ -103,7 +105,7 @@ PHL_Surface PHL_LoadBMP(int index) memcpy(&w, &QDAFile[18], 2); memcpy(&h, &QDAFile[22], 2); - surf = PHL_NewSurface(w * 2, h * 2); + surf = PHL_NewSurface(w * screenScale, h * screenScale); //surf = PHL_NewSurface(200, 200); //Load Palette @@ -137,7 +139,7 @@ PHL_Surface PHL_LoadBMP(int index) PHL_RGB c = palette[px][py]; //PHL_DrawRect(dx * 2, dy * 2, 2, 2, c); - SDL_Rect rect = {dx * 2, (h-1-dy) * 2, 2, 2}; + SDL_Rect rect = {dx * screenScale, (h-1-dy) * screenScale, screenScale, screenScale}; SDL_FillRect(surf, &rect, SDL_MapRGB(surf->format, c.r, c.g, c.b)); } } @@ -149,7 +151,7 @@ PHL_Surface PHL_LoadBMP(int index) void PHL_DrawRect(int x, int y, int w, int h, SDL_Color col) { - SDL_Rect rect = {x, y, w, h}; + SDL_Rect rect = {x*screenScale/2, y*screenScale/2, w*screenScale/2, h*screenScale/2}; SDL_FillRect(drawbuffer, &rect, SDL_MapRGB(drawbuffer->format, col.r, col.g, col.b)); } @@ -166,8 +168,8 @@ void PHL_DrawSurface(double x, double y, PHL_Surface surface) } SDL_Rect offset; - offset.x = x; - offset.y = y; + offset.x = x*screenScale/2; + offset.y = y*screenScale/2; SDL_BlitSurface(surface, NULL, drawbuffer, &offset); } @@ -176,20 +178,20 @@ void PHL_DrawSurfacePart(double x, double y, int cropx, int cropy, int cropw, in if (quakeTimer > 0) { int val = quakeTimer % 4; if (val == 0) { - y -= 1; + y -= (screenScale==1)?2:1; }else if (val == 2) { - y += 1; + y += (screenScale==1)?2:1; } } SDL_Rect crop, offset; - crop.x = cropx; - crop.y = cropy; - crop.w = cropw; - crop.h = croph; + crop.x = cropx*screenScale/2; + crop.y = cropy*screenScale/2; + crop.w = cropw*screenScale/2; + crop.h = croph*screenScale/2; - offset.x = x; - offset.y = y; + offset.x = x*screenScale/2; + offset.y = y*screenScale/2; SDL_BlitSurface(surface, &crop, drawbuffer, &offset); } @@ -203,7 +205,7 @@ void PHL_UpdateBackground(PHL_Background back, PHL_Background fore) PHL_SetDrawbuffer(backbuffer); int xx, yy; - + for (yy = 0; yy < 12; yy++) { for (xx = 0; xx < 16; xx++) diff --git a/src/sdl/graphics.h b/src/sdl/graphics.h index 3635294..459927d 100644 --- a/src/sdl/graphics.h +++ b/src/sdl/graphics.h @@ -27,6 +27,9 @@ typedef struct { */ extern PHL_Surface screen; +extern int wantFullscreen; +extern int screenScale; + SDL_Color PHL_NewRGB(uint8_t r, uint8_t g, uint8_t b); /* { @@ -89,7 +89,7 @@ void loadText() //Load saving message loadMessage(saving, f); - printf("\n%d", saving->length); + //printf("\n%d", saving->length); //Load save error message int i; |