Weeded out some bool usage

Cave Story was written in C89. No bools. I've left in Sound.cpp's
though, since that's written in C++98 currently.
This commit is contained in:
Clownacy 2019-05-24 10:07:30 +01:00
parent 5933a1201e
commit d2b5872c95
12 changed files with 107 additions and 97 deletions

View file

@ -250,7 +250,7 @@ void PutFront(int fx, int fy)
// Draw black bars
if (!(g_GameFlags & 8)) // Detect if credits are running
{
const bool fromFocus = (gStageNo == 31); // Get if we should only draw around a 320x240 area of the focus point
const BOOL fromFocus = (gStageNo == 31); // Get if we should only draw around a 320x240 area of the focus point
// Get focus rect
int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8);

View file

@ -30,8 +30,8 @@
struct SURFACE
{
bool in_use;
bool needs_updating;
BOOL in_use;
BOOL needs_updating;
SDL_Surface *surface;
SDL_Texture *texture;
};
@ -43,7 +43,7 @@ RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
int magnification;
bool fullscreen;
BOOL fullscreen;
SURFACE surf[SURFACE_ID_MAX];
@ -55,7 +55,7 @@ BOOL Flip_SystemTask(int hWnd)
{
(void)hWnd;
while (true)
while (TRUE)
{
if (!SystemTask())
return FALSE;
@ -102,17 +102,17 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth)
{
case 0:
magnification = 1;
fullscreen = false;
fullscreen = FALSE;
break;
case 1:
magnification = 2;
fullscreen = false;
fullscreen = FALSE;
break;
case 2:
magnification = 2;
fullscreen = true;
fullscreen = TRUE;
SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN);
break;
}
@ -132,7 +132,7 @@ void EndDirectDraw()
ReleaseSurface(i);
}
static bool IsEnableBitmap(SDL_RWops *fp)
static BOOL IsEnableBitmap(SDL_RWops *fp)
{
char str[16];
const char *extra_text = "(C)Pixel";
@ -152,7 +152,7 @@ void ReleaseSurface(int s)
{
SDL_DestroyTexture(surf[s].texture);
SDL_FreeSurface(surf[s].surface);
surf[s].in_use = false;
surf[s].in_use = FALSE;
}
}
@ -172,7 +172,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no, BOOL bSyst
}
else
{
if (surf[surf_no].in_use == true)
if (surf[surf_no].in_use == TRUE)
{
printf("Tried to create drawable surface at occupied slot (%d)\n", surf_no);
}
@ -197,7 +197,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no, BOOL bSyst
}
else
{
surf[surf_no].in_use = true;
surf[surf_no].in_use = TRUE;
success = TRUE;
}
}
@ -234,9 +234,9 @@ static void FlushSurface(Surface_Ids surf_no)
SDL_UnlockTexture(surf[surf_no].texture);
}
static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
static BOOL LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, BOOL create_surface)
{
bool success = false;
BOOL success = FALSE;
if (surf_no >= SURFACE_ID_MAX)
{
@ -258,15 +258,15 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
}
else
{
if (create_surface == false || MakeSurface_Generic(surface->w, surface->h, surf_no, FALSE))
if (create_surface == FALSE || MakeSurface_Generic(surface->w, surface->h, surf_no, FALSE))
{
if (magnification == 1)
{
SDL_Rect dst_rect = {0, 0, surface->w, surface->h};
SDL_BlitSurface(surface, NULL, surf[surf_no].surface, &dst_rect);
surf[surf_no].needs_updating = true;
surf[surf_no].needs_updating = TRUE;
printf(" ^ Successfully loaded\n");
success = true;
success = TRUE;
}
else
{
@ -304,9 +304,9 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
}
SDL_FreeSurface(converted_surface);
surf[surf_no].needs_updating = true;
surf[surf_no].needs_updating = TRUE;
printf(" ^ Successfully loaded\n");
success = true;
success = TRUE;
}
}
}
@ -321,7 +321,7 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
return success;
}
static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_surface)
static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, BOOL create_surface)
{
char path[PATH_LENGTH];
SDL_RWops *fp;
@ -358,7 +358,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s
return FALSE;
}
static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool create_surface)
static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, BOOL create_surface)
{
size_t size;
const unsigned char *data = FindResource(res, "BITMAP", &size);
@ -381,22 +381,22 @@ static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat
BOOL MakeSurface_File(const char *name, Surface_Ids surf_no)
{
return LoadBitmap_File(name, surf_no, true);
return LoadBitmap_File(name, surf_no, TRUE);
}
BOOL MakeSurface_Resource(const char *res, Surface_Ids surf_no)
{
return LoadBitmap_Resource(res, surf_no, true);
return LoadBitmap_Resource(res, surf_no, TRUE);
}
BOOL ReloadBitmap_File(const char *name, Surface_Ids surf_no)
{
return LoadBitmap_File(name, surf_no, false);
return LoadBitmap_File(name, surf_no, FALSE);
}
BOOL ReloadBitmap_Resource(const char *res, Surface_Ids surf_no)
{
return LoadBitmap_Resource(res, surf_no, false);
return LoadBitmap_Resource(res, surf_no, FALSE);
}
static SDL_Rect RectToSDLRect(RECT *rect)
@ -434,18 +434,18 @@ void BackupSurface(Surface_Ids surf_no, RECT *rect)
SDL_Rect frameRect = RectToSDLRectScaled(rect);
SDL_BlitSurface(surface, &frameRect, surf[surf_no].surface, &frameRect);
surf[surf_no].needs_updating = true;
surf[surf_no].needs_updating = TRUE;
// Free surface
SDL_FreeSurface(surface);
}
static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, bool transparent)
static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, BOOL transparent)
{
if (surf[surf_no].needs_updating)
{
FlushSurface(surf_no);
surf[surf_no].needs_updating = false;
surf[surf_no].needs_updating = FALSE;
}
// Get SDL_Rects
@ -470,12 +470,12 @@ static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // Transparency
{
DrawBitmap(rcView, x, y, rect, surf_no, true);
DrawBitmap(rcView, x, y, rect, surf_no, TRUE);
}
void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // No Transparency
{
DrawBitmap(rcView, x, y, rect, surf_no, false);
DrawBitmap(rcView, x, y, rect, surf_no, FALSE);
}
void Surface2Surface(int x, int y, RECT *rect, int to, int from)
@ -485,7 +485,7 @@ void Surface2Surface(int x, int y, RECT *rect, int to, int from)
SDL_Rect frameRect = RectToSDLRectScaled(rect);
SDL_BlitSurface(surf[from].surface, &frameRect, surf[to].surface, &rcSet);
surf[to].needs_updating = true;
surf[to].needs_updating = TRUE;
}
unsigned long GetCortBoxColor(unsigned long col)
@ -517,7 +517,7 @@ void CortBox2(RECT *rect, unsigned long col, Surface_Ids surf_no)
const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF);
SDL_FillRect(surf[surf_no].surface, &destRect, SDL_MapRGB(surf[surf_no].surface->format, col_red, col_green, col_blue));
surf[surf_no].needs_updating = true;
surf[surf_no].needs_updating = TRUE;
}
#ifdef WINDOWS
@ -638,7 +638,7 @@ void PutText(int x, int y, const char *text, unsigned long color)
void PutText2(int x, int y, const char *text, unsigned long color, Surface_Ids surf_no)
{
DrawText(gFont, (unsigned char*)surf[surf_no].surface->pixels, surf[surf_no].surface->pitch, surf[surf_no].surface->w, surf[surf_no].surface->h, x * magnification, y * magnification, color, text, strlen(text));
surf[surf_no].needs_updating = true;
surf[surf_no].needs_updating = TRUE;
}
void EndTextObject()

