From 6d624396ff2768f667b5638313df467ece1e4c2d Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Fri, 3 May 2019 13:54:43 +0200 Subject: [PATCH 01/11] Added *.out files to executable formats that are filtered out Signed-off-by: Gabriel Ravier --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 47b5d011..cdbda534 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,10 @@ build.zip msvc2003/devilution/orig.asm msvc2003/devilution/compare.asm -# Exclude build output on Linux (exclude normally produced executable files) +# Exclude build output on Linux (exclude normally produced executable files and out files) build_en/CSE2 build_en/DoConfig +*.out # The Makefile outputs "release" and "debug" for the english build build_en/release From c4fec6596c02a6cdb6cec416f3d5bde42cd69c4b Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 6 May 2019 13:06:16 +0200 Subject: [PATCH 02/11] Merge master into addSomeMoreStuffToGitIgnore Signed-off-by: Gabriel Ravier --- .gitignore | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d7b7b2cd..26c1a783 100644 --- a/.gitignore +++ b/.gitignore @@ -14,17 +14,26 @@ build_jp/*.rec msvc2003/devilution/orig.asm msvc2003/devilution/compare.asm -# Exclude build output on Linux (exclude normally produced executable files) +# Exclude build output on Linux (exclude normally produced executable files and out files) build_en/CSE2 build_en/CSE2d build_en/DoConfig build_en/DoConfigd +*.out + +# The Makefile outputs "release" and "debug" for the english build +build_en/release +build_en/debug build_jp/CSE2 build_jp/CSE2d build_jp/DoConfig build_jp/DoConfigd +# The Makefile outputs "releasejp" and "debugjp" for the japanese build +build_jp/releasejp +build_jp/debugjp + # Exclude executables in the build folder (and .exe.manifest files) build_en/*.exe From 0e4319a3338363aa3590da7e6ba492f4e685b676 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 14:09:41 +0200 Subject: [PATCH 03/11] Fixed bad .gitignore ignores (It ignored outdated executables) Signed-off-by: Gabriel Ravier --- .gitignore | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitignore b/.gitignore index 08a55b23..e092319d 100644 --- a/.gitignore +++ b/.gitignore @@ -19,19 +19,11 @@ build_en/CSE2 build_en/DoConfig *.out -# The Makefile outputs "release" and "debug" for the english build -build_en/release -build_en/debug - build_jp/CSE2 build_jp/CSE2d build_jp/DoConfig build_jp/DoConfigd -# The Makefile outputs "releasejp" and "debugjp" for the japanese build -build_jp/releasejp -build_jp/debugjp - # Exclude executables in the build folder (and .exe.manifest files) build_en/*.exe From 1ed1597c0791cacccbdbf9c01824bd05ba54f3e8 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 14:14:06 +0200 Subject: [PATCH 04/11] Properly made .out files be filtered (and some other stuff) Changed a few notes (such as for exes or for converted res files Removed VS Code stuff because this is the kind of stuff that should go into people's global .gitignore and not in local ones Signed-off-by: Gabriel Ravier --- .gitignore | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index e092319d..63beba99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Exclude obj directory (object files for Makefile build) /obj -# Exclude the converted resource files +# Exclude converted resource files src/Resource # Exclude .dat and .rec files in build directories (avoid Config.dat, 290.rec and others) @@ -16,16 +16,16 @@ msvc2003/devilution/compare.asm # Exclude build output on Linux (exclude normally produced executable files and out files) build_en/CSE2 +build_en/CSE2d build_en/DoConfig -*.out - +build_en/DoConfigd build_jp/CSE2 build_jp/CSE2d build_jp/DoConfig build_jp/DoConfigd +*.out - -# Exclude executables in the build folder (and .exe.manifest files) +# Exclude PE executables in the build folder (and .exe.manifest files) build_en/*.exe build_en/*.exe.manifest build_jp/*.exe @@ -45,12 +45,3 @@ msvc2003/Debug msvc2003/Release msvc2003/Debug (Japanese) msvc2003/Release (Japanese) - -# Exclude VS Code folder -.vscode/* - -# Include generically useful files for VS Code users -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json From 260d245e4cd43be3ace24005e06e8000712a509c Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 7 May 2019 20:58:29 +0100 Subject: [PATCH 05/11] Made NpcTbl.cpp ASM-accurate --- msvc2003/devilution/comparer-config.toml | 8 +++ src/NpcTbl.cpp | 84 +++++++++++++++++------- src/NpcTbl.h | 4 +- 3 files changed, 72 insertions(+), 24 deletions(-) diff --git a/msvc2003/devilution/comparer-config.toml b/msvc2003/devilution/comparer-config.toml index d44ee262..73bfb2a0 100644 --- a/msvc2003/devilution/comparer-config.toml +++ b/msvc2003/devilution/comparer-config.toml @@ -2126,6 +2126,14 @@ addr = 0x46E9E0 name = "ActNpc360" addr = 0x46EA90 +[[func]] +name = "LoadNpcTable" +addr = 0x472400 + +[[func]] +name = "ReleaseNpcTable" +addr = 0x472710 + [[func]] name = "InitBossChar" addr = 0x472740 diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index ef51beaf..9f9409a3 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -1,60 +1,98 @@ #include "NpcTbl.h" +#include #include #include #include +#include "WindowsWrapper.h" + #include "File.h" #include "Generic.h" #include "NpcAct.h" NPC_TABLE *gNpcTable; -bool LoadNpcTable(const char *path) +BOOL LoadNpcTable(const char *path) { - const long size = GetFileSizeLong(path); - if (size == -1) - return false; + FILE *fp; + long n; + long num; + unsigned long size; - const long num = size / 0x18; + size = GetFileSizeLong(path); + if (size == -1) + return FALSE; + + num = size / 0x18; gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE)); if (gNpcTable == NULL) - return false; + return FALSE; - FILE *fp = fopen(path, "rb"); + fp = fopen(path, "rb"); if (fp == NULL) - return false; + { + free(gNpcTable); + gNpcTable = 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 +#ifdef NONPORTABLE + for (n = 0; n < num; n++) //bits + fread(&gNpcTable[n].bits, 2, 1, fp); + for (n = 0; n < num; n++) //life + fread(&gNpcTable[n].life, 2, 1, fp); + for (n = 0; n < num; n++) //surf fread(&gNpcTable[n].surf, 1, 1, fp); - for (long n = 0; n < num; n++) //destroy_voice + for (n = 0; n < num; n++) //destroy_voice fread(&gNpcTable[n].destroy_voice, 1, 1, fp); - for (long n = 0; n < num; n++) //hit_voice + for (n = 0; n < num; n++) //hit_voice fread(&gNpcTable[n].hit_voice, 1, 1, fp); - for (long n = 0; n < num; n++) //size + for (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 + for (n = 0; n < num; n++) //exp + fread(&gNpcTable[n].exp, 4, 1, fp); + for (n = 0; n < num; n++) //damage + fread(&gNpcTable[n].damage, 4, 1, fp); + for (n = 0; n < num; n++) //hit fread(&gNpcTable[n].hit, 4, 1, fp); - for (long n = 0; n < num; n++) //view + for (n = 0; n < num; n++) //view fread(&gNpcTable[n].view, 4, 1, fp); +#else + for (n = 0; n < num; n++) //bits + gNpcTable[n].bits = File_ReadLE16(fp); + for (n = 0; n < num; n++) //life + gNpcTable[n].life = File_ReadLE16(fp); + for (n = 0; n < num; n++) //surf + fread(&gNpcTable[n].surf, 1, 1, fp); + for (n = 0; n < num; n++) //destroy_voice + fread(&gNpcTable[n].destroy_voice, 1, 1, fp); + for (n = 0; n < num; n++) //hit_voice + fread(&gNpcTable[n].hit_voice, 1, 1, fp); + for (n = 0; n < num; n++) //size + fread(&gNpcTable[n].size, 1, 1, fp); + for (n = 0; n < num; n++) //exp + gNpcTable[n].exp = File_ReadLE32(fp); + for (n = 0; n < num; n++) //damage + gNpcTable[n].damage = File_ReadLE32(fp); + for (n = 0; n < num; n++) //hit + fread(&gNpcTable[n].hit, 4, 1, fp); + for (n = 0; n < num; n++) //view + fread(&gNpcTable[n].view, 4, 1, fp); +#endif fclose(fp); - return true; + return TRUE; } void ReleaseNpcTable() { if (gNpcTable) + { free(gNpcTable); + gNpcTable = NULL; + } } //Npc function table diff --git a/src/NpcTbl.h b/src/NpcTbl.h index e7604d41..981df470 100644 --- a/src/NpcTbl.h +++ b/src/NpcTbl.h @@ -2,6 +2,8 @@ #include +#include "WindowsWrapper.h" + #include "Draw.h" #include "NpChar.h" @@ -29,7 +31,7 @@ struct NPC_TABLE extern NPC_TABLE *gNpcTable; -bool LoadNpcTable(const char *path); +BOOL LoadNpcTable(const char *path); void ReleaseNpcTable(); //NPC Function table From 1d0129e6818fbd6e84b858f58d827f762dbf3000 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 09:28:44 +0200 Subject: [PATCH 06/11] Corrected formatting in Map.cpp Signed-off-by: Gabriel Ravier --- src/Map.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/Map.cpp b/src/Map.cpp index 037bdc0e..097e10b4 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -29,16 +29,16 @@ BOOL LoadMapData2(const char *path_map) { unsigned char dum; - //Get path + // Get path char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, path_map); - //Open file + // Open file FILE *fp = fopen(path, "rb"); if (fp == NULL) return FALSE; - //Make sure file begins with "PXM" + // Make sure file begins with "PXM" char check[3]; fread(check, 1, 3, fp); @@ -50,10 +50,9 @@ BOOL LoadMapData2(const char *path_map) else { fread(&dum, 1, 1, fp); - //Get width and height + // Get width and height #ifdef NONPORTABLE - // This fails on big-endian hardware, and platforms - // where short is not two bytes long. + // This fails on big-endian hardware, and platforms where short is not two bytes long. fread(&gMap.width, 2, 1, fp); fread(&gMap.length, 2, 1, fp); #else @@ -68,7 +67,7 @@ BOOL LoadMapData2(const char *path_map) } else { - //Read tiledata + // Read tiledata fread(gMap.data, 1, gMap.length * gMap.width, fp); fclose(fp); return TRUE; @@ -80,7 +79,7 @@ BOOL LoadMapData2(const char *path_map) BOOL LoadAttributeData(const char *path_atrb) { - //Open file + // Open file char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, path_atrb); @@ -88,7 +87,7 @@ BOOL LoadAttributeData(const char *path_atrb) if (fp == NULL) return FALSE; - //Read data + // Read data fread(gMap.atrb, 1, 0x100, fp); fclose(fp); return TRUE; @@ -158,7 +157,7 @@ void PutStage_Back(int fx, int fy) RECT rect; int num_x; - //Get range to draw + // Get range to draw num_x = ((WINDOW_WIDTH + 0xF) / 0x10) + 1; num_y = ((WINDOW_HEIGHT + 0xF) / 0x10) + 1; put_x = (fx / 0x200 + 8) / 0x10; @@ -168,14 +167,14 @@ void PutStage_Back(int fx, int fy) { for (i = put_x; i < put_x + num_x; i++) { - //Get attribute + // Get attribute offset = i + j * gMap.width; atrb = GetAttribute(i, j); if (atrb >= 0x20) continue; - //Draw tile + // Draw tile rect.left = 16 * (gMap.data[offset] % 0x10); rect.top = 16 * (gMap.data[offset] / 0x10); rect.right = rect.left + 16; @@ -199,7 +198,7 @@ void PutStage_Front(int fx, int fy) RECT rect; int num_x; - //Get range to draw + // Get range to draw num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1; num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1; put_x = (fx / 0x200 + 8) / 16; @@ -209,14 +208,14 @@ void PutStage_Front(int fx, int fy) { for (i = put_x; i < put_x + num_x; i++) { - //Get attribute + // Get attribute offset = i + j * gMap.width; atrb = GetAttribute(i, j); if (atrb < 0x40 || atrb >= 0x80) continue; - //Draw tile + // Draw tile rect.left = 16 * (gMap.data[offset] % 0x10); rect.top = 16 * (gMap.data[offset] / 0x10); rect.right = rect.left + 16; @@ -242,11 +241,11 @@ void PutMapDataVector(int fx, int fy) RECT rect; int num_x; - //Animate the wind + // Animate the wind static unsigned char count = 0; count += 2; - //Get range to draw + // Get range to draw num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1; num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1; put_x = (fx / 0x200 + 8) / 16; @@ -256,7 +255,7 @@ void PutMapDataVector(int fx, int fy) { for (i = put_x; i < put_x + num_x; i++) { - //Get attribute + // Get attribute offset = i + j * gMap.width; atrb = GetAttribute(i, j); From b19733f47e6657ccaac7d4b22968dd33ba69cbe2 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 09:30:14 +0200 Subject: [PATCH 07/11] Correct formatting in Main.cpp Signed-off-by: Gabriel Ravier --- src/Main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index c8d08769..61d6a3bf 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -50,12 +50,12 @@ static unsigned long int next = 1; int rep_rand() { next = ((next) * 214013 + 2531011); - return ((next) >> 16) & 0x7FFF; + return ((next) >> 16) & 0x7FFF; } void rep_srand(unsigned int seed) { - next = seed; + next = seed; } //Framerate stuff @@ -82,7 +82,7 @@ int GetFramePerSecound() current_tick = SDL_GetTicks(); ++current_frame; - if ( base_tick + 1000 <= current_tick ) + if (base_tick + 1000 <= current_tick) { base_tick += 1000; frames_this_second = current_frame; @@ -487,7 +487,7 @@ bool SystemTask() case SDL_KEYDOWN: case SDL_KEYUP: - #ifdef FIX_BUGS +#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. @@ -561,7 +561,7 @@ bool SystemTask() break; } break; - #else +#else switch (event.key.keysym.sym) { case SDLK_ESCAPE: @@ -627,7 +627,7 @@ bool SystemTask() break; } break; - #endif +#endif } } From 846d34eaf1b622a415c5b4dc09081e8d4c531f63 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 09:35:36 +0200 Subject: [PATCH 08/11] Corrected formatting in MapName.cpp Signed-off-by: Gabriel Ravier --- src/MapName.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/MapName.cpp b/src/MapName.cpp index 05c32d79..7f403a4c 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -15,8 +15,9 @@ void ReadyMapName(const char *str) int a; //Handle "Studio Pixel presents" text in the intro - unsigned char presentText[24] = { - #ifdef JAPANESE + unsigned char presentText[24] = + { +#ifdef JAPANESE // "ŠJ”­ŽºPixel presents" 0x8A - 1, // ŠJ 0x4A - 1, @@ -38,7 +39,7 @@ void ReadyMapName(const char *str) 'n' - 1, 't' - 1, 's' - 1, - #else +#else // " Studio Pixel presents" ' ' - 1, ' ' - 1, @@ -63,7 +64,7 @@ void ReadyMapName(const char *str) 'n' - 1, 't' - 1, 's' - 1, - #endif +#endif 0xFF }; From 2f15c23277664ad36c893162d6b3b180914a1249 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 09:37:06 +0200 Subject: [PATCH 09/11] Add note to comment and correct other comment Signed-off-by: Gabriel Ravier --- src/MapName.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MapName.cpp b/src/MapName.cpp index 7f403a4c..29e25722 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -14,7 +14,7 @@ void ReadyMapName(const char *str) { int a; - //Handle "Studio Pixel presents" text in the intro + //Handle "Studio Pixel presents" text in the intro, using an obfuscated string unsigned char presentText[24] = { #ifdef JAPANESE @@ -93,7 +93,7 @@ void ReadyMapName(const char *str) void PutMapName(BOOL bMini) { - // 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no name for it. + // 'unused_rect' isn't the original name. The Linux port optimized this out, so there's no name for it. RECT unused_rect = {0, 0, 160, 16}; if (bMini) From 9ed2cdc9f1106681a24acd0f12f2e20a8821d59b Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 09:39:08 +0200 Subject: [PATCH 10/11] Correct comment spacing and convert MapName.cpp to UTF-8 Signed-off-by: Gabriel Ravier --- src/MapName.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/MapName.cpp b/src/MapName.cpp index 29e25722..490b8b40 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -14,16 +14,16 @@ void ReadyMapName(const char *str) { int a; - //Handle "Studio Pixel presents" text in the intro, using an obfuscated string + // Handle "Studio Pixel presents" text in the intro, using an obfuscated string unsigned char presentText[24] = { #ifdef JAPANESE - // "ŠJ”­ŽºPixel presents" - 0x8A - 1, // ŠJ + // "開発室Pixel presents" + 0x8A - 1, // é–‹ 0x4A - 1, - 0x94 - 1, // ”­ + 0x94 - 1, // 発 0xAD - 1, - 0x8E - 1, // Žº + 0x8E - 1, // 室 0xBA - 1, 'P' - 1, 'i' - 1, @@ -68,7 +68,7 @@ void ReadyMapName(const char *str) 0xFF }; - //Reset map name flags + // Reset map name flags gMapName.flag = 0; gMapName.wait = 0; @@ -80,10 +80,10 @@ void ReadyMapName(const char *str) str = (char*)presentText; } - //Copy map's name to the MapName + // Copy map's name to the MapName strcpy(gMapName.name, str); - //Draw the text to the surface + // Draw the text to the surface a = (int)strlen(gMapName.name); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); @@ -98,7 +98,7 @@ void PutMapName(BOOL bMini) if (bMini) { - //Map system + // Map system RECT rcBack; rcBack.left = 0; rcBack.right = WINDOW_WIDTH; @@ -110,7 +110,7 @@ void PutMapName(BOOL bMini) } else if (gMapName.flag) { - //MNA + // MNA PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, (WINDOW_HEIGHT - 80) / 2, &rc, SURFACE_ID_ROOM_NAME); if (++gMapName.wait > 160) gMapName.flag = 0; From 3b1c3d997aed99608d769c520260327affa485f2 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 10:23:49 +0200 Subject: [PATCH 11/11] Put *.out only for build_en/jp instead of globally Signed-off-by: Gabriel Ravier --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 63beba99..440e8458 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,8 @@ build_jp/CSE2 build_jp/CSE2d build_jp/DoConfig build_jp/DoConfigd -*.out +build_en/*.out +build_jp/*.out # Exclude PE executables in the build folder (and .exe.manifest files) build_en/*.exe