summaryrefslogtreecommitdiff
path: root/src/secret_base_80bb4ac.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/secret_base_80bb4ac.c')
-rwxr-xr-xsrc/secret_base_80bb4ac.c284
1 files changed, 282 insertions, 2 deletions
diff --git a/src/secret_base_80bb4ac.c b/src/secret_base_80bb4ac.c
index a0fbb1212..2c0b7a388 100755
--- a/src/secret_base_80bb4ac.c
+++ b/src/secret_base_80bb4ac.c
@@ -13,9 +13,12 @@
#include "palette.h"
#include "decoration.h"
#include "field_weather.h"
+#include "metatile_behavior.h"
extern u8 gUnknown_020387DC;
extern u16 gSpecialVar_0x8004;
+extern u16 gSpecialVar_0x8005;
+extern u16 gSpecialVar_0x8006;
extern u16 gSpecialVar_0x8007;
extern u16 gScriptResult;
extern const struct
@@ -46,7 +49,7 @@ void sub_80BB4AC(struct SecretBaseRecord *record) // 080bb4ac
record->sbr_field_1_6 = 0;
for (i=0; i<16; i++) {
record->decorations[i] = 0;
- record->sbr_field_22[i] = 0;
+ record->decorationPos[i] = 0;
}
for (i=0; i<6; i++) {
for (j=0; j<4; j++) {
@@ -321,7 +324,7 @@ void sub_80BBCCC(u8 flagIn)
curBaseId = VarGet(VAR_0x4054);
for (x=0; x<16; x++) {
if ((u8)(gSaveBlock1.secretBases[curBaseId].decorations[x] - 1) <= 0x77 && gDecorations[gSaveBlock1.secretBases[curBaseId].decorations[x]].decor_field_11 != 4) {
- sub_80FF394((gSaveBlock1.secretBases[0].sbr_field_22[x] >> 4) + 7, (gSaveBlock1.secretBases[0].sbr_field_22[x] & 0xF) + 7, gSaveBlock1.secretBases[curBaseId].decorations[x]);
+ sub_80FF394((gSaveBlock1.secretBases[0].decorationPos[x] >> 4) + 7, (gSaveBlock1.secretBases[0].decorationPos[x] & 0xF) + 7, gSaveBlock1.secretBases[curBaseId].decorations[x]);
}
}
if (curBaseId != 0) {
@@ -333,6 +336,52 @@ void sub_80BBCCC(u8 flagIn)
}
}
}
+
+void sub_80BBDD0(void)
+{
+ u8 *roomdecor;
+ u8 *roomdecorpos;
+ u8 ndecor;
+ u8 decidx;
+ u8 objid = 0;
+ u8 metatile;
+ u16 curBase = VarGet(VAR_0x4054);
+ if (!CurrentMapIsSecretBase()) {
+ roomdecor = gSaveBlock1.playerRoomDecor;
+ roomdecorpos = gSaveBlock1.playerRoomDecorPos;
+ ndecor = 12;
+ } else {
+ roomdecor = gSaveBlock1.secretBases[curBase].decorations;
+ roomdecorpos = gSaveBlock1.secretBases[curBase].decorationPos;
+ ndecor = 16;
+ }
+ for (decidx=0; decidx<ndecor; decidx++) {
+ if (roomdecor[decidx] == 0)
+ continue;
+ if (gDecorations[roomdecor[decidx]].decor_field_11 != 4)
+ continue;
+ for (objid=0; objid<gMapHeader.events->mapObjectCount; objid++) {
+ if (gMapHeader.events->mapObjects[objid].flagId == gSpecialVar_0x8004 + 0xAE)
+ break;
+ }
+ if (objid != gMapHeader.events->mapObjectCount) {
+ gSpecialVar_0x8006 = roomdecorpos[decidx] >> 4;
+ gSpecialVar_0x8007 = roomdecorpos[decidx] & 0xF;
+ metatile = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
+ if (sub_80572D8(metatile) == 1 || sub_80572EC(metatile) == 1) {
+ gScriptResult = gMapHeader.events->mapObjects[objid].graphicsId + 0x3f20;
+ VarSet(gScriptResult, gDecorations[roomdecor[decidx]].tiles[0]);
+ gScriptResult = gMapHeader.events->mapObjects[objid].localId;
+ FlagReset(gSpecialVar_0x8004 + 0xAE);
+ show_sprite(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
+ sub_805C0F8(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
+ sub_805C78C(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
+ gSpecialVar_0x8004 ++;
+ }
+ }
+ }
+}
+
#else
__attribute__((naked))
void sub_80BBCCC(u8 flagIn)
@@ -459,4 +508,235 @@ _080BBDC8: .4byte 0x00004089\n\
_080BBDCC: .4byte 0x00000e0a\n\
.syntax divided\n");
}
+
+__attribute__((naked))
+void sub_80BBDD0(void)
+{
+ asm(".syntax unified\n\
+ push {r4-r7,lr}\n\
+ mov r7, r10\n\
+ mov r6, r9\n\
+ mov r5, r8\n\
+ push {r5-r7}\n\
+ sub sp, 0x14\n\
+ ldr r0, _080BBE00 @ =0x00004054\n\
+ bl VarGet\n\
+ lsls r0, 16\n\
+ lsrs r4, r0, 16\n\
+ bl CurrentMapIsSecretBase\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ bne _080BBE08\n\
+ ldr r0, _080BBE04 @ =gSaveBlock1 + 0x2688\n\
+ str r0, [sp, 0x4]\n\
+ adds r0, 0xC\n\
+ str r0, [sp, 0x8]\n\
+ movs r1, 0xC\n\
+ str r1, [sp, 0xC]\n\
+ b _080BBE1E\n\
+ .align 2, 0\n\
+_080BBE00: .4byte 0x00004054\n\
+_080BBE04: .4byte gSaveBlock1 + 0x2688\n\
+_080BBE08:\n\
+ lsls r1, r4, 2\n\
+ adds r1, r4\n\
+ lsls r1, 5\n\
+ ldr r0, _080BBF7C @ =gSaveBlock1 + 0x1A1A\n\
+ adds r2, r1, r0\n\
+ str r2, [sp, 0x4]\n\
+ adds r0, 0x10\n\
+ adds r1, r0\n\
+ str r1, [sp, 0x8]\n\
+ movs r3, 0x10\n\
+ str r3, [sp, 0xC]\n\
+_080BBE1E:\n\
+ movs r6, 0\n\
+ ldr r4, [sp, 0xC]\n\
+ cmp r6, r4\n\
+ bcc _080BBE28\n\
+ b _080BBF6C\n\
+_080BBE28:\n\
+ ldr r5, _080BBF80 @ =gSaveBlock1\n\
+ mov r10, r5\n\
+_080BBE2C:\n\
+ ldr r1, [sp, 0x4]\n\
+ adds r0, r1, r6\n\
+ ldrb r1, [r0]\n\
+ mov r9, r0\n\
+ adds r2, r6, 0x1\n\
+ str r2, [sp, 0x10]\n\
+ cmp r1, 0\n\
+ bne _080BBE3E\n\
+ b _080BBF5E\n\
+_080BBE3E:\n\
+ ldrb r0, [r0]\n\
+ lsls r0, 5\n\
+ ldr r3, _080BBF84 @ =gDecorations\n\
+ adds r0, r3\n\
+ ldrb r0, [r0, 0x11]\n\
+ cmp r0, 0x4\n\
+ beq _080BBE4E\n\
+ b _080BBF5E\n\
+_080BBE4E:\n\
+ movs r5, 0\n\
+ ldr r0, _080BBF88 @ =gMapHeader\n\
+ ldr r2, [r0, 0x4]\n\
+ ldrb r3, [r2]\n\
+ mov r8, r0\n\
+ cmp r5, r3\n\
+ bcs _080BBE8E\n\
+ ldr r0, [r2, 0x4]\n\
+ ldrh r1, [r0, 0x14]\n\
+ ldr r4, _080BBF8C @ =gSpecialVar_0x8004\n\
+ ldrh r0, [r4]\n\
+ adds r0, 0xAE\n\
+ adds r7, r4, 0\n\
+ cmp r1, r0\n\
+ beq _080BBE8E\n\
+ adds r4, r2, 0\n\
+ adds r2, r3, 0\n\
+_080BBE70:\n\
+ adds r0, r5, 0x1\n\
+ lsls r0, 24\n\
+ lsrs r5, r0, 24\n\
+ cmp r5, r2\n\
+ bcs _080BBE8E\n\
+ ldr r1, [r4, 0x4]\n\
+ lsls r0, r5, 1\n\
+ adds r0, r5\n\
+ lsls r0, 3\n\
+ adds r0, r1\n\
+ ldrh r1, [r0, 0x14]\n\
+ ldrh r0, [r7]\n\
+ adds r0, 0xAE\n\
+ cmp r1, r0\n\
+ bne _080BBE70\n\
+_080BBE8E:\n\
+ mov r1, r8\n\
+ ldr r0, [r1, 0x4]\n\
+ ldrb r0, [r0]\n\
+ cmp r5, r0\n\
+ beq _080BBF5E\n\
+ ldr r7, _080BBF90 @ =gSpecialVar_0x8006\n\
+ ldr r2, [sp, 0x8]\n\
+ adds r1, r2, r6\n\
+ ldrb r0, [r1]\n\
+ lsrs r0, 4\n\
+ strh r0, [r7]\n\
+ ldr r6, _080BBF94 @ =gSpecialVar_0x8007\n\
+ ldrb r1, [r1]\n\
+ movs r0, 0xF\n\
+ ands r0, r1\n\
+ strh r0, [r6]\n\
+ ldrh r0, [r7]\n\
+ adds r0, 0x7\n\
+ ldrh r1, [r6]\n\
+ adds r1, 0x7\n\
+ bl MapGridGetMetatileBehaviorAt\n\
+ lsls r0, 24\n\
+ lsrs r4, r0, 24\n\
+ adds r0, r4, 0\n\
+ bl sub_80572D8\n\
+ lsls r0, 24\n\
+ lsrs r0, 24\n\
+ cmp r0, 0x1\n\
+ beq _080BBEDA\n\
+ adds r0, r4, 0\n\
+ bl sub_80572EC\n\
+ lsls r0, 24\n\
+ lsrs r0, 24\n\
+ cmp r0, 0x1\n\
+ bne _080BBF5E\n\
+_080BBEDA:\n\
+ mov r3, r8\n\
+ ldr r0, [r3, 0x4]\n\
+ ldr r1, [r0, 0x4]\n\
+ lsls r4, r5, 1\n\
+ adds r4, r5\n\
+ lsls r4, 3\n\
+ adds r1, r4, r1\n\
+ ldr r5, _080BBF98 @ =0x00003f20\n\
+ adds r0, r5, 0\n\
+ ldrb r1, [r1, 0x1]\n\
+ adds r0, r1\n\
+ ldr r1, _080BBF9C @ =gScriptResult\n\
+ strh r0, [r1]\n\
+ ldrh r0, [r1]\n\
+ mov r2, r9\n\
+ ldrb r1, [r2]\n\
+ lsls r1, 5\n\
+ ldr r3, _080BBFA0 @ =gDecorations + 0x1C\n\
+ adds r1, r3\n\
+ ldr r1, [r1]\n\
+ ldrh r1, [r1]\n\
+ bl VarSet\n\
+ mov r5, r8\n\
+ ldr r0, [r5, 0x4]\n\
+ ldr r0, [r0, 0x4]\n\
+ adds r4, r0\n\
+ ldrb r0, [r4]\n\
+ ldr r1, _080BBF9C @ =gScriptResult\n\
+ strh r0, [r1]\n\
+ ldr r2, _080BBF8C @ =gSpecialVar_0x8004\n\
+ ldrh r0, [r2]\n\
+ adds r0, 0xAE\n\
+ lsls r0, 16\n\
+ lsrs r0, 16\n\
+ bl FlagReset\n\
+ ldr r3, _080BBF9C @ =gScriptResult\n\
+ ldrb r0, [r3]\n\
+ mov r4, r10\n\
+ ldrb r1, [r4, 0x5]\n\
+ ldrb r2, [r4, 0x4]\n\
+ bl show_sprite\n\
+ ldr r5, _080BBF9C @ =gScriptResult\n\
+ ldrb r0, [r5]\n\
+ ldrb r1, [r4, 0x5]\n\
+ ldrb r2, [r4, 0x4]\n\
+ movs r4, 0\n\
+ ldrsh r3, [r7, r4]\n\
+ movs r5, 0\n\
+ ldrsh r4, [r6, r5]\n\
+ str r4, [sp]\n\
+ bl sub_805C0F8\n\
+ ldr r1, _080BBF9C @ =gScriptResult\n\
+ ldrb r0, [r1]\n\
+ mov r2, r10\n\
+ ldrb r1, [r2, 0x5]\n\
+ ldrb r2, [r2, 0x4]\n\
+ bl sub_805C78C\n\
+ ldr r3, _080BBF8C @ =gSpecialVar_0x8004\n\
+ ldrh r0, [r3]\n\
+ adds r0, 0x1\n\
+ strh r0, [r3]\n\
+_080BBF5E:\n\
+ ldr r4, [sp, 0x10]\n\
+ lsls r0, r4, 24\n\
+ lsrs r6, r0, 24\n\
+ ldr r5, [sp, 0xC]\n\
+ cmp r6, r5\n\
+ bcs _080BBF6C\n\
+ b _080BBE2C\n\
+_080BBF6C:\n\
+ add sp, 0x14\n\
+ pop {r3-r5}\n\
+ mov r8, r3\n\
+ mov r9, r4\n\
+ mov r10, r5\n\
+ pop {r4-r7}\n\
+ pop {r0}\n\
+ bx r0\n\
+ .align 2, 0\n\
+_080BBF7C: .4byte gSaveBlock1 + 0x1A1A\n\
+_080BBF80: .4byte gSaveBlock1\n\
+_080BBF84: .4byte gDecorations\n\
+_080BBF88: .4byte gMapHeader\n\
+_080BBF8C: .4byte gSpecialVar_0x8004\n\
+_080BBF90: .4byte gSpecialVar_0x8006\n\
+_080BBF94: .4byte gSpecialVar_0x8007\n\
+_080BBF98: .4byte 0x00003f20\n\
+_080BBF9C: .4byte gScriptResult\n\
+_080BBFA0: .4byte gDecorations + 0x1C\n\
+.syntax divided\n");
+}
#endif