pokeblock feed is decompiled

This commit is contained in:
DizzyEggg 2017-12-10 15:04:03 +01:00
parent bb1ae5f857
commit fb30acbc30
7 changed files with 566 additions and 844 deletions

View File

@ -1,754 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_817A5CC
sub_817A5CC: @ 817A5CC
push {r4-r7,lr}
ldr r0, =sPokeblockFeed
ldr r1, [r0]
ldr r0, =0x00001056
adds r3, r1, r0
movs r0, 0x1
strh r0, [r3]
ldr r2, =gUnknown_085EFEBC
ldr r7, =0x0000105a
adds r1, r7
ldrb r0, [r1]
lsls r0, 1
adds r0, r2
ldrb r2, [r0]
movs r4, 0
ldr r5, =gUnknown_085EFF00
adds r6, r5, 0
subs r6, 0xA
_0817A5F0:
lsls r1, r2, 2
adds r1, r2
lsls r1, 2
adds r0, r1, r6
ldrh r0, [r0]
ldrh r7, [r3]
adds r0, r7
strh r0, [r3]
adds r1, r5
movs r7, 0
ldrsh r0, [r1, r7]
cmp r0, 0x1
beq _0817A61A
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r4, 0x7
bls _0817A5F0
_0817A61A:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_817A5CC
thumb_func_start sub_817A634
sub_817A634: @ 817A634
push {r4,lr}
ldr r0, =sPokeblockFeed
ldr r4, [r0]
ldr r1, =0x00001050
adds r0, r4, r1
ldrb r0, [r0]
cmp r0, 0x5A
bls _0817A646
b _0817A90E
_0817A646:
lsls r0, 2
ldr r1, =_0817A65C
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_0817A65C:
.4byte _0817A7C8
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A818
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A858
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A8A2
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A8FC
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
.4byte _0817A90E
_0817A7C8:
ldr r1, =gUnknown_085EFEBC
ldr r2, =0x0000105a
adds r0, r4, r2
ldrb r0, [r0]
lsls r0, 1
adds r0, r1
ldrb r1, [r0]
ldr r3, =0x00001051
adds r0, r4, r3
strb r1, [r0]
ldr r1, =0x0000105b
adds r0, r4, r1
ldrb r0, [r0]
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
ldr r0, =gSprites
adds r1, r0
adds r0, r4, 0
stm r0!, {r1}
movs r2, 0x44
bl memcpy
ldr r2, =0x00001050
adds r1, r4, r2
movs r0, 0xA
strb r0, [r1]
b _0817A90E
.pool
_0817A818:
bl sub_817A91C
ldr r1, =gUnknown_085EFEBC
ldr r3, =0x0000105a
adds r0, r4, r3
ldrb r0, [r0]
lsls r0, 1
adds r1, 0x1
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
beq _0817A850
ldr r2, [r4]
ldrb r0, [r2, 0x1]
movs r1, 0x3
orrs r0, r1
strb r0, [r2, 0x1]
ldr r2, [r4]
ldrb r1, [r2, 0x3]
movs r0, 0x3F
negs r0, r0
ands r0, r1
strb r0, [r2, 0x3]
ldr r0, [r4]
ldr r1, =gUnknown_085F04FC
str r1, [r0, 0x10]
bl InitSpriteAffineAnim
_0817A850:
ldr r0, =0x00001050
adds r1, r4, r0
movs r0, 0x32
strb r0, [r1]
_0817A858:
ldr r1, =gUnknown_085EFEBC
ldr r2, =0x0000105a
adds r0, r4, r2
ldrb r0, [r0]
lsls r0, 1
adds r1, 0x1
adds r2, r0, r1
ldrb r1, [r2]
cmp r1, 0
beq _0817A8C8
ldr r3, =0x00001053
adds r0, r4, r3
ldrb r0, [r0]
cmp r0, 0
bne _0817A898
ldr r0, [r4]
adds r1, 0xA
lsls r1, 24
lsrs r1, 24
bl StartSpriteAffineAnim
b _0817A8C8
.pool
_0817A898:
ldr r0, [r4]
ldrb r1, [r2]
bl StartSpriteAffineAnim
b _0817A8C8
_0817A8A2:
bl sub_817A9E4
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0817A90E
ldr r1, =0x00001072
adds r0, r4, r1
movs r2, 0
ldrsh r0, [r0, r2]
cmp r0, 0
bne _0817A8E0
ldr r3, =0x00001051
adds r1, r4, r3
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
bl sub_817A91C
_0817A8C8:
ldr r0, =0x00001050
adds r1, r4, r0
movs r0, 0x3C
strb r0, [r1]
b _0817A90E
.pool
_0817A8E0:
ldr r0, [r4]
ldrb r0, [r0, 0x3]
lsls r0, 26
lsrs r0, 27
bl FreeOamMatrix
ldr r2, =0x00001050
adds r1, r4, r2
movs r0, 0x46
strb r0, [r1]
b _0817A90E
.pool
_0817A8FC:
bl sub_817AA3C
ldr r3, =0x00001051
adds r0, r4, r3
movs r1, 0
strb r1, [r0]
ldr r2, =0x00001050
adds r0, r4, r2
strb r1, [r0]
_0817A90E:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_817A634
thumb_func_start sub_817A91C
sub_817A91C: @ 817A91C
push {r4-r7,lr}
ldr r0, =sPokeblockFeed
ldr r5, [r0]
movs r4, 0
movs r0, 0x83
lsls r0, 5
adds r7, r5, r0
ldr r1, =gUnknown_085EFEEE
mov r12, r1
ldr r2, =0x00001051
adds r6, r5, r2
_0817A932:
lsls r2, r4, 1
adds r3, r7, r2
ldrb r1, [r6]
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
adds r2, r0
add r2, r12
ldrh r0, [r2]
strh r0, [r3]
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x9
bls _0817A932
ldr r0, =0x00001068
adds r6, r5, r0
movs r1, 0
ldrsh r0, [r6, r1]
cmp r0, 0
beq _0817A9DC
movs r2, 0x83
lsls r2, 5
adds r4, r5, r2
movs r1, 0
ldrsh r0, [r4, r1]
adds r2, 0x4
adds r1, r5, r2
movs r2, 0
ldrsh r1, [r1, r2]
bl Sin
ldr r2, =0x00001074
adds r1, r5, r2
strh r0, [r1]
movs r1, 0
ldrsh r0, [r4, r1]
subs r2, 0xE
adds r1, r5, r2
movs r2, 0
ldrsh r1, [r1, r2]
bl Cos
ldr r2, =0x00001076
adds r1, r5, r2
strh r0, [r1]
ldrh r0, [r6]
ldr r1, =0x00001078
adds r4, r5, r1
strh r0, [r4]
ldr r0, [r5]
ldrh r1, [r0, 0x24]
adds r2, 0x4
adds r0, r5, r2
strh r1, [r0]
ldr r0, [r5]
ldrh r1, [r0, 0x26]
adds r2, 0x2
adds r0, r5, r2
strh r1, [r0]
bl sub_817AB68
ldrh r0, [r4]
strh r0, [r6]
bl sub_817AA54
ldrh r0, [r4]
strh r0, [r6]
movs r0, 0
b _0817A9DE
.pool
_0817A9DC:
movs r0, 0x1
_0817A9DE:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_817A91C
thumb_func_start sub_817A9E4
sub_817A9E4: @ 817A9E4
push {r4,r5,lr}
ldr r0, =sPokeblockFeed
ldr r2, [r0]
ldr r1, =0x00001078
adds r0, r2, r1
ldr r5, =0x00001068
adds r4, r2, r5
ldrh r1, [r0]
ldrh r0, [r4]
subs r1, r0
lsls r1, 16
ldr r3, [r2]
lsrs r1, 15
movs r5, 0x85
lsls r5, 4
adds r0, r2, r5
adds r0, r1
ldrh r0, [r0]
strh r0, [r3, 0x24]
ldr r3, [r2]
movs r0, 0xC5
lsls r0, 4
adds r2, r0
adds r2, r1
ldrh r0, [r2]
strh r0, [r3, 0x26]
ldrh r0, [r4]
subs r0, 0x1
strh r0, [r4]
lsls r0, 16
cmp r0, 0
beq _0817AA34
movs r0, 0
b _0817AA36
.pool
_0817AA34:
movs r0, 0x1
_0817AA36:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_817A9E4
thumb_func_start sub_817AA3C
sub_817AA3C: @ 817AA3C
push {lr}
ldr r0, =sPokeblockFeed
ldr r0, [r0]
ldr r0, [r0]
bl FreeSpriteOamMatrix
movs r0, 0
pop {r1}
bx r1
.pool
thumb_func_end sub_817AA3C
thumb_func_start sub_817AA54
sub_817AA54: @ 817AA54
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x14
ldr r0, =sPokeblockFeed
ldr r7, [r0]
ldr r1, =0x00001070
adds r0, r7, r1
ldrh r0, [r0]
mov r9, r0
ldr r2, =0x00001078
adds r0, r7, r2
ldrh r0, [r0]
mov r3, r9
subs r0, r3
lsls r0, 16
lsrs r0, 16
mov r8, r0
ldr r4, =0x0000107a
adds r1, r7, r4
subs r2, 0xC
adds r0, r7, r2
ldrh r0, [r0]
ldrh r1, [r1]
adds r0, r1
lsls r0, 16
lsrs r0, 16
str r0, [sp]
ldr r3, =0x0000107c
adds r1, r7, r3
subs r4, 0xC
adds r0, r7, r4
ldrh r0, [r0]
ldrh r1, [r1]
adds r0, r1
lsls r0, 16
lsrs r0, 16
str r0, [sp, 0x4]
movs r5, 0
mov r0, r8
subs r0, 0x1
cmp r5, r0
bge _0817AB20
ldr r1, [sp]
lsls r0, r1, 16
asrs r0, 16
str r0, [sp, 0x8]
ldr r2, [sp, 0x4]
lsls r0, r2, 16
asrs r0, 16
mov r10, r0
_0817AABE:
mov r3, r9
adds r0, r3, r5
lsls r0, 1
movs r4, 0x85
lsls r4, 4
adds r2, r7, r4
adds r2, r0
ldrh r6, [r2]
ldr r3, [sp, 0x8]
subs r1, r6, r3
movs r4, 0xC5
lsls r4, 4
adds r3, r7, r4
adds r3, r0
ldrh r4, [r3]
mov r0, r10
subs r4, r0
lsls r4, 16
lsrs r4, 16
lsls r1, 16
asrs r1, 16
adds r5, 0x1
adds r0, r1, 0
muls r0, r5
mov r1, r8
str r2, [sp, 0xC]
str r3, [sp, 0x10]
bl __divsi3
subs r6, r0
ldr r2, [sp, 0xC]
strh r6, [r2]
lsls r4, 16
asrs r4, 16
adds r0, r4, 0
muls r0, r5
mov r1, r8
bl __divsi3
ldr r3, [sp, 0x10]
ldrh r1, [r3]
subs r1, r0
strh r1, [r3]
lsls r5, 16
lsrs r5, 16
mov r0, r8
subs r0, 0x1
cmp r5, r0
blt _0817AABE
_0817AB20:
mov r0, r9
add r0, r8
subs r0, 0x1
lsls r0, 1
movs r2, 0x85
lsls r2, 4
adds r1, r7, r2
adds r1, r0
mov r3, sp
ldrh r3, [r3]
strh r3, [r1]
movs r4, 0xC5
lsls r4, 4
adds r1, r7, r4
adds r1, r0
mov r0, sp
ldrh r0, [r0, 0x4]
strh r0, [r1]
add sp, 0x14
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_817AA54
thumb_func_start sub_817AB68
sub_817AB68: @ 817AB68
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x8
ldr r0, =sPokeblockFeed
ldr r6, [r0]
movs r0, 0
str r0, [sp]
ldr r1, =0x0000107a
adds r0, r6, r1
ldr r2, =0x00001074
adds r1, r6, r2
ldrh r2, [r0]
ldrh r0, [r1]
subs r2, r0
ldr r3, =0x0000107c
adds r0, r6, r3
ldr r1, =0x00001076
adds r3, r6, r1
ldrh r1, [r0]
ldrh r0, [r3]
subs r1, r0
ldr r3, =0x00001068
adds r3, r6
mov r9, r3
movs r0, 0x83
lsls r0, 5
adds r0, r6
mov r8, r0
lsls r2, 16
asrs r2, 16
str r2, [sp, 0x4]
lsls r1, 16
asrs r1, 16
mov r10, r1
_0817ABB2:
ldr r1, =0x0000106a
adds r0, r6, r1
movs r2, 0
ldrsh r0, [r0, r2]
cmp r0, 0
bge _0817ABC0
negs r0, r0
_0817ABC0:
lsls r0, 16
ldr r3, =0x00001066
adds r7, r6, r3
lsrs r0, 16
ldrh r1, [r7]
adds r0, r1
lsls r4, r0, 16
strh r0, [r7]
ldr r2, =0x00001064
adds r0, r6, r2
ldrh r2, [r0]
movs r3, 0
ldrsh r0, [r0, r3]
cmp r0, 0
bge _0817ABE2
movs r0, 0x1
str r0, [sp]
_0817ABE2:
ldr r1, =0x00001078
adds r0, r6, r1
ldrh r0, [r0]
mov r3, r9
ldrh r1, [r3]
subs r0, r1
lsls r0, 16
lsrs r5, r0, 16
cmp r1, 0
beq _0817ACB8
ldr r0, [sp]
cmp r0, 0
bne _0817AC54
mov r1, r8
movs r3, 0
ldrsh r0, [r1, r3]
lsrs r4, 24
adds r1, r2, r4
lsls r1, 16
asrs r1, 16
bl Sin
lsls r5, 1
movs r2, 0x85
lsls r2, 4
adds r1, r6, r2
adds r1, r5
ldr r3, [sp, 0x4]
adds r0, r3, r0
strh r0, [r1]
mov r1, r8
movs r2, 0
ldrsh r0, [r1, r2]
ldrh r1, [r7]
adds r1, r4
b _0817AC80
.pool
_0817AC54:
mov r1, r8
movs r3, 0
ldrsh r0, [r1, r3]
lsrs r4, 24
subs r1, r2, r4
lsls r1, 16
asrs r1, 16
bl Sin
lsls r5, 1
movs r2, 0x85
lsls r2, 4
adds r1, r6, r2
adds r1, r5
ldr r3, [sp, 0x4]
adds r0, r3, r0
strh r0, [r1]
mov r1, r8
movs r2, 0
ldrsh r0, [r1, r2]
ldrh r1, [r7]
subs r1, r4
_0817AC80:
lsls r1, 16
asrs r1, 16
bl Cos
movs r3, 0xC5
lsls r3, 4
adds r1, r6, r3
adds r1, r5
add r0, r10
strh r0, [r1]
ldr r1, =0x00001062
adds r0, r6, r1
ldrh r0, [r0]
mov r2, r8
ldrh r2, [r2]
adds r0, r2
movs r1, 0xFF
ands r0, r1
mov r3, r8
strh r0, [r3]
mov r1, r9
ldrh r0, [r1]
subs r0, 0x1
strh r0, [r1]
b _0817ABB2
.pool
_0817ACB8:
add sp, 0x8
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_817AB68
.align 2, 0 @ Don't pad with nop.

