From 3b395c26396ddd225c465fc8cc9c590dc833fbb7 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 14 Feb 2019 06:47:15 +0000 Subject: [PATCH 01/22] Draw.cpp fix and optimisations For whatever reason, alpha blending is enabled by default on surfaces. Disabling it should result in faster blits, and also follow DirectDraw's behaviour more closely. --- src/Draw.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index 6917b752..016b4a7b 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -155,6 +155,7 @@ bool MakeSurface_Generic(int bxsize, int bysize, int surf_no) { //Create surface surf[surf_no].surface = SDL_CreateRGBSurfaceWithFormat(0, bxsize * magnification, bysize * magnification, 0, SDL_PIXELFORMAT_RGBA32); + SDL_SetSurfaceBlendMode(surf[surf_no].surface, SDL_BLENDMODE_NONE); if (surf[surf_no].surface == NULL) { @@ -224,7 +225,7 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface) } else { - SDL_Surface *surface = SDL_LoadBMP_RW(fp, 1); + SDL_Surface *surface = SDL_LoadBMP_RW(fp, 0); if (surface == NULL) { @@ -238,7 +239,6 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface) { SDL_Rect dst_rect = {0, 0, surface->w, surface->h}; SDL_BlitSurface(surface, NULL, surf[surf_no].surface, &dst_rect); - SDL_FreeSurface(surface); surf[surf_no].needs_updating = true; printf(" ^ Successfully loaded\n"); success = true; @@ -287,6 +287,8 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface) } } + fp->close(fp); + return success; } @@ -379,6 +381,7 @@ void BackupSurface(int surf_no, RECT *rect) //Get texture of what's currently rendered on screen SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, SDL_PIXELFORMAT_RGBA32); + SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); SDL_RenderReadPixels(gRenderer, NULL, SDL_PIXELFORMAT_RGBA32, surface->pixels, surface->pitch); //Get rects From 8942c6cc481582905bade27799dd2abe330ee34e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 14 Feb 2019 15:42:50 +0000 Subject: [PATCH 02/22] Gave the music file extensions --- Makefile | 84 +++++++++--------- res/ORG/{ACCESS => ACCESS.org} | Bin res/ORG/{ANZEN => ANZEN.org} | Bin res/ORG/{BALCONY => BALCONY.org} | Bin res/ORG/{BALLOS => BALLOS.org} | Bin res/ORG/{BDOWN => BDOWN.org} | Bin res/ORG/{CEMETERY => CEMETERY.org} | Bin res/ORG/{CURLY => CURLY.org} | Bin res/ORG/{DR => DR.org} | Bin res/ORG/{ENDING => ENDING.org} | Bin res/ORG/{ESCAPE => ESCAPE.org} | Bin res/ORG/{FANFALE1 => FANFALE1.org} | Bin res/ORG/{FANFALE2 => FANFALE2.org} | Bin res/ORG/{FANFALE3 => FANFALE3.org} | Bin res/ORG/{FIREEYE => FIREEYE.org} | Bin res/ORG/{GAMEOVER => GAMEOVER.org} | Bin res/ORG/{GINSUKE => GINSUKE.org} | Bin res/ORG/{GRAND => GRAND.org} | Bin res/ORG/{GRAVITY => GRAVITY.org} | Bin res/ORG/{HELL => HELL.org} | Bin res/ORG/{IRONH => IRONH.org} | Bin res/ORG/{JENKA => JENKA.org} | Bin res/ORG/{JENKA2 => JENKA2.org} | Bin res/ORG/{KODOU => KODOU.org} | Bin res/ORG/{LASTBT3 => LASTBT3.org} | Bin res/ORG/{LASTBTL => LASTBTL.org} | Bin res/ORG/{LASTCAVE => LASTCAVE.org} | Bin res/ORG/{MARINE => MARINE.org} | Bin res/ORG/{MAZE => MAZE.org} | Bin res/ORG/{MDOWN2 => MDOWN2.org} | Bin res/ORG/{MURA => MURA.org} | Bin res/ORG/{OSIDE => OSIDE.org} | Bin res/ORG/{PLANT => PLANT.org} | Bin res/ORG/{QUIET => QUIET.org} | Bin res/ORG/{REQUIEM => REQUIEM.org} | Bin res/ORG/{TOROKO => TOROKO.org} | Bin res/ORG/{VIVI => VIVI.org} | Bin res/ORG/{WANPAK2 => WANPAK2.org} | Bin res/ORG/{WANPAKU => WANPAKU.org} | Bin res/ORG/{WEED => WEED.org} | Bin res/ORG/{WHITE => WHITE.org} | Bin res/ORG/{XXXX => XXXX.org} | Bin res/ORG/{ZONBIE => ZONBIE.org} | Bin src/Resource.cpp | 84 +++++++++--------- src/Resource/ORG/{ACCESS.h => ACCESS.org.h} | 0 src/Resource/ORG/{ANZEN.h => ANZEN.org.h} | 0 src/Resource/ORG/{BALCONY.h => BALCONY.org.h} | 0 src/Resource/ORG/{BALLOS.h => BALLOS.org.h} | 0 src/Resource/ORG/{BDOWN.h => BDOWN.org.h} | 0 .../ORG/{CEMETERY.h => CEMETERY.org.h} | 0 src/Resource/ORG/{CURLY.h => CURLY.org.h} | 0 src/Resource/ORG/{DR.h => DR.org.h} | 0 src/Resource/ORG/{ENDING.h => ENDING.org.h} | 0 src/Resource/ORG/{ESCAPE.h => ESCAPE.org.h} | 0 .../ORG/{FANFALE1.h => FANFALE1.org.h} | 0 .../ORG/{FANFALE2.h => FANFALE2.org.h} | 0 .../ORG/{FANFALE3.h => FANFALE3.org.h} | 0 src/Resource/ORG/{FIREEYE.h => FIREEYE.org.h} | 0 .../ORG/{GAMEOVER.h => GAMEOVER.org.h} | 0 src/Resource/ORG/{GINSUKE.h => GINSUKE.org.h} | 0 src/Resource/ORG/{GRAND.h => GRAND.org.h} | 0 src/Resource/ORG/{GRAVITY.h => GRAVITY.org.h} | 0 src/Resource/ORG/{HELL.h => HELL.org.h} | 0 src/Resource/ORG/{IRONH.h => IRONH.org.h} | 0 src/Resource/ORG/{JENKA.h => JENKA.org.h} | 0 src/Resource/ORG/{JENKA2.h => JENKA2.org.h} | 0 src/Resource/ORG/{KODOU.h => KODOU.org.h} | 0 src/Resource/ORG/{LASTBT3.h => LASTBT3.org.h} | 0 src/Resource/ORG/{LASTBTL.h => LASTBTL.org.h} | 0 .../ORG/{LASTCAVE.h => LASTCAVE.org.h} | 0 src/Resource/ORG/{MARINE.h => MARINE.org.h} | 0 src/Resource/ORG/{MAZE.h => MAZE.org.h} | 0 src/Resource/ORG/{MDOWN2.h => MDOWN2.org.h} | 0 src/Resource/ORG/{MURA.h => MURA.org.h} | 0 src/Resource/ORG/{OSIDE.h => OSIDE.org.h} | 0 src/Resource/ORG/{PLANT.h => PLANT.org.h} | 0 src/Resource/ORG/{QUIET.h => QUIET.org.h} | 0 src/Resource/ORG/{REQUIEM.h => REQUIEM.org.h} | 0 src/Resource/ORG/{TOROKO.h => TOROKO.org.h} | 0 src/Resource/ORG/{VIVI.h => VIVI.org.h} | 0 src/Resource/ORG/{WANPAK2.h => WANPAK2.org.h} | 0 src/Resource/ORG/{WANPAKU.h => WANPAKU.org.h} | 0 src/Resource/ORG/{WEED.h => WEED.org.h} | 0 src/Resource/ORG/{WHITE.h => WHITE.org.h} | 0 src/Resource/ORG/{XXXX.h => XXXX.org.h} | 0 src/Resource/ORG/{ZONBIE.h => ZONBIE.org.h} | 0 86 files changed, 84 insertions(+), 84 deletions(-) rename res/ORG/{ACCESS => ACCESS.org} (100%) rename res/ORG/{ANZEN => ANZEN.org} (100%) rename res/ORG/{BALCONY => BALCONY.org} (100%) rename res/ORG/{BALLOS => BALLOS.org} (100%) rename res/ORG/{BDOWN => BDOWN.org} (100%) rename res/ORG/{CEMETERY => CEMETERY.org} (100%) rename res/ORG/{CURLY => CURLY.org} (100%) rename res/ORG/{DR => DR.org} (100%) rename res/ORG/{ENDING => ENDING.org} (100%) rename res/ORG/{ESCAPE => ESCAPE.org} (100%) rename res/ORG/{FANFALE1 => FANFALE1.org} (100%) rename res/ORG/{FANFALE2 => FANFALE2.org} (100%) rename res/ORG/{FANFALE3 => FANFALE3.org} (100%) rename res/ORG/{FIREEYE => FIREEYE.org} (100%) rename res/ORG/{GAMEOVER => GAMEOVER.org} (100%) rename res/ORG/{GINSUKE => GINSUKE.org} (100%) rename res/ORG/{GRAND => GRAND.org} (100%) rename res/ORG/{GRAVITY => GRAVITY.org} (100%) rename res/ORG/{HELL => HELL.org} (100%) rename res/ORG/{IRONH => IRONH.org} (100%) rename res/ORG/{JENKA => JENKA.org} (100%) rename res/ORG/{JENKA2 => JENKA2.org} (100%) rename res/ORG/{KODOU => KODOU.org} (100%) rename res/ORG/{LASTBT3 => LASTBT3.org} (100%) rename res/ORG/{LASTBTL => LASTBTL.org} (100%) rename res/ORG/{LASTCAVE => LASTCAVE.org} (100%) rename res/ORG/{MARINE => MARINE.org} (100%) rename res/ORG/{MAZE => MAZE.org} (100%) rename res/ORG/{MDOWN2 => MDOWN2.org} (100%) rename res/ORG/{MURA => MURA.org} (100%) rename res/ORG/{OSIDE => OSIDE.org} (100%) rename res/ORG/{PLANT => PLANT.org} (100%) rename res/ORG/{QUIET => QUIET.org} (100%) rename res/ORG/{REQUIEM => REQUIEM.org} (100%) rename res/ORG/{TOROKO => TOROKO.org} (100%) rename res/ORG/{VIVI => VIVI.org} (100%) rename res/ORG/{WANPAK2 => WANPAK2.org} (100%) rename res/ORG/{WANPAKU => WANPAKU.org} (100%) rename res/ORG/{WEED => WEED.org} (100%) rename res/ORG/{WHITE => WHITE.org} (100%) rename res/ORG/{XXXX => XXXX.org} (100%) rename res/ORG/{ZONBIE => ZONBIE.org} (100%) rename src/Resource/ORG/{ACCESS.h => ACCESS.org.h} (100%) rename src/Resource/ORG/{ANZEN.h => ANZEN.org.h} (100%) rename src/Resource/ORG/{BALCONY.h => BALCONY.org.h} (100%) rename src/Resource/ORG/{BALLOS.h => BALLOS.org.h} (100%) rename src/Resource/ORG/{BDOWN.h => BDOWN.org.h} (100%) rename src/Resource/ORG/{CEMETERY.h => CEMETERY.org.h} (100%) rename src/Resource/ORG/{CURLY.h => CURLY.org.h} (100%) rename src/Resource/ORG/{DR.h => DR.org.h} (100%) rename src/Resource/ORG/{ENDING.h => ENDING.org.h} (100%) rename src/Resource/ORG/{ESCAPE.h => ESCAPE.org.h} (100%) rename src/Resource/ORG/{FANFALE1.h => FANFALE1.org.h} (100%) rename src/Resource/ORG/{FANFALE2.h => FANFALE2.org.h} (100%) rename src/Resource/ORG/{FANFALE3.h => FANFALE3.org.h} (100%) rename src/Resource/ORG/{FIREEYE.h => FIREEYE.org.h} (100%) rename src/Resource/ORG/{GAMEOVER.h => GAMEOVER.org.h} (100%) rename src/Resource/ORG/{GINSUKE.h => GINSUKE.org.h} (100%) rename src/Resource/ORG/{GRAND.h => GRAND.org.h} (100%) rename src/Resource/ORG/{GRAVITY.h => GRAVITY.org.h} (100%) rename src/Resource/ORG/{HELL.h => HELL.org.h} (100%) rename src/Resource/ORG/{IRONH.h => IRONH.org.h} (100%) rename src/Resource/ORG/{JENKA.h => JENKA.org.h} (100%) rename src/Resource/ORG/{JENKA2.h => JENKA2.org.h} (100%) rename src/Resource/ORG/{KODOU.h => KODOU.org.h} (100%) rename src/Resource/ORG/{LASTBT3.h => LASTBT3.org.h} (100%) rename src/Resource/ORG/{LASTBTL.h => LASTBTL.org.h} (100%) rename src/Resource/ORG/{LASTCAVE.h => LASTCAVE.org.h} (100%) rename src/Resource/ORG/{MARINE.h => MARINE.org.h} (100%) rename src/Resource/ORG/{MAZE.h => MAZE.org.h} (100%) rename src/Resource/ORG/{MDOWN2.h => MDOWN2.org.h} (100%) rename src/Resource/ORG/{MURA.h => MURA.org.h} (100%) rename src/Resource/ORG/{OSIDE.h => OSIDE.org.h} (100%) rename src/Resource/ORG/{PLANT.h => PLANT.org.h} (100%) rename src/Resource/ORG/{QUIET.h => QUIET.org.h} (100%) rename src/Resource/ORG/{REQUIEM.h => REQUIEM.org.h} (100%) rename src/Resource/ORG/{TOROKO.h => TOROKO.org.h} (100%) rename src/Resource/ORG/{VIVI.h => VIVI.org.h} (100%) rename src/Resource/ORG/{WANPAK2.h => WANPAK2.org.h} (100%) rename src/Resource/ORG/{WANPAKU.h => WANPAKU.org.h} (100%) rename src/Resource/ORG/{WEED.h => WEED.org.h} (100%) rename src/Resource/ORG/{WHITE.h => WHITE.org.h} (100%) rename src/Resource/ORG/{XXXX.h => XXXX.org.h} (100%) rename src/Resource/ORG/{ZONBIE.h => ZONBIE.org.h} (100%) diff --git a/Makefile b/Makefile index 433c9099..c3dee4a5 100644 --- a/Makefile +++ b/Makefile @@ -135,48 +135,48 @@ RESOURCES = \ BITMAP/CREDIT18.bmp \ CURSOR/CURSOR_IKA.bmp \ CURSOR/CURSOR_NORMAL.bmp \ - ORG/ACCESS \ - ORG/ANZEN \ - ORG/BALCONY \ - ORG/BALLOS \ - ORG/BDOWN \ - ORG/CEMETERY \ - ORG/CURLY \ - ORG/DR \ - ORG/ENDING \ - ORG/ESCAPE \ - ORG/FANFALE1 \ - ORG/FANFALE2 \ - ORG/FANFALE3 \ - ORG/FIREEYE \ - ORG/GAMEOVER \ - ORG/GINSUKE \ - ORG/GRAND \ - ORG/GRAVITY \ - ORG/HELL \ - ORG/IRONH \ - ORG/JENKA \ - ORG/JENKA2 \ - ORG/KODOU \ - ORG/LASTBT3 \ - ORG/LASTBTL \ - ORG/LASTCAVE \ - ORG/MARINE \ - ORG/MAZE \ - ORG/MDOWN2 \ - ORG/MURA \ - ORG/OSIDE \ - ORG/PLANT \ - ORG/QUIET \ - ORG/REQUIEM \ - ORG/TOROKO \ - ORG/VIVI \ - ORG/WANPAK2 \ - ORG/WANPAKU \ - ORG/WEED \ - ORG/WHITE \ - ORG/XXXX \ - ORG/ZONBIE \ + ORG/ACCESS.org \ + ORG/ANZEN.org \ + ORG/BALCONY.org \ + ORG/BALLOS.org \ + ORG/BDOWN.org \ + ORG/CEMETERY.org \ + ORG/CURLY.org \ + ORG/DR.org \ + ORG/ENDING.org \ + ORG/ESCAPE.org \ + ORG/FANFALE1.org \ + ORG/FANFALE2.org \ + ORG/FANFALE3.org \ + ORG/FIREEYE.org \ + ORG/GAMEOVER.org \ + ORG/GINSUKE.org \ + ORG/GRAND.org \ + ORG/GRAVITY.org \ + ORG/HELL.org \ + ORG/IRONH.org \ + ORG/JENKA.org \ + ORG/JENKA2.org \ + ORG/KODOU.org \ + ORG/LASTBT3.org \ + ORG/LASTBTL.org \ + ORG/LASTCAVE.org \ + ORG/MARINE.org \ + ORG/MAZE.org \ + ORG/MDOWN2.org \ + ORG/MURA.org \ + ORG/OSIDE.org \ + ORG/PLANT.org \ + ORG/QUIET.org \ + ORG/REQUIEM.org \ + ORG/TOROKO.org \ + ORG/VIVI.org \ + ORG/WANPAK2.org \ + ORG/WANPAKU.org \ + ORG/WEED.org \ + ORG/WHITE.org \ + ORG/XXXX.org \ + ORG/ZONBIE.org \ WAVE/WAVE100 ifeq ($(JAPANESE), 1) diff --git a/res/ORG/ACCESS b/res/ORG/ACCESS.org similarity index 100% rename from res/ORG/ACCESS rename to res/ORG/ACCESS.org diff --git a/res/ORG/ANZEN b/res/ORG/ANZEN.org similarity index 100% rename from res/ORG/ANZEN rename to res/ORG/ANZEN.org diff --git a/res/ORG/BALCONY b/res/ORG/BALCONY.org similarity index 100% rename from res/ORG/BALCONY rename to res/ORG/BALCONY.org diff --git a/res/ORG/BALLOS b/res/ORG/BALLOS.org similarity index 100% rename from res/ORG/BALLOS rename to res/ORG/BALLOS.org diff --git a/res/ORG/BDOWN b/res/ORG/BDOWN.org similarity index 100% rename from res/ORG/BDOWN rename to res/ORG/BDOWN.org diff --git a/res/ORG/CEMETERY b/res/ORG/CEMETERY.org similarity index 100% rename from res/ORG/CEMETERY rename to res/ORG/CEMETERY.org diff --git a/res/ORG/CURLY b/res/ORG/CURLY.org similarity index 100% rename from res/ORG/CURLY rename to res/ORG/CURLY.org diff --git a/res/ORG/DR b/res/ORG/DR.org similarity index 100% rename from res/ORG/DR rename to res/ORG/DR.org diff --git a/res/ORG/ENDING b/res/ORG/ENDING.org similarity index 100% rename from res/ORG/ENDING rename to res/ORG/ENDING.org diff --git a/res/ORG/ESCAPE b/res/ORG/ESCAPE.org similarity index 100% rename from res/ORG/ESCAPE rename to res/ORG/ESCAPE.org diff --git a/res/ORG/FANFALE1 b/res/ORG/FANFALE1.org similarity index 100% rename from res/ORG/FANFALE1 rename to res/ORG/FANFALE1.org diff --git a/res/ORG/FANFALE2 b/res/ORG/FANFALE2.org similarity index 100% rename from res/ORG/FANFALE2 rename to res/ORG/FANFALE2.org diff --git a/res/ORG/FANFALE3 b/res/ORG/FANFALE3.org similarity index 100% rename from res/ORG/FANFALE3 rename to res/ORG/FANFALE3.org diff --git a/res/ORG/FIREEYE b/res/ORG/FIREEYE.org similarity index 100% rename from res/ORG/FIREEYE rename to res/ORG/FIREEYE.org diff --git a/res/ORG/GAMEOVER b/res/ORG/GAMEOVER.org similarity index 100% rename from res/ORG/GAMEOVER rename to res/ORG/GAMEOVER.org diff --git a/res/ORG/GINSUKE b/res/ORG/GINSUKE.org similarity index 100% rename from res/ORG/GINSUKE rename to res/ORG/GINSUKE.org diff --git a/res/ORG/GRAND b/res/ORG/GRAND.org similarity index 100% rename from res/ORG/GRAND rename to res/ORG/GRAND.org diff --git a/res/ORG/GRAVITY b/res/ORG/GRAVITY.org similarity index 100% rename from res/ORG/GRAVITY rename to res/ORG/GRAVITY.org diff --git a/res/ORG/HELL b/res/ORG/HELL.org similarity index 100% rename from res/ORG/HELL rename to res/ORG/HELL.org diff --git a/res/ORG/IRONH b/res/ORG/IRONH.org similarity index 100% rename from res/ORG/IRONH rename to res/ORG/IRONH.org diff --git a/res/ORG/JENKA b/res/ORG/JENKA.org similarity index 100% rename from res/ORG/JENKA rename to res/ORG/JENKA.org diff --git a/res/ORG/JENKA2 b/res/ORG/JENKA2.org similarity index 100% rename from res/ORG/JENKA2 rename to res/ORG/JENKA2.org diff --git a/res/ORG/KODOU b/res/ORG/KODOU.org similarity index 100% rename from res/ORG/KODOU rename to res/ORG/KODOU.org diff --git a/res/ORG/LASTBT3 b/res/ORG/LASTBT3.org similarity index 100% rename from res/ORG/LASTBT3 rename to res/ORG/LASTBT3.org diff --git a/res/ORG/LASTBTL b/res/ORG/LASTBTL.org similarity index 100% rename from res/ORG/LASTBTL rename to res/ORG/LASTBTL.org diff --git a/res/ORG/LASTCAVE b/res/ORG/LASTCAVE.org similarity index 100% rename from res/ORG/LASTCAVE rename to res/ORG/LASTCAVE.org diff --git a/res/ORG/MARINE b/res/ORG/MARINE.org similarity index 100% rename from res/ORG/MARINE rename to res/ORG/MARINE.org diff --git a/res/ORG/MAZE b/res/ORG/MAZE.org similarity index 100% rename from res/ORG/MAZE rename to res/ORG/MAZE.org diff --git a/res/ORG/MDOWN2 b/res/ORG/MDOWN2.org similarity index 100% rename from res/ORG/MDOWN2 rename to res/ORG/MDOWN2.org diff --git a/res/ORG/MURA b/res/ORG/MURA.org similarity index 100% rename from res/ORG/MURA rename to res/ORG/MURA.org diff --git a/res/ORG/OSIDE b/res/ORG/OSIDE.org similarity index 100% rename from res/ORG/OSIDE rename to res/ORG/OSIDE.org diff --git a/res/ORG/PLANT b/res/ORG/PLANT.org similarity index 100% rename from res/ORG/PLANT rename to res/ORG/PLANT.org diff --git a/res/ORG/QUIET b/res/ORG/QUIET.org similarity index 100% rename from res/ORG/QUIET rename to res/ORG/QUIET.org diff --git a/res/ORG/REQUIEM b/res/ORG/REQUIEM.org similarity index 100% rename from res/ORG/REQUIEM rename to res/ORG/REQUIEM.org diff --git a/res/ORG/TOROKO b/res/ORG/TOROKO.org similarity index 100% rename from res/ORG/TOROKO rename to res/ORG/TOROKO.org diff --git a/res/ORG/VIVI b/res/ORG/VIVI.org similarity index 100% rename from res/ORG/VIVI rename to res/ORG/VIVI.org diff --git a/res/ORG/WANPAK2 b/res/ORG/WANPAK2.org similarity index 100% rename from res/ORG/WANPAK2 rename to res/ORG/WANPAK2.org diff --git a/res/ORG/WANPAKU b/res/ORG/WANPAKU.org similarity index 100% rename from res/ORG/WANPAKU rename to res/ORG/WANPAKU.org diff --git a/res/ORG/WEED b/res/ORG/WEED.org similarity index 100% rename from res/ORG/WEED rename to res/ORG/WEED.org diff --git a/res/ORG/WHITE b/res/ORG/WHITE.org similarity index 100% rename from res/ORG/WHITE rename to res/ORG/WHITE.org diff --git a/res/ORG/XXXX b/res/ORG/XXXX.org similarity index 100% rename from res/ORG/XXXX rename to res/ORG/XXXX.org diff --git a/res/ORG/ZONBIE b/res/ORG/ZONBIE.org similarity index 100% rename from res/ORG/ZONBIE rename to res/ORG/ZONBIE.org diff --git a/src/Resource.cpp b/src/Resource.cpp index 4ab54a9e..0d14833e 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -4,48 +4,48 @@ #include #include "WindowsWrapper.h" -#include "Resource/ORG/ACCESS.h" -#include "Resource/ORG/ANZEN.h" -#include "Resource/ORG/BALCONY.h" -#include "Resource/ORG/BALLOS.h" -#include "Resource/ORG/BDOWN.h" -#include "Resource/ORG/CEMETERY.h" -#include "Resource/ORG/CURLY.h" -#include "Resource/ORG/DR.h" -#include "Resource/ORG/ENDING.h" -#include "Resource/ORG/ESCAPE.h" -#include "Resource/ORG/FANFALE1.h" -#include "Resource/ORG/FANFALE2.h" -#include "Resource/ORG/FANFALE3.h" -#include "Resource/ORG/FIREEYE.h" -#include "Resource/ORG/GAMEOVER.h" -#include "Resource/ORG/GINSUKE.h" -#include "Resource/ORG/GRAND.h" -#include "Resource/ORG/GRAVITY.h" -#include "Resource/ORG/HELL.h" -#include "Resource/ORG/IRONH.h" -#include "Resource/ORG/JENKA.h" -#include "Resource/ORG/JENKA2.h" -#include "Resource/ORG/KODOU.h" -#include "Resource/ORG/LASTBT3.h" -#include "Resource/ORG/LASTBTL.h" -#include "Resource/ORG/LASTCAVE.h" -#include "Resource/ORG/MARINE.h" -#include "Resource/ORG/MAZE.h" -#include "Resource/ORG/MDOWN2.h" -#include "Resource/ORG/MURA.h" -#include "Resource/ORG/OSIDE.h" -#include "Resource/ORG/PLANT.h" -#include "Resource/ORG/QUIET.h" -#include "Resource/ORG/REQUIEM.h" -#include "Resource/ORG/TOROKO.h" -#include "Resource/ORG/VIVI.h" -#include "Resource/ORG/WANPAK2.h" -#include "Resource/ORG/WANPAKU.h" -#include "Resource/ORG/WEED.h" -#include "Resource/ORG/WHITE.h" -#include "Resource/ORG/XXXX.h" -#include "Resource/ORG/ZONBIE.h" +#include "Resource/ORG/ACCESS.org.h" +#include "Resource/ORG/ANZEN.org.h" +#include "Resource/ORG/BALCONY.org.h" +#include "Resource/ORG/BALLOS.org.h" +#include "Resource/ORG/BDOWN.org.h" +#include "Resource/ORG/CEMETERY.org.h" +#include "Resource/ORG/CURLY.org.h" +#include "Resource/ORG/DR.org.h" +#include "Resource/ORG/ENDING.org.h" +#include "Resource/ORG/ESCAPE.org.h" +#include "Resource/ORG/FANFALE1.org.h" +#include "Resource/ORG/FANFALE2.org.h" +#include "Resource/ORG/FANFALE3.org.h" +#include "Resource/ORG/FIREEYE.org.h" +#include "Resource/ORG/GAMEOVER.org.h" +#include "Resource/ORG/GINSUKE.org.h" +#include "Resource/ORG/GRAND.org.h" +#include "Resource/ORG/GRAVITY.org.h" +#include "Resource/ORG/HELL.org.h" +#include "Resource/ORG/IRONH.org.h" +#include "Resource/ORG/JENKA.org.h" +#include "Resource/ORG/JENKA2.org.h" +#include "Resource/ORG/KODOU.org.h" +#include "Resource/ORG/LASTBT3.org.h" +#include "Resource/ORG/LASTBTL.org.h" +#include "Resource/ORG/LASTCAVE.org.h" +#include "Resource/ORG/MARINE.org.h" +#include "Resource/ORG/MAZE.org.h" +#include "Resource/ORG/MDOWN2.org.h" +#include "Resource/ORG/MURA.org.h" +#include "Resource/ORG/OSIDE.org.h" +#include "Resource/ORG/PLANT.org.h" +#include "Resource/ORG/QUIET.org.h" +#include "Resource/ORG/REQUIEM.org.h" +#include "Resource/ORG/TOROKO.org.h" +#include "Resource/ORG/VIVI.org.h" +#include "Resource/ORG/WANPAK2.org.h" +#include "Resource/ORG/WANPAKU.org.h" +#include "Resource/ORG/WEED.org.h" +#include "Resource/ORG/WHITE.org.h" +#include "Resource/ORG/XXXX.org.h" +#include "Resource/ORG/ZONBIE.org.h" #include "Resource/WAVE/WAVE100.h" #include "Resource/BITMAP/CREDIT01.bmp.h" #include "Resource/BITMAP/CREDIT02.bmp.h" diff --git a/src/Resource/ORG/ACCESS.h b/src/Resource/ORG/ACCESS.org.h similarity index 100% rename from src/Resource/ORG/ACCESS.h rename to src/Resource/ORG/ACCESS.org.h diff --git a/src/Resource/ORG/ANZEN.h b/src/Resource/ORG/ANZEN.org.h similarity index 100% rename from src/Resource/ORG/ANZEN.h rename to src/Resource/ORG/ANZEN.org.h diff --git a/src/Resource/ORG/BALCONY.h b/src/Resource/ORG/BALCONY.org.h similarity index 100% rename from src/Resource/ORG/BALCONY.h rename to src/Resource/ORG/BALCONY.org.h diff --git a/src/Resource/ORG/BALLOS.h b/src/Resource/ORG/BALLOS.org.h similarity index 100% rename from src/Resource/ORG/BALLOS.h rename to src/Resource/ORG/BALLOS.org.h diff --git a/src/Resource/ORG/BDOWN.h b/src/Resource/ORG/BDOWN.org.h similarity index 100% rename from src/Resource/ORG/BDOWN.h rename to src/Resource/ORG/BDOWN.org.h diff --git a/src/Resource/ORG/CEMETERY.h b/src/Resource/ORG/CEMETERY.org.h similarity index 100% rename from src/Resource/ORG/CEMETERY.h rename to src/Resource/ORG/CEMETERY.org.h diff --git a/src/Resource/ORG/CURLY.h b/src/Resource/ORG/CURLY.org.h similarity index 100% rename from src/Resource/ORG/CURLY.h rename to src/Resource/ORG/CURLY.org.h diff --git a/src/Resource/ORG/DR.h b/src/Resource/ORG/DR.org.h similarity index 100% rename from src/Resource/ORG/DR.h rename to src/Resource/ORG/DR.org.h diff --git a/src/Resource/ORG/ENDING.h b/src/Resource/ORG/ENDING.org.h similarity index 100% rename from src/Resource/ORG/ENDING.h rename to src/Resource/ORG/ENDING.org.h diff --git a/src/Resource/ORG/ESCAPE.h b/src/Resource/ORG/ESCAPE.org.h similarity index 100% rename from src/Resource/ORG/ESCAPE.h rename to src/Resource/ORG/ESCAPE.org.h diff --git a/src/Resource/ORG/FANFALE1.h b/src/Resource/ORG/FANFALE1.org.h similarity index 100% rename from src/Resource/ORG/FANFALE1.h rename to src/Resource/ORG/FANFALE1.org.h diff --git a/src/Resource/ORG/FANFALE2.h b/src/Resource/ORG/FANFALE2.org.h similarity index 100% rename from src/Resource/ORG/FANFALE2.h rename to src/Resource/ORG/FANFALE2.org.h diff --git a/src/Resource/ORG/FANFALE3.h b/src/Resource/ORG/FANFALE3.org.h similarity index 100% rename from src/Resource/ORG/FANFALE3.h rename to src/Resource/ORG/FANFALE3.org.h diff --git a/src/Resource/ORG/FIREEYE.h b/src/Resource/ORG/FIREEYE.org.h similarity index 100% rename from src/Resource/ORG/FIREEYE.h rename to src/Resource/ORG/FIREEYE.org.h diff --git a/src/Resource/ORG/GAMEOVER.h b/src/Resource/ORG/GAMEOVER.org.h similarity index 100% rename from src/Resource/ORG/GAMEOVER.h rename to src/Resource/ORG/GAMEOVER.org.h diff --git a/src/Resource/ORG/GINSUKE.h b/src/Resource/ORG/GINSUKE.org.h similarity index 100% rename from src/Resource/ORG/GINSUKE.h rename to src/Resource/ORG/GINSUKE.org.h diff --git a/src/Resource/ORG/GRAND.h b/src/Resource/ORG/GRAND.org.h similarity index 100% rename from src/Resource/ORG/GRAND.h rename to src/Resource/ORG/GRAND.org.h diff --git a/src/Resource/ORG/GRAVITY.h b/src/Resource/ORG/GRAVITY.org.h similarity index 100% rename from src/Resource/ORG/GRAVITY.h rename to src/Resource/ORG/GRAVITY.org.h diff --git a/src/Resource/ORG/HELL.h b/src/Resource/ORG/HELL.org.h similarity index 100% rename from src/Resource/ORG/HELL.h rename to src/Resource/ORG/HELL.org.h diff --git a/src/Resource/ORG/IRONH.h b/src/Resource/ORG/IRONH.org.h similarity index 100% rename from src/Resource/ORG/IRONH.h rename to src/Resource/ORG/IRONH.org.h diff --git a/src/Resource/ORG/JENKA.h b/src/Resource/ORG/JENKA.org.h similarity index 100% rename from src/Resource/ORG/JENKA.h rename to src/Resource/ORG/JENKA.org.h diff --git a/src/Resource/ORG/JENKA2.h b/src/Resource/ORG/JENKA2.org.h similarity index 100% rename from src/Resource/ORG/JENKA2.h rename to src/Resource/ORG/JENKA2.org.h diff --git a/src/Resource/ORG/KODOU.h b/src/Resource/ORG/KODOU.org.h similarity index 100% rename from src/Resource/ORG/KODOU.h rename to src/Resource/ORG/KODOU.org.h diff --git a/src/Resource/ORG/LASTBT3.h b/src/Resource/ORG/LASTBT3.org.h similarity index 100% rename from src/Resource/ORG/LASTBT3.h rename to src/Resource/ORG/LASTBT3.org.h diff --git a/src/Resource/ORG/LASTBTL.h b/src/Resource/ORG/LASTBTL.org.h similarity index 100% rename from src/Resource/ORG/LASTBTL.h rename to src/Resource/ORG/LASTBTL.org.h diff --git a/src/Resource/ORG/LASTCAVE.h b/src/Resource/ORG/LASTCAVE.org.h similarity index 100% rename from src/Resource/ORG/LASTCAVE.h rename to src/Resource/ORG/LASTCAVE.org.h diff --git a/src/Resource/ORG/MARINE.h b/src/Resource/ORG/MARINE.org.h similarity index 100% rename from src/Resource/ORG/MARINE.h rename to src/Resource/ORG/MARINE.org.h diff --git a/src/Resource/ORG/MAZE.h b/src/Resource/ORG/MAZE.org.h similarity index 100% rename from src/Resource/ORG/MAZE.h rename to src/Resource/ORG/MAZE.org.h diff --git a/src/Resource/ORG/MDOWN2.h b/src/Resource/ORG/MDOWN2.org.h similarity index 100% rename from src/Resource/ORG/MDOWN2.h rename to src/Resource/ORG/MDOWN2.org.h diff --git a/src/Resource/ORG/MURA.h b/src/Resource/ORG/MURA.org.h similarity index 100% rename from src/Resource/ORG/MURA.h rename to src/Resource/ORG/MURA.org.h diff --git a/src/Resource/ORG/OSIDE.h b/src/Resource/ORG/OSIDE.org.h similarity index 100% rename from src/Resource/ORG/OSIDE.h rename to src/Resource/ORG/OSIDE.org.h diff --git a/src/Resource/ORG/PLANT.h b/src/Resource/ORG/PLANT.org.h similarity index 100% rename from src/Resource/ORG/PLANT.h rename to src/Resource/ORG/PLANT.org.h diff --git a/src/Resource/ORG/QUIET.h b/src/Resource/ORG/QUIET.org.h similarity index 100% rename from src/Resource/ORG/QUIET.h rename to src/Resource/ORG/QUIET.org.h diff --git a/src/Resource/ORG/REQUIEM.h b/src/Resource/ORG/REQUIEM.org.h similarity index 100% rename from src/Resource/ORG/REQUIEM.h rename to src/Resource/ORG/REQUIEM.org.h diff --git a/src/Resource/ORG/TOROKO.h b/src/Resource/ORG/TOROKO.org.h similarity index 100% rename from src/Resource/ORG/TOROKO.h rename to src/Resource/ORG/TOROKO.org.h diff --git a/src/Resource/ORG/VIVI.h b/src/Resource/ORG/VIVI.org.h similarity index 100% rename from src/Resource/ORG/VIVI.h rename to src/Resource/ORG/VIVI.org.h diff --git a/src/Resource/ORG/WANPAK2.h b/src/Resource/ORG/WANPAK2.org.h similarity index 100% rename from src/Resource/ORG/WANPAK2.h rename to src/Resource/ORG/WANPAK2.org.h diff --git a/src/Resource/ORG/WANPAKU.h b/src/Resource/ORG/WANPAKU.org.h similarity index 100% rename from src/Resource/ORG/WANPAKU.h rename to src/Resource/ORG/WANPAKU.org.h diff --git a/src/Resource/ORG/WEED.h b/src/Resource/ORG/WEED.org.h similarity index 100% rename from src/Resource/ORG/WEED.h rename to src/Resource/ORG/WEED.org.h diff --git a/src/Resource/ORG/WHITE.h b/src/Resource/ORG/WHITE.org.h similarity index 100% rename from src/Resource/ORG/WHITE.h rename to src/Resource/ORG/WHITE.org.h diff --git a/src/Resource/ORG/XXXX.h b/src/Resource/ORG/XXXX.org.h similarity index 100% rename from src/Resource/ORG/XXXX.h rename to src/Resource/ORG/XXXX.org.h diff --git a/src/Resource/ORG/ZONBIE.h b/src/Resource/ORG/ZONBIE.org.h similarity index 100% rename from src/Resource/ORG/ZONBIE.h rename to src/Resource/ORG/ZONBIE.org.h From c44186d93a83aa912b96347fbefa606c28bee8c9 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 15 Feb 2019 20:33:08 +0000 Subject: [PATCH 03/22] Ditched SDL's file IO for stdio and our own convenience functions ASM-accurate file stuff can come later. --- Makefile | 1 + src/Config.cpp | 26 +++++----- src/Draw.h | 1 - src/Ending.cpp | 38 ++++++++------ src/File.cpp | 98 +++++++++++++++++++++++++++++++++++ src/File.h | 15 ++++++ src/Font.cpp | 15 ++---- src/Generic.cpp | 15 ++++++ src/Generic.h | 1 + src/Map.cpp | 31 +++++------ src/MycParam.cpp | 63 +++++++++++----------- src/NpChar.cpp | 31 +++++++---- src/NpcTbl.cpp | 69 +++++++++++++------------ src/Profile.cpp | 132 ++++++++++++++++++++++++----------------------- src/TextScr.cpp | 40 ++++++++------ 15 files changed, 365 insertions(+), 211 deletions(-) create mode 100644 src/File.cpp create mode 100644 src/File.h diff --git a/Makefile b/Makefile index c3dee4a5..501602fb 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,7 @@ SOURCES = \ Ending \ Escape \ Fade \ + File \ Flags \ Flash \ Font \ diff --git a/src/Config.cpp b/src/Config.cpp index a4985e84..35277f18 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -5,11 +5,11 @@ #include #include -#include #include "WindowsWrapper.h" #include "Tags.h" #include "Config.h" +#include "File.h" bool LoadConfigData(CONFIG *conf) { @@ -21,30 +21,30 @@ bool LoadConfigData(CONFIG *conf) sprintf(path, "%s/%s", gModulePath, "Config.dat"); //Open file - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; - //Read data (we're using SDL_RWops so we can load it with the specific endianness expected) + //Read data //Read the version id and font name - fp->read(fp, conf->proof, sizeof(conf->proof), 1); - fp->read(fp, conf->font_name, sizeof(conf->font_name), 1); + fread(conf->proof, sizeof(conf->proof), 1, fp); + fread(conf->font_name, sizeof(conf->font_name), 1, fp); //Read control settings - conf->move_button_mode = SDL_ReadLE32(fp); - conf->attack_button_mode = SDL_ReadLE32(fp); - conf->ok_button_mode = SDL_ReadLE32(fp); + conf->move_button_mode = File_ReadLE32(fp); + conf->attack_button_mode = File_ReadLE32(fp); + conf->ok_button_mode = File_ReadLE32(fp); //Read display mode (320x240, 640x480, 24-bit fullscreen, 32-bit fullscreen) TODO: add more things? - conf->display_mode = SDL_ReadLE32(fp); + conf->display_mode = File_ReadLE32(fp); //Read joystick configuration (if enabled, and mappings) - conf->bJoystick = SDL_ReadLE32(fp); + conf->bJoystick = File_ReadLE32(fp); for (int button = 0; button < 8; button++) - conf->joystick_button[button] = SDL_ReadLE32(fp); + conf->joystick_button[button] = File_ReadLE32(fp); //Close file - fp->close(fp); + fclose(fp); //Check if version is correct, return that it succeeded if (!strcmp(conf->proof, "DOUKUTSU20041206")) diff --git a/src/Draw.h b/src/Draw.h index cf31af3b..2e7aed58 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -56,7 +56,6 @@ bool Flip_SystemTask(); bool StartDirectDraw(int lMagnification, int lColourDepth); void EndDirectDraw(); void ReleaseSurface(int s); -bool MakeSurface(SDL_RWops *rw, int surf_no); bool MakeSurface_File(const char *name, int surf_no); bool MakeSurface_Resource(const char *res, int surf_no); bool ReloadBitmap_File(const char *name, int surf_no); diff --git a/src/Ending.cpp b/src/Ending.cpp index 3846d1cf..8d4dd5af 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -1,7 +1,6 @@ #include #include -#include #include "WindowsWrapper.h" #include "Tags.h" @@ -163,25 +162,31 @@ bool StartCreditScript() //Open file char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, "Credit.tsc"); - - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + + Credit.size = GetFileSizeLong(path); + if (Credit.size == -1) + return false; + + //Allcoate buffer data + Credit.pData = (char*)malloc(Credit.size); + if (Credit.pData == NULL) + return false; + + FILE *fp = fopen(path, "rb"); + if (fp == NULL) { printf("Couldn't open %s", path); return false; } - - //Allcoate buffer data - Credit.size = SDL_RWsize(fp); - - Credit.pData = (char*)malloc(Credit.size); - if (!Credit.pData) - return false; - + //Read data - SDL_RWread(fp, Credit.pData, 1, Credit.size); - SDL_RWclose(fp); + fread(Credit.pData, 1, Credit.size, fp); EncryptionBinaryData2((uint8_t*)Credit.pData, Credit.size); + +#ifdef FIX_BUGS + // The original game forgot to close the file + fclose(fp); +#endif //Reset credits Credit.offset = 0; @@ -192,16 +197,15 @@ bool StartCreditScript() //Modify cliprect grcGame.left = WINDOW_WIDTH / 2; + // These three are non-vanilla: for wide/tallscreen support grcGame.right = ((WINDOW_WIDTH - 320) / 2) + 320; grcGame.top = (WINDOW_HEIGHT - 240) / 2; grcGame.bottom = ((WINDOW_HEIGHT - 240) / 2) + 240; //Reload casts if (!ReloadBitmap_File("casts", SURFACE_ID_CASTS)) - { return false; - } - + //Clear casts memset(Strip, 0, sizeof(Strip)); return true; diff --git a/src/File.cpp b/src/File.cpp new file mode 100644 index 00000000..dc3a5c68 --- /dev/null +++ b/src/File.cpp @@ -0,0 +1,98 @@ +#include "File.h" + +#include +#include +#include + +long LoadFileToMemory(const char *file_path, unsigned char **file_buffer) +{ + long returned_size = -1; + + FILE *file = fopen(file_path, "rb"); + + if (file != NULL) + { + if (!fseek(file, 0, SEEK_END)) + { + const long file_size = ftell(file); + + if (file_size >= 0) + { + rewind(file); + *file_buffer = (unsigned char*)malloc(file_size); + + if (*file_buffer != NULL) + { + if (fread(*file_buffer, file_size, 1, file) == 1) + returned_size = file_size; + + free(file_buffer); + } + } + } + + fclose(file); + } + + return returned_size; +} + +unsigned short File_ReadBE16(FILE *stream) +{ + unsigned char bytes[2]; + + fread(bytes, 2, 1, stream); + + return (bytes[0] << 8) | bytes[1]; +} + +unsigned long File_ReadBE32(FILE *stream) +{ + unsigned char bytes[4]; + + fread(bytes, 4, 1, stream); + + return (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; +} + +unsigned short File_ReadLE16(FILE *stream) +{ + unsigned char bytes[2]; + + fread(bytes, 2, 1, stream); + + return (bytes[1] << 8) | bytes[0]; +} + +unsigned long File_ReadLE32(FILE *stream) +{ + unsigned char bytes[4]; + + fread(bytes, 4, 1, stream); + + return (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0]; +} + +void File_WriteBE16(unsigned short value, FILE *stream) +{ + for (unsigned int i = 2; i-- != 0;) + fputc(value >> (8 * i), stream); +} + +void File_WriteBE32(unsigned long value, FILE *stream) +{ + for (unsigned int i = 4; i-- != 0;) + fputc(value >> (8 * i), stream); +} + +void File_WriteLE16(unsigned short value, FILE *stream) +{ + for (unsigned int i = 0; i < 2; ++i) + fputc(value >> (8 * i), stream); +} + +void File_WriteLE32(unsigned long value, FILE *stream) +{ + for (unsigned int i = 0; i < 4; ++i) + fputc(value >> (8 * i), stream); +} diff --git a/src/File.h b/src/File.h new file mode 100644 index 00000000..d84dc370 --- /dev/null +++ b/src/File.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +long LoadFileToMemory(const char *file_path, unsigned char **file_buffer); + +unsigned short File_ReadBE16(FILE *stream); +unsigned long File_ReadBE32(FILE *stream); +unsigned short File_ReadLE16(FILE *stream); +unsigned long File_ReadLE32(FILE *stream); + +void File_WriteBE16(unsigned short value, FILE *stream); +void File_WriteBE32(unsigned long value, FILE *stream); +void File_WriteLE16(unsigned short value, FILE *stream); +void File_WriteLE32(unsigned long value, FILE *stream); diff --git a/src/Font.cpp b/src/Font.cpp index db65ffcd..0a805c67 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -17,6 +17,8 @@ #include "SDL.h" +#include "File.h" + // Uncomment for that authentic pre-Windows Vista feel //#define DISABLE_FONT_ANTIALIASING @@ -156,19 +158,12 @@ FontObject* LoadFont(const char *font_filename, unsigned int cell_width, unsigne { FontObject *font_object = NULL; - FILE *file = fopen(font_filename, "rb"); + unsigned char *file_buffer; + const long file_size = LoadFileToMemory(font_filename, &file_buffer); - if (file != NULL) + if (file_size != -1) { - fseek(file, 0, SEEK_END); - const size_t file_size = ftell(file); - rewind(file); - unsigned char *file_buffer = (unsigned char*)malloc(file_size); - fread(file_buffer, 1, file_size, file); - fclose(file); - font_object = LoadFontFromData(file_buffer, file_size, cell_width, cell_height); - free(file_buffer); } diff --git a/src/Generic.cpp b/src/Generic.cpp index 20bbe30e..e1bec542 100644 --- a/src/Generic.cpp +++ b/src/Generic.cpp @@ -13,6 +13,21 @@ bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4) return true; } +long GetFileSizeLong(const char *path) +{ + long len = -1; + + FILE *fp = fopen(path, "rb"); + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); + len = ftell(fp); + fclose(fp); + } + + return len; +} + bool CheckFileExists(const char *name) { char path[PATH_LENGTH]; diff --git a/src/Generic.h b/src/Generic.h index fc7531d7..39b31705 100644 --- a/src/Generic.h +++ b/src/Generic.h @@ -2,5 +2,6 @@ #include bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4); +long GetFileSizeLong(const char *path); bool CheckFileExists(const char *name); bool IsShiftJIS(uint8_t c); diff --git a/src/Map.cpp b/src/Map.cpp index c3b50039..307297aa 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -1,7 +1,7 @@ +#include #include #include -#include #include "WindowsWrapper.h" #include "CommonDefines.h" @@ -9,6 +9,7 @@ #include "Tags.h" #include "Draw.h" #include "NpChar.h" +#include "File.h" #define PXM_BUFFER_SIZE 0x4B000 @@ -27,39 +28,39 @@ bool LoadMapData2(char *path_map) sprintf(path, "%s/%s", gDataPath, path_map); //Open file - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; //Make sure file begins with "PXM" char check[3]; - fp->read(fp, check, 1, 3); + fread(check, 1, 3, fp); if (!memcmp(check, "PXM", 3)) { uint8_t nul; - fp->read(fp, &nul, 1, 1); + fread(&nul, 1, 1, fp); //Get width and height - gMap.width = SDL_ReadLE16(fp); - gMap.length = SDL_ReadLE16(fp); + gMap.width = File_ReadLE16(fp); + gMap.length = File_ReadLE16(fp); if (gMap.data) { //Read tiledata - fp->read(fp, gMap.data, 1, gMap.length * gMap.width); - SDL_RWclose(fp); + fread(gMap.data, 1, gMap.length * gMap.width, fp); + fclose(fp); return true; } else { - SDL_RWclose(fp); + fclose(fp); return false; } } else { - SDL_RWclose(fp); + fclose(fp); return false; } @@ -72,13 +73,13 @@ bool LoadAttributeData(char *path_atrb) char path[260]; sprintf(path, "%s/%s", gDataPath, path_atrb); - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; //Read data - fp->read(fp, gMap.atrb, 1, 0x100); - SDL_RWclose(fp); + fread(gMap.atrb, 1, 0x100, fp); + fclose(fp); return true; } diff --git a/src/MycParam.cpp b/src/MycParam.cpp index 795ce041..ebfd30e2 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -10,6 +10,7 @@ #include "Game.h" #include "Draw.h" #include "Caret.h" +#include "File.h" ARMS_LEVEL gArmsLevelTable[14] = { @@ -394,19 +395,19 @@ bool SaveTimeCounter() char path[PATH_LENGTH]; sprintf(path, "%s/290.rec", gModulePath); - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); + FILE *fp = fopen(path, "rb"); if (fp) { //Read data - rec.counter[0] = SDL_ReadLE32(fp); - rec.counter[1] = SDL_ReadLE32(fp); - rec.counter[2] = SDL_ReadLE32(fp); - rec.counter[3] = SDL_ReadLE32(fp); - rec.random[0] = SDL_ReadU8(fp); - rec.random[1] = SDL_ReadU8(fp); - rec.random[2] = SDL_ReadU8(fp); - rec.random[3] = SDL_ReadU8(fp); - SDL_RWclose(fp); + rec.counter[0] = File_ReadLE32(fp); + rec.counter[1] = File_ReadLE32(fp); + rec.counter[2] = File_ReadLE32(fp); + rec.counter[3] = File_ReadLE32(fp); + rec.random[0] = fgetc(fp); + rec.random[1] = fgetc(fp); + rec.random[2] = fgetc(fp); + rec.random[3] = fgetc(fp); + fclose(fp); uint8_t *p = (uint8_t*)&rec.counter[0]; p[0] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[0]) : (rec.random[0] >> 1); @@ -432,18 +433,18 @@ bool SaveTimeCounter() p[3] += (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] >> 1) : (rec.random[i]); } - fp = SDL_RWFromFile(path, "wb"); - if (!fp) + fp = fopen(path, "wb"); + if (fp == NULL) return false; - SDL_WriteLE32(fp, rec.counter[0]); - SDL_WriteLE32(fp, rec.counter[1]); - SDL_WriteLE32(fp, rec.counter[2]); - SDL_WriteLE32(fp, rec.counter[3]); - SDL_WriteU8(fp, rec.random[0]); - SDL_WriteU8(fp, rec.random[1]); - SDL_WriteU8(fp, rec.random[2]); - SDL_WriteU8(fp, rec.random[3]); - SDL_RWclose(fp); + File_WriteLE32(rec.counter[0], fp); + File_WriteLE32(rec.counter[1], fp); + File_WriteLE32(rec.counter[2], fp); + File_WriteLE32(rec.counter[3], fp); + fputc(rec.random[0], fp); + fputc(rec.random[1], fp); + fputc(rec.random[2], fp); + fputc(rec.random[3], fp); + fclose(fp); return true; } @@ -453,22 +454,22 @@ int LoadTimeCounter() char path[PATH_LENGTH]; sprintf(path, "%s/290.rec", gModulePath); - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); + FILE *fp = fopen(path, "rb"); if (!fp) return 0; REC rec; //Read data - rec.counter[0] = SDL_ReadLE32(fp); - rec.counter[1] = SDL_ReadLE32(fp); - rec.counter[2] = SDL_ReadLE32(fp); - rec.counter[3] = SDL_ReadLE32(fp); - rec.random[0] = SDL_ReadU8(fp); - rec.random[1] = SDL_ReadU8(fp); - rec.random[2] = SDL_ReadU8(fp); - rec.random[3] = SDL_ReadU8(fp); - SDL_RWclose(fp); + rec.counter[0] = File_ReadLE32(fp); + rec.counter[1] = File_ReadLE32(fp); + rec.counter[2] = File_ReadLE32(fp); + rec.counter[3] = File_ReadLE32(fp); + rec.random[0] = fgetc(fp); + rec.random[1] = fgetc(fp); + rec.random[2] = fgetc(fp); + rec.random[3] = fgetc(fp); + fclose(fp); //Decode from checksum for (int i = 0; i < 4; i++) diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 62e49b18..6f3d6907 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -1,6 +1,7 @@ +#include #include +#include -#include #include "WindowsWrapper.h" #include "CommonDefines.h" @@ -15,6 +16,7 @@ #include "ValueView.h" #include "NpcTbl.h" #include "Draw.h" +#include "File.h" NPCHAR gNPC[NPC_MAX]; int gCurlyShoot_wait; @@ -54,18 +56,24 @@ bool LoadEvent(char *path_event) char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, path_event); - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; //Read "PXE" check char code[4]; - fp->read(fp, code, 1, 4); + fread(code, 1, 4, fp); if (memcmp(code, gPassPixEve, 3)) + { +#ifdef FIX_BUGS + // The original game forgot to close the file here + fclose(fp); +#endif return false; + } //Get amount of NPCs - int count = SDL_ReadLE32(fp); + int count = File_ReadLE32(fp); //Load NPCs memset(gNPC, 0, sizeof(gNPC)); @@ -75,12 +83,12 @@ bool LoadEvent(char *path_event) { //Get data from file EVENT eve; - eve.x = SDL_ReadLE16(fp); - eve.y = SDL_ReadLE16(fp); - eve.code_flag = SDL_ReadLE16(fp); - eve.code_event = SDL_ReadLE16(fp); - eve.code_char = SDL_ReadLE16(fp); - eve.bits = SDL_ReadLE16(fp); + eve.x = File_ReadLE16(fp); + eve.y = File_ReadLE16(fp); + eve.code_flag = File_ReadLE16(fp); + eve.code_event = File_ReadLE16(fp); + eve.code_char = File_ReadLE16(fp); + eve.bits = File_ReadLE16(fp); //Set NPC parameters if (eve.bits & npc_altDir) @@ -117,6 +125,7 @@ bool LoadEvent(char *path_event) n++; } + fclose(fp); return true; } diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index 5586abdd..f7ca6e71 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -1,49 +1,52 @@ -#include - -#include +#include +#include +#include #include "NpcTbl.h" #include "NpcAct.h" +#include "File.h" +#include "Generic.h" NPC_TABLE *gNpcTable; bool LoadNpcTable(const char *path) { - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - - if (fp == nullptr) - { - printf("LoadNpcTable failed\nSDL Error: %s\n", SDL_GetError()); + const long size = GetFileSizeLong(path); + if (size == -1) return false; - } - const size_t tblSize = SDL_RWsize(fp); + const long num = size / 0x18; - const size_t npcCount = tblSize / 0x18; - gNpcTable = (NPC_TABLE*)malloc(npcCount * sizeof(NPC_TABLE)); + gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE)); + if (gNpcTable == NULL) + return false; - for (size_t i = 0; i < npcCount; i++) //bits - gNpcTable[i].bits = SDL_ReadLE16(fp); - for (size_t i = 0; i < npcCount; i++) //life - gNpcTable[i].life = SDL_ReadLE16(fp); - for (size_t i = 0; i < npcCount; i++) //surf - fp->read(fp, &gNpcTable[i].surf, 1, 1); - for (size_t i = 0; i < npcCount; i++) //destroy_voice - fp->read(fp, &gNpcTable[i].destroy_voice, 1, 1); - for (size_t i = 0; i < npcCount; i++) //hit_voice - fp->read(fp, &gNpcTable[i].hit_voice, 1, 1); - for (size_t i = 0; i < npcCount; i++) //size - fp->read(fp, &gNpcTable[i].size, 1, 1); - for (size_t i = 0; i < npcCount; i++) //exp - gNpcTable[i].exp = SDL_ReadLE32(fp); - for (size_t i = 0; i < npcCount; i++) //damage - gNpcTable[i].damage = SDL_ReadLE32(fp); - for (size_t i = 0; i < npcCount; i++) //hit - fp->read(fp, &gNpcTable[i].hit, 4, 1); - for (size_t i = 0; i < npcCount; i++) //view - fp->read(fp, &gNpcTable[i].view, 4, 1); + FILE *fp = fopen(path, "rb"); + if (fp == NULL) + return false; + + for (long n = 0; n < num; n++) //bits + gNpcTable[n].bits = File_ReadLE16(fp); + for (long n = 0; n < num; n++) //life + gNpcTable[n].life = File_ReadLE16(fp); + for (long n = 0; n < num; n++) //surf + fread(&gNpcTable[n].surf, 1, 1, fp); + for (long n = 0; n < num; n++) //destroy_voice + fread(&gNpcTable[n].destroy_voice, 1, 1, fp); + for (long n = 0; n < num; n++) //hit_voice + fread(&gNpcTable[n].hit_voice, 1, 1, fp); + for (long n = 0; n < num; n++) //size + fread(&gNpcTable[n].size, 1, 1, fp); + for (long n = 0; n < num; n++) //exp + gNpcTable[n].exp = File_ReadLE32(fp); + for (long n = 0; n < num; n++) //damage + gNpcTable[n].damage = File_ReadLE32(fp); + for (long n = 0; n < num; n++) //hit + fread(&gNpcTable[n].hit, 4, 1, fp); + for (long n = 0; n < num; n++) //view + fread(&gNpcTable[n].view, 4, 1, fp); - SDL_RWclose(fp); + fclose(fp); return true; } diff --git a/src/Profile.cpp b/src/Profile.cpp index b2a6a44d..fb9439d7 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -1,6 +1,8 @@ +#include #include +#include +#include -#include #include "WindowsWrapper.h" #include "CommonDefines.h" @@ -19,7 +21,7 @@ #include "Stage.h" #include "Game.h" #include "BossLife.h" -#include "SelStage.h" +#include "File.h" const char *gDefaultName = "Profile.dat"; const char *gProfileCode = "Do041220"; @@ -29,11 +31,11 @@ bool IsProfile() char path[PATH_LENGTH]; sprintf(path, "%s/%s", gModulePath, gDefaultName); - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; - SDL_RWclose(fp); + fclose(fp); return true; } @@ -50,8 +52,8 @@ bool SaveProfile(char *name) //Open file PROFILE profile; - SDL_RWops *fp = SDL_RWFromFile(path, "wb"); - if (!fp) + FILE *fp = fopen(path, "wb"); + if (fp == NULL) return false; //Set up profile @@ -78,41 +80,41 @@ bool SaveProfile(char *name) memcpy(profile.flags, gFlagNPC, sizeof(profile.flags)); //Write to file - SDL_RWwrite(fp, profile.code, 8, 1); - SDL_WriteLE32(fp, profile.stage); - SDL_WriteLE32(fp, profile.music); - SDL_WriteLE32(fp, profile.x); - SDL_WriteLE32(fp, profile.y); - SDL_WriteLE32(fp, profile.direct); - SDL_WriteLE16(fp, profile.max_life); - SDL_WriteLE16(fp, profile.star); - SDL_WriteLE16(fp, profile.life); - SDL_WriteLE16(fp, profile.a); - SDL_WriteLE32(fp, profile.select_arms); - SDL_WriteLE32(fp, profile.select_item); - SDL_WriteLE32(fp, profile.equip); - SDL_WriteLE32(fp, profile.unit); - SDL_WriteLE32(fp, profile.counter); + fwrite(profile.code, 8, 1, fp); + File_WriteLE32(profile.stage, fp); + File_WriteLE32(profile.music, fp); + File_WriteLE32(profile.x, fp); + File_WriteLE32(profile.y, fp); + File_WriteLE32(profile.direct, fp); + File_WriteLE16(profile.max_life, fp); + File_WriteLE16(profile.star, fp); + File_WriteLE16(profile.life, fp); + File_WriteLE16(profile.a, fp); + File_WriteLE32(profile.select_arms, fp); + File_WriteLE32(profile.select_item, fp); + File_WriteLE32(profile.equip, fp); + File_WriteLE32(profile.unit, fp); + File_WriteLE32(profile.counter, fp); for (int arm = 0; arm < 8; arm++) { - SDL_WriteLE32(fp, profile.arms[arm].code); - SDL_WriteLE32(fp, profile.arms[arm].level); - SDL_WriteLE32(fp, profile.arms[arm].exp); - SDL_WriteLE32(fp, profile.arms[arm].max_num); - SDL_WriteLE32(fp, profile.arms[arm].num); + File_WriteLE32(profile.arms[arm].code, fp); + File_WriteLE32(profile.arms[arm].level, fp); + File_WriteLE32(profile.arms[arm].exp, fp); + File_WriteLE32(profile.arms[arm].max_num, fp); + File_WriteLE32(profile.arms[arm].num, fp); } for (int item = 0; item < 32; item++) - SDL_WriteLE32(fp, profile.items[item].code); + File_WriteLE32(profile.items[item].code, fp); for (int stage = 0; stage < 8; stage++) { - SDL_WriteLE32(fp, profile.permitstage[stage].index); - SDL_WriteLE32(fp, profile.permitstage[stage].event); + File_WriteLE32(profile.permitstage[stage].index, fp); + File_WriteLE32(profile.permitstage[stage].event, fp); } - SDL_RWwrite(fp, profile.permit_mapping, 0x80, 1); - SDL_RWwrite(fp, "FLAG", 4, 1); - SDL_RWwrite(fp, profile.flags, 1000, 1); + fwrite(profile.permit_mapping, 0x80, 1, fp); + fwrite("FLAG", 4, 1, fp); + fwrite(profile.flags, 1000, 1, fp); - SDL_RWclose(fp); + fclose(fp); return true; } @@ -129,51 +131,51 @@ bool LoadProfile(char *name) //Open file PROFILE profile; - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; //Check header code - SDL_RWread(fp, profile.code, 8, 1); + fread(profile.code, 8, 1, fp); if (memcmp(profile.code, gProfileCode, 8)) return false; //Read data - SDL_RWseek(fp, 0, RW_SEEK_SET); //Pixel epic redundant code 😎😎😎 - SDL_RWread(fp, profile.code, 8, 1); - profile.stage = SDL_ReadLE32(fp); - profile.music = SDL_ReadLE32(fp); - profile.x = SDL_ReadLE32(fp); - profile.y = SDL_ReadLE32(fp); - profile.direct = SDL_ReadLE32(fp); - profile.max_life = SDL_ReadLE16(fp); - profile.star = SDL_ReadLE16(fp); - profile.life = SDL_ReadLE16(fp); - profile.a = SDL_ReadLE16(fp); - profile.select_arms = SDL_ReadLE32(fp); - profile.select_item = SDL_ReadLE32(fp); - profile.equip = SDL_ReadLE32(fp); - profile.unit = SDL_ReadLE32(fp); - profile.counter = SDL_ReadLE32(fp); + fseek(fp, 0, SEEK_SET); //Pixel epic redundant code 😎😎😎 + fread(profile.code, 8, 1, fp); + profile.stage = File_ReadLE32(fp); + profile.music = File_ReadLE32(fp); + profile.x = File_ReadLE32(fp); + profile.y = File_ReadLE32(fp); + profile.direct = File_ReadLE32(fp); + profile.max_life = File_ReadLE16(fp); + profile.star = File_ReadLE16(fp); + profile.life = File_ReadLE16(fp); + profile.a = File_ReadLE16(fp); + profile.select_arms = File_ReadLE32(fp); + profile.select_item = File_ReadLE32(fp); + profile.equip = File_ReadLE32(fp); + profile.unit = File_ReadLE32(fp); + profile.counter = File_ReadLE32(fp); for (int arm = 0; arm < 8; arm++) { - profile.arms[arm].code = SDL_ReadLE32(fp); - profile.arms[arm].level = SDL_ReadLE32(fp); - profile.arms[arm].exp = SDL_ReadLE32(fp); - profile.arms[arm].max_num = SDL_ReadLE32(fp); - profile.arms[arm].num = SDL_ReadLE32(fp); + profile.arms[arm].code = File_ReadLE32(fp); + profile.arms[arm].level = File_ReadLE32(fp); + profile.arms[arm].exp = File_ReadLE32(fp); + profile.arms[arm].max_num = File_ReadLE32(fp); + profile.arms[arm].num = File_ReadLE32(fp); } for (int item = 0; item < 32; item++) - profile.items[item].code = SDL_ReadLE32(fp); + profile.items[item].code = File_ReadLE32(fp); for (int stage = 0; stage < 8; stage++) { - profile.permitstage[stage].index = SDL_ReadLE32(fp); - profile.permitstage[stage].event = SDL_ReadLE32(fp); + profile.permitstage[stage].index = File_ReadLE32(fp); + profile.permitstage[stage].event = File_ReadLE32(fp); } - SDL_RWread(fp, profile.permit_mapping, 0x80, 1); - SDL_RWread(fp, profile.FLAG, 4, 1); - SDL_RWread(fp, profile.flags, 1000, 1); - SDL_RWclose(fp); + fread(profile.permit_mapping, 0x80, 1, fp); + fread(profile.FLAG, 4, 1, fp); + fread(profile.flags, 1000, 1, fp); + fclose(fp); //Set things gSelectedArms = profile.select_arms; diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 0ecc2f70..4eb19eaa 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -29,6 +29,7 @@ #include "BossLife.h" #include "SelStage.h" #include "Flash.h" +#include "Generic.h" #define IS_COMMAND(c1, c2, c3) gTS.data[gTS.p_read + 1] == c1 && gTS.data[gTS.p_read + 2] == c2 && gTS.data[gTS.p_read + 3] == c3 @@ -105,16 +106,19 @@ bool LoadTextScript2(const char *name) char path[260]; sprintf(path, "%s/%s", gDataPath, name); + gTS.size = GetFileSizeLong(path); + if (gTS.size == -1) + return false; + //Open file - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; //Read data - gTS.size = SDL_RWsize(fp); - fp->read(fp, gTS.data, 1, gTS.size); + fread(gTS.data, 1, gTS.size, fp); gTS.data[gTS.size] = 0; - fp->close(fp); + fclose(fp); //Set path strcpy(gTS.path, name); @@ -131,30 +135,36 @@ bool LoadTextScript_Stage(char *name) char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, "Head.tsc"); - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - if (!fp) + long head_size = GetFileSizeLong(path); + if (head_size == -1) + return false; + + FILE *fp = fopen(path, "rb"); + if (fp == NULL) return false; //Read Head.tsc - int head_size = SDL_RWsize(fp); - fp->read(fp, gTS.data, 1, head_size); + fread(gTS.data, 1, head_size, fp); EncryptionBinaryData2((uint8_t*)gTS.data, head_size); gTS.data[head_size] = 0; - SDL_RWclose(fp); + fclose(fp); //Open stage's .tsc sprintf(path, "%s/%s", gDataPath, name); - fp = SDL_RWFromFile(path, "rb"); - if (!fp) + long body_size = GetFileSizeLong(path); + if (body_size == -1) + return false; + + fp = fopen(path, "rb"); + if (fp == NULL) return false; //Read stage's tsc - int body_size = SDL_RWsize(fp); - fp->read(fp, &gTS.data[head_size], 1, body_size); + fread(&gTS.data[head_size], 1, body_size, fp); EncryptionBinaryData2((uint8_t*)&gTS.data[head_size], body_size); gTS.data[head_size + body_size] = 0; - SDL_RWclose(fp); + fclose(fp); //Set parameters gTS.size = head_size + body_size; From 0403f26f6638ec0701a3fba8fe1bb125cf9c41bd Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 15 Feb 2019 20:52:03 +0000 Subject: [PATCH 04/22] Two fixes Made InitBack work with .bmp backgrounds, and fixed a file not being closed in Draw.cpp --- src/Back.cpp | 9 +++++++-- src/Draw.cpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index 8b2d5fa5..4c7f0651 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -20,8 +20,13 @@ bool InitBack(char *fName, int type) SDL_Surface *temp = SDL_LoadBMP(path); if (!temp) - return false; - + { + sprintf(path, "%s/%s.bmp", gDataPath, fName); + temp = SDL_LoadBMP(path); + if (!temp) + return false; + } + gBack.partsW = temp->w; gBack.partsH = temp->h; diff --git a/src/Draw.cpp b/src/Draw.cpp index 016b4a7b..8e7a6bab 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -305,6 +305,7 @@ static bool LoadBitmap_File(const char *name, int surf_no, bool create_surface) if (!IsEnableBitmap(fp)) { printf("Tried to load bitmap to surface %d, but it's missing the '(C)Pixel' string\n", surf_no); + fp->close(fp); } else { From b2a024d4b600cae0e1af03eb2fe9002fb560dad7 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 15 Feb 2019 22:43:19 +0000 Subject: [PATCH 05/22] Fixed bad free That's what I get for recycling code I guess. --- src/File.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/File.cpp b/src/File.cpp index dc3a5c68..257e5e7c 100644 --- a/src/File.cpp +++ b/src/File.cpp @@ -25,8 +25,6 @@ long LoadFileToMemory(const char *file_path, unsigned char **file_buffer) { if (fread(*file_buffer, file_size, 1, file) == 1) returned_size = file_size; - - free(file_buffer); } } } From ef4608867109471aac8fdc2f459b063b016d50d4 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 16 Feb 2019 12:50:58 +0000 Subject: [PATCH 06/22] Removed leftover SDL_rwops includes --- src/Back.cpp | 1 - src/Stage.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index 4c7f0651..ab65af7f 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -1,4 +1,3 @@ -#include #include "WindowsWrapper.h" #include "Tags.h" diff --git a/src/Stage.cpp b/src/Stage.cpp index 3c9968f3..31c2f755 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -1,7 +1,6 @@ #include #include -#include #include "WindowsWrapper.h" #include "CommonDefines.h" From eb16fa45dcac179a66477e15c2a1b7663eb13801 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 16 Feb 2019 17:11:15 +0000 Subject: [PATCH 07/22] Revert "hell" This reverts commit 07d01143e6f9585c7800f2c56842f406a2e948cd. --- res/ORG/CURLY.org | Bin 25737 -> 25738 bytes src/Resource/ORG/CURLY.org.h | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/ORG/CURLY.org b/res/ORG/CURLY.org index ae499fb57c6f3218f36caf30436b77e3499f62e1..621e7ed45b6c5a4d0abd387962aa7ab262271ba4 100644 GIT binary patch delta 11 ScmeA?$=G$0aYJVcBO3r7ZUjsK delta 9 QcmeA=$=G?4aYJVc02SW^MF0Q* diff --git a/src/Resource/ORG/CURLY.org.h b/src/Resource/ORG/CURLY.org.h index a16e9510..7db59483 100644 --- a/src/Resource/ORG/CURLY.org.h +++ b/src/Resource/ORG/CURLY.org.h @@ -1,6 +1,6 @@ #pragma once -const unsigned char rCURLY[0x6489] = { +const unsigned char rCURLY[0x648A] = { 0x4F, 0x72, 0x67, 0x2D, 0x30, 0x32, 0x5C, 0x00, 0x04, 0x06, 0x60, 0x00, 0x00, 0x00, 0xB8, 0x05, 0x00, 0x00, 0xE8, 0x03, 0x01, 0x00, 0x00, 0x00, 0xE8, 0x03, 0x42, 0x00, 0x51, 0x02, 0xE8, 0x03, 0x5C, 0x00, 0x00, 0x00, 0xE8, 0x03, 0x3F, 0x00, 0x4A, 0x01, 0xE8, 0x03, 0x2F, 0x00, 0xD9, 0x01, @@ -1609,5 +1609,5 @@ const unsigned char rCURLY[0x6489] = { 0xFF, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0xFF, 0x06, 0xFF, 0x06, 0xFF, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }; From 132f5235106b703f477dca05e85089ed63583ddf Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 16 Feb 2019 22:18:26 +0000 Subject: [PATCH 08/22] Changed direction key fix The old fix kinda just hardcoded the game to English keyboard layouts. Scancode bind the keys based on position instead of meaning, which should work better. --- src/Main.cpp | 270 ++++++++++++++++++++++----------------------------- 1 file changed, 118 insertions(+), 152 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 05e8621b..49ee65c7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -430,6 +430,13 @@ void JoystickProc() } } +#define DO_KEY_PRESS(key) \ + if (event.type == SDL_KEYDOWN) \ + gKey |= key; \ + else \ + gKey &= ~key; \ + break; + bool SystemTask() { //Handle window events @@ -470,186 +477,145 @@ bool SystemTask() break; case SDL_KEYDOWN: + case SDL_KEYUP: + #ifdef FIX_BUGS + //BUG FIX: Pixel relied on key codes for input, but these differ based on keyboard layout. + //This would break the alternate movement keys on typical English keyboards, since the '=' key + //is in a completely different place to where it is on a Japanese keyboard. + //To solve this, we use scancodes instead, which are based on the physical location of keys, + //rather than their meaning. + switch (event.key.keysym.scancode) + { + case SDL_SCANCODE_ESCAPE: + DO_KEY_PRESS(KEY_ESCAPE) + + case SDL_SCANCODE_W: + DO_KEY_PRESS(KEY_MAP) + + case SDL_SCANCODE_LEFT: + DO_KEY_PRESS(KEY_LEFT) + + case SDL_SCANCODE_RIGHT: + DO_KEY_PRESS(KEY_RIGHT) + + case SDL_SCANCODE_UP: + DO_KEY_PRESS(KEY_UP) + + case SDL_SCANCODE_DOWN: + DO_KEY_PRESS(KEY_DOWN) + + case SDL_SCANCODE_X: + DO_KEY_PRESS(KEY_X) + + case SDL_SCANCODE_Z: + DO_KEY_PRESS(KEY_Z) + + case SDL_SCANCODE_S: + DO_KEY_PRESS(KEY_ARMS) + + case SDL_SCANCODE_A: + DO_KEY_PRESS(KEY_ARMSREV) + + case SDL_SCANCODE_RSHIFT: + case SDL_SCANCODE_LSHIFT: + DO_KEY_PRESS(KEY_SHIFT) + + case SDL_SCANCODE_F1: + DO_KEY_PRESS(KEY_F1) + + case SDL_SCANCODE_F2: + DO_KEY_PRESS(KEY_F2) + + case SDL_SCANCODE_Q: + DO_KEY_PRESS(KEY_ITEM) + + case SDL_SCANCODE_COMMA: + DO_KEY_PRESS(KEY_ALT_LEFT) + + case SDL_SCANCODE_PERIOD: + DO_KEY_PRESS(KEY_ALT_DOWN) + + case SDL_SCANCODE_SLASH: + DO_KEY_PRESS(KEY_ALT_RIGHT) + + case SDL_SCANCODE_L: + DO_KEY_PRESS(KEY_ALT_UP) + + case SDL_SCANCODE_SEMICOLON: + DO_KEY_PRESS(KEY_PLUS) + + case SDL_SCANCODE_F5: + gbUseJoystick = false; + break; + } + break; + #else switch (event.key.keysym.sym) { case SDLK_ESCAPE: - gKey |= KEY_ESCAPE; - break; - + DO_KEY_PRESS(KEY_ESCAPE) + case SDLK_w: - gKey |= KEY_MAP; - break; - + DO_KEY_PRESS(KEY_MAP) + case SDLK_LEFT: - gKey |= KEY_LEFT; - break; - + DO_KEY_PRESS(KEY_LEFT) + case SDLK_RIGHT: - gKey |= KEY_RIGHT; - break; - + DO_KEY_PRESS(KEY_RIGHT) + case SDLK_UP: - gKey |= KEY_UP; - break; - + DO_KEY_PRESS(KEY_UP) + case SDLK_DOWN: - gKey |= KEY_DOWN; - break; - + DO_KEY_PRESS(KEY_DOWN) + case SDLK_x: - gKey |= KEY_X; - break; - + DO_KEY_PRESS(KEY_X) + case SDLK_z: - gKey |= KEY_Z; - break; - + DO_KEY_PRESS(KEY_Z) + case SDLK_s: - gKey |= KEY_ARMS; - break; - + DO_KEY_PRESS(KEY_ARMS) + case SDLK_a: - gKey |= KEY_ARMSREV; - break; - + DO_KEY_PRESS(KEY_ARMSREV) + case SDLK_RSHIFT: case SDLK_LSHIFT: - gKey |= KEY_SHIFT; - break; - + DO_KEY_PRESS(KEY_SHIFT) + case SDLK_F1: - gKey |= KEY_F1; - break; - + DO_KEY_PRESS(KEY_F1) + case SDLK_F2: - gKey |= KEY_F2; - break; - + DO_KEY_PRESS(KEY_F2) + case SDLK_q: - gKey |= KEY_ITEM; - break; - + DO_KEY_PRESS(KEY_ITEM) + case SDLK_COMMA: - gKey |= KEY_ALT_LEFT; - break; - + DO_KEY_PRESS(KEY_ALT_LEFT) + case SDLK_PERIOD: - gKey |= KEY_ALT_DOWN; - break; - + DO_KEY_PRESS(KEY_ALT_DOWN) + case SDLK_SLASH: - gKey |= KEY_ALT_RIGHT; - break; - + DO_KEY_PRESS(KEY_ALT_RIGHT) + case SDLK_l: - gKey |= KEY_ALT_UP; - break; - - #ifdef FIX_BUGS //BUG FIX: Pixel intended for the second alternate up key to be the plus key, Japanese keyboards have the plus key where the semi-colon key is, causing errors on other keyboard layouts) - case SDLK_PLUS: - #else + DO_KEY_PRESS(KEY_ALT_UP) + case SDLK_SEMICOLON: - #endif - gKey |= KEY_PLUS; - break; + DO_KEY_PRESS(KEY_PLUS) case SDLK_F5: gbUseJoystick = false; break; - - default: - break; - } - break; - - case SDL_KEYUP: - switch (event.key.keysym.sym) - { - case SDLK_ESCAPE: - gKey &= ~KEY_ESCAPE; - break; - - case SDLK_w: - gKey &= ~KEY_MAP; - break; - - case SDLK_LEFT: - gKey &= ~KEY_LEFT; - break; - - case SDLK_RIGHT: - gKey &= ~KEY_RIGHT; - break; - - case SDLK_UP: - gKey &= ~KEY_UP; - break; - - case SDLK_DOWN: - gKey &= ~KEY_DOWN; - break; - - case SDLK_x: - gKey &= ~KEY_X; - break; - - case SDLK_z: - gKey &= ~KEY_Z; - break; - - case SDLK_s: - gKey &= ~KEY_ARMS; - break; - - case SDLK_a: - gKey &= ~KEY_ARMSREV; - break; - - case SDLK_RSHIFT: - case SDLK_LSHIFT: - gKey &= ~KEY_SHIFT; - break; - - case SDLK_F1: - gKey &= ~KEY_F1; - break; - - case SDLK_F2: - gKey &= ~KEY_F2; - break; - - case SDLK_q: - gKey &= ~KEY_ITEM; - break; - - case SDLK_COMMA: - gKey &= ~KEY_ALT_LEFT; - break; - - case SDLK_PERIOD: - gKey &= ~KEY_ALT_DOWN; - break; - - case SDLK_SLASH: - gKey &= ~KEY_ALT_RIGHT; - break; - - case SDLK_l: - gKey &= ~KEY_ALT_UP; - break; - - #ifdef FIX_BUGS //BUG FIX: Pixel intended for the second alternate up key to be the plus key, Japanese keyboards have the plus key where the semi-colon key is, causing errors on other keyboard layouts) - case SDLK_PLUS: - #else - case SDLK_SEMICOLON: - #endif - gKey &= ~KEY_PLUS; - break; - - default: - break; } break; + #endif } } From 99474e4aefae152c231b9aa6d9888d8706147141 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 17 Feb 2019 00:43:38 +0000 Subject: [PATCH 09/22] Fix another capitalisation error in the stage table Should probably stick these fixes in FIX_BUGS at some point... --- src/Stage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stage.cpp b/src/Stage.cpp index 31c2f755..70abc405 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -89,7 +89,7 @@ const STAGE_TABLE gTMT[95] = { STAGE_ENTRY("Cent", "Cent", 1, "bkGreen", "Guest", "Cent", 0, "Plantation", "‘å”_‰€"), STAGE_ENTRY("Jail", "Jail1", 4, "bk0", "Guest", "Cent", 0, "Jail No. 1", "‘æ‚P˜S"), STAGE_ENTRY("Jail", "Momo", 4, "bk0", "Guest", "0", 0, "Hideout", "ƒJƒNƒŒƒK"), - STAGE_ENTRY("Jail", "lounge", 4, "bk0", "Guest", "0", 0, "Rest Area", "‹xŒeŠ"), + STAGE_ENTRY("Jail", "Lounge", 4, "bk0", "Guest", "0", 0, "Rest Area", "‹xŒeŠ"), STAGE_ENTRY("Store", "CentW", 4, "bk0", "Guest", "Cent", 0, "Teleporter", "“]‘—Žº"), STAGE_ENTRY("Store", "Jail2", 4, "bk0", "Guest", "Cent", 0, "Jail No. 2", "‘æ‚Q˜S"), STAGE_ENTRY("White", "Blcny1", 7, "bkFog", "Ravil", "Heri", 0, "Balcony", "ƒoƒ‹ƒRƒj["), From f9a4ea9ed4d03e05824f03032225cd5179aea276 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 18 Feb 2019 02:39:38 +0000 Subject: [PATCH 10/22] Fixed an inaccuracy in NPC002 (Behemoth) Was missing some calls for the sound effects, screen rumble, and smoke NPC --- src/NpcAct000.cpp | 69 +++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 1f0ee050..ff5f1c1e 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -214,14 +214,14 @@ void ActNpc002(NPCHAR *npc) rcLeft[5] = {128, 0, 160, 24}; rcLeft[6] = {160, 0, 192, 24}; - RECT rcUp[7]; - rcUp[0] = {32, 24, 64, 48}; - rcUp[1] = {0, 24, 32, 48}; - rcUp[2] = {32, 24, 64, 48}; - rcUp[3] = {64, 24, 96, 48}; - rcUp[4] = {96, 24, 128, 48}; - rcUp[5] = {128, 24, 160, 48}; - rcUp[6] = {160, 24, 192, 48}; + RECT rcRight[7]; + rcRight[0] = {32, 24, 64, 48}; + rcRight[1] = {0, 24, 32, 48}; + rcRight[2] = {32, 24, 64, 48}; + rcRight[3] = {64, 24, 96, 48}; + rcRight[4] = {96, 24, 128, 48}; + rcRight[5] = {128, 24, 160, 48}; + rcRight[6] = {160, 24, 192, 48}; //Turn when touching a wall if (npc->flag & 1) @@ -231,6 +231,28 @@ void ActNpc002(NPCHAR *npc) switch (npc->act_no) { + case 0: //Walking + if (npc->direct) + npc->xm = 0x100; + else + npc->xm = -0x100; + + if (++npc->ani_wait > 8) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 3) + npc->ani_no = 0; + + if (npc->shock) + { + npc->count1 = 0; + npc->act_no = 1; + npc->ani_no = 4; + } + break; case 1: //Shot npc->xm = 7 * npc->xm / 8; @@ -270,28 +292,11 @@ void ActNpc002(NPCHAR *npc) } if (npc->ani_no > 6) + { npc->ani_no = 5; - break; - case 0: //Walking - if (npc->direct) - npc->xm = 0x100; - else - npc->xm = -0x100; - - if (++npc->ani_wait > 8) - { - npc->ani_wait = 0; - ++npc->ani_no; - } - - if (npc->ani_no > 3) - npc->ani_no = 0; - - if (npc->shock) - { - npc->count1 = 0; - npc->act_no = 1; - npc->ani_no = 4; + PlaySoundObject(26, 1); + SetNpChar(4, npc->x, npc->y + 0x600, 0, 0, 0, 0, 0x100); + SetQuake(8); } break; } @@ -306,10 +311,10 @@ void ActNpc002(NPCHAR *npc) npc->y += npc->ym; //Set framerect - if (npc->direct) - npc->rect = rcUp[npc->ani_no]; - else + if (npc->direct == 0) npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; } //Dead enemy (make sure damage shown doesn't teleport to a new loaded npc) From 1042d3fcf2d713ba1485d9ffb6cb6202a0406fea Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 18 Feb 2019 02:56:27 +0000 Subject: [PATCH 11/22] Note a difference in the old Linux port --- src/NpcAct000.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index ff5f1c1e..7659e3cd 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -294,6 +294,7 @@ void ActNpc002(NPCHAR *npc) if (npc->ani_no > 6) { npc->ani_no = 5; + // These three lines are missing in the Linux port. Could this be because it's based on an older version? PlaySoundObject(26, 1); SetNpChar(4, npc->x, npc->y + 0x600, 0, 0, 0, 0, 0x100); SetQuake(8); From f08c1c3aa6d3f54192b7d1aed63c72523d320558 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 18 Feb 2019 13:24:10 +0000 Subject: [PATCH 12/22] Added some bugfixes and cleanup --- src/NpcAct000.cpp | 6 ++++++ src/NpcAct080.cpp | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 7659e3cd..ee8a0118 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -123,9 +123,15 @@ void ActNpc001(NPCHAR *npc) if (npc->x <= 0x9FFF) npc->cond = 0; +#ifdef FIX_BUGS + //Limit speed + if (npc->xm < -0x5FF) + npc->xm = -0x5FF; +#else //Limit speed (except pixel applied it to the X position) if (npc->x < -0x5FF) npc->x = -0x5FF; +#endif //Bounce off walls if (npc->flag & 1) diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index 6bd867f8..f7b30fb8 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -57,7 +57,7 @@ void ActNpc080(NPCHAR *npc) npc->ani_no = 1; npc->ani_wait = 0; npc->act_no = 2; - npc->bits &= ~0x20u; + npc->bits &= ~0x20; } if (gMC.x >= npc->x) @@ -91,16 +91,16 @@ void ActNpc080(NPCHAR *npc) npc->xm = 0x400; } - if (gMC.x >= npc->x) - { - npc->direct = 2; - npc->xm = 0x100; - } - else + if (gMC.x < npc->x) { npc->direct = 0; npc->xm = -0x100; } + else + { + npc->direct = 2; + npc->xm = 0x100; + } break; @@ -150,10 +150,17 @@ void ActNpc080(NPCHAR *npc) if (npc->xm < -0x400) npc->xm = -0x400; +#ifdef FIX_BUGS + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + if (npc->ym < -0x5FF) + npc->ym = -0x5FF; +#else if (npc->ym > 0x5FF) npc->xm = 0x5FF; if (npc->ym < -0x5FF) npc->xm = -0x5FF; +#endif npc->x += npc->xm; npc->y += npc->ym; From 132d3c511072eb4d380c3f5c5c7dd1a7029dbeaf Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 18 Feb 2019 14:36:58 +0000 Subject: [PATCH 13/22] Applied SURFACE_ID constants to everything --- src/ArmsItem.cpp | 32 +++++++++--------- src/Boss.cpp | 2 +- src/Bullet.cpp | 2 +- src/Caret.cpp | 2 +- src/Draw.cpp | 30 ++++++++--------- src/Draw.h | 82 ++++++++++++++++++++++++--------------------- src/Ending.cpp | 6 ++-- src/Escape.cpp | 2 +- src/Fade.cpp | 2 +- src/Game.cpp | 14 ++++---- src/GenericLoad.cpp | 34 +++++++++---------- src/MiniMap.cpp | 12 +++---- src/MyChar.cpp | 10 +++--- src/MycParam.cpp | 36 ++++++++++---------- src/NpChar.h | 4 ++- src/NpcAct060.cpp | 2 +- src/NpcAct340.cpp | 10 +++--- src/NpcTbl.h | 3 +- src/SelStage.cpp | 6 ++-- src/Star.cpp | 2 +- src/TextScr.cpp | 48 +++++++++++++------------- src/ValueView.cpp | 8 ++--- 22 files changed, 179 insertions(+), 170 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 72e78256..47cc9925 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -265,27 +265,27 @@ void PutCampObject() //Draw box int y; - PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, (WINDOW_HEIGHT - 224) / 2, &rcBoxTop, 26); + PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, (WINDOW_HEIGHT - 224) / 2, &rcBoxTop, SURFACE_ID_TEXT_BOX); for (y = 1; y < 18; y++) - PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBody, 26); - PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBottom, 26); + PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBody, SURFACE_ID_TEXT_BOX); + PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBottom, SURFACE_ID_TEXT_BOX); //Move titles if (gCampTitleY > (WINDOW_HEIGHT - 208) / 2) --gCampTitleY; //Draw titles - PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY, &rcTitle1, 26); - PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY + 52, &rcTitle2, 26); + PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY, &rcTitle1, SURFACE_ID_TEXT_BOX); + PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY + 52, &rcTitle2, SURFACE_ID_TEXT_BOX); //Draw arms cursor static int flash; ++flash; if (gCampActive) - PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], 26); + PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], SURFACE_ID_TEXT_BOX); else - PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash >> 1) & 1], 26); + PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash >> 1) & 1], SURFACE_ID_TEXT_BOX); //Draw arms for (int i = 0; i < ARMS_MAX && gArmsData[i].code; i++) @@ -296,9 +296,9 @@ void PutCampObject() rcArms.top = 16 * (gArmsData[i].code / 16); rcArms.bottom = rcArms.top + 16; - PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 192) / 2, &rcArms, 12); - PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 128) / 2, &rcPer, 26); - PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, &rcLv, 26); + PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 192) / 2, &rcArms, SURFACE_ID_ARMS_IMAGE); + PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 128) / 2, &rcPer, SURFACE_ID_TEXT_BOX); + PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, &rcLv, SURFACE_ID_TEXT_BOX); PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, gArmsData[i].level, 0); //Draw ammo @@ -309,16 +309,16 @@ void PutCampObject() } else { - PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 144) / 2, &rcNone, 26); - PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 128) / 2, &rcNone, 26); + PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 144) / 2, &rcNone, SURFACE_ID_TEXT_BOX); + PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 128) / 2, &rcNone, SURFACE_ID_TEXT_BOX); } } //Draw items cursor if (gCampActive) - PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[(flash >> 1) & 1], 26); + PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[(flash >> 1) & 1], SURFACE_ID_TEXT_BOX); else - PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], 26); + PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], SURFACE_ID_TEXT_BOX); for (int i = 0; i < ITEM_MAX && gItemData[i].code; i++) { @@ -328,7 +328,7 @@ void PutCampObject() rcItem.top = 16 * (gItemData[i].code / 8); rcItem.bottom = rcItem.top + 16; - PutBitmap3(&rcView, 32 * (i % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (i / 6) + (WINDOW_HEIGHT - 88) / 2, &rcItem, 8); + PutBitmap3(&rcView, 32 * (i % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (i / 6) + (WINDOW_HEIGHT - 88) / 2, &rcItem, SURFACE_ID_ITEM_IMAGE); } } @@ -383,7 +383,7 @@ int CampLoop() return 2; } - PutBitmap4(&rcView, 0, 0, &rcView, 10); + PutBitmap4(&rcView, 0, 0, &rcView, SURFACE_ID_SCREEN_GRAB); PutCampObject(); PutTextScript(); PutFramePerSecound(); diff --git a/src/Boss.cpp b/src/Boss.cpp index 658cdb81..e5584f94 100644 --- a/src/Boss.cpp +++ b/src/Boss.cpp @@ -66,7 +66,7 @@ void PutBossChar(int fx, int fy) (gBoss[b].x - side) / 0x200 - fx / 0x200 + a, (gBoss[b].y - gBoss[b].view.top) / 0x200 - fy / 0x200, &gBoss[b].rect, - 22); + SURFACE_ID_LEVEL_SPRITESET_2); } } } diff --git a/src/Bullet.cpp b/src/Bullet.cpp index eac79056..94a4831a 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -135,7 +135,7 @@ void PutBullet(int fx, int fy) break; } - PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, 17); + PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, SURFACE_ID_BULLET); } } } diff --git a/src/Caret.cpp b/src/Caret.cpp index 18c69d3d..55b49c7f 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -539,7 +539,7 @@ void PutCaret(int fx, int fy) (gCrt[i].x - gCrt[i].view_left) / 0x200 - fx / 0x200, (gCrt[i].y - gCrt[i].view_top) / 0x200 - fy / 0x200, &gCrt[i].rect, - 19); + SURFACE_ID_CARET); } } } diff --git a/src/Draw.cpp b/src/Draw.cpp index 8e7a6bab..6fbce920 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -133,7 +133,7 @@ void ReleaseSurface(int s) } } -bool MakeSurface_Generic(int bxsize, int bysize, int surf_no) +bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no) { bool success = false; @@ -182,7 +182,7 @@ bool MakeSurface_Generic(int bxsize, int bysize, int surf_no) return success; } -static void FlushSurface(int surf_no) +static void FlushSurface(Surface_Ids surf_no) { unsigned char *raw_pixels; int pitch; @@ -209,7 +209,7 @@ static void FlushSurface(int surf_no) SDL_UnlockTexture(surf[surf_no].texture); } -static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface) +static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface) { bool success = false; @@ -292,7 +292,7 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface) return success; } -static bool LoadBitmap_File(const char *name, int 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; @@ -329,7 +329,7 @@ static bool LoadBitmap_File(const char *name, int surf_no, bool create_surface) return false; } -static bool LoadBitmap_Resource(const char *res, int surf_no, bool create_surface) +static bool LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool create_surface) { SDL_RWops *fp = FindResource(res); @@ -344,22 +344,22 @@ static bool LoadBitmap_Resource(const char *res, int surf_no, bool create_surfac return false; } -bool MakeSurface_File(const char *name, int surf_no) +bool MakeSurface_File(const char *name, Surface_Ids surf_no) { return LoadBitmap_File(name, surf_no, true); } -bool MakeSurface_Resource(const char *res, int surf_no) +bool MakeSurface_Resource(const char *res, Surface_Ids surf_no) { return LoadBitmap_Resource(res, surf_no, true); } -bool ReloadBitmap_File(const char *name, int surf_no) +bool ReloadBitmap_File(const char *name, Surface_Ids surf_no) { return LoadBitmap_File(name, surf_no, false); } -bool ReloadBitmap_Resource(const char *res, int surf_no) +bool ReloadBitmap_Resource(const char *res, Surface_Ids surf_no) { return LoadBitmap_Resource(res, surf_no, false); } @@ -374,7 +374,7 @@ SDL_Rect RectToSDLRect(RECT *rect) return SDLRect; } -void BackupSurface(int surf_no, RECT *rect) +void BackupSurface(Surface_Ids surf_no, RECT *rect) { //Get renderer size int w, h; @@ -396,7 +396,7 @@ void BackupSurface(int surf_no, RECT *rect) SDL_FreeSurface(surface); } -static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, int 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) { @@ -427,12 +427,12 @@ static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, int surf_no, bool SDL_RenderSetClipRect(gRenderer, NULL); } -void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, int 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); } -void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, int 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); } @@ -459,7 +459,7 @@ void CortBox(RECT *rect, uint32_t col) SDL_RenderFillRect(gRenderer, &destRect); } -void CortBox2(RECT *rect, uint32_t col, int surf_no) +void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no) { //Get rect SDL_Rect destRect = RectToSDLRect(rect); @@ -581,7 +581,7 @@ void PutText(int x, int y, const char *text, uint32_t color) SDL_DestroyTexture(screen_texture); } -void PutText2(int x, int y, const char *text, uint32_t color, int surf_no) +void PutText2(int x, int y, const char *text, uint32_t color, Surface_Ids surf_no) { DrawText(gFont, surf[surf_no].surface, x * magnification, y * magnification, color, text, strlen(text)); surf[surf_no].needs_updating = true; diff --git a/src/Draw.h b/src/Draw.h index 2e7aed58..dc834463 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -12,35 +12,41 @@ extern RECT grcFull; extern int magnification; extern bool fullscreen; -enum Surface_Ids +typedef enum Surface_Ids { - SURFACE_ID_TITLE = 0x0, - SURFACE_ID_PIXEL = 0x1, - SURFACE_ID_LEVEL_TILESET = 0x2, - SURFACE_ID_FADE = 0x6, - SURFACE_ID_ITEM_IMAGE = 0x8, - SURFACE_ID_MAP = 0x9, - SURFACE_ID_SCREEN_GRAB = 0xA, - SURFACE_ID_ARMS = 0xB, - SURFACE_ID_ARMS_IMAGE = 0xC, - SURFACE_ID_ROOM_NAME = 0xD, - SURFACE_ID_STAGE_ITEM = 0xE, - SURFACE_ID_LOADING = 0xF, - SURFACE_ID_MY_CHAR = 0x10, - SURFACE_ID_BULLET = 0x11, - SURFACE_ID_CARET = 0x13, - SURFACE_ID_NPC_SYM = 0x14, - SURFACE_ID_LEVEL_SPRITESET_1 = 0x15, - SURFACE_ID_LEVEL_SPRITESET_2 = 0x16, - SURFACE_ID_NPC_REGU = 0x17, - SURFACE_ID_TEXT_BOX = 0x1A, - SURFACE_ID_FACE = 0x1B, - SURFACE_ID_LEVEL_BACKGROUND = 0x1C, - SURFACE_ID_CREDIT_CAST = 0x23, - SURFACE_ID_CREDITS_IMAGE = 0x24, - SURFACE_ID_CASTS = 0x25, - SURFACE_ID_MAX = 0x28, -}; + SURFACE_ID_TITLE = 0, + SURFACE_ID_PIXEL = 1, + SURFACE_ID_LEVEL_TILESET = 2, + SURFACE_ID_FADE = 6, + SURFACE_ID_ITEM_IMAGE = 8, + SURFACE_ID_MAP = 9, + SURFACE_ID_SCREEN_GRAB = 10, + SURFACE_ID_ARMS = 11, + SURFACE_ID_ARMS_IMAGE = 12, + SURFACE_ID_ROOM_NAME = 13, + SURFACE_ID_STAGE_ITEM = 14, + SURFACE_ID_LOADING = 15, + SURFACE_ID_MY_CHAR = 16, + SURFACE_ID_BULLET = 17, + SURFACE_ID_CARET = 19, + SURFACE_ID_NPC_SYM = 20, + SURFACE_ID_LEVEL_SPRITESET_1 = 21, + SURFACE_ID_LEVEL_SPRITESET_2 = 22, + SURFACE_ID_NPC_REGU = 23, + SURFACE_ID_TEXT_BOX = 26, + SURFACE_ID_FACE = 27, + SURFACE_ID_LEVEL_BACKGROUND = 28, + SURFACE_ID_VALUE_VIEW = 29, + SURFACE_ID_TEXT_LINE1 = 30, + SURFACE_ID_TEXT_LINE2 = 31, + SURFACE_ID_TEXT_LINE3 = 32, + SURFACE_ID_TEXT_LINE4 = 33, + SURFACE_ID_TEXT_LINE5 = 34, + SURFACE_ID_CREDIT_CAST = 35, + SURFACE_ID_CREDITS_IMAGE = 36, + SURFACE_ID_CASTS = 37, + SURFACE_ID_MAX = 40, +} Surface_Ids; struct SURFACE { @@ -56,18 +62,18 @@ bool Flip_SystemTask(); bool StartDirectDraw(int lMagnification, int lColourDepth); void EndDirectDraw(); void ReleaseSurface(int s); -bool MakeSurface_File(const char *name, int surf_no); -bool MakeSurface_Resource(const char *res, int surf_no); -bool ReloadBitmap_File(const char *name, int surf_no); -bool ReloadBitmap_Resource(const char *res, int surf_no); -bool MakeSurface_Generic(int bxsize, int bysize, int surf_no); -void BackupSurface(int surf_no, RECT *rect); -void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, int surf_no); -void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, int surf_no); +bool MakeSurface_File(const char *name, Surface_Ids surf_no); +bool MakeSurface_Resource(const char *res, Surface_Ids surf_no); +bool ReloadBitmap_File(const char *name, Surface_Ids surf_no); +bool ReloadBitmap_Resource(const char *res, Surface_Ids surf_no); +bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no); +void BackupSurface(Surface_Ids surf_no, RECT *rect); +void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no); +void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no); void Surface2Surface(int x, int y, RECT *rect, int to, int from); void CortBox(RECT *rect, uint32_t col); -void CortBox2(RECT *rect, uint32_t col, int surf_no); +void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no); void InitTextObject(const char *font_name); void PutText(int x, int y, const char *text, uint32_t color); -void PutText2(int x, int y, const char *text, uint32_t color, int surf_no); +void PutText2(int x, int y, const char *text, uint32_t color, Surface_Ids surf_no); void EndTextObject(); diff --git a/src/Ending.cpp b/src/Ending.cpp index 8d4dd5af..1a045e42 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -455,9 +455,9 @@ int Scene_DownIsland(int mode) //Draw scene CortBox(&grcFull, 0); - PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, 21); - PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, 21); - PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, 21); + PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1); + PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1); + PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1); PutTimeCounter(16, 8); //Draw window diff --git a/src/Escape.cpp b/src/Escape.cpp index f1befd4f..795fcd29 100644 --- a/src/Escape.cpp +++ b/src/Escape.cpp @@ -33,7 +33,7 @@ int Call_Escape() //Draw screen CortBox(&grcFull, 0x000000); - PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, 26); + PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, SURFACE_ID_TEXT_BOX); PutFramePerSecound(); if (!Flip_SystemTask()) diff --git a/src/Fade.cpp b/src/Fade.cpp index 6fd55084..cb25119d 100644 --- a/src/Fade.cpp +++ b/src/Fade.cpp @@ -283,7 +283,7 @@ void PutFade() { rect.left = 16 * gFade.ani_no[y][x]; rect.right = rect.left + 16; - PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, 6); + PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, SURFACE_ID_FADE); } } } diff --git a/src/Game.cpp b/src/Game.cpp index f7f2f8b8..fa5fbd50 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -352,14 +352,14 @@ int ModeTitle() PutNumber4((WINDOW_WIDTH + 56) / 2, WINDOW_HEIGHT - 24, v4, 0); //Draw main title - PutBitmap3(&grcGame, (WINDOW_WIDTH - 144) / 2, 40, &rcTitle, 0); - PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 16) / 2, &rcNew, 0); - PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 56) / 2, &rcContinue, 0); - PutBitmap3(&grcGame, (WINDOW_WIDTH - 160) / 2, WINDOW_HEIGHT - 48, &rcPixel, 1); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 144) / 2, 40, &rcTitle, SURFACE_ID_TITLE); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 16) / 2, &rcNew, SURFACE_ID_TITLE); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 56) / 2, &rcContinue, SURFACE_ID_TITLE); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 160) / 2, WINDOW_HEIGHT - 48, &rcPixel, SURFACE_ID_PIXEL); //Draw character cursor RECT char_rc; - int char_surf; + Surface_Ids char_surf; switch ( char_type ) { @@ -530,7 +530,7 @@ int ModeAction() //Open inventory if (gKeyTrg & gKeyItem) { - BackupSurface(10, &grcGame); + BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame); switch (CampLoop()) { @@ -544,7 +544,7 @@ int ModeAction() } else if (gMC.equip & 2 && gKeyTrg & gKeyMap) { - BackupSurface(10, &grcGame); + BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame); switch (MiniMapLoop()) { diff --git a/src/GenericLoad.cpp b/src/GenericLoad.cpp index b6edacd2..7c1c660f 100644 --- a/src/GenericLoad.cpp +++ b/src/GenericLoad.cpp @@ -149,37 +149,37 @@ static const PIXTONEPARAMETER gPtpTable[139] = bool LoadGenericData() { - MakeSurface_Resource("PIXEL", 1); + MakeSurface_Resource("PIXEL", SURFACE_ID_PIXEL); bool bError = false; - if (!MakeSurface_File("MyChar", 16)) + if (!MakeSurface_File("MyChar", SURFACE_ID_MY_CHAR)) bError = true; - if (!MakeSurface_File("Title", 0)) + if (!MakeSurface_File("Title", SURFACE_ID_TITLE)) bError = true; - if (!MakeSurface_File("ArmsImage", 12)) + if (!MakeSurface_File("ArmsImage", SURFACE_ID_ARMS_IMAGE)) bError = true; - if (!MakeSurface_File("Arms", 11)) + if (!MakeSurface_File("Arms", SURFACE_ID_ARMS)) bError = true; - if (!MakeSurface_File("ItemImage", 8)) + if (!MakeSurface_File("ItemImage", SURFACE_ID_ITEM_IMAGE)) bError = true; - if (!MakeSurface_File("StageImage", 14)) + if (!MakeSurface_File("StageImage", SURFACE_ID_STAGE_ITEM)) bError = true; - if (!MakeSurface_File("Npc/NpcSym", 20)) + if (!MakeSurface_File("Npc/NpcSym", SURFACE_ID_NPC_SYM)) bError = true; - if (!MakeSurface_File("Npc/NpcRegu", 23)) + if (!MakeSurface_File("Npc/NpcRegu", SURFACE_ID_NPC_REGU)) bError = true; - if (!MakeSurface_File("TextBox", 26)) + if (!MakeSurface_File("TextBox", SURFACE_ID_TEXT_BOX)) bError = true; - if (!MakeSurface_File("Caret", 19)) + if (!MakeSurface_File("Caret", SURFACE_ID_CARET)) bError = true; - if (!MakeSurface_File("Bullet", 17)) + if (!MakeSurface_File("Bullet", SURFACE_ID_BULLET)) bError = true; - if (!MakeSurface_File("Face", 27)) + if (!MakeSurface_File("Face", SURFACE_ID_FACE)) bError = true; - if (!MakeSurface_File("Fade", 6)) + if (!MakeSurface_File("Fade", SURFACE_ID_FADE)) bError = true; - MakeSurface_Resource("CREDIT01", 36); + MakeSurface_Resource("CREDIT01", SURFACE_ID_CREDITS_IMAGE); if (bError) { @@ -190,10 +190,10 @@ bool LoadGenericData() MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_SCREEN_GRAB); MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_LEVEL_BACKGROUND); MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_MAP); - MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, 37); //Unknown? + MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_CASTS); MakeSurface_Generic(256, 256, SURFACE_ID_LEVEL_TILESET); MakeSurface_Generic(160, 16, SURFACE_ID_ROOM_NAME); - MakeSurface_Generic(40, 240, 29); //Unknown? + MakeSurface_Generic(40, 240, SURFACE_ID_VALUE_VIEW); MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_1); MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_2); MakeSurface_Generic(WINDOW_WIDTH, 16 * MAX_STRIP, SURFACE_ID_CREDIT_CAST); diff --git a/src/MiniMap.cpp b/src/MiniMap.cpp index f4cc37cd..f0f03856 100644 --- a/src/MiniMap.cpp +++ b/src/MiniMap.cpp @@ -100,7 +100,7 @@ int MiniMapLoop() } } - PutBitmap4(&grcGame, 0, 0, &grcGame, 10); + PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB); rcView = {(WINDOW_WIDTH / 2) - f * gMap.width / 16, (WINDOW_HEIGHT / 2) - f * gMap.length / 16, (WINDOW_WIDTH / 2) + f * gMap.width / 16, (WINDOW_HEIGHT / 2) + f * gMap.length / 16}; PutMapName(true); @@ -114,7 +114,7 @@ int MiniMapLoop() RECT rcMiniMap = {0, 0, gMap.width, gMap.length}; rcView.right = --rcView.left + gMap.width + 2; rcView.bottom = --rcView.top + gMap.length + 2; - CortBox2(&rcMiniMap, 0, 9); + CortBox2(&rcMiniMap, 0, SURFACE_ID_MAP); int line = 0; uint8_t my_wait = 0; @@ -136,19 +136,19 @@ int MiniMapLoop() } } - PutBitmap4(&grcGame, 0, 0, &grcGame, 10); + PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB); CortBox(&rcView, 0); if (gMap.length > line) WriteMiniMapLine(line++); if (gMap.length > line) WriteMiniMapLine(line++); - PutBitmap3(&grcGame, rcView.left + 1, rcView.top + 1, &rcMiniMap, 9); + PutBitmap3(&grcGame, rcView.left + 1, rcView.top + 1, &rcMiniMap, SURFACE_ID_MAP); PutMapName(true); if ((++my_wait >> 3) & 1) - PutBitmap3(&grcGame, my_x + rcView.left + 1, my_y + rcView.top + 1, &my_rect, 26); + PutBitmap3(&grcGame, my_x + rcView.left + 1, my_y + rcView.top + 1, &my_rect, SURFACE_ID_TEXT_BOX); PutFramePerSecound(); if (!Flip_SystemTask()) @@ -170,7 +170,7 @@ int MiniMapLoop() } } - PutBitmap4(&grcGame, 0, 0, &grcGame, 10); + PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB); rcView = {(WINDOW_WIDTH / 2) - f * gMap.width / 16, (WINDOW_HEIGHT / 2) - f * gMap.length / 16, (WINDOW_WIDTH / 2) + f * gMap.width / 16, (WINDOW_HEIGHT / 2) + f * gMap.length / 16}; PutMapName(true); CortBox(&rcView, 0); diff --git a/src/MyChar.cpp b/src/MyChar.cpp index 935a20c4..bb0b0854 100644 --- a/src/MyChar.cpp +++ b/src/MyChar.cpp @@ -193,14 +193,14 @@ void PutMyChar(int fx, int fy) (gMC.x - gMC.view.left) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y, &gMC.rect_arms, - 11); + SURFACE_ID_ARMS); else PutBitmap3( &grcGame, (gMC.x - gMC.view.left) / 0x200 - fx / 0x200 - 8, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y, &gMC.rect_arms, - 11); + SURFACE_ID_ARMS); if (!((gMC.shock >> 1) & 1)) { @@ -212,7 +212,7 @@ void PutMyChar(int fx, int fy) rect.bottom += 32; } - PutBitmap3(&grcGame, (gMC.x - gMC.view.left) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, 16); + PutBitmap3(&grcGame, (gMC.x - gMC.view.left) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, SURFACE_ID_MY_CHAR); //Draw airtank RECT rcBubble[2]; @@ -221,9 +221,9 @@ void PutMyChar(int fx, int fy) ++gMC.bubble; if (gMC.equip & 0x10 && gMC.flag & 0x100) - PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], 19); + PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], SURFACE_ID_CARET); else if (gMC.unit == 1) - PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], 19); + PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], SURFACE_ID_CARET); } } } diff --git a/src/MycParam.cpp b/src/MycParam.cpp index ebfd30e2..3918f6ca 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -218,15 +218,15 @@ void PutArmsEnergy(bool flash) } else { - PutBitmap3(&rcView, gArmsEnergyX + 48, 16, &rcNone, 26); - PutBitmap3(&rcView, gArmsEnergyX + 48, 24, &rcNone, 26); + PutBitmap3(&rcView, gArmsEnergyX + 48, 16, &rcNone, SURFACE_ID_TEXT_BOX); + PutBitmap3(&rcView, gArmsEnergyX + 48, 24, &rcNone, SURFACE_ID_TEXT_BOX); } //Draw experience and ammo if (!flash || !((gMC.shock >> 1) & 1)) { - PutBitmap3(&rcView, gArmsEnergyX + 32, 24, &rcPer, 26); - PutBitmap3(&rcView, gArmsEnergyX, 32, &rcLv, 26); + PutBitmap3(&rcView, gArmsEnergyX + 32, 24, &rcPer, SURFACE_ID_TEXT_BOX); + PutBitmap3(&rcView, gArmsEnergyX, 32, &rcLv, SURFACE_ID_TEXT_BOX); PutNumber4(gArmsEnergyX - 8, 32, gArmsData[gSelectedArms].level, 0); RECT rcExpBox = {0, 72, 40, 80}; @@ -239,7 +239,7 @@ void PutArmsEnergy(bool flash) int exp_now = gArmsData[gSelectedArms].exp; int exp_next = gArmsLevelTable[0].exp[lv + 3 * arms_code]; - PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpBox, 26); + PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpBox, SURFACE_ID_TEXT_BOX); if (lv != 2 || gArmsData[gSelectedArms].exp != gArmsLevelTable[0].exp[3 * arms_code + 2]) { @@ -248,16 +248,16 @@ void PutArmsEnergy(bool flash) else rcExpVal.right = 0; - PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpVal, 26); + PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpVal, SURFACE_ID_TEXT_BOX); } else { - PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpMax, 26); + PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpMax, SURFACE_ID_TEXT_BOX); } static int add_flash = true; if (gMC.exp_wait && ((add_flash++ >> 1) & 1)) - PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpFlash, 26); + PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpFlash, SURFACE_ID_TEXT_BOX); } } @@ -293,7 +293,7 @@ void PutActiveArmsList() //Draw icon rect.left = 16 * gArmsData[a].code; rect.right = rect.left + 16; - PutBitmap3(&grcGame, x, 16, &rect, 12); + PutBitmap3(&grcGame, x, 16, &rect, SURFACE_ID_ARMS_IMAGE); } } } @@ -319,9 +319,9 @@ void PutMyLife(bool flash) rcLife.right = 40 * gMC.life / gMC.max_life - 1; rcBr.right = 40 * gMC.lifeBr / gMC.max_life - 1; - PutBitmap3(&grcGame, 16, 40, &rcCase, 26); - PutBitmap3(&grcGame, 40, 40, &rcBr, 26); - PutBitmap3(&grcGame, 40, 40, &rcLife, 26); + PutBitmap3(&grcGame, 16, 40, &rcCase, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcGame, 40, 40, &rcBr, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcGame, 40, 40, &rcLife, SURFACE_ID_TEXT_BOX); PutNumber4(8, 40, gMC.lifeBr, 0); } } @@ -340,9 +340,9 @@ void PutMyAir(int x, int y) //Draw "AIR" text if (gMC.air % 30 <= 10) - PutBitmap3(&grcGame, x, y, &rcAir[1], 26); + PutBitmap3(&grcGame, x, y, &rcAir[1], SURFACE_ID_TEXT_BOX); else - PutBitmap3(&grcGame, x, y, &rcAir[0], 26); + PutBitmap3(&grcGame, x, y, &rcAir[0], SURFACE_ID_TEXT_BOX); } } @@ -362,20 +362,20 @@ void PutTimeCounter(int x, int y) ++time_count; if (time_count % 30 <= 10) - PutBitmap3(&grcGame, x, y, &rcTime[1], 26); + PutBitmap3(&grcGame, x, y, &rcTime[1], SURFACE_ID_TEXT_BOX); else - PutBitmap3(&grcGame, x, y, &rcTime[0], 26); + PutBitmap3(&grcGame, x, y, &rcTime[0], SURFACE_ID_TEXT_BOX); } else { - PutBitmap3(&grcGame, x, y, &rcTime[0], 26); + PutBitmap3(&grcGame, x, y, &rcTime[0], SURFACE_ID_TEXT_BOX); } //Draw time PutNumber4(x, y, time_count / 3000, false); PutNumber4(x + 20, y, time_count / 50 % 60, true); PutNumber4(x + 32, y, time_count / 5 % 10, false); - PutBitmap3(&grcGame, x + 30, y, &rcTime[2], 26); + PutBitmap3(&grcGame, x + 30, y, &rcTime[2], SURFACE_ID_TEXT_BOX); } else { diff --git a/src/NpChar.h b/src/NpChar.h index 4cd6b14e..2ba81838 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -2,6 +2,8 @@ #include #include "WindowsWrapper.h" +#include "Draw.h" + #define NPC_MAX 0x200 enum NPC_flags @@ -38,7 +40,7 @@ struct NPCHAR int code_char; int code_flag; int code_event; - int surf; + Surface_Ids surf; int hit_voice; int destroy_voice; int life; diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index 0e352666..eefcc7e9 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -367,7 +367,7 @@ void ActNpc061(NPCHAR *npc) SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); npc->act_no = 50; - npc->surf = 20; + npc->surf = SURFACE_ID_NPC_SYM; npc->ani_no = 10; } diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp index 606816c7..fe701095 100644 --- a/src/NpcAct340.cpp +++ b/src/NpcAct340.cpp @@ -1479,7 +1479,7 @@ void ActNpc352(NPCHAR *npc) case 9: case 12: case 13: - npc->surf = 21; + npc->surf = SURFACE_ID_LEVEL_SPRITESET_1; break; default: break; @@ -1747,28 +1747,28 @@ void ActNpc355(NPCHAR *npc) switch (npc->direct) { case 0: - npc->surf = 16; + npc->surf = SURFACE_ID_MY_CHAR; npc->ani_no = 0; npc->x = npc->pNpc->x - 0x1C00; npc->y = npc->pNpc->y + 0x1400; break; case 1: - npc->surf = 23; + npc->surf = SURFACE_ID_NPC_REGU; npc->ani_no = 1; npc->x = npc->pNpc->x + 0x1C00; npc->y = npc->pNpc->y + 0x1400; break; case 2: - npc->surf = 16; + npc->surf = SURFACE_ID_MY_CHAR; npc->ani_no = 2; npc->x = npc->pNpc->x - 0xE00; npc->y = npc->pNpc->y - 0x2600; break; case 3: - npc->surf = 23; + npc->surf = SURFACE_ID_NPC_REGU; npc->ani_no = 3; npc->x = npc->pNpc->x + 0x800; npc->y = npc->pNpc->y - 0x2600; diff --git a/src/NpcTbl.h b/src/NpcTbl.h index 53adc243..8a41c7d5 100644 --- a/src/NpcTbl.h +++ b/src/NpcTbl.h @@ -1,6 +1,7 @@ #pragma once #include #include "NpChar.h" +#include "Draw.h" struct NPC_TBL_RECT { @@ -14,7 +15,7 @@ struct NPC_TABLE { uint16_t bits; uint16_t life; - uint8_t surf; + Surface_Ids surf; uint8_t hit_voice; uint8_t destroy_voice; uint8_t size; diff --git a/src/SelStage.cpp b/src/SelStage.cpp index d69277f4..1e576cde 100644 --- a/src/SelStage.cpp +++ b/src/SelStage.cpp @@ -138,7 +138,7 @@ int StageSelectLoop(int *p_event) RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; gSelectedStage = 0; - BackupSurface(10, &grcFull); + BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcFull); GetTextScriptPath(old_script_path); LoadTextScript2("StageSelect.tsc"); gStageSelectTitleY = (WINDOW_HEIGHT / 2) - 66; @@ -166,10 +166,10 @@ int StageSelectLoop(int *p_event) return 2; #ifdef FIX_BUGS - PutBitmap4(&rcView, 0, 0, &rcView, 10); + PutBitmap4(&rcView, 0, 0, &rcView, SURFACE_ID_SCREEN_GRAB); #else // The original accidentally drew the screencap with transparency enabled - PutBitmap3(&rcView, 0, 0, &rcView, 10); + PutBitmap3(&rcView, 0, 0, &rcView, SURFACE_ID_SCREEN_GRAB); #endif PutStageSelectObject(); PutTextScript(); diff --git a/src/Star.cpp b/src/Star.cpp index 49401717..9567b4c1 100644 --- a/src/Star.cpp +++ b/src/Star.cpp @@ -120,7 +120,7 @@ void PutStar(int fx, int fy) for (int i = 0; i < 3; i++) { if (gMC.star > i) - PutBitmap3(&grcGame, star[i].x / 0x200 - fx / 0x200 - 4, star[i].y / 0x200 - fy / 0x200 - 4, &rc[i], 16); + PutBitmap3(&grcGame, star[i].x / 0x200 - fx / 0x200 - 4, star[i].y / 0x200 - fy / 0x200 - 4, &rc[i], SURFACE_ID_MY_CHAR); } } } diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 4eb19eaa..e8050bae 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -53,7 +53,7 @@ BOOL InitTextScript2() //Create line surfaces for (int i = 0; i < 4; i++) - MakeSurface_Generic(gRect_line.right, gRect_line.bottom, i + 30); + MakeSurface_Generic(gRect_line.right, gRect_line.bottom, (Surface_Ids)(i + SURFACE_ID_TEXT_LINE1)); //Clear text memset(text, 0, sizeof(text)); @@ -216,7 +216,7 @@ BOOL StartTextScript(int no) for (int i = 0; i < 4; i++) { gTS.ypos_line[i] = 16 * i; - CortBox2(&gRect_line, 0x000000, i + 30); + CortBox2(&gRect_line, 0x000000, (Surface_Ids)(i + SURFACE_ID_TEXT_LINE1)); memset(&text[i * 0x40], 0, 0x40); }*/ @@ -265,7 +265,7 @@ BOOL JumpTextScript(int no) for (int i = 0; i < 4; i++) { gTS.ypos_line[i] = 16 * i; - CortBox2(&gRect_line, 0x000000, i + 30); + CortBox2(&gRect_line, 0x000000, (Surface_Ids)(i + SURFACE_ID_TEXT_LINE1)); memset(&text[i * 0x40], 0, 0x40); } @@ -317,7 +317,7 @@ void CheckNewLine() { gTS.mode = 3; g_GameFlags |= 4; - CortBox2(&gRect_line, 0, gTS.line % 4 + 30); + CortBox2(&gRect_line, 0, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1)); memset(&text[gTS.line % 4 * 0x40], 0, 0x40); } } @@ -357,7 +357,7 @@ void SetNumberTextScript(int index) str[offset + 1] = 0; //Append number to line - PutText2(6 * gTS.p_write, 0, str, 0xFFFFFE, gTS.line % 4 + 30); + PutText2(6 * gTS.p_write, 0, str, 0xFFFFFE, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1)); strcat(&text[gTS.line % 4 * 0x40], str); //Play sound and reset blinking cursor @@ -385,7 +385,7 @@ void ClearTextLine() for (int i = 0; i < 4; i++) { gTS.ypos_line[i] = 16 * i; - CortBox2(&gRect_line, 0x000000, i + 30); + CortBox2(&gRect_line, 0x000000, (Surface_Ids)(i + SURFACE_ID_TEXT_LINE1)); memset(&text[i * 0x40], 0, 0x40); } } @@ -418,11 +418,11 @@ void PutTextScript() RECT rcFrame2 = {0, 8, 244, 16}; RECT rcFrame3 = {0, 16, 244, 24}; - PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, gTS.rcText.top - 10, &rcFrame1, 26); + PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, gTS.rcText.top - 10, &rcFrame1, SURFACE_ID_TEXT_BOX); int i; for (i = 1; i < 7; i++) - PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, 8 * i + gTS.rcText.top - 10, &rcFrame2, 26); - PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, 8 * i + gTS.rcText.top - 10, &rcFrame3, 26); + PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, 8 * i + gTS.rcText.top - 10, &rcFrame2, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, 8 * i + gTS.rcText.top - 10, &rcFrame3, SURFACE_ID_TEXT_BOX); } //Draw face picture @@ -434,7 +434,7 @@ void PutTextScript() if (gTS.face_x < (TEXT_LEFT * 0x200)) gTS.face_x += 0x1000; - PutBitmap3(&gTS.rcText, gTS.face_x / 0x200, gTS.rcText.top - 3, &rcFace, 27); + PutBitmap3(&gTS.rcText, gTS.face_x / 0x200, gTS.rcText.top - 3, &rcFace, SURFACE_ID_FACE); //Draw text int text_offset; @@ -444,7 +444,7 @@ void PutTextScript() text_offset = 0; for (int i = 0; i < 4; i++) - PutBitmap3(&gTS.rcText, text_offset + TEXT_LEFT, gTS.offsetY + gTS.ypos_line[i] + gTS.rcText.top, &gRect_line, i + 30); + PutBitmap3(&gTS.rcText, text_offset + TEXT_LEFT, gTS.offsetY + gTS.ypos_line[i] + gTS.rcText.top, &gRect_line, (Surface_Ids)(i + SURFACE_ID_TEXT_LINE1)); //Draw NOD cursor if ((gTS.wait_beam++ % 20 > 12) && gTS.mode == 2) @@ -466,12 +466,12 @@ void PutTextScript() if (gTS.item) { - PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 112, &rcItemBox1, 26); - PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 96, &rcItemBox2, 26); - PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 112, &rcItemBox3, 26); - PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 104, &rcItemBox4, 26); - PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 96, &rcItemBox4, 26); - PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 88, &rcItemBox5, 26); + PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 112, &rcItemBox1, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 96, &rcItemBox2, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 112, &rcItemBox3, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 104, &rcItemBox4, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 96, &rcItemBox4, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 88, &rcItemBox5, SURFACE_ID_TEXT_BOX); if (gTS.item_y < WINDOW_HEIGHT - 104) ++gTS.item_y; @@ -483,7 +483,7 @@ void PutTextScript() rect.right = rect.left + 16; rect.top = 16 * (gTS.item / 16); rect.bottom = rect.top + 16; - PutBitmap3(&grcFull, (WINDOW_WIDTH - 24) / 2, gTS.item_y, &rect, 12); + PutBitmap3(&grcFull, (WINDOW_WIDTH - 24) / 2, gTS.item_y, &rect, SURFACE_ID_ARMS_IMAGE); } else { @@ -491,7 +491,7 @@ void PutTextScript() rect.right = rect.left + 32; rect.top = 16 * ((gTS.item - 1000) / 8); rect.bottom = rect.top + 16; - PutBitmap3(&grcFull, (WINDOW_WIDTH - 40) / 2, gTS.item_y, &rect, 8); + PutBitmap3(&grcFull, (WINDOW_WIDTH - 40) / 2, gTS.item_y, &rect, SURFACE_ID_ITEM_IMAGE); } } @@ -507,9 +507,9 @@ void PutTextScript() else i = WINDOW_HEIGHT - 96; - PutBitmap3(&grcFull, (WINDOW_WIDTH + 112) / 2, i, &rect_yesno, 26); + PutBitmap3(&grcFull, (WINDOW_WIDTH + 112) / 2, i, &rect_yesno, SURFACE_ID_TEXT_BOX); if (gTS.wait == 16) - PutBitmap3(&grcFull, 41 * gTS.select + (WINDOW_WIDTH + 102) / 2, WINDOW_HEIGHT - 86, &rect_cur, 26); + PutBitmap3(&grcFull, 41 * gTS.select + (WINDOW_WIDTH + 102) / 2, WINDOW_HEIGHT - 86, &rect_cur, SURFACE_ID_TEXT_BOX); } } @@ -1233,7 +1233,7 @@ int TextScriptProc() gTS.p_write = x; //Print text - PutText2(0, 0, str, 0xFFFFFE, gTS.line % 4 + 30); + PutText2(0, 0, str, 0xFFFFFE, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1)); sprintf(&text[gTS.line % 4 * 0x40], str); //Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping) @@ -1263,11 +1263,11 @@ int TextScriptProc() //Print text if (c[0] == '=') { - Surface2Surface(6 * gTS.p_write, 2, &rcSymbol, gTS.line % 4 + 30, 26); + Surface2Surface(6 * gTS.p_write, 2, &rcSymbol, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1), SURFACE_ID_TEXT_BOX); } else { - PutText2(6 * gTS.p_write, 0, c, 0xFFFFFE, gTS.line % 4 + 30); + PutText2(6 * gTS.p_write, 0, c, 0xFFFFFE, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1)); } strcat(&text[gTS.line % 4 * 0x40], c); diff --git a/src/ValueView.cpp b/src/ValueView.cpp index 48d85c59..7a637d0b 100644 --- a/src/ValueView.cpp +++ b/src/ValueView.cpp @@ -131,12 +131,12 @@ void SetValueView(int *px, int *py, int value) RECT rcMinus = {40, 48, 48, 56}; //Draw value - CortBox2(&gVV[index].rect, 0x000000, 29); + CortBox2(&gVV[index].rect, 0x000000, SURFACE_ID_VALUE_VIEW); if (minus) - Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcMinus, 29, 26); + Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcMinus, SURFACE_ID_VALUE_VIEW, SURFACE_ID_TEXT_BOX); else - Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcPlus, 29, 26); + Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcPlus, SURFACE_ID_VALUE_VIEW, SURFACE_ID_TEXT_BOX); for (int i = 3; i >= 0; i--) { @@ -181,7 +181,7 @@ void PutValueView(int flx, int fly) (*gVV[v].px) / 0x200 - (gVV[v].rect.right - gVV[v].rect.left) / 2 - flx / 0x200, (*gVV[v].py) / 0x200 + gVV[v].offset_y / 0x200 - 4 - fly / 0x200, &gVV[v].rect, - 29); + SURFACE_ID_VALUE_VIEW); } } } From e5caff593c599ab4b07df0df4183d8adc069f77b Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 18 Feb 2019 20:40:07 +0000 Subject: [PATCH 14/22] Removed the SDL dependency from Draw.h Should make compiling with VC++ 2003 simpler --- src/Back.cpp | 52 ++++++++++++++++++++++++++++++++++++++---------- src/Bullet.cpp | 3 +++ src/Caret.cpp | 5 +++-- src/Draw.cpp | 11 ++++++++++ src/Draw.h | 12 +---------- src/Ending.cpp | 7 +++++-- src/Fade.cpp | 2 +- src/Main.cpp | 7 ++++--- src/Map.cpp | 3 ++- src/MapName.cpp | 2 +- src/MiniMap.cpp | 1 + src/MyChar.cpp | 2 +- src/MycParam.cpp | 2 ++ src/NpChar.cpp | 1 + src/Stage.cpp | 1 + src/TextScr.cpp | 4 +++- 16 files changed, 81 insertions(+), 34 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index ab65af7f..bfc3ec5f 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -1,12 +1,15 @@ +#include "Back.h" + +#include #include "WindowsWrapper.h" #include "Tags.h" -#include "Back.h" #include "Frame.h" #include "Game.h" #include "Draw.h" #include "Stage.h" #include "Map.h" +#include "File.h" BACK gBack; int gWaterY; @@ -16,21 +19,48 @@ bool InitBack(char *fName, int type) //Get width and height char path[PATH_LENGTH]; sprintf(path, "%s/%s.pbm", gDataPath, fName); - - SDL_Surface *temp = SDL_LoadBMP(path); - if (!temp) + + FILE *fp = fopen(path, "rb"); + if (fp == NULL) { sprintf(path, "%s/%s.bmp", gDataPath, fName); - temp = SDL_LoadBMP(path); - if (!temp) + fp = fopen(path, "rb"); + if (fp == NULL) return false; } - gBack.partsW = temp->w; - gBack.partsH = temp->h; - - SDL_FreeSurface(temp); - +#ifdef FIX_BUGS // TODO: Maybe we need a 'BETTER_PORTABILITY' flag + if (fgetc(fp) != 'B' || fgetc(fp) != 'M') + { + fclose(fp); + return false; + } + + fseek(fp, 18, SEEK_SET); + + gBack.partsW = File_ReadLE32(fp); + gBack.partsH = File_ReadLE32(fp); + fclose(fp); +#else + // This is ridiculously platform-dependant: + // It should break on big-endian CPUs, and platforms + // where short isn't 16-bit and long isn't 32-bit. + short bmp_header_buffer[7]; + long bmp_header_buffer2[10]; + + fread(bmp_header_buffer, 14, 1, fp); + + // Check if this is a valid bitmap file + if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning) + return false; // The original game forgets to close fp + + fread(bmp_header_buffer2, 40, 1, fp); + fclose(fp); + + gBack.partsW = bmp_header_buffer2[1]; + gBack.partsH = bmp_header_buffer2[2]; +#endif + //Set background stuff and load texture gBack.flag = 1; if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND)) diff --git a/src/Bullet.cpp b/src/Bullet.cpp index 94a4831a..c198a8a9 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -1,4 +1,7 @@ #include "Bullet.h" + +#include + #include "Draw.h" #include "Caret.h" #include "NpChar.h" diff --git a/src/Caret.cpp b/src/Caret.cpp index 55b49c7f..f8b0b563 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -1,8 +1,9 @@ -#include +#include "Caret.h" + +#include #include "WindowsWrapper.h" -#include "Caret.h" #include "Draw.h" #include "Triangle.h" #include "Game.h" diff --git a/src/Draw.cpp b/src/Draw.cpp index 6fbce920..32ee95e2 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -27,6 +27,17 @@ #include "Tags.h" #include "Resource.h" +struct SURFACE +{ + bool in_use; + bool needs_updating; + SDL_Surface *surface; + SDL_Texture *texture; +}; + +SDL_Window *gWindow; +SDL_Renderer *gRenderer; + RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; diff --git a/src/Draw.h b/src/Draw.h index dc834463..48580e57 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -1,10 +1,6 @@ #pragma once #include #include "WindowsWrapper.h" -#include - -extern SDL_Window *gWindow; -extern SDL_Renderer *gRenderer; extern RECT grcGame; extern RECT grcFull; @@ -48,13 +44,7 @@ typedef enum Surface_Ids SURFACE_ID_MAX = 40, } Surface_Ids; -struct SURFACE -{ - bool in_use; - bool needs_updating; - SDL_Surface *surface; - SDL_Texture *texture; -}; +struct SURFACE; extern SURFACE surf[SURFACE_ID_MAX]; diff --git a/src/Ending.cpp b/src/Ending.cpp index 1a045e42..793663f8 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -1,11 +1,14 @@ +#include "Ending.h" + #include -#include +#include +#include +#include #include "WindowsWrapper.h" #include "Tags.h" #include "Generic.h" -#include "Ending.h" #include "Flags.h" #include "KeyControl.h" #include "Escape.h" diff --git a/src/Fade.cpp b/src/Fade.cpp index cb25119d..4c439944 100644 --- a/src/Fade.cpp +++ b/src/Fade.cpp @@ -1,4 +1,4 @@ -#include +#include #include "WindowsWrapper.h" diff --git a/src/Main.cpp b/src/Main.cpp index 49ee65c7..da8b0195 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -21,14 +21,15 @@ #include "Triangle.h" #include "Resource.h" +// These two are defined in Draw.cpp. This is a bit of a hack. +extern SDL_Window *gWindow; +extern SDL_Renderer *gRenderer; + char gModulePath[PATH_LENGTH]; char gDataPath[PATH_LENGTH]; int gJoystickButtonTable[8]; -SDL_Window *gWindow; -SDL_Renderer *gRenderer; - bool gbUseJoystick = false; bool bFps = false; diff --git a/src/Map.cpp b/src/Map.cpp index 307297aa..1cf765a3 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -1,6 +1,7 @@ #include #include -#include +#include +#include #include "WindowsWrapper.h" diff --git a/src/MapName.cpp b/src/MapName.cpp index cd9a4842..015d8908 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "CommonDefines.h" #include "MapName.h" diff --git a/src/MiniMap.cpp b/src/MiniMap.cpp index f0f03856..e588b26a 100644 --- a/src/MiniMap.cpp +++ b/src/MiniMap.cpp @@ -1,4 +1,5 @@ #include +#include #include "WindowsWrapper.h" diff --git a/src/MyChar.cpp b/src/MyChar.cpp index bb0b0854..4a05c8a0 100644 --- a/src/MyChar.cpp +++ b/src/MyChar.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include "WindowsWrapper.h" diff --git a/src/MycParam.cpp b/src/MycParam.cpp index 3918f6ca..c02db6ea 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -1,3 +1,5 @@ +#include "SDL.h" + #include "Sound.h" #include "MyChar.h" #include "MycParam.h" diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 6f3d6907..a34c7835 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "WindowsWrapper.h" diff --git a/src/Stage.cpp b/src/Stage.cpp index 70abc405..425057ca 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "WindowsWrapper.h" diff --git a/src/TextScr.cpp b/src/TextScr.cpp index e8050bae..6cd68665 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -1,5 +1,7 @@ #include -#include +#include +#include +#include #include "WindowsWrapper.h" From 809fb95b26db88269023e67b99b6ffb7585861d2 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 18 Feb 2019 20:40:51 +0000 Subject: [PATCH 15/22] Fix Surface_Ids crash --- src/NpChar.cpp | 4 ++-- src/NpcTbl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NpChar.cpp b/src/NpChar.cpp index a34c7835..85a08003 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -36,7 +36,7 @@ void InitNpChar() void SetUniqueParameter(NPCHAR *npc) { int code = npc->code_char; - npc->surf = gNpcTable[code].surf; + npc->surf = (Surface_Ids)gNpcTable[code].surf; npc->hit_voice = gNpcTable[code].hit_voice; npc->destroy_voice = gNpcTable[code].destroy_voice; npc->damage = gNpcTable[code].damage; @@ -348,7 +348,7 @@ void PutNpChar(int fx, int fy) (gNPC[n].x - side) / 0x200 - fx / 0x200 + a, (gNPC[n].y - gNPC[n].view.top) / 0x200 - fy / 0x200, &gNPC[n].rect, - gNPC[n].surf); + (Surface_Ids)gNPC[n].surf); } } } diff --git a/src/NpcTbl.h b/src/NpcTbl.h index 8a41c7d5..19e43a8f 100644 --- a/src/NpcTbl.h +++ b/src/NpcTbl.h @@ -15,7 +15,7 @@ struct NPC_TABLE { uint16_t bits; uint16_t life; - Surface_Ids surf; + uint8_t surf; uint8_t hit_voice; uint8_t destroy_voice; uint8_t size; From 0bb9760d875deab7f1ffcfe1326737206efd8d0c Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 18 Feb 2019 21:30:22 +0000 Subject: [PATCH 16/22] Rearranged #includes --- src/ArmsItem.cpp | 15 +++++----- src/ArmsItem.h | 1 + src/Back.cpp | 9 +++--- src/Boss.cpp | 17 +++++------ src/Boss.h | 1 + src/BossAlmo1.cpp | 2 ++ src/BossAlmo2.cpp | 3 +- src/BossBallos.cpp | 2 ++ src/BossFrog.cpp | 3 +- src/BossIronH.cpp | 3 +- src/BossLife.cpp | 5 ++-- src/BossOhm.cpp | 10 ++++--- src/BossOhm.h | 1 + src/BossPress.cpp | 3 +- src/BossTwinD.cpp | 3 +- src/BossX.cpp | 3 +- src/BulHit.cpp | 8 ++++-- src/BulHit.h | 1 + src/Bullet.cpp | 6 ++-- src/Bullet.h | 2 ++ src/Caret.cpp | 2 +- src/Caret.h | 1 + src/CommonDefines.h | 1 + src/Config.cpp | 8 +++--- src/Config.h | 1 + src/Draw.cpp | 8 +++--- src/Draw.h | 2 ++ src/Ending.cpp | 18 ++++++------ src/Ending.h | 1 + src/Escape.cpp | 3 +- src/Escape.h | 1 + src/Fade.cpp | 5 ++-- src/Fade.h | 1 + src/Flags.cpp | 2 +- src/Flags.h | 2 ++ src/Frame.cpp | 9 +++--- src/Frame.h | 1 + src/Game.cpp | 68 +++++++++++++++++++++++--------------------- src/Game.h | 1 + src/Generic.cpp | 2 ++ src/Generic.h | 1 + src/GenericLoad.cpp | 6 ++-- src/GenericLoad.h | 1 + src/Input.cpp | 8 ++++-- src/Input.h | 1 + src/KeyControl.cpp | 1 + src/KeyControl.h | 1 + src/Main.cpp | 24 +++++++++------- src/Main.h | 1 + src/Map.cpp | 7 +++-- src/Map.h | 1 + src/MapName.cpp | 3 +- src/MapName.h | 1 + src/MiniMap.cpp | 10 ++++--- src/MiniMap.h | 1 + src/MyChar.cpp | 17 +++++------ src/MyChar.h | 2 ++ src/MycHit.cpp | 18 ++++++------ src/MycHit.h | 1 + src/MycParam.cpp | 21 +++++++------- src/MycParam.h | 2 ++ src/NpChar.cpp | 21 +++++++------- src/NpChar.h | 2 ++ src/NpcAct.h | 2 +- src/NpcAct000.cpp | 16 +++++------ src/NpcAct020.cpp | 12 ++++---- src/NpcAct040.cpp | 12 ++++---- src/NpcAct060.cpp | 20 ++++++------- src/NpcAct080.cpp | 16 +++++------ src/NpcAct100.cpp | 14 ++++----- src/NpcAct120.cpp | 16 +++++------ src/NpcAct140.cpp | 18 ++++++------ src/NpcAct160.cpp | 18 ++++++------ src/NpcAct180.cpp | 20 ++++++------- src/NpcAct200.cpp | 14 ++++----- src/NpcAct220.cpp | 14 ++++----- src/NpcAct240.cpp | 14 ++++----- src/NpcAct260.cpp | 16 +++++------ src/NpcAct280.cpp | 14 ++++----- src/NpcAct300.cpp | 18 ++++++------ src/NpcAct320.cpp | 18 ++++++------ src/NpcAct340.cpp | 18 ++++++------ src/NpcHit.cpp | 18 ++++++------ src/NpcHit.h | 1 + src/NpcTbl.cpp | 5 ++-- src/NpcTbl.h | 4 ++- src/Organya.cpp | 6 ++-- src/Organya.h | 1 + src/Profile.cpp | 21 +++++++------- src/Profile.h | 2 ++ src/Resource.cpp | 3 ++ src/Resource.h | 1 + src/SelStage.cpp | 5 ++-- src/SelStage.h | 1 + src/Shoot.cpp | 11 +++---- src/Shoot.h | 1 + src/Sound.cpp | 7 +++-- src/Sound.h | 1 + src/Stage.cpp | 21 +++++++------- src/Star.cpp | 6 ++-- src/Star.h | 1 + src/Tags.h | 1 + src/TextScr.cpp | 44 ++++++++++++++-------------- src/TextScr.h | 3 ++ src/Triangle.cpp | 4 ++- src/Triangle.h | 1 + src/Types.h | 1 + src/ValueView.cpp | 4 +-- src/ValueView.h | 1 + src/WindowsWrapper.h | 1 + 110 files changed, 480 insertions(+), 372 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 47cc9925..f18b94dc 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -1,15 +1,16 @@ +#include "ArmsItem.h" + #include #include "CommonDefines.h" -#include "TextScr.h" -#include "ArmsItem.h" #include "Draw.h" -#include "KeyControl.h" #include "Escape.h" -#include "Sound.h" -#include "Main.h" #include "Game.h" +#include "KeyControl.h" +#include "Main.h" #include "Shoot.h" +#include "Sound.h" +#include "TextScr.h" int gArmsEnergyX = 16; @@ -417,7 +418,7 @@ bool CheckItem(int a) bool CheckArms(int a) { - for (int i = 0; i < ARMS_MAX; i++) + for (int i = 0; i < ARMS_MAX; i++) { if (gArmsData[i].code == a) return true; @@ -458,7 +459,7 @@ void FullArmsEnergy() int RotationArms() { int arms_num; - for ( arms_num = 0; gArmsData[arms_num].code != 0; arms_num++); + for (arms_num = 0; gArmsData[arms_num].code != 0; arms_num++); if (!arms_num) return 0; diff --git a/src/ArmsItem.h b/src/ArmsItem.h index 72cccc8d..8faa785d 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -1,4 +1,5 @@ #pragma once + struct ARMS { int code; diff --git a/src/Back.cpp b/src/Back.cpp index bfc3ec5f..b60586cd 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -1,15 +1,16 @@ #include "Back.h" #include + #include "WindowsWrapper.h" -#include "Tags.h" +#include "Draw.h" +#include "File.h" #include "Frame.h" #include "Game.h" -#include "Draw.h" -#include "Stage.h" #include "Map.h" -#include "File.h" +#include "Stage.h" +#include "Tags.h" BACK gBack; int gWaterY; diff --git a/src/Boss.cpp b/src/Boss.cpp index e5584f94..90854e23 100644 --- a/src/Boss.cpp +++ b/src/Boss.cpp @@ -1,9 +1,10 @@ +#include "Boss.h" + #include #include #include "WindowsWrapper.h" -#include "Boss.h" #include "BossAlmo1.h" #include "BossAlmo2.h" #include "BossBallos.h" @@ -13,16 +14,16 @@ #include "BossPress.h" #include "BossTwinD.h" #include "BossX.h" -#include "NpChar.h" -#include "MyChar.h" -#include "Sound.h" -#include "NpcHit.h" +#include "Bullet.h" #include "Caret.h" -#include "TextScr.h" -#include "ValueView.h" #include "Draw.h" #include "Map.h" -#include "Bullet.h" +#include "MyChar.h" +#include "NpChar.h" +#include "NpcHit.h" +#include "Sound.h" +#include "TextScr.h" +#include "ValueView.h" NPCHAR gBoss[BOSS_MAX]; diff --git a/src/Boss.h b/src/Boss.h index d0af8597..3c8d6b47 100644 --- a/src/Boss.h +++ b/src/Boss.h @@ -1,4 +1,5 @@ #pragma once + #include "NpChar.h" #define BOSS_MAX 20 diff --git a/src/BossAlmo1.cpp b/src/BossAlmo1.cpp index cb9e1914..418c3feb 100644 --- a/src/BossAlmo1.cpp +++ b/src/BossAlmo1.cpp @@ -1,5 +1,7 @@ #include "BossAlmo1.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Frame.h" #include "Game.h" diff --git a/src/BossAlmo2.cpp b/src/BossAlmo2.cpp index 6335ac08..5fdfa864 100644 --- a/src/BossAlmo2.cpp +++ b/src/BossAlmo2.cpp @@ -1,5 +1,7 @@ #include "BossAlmo2.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Flash.h" #include "Frame.h" @@ -9,7 +11,6 @@ #include "NpChar.h" #include "Sound.h" #include "Triangle.h" -#include "WindowsWrapper.h" static void ActBossCharA_Head(NPCHAR *npc) { diff --git a/src/BossBallos.cpp b/src/BossBallos.cpp index 3f8ccc6b..1da627e7 100644 --- a/src/BossBallos.cpp +++ b/src/BossBallos.cpp @@ -1,5 +1,7 @@ #include "BossBallos.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Flash.h" #include "Frame.h" diff --git a/src/BossFrog.cpp b/src/BossFrog.cpp index 1e34a0a5..bd65b611 100644 --- a/src/BossFrog.cpp +++ b/src/BossFrog.cpp @@ -1,5 +1,7 @@ #include "BossFrog.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Frame.h" #include "Game.h" @@ -7,7 +9,6 @@ #include "NpChar.h" #include "Sound.h" #include "Triangle.h" -#include "WindowsWrapper.h" static void ActBossChar02_01(void) { diff --git a/src/BossIronH.cpp b/src/BossIronH.cpp index 370c7e17..e9fbe74d 100644 --- a/src/BossIronH.cpp +++ b/src/BossIronH.cpp @@ -1,11 +1,12 @@ #include "BossIronH.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Frame.h" #include "Game.h" #include "MyChar.h" #include "Sound.h" -#include "WindowsWrapper.h" void ActBossChar_Ironhead(void) { diff --git a/src/BossLife.cpp b/src/BossLife.cpp index 5df2297f..cdd42b3f 100644 --- a/src/BossLife.cpp +++ b/src/BossLife.cpp @@ -1,10 +1,11 @@ +#include "BossLife.h" + #include "WindowsWrapper.h" #include "CommonDefines.h" -#include "BossLife.h" +#include "Boss.h" #include "Draw.h" #include "NpChar.h" -#include "Boss.h" static struct { diff --git a/src/BossOhm.cpp b/src/BossOhm.cpp index b5d792ad..4ea7def8 100644 --- a/src/BossOhm.cpp +++ b/src/BossOhm.cpp @@ -1,15 +1,17 @@ +#include "BossOhm.h" + #include #include "WindowsWrapper.h" #include "Boss.h" -#include "NpChar.h" -#include "MyChar.h" -#include "Sound.h" -#include "Frame.h" #include "Bullet.h" #include "Flash.h" +#include "Frame.h" #include "Game.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" void ActBoss01_12() { diff --git a/src/BossOhm.h b/src/BossOhm.h index 8b6fea74..d332f27d 100644 --- a/src/BossOhm.h +++ b/src/BossOhm.h @@ -1,2 +1,3 @@ #pragma once + void ActBossChar_Omega(); diff --git a/src/BossPress.cpp b/src/BossPress.cpp index ab25ff95..a8e41cda 100644 --- a/src/BossPress.cpp +++ b/src/BossPress.cpp @@ -1,10 +1,11 @@ #include "BossPress.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Game.h" #include "Map.h" #include "Sound.h" -#include "WindowsWrapper.h" void ActBossChar_Press(void) { diff --git a/src/BossTwinD.cpp b/src/BossTwinD.cpp index 12f2baf5..240c7882 100644 --- a/src/BossTwinD.cpp +++ b/src/BossTwinD.cpp @@ -1,5 +1,7 @@ #include "BossTwinD.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Flash.h" #include "Game.h" @@ -7,7 +9,6 @@ #include "NpChar.h" #include "Sound.h" #include "Triangle.h" -#include "WindowsWrapper.h" static void ActBossCharT_DragonBody(NPCHAR *npc) { diff --git a/src/BossX.cpp b/src/BossX.cpp index 89981474..1ee4531e 100644 --- a/src/BossX.cpp +++ b/src/BossX.cpp @@ -1,5 +1,7 @@ #include "BossX.h" +#include "WindowsWrapper.h" + #include "Boss.h" #include "Flash.h" #include "Frame.h" @@ -8,7 +10,6 @@ #include "NpChar.h" #include "Sound.h" #include "Triangle.h" -#include "WindowsWrapper.h" static void ActBossChar03_01(NPCHAR *npc) { diff --git a/src/BulHit.cpp b/src/BulHit.cpp index 5f0c4073..3d7fe199 100644 --- a/src/BulHit.cpp +++ b/src/BulHit.cpp @@ -1,13 +1,15 @@ +#include "BulHit.h" + #include #include #include "Bullet.h" -#include "NpChar.h" #include "Caret.h" -#include "Sound.h" -#include "MyChar.h" #include "Game.h" #include "Map.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" void Vanish(BULLET *bul) { diff --git a/src/BulHit.h b/src/BulHit.h index 3c12ef97..c6af92a7 100644 --- a/src/BulHit.h +++ b/src/BulHit.h @@ -1,2 +1,3 @@ #pragma once + void HitBulletMap(); diff --git a/src/Bullet.cpp b/src/Bullet.cpp index c198a8a9..96672301 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -4,11 +4,11 @@ #include "Draw.h" #include "Caret.h" -#include "NpChar.h" -#include "MyChar.h" -#include "Sound.h" #include "Game.h" #include "KeyControl.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" BULLET_TABLE gBulTbl[46] = { diff --git a/src/Bullet.h b/src/Bullet.h index 9d91da4b..fdc49918 100644 --- a/src/Bullet.h +++ b/src/Bullet.h @@ -1,5 +1,7 @@ #pragma once + #include + #include "WindowsWrapper.h" struct BULLET diff --git a/src/Caret.cpp b/src/Caret.cpp index f8b0b563..0b23010f 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -5,8 +5,8 @@ #include "WindowsWrapper.h" #include "Draw.h" -#include "Triangle.h" #include "Game.h" +#include "Triangle.h" #define CARET_MAX 0x40 CARET gCrt[CARET_MAX]; diff --git a/src/Caret.h b/src/Caret.h index 8523ddb7..95af4602 100644 --- a/src/Caret.h +++ b/src/Caret.h @@ -1,4 +1,5 @@ #pragma once + #include "WindowsWrapper.h" struct CARET_TABLE diff --git a/src/CommonDefines.h b/src/CommonDefines.h index 2a135b90..fe7da48e 100644 --- a/src/CommonDefines.h +++ b/src/CommonDefines.h @@ -1,4 +1,5 @@ #pragma once + #define PATH_LENGTH 260 //Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash. #define WINDOW_WIDTH 320 diff --git a/src/Config.cpp b/src/Config.cpp index 35277f18..bb218de6 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -1,15 +1,15 @@ #include -#include "Types.h" -#include "CommonDefines.h" -#include #include +#include #include #include "WindowsWrapper.h" -#include "Tags.h" +#include "CommonDefines.h" #include "Config.h" #include "File.h" +#include "Tags.h" +#include "Types.h" bool LoadConfigData(CONFIG *conf) { diff --git a/src/Config.h b/src/Config.h index 5e600d3d..6409e354 100644 --- a/src/Config.h +++ b/src/Config.h @@ -1,4 +1,5 @@ #pragma once + #include struct CONFIG diff --git a/src/Draw.cpp b/src/Draw.cpp index 32ee95e2..8eeb0faf 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -1,8 +1,6 @@ #include -#include "Types.h" -#include "CommonDefines.h" -#include #include +#include #ifdef WINDOWS #define RECT WINRECT @@ -22,10 +20,12 @@ #include "WindowsWrapper.h" +#include "CommonDefines.h" #include "Draw.h" #include "Font.h" -#include "Tags.h" #include "Resource.h" +#include "Tags.h" +#include "Types.h" struct SURFACE { diff --git a/src/Draw.h b/src/Draw.h index 48580e57..58bfd21f 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -1,5 +1,7 @@ #pragma once + #include + #include "WindowsWrapper.h" extern RECT grcGame; diff --git a/src/Ending.cpp b/src/Ending.cpp index 793663f8..046b3dca 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -7,17 +7,17 @@ #include "WindowsWrapper.h" -#include "Tags.h" -#include "Generic.h" -#include "Flags.h" -#include "KeyControl.h" -#include "Escape.h" -#include "Organya.h" -#include "MycParam.h" -#include "Main.h" -#include "Stage.h" #include "Draw.h" +#include "Escape.h" +#include "Flags.h" +#include "Generic.h" +#include "KeyControl.h" +#include "Main.h" +#include "MycParam.h" +#include "Organya.h" +#include "Stage.h" #include "TextScr.h" +#include "Tags.h" CREDIT Credit; STRIP Strip[MAX_STRIP]; diff --git a/src/Ending.h b/src/Ending.h index 3cc7ec63..b9bdfeb9 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -1,4 +1,5 @@ #pragma once + #include struct CREDIT diff --git a/src/Escape.cpp b/src/Escape.cpp index 795fcd29..99ee388b 100644 --- a/src/Escape.cpp +++ b/src/Escape.cpp @@ -1,7 +1,8 @@ +#include "Escape.h" + #include "WindowsWrapper.h" #include "CommonDefines.h" -#include "Escape.h" #include "Draw.h" #include "KeyControl.h" #include "Main.h" diff --git a/src/Escape.h b/src/Escape.h index 393ea8ce..b2be505f 100644 --- a/src/Escape.h +++ b/src/Escape.h @@ -1,2 +1,3 @@ #pragma once + int Call_Escape(); diff --git a/src/Fade.cpp b/src/Fade.cpp index 4c439944..cd305abc 100644 --- a/src/Fade.cpp +++ b/src/Fade.cpp @@ -1,10 +1,11 @@ +#include "Fade.h" + #include #include "WindowsWrapper.h" -#include "Fade.h" -#include "Game.h" #include "Draw.h" +#include "Game.h" FADE gFade; diff --git a/src/Fade.h b/src/Fade.h index 95da7f80..06c3da0e 100644 --- a/src/Fade.h +++ b/src/Fade.h @@ -1,4 +1,5 @@ #pragma once + #include "CommonDefines.h" #define FADE_WIDTH (((WINDOW_WIDTH - 1) >> 4) + 1) diff --git a/src/Flags.cpp b/src/Flags.cpp index 99309502..7da02b15 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -1,7 +1,7 @@ #include "Flags.h" -#include #include +#include uint8_t gFlagNPC[1000]; uint8_t gSkipFlag[0x40]; diff --git a/src/Flags.h b/src/Flags.h index 5e5c01c0..4fb6daea 100644 --- a/src/Flags.h +++ b/src/Flags.h @@ -1,5 +1,7 @@ #pragma once + #include + extern uint8_t gFlagNPC[1000]; extern uint8_t gSkipFlag[0x40]; diff --git a/src/Frame.cpp b/src/Frame.cpp index c6b5f4de..c20e67f8 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -1,12 +1,13 @@ +#include "Frame.h" + #include -#include "Frame.h" +#include "Boss.h" +#include "CommonDefines.h" +#include "Game.h" #include "Map.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" -#include "CommonDefines.h" -#include "Boss.h" FRAME gFrame; diff --git a/src/Frame.h b/src/Frame.h index 9a40f13e..0026a6b3 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -1,4 +1,5 @@ #pragma once + struct FRAME { int x; diff --git a/src/Game.cpp b/src/Game.cpp index fa5fbd50..15d240ad 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,47 +1,49 @@ -#include +#include "Game.h" + #include +#include #include + #include "WindowsWrapper.h" -#include "Tags.h" -#include "NpcTbl.h" -#include "NpChar.h" -#include "NpcHit.h" -#include "MiniMap.h" -#include "Generic.h" -#include "Boss.h" -#include "GenericLoad.h" #include "ArmsItem.h" -#include "TextScr.h" -#include "Bullet.h" -#include "BulHit.h" -#include "Shoot.h" -#include "Star.h" -#include "Fade.h" -#include "Frame.h" -#include "Flags.h" -#include "Escape.h" -#include "Stage.h" -#include "MyChar.h" -#include "MycHit.h" -#include "Caret.h" -#include "Map.h" -#include "Main.h" -#include "MycParam.h" -#include "MapName.h" -#include "Sound.h" -#include "Organya.h" -#include "Profile.h" -#include "MycParam.h" #include "Back.h" -#include "KeyControl.h" -#include "ValueView.h" +#include "Boss.h" +#include "BossLife.h" +#include "BulHit.h" +#include "Bullet.h" +#include "Caret.h" #include "Draw.h" #include "Ending.h" +#include "Escape.h" +#include "Fade.h" +#include "Flags.h" #include "Flash.h" -#include "BossLife.h" +#include "Frame.h" +#include "Generic.h" +#include "GenericLoad.h" +#include "KeyControl.h" +#include "Main.h" +#include "Map.h" +#include "MapName.h" +#include "MiniMap.h" +#include "MyChar.h" +#include "MycHit.h" +#include "MycParam.h" +#include "NpChar.h" +#include "NpcHit.h" +#include "NpcTbl.h" +#include "Organya.h" +#include "Profile.h" #include "SelStage.h" +#include "Shoot.h" +#include "Sound.h" +#include "Stage.h" +#include "Star.h" +#include "Tags.h" +#include "TextScr.h" +#include "ValueView.h" int g_GameFlags; int gCounter; diff --git a/src/Game.h b/src/Game.h index 58fe6416..19be7142 100644 --- a/src/Game.h +++ b/src/Game.h @@ -1,4 +1,5 @@ #pragma once + extern int g_GameFlags; extern int gCounter; diff --git a/src/Generic.cpp b/src/Generic.cpp index e1bec542..d36da3ed 100644 --- a/src/Generic.cpp +++ b/src/Generic.cpp @@ -1,3 +1,5 @@ +#include "Generic.h" + #include #include diff --git a/src/Generic.h b/src/Generic.h index 39b31705..e8074046 100644 --- a/src/Generic.h +++ b/src/Generic.h @@ -1,4 +1,5 @@ #pragma once + #include bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4); diff --git a/src/GenericLoad.cpp b/src/GenericLoad.cpp index 7c1c660f..80e915da 100644 --- a/src/GenericLoad.cpp +++ b/src/GenericLoad.cpp @@ -1,8 +1,10 @@ +#include "GenericLoad.h" + #include "CommonDefines.h" #include "Draw.h" -#include "Sound.h" -#include "PixTone.h" #include "Ending.h" +#include "PixTone.h" +#include "Sound.h" static const PIXTONEPARAMETER gPtpTable[139] = { diff --git a/src/GenericLoad.h b/src/GenericLoad.h index 3dcfb217..20b2136c 100644 --- a/src/GenericLoad.h +++ b/src/GenericLoad.h @@ -1,2 +1,3 @@ #pragma once + bool LoadGenericData(); diff --git a/src/Input.cpp b/src/Input.cpp index 7426bf97..d4d3ede3 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -1,12 +1,14 @@ -#include "Types.h" -#include "CommonDefines.h" +#include "Input.h" + #include #include + #include "WindowsWrapper.h" -#include "Input.h" +#include "CommonDefines.h" #include "Tags.h" +#include "Types.h" #define JOYSTICK_DEADZONE 10000 diff --git a/src/Input.h b/src/Input.h index 078a082a..2e5ff41b 100644 --- a/src/Input.h +++ b/src/Input.h @@ -1,4 +1,5 @@ #pragma once + extern bool gbUseJoystick; extern int gJoystickButtonTable[8]; diff --git a/src/KeyControl.cpp b/src/KeyControl.cpp index aa5f5c38..aa67f578 100644 --- a/src/KeyControl.cpp +++ b/src/KeyControl.cpp @@ -1,4 +1,5 @@ #include "KeyControl.h" + int gKey; int gKeyTrg; diff --git a/src/KeyControl.h b/src/KeyControl.h index 70ca0e4a..251600eb 100644 --- a/src/KeyControl.h +++ b/src/KeyControl.h @@ -1,4 +1,5 @@ #pragma once + enum KEYBIND { //The movement keys go in the order of left, right, up and down diff --git a/src/Main.cpp b/src/Main.cpp index da8b0195..8e994364 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1,25 +1,27 @@ +#include "Main.h" + #include -#include "Types.h" -#include "CommonDefines.h" #include -#include +#include #include + #include "WindowsWrapper.h" +#include "CommonDefines.h" +#include "Config.h" #include "Draw.h" -#include "Input.h" -#include "Profile.h" -#include "Organya.h" -#include "Sound.h" #include "Game.h" #include "Generic.h" -#include "MyChar.h" -#include "Main.h" -#include "Config.h" +#include "Input.h" #include "KeyControl.h" -#include "Triangle.h" +#include "MyChar.h" +#include "Organya.h" +#include "Profile.h" #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; diff --git a/src/Main.h b/src/Main.h index f2a0d57b..8d059ff1 100644 --- a/src/Main.h +++ b/src/Main.h @@ -1,3 +1,4 @@ #pragma once + void PutFramePerSecound(); int GetFramePerSecound(); diff --git a/src/Map.cpp b/src/Map.cpp index 1cf765a3..c6e4c54b 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -1,3 +1,5 @@ +#include "Map.h" + #include #include #include @@ -6,11 +8,10 @@ #include "WindowsWrapper.h" #include "CommonDefines.h" -#include "Map.h" -#include "Tags.h" #include "Draw.h" -#include "NpChar.h" #include "File.h" +#include "NpChar.h" +#include "Tags.h" #define PXM_BUFFER_SIZE 0x4B000 diff --git a/src/Map.h b/src/Map.h index 68e43d26..176301a9 100644 --- a/src/Map.h +++ b/src/Map.h @@ -1,4 +1,5 @@ #pragma once + #include struct MAP_DATA diff --git a/src/MapName.cpp b/src/MapName.cpp index 015d8908..4cfe28d5 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -1,8 +1,9 @@ +#include "MapName.h" + #include #include #include "CommonDefines.h" -#include "MapName.h" #include "Draw.h" MAP_NAME gMapName; diff --git a/src/MapName.h b/src/MapName.h index ea5e4415..92933f77 100644 --- a/src/MapName.h +++ b/src/MapName.h @@ -1,4 +1,5 @@ #pragma once + struct MAP_NAME { int flag; diff --git a/src/MiniMap.cpp b/src/MiniMap.cpp index e588b26a..d8490a78 100644 --- a/src/MiniMap.cpp +++ b/src/MiniMap.cpp @@ -1,18 +1,20 @@ +#include "MiniMap.h" + #include #include #include "WindowsWrapper.h" #include "CommonDefines.h" -#include "MapName.h" #include "Draw.h" #include "Escape.h" #include "Game.h" #include "KeyControl.h" -#include "Map.h" -#include "Stage.h" -#include "MyChar.h" #include "Main.h" +#include "Map.h" +#include "MapName.h" +#include "MyChar.h" +#include "Stage.h" int8_t gMapping[0x80]; diff --git a/src/MiniMap.h b/src/MiniMap.h index b998c8ca..cbeca307 100644 --- a/src/MiniMap.h +++ b/src/MiniMap.h @@ -1,4 +1,5 @@ #pragma once + #include extern int8_t gMapping[0x80]; diff --git a/src/MyChar.cpp b/src/MyChar.cpp index 4a05c8a0..a328b666 100644 --- a/src/MyChar.cpp +++ b/src/MyChar.cpp @@ -1,21 +1,22 @@ +#include "MyChar.h" + #include #include #include "WindowsWrapper.h" -#include "MyChar.h" -#include "MycParam.h" #include "ArmsItem.h" -#include "NpChar.h" +#include "Caret.h" #include "Draw.h" -#include "Sound.h" -#include "ValueView.h" -#include "KeyControl.h" -#include "TextScr.h" #include "Flags.h" #include "Game.h" +#include "KeyControl.h" +#include "MycParam.h" +#include "NpChar.h" +#include "Sound.h" #include "Star.h" -#include "Caret.h" +#include "TextScr.h" +#include "ValueView.h" MYCHAR gMC; diff --git a/src/MyChar.h b/src/MyChar.h index ade4fff4..a3d568c1 100644 --- a/src/MyChar.h +++ b/src/MyChar.h @@ -1,5 +1,7 @@ #pragma once + #include + #include "WindowsWrapper.h" struct MYCHAR diff --git a/src/MycHit.cpp b/src/MycHit.cpp index 498435a8..458c0787 100644 --- a/src/MycHit.cpp +++ b/src/MycHit.cpp @@ -1,18 +1,20 @@ +#include "MycHit.h" + #include #include "WindowsWrapper.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Map.h" -#include "Sound.h" -#include "Caret.h" -#include "Boss.h" #include "Back.h" +#include "Boss.h" +#include "Caret.h" #include "Game.h" -#include "TextScr.h" -#include "MycParam.h" #include "KeyControl.h" +#include "Map.h" +#include "MyChar.h" +#include "MycParam.h" +#include "NpChar.h" +#include "Sound.h" +#include "TextScr.h" void ResetMyCharFlag() { diff --git a/src/MycHit.h b/src/MycHit.h index 10be598f..a4ad0ed3 100644 --- a/src/MycHit.h +++ b/src/MycHit.h @@ -1,4 +1,5 @@ #pragma once + void ResetMyCharFlag(); void HitMyCharMap(); void HitMyCharNpChar(); diff --git a/src/MycParam.cpp b/src/MycParam.cpp index c02db6ea..076d9a48 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -1,18 +1,19 @@ +#include "MycParam.h" + #include "SDL.h" -#include "Sound.h" -#include "MyChar.h" -#include "MycParam.h" -#include "NpChar.h" -#include "CommonDefines.h" -#include "Tags.h" #include "ArmsItem.h" -#include "ValueView.h" -#include "TextScr.h" -#include "Game.h" -#include "Draw.h" +#include "CommonDefines.h" #include "Caret.h" +#include "Draw.h" +#include "Game.h" #include "File.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "Tags.h" +#include "TextScr.h" +#include "ValueView.h" ARMS_LEVEL gArmsLevelTable[14] = { diff --git a/src/MycParam.h b/src/MycParam.h index 1de454d3..de66ce9e 100644 --- a/src/MycParam.h +++ b/src/MycParam.h @@ -1,5 +1,7 @@ #pragma once + #include + struct ARMS_LEVEL { int exp[3]; diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 85a08003..8588c058 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -1,3 +1,5 @@ +#include "NpChar.h" + #include #include #include @@ -5,19 +7,18 @@ #include "WindowsWrapper.h" -#include "CommonDefines.h" -#include "Tags.h" -#include "NpChar.h" -#include "Caret.h" -#include "MyChar.h" -#include "Game.h" #include "ArmsItem.h" -#include "Flags.h" -#include "Sound.h" -#include "ValueView.h" -#include "NpcTbl.h" +#include "CommonDefines.h" +#include "Caret.h" #include "Draw.h" #include "File.h" +#include "Flags.h" +#include "Game.h" +#include "MyChar.h" +#include "NpcTbl.h" +#include "Sound.h" +#include "Tags.h" +#include "ValueView.h" NPCHAR gNPC[NPC_MAX]; int gCurlyShoot_wait; diff --git a/src/NpChar.h b/src/NpChar.h index 2ba81838..746b04e7 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -1,5 +1,7 @@ #pragma once + #include + #include "WindowsWrapper.h" #include "Draw.h" diff --git a/src/NpcAct.h b/src/NpcAct.h index 7bfc54d3..5b9263c5 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -362,4 +362,4 @@ void ActNpc356(NPCHAR *npc); void ActNpc357(NPCHAR *npc); void ActNpc358(NPCHAR *npc); void ActNpc359(NPCHAR *npc); -void ActNpc360(NPCHAR *npc); \ No newline at end of file +void ActNpc360(NPCHAR *npc); diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index ee8a0118..653f77b8 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -1,18 +1,16 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Caret.h" +#include "Frame.h" #include "Game.h" #include "Map.h" +#include "MyChar.h" +#include "NpChar.h" #include "Sound.h" -#include "Frame.h" -#include "Back.h" #include "Triangle.h" -#include "Frame.h" -#include "Map.h" -#include "Caret.h" //Null void ActNpc000(NPCHAR *npc) diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index bcbe5188..f4b980ab 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -1,15 +1,15 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Caret.h" +#include "Game.h" +#include "Frame.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "Caret.h" -#include "Frame.h" //Computer void ActNpc020(NPCHAR *npc) diff --git a/src/NpcAct040.cpp b/src/NpcAct040.cpp index 02fe7b33..c0a6aca9 100644 --- a/src/NpcAct040.cpp +++ b/src/NpcAct040.cpp @@ -1,15 +1,15 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Caret.h" +#include "CommonDefines.h" +#include "Game.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" -#include "Caret.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "CommonDefines.h" //Santa void ActNpc040(NPCHAR *npc) diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index eefcc7e9..4be42c60 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -1,18 +1,18 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" -#include "Map.h" #include "CommonDefines.h" -#include "Frame.h" -#include "MycParam.h" #include "Flash.h" +#include "Frame.h" +#include "Game.h" +#include "Map.h" +#include "MyChar.h" +#include "MycParam.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" //Toroko void ActNpc060(NPCHAR *npc) diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index f7b30fb8..940d6b95 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -1,17 +1,17 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" #include "Caret.h" +#include "CommonDefines.h" #include "Flash.h" #include "Frame.h" -#include "CommonDefines.h" +#include "Game.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" //Gravekeeper void ActNpc080(NPCHAR *npc) diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index 48d81858..9d2a040b 100644 --- a/src/NpcAct100.cpp +++ b/src/NpcAct100.cpp @@ -1,16 +1,16 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Bullet.h" +#include "Caret.h" +#include "Frame.h" +#include "Game.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "Frame.h" -#include "Caret.h" -#include "Bullet.h" //Grate void ActNpc100(NPCHAR *npc) diff --git a/src/NpcAct120.cpp b/src/NpcAct120.cpp index 41470ae1..51ca4586 100644 --- a/src/NpcAct120.cpp +++ b/src/NpcAct120.cpp @@ -1,17 +1,17 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Bullet.h" +#include "Caret.h" +#include "Frame.h" +#include "Game.h" +#include "KeyControl.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "Caret.h" -#include "KeyControl.h" -#include "Frame.h" -#include "Bullet.h" //Colon (1) void ActNpc120(NPCHAR *npc) diff --git a/src/NpcAct140.cpp b/src/NpcAct140.cpp index 1edda041..53cfd11d 100644 --- a/src/NpcAct140.cpp +++ b/src/NpcAct140.cpp @@ -1,18 +1,18 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" +#include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Flash.h" -#include "Bullet.h" -#include "CommonDefines.h" +#include "Game.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" //Toroko (frenzied) void ActNpc140(NPCHAR *npc) diff --git a/src/NpcAct160.cpp b/src/NpcAct160.cpp index 64a0684f..7291de11 100644 --- a/src/NpcAct160.cpp +++ b/src/NpcAct160.cpp @@ -1,18 +1,18 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" -#include "Frame.h" #include "Caret.h" -#include "MycParam.h" #include "CommonDefines.h" +#include "Frame.h" +#include "Game.h" +#include "MyChar.h" +#include "MycParam.h" +#include "NpChar.h" #include "NpcHit.h" +#include "Sound.h" +#include "Triangle.h" //Puu Black void ActNpc160(NPCHAR *npc) diff --git a/src/NpcAct180.cpp b/src/NpcAct180.cpp index a049f74d..e0f741af 100644 --- a/src/NpcAct180.cpp +++ b/src/NpcAct180.cpp @@ -1,18 +1,18 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Bullet.h" +#include "Caret.h" +#include "Flags.h" +#include "Frame.h" +#include "Game.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" -#include "Sound.h" -#include "Back.h" -#include "Triangle.h" -#include "Caret.h" -#include "Frame.h" -#include "Bullet.h" -#include "Flags.h" #include "NpcHit.h" +#include "Sound.h" +#include "Triangle.h" //Curly AI void ActNpc180(NPCHAR *npc) diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 163925b9..6c1806f5 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -1,16 +1,16 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" +#include "Game.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" //Dragon Zombie void ActNpc200(NPCHAR *npc) diff --git a/src/NpcAct220.cpp b/src/NpcAct220.cpp index c4d67c60..eb7e81f3 100644 --- a/src/NpcAct220.cpp +++ b/src/NpcAct220.cpp @@ -1,16 +1,16 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" +#include "Game.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" //Shovel Brigade void ActNpc220(NPCHAR *npc) diff --git a/src/NpcAct240.cpp b/src/NpcAct240.cpp index abe8b140..b97079a3 100644 --- a/src/NpcAct240.cpp +++ b/src/NpcAct240.cpp @@ -1,16 +1,16 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" #include "Caret.h" #include "Frame.h" +#include "Game.h" #include "Map.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" //Mimiga (jailed) void ActNpc240(NPCHAR *npc) diff --git a/src/NpcAct260.cpp b/src/NpcAct260.cpp index cf84aa58..02c58916 100644 --- a/src/NpcAct260.cpp +++ b/src/NpcAct260.cpp @@ -1,17 +1,17 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" -#include "MyChar.h" -#include "NpChar.h" -#include "Game.h" -#include "Sound.h" +#include "WindowsWrapper.h" + #include "Back.h" -#include "Triangle.h" #include "Caret.h" -#include "Map.h" #include "Frame.h" +#include "Game.h" +#include "Map.h" +#include "MyChar.h" #include "MycParam.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" //Shovel Brigade (caged) void ActNpc260(NPCHAR *npc) diff --git a/src/NpcAct280.cpp b/src/NpcAct280.cpp index e080f21f..d9982731 100644 --- a/src/NpcAct280.cpp +++ b/src/NpcAct280.cpp @@ -1,16 +1,16 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Boss.h" +#include "Frame.h" +#include "Game.h" +#include "Map.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "Frame.h" -#include "Map.h" -#include "Boss.h" //Sue (being teleported by Misery) void ActNpc280(NPCHAR *npc) diff --git a/src/NpcAct300.cpp b/src/NpcAct300.cpp index 746f9aaf..ea69a74e 100644 --- a/src/NpcAct300.cpp +++ b/src/NpcAct300.cpp @@ -1,18 +1,18 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Boss.h" +#include "Bullet.h" +#include "Caret.h" +#include "Frame.h" +#include "Game.h" +#include "Map.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "Caret.h" -#include "Boss.h" -#include "Frame.h" -#include "Map.h" -#include "Bullet.h" //Demon crown (opening) void ActNpc300(NPCHAR *npc) diff --git a/src/NpcAct320.cpp b/src/NpcAct320.cpp index b521c224..7992cfd9 100644 --- a/src/NpcAct320.cpp +++ b/src/NpcAct320.cpp @@ -1,18 +1,18 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Bullet.h" +#include "Caret.h" +#include "Frame.h" +#include "Game.h" +#include "KeyControl.h" +#include "Map.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "Frame.h" -#include "Map.h" -#include "Caret.h" -#include "Bullet.h" -#include "KeyControl.h" //Curly (carried, shooting) void ActNpc320(NPCHAR *npc) diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp index fe701095..742216ff 100644 --- a/src/NpcAct340.cpp +++ b/src/NpcAct340.cpp @@ -1,19 +1,19 @@ -#include "WindowsWrapper.h" - #include "NpcAct.h" +#include "WindowsWrapper.h" + +#include "Back.h" +#include "Caret.h" #include "CommonDefines.h" +#include "Flash.h" +#include "Flags.h" +#include "Frame.h" +#include "Game.h" +#include "Map.h" #include "MyChar.h" #include "NpChar.h" -#include "Game.h" #include "Sound.h" -#include "Back.h" #include "Triangle.h" -#include "Flags.h" -#include "Map.h" -#include "Caret.h" -#include "Frame.h" -#include "Flash.h" //Ballos void ActNpc340(NPCHAR *npc) diff --git a/src/NpcHit.cpp b/src/NpcHit.cpp index 9bf64dcd..e41c6483 100644 --- a/src/NpcHit.cpp +++ b/src/NpcHit.cpp @@ -1,14 +1,16 @@ -#include "NpChar.h" -#include "ValueView.h" -#include "Sound.h" -#include "Flags.h" -#include "Caret.h" -#include "Game.h" +#include "NpcHit.h" + #include "Back.h" #include "Bullet.h" -#include "MyChar.h" -#include "TextScr.h" +#include "Caret.h" +#include "Flags.h" +#include "Game.h" #include "Map.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "TextScr.h" +#include "ValueView.h" void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y) { diff --git a/src/NpcHit.h b/src/NpcHit.h index 2a36f40a..50f65e88 100644 --- a/src/NpcHit.h +++ b/src/NpcHit.h @@ -1,4 +1,5 @@ #pragma once + #include "NpChar.h" void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y); diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index f7ca6e71..7d4eb33c 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -1,11 +1,12 @@ +#include "NpcTbl.h" + #include #include #include -#include "NpcTbl.h" -#include "NpcAct.h" #include "File.h" #include "Generic.h" +#include "NpcAct.h" NPC_TABLE *gNpcTable; diff --git a/src/NpcTbl.h b/src/NpcTbl.h index 19e43a8f..e7604d41 100644 --- a/src/NpcTbl.h +++ b/src/NpcTbl.h @@ -1,7 +1,9 @@ #pragma once + #include -#include "NpChar.h" + #include "Draw.h" +#include "NpChar.h" struct NPC_TBL_RECT { diff --git a/src/Organya.cpp b/src/Organya.cpp index a4f05035..71be9854 100644 --- a/src/Organya.cpp +++ b/src/Organya.cpp @@ -1,16 +1,18 @@ +#include "Organya.h" + #include #include #include #include #include + #include "WindowsWrapper.h" #include "CommonDefines.h" -#include "Tags.h" -#include "Organya.h" #include "Resource.h" #include "Sound.h" +#include "Tags.h" #define PANDUMMY 0xFF #define VOLDUMMY 0xFF diff --git a/src/Organya.h b/src/Organya.h index d3180711..dbf43c5d 100644 --- a/src/Organya.h +++ b/src/Organya.h @@ -1,4 +1,5 @@ #pragma once + #include //Below are Organya song data structures diff --git a/src/Profile.cpp b/src/Profile.cpp index fb9439d7..826fef3c 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -1,3 +1,5 @@ +#include "Profile.h" + #include #include #include @@ -5,23 +7,22 @@ #include "WindowsWrapper.h" -#include "CommonDefines.h" -#include "Tags.h" -#include "Profile.h" -#include "Fade.h" #include "ArmsItem.h" +#include "BossLife.h" +#include "CommonDefines.h" +#include "Fade.h" +#include "File.h" #include "Flags.h" +#include "Frame.h" +#include "Game.h" #include "MiniMap.h" #include "MyChar.h" -#include "Star.h" #include "NpChar.h" -#include "Frame.h" #include "SelStage.h" -#include "ValueView.h" #include "Stage.h" -#include "Game.h" -#include "BossLife.h" -#include "File.h" +#include "Star.h" +#include "Tags.h" +#include "ValueView.h" const char *gDefaultName = "Profile.dat"; const char *gProfileCode = "Do041220"; diff --git a/src/Profile.h b/src/Profile.h index 999b7791..d9f527a1 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -1,5 +1,7 @@ #pragma once + #include + #include "ArmsItem.h" #include "SelStage.h" diff --git a/src/Resource.cpp b/src/Resource.cpp index 0d14833e..bde9f45c 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -1,7 +1,10 @@ +#include "Resource.h" + #include #include #include + #include "WindowsWrapper.h" #include "Resource/ORG/ACCESS.org.h" diff --git a/src/Resource.h b/src/Resource.h index cf507c85..89d552e6 100644 --- a/src/Resource.h +++ b/src/Resource.h @@ -1,4 +1,5 @@ #pragma once + #include SDL_RWops* FindResource(const char *name); diff --git a/src/SelStage.cpp b/src/SelStage.cpp index 1e576cde..75fafe7b 100644 --- a/src/SelStage.cpp +++ b/src/SelStage.cpp @@ -2,13 +2,14 @@ #include +#include "WindowsWrapper.h" + #include "Draw.h" #include "Escape.h" #include "KeyControl.h" #include "Main.h" -#include "TextScr.h" #include "Sound.h" -#include "WindowsWrapper.h" +#include "TextScr.h" PERMIT_STAGE gPermitStage[8]; diff --git a/src/SelStage.h b/src/SelStage.h index 586d17d4..7a2000bd 100644 --- a/src/SelStage.h +++ b/src/SelStage.h @@ -1,4 +1,5 @@ #pragma once + struct PERMIT_STAGE { int index; diff --git a/src/Shoot.cpp b/src/Shoot.cpp index 57bfafed..228652ea 100644 --- a/src/Shoot.cpp +++ b/src/Shoot.cpp @@ -1,11 +1,12 @@ -#include "ArmsItem.h" -#include "MycParam.h" #include "Shoot.h" -#include "Caret.h" + +#include "ArmsItem.h" #include "Bullet.h" -#include "Sound.h" -#include "MyChar.h" +#include "Caret.h" #include "KeyControl.h" +#include "MyChar.h" +#include "MycParam.h" +#include "Sound.h" int empty; int spur_charge; diff --git a/src/Shoot.h b/src/Shoot.h index f5c02a1e..e0fbb055 100644 --- a/src/Shoot.h +++ b/src/Shoot.h @@ -1,3 +1,4 @@ #pragma once + void ResetSpurCharge(void); void ShootBullet(); diff --git a/src/Sound.cpp b/src/Sound.cpp index 2eadcc30..79c7a432 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -1,11 +1,12 @@ -#include -#include +#include "Sound.h" + #include +#include #include +#include #include -#include "Sound.h" #include "Organya.h" #include "PixTone.h" diff --git a/src/Sound.h b/src/Sound.h index 6fffc424..2bbcbc3a 100644 --- a/src/Sound.h +++ b/src/Sound.h @@ -1,4 +1,5 @@ #pragma once + #include #include diff --git a/src/Stage.cpp b/src/Stage.cpp index 425057ca..39cad12e 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -1,26 +1,27 @@ +#include "Stage.h" + #include #include #include #include "WindowsWrapper.h" +#include "Back.h" +#include "Boss.h" +#include "Bullet.h" +#include "Caret.h" #include "CommonDefines.h" +#include "Draw.h" +#include "Flash.h" +#include "Frame.h" #include "Map.h" #include "MapName.h" #include "MyChar.h" -#include "Bullet.h" -#include "Boss.h" -#include "Draw.h" -#include "Tags.h" -#include "Frame.h" -#include "Caret.h" #include "NpChar.h" -#include "TextScr.h" #include "Organya.h" +#include "Tags.h" +#include "TextScr.h" #include "ValueView.h" -#include "Back.h" -#include "Stage.h" -#include "Flash.h" #ifdef JAPANESE #define STAGE_ENTRY(parts, map, bkType, back, npc, boss, boss_no, name_en, name_jp) {parts, map, bkType, back, npc, boss, boss_no, name_jp} diff --git a/src/Star.cpp b/src/Star.cpp index 9567b4c1..202598ab 100644 --- a/src/Star.cpp +++ b/src/Star.cpp @@ -1,11 +1,13 @@ +#include "Star.h" + #include #include "WindowsWrapper.h" -#include "MyChar.h" -#include "Draw.h" #include "Bullet.h" +#include "Draw.h" #include "Game.h" +#include "MyChar.h" static struct { diff --git a/src/Star.h b/src/Star.h index ddf82d4d..15179727 100644 --- a/src/Star.h +++ b/src/Star.h @@ -1,4 +1,5 @@ #pragma once + void InitStar(); void ActStar(); void PutStar(int fx, int fy); diff --git a/src/Tags.h b/src/Tags.h index 7cc408c1..6c240cab 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -1,4 +1,5 @@ #pragma once + #include "CommonDefines.h" extern char gModulePath[PATH_LENGTH]; diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 6cd68665..98c67b3d 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -1,3 +1,5 @@ +#include "TextScr.h" + #include #include #include @@ -5,33 +7,31 @@ #include "WindowsWrapper.h" -#include "CommonDefines.h" -#include "TextScr.h" -#include "Draw.h" -#include "Tags.h" #include "ArmsItem.h" -#include "MyChar.h" -#include "Fade.h" -#include "Stage.h" -#include "Frame.h" -#include "MycParam.h" -#include "Flags.h" -#include "Ending.h" -#include "Profile.h" -#include "Map.h" -#include "MiniMap.h" #include "Boss.h" -#include "MapName.h" -#include "KeyControl.h" -#include "NpChar.h" -#include "Sound.h" -#include "Organya.h" -#include "Game.h" -#include "Map.h" #include "BossLife.h" -#include "SelStage.h" +#include "CommonDefines.h" +#include "Draw.h" +#include "Ending.h" +#include "Fade.h" +#include "Flags.h" #include "Flash.h" +#include "Frame.h" +#include "Game.h" #include "Generic.h" +#include "KeyControl.h" +#include "Map.h" +#include "MapName.h" +#include "MiniMap.h" +#include "MyChar.h" +#include "MycParam.h" +#include "NpChar.h" +#include "Organya.h" +#include "Profile.h" +#include "SelStage.h" +#include "Sound.h" +#include "Stage.h" +#include "Tags.h" #define IS_COMMAND(c1, c2, c3) gTS.data[gTS.p_read + 1] == c1 && gTS.data[gTS.p_read + 2] == c2 && gTS.data[gTS.p_read + 3] == c3 diff --git a/src/TextScr.h b/src/TextScr.h index 2811461b..ca575e96 100644 --- a/src/TextScr.h +++ b/src/TextScr.h @@ -1,6 +1,9 @@ #pragma once + #include + #include "WindowsWrapper.h" + #include "CommonDefines.h" struct TEXT_SCRIPT diff --git a/src/Triangle.cpp b/src/Triangle.cpp index 4fcef18d..a850b586 100644 --- a/src/Triangle.cpp +++ b/src/Triangle.cpp @@ -1,5 +1,7 @@ -#include +#include "Triangle.h" + #include +#include int gSin[0x100]; int16_t gTan[0x21]; diff --git a/src/Triangle.h b/src/Triangle.h index 41311fe5..8d2ab68a 100644 --- a/src/Triangle.h +++ b/src/Triangle.h @@ -1,4 +1,5 @@ #pragma once + #include void InitTriangleTable(); diff --git a/src/Types.h b/src/Types.h index 77add6be..bf91c76d 100644 --- a/src/Types.h +++ b/src/Types.h @@ -1,2 +1,3 @@ #pragma once + //This was originally some sort of POSIX standard thing? leftover from the linux port diff --git a/src/ValueView.cpp b/src/ValueView.cpp index 7a637d0b..25c3e5bd 100644 --- a/src/ValueView.cpp +++ b/src/ValueView.cpp @@ -2,9 +2,9 @@ #include "WindowsWrapper.h" -#include "ValueView.h" -#include "Game.h" #include "Draw.h" +#include "Game.h" +#include "ValueView.h" #define VALUEVIEW_MAX 0x10 VALUEVIEW gVV[VALUEVIEW_MAX]; diff --git a/src/ValueView.h b/src/ValueView.h index 2a11ff87..e4e6ac71 100644 --- a/src/ValueView.h +++ b/src/ValueView.h @@ -1,4 +1,5 @@ #pragma once + #include "WindowsWrapper.h" struct VALUEVIEW diff --git a/src/WindowsWrapper.h b/src/WindowsWrapper.h index fbc9eb22..87b43c13 100644 --- a/src/WindowsWrapper.h +++ b/src/WindowsWrapper.h @@ -1,4 +1,5 @@ #pragma once + int rep_rand(); void rep_srand(unsigned int seed); From e1e49a4dcc80a165cc9ed6fa0a787aa5121b70b1 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 19 Feb 2019 00:18:32 +0000 Subject: [PATCH 17/22] Made ArmsItem.cpp ASM-accurate --- src/ArmsItem.cpp | 488 ++++++++++++++++++++++++++--------------------- src/ArmsItem.h | 22 ++- src/Draw.cpp | 6 +- src/Draw.h | 2 +- 4 files changed, 285 insertions(+), 233 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index f18b94dc..101f5378 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -2,6 +2,8 @@ #include +#include "WindowsWrapper.h" + #include "CommonDefines.h" #include "Draw.h" #include "Escape.h" @@ -19,7 +21,7 @@ ITEM gItemData[ITEM_MAX]; int gSelectedArms; int gSelectedItem; int gCampTitleY; -bool gCampActive; +BOOL gCampActive; void ClearArmsData() { @@ -32,106 +34,122 @@ void ClearItemData() memset(gItemData, 0, sizeof(gItemData)); } -bool AddArmsData(int code, int max_num) +BOOL AddArmsData(long code, long max_num) { - for (int i = 0; i < ARMS_MAX; i++) - { - if (gArmsData[i].code == code || !gArmsData[i].code) - { - if (!gArmsData[i].code) - { - memset(&gArmsData[i], 0, sizeof(ARMS)); - gArmsData[i].level = 1; - } - - gArmsData[i].code = code; - gArmsData[i].max_num += max_num; - gArmsData[i].num += max_num; - if (gArmsData[i].num > gArmsData[i].max_num) - gArmsData[i].num = gArmsData[i].max_num; - return true; - } - } - - return false; -} - -bool SubArmsData(int code) -{ - for (int i = 0; i < ARMS_MAX; i++) + int i = 0; + for (;i < ARMS_MAX;) { if (gArmsData[i].code == code) - { - //Shift all arms from the right to the left - int ia; - for (ia = i + 1; ia < ARMS_MAX; ++ia) - { - gArmsData[ia - 1].code = gArmsData[ia].code; - gArmsData[ia - 1].level = gArmsData[ia].level; - gArmsData[ia - 1].exp = gArmsData[ia].exp; - gArmsData[ia - 1].max_num = gArmsData[ia].max_num; - gArmsData[ia - 1].num = gArmsData[ia].num; - } - - gArmsData[ia - 1].code = 0; - gSelectedArms = 0; - return true; - } + break; + + if (gArmsData[i].code == 0) + break; + + ++i; + } + + if (i == ARMS_MAX) + return FALSE; + + if (gArmsData[i].code == 0) + { + memset(&gArmsData[i], 0, sizeof(ARMS)); + gArmsData[i].level = 1; } - return false; + gArmsData[i].code = code; + gArmsData[i].max_num += max_num; + gArmsData[i].num += max_num; + + if (gArmsData[i].num > gArmsData[i].max_num) + gArmsData[i].num = gArmsData[i].max_num; + + return TRUE; } -bool TradeArms(int code1, int code2, int max_num) +BOOL SubArmsData(long code) { - for (int i = 0; i < ARMS_MAX; i++) + int i = 0; + for (;i < ARMS_MAX; ++i) + if (gArmsData[i].code == code) + break; + +#ifdef FIX_BUGS + if (i == ARMS_MAX) +#else + if (i == ITEM_MAX) // Oops +#endif + return FALSE; + + //Shift all arms from the right to the left + for (i += 1; i < ARMS_MAX; ++i) + gArmsData[i - 1] = gArmsData[i]; + + gArmsData[i - 1].code = 0; + gSelectedArms = 0; + return TRUE; +} + +BOOL TradeArms(long code1, long code2, long max_num) +{ + int i = 0; + for (;i < ARMS_MAX;) { if (gArmsData[i].code == code1) - { - gArmsData[i].level = 1; - gArmsData[i].code = code2; - gArmsData[i].max_num += max_num; - gArmsData[i].num += max_num; - gArmsData[i].exp = 0; - return true; - } + break; + + ++i; } - - return false; + + if (i == ARMS_MAX) + return FALSE; + + gArmsData[i].level = 1; + gArmsData[i].code = code2; + gArmsData[i].max_num += max_num; + gArmsData[i].num += max_num; + gArmsData[i].exp = 0; + return TRUE; } -bool AddItemData(int code) +BOOL AddItemData(long code) { - for (int i = 0; i < ITEM_MAX; i++) - { - if (gItemData[i].code == code || !gItemData[i].code) - { - gItemData[i].code = code; - return true; - } - } - - return false; -} - -bool SubItemData(int code) -{ - for (int i = 0; i < ITEM_MAX; i++) + int i = 0; + for (;i < ITEM_MAX;) { if (gItemData[i].code == code) - { - //Shift all items from the right to the left - int ia; - for (ia = i + 1; ia < ITEM_MAX; ++ia) - gItemData[ia - 1].code = gItemData[ia].code; - - gItemData[ia - 1].code = 0; - gSelectedItem = 0; - return true; - } + break; + + if (gItemData[i].code == 0) + break; + + ++i; } - - return false; + + if (i == ITEM_MAX) + return false; + + gItemData[i].code = code; + return true; +} + +BOOL SubItemData(long code) +{ + int i = 0; + for (;i < ITEM_MAX; ++i) + if (gItemData[i].code == code) + break; + + if (i == ITEM_MAX) + return FALSE; + + //Shift all items from the right to the left + for (i += 1; i < ITEM_MAX; ++i) + gItemData[i - 1] = gItemData[i]; + + gItemData[i - 1].code = 0; + gSelectedItem = 0; + return TRUE; } void MoveCampCursor() @@ -143,104 +161,107 @@ void MoveCampCursor() while ( gItemData[item_num].code != 0 ) ++item_num; - if (arms_num || item_num) + if (arms_num == 0 && item_num == 0) + return; + + BOOL bChange = FALSE; + if (gCampActive == FALSE) { - bool bChange = false; - if (gCampActive) + if (gKeyTrg & gKeyLeft) { - if (gKeyTrg & gKeyLeft) - { - if (gSelectedItem % 6) - --gSelectedItem; - else - gSelectedItem += 5; - - bChange = true; - } + --gSelectedArms; + bChange = TRUE; + } + if (gKeyTrg & gKeyRight) + { + ++gSelectedArms; + bChange = TRUE; + } + if ((gKeyDown | gKeyUp) & gKeyTrg) + { + if (item_num) + gCampActive = TRUE; + bChange = TRUE; + } + + if (gSelectedArms < 0) + gSelectedArms = arms_num - 1; + if (gSelectedArms > arms_num - 1) + gSelectedArms = 0; + } + else + { + if (gKeyTrg & gKeyLeft) + { + if (gSelectedItem % 6 == 0) + gSelectedItem += 5; + else + --gSelectedItem; - if (gKeyTrg & gKeyRight) + bChange = TRUE; + } + + if (gKeyTrg & gKeyRight) + { + if (gSelectedItem == item_num - 1) + gSelectedItem = 6 * (gSelectedItem / 6); + else { - if (item_num - 1 == gSelectedItem) - gSelectedItem = 6 * (gSelectedItem / 6); - else if (gSelectedItem % 6 == 5) + if (gSelectedItem % 6 == 5) gSelectedItem -= 5; else ++gSelectedItem; - - bChange = true; } + + bChange = TRUE; + } + + if (gKeyTrg & gKeyUp) + { + if (gSelectedItem / 6 == 0) + gCampActive = FALSE; + else + gSelectedItem -= 6; - if (gKeyTrg & gKeyUp) - { - if (gSelectedItem + 5 > 10) - gSelectedItem -= 6; - else - gCampActive = false; - - bChange = true; - } + bChange = TRUE; + } + + if ( gKeyTrg & gKeyDown ) + { + if ( gSelectedItem / 6 == (item_num - 1) / 6 ) + gCampActive = FALSE; + else + gSelectedItem += 6; - if ( gKeyTrg & gKeyDown ) - { - if ( gSelectedItem / 6 == (item_num - 1) / 6 ) - gCampActive = false; - else - gSelectedItem += 6; - - bChange = true; - } + bChange = TRUE; + } + + if (gSelectedItem >= item_num) + gSelectedItem = item_num - 1; + + if (gCampActive && gKeyTrg & gKeyOk) + StartTextScript(gItemData[gSelectedItem].code + 6000); + } + + if (bChange) + { + if (gCampActive == FALSE) + { + PlaySoundObject(4, 1); - if (gSelectedItem >= item_num) - gSelectedItem = item_num - 1; - - if (gCampActive && gKeyTrg & gKeyOk) - StartTextScript(gItemData[gSelectedItem].code + 6000); + if (arms_num) + StartTextScript(gArmsData[gSelectedArms].code + 1000); + else + StartTextScript(1000); } else { - if (gKeyTrg & gKeyLeft) - { - --gSelectedArms; - bChange = true; - } - if (gKeyTrg & gKeyRight) - { - ++gSelectedArms; - bChange = true; - } - if ((gKeyDown | gKeyUp) & gKeyTrg) - { - if (item_num) - gCampActive = true; - bChange = true; - } + PlaySoundObject(1, 1); - if (gSelectedArms < 0) - gSelectedArms = arms_num - 1; - if (arms_num - 1 < gSelectedArms) - gSelectedArms = 0; - } - - if (bChange) - { - if (gCampActive) - { - PlaySoundObject(1, 1); - - if (item_num) - StartTextScript(gItemData[gSelectedItem].code + 5000); - else - StartTextScript(5000); - } + if (item_num) + StartTextScript(gItemData[gSelectedItem].code + 5000); else - { - PlaySoundObject(4, 1); - - if (arms_num) - StartTextScript(gArmsData[gSelectedArms].code + 1000); - else - StartTextScript(1000); - } + StartTextScript(5000); } } } @@ -252,12 +273,8 @@ void PutCampObject() RECT rcNone = {80, 48, 96, 56}; RECT rcLv = {80, 80, 96, 88}; RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; - RECT rcCur1[2]; - RECT rcCur2[2]; - rcCur1[0] = {0, 88, 40, 128}; - rcCur1[1] = {40, 88, 80, 128}; - rcCur2[0] = {80, 88, 112, 104}; - rcCur2[1] = {80, 104, 112, 120}; + RECT rcCur1[2] = {{0, 88, 40, 128}, {40, 88, 80, 128}}; + RECT rcCur2[2] = {{80, 88, 112, 104}, {80, 104, 112, 120}}; RECT rcTitle1 = {80, 48, 144, 56}; RECT rcTitle2 = {80, 56, 144, 64}; RECT rcBoxTop = {0, 0, 244, 8}; @@ -280,17 +297,20 @@ void PutCampObject() PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY + 52, &rcTitle2, SURFACE_ID_TEXT_BOX); //Draw arms cursor - static int flash; + static unsigned int flash; ++flash; - if (gCampActive) - PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], SURFACE_ID_TEXT_BOX); + if (gCampActive == FALSE) + PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash / 2) % 2], SURFACE_ID_TEXT_BOX); else - PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash >> 1) & 1], SURFACE_ID_TEXT_BOX); + PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], SURFACE_ID_TEXT_BOX); //Draw arms - for (int i = 0; i < ARMS_MAX && gArmsData[i].code; i++) + for (int i = 0; i < ARMS_MAX; i++) { + if (gArmsData[i].code == 0) + break; + RECT rcArms; rcArms.left = 16 * (gArmsData[i].code % 16); rcArms.right = rcArms.left + 16; @@ -316,13 +336,16 @@ void PutCampObject() } //Draw items cursor - if (gCampActive) - PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[(flash >> 1) & 1], SURFACE_ID_TEXT_BOX); + if (gCampActive == TRUE) + PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[(flash / 2) % 2], SURFACE_ID_TEXT_BOX); else PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], SURFACE_ID_TEXT_BOX); - for (int i = 0; i < ITEM_MAX && gItemData[i].code; i++) + for (int i = 0; i < ITEM_MAX; i++) { + if (gItemData[i].code == 0) + break; + RECT rcItem; rcItem.left = 32 * (gItemData[i].code % 8); rcItem.right = rcItem.left + 32; @@ -341,24 +364,23 @@ int CampLoop() char old_script_path[PATH_LENGTH]; GetTextScriptPath(old_script_path); - char name[13]; - strcpy(name, "ArmsItem.tsc"); - LoadTextScript2(name); + LoadTextScript2("ArmsItem.tsc"); gCampTitleY = (WINDOW_HEIGHT - 192) / 2; gCampActive = 0; gSelectedItem = 0; //Run script - int arms_num; - for (arms_num = 0; gArmsData[arms_num].code != 0; arms_num++); + int arms_num = 0; + for (;gArmsData[arms_num].code != 0;) + ++arms_num; if (arms_num) StartTextScript(gArmsData[gSelectedArms].code + 1000); else StartTextScript(gItemData[gSelectedItem].code + 5000); - while (true) + for (;;) { GetTrg(); @@ -389,108 +411,136 @@ int CampLoop() PutTextScript(); PutFramePerSecound(); - if (!gCampActive && (gKeyItem | gKeyCancel | gKeyOk) & gKeyTrg) - break; - else if (g_GameFlags & 2 && (gKeyItem | gKeyCancel) & gKeyTrg) - break; - + if (gCampActive) + { + if (g_GameFlags & 2 && (gKeyCancel | gKeyItem) & gKeyTrg) + { + StopTextScript(); + break; + } + } + else + { + if ((gKeyCancel | gKeyOk | gKeyItem) & gKeyTrg) + { + StopTextScript(); + break; + } + } + if (!Flip_SystemTask()) return 0; } //Resume original script - StopTextScript(); LoadTextScript_Stage(old_script_path); gArmsEnergyX = 32; return 1; } -bool CheckItem(int a) +BOOL CheckItem(long a) { for (int i = 0; i < ITEM_MAX; i++) { if (gItemData[i].code == a) - return true; + return TRUE; } - return false; + return FALSE; } -bool CheckArms(int a) +BOOL CheckArms(long a) { for (int i = 0; i < ARMS_MAX; i++) { if (gArmsData[i].code == a) - return true; + return TRUE; } - return false; + return FALSE; } -bool UseArmsEnergy(int num) +BOOL UseArmsEnergy(long num) { if (!gArmsData[gSelectedArms].max_num) - return true; + return TRUE; if (!gArmsData[gSelectedArms].num) - return false; + return FALSE; gArmsData[gSelectedArms].num -= num; if (gArmsData[gSelectedArms].num < 0) gArmsData[gSelectedArms].num = 0; - return true; + return TRUE; } -bool ChargeArmsEnergy(int num) +BOOL ChargeArmsEnergy(long num) { gArmsData[gSelectedArms].num += num; if (gArmsData[gSelectedArms].num > gArmsData[gSelectedArms].max_num) gArmsData[gSelectedArms].num = gArmsData[gSelectedArms].max_num; - return true; + return TRUE; } void FullArmsEnergy() { for (int a = 0; a < ARMS_MAX; a++) { - if (gArmsData[a].code) - gArmsData[a].num = gArmsData[a].max_num; + if (gArmsData[a].code == 0) + continue; + + gArmsData[a].num = gArmsData[a].max_num; } } int RotationArms() { - int arms_num; - for (arms_num = 0; gArmsData[arms_num].code != 0; arms_num++); - if (!arms_num) + int arms_num = 0; + for (;gArmsData[arms_num].code != 0;) + ++arms_num; + + if (arms_num == 0) return 0; - + ResetSpurCharge(); - + ++gSelectedArms; - while (gSelectedArms < arms_num && !gArmsData[gSelectedArms].code) + while (gSelectedArms < arms_num) + { + if (gArmsData[gSelectedArms].code) + break; + ++gSelectedArms; - + } + if (gSelectedArms == arms_num) gSelectedArms = 0; - + gArmsEnergyX = 32; PlaySoundObject(4, 1); - + return gArmsData[gSelectedArms].code; } int RotationArmsRev() { - int arms_num; - for (arms_num = 0; gArmsData[arms_num].code != 0; arms_num++); - if (!arms_num) + int arms_num = 0; + for (;gArmsData[arms_num].code != 0;) + ++arms_num; + + if (arms_num == 0) return 0; ResetSpurCharge(); if (--gSelectedArms < 0) gSelectedArms = arms_num - 1; - while (gSelectedArms < arms_num && !gArmsData[gSelectedArms].code) + + while (gSelectedArms < arms_num) + { + if (gArmsData[gSelectedArms].code) + break; + --gSelectedArms; + } gArmsEnergyX = 0; PlaySoundObject(4, 1); diff --git a/src/ArmsItem.h b/src/ArmsItem.h index 8faa785d..bc4bf01d 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -1,5 +1,7 @@ #pragma once +#include "WindowsWrapper.h" + struct ARMS { int code; @@ -27,20 +29,20 @@ extern ITEM gItemData[ITEM_MAX]; extern int gSelectedArms; extern int gSelectedItem; extern int gCampTitleY; -extern bool gCampActive; +extern BOOL gCampActive; void ClearArmsData(); void ClearItemData(); -bool AddArmsData(int code, int max_num); -bool SubArmsData(int code); -bool TradeArms(int code1, int code2, int max_num); -bool AddItemData(int code); -bool SubItemData(int code); +BOOL AddArmsData(long code, long max_num); +BOOL SubArmsData(long code); +BOOL TradeArms(long code1, long code2, long max_num); +BOOL AddItemData(long code); +BOOL SubItemData(long code); int CampLoop(); -bool CheckItem(int a); -bool CheckArms(int a); -bool UseArmsEnergy(int num); -bool ChargeArmsEnergy(int num); +BOOL CheckItem(long a); +BOOL CheckArms(long a); +BOOL UseArmsEnergy(long num); +BOOL ChargeArmsEnergy(long num); void FullArmsEnergy(); int RotationArms(); int RotationArmsRev(); diff --git a/src/Draw.cpp b/src/Draw.cpp index 8eeb0faf..283ce3d7 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -50,12 +50,12 @@ FontObject *gFont; #define FRAMERATE 20 -bool Flip_SystemTask() +BOOL Flip_SystemTask() { while (true) { if (!SystemTask()) - return false; + return FALSE; //Framerate limiter static uint32_t timePrev; @@ -75,7 +75,7 @@ bool Flip_SystemTask() } SDL_RenderPresent(gRenderer); - return true; + return TRUE; } bool StartDirectDraw(int lMagnification, int lColourDepth) diff --git a/src/Draw.h b/src/Draw.h index 58bfd21f..666e1df1 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -50,7 +50,7 @@ struct SURFACE; extern SURFACE surf[SURFACE_ID_MAX]; -bool Flip_SystemTask(); +BOOL Flip_SystemTask(); bool StartDirectDraw(int lMagnification, int lColourDepth); void EndDirectDraw(); void ReleaseSurface(int s); From fbaf46548f0a4716495b2c8a9e1fad4828ea05c1 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 19 Feb 2019 00:50:16 +0000 Subject: [PATCH 18/22] Made Back.cpp about as ASM-accurate as I can make it ...without removing the widescreen stuff, at least. --- src/Back.cpp | 61 +++++++++++++++++++++++++++------------------------- src/Back.h | 4 +++- src/Draw.cpp | 32 +++++++++++++-------------- src/Draw.h | 12 +++++------ 4 files changed, 57 insertions(+), 52 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index b60586cd..c6df1c6b 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -15,7 +15,7 @@ BACK gBack; int gWaterY; -bool InitBack(char *fName, int type) +BOOL InitBack(const char *fName, int type) { //Get width and height char path[PATH_LENGTH]; @@ -27,14 +27,14 @@ bool InitBack(char *fName, int type) sprintf(path, "%s/%s.bmp", gDataPath, fName); fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; } #ifdef FIX_BUGS // TODO: Maybe we need a 'BETTER_PORTABILITY' flag if (fgetc(fp) != 'B' || fgetc(fp) != 'M') { fclose(fp); - return false; + return FALSE; } fseek(fp, 18, SEEK_SET); @@ -53,7 +53,7 @@ bool InitBack(char *fName, int type) // Check if this is a valid bitmap file if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning) - return false; // The original game forgets to close fp + return FALSE; // The original game forgets to close fp fread(bmp_header_buffer2, 40, 1, fp); fclose(fp); @@ -65,22 +65,25 @@ bool InitBack(char *fName, int type) //Set background stuff and load texture gBack.flag = 1; if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND)) - return false; + return FALSE; gBack.type = type; gWaterY = 0x1E0000; - return true; + return TRUE; } void ActBack() { - if (gBack.type == 5) + switch (gBack.type) { - gBack.fx += 0xC00; - } - else if (gBack.type >= 5 && gBack.type <= 7) - { - ++gBack.fx; - gBack.fx %= 640; + case 5: + gBack.fx += 0xC00; + break; + + case 6: + case 7: + ++gBack.fx; + gBack.fx %= 640; + break; } } @@ -195,35 +198,35 @@ void PutBack(int fx, int fy) void PutFront(int fx, int fy) { - RECT rcWater[2]; - rcWater[0] = {0, 0, 32, 16}; - rcWater[1] = {0, 16, 32, 48}; + RECT rcWater[2] = {{0, 0, 32, 16}, {0, 16, 32, 48}}; - if (gBack.type == 3) + switch (gBack.type) { - int x_1 = fx / 0x4000; - int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1); - int y_1 = 0; - int y_2 = y_1 + 32; - - for (int y = y_1; y < y_2; y++) - { - int ypos = (y << 14) / 0x200 - fy / 0x200 + gWaterY / 0x200; + case 3: + int x_1 = fx / 0x4000; + int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1); + int y_1 = 0; + int y_2 = y_1 + 32; - if (ypos >= -32) + for (int y = y_1; y < y_2; y++) { + int ypos = (y * 0x20 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200; + + if (ypos < -32) + break; + if (ypos > WINDOW_HEIGHT) break; - + for (int x = x_1; x < x_2; x++) { - int xpos = (x << 14) / 0x200 - fx / 0x200; + int xpos = (x * 0x20 * 0x200) / 0x200 - fx / 0x200; PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND); if (!y) PutBitmap3(&grcGame, xpos, ypos, rcWater, SURFACE_ID_LEVEL_BACKGROUND); } } - } + } //Draw black bars diff --git a/src/Back.h b/src/Back.h index 62fd9102..469c1c36 100644 --- a/src/Back.h +++ b/src/Back.h @@ -1,5 +1,7 @@ #pragma once +#include "WindowsWrapper.h" + struct BACK { int flag; @@ -14,7 +16,7 @@ struct BACK extern BACK gBack; extern int gWaterY; -bool InitBack(char *fName, int type); +BOOL InitBack(const char *fName, int type); void ActBack(); void PutBack(int fx, int fy); void PutFront(int fx, int fy); diff --git a/src/Draw.cpp b/src/Draw.cpp index 283ce3d7..5df2c57a 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -78,7 +78,7 @@ BOOL Flip_SystemTask() return TRUE; } -bool StartDirectDraw(int lMagnification, int lColourDepth) +BOOL StartDirectDraw(int lMagnification, int lColourDepth) { //Initialize rendering SDL_InitSubSystem(SDL_INIT_VIDEO); @@ -107,7 +107,7 @@ bool StartDirectDraw(int lMagnification, int lColourDepth) } - return true; + return TRUE; } void EndDirectDraw() @@ -144,9 +144,9 @@ void ReleaseSurface(int s) } } -bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no) +BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no) { - bool success = false; + BOOL success = FALSE; #ifdef FIX_BUGS if (surf_no >= SURFACE_ID_MAX) @@ -184,7 +184,7 @@ bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no) else { surf[surf_no].in_use = true; - success = true; + success = TRUE; } } } @@ -303,7 +303,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; @@ -322,7 +322,7 @@ static bool LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s { printf("Loading surface (as .pbm) from %s for surface id %d\n", path, surf_no); if (LoadBitmap(fp, surf_no, create_surface)) - return true; + return TRUE; } } @@ -333,14 +333,14 @@ static bool LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s { printf("Loading surface (as .bmp) from %s for surface id %d\n", path, surf_no); if (LoadBitmap(fp, surf_no, create_surface)) - return true; + return TRUE; } printf("Failed to open file %s\n", name); - 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) { SDL_RWops *fp = FindResource(res); @@ -348,29 +348,29 @@ static bool LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat { printf("Loading surface from resource %s for surface id %d\n", res, surf_no); if (LoadBitmap(fp, surf_no, create_surface)) - return true; + return TRUE; } printf("Failed to open resource %s\n", res); - return false; + return FALSE; } -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); } -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); } -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); } -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); } diff --git a/src/Draw.h b/src/Draw.h index 666e1df1..d5ce2bd8 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -51,14 +51,14 @@ struct SURFACE; extern SURFACE surf[SURFACE_ID_MAX]; BOOL Flip_SystemTask(); -bool StartDirectDraw(int lMagnification, int lColourDepth); +BOOL StartDirectDraw(int lMagnification, int lColourDepth); void EndDirectDraw(); void ReleaseSurface(int s); -bool MakeSurface_File(const char *name, Surface_Ids surf_no); -bool MakeSurface_Resource(const char *res, Surface_Ids surf_no); -bool ReloadBitmap_File(const char *name, Surface_Ids surf_no); -bool ReloadBitmap_Resource(const char *res, Surface_Ids surf_no); -bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no); +BOOL MakeSurface_File(const char *name, Surface_Ids surf_no); +BOOL MakeSurface_Resource(const char *res, Surface_Ids surf_no); +BOOL ReloadBitmap_File(const char *name, Surface_Ids surf_no); +BOOL ReloadBitmap_Resource(const char *res, Surface_Ids surf_no); +BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no); void BackupSurface(Surface_Ids surf_no, RECT *rect); void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no); void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no); From 84945aa8985660c136a7eb8ba084df16864c8b5e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 19 Feb 2019 00:55:01 +0000 Subject: [PATCH 19/22] Removed some old unimplemented-function stuff that we no longer need --- src/Boss.cpp | 3 +-- src/NpChar.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Boss.cpp b/src/Boss.cpp index 90854e23..510da2c6 100644 --- a/src/Boss.cpp +++ b/src/Boss.cpp @@ -209,8 +209,7 @@ void ActBossChar() { if (gBoss[0].cond & 0x80) { - if (gpBossFuncTbl[gBoss[0].code_char] != nullptr) - gpBossFuncTbl[gBoss[0].code_char](); + gpBossFuncTbl[gBoss[0].code_char](); for (int bos = 0; bos < BOSS_MAX; bos++) { diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 8588c058..269802aa 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -360,8 +360,8 @@ void ActNpChar() { if (gNPC[i].cond & 0x80) { - if (gpNpcFuncTbl[gNPC[i].code_char] != nullptr) - gpNpcFuncTbl[gNPC[i].code_char](&gNPC[i]); + gpNpcFuncTbl[gNPC[i].code_char](&gNPC[i]); + if (gNPC[i].shock) --gNPC[i].shock; } @@ -404,8 +404,7 @@ void ChangeNpCharByEvent(int code_event, int code_char, int dir) } } - if (gpNpcFuncTbl[code_char] != nullptr) - gpNpcFuncTbl[code_char](&gNPC[n]); + gpNpcFuncTbl[code_char](&gNPC[n]); } } } @@ -447,8 +446,7 @@ void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir) } } - if (gpNpcFuncTbl[code_char] != nullptr) - gpNpcFuncTbl[code_char](&gNPC[n]); + gpNpcFuncTbl[code_char](&gNPC[n]); } } } From 8e76e3859155a575af532e352889438d6e8602d9 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 19 Feb 2019 03:32:28 +0000 Subject: [PATCH 20/22] Possible fix for static builds on non-Windows platforms? --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 501602fb..7364f5af 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,10 @@ LIBS += `sdl2-config --static-libs` `pkg-config freetype2 --libs` ifeq ($(STATIC), 1) CXXFLAGS += -static - LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 -lRpcrt4 -lDwrite -lusp10 + LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 + ifeq ($(WINDOWS), 1) + LIBS += -lRpcrt4 -lDwrite -lusp10 + endif endif # For an accurate result to the original's code, compile in alphabetical order From 754bed870cd91aaf1744c571fee61fd3dd1cc7d4 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 19 Feb 2019 04:33:50 +0000 Subject: [PATCH 21/22] Got NpcAct000.cpp to compile in MSVC2003 and made NPCs 0/1 ASM-accurate --- src/NpcAct000.cpp | 536 ++++++++++++++++++++++++---------------------- 1 file changed, 275 insertions(+), 261 deletions(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 653f77b8..c48eef68 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -15,18 +15,14 @@ //Null void ActNpc000(NPCHAR *npc) { - RECT rect[1]; - rect[0] = {0x00, 0x00, 0x10, 0x10}; + RECT rect[1] = {0x00, 0x00, 0x10, 0x10}; - switch (npc->act_no) + if (npc->act_no == 0) { - case 0: - npc->act_no = 1; + npc->act_no = 1; - if (npc->direct == 2) - npc->y += 0x2000; - - break; + if (npc->direct == 2) + npc->y += 0x2000; } npc->rect = rect[0]; @@ -35,10 +31,48 @@ void ActNpc000(NPCHAR *npc) //Experience void ActNpc001(NPCHAR *npc) { - //When not in wind - if (gBack.type != 5 && gBack.type != 6) + //In wind + if (gBack.type == 5 || gBack.type == 6) { - if (!npc->act_no) + if (npc->act_no == 0) + { + //Set state + npc->act_no = 1; + + //Set random speed + npc->ym = Random(-0x80, 0x80); + npc->xm = Random(0x7F, 0x100); + } + + //Blow to the left + npc->xm -= 8; + + //Destroy when off-screen + if (npc->x < 0xA000) + npc->cond = 0; + +#ifdef FIX_BUGS + //Limit speed + if (npc->xm < -0x600) + npc->xm = -0x600; +#else + //Limit speed (except pixel applied it to the X position) + if (npc->x < -0x600) + npc->x = -0x600; +#endif + + //Bounce off walls + if (npc->flag & 1) + npc->xm = 0x100; + if (npc->flag & 2) + npc->ym = 0x40; + if (npc->flag & 8) + npc->ym = -0x40; + } + //When not in wind + else + { + if (npc->act_no == 0) { //Set state npc->act_no = 1; @@ -63,13 +97,13 @@ void ActNpc001(NPCHAR *npc) //Bounce off walls if (npc->flag & 1 && npc->xm < 0) - npc->xm = -npc->xm; + npc->xm *= -1; if (npc->flag & 4 && npc->xm > 0) - npc->xm = -npc->xm; + npc->xm *= -1; //Bounce off ceiling if (npc->flag & 2 && npc->ym < 0) - npc->ym = -npc->ym; + npc->ym *= -1; //Bounce off floor if (npc->flag & 8) @@ -84,7 +118,7 @@ void ActNpc001(NPCHAR *npc) { PlaySoundObject(45, 1); if (++npc->count2 > 2) - npc->y -= 512; + npc->y -= 0x200; } else { @@ -101,64 +135,36 @@ void ActNpc001(NPCHAR *npc) if (npc->ym > 0x5FF) npc->ym = 0x5FF; } - //In wind - else - { - if (!npc->act_no) - { - //Set state - npc->act_no = 1; - - //Set random speed - npc->ym = Random(-0x80, 0x80); - npc->xm = Random(0x7F, 0x100); - } - - //Blow to the left - npc->xm -= 8; - - //Destroy when off-screen - if (npc->x <= 0x9FFF) - npc->cond = 0; - -#ifdef FIX_BUGS - //Limit speed - if (npc->xm < -0x5FF) - npc->xm = -0x5FF; -#else - //Limit speed (except pixel applied it to the X position) - if (npc->x < -0x5FF) - npc->x = -0x5FF; -#endif - - //Bounce off walls - if (npc->flag & 1) - npc->xm = 0x100; - if (npc->flag & 2) - npc->ym = 0x40; - if (npc->flag & 8) - npc->ym = -0x40; - } //Move npc->x += npc->xm; npc->y += npc->ym; //Get framerects - RECT rect[6]; - rect[0] = {0x00, 0x10, 0x10, 0x20}; - rect[1] = {0x10, 0x10, 0x20, 0x20}; - rect[2] = {0x20, 0x10, 0x30, 0x20}; - rect[3] = {0x30, 0x10, 0x40, 0x20}; - rect[4] = {0x40, 0x10, 0x50, 0x20}; - rect[5] = {0x50, 0x10, 0x60, 0x20}; + RECT rect[6] = { + {0x00, 0x10, 0x10, 0x20}, + {0x10, 0x10, 0x20, 0x20}, + {0x20, 0x10, 0x30, 0x20}, + {0x30, 0x10, 0x40, 0x20}, + {0x40, 0x10, 0x50, 0x20}, + {0x50, 0x10, 0x60, 0x20}, + }; RECT rcNo = {0, 0, 0, 0}; //Animate ++npc->ani_wait; - if (npc->direct) + if (npc->direct == 0) + { + if (npc->ani_wait > 2) + { + npc->ani_wait = 0; + if (++npc->ani_no > 5) + npc->ani_no = 0; + } + } + else { if (npc->ani_wait > 2) { @@ -167,27 +173,23 @@ void ActNpc001(NPCHAR *npc) npc->ani_no = 5; } } - else if (npc->ani_wait > 2) - { - npc->ani_wait = 0; - if (++npc->ani_no > 5) - npc->ani_no = 0; - } npc->rect = rect[npc->ani_no]; //Size if (npc->act_no) { - if (npc->exp == 5) + switch (npc->exp) { - npc->rect.top += 16; - npc->rect.bottom += 16; - } - else if (npc->exp == 20) - { - npc->rect.top += 32; - npc->rect.bottom += 32; + case 5: + npc->rect.top += 16; + npc->rect.bottom += 16; + break; + + case 20: + npc->rect.top += 32; + npc->rect.bottom += 32; + break; } npc->act_no = 1; @@ -200,7 +202,7 @@ void ActNpc001(NPCHAR *npc) //Blink after 400 frames if (npc->count1 > 400) { - if (npc->count1 / 2 & 1) + if (npc->count1 / 2 % 2) npc->rect = rcNo; } } @@ -209,23 +211,25 @@ void ActNpc001(NPCHAR *npc) void ActNpc002(NPCHAR *npc) { //Rects - RECT rcLeft[7]; - rcLeft[0] = {32, 0, 64, 24}; - rcLeft[1] = {0, 0, 32, 24}; - rcLeft[2] = {32, 0, 64, 24}; - rcLeft[3] = {64, 0, 96, 24}; - rcLeft[4] = {96, 0, 128, 24}; - rcLeft[5] = {128, 0, 160, 24}; - rcLeft[6] = {160, 0, 192, 24}; + RECT rcLeft[7] = { + {32, 0, 64, 24}, + {0, 0, 32, 24}, + {32, 0, 64, 24}, + {64, 0, 96, 24}, + {96, 0, 128, 24}, + {128, 0, 160, 24}, + {160, 0, 192, 24}, + }; - RECT rcRight[7]; - rcRight[0] = {32, 24, 64, 48}; - rcRight[1] = {0, 24, 32, 48}; - rcRight[2] = {32, 24, 64, 48}; - rcRight[3] = {64, 24, 96, 48}; - rcRight[4] = {96, 24, 128, 48}; - rcRight[5] = {128, 24, 160, 48}; - rcRight[6] = {160, 24, 192, 48}; + RECT rcRight[7] = { + {32, 24, 64, 48}, + {0, 24, 32, 48}, + {32, 24, 64, 48}, + {64, 24, 96, 48}, + {96, 24, 128, 48}, + {128, 24, 160, 48}, + {160, 24, 192, 48}, + }; //Turn when touching a wall if (npc->flag & 1) @@ -328,32 +332,34 @@ void ActNpc003(NPCHAR *npc) if (++npc->count1 > 100) npc->cond = 0; - npc->rect = {0, 0, 0, 0}; + RECT rect = {0, 0, 0, 0}; + npc->rect = rect; } //Smoke void ActNpc004(NPCHAR *npc) { - RECT rcLeft[8]; - RECT rcUp[8]; + RECT rcLeft[8] = { + {16, 0, 17, 1}, + {16, 0, 32, 16}, + {32, 0, 48, 16}, + {48, 0, 64, 16}, + {64, 0, 80, 16}, + {80, 0, 96, 16}, + {96, 0, 112, 16}, + {112, 0, 128, 16}, + }; - rcLeft[0] = {16, 0, 17, 1}; - rcLeft[1] = {16, 0, 32, 16}; - rcLeft[2] = {32, 0, 48, 16}; - rcLeft[3] = {48, 0, 64, 16}; - rcLeft[4] = {64, 0, 80, 16}; - rcLeft[5] = {80, 0, 96, 16}; - rcLeft[6] = {96, 0, 112, 16}; - rcLeft[7] = {112, 0, 128, 16}; - - rcUp[0] = {16, 0, 17, 1}; - rcUp[1] = {80, 48, 96, 64}; - rcUp[2] = {0, 128, 16, 144}; - rcUp[3] = {16, 128, 32, 144}; - rcUp[4] = {32, 128, 48, 144}; - rcUp[5] = {48, 128, 64, 144}; - rcUp[6] = {64, 128, 80, 144}; - rcUp[7] = {80, 128, 96, 144}; + RECT rcUp[8] = { + {16, 0, 17, 1}, + {80, 48, 96, 64}, + {0, 128, 16, 144}, + {16, 128, 32, 144}, + {32, 128, 48, 144}, + {48, 128, 64, 144}, + {64, 128, 80, 144}, + {80, 128, 96, 144}, + }; if (npc->act_no) { @@ -408,16 +414,17 @@ void ActNpc004(NPCHAR *npc) //Critter (Green, Egg Corridor) void ActNpc005(NPCHAR *npc) { - RECT rcLeft[3]; - RECT rcRight[3]; + RECT rcLeft[3] = { + {0, 48, 16, 64}, + {16, 48, 32, 64}, + {32, 48, 48, 64}, + }; - rcLeft[0] = {0, 48, 16, 64}; - rcLeft[1] = {16, 48, 32, 64}; - rcLeft[2] = {32, 48, 48, 64}; - - rcRight[0] = {0, 64, 16, 80}; - rcRight[1] = {16, 64, 32, 80}; - rcRight[2] = {32, 64, 48, 80}; + RECT rcRight[3] = { + {0, 64, 16, 80}, + {16, 64, 32, 80}, + {32, 64, 48, 80}, + }; switch (npc->act_no) { @@ -512,21 +519,22 @@ void ActNpc005(NPCHAR *npc) //Beetle (Goes left and right, Egg Corridor) void ActNpc006(NPCHAR *npc) { - RECT rcLeft[5]; - RECT rcRight[5]; - - rcLeft[0] = {0, 80, 16, 96}; - rcLeft[1] = {16, 80, 32, 96}; - rcLeft[2] = {32, 80, 48, 96}; - rcLeft[3] = {48, 80, 64, 96}; - rcLeft[4] = {64, 80, 80, 96}; - - rcRight[0] = {0, 96, 16, 112}; - rcRight[1] = {16, 96, 32, 112}; - rcRight[2] = {32, 96, 48, 112}; - rcRight[3] = {48, 96, 64, 112}; - rcRight[4] = {64, 96, 80, 112}; - + RECT rcLeft[5] = { + {0, 80, 16, 96}, + {16, 80, 32, 96}, + {32, 80, 48, 96}, + {48, 80, 64, 96}, + {64, 80, 80, 96}, + }; + + RECT rcRight[5] = { + {0, 96, 16, 112}, + {16, 96, 32, 112}, + {32, 96, 48, 112}, + {48, 96, 64, 112}, + {64, 96, 80, 112}, + }; + switch (npc->act_no) { case 0: //Init @@ -638,16 +646,17 @@ void ActNpc006(NPCHAR *npc) //Basil void ActNpc007(NPCHAR *npc) { - RECT rcLeft[3]; - RECT rcRight[3]; + RECT rcLeft[3] = { + {256, 64, 288, 80}, + {256, 80, 288, 96}, + {256, 96, 288, 112}, + }; - rcLeft[0] = {256, 64, 288, 80}; - rcLeft[1] = {256, 80, 288, 96}; - rcLeft[2] = {256, 96, 288, 112}; - - rcRight[0] = {288, 64, 320, 80}; - rcRight[1] = {288, 80, 320, 96}; - rcRight[2] = {288, 96, 320, 112}; + RECT rcRight[3] = { + {288, 64, 320, 80}, + {288, 80, 320, 96}, + {288, 96, 320, 112}, + }; switch (npc->act_no) { @@ -720,14 +729,15 @@ void ActNpc007(NPCHAR *npc) //Beetle (Follows you, Egg Corridor) void ActNpc008(NPCHAR *npc) { - RECT rcLeft[2]; - RECT rcRight[2]; + RECT rcLeft[2] = { + {80, 80, 96, 96}, + {96, 80, 112, 96}, + }; - rcLeft[0] = {80, 80, 96, 96}; - rcLeft[1] = {96, 80, 112, 96}; - - rcRight[0] = {80, 96, 96, 112}; - rcRight[1] = {96, 96, 112, 112}; + RECT rcRight[2] = { + {80, 96, 96, 112}, + {96, 96, 112, 112}, + }; switch (npc->act_no) { @@ -872,16 +882,17 @@ void ActNpc009(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[3]; - RECT rect_right[3]; + RECT rect_left[3] = { + {0, 0, 40, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {80, 0, 120, 24}; - rect_left[2] = {120, 0, 160, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {80, 24, 120, 48}; - rect_right[2] = {120, 24, 160, 48}; + RECT rect_right[3] = { + {0, 24, 40, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + }; if (npc->direct == 0) npc->rect = rect_left[npc->ani_no]; @@ -983,18 +994,19 @@ void ActNpc010(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[4]; - RECT rect_right[4]; + RECT rect_left[4] = { + {0, 0, 40, 24}, + {40, 0, 80, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {40, 0, 80, 24}; - rect_left[2] = {80, 0, 120, 24}; - rect_left[3] = {120, 0, 160, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {40, 24, 80, 48}; - rect_right[2] = {80, 24, 120, 48}; - rect_right[3] = {120, 24, 160, 48}; + RECT rect_right[4] = { + {0, 24, 40, 48}, + {40, 24, 80, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + }; if (gMC.x > npc->x) npc->direct = 2; @@ -1019,11 +1031,11 @@ void ActNpc011(NPCHAR *npc) npc->y += npc->ym; npc->x += npc->xm; - RECT rect_left[3]; - - rect_left[0] = {208, 104, 224, 120}; - rect_left[1] = {224, 104, 240, 120}; - rect_left[2] = {240, 104, 256, 120}; + RECT rect_left[3] = { + {208, 104, 224, 120}, + {224, 104, 240, 120}, + {240, 104, 256, 120}, + }; if (++npc->ani_wait > 1) { @@ -1323,38 +1335,39 @@ void ActNpc012(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[14]; - RECT rect_right[14]; + RECT rect_left[14] = { + {0, 0, 40, 24}, + {160, 0, 200, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + {240, 0, 280, 24}, + {200, 0, 240, 24}, + {280, 0, 320, 24}, + {0, 0, 0, 0}, + {80, 48, 120, 72}, + {0, 48, 40, 72}, + {0, 0, 40, 24}, + {40, 48, 80, 72}, + {0, 0, 40, 24}, + {280, 0, 320, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {160, 0, 200, 24}; - rect_left[2] = {80, 0, 120, 24}; - rect_left[3] = {120, 0, 160, 24}; - rect_left[4] = {240, 0, 280, 24}; - rect_left[5] = {200, 0, 240, 24}; - rect_left[6] = {280, 0, 320, 24}; - rect_left[7] = {0, 0, 0, 0}; - rect_left[8] = {80, 48, 120, 72}; - rect_left[9] = {0, 48, 40, 72}; - rect_left[10] = {0, 0, 40, 24}; - rect_left[11] = {40, 48, 80, 72}; - rect_left[12] = {0, 0, 40, 24}; - rect_left[13] = {280, 0, 320, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {160, 24, 200, 48}; - rect_right[2] = {80, 24, 120, 48}; - rect_right[3] = {120, 24, 160, 48}; - rect_right[4] = {240, 24, 280, 48}; - rect_right[5] = {200, 24, 240, 48}; - rect_right[6] = {280, 24, 320, 48}; - rect_right[7] = {0, 0, 0, 0}; - rect_right[8] = {80, 72, 120, 96}; - rect_right[9] = {0, 72, 40, 96}; - rect_right[10] = {0, 24, 40, 48}; - rect_right[11] = {40, 72, 80, 96}; - rect_right[12] = {0, 24, 40, 48}; - rect_right[13] = {280, 24, 320, 48}; + RECT rect_right[14] = { + {0, 24, 40, 48}, + {160, 24, 200, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + {240, 24, 280, 48}, + {200, 24, 240, 48}, + {280, 24, 320, 48}, + {0, 0, 0, 0}, + {80, 72, 120, 96}, + {0, 72, 40, 96}, + {0, 24, 40, 48}, + {40, 72, 80, 96}, + {0, 24, 40, 48}, + {280, 24, 320, 48}, + }; if (npc->direct == 0) npc->rect = rect_left[npc->ani_no]; @@ -1373,12 +1386,12 @@ void ActNpc012(NPCHAR *npc) //Forcefield void ActNpc013(NPCHAR *npc) { - RECT rect[4]; - - rect[0] = {128, 0, 144, 16}; - rect[1] = {144, 0, 160, 16}; - rect[2] = {160, 0, 176, 16}; - rect[3] = {176, 0, 192, 16}; + RECT rect[4] = { + {128, 0, 144, 16}, + {144, 0, 160, 16}, + {160, 0, 176, 16}, + {176, 0, 192, 16}, + }; if (++npc->ani_wait > 0) { @@ -1395,11 +1408,11 @@ void ActNpc013(NPCHAR *npc) //Santa's Key void ActNpc014(NPCHAR *npc) { - RECT rect[3]; - - rect[0] = {192, 0, 208, 16}; - rect[1] = {208, 0, 224, 16}; - rect[2] = {224, 0, 240, 16}; + RECT rect[3] = { + {192, 0, 208, 16}, + {208, 0, 224, 16}, + {224, 0, 240, 16}, + }; if (npc->act_no == 0) { @@ -1435,11 +1448,11 @@ void ActNpc014(NPCHAR *npc) //Chest (closed) void ActNpc015(NPCHAR *npc) { - RECT rcLeft[3]; - - rcLeft[0] = {240, 0, 256, 16}; - rcLeft[1] = {256, 0, 272, 16}; - rcLeft[2] = {272, 0, 288, 16}; + RECT rcLeft[3] = { + {240, 0, 256, 16}, + {256, 0, 272, 16}, + {272, 0, 288, 16}, + }; switch (npc->act_no) { @@ -1492,26 +1505,26 @@ void ActNpc015(NPCHAR *npc) //Save point void ActNpc016(NPCHAR *npc) { - RECT rects[8]; - - rects[0] = {96, 16, 112, 32}; - rects[1] = {112, 16, 128, 32}; - rects[2] = {128, 16, 144, 32}; - rects[3] = {144, 16, 160, 32}; - rects[4] = {160, 16, 176, 32}; - rects[5] = {176, 16, 192, 32}; - rects[6] = {192, 16, 208, 32}; - rects[7] = {208, 16, 224, 32}; + RECT rect[8] = { + {96, 16, 112, 32}, + {112, 16, 128, 32}, + {128, 16, 144, 32}, + {144, 16, 160, 32}, + {160, 16, 176, 32}, + {176, 16, 192, 32}, + {192, 16, 208, 32}, + {208, 16, 224, 32}, + }; switch (npc->act_no) { case 0: - npc->bits |= 0x2000u; + npc->bits |= 0x2000; npc->act_no = 1; if (npc->direct == 2) { - npc->bits &= ~0x2000u; + npc->bits &= ~0x2000; npc->ym = -0x200; for (int i = 0; i < 4; ++i) @@ -1521,36 +1534,36 @@ void ActNpc016(NPCHAR *npc) // Fallthrough case 1: if (npc->flag & 8) - npc->bits |= 0x2000u; + npc->bits |= 0x2000; break; } - if ( ++npc->ani_wait > 2 ) + if (++npc->ani_wait > 2) { npc->ani_wait = 0; ++npc->ani_no; } - if ( npc->ani_no > 7 ) + if (npc->ani_no > 7) npc->ani_no = 0; npc->ym += 0x40; - if ( npc->ym > 0x5FF ) + if (npc->ym > 0x5FF) npc->ym = 0x5FF; npc->y += npc->ym; - npc->rect = rects[npc->ani_no]; + npc->rect = rect[npc->ani_no]; } // Health refill void ActNpc017(NPCHAR *npc) { - RECT rect[2]; - - rect[0] = {288, 0, 304, 16}; - rect[1] = {304, 0, 320, 16}; + RECT rect[2] = { + {288, 0, 304, 16}, + {304, 0, 320, 16}, + }; int aa; @@ -1626,10 +1639,10 @@ void ActNpc017(NPCHAR *npc) // Door void ActNpc018(NPCHAR *npc) { - RECT rect[2]; - - rect[0] = {224, 16, 240, 40}; - rect[1] = {192, 112, 208, 136}; + RECT rect[2] = { + {224, 16, 240, 40}, + {192, 112, 208, 136}, + }; switch (npc->act_no) { @@ -1720,18 +1733,19 @@ void ActNpc019(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[4]; - RECT rect_right[4]; + RECT rect_left[4] = { + {0, 0, 40, 24}, + {160, 0, 200, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {160, 0, 200, 24}; - rect_left[2] = {80, 0, 120, 24}; - rect_left[3] = {120, 0, 160, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {160, 24, 200, 48}; - rect_right[2] = {80, 24, 120, 48}; - rect_right[3] = {120, 24, 160, 48}; + RECT rect_right[4] = { + {0, 24, 40, 48}, + {160, 24, 200, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + }; if (npc->direct == 0) npc->rect = rect_left[npc->ani_no]; From ff4352ffdebe5c0bcf361c50ce4e2c8bf1c5a598 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 19 Feb 2019 15:52:25 +0000 Subject: [PATCH 22/22] Made more NPCs ASM-accurate Geez, there has to be a faster way to do this. This is tedious as all hell. --- src/NpcAct000.cpp | 124 +++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index c48eef68..ff4f7c46 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -240,10 +240,10 @@ void ActNpc002(NPCHAR *npc) switch (npc->act_no) { case 0: //Walking - if (npc->direct) - npc->xm = 0x100; - else + if (npc->direct == 0) npc->xm = -0x100; + else + npc->xm = 0x100; if (++npc->ani_wait > 8) { @@ -282,10 +282,10 @@ void ActNpc002(NPCHAR *npc) } break; case 2: //Charge - if (npc->direct) - npc->xm = 0x400; - else + if (npc->direct == 0) npc->xm = -0x400; + else + npc->xm = 0x400; if (++npc->count1 > 200) { @@ -361,22 +361,12 @@ void ActNpc004(NPCHAR *npc) {80, 128, 96, 144}, }; - if (npc->act_no) - { - //Slight drag - npc->xm = 20 * npc->xm / 21; - npc->ym = 20 * npc->ym / 21; - - //Move - npc->x += npc->xm; - npc->y += npc->ym; - } - else + if (npc->act_no == 0) { //Move in random direction at random speed - if (!npc->direct || npc->direct == 1) + if (npc->direct == 0 || npc->direct == 1) { - uint8_t deg = Random(0, 0xFF); + const unsigned char deg = Random(0, 0xFF); npc->xm = GetCos(deg) * Random(0x200, 0x5FF) / 0x200; npc->ym = GetSin(deg) * Random(0x200, 0x5FF) / 0x200; } @@ -386,6 +376,16 @@ void ActNpc004(NPCHAR *npc) npc->ani_wait = Random(0, 3); npc->act_no = 1; } + else + { + //Slight drag + npc->xm = 20 * npc->xm / 21; + npc->ym = 20 * npc->ym / 21; + + //Move + npc->x += npc->xm; + npc->y += npc->ym; + } //Animate if (++npc->ani_wait > 4) @@ -395,20 +395,20 @@ void ActNpc004(NPCHAR *npc) } //Set framerect - if (npc->ani_no < 8) - { - if (npc->direct == 1) - npc->rect = rcUp[npc->ani_no]; - if (!npc->direct) - npc->rect = rcLeft[npc->ani_no]; - if (npc->direct == 2) - npc->rect = rcLeft[npc->ani_no]; - } - else + if (npc->ani_no > 7) { //Destroy if over npc->cond = 0; } + else + { + if (npc->direct == 1) + npc->rect = rcUp[npc->ani_no]; + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + if (npc->direct == 2) + npc->rect = rcLeft[npc->ani_no]; + } } //Critter (Green, Egg Corridor) @@ -434,21 +434,22 @@ void ActNpc005(NPCHAR *npc) // Fallthrough case 1: //Waiting //Look at player - if (npc->x <= gMC.x) - npc->direct = 2; - else + if (npc->x > gMC.x) npc->direct = 0; + else + npc->direct = 2; //Open eyes near player - if (npc->act_wait < 8 || npc->x - 0xE000 >= gMC.x || npc->x + 0xE000 <= gMC.x || npc->y - 0xA000 >= gMC.y || npc->y + 0xA000 <= gMC.y) + if (npc->act_wait >= 8 && npc->x - 0xE000 < gMC.x && npc->x + 0xE000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xA000 > gMC.y) { - if (npc->act_wait < 8) - ++npc->act_wait; - npc->ani_no = 0; + npc->ani_no = 1; } else { - npc->ani_no = 1; + if (npc->act_wait < 8) + ++npc->act_wait; + + npc->ani_no = 0; } //Jump if attacked @@ -480,10 +481,10 @@ void ActNpc005(NPCHAR *npc) PlaySoundObject(30, 1); //Jump in facing direction - if (npc->direct) - npc->xm = 0x100; - else + if (npc->direct == 0) npc->xm = -0x100; + else + npc->xm = 0x100; } break; @@ -510,10 +511,10 @@ void ActNpc005(NPCHAR *npc) npc->y += npc->ym; //Set framerect - if (npc->direct) - npc->rect = rcRight[npc->ani_no]; - else + if (npc->direct == 0) npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; } //Beetle (Goes left and right, Egg Corridor) @@ -540,10 +541,10 @@ void ActNpc006(NPCHAR *npc) case 0: //Init npc->act_no = 1; - if (npc->direct) - npc->act_no = 3; - else + if (npc->direct == 0) npc->act_no = 1; + else + npc->act_no = 3; break; case 1: @@ -565,7 +566,7 @@ void ActNpc006(NPCHAR *npc) ++npc->ani_no; } - if ( npc->ani_no > 2 ) + if (npc->ani_no > 2) npc->ani_no = 1; //Stop when hitting a wall @@ -608,7 +609,7 @@ void ActNpc006(NPCHAR *npc) ++npc->ani_no; } - if ( npc->ani_no > 2 ) + if (npc->ani_no > 2) npc->ani_no = 1; //Stop when hitting a wall @@ -631,16 +632,13 @@ void ActNpc006(NPCHAR *npc) npc->ani_no = 1; } break; - - default: - break; } //Set framerect - if (npc->direct) - npc->rect = rcRight[npc->ani_no]; - else + if (npc->direct == 0) npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; } //Basil @@ -772,26 +770,26 @@ void ActNpc008(NPCHAR *npc) break; case 1: - if (npc->x <= gMC.x) - { - npc->direct = 2; - npc->xm += 0x10; - } - else + if (npc->x > gMC.x) { npc->direct = 0; npc->xm -= 0x10; } + else + { + npc->direct = 2; + npc->xm += 0x10; + } if (npc->xm > 0x2FF) npc->xm = 0x2FF; if (npc->xm < -0x2FF) npc->xm = -0x2FF; - if (npc->y >= npc->tgt_y) - npc->ym -= 8; - else + if (npc->y < npc->tgt_y) npc->ym += 8; + else + npc->ym -= 8; if (npc->ym > 0x100) npc->ym = 0x100;