From a3fd87e581ecc7304fa681575c9a2f551bf42d7f Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 15 Nov 2019 20:53:31 +0000 Subject: [PATCH] Clean-up Ending.cpp --- src/Ending.cpp | 81 +++++++++++++++++++++++++++----------------------- src/Ending.h | 22 +++++++------- 2 files changed, 55 insertions(+), 48 deletions(-) diff --git a/src/Ending.cpp b/src/Ending.cpp index cd09bce7..e659ca89 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -23,9 +23,11 @@ STRIP Strip[MAX_STRIP]; ILLUSTRATION Illust; // Update casts -void ActionStripper() +void ActionStripper(void) { - for (int s = 0; s < MAX_STRIP; s++) + int s; + + for (s = 0; s < MAX_STRIP; ++s) { // Move up if (Strip[s].flag & 0x80 && Credit.mode) @@ -37,26 +39,27 @@ void ActionStripper() } // Draw casts -void PutStripper() +void PutStripper(void) { RECT rc; + int s; - for (int s = 0; s < MAX_STRIP; s++) + for (s = 0; s < MAX_STRIP; ++s) { if (Strip[s].flag & 0x80) { // Draw text rc.left = 0; rc.right = 320; - rc.top = s * 0x10; - rc.bottom = rc.top + 0x10; + rc.top = s * 16; + rc.bottom = rc.top + 16; PutBitmap3(&grcFull, (Strip[s].x / 0x200) + ((WINDOW_WIDTH - 320) / 2), (Strip[s].y / 0x200), &rc, SURFACE_ID_CREDIT_CAST); // Draw character - rc.left = 24 * (Strip[s].cast % 13); + rc.left = (Strip[s].cast % 13) * 24; rc.right = rc.left + 24; - rc.top = 24 * (Strip[s].cast / 13); + rc.top = (Strip[s].cast / 13) * 24; rc.bottom = rc.top + 24; PutBitmap3(&grcFull, (Strip[s].x / 0x200) + ((WINDOW_WIDTH - 320) / 2) - 24, (Strip[s].y / 0x200) - 8, &rc, SURFACE_ID_CASTS); @@ -70,7 +73,7 @@ void SetStripper(int x, int y, const char *text, int cast) RECT rc; int s; - for (s = 0; s < MAX_STRIP; s++) + for (s = 0; s < MAX_STRIP; ++s) if (!(Strip[s].flag & 0x80)) break; @@ -87,26 +90,27 @@ void SetStripper(int x, int y, const char *text, int cast) // Draw text rc.left = 0; rc.right = 320; - rc.top = s * 0x10; - rc.bottom = rc.top + 0x10; + rc.top = s * 16; + rc.bottom = rc.top + 16; CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST); PutText2(0, rc.top, text, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST); } // Regenerate cast text -void RestoreStripper() +void RestoreStripper(void) { RECT rc; + int s; - for (int s = 0; s < MAX_STRIP; s++) + for (s = 0; s < MAX_STRIP; ++s) { if (Strip[s].flag & 0x80) { rc.left = 0; rc.right = 320; - rc.top = s * 0x10; - rc.bottom = rc.top + 0x10; + rc.top = s * 16; + rc.bottom = rc.top + 16; CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST); PutText2(0, rc.top, Strip[s].str, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST); @@ -115,30 +119,30 @@ void RestoreStripper() } // Handle the illustration -void ActionIllust() +void ActionIllust(void) { switch (Illust.act_no) { case 0: // Off-screen to the left - Illust.x = -0x14000; + Illust.x = -160 * 0x200; break; case 1: // Move in from the left - Illust.x += 0x5000; + Illust.x += 40 * 0x200; if (Illust.x > 0) Illust.x = 0; break; case 2: // Move out from the right Illust.x -= 0x5000; - if (Illust.x < -0x14000) - Illust.x = -0x14000; + if (Illust.x < -160 * 0x200) + Illust.x = -160 * 0x200; break; } } // Draw illustration -void PutIllust() +void PutIllust(void) { RECT rcIllust = {0, 0, 160, 240}; #if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 @@ -159,16 +163,16 @@ void ReloadIllust(int a) } // Initialize and release credits -void InitCreditScript() +void InitCreditScript(void) { // Clear script state and casts memset(&Credit, 0, sizeof(CREDIT)); memset(Strip, 0, sizeof(Strip)); } -void ReleaseCreditScript() +void ReleaseCreditScript(void) { - if (Credit.pData) + if (Credit.pData != NULL) { // Free script data free(Credit.pData); @@ -179,10 +183,10 @@ void ReleaseCreditScript() const char *credit_script = "Credit.tsc"; // Start playing credits -BOOL StartCreditScript() +BOOL StartCreditScript(void) { // Clear previously existing credits data - if (Credit.pData) + if (Credit.pData != NULL) { free(Credit.pData); Credit.pData = NULL; @@ -221,7 +225,7 @@ BOOL StartCreditScript() Credit.offset = 0; Credit.wait = 0; Credit.mode = 1; - Illust.x = -0x14000; + Illust.x = -160 * 0x200; Illust.act_no = 0; // Modify cliprect @@ -243,7 +247,7 @@ BOOL StartCreditScript() } // Update credits -void ActionCredit() +void ActionCredit(void) { if (Credit.offset >= Credit.size) return; @@ -258,11 +262,12 @@ void ActionCredit() case 2: if (--Credit.wait <= 0) Credit.mode = 1; + break; } } // Parse credits -void ActionCredit_Read() +void ActionCredit_Read(void) { int a, b, len; char text[40]; @@ -429,7 +434,7 @@ void SetCreditIllust(int a) } // Slide illustration off-screen -void CutCreditIllust() +void CutCreditIllust(void) { Illust.act_no = 2; } @@ -437,8 +442,10 @@ void CutCreditIllust() // Scene of the island falling int Scene_DownIsland(HWND hWnd, int mode) { + int wait; + // Setup background - RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2}; + RECT rc_frame = {(WINDOW_WIDTH / 2) - 80, (WINDOW_HEIGHT / 2) - 40, (WINDOW_WIDTH / 2) + 80, (WINDOW_HEIGHT / 2) + 40}; RECT rc_sky = {0, 0, 160, 80}; RECT rc_ground = {160, 48, 320, 80}; @@ -446,10 +453,10 @@ int Scene_DownIsland(HWND hWnd, int mode) RECT rc_sprite = {160, 0, 200, 24}; ISLAND_SPRITE sprite; - sprite.x = 0x15000; - sprite.y = 0x8000; + sprite.x = 168 * 0x200; + sprite.y = 64 * 0x200; - for (int wait = 0; wait < 900; wait++) + for (wait = 0; wait < 900; ++wait) { // Get pressed keys GetTrg(); @@ -500,9 +507,9 @@ int Scene_DownIsland(HWND hWnd, int mode) // 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); + 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 / 0x200) - 12 + ((WINDOW_HEIGHT - 240) / 2), &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1); + PutBitmap3(&rc_frame, 80 + ((WINDOW_WIDTH - 320) / 2), 128 + ((WINDOW_HEIGHT - 240) / 2), &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1); PutTimeCounter(16, 8); // Draw window diff --git a/src/Ending.h b/src/Ending.h index 581f0481..54033793 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -37,19 +37,19 @@ struct ISLAND_SPRITE #define MAX_STRIP ((WINDOW_HEIGHT / 16) + 1) -void ActionStripper(); -void PutStripper(); +void ActionStripper(void); +void PutStripper(void); void SetStripper(int x, int y, const char *text, int cast); -void RestoreStripper(); -void ActionIllust(); -void PutIllust(); +void RestoreStripper(void); +void ActionIllust(void); +void PutIllust(void); void ReloadIllust(int a); -void InitCreditScript(); -void ReleaseCreditScript(); -BOOL StartCreditScript(); -void ActionCredit(); -void ActionCredit_Read(); +void InitCreditScript(void); +void ReleaseCreditScript(void); +BOOL StartCreditScript(void); +void ActionCredit(void); +void ActionCredit_Read(void); int GetScriptNumber(const char *text); void SetCreditIllust(int a); -void CutCreditIllust(); +void CutCreditIllust(void); int Scene_DownIsland(HWND hWnd, int mode);