diff --git a/src/HW/VIA/VIAEMDEV.c b/src/HW/VIA/VIAEMDEV.c index 1366182..bca9b88 100644 --- a/src/HW/VIA/VIAEMDEV.c +++ b/src/HW/VIA/VIAEMDEV.c @@ -591,10 +591,11 @@ LOCALPROC VIA1_Clear(void) VIA1_T1IntReady = false; } -GLOBALPROC VIA1_Zap(void) +bool VIA1_Zap(void) { VIA1_Clear(); VIA1_InterruptRequest = 0; + return true; } GLOBALPROC VIA1_Reset(void) diff --git a/src/HW/VIA/VIAEMDEV.h b/src/HW/VIA/VIAEMDEV.h index d206029..378f3f4 100644 --- a/src/HW/VIA/VIAEMDEV.h +++ b/src/HW/VIA/VIAEMDEV.h @@ -18,7 +18,7 @@ #define VIAEMDEV_H #include -void VIA1_Zap(void); +bool VIA1_Zap(void); void VIA1_Reset(void); uint32_t VIA1_Access(uint32_t Data, bool WriteMem, uint32_t addr); diff --git a/src/PROGMAIN.c b/src/PROGMAIN.c index aa4ec55..86be268 100644 --- a/src/PROGMAIN.c +++ b/src/PROGMAIN.c @@ -19,6 +19,7 @@ */ #include +#include #include "SYSDEPNS.h" #include "UI/MYOSGLUE.h" @@ -155,16 +156,6 @@ const DevMethods_t DEVICES[] = { .timebegin = EmVIA2 ? VIA2_ExtraTimeBegin : NULL, .timeend = EmVIA2 ? VIA2_ExtraTimeEnd : NULL, }, - // Screen - { - .init = NULL, - .reset = NULL, - .starttick = Sixtieth_PulseNtfy, // VBlank interrupt - .endtick = Screen_EndTickNotify, - .subtick = NULL, - .timebegin = NULL, - .timeend = NULL, - }, // Sony disk drive { .init = NULL, @@ -263,7 +254,17 @@ const DevMethods_t DEVICES[] = { .subtick = (SoundEnabled && (CurEmMd != kEmMd_PB100)) ? MacSound_SubTick : NULL, .timebegin = NULL, .timeend = NULL - } + }, + // Screen + { + .init = NULL, + .reset = NULL, + .starttick = Sixtieth_PulseNtfy, // VBlank interrupt + .endtick = Screen_EndTickNotify, + .subtick = NULL, + .timebegin = NULL, + .timeend = NULL, + }, }; LOCALPROC EmulatedHardwareZap(void) @@ -406,8 +407,7 @@ LOCALFUNC bool InitEmulation(void) int i; for ( i = 0; i < ARRAY_SIZE(DEVICES); i++ ) { if (DEVICES[i].init != NULL) { - bool retval = DEVICES[i].init(); - if (retval == false) { return false; } + assert(DEVICES[i].init()); } } diff --git a/src/UI/SDL2/OSGLUSD2.c b/src/UI/SDL2/OSGLUSD2.c index 9fe5408..ee0bc34 100644 --- a/src/UI/SDL2/OSGLUSD2.c +++ b/src/UI/SDL2/OSGLUSD2.c @@ -336,13 +336,6 @@ LOCALFUNC bool CreateMainWindow(void) Uint32 flags = 0 /* SDL_WINDOW_HIDDEN */; bool v = false; -#if 1 && 1 - if (UseMagnify) { - NewWindowHeight *= WindowScale; - NewWindowWidth *= WindowScale; - } -#endif - #if 1 if (UseFullScreen) #endif @@ -396,8 +389,7 @@ LOCALFUNC bool CreateMainWindow(void) NewWindowWidth, NewWindowHeight, flags))) { - fprintf(stderr, "SDL_CreateWindow fails: %s\n", - SDL_GetError()); + fprintf(stderr, "SDL_CreateWindow fails: %s\n", SDL_GetError()); } else if (NULL == (renderer = SDL_CreateRenderer( main_wind, -1, @@ -410,34 +402,24 @@ LOCALFUNC bool CreateMainWindow(void) /* would rather not require vsync */ ))) { - fprintf(stderr, "SDL_CreateRenderer fails: %s\n", - SDL_GetError()); + fprintf(stderr, "SDL_CreateRenderer fails: %s\n", SDL_GetError()); } else if (NULL == (texture = SDL_CreateTexture( renderer, - SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_RGBX8888, SDL_TEXTUREACCESS_STREAMING, -#if UseSDLscaling vMacScreenWidth, vMacScreenHeight -#else - NewWindowWidth, NewWindowHeight -#endif ))) { - fprintf(stderr, "SDL_CreateTexture fails: %s\n", - SDL_GetError()); + fprintf(stderr, "SDL_CreateTexture fails: %s\n", SDL_GetError()); } else if (NULL == (format = SDL_AllocFormat(SDL_PIXELFORMAT_ARGB8888))) { - fprintf(stderr, "SDL_AllocFormat fails: %s\n", - SDL_GetError()); + fprintf(stderr, "SDL_AllocFormat fails: %s\n", SDL_GetError()); } else { - /* SDL_ShowWindow(main_wind); */ - SDL_RenderClear(renderer); -#if 0 SDL_DisplayMode info; if (0 != SDL_GetCurrentDisplayMode(0, &info)) { @@ -446,7 +428,6 @@ LOCALFUNC bool CreateMainWindow(void) return false; } -#endif #if 1 if (UseFullScreen) diff --git a/src/UI/SDL2/VIDEO.c b/src/UI/SDL2/VIDEO.c index 512cb1f..89378ef 100644 --- a/src/UI/SDL2/VIDEO.c +++ b/src/UI/SDL2/VIDEO.c @@ -22,7 +22,7 @@ bool UseMagnify = (WantInitMagnify != 0); bool gBackgroundFlag = false; bool gTrueBackgroundFlag = false; -bool CurSpeedStopped = true; +bool CurSpeedStopped = false; SDL_Window *main_wind = NULL; SDL_Renderer *renderer = NULL; SDL_Texture *texture = NULL; @@ -66,18 +66,38 @@ GLOBALOSGLUPROC Screen_OutputFrame(uint8_t * src_ptr) { if (EmVideoDisable) { return; } - uint32_t src_format = GetPixFormatFromDepth(vMacScreenDepth); + uint32_t src_format = GetPixFormatFromDepth(vMacScreenDepth+1); + void *pixels; + int pitch; + // Setup source surface SDL_Surface *src = SDL_CreateRGBSurfaceWithFormatFrom( src_ptr, vMacScreenWidth, vMacScreenHeight, - vMacScreenDepth, + vMacScreenDepth+1, vMacScreenByteWidth, src_format ); - SDL_LockTexture(texture, NULL, NULL, NULL); + // Setup dst surface + SDL_LockTexture(texture, NULL, &pixels, &pitch); + SDL_Surface *dst = SDL_CreateRGBSurfaceWithFormatFrom( + pixels, + vMacScreenWidth, + vMacScreenHeight, + 32, vMacScreenWidth * 4, + SDL_PIXELFORMAT_RGBX8888 + ); + + // Blit src to dst + SDL_BlitSurface(src, NULL, dst, NULL); + + // Free surfaces + SDL_FreeSurface(src); + SDL_FreeSurface(dst); + + // Render the texture SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_UnlockTexture(texture); SDL_RenderPresent(renderer);