diff --git a/.gitignore b/.gitignore index c17fe1b..4692e1c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ # Temporary local Visual Studio settings and cached stuff eg precompiled headers that should not be committed /src/vcDave/.vs/ + +davegnukem +src/*.o +src/sdl/*.o diff --git a/Makefile b/Makefile index 199bfa8..c9d2029 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ CC = gcc # dj2016-10 Add L -I/usr/local/include/SDL in process of getting this working on Mac OS X - not sure if this is 'bad' to just have both /usr/include and /usr/local/include?? -INCLUDEDIRS= -I/usr/include/SDL -I/usr/local/include/SDL +INCLUDEDIRS= -I/usr/include/SDL2 -I/usr/local/include/SDL2 #CCFLAGS = -O -Wall $(INCLUDEDIRS) @@ -25,7 +25,7 @@ CCFLAGS = -Wall -Wno-switch -DDEBUG $(INCLUDEDIRS) #Release version: #CCFLAGS = -O -Wall -I/usr/local/include -DHAVE_SOUND $(INCLUDEDIRS) -LIBS = -lSDL -lSDLmain -lSDL_mixer -lpthread +LIBS = -lSDL2 -lSDL2_mixer -lpthread BIN = davegnukem @@ -50,7 +50,7 @@ else ifeq ($(UNAME_S),Haiku) INCLUDEDIRS=`sdl-config --cflags` CCFLAGS=-Wall -Wno-switch -DDEBUG $(INCLUDEDIRS) - LIBS=`sdl-config --libs` -lSDLmain -lSDL_mixer -lpthread + LIBS=`sdl-config --libs` -lSDL2 -lSDL2_mixer -lpthread endif ifeq ($(UNAME_S),Darwin) LIBS += -framework Cocoa diff --git a/src/djgraph.h b/src/djgraph.h index 5f8874d..e920840 100644 --- a/src/djgraph.h +++ b/src/djgraph.h @@ -54,6 +54,8 @@ class djVisual m_bFullscreen = false; } SDL_Surface *pSurface; + SDL_Renderer *pRenderer; + SDL_Texture *pTexture; djColor colorfore; djColor colorback; int width; diff --git a/src/ed_common.cpp b/src/ed_common.cpp index 639f669..05262bb 100644 --- a/src/ed_common.cpp +++ b/src/ed_common.cpp @@ -42,6 +42,13 @@ static djImage *pFont = NULL; void ED_CommonInit () { + SDL_FreeSurface(pVisMain->pSurface); + SDL_DestroyTexture(pVisMain->pTexture); + SDL_RenderSetLogicalSize(pVisMain->pRenderer, pVisMain->width, pVisMain->height); + pVisMain->pSurface = SDL_CreateRGBSurface(0, pVisMain->width, pVisMain->height, pVisMain->bpp, + 0, 0, 0, 0); + pVisMain->pTexture = SDL_CreateTextureFromSurface(pVisMain->pRenderer, pVisMain->pSurface); + // rtfb: // i don't know how and why it worked before i set this, // but when i first tried to put my hands on Editor, @@ -77,6 +84,13 @@ void ED_CommonKill () pFont = NULL; DeleteMacros (); djiClearBuffer (); + + SDL_FreeSurface(pVisMain->pSurface); + SDL_DestroyTexture(pVisMain->pTexture); + SDL_RenderSetLogicalSize(pVisMain->pRenderer, CFG_APPLICATION_RENDER_RES_W, CFG_APPLICATION_RENDER_RES_H); + pVisMain->pSurface = SDL_CreateRGBSurface(0, CFG_APPLICATION_RENDER_RES_W, CFG_APPLICATION_RENDER_RES_H, pVisMain->bpp, + 0, 0, 0, 0); + pVisMain->pTexture = SDL_CreateTextureFromSurface(pVisMain->pRenderer, pVisMain->pSurface); } diff --git a/src/graph.cpp b/src/graph.cpp index 801ba5f..935ebd3 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -54,7 +54,7 @@ void GraphFlip(bool bScaleView) // leaving text looking messed up [dj2016-10] if (pVisBack!=NULL && g_pFont8x8!=NULL && (!g_sMsg.empty() || bShowFrameRate)) { - pVisTemp = SDL_CreateRGBSurface(SDL_HWSURFACE, CFG_APPLICATION_RENDER_RES_W, 8, pVisBack->pSurface->format->BitsPerPixel, + pVisTemp = SDL_CreateRGBSurface(0, CFG_APPLICATION_RENDER_RES_W, 8, pVisBack->pSurface->format->BitsPerPixel, pVisBack->pSurface->format->Rmask, pVisBack->pSurface->format->Gmask, pVisBack->pSurface->format->Bmask, @@ -144,14 +144,15 @@ bool GraphInit( bool bFullScreen, int iWidth, int iHeight, int nForceScale ) // tries to set a 'true' 320x200 fullscreen display mode, IIRC - dj2017-08.) // No that doesn't seem to be what happens, press F5 when running with "-f" and see. // [low/future] - if 2 monitors, will this behave 'correct' - const SDL_VideoInfo* vidinfo = SDL_GetVideoInfo(); + SDL_DisplayMode dm; + int err = SDL_GetCurrentDisplayMode(0, &dm); int max_w = -1; int max_h = -1; - if (vidinfo) + if (!err) { // THIS MUST BE TESTED ON LINUX [dj2016-10] - max_w = vidinfo->current_w; - max_h = vidinfo->current_h; + max_w = dm.w; + max_h = dm.h; if (max_w>iWidth && max_h>iHeight) { int nMultiple = djMAX(1, djMIN( max_w / iWidth, max_h / iHeight ) ); @@ -166,22 +167,17 @@ bool GraphInit( bool bFullScreen, int iWidth, int iHeight, int nForceScale ) iWidth *= nMultiple; iHeight *= nMultiple; } - Log( "GraphInit(): DisplayResolution(%d,%d).\n", max_w, max_h ); } #endif - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - // Window dressing crap - SDL_WM_SetCaption("Dave Gnukem", NULL); - SDL_WM_SetIcon(SDL_LoadBMP(DATA_DIR "icon.bmp"), NULL); // Hide mouse cursor SDL_ShowCursor(0); //--- (1) - Front buffer Log( "GraphInit(): djgOpenVisual(w,h=%d,%d).\n", iWidth, iHeight ); - if (NULL == (pVisMain = djgOpenVisual( bFullScreen?"fullscreen":NULL, iWidth, iHeight ))) + if (NULL == (pVisMain = djgOpenVisual( bFullScreen?"fullscreen":NULL, iWidth, iHeight, 32 ))) { printf( "GraphInit(): COULDN'T OPEN GMAIN\n" ); return false; diff --git a/src/keys.cpp b/src/keys.cpp index abf8fbc..5b0037b 100644 --- a/src/keys.cpp +++ b/src/keys.cpp @@ -144,112 +144,16 @@ void InitialiseGameKeySystem() g_anValidGameKeys.push_back(SDLK_y); g_anValidGameKeys.push_back(SDLK_z); g_anValidGameKeys.push_back(SDLK_DELETE); - g_anValidGameKeys.push_back(SDLK_WORLD_0); - g_anValidGameKeys.push_back(SDLK_WORLD_1); - g_anValidGameKeys.push_back(SDLK_WORLD_2); - g_anValidGameKeys.push_back(SDLK_WORLD_3); - g_anValidGameKeys.push_back(SDLK_WORLD_4); - g_anValidGameKeys.push_back(SDLK_WORLD_5); - g_anValidGameKeys.push_back(SDLK_WORLD_6); - g_anValidGameKeys.push_back(SDLK_WORLD_7); - g_anValidGameKeys.push_back(SDLK_WORLD_8); - g_anValidGameKeys.push_back(SDLK_WORLD_9); - g_anValidGameKeys.push_back(SDLK_WORLD_10); - g_anValidGameKeys.push_back(SDLK_WORLD_11); - g_anValidGameKeys.push_back(SDLK_WORLD_12); - g_anValidGameKeys.push_back(SDLK_WORLD_13); - g_anValidGameKeys.push_back(SDLK_WORLD_14); - g_anValidGameKeys.push_back(SDLK_WORLD_15); - g_anValidGameKeys.push_back(SDLK_WORLD_16); - g_anValidGameKeys.push_back(SDLK_WORLD_17); - g_anValidGameKeys.push_back(SDLK_WORLD_18); - g_anValidGameKeys.push_back(SDLK_WORLD_19); - g_anValidGameKeys.push_back(SDLK_WORLD_20); - g_anValidGameKeys.push_back(SDLK_WORLD_21); - g_anValidGameKeys.push_back(SDLK_WORLD_22); - g_anValidGameKeys.push_back(SDLK_WORLD_23); - g_anValidGameKeys.push_back(SDLK_WORLD_24); - g_anValidGameKeys.push_back(SDLK_WORLD_25); - g_anValidGameKeys.push_back(SDLK_WORLD_26); - g_anValidGameKeys.push_back(SDLK_WORLD_27); - g_anValidGameKeys.push_back(SDLK_WORLD_28); - g_anValidGameKeys.push_back(SDLK_WORLD_29); - g_anValidGameKeys.push_back(SDLK_WORLD_30); - g_anValidGameKeys.push_back(SDLK_WORLD_31); - g_anValidGameKeys.push_back(SDLK_WORLD_32); - g_anValidGameKeys.push_back(SDLK_WORLD_33); - g_anValidGameKeys.push_back(SDLK_WORLD_34); - g_anValidGameKeys.push_back(SDLK_WORLD_35); - g_anValidGameKeys.push_back(SDLK_WORLD_36); - g_anValidGameKeys.push_back(SDLK_WORLD_37); - g_anValidGameKeys.push_back(SDLK_WORLD_38); - g_anValidGameKeys.push_back(SDLK_WORLD_39); - g_anValidGameKeys.push_back(SDLK_WORLD_40); - g_anValidGameKeys.push_back(SDLK_WORLD_41); - g_anValidGameKeys.push_back(SDLK_WORLD_42); - g_anValidGameKeys.push_back(SDLK_WORLD_43); - g_anValidGameKeys.push_back(SDLK_WORLD_44); - g_anValidGameKeys.push_back(SDLK_WORLD_45); - g_anValidGameKeys.push_back(SDLK_WORLD_46); - g_anValidGameKeys.push_back(SDLK_WORLD_47); - g_anValidGameKeys.push_back(SDLK_WORLD_48); - g_anValidGameKeys.push_back(SDLK_WORLD_49); - g_anValidGameKeys.push_back(SDLK_WORLD_50); - g_anValidGameKeys.push_back(SDLK_WORLD_51); - g_anValidGameKeys.push_back(SDLK_WORLD_52); - g_anValidGameKeys.push_back(SDLK_WORLD_53); - g_anValidGameKeys.push_back(SDLK_WORLD_54); - g_anValidGameKeys.push_back(SDLK_WORLD_55); - g_anValidGameKeys.push_back(SDLK_WORLD_56); - g_anValidGameKeys.push_back(SDLK_WORLD_57); - g_anValidGameKeys.push_back(SDLK_WORLD_58); - g_anValidGameKeys.push_back(SDLK_WORLD_59); - g_anValidGameKeys.push_back(SDLK_WORLD_60); - g_anValidGameKeys.push_back(SDLK_WORLD_61); - g_anValidGameKeys.push_back(SDLK_WORLD_62); - g_anValidGameKeys.push_back(SDLK_WORLD_63); - g_anValidGameKeys.push_back(SDLK_WORLD_64); - g_anValidGameKeys.push_back(SDLK_WORLD_65); - g_anValidGameKeys.push_back(SDLK_WORLD_66); - g_anValidGameKeys.push_back(SDLK_WORLD_67); - g_anValidGameKeys.push_back(SDLK_WORLD_68); - g_anValidGameKeys.push_back(SDLK_WORLD_69); - g_anValidGameKeys.push_back(SDLK_WORLD_70); - g_anValidGameKeys.push_back(SDLK_WORLD_71); - g_anValidGameKeys.push_back(SDLK_WORLD_72); - g_anValidGameKeys.push_back(SDLK_WORLD_73); - g_anValidGameKeys.push_back(SDLK_WORLD_74); - g_anValidGameKeys.push_back(SDLK_WORLD_75); - g_anValidGameKeys.push_back(SDLK_WORLD_76); - g_anValidGameKeys.push_back(SDLK_WORLD_77); - g_anValidGameKeys.push_back(SDLK_WORLD_78); - g_anValidGameKeys.push_back(SDLK_WORLD_79); - g_anValidGameKeys.push_back(SDLK_WORLD_80); - g_anValidGameKeys.push_back(SDLK_WORLD_81); - g_anValidGameKeys.push_back(SDLK_WORLD_82); - g_anValidGameKeys.push_back(SDLK_WORLD_83); - g_anValidGameKeys.push_back(SDLK_WORLD_84); - g_anValidGameKeys.push_back(SDLK_WORLD_85); - g_anValidGameKeys.push_back(SDLK_WORLD_86); - g_anValidGameKeys.push_back(SDLK_WORLD_87); - g_anValidGameKeys.push_back(SDLK_WORLD_88); - g_anValidGameKeys.push_back(SDLK_WORLD_89); - g_anValidGameKeys.push_back(SDLK_WORLD_90); - g_anValidGameKeys.push_back(SDLK_WORLD_91); - g_anValidGameKeys.push_back(SDLK_WORLD_92); - g_anValidGameKeys.push_back(SDLK_WORLD_93); - g_anValidGameKeys.push_back(SDLK_WORLD_94); - g_anValidGameKeys.push_back(SDLK_WORLD_95); - g_anValidGameKeys.push_back(SDLK_KP0); - g_anValidGameKeys.push_back(SDLK_KP1); - g_anValidGameKeys.push_back(SDLK_KP2); - g_anValidGameKeys.push_back(SDLK_KP3); - g_anValidGameKeys.push_back(SDLK_KP4); - g_anValidGameKeys.push_back(SDLK_KP5); - g_anValidGameKeys.push_back(SDLK_KP6); - g_anValidGameKeys.push_back(SDLK_KP7); - g_anValidGameKeys.push_back(SDLK_KP8); - g_anValidGameKeys.push_back(SDLK_KP9); + g_anValidGameKeys.push_back(SDLK_KP_0); + g_anValidGameKeys.push_back(SDLK_KP_1); + g_anValidGameKeys.push_back(SDLK_KP_2); + g_anValidGameKeys.push_back(SDLK_KP_3); + g_anValidGameKeys.push_back(SDLK_KP_4); + g_anValidGameKeys.push_back(SDLK_KP_5); + g_anValidGameKeys.push_back(SDLK_KP_6); + g_anValidGameKeys.push_back(SDLK_KP_7); + g_anValidGameKeys.push_back(SDLK_KP_8); + g_anValidGameKeys.push_back(SDLK_KP_9); g_anValidGameKeys.push_back(SDLK_KP_PERIOD); g_anValidGameKeys.push_back(SDLK_KP_DIVIDE); g_anValidGameKeys.push_back(SDLK_KP_MULTIPLY); @@ -290,19 +194,17 @@ void InitialiseGameKeySystem() g_anValidGameKeys.push_back(SDLK_LCTRL); g_anValidGameKeys.push_back(SDLK_RALT); g_anValidGameKeys.push_back(SDLK_LALT); - g_anValidGameKeys.push_back(SDLK_RMETA); - g_anValidGameKeys.push_back(SDLK_LMETA); - g_anValidGameKeys.push_back(SDLK_LSUPER); - g_anValidGameKeys.push_back(SDLK_RSUPER); + g_anValidGameKeys.push_back(SDLK_RGUI); + g_anValidGameKeys.push_back(SDLK_LGUI); g_anValidGameKeys.push_back(SDLK_MODE); - g_anValidGameKeys.push_back(SDLK_COMPOSE); + g_anValidGameKeys.push_back(SDLK_APPLICATION); g_anValidGameKeys.push_back(SDLK_HELP); - g_anValidGameKeys.push_back(SDLK_PRINT); + g_anValidGameKeys.push_back(SDLK_PRINTSCREEN); //g_anValidGameKeys.push_back(SDLK_SYSREQ); //g_anValidGameKeys.push_back(SDLK_BREAK); g_anValidGameKeys.push_back(SDLK_MENU); //g_anValidGameKeys.push_back(SDLK_POWER); - g_anValidGameKeys.push_back(SDLK_EURO); + g_anValidGameKeys.push_back(SDLK_CURRENCYSUBUNIT); } bool IsGameKey(int nKeyCode) diff --git a/src/main.cpp b/src/main.cpp index 8b12787..e3d1620 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -784,7 +784,7 @@ bool GetHighScoreUserName(char *szBuffer) DialogBoxEffect(nXLeft-12, 64, nDX+24, 64); djiPollBegin(); - SDLMod ModState = SDL_GetModState(); + SDL_Keymod ModState = SDL_GetModState(); SDL_Event Event; while (djiPollEvents(Event)) { diff --git a/src/sdl/djgraph.cpp b/src/sdl/djgraph.cpp index 9a9d483..f5048e2 100644 --- a/src/sdl/djgraph.cpp +++ b/src/sdl/djgraph.cpp @@ -98,37 +98,29 @@ djVisual* djgOpenVisual( const char *vistype, int w, int h, int bpp, bool bBackb djVisual * pVis; pVis = new djVisual; - pVis->m_bFullscreen = false; + pVis->m_bFullscreen = NULL != vistype && 0 == strcmp ( vistype, "fullscreen" ) ? true : false; + //dj2016-10 fixmelow_tocheck i am wondering if the below is doing speed optimal way of doing everything as this hasn't been looked at in years - // Create a default visual, just a plain non-resizing window + // Create a default visual: a resizable window or fullscreen //static SDL_Surface *p = NULL; - if (NULL == vistype) + if (NULL == vistype || pVis->m_bFullscreen) { - /*p = */pVis->pSurface = SDL_SetVideoMode(w, h, bpp, SDL_HWSURFACE|(bBackbuffer?SDL_DOUBLEBUF:0)); + SDL_Window *win = SDL_CreateWindow("Dave Gnukem", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, + pVis->m_bFullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_RESIZABLE); + SDL_SetWindowIcon(win, SDL_LoadBMP("data/icon.bmp")); + pVis->pRenderer = SDL_CreateRenderer(win, -1, 0); + SDL_RenderSetLogicalSize(pVis->pRenderer, CFG_APPLICATION_RENDER_RES_W, CFG_APPLICATION_RENDER_RES_H); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"); + pVis->pSurface = SDL_CreateRGBSurface(0, CFG_APPLICATION_RENDER_RES_W, CFG_APPLICATION_RENDER_RES_H, bpp, + 0, 0, 0, 0); + pVis->pTexture = SDL_CreateTextureFromSurface(pVis->pRenderer, pVis->pSurface); } else if (0 == strcmp( vistype, "memory" )) { - SDL_Surface *pSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, - bpp, - //fixme [dj2016-10] this doesn't quite seem right to me ? must come back to this and have a closer look at all this again later .. - // in theory this works but might be less efficient - 0xFF000000, - 0x00FF0000, - 0x0000FF00, - 0x000000FF); - if (pSurface!=NULL) - { - //SDL_SetColorKey(pSurface, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(pSurface->format, 255, 0, 255)); - pVis->pSurface = SDL_DisplayFormat(pSurface); - SDL_FreeSurface(pSurface); - } - } - else if (0 == strcmp( vistype, "fullscreen" )) - { - pVis->pSurface = SDL_SetVideoMode(w, h, bpp, SDL_HWSURFACE|(bBackbuffer?SDL_DOUBLEBUF:0)|SDL_FULLSCREEN); - pVis->m_bFullscreen = true; + pVis->pSurface = SDL_CreateRGBSurface(0, CFG_APPLICATION_RENDER_RES_W, CFG_APPLICATION_RENDER_RES_H, bpp, + 0, 0, 0, 0); } pVis->bpp = pVis->pSurface->format->BitsPerPixel; @@ -170,49 +162,19 @@ void djgFlush( djVisual * /*pVis*/) void djgFlip( djVisual * pVisDest, djVisual * pVisSrc, bool bScaleView ) { - if (pVisSrc==NULL)//<- Level editor etc. - { - SDL_Flip(pVisDest->pSurface); - } - else + if (pVisSrc!=NULL)//<- Not level editor etc. { - // [dj2016-10-08] If have large modern monitor then 320x200 window is really tiny and unpleasant to play - added - // this quick-n-dirty scaling blit to let the main window be any 'arbitrary' larger resolution to allow the - // gameplay window to at least be larger - my idea/thinking is just to e.g. try create the main window sort of - // (basically) the largest 'multiple' of 320x200 (ideally incorporating window dressing) that fits in your - // screen ... this is not entirely perfect but is a quick and easy way to get the game relatively playable - // as compared to the tiny gameplay window we have now (and also, NB, makes level editing much more - // user-friendly). - // Note pVisSrc->width could be eg 1600 while gamerendering is 320 CdjRect rcSrc(0, 0, CFG_APPLICATION_RENDER_RES_W, CFG_APPLICATION_RENDER_RES_H);//E.g. 320x200 for DG1 - CdjRect rcDest(0, 0, pVisDest->width, pVisDest->height); - unsigned int uScaleX = (pVisDest->width / CFG_APPLICATION_RENDER_RES_W); // Note we deliberately do *integer* division as we *want* to round down etc. - unsigned int uScaleY = (pVisDest->height / CFG_APPLICATION_RENDER_RES_H); // Note we deliberately do *integer* division as we *want* to round down etc. - unsigned int uScaleMax = djMAX(1,djMIN(uScaleX,uScaleY));//Select smallest of vertical/horizontal scaling factor in order to fit everything in the window - SDL_Rect rc; - rc.w = uScaleMax; - rc.h = uScaleMax; - - //dj2019-07 Hm leaving this change commented out for now (retro settings at very high resolution CFG_APPLICATION_RENDER_RES_W etc.) as it's very slow, and not necessary for anything yet, so still rethink this stuff; want to keep it clean/simple as possible or later this will just seem like spaghetti & I won't know what's what. - /* - bool bForceOwnScaleBlitHereEvenIf1to1=false;//dj2019-06 + CdjRect rcDest(0, 0, CFG_APPLICATION_RENDER_RES_W, CFG_APPLICATION_RENDER_RES_H); + SDL_Rect rc = {.w = 1, .h = 1}; + + //fixme this won't work bigendian #if SDL_BYTEORDER==SDL_BIG_ENDIAN + // Not yet supported for big-endian platforms (dj2019-06) + if (false) #else - // If retro settings requested, 'force' use own blit here so we can do the effect, even if it's a 1-1 pixel ratio [dj2019-06] - // This is really not that important, it's just 'silly' stuff for the extra-retro settings, but the 'force' option might - // come in handy later for other viewport-related stuff for genericizing this stuff, not sure. if (g_nSimulatedGraphics>0) //'Simulate' CGA/EGA - bForceOwnScaleBlitHereEvenIf1to1 = true; - #endif - //*/ - - if (bScaleView - && (/*bForceOwnScaleBlitHereEvenIf1to1 || */rcSrc.w!=rcDest.w || rcSrc.h!=rcDest.h) - //fixme is this righT? waht if bpp == 2 .. - && pVisSrc->pSurface->format->BytesPerPixel == 4//Current scaling blit implementation only supports 4BPP [dj2016-10] [TODO: Handle other format, OR if upgrading to libsdl2, just use libsdl's scale blit function] - ) { - //Quick-n-dirty scaling blit [dj2016-10] NB note that if/when we migrate to LibSDL2 we can just use the API functions for this instead djgLock(pVisSrc); djgLock(pVisDest); unsigned int uBPP = pVisSrc->pSurface->format->BytesPerPixel; @@ -220,14 +182,6 @@ void djgFlip( djVisual * pVisDest, djVisual * pVisSrc, bool bScaleView ) unsigned int uMemOffsetRow = 0; - //fixme this won't work bigendian - #if SDL_BYTEORDER==SDL_BIG_ENDIAN - // Not yet supported for big-endian platforms (dj2019-06) - if (false) - #else - if (g_nSimulatedGraphics>0) //'Simulate' CGA/EGA - #endif - { // Select target simulated-graphics palette const unsigned int NUMCOLORS = (g_nSimulatedGraphics==1?16:4); const djColor* pPalette = (g_nSimulatedGraphics==1 ? djPALETTE_EGA : djPALETTE_CGA); @@ -286,41 +240,25 @@ void djgFlip( djVisual * pVisDest, djVisual * pVisSrc, bool bScaleView ) nPixel = SDL_MapRGB(pVisDest->pSurface->format,pPalette[nClosest].r,pPalette[nClosest].g,pPalette[nClosest].b);//djgMapColor( pVis, pVis->colorfore ); SDL_FillRect(pVisDest->pSurface, &rc, nPixel); ++pSurfaceMem; - rc.x += uScaleMax; + ++rc.x; }//x - rc.y += uScaleMax; + ++rc.y; }//y - } - else//Normal default - { - //cbsu/sbsu?[low-dj2019-06] - rc.y=0; - for ( unsigned int y=0; ypSurface->pitch/uBPP)); - pSurfaceMem = ((unsigned int*)pVisSrc->pSurface->pixels) + uMemOffsetRow; - // Note we must be careful here, pVisSrc->pSurface->pitch is in *bytes*, pSurfaceMem is a pointer to unsigned int* so pointer 'math' in multiples of 4 - rc.x = 0; - for ( unsigned int x=0; xpSurface, &rc, *pSurfaceMem); - ++pSurfaceMem; - rc.x += uScaleMax; - } - rc.y += uScaleMax; - } - } djgUnlock(pVisDest); djgUnlock(pVisSrc); } + #endif else { CdjRect rcSrc(0, 0, pVisSrc->width, pVisSrc->height); //Non-scaling blit [faster, but can only do if src same size as dest] SDL_BlitSurface(pVisSrc->pSurface, &rcSrc, pVisDest->pSurface, &rcDest); } - SDL_Flip(pVisDest->pSurface); } + SDL_UpdateTexture(pVisDest->pTexture, NULL, pVisDest->pSurface->pixels, pVisDest->pSurface->pitch); + SDL_RenderClear(pVisDest->pRenderer); + SDL_RenderCopy(pVisDest->pRenderer, pVisDest->pTexture, NULL, NULL); + SDL_RenderPresent(pVisDest->pRenderer); } void djgClear( djVisual * pVis ) @@ -912,7 +850,7 @@ SDL_SWSURFACE, } SDL_UnlockSurface(pSurfaceImg); SDL_UnlockSurface(pSurface); -SDL_SetAlpha(pSurface, SDL_SRCALPHA, 0); +SDL_SetSurfaceAlphaMod(pSurface, 0); //SDL_UnlockSurface(pSurfaceImg); //SDL_FreeSurface(pSurfaceImg); diff --git a/src/sdl/djinput.cpp b/src/sdl/djinput.cpp index 6b813a0..c76f9c1 100644 --- a/src/sdl/djinput.cpp +++ b/src/sdl/djinput.cpp @@ -187,112 +187,16 @@ const char *GetKeyString(int nSDLKeyCode) case SDLK_y: return "Y"; case SDLK_z: return "Z"; case SDLK_DELETE: return "DEL"; - case SDLK_WORLD_0: return "WORLD0"; - case SDLK_WORLD_1: return "WORLD1"; - case SDLK_WORLD_2: return "WORLD2"; - case SDLK_WORLD_3: return "WORLD3"; - case SDLK_WORLD_4: return "WORLD4"; - case SDLK_WORLD_5: return "WORLD5"; - case SDLK_WORLD_6: return "WORLD6"; - case SDLK_WORLD_7: return "WORLD7"; - case SDLK_WORLD_8: return "WORLD8"; - case SDLK_WORLD_9: return "WORLD9"; - case SDLK_WORLD_10: return "WORLD10"; - case SDLK_WORLD_11: return "WORLD11"; - case SDLK_WORLD_12: return "WORLD12"; - case SDLK_WORLD_13: return "WORLD13"; - case SDLK_WORLD_14: return "WORLD14"; - case SDLK_WORLD_15: return "WORLD15"; - case SDLK_WORLD_16: return "WORLD16"; - case SDLK_WORLD_17: return "WORLD17"; - case SDLK_WORLD_18: return "WORLD18"; - case SDLK_WORLD_19: return "WORLD19"; - case SDLK_WORLD_20: return "WORLD20"; - case SDLK_WORLD_21: return "WORLD21"; - case SDLK_WORLD_22: return "WORLD22"; - case SDLK_WORLD_23: return "WORLD23"; - case SDLK_WORLD_24: return "WORLD24"; - case SDLK_WORLD_25: return "WORLD25"; - case SDLK_WORLD_26: return "WORLD26"; - case SDLK_WORLD_27: return "WORLD27"; - case SDLK_WORLD_28: return "WORLD28"; - case SDLK_WORLD_29: return "WORLD29"; - case SDLK_WORLD_30: return "WORLD30"; - case SDLK_WORLD_31: return "WORLD31"; - case SDLK_WORLD_32: return "WORLD32"; - case SDLK_WORLD_33: return "WORLD33"; - case SDLK_WORLD_34: return "WORLD34"; - case SDLK_WORLD_35: return "WORLD35"; - case SDLK_WORLD_36: return "WORLD36"; - case SDLK_WORLD_37: return "WORLD37"; - case SDLK_WORLD_38: return "WORLD38"; - case SDLK_WORLD_39: return "WORLD39"; - case SDLK_WORLD_40: return "WORLD40"; - case SDLK_WORLD_41: return "WORLD41"; - case SDLK_WORLD_42: return "WORLD42"; - case SDLK_WORLD_43: return "WORLD43"; - case SDLK_WORLD_44: return "WORLD44"; - case SDLK_WORLD_45: return "WORLD45"; - case SDLK_WORLD_46: return "WORLD46"; - case SDLK_WORLD_47: return "WORLD47"; - case SDLK_WORLD_48: return "WORLD48"; - case SDLK_WORLD_49: return "WORLD49"; - case SDLK_WORLD_50: return "WORLD50"; - case SDLK_WORLD_51: return "WORLD51"; - case SDLK_WORLD_52: return "WORLD52"; - case SDLK_WORLD_53: return "WORLD53"; - case SDLK_WORLD_54: return "WORLD54"; - case SDLK_WORLD_55: return "WORLD55"; - case SDLK_WORLD_56: return "WORLD56"; - case SDLK_WORLD_57: return "WORLD57"; - case SDLK_WORLD_58: return "WORLD58"; - case SDLK_WORLD_59: return "WORLD59"; - case SDLK_WORLD_60: return "WORLD60"; - case SDLK_WORLD_61: return "WORLD61"; - case SDLK_WORLD_62: return "WORLD62"; - case SDLK_WORLD_63: return "WORLD63"; - case SDLK_WORLD_64: return "WORLD64"; - case SDLK_WORLD_65: return "WORLD65"; - case SDLK_WORLD_66: return "WORLD66"; - case SDLK_WORLD_67: return "WORLD67"; - case SDLK_WORLD_68: return "WORLD68"; - case SDLK_WORLD_69: return "WORLD69"; - case SDLK_WORLD_70: return "WORLD70"; - case SDLK_WORLD_71: return "WORLD71"; - case SDLK_WORLD_72: return "WORLD72"; - case SDLK_WORLD_73: return "WORLD73"; - case SDLK_WORLD_74: return "WORLD74"; - case SDLK_WORLD_75: return "WORLD75"; - case SDLK_WORLD_76: return "WORLD76"; - case SDLK_WORLD_77: return "WORLD77"; - case SDLK_WORLD_78: return "WORLD78"; - case SDLK_WORLD_79: return "WORLD79"; - case SDLK_WORLD_80: return "WORLD80"; - case SDLK_WORLD_81: return "WORLD81"; - case SDLK_WORLD_82: return "WORLD82"; - case SDLK_WORLD_83: return "WORLD83"; - case SDLK_WORLD_84: return "WORLD84"; - case SDLK_WORLD_85: return "WORLD85"; - case SDLK_WORLD_86: return "WORLD86"; - case SDLK_WORLD_87: return "WORLD87"; - case SDLK_WORLD_88: return "WORLD88"; - case SDLK_WORLD_89: return "WORLD89"; - case SDLK_WORLD_90: return "WORLD90"; - case SDLK_WORLD_91: return "WORLD91"; - case SDLK_WORLD_92: return "WORLD92"; - case SDLK_WORLD_93: return "WORLD93"; - case SDLK_WORLD_94: return "WORLD94"; - case SDLK_WORLD_95: return "WORLD95"; - case SDLK_KP0: return "KEYPAD0"; - case SDLK_KP1: return "KEYPAD1"; - case SDLK_KP2: return "KEYPAD2"; - case SDLK_KP3: return "KEYPAD3"; - case SDLK_KP4: return "KEYPAD4"; - case SDLK_KP5: return "KEYPAD5"; - case SDLK_KP6: return "KEYPAD6"; - case SDLK_KP7: return "KEYPAD7"; - case SDLK_KP8: return "KEYPAD8"; - case SDLK_KP9: return "KEYPAD9"; + case SDLK_KP_0: return "KEYPAD0"; + case SDLK_KP_1: return "KEYPAD1"; + case SDLK_KP_2: return "KEYPAD2"; + case SDLK_KP_3: return "KEYPAD3"; + case SDLK_KP_4: return "KEYPAD4"; + case SDLK_KP_5: return "KEYPAD5"; + case SDLK_KP_6: return "KEYPAD6"; + case SDLK_KP_7: return "KEYPAD7"; + case SDLK_KP_8: return "KEYPAD8"; + case SDLK_KP_9: return "KEYPAD9"; case SDLK_KP_PERIOD: return "KPPERIOD"; case SDLK_KP_DIVIDE: return "KPDIVIDE"; case SDLK_KP_MULTIPLY: return "KPMULTIPLY"; @@ -324,28 +228,25 @@ const char *GetKeyString(int nSDLKeyCode) case SDLK_F13: return "F13"; case SDLK_F14: return "F14"; case SDLK_F15: return "F15"; - case SDLK_NUMLOCK: return "NUMLOCK"; + case SDLK_NUMLOCKCLEAR: return "NUMLOCKCLEAR"; case SDLK_CAPSLOCK: return "CAPSLOCK"; - case SDLK_SCROLLOCK: return "SCROLLOCK"; + case SDLK_SCROLLLOCK: return "SCROLLLOCK"; case SDLK_RSHIFT: return "RSHIFT"; case SDLK_LSHIFT: return "LSHIFT"; case SDLK_RCTRL: return "CTRL"; case SDLK_LCTRL: return "CTRL"; case SDLK_RALT: return "ALT"; case SDLK_LALT: return "ALT"; - case SDLK_RMETA: return "RMETA"; - case SDLK_LMETA: return "LMETA"; - case SDLK_LSUPER: return "LSUPER"; - case SDLK_RSUPER: return "RSUPER"; + case SDLK_RGUI: return "RGUI"; + case SDLK_LGUI: return "LGUI"; case SDLK_MODE: return "MODE"; - case SDLK_COMPOSE: return "COMPOSE"; + case SDLK_APPLICATION: return "APPLICATION"; case SDLK_HELP: return "HELP"; - case SDLK_PRINT: return "PRINT"; + case SDLK_PRINTSCREEN: return "PRINTSCREEN"; case SDLK_SYSREQ: return "SYSREQ"; - case SDLK_BREAK: return "BREAK"; case SDLK_MENU: return "MENU"; case SDLK_POWER: return "POWER"; - case SDLK_EURO: return "EURO"; + case SDLK_CURRENCYSUBUNIT: return "CURRENCYSUBUNIT"; default: return "UNKNOWN"; }