Decompile rom6

This commit is contained in:
KDSKardabox 2018-04-10 12:17:29 +05:30
parent a18dc6aa80
commit a3d065d0bd
9 changed files with 223 additions and 459 deletions

View File

@ -1,452 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start npc_before_player_of_type
npc_before_player_of_type: @ 8135424
push {r4,r5,lr}
adds r5, r0, 0
lsls r5, 24
lsrs r5, 24
ldr r4, =gUnknown_0203AB40
adds r1, r4, 0x2
adds r0, r4, 0
bl GetXYCoordsOneStepInFrontOfPlayer
bl PlayerGetZCoord
strb r0, [r4, 0x4]
ldrh r0, [r4]
ldrh r1, [r4, 0x2]
ldrb r2, [r4, 0x4]
bl GetFieldObjectIdByXYZ
lsls r0, 24
lsrs r0, 24
ldr r2, =gMapObjects
lsls r1, r0, 3
adds r1, r0
lsls r1, 2
adds r2, r1, r2
ldrb r0, [r2, 0x5]
cmp r0, r5
bne _08135470
ldr r1, =gSpecialVar_LastTalked
ldrb r0, [r2, 0x8]
strh r0, [r1]
movs r0, 0x1
b _08135472
.pool
_08135470:
movs r0, 0
_08135472:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end npc_before_player_of_type
thumb_func_start oei_task_add
oei_task_add: @ 8135478
push {lr}
ldr r0, =gUnknown_0203AB40
adds r1, r0, 0x2
bl GetXYCoordsOneStepInFrontOfPlayer
ldr r0, =task08_080C9820
movs r1, 0x8
bl CreateTask
lsls r0, 24
lsrs r0, 24
pop {r1}
bx r1
.pool
thumb_func_end oei_task_add
thumb_func_start task08_080C9820
task08_080C9820: @ 813549C
push {r4-r6,lr}
lsls r0, 24
lsrs r5, r0, 24
adds r6, r5, 0
bl ScriptContext2_Enable
ldr r1, =gPlayerAvatar
movs r0, 0x1
strb r0, [r1, 0x6]
ldrb r1, [r1, 0x5]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r1, =gMapObjects
adds r4, r0, r1
adds r0, r4, 0
bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive
lsls r0, 24
cmp r0, 0
beq _081354D2
adds r0, r4, 0
bl FieldObjectClearAnimIfSpecialAnimFinished
lsls r0, 24
cmp r0, 0
beq _0813551E
_081354D2:
ldr r0, =gMapHeader
ldrb r0, [r0, 0x17]
cmp r0, 0x5
bne _08135504
movs r0, 0x3B
bl FieldEffectStart
ldr r0, =gTasks
lsls r1, r5, 2
adds r1, r5
lsls r1, 3
adds r1, r0
ldr r0, =sub_8135578
b _0813551C
.pool
_08135504:
bl sub_808C114
adds r0, r4, 0
movs r1, 0x39
bl FieldObjectSetSpecialAnim
ldr r0, =gTasks
lsls r1, r6, 2
adds r1, r6
lsls r1, 3
adds r1, r0
ldr r0, =sub_813552C
_0813551C:
str r0, [r1]
_0813551E:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end task08_080C9820
thumb_func_start sub_813552C
sub_813552C: @ 813552C
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gPlayerAvatar
ldrb r1, [r0, 0x5]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r1, =gMapObjects
adds r0, r1
bl FieldObjectCheckIfSpecialAnimFinishedOrInactive
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08135560
movs r0, 0x3B
bl FieldEffectStart
ldr r0, =gTasks
lsls r1, r4, 2
adds r1, r4
lsls r1, 3
adds r1, r0
ldr r0, =sub_8135578
str r0, [r1]
_08135560:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_813552C
thumb_func_start sub_8135578
sub_8135578: @ 8135578
push {r4-r7,lr}
lsls r0, 24
lsrs r7, r0, 24
movs r0, 0x6
bl FieldEffectActiveListContains
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0
bne _081355FC
bl player_get_direction_lower_nybble
ldr r6, =gFieldEffectArguments
lsls r0, 24
lsrs r0, 24
str r0, [r6, 0x4]
cmp r0, 0x1
bne _0813559E
str r4, [r6, 0x8]
_0813559E:
ldr r1, [r6, 0x4]
cmp r1, 0x2
bne _081355A8
movs r0, 0x1
str r0, [r6, 0x8]
_081355A8:
cmp r1, 0x3
bne _081355B0
movs r0, 0x2
str r0, [r6, 0x8]
_081355B0:
cmp r1, 0x4
bne _081355B8
movs r0, 0x3
str r0, [r6, 0x8]
_081355B8:
ldr r5, =gPlayerAvatar
ldrb r0, [r5, 0x5]
lsls r4, r0, 3
adds r4, r0
lsls r4, 2
ldr r0, =gMapObjects
adds r4, r0
bl GetPlayerAvatarGraphicsIdByCurrentState
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
bl FieldObjectSetGraphicsId
ldrb r1, [r5, 0x4]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
ldr r1, =gSprites
adds r0, r1
ldrb r1, [r6, 0x8]
bl StartSpriteAnim
movs r0, 0x6
bl FieldEffectActiveListRemove
ldr r1, =gTasks
lsls r0, r7, 2
adds r0, r7
lsls r0, 3
adds r0, r1
ldr r1, =sub_813561C
str r1, [r0]
_081355FC:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8135578
thumb_func_start sub_813561C
sub_813561C: @ 813561C
push {r4,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r1, =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r1
ldrh r1, [r0, 0x18]
lsls r1, 16
ldrh r0, [r0, 0x1A]
orrs r1, r0
bl _call_via_r1
ldr r1, =gPlayerAvatar
movs r0, 0
strb r0, [r1, 0x6]
adds r0, r4, 0
bl DestroyTask
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_813561C
thumb_func_start sub_8135654
sub_8135654: @ 8135654
push {r4,lr}
bl ShouldDoBrailleStrengthEffect
lsls r0, 24
cmp r0, 0
beq _0813568C
ldr r4, =gSpecialVar_Result
bl GetCursorSelectionMonId
lsls r0, 24
lsrs r0, 24
strh r0, [r4]
ldr r1, =gUnknown_03005DB0
ldr r0, =FieldCallback_Teleport
str r0, [r1]
ldr r1, =gUnknown_0203CEEC
ldr r0, =sub_8179834
b _081356A8
.pool
_0813568C:
movs r0, 0x56
bl npc_before_player_of_type
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _0813569E
movs r0, 0
b _081356AC
_0813569E:
ldr r1, =gUnknown_03005DB0
ldr r0, =FieldCallback_Teleport
str r0, [r1]
ldr r1, =gUnknown_0203CEEC
ldr r0, =sub_81356C4
_081356A8:
str r0, [r1]
movs r0, 0x1
_081356AC:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sub_8135654
thumb_func_start sub_81356C4
sub_81356C4: @ 81356C4
push {lr}
bl GetCursorSelectionMonId
ldr r1, =gFieldEffectArguments
lsls r0, 24
lsrs r0, 24
str r0, [r1]
ldr r0, =Route111_EventScript_2907F0
bl ScriptContext1_SetupScript
pop {r0}
bx r0
.pool
thumb_func_end sub_81356C4
thumb_func_start oei_rocksmash
oei_rocksmash: @ 81356E4
push {lr}
bl oei_task_add
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
ldr r2, =sub_8135714
lsrs r0, r2, 16
strh r0, [r1, 0x18]
strh r2, [r1, 0x1A]
movs r0, 0x13
bl IncrementGameStat
movs r0, 0
pop {r1}
bx r1
.pool
thumb_func_end oei_rocksmash
thumb_func_start sub_8135714
sub_8135714: @ 8135714
push {lr}
movs r0, 0x83
bl PlaySE
movs r0, 0x25
bl FieldEffectActiveListRemove
bl EnableBothScriptContexts
pop {r0}
bx r0
thumb_func_end sub_8135714
thumb_func_start sub_813572C
sub_813572C: @ 813572C
push {lr}
bl sub_80FE314
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _0813573E
movs r0, 0
b _0813574C
_0813573E:
ldr r1, =gUnknown_03005DB0
ldr r0, =FieldCallback_Teleport
str r0, [r1]
ldr r1, =gUnknown_0203CEEC
ldr r0, =hm2_dig
str r0, [r1]
movs r0, 0x1
_0813574C:
pop {r1}
bx r1
.pool
thumb_func_end sub_813572C
thumb_func_start hm2_dig
hm2_dig: @ 8135760
push {lr}
bl Overworld_ResetStateAfterDigEscRope
movs r0, 0x26
bl FieldEffectStart
bl GetCursorSelectionMonId
ldr r1, =gFieldEffectArguments
lsls r0, 24
lsrs r0, 24
str r0, [r1]
pop {r0}
bx r0
.pool
thumb_func_end hm2_dig
thumb_func_start sub_8135780
sub_8135780: @ 8135780
push {lr}
bl oei_task_add
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
ldr r2, =sub_81357BC
lsrs r0, r2, 16
strh r0, [r1, 0x18]
strh r2, [r1, 0x1A]
bl ShouldDoBrailleDigEffect
lsls r0, 24
cmp r0, 0
bne _081357AC
movs r0, 0x1
bl SetPlayerAvatarTransitionFlags
_081357AC:
movs r0, 0
pop {r1}
bx r1
.pool
thumb_func_end sub_8135780
thumb_func_start sub_81357BC
sub_81357BC: @ 81357BC
push {r4,lr}
movs r0, 0x26
bl FieldEffectActiveListRemove
bl ShouldDoBrailleDigEffect
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0
beq _081357D6
bl DoBrailleDigEffect
b _081357EE
_081357D6:
ldr r0, =task08_080A1C44
movs r1, 0x8
bl CreateTask
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
strh r4, [r1, 0x8]
_081357EE:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81357BC
.align 2, 0 @ Don't pad with nop.

View File

@ -223,7 +223,7 @@ gFieldEffectScript_SandDisguisePlaceholder:: @ 82DBC09
field_eff_end
gFieldEffectScript_UseRockSmash:: @ 82DBC0F
field_eff_callnative oei_rocksmash
field_eff_callnative FldEff_UseRockSmash
field_eff_end
gFieldEffectScript_Unknown40:: @ 82DBC15
@ -231,7 +231,7 @@ gFieldEffectScript_Unknown40:: @ 82DBC15
field_eff_end
gFieldEffectScript_Unknown38:: @ 82DBC1B
field_eff_callnative sub_8135780
field_eff_callnative FldEff_UseDig
field_eff_end
gFieldEffectScript_Unknown39:: @ 82DBC21

View File

@ -433,14 +433,14 @@ gUnknown_08615D7E:: @ 8615D7E
gUnknown_08615D9C:: @ 8615D9C
.4byte sub_80D3718, 0x00000007
.4byte SetUpFieldMove_Flash, 0x0000000d
.4byte sub_8135654, 0x0000000d
.4byte SetUpFieldMove_RockSmash, 0x0000000d
.4byte SetUpFieldMove_Strength, 0x0000000d
.4byte sub_81B5820, 0x00000008
.4byte sub_81B5884, 0x0000000d
.4byte sub_81B5974, 0x0000000d
.4byte hm_prepare_waterfall, 0x0000000d
.4byte SetUpFieldMove_Teleport, 0x0000000d
.4byte sub_813572C, 0x0000000d
.4byte SetUpFieldMove_Dig, 0x0000000d
.4byte sub_80FA004, 0x0000000d
.4byte SetUpFieldMove_SoftBoiled, 0x00000010
.4byte SetUpFieldMove_SoftBoiled, 0x00000010

View File

@ -2,6 +2,10 @@
#define GUARD_BRAILLE_PUZZLES_H
bool8 ShouldDoBrailleFlyEffect(void);
bool8 ShouldDoBrailleStrengthEffect(void);
bool8 ShouldDoBrailleDigEffect(void);
void DoBrailleDigEffect(void);
void sub_8179918(void);
void sub_8179834(void);
#endif // GUARD_BRAILLE_PUZZLES_H

View File

@ -388,6 +388,7 @@ extern const u8 BattleFrontier_BattlePyramidEmptySquare_EventScript_252C88[];
extern const u8 FieryPath_EventScript_2908FD[];
extern const u8 EventScript_290CAE[];
extern const u8 EventScript_2926F8[];
extern const u8 Route111_EventScript_2907F0[];
//player pc
extern const u8 LittlerootTown_BrendansHouse_2F_EventScript_1F863F[];

View File

@ -39,5 +39,7 @@ void sub_808BCF4(void);
void sub_808D074(u8);
void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr);
u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8, u8);
void sub_808C114(void);
u8 GetPlayerAvatarGraphicsIdByCurrentState();
#endif // GUARD_FIELD_PLAYER_AVATAR_H

