shithub: candycrisis

Download patch

ref: 56f1e92bcab1dad60dad8791428b84a0a4c0453b
parent: 1fcb507e98d51bbf6c03967964d02f3c621daf6c
author: Jacob Moody <moody@posixcafe.org>
date: Wed Aug 30 18:46:25 EDT 2023

build and link

--- a/src/SDLU.c
+++ b/src/SDLU.c
@@ -168,11 +168,7 @@
 
         int currentWidth = 0;
         int currentHeight = 0;
-#if SDL_VERSION_ATLEAST(2,26,0)
-        SDL_GetWindowSizeInPixels(g_window, &currentWidth, &currentHeight);
-#else
         SDL_GetWindowSize(g_window, &currentWidth, &currentHeight);
-#endif
 
         if (currentWidth < minWidth || currentHeight < minHeight)
         {
@@ -216,7 +212,7 @@
     SDL_SetPaletteColors(s_grayscalePalette, grayscaleColors, 0, arrsize(grayscaleColors));
 
     s_standardCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
-    s_handCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
+    //s_handCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
 }
 
 
@@ -282,7 +278,7 @@
             return;
 	}
 	
-	return SDL_GetRGB( px, surface->format, &pixel->r, &pixel->g, &pixel->b );
+	SDL_GetRGB( px, surface->format, &pixel->r, &pixel->g, &pixel->b );
 }
 
 
@@ -440,13 +436,9 @@
 	int windowPixelH = 1;
 
 	SDL_GetWindowSize(g_window, &windowPointW, &windowPointH);
-#if SDL_VERSION_ATLEAST(2,26,0)
-	SDL_GetWindowSizeInPixels(g_window, &windowPixelW, &windowPixelH);
-#else
 	// Backwards compat with old versions of SDL
 	windowPixelW = windowPointW;
 	windowPixelH = windowPointH;
