From 55b473a4901321ecd9506fbab6734b4bc3269d36 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 14 Sep 2020 17:01:00 +0100 Subject: [PATCH] Document Flash.cpp some more --- src/BossAlmo2.cpp | 2 +- src/BossBallos.cpp | 2 +- src/BossOhm.cpp | 3 ++- src/BossTwinD.cpp | 2 +- src/BossX.cpp | 2 +- src/Flash.cpp | 21 +++++++++++++-------- src/Flash.h | 8 +++++++- src/NpcAct060.cpp | 2 +- src/NpcAct080.cpp | 2 +- src/NpcAct140.cpp | 2 +- src/NpcAct340.cpp | 4 ++-- src/TextScr.cpp | 2 +- 12 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/BossAlmo2.cpp b/src/BossAlmo2.cpp index 22ab1804..59367fb2 100644 --- a/src/BossAlmo2.cpp +++ b/src/BossAlmo2.cpp @@ -649,7 +649,7 @@ void ActBossChar_Undead(void) { gBoss[0].act_wait = 0; gBoss[0].act_no = 1001; - SetFlash(gBoss[0].x, gBoss[0].y, 1); + SetFlash(gBoss[0].x, gBoss[0].y, FLASH_MODE_EXPLOSION); PlaySoundObject(35, SOUND_MODE_PLAY); } diff --git a/src/BossBallos.cpp b/src/BossBallos.cpp index 2cc1d5a4..467ce2ce 100644 --- a/src/BossBallos.cpp +++ b/src/BossBallos.cpp @@ -656,7 +656,7 @@ void ActBossChar_Ballos(void) { gBoss[0].act_wait = 0; gBoss[0].act_no = 1002; - SetFlash(gBoss[0].x, gBoss[0].y, 1); + SetFlash(gBoss[0].x, gBoss[0].y, FLASH_MODE_EXPLOSION); PlaySoundObject(35, SOUND_MODE_PLAY); } diff --git a/src/BossOhm.cpp b/src/BossOhm.cpp index d09121a3..a04bbf98 100644 --- a/src/BossOhm.cpp +++ b/src/BossOhm.cpp @@ -1,3 +1,4 @@ + #include "BossOhm.h" #include @@ -470,7 +471,7 @@ void ActBossChar_Omega(void) { gBoss[0].act_wait = 0; gBoss[0].act_no = 160; - SetFlash(gBoss[0].x, gBoss[0].y, 1); + SetFlash(gBoss[0].x, gBoss[0].y, FLASH_MODE_EXPLOSION); PlaySoundObject(35, SOUND_MODE_PLAY); } diff --git a/src/BossTwinD.cpp b/src/BossTwinD.cpp index 5b7ccda0..0228ebc4 100644 --- a/src/BossTwinD.cpp +++ b/src/BossTwinD.cpp @@ -517,7 +517,7 @@ void ActBossChar_Twin(void) { npc->act_no = 1020; npc->act_wait = 0; - SetFlash(gBoss[0].x, gBoss[0].y, 1); + SetFlash(gBoss[0].x, gBoss[0].y, FLASH_MODE_EXPLOSION); PlaySoundObject(35, SOUND_MODE_PLAY); } diff --git a/src/BossX.cpp b/src/BossX.cpp index c3057617..ed6c8abb 100644 --- a/src/BossX.cpp +++ b/src/BossX.cpp @@ -844,7 +844,7 @@ void ActBossChar_MonstX(void) { npc->act_wait = 0; npc->act_no = 1001; - SetFlash(npc->x, npc->y, 1); + SetFlash(npc->x, npc->y, FLASH_MODE_EXPLOSION); PlaySoundObject(35, SOUND_MODE_PLAY); } diff --git a/src/Flash.cpp b/src/Flash.cpp index 6fa82709..786ef2ee 100644 --- a/src/Flash.cpp +++ b/src/Flash.cpp @@ -6,7 +6,7 @@ static struct { - int mode; + FlashMode mode; int act_no; BOOL flag; int cnt; @@ -24,7 +24,7 @@ void InitFlash(void) gFlashColor = GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE)); } -void SetFlash(int x, int y, int mode) +void SetFlash(int x, int y, FlashMode mode) { flash.act_no = 0; flash.flag = TRUE; @@ -41,7 +41,7 @@ void ActFlash_Explosion(int flx, int fly) switch (flash.act_no) { - case 0: + case 0: // Expand flash.cnt += 0x200; flash.width += flash.cnt; @@ -59,26 +59,28 @@ void ActFlash_Explosion(int flx, int fly) if (bottom > WINDOW_HEIGHT) bottom = WINDOW_HEIGHT; + // The tall part of the explosion flash.rect1.left = left; flash.rect1.right = right; flash.rect1.top = 0; flash.rect1.bottom = WINDOW_HEIGHT; + // The wide part of the explosion flash.rect2.left = 0; flash.rect2.right = WINDOW_WIDTH; flash.rect2.top = top; flash.rect2.bottom = bottom; - if (flash.width > (WINDOW_WIDTH * 0x200 * 4)) + if (flash.width > WINDOW_WIDTH * 0x200 * 4) // I guess in theory this means that the explosion would take longer in widescreen... { flash.act_no = 1; flash.cnt = 0; - flash.width = (WINDOW_HEIGHT * 0x200); + flash.width = WINDOW_HEIGHT * 0x200; } break; - case 1: + case 1: // Shrink flash.width -= flash.width / 8; if ((flash.width / 0x100) == 0) @@ -92,11 +94,13 @@ void ActFlash_Explosion(int flx, int fly) if (bottom > WINDOW_HEIGHT) bottom = WINDOW_HEIGHT; + // The tall part of the explosion flash.rect1.left = 0; flash.rect1.right = 0; flash.rect1.top = 0; flash.rect1.bottom = 0; + // The wide part of the explosion flash.rect2.top = top; flash.rect2.bottom = bottom; flash.rect2.left = 0; @@ -141,10 +145,11 @@ void ActFlash(int flx, int fly) switch (flash.mode) { - case 1: + case FLASH_MODE_EXPLOSION: ActFlash_Explosion(flx, fly); break; - case 2: + + case FLASH_MODE_FLASH: ActFlash_Flash(); break; } diff --git a/src/Flash.h b/src/Flash.h index c31aa598..1a636d72 100644 --- a/src/Flash.h +++ b/src/Flash.h @@ -1,9 +1,15 @@ #pragma once +enum FlashMode +{ + FLASH_MODE_EXPLOSION = 1, + FLASH_MODE_FLASH = 2 +}; + extern unsigned long gFlashColor; void InitFlash(void); -void SetFlash(int x, int y, int mode); +void SetFlash(int x, int y, FlashMode mode); void ActFlash_Explosion(int flx, int fly); void ActFlash_Flash(void); void ActFlash(int flx, int fly); diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index d3a6ac7a..6fdc641d 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -1001,7 +1001,7 @@ void ActNpc067(NPCHAR *npc) if (++npc->act_wait == 30) { PlaySoundObject(101, SOUND_MODE_PLAY); - SetFlash(0, 0, 2); + SetFlash(0, 0, FLASH_MODE_FLASH); npc->act_no = 27; npc->ani_no = 7; } diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index 29020e6b..8f495793 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -389,7 +389,7 @@ void ActNpc082(NPCHAR *npc) if (++npc->act_wait == 30) { PlaySoundObject(101, SOUND_MODE_PLAY); - SetFlash(0, 0, 2); + SetFlash(0, 0, FLASH_MODE_FLASH); npc->act_no = 27; npc->ani_no = 7; } diff --git a/src/NpcAct140.cpp b/src/NpcAct140.cpp index 68fc4389..d01f3e37 100644 --- a/src/NpcAct140.cpp +++ b/src/NpcAct140.cpp @@ -728,7 +728,7 @@ void ActNpc146(NPCHAR *npc) npc->act_no = 1; if (npc->direct == 2) - SetFlash(0, 0, 2); + SetFlash(0, 0, FLASH_MODE_FLASH); // Fallthrough case 1: if (++npc->act_wait > 10) diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp index 6fbd8800..7d95a88b 100644 --- a/src/NpcAct340.cpp +++ b/src/NpcAct340.cpp @@ -432,7 +432,7 @@ void ActNpc340(NPCHAR *npc) npc->direct = 2; if (++npc->act_wait == 40) - SetFlash(0, 0, 2); + SetFlash(0, 0, FLASH_MODE_FLASH); if (npc->act_wait > 50 && npc->act_wait % 10 == 1) { @@ -513,7 +513,7 @@ void ActNpc340(NPCHAR *npc) npc->ym = 0; npc->act_no = 1005; npc->act_wait = 0; - SetFlash(0, 0, 2); + SetFlash(0, 0, FLASH_MODE_FLASH); PlaySoundObject(29, SOUND_MODE_PLAY); } diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 76316012..2f570ba0 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -1032,7 +1032,7 @@ int TextScriptProc(void) } else if (IS_COMMAND('F','L','A')) { - SetFlash(0, 0, 2); + SetFlash(0, 0, FLASH_MODE_FLASH); gTS.p_read += 4; } else if (IS_COMMAND('F','A','I'))