decompile braille_puzzles.c

This commit is contained in:
ProjectRevoTPP 2017-10-05 13:02:39 -04:00
parent 09d5d81c9c
commit e7175999f5
7 changed files with 592 additions and 636 deletions

View File

@ -1,627 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_81795E8
sub_81795E8: @ 81795E8
push {lr}
ldr r0, =0x000008af
bl FlagGet
lsls r0, 24
cmp r0, 0
bne _08179634
ldr r0, =gSaveBlock1Ptr
ldr r2, [r0]
ldrh r1, [r2, 0x4]
ldr r0, =0x00004718
cmp r1, r0
bne _08179634
ldr r1, [r2]
ldr r0, =0x0003000a
cmp r1, r0
beq _08179616
ldr r0, =0x00030009
cmp r1, r0
beq _08179616
ldr r0, =0x0003000b
cmp r1, r0
bne _08179634
_08179616:
movs r0, 0x1
b _08179636
.pool
_08179634:
movs r0, 0
_08179636:
pop {r1}
bx r1
thumb_func_end sub_81795E8
thumb_func_start sub_817963C
sub_817963C: @ 817963C
push {lr}
ldr r2, =0x0000022a
movs r0, 0x10
movs r1, 0x8
bl MapGridSetMetatileIdAt
ldr r2, =0x0000022b
movs r0, 0x11
movs r1, 0x8
bl MapGridSetMetatileIdAt
movs r2, 0x8B
lsls r2, 2
movs r0, 0x12
movs r1, 0x8
bl MapGridSetMetatileIdAt
ldr r2, =0x00000e32
movs r0, 0x10
movs r1, 0x9
bl MapGridSetMetatileIdAt
ldr r2, =0x00000233
movs r0, 0x11
movs r1, 0x9
bl MapGridSetMetatileIdAt
ldr r2, =0x00000e34
movs r0, 0x12
movs r1, 0x9
bl MapGridSetMetatileIdAt
bl DrawWholeMapView
movs r0, 0x14
bl PlaySE
ldr r0, =0x000008af
bl FlagSet
bl ScriptContext2_Disable
pop {r0}
bx r0
.pool
thumb_func_end sub_817963C
thumb_func_start sub_81796AC
sub_81796AC: @ 81796AC
push {r4,lr}
ldr r4, =gPlayerParty
adds r0, r4, 0
movs r1, 0x41
movs r2, 0
bl GetMonData
movs r1, 0x9D
lsls r1, 1
cmp r0, r1
bne _081796F4
bl CalculatePlayerPartyCount
ldr r0, =gPlayerPartyCount
ldrb r1, [r0]
movs r0, 0x64
muls r0, r1
adds r1, r4, 0
subs r1, 0x64
adds r0, r1
movs r1, 0x41
movs r2, 0
bl GetMonData
ldr r1, =0x0000017d
cmp r0, r1
bne _081796F4
movs r0, 0x1
b _081796F6
.pool
_081796F4:
movs r0, 0
_081796F6:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_81796AC
thumb_func_start nullsub_84
nullsub_84: @ 81796FC
bx lr
thumb_func_end nullsub_84
thumb_func_start sub_8179700
sub_8179700: @ 8179700
push {lr}
ldr r0, =sub_8179778
movs r1, 0x9
bl CreateTask
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
movs r0, 0
strh r0, [r1, 0xA]
strh r0, [r1, 0xC]
movs r0, 0x2
strh r0, [r1, 0x10]
movs r0, 0x5
strh r0, [r1, 0x12]
movs r0, 0x32
strh r0, [r1, 0x14]
movs r0, 0
bl SetCameraPanningCallback
pop {r0}
bx r0
.pool
thumb_func_end sub_8179700
thumb_func_start sub_817973C
sub_817973C: @ 817973C
push {lr}
ldr r0, =sub_8179778
movs r1, 0x9
bl CreateTask
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
movs r0, 0
strh r0, [r1, 0xA]
strh r0, [r1, 0xC]
movs r0, 0x3
strh r0, [r1, 0x10]
movs r0, 0x5
strh r0, [r1, 0x12]
movs r0, 0x2
strh r0, [r1, 0x14]
movs r0, 0
bl SetCameraPanningCallback
pop {r0}
bx r0
.pool
thumb_func_end sub_817973C
thumb_func_start sub_8179778
sub_8179778: @ 8179778
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks
adds r4, r0, r1
ldrh r0, [r4, 0xA]
adds r0, 0x1
strh r0, [r4, 0xA]
movs r1, 0xA
ldrsh r0, [r4, r1]
movs r2, 0x12
ldrsh r1, [r4, r2]
bl __modsi3
cmp r0, 0
bne _081797D0
strh r0, [r4, 0xA]
ldrh r0, [r4, 0xC]
adds r0, 0x1
strh r0, [r4, 0xC]
ldrh r0, [r4, 0x10]
negs r0, r0
strh r0, [r4, 0x10]
movs r0, 0x10
ldrsh r1, [r4, r0]
movs r0, 0
bl SetCameraPanning
movs r2, 0xC
ldrsh r1, [r4, r2]
movs r2, 0x14
ldrsh r0, [r4, r2]
cmp r1, r0
bne _081797D0
adds r0, r5, 0
bl DestroyTask
bl EnableBothScriptContexts
bl InstallCameraPanAheadCallback
_081797D0:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8179778
thumb_func_start sub_81797DC
sub_81797DC: @ 81797DC
push {lr}
movs r0, 0x8B
lsls r0, 4
bl FlagGet
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0
bne _0817982C
ldr r0, =gSaveBlock1Ptr
ldr r3, [r0]
ldrh r1, [r3, 0x4]
movs r0, 0xC3
lsls r0, 3
cmp r1, r0
bne _0817982C
ldr r1, [r3]
ldr r0, =0x00170006
cmp r1, r0
beq _08179810
ldr r0, =0x00170005
cmp r1, r0
beq _08179810
ldr r0, =0x00170007
cmp r1, r0
bne _0817982C
_08179810:
ldr r0, =gUnknown_0203BD14
strb r2, [r0]
movs r0, 0x1
b _0817982E
.pool
_0817982C:
movs r0, 0
_0817982E:
pop {r1}
bx r1
thumb_func_end sub_81797DC
thumb_func_start sub_8179834
sub_8179834: @ 8179834
push {lr}
bl brm_get_pokemon_selection
ldr r1, =gFieldEffectSpawnParams
lsls r0, 24
lsrs r0, 24
str r0, [r1]
movs r0, 0x3C
bl FieldEffectStart
pop {r0}
bx r0
.pool
thumb_func_end sub_8179834
thumb_func_start sub_8179850
sub_8179850: @ 8179850
push {lr}
movs r0, 0x3C
bl FieldEffectActiveListRemove
bl sub_8179860
pop {r0}
bx r0
thumb_func_end sub_8179850
thumb_func_start sub_8179860
sub_8179860: @ 8179860
push {lr}
ldr r2, =0x0000022a
movs r0, 0xE
movs r1, 0x1A
bl MapGridSetMetatileIdAt
ldr r2, =0x0000022b
movs r0, 0xF
movs r1, 0x1A
bl MapGridSetMetatileIdAt
movs r2, 0x8B
lsls r2, 2
movs r0, 0x10
movs r1, 0x1A
bl MapGridSetMetatileIdAt
ldr r2, =0x00000e32
movs r0, 0xE
movs r1, 0x1B
bl MapGridSetMetatileIdAt
ldr r2, =0x00000233
movs r0, 0xF
movs r1, 0x1B
bl MapGridSetMetatileIdAt
ldr r2, =0x00000e34
movs r0, 0x10
movs r1, 0x1B
bl MapGridSetMetatileIdAt
bl DrawWholeMapView
movs r0, 0x14
bl PlaySE
movs r0, 0x8B
lsls r0, 4
bl FlagSet
bl ScriptContext2_Disable
pop {r0}
bx r0
.pool
thumb_func_end sub_8179860
thumb_func_start sub_81798D0
sub_81798D0: @ 81798D0
push {lr}
ldr r0, =0x000008b2
bl FlagGet
lsls r0, 24
cmp r0, 0
bne _08179910
ldr r0, =gSaveBlock1Ptr
ldr r2, [r0]
ldrh r1, [r2, 0x4]
ldr r0, =0x00004418
cmp r1, r0
bne _08179910
ldr r1, [r2]
ldr r0, =0x00190008
cmp r1, r0
bne _08179910
ldr r1, =gUnknown_0203BD14
movs r0, 0x1
strb r0, [r1]
movs r0, 0x1
b _08179912
.pool
_08179910:
movs r0, 0
_08179912:
pop {r1}
bx r1
thumb_func_end sub_81798D0
thumb_func_start sub_8179918
sub_8179918: @ 8179918
push {lr}
bl brm_get_pokemon_selection
ldr r1, =gFieldEffectSpawnParams
lsls r0, 24
lsrs r0, 24
str r0, [r1]
movs r0, 0x3C
bl FieldEffectStart
pop {r0}
bx r0
.pool
thumb_func_end sub_8179918
thumb_func_start sub_8179934
sub_8179934: @ 8179934
push {lr}
movs r0, 0x3C
bl FieldEffectActiveListRemove
bl sub_8179944
pop {r0}
bx r0
thumb_func_end sub_8179934
thumb_func_start sub_8179944
sub_8179944: @ 8179944
push {lr}
ldr r2, =0x0000022a
movs r0, 0xE
movs r1, 0x1A
bl MapGridSetMetatileIdAt
ldr r2, =0x0000022b
movs r0, 0xF
movs r1, 0x1A
bl MapGridSetMetatileIdAt
movs r2, 0x8B
lsls r2, 2
movs r0, 0x10
movs r1, 0x1A
bl MapGridSetMetatileIdAt
ldr r2, =0x00000e32
movs r0, 0xE
movs r1, 0x1B
bl MapGridSetMetatileIdAt
ldr r2, =0x00000233
movs r0, 0xF
movs r1, 0x1B
bl MapGridSetMetatileIdAt
ldr r2, =0x00000e34
movs r0, 0x10
movs r1, 0x1B
bl MapGridSetMetatileIdAt
bl DrawWholeMapView
movs r0, 0x14
bl PlaySE
ldr r0, =0x000008b2
bl FlagSet
bl ScriptContext2_Disable
pop {r0}
bx r0
.pool
thumb_func_end sub_8179944
thumb_func_start nullsub_64
nullsub_64: @ 81799B4
bx lr
thumb_func_end nullsub_64
thumb_func_start sub_81799B8
sub_81799B8: @ 81799B8
push {lr}
bl oei_task_add
lsls r0, 24
lsrs r2, r0, 24
ldr r0, =gUnknown_0203BD14
ldrb r0, [r0]
cmp r0, 0x1
bne _081799E4
ldr r1, =gTasks
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
adds r0, r1
ldr r2, =sub_8179934
b _081799F0
.pool
_081799E4:
ldr r1, =gTasks
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
adds r0, r1
ldr r2, =sub_8179850
_081799F0:
lsrs r1, r2, 16
strh r1, [r0, 0x18]
strh r2, [r0, 0x1A]
movs r0, 0
pop {r1}
bx r1
.pool
thumb_func_end sub_81799B8
thumb_func_start sub_8179A04
sub_8179A04: @ 8179A04
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
ldr r4, =gSaveBlock1Ptr
ldr r0, [r4]
ldrh r1, [r0, 0x4]
ldr r0, =0x00004318
cmp r1, r0
beq _08179A1A
b _08179B5A
_08179A1A:
ldr r0, =0x000008b1
bl FlagGet
lsls r0, 24
cmp r0, 0
beq _08179A28
b _08179B5A
_08179A28:
movs r0, 0x2
bl FlagGet
lsls r0, 24
cmp r0, 0
bne _08179A36
b _08179B5A
_08179A36:
movs r0, 0x3
bl FlagGet
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08179A58
b _08179B5A
.pool
_08179A54:
movs r0, 0x1
b _08179B5C
_08179A58:
movs r5, 0
mov r8, r4
ldr r4, =gUnknown_085EFE74
adds r0, r4, 0x1
mov r12, r0
ldr r6, =0x0000403b
ldr r1, =0x0000403c
mov r9, r1
_08179A68:
lsls r0, r5, 1
adds r1, r0, r4
add r0, r12
ldrb r3, [r0]
mov r7, r8
ldr r2, [r7]
movs r7, 0
ldrsh r0, [r2, r7]
ldrb r1, [r1]
cmp r0, r1
bne _08179B44
movs r1, 0x2
ldrsh r0, [r2, r1]
cmp r0, r3
bne _08179B44
cmp r5, 0xF
bhi _08179AB0
adds r0, r6, 0
bl VarGet
lsls r0, 16
movs r1, 0x80
lsls r1, 9
lsls r1, r5
orrs r1, r0
lsrs r1, 16
adds r0, r6, 0
bl VarSet
b _08179AF0
.pool
_08179AB0:
cmp r5, 0x1F
bhi _08179AD2
mov r0, r9
bl VarGet
lsls r0, 16
adds r2, r5, 0
subs r2, 0x10
movs r1, 0x80
lsls r1, 9
lsls r1, r2
orrs r1, r0
lsrs r1, 16
mov r0, r9
bl VarSet
b _08179AF0
_08179AD2:
ldr r4, =0x0000403d
adds r0, r4, 0
bl VarGet
lsls r0, 16
adds r2, r5, 0
subs r2, 0x20
movs r1, 0x80
lsls r1, 9
lsls r1, r2
orrs r1, r0
lsrs r1, 16
adds r0, r4, 0
bl VarSet
_08179AF0:
ldr r0, =0x0000403b
bl VarGet
lsls r0, 16
lsrs r4, r0, 16
ldr r0, =0x0000ffff
cmp r4, r0
bne _08179B5A
ldr r0, =0x0000403c
bl VarGet
lsls r0, 16
lsrs r0, 16
cmp r0, r4
bne _08179B5A
ldr r0, =0x0000403d
bl VarGet
lsls r0, 16
lsrs r0, 16
cmp r0, 0xF
bne _08179B5A
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, [r0]
ldr r0, =0x00150008
cmp r1, r0
beq _08179A54
b _08179B5A
.pool
_08179B44:
adds r0, r5, 0x1
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x23
bls _08179A68
movs r0, 0x3
bl FlagSet
movs r0, 0x2
bl FlagReset
_08179B5A:
movs r0, 0
_08179B5C:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8179A04
.align 2, 0 @ Don't pad with nop.

