Skip to content

Commit

Permalink
MTicks type
Browse files Browse the repository at this point in the history
  • Loading branch information
jorio committed Feb 3, 2022
1 parent fe1e135 commit d919168
Show file tree
Hide file tree
Showing 22 changed files with 41 additions and 32 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ if(NOT MSVC)
-Wall
#-Wextra # TODO
#-Wshadow # TODO
-Wno-sign-compare # TODO
-Wno-multichar
-Wno-unknown-pragmas
-Werror=return-type
Expand Down
9 changes: 4 additions & 5 deletions src/MTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
/// John Stiles, 2002/10/14
///

#pragma once

#ifndef __MTYPES__
#define __MTYPES__

#include <cstdint>

typedef signed char MBoolean;

typedef uint32_t MTicks;


struct MRGBColor
{
Expand Down Expand Up @@ -42,5 +43,3 @@ void UnionMRect( const MRect* a, const MRect* b, MRect* u );
void OffsetMRect( MRect* r, int x, int y );
unsigned char MPointInMRect( MPoint p, MRect* r );


#endif
2 changes: 1 addition & 1 deletion src/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

int destinationX[2], destinationR[2];
signed char tempGrid[kGridAcross][kGridDown];
int timeAI[2], timeMove[2];
MTicks timeAI[2], timeMove[2];
MBoolean moveQuick[2];
AutoPatternPtr autoPattern = NULL;

Expand Down
2 changes: 1 addition & 1 deletion src/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void AutoControl( int player );

extern int destinationX[2], destinationR[2];
extern signed char tempGrid[kGridAcross][kGridDown];
extern int timeAI[2];
extern MTicks timeAI[2];
extern MBoolean moveQuick[2];
enum
{
Expand Down
4 changes: 2 additions & 2 deletions src/gameticks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <SDL_timer.h>
#include "gameticks.h"

unsigned int baseTickCount, freezeTickCount;
MTicks baseTickCount, freezeTickCount;
int freezeLevel;

unsigned int MTickCount()
MTicks MTickCount()
{
return (unsigned int ) ((float)SDL_GetTicks() * 0.06f);
}
Expand Down
4 changes: 3 additions & 1 deletion src/gameticks.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// gameticks.h

unsigned int MTickCount();
#include "MTypes.h"

MTicks MTickCount();
void InitGameTickCount( void );
void FreezeGameTickCount( void );
void UnfreezeGameTickCount( void );
Expand Down
2 changes: 1 addition & 1 deletion src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void ShowTitle( void )

RetrieveResources( );

int time = MTickCount() + 120;
MTicks time = MTickCount() + 120;

DrawPICTInSurface( g_frontSurface, picTitle );
while( time > MTickCount() && !SDLU_Button() )
Expand Down
3 changes: 2 additions & 1 deletion src/grays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

int grays[2][kGridAcross], grayAir[2][kGridAcross];
int unallocatedGrays[2], lockGrays[2], rowBounce[2][kGridAcross], splat[2][kGridAcross];
int blinkTime[2], blinkStage[2];
MTicks blinkTime[2];
int blinkStage[2];
const int blinkList[] = { kGrayNoBlink, kGrayBlink1, kGrayBlink2,
kGrayBlink3, kGrayBlink2, kGrayBlink1 };

Expand Down
3 changes: 2 additions & 1 deletion src/grays.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ MBoolean BusyDroppingGrays( int player );

extern int grays[2][kGridAcross], grayAir[2][kGridAcross], graySpeed[2];
extern int unallocatedGrays[2], lockGrays[2], rowBounce[2][kGridAcross], splat[2][kGridAcross];
extern int blinkTime[2], sunTime[2], blinkStage[2], sunStage[2];
extern MTicks blinkTime[2];
extern int blinkStage[2];

#define kTimeBetweenBlinks 120
3 changes: 2 additions & 1 deletion src/hiscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ const char *highScoreRank;

static void FadeScreen( SDL_Surface* hiScoreSurface, SDL_Surface* fadeSurface, int start, int end )
{
int skip, timer, frame, fade, color, direction, fadeStart, fadeEnd;
MTicks timer;
int skip, frame, fade, color, direction, fadeStart, fadeEnd;
SDL_Rect destSDLRect;
SDL_Rect fullSDLRect = { 0, 0, 640, 480 };
int black;
Expand Down
7 changes: 4 additions & 3 deletions src/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using std::max;

const int startSkip = 1;
static MBoolean shouldFullRepaint = false;
static int startMenuTime = 0;
static MTicks startMenuTime = 0;
static int splatState[kNumSplats], splatColor[kNumSplats], splatSide[kNumSplats];
static MRect splatBlob[kNumSplats];

Expand Down Expand Up @@ -1084,7 +1084,8 @@ void SharewareVictory( void )
MRect bufferSrcRect = { 0, 50, 480, 350 };
MRect bufferDstRect = { 0, 0, 480, 300 };
MPoint dPoint = { 450, 50 }, lPoint, cPoint;
int scroll, ticks, x, y;
int scroll, x, y;
MTicks ticks;
const char* text;
int thisFade;
const char fade[120] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0
Expand Down Expand Up @@ -1215,7 +1216,7 @@ void RegisteredVictory( void )
MPoint bubblePoint, textPoint, shadowPoint;
MPoint setPoint[7][6];
MPoint msgSetPoint[7][2];
int ticks;
MTicks ticks;
int vertScroll, picture, weight, line, minimum;
int scrollDir[] = {1, -1, 1, -1, 1, -1, -1};
int spacing[] = {40, 19, 19, 19, 23, 19, 23 };
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ 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];
int chain[2];
int blobTime[2], startTime, endTime;
MTicks blobTime[2], startTime, endTime;
MBoolean finished = false, pauseKey = false, showStartMenu = true;
signed char grid[2][kGridAcross][kGridDown], suction[2][kGridAcross][kGridDown], charred[2][kGridAcross][kGridDown], glow[2][kGridAcross][kGridDown];
MRect playerWindowZRect, playerWindowRect[2];
Expand Down Expand Up @@ -642,7 +642,7 @@ void QuickFadeIn( MRGBColor *color )
if (fullscreen) {
for( float percent=0.0f; percent<1.0f; percent += 0.04f )
{
int c = MTickCount( );
MTicks c = MTickCount( );
SDLU_SetBrightness( percent );
while( c == MTickCount( ) )
{
Expand All @@ -663,7 +663,7 @@ void QuickFadeOut( MRGBColor *color )
if (fullscreen) {
for( float percent=1.0f; percent>0.0f; percent -= 0.04f )
{
int c = MTickCount( );
MTicks c = MTickCount( );
SDLU_SetBrightness( percent );
while( c == MTickCount( ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ extern 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];
extern int chain[2];
extern int blobTime[2], startTime, endTime;
extern MTicks blobTime[2], startTime, endTime;
extern MBoolean finished, pauseKey, showStartMenu;
extern MBoolean fullscreen, widescreen, crispUpscaling;
extern signed char grid[2][kGridAcross][kGridDown], suction[2][kGridAcross][kGridDown],
Expand Down
3 changes: 2 additions & 1 deletion src/next.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ SDL_Surface* nextDrawSurface;

MRect nextWindowZRect, nextWindowRect[2];
MBoolean nextWindowVisible[2] = {true, true};
int nextTime[2][2], nextStage[2][2], pullA[2], pullB[2];
MTicks nextTime[2][2];
int nextStage[2][2], pullA[2], pullB[2];

void InitNext( void )
{
Expand Down
3 changes: 2 additions & 1 deletion src/opponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ SDL_Surface* opponentDrawSurface;

MRect opponentWindowZRect, opponentWindowRect;
int opponentMood, opponentFrame;
int opponentTime, glowTime[kGlows], glowFrame[kGlows], panicTime, panicFrame;
MTicks opponentTime, glowTime[kGlows], panicTime;
int glowFrame[kGlows], panicFrame;
int heavyGlowArray[kGlowArraySize], glowArray[kGlowArraySize], lightGlowArray[kGlowArraySize];

void InitOpponent( void )
Expand Down
3 changes: 2 additions & 1 deletion src/opponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ enum
#define kGlowArraySize 30

extern int opponentMood, opponentFrame;
extern int opponentTime, glowTime[kGlows], glowFrame[kGlows], panicTime, panicFrame;
extern MTicks opponentTime, glowTime[kGlows], panicTime;
extern int glowFrame[kGlows], panicFrame;
extern int glowArray[kGlowArraySize], lightGlowArray[kGlowArraySize];

extern MRect opponentWindowZRect, opponentWindowRect;
3 changes: 2 additions & 1 deletion src/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ SkittlesFontPtr smallFont, bigFont, dashedLineFont, continueFont, tinyFont, bats
FRGBColor backColor[4];
MBoolean continueTimeOut;

static int dialogType, dialogStage, dialogTimer, dialogTarget, dialogShade, dialogItem;
static int dialogType, dialogStage, dialogTarget, dialogShade, dialogItem;
MTicks dialogTimer;
static float colorWrap = 0, colorInc;
static MRect logoRect = {0, 0, 111, 246}, lastPauseRect;
static MBoolean dialogStageComplete;
Expand Down
3 changes: 2 additions & 1 deletion src/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ SDL_Surface* numberMaskSurface;

MRect scoreWindowZRect, scoreWindowRect[2];
MBoolean scoreWindowVisible[2] = {true, true};
int roundStartScore[2], score[2], displayedScore[2], scoreTime[2];
int roundStartScore[2], score[2], displayedScore[2];
MTicks scoreTime[2];
const char characterList[] =
{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
Expand Down
2 changes: 1 addition & 1 deletion src/tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ SkittlesFontPtr balloonFont;
MPoint balloonPt;
char* balloonChar;
char balloonMsg[256];
int balloonTime, tutorialTime;
MTicks balloonTime, tutorialTime;
SDL_Surface* balloonSurface = NULL;

void InitTutorial( void )
Expand Down
2 changes: 1 addition & 1 deletion src/tutorial.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef struct
AutoPattern, *AutoPatternPtr;

extern AutoPatternPtr autoPattern;
extern int tutorialTime;
extern MTicks tutorialTime;

void InitTutorial( void );
void StartBalloon( const char *message );
Expand Down
2 changes: 1 addition & 1 deletion src/tweak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "graphics.h"
#include "players.h"

int xTweakTime[2], yTweakTime[2], rTweakTime[2];
MTicks xTweakTime[2], yTweakTime[2], rTweakTime[2];
int yTweak[2], xTweak[2], xDirection[2], rTweak[2], rDirection[2];
int lastShadow[2];
int tweakOffsetX[4][11], tweakOffsetY[4][11];
Expand Down
4 changes: 2 additions & 2 deletions src/victory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <stdio.h>
#include <string.h>

unsigned int winTime, loseTime;
MTicks winTime, loseTime;
int winStage, loseStage;
float drop[kGridAcross], last[kGridAcross];
SkittlesFontPtr victoryFont;
Expand Down Expand Up @@ -88,7 +88,7 @@ void BeginVictory( int player )

void Lose( int player )
{
int gameTime = GameTickCount();
MTicks gameTime = GameTickCount();
int skip = 1;
MRect boardRect;

Expand Down

0 comments on commit d919168

Please sign in to comment.