fix merge conflict and use EVENT_OBJECT_TEMPLATES_COUNT

This commit is contained in:
DizzyEggg 2018-11-18 20:19:10 +01:00
commit 27ee7d567e
37 changed files with 2386 additions and 4655 deletions

File diff suppressed because it is too large Load Diff

701
asm/mossdeep_gym.s Normal file
View File

@ -0,0 +1,701 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_81A8934
@ void sub_81A8934(u8)
sub_81A8934: @ 81A8934
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
ldr r4, =gUnknown_0203CE50
ldr r0, [r4]
cmp r0, 0
bne _081A894A
movs r0, 0x44
bl AllocZeroed
str r0, [r4]
_081A894A:
ldr r0, [r4]
adds r0, 0x41
strb r5, [r0]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81A8934
thumb_func_start sub_81A895C
sub_81A895C: @ 81A895C
push {r4,lr}
ldr r4, =gUnknown_0203CE50
ldr r0, [r4]
cmp r0, 0
beq _081A896E
bl Free
movs r0, 0
str r0, [r4]
_081A896E:
movs r0, 0xFF
movs r1, 0
movs r2, 0
bl GetEventObjectIdByLocalIdAndMap
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r1, =gEventObjects
adds r0, r1
bl EventObjectClearHeldMovementIfFinished
bl sub_80D338C
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81A895C
thumb_func_start sub_81A89A0
sub_81A89A0: @ 81A89A0
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x4
lsls r0, 24
lsrs r0, 24
str r0, [sp]
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0xC7
lsls r1, 4
adds r1, r0
mov r9, r1
movs r3, 0
mov r10, r3
mov r8, r3
_081A89C4:
mov r0, r8
lsls r4, r0, 1
adds r1, r4, r0
lsls r1, 3
add r1, r9
ldrh r0, [r1, 0x4]
adds r0, 0x7
ldrh r1, [r1, 0x6]
adds r1, 0x7
lsls r0, 16
asrs r0, 16
lsls r1, 16
asrs r1, 16
bl MapGridGetMetatileIdAt
lsls r0, 16
lsrs r1, r0, 16
ldr r0, =gUnknown_0203CE50
ldr r0, [r0]
adds r0, 0x41
ldrb r0, [r0]
movs r2, 0xA6
lsls r2, 2
cmp r0, 0
bne _081A89F8
subs r2, 0x48
_081A89F8:
ldr r0, =0x0000024f
cmp r1, r0
bls _081A8AD4
subs r1, r2
adds r0, r1, 0
cmp r1, 0
bge _081A8A08
adds r0, r1, 0x7
_081A8A08:
asrs r2, r0, 3
lsls r0, r2, 24
lsrs r0, 24
cmp r0, 0x4
bhi _081A8AD4
ldr r3, [sp]
cmp r0, r3
bne _081A8AD4
lsls r0, r2, 3
subs r0, r1, r0
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x3
bhi _081A8AD4
movs r1, 0
movs r2, 0
cmp r5, 0x1
beq _081A8A58
cmp r5, 0x1
bgt _081A8A44
cmp r5, 0
beq _081A8A4E
b _081A8AD4
.pool
_081A8A44:
cmp r5, 0x2
beq _081A8A64
cmp r5, 0x3
beq _081A8A70
b _081A8AD4
_081A8A4E:
ldr r7, =gUnknown_08612698
movs r1, 0x1
b _081A8A74
.pool
_081A8A58:
ldr r7, =gUnknown_0861269C
movs r2, 0x1
b _081A8A74
.pool
_081A8A64:
ldr r7, =gUnknown_086126A0
movs r1, 0xFF
b _081A8A74
.pool
_081A8A70:
ldr r7, =gUnknown_086126A4
movs r2, 0xFF
_081A8A74:
mov r3, r8
adds r0, r4, r3
lsls r0, 3
mov r3, r9
adds r4, r0, r3
lsls r0, r1, 24
asrs r0, 24
ldrh r1, [r4, 0x4]
adds r0, r1
strh r0, [r4, 0x4]
lsls r0, r2, 24
asrs r0, 24
ldrh r3, [r4, 0x6]
adds r0, r3
strh r0, [r4, 0x6]
ldrb r0, [r4]
ldr r6, =gSaveBlock1Ptr
ldr r2, [r6]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
bl GetEventObjectIdByLocalIdAndMap
lsls r0, 24
lsrs r0, 24
cmp r0, 0x10
beq _081A8ACC
mov r0, r8
adds r1, r5, 0
bl sub_81A8D60
ldrb r4, [r4]
mov r10, r4
mov r0, r10
ldr r2, [r6]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
adds r3, r7, 0
bl ScriptMovement_StartObjectMovementScript
b _081A8AD4
.pool
_081A8ACC:
mov r0, r8
adds r1, r5, 0
bl sub_81A8D94
_081A8AD4:
mov r0, r8
adds r0, 0x1
lsls r0, 24
lsrs r0, 24
mov r8, r0
cmp r0, 0x3F
bhi _081A8AE4
b _081A89C4
_081A8AE4:
mov r0, r10
add sp, 0x4
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81A89A0
thumb_func_start sub_81A8AF8
sub_81A8AF8: @ 81A8AF8
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
ldr r1, =gUnknown_0203CE50
ldr r2, [r1]
cmp r2, 0
bne _081A8B0C
b _081A8D4A
_081A8B0C:
adds r0, r2, 0
adds r0, 0x41
ldrb r0, [r0]
movs r3, 0xA6
lsls r3, 2
mov r10, r3
cmp r0, 0
bne _081A8B22
movs r0, 0x94
lsls r0, 2
mov r10, r0
_081A8B22:
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r3, 0xC7
lsls r3, 4
adds r7, r0, r3
movs r0, 0
mov r9, r0
adds r0, r2, 0
adds r0, 0x40
ldrb r0, [r0]
cmp r9, r0
bcc _081A8B3C
b _081A8D4A
_081A8B3C:
mov r8, r1
_081A8B3E:
mov r1, r8
ldr r0, [r1]
mov r2, r9
lsls r4, r2, 2
adds r0, r4
ldrb r0, [r0, 0x1]
lsls r1, r0, 1
adds r1, r0
lsls r1, 3
adds r1, r7
ldrh r0, [r1, 0x4]
adds r0, 0x7
ldrh r1, [r1, 0x6]
adds r1, 0x7
lsls r0, 16
asrs r0, 16
lsls r1, 16
asrs r1, 16
bl MapGridGetMetatileIdAt
lsls r0, 16
lsrs r0, 16
mov r3, r10
subs r1, r0, r3
adds r0, r1, 0
cmp r1, 0
bge _081A8B76
adds r0, r1, 0x7
_081A8B76:
asrs r0, 3
lsls r0, 3
subs r0, r1, r0
lsls r0, 24
lsrs r0, 24
mov r2, r8
ldr r1, [r2]
adds r1, r4
ldrb r1, [r1]
subs r0, r1
lsls r0, 24
asrs r1, r0, 24
cmp r1, 0
blt _081A8B96
cmp r1, 0x3
bne _081A8BAC
_081A8B96:
movs r0, 0x3
negs r0, r0
movs r6, 0
cmp r1, r0
bne _081A8BB4
b _081A8BB2
.pool
_081A8BAC:
movs r6, 0x2
cmp r1, 0
ble _081A8BB4
_081A8BB2:
movs r6, 0x1
_081A8BB4:
ldr r5, =gUnknown_0203CE50
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
ldrb r0, [r0]
ldr r1, =gSaveBlock1Ptr
ldr r2, [r1]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
bl GetEventObjectIdByLocalIdAndMap
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x10
bne _081A8BDC
b _081A8D32
_081A8BDC:
ldr r0, =gEventObjects
lsls r1, r2, 3
adds r1, r2
lsls r1, 2
adds r1, r0
ldrb r0, [r1, 0x18]
lsls r0, 28
lsrs r0, 28
adds r1, r0, 0
cmp r6, 0
bne _081A8C9C
cmp r0, 0x2
beq _081A8C60
cmp r0, 0x2
bgt _081A8C0C
cmp r0, 0x1
beq _081A8C30
b _081A8D32
.pool
_081A8C0C:
cmp r0, 0x3
beq _081A8C48
cmp r0, 0x4
beq _081A8C16
b _081A8D32
_081A8C16:
ldr r3, =gUnknown_086126AE
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0x7
b _081A8C72
.pool
_081A8C30:
ldr r3, =gUnknown_086126A8
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0xA
b _081A8C72
.pool
_081A8C48:
ldr r3, =gUnknown_086126AA
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0x8
b _081A8C72
.pool
_081A8C60:
ldr r3, =gUnknown_086126AC
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0x9
_081A8C72:
strb r1, [r0, 0x9]
mov r1, r8
ldr r0, [r1]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
ldrb r0, [r0]
ldr r1, =gSaveBlock1Ptr
ldr r2, [r1]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
bl ScriptMovement_StartObjectMovementScript
b _081A8D32
.pool
_081A8C9C:
cmp r6, 0x1
bne _081A8D32
cmp r0, 0x2
beq _081A8D00
cmp r0, 0x2
bgt _081A8CAE
cmp r0, 0x1
beq _081A8CD0
b _081A8D32
_081A8CAE:
cmp r1, 0x3
beq _081A8CE8
cmp r1, 0x4
bne _081A8D32
ldr r3, =gUnknown_086126AA
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0x8
b _081A8D12
.pool
_081A8CD0:
ldr r3, =gUnknown_086126AC
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0x9
b _081A8D12
.pool
_081A8CE8:
ldr r3, =gUnknown_086126AE
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0x7
b _081A8D12
.pool
_081A8D00:
ldr r3, =gUnknown_086126A8
ldr r0, [r5]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
movs r1, 0xA
_081A8D12:
strb r1, [r0, 0x9]
mov r2, r8
ldr r0, [r2]
adds r0, r4
ldrb r1, [r0, 0x1]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r0, r7
ldrb r0, [r0]
ldr r1, =gSaveBlock1Ptr
ldr r2, [r1]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
bl ScriptMovement_StartObjectMovementScript
_081A8D32:
mov r0, r9
adds r0, 0x1
lsls r0, 24
lsrs r0, 24
mov r9, r0
mov r3, r8
ldr r0, [r3]
adds r0, 0x40
ldrb r0, [r0]
cmp r9, r0
bcs _081A8D4A
b _081A8B3E
_081A8D4A:
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81A8AF8
thumb_func_start sub_81A8D60
sub_81A8D60: @ 81A8D60
push {r4,lr}
ldr r4, =gUnknown_0203CE50
ldr r3, [r4]
adds r2, r3, 0
adds r2, 0x40
ldrb r2, [r2]
lsls r2, 2
adds r3, r2
strb r0, [r3, 0x1]
ldr r2, [r4]
adds r0, r2, 0
adds r0, 0x40
ldrb r0, [r0]
lsls r0, 2
adds r2, r0
strb r1, [r2]
ldr r1, [r4]
adds r1, 0x40
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81A8D60
thumb_func_start sub_81A8D94
sub_81A8D94: @ 81A8D94
push {r4-r6,lr}
lsls r0, 24
lsrs r4, r0, 24
lsls r1, 24
lsrs r6, r1, 24
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0xC7
lsls r1, 4
adds r5, r0, r1
lsls r1, r4, 1
adds r1, r4
lsls r1, 3
adds r1, r5
ldrh r0, [r1, 0x4]
adds r0, 0x7
ldrh r1, [r1, 0x6]
adds r1, 0x7
lsls r0, 16
asrs r0, 16
lsls r1, 16
asrs r1, 16
bl MapGridGetMetatileIdAt
lsls r0, 16
lsrs r2, r0, 16
ldr r0, =gUnknown_0203CE50
ldr r0, [r0]
adds r0, 0x41
ldrb r0, [r0]
movs r1, 0xA6
lsls r1, 2
cmp r0, 0
bne _081A8DDA
subs r1, 0x48
_081A8DDA:
subs r1, r2, r1
adds r0, r1, 0
cmp r1, 0
bge _081A8DE4
adds r0, r1, 0x7
_081A8DE4:
asrs r0, 3
lsls r0, 3
subs r0, r1, r0
lsls r0, 24
lsrs r0, 24
subs r0, r6
lsls r0, 24
asrs r1, r0, 24
cmp r1, 0
blt _081A8DFC
cmp r1, 0x3
bne _081A8E08
_081A8DFC:
movs r2, 0
b _081A8E1A
.pool
_081A8E08:
cmp r1, 0
bgt _081A8E14
movs r0, 0x3
negs r0, r0
cmp r1, r0
bne _081A8E18
_081A8E14:
movs r2, 0x1
b _081A8E1A
_081A8E18:
movs r2, 0x2
_081A8E1A:
lsls r0, r4, 1
adds r0, r4
lsls r0, 3
adds r1, r0, r5
ldrb r0, [r1, 0x9]
adds r3, r0, 0
cmp r2, 0
bne _081A8E4C
cmp r0, 0x8
beq _081A8E72
cmp r0, 0x8
bgt _081A8E38
cmp r0, 0x7
beq _081A8E48
b _081A8E76
_081A8E38:
cmp r0, 0x9
beq _081A8E44
cmp r0, 0xA
bne _081A8E76
movs r0, 0x7
b _081A8E74
_081A8E44:
movs r0, 0x8
b _081A8E74
_081A8E48:
movs r0, 0x9
b _081A8E74
_081A8E4C:
cmp r2, 0x1
bne _081A8E76
cmp r0, 0x8
beq _081A8E6A
cmp r0, 0x8
bgt _081A8E5E
cmp r0, 0x7
beq _081A8E72
b _081A8E76
_081A8E5E:
cmp r3, 0x9
beq _081A8E6E
cmp r3, 0xA
bne _081A8E76
movs r0, 0x8
b _081A8E74
_081A8E6A:
movs r0, 0x9
b _081A8E74
_081A8E6E:
movs r0, 0x7
b _081A8E74
_081A8E72:
movs r0, 0xA
_081A8E74:
strb r0, [r1, 0x9]
_081A8E76:
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_81A8D94
.align 2, 0 @ Don't pad with nop.

