mirror of https://github.com/pret/pokeemerald.git
start decompiling mystery event script
This commit is contained in:
parent
24e0edee9f
commit
0bc7fb92db
|
@ -18556,7 +18556,7 @@ _081A4202:
|
|||
thumb_func_start sub_81A4224
|
||||
sub_81A4224: @ 81A4224
|
||||
push {lr}
|
||||
bl sub_81652B4
|
||||
bl ValidateEReaderTrainer
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_81A4224
|
||||
|
|
|
@ -5898,8 +5898,8 @@ _08165294:
|
|||
.pool
|
||||
thumb_func_end GetEreaderTrainerName
|
||||
|
||||
thumb_func_start sub_81652B4
|
||||
sub_81652B4: @ 81652B4
|
||||
thumb_func_start ValidateEReaderTrainer
|
||||
ValidateEReaderTrainer: @ 81652B4
|
||||
push {r4-r6,lr}
|
||||
ldr r2, =gSpecialVar_Result
|
||||
movs r0, 0
|
||||
|
@ -5951,7 +5951,7 @@ _08165316:
|
|||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_81652B4
|
||||
thumb_func_end ValidateEReaderTrainer
|
||||
|
||||
thumb_func_start sub_8165328
|
||||
sub_8165328: @ 8165328
|
||||
|
|
|
@ -38868,7 +38868,7 @@ _0801D7D0:
|
|||
ldr r1, [r4, 0x18]
|
||||
movs r2, 0xBC
|
||||
bl memcpy
|
||||
bl sub_81652B4
|
||||
bl ValidateEReaderTrainer
|
||||
b _0801D804
|
||||
.pool
|
||||
_0801D7F0:
|
||||
|
|
|
@ -262,6 +262,13 @@
|
|||
.2byte \output
|
||||
.2byte SPECIAL_\function
|
||||
.endm
|
||||
|
||||
@ temporary solution
|
||||
.macro specialvar_ output, functionId
|
||||
.byte 0x26
|
||||
.2byte \output
|
||||
.2byte \functionId
|
||||
.endm
|
||||
|
||||
@ Blocks script execution until a command or ASM code manually unblocks it. Generally used with specific commands and specials. If this command runs, and a subsequent command or piece of ASM does not unblock state, the script will remain blocked indefinitely (essentially a hang).
|
||||
.macro waitstate
|
||||
|
|
|
@ -468,7 +468,7 @@ _08178D74:
|
|||
bne _08178E58
|
||||
ldr r5, =0x0201c000
|
||||
adds r0, r5, 0
|
||||
bl sub_81538A0
|
||||
bl RunMysteryEventScript
|
||||
adds r4, r0, 0
|
||||
lsls r4, 16
|
||||
lsrs r4, 16
|
||||
|
|
|
@ -1,870 +0,0 @@
|
|||
.include "asm/macros.inc"
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_81537CC
|
||||
sub_81537CC: @ 81537CC
|
||||
push {r4,lr}
|
||||
adds r4, r3, 0
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
lsls r2, 16
|
||||
lsrs r2, 16
|
||||
movs r3, 0x1
|
||||
ands r0, r3
|
||||
cmp r0, 0
|
||||
beq _081537FC
|
||||
ands r1, r3
|
||||
cmp r1, 0
|
||||
beq _081537FC
|
||||
movs r0, 0x4
|
||||
ands r2, r0
|
||||
cmp r2, 0
|
||||
beq _081537FC
|
||||
movs r0, 0x80
|
||||
lsls r0, 2
|
||||
ands r0, r4
|
||||
cmp r0, 0
|
||||
beq _081537FC
|
||||
movs r0, 0x1
|
||||
b _081537FE
|
||||
_081537FC:
|
||||
movs r0, 0
|
||||
_081537FE:
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_81537CC
|
||||
|
||||
thumb_func_start sub_8153804
|
||||
sub_8153804: @ 8153804
|
||||
push {lr}
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftCantBeUsed
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x3
|
||||
bl SetMysteryEventScriptStatus
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8153804
|
||||
|
||||
thumb_func_start sub_8153820
|
||||
sub_8153820: @ 8153820
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
adds r5, r1, 0
|
||||
ldr r1, =gUnknown_082DED2C
|
||||
ldr r2, =gUnknown_082DED2C + 0x44
|
||||
bl InitScriptContext
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
bl SetupBytecodeScript
|
||||
str r5, [r4, 0x64]
|
||||
movs r0, 0
|
||||
str r0, [r4, 0x68]
|
||||
str r0, [r4, 0x6C]
|
||||
str r0, [r4, 0x70]
|
||||
pop {r4,r5}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8153820
|
||||
|
||||
thumb_func_start sub_8153850
|
||||
sub_8153850: @ 8153850
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl RunScriptCommand
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _08153868
|
||||
ldr r0, [r4, 0x70]
|
||||
cmp r0, 0
|
||||
beq _08153868
|
||||
movs r0, 0x1
|
||||
b _0815386A
|
||||
_08153868:
|
||||
movs r0, 0
|
||||
_0815386A:
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153850
|
||||
|
||||
thumb_func_start sub_8153870
|
||||
sub_8153870: @ 8153870
|
||||
push {lr}
|
||||
adds r1, r0, 0
|
||||
ldr r0, =gUnknown_0203BBC0
|
||||
bl sub_8153820
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8153870
|
||||
|
||||
thumb_func_start sub_8153884
|
||||
sub_8153884: @ 8153884
|
||||
push {r4,r5,lr}
|
||||
adds r5, r0, 0
|
||||
ldr r4, =gUnknown_0203BBC0
|
||||
adds r0, r4, 0
|
||||
bl sub_8153850
|
||||
ldr r1, [r4, 0x6C]
|
||||
str r1, [r5]
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153884
|
||||
|
||||
thumb_func_start sub_81538A0
|
||||
sub_81538A0: @ 81538A0
|
||||
push {r4,lr}
|
||||
adds r1, r0, 0
|
||||
ldr r4, =gUnknown_0203BBC0
|
||||
adds r0, r4, 0
|
||||
bl sub_8153820
|
||||
_081538AC:
|
||||
adds r0, r4, 0
|
||||
bl sub_8153850
|
||||
cmp r0, 0
|
||||
bne _081538AC
|
||||
ldr r0, [r4, 0x6C]
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_81538A0
|
||||
|
||||
thumb_func_start SetMysteryEventScriptStatus
|
||||
SetMysteryEventScriptStatus: @ 81538C4
|
||||
ldr r1, =gUnknown_0203BBC0
|
||||
str r0, [r1, 0x6C]
|
||||
bx lr
|
||||
.pool
|
||||
thumb_func_end SetMysteryEventScriptStatus
|
||||
|
||||
thumb_func_start sub_81538D0
|
||||
sub_81538D0: @ 81538D0
|
||||
push {lr}
|
||||
movs r2, 0
|
||||
ldr r0, =gSaveBlock1Ptr
|
||||
ldr r0, [r0]
|
||||
ldr r1, =0x00003b18
|
||||
adds r3, r0, r1
|
||||
movs r1, 0
|
||||
_081538DE:
|
||||
adds r0, r3, r1
|
||||
ldrb r0, [r0]
|
||||
adds r2, r0
|
||||
adds r1, 0x1
|
||||
cmp r1, 0xB
|
||||
bls _081538DE
|
||||
adds r0, r2, 0
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_81538D0
|
||||
|
||||
thumb_func_start sub_81538F8
|
||||
sub_81538F8: @ 81538F8
|
||||
push {r4,r5,lr}
|
||||
ldr r5, =gSaveBlock1Ptr
|
||||
ldr r0, [r5]
|
||||
ldr r1, =0x00003b18
|
||||
adds r4, r0, r1
|
||||
bl sub_81538D0
|
||||
adds r1, r0, 0
|
||||
ldrb r0, [r4]
|
||||
cmp r0, 0
|
||||
beq _0815392A
|
||||
ldrb r0, [r4, 0x1]
|
||||
cmp r0, 0
|
||||
beq _0815392A
|
||||
ldrh r0, [r4, 0x2]
|
||||
cmp r0, 0
|
||||
beq _0815392A
|
||||
cmp r1, 0
|
||||
beq _0815392A
|
||||
ldr r0, [r5]
|
||||
ldr r2, =0x00003b14
|
||||
adds r0, r2
|
||||
ldr r0, [r0]
|
||||
cmp r1, r0
|
||||
beq _0815393C
|
||||
_0815392A:
|
||||
movs r0, 0
|
||||
b _0815393E
|
||||
.pool
|
||||
_0815393C:
|
||||
movs r0, 0x1
|
||||
_0815393E:
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_81538F8
|
||||
|
||||
thumb_func_start sub_8153944
|
||||
sub_8153944: @ 8153944
|
||||
push {lr}
|
||||
sub sp, 0x4
|
||||
mov r1, sp
|
||||
movs r0, 0
|
||||
strh r0, [r1]
|
||||
ldr r0, =gSaveBlock1Ptr
|
||||
ldr r1, [r0]
|
||||
ldr r0, =0x00003b14
|
||||
adds r1, r0
|
||||
ldr r2, =0x01000008
|
||||
mov r0, sp
|
||||
bl CpuSet
|
||||
add sp, 0x4
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8153944
|
||||
|
||||
thumb_func_start sub_8153970
|
||||
sub_8153970: @ 8153970
|
||||
push {r4-r6,lr}
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
adds r3, r0, 0
|
||||
lsls r1, 24
|
||||
lsrs r1, 24
|
||||
adds r5, r1, 0
|
||||
lsls r2, 16
|
||||
lsrs r2, 16
|
||||
adds r6, r2, 0
|
||||
cmp r3, 0
|
||||
beq _08153990
|
||||
cmp r1, 0
|
||||
beq _08153990
|
||||
cmp r2, 0
|
||||
bne _08153996
|
||||
_08153990:
|
||||
bl sub_8153944
|
||||
b _081539BC
|
||||
_08153996:
|
||||
ldr r4, =gSaveBlock1Ptr
|
||||
ldr r0, [r4]
|
||||
ldr r1, =0x00003b18
|
||||
adds r0, r1
|
||||
strb r3, [r0]
|
||||
ldr r0, [r4]
|
||||
ldr r2, =0x00003b19
|
||||
adds r0, r2
|
||||
strb r5, [r0]
|
||||
ldr r0, [r4]
|
||||
adds r1, 0x2
|
||||
adds r0, r1
|
||||
strh r6, [r0]
|
||||
bl sub_81538D0
|
||||
ldr r1, [r4]
|
||||
ldr r2, =0x00003b14
|
||||
adds r1, r2
|
||||
str r0, [r1]
|
||||
_081539BC:
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8153970
|
||||
|
||||
thumb_func_start sub_81539D4
|
||||
sub_81539D4: @ 81539D4
|
||||
push {r4-r6,lr}
|
||||
ldr r6, =gSaveBlock1Ptr
|
||||
ldr r0, [r6]
|
||||
ldr r1, =0x00003b18
|
||||
adds r4, r0, r1
|
||||
bl sub_81538F8
|
||||
cmp r0, 0
|
||||
bne _081539F8
|
||||
bl sub_8153944
|
||||
movs r0, 0
|
||||
b _08153A1A
|
||||
.pool
|
||||
_081539F8:
|
||||
ldrh r5, [r4, 0x2]
|
||||
ldrb r0, [r4, 0x1]
|
||||
subs r0, 0x1
|
||||
strb r0, [r4, 0x1]
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08153A0C
|
||||
bl sub_8153944
|
||||
b _08153A18
|
||||
_08153A0C:
|
||||
bl sub_81538D0
|
||||
ldr r1, [r6]
|
||||
ldr r2, =0x00003b14
|
||||
adds r1, r2
|
||||
str r0, [r1]
|
||||
_08153A18:
|
||||
adds r0, r5, 0
|
||||
_08153A1A:
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_81539D4
|
||||
|
||||
thumb_func_start script_status_stop_and_ret_1
|
||||
script_status_stop_and_ret_1: @ 8153A24
|
||||
push {lr}
|
||||
bl StopScript
|
||||
movs r0, 0x1
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end script_status_stop_and_ret_1
|
||||
|
||||
thumb_func_start sub_8153A30
|
||||
sub_8153A30: @ 8153A30
|
||||
push {r4-r7,lr}
|
||||
adds r7, r0, 0
|
||||
bl ScriptReadWord
|
||||
str r0, [r7, 0x68]
|
||||
adds r0, r7, 0
|
||||
bl ScriptReadHalfword
|
||||
adds r5, r0, 0
|
||||
lsls r5, 16
|
||||
lsrs r5, 16
|
||||
adds r0, r7, 0
|
||||
bl ScriptReadWord
|
||||
adds r6, r0, 0
|
||||
adds r0, r7, 0
|
||||
bl ScriptReadHalfword
|
||||
adds r4, r0, 0
|
||||
lsls r4, 16
|
||||
lsrs r4, 16
|
||||
adds r0, r7, 0
|
||||
bl ScriptReadWord
|
||||
adds r3, r0, 0
|
||||
adds r0, r5, 0
|
||||
adds r1, r6, 0
|
||||
adds r2, r4, 0
|
||||
bl sub_81537CC
|
||||
cmp r0, 0x1
|
||||
bne _08153A74
|
||||
str r0, [r7, 0x70]
|
||||
b _08153A78
|
||||
_08153A74:
|
||||
bl sub_8153804
|
||||
_08153A78:
|
||||
movs r0, 0x1
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153A30
|
||||
|
||||
thumb_func_start sub_8153A80
|
||||
sub_8153A80: @ 8153A80
|
||||
movs r0, 0
|
||||
bx lr
|
||||
thumb_func_end sub_8153A80
|
||||
|
||||
thumb_func_start sub_8153A84
|
||||
sub_8153A84: @ 8153A84
|
||||
ldr r1, [r0, 0x8]
|
||||
ldrb r2, [r1]
|
||||
adds r1, 0x1
|
||||
str r1, [r0, 0x8]
|
||||
str r2, [r0, 0x6C]
|
||||
movs r0, 0
|
||||
bx lr
|
||||
thumb_func_end sub_8153A84
|
||||
|
||||
thumb_func_start sub_8153A94
|
||||
sub_8153A94: @ 8153A94
|
||||
push {r4,r5,lr}
|
||||
adds r4, r0, 0
|
||||
ldr r0, [r4, 0x8]
|
||||
ldrb r5, [r0]
|
||||
adds r0, 0x1
|
||||
str r0, [r4, 0x8]
|
||||
adds r0, r4, 0
|
||||
bl ScriptReadWord
|
||||
ldr r1, [r4, 0x68]
|
||||
subs r0, r1
|
||||
ldr r1, [r4, 0x64]
|
||||
adds r1, r0, r1
|
||||
cmp r5, 0xFF
|
||||
beq _08153AB8
|
||||
ldr r0, [r4, 0x6C]
|
||||
cmp r5, r0
|
||||
bne _08153ABE
|
||||
_08153AB8:
|
||||
ldr r0, =gStringVar4
|
||||
bl StringExpandPlaceholders
|
||||
_08153ABE:
|
||||
movs r0, 0
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153A94
|
||||
|
||||
thumb_func_start sub_8153ACC
|
||||
sub_8153ACC: @ 8153ACC
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl ScriptReadWord
|
||||
ldr r1, [r4, 0x68]
|
||||
subs r0, r1
|
||||
ldr r1, [r4, 0x64]
|
||||
adds r0, r1
|
||||
bl ScriptContext2_RunNewScript
|
||||
movs r0, 0
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153ACC
|
||||
|
||||
thumb_func_start sub_8153AE8
|
||||
sub_8153AE8: @ 8153AE8
|
||||
push {r4-r7,lr}
|
||||
mov r7, r9
|
||||
mov r6, r8
|
||||
push {r6,r7}
|
||||
adds r7, r0, 0
|
||||
bl IsEnigmaBerryValid
|
||||
mov r8, r0
|
||||
adds r0, r7, 0
|
||||
bl ScriptReadWord
|
||||
adds r4, r0, 0
|
||||
ldr r0, [r7, 0x68]
|
||||
subs r4, r0
|
||||
ldr r0, [r7, 0x64]
|
||||
adds r4, r0
|
||||
ldr r0, =gStringVar1
|
||||
mov r9, r0
|
||||
ldr r6, =gSaveBlock1Ptr
|
||||
ldr r1, [r6]
|
||||
ldr r5, =0x000031f8
|
||||
adds r1, r5
|
||||
movs r2, 0x7
|
||||
bl StringCopyN
|
||||
adds r0, r4, 0
|
||||
bl SetEnigmaBerry
|
||||
ldr r4, =gStringVar2
|
||||
ldr r1, [r6]
|
||||
adds r1, r5
|
||||
adds r0, r4, 0
|
||||
movs r2, 0x7
|
||||
bl StringCopyN
|
||||
mov r0, r8
|
||||
cmp r0, 0
|
||||
bne _08153B54
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftBerry
|
||||
b _08153B74
|
||||
.pool
|
||||
_08153B54:
|
||||
mov r0, r9
|
||||
adds r1, r4, 0
|
||||
bl StringCompare
|
||||
cmp r0, 0
|
||||
beq _08153B70
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftBerryTransform
|
||||
b _08153B74
|
||||
.pool
|
||||
_08153B70:
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftBerryObtained
|
||||
_08153B74:
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x2
|
||||
str r0, [r7, 0x6C]
|
||||
bl IsEnigmaBerryValid
|
||||
cmp r0, 0x1
|
||||
bne _08153B9C
|
||||
ldr r0, =0x0000402d
|
||||
movs r1, 0x1
|
||||
bl VarSet
|
||||
b _08153BA0
|
||||
.pool
|
||||
_08153B9C:
|
||||
movs r0, 0x1
|
||||
str r0, [r7, 0x6C]
|
||||
_08153BA0:
|
||||
movs r0, 0
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153AE8
|
||||
|
||||
thumb_func_start sub_8153BB0
|
||||
sub_8153BB0: @ 8153BB0
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
ldr r2, [r4, 0x8]
|
||||
ldrb r0, [r2]
|
||||
adds r2, 0x1
|
||||
str r2, [r4, 0x8]
|
||||
ldrb r1, [r2]
|
||||
adds r2, 0x1
|
||||
str r2, [r4, 0x8]
|
||||
bl GiveGiftRibbonToParty
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftSpecialRibbon
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x2
|
||||
str r0, [r4, 0x6C]
|
||||
movs r0, 0
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153BB0
|
||||
|
||||
thumb_func_start sub_8153BE4
|
||||
sub_8153BE4: @ 8153BE4
|
||||
push {r4-r6,lr}
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5,r6}
|
||||
sub sp, 0x4
|
||||
adds r4, r0, 0
|
||||
ldr r0, [r4, 0x8]
|
||||
ldrb r1, [r0]
|
||||
mov r9, r1
|
||||
adds r0, 0x1
|
||||
str r0, [r4, 0x8]
|
||||
ldrb r1, [r0]
|
||||
mov r8, r1
|
||||
adds r1, r0, 0x1
|
||||
str r1, [r4, 0x8]
|
||||
ldrb r6, [r0, 0x1]
|
||||
adds r1, 0x1
|
||||
str r1, [r4, 0x8]
|
||||
adds r0, r4, 0
|
||||
bl ScriptReadWord
|
||||
adds r5, r0, 0
|
||||
ldr r0, [r4, 0x68]
|
||||
subs r5, r0
|
||||
ldr r0, [r4, 0x64]
|
||||
adds r5, r0
|
||||
adds r0, r4, 0
|
||||
bl ScriptReadWord
|
||||
adds r1, r0, 0
|
||||
ldr r0, [r4, 0x68]
|
||||
subs r1, r0
|
||||
ldr r0, [r4, 0x64]
|
||||
adds r1, r0
|
||||
subs r1, r5
|
||||
lsls r1, 16
|
||||
lsrs r1, 16
|
||||
str r6, [sp]
|
||||
adds r0, r5, 0
|
||||
mov r2, r9
|
||||
mov r3, r8
|
||||
bl InitRamScript
|
||||
movs r0, 0
|
||||
add sp, 0x4
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153BE4
|
||||
|
||||
thumb_func_start sub_8153C4C
|
||||
sub_8153C4C: @ 8153C4C
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl EnableNationalPokedex
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftNationalDex
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x2
|
||||
str r0, [r4, 0x6C]
|
||||
movs r0, 0
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153C4C
|
||||
|
||||
thumb_func_start sub_8153C70
|
||||
sub_8153C70: @ 8153C70
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
ldr r1, [r4, 0x8]
|
||||
ldrb r0, [r1]
|
||||
adds r1, 0x1
|
||||
str r1, [r4, 0x8]
|
||||
bl sub_811EFC0
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftRareWord
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x2
|
||||
str r0, [r4, 0x6C]
|
||||
movs r0, 0
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153C70
|
||||
|
||||
thumb_func_start sub_8153C9C
|
||||
sub_8153C9C: @ 8153C9C
|
||||
push {r4,r5,lr}
|
||||
ldr r1, [r0, 0x8]
|
||||
ldrb r5, [r1]
|
||||
adds r1, 0x1
|
||||
str r1, [r0, 0x8]
|
||||
ldrb r4, [r1]
|
||||
adds r1, 0x1
|
||||
str r1, [r0, 0x8]
|
||||
bl ScriptReadHalfword
|
||||
adds r2, r0, 0
|
||||
lsls r2, 16
|
||||
lsrs r2, 16
|
||||
adds r0, r5, 0
|
||||
adds r1, r4, 0
|
||||
bl sub_8153970
|
||||
movs r0, 0
|
||||
pop {r4,r5}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153C9C
|
||||
|
||||
thumb_func_start sub_8153CC8
|
||||
sub_8153CC8: @ 8153CC8
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
sub sp, 0x88
|
||||
adds r6, r0, 0
|
||||
bl ScriptReadWord
|
||||
ldr r1, [r6, 0x68]
|
||||
subs r0, r1
|
||||
ldr r1, [r6, 0x64]
|
||||
adds r5, r0, r1
|
||||
movs r0, 0x64
|
||||
adds r0, r5
|
||||
mov r8, r0
|
||||
add r4, sp, 0x24
|
||||
adds r0, r4, 0
|
||||
adds r1, r5, 0
|
||||
movs r2, 0x64
|
||||
bl memcpy
|
||||
adds r0, r4, 0
|
||||
movs r1, 0x41
|
||||
bl GetMonData
|
||||
lsls r0, 16
|
||||
lsrs r4, r0, 16
|
||||
movs r0, 0xCE
|
||||
lsls r0, 1
|
||||
cmp r4, r0
|
||||
bne _08153D18
|
||||
ldr r0, =gStringVar1
|
||||
ldr r1, =gText_EggNickname
|
||||
movs r2, 0xB
|
||||
bl StringCopyN
|
||||
b _08153D22
|
||||
.pool
|
||||
_08153D18:
|
||||
ldr r0, =gStringVar1
|
||||
ldr r1, =gText_Pokemon
|
||||
movs r2, 0xB
|
||||
bl StringCopyN
|
||||
_08153D22:
|
||||
ldr r0, =gPlayerPartyCount
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0x6
|
||||
bne _08153D4C
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftFullParty
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x3
|
||||
b _08153DB6
|
||||
.pool
|
||||
_08153D4C:
|
||||
ldr r7, =gPlayerParty + 500
|
||||
adds r0, r7, 0
|
||||
adds r1, r5, 0
|
||||
movs r2, 0x64
|
||||
bl memcpy
|
||||
mov r0, sp
|
||||
mov r1, r8
|
||||
movs r2, 0x24
|
||||
bl memcpy
|
||||
movs r0, 0xCE
|
||||
lsls r0, 1
|
||||
cmp r4, r0
|
||||
beq _08153D86
|
||||
adds r0, r4, 0
|
||||
bl SpeciesToNationalPokedexNum
|
||||
adds r4, r0, 0
|
||||
lsls r4, 16
|
||||
lsrs r4, 16
|
||||
adds r0, r4, 0
|
||||
movs r1, 0x2
|
||||
bl GetSetPokedexFlag
|
||||
adds r0, r4, 0
|
||||
movs r1, 0x3
|
||||
bl GetSetPokedexFlag
|
||||
_08153D86:
|
||||
adds r0, r7, 0
|
||||
movs r1, 0xC
|
||||
bl GetMonData
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
bl ItemIsMail
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _08153DA4
|
||||
adds r0, r7, 0
|
||||
mov r1, sp
|
||||
bl GiveMailToMon2
|
||||
_08153DA4:
|
||||
bl CompactPartySlots
|
||||
bl CalculatePlayerPartyCount
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftSentOver
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x2
|
||||
_08153DB6:
|
||||
str r0, [r6, 0x6C]
|
||||
movs r0, 0
|
||||
add sp, 0x88
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153CC8
|
||||
|
||||
thumb_func_start sub_8153DD4
|
||||
sub_8153DD4: @ 8153DD4
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl ScriptReadWord
|
||||
adds r1, r0, 0
|
||||
ldr r0, [r4, 0x68]
|
||||
subs r1, r0
|
||||
ldr r0, [r4, 0x64]
|
||||
adds r1, r0
|
||||
ldr r0, =gSaveBlock2Ptr
|
||||
ldr r0, [r0]
|
||||
ldr r2, =0x00000bec
|
||||
adds r0, r2
|
||||
movs r2, 0xBC
|
||||
bl memcpy
|
||||
bl sub_81652B4
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_MysteryGiftNewTrainer
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x2
|
||||
str r0, [r4, 0x6C]
|
||||
movs r0, 0
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153DD4
|
||||
|
||||
thumb_func_start sub_8153E1C
|
||||
sub_8153E1C: @ 8153E1C
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl EnableResetRTC
|
||||
ldr r0, =gStringVar4
|
||||
ldr r1, =gText_InGameClockUsable
|
||||
bl StringExpandPlaceholders
|
||||
movs r0, 0x2
|
||||
str r0, [r4, 0x6C]
|
||||
movs r0, 0
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end sub_8153E1C
|
||||
|
||||
thumb_func_start sub_8153E40
|
||||
sub_8153E40: @ 8153E40
|
||||
push {r4-r6,lr}
|
||||
adds r6, r0, 0
|
||||
bl ScriptReadWord
|
||||
adds r5, r0, 0
|
||||
adds r0, r6, 0
|
||||
bl ScriptReadWord
|
||||
adds r4, r0, 0
|
||||
ldr r0, [r6, 0x68]
|
||||
subs r4, r0
|
||||
ldr r0, [r6, 0x64]
|
||||
adds r4, r0
|
||||
adds r0, r6, 0
|
||||
bl ScriptReadWord
|
||||
adds r1, r0, 0
|
||||
ldr r0, [r6, 0x68]
|
||||
subs r1, r0
|
||||
ldr r0, [r6, 0x64]
|
||||
adds r1, r0
|
||||
subs r1, r4
|
||||
adds r0, r4, 0
|
||||
bl CalcByteArraySum
|
||||
cmp r5, r0
|
||||
beq _08153E7E
|
||||
movs r0, 0
|
||||
str r0, [r6, 0x70]
|
||||
movs r0, 0x1
|
||||
str r0, [r6, 0x6C]
|
||||
_08153E7E:
|
||||
movs r0, 0x1
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153E40
|
||||
|
||||
thumb_func_start sub_8153E88
|
||||
sub_8153E88: @ 8153E88
|
||||
push {r4-r6,lr}
|
||||
adds r6, r0, 0
|
||||
bl ScriptReadWord
|
||||
adds r5, r0, 0
|
||||
adds r0, r6, 0
|
||||
bl ScriptReadWord
|
||||
adds r4, r0, 0
|
||||
ldr r0, [r6, 0x68]
|
||||
subs r4, r0
|
||||
ldr r0, [r6, 0x64]
|
||||
adds r4, r0
|
||||
adds r0, r6, 0
|
||||
bl ScriptReadWord
|
||||
adds r1, r0, 0
|
||||
ldr r0, [r6, 0x68]
|
||||
subs r1, r0
|
||||
ldr r0, [r6, 0x64]
|
||||
adds r1, r0
|
||||
subs r1, r4
|
||||
adds r0, r4, 0
|
||||
bl CalcCRC16
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
cmp r5, r0
|
||||
beq _08153ECA
|
||||
movs r0, 0
|
||||
str r0, [r6, 0x70]
|
||||
movs r0, 0x1
|
||||
str r0, [r6, 0x6C]
|
||||
_08153ECA:
|
||||
movs r0, 0x1
|
||||
pop {r4-r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8153E88
|
||||
|
||||
.align 2, 0 @ Don't pad with nop.
|
|
@ -114,7 +114,7 @@ sub_80E6CA0: @ 80E6CA0
|
|||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _080E6D1C
|
||||
bl sub_81539D4
|
||||
bl GetRecordMixingGift
|
||||
ldr r2, =0x000011c8
|
||||
adds r1, r5, r2
|
||||
strh r0, [r1]
|
||||
|
@ -186,7 +186,7 @@ sub_80E6D54: @ 80E6D54
|
|||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _080E6DEE
|
||||
bl sub_81539D4
|
||||
bl GetRecordMixingGift
|
||||
ldr r2, =0x000011c8
|
||||
adds r1, r5, r2
|
||||
strh r0, [r1]
|
||||
|
@ -282,7 +282,7 @@ _080E6E60:
|
|||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _080E6EFA
|
||||
bl sub_81539D4
|
||||
bl GetRecordMixingGift
|
||||
ldr r1, [r5]
|
||||
ldr r2, =0x00001210
|
||||
adds r1, r2
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
.section script_data, "aw", %progbits
|
||||
|
||||
.align 2
|
||||
gMysteryEventScriptCmdTable:: @ 82DED2C
|
||||
.4byte MEScrCmd_nop
|
||||
.4byte MEScrCmd_checkcompat
|
||||
.4byte MEScrCmd_end
|
||||
.4byte MEScrCmd_setmsg
|
||||
.4byte MEScrCmd_setstatus
|
||||
.4byte MEScrCmd_runscript
|
||||
.4byte MEScrCmd_initramscript
|
||||
.4byte MEScrCmd_setenigmaberry
|
||||
.4byte MEScrCmd_giveribbon
|
||||
.4byte MEScrCmd_givenationaldex
|
||||
.4byte MEScrCmd_addrareword
|
||||
.4byte MEScrCmd_setrecordmixinggift
|
||||
.4byte MEScrCmd_givepokemon
|
||||
.4byte MEScrCmd_addtrainer
|
||||
.4byte MEScrCmd_enableresetrtc
|
||||
.4byte MEScrCmd_checksum
|
||||
.4byte MEScrCmd_crc
|
||||
gMysteryEventScriptCmdTableEnd::
|
|
@ -1,41 +1,17 @@
|
|||
#include "constants/flags.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/moves.h"
|
||||
#include "constants/songs.h"
|
||||
#include "constants/species.h"
|
||||
#include "constants/vars.h"
|
||||
.include "asm/macros.inc"
|
||||
.include "asm/macros/event.inc"
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.section .rodata
|
||||
|
||||
gText_MysteryGiftBerry:: @ 8674AE4
|
||||
.string "Obtained a {STR_VAR_2} BERRY!\nDad has it at PETALBURG GYM.$"
|
||||
|
||||
gText_MysteryGiftBerryTransform:: @ 8674B16
|
||||
.string "The {STR_VAR_1} BERRY transformed into\none {STR_VAR_2} BERRY.$"
|
||||
|
||||
gText_MysteryGiftBerryObtained:: @ 8674B42
|
||||
.string "The {STR_VAR_1} BERRY has already been\nobtained.$"
|
||||
|
||||
gText_MysteryGiftSpecialRibbon:: @ 8674B6A
|
||||
.string "A special RIBBON was awarded to\nyour party POKéMON.$"
|
||||
|
||||
gText_MysteryGiftNationalDex:: @ 8674B9E
|
||||
.string "The POKéDEX has been upgraded\nwith the NATIONAL MODE.$"
|
||||
|
||||
gText_MysteryGiftRareWord:: @ 8674BD4
|
||||
.string "A rare word has been added.$"
|
||||
|
||||
gText_MysteryGiftSentOver:: @ 8674BF0
|
||||
.string "{STR_VAR_1} was sent over!$"
|
||||
|
||||
gText_MysteryGiftFullParty:: @ 8674C02
|
||||
.string "Your party is full.\n{STR_VAR_1} could not be sent over.$"
|
||||
|
||||
gText_MysteryGiftNewTrainer:: @ 8674C31
|
||||
.string "A new TRAINER has arrived in\nHOENN.$"
|
||||
.string "A new adversary has arrived in the\nBATTLE TOWER.$"
|
||||
|
||||
gText_MysteryGiftCantBeUsed:: @ 8674C86
|
||||
.string "This data can’t be used in\nthis version.$"
|
||||
|
||||
gUnknown_08674CAF:: @ 8674CAF
|
||||
.incbin "baserom.gba", 0x00674caf, 0x2e
|
||||
gUnknown_08674CB0:: @ 8674CB0
|
||||
.incbin "baserom.gba", 0x00674cb0, 0x2d
|
||||
|
||||
gText_MysteryGiftStampCard::
|
||||
.string "Thank you for using the STAMP CARD\nSystem.\pYou have {STR_VAR_1} more to collect to\nfill your STAMP CARD.$"
|
|
@ -1,21 +0,0 @@
|
|||
.section script_data, "aw", %progbits
|
||||
|
||||
.align 2
|
||||
gUnknown_082DED2C:: @ 82DED2C
|
||||
.4byte sub_8153A80
|
||||
.4byte sub_8153A30
|
||||
.4byte script_status_stop_and_ret_1
|
||||
.4byte sub_8153A94
|
||||
.4byte sub_8153A84
|
||||
.4byte sub_8153ACC
|
||||
.4byte sub_8153BE4
|
||||
.4byte sub_8153AE8
|
||||
.4byte sub_8153BB0
|
||||
.4byte sub_8153C4C
|
||||
.4byte sub_8153C70
|
||||
.4byte sub_8153C9C
|
||||
.4byte sub_8153CC8
|
||||
.4byte sub_8153DD4
|
||||
.4byte sub_8153E1C
|
||||
.4byte sub_8153E40
|
||||
.4byte sub_8153E88
|
|
@ -393,7 +393,7 @@ PetalburgCity_Gym_EventScript_204DCE:: @ 8204DCE
|
|||
checkpcitem ITEM_ENIGMA_BERRY, 1
|
||||
compare VAR_RESULT, 1
|
||||
goto_eq PetalburgCity_Gym_EventScript_204E17
|
||||
compare VAR_0x402D, 0
|
||||
compare VAR_ENIGMA_BERRY_AVAILABLE, 0
|
||||
goto_eq PetalburgCity_Gym_EventScript_204E17
|
||||
msgbox PetalburgCity_Gym_Text_2A6D3D, 4
|
||||
setvar VAR_RESULT, 1
|
||||
|
@ -407,7 +407,7 @@ PetalburgCity_Gym_EventScript_204E1D:: @ 8204E1D
|
|||
giveitem_std ITEM_ENIGMA_BERRY
|
||||
compare VAR_RESULT, 0
|
||||
goto_eq PetalburgCity_Gym_EventScript_272054
|
||||
setvar VAR_0x402D, 0
|
||||
setvar VAR_ENIGMA_BERRY_AVAILABLE, 0
|
||||
release
|
||||
end
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ gSpecials:: @ 81DBA64
|
|||
def_special sub_81B9B80
|
||||
def_special sub_81B9D08
|
||||
def_special sub_80F9490
|
||||
def_special sub_81652B4
|
||||
def_special ValidateEReaderTrainer
|
||||
def_special sub_8139228
|
||||
def_special sub_80F94E8
|
||||
def_special sub_816AE58
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#define VAR_HAPPINESS_STEP_COUNTER 0x402A
|
||||
#define VAR_POISON_STEP_COUNTER 0x402B
|
||||
#define VAR_RESET_RTC_ENABLE 0x402C
|
||||
#define VAR_0x402D 0x402D
|
||||
#define VAR_ENIGMA_BERRY_AVAILABLE 0x402D
|
||||
#define VAR_0x402E 0x402E
|
||||
|
||||
#define VAR_FRONTIER_MANIAC_FACILITY 0x402F
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef GUARD_MYSTERY_EVENT_MSG_H
|
||||
#define GUARD_MYSTERY_EVENT_MSG_H
|
||||
|
||||
extern const u8 gText_MysteryGiftBerry[];
|
||||
extern const u8 gText_MysteryGiftBerryTransform[];
|
||||
extern const u8 gText_MysteryGiftBerryObtained[];
|
||||
extern const u8 gText_MysteryGiftSpecialRibbon[];
|
||||
extern const u8 gText_MysteryGiftNationalDex[];
|
||||
extern const u8 gText_MysteryGiftRareWord[];
|
||||
extern const u8 gText_MysteryGiftSentOver[];
|
||||
extern const u8 gText_MysteryGiftFullParty[];
|
||||
extern const u8 gText_MysteryGiftNewTrainer[];
|
||||
extern const u8 gText_MysteryGiftNewAdversaryInBattleTower[];
|
||||
extern const u8 gText_MysteryGiftCantBeUsed[];
|
||||
|
||||
#endif // GUARD_MYSTERY_EVENT_MSG_H
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef GUARD_MYSTERY_EVENT_SCRIPT_H
|
||||
#define GUARD_MYSTERY_EVENT_SCRIPT_H
|
||||
|
||||
u32 RunMysteryEventScript(u8 *);
|
||||
void sub_8153870(u8 *script);
|
||||
bool32 sub_8153884(u32 *a0);
|
||||
u32 RunMysteryEventScript(u8 *script);
|
||||
void SetMysteryEventScriptStatus(u32 val);
|
||||
u16 GetRecordMixingGift(void);
|
||||
|
||||
|
|
|
@ -148,6 +148,10 @@ extern const u8 gText_MoveItemsDescription[];
|
|||
extern const u8 gText_SeeYa[];
|
||||
extern const u8 gText_SeeYaDescription[];
|
||||
|
||||
extern const u8 gText_EggNickname[];
|
||||
extern const u8 gText_Pokemon[];
|
||||
extern const u8 gText_InGameClockUsable[];
|
||||
|
||||
// menu texts
|
||||
extern const u8 gText_MenuPokedex[];
|
||||
extern const u8 gText_MenuPokemon[];
|
||||
|
|
|
@ -205,7 +205,7 @@ SECTIONS {
|
|||
asm/roulette_util.o(.text);
|
||||
asm/cable_car_util.o(.text);
|
||||
src/save.o(.text);
|
||||
asm/mystery_event_script.o(.text);
|
||||
src/mystery_event_script.o(.text);
|
||||
asm/field_effect_helpers.o(.text);
|
||||
asm/contest_ai.o(.text);
|
||||
asm/battle_anim_sound_tasks.o(.text);
|
||||
|
@ -289,7 +289,7 @@ SECTIONS {
|
|||
data/battle_scripts_2.o(script_data);
|
||||
data/battle_ai_scripts.o(script_data);
|
||||
data/contest_ai_scripts.o(script_data);
|
||||
data/script_funcs.o(script_data);
|
||||
data/mystery_event_script_cmd_table.o(script_data);
|
||||
} =0
|
||||
|
||||
lib_text :
|
||||
|
@ -543,7 +543,8 @@ SECTIONS {
|
|||
data/unk_transition.o(.rodata);
|
||||
data/link_strings.o(.rodata);
|
||||
data/fonts.o(.rodata);
|
||||
data/mystery_event_msg.o(.rodata);
|
||||
src/mystery_event_msg.o(.rodata);
|
||||
data/mystery_event_scripts.o(.rodata);
|
||||
src/m4a_tables.o(.rodata);
|
||||
data/sound_data.o(.rodata);
|
||||
} =0
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#include "global.h"
|
||||
|
||||
const u8 gText_MysteryGiftBerry[] = _("Obtained a {STR_VAR_2} BERRY!\nDad has it at PETALBURG GYM.");
|
||||
const u8 gText_MysteryGiftBerryTransform[] = _("The {STR_VAR_1} BERRY transformed into\none {STR_VAR_2} BERRY.");
|
||||
const u8 gText_MysteryGiftBerryObtained[] = _("The {STR_VAR_1} BERRY has already been\nobtained.");
|
||||
const u8 gText_MysteryGiftSpecialRibbon[] = _("A special RIBBON was awarded to\nyour party POKéMON.");
|
||||
const u8 gText_MysteryGiftNationalDex[] = _("The POKéDEX has been upgraded\nwith the NATIONAL MODE.");
|
||||
const u8 gText_MysteryGiftRareWord[] = _("A rare word has been added.");
|
||||
const u8 gText_MysteryGiftSentOver[] = _("{STR_VAR_1} was sent over!");
|
||||
const u8 gText_MysteryGiftFullParty[] = _("Your party is full.\n{STR_VAR_1} could not be sent over.");
|
||||
const u8 gText_MysteryGiftNewTrainer[] = _("A new TRAINER has arrived in\nHOENN.");
|
||||
const u8 gText_MysteryGiftNewAdversaryInBattleTower[] = _("A new adversary has arrived in the\nBATTLE TOWER.");
|
||||
const u8 gText_MysteryGiftCantBeUsed[] = _("This data can’t be used in\nthis version.");
|
|
@ -0,0 +1,396 @@
|
|||
#include "global.h"
|
||||
#include "berry.h"
|
||||
#include "battle_tower.h"
|
||||
#include "easy_chat.h"
|
||||
#include "event_data.h"
|
||||
#include "mail.h"
|
||||
#include "mystery_event_script.h"
|
||||
#include "pokedex.h"
|
||||
#include "pokemon.h"
|
||||
#include "pokemon_size_record.h"
|
||||
#include "script.h"
|
||||
#include "constants/species.h"
|
||||
#include "strings.h"
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "mystery_event_msg.h"
|
||||
#include "pokemon_storage_system.h"
|
||||
|
||||
extern void sub_811EFC0(u8);
|
||||
extern void ValidateEReaderTrainer(void);
|
||||
|
||||
extern ScrCmdFunc gMysteryEventScriptCmdTable[];
|
||||
extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[];
|
||||
|
||||
#define LANGUAGE_MASK 0x1
|
||||
#define VERSION_MASK 0x200
|
||||
|
||||
EWRAM_DATA struct ScriptContext sMysteryEventScriptContext = {0};
|
||||
|
||||
static bool32 CheckCompatibility(u16 a1, u32 a2, u16 a3, u32 a4)
|
||||
{
|
||||
if (!(a1 & LANGUAGE_MASK))
|
||||
return FALSE;
|
||||
|
||||
if (!(a2 & LANGUAGE_MASK))
|
||||
return FALSE;
|
||||
|
||||
if (!(a3 & 0x4))
|
||||
return FALSE;
|
||||
|
||||
if (!(a4 & VERSION_MASK))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void SetIncompatible(void)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftCantBeUsed);
|
||||
SetMysteryEventScriptStatus(3);
|
||||
}
|
||||
|
||||
static void InitMysteryEventScript(struct ScriptContext *ctx, u8 *script)
|
||||
{
|
||||
InitScriptContext(ctx, gMysteryEventScriptCmdTable, gMysteryEventScriptCmdTableEnd);
|
||||
SetupBytecodeScript(ctx, script);
|
||||
ctx->data[0] = (u32)script;
|
||||
ctx->data[1] = 0;
|
||||
ctx->data[2] = 0;
|
||||
ctx->data[3] = 0;
|
||||
}
|
||||
|
||||
static bool32 RunMysteryEventScriptCommand(struct ScriptContext *ctx)
|
||||
{
|
||||
if (RunScriptCommand(ctx) && ctx->data[3])
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_8153870(u8 *script)
|
||||
{
|
||||
InitMysteryEventScript(&sMysteryEventScriptContext, script);
|
||||
}
|
||||
|
||||
bool32 sub_8153884(u32 *a0)
|
||||
{
|
||||
bool32 ret = RunMysteryEventScriptCommand(&sMysteryEventScriptContext);
|
||||
*a0 = sMysteryEventScriptContext.data[2];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
u32 RunMysteryEventScript(u8 *script)
|
||||
{
|
||||
struct ScriptContext *ctx = &sMysteryEventScriptContext;
|
||||
InitMysteryEventScript(ctx, script);
|
||||
while (RunMysteryEventScriptCommand(ctx))
|
||||
;
|
||||
return ctx->data[2];
|
||||
}
|
||||
|
||||
void SetMysteryEventScriptStatus(u32 val)
|
||||
{
|
||||
sMysteryEventScriptContext.data[2] = val;
|
||||
}
|
||||
|
||||
static int CalcRecordMixingGiftChecksum(void)
|
||||
{
|
||||
unsigned int i;
|
||||
int sum = 0;
|
||||
u8 *data = (u8*)(&gSaveBlock1Ptr->recordMixingGift.data);
|
||||
|
||||
for (i = 0; i < sizeof(gSaveBlock1Ptr->recordMixingGift.data); i++)
|
||||
sum += data[i];
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
static bool32 IsRecordMixingGiftValid(void)
|
||||
{
|
||||
struct RecordMixingGiftData *data = &gSaveBlock1Ptr->recordMixingGift.data;
|
||||
int checksum = CalcRecordMixingGiftChecksum();
|
||||
|
||||
if (data->unk0 == 0
|
||||
|| data->quantity == 0
|
||||
|| data->itemId == 0
|
||||
|| checksum == 0
|
||||
|| checksum != gSaveBlock1Ptr->recordMixingGift.checksum)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void ClearRecordMixingGift(void)
|
||||
{
|
||||
CpuFill16(0, &gSaveBlock1Ptr->recordMixingGift, sizeof(gSaveBlock1Ptr->recordMixingGift));
|
||||
}
|
||||
|
||||
static void SetRecordMixingGift(u8 unk, u8 quantity, u16 itemId)
|
||||
{
|
||||
if (!unk || !quantity || !itemId)
|
||||
{
|
||||
ClearRecordMixingGift();
|
||||
}
|
||||
else
|
||||
{
|
||||
gSaveBlock1Ptr->recordMixingGift.data.unk0 = unk;
|
||||
gSaveBlock1Ptr->recordMixingGift.data.quantity = quantity;
|
||||
gSaveBlock1Ptr->recordMixingGift.data.itemId = itemId;
|
||||
gSaveBlock1Ptr->recordMixingGift.checksum = CalcRecordMixingGiftChecksum();
|
||||
}
|
||||
}
|
||||
|
||||
u16 GetRecordMixingGift(void)
|
||||
{
|
||||
struct RecordMixingGiftData *data = &gSaveBlock1Ptr->recordMixingGift.data;
|
||||
|
||||
if (!IsRecordMixingGiftValid())
|
||||
{
|
||||
ClearRecordMixingGift();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
u16 itemId = data->itemId;
|
||||
data->quantity--;
|
||||
if (data->quantity == 0)
|
||||
ClearRecordMixingGift();
|
||||
else
|
||||
gSaveBlock1Ptr->recordMixingGift.checksum = CalcRecordMixingGiftChecksum();
|
||||
|
||||
return itemId;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_end(struct ScriptContext *ctx)
|
||||
{
|
||||
StopScript(ctx);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_checkcompat(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 v1;
|
||||
u32 v2;
|
||||
u16 v3;
|
||||
u32 v4;
|
||||
|
||||
ctx->data[1] = ScriptReadWord(ctx);
|
||||
v1 = ScriptReadHalfword(ctx);
|
||||
v2 = ScriptReadWord(ctx);
|
||||
v3 = ScriptReadHalfword(ctx);
|
||||
v4 = ScriptReadWord(ctx);
|
||||
|
||||
if (CheckCompatibility(v1, v2, v3, v4) == TRUE)
|
||||
ctx->data[3] = 1;
|
||||
else
|
||||
SetIncompatible();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_nop(struct ScriptContext *ctx)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setstatus(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 value = ScriptReadByte(ctx);
|
||||
ctx->data[2] = value;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setmsg(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 value = ScriptReadByte(ctx);
|
||||
u8 *str = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
if (value == 255 || value == ctx->data[2])
|
||||
StringExpandPlaceholders(gStringVar4, str);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_runscript(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 *script = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
ScriptContext2_RunNewScript(script);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setenigmaberry(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 *str;
|
||||
const u8 *message;
|
||||
bool32 haveBerry = IsEnigmaBerryValid();
|
||||
u8 *berry = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
StringCopyN(gStringVar1, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_COUNT);
|
||||
SetEnigmaBerry(berry);
|
||||
StringCopyN(gStringVar2, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_COUNT);
|
||||
|
||||
if (!haveBerry)
|
||||
{
|
||||
str = gStringVar4;
|
||||
message = gText_MysteryGiftBerry;
|
||||
}
|
||||
else if (StringCompare(gStringVar1, gStringVar2))
|
||||
{
|
||||
str = gStringVar4;
|
||||
message = gText_MysteryGiftBerryTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = gStringVar4;
|
||||
message = gText_MysteryGiftBerryObtained;
|
||||
}
|
||||
|
||||
StringExpandPlaceholders(str, message);
|
||||
|
||||
ctx->data[2] = 2;
|
||||
|
||||
if (IsEnigmaBerryValid() == TRUE)
|
||||
VarSet(VAR_ENIGMA_BERRY_AVAILABLE, 1);
|
||||
else
|
||||
ctx->data[2] = 1;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_giveribbon(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 index = ScriptReadByte(ctx);
|
||||
u8 ribbonId = ScriptReadByte(ctx);
|
||||
GiveGiftRibbonToParty(index, ribbonId);
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftSpecialRibbon);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_initramscript(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
u8 mapNum = ScriptReadByte(ctx);
|
||||
u8 objectId = ScriptReadByte(ctx);
|
||||
u8 *script = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
u8 *scriptEnd = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
InitRamScript(script, scriptEnd - script, mapGroup, mapNum, objectId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_givenationaldex(struct ScriptContext *ctx)
|
||||
{
|
||||
EnableNationalPokedex();
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNationalDex);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_addrareword(struct ScriptContext *ctx)
|
||||
{
|
||||
sub_811EFC0(ScriptReadByte(ctx));
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftRareWord);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setrecordmixinggift(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 unk = ScriptReadByte(ctx);
|
||||
u8 quantity = ScriptReadByte(ctx);
|
||||
u16 itemId = ScriptReadHalfword(ctx);
|
||||
SetRecordMixingGift(unk, quantity, itemId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx)
|
||||
{
|
||||
struct MailStruct mail;
|
||||
struct Pokemon pokemon;
|
||||
u16 species;
|
||||
u16 heldItem;
|
||||
u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0];
|
||||
void *pokemonPtr = (void *)data;
|
||||
void *mailPtr = (void *)(data + sizeof(struct Pokemon));
|
||||
|
||||
pokemon = *(struct Pokemon *)pokemonPtr;
|
||||
species = GetMonData(&pokemon, MON_DATA_SPECIES2);
|
||||
|
||||
if (species == SPECIES_EGG)
|
||||
StringCopyN(gStringVar1, gText_EggNickname, POKEMON_NAME_LENGTH + 1);
|
||||
else
|
||||
StringCopyN(gStringVar1, gText_Pokemon, POKEMON_NAME_LENGTH + 1);
|
||||
|
||||
if (gPlayerPartyCount == PARTY_SIZE)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftFullParty);
|
||||
ctx->data[2] = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&gPlayerParty[5], pokemonPtr, sizeof(struct Pokemon));
|
||||
memcpy(&mail, mailPtr, sizeof(struct MailStruct));
|
||||
|
||||
if (species != SPECIES_EGG)
|
||||
{
|
||||
u16 pokedexNum = SpeciesToNationalPokedexNum(species);
|
||||
GetSetPokedexFlag(pokedexNum, FLAG_SET_SEEN);
|
||||
GetSetPokedexFlag(pokedexNum, FLAG_SET_CAUGHT);
|
||||
}
|
||||
|
||||
heldItem = GetMonData(&gPlayerParty[5], MON_DATA_HELD_ITEM);
|
||||
if (ItemIsMail(heldItem))
|
||||
GiveMailToMon2(&gPlayerParty[5], &mail);
|
||||
CompactPartySlots();
|
||||
CalculatePlayerPartyCount();
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftSentOver);
|
||||
ctx->data[2] = 2;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_addtrainer(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0];
|
||||
memcpy((void*)(gSaveBlock2Ptr) + 0xBEC, (void *)data, 0xBC);
|
||||
ValidateEReaderTrainer();
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNewTrainer);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_enableresetrtc(struct ScriptContext *ctx)
|
||||
{
|
||||
EnableResetRTC();
|
||||
StringExpandPlaceholders(gStringVar4, gText_InGameClockUsable);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_checksum(struct ScriptContext *ctx)
|
||||
{
|
||||
int checksum = ScriptReadWord(ctx);
|
||||
u8 *data = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
u8 *dataEnd = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
if (checksum != CalcByteArraySum(data, dataEnd - data))
|
||||
{
|
||||
ctx->data[3] = 0;
|
||||
ctx->data[2] = 1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_crc(struct ScriptContext *ctx)
|
||||
{
|
||||
int crc = ScriptReadWord(ctx);
|
||||
u8 *data = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
u8 *dataEnd = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
if (crc != CalcCRC16(data, dataEnd - data))
|
||||
{
|
||||
ctx->data[3] = 0;
|
||||
ctx->data[2] = 1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -1229,8 +1229,7 @@ gUnknown_0203ABB8: @ 203ABB8
|
|||
|
||||
.space 0x4 /*unused var?*/
|
||||
|
||||
gUnknown_0203BBC0: @ 203BBC0
|
||||
.space 0x74
|
||||
.include "src/mystery_event_script.o"
|
||||
|
||||
gUnknown_0203BC34: @ 203BC34
|
||||
.space 0x4
|
||||
|
|
Loading…
Reference in New Issue