From 358423aa389927d84f1bd5825ae83a664204fa3e Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 16 Sep 2019 15:30:38 +0200 Subject: [PATCH 01/40] Some nice commenting and reordering of stuff and staticing of stuff Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 28 ++++++++++++++++------------ src/ArmsItem.h | 34 +++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index d4a8d710..c96f5a01 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -14,18 +14,20 @@ #include "Sound.h" #include "TextScr.h" -int gArmsEnergyX = 16; +int gArmsEnergyX = 0x10; + +int gSelectedArms; +int gSelectedItem; ARMS gArmsData[ARMS_MAX]; ITEM gItemData[ITEM_MAX]; -int gSelectedArms; -int gSelectedItem; -int gCampTitleY; -BOOL gCampActive; + +static BOOL gCampActive; +static int gCampTitleY; void ClearArmsData() { - gArmsEnergyX = 32; + gArmsEnergyX = 0x20; memset(gArmsData, 0, sizeof(gArmsData)); } @@ -49,7 +51,7 @@ BOOL AddArmsData(long code, long max_num) } if (i == ARMS_MAX) - return FALSE; + return FALSE; // No space left if (gArmsData[i].code == 0) { @@ -62,6 +64,7 @@ BOOL AddArmsData(long code, long max_num) gArmsData[i].max_num += max_num; gArmsData[i].num += max_num; + // Cap the amount of current ammo to the maximum amount of ammo if (gArmsData[i].num > gArmsData[i].max_num) gArmsData[i].num = gArmsData[i].max_num; @@ -70,6 +73,7 @@ BOOL AddArmsData(long code, long max_num) BOOL SubArmsData(long code) { + // Find weapon index int i; for (i = 0; i < ARMS_MAX; ++i) if (gArmsData[i].code == code) @@ -80,7 +84,7 @@ BOOL SubArmsData(long code) #else if (i == ITEM_MAX) // Oops #endif - return FALSE; + return FALSE; // Not found // Shift all arms from the right to the left for (++i; i < ARMS_MAX; ++i) @@ -122,7 +126,7 @@ BOOL AddItemData(long code) while (i < ITEM_MAX) { if (gItemData[i].code == code) - break; + break; // Really, this could just return as the following code won't do anything meaningful in this case if (gItemData[i].code == 0) break; @@ -158,7 +162,7 @@ BOOL SubItemData(long code) return TRUE; } -void MoveCampCursor() +static void MoveCampCursor() { int arms_num = 0; int item_num = 0; @@ -442,7 +446,7 @@ int CampLoop() // Resume original script LoadTextScript_Stage(old_script_path); - gArmsEnergyX = 32; + gArmsEnergyX = 0x20; return 1; } @@ -528,7 +532,7 @@ int RotationArms() if (gSelectedArms == arms_num) gSelectedArms = 0; - gArmsEnergyX = 32; + gArmsEnergyX = 0x20; PlaySoundObject(4, 1); return gArmsData[gSelectedArms].code; diff --git a/src/ArmsItem.h b/src/ArmsItem.h index bc4bf01d..c09ec130 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -2,22 +2,35 @@ #include "WindowsWrapper.h" +// "Arms" is a synonym of "weapon" here +// "Code" means "ID" here +// "Num" often means "ammo" here + +/// Weapon struct struct ARMS { + /// ID of the weapon int code; + int level; int exp; + + /// Maximum ammunition int max_num; + + /// Current ammunition int num; }; struct ITEM { + /// ID of the item int code; }; +// Limits for the amount of weapons and items #define ARMS_MAX 8 -#define ITEM_MAX 32 +#define ITEM_MAX 0x20 extern int gArmsEnergyX; @@ -26,18 +39,29 @@ extern int gSelectedItem; extern ARMS gArmsData[ARMS_MAX]; extern ITEM gItemData[ITEM_MAX]; -extern int gSelectedArms; -extern int gSelectedItem; -extern int gCampTitleY; -extern BOOL gCampActive; +/// Clear the gArmsData array, reverting it to the default state (no weapons) void ClearArmsData(); + +/// Clear the gItemData array, reverting it to the default state (no items) void ClearItemData(); + +/// Add code to the weapon array, setting max_num as the max ammo, or find code and add max_num to its ammo. Fails if no space is available and the weapon isn't already present BOOL AddArmsData(long code, long max_num); + +/// Remove code from the weapon array. Fails if code is not found. BOOL SubArmsData(long code); + +/// Replace code1 with code2, setting max_num as its max ammo. Fails if code1 is not found. BOOL TradeArms(long code1, long code2, long max_num); + +/// Add code to the item array. Fails if no space is left BOOL AddItemData(long code); + +/// Remove code from the item array. Fails if code was not found. BOOL SubItemData(long code); + +// Inventory loop int CampLoop(); BOOL CheckItem(long a); BOOL CheckArms(long a); From 9bb916e99d19a949f9ed2f19ffc65d9aefc7f691 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 17 Sep 2019 09:56:33 +0200 Subject: [PATCH 02/40] Set PutCampObject as static and commented some func decls Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 2 +- src/ArmsItem.h | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index c96f5a01..477dcfc3 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -275,7 +275,7 @@ static void MoveCampCursor() } } -void PutCampObject() +static void PutCampObject() { int i; RECT rcArms; diff --git a/src/ArmsItem.h b/src/ArmsItem.h index c09ec130..c7a2f453 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -40,13 +40,13 @@ extern int gSelectedItem; extern ARMS gArmsData[ARMS_MAX]; extern ITEM gItemData[ITEM_MAX]; -/// Clear the gArmsData array, reverting it to the default state (no weapons) +/// Clear the weapons array, reverting it to the default state (no weapons) void ClearArmsData(); -/// Clear the gItemData array, reverting it to the default state (no items) +/// Clear the item array, reverting it to the default state (no items) void ClearItemData(); -/// Add code to the weapon array, setting max_num as the max ammo, or find code and add max_num to its ammo. Fails if no space is available and the weapon isn't already present +/// Add code to the weapons, setting max_num as the max ammo, or find code and add max_num to its ammo. Fails if no space is available and the weapon isn't already present BOOL AddArmsData(long code, long max_num); /// Remove code from the weapon array. Fails if code is not found. @@ -55,16 +55,22 @@ BOOL SubArmsData(long code); /// Replace code1 with code2, setting max_num as its max ammo. Fails if code1 is not found. BOOL TradeArms(long code1, long code2, long max_num); -/// Add code to the item array. Fails if no space is left +/// Add code to the items. Fails if no space is left BOOL AddItemData(long code); -/// Remove code from the item array. Fails if code was not found. +/// Remove code from the item array. Fails if code is not found. BOOL SubItemData(long code); -// Inventory loop +/// Inventory loop. Returns mode. int CampLoop(); + +/// Search for a in the items. Returns whether a was found. BOOL CheckItem(long a); + +/// Search for a in the weapons. Returns whether a was found. BOOL CheckArms(long a); + +/// Remove num ammo from the currently selected weapon. Returns whether there was any ammo left to fire. BOOL UseArmsEnergy(long num); BOOL ChargeArmsEnergy(long num); void FullArmsEnergy(); From f2a2b3fd0c69bec8d51ad99c1c0b7efebb021ef7 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 17 Sep 2019 10:25:18 +0200 Subject: [PATCH 03/40] Commented some func decls in ArmsItem.h and changed a "32" to "0x20" in the cpp Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 2 +- src/ArmsItem.h | 34 ++++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 477dcfc3..d31ee892 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -569,6 +569,6 @@ int RotationArmsRev() void ChangeToFirstArms() { gSelectedArms = 0; - gArmsEnergyX = 32; + gArmsEnergyX = 0x20; PlaySoundObject(4, 1); } diff --git a/src/ArmsItem.h b/src/ArmsItem.h index c7a2f453..f45601bb 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -28,10 +28,13 @@ struct ITEM int code; }; + // Limits for the amount of weapons and items #define ARMS_MAX 8 #define ITEM_MAX 0x20 + +/// X coordinate for the weapons energy extern int gArmsEnergyX; extern int gSelectedArms; @@ -40,40 +43,59 @@ extern int gSelectedItem; extern ARMS gArmsData[ARMS_MAX]; extern ITEM gItemData[ITEM_MAX]; + /// Clear the weapons array, reverting it to the default state (no weapons) void ClearArmsData(); /// Clear the item array, reverting it to the default state (no items) void ClearItemData(); + /// Add code to the weapons, setting max_num as the max ammo, or find code and add max_num to its ammo. Fails if no space is available and the weapon isn't already present BOOL AddArmsData(long code, long max_num); -/// Remove code from the weapon array. Fails if code is not found. +/// Remove code from the weapons. Fails if code is not found BOOL SubArmsData(long code); -/// Replace code1 with code2, setting max_num as its max ammo. Fails if code1 is not found. +/// Replace code1 with code2, setting max_num as its max ammo. Fails if code1 is not found BOOL TradeArms(long code1, long code2, long max_num); + /// Add code to the items. Fails if no space is left BOOL AddItemData(long code); -/// Remove code from the item array. Fails if code is not found. +/// Remove code from the items. Fails if code is not found BOOL SubItemData(long code); + /// Inventory loop. Returns mode. int CampLoop(); -/// Search for a in the items. Returns whether a was found. + +/// Search for a in the items. Returns whether a was found BOOL CheckItem(long a); -/// Search for a in the weapons. Returns whether a was found. +/// Search for a in the weapons. Returns whether a was found BOOL CheckArms(long a); -/// Remove num ammo from the currently selected weapon. Returns whether there was any ammo left to fire. + +/// Remove num ammo from the currently selected weapon. Returns whether there was any ammo left to fire BOOL UseArmsEnergy(long num); + +/// Add num ammo to the currently selected weapon (capped at the maximum ammunition). Returns true BOOL ChargeArmsEnergy(long num); + +/// Set every weapons ammunition to its maximum ammunition void FullArmsEnergy(); + + +// "Rotation" means "Weapons currently owned by the player (present in the weapons array)" + +/// Change the current weapon to the next one in the rotation. Returns the ID of the newly selected weapon int RotationArms(); + +/// Change the current weapon to the previous one in the rotation. Returns the ID of the newly selected weapon int RotationArmsRev(); + +/// Change the current weapon to be the first one and play the usual rotation animation void ChangeToFirstArms(); From 6ffc8d74294334e84c7922a594937a71707788d3 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 17 Sep 2019 10:31:07 +0200 Subject: [PATCH 04/40] Shorten long line Signed-off-by: Gabriel Ravier --- src/ArmsItem.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ArmsItem.h b/src/ArmsItem.h index f45601bb..6960fce3 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -51,7 +51,8 @@ void ClearArmsData(); void ClearItemData(); -/// Add code to the weapons, setting max_num as the max ammo, or find code and add max_num to its ammo. Fails if no space is available and the weapon isn't already present +/// Add code to the weapons, setting max_num as the max ammo, or find code and add max_num to its ammo. Fails if no space is available and the weapon isn't +/// already present BOOL AddArmsData(long code, long max_num); /// Remove code from the weapons. Fails if code is not found From 4766172c3b7307198ed3f8f580011c5e3e8f3937 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 17 Sep 2019 10:48:05 +0200 Subject: [PATCH 05/40] Replaced tabs before comments with spaces, shortened a few lines and formatted some switches Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index d31ee892..643c5e72 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -51,7 +51,7 @@ BOOL AddArmsData(long code, long max_num) } if (i == ARMS_MAX) - return FALSE; // No space left + return FALSE; // No space left if (gArmsData[i].code == 0) { @@ -82,9 +82,9 @@ BOOL SubArmsData(long code) #ifdef FIX_BUGS if (i == ARMS_MAX) #else - if (i == ITEM_MAX) // Oops + if (i == ITEM_MAX) // Oops #endif - return FALSE; // Not found + return FALSE; // Not found // Shift all arms from the right to the left for (++i; i < ARMS_MAX; ++i) @@ -126,7 +126,7 @@ BOOL AddItemData(long code) while (i < ITEM_MAX) { if (gItemData[i].code == code) - break; // Really, this could just return as the following code won't do anything meaningful in this case + break; // Really, this could just return as the following code won't do anything meaningful in this case if (gItemData[i].code == 0) break; @@ -348,9 +348,11 @@ static void PutCampObject() // Draw items cursor 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); + 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); + PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], + SURFACE_ID_TEXT_BOX); for (i = 0; i < ITEM_MAX; ++i) { @@ -400,10 +402,10 @@ int CampLoop() { switch (Call_Escape(ghWnd)) { - case 0: - return 0; - case 2: - return 2; + case 0: + return 0; + case 2: + return 2; } } @@ -412,10 +414,10 @@ int CampLoop() switch (TextScriptProc()) { - case 0: - return 0; - case 2: - return 2; + case 0: + return 0; + case 2: + return 2; } PutBitmap4(&rcView, 0, 0, &rcView, SURFACE_ID_SCREEN_GRAB); From 3a837a109082ddff8363aa01a8cbc3fe23c66a5d Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 17 Sep 2019 11:04:30 +0200 Subject: [PATCH 06/40] Commented some code Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 643c5e72..995f1dca 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -42,10 +42,10 @@ BOOL AddArmsData(long code, long max_num) while (i < ARMS_MAX) { if (gArmsData[i].code == code) - break; + break; // Found identical if (gArmsData[i].code == 0) - break; + break; // Found free slot ++i; } @@ -55,6 +55,7 @@ BOOL AddArmsData(long code, long max_num) if (gArmsData[i].code == 0) { + // Initialize new weapon memset(&gArmsData[i], 0, sizeof(ARMS)); gArmsData[i].level = 1; } @@ -77,12 +78,12 @@ BOOL SubArmsData(long code) int i; for (i = 0; i < ARMS_MAX; ++i) if (gArmsData[i].code == code) - break; + break; // Found #ifdef FIX_BUGS if (i == ARMS_MAX) #else - if (i == ITEM_MAX) // Oops + if (i == ITEM_MAX) // Wrong #endif return FALSE; // Not found @@ -103,14 +104,15 @@ BOOL TradeArms(long code1, long code2, long max_num) while (i < ARMS_MAX) { if (gArmsData[i].code == code1) - break; + break; // Found ++i; } if (i == ARMS_MAX) - return FALSE; + return FALSE; // Not found + // Initialize new weapon replacing old one, but adding the maximum ammunition to that of the old weapon. gArmsData[i].level = 1; gArmsData[i].code = code2; gArmsData[i].max_num += max_num; @@ -126,16 +128,16 @@ BOOL AddItemData(long code) while (i < ITEM_MAX) { if (gItemData[i].code == code) - break; // Really, this could just return as the following code won't do anything meaningful in this case + break; // Found identical. Really, this could just return as the following code won't do anything meaningful in this case if (gItemData[i].code == 0) - break; + break; // Found free slot ++i; } if (i == ITEM_MAX) - return FALSE; + return FALSE; // Not found gItemData[i].code = code; From 38a00ec88a41f3f12edce32753933eac78cb7a20 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 17 Sep 2019 11:09:29 +0200 Subject: [PATCH 07/40] More tabs to spaces for trailing comments Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 995f1dca..4247e258 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -104,13 +104,13 @@ BOOL TradeArms(long code1, long code2, long max_num) while (i < ARMS_MAX) { if (gArmsData[i].code == code1) - break; // Found + break; // Found ++i; } if (i == ARMS_MAX) - return FALSE; // Not found + return FALSE; // Not found // Initialize new weapon replacing old one, but adding the maximum ammunition to that of the old weapon. gArmsData[i].level = 1; From 372872eeea3fff1f1f648ea7f00c809a3d1820ce Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 17 Sep 2019 11:54:00 +0200 Subject: [PATCH 08/40] Some comments and a FIX_BUGS Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 8 ++++++-- src/ArmsItem.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 4247e258..e0fcb936 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -27,6 +27,9 @@ static int gCampTitleY; void ClearArmsData() { +#ifdef FIX_BUGS + gSelectedArms = 0; // Should probably be done in order to avoid potential problems +#endif gArmsEnergyX = 0x20; memset(gArmsData, 0, sizeof(gArmsData)); } @@ -149,10 +152,10 @@ BOOL SubItemData(long code) int i; for (i = 0; i < ITEM_MAX; ++i) if (gItemData[i].code == code) - break; + break; // Found if (i == ITEM_MAX) - return FALSE; + return FALSE; // Not found // Shift all items from the right to the left for (++i; i < ITEM_MAX; ++i) @@ -164,6 +167,7 @@ BOOL SubItemData(long code) return TRUE; } +/// Handle the moving static void MoveCampCursor() { int arms_num = 0; diff --git a/src/ArmsItem.h b/src/ArmsItem.h index 6960fce3..ec74a0ed 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -44,10 +44,10 @@ extern ARMS gArmsData[ARMS_MAX]; extern ITEM gItemData[ITEM_MAX]; -/// Clear the weapons array, reverting it to the default state (no weapons) +/// Clear the weapons array, reverting it to the default state (no weapons) and adjust variables (initialize weapons basically) void ClearArmsData(); -/// Clear the item array, reverting it to the default state (no items) +/// Clear the item array, reverting it to the default state (no items) (initialize items basically) void ClearItemData(); From 6a9abb9a0d6de39b823976710bc955ae1e048b6b Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 18 Sep 2019 08:29:20 +0200 Subject: [PATCH 09/40] Moar commenting of stuff and macro-ing of certain things Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 106 +++++++++++++++++++++++++++++------------------ src/Sound.h | 5 +++ 2 files changed, 71 insertions(+), 40 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index e0fcb936..c21bd222 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -22,13 +22,49 @@ int gSelectedItem; ARMS gArmsData[ARMS_MAX]; ITEM gItemData[ITEM_MAX]; +/// True if we're in the items section of the inventory (and not in the weapons section) (only relevant when the inventory is open) static BOOL gCampActive; static int gCampTitleY; +#define FIND_CODE_OR_0(iterator, array, arrayCount, codeVariable) \ + while ((iterator) < (arrayCount)) \ + { \ + if ((array)[(iterator)].code == (codeVariable)) \ + break; /* Found identical */ \ +\ + if ((array)[(iterator)].code == 0) \ + break; /* Found free slot */ \ +\ + ++(iterator); \ + } + +#define FIND_CODE(iterator, array, arrayCount, codeVariable) \ + for ((iterator) = 0; (iterator) < (arrayCount); ++(iterator)) \ + if ((array)[(iterator)].code == (codeVariable)) \ + break; // Found + +// Special version of FIND_CODE using while for accurate code +#define FIND_CODE_WHILE(iterator, array, arrayCount, codeVariable) \ + while ((iterator) < (arrayCount)) \ + { \ + if ((array)[(iterator)].code == (codeVariable)) \ + break; /* Found */ \ + ++(iterator); \ + } \ + +/* + while (i < ARMS_MAX) + { + if (gArmsData[i].code == code1) + break; // Found + + ++i; + } */ + void ClearArmsData() { #ifdef FIX_BUGS - gSelectedArms = 0; // Should probably be done in order to avoid potential problems + gSelectedArms = 0; // Should probably be done in order to avoid potential problems with the selected weapon being invalid (like is done in SubArmsData) #endif gArmsEnergyX = 0x20; memset(gArmsData, 0, sizeof(gArmsData)); @@ -42,16 +78,7 @@ void ClearItemData() BOOL AddArmsData(long code, long max_num) { int i = 0; - while (i < ARMS_MAX) - { - if (gArmsData[i].code == code) - break; // Found identical - - if (gArmsData[i].code == 0) - break; // Found free slot - - ++i; - } + FIND_CODE_OR_0(i, gArmsData, ARMS_MAX, code) if (i == ARMS_MAX) return FALSE; // No space left @@ -79,9 +106,7 @@ BOOL SubArmsData(long code) { // Find weapon index int i; - for (i = 0; i < ARMS_MAX; ++i) - if (gArmsData[i].code == code) - break; // Found + FIND_CODE(i, gArmsData, ARMS_MAX, code) #ifdef FIX_BUGS if (i == ARMS_MAX) @@ -104,13 +129,7 @@ BOOL SubArmsData(long code) BOOL TradeArms(long code1, long code2, long max_num) { int i = 0; - while (i < ARMS_MAX) - { - if (gArmsData[i].code == code1) - break; // Found - - ++i; - } + FIND_CODE_WHILE(i, gArmsData, ARMS_MAX, code1) if (i == ARMS_MAX) return FALSE; // Not found @@ -128,16 +147,7 @@ BOOL TradeArms(long code1, long code2, long max_num) BOOL AddItemData(long code) { int i = 0; - while (i < ITEM_MAX) - { - if (gItemData[i].code == code) - break; // Found identical. Really, this could just return as the following code won't do anything meaningful in this case - - if (gItemData[i].code == 0) - break; // Found free slot - - ++i; - } + FIND_CODE_OR_0(i, gItemData, ITEM_MAX, code) if (i == ITEM_MAX) return FALSE; // Not found @@ -167,9 +177,10 @@ BOOL SubItemData(long code) return TRUE; } -/// Handle the moving +/// Update the inventory cursor static void MoveCampCursor() { + // Compute the current amount of weapons and items int arms_num = 0; int item_num = 0; while (gArmsData[arms_num].code != 0) @@ -178,22 +189,26 @@ static void MoveCampCursor() ++item_num; if (arms_num == 0 && item_num == 0) - return; + return; // Empty inventory + // True if we're currently changing inventory mode (weapons->items / items->weapons) BOOL bChange = FALSE; if (gCampActive == FALSE) { + // Handle selected weapon if (gKeyTrg & gKeyLeft) { --gSelectedArms; bChange = TRUE; } + if (gKeyTrg & gKeyRight) { ++gSelectedArms; bChange = TRUE; } + if (gKeyTrg & (gKeyUp | gKeyDown)) { if (item_num) @@ -202,13 +217,16 @@ static void MoveCampCursor() bChange = TRUE; } + if (gSelectedArms < 0) gSelectedArms = arms_num - 1; + if (gSelectedArms > arms_num - 1) gSelectedArms = 0; } else { + // Handle selected item if (gKeyTrg & gKeyLeft) { if (gSelectedItem % 6 == 0) @@ -262,7 +280,8 @@ static void MoveCampCursor() { if (gCampActive == FALSE) { - PlaySoundObject(4, 1); + // Weapons to items + PlaySoundObject(SND_SWITCH_WEAPON, 1); if (arms_num) StartTextScript(gArmsData[gSelectedArms].code + 1000); @@ -271,7 +290,12 @@ static void MoveCampCursor() } else { - PlaySoundObject(1, 1); + // Items to weapons +#ifdef FIX_BUGS + PlaySoundObject(SND_SWITCH_WEAPON, 1); +#else + PlaySoundObject(SND_YES_NO_CHANGE_CHOICE, 1); // Pretty sure this is not intended +#endif if (item_num) StartTextScript(gItemData[gSelectedItem].code + 5000); @@ -281,16 +305,22 @@ static void MoveCampCursor() } } +/// Draw the inventory static void PutCampObject() { int i; + + /// Rect for the current weapon RECT rcArms; + + /// Rect for the current item RECT rcItem; - // Get rects RECT rcPer = {72, 48, 80, 56}; RECT rcNone = {80, 48, 96, 56}; RECT rcLv = {80, 80, 96, 88}; + + /// Final rect drawn on the screen RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT rcCur1[2] = {{0, 88, 40, 128}, {40, 88, 80, 128}}; RECT rcCur2[2] = {{80, 88, 112, 104}, {80, 104, 112, 120}}; @@ -461,10 +491,8 @@ int CampLoop() BOOL CheckItem(long a) { for (int i = 0; i < ITEM_MAX; ++i) - { if (gItemData[i].code == a) return TRUE; - } return FALSE; } @@ -472,10 +500,8 @@ BOOL CheckItem(long a) BOOL CheckArms(long a) { for (int i = 0; i < ARMS_MAX; ++i) - { if (gArmsData[i].code == a) return TRUE; - } return FALSE; } diff --git a/src/Sound.h b/src/Sound.h index e2a3f9f5..65691e49 100644 --- a/src/Sound.h +++ b/src/Sound.h @@ -15,6 +15,11 @@ enum SoundEffectNames { + SND_YES_NO_CHANGE_CHOICE = 1, + SND_MESSAGE_TYPING = 2, + SND_QUOTE_BUMP_HEAD = 3, + SND_SWITCH_WEAPON = 4, + SND_YES_NO_PROMPT = 5, // To be continued SND_SILLY_EXPLOSION = 25, SND_LARGE_OBJECT_HIT_GROUND = 26, From 79d8e175a2c60e4cb5a2f6f4fdac7f05995b6db8 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Thu, 19 Sep 2019 10:30:14 +0200 Subject: [PATCH 10/40] Documented some variables and macro-ed some stuff Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index c21bd222..ea9f2f28 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -316,13 +316,22 @@ static void PutCampObject() /// Rect for the current item RECT rcItem; + /// Probably the rect for the slash RECT rcPer = {72, 48, 80, 56}; + + /// Rect for when there is no ammo (double dashes) RECT rcNone = {80, 48, 96, 56}; + + /// Rect for the "Lv" text! RECT rcLv = {80, 80, 96, 88}; /// Final rect drawn on the screen RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; + + /// Cursor rect array for weapons, element [1] being for when the cursor is flashing RECT rcCur1[2] = {{0, 88, 40, 128}, {40, 88, 80, 128}}; + + /// Cursor rect array for items, element [1] being for when the cursor is flashing RECT rcCur2[2] = {{80, 88, 112, 104}, {80, 104, 112, 120}}; RECT rcTitle1 = {80, 48, 144, 56}; RECT rcTitle2 = {80, 56, 144, 64}; @@ -353,16 +362,16 @@ static void PutCampObject() else PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], SURFACE_ID_TEXT_BOX); - // Draw arms + // Draw weapons for (i = 0; i < ARMS_MAX; ++i) { if (gArmsData[i].code == 0) break; - rcArms.left = 16 * (gArmsData[i].code % 16); - rcArms.right = rcArms.left + 16; - rcArms.top = 16 * (gArmsData[i].code / 16); - rcArms.bottom = rcArms.top + 16; + rcArms.left = TILES_TO_PIXELS(gArmsData[i].code % 0x10); + rcArms.right = rcArms.left + TILES_TO_PIXELS(1); + rcArms.top = TILES_TO_PIXELS(PIXELS_TO_TILES(gArmsData[i].code)); + rcArms.bottom = rcArms.top + TILES_TO_PIXELS(1); 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); From 453ce04e8b6fae24da2fbb87302edb5dfcbd2078 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Fri, 20 Sep 2019 19:16:31 +0200 Subject: [PATCH 11/40] Added a few comments and a newline Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index ea9f2f28..bcc23b61 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -333,6 +333,7 @@ static void PutCampObject() /// Cursor rect array for items, element [1] being for when the cursor is flashing 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}; @@ -366,13 +367,15 @@ static void PutCampObject() for (i = 0; i < ARMS_MAX; ++i) { if (gArmsData[i].code == 0) - break; + break; // Not a weapon + // Get rect for current weapon rcArms.left = TILES_TO_PIXELS(gArmsData[i].code % 0x10); rcArms.right = rcArms.left + TILES_TO_PIXELS(1); rcArms.top = TILES_TO_PIXELS(PIXELS_TO_TILES(gArmsData[i].code)); rcArms.bottom = rcArms.top + TILES_TO_PIXELS(1); + // Draw the icon, slash and "Lv" 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); From 55cc349dd60d7464b313a93d060970f59c4ac816 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Fri, 20 Sep 2019 20:25:51 +0200 Subject: [PATCH 12/40] Moar commenting stuff Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index bcc23b61..b4da6ae6 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -367,9 +367,9 @@ static void PutCampObject() for (i = 0; i < ARMS_MAX; ++i) { if (gArmsData[i].code == 0) - break; // Not a weapon + break; // Invalid weapon - // Get rect for current weapon + // Get icon rect for next weapon rcArms.left = TILES_TO_PIXELS(gArmsData[i].code % 0x10); rcArms.right = rcArms.left + TILES_TO_PIXELS(1); rcArms.top = TILES_TO_PIXELS(PIXELS_TO_TILES(gArmsData[i].code)); @@ -389,6 +389,7 @@ static void PutCampObject() } else { + // Weapon doesn't use ammunition 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); } @@ -405,8 +406,9 @@ static void PutCampObject() for (i = 0; i < ITEM_MAX; ++i) { if (gItemData[i].code == 0) - break; + break; // Invalid item + // Get rect for next item rcItem.left = 32 * (gItemData[i].code % 8); rcItem.right = rcItem.left + 32; rcItem.top = 16 * (gItemData[i].code / 8); From 7de9ecf1e7afd3a01403ceaa992afb63f73ac22e Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 12:14:17 +0200 Subject: [PATCH 13/40] Some commenting Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index b4da6ae6..4fcec026 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -425,16 +425,16 @@ int CampLoop() RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; - // Load the inventory script + // Save the current script path (to restore it when we get out of the inventory) GetTextScriptPath(old_script_path); + // Load the inventory script LoadTextScript2("ArmsItem.tsc"); gCampTitleY = (WINDOW_HEIGHT - 192) / 2; gCampActive = FALSE; gSelectedItem = 0; - // Run script arms_num = 0; while (gArmsData[arms_num].code != 0) ++arms_num; From f68ee5c4e5e33abae34e36a1f295954b1b144b9e Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 15:22:42 +0200 Subject: [PATCH 14/40] Added an enum for g_GameFlags and a few comments in CampLoop Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 4 +++- src/Game.h | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 4fcec026..8221b7ad 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -435,6 +435,7 @@ int CampLoop() gCampActive = FALSE; gSelectedItem = 0; + // Compute current amount of weapons arms_num = 0; while (gArmsData[arms_num].code != 0) ++arms_num; @@ -448,6 +449,7 @@ int CampLoop() { GetTrg(); + // Handle ESC if (gKeyTrg & KEY_ESCAPE) { switch (Call_Escape(ghWnd)) @@ -459,7 +461,7 @@ int CampLoop() } } - if (g_GameFlags & 2) + if (g_GameFlags & GAME_FLAG_IS_CONTROL_ENABLED) MoveCampCursor(); switch (TextScriptProc()) diff --git a/src/Game.h b/src/Game.h index e821ed8c..65c20bce 100644 --- a/src/Game.h +++ b/src/Game.h @@ -2,6 +2,11 @@ #include "WindowsWrapper.h" +enum GameFlagsValues +{ + GAME_FLAG_IS_CONTROL_ENABLED = 2, // Idk tbh +}; + extern int g_GameFlags; extern int gCounter; From ac5439cdf53e6c23b1903f87e53903836f9b2dd1 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 15:25:36 +0200 Subject: [PATCH 15/40] Added TBD notes to GameFlag enum Signed-off-by: Gabriel Ravier --- src/Game.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Game.h b/src/Game.h index 65c20bce..9ab95863 100644 --- a/src/Game.h +++ b/src/Game.h @@ -4,7 +4,9 @@ enum GameFlagsValues { + // To be continued GAME_FLAG_IS_CONTROL_ENABLED = 2, // Idk tbh + // To be continued }; extern int g_GameFlags; From 63a8385c54644895ae67ecdcaea1fe4707a53d94 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 18:40:24 +0200 Subject: [PATCH 16/40] Documented bit 2 of g_GameFlags Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 2 +- src/Game.h | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 8221b7ad..d16989e6 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -479,7 +479,7 @@ int CampLoop() if (gCampActive) { - if (g_GameFlags & 2 && gKeyTrg & (gKeyCancel | gKeyItem)) + if (g_GameFlags & GAME_FLAG_IS_CONTROL_ENABLED && gKeyTrg & (gKeyCancel | gKeyItem)) { StopTextScript(); break; diff --git a/src/Game.h b/src/Game.h index 9ab95863..9623063f 100644 --- a/src/Game.h +++ b/src/Game.h @@ -5,7 +5,24 @@ enum GameFlagsValues { // To be continued - GAME_FLAG_IS_CONTROL_ENABLED = 2, // Idk tbh + + /** + * While this bit is set, the game will : + * - Disable manual movement of the character + * - Disable shooting bullets + * - Disable shooting Curly's nemesis + * - Disable changing weapons + * - Disable speeding up the display of text in TSC scripts + * - Disable damage of the character + * - Not display the HUD (Life, EXP, air, weapons) + * - Disable animation of the character + * - Disable movement of the inventory cursor + * - Disable getting out of the inventory while on the item section + * - Create a bullet if some other conditions are fullfilled while iterating over the stars in ActStar (If you have any idea of how that actually works, you may + * want to replace this line with a better explanation) + */ + GAME_FLAG_IS_CONTROL_ENABLED = 2, + // To be continued }; From 337c81da4dd5af85a65b9207de360dabd233f5ac Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 18:48:12 +0200 Subject: [PATCH 17/40] Changed GAME_FLAG_IS_CONTROL_ENABLED to GAME_FLAG_IS_CONTROL_DISABLED Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 4 ++-- src/Game.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index d16989e6..78fc7f2a 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -461,7 +461,7 @@ int CampLoop() } } - if (g_GameFlags & GAME_FLAG_IS_CONTROL_ENABLED) + if (g_GameFlags & GAME_FLAG_IS_CONTROL_DISABLED) MoveCampCursor(); switch (TextScriptProc()) @@ -479,7 +479,7 @@ int CampLoop() if (gCampActive) { - if (g_GameFlags & GAME_FLAG_IS_CONTROL_ENABLED && gKeyTrg & (gKeyCancel | gKeyItem)) + if (g_GameFlags & GAME_FLAG_IS_CONTROL_DISABLED && gKeyTrg & (gKeyCancel | gKeyItem)) { StopTextScript(); break; diff --git a/src/Game.h b/src/Game.h index 9623063f..9b4d32ff 100644 --- a/src/Game.h +++ b/src/Game.h @@ -21,7 +21,7 @@ enum GameFlagsValues * - Create a bullet if some other conditions are fullfilled while iterating over the stars in ActStar (If you have any idea of how that actually works, you may * want to replace this line with a better explanation) */ - GAME_FLAG_IS_CONTROL_ENABLED = 2, + GAME_FLAG_IS_CONTROL_DISABLED = 2, // To be continued }; From 986ab280e473ed35ed420103a277f6b3708f1dec Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 19:26:58 +0200 Subject: [PATCH 18/40] Revert change from GAME_FLAG_IS_CONTROL_ENABLED to GAME_FLAG_IS_CONTROL_DISABLED and clarify its documentation Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 4 ++-- src/Game.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 78fc7f2a..d16989e6 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -461,7 +461,7 @@ int CampLoop() } } - if (g_GameFlags & GAME_FLAG_IS_CONTROL_DISABLED) + if (g_GameFlags & GAME_FLAG_IS_CONTROL_ENABLED) MoveCampCursor(); switch (TextScriptProc()) @@ -479,7 +479,7 @@ int CampLoop() if (gCampActive) { - if (g_GameFlags & GAME_FLAG_IS_CONTROL_DISABLED && gKeyTrg & (gKeyCancel | gKeyItem)) + if (g_GameFlags & GAME_FLAG_IS_CONTROL_ENABLED && gKeyTrg & (gKeyCancel | gKeyItem)) { StopTextScript(); break; diff --git a/src/Game.h b/src/Game.h index 9b4d32ff..07c26336 100644 --- a/src/Game.h +++ b/src/Game.h @@ -7,7 +7,7 @@ enum GameFlagsValues // To be continued /** - * While this bit is set, the game will : + * While this bit is NOT set, the game will : * - Disable manual movement of the character * - Disable shooting bullets * - Disable shooting Curly's nemesis @@ -21,7 +21,7 @@ enum GameFlagsValues * - Create a bullet if some other conditions are fullfilled while iterating over the stars in ActStar (If you have any idea of how that actually works, you may * want to replace this line with a better explanation) */ - GAME_FLAG_IS_CONTROL_DISABLED = 2, + GAME_FLAG_IS_CONTROL_ENABLED = 2, // To be continued }; From f6ed183687d60c4d8c7bf20c5e9f38b09e52203c Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 20:04:54 +0200 Subject: [PATCH 19/40] Remove macros for searching for codes Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 88 ++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index d16989e6..8b0ca15c 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -26,41 +26,6 @@ ITEM gItemData[ITEM_MAX]; static BOOL gCampActive; static int gCampTitleY; -#define FIND_CODE_OR_0(iterator, array, arrayCount, codeVariable) \ - while ((iterator) < (arrayCount)) \ - { \ - if ((array)[(iterator)].code == (codeVariable)) \ - break; /* Found identical */ \ -\ - if ((array)[(iterator)].code == 0) \ - break; /* Found free slot */ \ -\ - ++(iterator); \ - } - -#define FIND_CODE(iterator, array, arrayCount, codeVariable) \ - for ((iterator) = 0; (iterator) < (arrayCount); ++(iterator)) \ - if ((array)[(iterator)].code == (codeVariable)) \ - break; // Found - -// Special version of FIND_CODE using while for accurate code -#define FIND_CODE_WHILE(iterator, array, arrayCount, codeVariable) \ - while ((iterator) < (arrayCount)) \ - { \ - if ((array)[(iterator)].code == (codeVariable)) \ - break; /* Found */ \ - ++(iterator); \ - } \ - -/* - while (i < ARMS_MAX) - { - if (gArmsData[i].code == code1) - break; // Found - - ++i; - } */ - void ClearArmsData() { #ifdef FIX_BUGS @@ -78,7 +43,14 @@ void ClearItemData() BOOL AddArmsData(long code, long max_num) { int i = 0; - FIND_CODE_OR_0(i, gArmsData, ARMS_MAX, code) + while (i < ARMS_MAX) + { + if (gArmsData[i].code == code) + break; // Found identical + + if (gArmsData[i].code == 0) + break; // Found free slot + } if (i == ARMS_MAX) return FALSE; // No space left @@ -106,7 +78,9 @@ BOOL SubArmsData(long code) { // Find weapon index int i; - FIND_CODE(i, gArmsData, ARMS_MAX, code) + for (i = 0; i < ARMS_MAX; ++i) + if (gArmsData[i].code == code) + break; // Found #ifdef FIX_BUGS if (i == ARMS_MAX) @@ -129,7 +103,12 @@ BOOL SubArmsData(long code) BOOL TradeArms(long code1, long code2, long max_num) { int i = 0; - FIND_CODE_WHILE(i, gArmsData, ARMS_MAX, code1) + while (i < ARMS_MAX) + { + if (gArmsData[i].code == code1) + break; // Found identical + ++i; + } if (i == ARMS_MAX) return FALSE; // Not found @@ -147,7 +126,16 @@ BOOL TradeArms(long code1, long code2, long max_num) BOOL AddItemData(long code) { int i = 0; - FIND_CODE_OR_0(i, gItemData, ITEM_MAX, code) + while (i < ITEM_MAX) + { + if (gItemData[i].code == code) + break; // Found identical + + if (gItemData[i].code == 0) + break; // Found free slot + + ++i; + } if (i == ITEM_MAX) return FALSE; // Not found @@ -432,6 +420,8 @@ int CampLoop() LoadTextScript2("ArmsItem.tsc"); gCampTitleY = (WINDOW_HEIGHT - 192) / 2; + + // Put the cursor on the first weapon gCampActive = FALSE; gSelectedItem = 0; @@ -455,9 +445,9 @@ int CampLoop() switch (Call_Escape(ghWnd)) { case 0: - return 0; + return 0; // Quit game case 2: - return 2; + return 2; // Go to game intro } } @@ -467,16 +457,18 @@ int CampLoop() switch (TextScriptProc()) { case 0: - return 0; + return 0; // Quit game case 2: - return 2; + return 2; // Go to game intro } + // Get currently displayed image PutBitmap4(&rcView, 0, 0, &rcView, SURFACE_ID_SCREEN_GRAB); PutCampObject(); PutTextScript(); PutFramePerSecound(); + // Check whether we're getting out of the loop if (gCampActive) { if (g_GameFlags & GAME_FLAG_IS_CONTROL_ENABLED && gKeyTrg & (gKeyCancel | gKeyItem)) @@ -495,22 +487,22 @@ int CampLoop() } if (!Flip_SystemTask(ghWnd)) - return 0; + return 0; // Quit game } // Resume original script LoadTextScript_Stage(old_script_path); - gArmsEnergyX = 0x20; - return 1; + gArmsEnergyX = 0x20; // ? + return 1; // Go to game } BOOL CheckItem(long a) { for (int i = 0; i < ITEM_MAX; ++i) if (gItemData[i].code == a) - return TRUE; + return TRUE; // Found - return FALSE; + return FALSE; // Not found } BOOL CheckArms(long a) From eb46198635fde10abd14ec48b5241fe97ff38c94 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Sat, 21 Sep 2019 20:06:09 +0200 Subject: [PATCH 20/40] Add some comments for the searching of codes Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 8b0ca15c..852d7f79 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -42,6 +42,7 @@ void ClearItemData() BOOL AddArmsData(long code, long max_num) { + // Search for code int i = 0; while (i < ARMS_MAX) { @@ -76,7 +77,7 @@ BOOL AddArmsData(long code, long max_num) BOOL SubArmsData(long code) { - // Find weapon index + // Search for code int i; for (i = 0; i < ARMS_MAX; ++i) if (gArmsData[i].code == code) @@ -102,6 +103,7 @@ BOOL SubArmsData(long code) BOOL TradeArms(long code1, long code2, long max_num) { + // Search for code1 int i = 0; while (i < ARMS_MAX) { @@ -125,6 +127,7 @@ BOOL TradeArms(long code1, long code2, long max_num) BOOL AddItemData(long code) { + // Search for code int i = 0; while (i < ITEM_MAX) { @@ -147,6 +150,7 @@ BOOL AddItemData(long code) BOOL SubItemData(long code) { + // Search for code int i; for (i = 0; i < ITEM_MAX; ++i) if (gItemData[i].code == code) From 9d8018e901e1380042c26ce30697c64c0b6087ad Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 07:28:48 +0200 Subject: [PATCH 21/40] More comments in ArmsItem Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 852d7f79..609bff00 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -203,13 +203,14 @@ static void MoveCampCursor() if (gKeyTrg & (gKeyUp | gKeyDown)) { + // If there are any items, we're changing to the items section, since the weapons section has only 1 row if (item_num) gCampActive = TRUE; bChange = TRUE; } - + // Loop around gSelectedArms if needed if (gSelectedArms < 0) gSelectedArms = arms_num - 1; @@ -513,24 +514,24 @@ BOOL CheckArms(long a) { for (int i = 0; i < ARMS_MAX; ++i) if (gArmsData[i].code == a) - return TRUE; + return TRUE; // Found - return FALSE; + return FALSE; // Not found } BOOL UseArmsEnergy(long num) { if (gArmsData[gSelectedArms].max_num == 0) - return TRUE; + return TRUE; // No ammo needed if (gArmsData[gSelectedArms].num == 0) - return FALSE; + return FALSE; // No ammo left gArmsData[gSelectedArms].num -= num; if (gArmsData[gSelectedArms].num < 0) gArmsData[gSelectedArms].num = 0; - return TRUE; + return TRUE; // Was able to spend ammo } BOOL ChargeArmsEnergy(long num) From 6cd2a498295ab952c18ed8dff83b35a98a93ce95 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 08:46:38 +0200 Subject: [PATCH 22/40] Corrected comment Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 609bff00..14ed98e2 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -183,7 +183,7 @@ static void MoveCampCursor() if (arms_num == 0 && item_num == 0) return; // Empty inventory - // True if we're currently changing inventory mode (weapons->items / items->weapons) + /// True if we're currently changing cursor position BOOL bChange = FALSE; if (gCampActive == FALSE) @@ -538,10 +538,11 @@ BOOL ChargeArmsEnergy(long num) { gArmsData[gSelectedArms].num += num; + // Cap the ammo to the maximum ammunition if (gArmsData[gSelectedArms].num > gArmsData[gSelectedArms].max_num) gArmsData[gSelectedArms].num = gArmsData[gSelectedArms].max_num; - return TRUE; + return TRUE; // Always successfull } void FullArmsEnergy() From c94d1f1379c4ddbdbd2407f2df30dd00b59e2018 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 09:25:55 +0200 Subject: [PATCH 23/40] Corrected some comments in ArmsItem Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 14ed98e2..b65c78e8 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -273,7 +273,7 @@ static void MoveCampCursor() { if (gCampActive == FALSE) { - // Weapons to items + // Switch to a weapon PlaySoundObject(SND_SWITCH_WEAPON, 1); if (arms_num) @@ -283,7 +283,7 @@ static void MoveCampCursor() } else { - // Items to weapons + // Switch to an item #ifdef FIX_BUGS PlaySoundObject(SND_SWITCH_WEAPON, 1); #else From d73f82cfcf62a585ea9d17cfc7734ccab6356e65 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 10:32:23 +0200 Subject: [PATCH 24/40] Removed wrong FIX_BUGS Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index b65c78e8..56597a2c 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -284,11 +284,7 @@ static void MoveCampCursor() else { // Switch to an item -#ifdef FIX_BUGS - PlaySoundObject(SND_SWITCH_WEAPON, 1); -#else - PlaySoundObject(SND_YES_NO_CHANGE_CHOICE, 1); // Pretty sure this is not intended -#endif + PlaySoundObject(SND_YES_NO_CHANGE_CHOICE, 1); if (item_num) StartTextScript(gItemData[gSelectedItem].code + 5000); From b4ef218dcae2827a176f57cbac7455a64c3170d4 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 10:34:07 +0200 Subject: [PATCH 25/40] Removed unnecessary "and" from comment Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 56597a2c..e2e10f83 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -22,7 +22,7 @@ int gSelectedItem; ARMS gArmsData[ARMS_MAX]; ITEM gItemData[ITEM_MAX]; -/// True if we're in the items section of the inventory (and not in the weapons section) (only relevant when the inventory is open) +/// True if we're in the items section of the inventory (not in the weapons section) (only relevant when the inventory is open) static BOOL gCampActive; static int gCampTitleY; From 4fc38593d2f686004bc4021f1106ff7c99aae9a0 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 19:47:34 +0200 Subject: [PATCH 26/40] More comments in ArmsItem Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index e2e10f83..6051a297 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -233,9 +233,9 @@ static void MoveCampCursor() if (gKeyTrg & gKeyRight) { if (gSelectedItem == item_num - 1) - gSelectedItem = 6 * (gSelectedItem / 6); + gSelectedItem = 6 * (gSelectedItem / 6); // Round down to multiple of 6 else if (gSelectedItem % 6 == 5) - gSelectedItem -= 5; + gSelectedItem -= 5; // Loop around row else ++gSelectedItem; @@ -245,7 +245,7 @@ static void MoveCampCursor() if (gKeyTrg & gKeyUp) { if (gSelectedItem / 6 == 0) - gCampActive = FALSE; + gCampActive = FALSE; // We're on the first row, transition to weapons else gSelectedItem -= 6; @@ -255,7 +255,7 @@ static void MoveCampCursor() if (gKeyTrg & gKeyDown) { if (gSelectedItem / 6 == (item_num - 1) / 6) - gCampActive = FALSE; + gCampActive = FALSE; // We're on the last row, transition to weapons else gSelectedItem += 6; @@ -263,7 +263,7 @@ static void MoveCampCursor() } if (gSelectedItem >= item_num) - gSelectedItem = item_num - 1; + gSelectedItem = item_num - 1; // Don't allow selecting a non-existing item if (gCampActive && gKeyTrg & gKeyOk) StartTextScript(gItemData[gSelectedItem].code + 6000); From ba8f2138b8c19a91dd275a38c98e4c116c4eac62 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 19:52:34 +0200 Subject: [PATCH 27/40] Finished commenting ArmsItem basically Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 6051a297..63365e22 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -546,7 +546,7 @@ void FullArmsEnergy() for (int a = 0; a < ARMS_MAX; a++) { if (gArmsData[a].code == 0) - continue; + continue; // Don't change empty weapons gArmsData[a].num = gArmsData[a].max_num; } @@ -554,6 +554,7 @@ void FullArmsEnergy() int RotationArms() { + // Get amount of weapons int arms_num = 0; while (gArmsData[arms_num].code != 0) ++arms_num; @@ -563,6 +564,7 @@ int RotationArms() ResetSpurCharge(); + // Select next valid weapon ++gSelectedArms; while (gSelectedArms < arms_num) @@ -577,13 +579,14 @@ int RotationArms() gSelectedArms = 0; gArmsEnergyX = 0x20; - PlaySoundObject(4, 1); + PlaySoundObject(SND_SWITCH_WEAPON, 1); return gArmsData[gSelectedArms].code; } int RotationArmsRev() { + // Get amount of weapons int arms_num = 0; while (gArmsData[arms_num].code != 0) ++arms_num; @@ -593,6 +596,7 @@ int RotationArmsRev() ResetSpurCharge(); + // Select previous valid weapon if (--gSelectedArms < 0) gSelectedArms = arms_num - 1; @@ -605,7 +609,7 @@ int RotationArmsRev() } gArmsEnergyX = 0; - PlaySoundObject(4, 1); + PlaySoundObject(SND_SWITCH_WEAPON, 1); return gArmsData[gSelectedArms].code; } @@ -614,5 +618,5 @@ void ChangeToFirstArms() { gSelectedArms = 0; gArmsEnergyX = 0x20; - PlaySoundObject(4, 1); + PlaySoundObject(SND_SWITCH_WEAPON, 1); } From 3f6c744e16aa1460efa9f57e1e9e2f05973ddcff Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 19:57:00 +0200 Subject: [PATCH 28/40] Re-added accidentally removed statement Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 63365e22..0d4b405e 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -51,6 +51,8 @@ BOOL AddArmsData(long code, long max_num) if (gArmsData[i].code == 0) break; // Found free slot + + ++i; } if (i == ARMS_MAX) From e5e01b2b3eba5e14dd8a68d2251a46334a8f20bc Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 19:59:16 +0200 Subject: [PATCH 29/40] Re-added accidentally removed spacing Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 0d4b405e..5b57a938 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -111,6 +111,7 @@ BOOL TradeArms(long code1, long code2, long max_num) { if (gArmsData[i].code == code1) break; // Found identical + ++i; } From 07dc0aff9f9081a71686d750303131811f3071a4 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 20:12:20 +0200 Subject: [PATCH 30/40] Removed static from MoveArmsCursor to fix function ordering Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 5b57a938..1545cb51 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -173,7 +173,7 @@ BOOL SubItemData(long code) } /// Update the inventory cursor -static void MoveCampCursor() +void MoveCampCursor() { // Compute the current amount of weapons and items int arms_num = 0; From 5ca917bc97de25b736b9341757d10483a0a94c11 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 20:16:09 +0200 Subject: [PATCH 31/40] Removed usage of TILES_TO_PIXELS/PIXELS_TO_TILES in PutCampObject Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 1545cb51..71fc7935 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -362,10 +362,10 @@ static void PutCampObject() break; // Invalid weapon // Get icon rect for next weapon - rcArms.left = TILES_TO_PIXELS(gArmsData[i].code % 0x10); - rcArms.right = rcArms.left + TILES_TO_PIXELS(1); - rcArms.top = TILES_TO_PIXELS(PIXELS_TO_TILES(gArmsData[i].code)); - rcArms.bottom = rcArms.top + TILES_TO_PIXELS(1); + rcArms.left = (gArmsData[i].code % 16) * 16; + rcArms.right = rcArms.left + 16; + rcArms.top = ((gArmsData[i].code) / 16) * 16; + rcArms.bottom = rcArms.top + 16; // Draw the icon, slash and "Lv" PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 192) / 2, &rcArms, SURFACE_ID_ARMS_IMAGE); From 818640781bbd618728cf5814e283d1f52bc04c8a Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 20:18:49 +0200 Subject: [PATCH 32/40] Fixed switch formatting Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 71fc7935..c5a74842 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -448,10 +448,10 @@ int CampLoop() { switch (Call_Escape(ghWnd)) { - case 0: - return 0; // Quit game - case 2: - return 2; // Go to game intro + case 0: + return 0; // Quit game + case 2: + return 2; // Go to game intro } } @@ -460,10 +460,10 @@ int CampLoop() switch (TextScriptProc()) { - case 0: - return 0; // Quit game - case 2: - return 2; // Go to game intro + case 0: + return 0; // Quit game + case 2: + return 2; // Go to game intro } // Get currently displayed image From e2c7ea8996561f17cf026939d4097de1f5f4a6ab Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 20:22:49 +0200 Subject: [PATCH 33/40] Left long lines long instead of making them take several lines Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index c5a74842..4fb60649 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -389,11 +389,9 @@ static void PutCampObject() // Draw items cursor 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); + 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); + PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], SURFACE_ID_TEXT_BOX); for (i = 0; i < ITEM_MAX; ++i) { From 417fce45b31ff833f4cf0d42abc51ca8d8519cef Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 20:25:55 +0200 Subject: [PATCH 34/40] Fixed other static function --- src/ArmsItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 4fb60649..52ba98aa 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -298,7 +298,7 @@ void MoveCampCursor() } /// Draw the inventory -static void PutCampObject() +void PutCampObject() { int i; From b2b9d8ab128e5f2c126300697816e447593d2141 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 23 Sep 2019 20:29:09 +0200 Subject: [PATCH 35/40] Used tabs instead of spaces before trailing comments Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 70 ++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 52ba98aa..05339d72 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -47,16 +47,16 @@ BOOL AddArmsData(long code, long max_num) while (i < ARMS_MAX) { if (gArmsData[i].code == code) - break; // Found identical + break; // Found identical if (gArmsData[i].code == 0) - break; // Found free slot + break; // Found free slot ++i; } if (i == ARMS_MAX) - return FALSE; // No space left + return FALSE; // No space left if (gArmsData[i].code == 0) { @@ -83,14 +83,14 @@ BOOL SubArmsData(long code) int i; for (i = 0; i < ARMS_MAX; ++i) if (gArmsData[i].code == code) - break; // Found + break; // Found #ifdef FIX_BUGS if (i == ARMS_MAX) #else - if (i == ITEM_MAX) // Wrong + if (i == ITEM_MAX) // Wrong #endif - return FALSE; // Not found + return FALSE; // Not found // Shift all arms from the right to the left for (++i; i < ARMS_MAX; ++i) @@ -110,13 +110,13 @@ BOOL TradeArms(long code1, long code2, long max_num) while (i < ARMS_MAX) { if (gArmsData[i].code == code1) - break; // Found identical + break; // Found identical ++i; } if (i == ARMS_MAX) - return FALSE; // Not found + return FALSE; // Not found // Initialize new weapon replacing old one, but adding the maximum ammunition to that of the old weapon. gArmsData[i].level = 1; @@ -135,16 +135,16 @@ BOOL AddItemData(long code) while (i < ITEM_MAX) { if (gItemData[i].code == code) - break; // Found identical + break; // Found identical if (gItemData[i].code == 0) - break; // Found free slot + break; // Found free slot ++i; } if (i == ITEM_MAX) - return FALSE; // Not found + return FALSE; // Not found gItemData[i].code = code; @@ -157,10 +157,10 @@ BOOL SubItemData(long code) int i; for (i = 0; i < ITEM_MAX; ++i) if (gItemData[i].code == code) - break; // Found + break; // Found if (i == ITEM_MAX) - return FALSE; // Not found + return FALSE; // Not found // Shift all items from the right to the left for (++i; i < ITEM_MAX; ++i) @@ -236,9 +236,9 @@ void MoveCampCursor() if (gKeyTrg & gKeyRight) { if (gSelectedItem == item_num - 1) - gSelectedItem = 6 * (gSelectedItem / 6); // Round down to multiple of 6 + gSelectedItem = 6 * (gSelectedItem / 6); // Round down to multiple of 6 else if (gSelectedItem % 6 == 5) - gSelectedItem -= 5; // Loop around row + gSelectedItem -= 5; // Loop around row else ++gSelectedItem; @@ -248,7 +248,7 @@ void MoveCampCursor() if (gKeyTrg & gKeyUp) { if (gSelectedItem / 6 == 0) - gCampActive = FALSE; // We're on the first row, transition to weapons + gCampActive = FALSE; // We're on the first row, transition to weapons else gSelectedItem -= 6; @@ -258,7 +258,7 @@ void MoveCampCursor() if (gKeyTrg & gKeyDown) { if (gSelectedItem / 6 == (item_num - 1) / 6) - gCampActive = FALSE; // We're on the last row, transition to weapons + gCampActive = FALSE; // We're on the last row, transition to weapons else gSelectedItem += 6; @@ -266,7 +266,7 @@ void MoveCampCursor() } if (gSelectedItem >= item_num) - gSelectedItem = item_num - 1; // Don't allow selecting a non-existing item + gSelectedItem = item_num - 1; // Don't allow selecting a non-existing item if (gCampActive && gKeyTrg & gKeyOk) StartTextScript(gItemData[gSelectedItem].code + 6000); @@ -359,7 +359,7 @@ void PutCampObject() for (i = 0; i < ARMS_MAX; ++i) { if (gArmsData[i].code == 0) - break; // Invalid weapon + break; // Invalid weapon // Get icon rect for next weapon rcArms.left = (gArmsData[i].code % 16) * 16; @@ -396,7 +396,7 @@ void PutCampObject() for (i = 0; i < ITEM_MAX; ++i) { if (gItemData[i].code == 0) - break; // Invalid item + break; // Invalid item // Get rect for next item rcItem.left = 32 * (gItemData[i].code % 8); @@ -447,9 +447,9 @@ int CampLoop() switch (Call_Escape(ghWnd)) { case 0: - return 0; // Quit game + return 0; // Quit game case 2: - return 2; // Go to game intro + return 2; // Go to game intro } } @@ -459,9 +459,9 @@ int CampLoop() switch (TextScriptProc()) { case 0: - return 0; // Quit game + return 0; // Quit game case 2: - return 2; // Go to game intro + return 2; // Go to game intro } // Get currently displayed image @@ -489,46 +489,46 @@ int CampLoop() } if (!Flip_SystemTask(ghWnd)) - return 0; // Quit game + return 0; // Quit game } // Resume original script LoadTextScript_Stage(old_script_path); gArmsEnergyX = 0x20; // ? - return 1; // Go to game + return 1; // Go to game } BOOL CheckItem(long a) { for (int i = 0; i < ITEM_MAX; ++i) if (gItemData[i].code == a) - return TRUE; // Found + return TRUE; // Found - return FALSE; // Not found + return FALSE; // Not found } BOOL CheckArms(long a) { for (int i = 0; i < ARMS_MAX; ++i) if (gArmsData[i].code == a) - return TRUE; // Found + return TRUE; // Found - return FALSE; // Not found + return FALSE; // Not found } BOOL UseArmsEnergy(long num) { if (gArmsData[gSelectedArms].max_num == 0) - return TRUE; // No ammo needed + return TRUE; // No ammo needed if (gArmsData[gSelectedArms].num == 0) - return FALSE; // No ammo left + return FALSE; // No ammo left gArmsData[gSelectedArms].num -= num; if (gArmsData[gSelectedArms].num < 0) gArmsData[gSelectedArms].num = 0; - return TRUE; // Was able to spend ammo + return TRUE; // Was able to spend ammo } BOOL ChargeArmsEnergy(long num) @@ -539,7 +539,7 @@ BOOL ChargeArmsEnergy(long num) if (gArmsData[gSelectedArms].num > gArmsData[gSelectedArms].max_num) gArmsData[gSelectedArms].num = gArmsData[gSelectedArms].max_num; - return TRUE; // Always successfull + return TRUE; // Always successfull } void FullArmsEnergy() @@ -547,7 +547,7 @@ void FullArmsEnergy() for (int a = 0; a < ARMS_MAX; a++) { if (gArmsData[a].code == 0) - continue; // Don't change empty weapons + continue; // Don't change empty weapons gArmsData[a].num = gArmsData[a].max_num; } From 6645b85139985d61a2b1f54041b952f031e06a89 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 24 Sep 2019 09:30:44 +0200 Subject: [PATCH 36/40] Change gArmsEnergyX stuff from hexadecimal to decimal. Also commented some more stuff. Signed-off-by: Gabriel Ravier --- src/ArmsItem.cpp | 10 +++++----- src/ArmsItem.h | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 05339d72..0723db39 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -14,7 +14,7 @@ #include "Sound.h" #include "TextScr.h" -int gArmsEnergyX = 0x10; +int gArmsEnergyX = 16; int gSelectedArms; int gSelectedItem; @@ -31,7 +31,7 @@ void ClearArmsData() #ifdef FIX_BUGS gSelectedArms = 0; // Should probably be done in order to avoid potential problems with the selected weapon being invalid (like is done in SubArmsData) #endif - gArmsEnergyX = 0x20; + gArmsEnergyX = 32; memset(gArmsData, 0, sizeof(gArmsData)); } @@ -494,7 +494,7 @@ int CampLoop() // Resume original script LoadTextScript_Stage(old_script_path); - gArmsEnergyX = 0x20; // ? + gArmsEnergyX = 32; // Displays weapon rotation animation in case the weapon was changed return 1; // Go to game } @@ -579,7 +579,7 @@ int RotationArms() if (gSelectedArms == arms_num) gSelectedArms = 0; - gArmsEnergyX = 0x20; + gArmsEnergyX = 32; PlaySoundObject(SND_SWITCH_WEAPON, 1); return gArmsData[gSelectedArms].code; @@ -618,6 +618,6 @@ int RotationArmsRev() void ChangeToFirstArms() { gSelectedArms = 0; - gArmsEnergyX = 0x20; + gArmsEnergyX = 32; PlaySoundObject(SND_SWITCH_WEAPON, 1); } diff --git a/src/ArmsItem.h b/src/ArmsItem.h index ec74a0ed..0bfbe041 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -34,13 +34,20 @@ struct ITEM #define ITEM_MAX 0x20 -/// X coordinate for the weapons energy +/// X coordinate for the weapons HUD section. Set it to 32 for the forward weapon rotation "animation", 0 for the reverse weapon rotation "animation" and 16 to immobilise it extern int gArmsEnergyX; + +/// Currently selected weapon extern int gSelectedArms; + +// Currently selected item extern int gSelectedItem; +/// Contains data for all the weapons the character currently has extern ARMS gArmsData[ARMS_MAX]; + +/// Contains data for all the items the character currently has extern ITEM gItemData[ITEM_MAX]; From bf1239c4a18d9732eda63998ecf7de7b255635ca Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 24 Sep 2019 09:32:21 +0200 Subject: [PATCH 37/40] Commented all members of ARMS Signed-off-by: Gabriel Ravier --- src/ArmsItem.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ArmsItem.h b/src/ArmsItem.h index 0bfbe041..4ec5b407 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -12,7 +12,10 @@ struct ARMS /// ID of the weapon int code; + /// Current level of the weapon int level; + + /// Current EXP of the weapon, is reset to 0 at each level up int exp; /// Maximum ammunition From a67700d92709c332ae7f345767b353d122b7c8e0 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 24 Sep 2019 10:12:05 +0200 Subject: [PATCH 38/40] Clarify vague comment Signed-off-by: Gabriel Ravier --- src/ArmsItem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArmsItem.h b/src/ArmsItem.h index 4ec5b407..811a1b05 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -15,7 +15,7 @@ struct ARMS /// Current level of the weapon int level; - /// Current EXP of the weapon, is reset to 0 at each level up + /// Current EXP of the weapon. It is counted from the current level (it's reset to 0 at each level up) int exp; /// Maximum ammunition From 7bf3109019618aeca207d306ba1e57360c2a1314 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 25 Sep 2019 17:29:22 +0100 Subject: [PATCH 39/40] Cast X_TO_UNITS and UNITS_TO_X values to int This shuts up some MSVC warnings about implicitly casting doubles to ints when the macros' results are assigned to variables. --- src/CommonDefines.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CommonDefines.h b/src/CommonDefines.h index 1393bccc..e57af2f5 100644 --- a/src/CommonDefines.h +++ b/src/CommonDefines.h @@ -3,15 +3,15 @@ #define WINDOW_WIDTH 320 #define WINDOW_HEIGHT 240 -#define TILES_TO_PIXELS(x) ((x) * 0x10) -#define PIXELS_TO_TILES(x) ((x) / 0x10) -#define PIXELS_TO_UNITS(x) ((x) * 0x200) -#define UNITS_TO_PIXELS(x) ((x) / 0x200) -#define TILES_TO_UNITS(x) ((x) * (0x200 * 0x10)) -#define UNITS_TO_TILES(x) ((x) / (0x200 * 0x10)) +#define TILES_TO_PIXELS(x) ((int)((x) * 0x10)) +#define PIXELS_TO_TILES(x) ((int)((x) / 0x10)) +#define PIXELS_TO_UNITS(x) ((int)((x) * 0x200)) +#define UNITS_TO_PIXELS(x) ((int)((x) / 0x200)) +#define TILES_TO_UNITS(x) ((int)((x) * (0x200 * 0x10))) +#define UNITS_TO_TILES(x) ((int)((x) / (0x200 * 0x10))) -#define SECONDS_TO_FRAMES(x) ((x) * 50) -#define FRAMES_TO_SECONDS(x) ((x) / 50) +#define SECONDS_TO_FRAMES(x) ((int)((x) * 50)) +#define FRAMES_TO_SECONDS(x) ((int)((x) / 50)) enum Collisions { From 99f9629376bc18c684eae07a297505b9dca50752 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 27 Sep 2019 15:12:51 +0000 Subject: [PATCH 40/40] Remove the SHIFT-JIS from the stage table Clang never stops complaining about it, so instead we just use raw hex values, and have the original Japanese in UTF-8 as a comment. --- src/Stage.cpp | 174 +++++++++++++++++++++++++------------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/src/Stage.cpp b/src/Stage.cpp index 8fa7db54..e86dbfc7 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -31,101 +31,101 @@ int gStageNo; // Note: Pixel made numerous capitalisation errors when making this table. // This isn't a problem for Windows, because of its case-insensitive filesystem. const STAGE_TABLE gTMT[95] = { - STAGE_ENTRY("0", "0", 4, "bk0", "Guest", "0", 0, "Null", "無"), - STAGE_ENTRY("Pens", "Pens1", 1, "BkBlue", "Guest", "0", 0, "Arthur's House", "アーサーの家"), - STAGE_ENTRY("Eggs", "Eggs", 1, "BkGreen", "Eggs1", "Ravil", 0, "Egg Corridor", "タマゴ回廊"), - STAGE_ENTRY("EggX", "EggX", 4, "bk0", "Eggs1", "0", 0, "Egg No. 00", "タマゴ No.00"), - STAGE_ENTRY("EggIn", "Egg6", 4, "bk0", "Eggs1", "0", 0, "Egg No. 06", "タマゴ No.06"), - STAGE_ENTRY("Store", "EggR", 4, "bk0", "Eggs1", "0", 0, "Egg Observation Room", "タマゴ監視室"), - STAGE_ENTRY("Weed", "Weed", 1, "BkBlue", "Weed", "0", 0, "Grasstown", "クサムラ"), - STAGE_ENTRY("Barr", "Santa", 4, "bk0", "Weed", "0", 0, "Santa's House", "サンタの家"), - STAGE_ENTRY("Barr", "Chako", 1, "BkBlue", "Guest", "0", 0, "Chaco's House", "チャコの家"), - STAGE_ENTRY("Maze", "MazeI", 4, "bk0", "Maze", "0", 0, "Labyrinth I", "迷宮I"), - STAGE_ENTRY("Sand", "Sand", 1, "BkGreen", "Sand", "Omg", 1, "Sand Zone", "砂区"), - STAGE_ENTRY("Mimi", "Mimi", 1, "BkBlue", "Guest", "0", 0, "Mimiga Village", "ミミガーの村"), - STAGE_ENTRY("Cave", "Cave", 4, "bk0", "Cemet", "0", 0, "First Cave", "最初の洞窟"), - STAGE_ENTRY("Cave", "Start", 4, "bk0", "Cemet", "0", 0, "Start Point", "スタート地点"), - STAGE_ENTRY("Mimi", "Barr", 4, "bk0", "Cemet", "Bllg", 0, "Shack", "バラック小屋"), - STAGE_ENTRY("Mimi", "Pool", 1, "BkBlue", "Guest", "0", 0, "Reservoir", "貯水池"), - STAGE_ENTRY("Mimi", "Cemet", 4, "bk0", "Cemet", "0", 0, "Graveyard", "はかば"), - STAGE_ENTRY("Mimi", "Plant", 1, "BkGreen", "Plant", "0", 0, "Yamashita Farm", "山下農園"), - STAGE_ENTRY("Store", "Shelt", 4, "bk0", "Eggs1", "0", 0, "Shelter", "シェルター"), - STAGE_ENTRY("Pens", "Comu", 1, "BkBlue", "Guest", "0", 0, "Assembly Hall", "集会場"), - STAGE_ENTRY("Mimi", "MiBox", 4, "bk0", "0", "0", 0, "Save Point", "セーブポイント"), - STAGE_ENTRY("Store", "EgEnd1", 4, "bk0", "0", "0", 0, "Side Room", "タマゴ回廊の個室"), - STAGE_ENTRY("Store", "Cthu", 4, "bk0", "0", "0", 0, "Cthulhu's Abode", "クトゥルーの住処"), - STAGE_ENTRY("EggIn", "Egg1", 4, "bk0", "Eggs1", "0", 0, "Egg No. 01", "タマゴ No.01"), - STAGE_ENTRY("Pens", "Pens2", 1, "BkBlue", "Guest", "0", 0, "Arthur's House", "アーサーの家"), - STAGE_ENTRY("Barr", "Malco", 1, "BkBlue", "Weed", "Bllg", 0, "Power Room", "電源室"), - STAGE_ENTRY("Barr", "WeedS", 1, "BkBlue", "0", "0", 0, "Save Point", "セーブポイント"), - STAGE_ENTRY("Store", "WeedD", 1, "BkBlue", "0", "0", 0, "Execution Chamber", "処刑室"), - STAGE_ENTRY("Weed", "Frog", 2, "BkGreen", "Weed", "Frog", 2, "Gum", "ガム"), - STAGE_ENTRY("Sand", "Curly", 4, "bk0", "Sand", "Curly", 0, "Sand Zone Residence", "砂区駐在所"), - STAGE_ENTRY("Pens", "WeedB", 1, "BkBlue", "Ravil", "0", 0, "Grasstown Hut", "クサムラの小屋"), - STAGE_ENTRY("River", "Stream", 5, "BkBlue", "Stream", "IronH", 5, "Main Artery", "大動脈"), - STAGE_ENTRY("Pens", "CurlyS", 4, "bk0", "Sand", "Curly", 0, "Small Room", "小部屋"), - STAGE_ENTRY("Barr", "Jenka1", 4, "bk0", "Sand", "Bllg", 0, "Jenka's House", "ジェンカの家"), - STAGE_ENTRY("Sand", "Dark", 1, "bkBlack", "Sand", "0", 0, "Deserted House", "廃屋"), - STAGE_ENTRY("Gard", "Gard", 1, "BkGard", "Toro", "Bllg", 0, "Sand Zone Storehouse", "砂区倉庫"), - STAGE_ENTRY("Barr", "Jenka2", 4, "bk0", "Sand", "Bllg", 0, "Jenka's House", "ジェンカの家"), - STAGE_ENTRY("Sand", "SandE", 1, "BkGreen", "Sand", "Bllg", 0, "Sand Zone", "砂区"), - STAGE_ENTRY("Maze", "MazeH", 4, "bk0", "Maze", "0", 0, "Labyrinth H", "迷宮H"), - STAGE_ENTRY("Maze", "MazeW", 1, "BkMaze", "Maze", "X", 3, "Labyrinth W", "迷宮W"), - STAGE_ENTRY("Maze", "MazeO", 4, "bk0", "Guest", "0", 0, "Camp", "キャンプ"), - STAGE_ENTRY("Maze", "MazeD", 4, "bk0", "Guest", "Dark", 0, "Clinic Ruins", "診療所跡"), - STAGE_ENTRY("Store", "MazeA", 4, "bk0", "Maze", "0", 0, "Labyrinth Shop", "迷宮の店"), - STAGE_ENTRY("Maze", "MazeB", 1, "BkBlue", "Maze", "0", 0, "Labyrinth B", "迷宮B"), - STAGE_ENTRY("Maze", "MazeS", 2, "BkGray", "Maze", "Bllg", 0, "Boulder Chamber", "大石の塞ぐ所"), - STAGE_ENTRY("Maze", "MazeM", 1, "BkRed", "Maze", "0", 0, "Labyrinth M", "迷宮M"), - STAGE_ENTRY("Cave", "Drain", 3, "BkWater", "Cemet", "0", 0, "Dark Place", "暗い所"), - STAGE_ENTRY("Almond", "Almond", 3, "BkWater", "Cemet", "Almo1", 4, "Core", "コア"), - STAGE_ENTRY("River", "River", 2, "bkGreen", "Weed", "0", 0, "Waterway", "水路"), - STAGE_ENTRY("Eggs", "Eggs2", 1, "BkGreen", "Eggs2", "0", 0, "Egg Corridor?", "タマゴ回廊?"), - STAGE_ENTRY("Store", "Cthu2", 4, "bk0", "Eggs1", "0", 0, "Cthulhu's Abode?", "クトゥルーの住処?"), - STAGE_ENTRY("Store", "EggR2", 4, "bk0", "Eggs1", "TwinD", 6, "Egg Observation Room?", "タマゴ監視室?"), - STAGE_ENTRY("EggX", "EggX2", 4, "bk0", "Eggs1", "0", 0, "Egg No. 00", "タマゴ No.00"), - STAGE_ENTRY("Oside", "Oside", 6, "BkMoon", "Moon", "0", 0, "Outer Wall", "外壁"), - STAGE_ENTRY("Store", "EgEnd2", 4, "bk0", "Eggs1", "0", 0, "Side Room", "タマゴ回廊の個室"), - STAGE_ENTRY("Store", "Itoh", 2, "bkBlue", "Guest", "0", 0, "Storehouse", "倉庫"), - STAGE_ENTRY("Cent", "Cent", 1, "bkGreen", "Guest", "Cent", 0, "Plantation", "大農園"), - STAGE_ENTRY("Jail", "Jail1", 4, "bk0", "Guest", "Cent", 0, "Jail No. 1", "第1牢"), - STAGE_ENTRY("Jail", "Momo", 4, "bk0", "Guest", "0", 0, "Hideout", "カクレガ"), - STAGE_ENTRY("Jail", "lounge", 4, "bk0", "Guest", "0", 0, "Rest Area", "休憩所"), - STAGE_ENTRY("Store", "CentW", 4, "bk0", "Guest", "Cent", 0, "Teleporter", "転送室"), - STAGE_ENTRY("Store", "Jail2", 4, "bk0", "Guest", "Cent", 0, "Jail No. 2", "第2牢"), - STAGE_ENTRY("White", "Blcny1", 7, "BkFog", "Ravil", "Heri", 0, "Balcony", "バルコニー"), - STAGE_ENTRY("Jail", "Priso1", 4, "BkGray", "Red", "0", 0, "Final Cave", "最後の洞窟"), - STAGE_ENTRY("White", "Ring1", 7, "BkFog", "Guest", "Miza", 0, "Throne Room", "王の玉座"), - STAGE_ENTRY("White", "Ring2", 7, "BkFog", "Guest", "Dr", 0, "The King's Table", "王の食卓"), - STAGE_ENTRY("Pens", "Prefa1", 4, "Bk0", "0", "0", 0, "Prefab Building", "プレハブ"), - STAGE_ENTRY("Jail", "Priso2", 4, "BkGray", "Red", "0", 0, "Last Cave (Hidden)", "最後の洞窟・裏"), - STAGE_ENTRY("White", "Ring3", 4, "Bk0", "Miza", "Almo2", 7, "Black Space", "黒い広間"), - STAGE_ENTRY("Pens", "Little", 2, "BkBlue", "Guest", "0", 0, "Little House", "リトル家"), - STAGE_ENTRY("White", "Blcny2", 7, "BkFog", "Ravil", "Heri", 0, "Balcony", "バルコニー"), - STAGE_ENTRY("Fall", "Fall", 1, "BkFall", "Guest", "Heri", 0, "Fall", "落下"), - STAGE_ENTRY("White", "Kings", 4, "Bk0", "Kings", "0", 0, "u", "u"), - STAGE_ENTRY("Pens", "Pixel", 1, "BkBlue", "Guest", "0", 0, "Waterway Cabin", "水路の小部屋"), + STAGE_ENTRY("0", "0", 4, "bk0", "Guest", "0", 0, "Null", "\x96\xB3"), // 辟。 + STAGE_ENTRY("Pens", "Pens1", 1, "BkBlue", "Guest", "0", 0, "Arthur's House", "\x83\x41\x81\x5B\x83\x54\x81\x5B\x82\xCC\x89\xC6"), // 繧「繝シ繧オ繝シ縺ョ螳カ + STAGE_ENTRY("Eggs", "Eggs", 1, "BkGreen", "Eggs1", "Ravil", 0, "Egg Corridor", "\x83\x5E\x83\x7D\x83\x53\x89\xF1\x98\x4C"), // 繧ソ繝槭ざ蝗槫サ + STAGE_ENTRY("EggX", "EggX", 4, "bk0", "Eggs1", "0", 0, "Egg No. 00", "\x83\x5E\x83\x7D\x83\x53\x20\x4E\x6F\x2E\x30\x30"), // 繧ソ繝槭ざ No.00 + STAGE_ENTRY("EggIn", "Egg6", 4, "bk0", "Eggs1", "0", 0, "Egg No. 06", "\x83\x5E\x83\x7D\x83\x53\x20\x4E\x6F\x2E\x30\x36"), // 繧ソ繝槭ざ No.06 + STAGE_ENTRY("Store", "EggR", 4, "bk0", "Eggs1", "0", 0, "Egg Observation Room", "\x83\x5E\x83\x7D\x83\x53\x8A\xC4\x8E\x8B\x8E\xBA"), // 繧ソ繝槭ざ逶」隕門ョ、 + STAGE_ENTRY("Weed", "Weed", 1, "BkBlue", "Weed", "0", 0, "Grasstown", "\x83\x4E\x83\x54\x83\x80\x83\x89"), // 繧ッ繧オ繝繝ゥ + STAGE_ENTRY("Barr", "Santa", 4, "bk0", "Weed", "0", 0, "Santa's House", "\x83\x54\x83\x93\x83\x5E\x82\xCC\x89\xC6"), // 繧オ繝ウ繧ソ縺ョ螳カ + STAGE_ENTRY("Barr", "Chako", 1, "BkBlue", "Guest", "0", 0, "Chaco's House", "\x83\x60\x83\x83\x83\x52\x82\xCC\x89\xC6"), // 繝√Ε繧ウ縺ョ螳カ + STAGE_ENTRY("Maze", "MazeI", 4, "bk0", "Maze", "0", 0, "Labyrinth I", "\x96\xC0\x8B\x7B\x82\x68"), // 霑キ螳ョシゥ + STAGE_ENTRY("Sand", "Sand", 1, "BkGreen", "Sand", "Omg", 1, "Sand Zone", "\x8D\xBB\x8B\xE6"), // 遐ょ玄 + STAGE_ENTRY("Mimi", "Mimi", 1, "BkBlue", "Guest", "0", 0, "Mimiga Village", "\x83\x7E\x83\x7E\x83\x4B\x81\x5B\x82\xCC\x91\xBA"), // 繝溘Α繧ャ繝シ縺ョ譚 + STAGE_ENTRY("Cave", "Cave", 4, "bk0", "Cemet", "0", 0, "First Cave", "\x8D\xC5\x8F\x89\x82\xCC\x93\xB4\x8C\x41"), // 譛蛻昴ョ豢樒ェ + STAGE_ENTRY("Cave", "Start", 4, "bk0", "Cemet", "0", 0, "Start Point", "\x83\x58\x83\x5E\x81\x5B\x83\x67\x92\x6E\x93\x5F"), // 繧ケ繧ソ繝シ繝亥慍轤ケ + STAGE_ENTRY("Mimi", "Barr", 4, "bk0", "Cemet", "Bllg", 0, "Shack", "\x83\x6F\x83\x89\x83\x62\x83\x4E\x8F\xAC\x89\xAE"), // 繝舌Λ繝繧ッ蟆丞ア + STAGE_ENTRY("Mimi", "Pool", 1, "BkBlue", "Guest", "0", 0, "Reservoir", "\x92\x99\x90\x85\x92\x72"), // 雋ッ豌エ豎 + STAGE_ENTRY("Mimi", "Cemet", 4, "bk0", "Cemet", "0", 0, "Graveyard", "\x82\xCD\x82\xA9\x82\xCE"), // 縺ッ縺九ー + STAGE_ENTRY("Mimi", "Plant", 1, "BkGreen", "Plant", "0", 0, "Yamashita Farm", "\x8E\x52\x89\xBA\x94\x5F\x89\x80"), // 螻ア荳玖セイ蝨 + STAGE_ENTRY("Store", "Shelt", 4, "bk0", "Eggs1", "0", 0, "Shelter", "\x83\x56\x83\x46\x83\x8B\x83\x5E\x81\x5B"), // 繧キ繧ァ繝ォ繧ソ繝シ + STAGE_ENTRY("Pens", "Comu", 1, "BkBlue", "Guest", "0", 0, "Assembly Hall", "\x8F\x57\x89\xEF\x8F\xEA"), // 髮莨壼エ + STAGE_ENTRY("Mimi", "MiBox", 4, "bk0", "0", "0", 0, "Save Point", "\x83\x5A\x81\x5B\x83\x75\x83\x7C\x83\x43\x83\x93\x83\x67"), // 繧サ繝シ繝悶昴う繝ウ繝 + STAGE_ENTRY("Store", "EgEnd1", 4, "bk0", "0", "0", 0, "Side Room", "\x83\x5E\x83\x7D\x83\x53\x89\xF1\x98\x4C\x82\xCC\x8C\xC2\x8E\xBA"), // 繧ソ繝槭ざ蝗槫サ翫ョ蛟句ョ、 + STAGE_ENTRY("Store", "Cthu", 4, "bk0", "0", "0", 0, "Cthulhu's Abode", "\x83\x4E\x83\x67\x83\x44\x83\x8B\x81\x5B\x82\xCC\x8F\x5A\x8F\x88"), // 繧ッ繝医ぇ繝ォ繝シ縺ョ菴丞ヲ + STAGE_ENTRY("EggIn", "Egg1", 4, "bk0", "Eggs1", "0", 0, "Egg No. 01", "\x83\x5E\x83\x7D\x83\x53\x20\x4E\x6F\x2E\x30\x31"), // 繧ソ繝槭ざ No.01 + STAGE_ENTRY("Pens", "Pens2", 1, "BkBlue", "Guest", "0", 0, "Arthur's House", "\x83\x41\x81\x5B\x83\x54\x81\x5B\x82\xCC\x89\xC6"), // 繧「繝シ繧オ繝シ縺ョ螳カ + STAGE_ENTRY("Barr", "Malco", 1, "BkBlue", "Weed", "Bllg", 0, "Power Room", "\x93\x64\x8C\xB9\x8E\xBA"), // 髮サ貅仙ョ、 + STAGE_ENTRY("Barr", "WeedS", 1, "BkBlue", "0", "0", 0, "Save Point", "\x83\x5A\x81\x5B\x83\x75\x83\x7C\x83\x43\x83\x93\x83\x67"), // 繧サ繝シ繝悶昴う繝ウ繝 + STAGE_ENTRY("Store", "WeedD", 1, "BkBlue", "0", "0", 0, "Execution Chamber", "\x8F\x88\x8C\x59\x8E\xBA"), // 蜃ヲ蛻大ョ、 + STAGE_ENTRY("Weed", "Frog", 2, "BkGreen", "Weed", "Frog", 2, "Gum", "\x83\x4B\x83\x80"), // 繧ャ繝 + STAGE_ENTRY("Sand", "Curly", 4, "bk0", "Sand", "Curly", 0, "Sand Zone Residence", "\x8D\xBB\x8B\xE6\x92\x93\x8D\xDD\x8F\x8A"), // 遐ょ玄鬧仙惠謇 + STAGE_ENTRY("Pens", "WeedB", 1, "BkBlue", "Ravil", "0", 0, "Grasstown Hut", "\x83\x4E\x83\x54\x83\x80\x83\x89\x82\xCC\x8F\xAC\x89\xAE"), // 繧ッ繧オ繝繝ゥ縺ョ蟆丞ア + STAGE_ENTRY("River", "Stream", 5, "BkBlue", "Stream", "IronH", 5, "Main Artery", "\x91\xE5\x93\xAE\x96\xAC"), // 螟ァ蜍戊ц + STAGE_ENTRY("Pens", "CurlyS", 4, "bk0", "Sand", "Curly", 0, "Small Room", "\x8F\xAC\x95\x94\x89\xAE"), // 蟆城Κ螻 + STAGE_ENTRY("Barr", "Jenka1", 4, "bk0", "Sand", "Bllg", 0, "Jenka's House", "\x83\x57\x83\x46\x83\x93\x83\x4A\x82\xCC\x89\xC6"), // 繧ク繧ァ繝ウ繧ォ縺ョ螳カ + STAGE_ENTRY("Sand", "Dark", 1, "bkBlack", "Sand", "0", 0, "Deserted House", "\x94\x70\x89\xAE"), // 蟒螻 + STAGE_ENTRY("Gard", "Gard", 1, "BkGard", "Toro", "Bllg", 0, "Sand Zone Storehouse", "\x8D\xBB\x8B\xE6\x91\x71\x8C\xC9"), // 遐ょ玄蛟牙コォ + STAGE_ENTRY("Barr", "Jenka2", 4, "bk0", "Sand", "Bllg", 0, "Jenka's House", "\x83\x57\x83\x46\x83\x93\x83\x4A\x82\xCC\x89\xC6"), // 繧ク繧ァ繝ウ繧ォ縺ョ螳カ + STAGE_ENTRY("Sand", "SandE", 1, "BkGreen", "Sand", "Bllg", 0, "Sand Zone", "\x8D\xBB\x8B\xE6"), // 遐ょ玄 + STAGE_ENTRY("Maze", "MazeH", 4, "bk0", "Maze", "0", 0, "Labyrinth H", "\x96\xC0\x8B\x7B\x82\x67"), // 霑キ螳ョシィ + STAGE_ENTRY("Maze", "MazeW", 1, "BkMaze", "Maze", "X", 3, "Labyrinth W", "\x96\xC0\x8B\x7B\x82\x76"), // 霑キ螳ョシキ + STAGE_ENTRY("Maze", "MazeO", 4, "bk0", "Guest", "0", 0, "Camp", "\x83\x4C\x83\x83\x83\x93\x83\x76"), // 繧ュ繝」繝ウ繝 + STAGE_ENTRY("Maze", "MazeD", 4, "bk0", "Guest", "Dark", 0, "Clinic Ruins", "\x90\x66\x97\xC3\x8F\x8A\x90\xD5"), // 險コ逋よ園霍。 + STAGE_ENTRY("Store", "MazeA", 4, "bk0", "Maze", "0", 0, "Labyrinth Shop", "\x96\xC0\x8B\x7B\x82\xCC\x93\x58"), // 霑キ螳ョ縺ョ蠎 + STAGE_ENTRY("Maze", "MazeB", 1, "BkBlue", "Maze", "0", 0, "Labyrinth B", "\x96\xC0\x8B\x7B\x82\x61"), // 霑キ螳ョシ「 + STAGE_ENTRY("Maze", "MazeS", 2, "BkGray", "Maze", "Bllg", 0, "Boulder Chamber", "\x91\xE5\x90\xCE\x82\xCC\x8D\xC7\x82\xAE\x8F\x8A"), // 螟ァ遏ウ縺ョ蝪槭$謇 + STAGE_ENTRY("Maze", "MazeM", 1, "BkRed", "Maze", "0", 0, "Labyrinth M", "\x96\xC0\x8B\x7B\x82\x6C"), // 霑キ螳ョシュ + STAGE_ENTRY("Cave", "Drain", 3, "BkWater", "Cemet", "0", 0, "Dark Place", "\x88\xC3\x82\xA2\x8F\x8A"), // 證励>謇 + STAGE_ENTRY("Almond", "Almond", 3, "BkWater", "Cemet", "Almo1", 4, "Core", "\x83\x52\x83\x41"), // 繧ウ繧「 + STAGE_ENTRY("River", "River", 2, "bkGreen", "Weed", "0", 0, "Waterway", "\x90\x85\x98\x48"), // 豌エ霍ッ + STAGE_ENTRY("Eggs", "Eggs2", 1, "BkGreen", "Eggs2", "0", 0, "Egg Corridor?", "\x83\x5E\x83\x7D\x83\x53\x89\xF1\x98\x4C\x81\x48"), // 繧ソ繝槭ざ蝗槫サ奇シ + STAGE_ENTRY("Store", "Cthu2", 4, "bk0", "Eggs1", "0", 0, "Cthulhu's Abode?", "\x83\x4E\x83\x67\x83\x44\x83\x8B\x81\x5B\x82\xCC\x8F\x5A\x8F\x88\x81\x48"), // 繧ッ繝医ぇ繝ォ繝シ縺ョ菴丞ヲシ + STAGE_ENTRY("Store", "EggR2", 4, "bk0", "Eggs1", "TwinD", 6, "Egg Observation Room?", "\x83\x5E\x83\x7D\x83\x53\x8A\xC4\x8E\x8B\x8E\xBA\x81\x48"), // 繧ソ繝槭ざ逶」隕門ョ、シ + STAGE_ENTRY("EggX", "EggX2", 4, "bk0", "Eggs1", "0", 0, "Egg No. 00", "\x83\x5E\x83\x7D\x83\x53\x20\x4E\x6F\x2E\x30\x30"), // 繧ソ繝槭ざ No.00 + STAGE_ENTRY("Oside", "Oside", 6, "BkMoon", "Moon", "0", 0, "Outer Wall", "\x8A\x4F\x95\xC7"), // 螟門」 + STAGE_ENTRY("Store", "EgEnd2", 4, "bk0", "Eggs1", "0", 0, "Side Room", "\x83\x5E\x83\x7D\x83\x53\x89\xF1\x98\x4C\x82\xCC\x8C\xC2\x8E\xBA"), // 繧ソ繝槭ざ蝗槫サ翫ョ蛟句ョ、 + STAGE_ENTRY("Store", "Itoh", 2, "bkBlue", "Guest", "0", 0, "Storehouse", "\x91\x71\x8C\xC9"), // 蛟牙コォ + STAGE_ENTRY("Cent", "Cent", 1, "bkGreen", "Guest", "Cent", 0, "Plantation", "\x91\xE5\x94\x5F\x89\x80"), // 螟ァ霎イ蝨 + STAGE_ENTRY("Jail", "Jail1", 4, "bk0", "Guest", "Cent", 0, "Jail No. 1", "\x91\xE6\x82\x50\x98\x53"), // 隨ャシ醍欧 + STAGE_ENTRY("Jail", "Momo", 4, "bk0", "Guest", "0", 0, "Hideout", "\x83\x4A\x83\x4E\x83\x8C\x83\x4B"), // 繧ォ繧ッ繝ャ繧ャ + STAGE_ENTRY("Jail", "lounge", 4, "bk0", "Guest", "0", 0, "Rest Area", "\x8B\x78\x8C\x65\x8F\x8A"), // 莨第ゥ謇 + STAGE_ENTRY("Store", "CentW", 4, "bk0", "Guest", "Cent", 0, "Teleporter", "\x93\x5D\x91\x97\x8E\xBA"), // 霆「騾∝ョ、 + STAGE_ENTRY("Store", "Jail2", 4, "bk0", "Guest", "Cent", 0, "Jail No. 2", "\x91\xE6\x82\x51\x98\x53"), // 隨ャシ堤欧 + STAGE_ENTRY("White", "Blcny1", 7, "BkFog", "Ravil", "Heri", 0, "Balcony", "\x83\x6F\x83\x8B\x83\x52\x83\x6A\x81\x5B"), // 繝舌Ν繧ウ繝九シ + STAGE_ENTRY("Jail", "Priso1", 4, "BkGray", "Red", "0", 0, "Final Cave", "\x8D\xC5\x8C\xE3\x82\xCC\x93\xB4\x8C\x41"), // 譛蠕後ョ豢樒ェ + STAGE_ENTRY("White", "Ring1", 7, "BkFog", "Guest", "Miza", 0, "Throne Room", "\x89\xA4\x82\xCC\x8B\xCA\x8D\xC0"), // 邇九ョ邇牙コァ + STAGE_ENTRY("White", "Ring2", 7, "BkFog", "Guest", "Dr", 0, "The King's Table", "\x89\xA4\x82\xCC\x90\x48\x91\xEC"), // 邇九ョ鬟溷酷 + STAGE_ENTRY("Pens", "Prefa1", 4, "Bk0", "0", "0", 0, "Prefab Building", "\x83\x76\x83\x8C\x83\x6E\x83\x75"), // 繝励Ξ繝上ヶ + STAGE_ENTRY("Jail", "Priso2", 4, "BkGray", "Red", "0", 0, "Last Cave (Hidden)", "\x8D\xC5\x8C\xE3\x82\xCC\x93\xB4\x8C\x41\x81\x45\x97\xA0"), // 譛蠕後ョ豢樒ェ溘サ陬 + STAGE_ENTRY("White", "Ring3", 4, "Bk0", "Miza", "Almo2", 7, "Black Space", "\x8D\x95\x82\xA2\x8D\x4C\x8A\xD4"), // 鮟偵>蠎髢 + STAGE_ENTRY("Pens", "Little", 2, "BkBlue", "Guest", "0", 0, "Little House", "\x83\x8A\x83\x67\x83\x8B\x89\xC6"), // 繝ェ繝医Ν螳カ + STAGE_ENTRY("White", "Blcny2", 7, "BkFog", "Ravil", "Heri", 0, "Balcony", "\x83\x6F\x83\x8B\x83\x52\x83\x6A\x81\x5B"), // 繝舌Ν繧ウ繝九シ + STAGE_ENTRY("Fall", "Fall", 1, "BkFall", "Guest", "Heri", 0, "Fall", "\x97\x8E\x89\xBA"), // 關ス荳 + STAGE_ENTRY("White", "Kings", 4, "Bk0", "Kings", "0", 0, "u", "\x75"), // u + STAGE_ENTRY("Pens", "Pixel", 1, "BkBlue", "Guest", "0", 0, "Waterway Cabin", "\x90\x85\x98\x48\x82\xCC\x8F\xAC\x95\x94\x89\xAE"), // 豌エ霍ッ縺ョ蟆城Κ螻 STAGE_ENTRY("Maze", "e_Maze", 1, "BkMaze", "Guest", "Maze", 3, "", ""), STAGE_ENTRY("Barr", "e_Jenk", 4, "bk0", "Sand", "Bllg", 0, "", ""), STAGE_ENTRY("Barr", "e_Malc", 1, "BkBlue", "Weed", "Bllg", 0, "", ""), STAGE_ENTRY("Mimi", "e_Ceme", 4, "bk0", "Plant", "0", 0, "", ""), STAGE_ENTRY("Fall", "e_Sky", 1, "BkFall", "Guest", "Heri", 0, "", ""), - STAGE_ENTRY("Pens", "Prefa2", 4, "Bk0", "0", "0", 0, "Prefab House", "プレハブ"), - STAGE_ENTRY("Hell", "Hell1", 2, "bkRed", "Hell", "0", 0, "Sacred Ground - B1", "聖域地下1階"), - STAGE_ENTRY("Hell", "Hell2", 2, "bkRed", "Hell", "0", 0, "Sacred Ground - B2", "聖域地下2階"), - STAGE_ENTRY("Hell", "Hell3", 1, "bkRed", "Hell", "Press", 8, "Sacred Ground - B3", "聖域地下3階"), - STAGE_ENTRY("Cave", "Mapi", 2, "bk0", "Cemet", "0", 0, "Storage", "物置"), - STAGE_ENTRY("Hell", "Hell4", 4, "bk0", "Hell", "0", 0, "Passage?", "通路?"), - STAGE_ENTRY("Hell", "Hell42", 4, "bk0", "Hell", "Press", 8, "Passage?", "通路?"), - STAGE_ENTRY("Hell", "Statue", 1, "bkBlue", "0", "Cent", 0, "Statue Chamber", "石像の間"), - STAGE_ENTRY("Hell", "Ballo1", 2, "bkBlue", "Priest", "Ballos", 9, "Seal Chamber", "封印の間"), - STAGE_ENTRY("White", "Ostep", 7, "BkFog", "0", "0", 0, "Corridor", "わたり廊下"), + STAGE_ENTRY("Pens", "Prefa2", 4, "Bk0", "0", "0", 0, "Prefab House", "\x83\x76\x83\x8C\x83\x6E\x83\x75"), // 繝励Ξ繝上ヶ + STAGE_ENTRY("Hell", "Hell1", 2, "bkRed", "Hell", "0", 0, "Sacred Ground - B1", "\x90\xB9\x88\xE6\x92\x6E\x89\xBA\x82\x50\x8A\x4B"), // 閨門沺蝨ー荳具シ鷹嚴 + STAGE_ENTRY("Hell", "Hell2", 2, "bkRed", "Hell", "0", 0, "Sacred Ground - B2", "\x90\xB9\x88\xE6\x92\x6E\x89\xBA\x82\x51\x8A\x4B"), // 閨門沺蝨ー荳具シ帝嚴 + STAGE_ENTRY("Hell", "Hell3", 1, "bkRed", "Hell", "Press", 8, "Sacred Ground - B3", "\x90\xB9\x88\xE6\x92\x6E\x89\xBA\x82\x52\x8A\x4B"), // 閨門沺蝨ー荳具シ馴嚴 + STAGE_ENTRY("Cave", "Mapi", 2, "bk0", "Cemet", "0", 0, "Storage", "\x95\xA8\x92\x75"), // 迚ゥ鄂ョ + STAGE_ENTRY("Hell", "Hell4", 4, "bk0", "Hell", "0", 0, "Passage?", "\x92\xCA\x98\x48\x81\x48"), // 騾夊キッシ + STAGE_ENTRY("Hell", "Hell42", 4, "bk0", "Hell", "Press", 8, "Passage?", "\x92\xCA\x98\x48\x81\x48"), // 騾夊キッシ + STAGE_ENTRY("Hell", "Statue", 1, "bkBlue", "0", "Cent", 0, "Statue Chamber", "\x90\xCE\x91\x9C\x82\xCC\x8A\xD4"), // 遏ウ蜒上ョ髢 + STAGE_ENTRY("Hell", "Ballo1", 2, "bkBlue", "Priest", "Ballos", 9, "Seal Chamber", "\x95\x95\x88\xF3\x82\xCC\x8A\xD4"), // 蟆∝魂縺ョ髢 + STAGE_ENTRY("White", "Ostep", 7, "BkFog", "0", "0", 0, "Corridor", "\x82\xED\x82\xBD\x82\xE8\x98\x4C\x89\xBA"), // 繧上◆繧雁サ贋ク STAGE_ENTRY("Labo", "e_Labo", 4, "bk0", "Guest", "0", 0, "", ""), - STAGE_ENTRY("Cave", "Pole", 4, "bk0", "Guest", "0", 0, "Hermit Gunsmith", "はぐれ銃鍛冶"), + STAGE_ENTRY("Cave", "Pole", 4, "bk0", "Guest", "0", 0, "Hermit Gunsmith", "\x82\xCD\x82\xAE\x82\xEA\x8F\x65\x92\x62\x96\xE8"), // 縺ッ縺舌l驫骰帛カ STAGE_ENTRY("0", "Island", 4, "bk0", "Island", "0", 0, "", ""), - STAGE_ENTRY("Hell", "Ballo2", 2, "bkBlue", "Priest", "Bllg", 9, "Seal Chamber", "封印の間"), + STAGE_ENTRY("Hell", "Ballo2", 2, "bkBlue", "Priest", "Bllg", 9, "Seal Chamber", "\x95\x95\x88\xF3\x82\xCC\x8A\xD4"), // 蟆∝魂縺ョ髢 STAGE_ENTRY("White", "e_Blcn", 7, "BkFog", "Miza", "0", 9, "", ""), - STAGE_ENTRY("Oside", "Clock", 6, "BkMoon", "Moon", "0", 0, "Clock Room", "時計屋"), + STAGE_ENTRY("Oside", "Clock", 6, "BkMoon", "Moon", "0", 0, "Clock Room", "\x8E\x9E\x8C\x76\x89\xAE"), // 譎りィ亥ア }; BOOL TransferStage(int no, int w, int x, int y)