View File

@ -72,7 +72,7 @@ gUnknown_08613794:: @ 8613794
.byte 0x00, 0x04, 0x09, 0x0e, 0x13, 0x18, 0x1d, 0x00
.align 1
gUnknown_0861379C:: @ 861379C
sPickupItemsLvl50:: @ 861379C
.2byte 0x0015, 0x0051, 0x0085, 0x0022, 0x008d, 0x0018, 0x00b3, 0x00db, 0x0019, 0x002d, 0x0015, 0x004a, 0x0087, 0x0022, 0x008a, 0x0018
.2byte 0x00c8, 0x00ba, 0x0013, 0x0025, 0x0015, 0x004b, 0x0088, 0x0022, 0x008d, 0x0018, 0x00c6, 0x00c4, 0x0019, 0x002d, 0x0015, 0x004c
.2byte 0x008d, 0x0022, 0x008a, 0x0018, 0x00b7, 0x00bb, 0x0013, 0x0025, 0x0015, 0x004d, 0x0086, 0x0022, 0x008d, 0x0018, 0x00b3, 0x00db
@ -88,7 +88,7 @@ gUnknown_0861379C:: @ 861379C
.2byte 0x008d, 0x0022, 0x008a, 0x0018, 0x00b7, 0x00bb, 0x0013, 0x0025
.align 1
gUnknown_0861392C:: @ 861392C
sPickupItemsLvlOpen:: @ 861392C
.2byte 0x0015, 0x0051, 0x0085, 0x0022, 0x008d, 0x0018, 0x00b3, 0x00db, 0x0019, 0x002d, 0x0015, 0x004a, 0x0087, 0x0022, 0x008a, 0x0018
.2byte 0x00c8, 0x00ba, 0x0013, 0x0025, 0x0015, 0x004b, 0x0088, 0x0022, 0x008d, 0x0018, 0x00c6, 0x00c4, 0x0019, 0x002d, 0x0015, 0x004c
.2byte 0x008d, 0x0022, 0x008a, 0x0018, 0x00b7, 0x00bb, 0x0013, 0x0025, 0x0015, 0x004d, 0x0086, 0x0022, 0x008d, 0x0018, 0x00b3, 0x00db
@ -506,42 +506,3 @@ gUnknown_08613EC0:: @ 8613EC0
.4byte gUnknown_08613E9C
.4byte gUnknown_08613EA8
.4byte gUnknown_08613EB4
gUnknown_08613ED8:: @ 8613ED8
.byte 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x03, 0x04
.align 2
gUnknown_08613EE0:: @ 8613EE0
.4byte sub_81A8E9C
.4byte sub_81A8F38
.4byte sub_81A9048
.4byte sub_81A9134
.4byte sub_81A917C
.4byte sub_81A91FC
.4byte sub_81A9254
.4byte CalculateBattlePyramidItemBallItemId
.4byte sub_81A93C8
.4byte sub_81A9414
.4byte sub_81A9424
.4byte sub_81A9618
.4byte sub_81A966C
.4byte sub_81A9684
.4byte sub_81A975C
.4byte sub_81A97C8
.4byte sub_81A9828
.4byte sub_81A9834
.align 1
gUnknown_08613F28:: @ 8613F28
.2byte 0x003f, 0x0040, 0x0041, 0x0043, 0x0042, 0x0046
.align 2
gUnknown_08613F34:: @ 8613F34
.2byte 0x00b3, 0x00b4, 0x00b7, 0x00c8, 0x00b9, 0x00bb, 0x00c4, 0x00c6, 0x00ba
gUnknown_08613F46:: @ 8613F46
.byte 0x01, 0x04, 0xff, 0xff, 0x00, 0x02, 0x05, 0xff, 0x01, 0x03, 0x06, 0xff, 0x02, 0x07, 0xff, 0xff, 0x00, 0x05, 0x08, 0xff, 0x01, 0x04, 0x06, 0x09, 0x02, 0x05, 0x07, 0x0a, 0x03, 0x06, 0x0b, 0xff
.byte 0x04, 0x09, 0x0c, 0xff, 0x05, 0x08, 0x0a, 0x0d, 0x06, 0x09, 0x0b, 0x0e, 0x07, 0x0a, 0x0f, 0xff, 0x08, 0x0d, 0xff, 0xff, 0x09, 0x0c, 0x0e, 0xff, 0x0a, 0x0d, 0x0f, 0xff, 0x0b, 0x0e, 0xff, 0xff
gUnknown_08613F86:: @ 8613F86
.byte 0x1e, 0x28, 0x32, 0x3c, 0x46, 0x50, 0x55, 0x5a, 0x5f, 0x64