View file

@ -10,7 +10,7 @@ extern RECT grcGame;
extern RECT grcFull;
extern int magnification;
extern bool fullscreen;
extern BOOL fullscreen;
typedef enum Surface_Ids
{

View file

@ -11,6 +11,8 @@
#include FT_LCD_FILTER_H
#include FT_BITMAP_H
#include "WindowsWrapper.h"
#include "File.h"
// Uncomment for that authentic pre-Windows Vista feel
@ -39,7 +41,7 @@ typedef struct FontObject
FT_Face face;
unsigned char *data;
#ifndef DISABLE_FONT_ANTIALIASING
bool lcd_mode;
BOOL lcd_mode;
#endif
CachedGlyph *glyph_list_head;
} FontObject;

View file

@ -26,7 +26,7 @@ void ReleaseDirectInput()
}
}
bool InitDirectInput()
BOOL InitDirectInput()
{
// Open first available joystick
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
@ -40,10 +40,10 @@ bool InitDirectInput()
break;
}
return true;
return TRUE;
}
bool GetJoystickStatus(JOYSTICK_STATUS *pStatus)
BOOL GetJoystickStatus(JOYSTICK_STATUS *pStatus)
{
// Clear status
memset(pStatus, 0, sizeof(JOYSTICK_STATUS));
@ -64,13 +64,13 @@ bool GetJoystickStatus(JOYSTICK_STATUS *pStatus)
for (int button = 0; button < numButtons; button++)
pStatus->bButton[button] = SDL_JoystickGetButton(joystick, button) != 0;
return true;
return TRUE;
}
return false;
return FALSE;
}
bool ResetJoystickStatus()
BOOL ResetJoystickStatus()
{
return true;
return TRUE;
}

