2021-04-13 09:47:52 +02:00
|
|
|
#include "common.h"
|
2022-02-19 15:39:34 +01:00
|
|
|
#include "nu/nusys.h"
|
|
|
|
#include "hud_element.h"
|
|
|
|
#include "sprite.h"
|
2023-09-16 05:53:00 +02:00
|
|
|
#include "game_modes.h"
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2023-02-17 03:06:56 +01:00
|
|
|
#if VERSION_JP
|
|
|
|
#define TITLE_WIDTH 272
|
|
|
|
#define TITLE_TILE_HEIGHT 2
|
|
|
|
#define TITLE_HEIGHT 88
|
|
|
|
#define TITLE_POS_LEFT 25
|
|
|
|
#define TITLE_POS_TOP 34
|
|
|
|
#define FILENAME_ERROR "\x54\x77\xA2\xF7\xF7\xf7\xf7\xf7"
|
|
|
|
#else
|
2022-02-19 15:39:34 +01:00
|
|
|
// Properties of the title screen Paper Mario logo
|
|
|
|
#define TITLE_WIDTH 200 // Width of the texture
|
|
|
|
#define TITLE_HEIGHT 112 // Height of the texture
|
|
|
|
#define TITLE_TILE_HEIGHT 2 // Height of an individually loaded tile in the texture
|
|
|
|
#define TITLE_POS_LEFT ((SCREEN_WIDTH - TITLE_WIDTH) / 2) // Left edge of the texture on screen
|
|
|
|
#define TITLE_POS_TOP 15 // Top edge of the texture on screen (with no offset)
|
2023-02-17 03:06:56 +01:00
|
|
|
#define FILENAME_ERROR "ERROR\xf7\xf7\xf7"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TITLE_NUM_TILES (TITLE_HEIGHT / TITLE_TILE_HEIGHT) // Number of tiles in the texture
|
|
|
|
#define TITLE_TILE_PIXELS (TITLE_WIDTH * TITLE_TILE_HEIGHT) // Number of pixels in a single tile of the texture
|
2021-04-23 13:55:30 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
|
|
|
|
enum TitleScreenStates {
|
|
|
|
TITLE_STATE_INIT = 0x00000000,
|
|
|
|
TITLE_STATE_APPEAR = 0x00000001,
|
|
|
|
TITLE_STATE_HOLD = 0x00000002, // show the title screen with PRESS START blinking
|
|
|
|
TITLE_STATE_UNUSED = 0x00000003,
|
|
|
|
TITLE_STATE_BEGIN_DISMISS = 0x00000004,
|
|
|
|
TITLE_STATE_DISMISS = 0x00000005,
|
|
|
|
TITLE_STATE_EXIT = 0x00000006,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NEXT_STATE_DEMO = 10,
|
|
|
|
NEXT_STATE_INTRO = 9,
|
|
|
|
NEXT_STATE_FILE_SELECT = 5,
|
|
|
|
NEXT_STATE_NONE = 0, // used only for the initial value
|
|
|
|
};
|
|
|
|
|
|
|
|
s16 TitleScreenNextState = NEXT_STATE_NONE;
|
2022-04-05 14:53:40 +02:00
|
|
|
|
|
|
|
SaveMetadata gSaveSlotMetadata[4] = {
|
2023-10-14 21:43:12 +02:00
|
|
|
{ .filename = { FILENAME_ERROR } },
|
|
|
|
{ .filename = { FILENAME_ERROR } },
|
|
|
|
{ .filename = { FILENAME_ERROR } },
|
|
|
|
{ .filename = { FILENAME_ERROR } },
|
2022-04-05 14:53:40 +02:00
|
|
|
};
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
u8 gSaveSlotHasData[4] = { TRUE, TRUE, TRUE, TRUE };
|
2023-03-28 07:42:44 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
s32 PressStart_Alpha = 0; // the opacity of "PRESS START" text
|
|
|
|
b32 PressStart_IsVisible = FALSE; // toggles the visibility of "PRESS START"
|
|
|
|
s32 PressStart_BlinkCounter = 0; // counts to 16, then toggles PressStart_IsVisible
|
2023-03-28 07:42:44 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
// controls whether the intro story or the demo will player after TITLE_STATE_HOLD is done
|
|
|
|
// since this state is reached for the first time after the intro has already played once or was skipped,
|
|
|
|
// this is initially false and the demo is will play first.
|
|
|
|
s32 PlayIntroNext = FALSE;
|
2022-02-19 15:39:34 +01:00
|
|
|
|
2022-06-09 01:36:32 +02:00
|
|
|
Lights1 D_80077A38 = gdSPDefLights1(255, 255, 255, 0, 0, 0, 0, 0, 0);
|
2022-02-19 15:39:34 +01:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
Gfx TitleSetupGfx[] = {
|
2021-04-23 13:55:30 +02:00
|
|
|
gsDPPipeSync(),
|
|
|
|
gsDPSetCycleType(G_CYC_1CYCLE),
|
|
|
|
gsDPSetRenderMode(G_RM_CLD_SURF, G_RM_CLD_SURF2),
|
|
|
|
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
|
|
|
|
gsDPSetTextureFilter(G_TF_POINT),
|
2021-08-16 20:14:58 +02:00
|
|
|
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
2021-04-23 13:55:30 +02:00
|
|
|
gsDPSetTexturePersp(G_TP_NONE),
|
|
|
|
gsDPSetColorDither(G_CD_DISABLE),
|
|
|
|
gsDPSetAlphaDither(G_AD_DISABLE),
|
|
|
|
gsDPSetTextureLOD(G_TL_TILE),
|
|
|
|
gsDPSetTextureLUT(G_TT_NONE),
|
|
|
|
gsDPSetTextureDetail(G_TD_CLAMP),
|
|
|
|
gsDPSetTextureConvert(G_TC_FILT),
|
|
|
|
gsDPSetCombineKey(G_CK_NONE),
|
|
|
|
gsDPSetAlphaCompare(G_AC_NONE),
|
|
|
|
gsDPNoOp(),
|
2021-07-22 20:48:30 +02:00
|
|
|
gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
|
2021-04-23 13:55:30 +02:00
|
|
|
gsSPEndDisplayList(),
|
|
|
|
};
|
|
|
|
|
2022-02-19 15:39:34 +01:00
|
|
|
typedef struct TitleDataStruct {
|
2023-03-28 07:42:44 +02:00
|
|
|
/* 0x0 */ s32 logo;
|
|
|
|
/* 0x4 */ s32 copyright;
|
|
|
|
/* 0x8 */ s32 pressStart;
|
|
|
|
/* 0xC */ s32 copyrightPalette;
|
2023-02-17 03:06:56 +01:00
|
|
|
} TitleDataStruct; // size = 0x10
|
2022-02-19 15:39:34 +01:00
|
|
|
|
2023-05-01 19:51:52 +02:00
|
|
|
#if VERSION_JP
|
|
|
|
#define COPYRIGHT_WIDTH 128
|
|
|
|
#else
|
|
|
|
#define COPYRIGHT_WIDTH 144
|
|
|
|
#endif
|
|
|
|
|
2024-03-05 11:54:53 +01:00
|
|
|
BSS s16 TitleScreen_AppearDelay;
|
|
|
|
BSS TitleDataStruct* TitleScreen_ImgList;
|
|
|
|
BSS s32* TitleScreen_ImgList_Logo;
|
|
|
|
BSS u8 (*TitleScreen_ImgList_Copyright)[COPYRIGHT_WIDTH];
|
|
|
|
BSS s32* TitleScreen_ImgList_PressStart;
|
|
|
|
BSS s32* TitleScreen_ImgList_CopyrightPalette;
|
|
|
|
BSS s16 TitleScreen_TimeLeft;
|
2022-02-19 15:39:34 +01:00
|
|
|
|
|
|
|
void appendGfx_title_screen(void);
|
|
|
|
void draw_title_screen_NOP(void);
|
|
|
|
void title_screen_draw_images(f32, f32);
|
|
|
|
void title_screen_draw_logo(f32);
|
|
|
|
void title_screen_draw_press_start(void);
|
|
|
|
void title_screen_draw_copyright(f32);
|
|
|
|
|
|
|
|
void state_init_title_screen(void) {
|
|
|
|
s32 titleDataSize;
|
|
|
|
void* titleDataDst;
|
|
|
|
void* titleData;
|
|
|
|
|
|
|
|
gOverrideFlags = 0;
|
|
|
|
timeFreezeMode = 0;
|
2023-06-29 14:06:23 +02:00
|
|
|
D_8014C248 = TRUE;
|
2022-02-19 15:39:34 +01:00
|
|
|
general_heap_create();
|
|
|
|
clear_printers();
|
2022-12-06 00:29:22 +01:00
|
|
|
sfx_set_reverb_mode(0);
|
2023-10-14 21:43:12 +02:00
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_INIT;
|
|
|
|
gGameStatusPtr->logoTime = 0;
|
2022-02-19 15:39:34 +01:00
|
|
|
gGameStatusPtr->isBattle = FALSE;
|
2023-10-14 21:43:12 +02:00
|
|
|
gGameStatusPtr->introPart = INTRO_PART_NONE;
|
|
|
|
startup_fade_screen_update();
|
2022-02-19 15:39:34 +01:00
|
|
|
titleData = load_asset_by_name("title_data", &titleDataSize);
|
2023-03-28 07:42:44 +02:00
|
|
|
titleDataDst = TitleScreen_ImgList = heap_malloc(titleDataSize);
|
2022-02-19 15:39:34 +01:00
|
|
|
decode_yay0(titleData, titleDataDst);
|
|
|
|
general_heap_free(titleData);
|
|
|
|
|
2023-03-28 07:42:44 +02:00
|
|
|
TitleScreen_ImgList_Logo = (s32*)(TitleScreen_ImgList->logo + (s32) TitleScreen_ImgList);
|
2023-05-01 19:51:52 +02:00
|
|
|
TitleScreen_ImgList_Copyright = (u8 (*)[COPYRIGHT_WIDTH]) ((s32*)(TitleScreen_ImgList->copyright + (s32) TitleScreen_ImgList));
|
2023-03-28 07:42:44 +02:00
|
|
|
TitleScreen_ImgList_PressStart = (s32*)(TitleScreen_ImgList->pressStart + (s32) TitleScreen_ImgList);
|
2023-02-17 03:06:56 +01:00
|
|
|
#if VERSION_JP
|
2023-03-28 07:42:44 +02:00
|
|
|
TitleScreen_ImgList_CopyrightPalette = (s32*)(TitleScreen_ImgList->copyrightPalette + (s32) TitleScreen_ImgList);
|
2023-02-17 03:06:56 +01:00
|
|
|
#endif
|
2022-02-19 15:39:34 +01:00
|
|
|
|
|
|
|
create_cameras_a();
|
2023-03-02 09:32:54 +01:00
|
|
|
gCameras[CAM_DEFAULT].updateMode = CAM_UPDATE_MODE_6;
|
2023-04-20 10:15:58 +02:00
|
|
|
gCameras[CAM_DEFAULT].needsInit = TRUE;
|
2022-10-01 03:44:48 +02:00
|
|
|
gCameras[CAM_DEFAULT].nearClip = CAM_NEAR_CLIP;
|
|
|
|
gCameras[CAM_DEFAULT].farClip = CAM_FAR_CLIP;
|
2022-02-19 15:39:34 +01:00
|
|
|
gCurrentCameraID = CAM_DEFAULT;
|
|
|
|
gCameras[CAM_DEFAULT].vfov = 25.0f;
|
2023-04-20 10:15:58 +02:00
|
|
|
gCameras[CAM_DEFAULT].flags |= CAMERA_FLAG_DISABLED;
|
|
|
|
gCameras[CAM_BATTLE].flags |= CAMERA_FLAG_DISABLED;
|
|
|
|
gCameras[CAM_TATTLE].flags |= CAMERA_FLAG_DISABLED;
|
|
|
|
gCameras[CAM_3].flags |= CAMERA_FLAG_DISABLED;
|
2023-10-14 21:43:12 +02:00
|
|
|
set_cam_viewport(CAM_DEFAULT, 12, 28, 296, 184);
|
2022-04-05 11:52:06 +02:00
|
|
|
gCameras[CAM_DEFAULT].auxBoomLength = 40;
|
2022-02-19 15:39:34 +01:00
|
|
|
gCameras[CAM_DEFAULT].bgColor[0] = 0;
|
|
|
|
gCameras[CAM_DEFAULT].bgColor[1] = 0;
|
|
|
|
gCameras[CAM_DEFAULT].bgColor[2] = 0;
|
2022-10-01 03:44:48 +02:00
|
|
|
gCameras[CAM_DEFAULT].lookAt_obj_target.x = 25.0f;
|
|
|
|
gCameras[CAM_DEFAULT].lookAt_obj_target.y = 25.0f;
|
|
|
|
gCameras[CAM_DEFAULT].auxPitch = 0;
|
|
|
|
gCameras[CAM_DEFAULT].lookAt_dist = 100;
|
2022-04-05 11:52:06 +02:00
|
|
|
gCameras[CAM_DEFAULT].auxBoomPitch = 0;
|
2022-02-19 15:39:34 +01:00
|
|
|
gCameras[CAM_DEFAULT].lookAt_eye.x = 500.0f;
|
|
|
|
gCameras[CAM_DEFAULT].lookAt_eye.y = 1000.0f;
|
|
|
|
gCameras[CAM_DEFAULT].lookAt_eye.z = 1500.0f;
|
2022-10-01 03:44:48 +02:00
|
|
|
gCameras[CAM_DEFAULT].lookAt_obj_target.z = 150.0f;
|
2022-02-19 15:39:34 +01:00
|
|
|
clear_script_list();
|
2022-11-22 05:12:28 +01:00
|
|
|
clear_worker_list();
|
2022-02-19 15:39:34 +01:00
|
|
|
clear_render_tasks();
|
2022-11-22 05:12:28 +01:00
|
|
|
spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD);
|
2022-02-19 15:39:34 +01:00
|
|
|
clear_animator_list();
|
|
|
|
clear_entity_models();
|
|
|
|
clear_npcs();
|
2022-03-26 12:47:10 +01:00
|
|
|
hud_element_clear_cache();
|
2022-02-19 15:39:34 +01:00
|
|
|
reset_background_settings();
|
2023-10-14 21:43:12 +02:00
|
|
|
clear_entity_data(TRUE);
|
2022-02-19 15:39:34 +01:00
|
|
|
clear_effect_data();
|
|
|
|
gOverrideFlags |= GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
|
|
|
|
clear_player_data();
|
2023-10-14 21:43:12 +02:00
|
|
|
gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
|
2022-02-19 15:39:34 +01:00
|
|
|
game_mode_set_fpDrawAuxUI(0, appendGfx_title_screen);
|
|
|
|
load_map_bg("title_bg");
|
2023-11-24 05:06:58 +01:00
|
|
|
set_background(&gBackgroundImage);
|
2022-02-19 15:39:34 +01:00
|
|
|
bgm_set_song(0, SONG_MAIN_THEME, 0, 500, 8);
|
2023-10-14 21:43:12 +02:00
|
|
|
TitleScreen_TimeLeft = 480;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void state_step_title_screen(void) {
|
2023-10-14 21:43:12 +02:00
|
|
|
s32 temp;
|
2022-06-13 18:34:22 +02:00
|
|
|
u32 pressedButtons = gGameStatusPtr->pressedButtons[0];
|
2022-02-19 15:39:34 +01:00
|
|
|
|
|
|
|
set_curtain_scale(1.0f);
|
|
|
|
set_curtain_fade(0.0f);
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
if (TitleScreen_TimeLeft > 0) {
|
|
|
|
TitleScreen_TimeLeft--;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
switch (gGameStatusPtr->startupState) {
|
|
|
|
case TITLE_STATE_INIT:
|
|
|
|
TitleScreen_AppearDelay = 3;
|
|
|
|
gOverrideFlags |= GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
|
|
|
|
gGameStatusPtr->titleScreenDismissTime = 20;
|
|
|
|
gGameStatusPtr->titleScreenTimer = gGameStatusPtr->titleScreenDismissTime;
|
|
|
|
gGameStatusPtr->startupState++;
|
2022-02-19 15:39:34 +01:00
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_APPEAR:
|
|
|
|
if (TitleScreen_AppearDelay != 0) {
|
|
|
|
TitleScreen_AppearDelay--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (gGameStatusPtr->titleScreenTimer != 0) {
|
|
|
|
gGameStatusPtr->titleScreenTimer--;
|
|
|
|
}
|
|
|
|
gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
|
|
|
|
if (startup_fade_screen_in(6) != 0) {
|
|
|
|
if (gGameStatusPtr->titleScreenTimer == 0) {
|
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_HOLD;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
|
|
|
}
|
2023-10-14 21:43:12 +02:00
|
|
|
startup_fade_screen_update();
|
2022-02-19 15:39:34 +01:00
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_HOLD:
|
|
|
|
if (PlayIntroNext && TitleScreen_TimeLeft == 120) {
|
2022-02-19 15:39:34 +01:00
|
|
|
bgm_set_song(0, -1, 0, 3900, 8);
|
|
|
|
}
|
2023-10-14 21:43:12 +02:00
|
|
|
if (TitleScreen_TimeLeft == 0) {
|
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_BEGIN_DISMISS;
|
|
|
|
if (!PlayIntroNext) {
|
|
|
|
TitleScreenNextState = NEXT_STATE_DEMO;
|
2022-02-19 15:39:34 +01:00
|
|
|
} else {
|
2023-10-14 21:43:12 +02:00
|
|
|
TitleScreenNextState = NEXT_STATE_INTRO;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
2023-10-14 21:43:12 +02:00
|
|
|
PlayIntroNext ^= 1;
|
2022-02-19 15:39:34 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (pressedButtons & (BUTTON_A | BUTTON_START)) {
|
2023-10-14 21:43:12 +02:00
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_BEGIN_DISMISS;
|
|
|
|
TitleScreenNextState = NEXT_STATE_FILE_SELECT;
|
2023-08-05 07:24:23 +02:00
|
|
|
sfx_play_sound(SOUND_FILE_MENU_IN);
|
2022-02-19 15:39:34 +01:00
|
|
|
bgm_set_song(0, SONG_FILE_SELECT, 0, 500, 8);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_BEGIN_DISMISS:
|
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_DISMISS;
|
|
|
|
startup_set_fade_screen_color(208);
|
|
|
|
if (TitleScreenNextState == NEXT_STATE_INTRO || TitleScreenNextState == NEXT_STATE_DEMO) {
|
|
|
|
gGameStatusPtr->titleScreenDismissTime = 20;
|
2022-02-19 15:39:34 +01:00
|
|
|
} else {
|
2023-10-14 21:43:12 +02:00
|
|
|
gGameStatusPtr->titleScreenDismissTime = 10;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
2023-10-14 21:43:12 +02:00
|
|
|
gGameStatusPtr->titleScreenTimer = gGameStatusPtr->titleScreenDismissTime;
|
2022-02-19 15:39:34 +01:00
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_DISMISS:
|
|
|
|
if (TitleScreenNextState == NEXT_STATE_INTRO || TitleScreenNextState == NEXT_STATE_DEMO) {
|
|
|
|
if (gGameStatusPtr->titleScreenTimer != 0) {
|
|
|
|
gGameStatusPtr->titleScreenTimer--;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
2023-10-14 21:43:12 +02:00
|
|
|
if (startup_fade_screen_out(10) != 0) {
|
|
|
|
if (gGameStatusPtr->titleScreenTimer == 0) {
|
|
|
|
gGameStatusPtr->titleScreenTimer = 3;
|
|
|
|
gOverrideFlags |= GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
|
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_EXIT;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
|
|
|
}
|
2023-10-14 21:43:12 +02:00
|
|
|
startup_fade_screen_update();
|
|
|
|
} else if (TitleScreenNextState == NEXT_STATE_FILE_SELECT) {
|
|
|
|
if (gGameStatusPtr->titleScreenTimer == 0) {
|
|
|
|
gGameStatusPtr->titleScreenTimer = 3;
|
|
|
|
gOverrideFlags |= GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
|
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_EXIT;
|
2022-02-19 15:39:34 +01:00
|
|
|
} else {
|
2023-10-14 21:43:12 +02:00
|
|
|
gGameStatusPtr->titleScreenTimer--;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
|
|
|
} else {
|
2023-10-14 21:43:12 +02:00
|
|
|
gGameStatusPtr->titleScreenTimer = 3;
|
|
|
|
gOverrideFlags |= GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
|
|
|
|
gGameStatusPtr->startupState = TITLE_STATE_EXIT;
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_EXIT:
|
|
|
|
if (gGameStatusPtr->titleScreenTimer != 0) {
|
|
|
|
gGameStatusPtr->titleScreenTimer--;
|
2022-02-19 15:39:34 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
general_heap_create();
|
|
|
|
clear_render_tasks();
|
|
|
|
create_cameras_a();
|
|
|
|
clear_entity_models();
|
|
|
|
clear_animator_list();
|
|
|
|
clear_npcs();
|
2022-03-26 12:47:10 +01:00
|
|
|
hud_element_clear_cache();
|
2022-11-22 05:12:28 +01:00
|
|
|
spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD);
|
2023-10-14 21:43:12 +02:00
|
|
|
clear_entity_data(TRUE);
|
2022-02-19 15:39:34 +01:00
|
|
|
clear_windows();
|
2023-10-14 21:43:12 +02:00
|
|
|
gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
|
2022-02-19 15:39:34 +01:00
|
|
|
gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
|
|
|
|
gGameStatusPtr->entryID = 0;
|
2021-04-23 13:55:30 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
switch (TitleScreenNextState) {
|
|
|
|
case NEXT_STATE_INTRO:
|
|
|
|
gGameStatusPtr->introPart = INTRO_PART_0;
|
2022-02-19 15:39:34 +01:00
|
|
|
set_game_mode(GAME_MODE_INTRO);
|
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case NEXT_STATE_DEMO:
|
2022-02-19 15:39:34 +01:00
|
|
|
set_game_mode(GAME_MODE_DEMO);
|
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case NEXT_STATE_FILE_SELECT:
|
|
|
|
gGameStatusPtr->areaID = AREA_KMR;
|
|
|
|
gGameStatusPtr->mapID = 0xB; //TODO hardcoded map IDs
|
2022-02-19 15:39:34 +01:00
|
|
|
gGameStatusPtr->entryID = 0;
|
|
|
|
set_game_mode(GAME_MODE_FILE_SELECT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
if (!(gOverrideFlags & GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME)) {
|
2022-02-19 15:39:34 +01:00
|
|
|
update_npcs();
|
|
|
|
update_cameras();
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
void state_drawUI_title_screen(void) {
|
2023-10-14 21:43:12 +02:00
|
|
|
switch (gGameStatusPtr->startupState) {
|
|
|
|
case TITLE_STATE_INIT:
|
|
|
|
PressStart_Alpha = 0;
|
|
|
|
PressStart_IsVisible = FALSE;
|
|
|
|
PressStart_BlinkCounter = 0;
|
2021-06-30 04:27:12 +02:00
|
|
|
draw_title_screen_NOP();
|
2021-04-23 13:55:30 +02:00
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_HOLD:
|
2021-06-30 04:27:12 +02:00
|
|
|
draw_title_screen_NOP();
|
2021-04-23 13:55:30 +02:00
|
|
|
if (gGameStatusPtr->contBitPattern & 1) {
|
2021-06-30 04:27:12 +02:00
|
|
|
title_screen_draw_press_start();
|
2021-04-23 13:55:30 +02:00
|
|
|
}
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_UNUSED:
|
2021-04-23 13:55:30 +02:00
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_APPEAR:
|
|
|
|
case TITLE_STATE_BEGIN_DISMISS:
|
|
|
|
case TITLE_STATE_DISMISS:
|
2021-06-30 04:27:12 +02:00
|
|
|
draw_title_screen_NOP();
|
2021-04-23 13:55:30 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2022-02-19 15:39:34 +01:00
|
|
|
void appendGfx_title_screen(void) {
|
|
|
|
f32 phi_f12;
|
|
|
|
s32 temp;
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
switch (gGameStatusPtr->startupState) {
|
|
|
|
case TITLE_STATE_INIT:
|
|
|
|
case TITLE_STATE_UNUSED:
|
2022-02-19 15:39:34 +01:00
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_APPEAR:
|
|
|
|
phi_f12 = gGameStatusPtr->titleScreenTimer;
|
|
|
|
phi_f12 /= gGameStatusPtr->titleScreenDismissTime;
|
2022-02-19 15:39:34 +01:00
|
|
|
phi_f12 = SQ(phi_f12);
|
|
|
|
title_screen_draw_images(phi_f12, phi_f12);
|
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_HOLD:
|
2022-02-19 15:39:34 +01:00
|
|
|
title_screen_draw_images(0.0f, 0.0f);
|
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_BEGIN_DISMISS:
|
2022-02-19 15:39:34 +01:00
|
|
|
title_screen_draw_images(0.0f, 0.0f);
|
|
|
|
break;
|
2023-10-14 21:43:12 +02:00
|
|
|
case TITLE_STATE_DISMISS:
|
|
|
|
temp = gGameStatusPtr->titleScreenTimer - 1;
|
|
|
|
phi_f12 = gGameStatusPtr->titleScreenDismissTime - temp;
|
|
|
|
phi_f12 /= gGameStatusPtr->titleScreenDismissTime;
|
2022-02-19 15:39:34 +01:00
|
|
|
phi_f12 = SQ(phi_f12);
|
|
|
|
title_screen_draw_images(phi_f12, phi_f12);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPPipeSync(gMainGfxPos++);
|
|
|
|
gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxCfb_ptr));
|
|
|
|
gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
|
|
gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
|
|
|
|
gDPPipeSync(gMainGfxPos++);
|
|
|
|
gSPClearGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING |
|
2022-02-19 15:39:34 +01:00
|
|
|
G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
|
2023-03-08 17:55:54 +01:00
|
|
|
gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH);
|
|
|
|
gSPSetLights1(gMainGfxPos++, D_80077A38);
|
|
|
|
|
|
|
|
gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
|
|
|
|
gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
|
|
|
|
gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
|
|
|
|
gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
|
|
|
|
gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
|
|
|
|
gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
|
|
|
|
gDPSetTextureConvert(gMainGfxPos++, G_TC_FILT);
|
|
|
|
gDPSetCombineKey(gMainGfxPos++, G_CK_NONE);
|
|
|
|
gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
|
2023-04-20 10:15:58 +02:00
|
|
|
render_frame(FALSE);
|
|
|
|
render_frame(TRUE);
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
void draw_title_screen_NOP(void) {
|
2021-04-13 09:47:52 +02:00
|
|
|
}
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
void title_screen_draw_images(f32 logoMoveAlpha, f32 copyrightMoveAlpha) {
|
|
|
|
title_screen_draw_logo(logoMoveAlpha);
|
|
|
|
title_screen_draw_copyright(copyrightMoveAlpha);
|
2021-04-23 13:55:30 +02:00
|
|
|
}
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
void title_screen_draw_logo(f32 moveAlpha) {
|
2022-02-19 15:39:34 +01:00
|
|
|
s32 yOffset;
|
|
|
|
s32 i;
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
gSPDisplayList(gMainGfxPos++, TitleSetupGfx);
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPPipeSync(gMainGfxPos++);
|
2023-10-14 21:43:12 +02:00
|
|
|
yOffset = -100 * moveAlpha;
|
2022-02-19 15:39:34 +01:00
|
|
|
|
|
|
|
for (i = 0; i < TITLE_NUM_TILES; i++) {
|
|
|
|
// Load a tile from the logo texture
|
2023-03-28 07:42:44 +02:00
|
|
|
gDPLoadTextureTile(gMainGfxPos++, &TitleScreen_ImgList_Logo[i * TITLE_TILE_PIXELS], G_IM_FMT_RGBA, G_IM_SIZ_32b,
|
2022-02-19 15:39:34 +01:00
|
|
|
TITLE_WIDTH, TITLE_TILE_HEIGHT, // width, height
|
|
|
|
0, 0, (TITLE_WIDTH - 1), (TITLE_TILE_HEIGHT - 1), // uls, ult, lrs, lrt
|
|
|
|
0, // pal
|
|
|
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, // cms, cmt
|
|
|
|
G_TX_NOMASK, G_TX_NOMASK, // masks, maskt
|
|
|
|
G_TX_NOLOD, G_TX_NOLOD); // shifts, shiftt
|
|
|
|
// Draw a scissored texture rectangle with the loaded tile
|
2023-03-08 17:55:54 +01:00
|
|
|
gSPScisTextureRectangle(gMainGfxPos++,
|
2022-02-19 15:39:34 +01:00
|
|
|
(TITLE_POS_LEFT) << 2, // ulx
|
|
|
|
(TITLE_POS_TOP + TITLE_TILE_HEIGHT * i + yOffset) << 2, // uly
|
|
|
|
(TITLE_POS_LEFT + TITLE_WIDTH) << 2, // lrx
|
|
|
|
(TITLE_POS_TOP + TITLE_TILE_HEIGHT + TITLE_TILE_HEIGHT * i + yOffset) << 2, // lry
|
|
|
|
G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
|
|
|
|
}
|
|
|
|
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPPipeSync(gMainGfxPos++);
|
2022-02-19 15:39:34 +01:00
|
|
|
}
|
2021-04-23 13:55:30 +02:00
|
|
|
|
2023-03-08 16:40:22 +01:00
|
|
|
#if VERSION_IQUE
|
2023-02-21 15:37:27 +01:00
|
|
|
#define VAR_1 20
|
|
|
|
#define VAR_2 628
|
|
|
|
#else
|
|
|
|
#define VAR_1 32
|
|
|
|
#define VAR_2 676
|
|
|
|
#endif
|
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
void title_screen_draw_press_start(void) {
|
2023-10-14 21:43:12 +02:00
|
|
|
switch (PressStart_IsVisible) {
|
2023-03-28 07:42:44 +02:00
|
|
|
case FALSE:
|
2023-10-14 21:43:12 +02:00
|
|
|
PressStart_Alpha -= 128;
|
|
|
|
if (PressStart_Alpha < 0) {
|
|
|
|
PressStart_Alpha = 0;
|
2021-04-23 13:55:30 +02:00
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
PressStart_BlinkCounter++;
|
|
|
|
if (PressStart_BlinkCounter >= 16) {
|
|
|
|
PressStart_BlinkCounter = 0;
|
|
|
|
PressStart_IsVisible = TRUE;
|
2021-04-23 13:55:30 +02:00
|
|
|
}
|
|
|
|
break;
|
2023-03-28 07:42:44 +02:00
|
|
|
case TRUE:
|
2023-10-14 21:43:12 +02:00
|
|
|
PressStart_Alpha += 128;
|
|
|
|
if (PressStart_Alpha > 255) {
|
|
|
|
PressStart_Alpha = 255;
|
2021-04-23 13:55:30 +02:00
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
PressStart_BlinkCounter++;
|
|
|
|
if (PressStart_BlinkCounter >= 16) {
|
|
|
|
PressStart_BlinkCounter = 0;
|
|
|
|
PressStart_IsVisible = FALSE;
|
2021-04-23 13:55:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
gSPDisplayList(gMainGfxPos++, TitleSetupGfx);
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPSetCombineMode(gMainGfxPos++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
|
2023-10-14 21:43:12 +02:00
|
|
|
gDPSetPrimColor(gMainGfxPos++, 0, 0, 248, 240, 152, PressStart_Alpha);
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPPipeSync(gMainGfxPos++);
|
2023-05-01 19:51:52 +02:00
|
|
|
gDPLoadTextureBlock(gMainGfxPos++, TitleScreen_ImgList_PressStart, G_IM_FMT_IA, G_IM_SIZ_8b, 128, VAR_1, 0,
|
|
|
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
|
|
|
|
G_TX_NOLOD);
|
2023-03-08 17:55:54 +01:00
|
|
|
gSPTextureRectangle(gMainGfxPos++, 384, 548, 896, VAR_2, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
|
|
|
|
gDPPipeSync(gMainGfxPos++);
|
2021-04-23 13:55:30 +02:00
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2023-03-08 16:40:22 +01:00
|
|
|
#if VERSION_IQUE
|
2023-05-01 19:51:52 +02:00
|
|
|
#define RECT_SIZE 0x28
|
|
|
|
#define YL_BASE 724
|
|
|
|
#define YH_BASE 764
|
|
|
|
#define COPYRIGHT_TEX_CHUNKS 4
|
|
|
|
#define COPYRIGHT_IMG(k, i) &TitleScreen_ImgList_Copyright[k]
|
|
|
|
#define LTT_LRT 9
|
2023-02-21 15:37:27 +01:00
|
|
|
#else
|
2023-05-01 19:51:52 +02:00
|
|
|
#define RECT_SIZE 0x40
|
|
|
|
#define YL_BASE 764
|
|
|
|
#define YH_BASE 828
|
|
|
|
#define COPYRIGHT_TEX_CHUNKS 2
|
|
|
|
#define COPYRIGHT_IMG(k, i) &TitleScreen_ImgList_Copyright[16 * i]
|
|
|
|
#define LTT_LRT 15
|
|
|
|
#endif
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
void title_screen_draw_copyright(f32 moveAlpha) {
|
2021-04-26 19:47:38 +02:00
|
|
|
s32 alpha;
|
|
|
|
s32 i;
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
gSPDisplayList(gMainGfxPos++, &TitleSetupGfx);
|
2023-02-17 03:06:56 +01:00
|
|
|
#if VERSION_JP
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPSetTextureLUT(gMainGfxPos++, G_TT_RGBA16);
|
2023-02-17 03:06:56 +01:00
|
|
|
#endif
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPPipeSync(gMainGfxPos++);
|
2021-04-26 19:47:38 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
alpha = 255.0f - (moveAlpha * 255.0f);
|
2022-02-19 15:39:34 +01:00
|
|
|
if (alpha < 255) {
|
2021-04-26 19:47:38 +02:00
|
|
|
if (alpha < 0) {
|
|
|
|
alpha = 0;
|
|
|
|
}
|
2023-04-26 01:33:17 +02:00
|
|
|
gDPSetCombineMode(gMainGfxPos++, PM_CC_02, PM_CC_02);
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
|
2021-04-26 19:47:38 +02:00
|
|
|
}
|
|
|
|
|
2023-02-17 03:06:56 +01:00
|
|
|
#if VERSION_JP
|
2023-03-28 07:42:44 +02:00
|
|
|
gDPLoadTLUT_pal16(gMainGfxPos++, 0, TitleScreen_ImgList_CopyrightPalette);
|
2023-05-01 19:51:52 +02:00
|
|
|
gDPLoadTextureTile_4b(gMainGfxPos++, TitleScreen_ImgList_Copyright, G_IM_FMT_CI,
|
|
|
|
COPYRIGHT_WIDTH, 0, 0, 0, 127, 31, 0,
|
2023-02-17 03:06:56 +01:00
|
|
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
|
|
|
|
G_TX_NOLOD);
|
2023-05-01 19:51:52 +02:00
|
|
|
gSPTextureRectangle(gMainGfxPos++, 388, YL_BASE, 900, 892, G_TX_RENDERTILE,
|
2023-02-17 03:06:56 +01:00
|
|
|
0, 0, 0x0400, 0x0400);
|
|
|
|
#else
|
2023-05-01 19:51:52 +02:00
|
|
|
for (i = 0; i < COPYRIGHT_TEX_CHUNKS; i++) {
|
|
|
|
s32 k = 10 * i;
|
2021-04-26 19:47:38 +02:00
|
|
|
alpha = 0; // TODO figure out why this is needed
|
2023-05-01 19:51:52 +02:00
|
|
|
|
|
|
|
gDPLoadTextureTile(gMainGfxPos++, COPYRIGHT_IMG(k, i), G_IM_FMT_IA, G_IM_SIZ_8b,
|
|
|
|
COPYRIGHT_WIDTH, 32, 0, 0, 143, LTT_LRT, 0,
|
2021-09-22 13:17:46 +02:00
|
|
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
|
|
|
|
G_TX_NOLOD);
|
2023-05-01 19:51:52 +02:00
|
|
|
gSPTextureRectangle(gMainGfxPos++, 356, YL_BASE + (RECT_SIZE * i), 932, YH_BASE + (RECT_SIZE * i),
|
|
|
|
G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
|
2021-04-26 19:47:38 +02:00
|
|
|
}
|
2023-02-17 03:06:56 +01:00
|
|
|
#endif
|
2023-03-08 17:55:54 +01:00
|
|
|
gDPPipeSync(gMainGfxPos++);
|
2021-04-26 19:47:38 +02:00
|
|
|
}
|