Link bg_clip.c

This commit is contained in:
y.demaisonregne 2023-06-24 15:48:52 +02:00
parent 187ce2b4e0
commit 944a46e7cb
11 changed files with 1454 additions and 3251 deletions

View File

@ -832,7 +832,7 @@ lbl_080566c0: .4byte 0x02030800
RoomRemoveNeverReformBlocksAndCollectedTanks: @ 0x080566c4
push {lr}
bl remove_never_reform_blocks
bl remove_collected_tanks
bl BgClipRemoveCollectedTanks
pop {r0}
bx r0
.align 2, 0
@ -2029,7 +2029,7 @@ lbl_08057042:
ldrsh r0, [r4, r1]
cmp r0, #2
bne lbl_0805706c
bl check_special_clipdata
bl BgClipCheckTouchingSpecialClipdata
movs r1, #0
ldrsh r0, [r4, r1]
cmp r0, #2

File diff suppressed because it is too large Load Diff

1376
asm/disasm_0x0805b24c.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -284,14 +284,14 @@ lbl_0805e96e:
ldrb r1, [r4, #6]
ldrb r2, [r4, #5]
adds r0, r7, #0
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
movs r0, #0x10
adds r0, r0, r7
mov r8, r0
ldrb r1, [r4, #6]
adds r1, #1
ldrb r2, [r4, #5]
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
adds r1, r7, #0
adds r1, #0x20
str r1, [sp]
@ -299,14 +299,14 @@ lbl_0805e96e:
adds r1, #2
ldrb r2, [r4, #5]
ldr r0, [sp]
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
adds r5, r7, #0
adds r5, #0x30
ldrb r1, [r4, #6]
adds r1, #3
ldrb r2, [r4, #5]
adds r0, r5, #0
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
mov r6, r8
ldr r3, [sp]
mov r8, r3
@ -319,14 +319,14 @@ lbl_0805e9c0:
ldrb r1, [r4, #6]
ldrb r2, [r4, #5]
adds r0, r7, #0
bl set_raw_bg1_block_value
bl BgClipSetRawBG1BlockValue
movs r0, #0x10
adds r0, r0, r7
mov r8, r0
ldrb r1, [r4, #6]
adds r1, #1
ldrb r2, [r4, #5]
bl set_raw_bg1_block_value
bl BgClipSetRawBG1BlockValue
movs r1, #0x20
adds r1, r1, r7
mov sb, r1
@ -334,14 +334,14 @@ lbl_0805e9c0:
adds r1, #2
ldrb r2, [r4, #5]
mov r0, sb
bl set_raw_bg1_block_value
bl BgClipSetRawBG1BlockValue
adds r5, r7, #0
adds r5, #0x30
ldrb r1, [r4, #6]
adds r1, #3
ldrb r2, [r4, #5]
adds r0, r5, #0
bl set_raw_bg1_block_value
bl BgClipSetRawBG1BlockValue
mov r6, r8
mov r8, sb
lbl_0805ea04:
@ -351,26 +351,26 @@ lbl_0805ea04:
add r4, sl
ldrb r1, [r4, #6]
ldrb r2, [r4, #5]
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
lsls r0, r6, #0x10
lsrs r0, r0, #0x10
ldrb r1, [r4, #6]
adds r1, #1
ldrb r2, [r4, #5]
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
mov r3, r8
lsls r0, r3, #0x10
lsrs r0, r0, #0x10
ldrb r1, [r4, #6]
adds r1, #2
ldrb r2, [r4, #5]
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
lsls r0, r5, #0x10
lsrs r0, r0, #0x10
ldrb r1, [r4, #6]
adds r1, #3
ldrb r2, [r4, #5]
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
add sp, #4
pop {r3, r4, r5}
mov r8, r3
@ -441,25 +441,25 @@ lbl_0805eabc:
ldrb r1, [r4, #6]
ldrb r2, [r4, #5]
adds r0, r5, #0
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
adds r0, r5, #0
adds r0, #0x10
ldrb r1, [r4, #6]
adds r1, #1
ldrb r2, [r4, #5]
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
adds r0, r5, #0
adds r0, #0x20
ldrb r1, [r4, #6]
adds r1, #2
ldrb r2, [r4, #5]
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
adds r0, r5, #0
adds r0, #0x30
ldrb r1, [r4, #6]
adds r1, #3
ldrb r2, [r4, #5]
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
ldrb r2, [r4, #1]
lsls r1, r2, #0x18
lsrs r0, r1, #0x1c
@ -513,39 +513,39 @@ sub_0805eb18: @ 0x0805eb18
ldrb r1, [r5, #6]
ldrb r2, [r5, #5]
adds r0, r4, #0
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
adds r6, r4, #0
adds r6, #0x10
ldrb r1, [r5, #6]
adds r1, #1
ldrb r2, [r5, #5]
adds r0, r6, #0
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
movs r0, #0x20
adds r0, r0, r4
mov r8, r0
ldrb r1, [r5, #6]
adds r1, #2
ldrb r2, [r5, #5]
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
movs r0, #0x30
adds r0, r0, r4
mov sb, r0
ldrb r1, [r5, #6]
adds r1, #3
ldrb r2, [r5, #5]
bl set_bg1_block_value
bl BgClipSetBG1BlockValue
ldrb r1, [r5, #6]
ldrb r2, [r5, #5]
adds r0, r4, #0
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
lsls r6, r6, #0x10
lsrs r6, r6, #0x10
ldrb r1, [r5, #6]
adds r1, #1
ldrb r2, [r5, #5]
adds r0, r6, #0
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
mov r0, r8
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
@ -553,7 +553,7 @@ sub_0805eb18: @ 0x0805eb18
ldrb r1, [r5, #6]
adds r1, #2
ldrb r2, [r5, #5]
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
mov r0, sb
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
@ -561,7 +561,7 @@ sub_0805eb18: @ 0x0805eb18
ldrb r1, [r5, #6]
adds r1, #3
ldrb r2, [r5, #5]
bl set_clipdata_block_value
bl BgClipSetClipdataBlockValue
ldrb r1, [r5, #1]
movs r0, #4
rsbs r0, r0, #0
@ -585,8 +585,8 @@ sub_0805eb18: @ 0x0805eb18
lbl_0805ebe8: .4byte gHatchData
lbl_0805ebec: .4byte 0x083602c8
thumb_func_start check_enter_door
check_enter_door: @ 0x0805ebf0
thumb_func_start ConnectionCheckEnterDoor
ConnectionCheckEnterDoor: @ 0x0805ebf0
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, sb
@ -798,8 +798,8 @@ lbl_0805ed84:
bx r1
.align 2, 0
thumb_func_start check_area_connection
check_area_connection: @ 0x0805ed94
thumb_func_start ConnectionCheckAreaConnection
ConnectionCheckAreaConnection: @ 0x0805ed94
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, sb
@ -1119,8 +1119,8 @@ lbl_0805effa:
pop {r1}
bx r1
thumb_func_start set_hatch_as_opened
set_hatch_as_opened: @ 0x0805f004
thumb_func_start ConnectionSetHatchAsOpened
ConnectionSetHatchAsOpened: @ 0x0805f004
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
@ -1758,7 +1758,7 @@ lbl_0805f4b0:
bls lbl_0805f4da
ldrb r1, [r1, #7]
movs r0, #0
bl set_hatch_as_opened
bl ConnectionSetHatchAsOpened
cmp r0, #0
bne lbl_0805f4da
lsls r0, r4, #0x18
@ -1832,7 +1832,7 @@ lbl_0805f53e:
adds r0, r0, r1
ldrh r1, [r0]
adds r0, r1, #0
bl check_clipdata_behavior_change_bldalpha
bl BgClipGetNewBldalphaValue
lsls r0, r0, #0x10
lsrs r1, r0, #0x10
cmp r1, #0

View File

@ -9387,8 +9387,8 @@ lbl_0806cbc8:
pop {r0}
bx r0
thumb_func_start update_minimap_square_for_collected_item
update_minimap_square_for_collected_item: @ 0x0806cbd8
thumb_func_start MinimapUpdateForCollectedItem
MinimapUpdateForCollectedItem: @ 0x0806cbd8
push {r4, r5, r6, r7, lr}
lsls r0, r0, #0x18
lsrs r2, r0, #0x18
@ -9453,8 +9453,8 @@ lbl_0806cc5c: .4byte 0x02034000
lbl_0806cc60: .4byte 0x02034800
lbl_0806cc64: .4byte gUpdateMinimapFlag
thumb_func_start sub_0806cc68
sub_0806cc68: @ 0x0806cc68
thumb_func_start MinimapCheckIsTileExplored
MinimapCheckIsTileExplored: @ 0x0806cc68
push {r4, r5, r6, r7, lr}
lsls r0, r0, #0x18
lsrs r2, r0, #0x18

View File

@ -1842,7 +1842,7 @@ lbl_0806f218:
strb r2, [r0]
cmp r1, #7
bls lbl_0806f234
bl finish_collecting_ability
bl BgClipFinishCollectingAbility
lbl_0806f234:
ldr r1, lbl_0806f244 @ =gCurrentMessage
ldrb r0, [r1, #0xc]
@ -2057,7 +2057,7 @@ lbl_0806f3c4:
strb r2, [r0]
cmp r1, #7
bls lbl_0806f3e0
bl finish_collecting_ability
bl BgClipFinishCollectingAbility
lbl_0806f3e0:
ldr r1, lbl_0806f3f0 @ =gCurrentMessage
ldrb r0, [r1, #0xc]

View File

@ -17,7 +17,7 @@ void BgClipCheckTouchingTransitionOnElevator(void);
void BgClipCheckTouchingTransitionOrTank(void);
void BgClipFinishCollectingTank(void);
void BgClipFinishCollectingAbility(void);
void BgClipCheckGrabbingCrumnbleBlock(u8 dontDestroy);
void BgClipCheckGrabbingCrumbleBlock(u8 dontDestroy);
u8 BgClipCheckOpeningHatch(u16 xPosition, u16 yPosition);
void BgClipSetItemAsCollected(u16 xPosition, u16 yPosition, u8 type);
void BgClipRemoveCollectedTanks(void);

View File

@ -10,7 +10,7 @@ void ConnectionUpdateHatchAnimation(u8 dontSetRaw, u32 hatch);
void ConnectionHatchFlashingAnimation(u8 hatch);
void ConnectionOverrideOpenedHatch(u8 hatch, u32 type);
u32 ConnectionCheckEnterDoor(u16 yPosition, u16 xPosition);
u8 ConnectionCheckAreaConnection(u16 yPosition, u16 xPosition);
u32 ConnectionCheckAreaConnection(u16 yPosition, u16 xPosition);
void ConnectionProcessDoorType(u8 type);
u8 ConnectionFindEventBasedDoor(u8 sourceDoor);
u32 ConnectionSetHatchAsOpened(u8 action, u8 hatch);

View File

@ -511,6 +511,8 @@ SECTIONS {
src/room_cutscene.o(.text);
src/clipdata.o(.text);
asm/disasm_0x080582c4.o(.text);
src/bg_clip.o(.text);
asm/disasm_0x0805b24c.o(.text);
src/color_fading.o(.text);
asm/disasm_0x0805cfe0.o(.text);
src/animated_graphics.o(.text);

View File

@ -1,6 +1,5 @@
#include "gba.h"
#include "bg_clip.h"
#include "transparency.h"
#include "block.h"
#include "minimap.h"
#include "connection.h"
@ -144,12 +143,17 @@ void BgClipSetClipdataBlockValue(u16 value, u16 yPosition, u16 xPosition)
*/
void BgClipCheckTouchingSpecialClipdata(void)
{
BgClipCheckGrabbingCrumnbleBlock(FALSE);
BgClipCheckGrabbingCrumbleBlock(FALSE);
if (gSamusData.pose == SPOSE_USING_AN_ELEVATOR)
BgClipCheckTouchingTransitionOnElevator();
else if (!gDisableDoorAndTanks)
{
if (gFrameCounter8Bit & 0x1)
BgClipCheckTouchingTransitionOnElevator();
return;
}
if (!gDisableDoorAndTanks)
{
if (gFrameCounter8Bit & 1)
BgClipCheckTouchingTransitionOrTank();
else if (!gDisableClipdataChangingTransparency)
BgClipApplyClipdataChangingTransparency();
@ -573,7 +577,7 @@ void BgClipFinishCollectingTank(void)
clipdata = 0;
BgClipSetBG1BlockValue(0, gLastTankCollected.yPosition, gLastTankCollected.xPosition);
BgClipSetBG1BlockValue(clipdata, gLastTankCollected.yPosition, gLastTankCollected.xPosition);
BgClipSetClipdataBlockValue(clipdata, gLastTankCollected.yPosition, gLastTankCollected.xPosition);
BgClipSetItemAsCollected(gLastTankCollected.xPosition, gLastTankCollected.yPosition, sTankBehaviors[tank].itemType);
MinimapUpdateForCollectedItem(gLastTankCollected.xPosition, gLastTankCollected.yPosition);
}
@ -590,7 +594,7 @@ void BgClipFinishCollectingAbility(void)
*
* @param dontDestroy
*/
void BgClipCheckGrabbingCrumnbleBlock(u8 dontDestroy)
void BgClipCheckGrabbingCrumbleBlock(u8 dontDestroy)
{
u8 setPose;
s32 yOffset;
@ -634,7 +638,7 @@ void BgClipCheckGrabbingCrumnbleBlock(u8 dontDestroy)
// Destroy block
if (BlockStoreBrokenReformBlock(BLOCK_TYPE_SLOW_CRUMBLE, xPosition, yPosition, TRUE))
{
BgClipSetBG1BlockValue(0x401, yPosition, xPosition);
BgClipSetBG1BlockValue(CLIPDATA_TILEMAP_FLAG | CLIPDATA_TILEMAP_SOLID, yPosition, xPosition);
BgClipSetClipdataBlockValue(CLIPDATA_TILEMAP_FLAG | CLIPDATA_TILEMAP_SOLID, yPosition, xPosition);
setPose = FALSE;
}
@ -706,7 +710,7 @@ u8 BgClipCheckOpeningHatch(u16 xPosition, u16 yPosition)
if (gHatchData[i].hits >= sHatchBehaviors[gHatchData[i].type][1])
{
// Unlock
gHatchData[i].locked = FALSE;
gHatchData[i].flashingTimer = FALSE;
gHatchData[i].opening = TRUE;
// Set hatch as opened
@ -716,12 +720,12 @@ u8 BgClipCheckOpeningHatch(u16 xPosition, u16 yPosition)
ConnectionSetHatchAsOpened(HATCH_ACTION_SETTING_SOURCE, gHatchData[i].sourceDoor);
}
else
gHatchData[i].flashingTimer = 0x1; // Set flashing
gHatchData[i].flashingTimer = 1; // Set flashing
}
else
gHatchData[i].hits = 0x0; // Locked, reset
gHatchData[i].hits = 0; // Locked, reset
gHatchData[i].hitTimer = 0x0;
gHatchData[i].hitTimer = 0;
break;
}
}
@ -744,7 +748,7 @@ void BgClipSetItemAsCollected(u16 xPosition, u16 yPosition, u8 type)
u8* pItem;
s32 limit;
if (gCurrentArea > MAX_AMOUNT_OF_AREAS)
if (gCurrentArea >= MAX_AMOUNT_OF_AREAS)
return;
i = gCurrentArea;
@ -788,7 +792,7 @@ void BgClipRemoveCollectedTanks(void)
if (gPauseScreenFlag != PAUSE_SCREEN_NONE)
return;
if (gCurrentArea > MAX_AMOUNT_OF_AREAS)
if (gCurrentArea >= MAX_AMOUNT_OF_AREAS)
return;
i = gCurrentArea;

View File

@ -312,7 +312,7 @@ u32 ConnectionCheckEnterDoor(u16 yPosition, u16 xPosition)
* @param xPosition X Position
* @return u8 Could enter
*/
u8 ConnectionCheckAreaConnection(u16 yPosition, u16 xPosition)
u32 ConnectionCheckAreaConnection(u16 yPosition, u16 xPosition)
{
const struct Door* pDoor;
struct HatchData* pHatch;