X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fui_sdl.c;h=6917c6c12d4e5b078de1eb5d3d47de5bd881b222;hb=89280969bb7e3d9dc9d415c3a0fb0760971754e6;hp=2e56a647a1043a5c1a9d2280c33bd103af461254;hpb=a6f11cb266052c58ae7e2d6d6e8abd34a9e93214;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/ui_sdl.c b/AcessNative/acesskernel_src/ui_sdl.c index 2e56a647..6917c6c1 100644 --- a/AcessNative/acesskernel_src/ui_sdl.c +++ b/AcessNative/acesskernel_src/ui_sdl.c @@ -7,14 +7,13 @@ #define const #include "ui.h" #undef const -#include +#include // === IMPORTS === extern void AcessNative_Exit(void); // === PROTOTYPES === int UI_Initialise(int MaxWidth, int MaxHeight); - int UI_MainThread(void *Unused); void UI_BlitBitmap(int DstX, int DstY, int SrcW, int SrcH, Uint32 *Bitmap); void UI_BlitFramebuffer(int DstX, int DstY, int SrcX, int SrcY, int W, int H); void UI_FillBitmap(int X, int Y, int W, int H, Uint32 Value); @@ -36,12 +35,25 @@ int UI_Initialise(int MaxWidth, int MaxHeight) giUI_Width = MaxWidth; giUI_Height = MaxHeight; - // Start main thread - gInputThread = SDL_CreateThread(UI_MainThread, NULL); + // Set up video + SDL_Init(SDL_INIT_VIDEO); + printf("UI attempting %ix%i %ibpp\n", giUI_Width, giUI_Height, 32); + gScreen = SDL_SetVideoMode(giUI_Width, giUI_Height, 32, 0); + if( !gScreen ) { + fprintf(stderr, "Couldn't set %ix%i video mode: %s\n", giUI_Width, giUI_Height, SDL_GetError()); + SDL_Quit(); + exit(2); + } + SDL_WM_SetCaption("Acess2", "Acess2"); - while(gScreen == NULL) - SDL_Delay(10); + giUI_Width = gScreen->w; + giUI_Height = gScreen->h; + giUI_Pitch = gScreen->pitch; + + printf("UI window %ix%i %i bytes per line\n", giUI_Width, giUI_Height, giUI_Pitch); + SDL_EnableUNICODE(1); + return 0; } @@ -100,28 +112,11 @@ Uint32 UI_GetAcessKeyFromSDL(SDLKey Sym, Uint16 Unicode) return ret; } -int UI_MainThread(void *Unused) +void UI_MainLoop(void) { SDL_Event event; Uint32 acess_sym; - - SDL_Init(SDL_INIT_VIDEO); - - // Set up video - gScreen = SDL_SetVideoMode(giUI_Width, giUI_Height, 32, 0); - if( !gScreen ) { - fprintf(stderr, "Couldn't set %ix%i video mode: %s\n", giUI_Width, giUI_Height, SDL_GetError()); - SDL_Quit(); - exit(2); - } - SDL_WM_SetCaption("Acess2", "Acess2"); - - giUI_Width = gScreen->w; - giUI_Height = gScreen->h; - giUI_Pitch = gScreen->pitch; - - SDL_EnableUNICODE(1); - + for( ;; ) { while(SDL_PollEvent(&event)) @@ -130,7 +125,7 @@ int UI_MainThread(void *Unused) { case SDL_QUIT: AcessNative_Exit(); - return 0; + return ; case SDL_KEYDOWN: acess_sym = UI_GetAcessKeyFromSDL(event.key.keysym.sym,