mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-02 07:46:01 +00:00
eb0a82c513
* progress * progress * change * named most * name prerender things * fix and format * play prefix * address most comments (still a few more things to do) * fix error * reword input test comments * some more * rework env draw flags * add hilite * merge and format * init to proper values * rename env draw flag names * 7 to 6 * more small changes
110 lines
2.9 KiB
C
110 lines
2.9 KiB
C
#include "global.h"
|
|
|
|
typedef enum {
|
|
/* 0 */ LETTERBOX_STATE_IDLE,
|
|
/* 1 */ LETTERBOX_STATE_GROWING,
|
|
/* 2 */ LETTERBOX_STATE_SHRINKING
|
|
} LetterboxState;
|
|
|
|
s32 sLetterboxState = LETTERBOX_STATE_IDLE;
|
|
|
|
s32 sLetterboxSizeTarget = 0;
|
|
s32 sLetterboxSize = 0;
|
|
|
|
void Letterbox_SetSizeTarget(s32 target) {
|
|
if (R_HREG_MODE == HREG_MODE_LETTERBOX && R_LETTERBOX_ENABLE_LOGS == 1) {
|
|
osSyncPrintf("shrink_window_setval(%d)\n", target);
|
|
}
|
|
|
|
sLetterboxSizeTarget = target;
|
|
}
|
|
|
|
u32 Letterbox_GetSizeTarget(void) {
|
|
return sLetterboxSizeTarget;
|
|
}
|
|
|
|
void Letterbox_SetSize(s32 size) {
|
|
if (R_HREG_MODE == HREG_MODE_LETTERBOX && R_LETTERBOX_ENABLE_LOGS == 1) {
|
|
osSyncPrintf("shrink_window_setnowval(%d)\n", size);
|
|
}
|
|
|
|
sLetterboxSize = size;
|
|
}
|
|
|
|
u32 Letterbox_GetSize(void) {
|
|
return sLetterboxSize;
|
|
}
|
|
|
|
void Letterbox_Init(void) {
|
|
if (R_HREG_MODE == HREG_MODE_LETTERBOX && R_LETTERBOX_ENABLE_LOGS == 1) {
|
|
osSyncPrintf("shrink_window_init()\n");
|
|
}
|
|
|
|
sLetterboxState = LETTERBOX_STATE_IDLE;
|
|
sLetterboxSizeTarget = 0;
|
|
sLetterboxSize = 0;
|
|
}
|
|
|
|
void Letterbox_Destroy(void) {
|
|
if (R_HREG_MODE == HREG_MODE_LETTERBOX && R_LETTERBOX_ENABLE_LOGS == 1) {
|
|
osSyncPrintf("shrink_window_cleanup()\n");
|
|
}
|
|
|
|
sLetterboxSize = 0;
|
|
}
|
|
|
|
void Letterbox_Update(s32 updateRate) {
|
|
s32 step;
|
|
|
|
if (updateRate == 3) {
|
|
step = 10;
|
|
} else {
|
|
step = 30 / updateRate;
|
|
}
|
|
|
|
if (sLetterboxSize < sLetterboxSizeTarget) {
|
|
if (sLetterboxState != LETTERBOX_STATE_GROWING) {
|
|
sLetterboxState = LETTERBOX_STATE_GROWING;
|
|
}
|
|
|
|
if (sLetterboxSize + step < sLetterboxSizeTarget) {
|
|
sLetterboxSize += step;
|
|
} else {
|
|
sLetterboxSize = sLetterboxSizeTarget;
|
|
}
|
|
} else if (sLetterboxSizeTarget < sLetterboxSize) {
|
|
if (sLetterboxState != LETTERBOX_STATE_SHRINKING) {
|
|
sLetterboxState = LETTERBOX_STATE_SHRINKING;
|
|
}
|
|
|
|
if (sLetterboxSizeTarget < sLetterboxSize - step) {
|
|
sLetterboxSize -= step;
|
|
} else {
|
|
sLetterboxSize = sLetterboxSizeTarget;
|
|
}
|
|
} else {
|
|
sLetterboxState = LETTERBOX_STATE_IDLE;
|
|
}
|
|
|
|
if (R_HREG_MODE == HREG_MODE_LETTERBOX) {
|
|
if (R_LETTERBOX_INIT != HREG_MODE_LETTERBOX) {
|
|
R_LETTERBOX_INIT = HREG_MODE_LETTERBOX;
|
|
R_LETTERBOX_ENABLE_LOGS = 0;
|
|
HREG(82) = 0; // this reg is not used in this mode
|
|
R_LETTERBOX_STATE = 0;
|
|
R_LETTERBOX_SIZE = 0;
|
|
R_LETTERBOX_TARGET_SIZE = 0;
|
|
R_LETTERBOX_STEP = 0;
|
|
|
|
// these regs are not used in this mode
|
|
HREG(87) = 0;
|
|
HREG(88) = 0;
|
|
HREG(89) = 0;
|
|
}
|
|
|
|
R_LETTERBOX_STATE = sLetterboxState;
|
|
R_LETTERBOX_SIZE = sLetterboxSize;
|
|
R_LETTERBOX_TARGET_SIZE = sLetterboxSizeTarget;
|
|
R_LETTERBOX_STEP = step;
|
|
}
|
|
}
|