View File

@ -1662,7 +1662,7 @@ EventScript_271C3A:: @ 8271C3A
waitmessage
bufferitemnameplural 1, VAR_0x8004, 32773
setvar VAR_0x8004, 12
special sub_81A8E7C
special CallBattlePyramidFunction
compare VAR_RESULT, 1
goto_eq EventScript_271C86
msgbox gUnknown_08272A9A, 4
@ -3361,7 +3361,7 @@ EventScript_2736F8:: @ 82736F8
compare VAR_RESULT, 1
goto_eq BattleFrontier_BattlePikeThreePathRoom_EventScript_2C4222
setvar VAR_0x8004, 12
special sub_81A8E7C
special CallBattlePyramidFunction
compare VAR_RESULT, 1
goto_eq BattleFrontier_BattlePyramidTop_EventScript_252B42
compare VAR_RESULT, 2

View File

@ -19,7 +19,7 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252A5D:: @ 8252A5D
setvar VAR_RESULT, 0
BattleFrontier_BattlePyramidEmptySquare_EventScript_252A77:: @ 8252A77
special sub_81A8E7C
special CallBattlePyramidFunction
delay 2
compare VAR_RESULT, 2
goto_if 5, BattleFrontier_BattlePyramidEmptySquare_EventScript_252A77
@ -39,7 +39,7 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252A98:: @ 8252A98
BattleFrontier_BattlePyramidEmptySquare_MapScript1_252AA2: @ 8252AA2
setvar VAR_0x8004, 15
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 0
special CallFrontierUtilFunc
switch VAR_TEMP_0
@ -68,7 +68,7 @@ BattleFrontier_BattlePyramidEmptySquare_MapScript1_252AA2: @ 8252AA2
BattleFrontier_BattlePyramidEmptySquare_EventScript_252B39:: @ 8252B39
setvar VAR_0x8004, 17
special sub_81A8E7C
special CallBattlePyramidFunction
end
BattleFrontier_BattlePyramidEmptySquare_EventScript_252B42:: @ 8252B42
@ -80,16 +80,16 @@ BattleFrontier_BattlePyramidTop_EventScript_252B42:: @ 8252B42
setvar VAR_0x8004, 2
setvar VAR_0x8005, 7
setvar VAR_0x8006, 255
special sub_81A8E7C
special CallBattlePyramidFunction
BattleFrontier_BattlePyramidEmptySquare_EventScript_252B66:: @ 8252B66
BattleFrontier_BattlePyramidTop_EventScript_252B66:: @ 8252B66
setvar VAR_0x8004, 13
setvar VAR_0x8005, 0
setvar VAR_0x8006, 0
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 14
special sub_81A8E7C
special CallBattlePyramidFunction
special HealPlayerParty
warpsilent MAP_BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY, 255, 7, 13
waitstate
@ -98,14 +98,14 @@ BattleFrontier_BattlePyramidTop_EventScript_252B66:: @ 8252B66
BattleFrontier_BattlePyramidEmptySquare_EventScript_252B8D:: @ 8252B8D
setvar VAR_0x8004, 3
setvar VAR_0x8005, 1
special sub_81A8E7C
special CallBattlePyramidFunction
special SavePlayerParty
setvar VAR_0x8004, 2
setvar VAR_0x8005, 0
setvar VAR_0x8006, 0
special CallFrontierUtilFunc
setvar VAR_0x8004, 9
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 3
setvar VAR_0x8005, 3
special CallFrontierUtilFunc
@ -121,7 +121,7 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252BD5:: @ 8252BD5
setvar VAR_0x8004, 13
setvar VAR_0x8005, 32
setvar VAR_0x8006, 0
special sub_81A8E7C
special CallBattlePyramidFunction
return
BattleFrontier_BattlePyramidEmptySquare_EventScript_252BE8:: @ 8252BE8
@ -137,7 +137,7 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252BE8:: @ 8252BE8
compare VAR_RESULT, 7
goto_eq BattleFrontier_BattlePyramidEmptySquare_EventScript_252C45
setvar VAR_0x8004, 6
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 0
setvar VAR_0x8006, 0
@ -155,7 +155,7 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252C45:: @ 8252C45
BattleFrontier_BattlePyramidEmptySquare_EventScript_252C4F:: @ 8252C4F
trainerbattle 9, TRAINER_PHILLIP, 0, BattleFrontier_BattlePyramidEmptySquare_Text_252C8D, BattleFrontier_BattlePyramidEmptySquare_Text_252C8D
setvar VAR_0x8004, 10
special sub_81A8E7C
special CallBattlePyramidFunction
waitmessage
waitbuttonpress
closemessage
@ -164,12 +164,12 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252C4F:: @ 8252C4F
BattleFrontier_BattlePyramidEmptySquare_EventScript_252C6A:: @ 8252C6A
setvar VAR_0x8004, 7
special sub_81A8E7C
special CallBattlePyramidFunction
callstd 1
compare VAR_0x8007, 0
goto_eq BattleFrontier_BattlePyramidEmptySquare_EventScript_252C87
setvar VAR_0x8004, 8
special sub_81A8E7C
special CallBattlePyramidFunction
BattleFrontier_BattlePyramidEmptySquare_EventScript_252C87:: @ 8252C87
end

View File

@ -35,11 +35,11 @@ BattleFrontier_BattlePyramidLobby_EventScript_250768:: @ 8250768
setvar VAR_0x8004, 2
setvar VAR_0x8005, 1
setvar VAR_0x8006, 0
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 2
setvar VAR_0x8006, 0
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 0
setvar VAR_0x8006, 0
@ -69,7 +69,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_2507DA:: @ 82507DA
special CallFrontierUtilFunc
special LoadPlayerParty
setvar VAR_0x8004, 14
special sub_81A8E7C
special CallBattlePyramidFunction
special HealPlayerParty
message BattleFrontier_BattlePyramidLobby_Text_2519F8
waitmessage
@ -82,10 +82,10 @@ BattleFrontier_BattlePyramidLobby_EventScript_2507DA:: @ 82507DA
message BattleFrontier_BattlePyramidLobby_Text_251A77
waitmessage
setvar VAR_0x8004, 4
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 3
setvar VAR_0x8005, 0
special sub_81A8E7C
special CallBattlePyramidFunction
playse SE_SAVE
waitse
msgbox BattleFrontier_BattlePyramidLobby_Text_251BB6, 4
@ -99,7 +99,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_250852:: @ 8250852
special CallFrontierUtilFunc
special LoadPlayerParty
setvar VAR_0x8004, 14
special sub_81A8E7C
special CallBattlePyramidFunction
special HealPlayerParty
lockall
message BattleFrontier_BattlePyramidLobby_Text_251B5A
@ -111,10 +111,10 @@ BattleFrontier_BattlePyramidLobby_EventScript_250852:: @ 8250852
setvar VAR_0x8004, 2
setvar VAR_0x8005, 2
setvar VAR_0x8006, 0
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 3
setvar VAR_0x8005, 0
special sub_81A8E7C
special CallBattlePyramidFunction
playse SE_SAVE
waitse
msgbox BattleFrontier_BattlePyramidLobby_Text_251BB6, 4
@ -180,11 +180,11 @@ BattleFrontier_BattlePyramidLobby_EventScript_2509A5:: @ 82509A5
setvar VAR_0x8005, 4
special CallFrontierUtilFunc
setvar VAR_0x8004, 0
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 2
setvar VAR_0x8006, 1
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 2
setvar VAR_0x8005, 0
setvar VAR_0x8006, 1
@ -194,9 +194,9 @@ BattleFrontier_BattlePyramidLobby_EventScript_2509A5:: @ 82509A5
setvar VAR_0x8006, 0
special CallFrontierUtilFunc
setvar VAR_0x8004, 6
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 9
special sub_81A8E7C
special CallBattlePyramidFunction
special LoadPlayerParty
closemessage
delay 2
@ -284,7 +284,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_250B28:: @ 8250B28
msgbox BattleFrontier_BattlePyramidLobby_Text_251C8A, 4
setvar VAR_0x8004, 1
setvar VAR_0x8005, 5
special sub_81A8E7C
special CallBattlePyramidFunction
compare VAR_RESULT, 0
goto_if 5, BattleFrontier_BattlePyramidLobby_EventScript_250B53
setvar VAR_RESULT, 0
@ -294,7 +294,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_250B28:: @ 8250B28
BattleFrontier_BattlePyramidLobby_EventScript_250B53:: @ 8250B53
setvar VAR_0x8004, 1
setvar VAR_0x8005, 3
special sub_81A8E7C
special CallBattlePyramidFunction
goto BattleFrontier_BattlePyramidLobby_EventScript_250BA4
return
@ -302,7 +302,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_250B66:: @ 8250B66
msgbox BattleFrontier_BattlePyramidLobby_Text_251C8A, 4
setvar VAR_0x8004, 1
setvar VAR_0x8005, 6
special sub_81A8E7C
special CallBattlePyramidFunction
compare VAR_RESULT, 0
goto_if 5, BattleFrontier_BattlePyramidLobby_EventScript_250B91
setvar VAR_RESULT, 0
@ -312,7 +312,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_250B66:: @ 8250B66
BattleFrontier_BattlePyramidLobby_EventScript_250B91:: @ 8250B91
setvar VAR_0x8004, 1
setvar VAR_0x8005, 4
special sub_81A8E7C
special CallBattlePyramidFunction
goto BattleFrontier_BattlePyramidLobby_EventScript_250BA4
return
@ -439,7 +439,7 @@ BattleFrontier_BattlePyramidLobby_EventScript_250D56:: @ 8250D56
msgbox BattleFrontier_BattlePyramidLobby_Text_251569, 4
setvar VAR_0x8004, 1
setvar VAR_0x8005, 1
special sub_81A8E7C
special CallBattlePyramidFunction
compare VAR_RESULT, 0
goto_eq BattleFrontier_BattlePyramidLobby_EventScript_250D94
msgbox BattleFrontier_BattlePyramidLobby_Text_2515AD, 4

