diff options
| author | fig02 <fig02srl@gmail.com> | 2022-08-15 09:39:06 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-15 09:39:06 -0400 |
| commit | fec5cd84aff63ef1872587385c8f49e8c81faa0c (patch) | |
| tree | c2fe8d7788a49a0586c1adac97695d810f3f8cec /src/code/shrink_window.c | |
| parent | dda78f9e2c05e0a982731fbc7254fcef68334142 (diff) | |
Doc shrink_window, rename system to Letterbox (#1341)
* docs
* missed some hex
* document Gfx_SetupFrame
* review
Diffstat (limited to 'src/code/shrink_window.c')
| -rw-r--r-- | src/code/shrink_window.c | 91 |
1 files changed, 51 insertions, 40 deletions
diff --git a/src/code/shrink_window.c b/src/code/shrink_window.c index cc68129e2..8232ee838 100644 --- a/src/code/shrink_window.c +++ b/src/code/shrink_window.c @@ -1,79 +1,89 @@ #include "global.h" -s32 D_8012CED0 = 0; +typedef enum { + /* 0 */ LETTERBOX_STATE_IDLE, + /* 1 */ LETTERBOX_STATE_GROWING, + /* 2 */ LETTERBOX_STATE_SHRINKING +} LetterboxState; -s32 sShrinkWindowVal = 0; -s32 sShrinkWindowCurrentVal = 0; +s32 sLetterboxState = LETTERBOX_STATE_IDLE; -void ShrinkWindow_SetVal(s32 value) { +s32 sLetterboxSizeTarget = 0; +s32 sLetterboxSize = 0; + +void Letterbox_SetSizeTarget(s32 target) { if (HREG(80) == 0x13 && HREG(81) == 1) { - osSyncPrintf("shrink_window_setval(%d)\n", value); + osSyncPrintf("shrink_window_setval(%d)\n", target); } - sShrinkWindowVal = value; + + sLetterboxSizeTarget = target; } -u32 ShrinkWindow_GetVal(void) { - return sShrinkWindowVal; +u32 Letterbox_GetSizeTarget(void) { + return sLetterboxSizeTarget; } -void ShrinkWindow_SetCurrentVal(s32 currentVal) { +void Letterbox_SetSize(s32 size) { if (HREG(80) == 0x13 && HREG(81) == 1) { - osSyncPrintf("shrink_window_setnowval(%d)\n", currentVal); + osSyncPrintf("shrink_window_setnowval(%d)\n", size); } - sShrinkWindowCurrentVal = currentVal; + + sLetterboxSize = size; } -u32 ShrinkWindow_GetCurrentVal(void) { - return sShrinkWindowCurrentVal; +u32 Letterbox_GetSize(void) { + return sLetterboxSize; } -void ShrinkWindow_Init(void) { +void Letterbox_Init(void) { if (HREG(80) == 0x13 && HREG(81) == 1) { osSyncPrintf("shrink_window_init()\n"); } - D_8012CED0 = 0; - sShrinkWindowVal = 0; - sShrinkWindowCurrentVal = 0; + + sLetterboxState = LETTERBOX_STATE_IDLE; + sLetterboxSizeTarget = 0; + sLetterboxSize = 0; } -void ShrinkWindow_Destroy(void) { +void Letterbox_Destroy(void) { if (HREG(80) == 0x13 && HREG(81) == 1) { osSyncPrintf("shrink_window_cleanup()\n"); } - sShrinkWindowCurrentVal = 0; + + sLetterboxSize = 0; } -void ShrinkWindow_Update(s32 updateRate) { - s32 off; +void Letterbox_Update(s32 updateRate) { + s32 step; if (updateRate == 3) { - off = 10; + step = 10; } else { - off = 30 / updateRate; + step = 30 / updateRate; } - if (sShrinkWindowCurrentVal < sShrinkWindowVal) { - if (D_8012CED0 != 1) { - D_8012CED0 = 1; + if (sLetterboxSize < sLetterboxSizeTarget) { + if (sLetterboxState != LETTERBOX_STATE_GROWING) { + sLetterboxState = LETTERBOX_STATE_GROWING; } - if (sShrinkWindowCurrentVal + off < sShrinkWindowVal) { - sShrinkWindowCurrentVal += off; + if (sLetterboxSize + step < sLetterboxSizeTarget) { + sLetterboxSize += step; } else { - sShrinkWindowCurrentVal = sShrinkWindowVal; + sLetterboxSize = sLetterboxSizeTarget; } - } else if (sShrinkWindowVal < sShrinkWindowCurrentVal) { - if (D_8012CED0 != 2) { - D_8012CED0 = 2; + } else if (sLetterboxSizeTarget < sLetterboxSize) { + if (sLetterboxState != LETTERBOX_STATE_SHRINKING) { + sLetterboxState = LETTERBOX_STATE_SHRINKING; } - if (sShrinkWindowVal < sShrinkWindowCurrentVal - off) { - sShrinkWindowCurrentVal -= off; + if (sLetterboxSizeTarget < sLetterboxSize - step) { + sLetterboxSize -= step; } else { - sShrinkWindowCurrentVal = sShrinkWindowVal; + sLetterboxSize = sLetterboxSizeTarget; } } else { - D_8012CED0 = 0; + sLetterboxState = LETTERBOX_STATE_IDLE; } if (HREG(80) == 0x13) { @@ -89,9 +99,10 @@ void ShrinkWindow_Update(s32 updateRate) { HREG(88) = 0; HREG(89) = 0; } - HREG(83) = D_8012CED0; - HREG(84) = sShrinkWindowCurrentVal; - HREG(85) = sShrinkWindowVal; - HREG(86) = off; + + HREG(83) = sLetterboxState; + HREG(84) = sLetterboxSize; + HREG(85) = sLetterboxSizeTarget; + HREG(86) = step; } } |