View file

@ -1,18 +1,20 @@
#pragma once
extern bool gbUseJoystick;
#include "WindowsWrapper.h"
extern BOOL gbUseJoystick;
extern int gJoystickButtonTable[8];
struct JOYSTICK_STATUS
{
bool bLeft;
bool bRight;
bool bUp;
bool bDown;
bool bButton[32];
BOOL bLeft;
BOOL bRight;
BOOL bUp;
BOOL bDown;
BOOL bButton[32];
};
void ReleaseDirectInput();
bool InitDirectInput();
bool GetJoystickStatus(JOYSTICK_STATUS *pStatus);
bool ResetJoystickStatus();
BOOL InitDirectInput();
BOOL GetJoystickStatus(JOYSTICK_STATUS *pStatus);
BOOL ResetJoystickStatus();

View file

@ -33,10 +33,10 @@ char gDataPath[PATH_LENGTH];
int gJoystickButtonTable[8];
int ghWnd; // Placeholder until we restore the WinAPI code
bool gbUseJoystick = false;
bool bFps = false;
BOOL gbUseJoystick = FALSE;
BOOL bFps = FALSE;
bool bActive = true;
BOOL bActive = TRUE;
#ifdef JAPANESE
const char *lpWindowName = "洞窟物語エンジン2";
@ -68,7 +68,7 @@ void PutFramePerSecound()
int GetFramePerSecound()
{
unsigned int current_tick;
static bool need_new_base_tick = true;
static BOOL need_new_base_tick = TRUE;
static int frames_this_second;
static int current_frame;
static int base_tick;
@ -76,7 +76,7 @@ int GetFramePerSecound()
if (need_new_base_tick)
{
base_tick = SDL_GetTicks();
need_new_base_tick = false;
need_new_base_tick = FALSE;
}
current_tick = SDL_GetTicks();
@ -299,7 +299,7 @@ int main(int argc, char *argv[])
StartDirectDraw(2, colourDepth);
fullscreen = true;
fullscreen = TRUE;
SDL_ShowCursor(0);
break;
}
@ -313,7 +313,7 @@ int main(int argc, char *argv[])
{
// Check debug things
if (CheckFileExists("fps"))
bFps = true;
bFps = TRUE;
#ifndef WINDOWS
// Load icon
@ -359,7 +359,7 @@ int main(int argc, char *argv[])
if (config.bJoystick && InitDirectInput())
{
ResetJoystickStatus();
gbUseJoystick = true;
gbUseJoystick = TRUE;
}
// Initialize stuff
@ -390,7 +390,7 @@ void InactiveWindow()
{
if (bActive)
{
bActive = false;
bActive = FALSE;
StopOrganyaMusic();
SleepNoise();
}
@ -402,7 +402,7 @@ void ActiveWindow()
{
if (!bActive)
{
bActive = true;
bActive = TRUE;
StopOrganyaMusic();
PlayOrganyaMusic();
ResetNoise();
@ -446,10 +446,10 @@ void JoystickProc()
gKey &= ~key; \
break;
bool SystemTask()
BOOL SystemTask()
{
// Handle window events
bool focusGained = true;
BOOL focusGained = TRUE;
while (SDL_PollEvent(NULL) || !focusGained)
{
@ -459,19 +459,19 @@ bool SystemTask()
switch (event.type)
{
case SDL_QUIT:
return false;
return FALSE;
break;
case SDL_WINDOWEVENT:
switch (event.window.event)
{
case SDL_WINDOWEVENT_FOCUS_GAINED:
focusGained = true;
focusGained = TRUE;
ActiveWindow();
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
focusGained = false;
focusGained = FALSE;
InactiveWindow();
break;
@ -552,7 +552,7 @@ bool SystemTask()
DO_KEY_PRESS(KEY_PLUS)
case SDL_SCANCODE_F5:
gbUseJoystick = false;
gbUseJoystick = FALSE;
break;
default:
@ -621,7 +621,7 @@ bool SystemTask()
DO_KEY_PRESS(KEY_PLUS)
case SDLK_F5:
gbUseJoystick = false;
gbUseJoystick = FALSE;
break;
}
break;
@ -633,5 +633,5 @@ bool SystemTask()
if (gbUseJoystick)
JoystickProc();
return true;
return TRUE;
}

View file

@ -30,9 +30,9 @@ MUSICINFO info;
int gTrackVol[MAXTRACK];
int gOrgVolume = 100;
bool bFadeout = false;
BOOL bFadeout = FALSE;
bool OrganyaNoteAlloc(unsigned short alloc)
BOOL OrganyaNoteAlloc(unsigned short alloc)
{
for(int j = 0; j < MAXTRACK; j++)
{
@ -51,7 +51,7 @@ bool OrganyaNoteAlloc(unsigned short alloc)
}
}
return false;
return FALSE;
}
for(int i = 0; i < alloc; i++)
@ -72,7 +72,7 @@ bool OrganyaNoteAlloc(unsigned short alloc)
//this->track = 0;
return true;
return FALSE;
}
void OrganyaReleaseNote()
@ -109,7 +109,7 @@ OCTWAVE oct_wave[8] = {
{ 8,128, 32 }, //7 Oct
};
bool MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
{
for (int j = 0; j < 8; j++)
{
@ -150,7 +150,7 @@ bool MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
}
}
return true;
return TRUE;
}
//Playing melody tracks
@ -272,17 +272,17 @@ BOOL InitWaveData100()
}
//Create org wave
bool MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi)
BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi)
{
if(wave_no > 99)
{
printf("WARNING: track %d has out-of-range wave_no %d\n", track, wave_no);
return false;
return FALSE;
}
ReleaseOrganyaObject(track);
MakeSoundObject8(wave_data[wave_no], track, pipi);
return true;
return TRUE;
}
//Dram
@ -525,14 +525,14 @@ void LoadOrganya(const char *name)
SetPlayPointer(0);
//Set as loaded
info.loaded = true;
info.loaded = TRUE;
}
void SetOrganyaPosition(unsigned int x)
{
SetPlayPointer(x);
gOrgVolume = 100;
bFadeout = false;
bFadeout = FALSE;
}
unsigned int GetOrganyaPosition()
@ -546,15 +546,15 @@ void PlayOrganyaMusic()
OrganyaStartTimer(info.wait);
}
bool ChangeOrganyaVolume(signed int volume)
BOOL ChangeOrganyaVolume(signed int volume)
{
if (volume >= 0 && volume <= 100)
{
gOrgVolume = volume;
return true;
return TRUE;
}
return false;
return FALSE;
}
void StopOrganyaMusic()
@ -573,12 +573,12 @@ void StopOrganyaMusic()
void SetOrganyaFadeout()
{
bFadeout = true;
bFadeout = TRUE;
}
//Org timer
SDL_Thread *OrganyaTimer = NULL;
bool bEndTimer = false;
BOOL bEndTimer = FALSE;
int OrganyaPlayTimer(void *ptr)
{
@ -587,7 +587,7 @@ int OrganyaPlayTimer(void *ptr)
//Set time for next step to play
Uint32 NextTick = SDL_GetTicks() + info.wait;
while (bEndTimer == false)
while (bEndTimer == FALSE)
{
if (info.loaded)
{
@ -615,13 +615,13 @@ int OrganyaPlayTimer(void *ptr)
void OrganyaStartTimer(unsigned int wait)
{
OrganyaEndTimer();
bEndTimer = false;
bEndTimer = FALSE;
OrganyaTimer = SDL_CreateThread(OrganyaPlayTimer, "OrganyaPlayTimer", (void*)NULL);
}
void OrganyaEndTimer()
{
bEndTimer = true; //Tell thread to end
bEndTimer = TRUE; //Tell thread to end
SDL_WaitThread(OrganyaTimer, NULL); //Wait for thread to end
OrganyaTimer = NULL;
}

View file

@ -1,5 +1,7 @@
#pragma once
#include "WindowsWrapper.h"
//Below are Organya song data structures
struct NOTELIST {
NOTELIST *from; //Previous address
@ -26,8 +28,8 @@ struct TRACKDATA {
//Unique information held in songs
struct MUSICINFO {
unsigned short wait;
bool loaded;
bool playing;
BOOL loaded;
BOOL playing;
unsigned char line; //Number of lines in one measure
unsigned char dot; //Number of dots per line
unsigned short alloc_note; //Number of allocated notes
@ -36,14 +38,14 @@ struct MUSICINFO {
TRACKDATA tdata[16];
};
bool MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi);
BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi);
void OrganyaPlayData();
void SetPlayPointer(long x);
void LoadOrganya(const char *name);
void SetOrganyaPosition(unsigned int x);
unsigned int GetOrganyaPosition();
void PlayOrganyaMusic();
bool ChangeOrganyaVolume(signed int volume);
BOOL ChangeOrganyaVolume(signed int volume);
void StopOrganyaMusic();
void SetOrganyaFadeout();
void OrganyaStartTimer(unsigned int wait);

View file

@ -8,6 +8,8 @@
#include <SDL.h>
#include "WindowsWrapper.h"
#include "Organya.h"
#include "PixTone.h"
@ -219,7 +221,7 @@ void AudioCallback(void *userdata, Uint8 *stream, int len)
//Sound things
SOUNDBUFFER* lpSECONDARYBUFFER[SOUND_NO];
bool InitDirectSound()
BOOL InitDirectSound()
{
//Init sound
SDL_InitSubSystem(SDL_INIT_AUDIO);
@ -240,7 +242,7 @@ bool InitDirectSound()
if (audioDevice == 0)
{
printf("Failed to open audio device\nSDL Error: %s\n", SDL_GetError());
return false;
return FALSE;
}
//Unpause audio device
@ -248,7 +250,7 @@ bool InitDirectSound()
//Start organya
StartOrganya();
return true;
return TRUE;
}
void EndDirectSound()

View file

@ -2,6 +2,8 @@
#include <stddef.h>
#include "WindowsWrapper.h"
#include "PixTone.h"
class SOUNDBUFFER
@ -91,7 +93,7 @@ enum MUSIC_IDS
#define SOUND_NO 0x100
extern SOUNDBUFFER* lpSECONDARYBUFFER[SOUND_NO];
bool InitDirectSound();
BOOL InitDirectSound();
void EndDirectSound();
void PlaySoundObject(int no, int mode);
void ChangeSoundFrequency(int no, unsigned long rate);

View file

@ -35,4 +35,4 @@ struct RECT
int bottom;
};
bool SystemTask();
BOOL SystemTask();