From 4f208b3b8e25eada4d8c4b8d117d31edd42c1acb Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 12:41:39 +0200 Subject: [PATCH 01/18] Make comment style consistent Just added a space if there was no space after "//" Also I changed my regex to "((//|\;)[^ ]|(for|while|if|while|do|void|int|bool)\(|(for|while|if|while|do)\ \(.*\)\;)" Signed-off-by: Gabriel Ravier --- src/Back.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index 51b715fa..19ade92f 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -21,7 +21,7 @@ BOOL InitBack(const char *fName, int type) // Unused, hilariously color_black = GetCortBoxColor(RGB(0, 0, 0x10)); - //Get width and height + // Get width and height char path[PATH_LENGTH]; sprintf(path, "%s/%s.pbm", gDataPath, fName); @@ -72,7 +72,7 @@ BOOL InitBack(const char *fName, int type) fclose(fp); #endif - //Set background stuff and load texture + // Set background stuff and load texture gBack.flag = 1; if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND)) return FALSE; @@ -138,7 +138,7 @@ void PutBack(int fx, int fy) case 6: case 7: - //Sky + // Sky static unsigned int fillNext; fillNext = 0; for (int y = 0; y < WINDOW_HEIGHT - 240 + 88; y += 88) @@ -156,7 +156,7 @@ void PutBack(int fx, int fy) rect.right = 320; PutBitmap4(&grcGame, (WINDOW_WIDTH - 320) / 2, WINDOW_HEIGHT - 240, &rect, SURFACE_ID_LEVEL_BACKGROUND); - //Cloud layer 1 + // Cloud layer 1 rect.top = 88; rect.bottom = 123; rect.left = gBack.fx / 2; @@ -167,7 +167,7 @@ void PutBack(int fx, int fy) for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++) PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx / 2 % 320, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); - //Cloud layer 2 + // Cloud layer 2 rect.top = 123; rect.bottom = 146; rect.left = gBack.fx % 320; @@ -178,7 +178,7 @@ void PutBack(int fx, int fy) for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++) PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx % 320, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); - //Cloud layer 3 + // Cloud layer 3 rect.top = 146; rect.bottom = 176; rect.left = 2 * gBack.fx % 320; @@ -189,7 +189,7 @@ void PutBack(int fx, int fy) for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++) PutBitmap4(&grcGame, (320 * (i + 1)) - 2 * gBack.fx % 320, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); - //Cloud layer 4 + // Cloud layer 4 rect.top = 176; rect.bottom = 240; rect.left = 4 * gBack.fx % 320; @@ -248,49 +248,49 @@ void PutFront(int fx, int fy) } - //Draw black bars - if (!(g_GameFlags & 8)) //Detect if credits are running + // Draw black bars + if (!(g_GameFlags & 8)) // Detect if credits are running { - const bool fromFocus = (gStageNo == 31); //Get if we should only draw around a 320x240 area of the focus point + const bool fromFocus = (gStageNo == 31); // Get if we should only draw around a 320x240 area of the focus point - //Get focus rect + // Get focus rect int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8); int focusY = gFrame.y + (WINDOW_HEIGHT << 8) - (240 << 8); int focusR = focusX + (320 << 9); int focusB = focusY + (240 << 9); - //Get borders + // Get borders const int barLeft = fromFocus ? focusX : -0x1000; const int barTop = fromFocus ? focusY : -0x1000; const int barRight = fromFocus ? focusR : (gMap.width << 13) - 0x1000; const int barBottom = fromFocus ? focusB : (gMap.length << 13) - 0x1000; - //Draw bars + // Draw bars RECT barRect; - //Left + // Left barRect.left = 0; barRect.top = 0; barRect.right = (barLeft - gFrame.x) >> 9; barRect.bottom = WINDOW_HEIGHT; CortBox(&barRect, 0x000000); - //Top + // Top barRect.left = 0; barRect.top = 0; barRect.right = WINDOW_WIDTH; barRect.bottom = (barTop - gFrame.y) >> 9; CortBox(&barRect, 0x000000); - //Right + // Right barRect.left = (barRight - gFrame.x) >> 9; barRect.top = 0; barRect.right = WINDOW_WIDTH; barRect.bottom = WINDOW_HEIGHT; CortBox(&barRect, 0x000000); - //Bottom + // Bottom barRect.left = 0; barRect.top = (barBottom - gFrame.y) >> 9; barRect.right = WINDOW_WIDTH; From 0f7afa74017abb467aa8091fbd9b6a355c08a39e Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 12:54:21 +0200 Subject: [PATCH 02/18] Fixed comment formatting in BossOhm.cpp (intended to do this for all bosses but found nothing lol) (btw changed my regex to "((//|\;)[^ \t]|(for|while|if|while|do|void|int|bool)\(|(for|while|if|while|do)\ \(.*\)\;)") Signed-off-by: Gabriel Ravier --- src/BossOhm.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BossOhm.cpp b/src/BossOhm.cpp index 7a82b099..2df6aedd 100644 --- a/src/BossOhm.cpp +++ b/src/BossOhm.cpp @@ -183,7 +183,7 @@ void ActBossChar_Omega() gBoss[5].cond = 0x80; break; - case 20: //Rising out of the ground + case 20: // Rising out of the ground gBoss[0].act_no = 30; gBoss[0].act_wait = 0; gBoss[0].ani_no = 0; @@ -227,7 +227,7 @@ void ActBossChar_Omega() } break; - case 50: //Open mouth + case 50: // Open mouth if (++gBoss[0].count1 > 2) { gBoss[0].count1 = 0; @@ -244,7 +244,7 @@ void ActBossChar_Omega() } break; - case 60: //Shoot out of mouth + case 60: // Shoot out of mouth if (++gBoss[0].act_wait > 20 && gBoss[0].act_wait < 80 && !(gBoss[0].act_wait % 3)) { if (Random(0, 9) < 8) @@ -263,7 +263,7 @@ void ActBossChar_Omega() } break; - case 70: //Close mouth + case 70: // Close mouth if (++gBoss[0].count1 > 2) { gBoss[0].count1 = 0; @@ -299,7 +299,7 @@ void ActBossChar_Omega() } break; - case 90: //Go back into the ground + case 90: // Go back into the ground SetQuake(2); gBoss[0].y += 0x200; @@ -313,7 +313,7 @@ void ActBossChar_Omega() } break; - case 100: //Move to proper position for coming out of the ground + case 100: // Move to proper position for coming out of the ground if (++gBoss[0].act_wait == 120) { gBoss[0].act_wait = 0; From 1790f7485778d59cc43eb5d214432afd3f806368 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 14:07:07 +0200 Subject: [PATCH 03/18] Removed bad parentheses spacing Basically for all "( expr )" I removed the spaces to be consistent with the rest Also I used this enormous regex here : "((//|\;)[^ \t]|(for|while|if|while|do|void|int|bool)\(|(for|while|if|while|do)\ \(.*\)\;|\(\ |\ \))" 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 bd616612..aba1bbea 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -158,9 +158,9 @@ void MoveCampCursor() { int arms_num = 0; int item_num = 0; - while ( gArmsData[arms_num].code != 0 ) + while (gArmsData[arms_num].code != 0) ++arms_num; - while ( gItemData[item_num].code != 0 ) + while (gItemData[item_num].code != 0) ++item_num; if (arms_num == 0 && item_num == 0) @@ -228,9 +228,9 @@ void MoveCampCursor() bChange = TRUE; } - if ( gKeyTrg & gKeyDown ) + if (gKeyTrg & gKeyDown) { - if ( gSelectedItem / 6 == (item_num - 1) / 6 ) + if (gSelectedItem / 6 == (item_num - 1) / 6) gCampActive = FALSE; else gSelectedItem += 6; @@ -325,7 +325,7 @@ void PutCampObject() PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, gArmsData[i].level, 0); // Draw ammo - if ( gArmsData[i].max_num ) + if (gArmsData[i].max_num) { PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 144) / 2, gArmsData[i].num, 0); PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 128) / 2, gArmsData[i].max_num, 0); From 666269029dbd79b2fdbe46131d853af9b2801cdf Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 7 May 2019 13:18:32 +0100 Subject: [PATCH 04/18] Made Config.cpp ASM-accurate --- msvc2003/devilution/comparer-config.toml | 8 ++++++ src/Config.cpp | 34 +++++++++++++++++------- src/Config.h | 4 ++- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/msvc2003/devilution/comparer-config.toml b/msvc2003/devilution/comparer-config.toml index 9b675d93..922dd4ff 100644 --- a/msvc2003/devilution/comparer-config.toml +++ b/msvc2003/devilution/comparer-config.toml @@ -271,6 +271,14 @@ addr = 0x40ABC0 name = "SetCaret" addr = 0x40AC90 +[[func]] +name = "LoadConfigData" +addr = 0x40AD60 + +[[func]] +name = "DefaultConfigData" +addr = 0x40AE30 + [[func]] name = "Call_Escape" addr = 0x40DD70 diff --git a/src/Config.cpp b/src/Config.cpp index 1b7c7bc4..c9b12710 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -11,21 +11,27 @@ #include "Tags.h" #include "Types.h" -bool LoadConfigData(CONFIG *conf) +static const char* const config_filename = "Config.dat"; // Not the original name +static const char* const config_magic = "DOUKUTSU20041206"; // Not the original name + +BOOL LoadConfigData(CONFIG *conf) { //Clear old config data memset(conf, 0, sizeof(CONFIG)); //Get path char path[PATH_LENGTH]; - sprintf(path, "%s/%s", gModulePath, "Config.dat"); + sprintf(path, "%s/%s", gModulePath, config_filename); //Open file FILE *fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read data +#ifdef NONPORTABLE + size_t fread_result = fread(conf, sizeof(CONFIG), 1, fp); // Not the original name +#else //Read the version id and font name fread(conf->proof, sizeof(conf->proof), 1, fp); fread(conf->font_name, sizeof(conf->font_name), 1, fp); @@ -42,23 +48,33 @@ bool LoadConfigData(CONFIG *conf) conf->bJoystick = File_ReadLE32(fp); for (int button = 0; button < 8; button++) conf->joystick_button[button] = File_ReadLE32(fp); +#endif //Close file fclose(fp); - //Check if version is correct, return that it succeeded - if (!strcmp(conf->proof, "DOUKUTSU20041206")) - return true; + //Check if version is not correct, and return if it failed +#ifdef NONPORTABLE + if (fread_result != 1 || strcmp(conf->proof, config_magic)) +#else + if (strcmp(conf->proof, config_magic)) +#endif + { + memset(conf, 0, sizeof(CONFIG)); + return FALSE; + } - //If not, return that it failed - return false; + return TRUE; } void DefaultConfigData(CONFIG *conf) { - //Claer old config data + //Clear old config data memset(conf, 0, sizeof(CONFIG)); + //Fun fact: The Linux port added this line: + //conf->display_mode = 1; + //Reset joystick settings (as these can't simply be set to 0) conf->bJoystick = 1; conf->joystick_button[0] = 2; diff --git a/src/Config.h b/src/Config.h index f7981004..c61e1947 100644 --- a/src/Config.h +++ b/src/Config.h @@ -2,6 +2,8 @@ #include +#include "WindowsWrapper.h" + struct CONFIG { char proof[0x20]; @@ -14,5 +16,5 @@ struct CONFIG int32_t joystick_button[8]; }; -bool LoadConfigData(CONFIG *conf); +BOOL LoadConfigData(CONFIG *conf); void DefaultConfigData(CONFIG *conf); From c7c40fa24a16685e87da1a278a0f44a5899ffa4f Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 14:31:06 +0200 Subject: [PATCH 05/18] Fixed comments and spacing in boss files Add spaces for comments Remove spaces in "( expr )" things Signed-off-by: Gabriel Ravier --- src/Boss.cpp | 4 ++-- src/BossAlmo1.cpp | 2 +- src/BossBallos.cpp | 2 +- src/BossTwinD.cpp | 2 +- src/BossX.cpp | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Boss.cpp b/src/Boss.cpp index ae6f1c80..3e5d8c66 100644 --- a/src/Boss.cpp +++ b/src/Boss.cpp @@ -97,7 +97,7 @@ void HitBossBullet() if (gBul[bul].damage == -1) continue; - //Check if bullet touches boss + // Check if bullet touches boss bHit = FALSE; if (gBoss[bos].bits & npc_shootable && gBoss[bos].x - gBoss[bos].hit.back < gBul[bul].x + gBul[bul].enemyXL @@ -114,7 +114,7 @@ void HitBossBullet() if (bHit) { - //Damage boss + // Damage boss if (gBoss[bos].bits & npc_shootable) { if (gBoss[bos].cond & 0x10) diff --git a/src/BossAlmo1.cpp b/src/BossAlmo1.cpp index 2654c696..a9af1ffb 100644 --- a/src/BossAlmo1.cpp +++ b/src/BossAlmo1.cpp @@ -459,7 +459,7 @@ void ActBossChar_Core(void) PlaySoundObject(101, 1); } - if ( npc->act_wait > 400 ) + if (npc->act_wait > 400) { npc->act_no = 200; gBoss[4].ani_no = 2; diff --git a/src/BossBallos.cpp b/src/BossBallos.cpp index c533edde..93920519 100644 --- a/src/BossBallos.cpp +++ b/src/BossBallos.cpp @@ -230,7 +230,7 @@ void ActBossChar_Ballos(void) SetQuake2(30); PlaySoundObject(44, 1); - if ( gMC.y > npc->y + 0x6000 && gMC.x < npc->x + 0x3000 && gMC.x > npc->x - 0x3000 ) + if (gMC.y > npc->y + 0x6000 && gMC.x < npc->x + 0x3000 && gMC.x > npc->x - 0x3000) DamageMyChar(16); for (i = 0; i < 0x10; ++i) diff --git a/src/BossTwinD.cpp b/src/BossTwinD.cpp index 86d03874..47b59ab5 100644 --- a/src/BossTwinD.cpp +++ b/src/BossTwinD.cpp @@ -490,7 +490,7 @@ void ActBossChar_Twin(void) } } - if ( npc->count1 > 0x3FF ) + if (npc->count1 > 0x3FF) npc->count1 -= 0x400; break; diff --git a/src/BossX.cpp b/src/BossX.cpp index 92c6e6cf..e17d5667 100644 --- a/src/BossX.cpp +++ b/src/BossX.cpp @@ -55,7 +55,7 @@ static void ActBossChar03_01(NPCHAR *npc) ++npc->ani_no; } - if ( npc->ani_no > 3 ) + if (npc->ani_no > 3) npc->ani_no = 2; npc->xm -= 0x20; @@ -100,7 +100,7 @@ static void ActBossChar03_01(NPCHAR *npc) ++npc->ani_no; } - if ( npc->ani_no > 5 ) + if (npc->ani_no > 5) npc->ani_no = 4; npc->xm += 0x20; From f8d4ae7014f18105de8ebe54667c2c1f15505df5 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 7 May 2019 13:52:50 +0100 Subject: [PATCH 06/18] Made Stage.cpp ASM-accurate --- msvc2003/devilution/comparer-config.toml | 12 +++++ src/NpChar.cpp | 22 ++++----- src/NpChar.h | 6 +-- src/Stage.cpp | 63 +++++++++++------------- src/TextScr.cpp | 20 ++++---- src/TextScr.h | 4 +- 6 files changed, 66 insertions(+), 61 deletions(-) diff --git a/msvc2003/devilution/comparer-config.toml b/msvc2003/devilution/comparer-config.toml index 922dd4ff..a2fda3bd 100644 --- a/msvc2003/devilution/comparer-config.toml +++ b/msvc2003/devilution/comparer-config.toml @@ -614,6 +614,18 @@ addr = 0x41FE70 name = "PlaySoundObject" addr = 0x420640 +[[func]] +name = "TransferStage" +addr = 0x420BE0 + +[[func]] +name = "ChangeMusic" +addr = 0x420EE0 + +[[func]] +name = "ReCallMusic" +addr = 0x420F50 + [[func]] name = "InitStar" addr = 0x420FA0 diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 5473113a..ec80dd17 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -53,14 +53,14 @@ void SetUniqueParameter(NPCHAR *npc) npc->view.bottom = gNpcTable[code].view.bottom << 9; } -bool LoadEvent(const char *path_event) +BOOL LoadEvent(const char *path_event) { char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, path_event); FILE *fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read "PXE" check char code[4]; @@ -71,7 +71,7 @@ bool LoadEvent(const char *path_event) // The original game forgot to close the file here fclose(fp); #endif - return false; + return FALSE; } //Get amount of NPCs @@ -128,7 +128,7 @@ bool LoadEvent(const char *path_event) } fclose(fp); - return true; + return TRUE; } void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index) @@ -235,7 +235,7 @@ void SetExpObjects(int x, int y, int exp) } } -bool SetBulletObject(int x, int y, int val) +BOOL SetBulletObject(int x, int y, int val) { int tamakazu_ari[10]; @@ -254,7 +254,7 @@ bool SetBulletObject(int x, int y, int val) } if (!t) - return false; + return FALSE; n = Random(1, 10 * t); int bullet_no = tamakazu_ari[n % t]; @@ -272,14 +272,14 @@ bool SetBulletObject(int x, int y, int val) gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits; gNPC[n].exp = val; SetUniqueParameter(&gNPC[n]); - return true; + return TRUE; } } - return false; + return FALSE; } -bool SetLifeObject(int x, int y, int val) +BOOL SetLifeObject(int x, int y, int val) { for (int n = 0x100; n < NPC_MAX; n++) { @@ -294,11 +294,11 @@ bool SetLifeObject(int x, int y, int val) gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits; gNPC[n].exp = val; SetUniqueParameter(&gNPC[n]); - return true; + return TRUE; } } - return false; + return FALSE; } void VanishNpChar(NPCHAR *npc) diff --git a/src/NpChar.h b/src/NpChar.h index ac3e0886..79dde896 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -83,13 +83,13 @@ extern int gSuperXpos; extern int gSuperYpos; void InitNpChar(); -bool LoadEvent(const char *path_event); +BOOL LoadEvent(const char *path_event); void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index); void SetDestroyNpChar(int x, int y, int w, int num); void SetDestroyNpCharUp(int x, int y, int w, int num); void SetExpObjects(int x, int y, int exp); -bool SetBulletObject(int x, int y, int val); -bool SetLifeObject(int x, int y, int val); +BOOL SetBulletObject(int x, int y, int val); +BOOL SetLifeObject(int x, int y, int val); void VanishNpChar(NPCHAR *npc); void PutNpChar(int fx, int fy); void ActNpChar(); diff --git a/src/Stage.cpp b/src/Stage.cpp index 9c732c08..54bdbadb 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -132,7 +132,7 @@ const STAGE_TABLE gTMT[95] = { BOOL TransferStage(int no, int w, int x, int y) { //Move character - SetMyCharPosition(x << 13, y << 13); + SetMyCharPosition(x * 0x10 * 0x200, y * 0x10 * 0x200); BOOL bError = FALSE; @@ -166,7 +166,7 @@ BOOL TransferStage(int no, int w, int x, int y) bError = TRUE; //Load background - strcpy(path, gTMT[no].back); + sprintf(path, "%s", gTMT[no].back); if (!InitBack(path, gTMT[no].bkType)) bError = TRUE; @@ -183,28 +183,21 @@ BOOL TransferStage(int no, int w, int x, int y) bError = TRUE; if (bError) - { - printf("Failed to load stage %d\n", no); return FALSE; - } - else - { - //Load map name - ReadyMapName(gTMT[no].name); - StartTextScript(w); - SetFrameMyChar(); - ClearBullet(); - InitCaret(); - ClearValueView(); - ResetQuake(); - InitBossChar(gTMT[no].boss_no); - ResetFlash(); - gStageNo = no; - return TRUE; - } + //Load map name + ReadyMapName(gTMT[no].name); - return FALSE; + StartTextScript(w); + SetFrameMyChar(); + ClearBullet(); + InitCaret(); + ClearValueView(); + ResetQuake(); + InitBossChar(gTMT[no].boss_no); + ResetFlash(); + gStageNo = no; + return TRUE; } //Music @@ -264,22 +257,22 @@ int gMusicNo; void ChangeMusic(int no) { - if (!no || no != gMusicNo) - { - //Stop and keep track of old song - gOldPos = GetOrganyaPosition(); - gOldNo = gMusicNo; - StopOrganyaMusic(); + if (no && no == gMusicNo) + return; - //Load .org - LoadOrganya(gMusicTable[no]); + //Stop and keep track of old song + gOldPos = GetOrganyaPosition(); + gOldNo = gMusicNo; + StopOrganyaMusic(); - //Reset position, volume, and then play the song - ChangeOrganyaVolume(100); - SetOrganyaPosition(0); - PlayOrganyaMusic(); - gMusicNo = no; - } + //Load .org + LoadOrganya(gMusicTable[no]); + + //Reset position, volume, and then play the song + ChangeOrganyaVolume(100); + SetOrganyaPosition(0); + PlayOrganyaMusic(); + gMusicNo = no; } void ReCallMusic() diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 8d90f8bf..0b6ae794 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -112,7 +112,7 @@ void EncryptionBinaryData2(uint8_t *pData, int size) } //Load generic .tsc -bool LoadTextScript2(const char *name) +BOOL LoadTextScript2(const char *name) { //Get path char path[260]; @@ -120,12 +120,12 @@ bool LoadTextScript2(const char *name) gTS.size = GetFileSizeLong(path); if (gTS.size == -1) - return false; + return FALSE; //Open file FILE *fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read data fread(gTS.data, 1, gTS.size, fp); @@ -137,11 +137,11 @@ bool LoadTextScript2(const char *name) //Decrypt data EncryptionBinaryData2((uint8_t*)gTS.data, gTS.size); - return true; + return TRUE; } //Load stage .tsc -bool LoadTextScript_Stage(const char *name) +BOOL LoadTextScript_Stage(const char *name) { //Open Head.tsc char path[PATH_LENGTH]; @@ -149,11 +149,11 @@ bool LoadTextScript_Stage(const char *name) long head_size = GetFileSizeLong(path); if (head_size == -1) - return false; + return FALSE; FILE *fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read Head.tsc fread(gTS.data, 1, head_size, fp); @@ -166,11 +166,11 @@ bool LoadTextScript_Stage(const char *name) long body_size = GetFileSizeLong(path); if (body_size == -1) - return false; + return FALSE; fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read stage's tsc fread(&gTS.data[head_size], 1, body_size, fp); @@ -181,7 +181,7 @@ bool LoadTextScript_Stage(const char *name) //Set parameters gTS.size = head_size + body_size; strcpy(gTS.path, name); - return true; + return TRUE; } //Get current path diff --git a/src/TextScr.h b/src/TextScr.h index 90008c0e..0e7d11e3 100644 --- a/src/TextScr.h +++ b/src/TextScr.h @@ -60,8 +60,8 @@ struct TEXT_SCRIPT BOOL InitTextScript2(); void EndTextScript(); void EncryptionBinaryData2(uint8_t *pData, int size); -bool LoadTextScript2(const char *name); -bool LoadTextScript_Stage(const char *name); +BOOL LoadTextScript2(const char *name); +BOOL LoadTextScript_Stage(const char *name); void GetTextScriptPath(char *path); BOOL StartTextScript(int no); void StopTextScript(); From b0ebfd3aa38260bf1e947c6d73c23d21b2a5ad22 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 15:04:45 +0200 Subject: [PATCH 07/18] Fix RECT declaration indentation Signed-off-by: Gabriel Ravier --- src/BossAlmo1.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BossAlmo1.cpp b/src/BossAlmo1.cpp index a9af1ffb..bdd88eb6 100644 --- a/src/BossAlmo1.cpp +++ b/src/BossAlmo1.cpp @@ -13,7 +13,8 @@ static void ActBossChar_Core_Face(NPCHAR *npc) { - RECT rect[4] = { + RECT rect[4] = + { {0, 0, 72, 112}, {0, 112, 72, 224}, {160, 0, 232, 112}, @@ -62,7 +63,8 @@ static void ActBossChar_Core_Face(NPCHAR *npc) static void ActBossChar_Core_Tail(NPCHAR *npc) { - RECT rect[3] = { + RECT rect[3] = + { {72, 0, 160, 112}, {72, 112, 160, 224}, {0, 0, 0, 0}, @@ -114,7 +116,8 @@ static void ActBossChar_Core_Mini(NPCHAR *npc) int ym; int xm; - RECT rect[3] = { + RECT rect[3] = + { {256, 0, 320, 40}, {256, 40, 320, 80}, {256, 80, 320, 120}, From 8c9aac9594b23080fa8647ea30dd05a02f3f6bfa Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 15:11:07 +0200 Subject: [PATCH 08/18] Fixed declaration formatting Signed-off-by: Gabriel Ravier --- src/BossAlmo2.cpp | 12 ++++++++---- src/BossBallos.cpp | 9 ++++++--- src/BossFrog.cpp | 6 ++++-- src/BossIronH.cpp | 6 ++++-- src/BossOhm.cpp | 9 ++++++--- src/BossPress.cpp | 6 ++++-- src/BossTwinD.cpp | 12 ++++++++---- src/BossX.cpp | 15 ++++++++++----- 8 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/BossAlmo2.cpp b/src/BossAlmo2.cpp index 67c1b020..cded7e21 100644 --- a/src/BossAlmo2.cpp +++ b/src/BossAlmo2.cpp @@ -14,7 +14,8 @@ static void ActBossCharA_Head(NPCHAR *npc) { - RECT rect[4] = { + RECT rect[4] = + { {0, 0, 72, 112}, {0, 112, 72, 224}, {160, 0, 232, 112}, @@ -61,7 +62,8 @@ static void ActBossCharA_Head(NPCHAR *npc) static void ActBossCharA_Tail(NPCHAR *npc) { - RECT rect[3] = { + RECT rect[3] = + { {72, 0, 160, 112}, {72, 112, 160, 224}, {0, 0, 0, 0}, @@ -107,7 +109,8 @@ static void ActBossCharA_Tail(NPCHAR *npc) static void ActBossCharA_Face(NPCHAR *npc) { - RECT rect[5] = { + RECT rect[5] = + { {0, 0, 0, 0}, {160, 112, 232, 152}, {160, 152, 232, 192}, @@ -174,7 +177,8 @@ static void ActBossCharA_Mini(NPCHAR *npc) { int deg; - RECT rect[3] = { + RECT rect[3] = + { {256, 0, 320, 40}, {256, 40, 320, 80}, {256, 80, 320, 120}, diff --git a/src/BossBallos.cpp b/src/BossBallos.cpp index 93920519..c594ebe0 100644 --- a/src/BossBallos.cpp +++ b/src/BossBallos.cpp @@ -13,7 +13,8 @@ static void ActBossChar_Eye(NPCHAR *npc) { - RECT rcLeft[5] = { + RECT rcLeft[5] = + { {272, 0, 296, 16}, {272, 16, 296, 32}, {272, 32, 296, 48}, @@ -21,7 +22,8 @@ static void ActBossChar_Eye(NPCHAR *npc) {240, 16, 264, 32}, }; - RECT rcRight[5] = { + RECT rcRight[5] = + { {296, 0, 320, 16}, {296, 16, 320, 32}, {296, 32, 320, 48}, @@ -104,7 +106,8 @@ static void ActBossChar_Eye(NPCHAR *npc) static void ActBossChar_Body(NPCHAR *npc) { - RECT rc[4] = { + RECT rc[4] = + { {0, 0, 120, 120}, {120, 0, 240, 120}, {0, 120, 120, 240}, diff --git a/src/BossFrog.cpp b/src/BossFrog.cpp index bc665689..ca5b733b 100644 --- a/src/BossFrog.cpp +++ b/src/BossFrog.cpp @@ -91,7 +91,8 @@ void ActBossChar_Frog(void) int ym; int xm; - RECT rcLeft[9] = { + RECT rcLeft[9] = + { {0, 0, 0, 0}, {0, 48, 80, 112}, {0, 112, 80, 176}, @@ -103,7 +104,8 @@ void ActBossChar_Frog(void) {120, 0, 160, 24}, }; - RECT rcRight[9] = { + RECT rcRight[9] = + { {0, 0, 0, 0}, {80, 48, 160, 112}, {80, 112, 160, 176}, diff --git a/src/BossIronH.cpp b/src/BossIronH.cpp index c76ec3c0..580a6292 100644 --- a/src/BossIronH.cpp +++ b/src/BossIronH.cpp @@ -174,7 +174,8 @@ void ActBossChar_Ironhead(void) break; } - RECT rc[9] = { + RECT rc[9] = + { {0, 0, 64, 24}, {64, 0, 128, 24}, {128, 0, 192, 24}, @@ -186,7 +187,8 @@ void ActBossChar_Ironhead(void) {256, 48, 320, 72}, }; - RECT rcDamage[9] = { + RECT rcDamage[9] = + { {0, 24, 64, 48}, {64, 24, 128, 48}, {128, 24, 192, 48}, diff --git a/src/BossOhm.cpp b/src/BossOhm.cpp index 2df6aedd..b14ffcd9 100644 --- a/src/BossOhm.cpp +++ b/src/BossOhm.cpp @@ -41,12 +41,14 @@ static void ActBoss01_34() { int i; - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {0, 56, 40, 88}, {40, 56, 80, 88}, }; - RECT rcRight[2] = { + RECT rcRight[2] = + { {0, 88, 40, 120}, {40, 88, 80, 120}, }; @@ -454,7 +456,8 @@ void ActBossChar_Omega() break; } - RECT rect[4] = { + RECT rect[4] = + { {0, 0, 80, 56}, {80, 0, 160, 56}, {160, 0, 240, 56}, diff --git a/src/BossPress.cpp b/src/BossPress.cpp index 5412b46e..59fdcc0a 100644 --- a/src/BossPress.cpp +++ b/src/BossPress.cpp @@ -206,13 +206,15 @@ void ActBossChar_Press(void) gBoss[3].x = npc->x; gBoss[3].y = npc->y + 0x5000; - RECT rc[3] = { + RECT rc[3] = + { {0, 0, 80, 120}, {80, 0, 160, 120}, {160, 0, 240, 120}, }; - RECT rcDamage[3] = { + RECT rcDamage[3] = + { {0, 120, 80, 240}, {80, 120, 160, 240}, {160, 120, 240, 240}, diff --git a/src/BossTwinD.cpp b/src/BossTwinD.cpp index 47b59ab5..f4fb043d 100644 --- a/src/BossTwinD.cpp +++ b/src/BossTwinD.cpp @@ -14,13 +14,15 @@ static void ActBossCharT_DragonBody(NPCHAR *npc) { unsigned char deg; - RECT rcLeft[3] = { + RECT rcLeft[3] = + { {0, 0, 40, 40}, {40, 0, 80, 40}, {80, 0, 120, 40}, }; - RECT rcRight[3] = { + RECT rcRight[3] = + { {0, 40, 40, 80}, {40, 40, 80, 80}, {80, 40, 120, 80}, @@ -96,14 +98,16 @@ static void ActBossCharT_DragonHead(NPCHAR *npc) int ym; int xm; - RECT rcLeft[4] = { + RECT rcLeft[4] = + { {0, 80, 40, 112}, {40, 80, 80, 112}, {80, 80, 120, 112}, {120, 80, 160, 112}, }; - RECT rcRight[4] = { + RECT rcRight[4] = + { {0, 112, 40, 144}, {40, 112, 80, 144}, {80, 112, 120, 144}, diff --git a/src/BossX.cpp b/src/BossX.cpp index e17d5667..d4edb544 100644 --- a/src/BossX.cpp +++ b/src/BossX.cpp @@ -13,7 +13,8 @@ static void ActBossChar03_01(NPCHAR *npc) { - RECT rcUp[6] = { + RECT rcUp[6] = + { {0, 0, 72, 32}, {0, 32, 72, 64}, {72, 0, 144, 32}, @@ -22,7 +23,8 @@ static void ActBossChar03_01(NPCHAR *npc) {144, 32, 216, 64}, }; - RECT rcDown[6] = { + RECT rcDown[6] = + { {0, 64, 72, 96}, {0, 96, 72, 128}, {72, 64, 144, 96}, @@ -214,7 +216,8 @@ static void ActBossChar03_02(NPCHAR *npc) { int direct; - RECT rect[4] = { + RECT rect[4] = + { {0, 128, 72, 160}, {72, 128, 144, 160}, {0, 160, 72, 192}, @@ -366,7 +369,8 @@ static void ActBossChar03_04(NPCHAR *npc) int ym; int xm; - RECT rect[8] = { + RECT rect[8] = + { {0, 192, 16, 208}, {16, 192, 32, 208}, {32, 192, 48, 208}, @@ -440,7 +444,8 @@ static void ActBossChar03_face(NPCHAR *npc) { static unsigned char flash; - RECT rect[3] = { + RECT rect[3] = + { {216, 0, 320, 48}, {216, 48, 320, 96}, {216, 144, 320, 192}, From 7102e02fe207ef703311449dfb5ed33e76b97708 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 15:38:21 +0200 Subject: [PATCH 09/18] Redid formatting for files starting with [C-E] Also fixed potentially erroneous macro MAX_STRIP (would have problems with operation order in operations) Signed-off-by: Gabriel Ravier --- src/Caret.cpp | 60 ++++++++++++------- src/CommonDefines.h | 2 +- src/Draw.cpp | 63 ++++++++++---------- src/Ending.cpp | 140 ++++++++++++++++++++++---------------------- src/Ending.h | 2 +- src/Escape.cpp | 12 ++-- 6 files changed, 149 insertions(+), 130 deletions(-) diff --git a/src/Caret.cpp b/src/Caret.cpp index ee9d99e4..b1b4a290 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -23,14 +23,16 @@ void ActCaret00(CARET *crt) void ActCaret01(CARET *crt) { - RECT rcLeft[4] = { + RECT rcLeft[4] = + { {0, 64, 8, 72}, {8, 64, 16, 72}, {16, 64, 24, 72}, {24, 64, 32, 72}, }; - RECT rcRight[4] = { + RECT rcRight[4] = + { {64, 24, 72, 32}, {72, 24, 80, 32}, {80, 24, 88, 32}, @@ -63,21 +65,24 @@ void ActCaret01(CARET *crt) void ActCaret02(CARET *crt) { - RECT rect_left[4] = { + RECT rect_left[4] = + { {0, 32, 16, 48}, {16, 32, 32, 48}, {32, 32, 48, 48}, {48, 32, 64, 48}, }; - RECT rect_right[4] = { + RECT rect_right[4] = + { {176, 0, 192, 16}, {192, 0, 208, 16}, {208, 0, 224, 16}, {224, 0, 240, 16}, }; - RECT rect_up[3] = { + RECT rect_up[3] = + { {0, 32, 16, 48}, {32, 32, 48, 48}, {16, 32, 32, 48}, @@ -126,7 +131,8 @@ void ActCaret02(CARET *crt) void ActCaret03(CARET *crt) { - RECT rect[4] = { + RECT rect[4] = + { {0, 48, 16, 64}, {16, 48, 32, 64}, {32, 48, 48, 64}, @@ -145,7 +151,8 @@ void ActCaret03(CARET *crt) void ActCaret04(CARET *crt) { - RECT rect[9] = { + RECT rect[9] = + { {64, 32, 80, 48}, {80, 32, 96, 48}, {96, 32, 112, 48}, @@ -170,7 +177,8 @@ void ActCaret04(CARET *crt) void ActCaret05(CARET *crt) { - RECT rect[7] = { + RECT rect[7] = + { {32, 64, 40, 72}, {32, 72, 40, 80}, {40, 64, 48, 72}, @@ -186,7 +194,7 @@ void ActCaret05(CARET *crt) ++crt->ani_no; } - if ( crt->ani_no > 6 ) + if (crt->ani_no > 6) crt->cond = 0; crt->x += 0x80; @@ -197,7 +205,8 @@ void ActCaret05(CARET *crt) void ActCaret07(CARET *crt) { - RECT rcLeft[7] = { + RECT rcLeft[7] = + { {56, 0, 64, 8}, {64, 0, 72, 8}, {72, 0, 80, 8}, @@ -264,12 +273,14 @@ void ActCaret09(CARET *crt) void ActCaret10(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {0, 0, 56, 16}, {0, 16, 56, 32}, }; - RECT rcRight[2] = { + RECT rcRight[2] = + { {0, 96, 56, 112}, {0, 112, 56, 128}, }; @@ -314,7 +325,8 @@ void ActCaret11(CARET *crt) crt->x += crt->xm; crt->y += crt->ym; - RECT rcRight[7] = { + RECT rcRight[7] = + { {56, 8, 64, 16}, {64, 8, 72, 16}, {72, 8, 80, 16}, @@ -336,7 +348,8 @@ void ActCaret11(CARET *crt) void ActCaret12(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {112, 0, 144, 32}, {144, 0, 176, 32}, }; @@ -345,7 +358,7 @@ void ActCaret12(CARET *crt) { crt->ani_wait = 0; if (++crt->ani_no > 1) - crt->cond = 0; + crt->cond = 0; } crt->rect = rcLeft[crt->ani_no]; @@ -353,7 +366,8 @@ void ActCaret12(CARET *crt) void ActCaret13(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {56, 24, 64, 32}, {0, 0, 0, 0}, }; @@ -397,7 +411,8 @@ void ActCaret13(CARET *crt) void ActCaret14(CARET *crt) { - RECT rect[5] = { + RECT rect[5] = + { {0, 96, 40, 136}, {40, 96, 80, 136}, {80, 96, 120, 136}, @@ -418,7 +433,8 @@ void ActCaret14(CARET *crt) void ActCaret15(CARET *crt) { - RECT rcLeft[4] = { + RECT rcLeft[4] = + { {0, 72, 8, 80}, {8, 72, 16, 80}, {16, 72, 24, 80}, @@ -438,7 +454,8 @@ void ActCaret15(CARET *crt) void ActCaret16(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {104, 96, 144, 104}, {104, 104, 144, 112}, }; @@ -454,7 +471,8 @@ void ActCaret16(CARET *crt) void ActCaret17(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {0, 144, 144, 152}, {0, 0, 0, 0}, }; @@ -468,7 +486,7 @@ void ActCaret17(CARET *crt) crt->rect = rcLeft[1]; } -//Tables +// Tables CARET_TABLE gCaretTable[18] = { {0, 0}, diff --git a/src/CommonDefines.h b/src/CommonDefines.h index 9e4b95b3..e280beb3 100644 --- a/src/CommonDefines.h +++ b/src/CommonDefines.h @@ -1,6 +1,6 @@ #pragma once -#define PATH_LENGTH 260 //Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash. +#define PATH_LENGTH 260 // Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash. #define WINDOW_WIDTH 320 #define WINDOW_HEIGHT 240 diff --git a/src/Draw.cpp b/src/Draw.cpp index c1db3ff6..00c95ecc 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -56,7 +56,7 @@ BOOL Flip_SystemTask() if (!SystemTask()) return FALSE; - //Framerate limiter + // Framerate limiter static uint32_t timePrev; const uint32_t timeNow = SDL_GetTicks(); @@ -81,15 +81,15 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth) { (void)lColourDepth; - //Initialize rendering + // Initialize rendering SDL_InitSubSystem(SDL_INIT_VIDEO); - //Create renderer + // Create renderer gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED); if (gRenderer != NULL) { - //Print the name of the renderer SDL2 is using + // Print the name of the renderer SDL2 is using SDL_RendererInfo info; SDL_GetRendererInfo(gRenderer, &info); printf("Renderer: %s\n", info.name); @@ -120,10 +120,10 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth) void EndDirectDraw() { - //Quit sub-system + // Quit sub-system SDL_QuitSubSystem(SDL_INIT_VIDEO); - //Release all surfaces + // Release all surfaces for (int i = 0; i < SURFACE_ID_MAX; i++) ReleaseSurface(i); } @@ -143,7 +143,7 @@ static bool IsEnableBitmap(SDL_RWops *fp) void ReleaseSurface(int s) { - //Release the surface we want to release + // Release the surface we want to release if (surf[s].in_use) { SDL_DestroyTexture(surf[s].texture); @@ -172,7 +172,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no) } else { - //Create surface + // Create surface surf[surf_no].surface = SDL_CreateRGBSurfaceWithFormat(0, bxsize * magnification, bysize * magnification, 0, SDL_PIXELFORMAT_RGB24); SDL_SetSurfaceBlendMode(surf[surf_no].surface, SDL_BLENDMODE_NONE); @@ -320,7 +320,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s char path[PATH_LENGTH]; SDL_RWops *fp; - //Attempt to load PBM + // Attempt to load PBM sprintf(path, "%s/%s.pbm", gDataPath, name); fp = SDL_RWFromFile(path, "rb"); if (fp) @@ -338,7 +338,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s } } - //Attempt to load BMP + // Attempt to load BMP sprintf(path, "%s/%s.bmp", gDataPath, name); fp = SDL_RWFromFile(path, "rb"); if (fp) @@ -412,22 +412,22 @@ static SDL_Rect RectToSDLRectScaled(RECT *rect) void BackupSurface(Surface_Ids surf_no, RECT *rect) { - //Get renderer size + // Get renderer size int w, h; SDL_GetRendererOutputSize(gRenderer, &w, &h); - //Get texture of what's currently rendered on screen + // Get texture of what's currently rendered on screen SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, SDL_PIXELFORMAT_RGB24); SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); SDL_RenderReadPixels(gRenderer, NULL, SDL_PIXELFORMAT_RGB24, surface->pixels, surface->pitch); - //Get rects + // Get rects SDL_Rect frameRect = RectToSDLRectScaled(rect); SDL_BlitSurface(surface, &frameRect, surf[surf_no].surface, &frameRect); surf[surf_no].needs_updating = true; - //Free surface + // Free surface SDL_FreeSurface(surface); } @@ -439,40 +439,39 @@ static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_ surf[surf_no].needs_updating = false; } - //Get SDL_Rects + // Get SDL_Rects SDL_Rect clipRect = RectToSDLRectScaled(rcView); - SDL_Rect frameRect = RectToSDLRectScaled(rect); - //Get dest rect + // Get dest rect SDL_Rect destRect = {x * magnification, y * magnification, frameRect.w, frameRect.h}; - //Set cliprect + // Set cliprect SDL_RenderSetClipRect(gRenderer, &clipRect); SDL_SetTextureBlendMode(surf[surf_no].texture, transparent ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE); - //Draw to screen + // Draw to screen if (SDL_RenderCopy(gRenderer, surf[surf_no].texture, &frameRect, &destRect) < 0) printf("Failed to draw texture %d\nSDL Error: %s\n", surf_no, SDL_GetError()); - //Undo cliprect + // Undo cliprect SDL_RenderSetClipRect(gRenderer, NULL); } -void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) //Transparency +void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // Transparency { DrawBitmap(rcView, x, y, rect, surf_no, true); } -void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) //No Transparency +void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // No Transparency { DrawBitmap(rcView, x, y, rect, surf_no, false); } void Surface2Surface(int x, int y, RECT *rect, int to, int from) { - //Get rects + // Get rects SDL_Rect rcSet = {x * magnification, y * magnification, (rect->right - rect->left) * magnification, (rect->bottom - rect->top) * magnification}; SDL_Rect frameRect = RectToSDLRectScaled(rect); @@ -488,10 +487,10 @@ unsigned long GetCortBoxColor(unsigned long col) void CortBox(RECT *rect, uint32_t col) { - //Get rect + // Get rect SDL_Rect destRect = RectToSDLRectScaled(rect); - //Set colour and draw + // Set colour and draw const unsigned char col_red = col & 0x0000FF; const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_blue = (col & 0xFF0000) >> 16; @@ -501,10 +500,10 @@ void CortBox(RECT *rect, uint32_t col) void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no) { - //Get rect + // Get rect SDL_Rect destRect = RectToSDLRectScaled(rect); - //Set colour and draw + // Set colour and draw const unsigned char col_red = col & 0x0000FF; const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_blue = (col & 0xFF0000) >> 16; @@ -558,7 +557,7 @@ static unsigned char* GetFontFromWindows(size_t *data_size, const char *font_nam void InitTextObject(const char *font_name) { - //Get font size + // Get font size unsigned int fontWidth, fontHeight; // The original did this, but Windows would downscale it to 5/10 anyway. @@ -569,8 +568,10 @@ void InitTextObject(const char *font_name) } else {*/ - fontWidth = 5 * magnification; - fontHeight = 10 * magnification; + + fontWidth = 5 * magnification; + fontHeight = 10 * magnification; + // } size_t data_size; @@ -632,7 +633,7 @@ void PutText2(int x, int y, const char *text, uint32_t color, Surface_Ids surf_n void EndTextObject() { - //Destroy font + // Destroy font UnloadFont(gFont); gFont = NULL; } diff --git a/src/Ending.cpp b/src/Ending.cpp index d8194a8a..df7751be 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -23,32 +23,32 @@ CREDIT Credit; STRIP Strip[MAX_STRIP]; ILLUSTRATION Illust; -//Update casts +// Update casts void ActionStripper() { for (int s = 0; s < MAX_STRIP; s++) { - //Move up + // Move up if (Strip[s].flag & 0x80 && Credit.mode) Strip[s].y -= 0x100; - //Get removed when off-screen + // Get removed when off-screen if (Strip[s].y <= -0x2000) Strip[s].flag = 0; } } -//Draw casts +// Draw casts void PutStripper() { for (int s = 0; s < MAX_STRIP; s++) { if (Strip[s].flag & 0x80) { - //Draw text + // Draw text RECT rc = {0, 16 * s, 320, 16 * s + 16}; PutBitmap3(&grcFull, (Strip[s].x + ((WINDOW_WIDTH - 320) << 8)) / 0x200, Strip[s].y / 0x200, &rc, SURFACE_ID_CREDIT_CAST); - //Draw character + // Draw character rc.left = 24 * (Strip[s].cast % 13); rc.right = rc.left + 24; rc.top = 24 * (Strip[s].cast / 13); @@ -58,21 +58,21 @@ void PutStripper() } } -//Create a cast object +// Create a cast object void SetStripper(int x, int y, const char *text, int cast) { for (int s = 0; s < MAX_STRIP; s++) { if (!(Strip[s].flag & 0x80)) { - //Initialize cast property + // Initialize cast property Strip[s].flag = 0x80; Strip[s].x = x; Strip[s].y = y; Strip[s].cast = cast; strcpy(Strip[s].str, text); - //Draw text + // Draw text RECT rc = {0, 16 * s, 320, 16 * s + 16}; CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST); PutText2(0, 16 * s, text, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST); @@ -81,7 +81,7 @@ void SetStripper(int x, int y, const char *text, int cast) } } -//Regenerate cast text +// Regenerate cast text void RestoreStripper() { for (int s = 0; s < MAX_STRIP; s++) @@ -95,22 +95,22 @@ void RestoreStripper() } } -//Handle the illustration +// Handle the illustration void ActionIllust() { switch (Illust.act_no) { - case 0: //Off-screen to the left + case 0: // Off-screen to the left Illust.x = -0x14000; break; - case 1: //Move in from the left + case 1: // Move in from the left Illust.x += 0x5000; if (Illust.x > 0) Illust.x = 0; break; - case 2: //Move out from the right + case 2: // Move out from the right Illust.x -= 0x5000; if (Illust.x < -0x14000) Illust.x = -0x14000; @@ -118,7 +118,7 @@ void ActionIllust() } } -//Draw illustration +// Draw illustration void PutIllust() { RECT rcIllust = {0, 0, 160, 240}; @@ -126,7 +126,7 @@ void PutIllust() PutBitmap3(&rcClip, (Illust.x + ((WINDOW_WIDTH - 320) << 8)) / 0x200, (WINDOW_HEIGHT - 240) / 2, &rcIllust, SURFACE_ID_CREDITS_IMAGE); } -//Load illustration +// Load illustration void ReloadIllust(int a) { char name[16]; @@ -134,10 +134,10 @@ void ReloadIllust(int a) ReloadBitmap_Resource(name, SURFACE_ID_CREDITS_IMAGE); } -//Initialize and release credits +// Initialize and release credits void InitCreditScript() { - //Clear script state and casts + // Clear script state and casts memset(&Credit, 0, sizeof(CREDIT)); memset(Strip, 0, sizeof(Strip)); } @@ -146,23 +146,23 @@ void ReleaseCreditScript() { if (Credit.pData) { - //Free script data + // Free script data free(Credit.pData); Credit.pData = NULL; } } -//Start playing credits +// Start playing credits bool StartCreditScript() { - //Clear previously existing credits data + // Clear previously existing credits data if (Credit.pData) { free(Credit.pData); Credit.pData = NULL; } - //Open file + // Open file char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, "Credit.tsc"); @@ -170,7 +170,7 @@ bool StartCreditScript() if (Credit.size == -1) return false; - //Allcoate buffer data + // Allocate buffer data Credit.pData = (char*)malloc(Credit.size); if (Credit.pData == NULL) return false; @@ -182,7 +182,7 @@ bool StartCreditScript() return false; } - //Read data + // Read data fread(Credit.pData, 1, Credit.size, fp); EncryptionBinaryData2((uint8_t*)Credit.pData, Credit.size); @@ -191,30 +191,30 @@ bool StartCreditScript() fclose(fp); #endif - //Reset credits + // Reset credits Credit.offset = 0; Credit.wait = 0; Credit.mode = 1; Illust.x = -0x14000; Illust.act_no = 0; - //Modify cliprect + // Modify cliprect grcGame.left = WINDOW_WIDTH / 2; // These three are non-vanilla: for wide/tallscreen support grcGame.right = ((WINDOW_WIDTH - 320) / 2) + 320; grcGame.top = (WINDOW_HEIGHT - 240) / 2; grcGame.bottom = ((WINDOW_HEIGHT - 240) / 2) + 240; - //Reload casts + // Reload casts if (!ReloadBitmap_File("casts", SURFACE_ID_CASTS)) return false; - //Clear casts + // Clear casts memset(Strip, 0, sizeof(Strip)); return true; } -//Get number from text (4 digit) +// Get number from text (4 digit) int GetScriptNumber(const char *text) { return 1000 * text[0] - 48000 + @@ -223,19 +223,19 @@ int GetScriptNumber(const char *text) text[3] - 48; } -//Parse credits +// Parse credits void ActionCredit_Read() { while (Credit.offset < Credit.size) { - //Get character + // Get character uint8_t character = Credit.pData[Credit.offset]; int a, b, len; switch (character) { - case '[': //Create cast - //Get the range for the cast text + case '[': // Create cast + // Get the range for the cast text a = ++Credit.offset; while (Credit.pData[a] != ']') @@ -248,35 +248,35 @@ void ActionCredit_Read() len = a - Credit.offset; - //Copy the text to the cast text + // Copy the text to the cast text char text[40]; memcpy(text, &Credit.pData[Credit.offset], a - Credit.offset); text[len] = 0; - //Get cast id + // Get cast id Credit.offset = a + 1; len = GetScriptNumber(&Credit.pData[a + 1]); - //Create cast object + // Create cast object SetStripper(Credit.start_x, (WINDOW_HEIGHT << 9) + 0x1000, text, len); - //Change offset + // Change offset Credit.offset += 4; return; - case 'j': //Jump to label - //Get number + case 'j': // Jump to label + // Get number b = GetScriptNumber(&Credit.pData[++Credit.offset]); - //Change offset + // Change offset Credit.offset += 4; - //Jump to specific label + // Jump to specific label while (Credit.offset < Credit.size) { if (Credit.pData[Credit.offset] == 'l') { - //what is this + // What is this a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; if (b == a) @@ -294,29 +294,29 @@ void ActionCredit_Read() return; - case '~': //Start fading out music + case '~': // Start fading out music ++Credit.offset; SetOrganyaFadeout(); return; - case 'f': //Flag jump - //Read numbers XXXX:YYYY + case 'f': // Flag jump + // Read numbers XXXX:YYYY a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 5; b = GetScriptNumber(&Credit.pData[Credit.offset]); Credit.offset += 4; - //If flag is set + // If flag is set if (GetNPCFlag(a)) { - //Jump to label - while ( Credit.offset < Credit.size ) + // Jump to label + while (Credit.offset < Credit.size) { if (Credit.pData[Credit.offset] == 'l') { a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; - if ( b == a ) + if (b == a) return; } else if (IsShiftJIS(Credit.pData[Credit.offset])) @@ -331,39 +331,39 @@ void ActionCredit_Read() } return; - case '+': //Change casts x-position + case '+': // Change casts x-position Credit.start_x = GetScriptNumber(&Credit.pData[++Credit.offset]) << 9; Credit.offset += 4; return; - case '-': //Wait for X amount of frames + case '-': // Wait for X amount of frames Credit.wait = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; Credit.mode = 2; return; - case '/': //Stop credits + case '/': // Stop credits Credit.mode = 0; return; - case '!': //Change music + case '!': // Change music a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; ChangeMusic(a); return; } - //Progress through file + // Progress through file ++Credit.offset; } } -//Update credits +// Update credits void ActionCredit() { if (Credit.offset < Credit.size) { - //Update script, or if waiting, decrement the wait value + // Update script, or if waiting, decrement the wait value if (Credit.mode == 1) { ActionCredit_Read(); @@ -375,28 +375,28 @@ void ActionCredit() } } -//Change illustration +// Change illustration void SetCreditIllust(int a) { ReloadIllust(a); Illust.act_no = 1; } -//Slide illustration off-screen +// Slide illustration off-screen void CutCreditIllust() { Illust.act_no = 2; } -//Scene of the island falling +// Scene of the island falling int Scene_DownIsland(int mode) { - //Setup background + // Setup background RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2}; RECT rc_sky = {0, 0, 160, 80}; RECT rc_ground = {160, 48, 320, 80}; - //Setup island + // Setup island RECT rc_sprite = {160, 0, 200, 24}; ISLAND_SPRITE sprite; @@ -405,10 +405,10 @@ int Scene_DownIsland(int mode) for (int wait = 0; wait < 900; wait++) { - //Get pressed keys + // Get pressed keys GetTrg(); - //Escape menu + // Escape menu if (gKey & 0x8000) { int escRet = Call_Escape(); @@ -421,7 +421,7 @@ int Scene_DownIsland(int mode) switch (mode) { case 0: - //Move down + // Move down sprite.y += 0x33; break; @@ -432,38 +432,38 @@ int Scene_DownIsland(int mode) { if (wait >= 600) { - //End scene + // End scene if (wait == 750) wait = 900; } else { - //Move down slow + // Move down slow sprite.y += 0xC; } } else { - //Move down slower + // Move down slower sprite.y += 0x19; } } else { - //Move down at normal speed + // Move down at normal speed sprite.y += 0x33; } break; } - //Draw scene + // Draw scene CortBox(&grcFull, 0); PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1); PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1); PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1); PutTimeCounter(16, 8); - //Draw window + // Draw window PutFramePerSecound(); if (!Flip_SystemTask()) return 0; diff --git a/src/Ending.h b/src/Ending.h index b5a4d693..a490e027 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -33,7 +33,7 @@ struct ISLAND_SPRITE int y; }; -#define MAX_STRIP (WINDOW_HEIGHT / 16) + 1 +#define MAX_STRIP ((WINDOW_HEIGHT / 16) + 1) void ActionStripper(); void PutStripper(); diff --git a/src/Escape.cpp b/src/Escape.cpp index 0266af8a..99a8bdd4 100644 --- a/src/Escape.cpp +++ b/src/Escape.cpp @@ -13,33 +13,33 @@ int Call_Escape() while (1) { - //Get pressed keys + // Get pressed keys GetTrg(); - if (gKeyTrg & KEY_ESCAPE) //Escape is pressed, quit game + if (gKeyTrg & KEY_ESCAPE) // Escape is pressed, quit game { gKeyTrg = 0; return 0; } - if (gKeyTrg & KEY_F1) //F1 is pressed, continue + if (gKeyTrg & KEY_F1) // F1 is pressed, continue { gKeyTrg = 0; return 1; } - if (gKeyTrg & KEY_F2) //F2 is pressed, reset + if (gKeyTrg & KEY_F2) // F2 is pressed, reset { gKeyTrg = 0; return 2; } - //Draw screen + // Draw screen CortBox(&grcFull, 0x000000); PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, SURFACE_ID_TEXT_BOX); PutFramePerSecound(); if (!Flip_SystemTask()) { - //Quit if window is closed + // Quit if window is closed gKeyTrg = 0; return 0; } From e8875bd051ca293df80b1f945a07d80ba1bdb7f5 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 15:38:21 +0200 Subject: [PATCH 10/18] Redid formatting for files starting with [C-E] Also fixed potentially erroneous macro MAX_STRIP (would have problems with operation order in operations) Btw used regex "((//|\;)[^ \t]|(for|while|if|while|do|void|int|bool)\(|(for|while|if|while|do)\ \(.*\)\;|\(\ |\ \)|//\ [a-z])" for this Signed-off-by: Gabriel Ravier --- src/Caret.cpp | 60 ++++++++++++------- src/CommonDefines.h | 2 +- src/Draw.cpp | 63 ++++++++++---------- src/Ending.cpp | 140 ++++++++++++++++++++++---------------------- src/Ending.h | 2 +- src/Escape.cpp | 12 ++-- 6 files changed, 149 insertions(+), 130 deletions(-) diff --git a/src/Caret.cpp b/src/Caret.cpp index ee9d99e4..b1b4a290 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -23,14 +23,16 @@ void ActCaret00(CARET *crt) void ActCaret01(CARET *crt) { - RECT rcLeft[4] = { + RECT rcLeft[4] = + { {0, 64, 8, 72}, {8, 64, 16, 72}, {16, 64, 24, 72}, {24, 64, 32, 72}, }; - RECT rcRight[4] = { + RECT rcRight[4] = + { {64, 24, 72, 32}, {72, 24, 80, 32}, {80, 24, 88, 32}, @@ -63,21 +65,24 @@ void ActCaret01(CARET *crt) void ActCaret02(CARET *crt) { - RECT rect_left[4] = { + RECT rect_left[4] = + { {0, 32, 16, 48}, {16, 32, 32, 48}, {32, 32, 48, 48}, {48, 32, 64, 48}, }; - RECT rect_right[4] = { + RECT rect_right[4] = + { {176, 0, 192, 16}, {192, 0, 208, 16}, {208, 0, 224, 16}, {224, 0, 240, 16}, }; - RECT rect_up[3] = { + RECT rect_up[3] = + { {0, 32, 16, 48}, {32, 32, 48, 48}, {16, 32, 32, 48}, @@ -126,7 +131,8 @@ void ActCaret02(CARET *crt) void ActCaret03(CARET *crt) { - RECT rect[4] = { + RECT rect[4] = + { {0, 48, 16, 64}, {16, 48, 32, 64}, {32, 48, 48, 64}, @@ -145,7 +151,8 @@ void ActCaret03(CARET *crt) void ActCaret04(CARET *crt) { - RECT rect[9] = { + RECT rect[9] = + { {64, 32, 80, 48}, {80, 32, 96, 48}, {96, 32, 112, 48}, @@ -170,7 +177,8 @@ void ActCaret04(CARET *crt) void ActCaret05(CARET *crt) { - RECT rect[7] = { + RECT rect[7] = + { {32, 64, 40, 72}, {32, 72, 40, 80}, {40, 64, 48, 72}, @@ -186,7 +194,7 @@ void ActCaret05(CARET *crt) ++crt->ani_no; } - if ( crt->ani_no > 6 ) + if (crt->ani_no > 6) crt->cond = 0; crt->x += 0x80; @@ -197,7 +205,8 @@ void ActCaret05(CARET *crt) void ActCaret07(CARET *crt) { - RECT rcLeft[7] = { + RECT rcLeft[7] = + { {56, 0, 64, 8}, {64, 0, 72, 8}, {72, 0, 80, 8}, @@ -264,12 +273,14 @@ void ActCaret09(CARET *crt) void ActCaret10(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {0, 0, 56, 16}, {0, 16, 56, 32}, }; - RECT rcRight[2] = { + RECT rcRight[2] = + { {0, 96, 56, 112}, {0, 112, 56, 128}, }; @@ -314,7 +325,8 @@ void ActCaret11(CARET *crt) crt->x += crt->xm; crt->y += crt->ym; - RECT rcRight[7] = { + RECT rcRight[7] = + { {56, 8, 64, 16}, {64, 8, 72, 16}, {72, 8, 80, 16}, @@ -336,7 +348,8 @@ void ActCaret11(CARET *crt) void ActCaret12(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {112, 0, 144, 32}, {144, 0, 176, 32}, }; @@ -345,7 +358,7 @@ void ActCaret12(CARET *crt) { crt->ani_wait = 0; if (++crt->ani_no > 1) - crt->cond = 0; + crt->cond = 0; } crt->rect = rcLeft[crt->ani_no]; @@ -353,7 +366,8 @@ void ActCaret12(CARET *crt) void ActCaret13(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {56, 24, 64, 32}, {0, 0, 0, 0}, }; @@ -397,7 +411,8 @@ void ActCaret13(CARET *crt) void ActCaret14(CARET *crt) { - RECT rect[5] = { + RECT rect[5] = + { {0, 96, 40, 136}, {40, 96, 80, 136}, {80, 96, 120, 136}, @@ -418,7 +433,8 @@ void ActCaret14(CARET *crt) void ActCaret15(CARET *crt) { - RECT rcLeft[4] = { + RECT rcLeft[4] = + { {0, 72, 8, 80}, {8, 72, 16, 80}, {16, 72, 24, 80}, @@ -438,7 +454,8 @@ void ActCaret15(CARET *crt) void ActCaret16(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {104, 96, 144, 104}, {104, 104, 144, 112}, }; @@ -454,7 +471,8 @@ void ActCaret16(CARET *crt) void ActCaret17(CARET *crt) { - RECT rcLeft[2] = { + RECT rcLeft[2] = + { {0, 144, 144, 152}, {0, 0, 0, 0}, }; @@ -468,7 +486,7 @@ void ActCaret17(CARET *crt) crt->rect = rcLeft[1]; } -//Tables +// Tables CARET_TABLE gCaretTable[18] = { {0, 0}, diff --git a/src/CommonDefines.h b/src/CommonDefines.h index 9e4b95b3..e280beb3 100644 --- a/src/CommonDefines.h +++ b/src/CommonDefines.h @@ -1,6 +1,6 @@ #pragma once -#define PATH_LENGTH 260 //Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash. +#define PATH_LENGTH 260 // Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash. #define WINDOW_WIDTH 320 #define WINDOW_HEIGHT 240 diff --git a/src/Draw.cpp b/src/Draw.cpp index c1db3ff6..00c95ecc 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -56,7 +56,7 @@ BOOL Flip_SystemTask() if (!SystemTask()) return FALSE; - //Framerate limiter + // Framerate limiter static uint32_t timePrev; const uint32_t timeNow = SDL_GetTicks(); @@ -81,15 +81,15 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth) { (void)lColourDepth; - //Initialize rendering + // Initialize rendering SDL_InitSubSystem(SDL_INIT_VIDEO); - //Create renderer + // Create renderer gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED); if (gRenderer != NULL) { - //Print the name of the renderer SDL2 is using + // Print the name of the renderer SDL2 is using SDL_RendererInfo info; SDL_GetRendererInfo(gRenderer, &info); printf("Renderer: %s\n", info.name); @@ -120,10 +120,10 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth) void EndDirectDraw() { - //Quit sub-system + // Quit sub-system SDL_QuitSubSystem(SDL_INIT_VIDEO); - //Release all surfaces + // Release all surfaces for (int i = 0; i < SURFACE_ID_MAX; i++) ReleaseSurface(i); } @@ -143,7 +143,7 @@ static bool IsEnableBitmap(SDL_RWops *fp) void ReleaseSurface(int s) { - //Release the surface we want to release + // Release the surface we want to release if (surf[s].in_use) { SDL_DestroyTexture(surf[s].texture); @@ -172,7 +172,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no) } else { - //Create surface + // Create surface surf[surf_no].surface = SDL_CreateRGBSurfaceWithFormat(0, bxsize * magnification, bysize * magnification, 0, SDL_PIXELFORMAT_RGB24); SDL_SetSurfaceBlendMode(surf[surf_no].surface, SDL_BLENDMODE_NONE); @@ -320,7 +320,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s char path[PATH_LENGTH]; SDL_RWops *fp; - //Attempt to load PBM + // Attempt to load PBM sprintf(path, "%s/%s.pbm", gDataPath, name); fp = SDL_RWFromFile(path, "rb"); if (fp) @@ -338,7 +338,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s } } - //Attempt to load BMP + // Attempt to load BMP sprintf(path, "%s/%s.bmp", gDataPath, name); fp = SDL_RWFromFile(path, "rb"); if (fp) @@ -412,22 +412,22 @@ static SDL_Rect RectToSDLRectScaled(RECT *rect) void BackupSurface(Surface_Ids surf_no, RECT *rect) { - //Get renderer size + // Get renderer size int w, h; SDL_GetRendererOutputSize(gRenderer, &w, &h); - //Get texture of what's currently rendered on screen + // Get texture of what's currently rendered on screen SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, SDL_PIXELFORMAT_RGB24); SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); SDL_RenderReadPixels(gRenderer, NULL, SDL_PIXELFORMAT_RGB24, surface->pixels, surface->pitch); - //Get rects + // Get rects SDL_Rect frameRect = RectToSDLRectScaled(rect); SDL_BlitSurface(surface, &frameRect, surf[surf_no].surface, &frameRect); surf[surf_no].needs_updating = true; - //Free surface + // Free surface SDL_FreeSurface(surface); } @@ -439,40 +439,39 @@ static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_ surf[surf_no].needs_updating = false; } - //Get SDL_Rects + // Get SDL_Rects SDL_Rect clipRect = RectToSDLRectScaled(rcView); - SDL_Rect frameRect = RectToSDLRectScaled(rect); - //Get dest rect + // Get dest rect SDL_Rect destRect = {x * magnification, y * magnification, frameRect.w, frameRect.h}; - //Set cliprect + // Set cliprect SDL_RenderSetClipRect(gRenderer, &clipRect); SDL_SetTextureBlendMode(surf[surf_no].texture, transparent ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE); - //Draw to screen + // Draw to screen if (SDL_RenderCopy(gRenderer, surf[surf_no].texture, &frameRect, &destRect) < 0) printf("Failed to draw texture %d\nSDL Error: %s\n", surf_no, SDL_GetError()); - //Undo cliprect + // Undo cliprect SDL_RenderSetClipRect(gRenderer, NULL); } -void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) //Transparency +void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // Transparency { DrawBitmap(rcView, x, y, rect, surf_no, true); } -void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) //No Transparency +void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // No Transparency { DrawBitmap(rcView, x, y, rect, surf_no, false); } void Surface2Surface(int x, int y, RECT *rect, int to, int from) { - //Get rects + // Get rects SDL_Rect rcSet = {x * magnification, y * magnification, (rect->right - rect->left) * magnification, (rect->bottom - rect->top) * magnification}; SDL_Rect frameRect = RectToSDLRectScaled(rect); @@ -488,10 +487,10 @@ unsigned long GetCortBoxColor(unsigned long col) void CortBox(RECT *rect, uint32_t col) { - //Get rect + // Get rect SDL_Rect destRect = RectToSDLRectScaled(rect); - //Set colour and draw + // Set colour and draw const unsigned char col_red = col & 0x0000FF; const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_blue = (col & 0xFF0000) >> 16; @@ -501,10 +500,10 @@ void CortBox(RECT *rect, uint32_t col) void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no) { - //Get rect + // Get rect SDL_Rect destRect = RectToSDLRectScaled(rect); - //Set colour and draw + // Set colour and draw const unsigned char col_red = col & 0x0000FF; const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_blue = (col & 0xFF0000) >> 16; @@ -558,7 +557,7 @@ static unsigned char* GetFontFromWindows(size_t *data_size, const char *font_nam void InitTextObject(const char *font_name) { - //Get font size + // Get font size unsigned int fontWidth, fontHeight; // The original did this, but Windows would downscale it to 5/10 anyway. @@ -569,8 +568,10 @@ void InitTextObject(const char *font_name) } else {*/ - fontWidth = 5 * magnification; - fontHeight = 10 * magnification; + + fontWidth = 5 * magnification; + fontHeight = 10 * magnification; + // } size_t data_size; @@ -632,7 +633,7 @@ void PutText2(int x, int y, const char *text, uint32_t color, Surface_Ids surf_n void EndTextObject() { - //Destroy font + // Destroy font UnloadFont(gFont); gFont = NULL; } diff --git a/src/Ending.cpp b/src/Ending.cpp index d8194a8a..df7751be 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -23,32 +23,32 @@ CREDIT Credit; STRIP Strip[MAX_STRIP]; ILLUSTRATION Illust; -//Update casts +// Update casts void ActionStripper() { for (int s = 0; s < MAX_STRIP; s++) { - //Move up + // Move up if (Strip[s].flag & 0x80 && Credit.mode) Strip[s].y -= 0x100; - //Get removed when off-screen + // Get removed when off-screen if (Strip[s].y <= -0x2000) Strip[s].flag = 0; } } -//Draw casts +// Draw casts void PutStripper() { for (int s = 0; s < MAX_STRIP; s++) { if (Strip[s].flag & 0x80) { - //Draw text + // Draw text RECT rc = {0, 16 * s, 320, 16 * s + 16}; PutBitmap3(&grcFull, (Strip[s].x + ((WINDOW_WIDTH - 320) << 8)) / 0x200, Strip[s].y / 0x200, &rc, SURFACE_ID_CREDIT_CAST); - //Draw character + // Draw character rc.left = 24 * (Strip[s].cast % 13); rc.right = rc.left + 24; rc.top = 24 * (Strip[s].cast / 13); @@ -58,21 +58,21 @@ void PutStripper() } } -//Create a cast object +// Create a cast object void SetStripper(int x, int y, const char *text, int cast) { for (int s = 0; s < MAX_STRIP; s++) { if (!(Strip[s].flag & 0x80)) { - //Initialize cast property + // Initialize cast property Strip[s].flag = 0x80; Strip[s].x = x; Strip[s].y = y; Strip[s].cast = cast; strcpy(Strip[s].str, text); - //Draw text + // Draw text RECT rc = {0, 16 * s, 320, 16 * s + 16}; CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST); PutText2(0, 16 * s, text, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST); @@ -81,7 +81,7 @@ void SetStripper(int x, int y, const char *text, int cast) } } -//Regenerate cast text +// Regenerate cast text void RestoreStripper() { for (int s = 0; s < MAX_STRIP; s++) @@ -95,22 +95,22 @@ void RestoreStripper() } } -//Handle the illustration +// Handle the illustration void ActionIllust() { switch (Illust.act_no) { - case 0: //Off-screen to the left + case 0: // Off-screen to the left Illust.x = -0x14000; break; - case 1: //Move in from the left + case 1: // Move in from the left Illust.x += 0x5000; if (Illust.x > 0) Illust.x = 0; break; - case 2: //Move out from the right + case 2: // Move out from the right Illust.x -= 0x5000; if (Illust.x < -0x14000) Illust.x = -0x14000; @@ -118,7 +118,7 @@ void ActionIllust() } } -//Draw illustration +// Draw illustration void PutIllust() { RECT rcIllust = {0, 0, 160, 240}; @@ -126,7 +126,7 @@ void PutIllust() PutBitmap3(&rcClip, (Illust.x + ((WINDOW_WIDTH - 320) << 8)) / 0x200, (WINDOW_HEIGHT - 240) / 2, &rcIllust, SURFACE_ID_CREDITS_IMAGE); } -//Load illustration +// Load illustration void ReloadIllust(int a) { char name[16]; @@ -134,10 +134,10 @@ void ReloadIllust(int a) ReloadBitmap_Resource(name, SURFACE_ID_CREDITS_IMAGE); } -//Initialize and release credits +// Initialize and release credits void InitCreditScript() { - //Clear script state and casts + // Clear script state and casts memset(&Credit, 0, sizeof(CREDIT)); memset(Strip, 0, sizeof(Strip)); } @@ -146,23 +146,23 @@ void ReleaseCreditScript() { if (Credit.pData) { - //Free script data + // Free script data free(Credit.pData); Credit.pData = NULL; } } -//Start playing credits +// Start playing credits bool StartCreditScript() { - //Clear previously existing credits data + // Clear previously existing credits data if (Credit.pData) { free(Credit.pData); Credit.pData = NULL; } - //Open file + // Open file char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, "Credit.tsc"); @@ -170,7 +170,7 @@ bool StartCreditScript() if (Credit.size == -1) return false; - //Allcoate buffer data + // Allocate buffer data Credit.pData = (char*)malloc(Credit.size); if (Credit.pData == NULL) return false; @@ -182,7 +182,7 @@ bool StartCreditScript() return false; } - //Read data + // Read data fread(Credit.pData, 1, Credit.size, fp); EncryptionBinaryData2((uint8_t*)Credit.pData, Credit.size); @@ -191,30 +191,30 @@ bool StartCreditScript() fclose(fp); #endif - //Reset credits + // Reset credits Credit.offset = 0; Credit.wait = 0; Credit.mode = 1; Illust.x = -0x14000; Illust.act_no = 0; - //Modify cliprect + // Modify cliprect grcGame.left = WINDOW_WIDTH / 2; // These three are non-vanilla: for wide/tallscreen support grcGame.right = ((WINDOW_WIDTH - 320) / 2) + 320; grcGame.top = (WINDOW_HEIGHT - 240) / 2; grcGame.bottom = ((WINDOW_HEIGHT - 240) / 2) + 240; - //Reload casts + // Reload casts if (!ReloadBitmap_File("casts", SURFACE_ID_CASTS)) return false; - //Clear casts + // Clear casts memset(Strip, 0, sizeof(Strip)); return true; } -//Get number from text (4 digit) +// Get number from text (4 digit) int GetScriptNumber(const char *text) { return 1000 * text[0] - 48000 + @@ -223,19 +223,19 @@ int GetScriptNumber(const char *text) text[3] - 48; } -//Parse credits +// Parse credits void ActionCredit_Read() { while (Credit.offset < Credit.size) { - //Get character + // Get character uint8_t character = Credit.pData[Credit.offset]; int a, b, len; switch (character) { - case '[': //Create cast - //Get the range for the cast text + case '[': // Create cast + // Get the range for the cast text a = ++Credit.offset; while (Credit.pData[a] != ']') @@ -248,35 +248,35 @@ void ActionCredit_Read() len = a - Credit.offset; - //Copy the text to the cast text + // Copy the text to the cast text char text[40]; memcpy(text, &Credit.pData[Credit.offset], a - Credit.offset); text[len] = 0; - //Get cast id + // Get cast id Credit.offset = a + 1; len = GetScriptNumber(&Credit.pData[a + 1]); - //Create cast object + // Create cast object SetStripper(Credit.start_x, (WINDOW_HEIGHT << 9) + 0x1000, text, len); - //Change offset + // Change offset Credit.offset += 4; return; - case 'j': //Jump to label - //Get number + case 'j': // Jump to label + // Get number b = GetScriptNumber(&Credit.pData[++Credit.offset]); - //Change offset + // Change offset Credit.offset += 4; - //Jump to specific label + // Jump to specific label while (Credit.offset < Credit.size) { if (Credit.pData[Credit.offset] == 'l') { - //what is this + // What is this a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; if (b == a) @@ -294,29 +294,29 @@ void ActionCredit_Read() return; - case '~': //Start fading out music + case '~': // Start fading out music ++Credit.offset; SetOrganyaFadeout(); return; - case 'f': //Flag jump - //Read numbers XXXX:YYYY + case 'f': // Flag jump + // Read numbers XXXX:YYYY a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 5; b = GetScriptNumber(&Credit.pData[Credit.offset]); Credit.offset += 4; - //If flag is set + // If flag is set if (GetNPCFlag(a)) { - //Jump to label - while ( Credit.offset < Credit.size ) + // Jump to label + while (Credit.offset < Credit.size) { if (Credit.pData[Credit.offset] == 'l') { a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; - if ( b == a ) + if (b == a) return; } else if (IsShiftJIS(Credit.pData[Credit.offset])) @@ -331,39 +331,39 @@ void ActionCredit_Read() } return; - case '+': //Change casts x-position + case '+': // Change casts x-position Credit.start_x = GetScriptNumber(&Credit.pData[++Credit.offset]) << 9; Credit.offset += 4; return; - case '-': //Wait for X amount of frames + case '-': // Wait for X amount of frames Credit.wait = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; Credit.mode = 2; return; - case '/': //Stop credits + case '/': // Stop credits Credit.mode = 0; return; - case '!': //Change music + case '!': // Change music a = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.offset += 4; ChangeMusic(a); return; } - //Progress through file + // Progress through file ++Credit.offset; } } -//Update credits +// Update credits void ActionCredit() { if (Credit.offset < Credit.size) { - //Update script, or if waiting, decrement the wait value + // Update script, or if waiting, decrement the wait value if (Credit.mode == 1) { ActionCredit_Read(); @@ -375,28 +375,28 @@ void ActionCredit() } } -//Change illustration +// Change illustration void SetCreditIllust(int a) { ReloadIllust(a); Illust.act_no = 1; } -//Slide illustration off-screen +// Slide illustration off-screen void CutCreditIllust() { Illust.act_no = 2; } -//Scene of the island falling +// Scene of the island falling int Scene_DownIsland(int mode) { - //Setup background + // Setup background RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2}; RECT rc_sky = {0, 0, 160, 80}; RECT rc_ground = {160, 48, 320, 80}; - //Setup island + // Setup island RECT rc_sprite = {160, 0, 200, 24}; ISLAND_SPRITE sprite; @@ -405,10 +405,10 @@ int Scene_DownIsland(int mode) for (int wait = 0; wait < 900; wait++) { - //Get pressed keys + // Get pressed keys GetTrg(); - //Escape menu + // Escape menu if (gKey & 0x8000) { int escRet = Call_Escape(); @@ -421,7 +421,7 @@ int Scene_DownIsland(int mode) switch (mode) { case 0: - //Move down + // Move down sprite.y += 0x33; break; @@ -432,38 +432,38 @@ int Scene_DownIsland(int mode) { if (wait >= 600) { - //End scene + // End scene if (wait == 750) wait = 900; } else { - //Move down slow + // Move down slow sprite.y += 0xC; } } else { - //Move down slower + // Move down slower sprite.y += 0x19; } } else { - //Move down at normal speed + // Move down at normal speed sprite.y += 0x33; } break; } - //Draw scene + // Draw scene CortBox(&grcFull, 0); PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1); PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1); PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1); PutTimeCounter(16, 8); - //Draw window + // Draw window PutFramePerSecound(); if (!Flip_SystemTask()) return 0; diff --git a/src/Ending.h b/src/Ending.h index b5a4d693..a490e027 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -33,7 +33,7 @@ struct ISLAND_SPRITE int y; }; -#define MAX_STRIP (WINDOW_HEIGHT / 16) + 1 +#define MAX_STRIP ((WINDOW_HEIGHT / 16) + 1) void ActionStripper(); void PutStripper(); diff --git a/src/Escape.cpp b/src/Escape.cpp index 0266af8a..99a8bdd4 100644 --- a/src/Escape.cpp +++ b/src/Escape.cpp @@ -13,33 +13,33 @@ int Call_Escape() while (1) { - //Get pressed keys + // Get pressed keys GetTrg(); - if (gKeyTrg & KEY_ESCAPE) //Escape is pressed, quit game + if (gKeyTrg & KEY_ESCAPE) // Escape is pressed, quit game { gKeyTrg = 0; return 0; } - if (gKeyTrg & KEY_F1) //F1 is pressed, continue + if (gKeyTrg & KEY_F1) // F1 is pressed, continue { gKeyTrg = 0; return 1; } - if (gKeyTrg & KEY_F2) //F2 is pressed, reset + if (gKeyTrg & KEY_F2) // F2 is pressed, reset { gKeyTrg = 0; return 2; } - //Draw screen + // Draw screen CortBox(&grcFull, 0x000000); PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, SURFACE_ID_TEXT_BOX); PutFramePerSecound(); if (!Flip_SystemTask()) { - //Quit if window is closed + // Quit if window is closed gKeyTrg = 0; return 0; } From 08de04bad7a7c9ac41efc71c76e294ace7fe9e0c Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 7 May 2019 16:35:41 +0100 Subject: [PATCH 11/18] Some accuracy-related things for Back.cpp --- src/Back.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index 51b715fa..b388fe30 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -38,8 +38,8 @@ BOOL InitBack(const char *fName, int type) // This is ridiculously platform-dependant: // It should break on big-endian CPUs, and platforms // where short isn't 16-bit and long isn't 32-bit. - short bmp_header_buffer[7]; - long bmp_header_buffer2[10]; + unsigned short bmp_header_buffer[7]; // These names aren't the original. This ruins the stack frame layout. + unsigned long bmp_header_buffer2[10]; fread(bmp_header_buffer, 14, 1, fp); From a5dcebec01f11a0cf6a73c5b70a79aa3c9886085 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 7 May 2019 16:42:19 +0100 Subject: [PATCH 12/18] Added some functions to the Devilution list --- msvc2003/devilution/comparer-config.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/msvc2003/devilution/comparer-config.toml b/msvc2003/devilution/comparer-config.toml index a2fda3bd..d44ee262 100644 --- a/msvc2003/devilution/comparer-config.toml +++ b/msvc2003/devilution/comparer-config.toml @@ -11,6 +11,14 @@ name = "InitBack" addr = 0x402270 size = 0x100 +[[func]] +name = "ActBack" +addr = 0x402370 + +[[func]] +name = "PutBack" +addr = 0x4023D0 + [[func]] name = "PutFront" addr = 0x402830 From b062d8af5b4c11dc2eaa551a1391ff57f77e4174 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 7 May 2019 16:47:17 +0100 Subject: [PATCH 13/18] Add a missing PATH_LENGTH --- src/Map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Map.cpp b/src/Map.cpp index 592fe34f..037bdc0e 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -81,7 +81,7 @@ BOOL LoadMapData2(const char *path_map) BOOL LoadAttributeData(const char *path_atrb) { //Open file - char path[260]; + char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, path_atrb); FILE *fp = fopen(path, "rb"); From ef00d064ab311bc0b00a0c4a7cc7d60b9e534770 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 17:47:21 +0200 Subject: [PATCH 14/18] Reverted RECT formatting changes That's actually how the code is supposed to be formatted Signed-off-by: Gabriel Ravier --- src/Caret.cpp | 70 +++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/src/Caret.cpp b/src/Caret.cpp index b1b4a290..2fac8bec 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -23,16 +23,14 @@ void ActCaret00(CARET *crt) void ActCaret01(CARET *crt) { - RECT rcLeft[4] = - { + RECT rcLeft[4] = { {0, 64, 8, 72}, {8, 64, 16, 72}, {16, 64, 24, 72}, {24, 64, 32, 72}, }; - RECT rcRight[4] = - { + RECT rcRight[4] = { {64, 24, 72, 32}, {72, 24, 80, 32}, {80, 24, 88, 32}, @@ -65,24 +63,21 @@ void ActCaret01(CARET *crt) void ActCaret02(CARET *crt) { - RECT rect_left[4] = - { + RECT rect_left[4] = { {0, 32, 16, 48}, {16, 32, 32, 48}, {32, 32, 48, 48}, {48, 32, 64, 48}, }; - RECT rect_right[4] = - { + RECT rect_right[4] = { {176, 0, 192, 16}, {192, 0, 208, 16}, {208, 0, 224, 16}, {224, 0, 240, 16}, }; - RECT rect_up[3] = - { + RECT rect_up[3] = { {0, 32, 16, 48}, {32, 32, 48, 48}, {16, 32, 32, 48}, @@ -131,8 +126,8 @@ void ActCaret02(CARET *crt) void ActCaret03(CARET *crt) { - RECT rect[4] = - { + RECT rect[4] ={ + {0, 48, 16, 64}, {16, 48, 32, 64}, {32, 48, 48, 64}, @@ -151,8 +146,8 @@ void ActCaret03(CARET *crt) void ActCaret04(CARET *crt) { - RECT rect[9] = - { + RECT rect[9] ={ + {64, 32, 80, 48}, {80, 32, 96, 48}, {96, 32, 112, 48}, @@ -177,8 +172,8 @@ void ActCaret04(CARET *crt) void ActCaret05(CARET *crt) { - RECT rect[7] = - { + RECT rect[7] ={ + {32, 64, 40, 72}, {32, 72, 40, 80}, {40, 64, 48, 72}, @@ -205,8 +200,8 @@ void ActCaret05(CARET *crt) void ActCaret07(CARET *crt) { - RECT rcLeft[7] = - { + RECT rcLeft[7] ={ + {56, 0, 64, 8}, {64, 0, 72, 8}, {72, 0, 80, 8}, @@ -273,14 +268,14 @@ void ActCaret09(CARET *crt) void ActCaret10(CARET *crt) { - RECT rcLeft[2] = - { + RECT rcLeft[2] ={ + {0, 0, 56, 16}, {0, 16, 56, 32}, }; - RECT rcRight[2] = - { + RECT rcRight[2] ={ + {0, 96, 56, 112}, {0, 112, 56, 128}, }; @@ -325,8 +320,8 @@ void ActCaret11(CARET *crt) crt->x += crt->xm; crt->y += crt->ym; - RECT rcRight[7] = - { + RECT rcRight[7] ={ + {56, 8, 64, 16}, {64, 8, 72, 16}, {72, 8, 80, 16}, @@ -348,8 +343,8 @@ void ActCaret11(CARET *crt) void ActCaret12(CARET *crt) { - RECT rcLeft[2] = - { + RECT rcLeft[2] ={ + {112, 0, 144, 32}, {144, 0, 176, 32}, }; @@ -366,8 +361,8 @@ void ActCaret12(CARET *crt) void ActCaret13(CARET *crt) { - RECT rcLeft[2] = - { + RECT rcLeft[2] ={ + {56, 24, 64, 32}, {0, 0, 0, 0}, }; @@ -411,8 +406,8 @@ void ActCaret13(CARET *crt) void ActCaret14(CARET *crt) { - RECT rect[5] = - { + RECT rect[5] ={ + {0, 96, 40, 136}, {40, 96, 80, 136}, {80, 96, 120, 136}, @@ -433,8 +428,8 @@ void ActCaret14(CARET *crt) void ActCaret15(CARET *crt) { - RECT rcLeft[4] = - { + RECT rcLeft[4] ={ + {0, 72, 8, 80}, {8, 72, 16, 80}, {16, 72, 24, 80}, @@ -454,8 +449,8 @@ void ActCaret15(CARET *crt) void ActCaret16(CARET *crt) { - RECT rcLeft[2] = - { + RECT rcLeft[2] ={ + {104, 96, 144, 104}, {104, 104, 144, 112}, }; @@ -471,8 +466,8 @@ void ActCaret16(CARET *crt) void ActCaret17(CARET *crt) { - RECT rcLeft[2] = - { + RECT rcLeft[2] ={ + {0, 144, 144, 152}, {0, 0, 0, 0}, }; @@ -487,8 +482,7 @@ void ActCaret17(CARET *crt) } // Tables -CARET_TABLE gCaretTable[18] = -{ +CARET_TABLE gCaretTable[18] = { {0, 0}, {0x800, 0x800}, {0x1000, 0x1000}, From 3d42044917bb626be804f22a4dbd242856f448e8 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 17:52:33 +0200 Subject: [PATCH 15/18] Corrected weird half-commented-out code Signed-off-by: Gabriel Ravier --- src/Draw.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index 00c95ecc..7bbfa596 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -567,13 +567,14 @@ void InitTextObject(const char *font_name) fontHeight = 12; } else - {*/ + { + fontWidth = 5 * magnification; + fontHeight = 10 * magnification; + }*/ fontWidth = 5 * magnification; fontHeight = 10 * magnification; -// } - size_t data_size; #ifdef WINDOWS // Actually use the font Config.dat specifies From 1b0ebfe25d338ff6f9e05d4c3162f3a4b65a25c4 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 18:10:54 +0200 Subject: [PATCH 16/18] Revert RECT formatting changes Signed-off-by: Gabriel Ravier --- src/BossAlmo1.cpp | 6 ++---- src/BossAlmo2.cpp | 12 ++++-------- src/BossBallos.cpp | 9 +++------ src/BossFrog.cpp | 6 ++---- src/BossIronH.cpp | 6 ++---- src/BossOhm.cpp | 9 +++------ src/BossPress.cpp | 6 ++---- src/BossTwinD.cpp | 12 ++++-------- src/BossX.cpp | 15 +++++---------- 9 files changed, 27 insertions(+), 54 deletions(-) diff --git a/src/BossAlmo1.cpp b/src/BossAlmo1.cpp index bdd88eb6..3de864be 100644 --- a/src/BossAlmo1.cpp +++ b/src/BossAlmo1.cpp @@ -13,8 +13,7 @@ static void ActBossChar_Core_Face(NPCHAR *npc) { - RECT rect[4] = - { + RECT rect[4] = { {0, 0, 72, 112}, {0, 112, 72, 224}, {160, 0, 232, 112}, @@ -63,8 +62,7 @@ static void ActBossChar_Core_Face(NPCHAR *npc) static void ActBossChar_Core_Tail(NPCHAR *npc) { - RECT rect[3] = - { + RECT rect[3] = { {72, 0, 160, 112}, {72, 112, 160, 224}, {0, 0, 0, 0}, diff --git a/src/BossAlmo2.cpp b/src/BossAlmo2.cpp index cded7e21..67c1b020 100644 --- a/src/BossAlmo2.cpp +++ b/src/BossAlmo2.cpp @@ -14,8 +14,7 @@ static void ActBossCharA_Head(NPCHAR *npc) { - RECT rect[4] = - { + RECT rect[4] = { {0, 0, 72, 112}, {0, 112, 72, 224}, {160, 0, 232, 112}, @@ -62,8 +61,7 @@ static void ActBossCharA_Head(NPCHAR *npc) static void ActBossCharA_Tail(NPCHAR *npc) { - RECT rect[3] = - { + RECT rect[3] = { {72, 0, 160, 112}, {72, 112, 160, 224}, {0, 0, 0, 0}, @@ -109,8 +107,7 @@ static void ActBossCharA_Tail(NPCHAR *npc) static void ActBossCharA_Face(NPCHAR *npc) { - RECT rect[5] = - { + RECT rect[5] = { {0, 0, 0, 0}, {160, 112, 232, 152}, {160, 152, 232, 192}, @@ -177,8 +174,7 @@ static void ActBossCharA_Mini(NPCHAR *npc) { int deg; - RECT rect[3] = - { + RECT rect[3] = { {256, 0, 320, 40}, {256, 40, 320, 80}, {256, 80, 320, 120}, diff --git a/src/BossBallos.cpp b/src/BossBallos.cpp index c594ebe0..93920519 100644 --- a/src/BossBallos.cpp +++ b/src/BossBallos.cpp @@ -13,8 +13,7 @@ static void ActBossChar_Eye(NPCHAR *npc) { - RECT rcLeft[5] = - { + RECT rcLeft[5] = { {272, 0, 296, 16}, {272, 16, 296, 32}, {272, 32, 296, 48}, @@ -22,8 +21,7 @@ static void ActBossChar_Eye(NPCHAR *npc) {240, 16, 264, 32}, }; - RECT rcRight[5] = - { + RECT rcRight[5] = { {296, 0, 320, 16}, {296, 16, 320, 32}, {296, 32, 320, 48}, @@ -106,8 +104,7 @@ static void ActBossChar_Eye(NPCHAR *npc) static void ActBossChar_Body(NPCHAR *npc) { - RECT rc[4] = - { + RECT rc[4] = { {0, 0, 120, 120}, {120, 0, 240, 120}, {0, 120, 120, 240}, diff --git a/src/BossFrog.cpp b/src/BossFrog.cpp index ca5b733b..bc665689 100644 --- a/src/BossFrog.cpp +++ b/src/BossFrog.cpp @@ -91,8 +91,7 @@ void ActBossChar_Frog(void) int ym; int xm; - RECT rcLeft[9] = - { + RECT rcLeft[9] = { {0, 0, 0, 0}, {0, 48, 80, 112}, {0, 112, 80, 176}, @@ -104,8 +103,7 @@ void ActBossChar_Frog(void) {120, 0, 160, 24}, }; - RECT rcRight[9] = - { + RECT rcRight[9] = { {0, 0, 0, 0}, {80, 48, 160, 112}, {80, 112, 160, 176}, diff --git a/src/BossIronH.cpp b/src/BossIronH.cpp index 580a6292..c76ec3c0 100644 --- a/src/BossIronH.cpp +++ b/src/BossIronH.cpp @@ -174,8 +174,7 @@ void ActBossChar_Ironhead(void) break; } - RECT rc[9] = - { + RECT rc[9] = { {0, 0, 64, 24}, {64, 0, 128, 24}, {128, 0, 192, 24}, @@ -187,8 +186,7 @@ void ActBossChar_Ironhead(void) {256, 48, 320, 72}, }; - RECT rcDamage[9] = - { + RECT rcDamage[9] = { {0, 24, 64, 48}, {64, 24, 128, 48}, {128, 24, 192, 48}, diff --git a/src/BossOhm.cpp b/src/BossOhm.cpp index b14ffcd9..2df6aedd 100644 --- a/src/BossOhm.cpp +++ b/src/BossOhm.cpp @@ -41,14 +41,12 @@ static void ActBoss01_34() { int i; - RECT rcLeft[2] = - { + RECT rcLeft[2] = { {0, 56, 40, 88}, {40, 56, 80, 88}, }; - RECT rcRight[2] = - { + RECT rcRight[2] = { {0, 88, 40, 120}, {40, 88, 80, 120}, }; @@ -456,8 +454,7 @@ void ActBossChar_Omega() break; } - RECT rect[4] = - { + RECT rect[4] = { {0, 0, 80, 56}, {80, 0, 160, 56}, {160, 0, 240, 56}, diff --git a/src/BossPress.cpp b/src/BossPress.cpp index 59fdcc0a..5412b46e 100644 --- a/src/BossPress.cpp +++ b/src/BossPress.cpp @@ -206,15 +206,13 @@ void ActBossChar_Press(void) gBoss[3].x = npc->x; gBoss[3].y = npc->y + 0x5000; - RECT rc[3] = - { + RECT rc[3] = { {0, 0, 80, 120}, {80, 0, 160, 120}, {160, 0, 240, 120}, }; - RECT rcDamage[3] = - { + RECT rcDamage[3] = { {0, 120, 80, 240}, {80, 120, 160, 240}, {160, 120, 240, 240}, diff --git a/src/BossTwinD.cpp b/src/BossTwinD.cpp index f4fb043d..47b59ab5 100644 --- a/src/BossTwinD.cpp +++ b/src/BossTwinD.cpp @@ -14,15 +14,13 @@ static void ActBossCharT_DragonBody(NPCHAR *npc) { unsigned char deg; - RECT rcLeft[3] = - { + RECT rcLeft[3] = { {0, 0, 40, 40}, {40, 0, 80, 40}, {80, 0, 120, 40}, }; - RECT rcRight[3] = - { + RECT rcRight[3] = { {0, 40, 40, 80}, {40, 40, 80, 80}, {80, 40, 120, 80}, @@ -98,16 +96,14 @@ static void ActBossCharT_DragonHead(NPCHAR *npc) int ym; int xm; - RECT rcLeft[4] = - { + RECT rcLeft[4] = { {0, 80, 40, 112}, {40, 80, 80, 112}, {80, 80, 120, 112}, {120, 80, 160, 112}, }; - RECT rcRight[4] = - { + RECT rcRight[4] = { {0, 112, 40, 144}, {40, 112, 80, 144}, {80, 112, 120, 144}, diff --git a/src/BossX.cpp b/src/BossX.cpp index d4edb544..e17d5667 100644 --- a/src/BossX.cpp +++ b/src/BossX.cpp @@ -13,8 +13,7 @@ static void ActBossChar03_01(NPCHAR *npc) { - RECT rcUp[6] = - { + RECT rcUp[6] = { {0, 0, 72, 32}, {0, 32, 72, 64}, {72, 0, 144, 32}, @@ -23,8 +22,7 @@ static void ActBossChar03_01(NPCHAR *npc) {144, 32, 216, 64}, }; - RECT rcDown[6] = - { + RECT rcDown[6] = { {0, 64, 72, 96}, {0, 96, 72, 128}, {72, 64, 144, 96}, @@ -216,8 +214,7 @@ static void ActBossChar03_02(NPCHAR *npc) { int direct; - RECT rect[4] = - { + RECT rect[4] = { {0, 128, 72, 160}, {72, 128, 144, 160}, {0, 160, 72, 192}, @@ -369,8 +366,7 @@ static void ActBossChar03_04(NPCHAR *npc) int ym; int xm; - RECT rect[8] = - { + RECT rect[8] = { {0, 192, 16, 208}, {16, 192, 32, 208}, {32, 192, 48, 208}, @@ -444,8 +440,7 @@ static void ActBossChar03_face(NPCHAR *npc) { static unsigned char flash; - RECT rect[3] = - { + RECT rect[3] = { {216, 0, 320, 48}, {216, 48, 320, 96}, {216, 144, 320, 192}, From 569c2c28b6a851b05221979242b988d09f290e31 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 18:48:18 +0200 Subject: [PATCH 17/18] Fix bad RECT declaration spacing Yes I'm that bad at search & replace Signed-off-by: Gabriel Ravier --- src/Caret.cpp | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/Caret.cpp b/src/Caret.cpp index 2fac8bec..a17223ff 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -126,8 +126,7 @@ void ActCaret02(CARET *crt) void ActCaret03(CARET *crt) { - RECT rect[4] ={ - + RECT rect[4] = { {0, 48, 16, 64}, {16, 48, 32, 64}, {32, 48, 48, 64}, @@ -146,8 +145,7 @@ void ActCaret03(CARET *crt) void ActCaret04(CARET *crt) { - RECT rect[9] ={ - + RECT rect[9] = { {64, 32, 80, 48}, {80, 32, 96, 48}, {96, 32, 112, 48}, @@ -172,8 +170,7 @@ void ActCaret04(CARET *crt) void ActCaret05(CARET *crt) { - RECT rect[7] ={ - + RECT rect[7] = { {32, 64, 40, 72}, {32, 72, 40, 80}, {40, 64, 48, 72}, @@ -200,8 +197,7 @@ void ActCaret05(CARET *crt) void ActCaret07(CARET *crt) { - RECT rcLeft[7] ={ - + RECT rcLeft[7] = { {56, 0, 64, 8}, {64, 0, 72, 8}, {72, 0, 80, 8}, @@ -268,14 +264,12 @@ void ActCaret09(CARET *crt) void ActCaret10(CARET *crt) { - RECT rcLeft[2] ={ - + RECT rcLeft[2] = { {0, 0, 56, 16}, {0, 16, 56, 32}, }; - RECT rcRight[2] ={ - + RECT rcRight[2] = { {0, 96, 56, 112}, {0, 112, 56, 128}, }; @@ -320,8 +314,7 @@ void ActCaret11(CARET *crt) crt->x += crt->xm; crt->y += crt->ym; - RECT rcRight[7] ={ - + RECT rcRight[7] = { {56, 8, 64, 16}, {64, 8, 72, 16}, {72, 8, 80, 16}, @@ -343,8 +336,7 @@ void ActCaret11(CARET *crt) void ActCaret12(CARET *crt) { - RECT rcLeft[2] ={ - + RECT rcLeft[2] = { {112, 0, 144, 32}, {144, 0, 176, 32}, }; @@ -361,8 +353,7 @@ void ActCaret12(CARET *crt) void ActCaret13(CARET *crt) { - RECT rcLeft[2] ={ - + RECT rcLeft[2] = { {56, 24, 64, 32}, {0, 0, 0, 0}, }; @@ -406,8 +397,7 @@ void ActCaret13(CARET *crt) void ActCaret14(CARET *crt) { - RECT rect[5] ={ - + RECT rect[5] = { {0, 96, 40, 136}, {40, 96, 80, 136}, {80, 96, 120, 136}, @@ -428,8 +418,7 @@ void ActCaret14(CARET *crt) void ActCaret15(CARET *crt) { - RECT rcLeft[4] ={ - + RECT rcLeft[4] = { {0, 72, 8, 80}, {8, 72, 16, 80}, {16, 72, 24, 80}, @@ -449,8 +438,7 @@ void ActCaret15(CARET *crt) void ActCaret16(CARET *crt) { - RECT rcLeft[2] ={ - + RECT rcLeft[2] = { {104, 96, 144, 104}, {104, 104, 144, 112}, }; @@ -466,8 +454,7 @@ void ActCaret16(CARET *crt) void ActCaret17(CARET *crt) { - RECT rcLeft[2] ={ - + RECT rcLeft[2] = { {0, 144, 144, 152}, {0, 0, 0, 0}, }; From edba2f176ce2227643ff60aee04d936b041f3dd3 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 7 May 2019 19:07:01 +0200 Subject: [PATCH 18/18] Correct RECT formatting error I missed Signed-off-by: Gabriel Ravier --- src/BossAlmo1.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/BossAlmo1.cpp b/src/BossAlmo1.cpp index 3de864be..a9af1ffb 100644 --- a/src/BossAlmo1.cpp +++ b/src/BossAlmo1.cpp @@ -114,8 +114,7 @@ static void ActBossChar_Core_Mini(NPCHAR *npc) int ym; int xm; - RECT rect[3] = - { + RECT rect[3] = { {256, 0, 320, 40}, {256, 40, 320, 80}, {256, 80, 320, 120},