X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui.cpp;h=29f626dec4922bf90620e04bb9ad3da617666de5;hb=5c366a13aeb0ebb8c18a28616732e058466191af;hp=17e522c9b7074ee6ed8ef272450c393f5ec42850;hpb=99461abfcbc562e740a5e0900167ece9a4a5a035;p=virtualjaguar diff --git a/src/gui.cpp b/src/gui.cpp index 17e522c..29f626d 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -5,10 +5,19 @@ // by James L. Hammons // +#include +#include +#include #include "types.h" #include "tom.h" +#include "font1.h" #include "gui.h" +// Private function prototypes + +uint32 CountROMFiles(char * path); + + void InitGUI(void) { } @@ -17,7 +26,198 @@ void GUIDone(void) { } -void DrawText(uint16 * screen, uint32 x, uint32 y, const char * string) +// +// Render the backbuffer to the primary screen surface +// +void BlitBackbuffer(void) { - uint32 pitch = TOMGetSDLScreenPitch(); + extern SDL_Surface * surface, * mainSurface; + extern int16 * backbuffer; + + if (SDL_MUSTLOCK(surface)) + while (SDL_LockSurface(surface) < 0) + SDL_Delay(10); + + memcpy(surface->pixels, backbuffer, tom_getVideoModeWidth() * tom_getVideoModeHeight() * 2); + + if (SDL_MUSTLOCK(surface)) + SDL_UnlockSurface(surface); + + SDL_Rect srcrect, dstrect; + srcrect.x = srcrect.y = 0, srcrect.w = surface->w, srcrect.h = surface->h; + dstrect.x = dstrect.y = 0, dstrect.w = surface->w, dstrect.h = surface->h; + SDL_BlitSurface(surface, &srcrect, mainSurface, &dstrect); + SDL_Flip(mainSurface); +} + +// +// Draw text at the given x/y coordinates. Can invert text as well. +// +void DrawText(int16 * screen, uint32 x, uint32 y, bool invert, const char * text, ...) +{ + char string[4096]; + va_list arg; + + va_start(arg, text); + vsprintf(string, text, arg); + va_end(arg); + + uint32 pitch = TOMGetSDLScreenPitch() / 2; // Returns pitch in bytes but we need words... + uint32 length = strlen(string), address = x + (y * pitch); + + for(uint32 i=0; id_name, '.'); + if (ext != NULL) + if (strcmpi(ext, ".zip") == 0 || strcmpi(ext, ".jag") == 0) + strcpy(&names[i++ * 2048], de->d_name); + } + + closedir(dp); + + // Main GUI selection loop + + uint32 cursor = 0, startFile = 0; + + if (numFiles > 1) // Only go GUI if more than one possibility! + { + bool done = false; + uint32 limit = (numFiles > 24 ? 24 : numFiles); + SDL_Event event; + + while (!done) + { + while (SDL_PollEvent(&event)) + { + // Draw the GUI... + memset(backbuffer, 0x11, tom_getVideoModeWidth() * tom_getVideoModeHeight() * 2); + + for(uint32 i=0; id_name, '.'); + if (ext != NULL) + if (strcmpi(ext, ".zip") == 0 || strcmpi(ext, ".jag") == 0) + numFiles++; + } + + closedir(dp); + } + + return numFiles; }