View File

@ -919,7 +919,7 @@ _08135C64:
.4byte _08135CFC
_08135C7C:
bl reset_temp_tile_data_buffers
ldr r1, =gUnknown_08D9B2B4
ldr r1, =gMenuPokeblock_Gfx
movs r0, 0
str r0, [sp]
movs r0, 0x2
@ -934,7 +934,7 @@ _08135C98:
lsrs r0, 24
cmp r0, 0x1
beq _08135D18
ldr r0, =gUnknown_08D9B7C8
ldr r0, =gMenuPokeblockDevice_Gfx
ldr r4, =gUnknown_0203AB50
ldr r1, [r4]
bl LZDecompressWram
@ -942,7 +942,7 @@ _08135C98:
b _08135CE2
.pool
_08135CBC:
ldr r0, =gUnknown_08D9B470
ldr r0, =gMenuPokeblock_Pal
movs r1, 0
movs r2, 0xC0
bl LoadCompressedPalette

View File

@ -880,13 +880,13 @@ gBuyMenuFrame_Tilemap:: @ 8D9B0F0
gMenuMoneyGfx:: @ 8D9B230
.incbin "baserom.gba", 0xd9b230, 0x84
gUnknown_08D9B2B4:: @ 8D9B2B4
gMenuPokeblock_Gfx:: @ 8D9B2B4
.incbin "baserom.gba", 0xd9b2b4, 0x1bc
gUnknown_08D9B470:: @ 8D9B470
gMenuPokeblock_Pal:: @ 8D9B470
.incbin "baserom.gba", 0xd9b470, 0x358
gUnknown_08D9B7C8:: @ 8D9B7C8
gMenuPokeblockDevice_Gfx:: @ 8D9B7C8
.incbin "baserom.gba", 0xd9b7c8, 0x27c
gUnknown_08D9BA44:: @ 8D9BA44