View File

@ -9,7 +9,7 @@ BattleFrontier_BattlePyramidTop_MapScript1_2550B6: @ 82550B6
setvar VAR_0x8004, 13
setvar VAR_0x8005, 200
setvar VAR_0x8006, 0
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_TEMP_F, 1
end
@ -71,14 +71,14 @@ BattleFrontier_BattlePyramidTop_EventScript_25518A:: @ 825518A
BattleFrontier_BattlePyramidTop_EventScript_255193:: @ 8255193
setvar VAR_0x8004, 3
setvar VAR_0x8005, 1
special sub_81A8E7C
special CallBattlePyramidFunction
special SavePlayerParty
setvar VAR_0x8004, 2
setvar VAR_0x8005, 0
setvar VAR_0x8006, 0
special CallFrontierUtilFunc
setvar VAR_0x8004, 9
special sub_81A8E7C
special CallBattlePyramidFunction
setvar VAR_0x8004, 3
setvar VAR_0x8005, 3
special CallFrontierUtilFunc

View File

@ -7,7 +7,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_MapScripts:: @ 8243D92
BattleFrontier_BattleTowerMultiBattleRoom_MapScript1_243DA7: @ 8243DA7
setvar VAR_0x8004, 17
special sub_81A8E7C
special CallBattlePyramidFunction
end
BattleFrontier_BattleTowerMultiBattleRoom_MapScript1_243DB0: @ 8243DB0

View File

@ -251,7 +251,7 @@ gSpecials:: @ 81DBA64
def_special CallBattleArenaFunction
def_special CallBattleFactoryFunction
def_special CallBattlePikeFunction
def_special sub_81A8E7C
def_special CallBattlePyramidFunction
def_special StopMapMusic
def_special sub_81B99B4
def_special sub_81B9B80

24
include/battle_pyramid.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef GUARD_BATTLE_PYRAMID_H
#define GUARD_BATTLE_PYRAMID_H
void CallBattlePyramidFunction(void);
u16 LocalIdToPyramidTrainerId(u8 localId);
bool8 GetBattlePyramidTrainerFlag(u8 eventId);
void sub_81A9B04(void);
void GenerateBattlePyramidWildMon(void);
u8 GetPyramidRunMultiplier(void);
u8 InBattlePyramid(void);
bool8 InBattlePyramid_(void);
void sub_81A9E90(void);
void sub_81A9EC8(void);
void CopyPyramidTrainerSpeechBefore(u16 trainerId);
void CopyPyramidTrainerWinSpeech(u16 trainerId);
void CopyPyramidTrainerLoseSpeech(u16 trainerId);
u8 GetTrainerEncounterMusicIdInBattlePyramind(u16 trainerId);
void sub_81AA078(u16 *mapArg, u8 arg1);
void sub_81AA1D8(void);
void sub_81AA2F8(void);
u8 sub_81AAA40(void);
u16 GetBattlePyramidPickupItemId(void);
#endif // GUARD_BATTLE_PYRAMID_H

View File

@ -34,6 +34,7 @@ struct PyramidBagCursorData
extern struct PyramidBagResources *gPyramidBagResources;
extern struct PyramidBagCursorData gPyramidBagCursorData;
void sub_81C4EEC(void);
void CB2_PyramidBagMenuFromStartMenu(void);
void sub_81C4F84(void);
void sub_81C5924(void);

View File

@ -1,12 +1,15 @@
#ifndef GUARD_DECORATION_INVENTORY_H
#define GUARD_DECORATION_INVENTORY_H
struct DecorationInventory {
struct DecorationInventory
{
u8 *items;
u8 size;
};
extern struct DecorationInventory gDecorationInventories[];
void SetDecorationInventoriesPointers(void);
void ClearDecorationInventories(void);
s8 GetFirstEmptyDecorSlot(u8 idx);
u8 CheckHasDecoration(u8);

View File

@ -135,6 +135,7 @@ enum LanguageId
#define BAG_POKEBALLS_COUNT 16
#define BAG_TMHM_COUNT 64
#define BAG_BERRIES_COUNT 46
#define EVENT_OBJECT_TEMPLATES_COUNT 64
#define PYRAMID_BAG_ITEMS_COUNT 10
#define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode.
@ -442,12 +443,14 @@ struct BattleFrontier
/*0xE10*/ u8 field_E10_1:3;
/*0xE10*/ u8 field_E10_2:4;
/*0xE10*/ u8 field_E10_3:1;
/*0xE12*/ u16 field_E12[4];
/*0xE12*/ u16 field_E12[3];
/*0xE18*/ u16 field_E18;
/*0xE1A*/ u16 pyramidWinStreaks[2];
/*0xE1E*/ u16 pyramidRecordStreaks[2];
/*0xE1E*/ u16 field_E1F[5];
/*0xE22*/ u16 field_E22[4];
/*0xE2A*/ u8 field_E2A;
/*0xE2C*/ struct PyramidBag pyramidBag;
/*0xE58*/ u16 field_E58;
/*0xE68*/ u8 field_E68;
/*0xE6A*/ u16 field_E6A;
/*0xE6C*/ u16 field_E6C;
/*0xE6E*/ u16 field_E6E;
@ -905,7 +908,7 @@ struct SaveBlock1
/*0x9C8*/ u16 trainerRematchStepCounter;
/*0x9CA*/ u8 trainerRematches[100];
/*0xA30*/ struct EventObject eventObjects[EVENT_OBJECTS_COUNT];
/*0xC70*/ struct EventObjectTemplate eventObjectTemplates[64];
/*0xC70*/ struct EventObjectTemplate eventObjectTemplates[EVENT_OBJECT_TEMPLATES_COUNT];
/*0x1270*/ u8 flags[FLAGS_COUNT];
/*0x139C*/ u16 vars[VARS_COUNT];
/*0x159C*/ u32 gameStats[NUM_GAME_STATS];

View File

@ -30,6 +30,5 @@ void LoadPlayerBag(void);
void SavePlayerBag(void);
void ApplyNewEncryptionKeyToHword(u16 *hWord, u32 newKey);
void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey);
void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey);
#endif // GUARD_LOAD_SAVE_H

View File

@ -73,7 +73,7 @@ void SetFixedHoleWarpAsDestination(s16 x, s16 y);
void warp1_set_to_sav1w(void);
void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void sub_8084F6C(u8 a1);
void sub_8084FAC(void);
void sub_8084FAC(int unused);
const struct MapConnection *GetMapConnection(u8 dir);
static bool8 SetDiveWarp(u8 dir, u16 x, u16 y);
bool8 SetDiveWarpEmerge(u16 x, u16 y);

View File

@ -54,7 +54,12 @@ enum
SAVE_HALL_OF_FAME_ERASE_BEFORE // unused
};
#define SECTION_ID_RECORDED_BATTLE 31
#define SECTOR_SAVE_SLOT_LENGTH 14
#define SECTOR_ID_HOF_1 28
#define SECTOR_ID_HOF_2 29
#define SECTOR_ID_TRAINER_HILL 30
#define SECTOR_ID_RECORDED_BATTLE 31
#define SECTORS_COUNT 32
extern u16 gLastWrittenSector;
extern u32 gLastSaveCounter;
@ -72,26 +77,6 @@ extern struct SaveSection gSaveDataBuffer;
void ClearSaveData(void);
void Save_ResetSaveCounters(void);
bool32 SetDamagedSectorBits(u8 op, u8 bit);
u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location);
u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location);
u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size);
u8 TryWriteSector(u8 sector, u8 *data);
u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location);
u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location);
u8 sub_81529D4(u16 a1, const struct SaveSectionLocation *location);
u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location);
u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location);
u8 sav12_xor_get(u16 a1, const struct SaveSectionLocation *location);
u8 sub_8152CAC(u16 a1, const struct SaveSectionLocation *location);
u8 sub_8152D44(u16 a1, const struct SaveSectionLocation *location);
u8 sub_8152DD0(u16 a1, const struct SaveSectionLocation *location);
u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location);
u8 GetSaveValidStatus(const struct SaveSectionLocation *location);
u8 sub_81530DC(u8 a1, u8 *data, u16 size);
u8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section);
u16 CalculateChecksum(void *data, u16 size);
void UpdateSaveAddresses(void);
u8 HandleSavingData(u8 saveType);
u8 TrySavingData(u8 saveType);
bool8 sub_8153380(void);

View File

@ -1,7 +1,6 @@
#ifndef GUARD_SAVE_LOCATION_H
#define GUARD_SAVE_LOCATION_H
bool32 sub_81AFCEC(void);
void TrySetMapSaveWarpStatus(void);
void sub_81AFDA0(void);
void sub_81AFDD0(void);

