diff --git a/src/MTypes.cpp b/src/MTypes.c similarity index 69% rename from src/MTypes.cpp rename to src/MTypes.c index 248dce5..e3a958b 100644 --- a/src/MTypes.cpp +++ b/src/MTypes.c @@ -8,18 +8,14 @@ #include "MTypes.h" -#include - -using std::min; -using std::max; void UnionMRect( const MRect* a, const MRect* b, MRect* u ) { - u->top = min( a->top, b->top ); - u->left = min( a->left, b->left ); - u->bottom = max( a->bottom, b->bottom ); - u->right = max( a->right, b->right ); + u->top = MinShort( a->top, b->top ); + u->left = MinShort( a->left, b->left ); + u->bottom = MaxShort( a->bottom, b->bottom ); + u->right = MaxShort( a->right, b->right ); } diff --git a/src/MTypes.h b/src/MTypes.h index cfb77f2..5746535 100644 --- a/src/MTypes.h +++ b/src/MTypes.h @@ -8,38 +8,44 @@ #pragma once -#include +#include +#include typedef signed char MBoolean; typedef uint32_t MTicks; -struct MRGBColor +typedef struct MRGBColor { unsigned short red; unsigned short green; unsigned short blue; -}; +} MRGBColor; -struct MRect +typedef struct MRect { short top; short left; short bottom; - short right; -}; + short right; +} MRect; -struct MPoint +typedef struct MPoint { short v; short h; -}; +} MPoint; void UnionMRect( const MRect* a, const MRect* b, MRect* u ); void OffsetMRect( MRect* r, int x, int y ); unsigned char MPointInMRect( MPoint p, const MRect* r ); + +static inline short MinShort(short a, short b) { return a < b ? a : b; } +static inline short MaxShort(short a, short b) { return a < b ? b : a; } +static inline int MinInt(int a, int b) { return a < b ? a : b; } +static inline int MaxInt(int a, int b) { return a < b ? b : a; } diff --git a/src/SDLU.cpp b/src/SDLU.c similarity index 92% rename from src/SDLU.cpp rename to src/SDLU.c index 459581c..32d5f6d 100644 --- a/src/SDLU.cpp +++ b/src/SDLU.c @@ -9,14 +9,10 @@ #include "SDLU.h" #include "gameticks.h" #include "music.h" - #include "main.h" // for Error -#include - -using std::deque; // for acquiresurface -const int k_acquireMax = 10; +#define k_acquireMax 10 static int s_acquireHead = -1; static SDL_Surface* s_acquireList[k_acquireMax]; @@ -38,7 +34,7 @@ static MBoolean s_isForeground = true; static float s_fadeGamma = 1; // for checktyping -struct BufferedKey +typedef struct BufferedKey { bool isASCII; @@ -47,14 +43,18 @@ struct BufferedKey char ascii; SDL_Keycode keycode; } value; -}; +} BufferedKey; +#define k_maxBufferedKeys 256 static MBoolean s_interestedInTyping = false; -static std::deque s_keyBuffer; +static BufferedKey s_keyBuffer[k_maxBufferedKeys]; +static int s_keyBufferSize = 0; -int SDLUi_EventFilter(void*, SDL_Event *event) +int SDLUi_EventFilter(void* junk, SDL_Event *event) { + (void) junk; + switch (event->type) { case SDL_TEXTINPUT: @@ -67,7 +67,8 @@ int SDLUi_EventFilter(void*, SDL_Event *event) BufferedKey key; key.isASCII = true; key.value.ascii = *asciiPtr; - s_keyBuffer.push_back(key); + s_keyBuffer[s_keyBufferSize] = key; + s_keyBufferSize = MinInt(k_maxBufferedKeys, s_keyBufferSize + 1); } } break; @@ -81,7 +82,8 @@ int SDLUi_EventFilter(void*, SDL_Event *event) BufferedKey key; key.isASCII = false; key.value.keycode = event->key.keysym.sym; - s_keyBuffer.push_back(key); + s_keyBuffer[s_keyBufferSize] = key; + s_keyBufferSize = MinInt(k_maxBufferedKeys, s_keyBufferSize + 1); } break; } @@ -385,7 +387,7 @@ MBoolean SDLU_IsForeground() void SDLU_StartWatchingTyping() { s_interestedInTyping = true; - s_keyBuffer.clear(); + s_keyBufferSize = 0; // clear keybuffer } @@ -397,10 +399,13 @@ void SDLU_StopWatchingTyping() MBoolean SDLU_CheckASCIITyping(char* ascii) { - if (!s_keyBuffer.empty() && s_keyBuffer.front().isASCII) + if (s_keyBufferSize > 0 && s_keyBuffer[0].isASCII) { - *ascii = s_keyBuffer.front().value.ascii; - s_keyBuffer.pop_front(); + *ascii = s_keyBuffer[0].value.ascii; + + s_keyBufferSize--; + SDL_memcpy(&s_keyBuffer[0], &s_keyBuffer[1], (s_keyBufferSize) * sizeof(BufferedKey)); + return true; } @@ -411,10 +416,13 @@ MBoolean SDLU_CheckASCIITyping(char* ascii) MBoolean SDLU_CheckSDLTyping(SDL_Keycode* sdlKey) { - if (!s_keyBuffer.empty() && !s_keyBuffer.front().isASCII) + if (s_keyBufferSize > 0 && !s_keyBuffer[0].isASCII) { - *sdlKey = s_keyBuffer.front().value.keycode; - s_keyBuffer.pop_front(); + *sdlKey = s_keyBuffer[0].value.keycode; + + s_keyBufferSize--; + SDL_memcpy(&s_keyBuffer[0], &s_keyBuffer[1], (s_keyBufferSize) * sizeof(BufferedKey)); + return true; } diff --git a/src/blitter.cpp b/src/blitter.c similarity index 100% rename from src/blitter.cpp rename to src/blitter.c diff --git a/src/control.cpp b/src/control.c similarity index 100% rename from src/control.cpp rename to src/control.c diff --git a/src/font.cpp b/src/font.c similarity index 97% rename from src/font.cpp rename to src/font.c index 11eedc4..57cdf89 100644 --- a/src/font.cpp +++ b/src/font.c @@ -7,9 +7,9 @@ #include "gworld.h" -const int kNumFonts = (picBatsuFont-picFont+1); +#define kNumFonts (picBatsuFont-picFont+1) -static SkittlesFont s_font[kNumFonts] = {}; +static SkittlesFont s_font[kNumFonts]; static SkittlesFontPtr LoadFont( SkittlesFontPtr font, int pictID, unsigned char *letterMap ) diff --git a/src/gameticks.cpp b/src/gameticks.c similarity index 100% rename from src/gameticks.cpp rename to src/gameticks.c diff --git a/src/graphics.cpp b/src/graphics.c similarity index 98% rename from src/graphics.cpp rename to src/graphics.c index 6ad6d1d..b5007df 100644 --- a/src/graphics.cpp +++ b/src/graphics.c @@ -23,7 +23,9 @@ SDL_Surface* backdropSurface = NULL; void DrawSpriteBlobs( int player, int type ) { MRect firstRect, secondRect, thirdRect; - const int repeat = 0xFF, forever = 0xFE; + +#define repeat 0xFF +#define forever 0xFE static const unsigned char blobAnimation[6][2][25] = { @@ -100,6 +102,9 @@ void DrawSpriteBlobs( int player, int type ) SurfaceDrawSprite( &secondRect, colorB[player], blobAnimation[type][1][anim[player]] ); SDLU_ReleaseSurface( playerSpriteSurface[player] ); + +#undef repeat +#undef forever } void CleanSpriteArea( int player, MRect *myRect ) diff --git a/src/graymonitor.cpp b/src/graymonitor.c similarity index 100% rename from src/graymonitor.cpp rename to src/graymonitor.c diff --git a/src/grays.cpp b/src/grays.c similarity index 100% rename from src/grays.cpp rename to src/grays.c diff --git a/src/gworld.cpp b/src/gworld.c similarity index 98% rename from src/gworld.cpp rename to src/gworld.c index 6b69ff4..c45225a 100644 --- a/src/gworld.cpp +++ b/src/gworld.c @@ -185,8 +185,8 @@ SDL_Surface* LoadPICTAsSurface( int pictID, int depth ) { const char* filename; SDL_Surface* surface; - SDL_Rect rect = {}; - uint8_t* pixels = nullptr; + SDL_Rect rect = {0}; + uint8_t* pixels = NULL; filename = QuickResourceName( "PICT", pictID, ".jpg" ); if( !FileExists( filename ) ) @@ -195,7 +195,7 @@ SDL_Surface* LoadPICTAsSurface( int pictID, int depth ) } if( !FileExists( filename ) ) { - return nullptr; + return NULL; } pixels = stbi_load(filename, &rect.w, &rect.h, NULL, 3); diff --git a/src/hiscore.cpp b/src/hiscore.c similarity index 98% rename from src/hiscore.cpp rename to src/hiscore.c index 5203402..349b775 100644 --- a/src/hiscore.cpp +++ b/src/hiscore.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "main.h" #include "gworld.h" @@ -25,8 +24,6 @@ #include "music.h" #include "soundfx.h" -using std::min; - Combo defaultBest = { /*bestGrid[kGridAcross][kGridDown] = */ @@ -225,9 +222,9 @@ void ShowHiscore( void ) SDLU_GetPixel( hiScoreSurface, RandomBefore( fullSDLRect.w ), RandomBefore( fullSDLRect.h ), &anyColor ); - anyColor.r = min( 255, anyColor.r + 112 ); - anyColor.g = min( 255, anyColor.g + 112 ); - anyColor.b = min( 255, anyColor.b + 112 ); + anyColor.r = MinInt( 255, anyColor.r + 112 ); + anyColor.g = MinInt( 255, anyColor.g + 112 ); + anyColor.b = MinInt( 255, anyColor.b + 112 ); dPoint.v = widescreen? 100: 20; dPoint.h = 225; diff --git a/src/keyselect.cpp b/src/keyselect.c similarity index 100% rename from src/keyselect.cpp rename to src/keyselect.c diff --git a/src/level.cpp b/src/level.c similarity index 97% rename from src/level.cpp rename to src/level.c index 2460349..91d2076 100644 --- a/src/level.cpp +++ b/src/level.c @@ -2,7 +2,6 @@ #include #include -#include #include "SDLU.h" @@ -42,9 +41,6 @@ int difficultyTicks, backdropTicks, backdropFrame; #define kIncrementPerFrame 2 #define kSplatType 4 -using std::min; -using std::max; - const int startSkip = 1; static MBoolean shouldFullRepaint = false; static MTicks startMenuTime = 0; @@ -63,13 +59,13 @@ enum kTitleItemQuit, }; -struct TitleItemDef +typedef struct TitleItemDef { const char* name; MRGBColor color1; MRGBColor color2; MRect rect; -}; +} TitleItemDef; static const TitleItemDef k_titleItemDefs[kTitleItems] = { @@ -224,21 +220,21 @@ void GameStartMenu( void ) dPoint.v = 215; for (int i = 0; i < kTitleItems; i++) { - auto &item = titleItems[i]; - item.rect.left = dPoint.h; - item.rect.top = dPoint.v - 6; - item.rect.bottom = dPoint.v + 16 + 6; - auto nameLength = strlen(item.name); + TitleItemDef* item = &titleItems[i]; + item->rect.left = dPoint.h; + item->rect.top = dPoint.v - 6; + item->rect.bottom = dPoint.v + 16 + 6; + int nameLength = (int) strlen(item->name); for (int charNo = 0; charNo < nameLength; charNo++) { - char c = item.name[charNo]; + char c = item->name[charNo]; float p = charNo / (float) (nameLength - 1); - int red = item.color1.red * (1.0f - p) + item.color2.red * p; - int green = item.color1.green * (1.0f - p) + item.color2.green * p; - int blue = item.color1.blue * (1.0f - p) + item.color2.blue * p; + int red = item->color1.red * (1.0f - p) + item->color2.red * p; + int green = item->color1.green * (1.0f - p) + item->color2.green * p; + int blue = item->color1.blue * (1.0f - p) + item->color2.blue * p; SurfaceBlitCharacter(font, c, &dPoint, red, green, blue, 1); } - item.rect.right = dPoint.h; + item->rect.right = dPoint.h; dPoint.h = left; dPoint.v += 24; } @@ -478,7 +474,7 @@ void GameStartMenu( void ) // update glows for (int glowUpdate=0; glowUpdate < kTitleItems; ++glowUpdate) { - const MRect& titleRect = titleItems[glowUpdate].rect; + const MRect* titleRect = &titleItems[glowUpdate].rect; oldGlow = titleGlow[glowUpdate]; if( selected == glowUpdate ) @@ -495,13 +491,13 @@ void GameStartMenu( void ) if( titleGlow[glowUpdate] != oldGlow ) { SurfaceBlitColorOver( gameStartSurface, gameStartDrawSurface, - &titleRect, &titleRect, + titleRect, titleRect, 0, 0, 0, titleGlow[glowUpdate] ); - drawRect[kGlow].top = min(drawRect[kGlow].top, titleRect.top); - drawRect[kGlow].left = min(drawRect[kGlow].left, titleRect.left); - drawRect[kGlow].bottom = max(drawRect[kGlow].bottom, titleRect.bottom); - drawRect[kGlow].right = max(drawRect[kGlow].right, titleRect.right); + drawRect[kGlow].top = MinShort(drawRect[kGlow].top, titleRect->top); + drawRect[kGlow].left = MinShort(drawRect[kGlow].left, titleRect->left); + drawRect[kGlow].bottom = MaxShort(drawRect[kGlow].bottom, titleRect->bottom); + drawRect[kGlow].right = MaxShort(drawRect[kGlow].right, titleRect->right); } } @@ -1274,13 +1270,14 @@ void RegisteredVictory( void ) }; // In widescreen mode, move vertical text positions closer to the center - if (widescreen) { - for (auto& dp : dPoint) { - if (dp.v >= 130) { - dp.v -= 20; - } else { - dp.v += 20; - } + if (widescreen) + { + for (int i = 0; i < arrsize(dPoint); i++) + { + if (dPoint[i].v >= 130) + dPoint[i].v -= 20; + else + dPoint[i].v += 20; } } diff --git a/src/main.cpp b/src/main.c similarity index 99% rename from src/main.cpp rename to src/main.c index a694118..b2cdca0 100644 --- a/src/main.cpp +++ b/src/main.c @@ -290,7 +290,7 @@ SDL_Renderer* g_renderer; SDL_Window* g_window; SDL_Texture* g_windowTexture; SDL_Surface* g_frontSurface; -SDL_Rect g_widescreenCrop {0,60,640,360}; +SDL_Rect g_widescreenCrop = {0,60,640,360}; signed char nextA[2], nextB[2], nextM[2], nextG[2], colorA[2], colorB[2], blobX[2], blobY[2], blobR[2], blobSpin[2], speed[2], role[2], halfway[2], control[2], dropping[2], magic[2], grenade[2], anim[2]; @@ -314,6 +314,9 @@ MBoolean crispUpscaling = false; int main(int argc, char *argv[]) { + (void) argc; + (void) argv; + Initialize( ); LoadPrefs( ); @@ -436,11 +439,7 @@ void Error( const char* extra ) fprintf(stderr, "%s\n", error); - SDL_ShowSimpleMessageBox( - SDL_MESSAGEBOX_ERROR, - "Candy Crisis", - error, - nullptr); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Candy Crisis", error, NULL); abort(); } diff --git a/src/main.h b/src/main.h index 73385a3..195cea4 100644 --- a/src/main.h +++ b/src/main.h @@ -34,10 +34,10 @@ const char* QuickResourceName( const char* prefix, int id, const char* extension void WaitForRegainFocus(); -struct KeyList +typedef struct KeyList { short left, right, drop, rotate; -}; +} KeyList; #define kGridAcross 6 @@ -238,9 +238,9 @@ enum #define kLastBlob kBlob7 #define kBlobTypes (kLastBlob - kFirstBlob + 1) -constexpr double pi = 3.14159265358979323846264338327950288; +#define kPi 3.14159265358979323846264338327950288 -#define arrsize(x) int(sizeof((x)) / sizeof((x)[0])) +#define arrsize(x) ( (int)(sizeof((x)) / sizeof((x)[0])) ) extern SDL_Renderer* g_renderer; extern SDL_Window* g_window; diff --git a/src/moving.cpp b/src/moving.c similarity index 100% rename from src/moving.cpp rename to src/moving.c diff --git a/src/music.cpp b/src/music.cpp index ca40dcb..e79f512 100644 --- a/src/music.cpp +++ b/src/music.cpp @@ -4,6 +4,9 @@ #include #include +extern "C" +{ + #include "main.h" #include "music.h" #include "gworld.h" @@ -11,16 +14,21 @@ #include "soundfx.h" #include "graphics.h" +} + #include "support/ModStream.h" const int k_noMusic = -1; const int k_songs = 14; +extern "C" +{ MBoolean musicOn = true; int musicSelection = k_noMusic; static MBoolean s_musicFast = false; int s_musicPaused = 0; +} static cmixer::ModStream* s_musicChannel = NULL; diff --git a/src/next.cpp b/src/next.c similarity index 100% rename from src/next.cpp rename to src/next.c diff --git a/src/opponent.cpp b/src/opponent.c similarity index 99% rename from src/opponent.cpp rename to src/opponent.c index 4ef645d..9e8749c 100644 --- a/src/opponent.cpp +++ b/src/opponent.c @@ -48,7 +48,7 @@ void InitOpponent( void ) for( index=0; index #include #include #include @@ -30,19 +29,16 @@ #include "hiscore.h" #include "score.h" -using std::min; -using std::max; - -struct FRGBColor +typedef struct FRGBColor { float red, green, blue; -}; +} FRGBColor; -struct ClickableZone +typedef struct ClickableZone { int item; MRect rect; -}; +} ClickableZone; SDL_Surface* backSurface; SDL_Surface* drawSurface; @@ -122,14 +118,14 @@ static MPoint DrawRainbowText( SkittlesFontPtr font, const char *line, MPoint dP { case kTextBrightRainbow: r = (int)(208.0 + 40.0 * sin(wave )); - g = (int)(208.0 + 40.0 * sin(wave + ((2.*pi) * 1./3.))); - b = (int)(208.0 + 40.0 * sin(wave + ((2.*pi) * 2./3.))); + g = (int)(208.0 + 40.0 * sin(wave + ((2.*kPi) * 1./3.))); + b = (int)(208.0 + 40.0 * sin(wave + ((2.*kPi) * 2./3.))); break; case kTextRainbow: r = (int)(128.0 + 96.0 * sin(wave )); - g = (int)(128.0 + 96.0 * sin(wave + ((2.*pi) * 1./3.))); - b = (int)(128.0 + 96.0 * sin(wave + ((2.*pi) * 2./3.))); + g = (int)(128.0 + 96.0 * sin(wave + ((2.*kPi) * 1./3.))); + b = (int)(128.0 + 96.0 * sin(wave + ((2.*kPi) * 2./3.))); break; } @@ -648,7 +644,7 @@ static void DrawHiScoreContents( int *item, int shade ) SurfaceBlitCharacter( dashedLineFont, '.', &dashedLinePoint, 0, 0, 0, 0 ); } - nameLength = int(strlen(highScoreName)); + nameLength = (int) strlen(highScoreName); for( index = 0; index < nameLength; index++ ) { SurfaceBlitCharacter( bigFont, highScoreName[index], &hPoint, 255, 255, 255, 1 ); @@ -832,7 +828,7 @@ static MBoolean ContinueSelected( int *item, unsigned char inKey, SDL_Keycode in static MBoolean HiScoreSelected( int *item, unsigned char inKey, SDL_Keycode inSDLKey ) { - int nameLength = int(strlen(highScoreName)); + int nameLength = (int) strlen(highScoreName); // return (SDL key) if( inSDLKey == SDLK_RETURN ) @@ -1136,9 +1132,9 @@ void HandleDialog( int type ) SDLU_GetPixel( boardSurface[0], RandomBefore( boardWorldZRect.right ), RandomBefore( boardWorldZRect.bottom ), &inColor ); - backColor[count].red = min( 255.0f, inColor.r + lighten[count] ); - backColor[count].green = min( 255.0f, inColor.g + lighten[count] ); - backColor[count].blue = min( 255.0f, inColor.b + lighten[count] ); + backColor[count].red = MinInt( 255.0f, inColor.r + lighten[count] ); + backColor[count].green = MinInt( 255.0f, inColor.g + lighten[count] ); + backColor[count].blue = MinInt( 255.0f, inColor.b + lighten[count] ); } // Get some graphics that we're going to need diff --git a/src/players.cpp b/src/players.c similarity index 100% rename from src/players.cpp rename to src/players.c diff --git a/src/prefs.cpp b/src/prefs.c similarity index 52% rename from src/prefs.cpp rename to src/prefs.c index 52619a2..6e83808 100644 --- a/src/prefs.cpp +++ b/src/prefs.c @@ -1,6 +1,5 @@ // prefs.c -#include #include #include #include @@ -12,12 +11,12 @@ #include "hiscore.h" #include "keyselect.h" -struct Preference +typedef struct Preference { const char* keyName; void* valuePtr; unsigned int valueLength; -}; +} Preference; Preference prefList[] = { @@ -31,84 +30,74 @@ Preference prefList[] = { "CrispUpscaling", &crispUpscaling, sizeof(crispUpscaling ) }, }; -static std::fstream GetPrefsStream(std::ios::openmode openmode) +static FILE* GetPrefsStream(const char* openmode) { static char path[1024]; const char* userDir = SDL_GetPrefPath(NULL, "CandyCrisis"); snprintf(path, sizeof(path), "%sCandyCrisisPrefs.bin", userDir); - - return std::fstream(path, std::ios::binary | openmode); + return fopen(path, openmode); } void LoadPrefs() { - std::fstream stream; - try - { - stream = GetPrefsStream(std::ios::in); - } - catch (...) + FILE* stream = GetPrefsStream("rb"); + if (!stream) { return; } - if (!stream.good()) + for (int i = 0; i < arrsize(prefList); i++) { - return; - } + Preference* pref = &prefList[i]; + + fseek(stream, 0, SEEK_SET); - for (Preference& pref: prefList) - { - stream.seekg(0, std::ios::beg); - while (stream.good() && !stream.eof()) + while (!feof(stream)) { int keyLength; char key[256]; unsigned int contentsLength; - keyLength = stream.get(); - if (stream.eof()) break; - stream.read(key, keyLength); + keyLength = fgetc(stream); + if (keyLength < 0 || feof(stream)) + break; + fread(key, keyLength, 1, stream); key[keyLength] = '\0'; - stream.read((char*)&contentsLength, sizeof(contentsLength)); + fread(&contentsLength, sizeof(contentsLength), 1, stream); - if (!strncmp(key, pref.keyName, strlen(pref.keyName))) + if (!strncmp(key, pref->keyName, strlen(pref->keyName))) { - if (contentsLength != pref.valueLength) + if (contentsLength != pref->valueLength) break; - stream.read((char*) pref.valuePtr, pref.valueLength); + fread(pref->valuePtr, pref->valueLength, 1, stream); break; } else { - stream.seekg(contentsLength, std::ios::cur); + fseek(stream, contentsLength, SEEK_CUR); } } } + + fclose(stream); } void SavePrefs() { - std::fstream stream; - try - { - stream = GetPrefsStream(std::ios::out); - } - catch (...) - { - return; - } - - if (!stream.good()) + FILE* stream = GetPrefsStream("wb"); + if (!stream) { return; } - for (Preference& pref: prefList) + for (int i = 0; i < arrsize(prefList); i++) { - stream.put(strlen(pref.keyName)); - stream.write(pref.keyName, strlen(pref.keyName)); - stream.write((const char*)&pref.valueLength, sizeof(pref.valueLength)); - stream.write((const char*)pref.valuePtr, pref.valueLength); + const Preference* pref = &prefList[i]; + fputc(strlen(pref->keyName), stream); + fwrite(pref->keyName, strlen(pref->keyName), 1, stream); + fwrite(&pref->valueLength, sizeof(pref->valueLength), 1, stream); + fwrite(pref->valuePtr, pref->valueLength, 1, stream); } + + fclose(stream); } diff --git a/src/random.cpp b/src/random.c similarity index 100% rename from src/random.cpp rename to src/random.c diff --git a/src/score.cpp b/src/score.c similarity index 98% rename from src/score.cpp rename to src/score.c index 4929f37..b9c3351 100644 --- a/src/score.cpp +++ b/src/score.c @@ -113,7 +113,7 @@ void ShowScore( int player ) myRect = scoreWindowZRect; myRect.right -= 2; myRect.left = myRect.right - kNumberHorizSize; - for( count = int(strlen(myString)) - 1; count >= 0; count-- ) + for( count = (int) strlen(myString) - 1; count >= 0; count-- ) { DrawCharacter( myString[count], &myRect ); OffsetMRect( &myRect, -kNumberHorizSize - 1, 0 ); diff --git a/src/soundfx.cpp b/src/soundfx.cpp index 9b73b3d..880ffd8 100644 --- a/src/soundfx.cpp +++ b/src/soundfx.cpp @@ -1,13 +1,16 @@ // soundfx.c -#include "main.h" -#include "soundfx.h" -#include "music.h" - #include "support/cmixer.h" #include -MBoolean soundOn = true; +extern "C" +{ + #include "main.h" + #include "soundfx.h" + #include "music.h" + + MBoolean soundOn = true; +} static std::vector s_soundBank; static constexpr float k_playerStereoSeparation = 0.5f; diff --git a/src/tutorial.cpp b/src/tutorial.c similarity index 100% rename from src/tutorial.cpp rename to src/tutorial.c diff --git a/src/tweak.cpp b/src/tweak.c similarity index 100% rename from src/tweak.cpp rename to src/tweak.c diff --git a/src/tweak.h b/src/tweak.h index 95b1a3d..b57a797 100644 --- a/src/tweak.h +++ b/src/tweak.h @@ -6,6 +6,6 @@ void StartTweak( int player, int direction, int rotate, int fall ); void UpdateTweak( int player, int suction ); void InitTweak( void ); -#define d2r(x) ((x)*(pi/180)) +#define d2r(x) ((x)*(kPi/180)) #define kTweakDelay 1 diff --git a/src/victory.cpp b/src/victory.c similarity index 100% rename from src/victory.cpp rename to src/victory.c diff --git a/src/zap.cpp b/src/zap.c similarity index 99% rename from src/zap.cpp rename to src/zap.c index 38303a1..03baba6 100644 --- a/src/zap.cpp +++ b/src/zap.c @@ -3,7 +3,6 @@ #include "SDLU.h" #include -#include #include "main.h" #include "players.h" @@ -36,8 +35,6 @@ int zapScoreWidth[2]; int zapScoreR[2], zapScoreG[2], zapScoreB[2]; int zapOffsetX[7][kZapFrames], zapOffsetY[7][kZapFrames]; -using std::min; - void ZapScoreDisplay( int player, int amount, int multiplier, int x, int y, int c ) { char *scan;