View File

@ -3,23 +3,7 @@
.section .rodata
gUnknown_085EFEBC:: @ 85EFEBC
.incbin "baserom.gba", 0x5efebc, 0x32
gUnknown_085EFEEE:: @ 85EFEEE
.incbin "baserom.gba", 0x5efeee, 0x12
gUnknown_085EFF00:: @ 85EFF00
.incbin "baserom.gba", 0x5eff00, 0x5fc
gUnknown_085F04FC:: @ 85F04FC
.incbin "baserom.gba", 0x5f04fc, 0x54
gUnknown_085F0550:: @ 85F0550
.incbin "baserom.gba", 0x5f0550, 0x8
gUnknown_085F0558:: @ 85F0558
.incbin "baserom.gba", 0x5f0558, 0x10
.align 2
sPokeblocksPals:: @ 85F0568
.incbin "baserom.gba", 0x5f0568, 0x48

View File

@ -223,7 +223,6 @@ SECTIONS {
src/save_failed_screen.o(.text);
src/braille_puzzles.o(.text);
src/pokeblock_feed.o(.text);
asm/pokeblock_feed.o(.text);
src/clear_save_data_screen.o(.text);
asm/intro_credits_graphics.o(.text);
src/evolution_graphics.o(.text);
@ -451,6 +450,7 @@ SECTIONS {
data/mystery_event_menu.o(.rodata);
src/save_failed_screen.o(.rodata);
data/braille_puzzles.o(.rodata);
src/pokeblock_feed.o(.rodata);
data/pokeblock_feed.o(.rodata);
src/clear_save_data_screen.o(.rodata);
data/intro_credits_graphics.o(.rodata);

View File

@ -20,14 +20,18 @@
#include "party_menu.h"
#include "m4a.h"
#include "sound.h"
#include "trig.h"
#include "battle.h" // to get rid of once gMonSpritesGfxPtr is put elsewhere
struct PokeblockFeedStruct
{
u8 field_0[0x48];
u8 tilemapBuffer[0x1008];
struct Sprite *monSpritePtr;
struct Sprite savedMonSprite;
u8 tilemapBuffer[0x808];
s16 field_850[0x200];
s16 field_C50[0x200];
u8 field_1050;
u8 field_1051;
u8 animId;
u8 field_1052;
bool8 noMonFlip;
u16 species;
@ -39,7 +43,7 @@ struct PokeblockFeedStruct
u8 monSpriteId;
u8 pokeblockCaseSpriteId;
u8 pokeblockSpriteId;
u8 field_1060[0x1E];
s16 field_1060[15];
s16 loadGfxState;
u8 somefield[2];
};
@ -50,30 +54,352 @@ extern s16 gPokeblockGain;
extern struct MusicPlayerInfo gMPlay_BGM;
extern struct SpriteTemplate gUnknown_0202499C;
extern struct PokeblockFeedStruct *sPokeblockFeed;
extern struct CompressedSpritePalette sPokeblockSpritePal;
extern const u8 gBattleTerrainPalette_Frontier[];
extern const u8 gBattleTerrainTiles_Building[];
extern const u8 gUnknown_08D9BA44[];
extern const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet;
extern const struct CompressedSpriteSheet gPokeblock_SpriteSheet;
extern const struct CompressedSpritePalette gPokeblockCase_SpritePal;
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const u16 gUnknown_0860F074[];
extern const u8 *sPokeblocksPals[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F05B0[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0664[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0668[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F066C[];
extern const struct SpriteTemplate sThrownPokeblockSpriteTemplate;
extern bool8 sub_81221EC(void);
extern void sub_806A068(u16, u8);
extern void sub_809882C(u8, u16, u8);
// this file's functions
static void HandleInitBackgrounds(void);
static void HandleInitWindows(void);
static bool8 LoadMonAndSceneGfx(struct Pokemon *mon);
u8 CreatePokeblockCaseSpriteForFeeding(void);
static u8 CreateMonSprite(struct Pokemon *mon);
void LaunchPokeblockFeedTask(void);
static void LaunchPokeblockFeedTask(void);
static void SetPokeblockSpritePal(u8 pokeblockCaseId);
void sub_817A5CC(void);
void sub_8148108(u8 spriteId, bool8 a1);
u8 CreatePokeblockSprite(void);
void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 arg1);
static void sub_817A5CC(void);
static void sub_8148108(u8 spriteId, bool8 a1);
static void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 arg1);
static void PrepareMonToMoveToPokeblock(u8 spriteId);
void Task_HandleMonAtePokeblock(u8 taskId);
void Task_PaletteFadeToReturn(u8 taskId);
void sub_817A634(void);
static void Task_HandleMonAtePokeblock(u8 taskId);
static void Task_PaletteFadeToReturn(u8 taskId);
static void sub_817A634(void);
static void sub_817A468(struct Sprite *sprite);
static void sub_817AB68(void);
static void sub_817AA54(void);
static bool8 sub_817A91C(void);
static bool8 FreeMonSpriteOamMatrix(void);
static bool8 sub_817A9E4(void);
static bool8 LoadMonAndSceneGfx(struct Pokemon *mon);
static u8 CreatePokeblockSprite(void);
static u8 CreatePokeblockCaseSpriteForFeeding(void);
static u8 CreateMonSprite(struct Pokemon *mon);
// ram variables
EWRAM_DATA static struct PokeblockFeedStruct *sPokeblockFeed = NULL;
EWRAM_DATA static struct CompressedSpritePalette sPokeblockSpritePal = {0};
// const rom data
static const u8 sNatureToMonPokeblockAnim[][2] =
{
{ 0, 0 }, // HARDY
{ 3, 0 }, // LONELY
{ 4, 1 }, // BRAVE
{ 5, 0 }, // ADAMANT
{ 10, 0 }, // NAUGHTY
{ 13, 0 }, // BOLD
{ 15, 0 }, // DOCILE
{ 16, 2 }, // RELAXED
{ 18, 0 }, // IMPISH
{ 19, 0 }, // LAX
{ 20, 0 }, // TIMID
{ 25, 0 }, // HASTY
{ 27, 3 }, // SERIOUS
{ 28, 0 }, // JOLLY
{ 29, 0 }, // NAIVE
{ 33, 4 }, // MODEST
{ 36, 0 }, // MILD
{ 37, 0 }, // QUIET
{ 39, 0 }, // BASHFUL
{ 42, 0 }, // RASH
{ 45, 0 }, // CALM
{ 46, 5 }, // GENTLE
{ 47, 6 }, // SASSY
{ 48, 0 }, // CAREFUL
{ 53, 0 }, // QUIRKY
};
static const s16 sMonPokeblockAnims[][10] =
{
// HARDY
{ 0, 4, 0, 8, 24, 0, 0, 0, 12, 0},
{ 0, 4, 0, 16, 24, 0, 0, 0, 12, 0},
{ 0, 4, 0, 32, 32, 0, 0, 0, 16, 1},
// LONELY
{ 0, 3, 6, 0, 48, 0, 0, 0, 24, 1},
// BRAVE
{ 64, 16, -24, 0, 32, 0, 0, 0, 0, 1},
// ADAMANT
{ 0, 4, 8, 0, 16, 0, -8, 0, 0, 0},
{ 0, 0, 0, 0, 16, 0, 0, 0, 0, 0},
{ 0, 4, 8, 0, 16, 0, -8, 0, 0, 0},
{ 0, 0, 0, 0, 16, 0, 0, 0, 0, 0},
{ 0, 4, -16, 0, 4, 0, 16, 0, 0, 1},
// NAUGHTY
{ 0, 3, 6, 0, 12, 0, 0, 0, 6, 0},
{ 0, 3, -6, 0, 12, 0, 0, 0, 6, 0},
{ 0, 16, 16, 0, 45, 1, 0, 0, 0, 1},
// BOLD
{ 0, 16, 0, 24, 32, 0, 0, 0, 16, 0},
{ 0, 16, 0, 23, 32, 0, 0, 0, 16, 1},
// DOCILE
{ 0, 0, 0, 0, 80, 0, 0, 0, 0, 1},
// RELAXED
{ 0, 2, 8, 0, 32, 0, 0, 0, 0, 0},
{ 0, 2, -8, 0, 32, 0, 0, 0, 0, 1},
// IMPISH
{ 0, 32, 2, 1, 48, 1, 0, 0, 24, 1},
// LAX
{ 0, 2, 16, 16, 128, 0, 0, 0, 0, 1},
// TIMID
{ 0, 2, -8, 0, 48, 0, -24, 0, 0, 0},
{ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0},
{ 64, 32, 2, 0, 36, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0},
{ 0, 2, 8, 0, 48, 0, 24, 0, 0, 1},
// HASTY
{ 64, 24, 16, 0, 32, 0, 0, 0, 0, 0},
{ 0, 28, 2, 1, 32, 1, 0, 0, 16, 1},
// SERIOUS
{ 0, 0, 0, 0, 32, 0, 0, 0, 0, 1},
// JOLLY
{ 64, 16, -16, 2, 48, 0, 0, 0, 32, 1},
// NAIVE
{ 0, 12, -8, 4, 24, 0, 8, 0, 12, 0},
{ 0, 12, 8, 8, 24, 0, -16, 0, 12, 0},
{ 0, 12, -8, 16, 24, 0, 16, 0, 12, 0},
{ 0, 12, 8, 28, 24, 0, -8, 0, 12, 1},
// MODEST
{ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0},
{ 64, 16, -4, 0, 32, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 8, 0, 0, 0, 0, 1},
// MILD
{ 128, 4, 0, 8, 64, 0, 0, 0, 0, 1},
// QUIET
{ 0, 2, 16, 0, 48, 0, 0, 0, 0, 0},
{ 128, 2, 16, 0, 48, 0, 0, 0, 0, 1},
// BASHFUL
{ 0, 2, -4, 0, 48, 0, -48, 0, 0, 0},
{ 0, 0, 0, 0, 80, 0, 0, 0, 0, 0},
{ 0, 2, 8, 0, 24, 0, 48, 0, 0, 1},
// RASH
{ 64, 4, 64, 58, 52, 0, -88, 0, 0, 0},
{ 0, 0, 0, 0, 80, 0, 0, 0, 0, 0},
{ 0, 24, 80, 0, 32, 0, 88, 0, 0, 1},
// CALM
{ 0, 2, 16, 4, 64, 0, 0, 0, 0, 1},
// GENTLE
{ 0, 0, 0, 0, 32, 0, 0, 0, 0, 1},
// SASSY
{ 0, 0, 0, 0, 42, 0, 0, 0, 0, 1},
// CAREFUL
{ 0, 4, 0, 8, 24, 0, 0, 0, 12, 0},
{ 0, 0, 0, 0, 12, 0, 0, 0, 0, 0},
{ 0, 4, 0, 12, 24, 0, 0, 0, 12, 0},
{ 0, 0, 0, 0, 12, 0, 0, 0, 0, 0},
{ 0, 4, 0, 4, 24, 0, 0, 0, 12, 1},
// QUIRKY
{ 0, 4, 16, 12, 64, 0, 0, 0, 0, 0},
{ 0, -4, 16, 12, 64, 0, 0, 0, 0, 1},
};
static const union AffineAnimCmd sSpriteAffineAnim_8411E90[] =
{
AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411EA0[] =
{
AFFINEANIMCMD_FRAME(0, 0, 12, 1),
AFFINEANIMCMD_FRAME(0, 0, 0, 30),
AFFINEANIMCMD_FRAME(0, 0, -12, 1),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411EC0[] =
{
AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 12, 1),
AFFINEANIMCMD_FRAME(0, 0, 0, 28),
AFFINEANIMCMD_FRAME(0, 0, -4, 3),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411EE8[] =
{
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16),
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411F08[] =
{
AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16),
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411F30[] =
{
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411F50[] =
{
AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411F78[] =
{
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411F98[] =
{
AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411FC0[] =
{
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 4),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8411FE0[] =
{
AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 4),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8412008[] =
{
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16),
AFFINEANIMCMD_FRAME(0x0, 0x0, -12, 2),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd sSpriteAffineAnim_8412028[] =
{
AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16),
AFFINEANIMCMD_FRAME(0x0, 0x0, -12, 2),
AFFINEANIMCMD_END
};
static const union AffineAnimCmd *const sSpriteAffineAnimTable_85F04FC[] =
{
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411EA0,
sSpriteAffineAnim_8411EE8,
sSpriteAffineAnim_8411F30,
sSpriteAffineAnim_8411F78,
sSpriteAffineAnim_8411FC0,
sSpriteAffineAnim_8412008,
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411EC0,
sSpriteAffineAnim_8411F08,
sSpriteAffineAnim_8411F50,
sSpriteAffineAnim_8411F98,
sSpriteAffineAnim_8411FE0,
sSpriteAffineAnim_8412028,
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411E90,
sSpriteAffineAnim_8411E90,
};
static const struct BgTemplate sBackgroundTemplates[] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 2,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
static const struct WindowTemplate sWindowTemplates[] =
{
{0, 1, 0xF, 0x1C, 4, 0xF, 0xA},
DUMMY_WIN_TEMPLATE
};
// code
static void CB2_PokeblockFeed(void)
{
RunTasks();
@ -90,7 +416,7 @@ static void VBlankCB_PokeblockFeed(void)
TransferPlttBuffer();
}
bool8 TransitionToPokeblockFeedScene(void)
static bool8 TransitionToPokeblockFeedScene(void)
{
switch (gMain.state)
{
@ -177,29 +503,12 @@ void CB2_PreparePokeblockFeedScene(void)
}
}
extern const struct BgTemplate gUnknown_085F0550[2];
extern const u8 gBattleTerrainPalette_Frontier[];
extern const u8 gBattleTerrainTiles_Building[];
extern const u8 gUnknown_08D9BA44[];
extern const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet;
extern const struct CompressedSpriteSheet gPokeblock_SpriteSheet;
extern const struct CompressedSpritePalette gPokeblockCase_SpritePal;
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const struct WindowTemplate gUnknown_085F0558[];
extern const u16 gUnknown_0860F074[];
extern const u8 *sPokeblocksPals[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F05B0[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0664[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0668[];
extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F066C[];
extern const struct SpriteTemplate sThrownPokeblockSpriteTemplate;
static void HandleInitBackgrounds(void)
{
ResetVramOamAndBgCntRegs();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_085F0550, ARRAY_COUNT(gUnknown_085F0550));
InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates));
SetBgTilemapBuffer(1, sPokeblockFeed->tilemapBuffer);
ResetAllBgsCoordinates();
schedule_bg_copy_tilemap_to_vram(1);
@ -274,11 +583,9 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon)
return FALSE;
}
extern void sub_809882C(u8, u16, u8);
static void HandleInitWindows(void)
{
InitWindows(gUnknown_085F0558);
InitWindows(sWindowTemplates);
DeactivateAllTextPrinters();
sub_809882C(0, 1, 0xE0);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
@ -297,7 +604,7 @@ static void SetPokeblockSpritePal(u8 pokeblockCaseId)
#define tFrames data[0]
#define tData1 data[1]
void Task_HandlePokeblockFeed(u8 taskId)
static void Task_HandlePokeblockFeed(u8 taskId)
{
if (!gPaletteFade.active)
{
@ -332,20 +639,20 @@ void Task_HandlePokeblockFeed(u8 taskId)
}
}
void LaunchPokeblockFeedTask(void)
static void LaunchPokeblockFeedTask(void)
{
u8 taskId = CreateTask(Task_HandlePokeblockFeed, 0);
gTasks[taskId].tFrames = 0;
gTasks[taskId].tData1 = 1;
}
void Task_WaitForAtePokeblockText(u8 taskId)
static void Task_WaitForAtePokeblockText(u8 taskId)
{
if (RunTextPrintersRetIsActive(0) != TRUE)
gTasks[taskId].func = Task_PaletteFadeToReturn;
}
void Task_HandleMonAtePokeblock(u8 taskId)
static void Task_HandleMonAtePokeblock(u8 taskId)
{
struct Pokemon *mon = &gPlayerParty[gPokeblockMonId];
struct Pokeblock *pokeblock = &gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId];
@ -366,7 +673,7 @@ void Task_HandleMonAtePokeblock(u8 taskId)
gTasks[taskId].func = Task_WaitForAtePokeblockText;
}
void Task_ReturnAfterPaletteFade(u8 taskId)
static void Task_ReturnAfterPaletteFade(u8 taskId)
{
if (!gPaletteFade.active)
{
@ -381,12 +688,15 @@ void Task_ReturnAfterPaletteFade(u8 taskId)
}
}
void Task_PaletteFadeToReturn(u8 taskId)
static void Task_PaletteFadeToReturn(u8 taskId)
{
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gTasks[taskId].func = Task_ReturnAfterPaletteFade;
}
#undef tFrames
#undef tData1
static u8 CreateMonSprite(struct Pokemon* mon)
{
u16 species = GetMonData(mon, MON_DATA_SPECIES2);
@ -395,7 +705,7 @@ static u8 CreateMonSprite(struct Pokemon* mon)
sPokeblockFeed->species = species;
sPokeblockFeed->monSpriteId_ = spriteId;
sPokeblockFeed->nature = GetNature(mon);
gSprites[spriteId].data2 = species;
gSprites[spriteId].data[2] = species;
gSprites[spriteId].callback = SpriteCallbackDummy;
sPokeblockFeed->noMonFlip = TRUE;
@ -414,24 +724,24 @@ static void PrepareMonToMoveToPokeblock(u8 spriteId)
{
gSprites[spriteId].pos1.x = 48;
gSprites[spriteId].pos1.y = 80;
gSprites[spriteId].data0 = -8;
gSprites[spriteId].data1 = 1;
gSprites[spriteId].data[0] = -8;
gSprites[spriteId].data[1] = 1;
gSprites[spriteId].callback = sub_817A468;
}
static void sub_817A468(struct Sprite* sprite)
{
sprite->pos1.x += 4;
sprite->pos1.y += sprite->data0;
sprite->data0 += sprite->data1;
sprite->pos1.y += sprite->data[0];
sprite->data[0] += sprite->data[1];
if (sprite->data0 == 0)
PlayCry1(sprite->data2, 0);
if (sprite->data0 == 9)
if (sprite->data[0] == 0)
PlayCry1(sprite->data[2], 0);
if (sprite->data[0] == 9)
sprite->callback = SpriteCallbackDummy;
}
u8 CreatePokeblockCaseSpriteForFeeding(void)
static u8 CreatePokeblockCaseSpriteForFeeding(void)
{
u8 spriteId = CreatePokeblockCaseSprite(188, 100, 2);
gSprites[spriteId].oam.affineMode = 1;
@ -441,7 +751,7 @@ u8 CreatePokeblockCaseSpriteForFeeding(void)
return spriteId;
}
void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 a1)
static void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 a1)
{
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
gSprites[spriteId].oam.affineMode = 3;
@ -454,19 +764,205 @@ void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 a1)
InitSpriteAffineAnim(&gSprites[spriteId]);
}
u8 CreatePokeblockSprite(void)
static u8 CreatePokeblockSprite(void)
{
u8 spriteId = CreateSprite(&sThrownPokeblockSpriteTemplate, 174, 84, 1);
gSprites[spriteId].data0 = -12;
gSprites[spriteId].data1 = 1;
gSprites[spriteId].data[0] = -12;
gSprites[spriteId].data[1] = 1;
return spriteId;
}
static void SpriteCB_ThrownPokeblock(struct Sprite* sprite)
{
sprite->pos1.x -= 4;
sprite->pos1.y += sprite->data0;
sprite->data0 += sprite->data1;
if (sprite->data0 == 10)
sprite->pos1.y += sprite->data[0];
sprite->data[0] += sprite->data[1];
if (sprite->data[0] == 10)
DestroySprite(sprite);
}
static void sub_817A5CC(void)
{
u8 animId, i;
struct PokeblockFeedStruct *pokeblockFeed;
pokeblockFeed = sPokeblockFeed;
pokeblockFeed->field_1056 = 1;
animId = sNatureToMonPokeblockAnim[pokeblockFeed->nature][0];
for (i = 0; i < 8; i++, animId++)
{
pokeblockFeed->field_1056 += sMonPokeblockAnims[animId][4];
if (sMonPokeblockAnims[animId][9] == 1)
break;
}
}
static void sub_817A634(void)
{
struct PokeblockFeedStruct *pokeblockFeed = sPokeblockFeed;
switch (pokeblockFeed->field_1050)
{
case 0:
pokeblockFeed->animId = sNatureToMonPokeblockAnim[pokeblockFeed->nature][0];
pokeblockFeed->monSpritePtr = &gSprites[pokeblockFeed->monSpriteId_];
pokeblockFeed->savedMonSprite = *pokeblockFeed->monSpritePtr;
pokeblockFeed->field_1050 = 10;
break;
case 1 ... 9:
break;
case 10:
sub_817A91C();
if (sNatureToMonPokeblockAnim[pokeblockFeed->nature][1] != 0)
{
pokeblockFeed->monSpritePtr->oam.affineMode = 3;
pokeblockFeed->monSpritePtr->oam.matrixNum = 0;
pokeblockFeed->monSpritePtr->affineAnims = sSpriteAffineAnimTable_85F04FC;
InitSpriteAffineAnim(pokeblockFeed->monSpritePtr);
}
pokeblockFeed->field_1050 = 50;
case 50:
if (sNatureToMonPokeblockAnim[pokeblockFeed->nature][1] != 0)
{
if (!pokeblockFeed->noMonFlip) // double negation, so mon's sprite is flipped
StartSpriteAffineAnim(pokeblockFeed->monSpritePtr, sNatureToMonPokeblockAnim[pokeblockFeed->nature][1] + 10);
else
StartSpriteAffineAnim(pokeblockFeed->monSpritePtr, sNatureToMonPokeblockAnim[pokeblockFeed->nature][1]);
}
pokeblockFeed->field_1050 = 60;
break;
case 60:
if (sub_817A9E4() == TRUE)
{
if (pokeblockFeed->field_1060[9] == 0)
{
pokeblockFeed->animId++;
sub_817A91C();
pokeblockFeed->field_1050 = 60;
}
else
{
FreeOamMatrix(pokeblockFeed->monSpritePtr->oam.matrixNum);
pokeblockFeed->field_1050 = 70;
}
}
break;
case 70:
FreeMonSpriteOamMatrix();
pokeblockFeed->animId = 0;
pokeblockFeed->field_1050 = 0;
break;
case 71 ... 90:
break;
}
}
static bool8 sub_817A91C(void)
{
struct PokeblockFeedStruct *pokeblockFeed = sPokeblockFeed;
u8 i;
for (i = 0; i < 10; i++)
pokeblockFeed->field_1060[i] = sMonPokeblockAnims[pokeblockFeed->animId][i];
if (pokeblockFeed->field_1060[4] == 0)
{
return TRUE;
}
else
{
pokeblockFeed->field_1060[10] = Sin(pokeblockFeed->field_1060[0], pokeblockFeed->field_1060[2]);
pokeblockFeed->field_1060[11] = Cos(pokeblockFeed->field_1060[0], pokeblockFeed->field_1060[3]);
pokeblockFeed->field_1060[12] = pokeblockFeed->field_1060[4];
pokeblockFeed->field_1060[13] = pokeblockFeed->monSpritePtr->pos2.x;
pokeblockFeed->field_1060[14] = pokeblockFeed->monSpritePtr->pos2.y;
sub_817AB68();
pokeblockFeed->field_1060[4] = pokeblockFeed->field_1060[12];
sub_817AA54();
pokeblockFeed->field_1060[4] = pokeblockFeed->field_1060[12];
return FALSE;
}
}
static bool8 sub_817A9E4(void)
{
u16 var = sPokeblockFeed->field_1060[12] - sPokeblockFeed->field_1060[4];
sPokeblockFeed->monSpritePtr->pos2.x = sPokeblockFeed->field_850[var];
sPokeblockFeed->monSpritePtr->pos2.y = sPokeblockFeed->field_C50[var];
if (--sPokeblockFeed->field_1060[4] == 0)
return TRUE;
else
return FALSE;
}
static bool8 FreeMonSpriteOamMatrix(void)
{
FreeSpriteOamMatrix(sPokeblockFeed->monSpritePtr);
return FALSE;
}
static void sub_817AA54(void)
{
struct PokeblockFeedStruct *pokeblockFeed = sPokeblockFeed;
u16 i;
u16 r8 = pokeblockFeed->field_1060[8];
u16 r7 = pokeblockFeed->field_1060[12] - r8;
s16 var3 = pokeblockFeed->field_1060[13] + pokeblockFeed->field_1060[6];
s16 r9 = pokeblockFeed->field_1060[14] + pokeblockFeed->field_1060[7];
for (i = 0; i < r7 - 1; i++)
{
s16 r1 = pokeblockFeed->field_850[r8 + i] - (var3);
s16 r4 = pokeblockFeed->field_C50[r8 + i] - r9;
pokeblockFeed->field_850[r8 + i] -= r1 * (i + 1) / r7;
pokeblockFeed->field_C50[r8 + i] -= r4 * (i + 1) / r7;
}
pokeblockFeed->field_850[(r8 + r7) - 1] = var3;
pokeblockFeed->field_C50[(r8 + r7) - 1] = r9;
}
static void sub_817AB68(void)
{
struct PokeblockFeedStruct *pokeblockFeed = sPokeblockFeed;
bool8 var_24 = FALSE;
s16 r8 = pokeblockFeed->field_1060[13] - pokeblockFeed->field_1060[10];
s16 r7 = pokeblockFeed->field_1060[14] - pokeblockFeed->field_1060[11];
while (1)
{
u16 r5;
u16 r4;
u16 var;
var = abs(pokeblockFeed->field_1060[5]);
r5 = var + pokeblockFeed->field_1060[3];
pokeblockFeed->field_1060[3] = r5;
if (pokeblockFeed->field_1060[2] < 0)
var_24 = TRUE;
r4 = pokeblockFeed->field_1060[12] - pokeblockFeed->field_1060[4];
if (pokeblockFeed->field_1060[4] == 0)
break;
if (!var_24)
{
pokeblockFeed->field_850[r4] = Sin(pokeblockFeed->field_1060[0], pokeblockFeed->field_1060[2] + r5 / 256) + r8;
pokeblockFeed->field_C50[r4] = Cos(pokeblockFeed->field_1060[0], pokeblockFeed->field_1060[3] + r5 / 256) + r7;
}
else
{
pokeblockFeed->field_850[r4] = Sin(pokeblockFeed->field_1060[0], pokeblockFeed->field_1060[2] - r5 / 256) + r8;
pokeblockFeed->field_C50[r4] = Cos(pokeblockFeed->field_1060[0], pokeblockFeed->field_1060[3] - r5 / 256) + r7;
}
pokeblockFeed->field_1060[0] += pokeblockFeed->field_1060[1];
pokeblockFeed->field_1060[0] &= 0xFF;
pokeblockFeed->field_1060[4]--;
}
}

View File

@ -1393,11 +1393,7 @@ gUnknown_0203BCF8: @ 203BCF8
gBraillePuzzleCallbackFlag: @ 203BD14
.space 0x4
sPokeblockFeed: @ 203BD18
.space 0x4
sPokeblockSpritePal: @ 203BD1C
.space 0x8
.include "src/pokeblock_feed.o"
gUnknown_0203BD24: @ 203BD24
.space 0x2