View File

@ -268,7 +268,8 @@ SECTIONS {
src/battle_arena.o(.text);
src/battle_factory.o(.text);
src/battle_pike.o(.text);
asm/battle_frontier_2.o(.text);
asm/mossdeep_gym.o(.text);
src/battle_pyramid.o(.text);
src/item_menu.o(.text);
src/list_menu.o(.text);
src/dynamic_placeholder_text_util.o(.text);
@ -579,6 +580,7 @@ SECTIONS {
data/battle_pike.o(.rodata);
src/battle_pike.o(.rodata);
data/battle_frontier_3.o(.rodata);
src/battle_pyramid.o(.rodata);
src/item_menu.o(.rodata);
src/list_menu.o(.rodata);
src/save_location.o(.rodata);

View File

@ -5,6 +5,7 @@
#include "battle_controllers.h"
#include "battle_interface.h"
#include "battle_message.h"
#include "battle_pyramid.h"
#include "battle_scripts.h"
#include "battle_setup.h"
#include "battle_tower.h"
@ -109,10 +110,8 @@ extern const u8 gText_Love[];
// functions
extern void sub_81B9150(void);
extern void sub_80B3AF8(u8 taskId); // cable club
extern u8 sub_81A9E28(void); // battle frontier 2
extern void sub_81B8FB0(u8, u8); // party menu
extern u8 pokemon_order_func(u8); // party menu
extern bool8 InBattlePyramid(void);
// this file's functions
static void CB2_InitBattleInternal(void);
@ -5604,7 +5603,7 @@ bool8 TryRunFromBattle(u8 battler)
if (InBattlePyramid())
{
gBattleStruct->runTries++;
pyramidMultiplier = sub_81A9E28();
pyramidMultiplier = GetPyramidRunMultiplier();
speedVar = (gBattleMons[battler].speed * pyramidMultiplier) / (gBattleMons[BATTLE_OPPOSITE(battler)].speed) + (gBattleStruct->runTries * 30);
if (speedVar > (Random() & 0xFF))
{
@ -5630,7 +5629,7 @@ bool8 TryRunFromBattle(u8 battler)
{
if (InBattlePyramid())
{
pyramidMultiplier = sub_81A9E28();
pyramidMultiplier = GetPyramidRunMultiplier();
speedVar = (gBattleMons[battler].speed * pyramidMultiplier) / (gBattleMons[BATTLE_OPPOSITE(battler)].speed) + (gBattleStruct->runTries * 30);
if (speedVar > (Random() & 0xFF))
effect++;

1297
src/battle_pyramid.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,7 @@
#include "party_menu.h"
#include "battle_arena.h"
#include "battle_pike.h"
#include "battle_pyramid.h"
extern u16 gBattle_BG1_X;
extern u16 gBattle_BG1_Y;
@ -62,11 +63,8 @@ extern void sub_81D388C(struct Pokemon* mon, void* statStoreLocation); // pokena
extern void sub_81D3640(u8 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); // pokenav.s
extern void sub_81D3784(u8 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); // pokenav.s
extern u8* GetMonNickname(struct Pokemon* mon, u8* dst); // party_menu
extern u8 BattleArena_ShowJudgmentWindow(u8* arg0); // battle frontier 2
extern void sub_81B8E80(u8 battlerId, u8, u8); // party menu
extern bool8 sub_81B1250(void); // ?
extern bool8 InBattlePyramid(void);
extern u16 GetBattlePyramidPickupItemId(void);
extern u8 sub_813B21C(void);
extern u16 get_unknown_box_id(void);
@ -9859,14 +9857,16 @@ static void atkE4_getsecretpowereffect(void)
}
static void atkE5_pickup(void)
{
if (!InBattlePike())
{
s32 i;
u16 species, heldItem;
u8 ability;
if (InBattlePyramid())
if (InBattlePike())
{
}
else if (InBattlePyramid())
{
for (i = 0; i < PARTY_SIZE; i++)
{
@ -9929,7 +9929,6 @@ static void atkE5_pickup(void)
}
}
}
}
gBattlescriptCurrInstr++;
}

View File

@ -34,6 +34,7 @@
#include "battle_tower.h"
#include "gym_leader_rematch.h"
#include "battle_pike.h"
#include "battle_pyramid.h"
#include "constants/map_types.h"
#include "constants/battle_frontier.h"
@ -54,7 +55,6 @@ struct TrainerBattleParameter
u8 ptrType;
};
extern bool8 InBattlePyramid(void);
extern bool32 InTrainerHill(void);
extern bool32 FieldPoisonEffectIsRunning(void);
extern void RestartWildEncounterImmunitySteps(void);
@ -63,17 +63,13 @@ extern void sub_81BE72C(void);
extern void sub_808BCF4(void);
extern void sub_80EECC8(void);
extern void sub_80AF6F0(void);
extern u16 sub_81A9AA8(u8 localId);
extern u16 sub_81D6180(u8 localId);
extern bool8 GetBattlePyramidTrainerFlag(u8 eventObjId);
extern bool8 GetTrainerHillTrainerFlag(u8 eventObjId);
extern bool8 sub_81D5C18(void);
extern void sub_81A9B04(void);
extern void sub_81D639C(void);
extern void sub_81D6384(void);
extern void sub_81D61E8(void);
extern void sub_80982B8(void);
extern void sub_81A9EDC(u16 a0);
extern void CopyTrainerHillTrainerText(u8 a0, u16 arg1);
// this file's functions
@ -1131,12 +1127,12 @@ const u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data)
{
TrainerBattleLoadArgs(sOrdinaryBattleParams, data);
SetMapVarsToTrainer();
gTrainerBattleOpponent_A = sub_81A9AA8(gSpecialVar_LastTalked);
gTrainerBattleOpponent_A = LocalIdToPyramidTrainerId(gSpecialVar_LastTalked);
}
else
{
TrainerBattleLoadArgs(sTrainerBOrdinaryBattleParams, data);
gTrainerBattleOpponent_B = sub_81A9AA8(gSpecialVar_LastTalked);
gTrainerBattleOpponent_B = LocalIdToPyramidTrainerId(gSpecialVar_LastTalked);
}
return EventScript_271362;
case TRAINER_BATTLE_SET_TRAINER_A:
@ -1360,9 +1356,9 @@ void ShowTrainerIntroSpeech(void)
if (InBattlePyramid())
{
if (gNoOfApproachingTrainers == 0 || gNoOfApproachingTrainers == 1)
sub_81A9EDC(sub_81A9AA8(gSpecialVar_LastTalked));
CopyPyramidTrainerSpeechBefore(LocalIdToPyramidTrainerId(gSpecialVar_LastTalked));
else
sub_81A9EDC(sub_81A9AA8(gEventObjects[gApproachingTrainers[gApproachingTrainerId].eventObjectId].localId));
CopyPyramidTrainerSpeechBefore(LocalIdToPyramidTrainerId(gEventObjects[gApproachingTrainers[gApproachingTrainerId].eventObjectId].localId));
sub_80982B8();
}

View File

@ -10,6 +10,7 @@
#include "bg.h"
#include "text_window.h"
#include "constants/songs.h"
#include "constants/rgb.h"
extern const u8 gText_ClearAllSaveData[];
extern const u8 gText_ClearingData[];
@ -144,10 +145,10 @@ static bool8 SetupClearSaveDataScreen(void)
DmaFill32(3, 0, (void *)OAM, OAM_SIZE);
DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2);
ResetPaletteFade();
gPlttBufferUnfaded[0] = 0x7fff;
gPlttBufferFaded[0] = 0x7fff;
gPlttBufferUnfaded[1] = 0x3945;
gPlttBufferFaded[1] = 0x3945;
gPlttBufferUnfaded[0] = RGB_WHITE;
gPlttBufferFaded[0] = RGB_WHITE;
gPlttBufferUnfaded[1] = RGB(5, 10, 14);
gPlttBufferFaded[1] = RGB(5, 10, 14);
for (i = 0; i < 0x10; i++)
((u16 *)(VRAM + 0x20))[i] = 0x1111;
@ -163,7 +164,7 @@ static bool8 SetupClearSaveDataScreen(void)
SetGpuReg(REG_OFFSET_BLDCNT, 0);
InitClearSaveDataScreenWindows();
BeginNormalPaletteFade(0x0000FFFF, 0, 0x10, 0, 0xFFFF);
EnableInterrupts(1);
EnableInterrupts(INTR_FLAG_VBLANK);
SetVBlankCallback(VBlankCB);
gMain.state = 1;
break;
@ -184,7 +185,7 @@ static void CB2_FadeAndDoReset(void)
{
case 0:
default:
BeginNormalPaletteFade(0x0000FFFF, 0, 0, 0x10, 0xFFFF);
BeginNormalPaletteFade(0x0000FFFF, 0, 0, 0x10, RGB_WHITEALPHA);
gMain.state = 1;
break;
case 1:
@ -194,6 +195,7 @@ static void CB2_FadeAndDoReset(void)
FreeAllWindowBuffers();
DoSoftReset();
}
break;
}
}

View File