View File

@ -1411,7 +1411,7 @@ _0809CA64:
b _0809CB28 b _0809CB28
.pool .pool
_0809CA7C: _0809CA7C:
bl sub_8179A04 bl ShouldDoBrailleRegicePuzzle
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1

View File

@ -258,7 +258,7 @@ sub_813561C: @ 813561C
thumb_func_start sub_8135654 thumb_func_start sub_8135654
sub_8135654: @ 8135654 sub_8135654: @ 8135654
push {r4,lr} push {r4,lr}
bl sub_81797DC bl ShouldDoBrailleStrengthEffect
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _0813568C beq _0813568C
@ -404,7 +404,7 @@ sub_8135780: @ 8135780
lsrs r0, r2, 16 lsrs r0, r2, 16
strh r0, [r1, 0x18] strh r0, [r1, 0x18]
strh r2, [r1, 0x1A] strh r2, [r1, 0x1A]
bl sub_81795E8 bl ShouldDoBrailleDigEffect
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _081357AC bne _081357AC
@ -422,12 +422,12 @@ sub_81357BC: @ 81357BC
push {r4,lr} push {r4,lr}
movs r0, 0x26 movs r0, 0x26
bl FieldEffectActiveListRemove bl FieldEffectActiveListRemove
bl sub_81795E8 bl ShouldDoBrailleDigEffect
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
cmp r4, 0 cmp r4, 0
beq _081357D6 beq _081357D6
bl sub_817963C bl DoBrailleDigEffect
b _081357EE b _081357EE
_081357D6: _081357D6:
ldr r0, =task08_080A1C44 ldr r0, =task08_080A1C44
@ -3329,7 +3329,7 @@ _081370E2:
thumb_func_start sub_81370FC thumb_func_start sub_81370FC
sub_81370FC: @ 81370FC sub_81370FC: @ 81370FC
push {r4,lr} push {r4,lr}
bl sub_81798D0 bl ShouldDoBrailleFlyEffect
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08137134 beq _08137134

