Some intro code

This commit is contained in:
YohannDR 2023-01-30 23:33:51 +01:00
parent 320b8ec510
commit 5371acd782
8 changed files with 406 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#define CUTSCENE_DATA sNonGameplayRAMPointer[0]->cutscene
#define CUTSCENE_DATA sNonGameplayRAMPointer->cutscene
#define CUTSCENE_NONE 0
#define CUTSCENE_INTRO_TEXT 1

View File

@ -0,0 +1,6 @@
#define INTRO_TEXT_ACTION_NONE 0
#define INTRO_TEXT_ACTION_START 1
#define INTRO_TEXT_SPACE 2
#define INTRO_TEXT_UNKNOWN 3
#define INTRO_TEXT_NEW_LINE 4
#define INTRO_TEXT_END 5

37
include/data/intro_data.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef INTRO_DATA_H
#define INTRO_DATA_H
#include "types.h"
#include "structs/in_game_timer.h"
extern const u16 sIntroEmergencOrderTextOAM[52];
extern const u16 sIntroExterminateAllTextOAM[163];
extern const u16 sIntroDefeatTheTextOAM[163];
extern const u16 sIntroTextMarkerOAM[10];
extern const u16 sIntroShipFlyingTowardsCameraOAM_1[19];
extern const u16 sIntroShipFlyingTowardsCameraOAM_2[28];
extern const u16 sIntroViewOfZebesShipOAM[13];
extern const u16 sIntroViewOfZebesHeatOAM_1[37];
extern const u16 sIntroViewOfZebesHeatOAM_2[73];
extern const u16 sIntroFuzzOAM[52];
extern const u16 sIntroTextAndSipPAL[16 * 6];
extern const u16 sIntroPAL_45f9d4[16 * 1];
extern const u16 sIntroSamusInHerShipPAL[16 * 5];
extern const u16 sIntroViewOfZebesPAL[16 * 10];
extern const u16 sIntroMotherBrainPAL[16 * 5];
extern const u8 sIntroFuzzRandomValues_1[64];
extern const u8 sIntroFuzzRandomValues_2[64];
extern const u8 sTimeAttackPasswordCharacters[32];
extern const struct InGameTimer sTimeAttackAntiCheatTimes[4];
extern const u8 sArray_45fd24[12];
extern const u8 sArray_45fd30[4];
extern const u8 sArray_45fd34[4];
#endif /* INTRO_DATA_H */

24
include/intro.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef INTRO_H
#define INTRO_H
#include "types.h"
void IntroVBlank(void);
void IntroFuzzVBlank(void);
void IntroInit(void);
void IntroTextProcessOAM(void);
u8 IntroProcessText(u8 action, u16 indent);
u8 IntroEmergencyOrder(void);
void IntroShipFlyingTowardsCameraProcessOAM(void);
u8 IntroShipFlyingTowardsCamera(void);
u8 IntroSamusInHerShip(void);
u8 IntroExterminate(void);
void IntroViewOfZebesProcessOAM(void);
u8 IntroViewOfZebes(void);
u8 IntroDefeat(void);
u8 IntroMotherBrain(void);
void IntroFuzzProcessOAM(void);
u8 IntroFuzz(void);
u32 IntroSubroutine(void);
#endif /* INTRO_H */

40
include/structs/intro.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef INTRO_STRUCT_H
#define INTRO_STRUCT_H
#include "types.h"
#define INTRO_DATA sNonGameplayRAMPointer->intro
struct IntroData {
u8 stage; // 0
u8 currentCharacter; // 1
u8 characterPalette; // 2
u8 nextCharacter; // 3
i16 charDrawerY; // 4
u16 charDrawerX; // 6
u8 charDrawerPalette; // 8
u8 unk_9; // 9
u8 unk_A; // A
u16 timer; // C
u16* pTextOamFramePointer; // 10
u16 fuzzPalette[16]; // 14
u16 rotation; // 34
i16 scaling; // 36
u8 padding_38_3c[5]; // 38
u8 unk_3d; // 3D
u16 shipFlyingTowardsCameraX; // 3E
u16 shipFlyingTowardsCameraY; // 40
u8 unk_42; // 42
u16 dispcnt; // 44
u16 bldcnt; // 46
};
#endif /* INTRO_STRUCT_H */

