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 // Draw black bars
if (!(g_GameFlags & 8)) // Detect if credits are running 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 // Get focus rect
int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8); int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8);

View file

@ -30,8 +30,8 @@
struct SURFACE struct SURFACE
{ {
bool in_use; BOOL in_use;
bool needs_updating; BOOL needs_updating;
SDL_Surface *surface; SDL_Surface *surface;
SDL_Texture *texture; SDL_Texture *texture;
}; };
@ -43,7 +43,7 @@ RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
int magnification; int magnification;
bool fullscreen; BOOL fullscreen;
SURFACE surf[SURFACE_ID_MAX]; SURFACE surf[SURFACE_ID_MAX];
@ -55,7 +55,7 @@ BOOL Flip_SystemTask(int hWnd)
{ {
(void)hWnd; (void)hWnd;
while (true) while (TRUE)
{ {
if (!SystemTask()) if (!SystemTask())
return FALSE; return FALSE;
@ -102,17 +102,17 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth)
{ {
case 0: case 0:
magnification = 1; magnification = 1;
fullscreen = false; fullscreen = FALSE;
break; break;
case 1: case 1:
magnification = 2; magnification = 2;
fullscreen = false; fullscreen = FALSE;
break; break;
case 2: case 2:
magnification = 2; magnification = 2;
fullscreen = true; fullscreen = TRUE;
SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN); SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN);
break; break;
} }
@ -132,7 +132,7 @@ void EndDirectDraw()
ReleaseSurface(i); ReleaseSurface(i);
} }
static bool IsEnableBitmap(SDL_RWops *fp) static BOOL IsEnableBitmap(SDL_RWops *fp)
{ {
char str[16]; char str[16];
const char *extra_text = "(C)Pixel"; const char *extra_text = "(C)Pixel";
@ -152,7 +152,7 @@ void ReleaseSurface(int s)
{ {
SDL_DestroyTexture(surf[s].texture); SDL_DestroyTexture(surf[s].texture);
SDL_FreeSurface(surf[s].surface); 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 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); 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 else
{ {
surf[surf_no].in_use = true; surf[surf_no].in_use = TRUE;
success = TRUE; success = TRUE;
} }
} }
@ -234,9 +234,9 @@ static void FlushSurface(Surface_Ids surf_no)
SDL_UnlockTexture(surf[surf_no].texture); 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) if (surf_no >= SURFACE_ID_MAX)
{ {
@ -258,15 +258,15 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
} }
else 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) if (magnification == 1)
{ {
SDL_Rect dst_rect = {0, 0, surface->w, surface->h}; SDL_Rect dst_rect = {0, 0, surface->w, surface->h};
SDL_BlitSurface(surface, NULL, surf[surf_no].surface, &dst_rect); 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"); printf(" ^ Successfully loaded\n");
success = true; success = TRUE;
} }
else else
{ {
@ -304,9 +304,9 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
} }
SDL_FreeSurface(converted_surface); SDL_FreeSurface(converted_surface);
surf[surf_no].needs_updating = true; surf[surf_no].needs_updating = TRUE;
printf(" ^ Successfully loaded\n"); 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; 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]; char path[PATH_LENGTH];
SDL_RWops *fp; SDL_RWops *fp;
@ -358,7 +358,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s
return FALSE; 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; size_t size;
const unsigned char *data = FindResource(res, "BITMAP", &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) 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) 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) 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) 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) static SDL_Rect RectToSDLRect(RECT *rect)
@ -434,18 +434,18 @@ void BackupSurface(Surface_Ids surf_no, RECT *rect)
SDL_Rect frameRect = RectToSDLRectScaled(rect); SDL_Rect frameRect = RectToSDLRectScaled(rect);
SDL_BlitSurface(surface, &frameRect, surf[surf_no].surface, &frameRect); SDL_BlitSurface(surface, &frameRect, surf[surf_no].surface, &frameRect);
surf[surf_no].needs_updating = true; surf[surf_no].needs_updating = TRUE;
// Free surface // Free surface
SDL_FreeSurface(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) if (surf[surf_no].needs_updating)
{ {
FlushSurface(surf_no); FlushSurface(surf_no);
surf[surf_no].needs_updating = false; surf[surf_no].needs_updating = FALSE;
} }
// Get SDL_Rects // 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 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 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) 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_Rect frameRect = RectToSDLRectScaled(rect);
SDL_BlitSurface(surf[from].surface, &frameRect, surf[to].surface, &rcSet); 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) 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_green = (unsigned char)((col >> 8) & 0xFF);
const unsigned char col_blue = (unsigned char)((col >> 16) & 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)); 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 #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) 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)); 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() void EndTextObject()

View file

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

View file

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

View file

@ -26,7 +26,7 @@ void ReleaseDirectInput()
} }
} }
bool InitDirectInput() BOOL InitDirectInput()
{ {
// Open first available joystick // Open first available joystick
SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_InitSubSystem(SDL_INIT_JOYSTICK);
@ -40,10 +40,10 @@ bool InitDirectInput()
break; break;
} }
return true; return TRUE;
} }
bool GetJoystickStatus(JOYSTICK_STATUS *pStatus) BOOL GetJoystickStatus(JOYSTICK_STATUS *pStatus)
{ {
// Clear status // Clear status
memset(pStatus, 0, sizeof(JOYSTICK_STATUS)); memset(pStatus, 0, sizeof(JOYSTICK_STATUS));
@ -64,13 +64,13 @@ bool GetJoystickStatus(JOYSTICK_STATUS *pStatus)
for (int button = 0; button < numButtons; button++) for (int button = 0; button < numButtons; button++)
pStatus->bButton[button] = SDL_JoystickGetButton(joystick, button) != 0; 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 #pragma once
extern bool gbUseJoystick; #include "WindowsWrapper.h"
extern BOOL gbUseJoystick;
extern int gJoystickButtonTable[8]; extern int gJoystickButtonTable[8];
struct JOYSTICK_STATUS struct JOYSTICK_STATUS
{ {
bool bLeft; BOOL bLeft;
bool bRight; BOOL bRight;
bool bUp; BOOL bUp;
bool bDown; BOOL bDown;
bool bButton[32]; BOOL bButton[32];
}; };
void ReleaseDirectInput(); void ReleaseDirectInput();
bool InitDirectInput(); BOOL InitDirectInput();
bool GetJoystickStatus(JOYSTICK_STATUS *pStatus); BOOL GetJoystickStatus(JOYSTICK_STATUS *pStatus);
bool ResetJoystickStatus(); BOOL ResetJoystickStatus();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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