View File

@ -316,7 +316,7 @@ gFieldEffectScript_FieldMoveShowMonInit:: @ 82DBCCC
field_eff_end field_eff_end
gFieldEffectScript_Unknown60:: @ 82DBCD2 gFieldEffectScript_Unknown60:: @ 82DBCD2
field_eff_callnative sub_81799B8 field_eff_callnative FldEff_UsePuzzleEffect
field_eff_end field_eff_end
gFieldEffectScript_Unknown61:: @ 82DBCD8 gFieldEffectScript_Unknown61:: @ 82DBCD8

View File

@ -222,7 +222,7 @@ SECTIONS {
asm/berry_tag_screen.o(.text); asm/berry_tag_screen.o(.text);
asm/mystery_event_menu.o(.text); asm/mystery_event_menu.o(.text);
asm/save_failed_screen.o(.text); asm/save_failed_screen.o(.text);
asm/braille_puzzles.o(.text); src/braille_puzzles.o(.text);
asm/pokeblock_feed.o(.text); asm/pokeblock_feed.o(.text);
asm/clear_save_data_screen.o(.text); asm/clear_save_data_screen.o(.text);
asm/intro_credits_graphics.o(.text); asm/intro_credits_graphics.o(.text);

583
src/braille_puzzles.c Executable file
View File

@ -0,0 +1,583 @@
#include "global.h"
#include "event_data.h"
#include "songs.h"
#include "sound.h"
#include "script.h"
#include "species.h"
#include "task.h"
#include "field_effect.h"
#include "flags.h"
extern void MapGridSetMetatileIdAt(s32 x, s32 y, u16 metatileId); // fieldmap
extern void DrawWholeMapView(); // field_camera
extern void SetCameraPanningCallback(void ( *callback)()); // field_camera
extern void InstallCameraPanAheadCallback(void);
extern void SetCameraPanning(s16 x, s16 y);
extern u8 brm_get_pokemon_selection(void);
extern void FieldEffectActiveListRemove(u8 id); // field_effect
extern u8 oei_task_add(void);
// why do this, GF?
enum
{
STRENGTH_PUZZLE,
FLY_PUZZLE
};
extern u8 gBraillePuzzleCallbackFlag;
extern u8 gUnknown_085EFE74[][2];
void SealedChamberShakingEffect(u8);
void sub_8179860(void);
void sub_8179944(void);
bool8 ShouldDoBrailleDigEffect(void)
{
if (!FlagGet(SYS_BRAILLE_DIG)
&& (gSaveBlock1Ptr->location.mapGroup == 0x18
&& gSaveBlock1Ptr->location.mapNum == 0x47))
{
if (gSaveBlock1Ptr->pos.x == 10 && gSaveBlock1Ptr->pos.y == 3)
return TRUE;
if (gSaveBlock1Ptr->pos.x == 9 && gSaveBlock1Ptr->pos.y == 3)
return TRUE;
if (gSaveBlock1Ptr->pos.x == 11 && gSaveBlock1Ptr->pos.y == 3)
return TRUE;
}
return FALSE;
}
void DoBrailleDigEffect(void)
{
MapGridSetMetatileIdAt(16, 8, 554);
MapGridSetMetatileIdAt(17, 8, 555);
MapGridSetMetatileIdAt(18, 8, 556);
MapGridSetMetatileIdAt(16, 9, 3634);
MapGridSetMetatileIdAt(17, 9, 563);
MapGridSetMetatileIdAt(18, 9, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_DIG);
ScriptContext2_Disable();
}
bool8 CheckRelicanthWailord(void)
{
// Emerald change: why did they flip it?
// First comes Wailord
if (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2, 0) == SPECIES_WAILORD)
{
CalculatePlayerPartyCount();
// Last comes Relicanth
if (GetMonData(&gPlayerParty[gPlayerPartyCount - 1], MON_DATA_SPECIES2, 0) == SPECIES_RELICANTH)
return TRUE;
}
return FALSE;
}
// THEORY: this was caused by block commenting out all of the older R/S braille functions but leaving the call to it itself, which creates the nullsub.
// the code is shown below to show what this might look like.
void ShouldDoBrailleStrengthEffectOld(void)
{
/*
if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1.location.mapGroup == MAP_GROUP_DESERT_RUINS && gSaveBlock1.location.mapNum == MAP_ID_DESERT_RUINS))
{
if (gSaveBlock1.pos.x == 10 && gSaveBlock1.pos.y == 23)
return TRUE;
else if (gSaveBlock1.pos.x == 9 && gSaveBlock1.pos.y == 23)
return TRUE;
else if (gSaveBlock1.pos.x == 11 && gSaveBlock1.pos.y == 23)
return TRUE;
}
return FALSE;
}
void DoBrailleStrengthEffect(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_STRENGTH);
MapGridSetMetatileIdAt(14, 26, 554);
MapGridSetMetatileIdAt(15, 26, 555);
MapGridSetMetatileIdAt(16, 26, 556);
MapGridSetMetatileIdAt(14, 27, 3634);
MapGridSetMetatileIdAt(15, 27, 563);
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_STRENGTH);
ScriptContext2_Disable();
}
bool8 ShouldDoBrailleFlyEffect(void)
{
if (!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1.location.mapGroup == MAP_GROUP_ANCIENT_TOMB && gSaveBlock1.location.mapNum == MAP_ID_ANCIENT_TOMB))
{
if (gSaveBlock1.pos.x == 8 && gSaveBlock1.pos.y == 25)
return TRUE;
}
return FALSE;
}
void DoBrailleFlyEffect(void)
{
gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
FieldEffectStart(FLDEFF_USE_FLY_ANCIENT_TOMB);
}
bool8 FldEff_UseFlyAncientTomb(void)
{
u8 taskId = oei_task_add();
gTasks[taskId].data[8] = (u32)UseFlyAncientTomb_Callback >> 16;
gTasks[taskId].data[9] = (u32)UseFlyAncientTomb_Callback;
return FALSE;
}
void UseFlyAncientTomb_Callback(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_FLY_ANCIENT_TOMB);
UseFlyAncientTomb_Finish();
}
void UseFlyAncientTomb_Finish(void)
{
MapGridSetMetatileIdAt(14, 26, 554);
MapGridSetMetatileIdAt(15, 26, 555);
MapGridSetMetatileIdAt(16, 26, 556);
MapGridSetMetatileIdAt(14, 27, 3634);
MapGridSetMetatileIdAt(15, 27, 563);
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_FLY);
ScriptContext2_Disable();
}
*/
}
void DoSealedChamberShakingEffect1(void)
{
u8 taskId = CreateTask(SealedChamberShakingEffect, 9);
gTasks[taskId].data[1] = 0;
gTasks[taskId].data[2] = 0;
gTasks[taskId].data[4] = 2;
gTasks[taskId].data[5] = 5;
gTasks[taskId].data[6] = 50;
SetCameraPanningCallback(0);
}
void DoSealedChamberShakingEffect2(void)
{
u8 taskId = CreateTask(SealedChamberShakingEffect, 9);
gTasks[taskId].data[1] = 0;
gTasks[taskId].data[2] = 0;
gTasks[taskId].data[4] = 3;
gTasks[taskId].data[5] = 5;
gTasks[taskId].data[6] = 2;
SetCameraPanningCallback(0);
}
void SealedChamberShakingEffect(u8 taskId)
{
struct Task *task = &gTasks[taskId];
task->data[1]++;
if (!(task->data[1] % task->data[5]))
{
task->data[1] = 0;
task->data[2]++;
task->data[4] = -task->data[4];
SetCameraPanning(0, task->data[4]);
if (task->data[2] == task->data[6])
{
DestroyTask(taskId);
EnableBothScriptContexts();
InstallCameraPanAheadCallback();
}
}
}
// moved later in the function because it was rewritten.
bool8 ShouldDoBrailleStrengthEffect(void)
{
if (!FlagGet(SYS_BRAILLE_STRENGTH) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x06))
{
if (gSaveBlock1Ptr->pos.x == 6 && gSaveBlock1Ptr->pos.y == 23)
{ gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; }
else if (gSaveBlock1Ptr->pos.x == 5 && gSaveBlock1Ptr->pos.y == 23)
{ gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; }
else if (gSaveBlock1Ptr->pos.x == 7 && gSaveBlock1Ptr->pos.y == 23)
{ gBraillePuzzleCallbackFlag = STRENGTH_PUZZLE; return TRUE; }
}
return FALSE;
}
void sub_8179834(void)
{
gFieldEffectSpawnParams[0] = brm_get_pokemon_selection();
FieldEffectStart(FLDEFF_USE_FLY_ANCIENT_TOMB);
}
void UseStrengthDesertRuins_Callback(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_FLY_ANCIENT_TOMB);
sub_8179860();
}
void sub_8179860(void)
{
MapGridSetMetatileIdAt(14, 26, 554);
MapGridSetMetatileIdAt(15, 26, 555);
MapGridSetMetatileIdAt(16, 26, 556);
MapGridSetMetatileIdAt(14, 27, 3634);
MapGridSetMetatileIdAt(15, 27, 563);
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_STRENGTH);
ScriptContext2_Disable();
}
bool8 ShouldDoBrailleFlyEffect(void)
{
if(!FlagGet(SYS_BRAILLE_FLY) && (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x44))
{
if(gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 25)
{ gBraillePuzzleCallbackFlag = FLY_PUZZLE; return TRUE; }
}
return FALSE;
}
void sub_8179918(void)
{
gFieldEffectSpawnParams[0] = brm_get_pokemon_selection();
FieldEffectStart(FLDEFF_USE_FLY_ANCIENT_TOMB);
}
void UseFlyAncientTomb_Callback(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_FLY_ANCIENT_TOMB);
sub_8179944();
}
void sub_8179944(void)
{
MapGridSetMetatileIdAt(14, 26, 554);
MapGridSetMetatileIdAt(15, 26, 555);
MapGridSetMetatileIdAt(16, 26, 556);
MapGridSetMetatileIdAt(14, 27, 3634);
MapGridSetMetatileIdAt(15, 27, 563);
MapGridSetMetatileIdAt(16, 27, 3636);
DrawWholeMapView();
PlaySE(SE_BAN);
FlagSet(SYS_BRAILLE_FLY);
ScriptContext2_Disable();
}
// theory: another commented out DoBrailleWait and Task_BrailleWait.
void DoBrailleWait(void)
{
/*
if (!FlagGet(SYS_BRAILLE_WAIT))
CreateTask(Task_BrailleWait, 0x50);
}
void Task_BrailleWait(u8 taskId)
{
s16 *data = gTasks[taskId].data;
switch (data[0])
{
case 0:
data[1] = 7200;
data[0] = 1;
break;
case 1:
if (BrailleWait_CheckButtonPress() != FALSE)
{
MenuZeroFillScreen();
PlaySE(SE_SELECT);
data[0] = 2;
}
else
{
data[1] = data[1] - 1;
if (data[1] == 0)
{
MenuZeroFillScreen();
data[0] = 3;
data[1] = 30;
}
}
break;
case 2:
if (BrailleWait_CheckButtonPress() == FALSE)
{
data[1] = data[1] - 1;
if (data[1] == 0)
data[0] = 4;
break;
}
sub_8064E2C();
DestroyTask(taskId);
ScriptContext2_Disable();
break;
case 3:
data[1] = data[1] - 1;
if (data[1] == 0)
data[0] = 4;
break;
case 4:
sub_8064E2C();
ScriptContext1_SetupScript(S_OpenRegiceChamber);
DestroyTask(taskId);
break;
}
}
bool32 BrailleWait_CheckButtonPress(void)
{
u16 keyMask = A_BUTTON | B_BUTTON | START_BUTTON | SELECT_BUTTON | DPAD_ANY;
if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
keyMask |= L_BUTTON | R_BUTTON;
if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
keyMask |= L_BUTTON;
if (gMain.newKeys & keyMask)
return TRUE;
else
return FALSE;
*/
}
// this used to be FldEff_UseFlyAncientTomb . why did GF merge the 2 functions?
bool8 FldEff_UsePuzzleEffect(void)
{
u8 taskId = oei_task_add();
if(gBraillePuzzleCallbackFlag == FLY_PUZZLE)
{
gTasks[taskId].data[8] = (u32)UseFlyAncientTomb_Callback >> 16;
gTasks[taskId].data[9] = (u32)UseFlyAncientTomb_Callback;
}
else
{
gTasks[taskId].data[8] = (u32)UseStrengthDesertRuins_Callback >> 16;
gTasks[taskId].data[9] = (u32)UseStrengthDesertRuins_Callback;
}
return FALSE;
}
// can't get this one to match due to the weird macro-like varsets with strange bitshifting.
// to note: 0x10000 is loaded in, and its obviously supposed to be 1, but i cant get 0x80 << 9 to be loaded in without using it directly.
// maybe there's some way of writing it that works?
#ifdef NONMATCHING
// ShouldDoBrailleRegicePuzzle
bool8 ShouldDoBrailleRegicePuzzle(void)
{
u8 i;
if (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x43)
{
// _08179A1A
if (FlagGet(SYS_BRAILLE_WAIT) != FALSE)
return FALSE;
if (FlagGet(2) == FALSE)
return FALSE;
if (FlagGet(3) == TRUE)
return FALSE;
for(i = 0; i < 36; i++)
{
if(gSaveBlock1Ptr->pos.x == gUnknown_085EFE74[i][0] && gSaveBlock1Ptr->pos.y == gUnknown_085EFE74[i][1])
{
if(i < 16)
VarSet(0x403B, (0x10000 << i | VarGet(0x403B) << 16) >> 16); // correct
else if(i < 32)
VarSet(0x403C, (0x10000 << (i - 16) | VarGet(0x403C) << 16) >> 16); // hmm?
else
VarSet(0x403D, (0x10000 << (i - 32) | VarGet(0x403D) << 16) >> 16); // hmm?
if(VarGet(0x403B) != 0xFFFF || VarGet(0x403C) != 0xFF || VarGet(0x403D) != 0xF)
return FALSE;
if(gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 21)
return TRUE;
else
return FALSE;
}
}
}
// TODO: Find what flags 2 and 3 are.
FlagSet(3);
FlagReset(2);
return FALSE;
}
#else
__attribute__((naked))
bool8 ShouldDoBrailleRegicePuzzle(void)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r9\n\
mov r6, r8\n\
push {r6,r7}\n\
ldr r4, =gSaveBlock1Ptr\n\
ldr r0, [r4]\n\
ldrh r1, [r0, 0x4]\n\
ldr r0, =0x00004318\n\
cmp r1, r0\n\
beq _08179A1A\n\
b _08179B5A\n\
_08179A1A:\n\
ldr r0, =0x000008b1\n\
bl FlagGet\n\
lsls r0, 24\n\
cmp r0, 0\n\
beq _08179A28\n\
b _08179B5A\n\
_08179A28:\n\
movs r0, 0x2\n\
bl FlagGet\n\
lsls r0, 24\n\
cmp r0, 0\n\
bne _08179A36\n\
b _08179B5A\n\
_08179A36:\n\
movs r0, 0x3\n\
bl FlagGet\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x1\n\
bne _08179A58\n\
b _08179B5A\n\
.pool\n\
_08179A54:\n\
movs r0, 0x1\n\
b _08179B5C\n\
_08179A58:\n\
movs r5, 0\n\
mov r8, r4\n\
ldr r4, =gUnknown_085EFE74\n\
adds r0, r4, 0x1\n\
mov r12, r0\n\
ldr r6, =0x0000403b\n\
ldr r1, =0x0000403c\n\
mov r9, r1\n\
_08179A68:\n\
lsls r0, r5, 1\n\
adds r1, r0, r4\n\
add r0, r12\n\
ldrb r3, [r0]\n\
mov r7, r8\n\
ldr r2, [r7]\n\
movs r7, 0\n\
ldrsh r0, [r2, r7]\n\
ldrb r1, [r1]\n\
cmp r0, r1\n\
bne _08179B44\n\
movs r1, 0x2\n\
ldrsh r0, [r2, r1]\n\
cmp r0, r3\n\
bne _08179B44\n\
cmp r5, 0xF\n\
bhi _08179AB0\n\
adds r0, r6, 0\n\
bl VarGet\n\
lsls r0, 16\n\
movs r1, 0x80\n\
lsls r1, 9\n\
lsls r1, r5\n\
orrs r1, r0\n\
lsrs r1, 16\n\
adds r0, r6, 0\n\
bl VarSet\n\
b _08179AF0\n\
.pool\n\
_08179AB0:\n\
cmp r5, 0x1F\n\
bhi _08179AD2\n\
mov r0, r9\n\
bl VarGet\n\
lsls r0, 16\n\
adds r2, r5, 0\n\
subs r2, 0x10\n\
movs r1, 0x80\n\
lsls r1, 9\n\
lsls r1, r2\n\
orrs r1, r0\n\
lsrs r1, 16\n\
mov r0, r9\n\
bl VarSet\n\
b _08179AF0\n\
_08179AD2:\n\
ldr r4, =0x0000403d\n\
adds r0, r4, 0\n\
bl VarGet\n\
lsls r0, 16\n\
adds r2, r5, 0\n\
subs r2, 0x20\n\
movs r1, 0x80\n\
lsls r1, 9\n\
lsls r1, r2\n\
orrs r1, r0\n\
lsrs r1, 16\n\
adds r0, r4, 0\n\
bl VarSet\n\
_08179AF0:\n\
ldr r0, =0x0000403b\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
ldr r0, =0x0000ffff\n\
cmp r4, r0\n\
bne _08179B5A\n\
ldr r0, =0x0000403c\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r0, 16\n\
cmp r0, r4\n\
bne _08179B5A\n\
ldr r0, =0x0000403d\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r0, 16\n\
cmp r0, 0xF\n\
bne _08179B5A\n\
ldr r0, =gSaveBlock1Ptr\n\
ldr r0, [r0]\n\
ldr r1, [r0]\n\
ldr r0, =0x00150008\n\
cmp r1, r0\n\
beq _08179A54\n\
b _08179B5A\n\
.pool\n\
_08179B44:\n\
adds r0, r5, 0x1\n\
lsls r0, 24\n\
lsrs r5, r0, 24\n\
cmp r5, 0x23\n\
bls _08179A68\n\
movs r0, 0x3\n\
bl FlagSet\n\
movs r0, 0x2\n\
bl FlagReset\n\
_08179B5A:\n\
movs r0, 0\n\
_08179B5C:\n\
pop {r3,r4}\n\
mov r8, r3\n\
mov r9, r4\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1\n\
.syntax divided");
}
#endif

View File

@ -1651,7 +1651,7 @@ gUnknown_0203BCFE: @ 203BCFE
gUnknown_0203BD0E: @ 203BD0E gUnknown_0203BD0E: @ 203BD0E
.space 0x6 .space 0x6
gUnknown_0203BD14: @ 203BD14 gBraillePuzzleCallbackFlag: @ 203BD14
.space 0x4 .space 0x4
gUnknown_0203BD18: @ 203BD18 gUnknown_0203BD18: @ 203BD18