Decompile EndingImageInit

This commit is contained in:
YohannDR 2023-02-07 19:08:17 +01:00
parent 7be74b2e7b
commit fa5b2be4ab
9 changed files with 364 additions and 6 deletions

View File

@ -4561,7 +4561,7 @@ lbl_0800f2b8:
strb r0, [r2] strb r0, [r2]
b lbl_0800f2fa b lbl_0800f2fa
lbl_0800f2c0: lbl_0800f2c0:
bl SpriteUtilGetCurrentCompletionPercentage bl SpriteUtilGetFinalCompletionPercentage
movs r3, #1 movs r3, #1
str r3, [sp, #0x10] str r3, [sp, #0x10]
cmp r0, #0x64 cmp r0, #0x64
@ -9585,8 +9585,8 @@ lbl_08011756:
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_start SpriteUtilGetCurrentCompletionPercentage thumb_func_start SpriteUtilGetFinalCompletionPercentage
SpriteUtilGetCurrentCompletionPercentage: @ 0x0801175c SpriteUtilGetFinalCompletionPercentage: @ 0x0801175c
push {r4, r5, lr} push {r4, r5, lr}
bl GetPercentAndEndingNumber bl GetPercentAndEndingNumber
lsrs r1, r0, #0x18 lsrs r1, r0, #0x18

View File

@ -0,0 +1,29 @@
#ifndef ENDING_AND_GALLERY_DATA_H
#define ENDING_AND_GALLERY_DATA_H
#include "types.h"
#define NUMBER_OF_ENDING_IMAGES 8
// ...
extern const u16 sEndingImageTextPAL[14 * 16];
// ...
extern const u32* const sEndingImagesTopHalfGfxPointers[NUMBER_OF_ENDING_IMAGES];
extern const u32* const sEndingImagesLowerHalfGfxPointers[NUMBER_OF_ENDING_IMAGES];
extern const u32* const sEndingImagesTopHalfTileTablePointers[NUMBER_OF_ENDING_IMAGES];
extern const u32* const sEndingImagesLowerHalfTileTablePointers[NUMBER_OF_ENDING_IMAGES];
extern const u16* const sEndingImagesPalPointers[NUMBER_OF_ENDING_IMAGES];
// ...
extern const u32 sEndingImageTextGFX[803];
extern const u32 sEndingImageTextJapGFX[511];
// ...
extern const u32 sEndingImageNumbersMiscGFX[218];
#endif /* ENDING_AND_GALLERY_DATA_H */

View File

@ -0,0 +1,34 @@
#ifndef ENDING_AND_GALLERY_H
#define ENDING_AND_GALLERY_H
#include "types.h"
void FusionGalleryVBlank(void);
void FusionGalleryInit(void);
u32 FusionGalleryDisplay(void);
u32 FusionGallerySubroutine(void);
void EndingImageCheckDisplayLetter(u32 offset);
void EndingImageLoadTextOAM(u32 set);
void EndingImageDisplayLinePermanently(u32 line);
void EndingImageLoadIGTAndPercentageGraphics(void);
void GalleryVBlank(void);
void EndScreenVBlank(void);
void UnlockedOptionsVBlank(void);
void CreditsInit(void);
u8 CreditsDisplayLine(u32 line);
u8 CreditsDisplay(void);
u8 CreditsChozoWallMovement(void);
u8 CreditsChozoWallZoom(void);
void EndScreenInit(void);
u8 EndScreenSamusPosing(void);
void EndingImageInit(void);
void EndingImageDisplayText(void);
u8 EndingImageDisplay(void);
void UnlockedOptionsInit(void);
u8 UnlockedOptionsPopUp(void);
u32 CreditsSubroutine(void);
void GalleryInit(void);
u32 GalleryDisplay(void);
u32 GallerySubroutine(void);
#endif /* ENDING_AND_GALLERY_H */

View File

@ -87,6 +87,6 @@ u8 SpriteCheckCollidingWithSamusDrawing(void);
void SpriteUtilSetSplashEffect(u16 yPosition, u16 xPosition, u8 size); void SpriteUtilSetSplashEffect(u16 yPosition, u16 xPosition, u8 size);
u32 SpriteUtilCheckOutOfRoomEffect(u16 oldY, u16 yPosition, u16 xPosition, u8 size); u32 SpriteUtilCheckOutOfRoomEffect(u16 oldY, u16 yPosition, u16 xPosition, u8 size);
u32 SpriteUtilCheckInRoomEffect(u16 oldY, u16 yPosition, u16 xPosition, u8 size); u32 SpriteUtilCheckInRoomEffect(u16 oldY, u16 yPosition, u16 xPosition, u8 size);
u32 SpriteUtilGetCurrentCompletionPercentage(void); u32 SpriteUtilGetFinalCompletionPercentage(void);
#endif /* SPRITE_UTIL_H */ #endif /* SPRITE_UTIL_H */

View File

@ -0,0 +1,49 @@
#ifndef ENDING_AND_GALLERY_STRUCT_H
#define ENDING_AND_GALLERY_STRUCT_H
#include "types.h"
#define ENDING_DATA sNonGameplayRamPointer->ending
struct EndingData {
u8 stage;
u8 unk_1;
u8 endScreenTimer;
u16 timer;
u8 unk_6;
u16 unk_8;
u16 unk_A;
u16 currentCreditLine;
u16 unk_E;
u16 creditLineTilemap_1[32];
u16 creditLineTilemap_2[32];
u32 unk_90;
u32 unk_94;
u8 endingNumber;
u8 completionPercentage;
u8 language;
u8 oamLength;
u8 padding_9C[136];
u8 unk_124[6];
u8 unk_12A[17];
u8 padding_13B[6];
u8 unk_141;
u8 unk_142[6];
u8 unk_148[17];
u8 padding_159[7];
u8 unk_160[6];
u8 unk_166[17];
u8 unk_177;
u8 unk_178;
u8 unk_179;
u8 padding_17A[3];
u8 unk_17D;
u16 oamXPositions[30];
u16 oamYPositions[30];
u16* oamFramePointers[30];
u8 padding_270[79];
u16 dispcnt;
u16 bldcnt;
};
#endif /* ENDING_AND_GALLERY_STRUCT_H */

View File

@ -7,12 +7,14 @@
#include "structs/cutscene.h" #include "structs/cutscene.h"
#include "structs/intro.h" #include "structs/intro.h"
#include "structs/game_over.h" #include "structs/game_over.h"
#include "structs/ending_and_gallery.h"
union NonGameplayRAM { union NonGameplayRAM {
struct CutsceneData cutscene; struct CutsceneData cutscene;
struct IntroData intro; struct IntroData intro;
struct GameOverData gameOver; struct GameOverData gameOver;
struct EndingData ending;
u8 inGame[1576]; u8 inGame[1576];
}; };

244
src/ending_and_gallery.c Normal file
View File

@ -0,0 +1,244 @@
#include "ending_and_gallery.h"
#include "callbacks.h"
#include "data/shortcut_pointers.h"
#include "data/ending_and_gallery_data.h"
#include "constants/game_state.h"
#include "structs/bg_clip.h"
#include "structs/display.h"
#include "structs/ending_and_gallery.h"
#include "structs/game_state.h"
void FusionGalleryVBlank(void)
{
}
void FusionGalleryInit(void)
{
}
u32 FusionGalleryDisplay(void)
{
}
u32 FusionGallerySubroutine(void)
{
}
void EndingImageCheckDisplayLetter(u32 offset)
{
}
void EndingImageLoadTextOAM(u32 set)
{
}
void EndingImageDisplayLinePermanently(u32 line)
{
}
void EndingImageLoadIGTAndPercentageGraphics(void)
{
}
void GalleryVBlank(void)
{
}
void EndScreenVBlank(void)
{
}
void UnlockedOptionsVBlank(void)
{
}
void CreditsInit(void)
{
}
u8 CreditsDisplayLine(u32 line)
{
}
u8 CreditsDisplay(void)
{
}
u8 CreditsChozoWallMovement(void)
{
}
u8 CreditsChozoWallZoom(void)
{
}
void EndScreenInit(void)
{
}
u8 EndScreenSamusPosing(void)
{
}
/**
* @brief 867b4 | 29c | Initiliazes the ending image sequence
*
*/
void EndingImageInit(void)
{
u32 zero;
u32 endingNumber;
u32 part1;
u32 part2;
u32 part3;
u32 part4;
u32 part5;
u32 pen;
u32 mask;
write16(REG_IME, FALSE);
write16(REG_DISPSTAT, read16(REG_DISPSTAT) & ~DSTAT_IF_HBLANK);
write16(REG_IE, read16(REG_IE) & ~IF_HBLANK);
write16(REG_IF, IF_HBLANK);
write16(REG_IME, TRUE);
write16(REG_DISPCNT, 0);
write16(REG_IME, FALSE);
CallbackSetVBlank(GalleryVBlank);
write16(REG_IME, TRUE);
zero = 0;
dma_set(3, &zero, &gNonGameplayRAM, (DMA_ENABLE | DMA_32BIT | DMA_SRC_FIXED) << 16 | sizeof(gNonGameplayRAM) / 4);
pen = GetPercentAndEndingNumber();
mask = 0xFF;
// TODO figure out how PEN is structured
part1 = pen >> 0x18;
part2 = (pen >> 0x10) & mask;
part3 = (pen >> 0xC) & 0xF;
part4 = (pen >> 0x8) & 0xF;
part5 = (pen >> 0x4) & 0xF;
endingNumber = pen & 0xF;
LZ77UncompVRAM(sEndingImagesTopHalfGfxPointers[endingNumber], VRAM_BASE);
LZ77UncompVRAM(sEndingImagesLowerHalfGfxPointers[endingNumber], VRAM_BASE + 0x8000);
LZ77UncompVRAM(sEndingImagesTopHalfTileTablePointers[endingNumber], VRAM_BASE + 0xE000);
LZ77UncompVRAM(sEndingImagesLowerHalfTileTablePointers[endingNumber], VRAM_BASE + 0xF800);
BitFill(3, 0x4FF04FF, VRAM_BASE + 0xE800, 0x800, 0x20);
dma_set(3, sEndingImagesPalPointers[endingNumber], PALRAM_BASE, DMA_ENABLE << 16 | 0x100);
ENDING_DATA.completionPercentage = part1 + part2 + part3 + part4 + part5;
LZ77UncompVRAM(sEndingImageNumbersMiscGFX, VRAM_BASE + 0x10000);
ENDING_DATA.language = gLanguage;
if (gLanguage > LANGUAGE_ENGLISH)
ENDING_DATA.language = LANGUAGE_ENGLISH;
if (ENDING_DATA.language == LANGUAGE_HIRAGANA)
LZ77UncompVRAM(sEndingImageTextJapGFX, VRAM_BASE + 0x11000);
else
LZ77UncompVRAM(sEndingImageTextGFX, VRAM_BASE + 0x11000);
dma_set(3, sEndingImageTextPAL, PALRAM_BASE + 0x200, DMA_ENABLE << 16 | sizeof(sEndingImageTextPAL) / 2);
EndingImageLoadIGTAndPercentageGraphics();
write16(REG_BG0CNT, 0x9C00);
write16(REG_BG1CNT, 0x9E09);
gNextOamSlot = 0;
ResetFreeOAM();
gBG0XPosition = 0;
gBG0YPosition = 0x1000;
gBG1XPosition = 0;
gBG1YPosition = 0x1000;
gBG2XPosition = 0;
gBG2YPosition = 0;
gBG3XPosition = 0;
gBG3YPosition = 0;
write16(REG_BG0HOFS, 0);
write16(REG_BG0VOFS, 0);
write16(REG_BG1HOFS, 0);
write16(REG_BG1VOFS, 0);
write16(REG_BG2HOFS, 0);
write16(REG_BG2VOFS, 0);
write16(REG_BG3HOFS, 0);
write16(REG_BG3VOFS, 0);
ENDING_DATA.dispcnt = DCNT_OBJ | DCNT_BG0 | DCNT_BG1;
ENDING_DATA.bldcnt = BLDCNT_BG0_FIRST_TARGET_PIXEL | BLDCNT_BG1_FIRST_TARGET_PIXEL | BLDCNT_BG2_FIRST_TARGET_PIXEL |
BLDCNT_BG3_FIRST_TARGET_PIXEL | BLDCNT_OBJ_FIRST_TARGET_PIXEL | BLDCNT_BACKDROP_FIRST_TARGET_PIXEL |
BLDCNT_ALPHA_BLENDING_EFFECT | BLDCNT_BRIGHTNESS_INCREASE_EFFECT;
gWrittenToBLDALPHA_L = 16;
gWrittenToBLDALPHA_H = 0;
gWrittenToBLDY_NonGameplay = 16;
GalleryVBlank();
}
void EndingImageDisplayText(void)
{
}
u8 EndingImageDisplay(void)
{
}
void UnlockedOptionsInit(void)
{
}
u8 UnlockedOptionsPopUp(void)
{
}
u32 CreditsSubroutine(void)
{
}
void GalleryInit(void)
{
}
u32 GalleryDisplay(void)
{
}
u32 GallerySubroutine(void)
{
}

View File

@ -2855,7 +2855,7 @@ u32 SpriteUtilCheckInRoomEffect(u16 oldY, u16 yPosition, u16 xPosition, u8 size)
* *
* @return u32 * @return u32
*/ */
u32 SpriteUtilGetCurrentCompletionPercentage(void) u32 SpriteUtilGetFinalCompletionPercentage(void)
{ {
u32 result; u32 result;
u32 part1; u32 part1;

View File

@ -388,7 +388,7 @@ void MechaRidleyInit(void)
gBossWork.work9 = 0; gBossWork.work9 = 0;
gBossWork.work10 = 0; gBossWork.work10 = 0;
gBossWork.work11 = SpriteUtilGetCurrentCompletionPercentage(); gBossWork.work11 = SpriteUtilGetFinalCompletionPercentage();
// Offset to the right // Offset to the right
gCurrentSprite.xPosition += BLOCK_SIZE * 11; gCurrentSprite.xPosition += BLOCK_SIZE * 11;