Fix start-up crash due to invalid SDL usage

This is now, minus configuration, fully functional again. Nice.
This commit is contained in:
InvisibleUp 2020-07-04 18:30:15 -04:00
parent b889a8117a
commit b4854c1546
5 changed files with 45 additions and 43 deletions

View File

@ -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)

View File

@ -18,7 +18,7 @@
#define VIAEMDEV_H
#include <stdint.h>
void VIA1_Zap(void);
bool VIA1_Zap(void);
void VIA1_Reset(void);
uint32_t VIA1_Access(uint32_t Data, bool WriteMem, uint32_t addr);

View File

@ -19,6 +19,7 @@
*/
#include <string.h>
#include <assert.h>
#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());
}
}

View File

@ -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)

View File

@ -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);