View File

@ -177,7 +177,7 @@ SECTIONS {
asm/trader.o(.text);
src/starter_choose.o(.text);
src/wallclock.o(.text);
asm/rom6.o(.text);
src/rom6.o(.text);
src/pokeblock.o(.text);
src/fldeff_flash.o(.text);
asm/post_battle_event_funcs.o(.text);

View File

@ -912,7 +912,7 @@ void re_escape_rope(u8 taskId)
DisplayItemMessageOnField(taskId, gStringVar4, task08_080A1C44);
}
bool8 sub_80FE314(void)
bool8 CanUseEscapeRopeOnCurrMap(void)
{
if (gMapHeader.flags & 2)
return TRUE;
@ -922,7 +922,7 @@ bool8 sub_80FE314(void)
void ItemUseOutOfBattle_EscapeRope(u8 taskId)
{
if (sub_80FE314() == TRUE)
if (CanUseEscapeRopeOnCurrMap() == TRUE)
{
gUnknown_0203A0F4 = re_escape_rope;
SetUpItemUseOnFieldCallback(taskId);

209
src/rom6.c Normal file
View File

@ -0,0 +1,209 @@
#include "global.h"
#include "constants/map_objects.h"
#include "constants/songs.h"
#include "rom6.h"
#include "braille_puzzles.h"
#include "event_data.h"
#include "event_scripts.h"
#include "field_effect.h"
#include "field_map_obj.h"
#include "field_player_avatar.h"
#include "item_use.h"
#include "party_menu.h"
#include "overworld.h"
#include "script.h"
#include "sound.h"
#include "sprite.h"
#include "task.h"
// static functions
static void task08_080C9820(u8 taskId);
static void sub_8135578(u8 taskId);
static void sub_813552C(u8 taskId);
static void sub_813561C(u8 taskId);
static void sub_81356C4(void);
static void sub_8135714(void);
static void hm2_dig(void);
static void sub_8135780(void);
// extern RAM loc
extern struct MapPosition gUnknown_0203AB40;
// text
bool8 npc_before_player_of_type(u8 a)
{
u8 mapObjId;
GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203AB40.x, &gUnknown_0203AB40.y);
gUnknown_0203AB40.height = PlayerGetZCoord();
mapObjId = GetFieldObjectIdByXYZ(gUnknown_0203AB40.x, gUnknown_0203AB40.y, gUnknown_0203AB40.height);
if (gMapObjects[mapObjId].graphicsId != a)
{
return FALSE;
}
else
{
gSpecialVar_LastTalked = gMapObjects[mapObjId].localId;
return TRUE;
}
}
u8 oei_task_add(void)
{
GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203AB40.x, &gUnknown_0203AB40.y);
return CreateTask(task08_080C9820, 8);
}
static void task08_080C9820(u8 taskId)
{
u8 mapObjId;
ScriptContext2_Enable();
gPlayerAvatar.preventStep = TRUE;
mapObjId = gPlayerAvatar.mapObjectId;
if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(&gMapObjects[mapObjId])
|| FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[mapObjId]))
{
if (gMapHeader.mapType == MAP_TYPE_UNDERWATER)
{
FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT);
gTasks[taskId].func = sub_8135578;
}
else
{
sub_808C114();
FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], 0x39);
gTasks[taskId].func = sub_813552C;
}
}
}
static void sub_813552C(u8 taskId)
{
if (FieldObjectCheckIfSpecialAnimFinishedOrInactive(&gMapObjects[gPlayerAvatar.mapObjectId]) == TRUE)
{
FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT);
gTasks[taskId].func = sub_8135578;
}
}
static void sub_8135578(u8 taskId)
{
if (!FieldEffectActiveListContains(6))
{
gFieldEffectArguments[1] = player_get_direction_lower_nybble();
if (gFieldEffectArguments[1] == 1)
gFieldEffectArguments[2] = 0;
if (gFieldEffectArguments[1] == 2)
gFieldEffectArguments[2] = 1;
if (gFieldEffectArguments[1] == 3)
gFieldEffectArguments[2] = 2;
if (gFieldEffectArguments[1] == 4)
gFieldEffectArguments[2] = 3;
FieldObjectSetGraphicsId(&gMapObjects[gPlayerAvatar.mapObjectId], GetPlayerAvatarGraphicsIdByCurrentState());
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], gFieldEffectArguments[2]);
FieldEffectActiveListRemove(6);
gTasks[taskId].func = sub_813561C;
}
}
static void sub_813561C(u8 taskId)
{
void (*func)(void) = (void (*)(void))(((u16)gTasks[taskId].data[8] << 16) | (u16)gTasks[taskId].data[9]);
func();
gPlayerAvatar.preventStep = FALSE;
DestroyTask(taskId);
}
bool8 SetUpFieldMove_RockSmash(void)
{
if(ShouldDoBrailleStrengthEffect())
{
gSpecialVar_Result = GetCursorSelectionMonId();
gUnknown_03005DB0 = FieldCallback_Teleport;
gUnknown_0203CEEC = sub_8179834;
return TRUE;
}
else if (npc_before_player_of_type(0x56) == TRUE)
{
gUnknown_03005DB0 = FieldCallback_Teleport;
gUnknown_0203CEEC = sub_81356C4;
return TRUE;
}
else
{
return FALSE;
}
}
static void sub_81356C4(void)
{
gFieldEffectArguments[0] = GetCursorSelectionMonId();
ScriptContext1_SetupScript(Route111_EventScript_2907F0);
}
bool8 FldEff_UseRockSmash(void)
{
u8 taskId = oei_task_add();
gTasks[taskId].data[8] = (u32)sub_8135714 >> 16;
gTasks[taskId].data[9] = (u32)sub_8135714;
IncrementGameStat(GAME_STAT_USED_ROCK_SMASH);
return FALSE;
}
static void sub_8135714(void)
{
PlaySE(SE_W088);
FieldEffectActiveListRemove(FLDEFF_USE_ROCK_SMASH);
EnableBothScriptContexts();
}
bool8 SetUpFieldMove_Dig(void)
{
if (CanUseEscapeRopeOnCurrMap() == TRUE)
{
gUnknown_03005DB0 = FieldCallback_Teleport;
gUnknown_0203CEEC = hm2_dig;
return TRUE;
}
else
{
return FALSE;
}
}
static void hm2_dig(void)
{
Overworld_ResetStateAfterDigEscRope();
FieldEffectStart(FLDEFF_USE_DIG);
gFieldEffectArguments[0] = GetCursorSelectionMonId();
}
bool8 FldEff_UseDig(void)
{
u8 taskId = oei_task_add();
gTasks[taskId].data[8] = (u32)sub_8135780 >> 16;
gTasks[taskId].data[9] = (u32)sub_8135780;
if (!ShouldDoBrailleDigEffect())
SetPlayerAvatarTransitionFlags(1);
return FALSE;
}
static void sub_8135780(void)
{
u8 taskId;
FieldEffectActiveListRemove(FLDEFF_USE_DIG);
if (ShouldDoBrailleDigEffect())
{
DoBrailleDigEffect();
}
else
{
taskId = CreateTask(task08_080A1C44, 8);
gTasks[taskId].data[0] = 0;
}
}