Match InGameMainLoop

This commit is contained in:
YohannDR 2023-01-30 09:32:31 +01:00
parent 113873045c
commit 67c7651e2e
6 changed files with 142 additions and 6 deletions

View File

@ -2,8 +2,8 @@
.syntax unified
thumb_func_start ingame_main
ingame_main: @ 0x0800c4b4
thumb_func_start InGameMainLoop
InGameMainLoop: @ 0x0800c4b4
push {r4, lr}
bl ingame_setvblank_callback
movs r4, #0

View File

@ -6,8 +6,8 @@
struct ButtonAssignments {
u16 armMissiles;
u16 diagonalAim;
u16 swapMissiles;
u16 pause;
u16 swapMissiles;
};
#endif /* GBA_INPUT_H */
#endif /* GBA_INPUT_H */

View File

@ -10,6 +10,7 @@ extern vu16 gVBlankRequestFlag;
extern u8 gDisableSoftreset;
extern u8 gDebugFlag;
extern u8 gDisablePause;
extern u8 gDisableScrolling;
extern u8 gShipLandingFlag;
extern u16 gButtonInput;
extern u16 gPreviousButtonInput;
@ -22,6 +23,7 @@ extern u16 gFrameCounter16Bit;
extern u8 gDifficulty;
extern i8 gLanguage;
extern u8 gResetGame;
extern u8 gNotPressingUp;
extern i16 gMainGameMode;
extern i16 gGameModeSub1;

View File

@ -107,5 +107,6 @@ extern u8 gIgnoreSamusAndSpriteCollision;
extern u8 gSpriteDrawOrder[MAX_AMOUNT_OF_SPRITES];
extern struct BossWork gBossWork;
extern u8 gSpriteRNG;
extern u8 gDisableDrawingSprites;
#endif

View File

@ -75,7 +75,7 @@ void agbmain(void)
break;
case GM_INGAME:
if (ingame_main())
if (InGameMainLoop())
{
if (gPauseScreenFlag == PAUSE_SCREEN_NONE)
{
@ -175,7 +175,7 @@ void agbmain(void)
break;
case GM_DEMO:
if (ingame_main())
if (InGameMainLoop())
{
if (gPauseScreenFlag == PAUSE_SCREEN_PAUSE_OR_CUTSCENE)
{

View File

@ -2,23 +2,156 @@
#include "gba.h"
#include "callbacks.h"
#include "oam.h"
#include "projectile.h"
#include "samus.h"
#include "sprite.h"
#include "demo.h"
#include "particle.h"
#include "room.h"
#include "scroll.h"
#include "init_helpers.h"
#include "hud_generic.h"
#include "display.h"
#include "data/hud_data.h"
#include "constants/demo.h"
#include "constants/game_state.h"
#include "structs/cutscene.h"
#include "structs/demo.h"
#include "structs/display.h"
#include "structs/game_state.h"
#include "structs/room.h"
#include "structs/sprite.h"
#include "structs/connection.h"
/**
* @brief c4b4 | 244 | Main loop in game
*
* @return u32 bool, changing game mode
*/
u32 InGameMainLoop(void)
{
u32 changing;
SetVBlankCodeInGame();
changing = FALSE;
switch (gGameModeSub1)
{
case 0:
if (gGameModeSub3 == 0)
DemoResetInputAndDuration();
if (gDemoState == DEMO_STATE_PLAYING)
CopyDemoInput();
InitAndLoadGenerics();
gGameModeSub1++;
break;
case SUB_GAME_MODE_DOOR_TRANSITION:
IOWriteRegisters();
if (unk_5c3ac()) // Undefined
gGameModeSub1++;
break;
case SUB_GAME_MODE_PLAYING:
DemoMainLoop();
IOWriteRegisters();
if ((gChangedInput & gButtonAssignments.pause || gPauseScreenFlag != PAUSE_SCREEN_NONE) && process_pause_button_press()) // Undefined
gGameModeSub1++;
if (gGameModeSub1 == SUB_GAME_MODE_PLAYING)
{
gPreviousXPosition = gSamusData.xPosition;
gPreviousYPosition = gSamusData.yPosition;
if (!(gButtonInput & KEY_UP))
gNotPressingUp = TRUE;
if (gPreventMovementTimer != 0)
gPreventMovementTimer--;
else
{
SamusUpdate();
SamusUpdateHitboxMovingDirection();
}
InGameTimerUpdate();
}
RoomUpdateGFXInfo();
break;
case SUB_GAME_MODE_LOADING_ROOM:
IOWriteRegistersDuringTransition();
if (process_fading_effect())
{
gGameModeSub1 = 0;
if (gPauseScreenFlag != PAUSE_SCREEN_NONE || gCurrentCutscene != 0 || gTourianEscapeCutsceneStage != 0)
changing = TRUE;
}
break;
case 5:
IOWriteRegisters();
SamusUpdate();
RoomUpdateGFXInfo();
break;
case 6:
unk_cde8();
RoomUpdateGFXInfo();
break;
}
if (gGameModeSub1 == 5)
{
SamusCallGFXFunctions();
SamusDraw();
ResetFreeOAM();
RoomUpdate();
}
else if (gGameModeSub1 != 0)
{
RoomUpdateAnimatedGraphicsAndPalettes();
SpriteUpdate();
if (!gDisableDrawingSamusAndScrolling)
{
ScrollProcessGeneral();
SamusCallGFXFunctions();
}
else if (gDisableScrolling == 2)
ScrollProcessGeneral();
ProjectileUpdate();
HUDDraw();
SpriteDrawAll_2();
ParticleProcessAll();
ProjectileDrawAllStatusFalse();
if (!gDisableDrawingSprites)
SpriteDrawAll();
if (!gDisableDrawingSamusAndScrolling)
SamusDraw();
SpriteDrawAll_Upper();
ProjectileDrawAllStatusTrue();
ResetFreeOAM();
RoomUpdate();
if (gGameModeSub1 == SUB_GAME_MODE_PLAYING)
SamusCallCheckLowHealth();
}
return changing;
}
/**