View File

@ -3,11 +3,14 @@
#include "gba.h"
#include "types.h"
#include "structs/cutscene.h"
#include "structs/intro.h"
union NonGameplayRAM {
struct CutsceneData cutscene;
struct IntroData intro;
u8 inGame[1576];
};
@ -28,6 +31,7 @@ extern u16 gBG3VOFS_NonGameplay;
extern void* const sMemoryPointers[1];
extern union NonGameplayRAM* const sNonGameplayRAMPointer[1];
// This isn't an array, also not const on purpose, do not add const
extern union NonGameplayRAM* sNonGameplayRAMPointer;
#endif

View File

@ -28,6 +28,4 @@ void* const sMemoryPointers[] = {
EWRAM_BASE
};
union NonGameplayRAM* const sNonGameplayRAMPointer[] = {
&gNonGameplayRAM
};
union NonGameplayRAM* sNonGameplayRAMPointer = &gNonGameplayRAM;

292
src/intro.c Normal file
View File

@ -0,0 +1,292 @@
#include "intro.h"
#include "temp_globals.h"
#include "data/intro_data.h"
#include "constants/intro.h"
#include "structs/bg_clip.h"
#include "structs/display.h"
#include "structs/intro.h"
/**
* @brief 800f4 | 90 | V-blank code for the intro
*
*/
void IntroVBlank(void)
{
dma_set(3, gOamData, OAM_BASE, (DMA_ENABLE | DMA_32BIT) << 16 | OAM_SIZE / 4);
write16(REG_DISPCNT, INTRO_DATA.dispcnt);
write16(REG_BLDCNT, INTRO_DATA.bldcnt);
write16(REG_BLDALPHA, gWrittenToBLDALPHA_H << 8 | gWrittenToBLDALPHA_L);
write16(REG_BLDY, gWrittenToBLDY_NonGameplay);
write16(REG_BG0HOFS, gBG0XPosition & 0x1FF);
write16(REG_BG0VOFS, gBG0YPosition & 0x1FF);
}
/**
* @brief 80184 | 58 | V-blank code for the intro fuzz
*
*/
void IntroFuzzVBlank(void)
{
dma_set(3, gOamData, OAM_BASE, (DMA_ENABLE | DMA_32BIT) << 16 | OAM_SIZE / 4);
write16(REG_DISPCNT, INTRO_DATA.dispcnt);
write16(REG_BLDCNT, INTRO_DATA.bldcnt);
dma_set(3, INTRO_DATA.fuzzPalette, PALRAM_BASE + 0x200, DMA_ENABLE << 16 | sizeof(INTRO_DATA.fuzzPalette) / 2);
}
void IntroInit(void)
{
}
void IntroTextProcessOAM(void)
{
}
/**
* @brief 80550 | 180 | Processes the intro text
*
* @param action Text action
* @param indent Indent
* @return u8 To document
*/
u8 IntroProcessText(u8 action, u16 indent)
{
u8 dontProcess;
u8 flag_unk2;
u8 newLine;
u8 flag_unk3;
i32 previousY;
i32 newY;
// TODO macro
do{newY = (i16)indent;}while(0);
dontProcess = FALSE;
flag_unk2 = FALSE;
newLine = FALSE;
flag_unk3 = FALSE;
previousY = INTRO_DATA.charDrawerY;
switch (action)
{
case INTRO_TEXT_END:
if (INTRO_DATA.unk_A != 1)
{
if (INTRO_DATA.unk_A > 0x14)
return 2;
}
else
{
INTRO_DATA.charDrawerY += 8;
SoundPlay(0x226);
}
return 0;
case INTRO_TEXT_ACTION_START:
if (INTRO_DATA.unk_A > 3)
{
INTRO_DATA.nextCharacter += 2;
INTRO_DATA.currentCharacter++;
flag_unk3++;
}
dontProcess++;
break;
case INTRO_TEXT_SPACE:
if (INTRO_DATA.unk_A == 1)
INTRO_DATA.charDrawerY += 8;
else if (INTRO_DATA.unk_A > 3)
{
INTRO_DATA.nextCharacter++;
INTRO_DATA.currentCharacter++;
flag_unk3++;
}
dontProcess++;
break;
case INTRO_TEXT_NEW_LINE:
newLine++;
case INTRO_TEXT_UNKNOWN:
flag_unk2++;
}
if (!dontProcess)
{
switch (INTRO_DATA.unk_A)
{
case 0:
case 3:
INTRO_DATA.characterPalette = 1;
break;
case 1:
INTRO_DATA.characterPalette = 2;
if (newLine)
{
INTRO_DATA.charDrawerY = newY;
INTRO_DATA.charDrawerX += 0x18;
}
else
INTRO_DATA.charDrawerY += 0x8;
break;
case 4:
INTRO_DATA.characterPalette = 0;
break;
case 5:
INTRO_DATA.currentCharacter++;
if (flag_unk2)
INTRO_DATA.nextCharacter += 2;
else
INTRO_DATA.nextCharacter++;
flag_unk3++;
}
}
if (previousY != INTRO_DATA.charDrawerY && action != INTRO_TEXT_SPACE)
SoundPlay(0x226);
if (flag_unk3 != 0)
return 1;
return 0;
}
u8 IntroEmergencyOrder(void)
{
}
void IntroShipFlyingTowardsCameraProcessOAM(void)
{
}
/**
* @brief 808ec | 9c | Handles the ship flying towards camera part of the intro
*
* @return u8 FALSE
*/
u8 IntroShipFlyingTowardsCamera(void)
{
u8 ended;
ended = FALSE;
switch (INTRO_DATA.timer)
{
case 0:
INTRO_DATA.bldcnt = BLDCNT_ALPHA_BLENDING_EFFECT | BLDCNT_BG0_SECOND_TARGET_PIXEL | BLDCNT_OBJ_SECOND_TARGET_PIXEL;
gWrittenToBLDALPHA_L = 9;
gWrittenToBLDALPHA_H = 7;
break;
case 1:
INTRO_DATA.dispcnt = DCNT_BG0 | DCNT_OBJ;
SoundPlay(4);
SoundPlay(0x227);
break;
case 0x20:
INTRO_DATA.dispcnt = 0;
INTRO_DATA.bldcnt = 0;
INTRO_DATA.stage++;
ended = TRUE;
}
IntroShipFlyingTowardsCameraProcessOAM();
if (ended)
INTRO_DATA.timer = 0;
else
INTRO_DATA.timer++;
return FALSE;
}
u8 IntroSamusInHerShip(void)
{
}
u8 IntroExterminate(void)
{
}
void IntroViewOfZebesProcessOAM(void)
{
}
u8 IntroViewOfZebes(void)
{
}
u8 IntroDefeat(void)
{
}
u8 IntroMotherBrain(void)
{
}
/**
* @brief 81018 | 88 | Processes the OAM for the intro fuzz
*
*/
void IntroFuzzProcessOAM(void)
{
u16* dst;
const u16* src;
u16 partCount;
u16 i;
u16 part;
u16 offset;
dst = (u16*)gOamData;
src = sIntroFuzzOAM;
partCount = *src++;
offset = BLOCK_SIZE * 2;
for (i = 0; i < partCount; i++)
{
part = *src++;
*dst++ = part;
gOamData[i].split.y = part - BLOCK_SIZE * 2;
part = *src++;
*dst++ = part;
gOamData[i].split.x = (part + offset) & 0x1FF;
*dst++ = *src++;
dst++;
}
gNextOAMSlot = i;
}
u8 IntroFuzz(void)
{
}
u32 IntroSubroutine(void)
{
}