diff --git a/.gitignore b/.gitignore index 440e8458..048e86c3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,13 +16,13 @@ msvc2003/devilution/compare.asm # Exclude build output on Linux (exclude normally produced executable files and out files) build_en/CSE2 -build_en/CSE2d +build_en/CSE2_debug build_en/DoConfig -build_en/DoConfigd +build_en/DoConfig_debug build_jp/CSE2 -build_jp/CSE2d +build_jp/CSE2_debug build_jp/DoConfig -build_jp/DoConfigd +build_jp/DoConfig_debug build_en/*.out build_jp/*.out diff --git a/CMakeLists.txt b/CMakeLists.txt index b62868ed..9fb63af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,10 +263,7 @@ elseif(NOT WIN32) endif() # Magic to convert resources to header files -add_executable(bin2h "src/misc/bin2h.c") -if(MSVC) - target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS) # Shut up those stupid warnings -endif() +add_subdirectory("bin2h") foreach(FILENAME IN LISTS RESOURCES) set(IN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res") set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/Resource") @@ -294,10 +291,8 @@ set_target_properties(CSE2 PROPERTIES CXX_EXTENSIONS OFF ) -# Name debug builds "CSE2d", to distinguish them -set_target_properties(CSE2 PROPERTIES - DEBUG_OUTPUT_NAME "CSE2d" -) +# Name debug builds "CSE2_debug", to distinguish them +set_target_properties(CSE2 PROPERTIES DEBUG_OUTPUT_NAME "CSE2_debug") # Send executable to the build_en/build_jp directory set_target_properties(CSE2 PROPERTIES @@ -372,6 +367,9 @@ endif() add_subdirectory("DoConfig") +# Name debug builds "DoConfig_debug", to distinguish them +set_target_properties(DoConfig PROPERTIES DEBUG_OUTPUT_NAME "DoConfig_debug") + # Send executable to the build_en/build_jp directory set_target_properties(DoConfig PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY} diff --git a/DoConfig/CMakeLists.txt b/DoConfig/CMakeLists.txt index 6c1d9776..a2973d94 100644 --- a/DoConfig/CMakeLists.txt +++ b/DoConfig/CMakeLists.txt @@ -10,9 +10,6 @@ project(DoConfig LANGUAGES CXX) add_executable(DoConfig "DoConfig.cpp" "icon.rc") -# Name debug builds "DoConfigd", to distinguish them -set_target_properties(CSE2 PROPERTIES DEBUG_OUTPUT_NAME "DoConfigd") - # Windows tweak if(WIN32) set_target_properties(DoConfig PROPERTIES WIN32_EXECUTABLE YES) # Disable the console window diff --git a/DoConfig/DoConfig.cpp b/DoConfig/DoConfig.cpp index 185ca7b6..d8cae819 100644 --- a/DoConfig/DoConfig.cpp +++ b/DoConfig/DoConfig.cpp @@ -5,14 +5,17 @@ * http://sam.zoy.org/wtfpl/COPYING for more details. */ #include -#include #include -#include #include "FL/Fl.H" #include "FL/Fl_Window.H" #include "FL/Fl_Radio_Round_Button.H" #include "FL/Fl_Choice.H" #include "FL/Fl_Check_Button.H" +#include +#include +#include +#include +#include #define MAGIC "DOUKUTSU20041206" #define FONT "Courier New" diff --git a/Makefile b/Makefile index 6d86c2d4..f03e0e10 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ ifeq ($(RELEASE), 1) FILENAME_DEF = CSE2 else CXXFLAGS = -Og -g3 - FILENAME_DEF = CSE2d + FILENAME_DEF = CSE2_debug endif ifeq ($(JAPANESE), 1) @@ -226,10 +226,10 @@ src/Resource/%.h: res/% obj/bin2h @echo Converting $< @obj/bin2h $< $@ -obj/bin2h: src/misc/bin2h.c +obj/bin2h: bin2h/bin2h.c @mkdir -p $(@D) @echo Compiling $^ - @$(CC) -O3 -s -std=c90 $^ -o $@ + @$(CC) -O3 -s -std=c90 -Wall -Wextra -pedantic $^ -o $@ include $(wildcard $(DEPENDENCIES)) diff --git a/bin2h/CMakeLists.txt b/bin2h/CMakeLists.txt new file mode 100644 index 00000000..f2b1ce9d --- /dev/null +++ b/bin2h/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.7.2) + +if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9)) + cmake_policy(SET CMP0069 NEW) +endif() + +project(bin2h LANGUAGES C) + +add_executable(bin2h "bin2h.c") + +set_target_properties(bin2h PROPERTIES + C_STANDARD 90 + C_STANDARD_REQUIRED ON + C_EXTENSIONS OFF +) + +# MSVC tweak +if(MSVC) + target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS) # Shut up those stupid warnings +endif() + +# Enable link-time optimisation if available +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9)) + include(CheckIPOSupported) + check_ipo_supported(RESULT result) + if(result) + set_target_properties(bin2h PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + endif() +endif() diff --git a/src/misc/bin2h.c b/bin2h/bin2h.c similarity index 81% rename from src/misc/bin2h.c rename to bin2h/bin2h.c index 287d68cb..11c1de1e 100644 --- a/src/misc/bin2h.c +++ b/bin2h/bin2h.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) filename_pointer = (last_path_seperator == NULL) ? argv[1] : last_path_seperator + 1; dot = strchr(filename_pointer, '.'); - filename_length = (dot == NULL) ? strlen(filename_pointer) : dot - filename_pointer; + filename_length = (dot == NULL) ? strlen(filename_pointer) : (size_t)(dot - filename_pointer); filename = malloc(filename_length + 1); memcpy(filename, filename_pointer, filename_length); @@ -65,17 +65,17 @@ int main(int argc, char *argv[]) setvbuf(out_file, NULL, _IOFBF, 0x10000); - fprintf(out_file, "#pragma once\n\nconst unsigned char r%s[0x%lX] = {\n\t", filename, in_file_size); + fprintf(out_file, "#pragma once\n\nstatic const unsigned char r%s[0x%lX] = {\n\t", filename, in_file_size); for (i = 0; i < in_file_size - 1; ++i) { - if (i % 16 == 15) - fprintf(out_file, "0x%02X,\n\t", *in_file_pointer++); + if (i % 32 == 32-1) + fprintf(out_file, "%d,\n\t", *in_file_pointer++); else - fprintf(out_file, "0x%02X, ", *in_file_pointer++); + fprintf(out_file, "%d,", *in_file_pointer++); } - fprintf(out_file, "0x%02X\n};\n", *in_file_pointer++); + fprintf(out_file, "%d\n};\n", *in_file_pointer++); fclose(out_file); free(in_file_buffer); diff --git a/src/Back.cpp b/src/Back.cpp index 37b6e5c9..71832cf4 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -1,9 +1,11 @@ #include "Back.h" +#include #include #include "WindowsWrapper.h" +#include "CommonDefines.h" #include "Draw.h" #include "File.h" #include "Frame.h" @@ -250,7 +252,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); diff --git a/src/BossIronH.cpp b/src/BossIronH.cpp index c76ec3c0..6ad2f238 100644 --- a/src/BossIronH.cpp +++ b/src/BossIronH.cpp @@ -6,6 +6,7 @@ #include "Frame.h" #include "Game.h" #include "MyChar.h" +#include "NpChar.h" #include "Sound.h" void ActBossChar_Ironhead(void) diff --git a/src/BossPress.cpp b/src/BossPress.cpp index 5412b46e..f9b62b6c 100644 --- a/src/BossPress.cpp +++ b/src/BossPress.cpp @@ -5,6 +5,7 @@ #include "Boss.h" #include "Game.h" #include "Map.h" +#include "NpChar.h" #include "Sound.h" void ActBossChar_Press(void) diff --git a/src/BulHit.cpp b/src/BulHit.cpp index df8330a2..91db2033 100644 --- a/src/BulHit.cpp +++ b/src/BulHit.cpp @@ -1,13 +1,9 @@ #include "BulHit.h" -#include -#include - #include "Bullet.h" #include "Caret.h" #include "Game.h" #include "Map.h" -#include "MyChar.h" #include "NpChar.h" #include "Sound.h" diff --git a/src/Config.cpp b/src/Config.cpp index 909948e3..732466be 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -8,7 +8,6 @@ #include "Config.h" #include "File.h" #include "Tags.h" -#include "Types.h" static const char* const config_filename = "Config.dat"; // Not the original name static const char* const config_magic = "DOUKUTSU20041206"; // Not the original name diff --git a/src/Draw.cpp b/src/Draw.cpp index 44c28157..b5834958 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -1,5 +1,8 @@ #include #include +#ifdef WINDOWS +#include +#endif #include #ifdef WINDOWS @@ -23,12 +26,11 @@ #include "Font.h" #include "Resource.h" #include "Tags.h" -#include "Types.h" struct SURFACE { - bool in_use; - bool needs_updating; + BOOL in_use; + BOOL needs_updating; SDL_Surface *surface; SDL_Texture *texture; }; @@ -40,7 +42,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]; @@ -52,7 +54,7 @@ BOOL Flip_SystemTask(int hWnd) { (void)hWnd; - while (true) + while (TRUE) { if (!SystemTask()) return FALSE; @@ -99,17 +101,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; } @@ -129,7 +131,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"; @@ -149,7 +151,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; } } @@ -169,7 +171,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); } @@ -194,7 +196,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; } } @@ -231,9 +233,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) { @@ -255,15 +257,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 { @@ -301,9 +303,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; } } } @@ -318,7 +320,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; @@ -355,7 +357,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); @@ -378,22 +380,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) @@ -431,18 +433,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 @@ -467,12 +469,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) @@ -482,7 +484,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) @@ -514,7 +516,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 @@ -635,7 +637,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() diff --git a/src/Draw.h b/src/Draw.h index 4542f4b9..0ee159e7 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -10,7 +10,7 @@ extern RECT grcGame; extern RECT grcFull; extern int magnification; -extern bool fullscreen; +extern BOOL fullscreen; typedef enum Surface_Ids { diff --git a/src/Ending.h b/src/Ending.h index 4a745ce4..04dea864 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -2,6 +2,8 @@ #include "WindowsWrapper.h" +#include "CommonDefines.h" + struct CREDIT { int size; diff --git a/src/Fade.cpp b/src/Fade.cpp index 403a4e0e..9c5986bc 100644 --- a/src/Fade.cpp +++ b/src/Fade.cpp @@ -6,7 +6,6 @@ #include "WindowsWrapper.h" #include "Draw.h" -#include "Game.h" #define FADE_WIDTH (((WINDOW_WIDTH - 1) / 16) + 1) #define FADE_HEIGHT (((WINDOW_HEIGHT - 1) / 16) + 1) diff --git a/src/Font.cpp b/src/Font.cpp index 915cd499..4ce46010 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -11,6 +10,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 +40,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; diff --git a/src/Frame.cpp b/src/Frame.cpp index f50c17be..be669d89 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -1,7 +1,5 @@ #include "Frame.h" -#include - #include "Boss.h" #include "CommonDefines.h" #include "Game.h" @@ -16,7 +14,7 @@ void MoveFrame3() short map_w, map_l; GetMapData(0, &map_w, &map_l); -#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 // TODO - Really need to make this a compiler flag +#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 // TODO - Really need to make this a compiler flag (also, should probably move this stuff to the enhanced branch) if (g_GameFlags & 8) { // Use the original camera boundaries during the credits @@ -41,7 +39,7 @@ void MoveFrame3() // Widescreen/tallscreen-safe behaviour if (map_w * 0x10 < WINDOW_WIDTH) { - gFrame.x = -((WINDOW_WIDTH - map_w * 0x10) * 0x200 / 2); + gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2); } else { @@ -56,7 +54,7 @@ void MoveFrame3() if (map_l * 0x10 < WINDOW_HEIGHT) { - gFrame.y = -((WINDOW_HEIGHT - map_l * 0x10) * 0x200 / 2); + gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2); } else { @@ -126,15 +124,64 @@ void SetFramePosition(int fx, int fy) gFrame.y = fy; // Keep in bounds +#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 + if (g_GameFlags & 8) + { + // Use the original camera boundaries during the credits + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200; + if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200; + + gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200; + gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200; + } + else + { + // Widescreen/tallscreen-safe behaviour + if (map_w * 0x10 < WINDOW_WIDTH) + { + gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2); + } + else + { + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200; + } + + if (map_l * 0x10 < WINDOW_HEIGHT) + { + gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2); + } + else + { + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200; + } + } +#else + // Vanilla behaviour if (gFrame.x / 0x200 < 0) gFrame.x = 0; if (gFrame.y / 0x200 < 0) gFrame.y = 0; - if (gFrame.x > ((((map_w - 1) * 0x10) - WINDOW_WIDTH)) * 0x200) + if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200) gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200; - if (gFrame.y > ((((map_l - 1) * 0x10) - WINDOW_HEIGHT)) * 0x200) + if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200) gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200; +#endif } void SetFrameMyChar() @@ -150,15 +197,64 @@ void SetFrameMyChar() gFrame.y = mc_y - (WINDOW_HEIGHT << 8); // Keep in bounds +#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 + if (g_GameFlags & 8) + { + // Use the original camera boundaries during the credits + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200; + if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200; + + gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200; + gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200; + } + else + { + // Widescreen/tallscreen-safe behaviour + if (map_w * 0x10 < WINDOW_WIDTH) + { + gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2); + } + else + { + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200; + } + + if (map_l * 0x10 < WINDOW_HEIGHT) + { + gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2); + } + else + { + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200; + } + } +#else + // Vanilla behaviour if (gFrame.x / 0x200 < 0) gFrame.x = 0; if (gFrame.y / 0x200 < 0) gFrame.y = 0; - if (gFrame.x > ((((map_w - 1) * 0x10) - WINDOW_WIDTH)) * 0x200) + if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200) gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200; - if (gFrame.y > ((((map_l - 1) * 0x10) - WINDOW_HEIGHT)) * 0x200) + if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200) gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200; +#endif } void SetFrameTargetMyChar(int wait) diff --git a/src/Game.cpp b/src/Game.cpp index cca03ae1..0c38875d 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,8 +1,7 @@ #include "Game.h" -#include +#include #include -#include #include @@ -15,6 +14,7 @@ #include "BulHit.h" #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Draw.h" #include "Ending.h" #include "Escape.h" @@ -35,7 +35,6 @@ #include "NpChar.h" #include "NpcHit.h" #include "NpcTbl.h" -#include "Organya.h" #include "Profile.h" #include "SelStage.h" #include "Shoot.h" diff --git a/src/Input.cpp b/src/Input.cpp index 0c6e936a..a26e4ef0 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -3,14 +3,10 @@ #include #include -#include +#include "SDL.h" #include "WindowsWrapper.h" -#include "CommonDefines.h" -#include "Tags.h" -#include "Types.h" - #define JOYSTICK_DEADZONE 10000 SDL_Joystick *joystick; // This was probably a name that was given by Simon, but it fits the rest of Pixel's names so it's fine. @@ -26,7 +22,7 @@ void ReleaseDirectInput() } } -bool InitDirectInput() +BOOL InitDirectInput() { // Open first available joystick SDL_InitSubSystem(SDL_INIT_JOYSTICK); @@ -40,10 +36,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 +60,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; } diff --git a/src/Input.h b/src/Input.h index 2e5ff41b..973edecf 100644 --- a/src/Input.h +++ b/src/Input.h @@ -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(); diff --git a/src/Main.cpp b/src/Main.cpp index df5d9921..ec5c9eb7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "SDL.h" #include "WindowsWrapper.h" @@ -21,7 +21,6 @@ #include "Resource.h" #include "Sound.h" #include "Triangle.h" -#include "Types.h" // These two are defined in Draw.cpp. This is a bit of a hack. extern SDL_Window *gWindow; @@ -33,10 +32,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 +67,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 +75,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 +298,7 @@ int main(int argc, char *argv[]) StartDirectDraw(2, colourDepth); - fullscreen = true; + fullscreen = TRUE; SDL_ShowCursor(0); break; } @@ -313,7 +312,7 @@ int main(int argc, char *argv[]) { // Check debug things if (CheckFileExists("fps")) - bFps = true; + bFps = TRUE; #ifndef WINDOWS // Load icon @@ -359,7 +358,7 @@ int main(int argc, char *argv[]) if (config.bJoystick && InitDirectInput()) { ResetJoystickStatus(); - gbUseJoystick = true; + gbUseJoystick = TRUE; } // Initialize stuff @@ -390,7 +389,7 @@ void InactiveWindow() { if (bActive) { - bActive = false; + bActive = FALSE; StopOrganyaMusic(); SleepNoise(); } @@ -402,7 +401,7 @@ void ActiveWindow() { if (!bActive) { - bActive = true; + bActive = TRUE; StopOrganyaMusic(); PlayOrganyaMusic(); ResetNoise(); @@ -446,10 +445,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 +458,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 +551,7 @@ bool SystemTask() DO_KEY_PRESS(KEY_PLUS) case SDL_SCANCODE_F5: - gbUseJoystick = false; + gbUseJoystick = FALSE; break; default: @@ -621,7 +620,7 @@ bool SystemTask() DO_KEY_PRESS(KEY_PLUS) case SDLK_F5: - gbUseJoystick = false; + gbUseJoystick = FALSE; break; } break; @@ -633,5 +632,5 @@ bool SystemTask() if (gbUseJoystick) JoystickProc(); - return true; + return TRUE; } diff --git a/src/Map.cpp b/src/Map.cpp index 94bec202..25decba2 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -1,6 +1,7 @@ #include "Map.h" #include +#include #include #include diff --git a/src/MiniMap.cpp b/src/MiniMap.cpp index f444580b..ce3f4ea1 100644 --- a/src/MiniMap.cpp +++ b/src/MiniMap.cpp @@ -7,7 +7,6 @@ #include "CommonDefines.h" #include "Draw.h" #include "Escape.h" -#include "Game.h" #include "KeyControl.h" #include "Main.h" #include "Map.h" diff --git a/src/MycParam.cpp b/src/MycParam.cpp index 62527be8..ede5fcdb 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -1,5 +1,7 @@ #include "MycParam.h" +#include + #include "SDL.h" #include "WindowsWrapper.h" diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index 84156504..f7bc6f6d 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "Game.h" #include "Frame.h" diff --git a/src/NpcAct040.cpp b/src/NpcAct040.cpp index b9002563..dad7b9ef 100644 --- a/src/NpcAct040.cpp +++ b/src/NpcAct040.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "CommonDefines.h" #include "Game.h" diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index b57049c3..8c4589a4 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -2,8 +2,8 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "CommonDefines.h" +#include "Draw.h" #include "Flash.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index ce481c4c..12203beb 100644 --- a/src/NpcAct100.cpp +++ b/src/NpcAct100.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" @@ -10,7 +9,6 @@ #include "MyChar.h" #include "NpChar.h" #include "Sound.h" -#include "Triangle.h" // Grate void ActNpc100(NPCHAR *npc) diff --git a/src/NpcAct120.cpp b/src/NpcAct120.cpp index 2e0ba946..8a419708 100644 --- a/src/NpcAct120.cpp +++ b/src/NpcAct120.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" diff --git a/src/NpcAct140.cpp b/src/NpcAct140.cpp index a2c78e43..afb1cf92 100644 --- a/src/NpcAct140.cpp +++ b/src/NpcAct140.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "CommonDefines.h" diff --git a/src/NpcAct160.cpp b/src/NpcAct160.cpp index f723aec4..83cb51a3 100644 --- a/src/NpcAct160.cpp +++ b/src/NpcAct160.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "CommonDefines.h" #include "Frame.h" diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 80db74aa..a458b70e 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" diff --git a/src/NpcAct220.cpp b/src/NpcAct220.cpp index b177be2d..f099dc43 100644 --- a/src/NpcAct220.cpp +++ b/src/NpcAct220.cpp @@ -2,10 +2,7 @@ #include "WindowsWrapper.h" -#include "Back.h" -#include "Bullet.h" #include "Caret.h" -#include "Frame.h" #include "Game.h" #include "MyChar.h" #include "NpChar.h" diff --git a/src/NpcAct240.cpp b/src/NpcAct240.cpp index e9f94375..98567704 100644 --- a/src/NpcAct240.cpp +++ b/src/NpcAct240.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct260.cpp b/src/NpcAct260.cpp index f27f0188..eeaa4000 100644 --- a/src/NpcAct260.cpp +++ b/src/NpcAct260.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct280.cpp b/src/NpcAct280.cpp index 791061b5..296dd084 100644 --- a/src/NpcAct280.cpp +++ b/src/NpcAct280.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Boss.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct300.cpp b/src/NpcAct300.cpp index 0427951d..095e2a86 100644 --- a/src/NpcAct300.cpp +++ b/src/NpcAct300.cpp @@ -4,7 +4,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Boss.h" #include "Bullet.h" #include "Caret.h" diff --git a/src/NpcAct320.cpp b/src/NpcAct320.cpp index 17b4d610..f2b3877d 100644 --- a/src/NpcAct320.cpp +++ b/src/NpcAct320.cpp @@ -1,8 +1,9 @@ #include "NpcAct.h" +#include + #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" @@ -12,7 +13,6 @@ #include "MyChar.h" #include "NpChar.h" #include "Sound.h" -#include "Triangle.h" // Curly (carried, shooting) void ActNpc320(NPCHAR *npc) diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp index 6b1ad3f2..d40b3e4c 100644 --- a/src/NpcAct340.cpp +++ b/src/NpcAct340.cpp @@ -2,9 +2,9 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "CommonDefines.h" +#include "Draw.h" #include "Flash.h" #include "Flags.h" #include "Frame.h" diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index 9f9409a3..a6c64440 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "WindowsWrapper.h" diff --git a/src/NpcTbl.h b/src/NpcTbl.h index 121cc711..b61455a9 100644 --- a/src/NpcTbl.h +++ b/src/NpcTbl.h @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Draw.h" #include "NpChar.h" struct NPC_TBL_RECT diff --git a/src/Organya.cpp b/src/Organya.cpp index a57aa12e..6b885b04 100644 --- a/src/Organya.cpp +++ b/src/Organya.cpp @@ -4,16 +4,12 @@ #include #include -#include -#include -#include +#include "SDL.h" #include "WindowsWrapper.h" -#include "CommonDefines.h" #include "Resource.h" #include "Sound.h" -#include "Tags.h" #define PANDUMMY 0xFF #define VOLDUMMY 0xFF @@ -30,9 +26,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 +47,7 @@ bool OrganyaNoteAlloc(unsigned short alloc) } } - return false; + return FALSE; } for(int i = 0; i < alloc; i++) @@ -72,7 +68,7 @@ bool OrganyaNoteAlloc(unsigned short alloc) //this->track = 0; - return true; + return FALSE; } void OrganyaReleaseNote() @@ -109,7 +105,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 +146,7 @@ bool MakeSoundObject8(signed char *wavep, signed char track, signed char pipi) } } - return true; + return TRUE; } //Playing melody tracks @@ -272,17 +268,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 +521,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 +542,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 +569,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 +583,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 +611,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; } diff --git a/src/Organya.h b/src/Organya.h index 75b53d3a..78fdc55d 100644 --- a/src/Organya.h +++ b/src/Organya.h @@ -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); diff --git a/src/PixTone.cpp b/src/PixTone.cpp index 02b3da2a..760a3c13 100644 --- a/src/PixTone.cpp +++ b/src/PixTone.cpp @@ -1,7 +1,6 @@ #include "PixTone.h" #include -#include #include #include "WindowsWrapper.h" diff --git a/src/SelStage.cpp b/src/SelStage.cpp index 1664e6eb..aa4d3a02 100644 --- a/src/SelStage.cpp +++ b/src/SelStage.cpp @@ -4,6 +4,7 @@ #include "WindowsWrapper.h" +#include "CommonDefines.h" #include "Draw.h" #include "Escape.h" #include "KeyControl.h" diff --git a/src/Shoot.cpp b/src/Shoot.cpp index 8955e670..c2babebf 100644 --- a/src/Shoot.cpp +++ b/src/Shoot.cpp @@ -1,5 +1,7 @@ #include "Shoot.h" +#include "WindowsWrapper.h" + #include "ArmsItem.h" #include "Bullet.h" #include "Caret.h" diff --git a/src/Sound.cpp b/src/Sound.cpp index 9d2e6526..2be03cb0 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -1,12 +1,13 @@ #include "Sound.h" -#include -#include +#include #include -#include -#include +#include +#include -#include +#include "SDL.h" + +#include "WindowsWrapper.h" #include "Organya.h" #include "PixTone.h" @@ -14,9 +15,9 @@ #define FREQUENCY 44100 #ifdef RASPBERRY_PI -#define STREAM_SIZE 0x400 +#define STREAM_SIZE 0x400 // Larger buffer to prevent stutter #else -#define STREAM_SIZE (FREQUENCY / 200) +#define STREAM_SIZE 0x100 // FREQUENCY/200 rounded to the nearest power of 2 (SDL2 *needs* a power-of-2 buffer size) #endif #define clamp(x, y, z) (((x) > (z)) ? (z) : ((x) < (y)) ? (y) : (x)) @@ -219,7 +220,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 +241,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 +249,7 @@ bool InitDirectSound() //Start organya StartOrganya(); - return true; + return TRUE; } void EndDirectSound() diff --git a/src/Sound.h b/src/Sound.h index 3eeb732d..8803644c 100644 --- a/src/Sound.h +++ b/src/Sound.h @@ -2,6 +2,8 @@ #include +#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); diff --git a/src/Stage.cpp b/src/Stage.cpp index c8424bb6..744026ff 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -18,7 +18,6 @@ #include "MyChar.h" #include "NpChar.h" #include "Organya.h" -#include "Tags.h" #include "TextScr.h" #include "ValueView.h" diff --git a/src/ValueView.cpp b/src/ValueView.cpp index 41ea45e9..bb629f6c 100644 --- a/src/ValueView.cpp +++ b/src/ValueView.cpp @@ -3,7 +3,6 @@ #include "WindowsWrapper.h" #include "Draw.h" -#include "Game.h" #include "ValueView.h" #define VALUEVIEW_MAX 0x10 diff --git a/src/WindowsWrapper.h b/src/WindowsWrapper.h index 09ee401c..8feb6218 100644 --- a/src/WindowsWrapper.h +++ b/src/WindowsWrapper.h @@ -35,4 +35,4 @@ struct RECT int bottom; }; -bool SystemTask(); +BOOL SystemTask();