-#endif
 
 	if (windowPointW != windowPixelW || windowPointH != windowPixelH)
 	{
--- a/src/SDLU.h
+++ b/src/SDLU.h
@@ -27,8 +27,8 @@
 #define SYSTEM_CURSOR_ARROW     1
 #define SYSTEM_CURSOR_HAND      2
 
-void         SDLU_Init();
-void         SDLU_CreateRendererTexture();
+void         SDLU_Init(void);
+void         SDLU_CreateRendererTexture(void);
 SDL_Rect*    SDLU_MRectToSDLRect( const MRect* in, SDL_Rect* out );
 MRect*       SDLU_SDLRectToMRect( const SDL_Rect* in, MRect* out );
 int          SDLU_BlitSurface( SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect );
@@ -38,16 +38,16 @@
 void         SDLU_BlitFrontSurface( SDL_Surface* source, SDL_Rect* sourceSDLRect, SDL_Rect* destSDLRect );
 void         SDLU_SetBrightness( float b );
 void         SDLU_AcquireSurface( SDL_Surface* surface );
-SDL_Surface* SDLU_GetCurrentSurface();
+SDL_Surface* SDLU_GetCurrentSurface(void);
 void         SDLU_ReleaseSurface( SDL_Surface* surface );
 void         SDLU_GetMouse( MPoint* pt );
-int          SDLU_Button();
-void         SDLU_Yield();
-void         SDLU_PumpEvents();
-void         SDLU_StartWatchingTyping();
-void         SDLU_StopWatchingTyping();
+int          SDLU_Button(void);
+void         SDLU_Yield(void);
+void         SDLU_PumpEvents(void);
+void         SDLU_StartWatchingTyping(void);
+void         SDLU_StopWatchingTyping(void);
 MBoolean     SDLU_CheckASCIITyping(char* ascii);
 MBoolean     SDLU_CheckSDLTyping(SDL_Keycode* sdlKey);
-MBoolean     SDLU_IsForeground();
-void         SDLU_Present();
+MBoolean     SDLU_IsForeground(void);
+void         SDLU_Present(void);
 void         SDLU_SetSystemCursor(int which);
--- a/src/gameticks.c
+++ b/src/gameticks.c
@@ -1,6 +1,10 @@
 // gameticks.c
 
+#ifdef __plan9__
+#include <SDL2/SDL.h>
+#else
 #include <SDL_timer.h>
+#endif
 #include "gameticks.h"
 
 MTicks baseTickCount, freezeTickCount;
--- a/src/gameticks.h
+++ b/src/gameticks.h
@@ -2,7 +2,7 @@
 
 #include "MTypes.h"
 
-MTicks MTickCount();
+MTicks MTickCount( void );
 void InitGameTickCount( void );
 void FreezeGameTickCount( void );
 void UnfreezeGameTickCount( void );
--- a/src/gworld.h
+++ b/src/gworld.h
@@ -10,8 +10,8 @@
 #define kBlastHeight 72
 #define kBlastFrames 14
 
-void GetBlobGraphics();
-void InitPlayerWorlds();
+void GetBlobGraphics(void);
+void InitPlayerWorlds(void);
 
 void         DrawPICTInSurface( SDL_Surface* surface, int pictID );
 SDL_Surface* LoadPICTAsSurface( int pictID, int depth );
--- a/src/keyselect.h
+++ b/src/keyselect.h
@@ -5,7 +5,7 @@
 extern "C"
 #endif
 
-void CheckKeys();
+void CheckKeys(void);
 
 extern SDL_Keycode playerKeys[2][4];
 extern const SDL_Keycode defaultPlayerKeys[2][4];
binary files a/src/main.c b/src/main.c differ
--- a/src/main.h
+++ b/src/main.h
@@ -22,16 +22,16 @@
 void QuickFadeIn( MRGBColor* color );
 void QuickFadeOut( MRGBColor* color );
 MBoolean FileExists( const char* name );
-void GoToBackground();
+void GoToBackground( void );
 MBoolean ControlKeyIsPressed( void );
 MBoolean OptionKeyIsPressed( void );
 MBoolean DeleteKeyIsPressed( void );
-MBoolean IsRegistered();
-void InitRegistration();
-void NoPaint();
-void NeedRefresh();
+MBoolean IsRegistered( void );
+void InitRegistration( void );
+void NoPaint( void );
+void NeedRefresh( void );
 const char* QuickResourceName( const char* prefix, int id, const char* extension );
-void WaitForRegainFocus();
+void WaitForRegainFocus( void );
 
 
 typedef struct KeyList
@@ -261,4 +261,4 @@
 extern MBoolean playerWindowVisible[2];
 extern KeyList hitKey[2];
 extern int backgroundID;
-extern void (*DoFullRepaint)();
+extern void (*DoFullRepaint)(void);
--- a/src/music.h
+++ b/src/music.h
@@ -8,7 +8,7 @@
 void SlowMusic( void );
 int GetCurrentMusic( void );
 void ChooseMusic( short which );
-void ShutdownMusic();
+void ShutdownMusic( void );
 
 
 extern MBoolean musicOn;
--- a/src/soundfx.h
+++ b/src/soundfx.h
@@ -1,12 +1,12 @@
 // soundfx.h
 
 
-void InitSound();
-void ShutdownSound();
+void InitSound( void );
+void ShutdownSound( void );
 void PlayStereo( int player, short which );
 void PlayStereoFrequency( int player, short which, short freq );
 void PlayMono( int which );
-void UpdateSound();
+void UpdateSound( void );
 
 enum
 {
--- a/src/support/cmixer.c
+++ b/src/support/cmixer.c
@@ -61,6 +61,11 @@
 	PCMFORMAT_2CH_LE16	= 0x22,
 	PCMFORMAT_1CH_BE16	= PCMFORMAT_1CH_LE16 | 0x80,
 	PCMFORMAT_2CH_BE16	= PCMFORMAT_2CH_LE16 | 0x80,
+
+	VOIX = 0x1,
+	DEAD = 0x2,
+	MODS = 0x3,
+	WAVS = 0x4,
 };
 
 struct CMWavStream
@@ -417,7 +422,7 @@
 static inline CMVoice* CMVoice_Check(void* ptr)
 {
 	CMVoice* voice = (CMVoice*) ptr;
-	CM_ASSERT(voice->cookie == 'VOIX', "VOIX cookie not found");
+	CM_ASSERT(voice->cookie == VOIX, "VOIX cookie not found");
 	return voice;
 }
 
@@ -425,7 +430,7 @@
 {
 	CMVoice* voice = SDL_calloc(1, sizeof(CMVoice));
 	
-	voice->cookie = 'VOIX';
+	voice->cookie = VOIX;
 	voice->sampleRate = 0;
 	voice->sampleCount = 0;
 	voice->end = 0;
@@ -463,7 +468,7 @@
 	if (voice->callbacks.free)
 		voice->callbacks.free(voice);
 
-	voice->cookie = 'DEAD';
+	voice->cookie = DEAD;
 	SDL_free(voice);
 }
 
@@ -708,8 +713,8 @@
 
 static inline CMWavStream* CMWavStream_Check(CMVoice* voice)
 {
-	CM_ASSERT(voice->cookie == 'VOIX', "VOIX cookie not found");
-	CM_ASSERT(voice->wav.cookie == 'WAVS', "WAVS cookie not found");
+	CM_ASSERT(voice->cookie == VOIX, "VOIX cookie not found");
+	CM_ASSERT(voice->wav.cookie == WAVS, "WAVS cookie not found");
 	return &voice->wav;
 }
 
@@ -717,7 +722,7 @@
 {
 	CMWavStream* wav = &voice->wav;
 
-	wav->cookie = 'WAVS';
+	wav->cookie = WAVS;
 	wav->pcmformat = PCMFORMAT_NULL;
 	wav->idx = 0;
 
@@ -745,7 +750,7 @@
 	wav->data = NULL;
 	wav->dataLength = 0;
 	wav->ownData = false;
-	wav->cookie = 'DEAD';
+	wav->cookie = DEAD;
 }
 
 static void RewindWav(CMVoice* voice)
@@ -916,8 +921,8 @@
 
 static inline CMModStream* CMModStream_Check(CMVoice* voice)
 {
-	CM_ASSERT(voice->cookie == 'VOIX', "VOIX cookie not found");
-	CM_ASSERT(voice->mod.cookie == 'MODS', "MODS cookie not found");
+	CM_ASSERT(voice->cookie == VOIX, "VOIX cookie not found");
+	CM_ASSERT(voice->mod.cookie == MODS, "MODS cookie not found");
 	return &voice->mod;
 }
 
@@ -934,7 +939,7 @@
 	voice->callbacks.fillBuffer = StreamMod;
 	voice->callbacks.free = FreeMod;
 
-	voice->mod.cookie = 'MODS';
+	voice->mod.cookie = MODS;
 	voice->mod.replayBuffer = SDL_calloc(1, 2048 * 8 * sizeof(voice->mod.replayBuffer[0]));
 	voice->mod.replayBufferOffset = 0;
 	voice->mod.replayBufferSamples = 0;
@@ -956,7 +961,7 @@
 	SDL_free(mod->moduleFileMemory);
 	SDL_free(mod->replayBuffer);
 
-	mod->cookie = 'DEAD';
+	mod->cookie = DEAD;
 }
 
 void CMVoice_SetMODPlaybackSpeed(CMVoice* voice, double speed)