@ -2559,7 +2559,7 @@ struct EventObjectTemplate *GetBaseTemplateForEventObject(const struct EventObje
{
return NULL;
}
for (i = 0; i < 64; i++) // Using ARRAY_COUNT here results in the wrong conditional branch instruction (bls instead of ble)
for (i = 0; i < EVENT_OBJECT_TEMPLATES_COUNT; i++)
{
if (eventObject->localId == gSaveBlock1Ptr->eventObjectTemplates[i].localId)
{

View File

@ -521,7 +521,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId)
static void Task_Hof_TrySaveData(u8 taskId)
{
gGameContinueCallback = CB2_DoHallOfFameScreenDontSaveData;
if (TrySavingData(3) == 0xFF && gDamagedSaveSectors != 0)
if (TrySavingData(SAVE_HALL_OF_FAME) == 0xFF && gDamagedSaveSectors != 0)
{
UnsetBgTilemapBuffer(1);
UnsetBgTilemapBuffer(3);

View File

@ -10,9 +10,9 @@
#include "item_menu.h"
#include "strings.h"
#include "load_save.h"
#include "battle_pyramid.h"
#include "battle_pyramid_bag.h"
extern bool8 InBattlePyramid(void);
extern u16 gUnknown_0203CF30[];
extern const struct Item gItems[];

View File

@ -6,14 +6,15 @@
#include "random.h"
#include "malloc.h"
#include "item.h"
#include "overworld.h"
#include "decoration_inventory.h"
static void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey);
extern void* gUnknown_0203CF5C;
extern bool16 IdentifyFlash(void);
extern void SetDecorationInventoriesPointers(void);
extern void ApplyNewEncryptionKeyToGameStats(u32 key);
extern void ApplyNewEncryptionKeyToBerryPowder(u32 key);
extern void sub_8084FAC(int unused);
#define SAVEBLOCK_MOVE_RANGE 128
@ -286,7 +287,7 @@ void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey)
*word ^= newKey;
}
void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey)
static void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey)
{
ApplyNewEncryptionKeyToGameStats(encryptionKey);
ApplyNewEncryptionKeyToBagItems_(encryptionKey);

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "overworld.h"
#include "battle_pyramid.h"
#include "battle_setup.h"
#include "berry.h"
#include "bg.h"
@ -113,7 +114,6 @@ extern void ShowMapNamePopup(void);
extern bool32 InTrainerHill(void);
extern bool32 sub_808651C(void);
extern bool8 sub_80AF6A4(void);
extern bool8 sub_81A9E6C(void);
extern bool8 sub_80E909C(void);
extern void sub_81AA1D8(void);
extern void c2_change_map(void);
@ -517,7 +517,7 @@ void LoadSaveblockEventObjScripts(void)
struct EventObjectTemplate *savObjTemplates = gSaveBlock1Ptr->eventObjectTemplates;
s32 i;
for (i = 0; i < 64; i++)
for (i = 0; i < EVENT_OBJECT_TEMPLATES_COUNT; i++)
savObjTemplates[i].script = mapHeaderObjTemplates[i].script;
}
@ -526,7 +526,7 @@ void Overworld_SetEventObjTemplateCoords(u8 localId, s16 x, s16 y)
s32 i;
struct EventObjectTemplate *savObjTemplates = gSaveBlock1Ptr->eventObjectTemplates;
for (i = 0; i < 64; i++)
for (i = 0; i < EVENT_OBJECT_TEMPLATES_COUNT; i++)
{
struct EventObjectTemplate *eventObjectTemplate = &savObjTemplates[i];
if (eventObjectTemplate->localId == localId)
@ -543,7 +543,7 @@ void Overworld_SetEventObjTemplateMovementType(u8 localId, u8 movementType)
s32 i;
struct EventObjectTemplate *savObjTemplates = gSaveBlock1Ptr->eventObjectTemplates;
for (i = 0; i < 64; i++)
for (i = 0; i < EVENT_OBJECT_TEMPLATES_COUNT; i++)
{
struct EventObjectTemplate *eventObjectTemplate = &savObjTemplates[i];
if (eventObjectTemplate->localId == localId)
@ -764,7 +764,7 @@ void sub_8084F6C(u8 a1)
SetWarpData(&gSaveBlock1Ptr->warp1, warp->group, warp->map, -1, warp->x, warp->y);
}
void sub_8084FAC(void)
void sub_8084FAC(int unused)
{
gSaveBlock1Ptr->warp1 = gSaveBlock1Ptr->warp2;
}
@ -1808,7 +1808,7 @@ static void InitCurrentFlashLevelScanlineEffect(void)
{
u8 flashLevel;
if (sub_81A9E6C())
if (InBattlePyramid_())
{
door_upload_tiles();
ScanlineEffect_SetParams(sFlashEffectParams);

View File

@ -4,6 +4,7 @@
#include "battle_controllers.h"
#include "battle_message.h"
#include "battle_pike.h"
#include "battle_pyramid.h"
#include "battle_setup.h"
#include "battle_tower.h"
#include "event_data.h"
@ -81,9 +82,7 @@ extern u8 StorageGetCurrentBox(void);
extern void set_unknown_box_id(u8);
extern void sub_803FA70(u8 battlerId);
extern u8 sav1_map_get_name(void);
extern bool8 InBattlePyramid(void);
extern bool8 sub_806F104(void);
extern u8 GetTrainerEncounterMusicIdInBattlePyramind(u16 trainerOpponentId);
extern u8 sub_81D63C8(u16 trainerOpponentId);
extern void SummaryScreen_SetUnknownTaskId(u8);

View File

@ -490,7 +490,7 @@ bool32 MoveRecordedBattleToSaveData(void)
static bool32 TryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst, struct SaveSection *saveBuffer)
{
if (TryCopySpecialSaveSection(SECTION_ID_RECORDED_BATTLE, (void*)(saveBuffer)) != 1)
if (TryCopySpecialSaveSection(SECTOR_ID_RECORDED_BATTLE, (void*)(saveBuffer)) != 1)
return FALSE;
memcpy(dst, saveBuffer, sizeof(struct RecordedBattleSave));

View File

@ -1,15 +1,23 @@
#include "global.h"
#include "gba/flash_internal.h"
#include "save.h"
#include "constants/game_stat.h"
#include "task.h"
#include "decompress.h"
#include "load_save.h"
#include "overworld.h"
#include "main.h"
#include "constants/game_stat.h"
static u16 CalculateChecksum(void *data, u16 size);
static u8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section);
static u8 GetSaveValidStatus(const struct SaveSectionLocation *location);
static u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location);
static u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location);
static u8 TryWriteSector(u8 sector, u8 *data);
static u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location);
// for the chunk declarations
extern bool8 gSoftResetDisabled;
extern u32 gUnknown_0203CF5C;
// Divide save blocks into individual chunks to be written to flash sectors
@ -24,7 +32,7 @@ extern u32 gUnknown_0203CF5C;
* Sectors 0 - 13: Save Slot 1
* Sectors 14 - 27: Save Slot 2
* Sectors 28 - 29: Hall of Fame
* Sector 30: e-Reader/Mystery Gift Stuff (note: e-Reader is deprecated in Emerald US)
* Sector 30: Trainer Hill
* Sector 31: Recorded Battle
*
* There are two save slots for saving the player's game data. We alternate between
@ -105,7 +113,7 @@ void Save_ResetSaveCounters(void)
gDamagedSaveSectors = 0;
}
bool32 SetDamagedSectorBits(u8 op, u8 bit)
static bool32 SetDamagedSectorBits(u8 op, u8 bit)
{
bool32 retVal = FALSE;
@ -126,7 +134,7 @@ bool32 SetDamagedSectorBits(u8 op, u8 bit)
return retVal;
}
u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location)
static u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location)
{
u32 retVal;
u16 i;
@ -142,11 +150,11 @@ u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location)
gLastKnownGoodSector = gLastWrittenSector; // backup the current written sector before attempting to write.
gLastSaveCounter = gSaveCounter;
gLastWrittenSector++;
gLastWrittenSector = gLastWrittenSector % 0xE; // array count save sector locations
gLastWrittenSector = gLastWrittenSector % SECTOR_SAVE_SLOT_LENGTH; // array count save sector locations
gSaveCounter++;
retVal = 1;
for (i = 0; i < 0xE; i++)
for (i = 0; i < SECTOR_SAVE_SLOT_LENGTH; i++)
HandleWriteSector(i, location);
if (gDamagedSaveSectors != 0) // skip the damaged sector.
@ -160,7 +168,7 @@ u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location)
return retVal;
}
u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location)
static u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location)
{
u16 i;
u16 sector;
@ -168,8 +176,8 @@ u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location)
u16 size;
sector = a1 + gLastWrittenSector;
sector %= 0xE;
sector += 0xE * (gSaveCounter % 2);
sector %= SECTOR_SAVE_SLOT_LENGTH;
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
data = location[a1].data;
size = location[a1].size;
@ -189,7 +197,7 @@ u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location)
return TryWriteSector(sector, gFastSaveSection->data);
}
u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size)
static u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size)
{
u16 i;
struct SaveSection *section = &gSaveDataBuffer;
@ -206,7 +214,7 @@ u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size)
return TryWriteSector(sector, section->data);
}
u8 TryWriteSector(u8 sector, u8 *data)
static u8 TryWriteSector(u8 sector, u8 *data)
{
if (ProgramFlashSectorAndVerify(sector, data) != 0) // is damaged?
{
@ -220,20 +228,20 @@ u8 TryWriteSector(u8 sector, u8 *data)
}
}
u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location) // location is unused
static u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location) // location is unused
{
gFastSaveSection = &gSaveDataBuffer;
gLastKnownGoodSector = gLastWrittenSector;
gLastSaveCounter = gSaveCounter;
gLastWrittenSector++;
gLastWrittenSector = gLastWrittenSector % 0xE;
gLastWrittenSector %= SECTOR_SAVE_SLOT_LENGTH;
gSaveCounter++;
gUnknown_03006208 = 0;
gDamagedSaveSectors = 0;
return 0;
}
u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location) // only ever called once, and gSaveBlock2 is passed to this function. location is unused
static u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location) // only ever called once, and gSaveBlock2 is passed to this function. location is unused
{
gFastSaveSection = &gSaveDataBuffer;
gLastKnownGoodSector = gLastWrittenSector;
@ -243,7 +251,7 @@ u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location) // only ev
return 0;
}
u8 sub_81529D4(u16 a1, const struct SaveSectionLocation *location)
static u8 sub_81529D4(u16 a1, const struct SaveSectionLocation *location)
{
u8 retVal;
@ -267,7 +275,7 @@ u8 sub_81529D4(u16 a1, const struct SaveSectionLocation *location)
return retVal;
}
u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location)
static u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location)
{
u8 retVal = 1;
@ -282,7 +290,7 @@ u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location)
return retVal;
}
u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location)
static u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location)
{
u16 i;
u16 sector;
@ -291,8 +299,8 @@ u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location)
u8 status;
sector = a1 + gLastWrittenSector;
sector %= 0xE;
sector += 0xE * (gSaveCounter % 2);
sector %= SECTOR_SAVE_SLOT_LENGTH;
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
data = location[a1].data;
size = location[a1].size;
@ -356,13 +364,13 @@ u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location)
}
}
u8 sav12_xor_get(u16 a1, const struct SaveSectionLocation *location)
static u8 sav12_xor_get(u16 a1, const struct SaveSectionLocation *location)
{
u16 sector;
sector = a1 + gLastWrittenSector; // no sub 1?
sector %= 0xE;
sector += 0xE * (gSaveCounter % 2);
sector %= SECTOR_SAVE_SLOT_LENGTH;
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25))
{
@ -379,13 +387,13 @@ u8 sav12_xor_get(u16 a1, const struct SaveSectionLocation *location)
}
}
u8 sub_8152CAC(u16 a1, const struct SaveSectionLocation *location)
static u8 sub_8152CAC(u16 a1, const struct SaveSectionLocation *location)
{
u16 sector;
sector = a1 + gLastWrittenSector - 1;
sector %= 0xE;
sector += 0xE * (gSaveCounter % 2);
sector %= SECTOR_SAVE_SLOT_LENGTH;
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), ((u8 *)gFastSaveSection)[sizeof(struct UnkSaveSection)]))
{
@ -402,13 +410,13 @@ u8 sub_8152CAC(u16 a1, const struct SaveSectionLocation *location)
}
}
u8 sub_8152D44(u16 a1, const struct SaveSectionLocation *location)
static u8 sub_8152D44(u16 a1, const struct SaveSectionLocation *location)
{
u16 sector;
sector = a1 + gLastWrittenSector - 1; // no sub 1?
sector %= 0xE;
sector += 0xE * (gSaveCounter % 2);
sector %= SECTOR_SAVE_SLOT_LENGTH;
sector += SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25))
{
@ -425,7 +433,7 @@ u8 sub_8152D44(u16 a1, const struct SaveSectionLocation *location)
}
}
u8 sub_8152DD0(u16 a1, const struct SaveSectionLocation *location)
static u8 sub_8152DD0(u16 a1, const struct SaveSectionLocation *location)
{
u8 retVal;
gFastSaveSection = &gSaveDataBuffer;
@ -442,14 +450,14 @@ u8 sub_8152DD0(u16 a1, const struct SaveSectionLocation *location)
return retVal;
}
u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location)
static u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location)
{
u16 i;
u16 checksum;
u16 v3 = 0xE * (gSaveCounter % 2);
u16 v3 = SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
u16 id;
for (i = 0; i < 0xE; i++)
for (i = 0; i < SECTOR_SAVE_SLOT_LENGTH; i++)
{
DoReadFlashWholeSection(i + v3, gFastSaveSection);
id = gFastSaveSection->id;
@ -468,7 +476,7 @@ u8 sub_8152E10(u16 a1, const struct SaveSectionLocation *location)
return 1;
}
u8 GetSaveValidStatus(const struct SaveSectionLocation *location)
static u8 GetSaveValidStatus(const struct SaveSectionLocation *location)
{
u16 i;
u16 checksum;
@ -480,7 +488,7 @@ u8 GetSaveValidStatus(const struct SaveSectionLocation *location)
u8 saveSlot2Status;
// check save slot 1.
for (i = 0; i < 0xE; i++)
for (i = 0; i < SECTOR_SAVE_SLOT_LENGTH; i++)
{
DoReadFlashWholeSection(i, gFastSaveSection);
if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE)
@ -511,9 +519,9 @@ u8 GetSaveValidStatus(const struct SaveSectionLocation *location)
securityPassed = FALSE;
// check save slot 2.
for (i = 0; i < 0xE; i++)
for (i = 0; i < SECTOR_SAVE_SLOT_LENGTH; i++)
{
DoReadFlashWholeSection(i + 0xE, gFastSaveSection);
DoReadFlashWholeSection(i + SECTOR_SAVE_SLOT_LENGTH, gFastSaveSection);
if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE)
{
securityPassed = TRUE;
@ -543,25 +551,17 @@ u8 GetSaveValidStatus(const struct SaveSectionLocation *location)
if ((saveSlot1Counter == -1 && saveSlot2Counter == 0) || (saveSlot1Counter == 0 && saveSlot2Counter == -1))
{
if ((unsigned)(saveSlot1Counter + 1) < (unsigned)(saveSlot2Counter + 1))
{
gSaveCounter = saveSlot2Counter;
}
else
{
gSaveCounter = saveSlot1Counter;
}
}
else
{
if (saveSlot1Counter < saveSlot2Counter)
{
gSaveCounter = saveSlot2Counter;
}
else
{
gSaveCounter = saveSlot1Counter;
}
}
return 1;
}
@ -593,7 +593,7 @@ u8 GetSaveValidStatus(const struct SaveSectionLocation *location)
return 2;
}
u8 sub_81530DC(u8 a1, u8 *data, u16 size)
static u8 sub_81530DC(u8 a1, u8 *data, u16 size)
{
u16 i;
struct SaveSection *section = &gSaveDataBuffer;
@ -618,13 +618,13 @@ u8 sub_81530DC(u8 a1, u8 *data, u16 size)
}
}
u8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section)
static u8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section)
{
ReadFlash(sector, 0, section->data, sizeof(struct SaveSection));
return 1;
}
u16 CalculateChecksum(void *data, u16 size)
static u16 CalculateChecksum(void *data, u16 size)
{
u16 i;
u32 checksum = 0;
@ -635,7 +635,7 @@ u16 CalculateChecksum(void *data, u16 size)
return ((checksum >> 16) + checksum);
}
void UpdateSaveAddresses(void)
static void UpdateSaveAddresses(void)
{
int i = 0;
@ -668,7 +668,7 @@ u8 HandleSavingData(u8 saveType)
switch (saveType)
{
case SAVE_HALL_OF_FAME_ERASE_BEFORE: // deletes HOF before overwriting HOF completely. unused
for (i = 0xE * 2 + 0; i < 32; i++)
for (i = SECTOR_ID_HOF_1; i < SECTORS_COUNT; i++)
EraseFlashSector(i);
case SAVE_HALL_OF_FAME: // hall of fame.
if (GetGameStat(GAME_STAT_ENTERED_HOF) < 999)
@ -676,8 +676,8 @@ u8 HandleSavingData(u8 saveType)
SaveSerializedGame();
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
tempAddr = gDecompressionBuffer;
HandleWriteSectorNBytes(0x1C, tempAddr, 0xF80);
HandleWriteSectorNBytes(0x1D, tempAddr + 0xF80, 0xF80);
HandleWriteSectorNBytes(SECTOR_ID_HOF_1, tempAddr, 0xF80);
HandleWriteSectorNBytes(SECTOR_ID_HOF_2, tempAddr + 0xF80, 0xF80);
break;
case SAVE_NORMAL: // normal save. also called by overwriting your own save.
default:
@ -692,7 +692,7 @@ u8 HandleSavingData(u8 saveType)
for(i = 0; i < 5; i++)
sav12_xor_get(i, gRamSaveSectionLocations);
break;
// support for Ereader was removed in Emerald.
// Support for Ereader was removed in Emerald.
/*
case EREADER_SAVE: // used in mossdeep "game corner" before/after battling old man e-reader trainer
SaveSerializedGame();
@ -700,7 +700,7 @@ u8 HandleSavingData(u8 saveType)
break;
*/
case SAVE_OVERWRITE_DIFFERENT_FILE:
for (i = (0xE * 2 + 0); i < 32; i++)
for (i = SECTOR_ID_HOF_1; i < SECTORS_COUNT; i++)
EraseFlashSector(i); // erase HOF.
SaveSerializedGame();
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
@ -710,7 +710,7 @@ u8 HandleSavingData(u8 saveType)
return 0;
}
u8 TrySavingData(u8 saveType) // TrySave
u8 TrySavingData(u8 saveType)
{
if (gFlashMemoryPresent != TRUE)
{
@ -744,7 +744,7 @@ bool8 sub_8153380(void) // trade.s save
bool8 sub_81533AC(void) // trade.s save
{
u8 retVal = sub_81529D4(0xE, gRamSaveSectionLocations);
u8 retVal = sub_81529D4(SECTOR_SAVE_SLOT_LENGTH, gRamSaveSectionLocations);
if (gDamagedSaveSectors)
DoSaveFailedScreen(0);
if (retVal == 0xFF)
@ -755,7 +755,7 @@ bool8 sub_81533AC(void) // trade.s save
u8 sub_81533E0(void) // trade.s save
{
sub_8152A34(0xE, gRamSaveSectionLocations);
sub_8152A34(SECTOR_SAVE_SLOT_LENGTH, gRamSaveSectionLocations);
if (gDamagedSaveSectors)
DoSaveFailedScreen(0);
return 0;
@ -763,7 +763,7 @@ u8 sub_81533E0(void) // trade.s save
u8 sub_8153408(void) // trade.s save
{
sub_8152CAC(0xE, gRamSaveSectionLocations);
sub_8152CAC(SECTOR_SAVE_SLOT_LENGTH, gRamSaveSectionLocations);
if (gDamagedSaveSectors)
DoSaveFailedScreen(0);
return 0;
@ -840,8 +840,8 @@ u16 sub_815355C(void)
return 0;
UpdateSaveAddresses();
GetSaveValidStatus(gRamSaveSectionLocations);
v3 = 0xE * (gSaveCounter % 2);
for (i = 0; i < 14; i++)
v3 = SECTOR_SAVE_SLOT_LENGTH * (gSaveCounter % 2);
for (i = 0; i < SECTOR_SAVE_SLOT_LENGTH; i++)
{
DoReadFlashWholeSection(i + v3, gFastSaveSection);
if (gFastSaveSection->id == 0)
@ -859,7 +859,7 @@ u32 TryCopySpecialSaveSection(u8 sector, u8* dst)
s32 size;
u8* savData;
if (sector != 30 && sector != 31)
if (sector != SECTOR_ID_TRAINER_HILL && sector != SECTOR_ID_RECORDED_BATTLE)
return 0xFF;
ReadFlash(sector, 0, (u8 *)&gSaveDataBuffer, sizeof(struct SaveSection));
if (*(u32*)(&gSaveDataBuffer.data[0]) != 0xB39D)

View File

@ -13,16 +13,17 @@
#include "starter_choose.h"
#include "gba/flash_internal.h"
#include "text_window.h"
#include "constants/rgb.h"
#define MSG_WIN_TOP 12
#define CLOCK_WIN_TOP (MSG_WIN_TOP - 4)
extern u8 gText_SaveFailedCheckingBackup[];
extern u8 gText_BackupMemoryDamaged[];
extern u8 gText_CheckCompleted[];
extern u8 gText_SaveCompleteGameCannotContinue[];
extern u8 gText_SaveCompletePressA[];
extern u8 gText_GamePlayCannotBeContinued[];
extern const u8 gText_SaveFailedCheckingBackup[];
extern const u8 gText_BackupMemoryDamaged[];
extern const u8 gText_CheckCompleted[];
extern const u8 gText_SaveCompleteGameCannotContinue[];
extern const u8 gText_SaveCompletePressA[];
extern const u8 gText_GamePlayCannotBeContinued[];
// gSaveFailedClockInfo enum
enum
@ -155,8 +156,8 @@ static void VBlankCB_UpdateClockGraphics(void);
static bool8 VerifySectorWipe(u16 sector);
static bool8 WipeSectors(u32);
// although this is a general text printer, it's only used in this file.
static void SaveFailedScreenTextPrint(u8 *text, u8 var1, u8 var2)
// Although this is a general text printer, it's only used in this file.
static void SaveFailedScreenTextPrint(const u8 *text, u8 var1, u8 var2)
{
u8 color[3];
@ -203,7 +204,6 @@ static void CB2_SaveFailedScreen(void)
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
// how come this doesnt use the Dma manager?
DmaFill16(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
@ -217,7 +217,6 @@ static void CB2_SaveFailedScreen(void)
CpuFill32(0, &gDecompressionBuffer[0x2000], 0x800);
LoadBgTiles(0, gTextWindowFrame1_Gfx, 0x120, 0x214);
InitWindows(gUnknown_085EFD94);
// AddWindowWithoutTileMap returns a u16/integer, but the info is clobbered into a u8 here resulting in lost info. Bug?
gSaveFailedWindowIds[TEXT_WIN_ID] = AddWindowWithoutTileMap(gUnknown_085EFD9C);
SetWindowAttribute(gSaveFailedWindowIds[TEXT_WIN_ID], 7, (u32)&gDecompressionBuffer[0x2800]);
gSaveFailedWindowIds[CLOCK_WIN_ID] = AddWindowWithoutTileMap(gUnknown_085EFDA4);
@ -237,10 +236,10 @@ static void CB2_SaveFailedScreen(void)
CopyWindowToVram(gSaveFailedWindowIds[CLOCK_WIN_ID], 2); // again?
CopyWindowToVram(gSaveFailedWindowIds[TEXT_WIN_ID], 1);
SaveFailedScreenTextPrint(gText_SaveFailedCheckingBackup, 1, 0);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
EnableInterrupts(1);
SetVBlankCallback(VBlankCB);
SetGpuReg(0, 0x1040);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(2);
ShowBg(3);
@ -346,7 +345,7 @@ static void CB2_ReturnToTitleScreen(void)
static void VBlankCB_UpdateClockGraphics(void)
{
unsigned int n = (gMain.vblankCounter2 >> 3) & 7;
u32 n = (gMain.vblankCounter2 >> 3) & 7;
gMain.oamBuffer[0] = sClockOamData;
gMain.oamBuffer[0].x = 112;

View File

@ -9,21 +9,18 @@
static bool32 IsCurMapInLocationList(const u16 *list)
{
s32 i;
u16 locSum = (gSaveBlock1Ptr->location.mapGroup << 8) + (gSaveBlock1Ptr->location.mapNum);
// im sure it was written a different way, but for the love of christ I cant figure out how to write it different where it still matches.
if (*list != 0xFFFF)
for (i = 0; list[i] != 0xFFFF; i++)
{
u16 termValue = 0xFFFF;
const u16 *localList;
for (localList = list; *localList != termValue; localList++)
if (*localList == locSum)
if (list[i] == locSum)
return TRUE;
}
return FALSE;
}
// TODO: Not require a packed u16 array for these lists
static const u16 sSaveLocationPokeCenterList[] =
{
MAP_OLDALE_TOWN_POKEMON_CENTER_1F,
@ -72,7 +69,7 @@ static bool32 IsCurMapPokeCenter(void)
return IsCurMapInLocationList(sSaveLocationPokeCenterList);
}
static const u16 sSaveLocationReloadLocList[] = // there's only 1 location, and it's presumed its for the save reload feature for battle tower
static const u16 sSaveLocationReloadLocList[] = // There's only 1 location, and it's presumed its for the save reload feature for battle tower.
{
MAP_BATTLE_FRONTIER_BATTLE_TOWER_LOBBY,
0xFFFF,
@ -83,13 +80,13 @@ static bool32 IsCurMapReloadLocation(void)
return IsCurMapInLocationList(sSaveLocationReloadLocList);
}
// nulled out list. unknown what this would have been
// Nulled out list. Unknown what this would have been.
static const u16 sUnknown_0861440E[] =
{
0xFFFF,
};
bool32 sub_81AFCEC(void)
static bool32 sub_81AFCEC(void)
{
return IsCurMapInLocationList(sUnknown_0861440E);
}

View File

@ -460,18 +460,18 @@ static bool32 InitStartMenuStep(void)
sUnknown_02037619[0]++;
break;
case 3:
if (GetSafariZoneFlag() != FALSE)
if (GetSafariZoneFlag())
{
ShowSafariBallsWindow();
}
if (InBattlePyramid() != FALSE)
if (InBattlePyramid())
{
ShowPyramidFloorWindow();
}
sUnknown_02037619[0]++;
break;
case 4:
if (PrintStartMenuActions(&sUnknown_02037619[1], 2) == FALSE)
if (!PrintStartMenuActions(&sUnknown_02037619[1], 2))
{
break;
}

View File

@ -12,11 +12,10 @@
#include "task.h"
#include "trainer_see.h"
#include "util.h"
#include "battle_pyramid.h"
#include "constants/field_effects.h"
extern bool8 InBattlePyramid(void);
extern bool32 InTrainerHill(void);
extern bool8 GetBattlePyramidTrainerFlag(u8 eventObjectId);
extern bool8 GetTrainerHillTrainerFlag(u8 eventObjectId);
extern void sub_809BE48(u16 npcId);

View File

@ -19,6 +19,7 @@
#include "link.h"
#include "script.h"
#include "battle_pike.h"
#include "battle_pyramid.h"
#include "constants/items.h"
#include "constants/maps.h"
@ -26,9 +27,6 @@ extern const u8 EventScript_RepelWoreOff[];
#define NUM_FEEBAS_SPOTS 6
extern void GenerateBattlePyramidWildMon(void);
extern bool8 InBattlePyramid(void);
// this file's functions
static u16 FeebasRandom(void);
static void FeebasSeedRng(u16 seed);