start decompiling sprite.s

This commit is contained in:
DizzyEggg 2017-09-02 00:21:11 +02:00
parent bc5acf7394
commit 26bf61e06f
49 changed files with 395 additions and 675 deletions

View File

@ -412,7 +412,7 @@ _0807FB08:
movs r0, 0
movs r1, 0
bl SetGpuReg
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0
bl SetVBlankCallback
@ -1596,7 +1596,7 @@ sub_8080588: @ 8080588
movs r0, 0
movs r1, 0
bl SetGpuReg
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
ldr r0, =sub_807F764

View File

@ -130,7 +130,7 @@ _08177D2C:
b _08177DDA
.pool
_08177D40:
bl ResetAllObjectData
bl ResetSpriteData
b _08177DDC
_08177D46:
bl ResetObjectPaletteAllocator

View File

@ -165,7 +165,7 @@ _0814FD4E:
b _08150224
.pool
_0814FDD8:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
@ -664,7 +664,7 @@ _08150298:
cmp r4, 0x13
bls _08150298
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetPaletteFade
movs r0, 0
bl UnsetBgTilemapBuffer

View File

@ -272,7 +272,7 @@ _0817AEEC:
cmp r1, r2
bls _0817AEEC
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_085F06C0

View File

@ -570,7 +570,7 @@ _080D7B4E:
movs r1, 0x80
orrs r0, r1
strb r0, [r2, 0x8]
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C

View File

@ -346,7 +346,7 @@ sub_80F5B00: @ 80F5B00
bl sub_80F57C4
bl dp12_8087EA4
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetObjectPaletteAllocator
bl sub_80F591C

View File

@ -155,7 +155,7 @@ _0812FEE2:
orrs r0, r7
str r0, [r1, 0x8]
ldr r0, [r1, 0x8]
bl ResetAllObjectData
bl ResetSpriteData
b _0812FF36
.pool
_0812FF14:

View File

@ -485,7 +485,7 @@ sub_81758E4: @ 81758E4
cmp r7, 0x1
beq _081759F0
_08175906:
bl ResetAllObjectData
bl ResetSpriteData
bl dp13_810BB8C
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
@ -719,7 +719,7 @@ sub_8175B1C: @ 8175B1C
movs r0, 0
movs r2, 0
bl sub_8176D1C
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0x1
negs r0, r0
@ -2642,7 +2642,7 @@ _08176AD6:
movs r0, 0x52
movs r1, 0
bl SetGpuReg
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0x1
strb r0, [r6]

View File

@ -93,7 +93,7 @@ sub_8177888: @ 8177888
ldr r0, [r1, 0x8]
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetPaletteFade
bl ResetObjectPaletteAllocator
ldr r0, =gUnknown_085E7088

View File

@ -292,7 +292,7 @@ _0811A454:
_0811A468:
movs r0, 0
bl SetVBlankCallback
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
b _0811A4C0

View File

@ -599,7 +599,7 @@ _080717EC:
bl DeactivateAllTextPrinters
bl ResetPaletteFade
bl ResetObjectPaletteAllocator
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl remove_some_task
bl m4aSoundVSyncOn

View File

@ -191,7 +191,7 @@ evolution_cutscene: @ 813DA8C
strb r0, [r1]
bl c2_berry_program_update_menu
bl sub_8035AA4
bl ResetAllObjectData
bl ResetSpriteData
bl remove_some_task
bl ResetTasks
bl ResetObjectPaletteAllocator
@ -484,7 +484,7 @@ sub_813DD7C: @ 813DD7C
strb r0, [r1]
bl c2_berry_program_update_menu
bl sub_8035AA4
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
movs r0, 0x4
@ -624,7 +624,7 @@ _0813DFE0:
bl SetHBlankCallback
movs r0, 0
bl SetVBlankCallback
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
movs r0, 0x4

View File

@ -59,7 +59,7 @@ sub_81701C4: @ 81701C4
movs r0, 0x1E
movs r1, 0
bl SetGpuReg
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags

View File

@ -2977,7 +2977,7 @@ sub_8174F70: @ 8174F70
push {lr}
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl reset_temp_tile_data_buffers
bl dp13_810BB8C
bl ResetObjectPaletteAllocator

View File

@ -186,7 +186,7 @@ _0816CCF4:
bl load_copyright_graphics
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0x1
negs r0, r0
@ -934,7 +934,7 @@ task_intro_6: @ 816D48C
bl intro_reset_and_hide_bgs
movs r0, 0
bl SetVBlankCallback
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =gUnknown_0203BD24
movs r1, 0
@ -1806,7 +1806,7 @@ task_intro_10: @ 816DBAC
movs r2, 0
movs r3, 0
bl sub_816F2A8
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0x1
negs r0, r0
@ -1940,7 +1940,7 @@ task_intro_13: @ 816DD28
cmp r0, 0
bne _0816DD94
bl intro_reset_and_hide_bgs
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
movs r0, 0x8
@ -2570,7 +2570,7 @@ task_intro_19: @ 816E2A0
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
bl ResetAllObjectData
bl ResetSpriteData
ldr r0, =gUnknown_08D89224
movs r1, 0xC0
lsls r1, 19

View File

@ -200,7 +200,7 @@ sub_80094EC: @ 80094EC
sub_8009570: @ 8009570
push {r4,lr}
sub sp, 0x4
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
ldr r0, =sub_80096BC
@ -3352,7 +3352,7 @@ c2_800ACD4: @ 800AF30
movs r1, 0xE0
lsls r1, 9
bl InitHeap
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetPaletteFadeControl
movs r0, 0
@ -16598,7 +16598,7 @@ sub_8011AE8: @ 8011AE8
thumb_func_start sub_8011AFC
sub_8011AFC: @ 8011AFC
push {r4,lr}
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
bl ResetPaletteFade
@ -28634,7 +28634,7 @@ _08018482:
movs r0, 0
bl SetVBlankCallback
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
bl remove_some_task
@ -32618,7 +32618,7 @@ sub_801A43C: @ 801A43C
bl InitWindows
bl DeactivateAllTextPrinters
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl remove_some_task
bl m4aSoundVSyncOn
@ -33628,7 +33628,7 @@ _0801AD4C:
movs r0, 0x4
bl AllocZeroed
str r0, [r4]
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
movs r0, 0
@ -39768,7 +39768,7 @@ _0801DE74:
b _0801DF04
_0801DE7A:
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl sub_801F4D0
b _0801DEBC
@ -46018,7 +46018,7 @@ _080210BE:
.pool
_080210E4:
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
b _080212FC
_080210F2:
@ -53101,7 +53101,7 @@ _08024A16:
sub_8024A1C: @ 8024A1C
push {lr}
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
pop {r0}
bx r0
@ -65202,7 +65202,7 @@ _0802ACC8:
_0802ACE0:
movs r0, 0
bl SetVBlankCallback
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =sub_802BD84
movs r1, 0x5

View File

@ -227,7 +227,7 @@ _0812168E:
bl ResetTasks
b _081219D4
_08121694:
bl ResetAllObjectData
bl ResetSpriteData
b _081219D4
_0812169A:
bl ResetObjectPaletteAllocator

View File

@ -129,7 +129,7 @@ InitMainMenu: @ 802F6F4
bl LoadPalette
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
cmp r4, 0
beq _0802F7EC
@ -1930,7 +1930,7 @@ task_new_game_prof_birch_speech_1: @ 80307B0
movs r2, 0x10
bl LoadPalette
bl remove_some_task
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl dp13_810BB8C
adds r0, r4, 0
@ -3709,7 +3709,7 @@ new_game_prof_birch_speech_part2_start: @ 8031678
ldr r0, =0x0000ffc4
strh r0, [r4, 0x10]
bl remove_some_task
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl dp13_810BB8C
adds r0, r5, 0

View File

@ -36,7 +36,7 @@ _08178968:
sub_8178974: @ 8178974
push {r4,lr}
sub sp, 0x8
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
ldr r0, =sub_8178944

View File

@ -104,7 +104,7 @@ _080E2E58:
bl ResetPaletteFade
b _080E2E86
_080E2E5E:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
b _080E2E86
_080E2E68:

View File

@ -212,7 +212,7 @@ _080BA69C:
bl ResetPaletteFade
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
ldr r1, =gMain
movs r0, 0x87
lsls r0, 3

View File

@ -84,7 +84,7 @@ _08179C20:
b _08179D30
.pool
_08179C34:
bl ResetAllObjectData
bl ResetSpriteData
ldr r1, =gMain
movs r2, 0x87
lsls r2, 3
@ -781,7 +781,7 @@ sub_817A2C0: @ 817A2C0
ands r0, r1
cmp r0, 0
bne _0817A304
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =gMPlay_BGM
ldr r1, =0x0000ffff

View File

@ -381,7 +381,7 @@ _080BB582:
_080BB5FC:
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetPaletteFade
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
@ -2136,7 +2136,7 @@ _080BC682:
b _080BC838
.pool
_080BC6CC:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
movs r0, 0x8
@ -9937,7 +9937,7 @@ _080C0A60:
bne _080C0A7E
movs r0, 0
bl ClearGpuRegBits
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
movs r0, 0x8

View File

@ -1287,7 +1287,7 @@ _0813D45C:
.4byte _0813D544
.4byte _0813D56C
_0813D48C:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0x3
bl HideBg

View File

@ -3378,7 +3378,7 @@ _081246E4:
.pool
_08124754:
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl FreeSpriteTileRanges
bl ResetObjectPaletteAllocator
b _0812489C

View File

@ -889,7 +889,7 @@ _0809EFCA:
bl LoadOamFromSprites
bl remove_some_task
bl dp12_8087EA4
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetPaletteFade
bl sub_809F048

View File

@ -131,7 +131,7 @@ _080A9444:
bl sub_8035AA4
b _080A95D2
_080A944A:
bl ResetAllObjectData
bl ResetSpriteData
b _080A95D2
_080A9450:
bl ResetObjectPaletteAllocator

View File

@ -4292,7 +4292,7 @@ sub_8086988: @ 8086988
push {r4,lr}
adds r4, r0, 0
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetPaletteFade
bl dp12_8087EA4
bl dp13_810BB8C

View File

@ -681,7 +681,7 @@ _08135A0E:
b _08135BA6
.pool
_08135A30:
bl ResetAllObjectData
bl ResetSpriteData
b _08135B9E
_08135A36:
ldr r0, =gUnknown_0203AB50
@ -1994,7 +1994,7 @@ _0813655A:
adds r1, r4, 0
bl sub_81AE6C8
bl sub_8136418
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, [r6]
movs r1, 0x80
@ -3503,7 +3503,7 @@ c2_change_map: @ 8137200
ldr r0, [r1, 0x8]
bl ResetPaletteFade
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
ldr r3, =0x04000208
ldrh r2, [r3]
strh r4, [r3]

View File

@ -1275,7 +1275,7 @@ sub_80355F8: @ 80355F8
thumb_func_start sub_8035608
sub_8035608: @ 8035608
push {lr}
bl ResetAllObjectData
bl ResetSpriteData
ldr r0, =gUnknown_0831AC88
movs r1, 0
movs r2, 0
@ -3240,7 +3240,7 @@ _080368BE:
_080368FE:
bl c2_berry_program_update_menu
bl sub_8035AA4
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl sub_8036154
bl ResetObjectPaletteAllocator
@ -7445,7 +7445,7 @@ _08038E1A:
movs r2, 0x40
bl LoadCompressedPalette
bl sub_803570C
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl sub_8036154
movs r0, 0x4A
@ -7923,7 +7923,7 @@ _080392FE:
adds r4, 0x1
cmp r4, 0x1
ble _080392FE
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
@ -16426,7 +16426,7 @@ sub_803DE40: @ 803DE40
ands r0, r1
cmp r0, 0
bne _0803DE86
bl ResetAllObjectData
bl ResetSpriteData
ldr r0, =gUnknown_03005D54
ldrb r0, [r0]
cmp r0, 0

View File

@ -1850,7 +1850,7 @@ sub_80C7E98: @ 80C7E98
push {r4,lr}
sub sp, 0x4
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl FreeSpriteTileRanges
bl ResetObjectPaletteAllocator
bl ClearDma3Requests

View File

@ -281,7 +281,7 @@ sub_813C80C: @ 813C80C
push {lr}
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetPaletteFade
bl ResetObjectPaletteAllocator
pop {r0}

View File

@ -15155,7 +15155,7 @@ _08160688:
thumb_func_start sub_81606A0
sub_81606A0: @ 81606A0
push {r4-r6,lr}
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
bl clear_scheduled_bg_copies_to_vram
@ -15209,7 +15209,7 @@ sub_81606A0: @ 81606A0
thumb_func_start sub_8160740
sub_8160740: @ 8160740
push {r4,r5,lr}
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
bl clear_scheduled_bg_copies_to_vram
@ -16000,7 +16000,7 @@ sub_8160EA0: @ 8160EA0
bl Free
movs r0, 0
str r0, [r4]
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
pop {r4}
pop {r0}
@ -26005,7 +26005,7 @@ _081663E8:
b _0816653C
.pool
_0816640C:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
b _0816653C
_08166416:

View File

@ -21261,7 +21261,7 @@ _08190508:
movs r1, 0x3F
bl SetGpuReg
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
movs r0, 0x4
@ -28491,7 +28491,7 @@ _0819431C:
movs r1, 0x3F
bl SetGpuReg
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gTasks
mov r3, r8
@ -40888,7 +40888,7 @@ _0819A5C0:
.pool
_0819A69C:
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetObjectPaletteAllocator
ldr r0, =gUnknown_08DC0754
@ -47344,7 +47344,7 @@ _0819DCD4:
.pool
_0819DDA8:
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetObjectPaletteAllocator
bl dp13_810BB8C
@ -72397,7 +72397,7 @@ _081AAE56:
b _081AB01A
.pool
_081AAE78:
bl ResetAllObjectData
bl ResetSpriteData
b _081AB012
_081AAE7E:
movs r0, 0x87
@ -73639,7 +73639,7 @@ _081AB984:
bl SetMainCallback2
_081AB98A:
bl sub_81AB824
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl free_bag_item_list_buffers
adds r0, r5, 0
@ -82414,7 +82414,7 @@ _081B02B2:
b _081B048C
.pool
_081B02D4:
bl ResetAllObjectData
bl ResetSpriteData
b _081B0484
_081B02DA:
bl ResetObjectPaletteAllocator
@ -84392,7 +84392,7 @@ _081B1338:
ldr r0, [r4]
bl SetMainCallback2
_081B133E:
bl ResetAllObjectData
bl ResetSpriteData
bl sub_81B06F4
adds r0, r5, 0
bl DestroyTask

View File

@ -7979,7 +7979,7 @@ sub_81BF384: @ 81BF384
bl m4aSoundVSyncOff
movs r0, 0
bl SetVBlankCallback
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl remove_some_task
movs r0, 0
@ -8869,7 +8869,7 @@ _081BFBBC:
b _081BFDE4
.pool
_081BFBD0:
bl ResetAllObjectData
bl ResetSpriteData
ldr r1, =gMain
movs r0, 0x87
lsls r0, 3
@ -9824,7 +9824,7 @@ sub_81C0484: @ 81C0484
ldrb r0, [r0]
strb r0, [r1]
bl sub_81C4898
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl sub_80A369C
ldr r0, =gMPlay_BGM
@ -18627,7 +18627,7 @@ _081C50FA:
b _081C51A0
.pool
_081C510C:
bl ResetAllObjectData
bl ResetSpriteData
b _081C51A2
_081C5112:
bl sub_81221AC
@ -19859,7 +19859,7 @@ _081C5B94:
bl SetMainCallback2
_081C5B9E:
bl sub_81C56CC
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl FreeAllWindowBuffers
ldr r0, =gUnknown_0203CF2C
@ -22520,7 +22520,7 @@ _081C72F0:
movs r0, 0x1
strh r0, [r1, 0x8]
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
movs r0, 0
bl SetVBlankCallback
@ -23019,7 +23019,7 @@ sub_81C76C4: @ 81C76C4
adds r4, r0, 0
cmp r4, 0
beq _081C76F4
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =sub_81C7764
movs r1, 0x1
@ -53538,7 +53538,7 @@ sub_81D6774: @ 81D6774
bl remove_some_task
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
movs r0, 0
movs r1, 0xF0
@ -53595,7 +53595,7 @@ sub_81D6800: @ 81D6800
ands r0, r1
cmp r0, 0
bne _081D6830
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r4, =gUnknown_0203CF60
ldr r0, [r4]
@ -55265,7 +55265,7 @@ sub_81D7600: @ 81D7600
movs r0, 0
bl SetVBlankCallback
bl remove_some_task
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
strh r4, [r5]
adds r0, r7, 0
@ -56629,7 +56629,7 @@ sub_81D8164: @ 81D8164
bne _081D8192
movs r0, 0
bl SetVBlankCallback
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =gTasks
lsls r1, r4, 2
@ -57191,7 +57191,7 @@ sub_81D8684: @ 81D8684
bl SetVBlankCallback
movs r0, 0
bl SetHBlankCallback
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =gTasks
lsls r1, r4, 2
@ -58291,7 +58291,7 @@ sub_81D9034: @ 81D9034
movs r0, 0
bl SetVBlankCallback
bl sub_81D6904
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldrb r0, [r4, 0x4]
bl DestroyTask

View File

@ -442,7 +442,7 @@ _08140630:
.pool
_08140650:
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl reset_temp_tile_data_buffers
b _081407F8
@ -3271,7 +3271,7 @@ sub_8141E7C: @ 8141E7C
bl SetGpuReg
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl sub_8140418
ldr r1, =gUnknown_03005DAC
ldr r0, =sub_80AF168

View File

@ -226,7 +226,7 @@ _08178FF8:
adds r2, r5, 0
bl SetWindowAttribute
bl DeactivateAllTextPrinters
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetPaletteFade
ldr r0, =gUnknown_085B0A00

View File

@ -452,7 +452,7 @@ _080DFE20:
bl reset_temp_tile_data_buffers
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl clear_scheduled_bg_copies_to_vram
ldr r4, =gUnknown_02039F70

View File

@ -569,7 +569,7 @@ _0812A934:
sub_812A9AC: @ 812A9AC
push {lr}
bl ResetPaletteFade
bl ResetAllObjectData
bl ResetSpriteData
ldr r1, =gOamLimit
movs r0, 0x80
strb r0, [r1]

View File

@ -5,514 +5,6 @@
.text
thumb_func_start ResetAllObjectData
@ void ResetAllObjectData()
ResetAllObjectData: @ 8006974
push {r4,lr}
movs r0, 0
movs r1, 0x80
bl ResetOamRange
bl ResetAllSprites
bl ClearSpriteCopyRequests
bl ResetAffineAnimData
bl FreeSpriteTileRanges
ldr r1, =gOamLimit
movs r0, 0x40
strb r0, [r1]
ldr r0, =gReservedSpriteTileCount
movs r4, 0
strh r4, [r0]
movs r0, 0
bl AllocSpriteTiles
ldr r0, =gSpriteCoordOffsetX
strh r4, [r0]
ldr r0, =gSpriteCoordOffsetY
strh r4, [r0]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end ResetAllObjectData
thumb_func_start AnimateSprites
@ void AnimateSprites()
AnimateSprites: @ 80069C0
push {r4-r7,lr}
movs r6, 0
movs r7, 0x1
_080069C6:
lsls r0, r6, 4
adds r0, r6
lsls r0, 2
ldr r1, =gSprites
adds r4, r0, r1
adds r5, r4, 0
adds r5, 0x3E
ldrb r1, [r5]
adds r0, r7, 0
ands r0, r1
cmp r0, 0
beq _080069F6
ldr r1, [r4, 0x1C]
adds r0, r4, 0
bl _call_via_r1
ldrb r1, [r5]
adds r0, r7, 0
ands r0, r1
cmp r0, 0
beq _080069F6
adds r0, r4, 0
bl AnimateSprite
_080069F6:
adds r0, r6, 0x1
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0x3F
bls _080069C6
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end AnimateSprites
thumb_func_start BuildOamBuffer
@ void BuildOamBuffer()
BuildOamBuffer: @ 8006A0C
push {r4,r5,lr}
bl UpdateOamCoords
bl BuildSpritePriorities
bl SortSprites
ldr r5, =gMain
ldr r0, =0x00000439
adds r5, r0
ldrb r0, [r5]
lsls r4, r0, 31
lsrs r4, 31
movs r1, 0x1
orrs r0, r1
strb r0, [r5]
bl AddSpritesToOamBuffer
bl CopyMatricesToOamBuffer
movs r2, 0x1
ldrb r1, [r5]
movs r0, 0x2
negs r0, r0
ands r0, r1
orrs r4, r0
strb r4, [r5]
ldr r0, =gShouldProcessSpriteCopyRequests
strb r2, [r0]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end BuildOamBuffer
thumb_func_start UpdateOamCoords
@ void UpdateOamCoords()
UpdateOamCoords: @ 8006A58
push {r4-r7,lr}
movs r4, 0
ldr r7, =gSprites
ldr r0, =0x000001ff
adds r5, r0, 0
ldr r6, =0xfffffe00
_08006A64:
lsls r0, r4, 4
adds r0, r4
lsls r0, 2
adds r3, r0, r7
adds r0, r3, 0
adds r0, 0x3E
ldrb r1, [r0]
movs r0, 0x5
ands r0, r1
cmp r0, 0x1
bne _08006B0A
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _08006AD8
movs r2, 0x20
ldrsh r1, [r3, r2]
movs r2, 0x24
ldrsh r0, [r3, r2]
adds r1, r0
adds r0, r3, 0
adds r0, 0x28
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
adds r1, r0
ldr r0, =gSpriteCoordOffsetX
movs r2, 0
ldrsh r0, [r0, r2]
adds r1, r0
ands r1, r5
ldrh r2, [r3, 0x2]
adds r0, r6, 0
ands r0, r2
orrs r0, r1
strh r0, [r3, 0x2]
ldrh r1, [r3, 0x26]
ldrh r0, [r3, 0x22]
adds r1, r0
adds r0, r3, 0
adds r0, 0x29
ldrb r0, [r0]
ldr r2, =gSpriteCoordOffsetY
adds r0, r1
ldrb r2, [r2]
adds r0, r2
b _08006B08
.pool
_08006AD8:
movs r2, 0x20
ldrsh r1, [r3, r2]
movs r2, 0x24
ldrsh r0, [r3, r2]
adds r1, r0
adds r0, r3, 0
adds r0, 0x28
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
adds r1, r0
ands r1, r5
ldrh r2, [r3, 0x2]
adds r0, r6, 0
ands r0, r2
orrs r0, r1
strh r0, [r3, 0x2]
ldrh r1, [r3, 0x26]
ldrh r0, [r3, 0x22]
adds r1, r0
adds r0, r3, 0
adds r0, 0x29
ldrb r0, [r0]
adds r0, r1
_08006B08:
strb r0, [r3]
_08006B0A:
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x3F
bls _08006A64
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end UpdateOamCoords
thumb_func_start BuildSpritePriorities
@ void BuildSpritePriorities()
BuildSpritePriorities: @ 8006B1C
push {r4,lr}
movs r2, 0
ldr r4, =gSprites
ldr r3, =gSpritePriorities
_08006B24:
lsls r0, r2, 4
adds r0, r2
lsls r0, 2
adds r0, r4
adds r1, r0, 0
adds r1, 0x43
ldrb r1, [r1]
ldrb r0, [r0, 0x5]
lsls r0, 28
lsrs r0, 30
lsls r0, 8
orrs r1, r0
lsls r0, r2, 1
adds r0, r3
strh r1, [r0]
adds r0, r2, 0x1
lsls r0, 16
lsrs r2, r0, 16
cmp r2, 0x3F
bls _08006B24
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end BuildSpritePriorities
thumb_func_start SortSprites
@ void SortSprites()
SortSprites: @ 8006B5C
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x4
movs r0, 0x1
mov r12, r0
ldr r1, =gSpriteOrder
mov r10, r1
ldr r3, =0xffffff00
mov r9, r3
ldr r6, =0xc0000300
mov r8, r6
_08006B78:
mov r5, r12
mov r0, r12
subs r0, 0x1
add r0, r10
ldrb r2, [r0]
lsls r0, r2, 4
adds r0, r2
lsls r0, 2
ldr r7, =gSprites
adds r3, r0, r7
mov r0, r12
add r0, r10
ldrb r1, [r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r4, r0, r7
lsls r2, 1
ldr r0, =gSpritePriorities
adds r2, r0
ldrh r2, [r2]
str r2, [sp]
lsls r1, 1
adds r1, r0
ldrh r6, [r1]
ldrb r1, [r3]
ldrb r2, [r4]
adds r0, r1, 0
cmp r0, 0x9F
ble _08006BBA
add r0, r9
lsls r0, 16
lsrs r1, r0, 16
_08006BBA:
lsls r0, r2, 16
asrs r0, 16
cmp r0, 0x9F
ble _08006BC8
add r0, r9
lsls r0, 16
lsrs r2, r0, 16
_08006BC8:
ldr r0, [r3]
mov r7, r8
ands r0, r7
cmp r0, r8
bne _08006BEC
ldrb r0, [r3, 0x1]
lsrs r0, 6
cmp r0, 0
beq _08006BDE
cmp r0, 0x2
bne _08006BEC
_08006BDE:
lsls r0, r1, 16
asrs r0, 16
cmp r0, 0x80
ble _08006BEC
add r0, r9
lsls r0, 16
lsrs r1, r0, 16
_08006BEC:
ldr r0, [r4]
mov r3, r8
ands r0, r3
cmp r0, r8
bne _08006C10
ldrb r0, [r4, 0x1]
lsrs r0, 6
cmp r0, 0
beq _08006C02
cmp r0, 0x2
bne _08006C10
_08006C02:
lsls r0, r2, 16
asrs r0, 16
cmp r0, 0x80
ble _08006C10
add r0, r9
lsls r0, 16
lsrs r2, r0, 16
_08006C10:
movs r7, 0x1
add r12, r7
cmp r5, 0
beq _08006CF6
ldr r0, [sp]
cmp r0, r6
bhi _08006C38
cmp r0, r6
bne _08006CF6
b _08006CEE
.pool
_08006C38:
mov r1, r10
adds r3, r5, r1
ldrb r4, [r3]
subs r2, r5, 0x1
adds r1, r2, r1
ldrb r0, [r1]
strb r0, [r3]
strb r4, [r1]
lsls r2, 24
lsrs r5, r2, 24
subs r0, r5, 0x1
add r0, r10
ldrb r2, [r0]
lsls r0, r2, 4
adds r0, r2
lsls r0, 2
ldr r6, =gSprites
adds r3, r0, r6
mov r7, r10
adds r0, r5, r7
ldrb r1, [r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r4, r0, r6
lsls r2, 1
ldr r0, =gSpritePriorities
adds r2, r0
ldrh r2, [r2]
str r2, [sp]
lsls r1, 1
adds r1, r0
ldrh r6, [r1]
ldrb r1, [r3]
ldrb r2, [r4]
adds r0, r1, 0
cmp r0, 0x9F
ble _08006C8A
add r0, r9
lsls r0, 16
lsrs r1, r0, 16
_08006C8A:
lsls r0, r2, 16
asrs r0, 16
cmp r0, 0x9F
ble _08006C98
add r0, r9
lsls r0, 16
lsrs r2, r0, 16
_08006C98:
ldr r0, [r3]
mov r7, r8
ands r0, r7
cmp r0, r8
bne _08006CBC
ldrb r0, [r3, 0x1]
lsrs r0, 6
cmp r0, 0
beq _08006CAE
cmp r0, 0x2
bne _08006CBC
_08006CAE:
lsls r0, r1, 16
asrs r0, 16
cmp r0, 0x80
ble _08006CBC
add r0, r9
lsls r0, 16
lsrs r1, r0, 16
_08006CBC:
ldr r0, [r4]
mov r3, r8
ands r0, r3
cmp r0, r8
bne _08006CE0
ldrb r0, [r4, 0x1]
lsrs r0, 6
cmp r0, 0
beq _08006CD2
cmp r0, 0x2
bne _08006CE0
_08006CD2:
lsls r0, r2, 16
asrs r0, 16
cmp r0, 0x80
ble _08006CE0
add r0, r9
lsls r0, 16
lsrs r2, r0, 16
_08006CE0:
cmp r5, 0
beq _08006CF6
ldr r7, [sp]
cmp r7, r6
bhi _08006C38
cmp r7, r6
bne _08006CF6
_08006CEE:
lsls r1, 16
lsls r0, r2, 16
cmp r1, r0
blt _08006C38
_08006CF6:
mov r1, r12
lsls r0, r1, 24
lsrs r0, 24
mov r12, r0
cmp r0, 0x3F
bhi _08006D04
b _08006B78
_08006D04:
add sp, 0x4
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end SortSprites
thumb_func_start CopyMatricesToOamBuffer
@ void CopyMatricesToOamBuffer()
CopyMatricesToOamBuffer: @ 8006D1C
push {r4-r6,lr}
movs r4, 0
ldr r5, =gMain
ldr r6, =gOamMatrices
_08006D24:
lsls r2, r4, 2
lsls r1, r4, 5
adds r1, r5
lsls r3, r4, 3
adds r3, r6
ldrh r0, [r3]
strh r0, [r1, 0x3E]
adds r0, r2, 0x1
lsls r0, 3
adds r0, r5
ldrh r1, [r3, 0x2]
strh r1, [r0, 0x3E]
adds r0, r2, 0x2
lsls r0, 3
adds r0, r5
ldrh r1, [r3, 0x4]
strh r1, [r0, 0x3E]
adds r2, 0x3
lsls r2, 3
adds r2, r5
ldrh r0, [r3, 0x6]
strh r0, [r2, 0x3E]
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x1F
bls _08006D24
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end CopyMatricesToOamBuffer
thumb_func_start AddSpritesToOamBuffer
@ void AddSpritesToOamBuffer()
AddSpritesToOamBuffer: @ 8006D68

View File

@ -1938,7 +1938,7 @@ _080A045A:
b _080A04FC
.pool
_080A0490:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetTasks
bl ResetPaletteFade
bl dp12_8087EA4

View File

@ -147,7 +147,7 @@ set_256color_bg_bg0: @ 8133F0C
bl clear_scheduled_bg_copies_to_vram
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetPaletteFade
bl ResetObjectPaletteAllocator
bl dp13_810BB8C

View File

@ -616,7 +616,7 @@ _080AA8C4:
bl LZ77UnCompVram
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r1, =gUnknown_0300301C
movs r0, 0x9

View File

@ -175,7 +175,7 @@ sub_8077294: @ 8077294
sub_80772A4: @ 80772A4
push {r4,r5,lr}
sub sp, 0xC
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetTasks
bl ResetPaletteFade
@ -7272,7 +7272,7 @@ _0807AEC0:
str r0, [r4]
bl init_uns_table_pokemon_copy
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =sub_807AC24
bl SetVBlankCallback
@ -7731,7 +7731,7 @@ _0807B2D0:
str r0, [r4]
bl init_uns_table_pokemon_copy
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
ldr r0, =sub_807AC24
bl SetVBlankCallback

View File

@ -727,7 +727,7 @@ _080C2D36:
b _080C2DCC
.pool
_080C2D50:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
ldr r1, =gMain
@ -5320,7 +5320,7 @@ _080C54EE:
b _080C56F4
_080C54F4:
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
bl reset_temp_tile_data_buffers
@ -5603,7 +5603,7 @@ _080C57A6:
_080C57AC:
bl sub_80C50D0
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
b _080C57E4
_080C57BE:
@ -7196,7 +7196,7 @@ _080C6520:
bl sub_80C50D0
b _080C6694
_080C6526:
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
bl ResetPaletteFade
bl reset_temp_tile_data_buffers
@ -7434,7 +7434,7 @@ _080C676A:
.pool
_080C6774:
bl sub_80C50D0
bl ResetAllObjectData
bl ResetSpriteData
bl ResetObjectPaletteAllocator
b _080C67A4
_080C6782:

View File

@ -178,7 +178,7 @@ _08134906:
bl clear_scheduled_bg_copies_to_vram
bl remove_some_task
bl ResetTasks
bl ResetAllObjectData
bl ResetSpriteData
bl ResetPaletteFade
bl ResetObjectPaletteAllocator
ldr r0, =gUnknown_085B2208

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "sprite.h"
#include "main.h"
#define OAM_MATRIX_COUNT 32
@ -10,6 +11,56 @@ struct SpriteCopyRequest
u16 size;
};
// this file's functions
void UpdateOamCoords(void);
void BuildSpritePriorities(void);
void SortSprites(void);
void CopyMatricesToOamBuffer(void);
void AddSpritesToOamBuffer(void);
u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority);
void ClearSpriteCopyRequests(void);
void ResetOamMatrices(void);
void ResetSprite(struct Sprite *sprite);
s16 AllocSpriteTiles(u16 tileCount);
void RequestSpriteFrameImageCopy(u16 index, u16 tileNum, const struct SpriteFrameImage *images);
void ResetAllSprites(void);
void BeginAnim(struct Sprite *sprite);
void ContinueAnim(struct Sprite *sprite);
void AnimCmd_frame(struct Sprite *sprite);
void AnimCmd_end(struct Sprite *sprite);
void AnimCmd_jump(struct Sprite *sprite);
void AnimCmd_loop(struct Sprite *sprite);
void BeginAnimLoop(struct Sprite *sprite);
void ContinueAnimLoop(struct Sprite *sprite);
void JumpToTopOfAnimLoop(struct Sprite *sprite);
void BeginAffineAnim(struct Sprite *sprite);
void ContinueAffineAnim(struct Sprite *sprite);
void AffineAnimDelay(u8 matrixNum, struct Sprite *sprite);
void AffineAnimCmd_loop(u8 matrixNum, struct Sprite *sprite);
void BeginAffineAnimLoop(u8 matrixNum, struct Sprite *sprite);
void ContinueAffineAnimLoop(u8 matrixNum, struct Sprite *sprite);
void JumpToTopOfAffineAnimLoop(u8 matrixNum, struct Sprite *sprite);
void AffineAnimCmd_jump(u8 matrixNum, struct Sprite *sprite);
void AffineAnimCmd_end(u8 matrixNum, struct Sprite *sprite);
void AffineAnimCmd_frame(u8 matrixNum, struct Sprite *sprite);
void CopyOamMatrix(u8 destMatrixIndex, struct OamMatrix *srcMatrix);
u8 GetSpriteMatrixNum(struct Sprite *sprite);
void SetSpriteOamFlipBits(struct Sprite *sprite, u8 hFlip, u8 vFlip);
void AffineAnimStateRestartAnim(u8 matrixNum);
void AffineAnimStateStartAnim(u8 matrixNum, u8 animNum);
void AffineAnimStateReset(u8 matrixNum);
void ApplyAffineAnimFrameAbsolute(u8 matrixNum, struct AffineAnimFrameCmd *frameCmd);
void DecrementAnimDelayCounter(struct Sprite *sprite);
bool8 DecrementAffineAnimDelayCounter(struct Sprite *sprite, u8 matrixNum);
void ApplyAffineAnimFrameRelativeAndUpdateMatrix(u8 matrixNum, struct AffineAnimFrameCmd *frameCmd);
s16 ConvertScaleParam(s16 scale);
void GetAffineAnimFrame(u8 matrixNum, struct Sprite *sprite, struct AffineAnimFrameCmd *frameCmd);
void ApplyAffineAnimFrame(u8 matrixNum, struct AffineAnimFrameCmd *frameCmd);
void ResetAffineAnimData(void);
u8 IndexOfSpriteTileTag(u16 tag);
void AllocSpriteTileRange(u16 tag, u16 start, u16 count);
void DoLoadSpritePalette(const u16 *src, u16 paletteOffset);
EWRAM_DATA struct Sprite gSprites[MAX_SPRITES + 1] = {0};
EWRAM_DATA u16 gSpritePriorities[MAX_SPRITES] = {0};
EWRAM_DATA u8 gSpriteOrder[MAX_SPRITES] = {0};
@ -23,3 +74,188 @@ EWRAM_DATA s16 gSpriteCoordOffsetX = 0;
EWRAM_DATA s16 gSpriteCoordOffsetY = 0;
EWRAM_DATA struct OamMatrix gOamMatrices[OAM_MATRIX_COUNT] = {0};
EWRAM_DATA bool8 gAffineAnimsDisabled = 0;
void ResetSpriteData(void)
{
ResetOamRange(0, 128);
ResetAllSprites();
ClearSpriteCopyRequests();
ResetAffineAnimData();
FreeSpriteTileRanges();
gOamLimit = 64;
gReservedSpriteTileCount = 0;
AllocSpriteTiles(0);
gSpriteCoordOffsetX = 0;
gSpriteCoordOffsetY = 0;
}
void AnimateSprites(void)
{
u8 i;
for (i = 0; i < MAX_SPRITES; i++)
{
struct Sprite *sprite = &gSprites[i];
if (sprite->inUse)
{
sprite->callback(sprite);
if (sprite->inUse)
AnimateSprite(sprite);
}
}
}
void BuildOamBuffer(void)
{
u8 temp;
UpdateOamCoords();
BuildSpritePriorities();
SortSprites();
temp = gMain.oamLoadDisabled;
gMain.oamLoadDisabled = TRUE;
AddSpritesToOamBuffer();
CopyMatricesToOamBuffer();
gMain.oamLoadDisabled = temp;
gShouldProcessSpriteCopyRequests = TRUE;
}
void UpdateOamCoords(void)
{
u8 i;
for (i = 0; i < MAX_SPRITES; i++)
{
struct Sprite *sprite = &gSprites[i];
if (sprite->inUse && !sprite->invisible)
{
if (sprite->coordOffsetEnabled)
{
sprite->oam.x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
sprite->oam.y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
}
else
{
sprite->oam.x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX;
sprite->oam.y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY;
}
}
}
}
void BuildSpritePriorities(void)
{
u16 i;
for (i = 0; i < MAX_SPRITES; i++)
{
struct Sprite *sprite = &gSprites[i];
u16 priority = sprite->subpriority | (sprite->oam.priority << 8);
gSpritePriorities[i] = priority;
}
}
void SortSprites(void)
{
u8 i;
for (i = 1; i < MAX_SPRITES; i++)
{
u8 j = i;
struct Sprite *sprite1 = &gSprites[gSpriteOrder[i - 1]];
struct Sprite *sprite2 = &gSprites[gSpriteOrder[i]];
u16 sprite1Priority = gSpritePriorities[gSpriteOrder[i - 1]];
u16 sprite2Priority = gSpritePriorities[gSpriteOrder[i]];
s16 sprite1Y = sprite1->oam.y;
s16 sprite2Y = sprite2->oam.y;
if (sprite1Y >= DISPLAY_HEIGHT)
sprite1Y = sprite1Y - 256;
if (sprite2Y >= DISPLAY_HEIGHT)
sprite2Y = sprite2Y - 256;
if (sprite1->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite1->oam.size == 3)
{
u32 shape = sprite1->oam.shape;
if (shape == ST_OAM_SQUARE || shape == 2)
{
if (sprite1Y > 128)
sprite1Y = sprite1Y - 256;
}
}
if (sprite2->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite2->oam.size == 3)
{
u32 shape = sprite2->oam.shape;
if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE)
{
if (sprite2Y > 128)
sprite2Y = sprite2Y - 256;
}
}
while (j > 0
&& ((sprite1Priority > sprite2Priority)
|| (sprite1Priority == sprite2Priority && sprite1Y < sprite2Y)))
{
u8 temp = gSpriteOrder[j];
gSpriteOrder[j] = gSpriteOrder[j - 1];
gSpriteOrder[j - 1] = temp;
// UB: If j equals 1, then j-- makes j equal 0.
// Then, gSpriteOrder[-1] gets accessed below.
// Although this doesn't result in a bug in the ROM,
// the behavior is undefined.
j--;
sprite1 = &gSprites[gSpriteOrder[j - 1]];
sprite2 = &gSprites[gSpriteOrder[j]];
sprite1Priority = gSpritePriorities[gSpriteOrder[j - 1]];
sprite2Priority = gSpritePriorities[gSpriteOrder[j]];
sprite1Y = sprite1->oam.y;
sprite2Y = sprite2->oam.y;
if (sprite1Y >= DISPLAY_HEIGHT)
sprite1Y = sprite1Y - 256;
if (sprite2Y >= DISPLAY_HEIGHT)
sprite2Y = sprite2Y - 256;
if (sprite1->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite1->oam.size == 3)
{
u32 shape = sprite1->oam.shape;
if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE)
{
if (sprite1Y > 128)
sprite1Y = sprite1Y - 256;
}
}
if (sprite2->oam.affineMode == ST_OAM_AFFINE_DOUBLE
&& sprite2->oam.size == 3)
{
u32 shape = sprite2->oam.shape;
if (shape == ST_OAM_SQUARE || shape == ST_OAM_V_RECTANGLE)
{
if (sprite2Y > 128)
sprite2Y = sprite2Y - 256;
}
}
}
}
}
void CopyMatricesToOamBuffer(void)
{
u8 i;
for (i = 0; i < OAM_MATRIX_COUNT; i++)
{
u32 base = 4 * i;
gMain.oamBuffer[base + 0].affineParam = gOamMatrices[i].a;
gMain.oamBuffer[base + 1].affineParam = gOamMatrices[i].b;
gMain.oamBuffer[base + 2].affineParam = gOamMatrices[i].c;
gMain.oamBuffer[base + 3].affineParam = gOamMatrices[i].d;
}
}

View File

@ -15,9 +15,8 @@ extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese);
extern void audio_play(u16 songNum);
extern u8* sub_81AFC74(u8 a1);
extern struct Window gWindows[20];
EWRAM_DATA struct TextPrinter gTempTextPrinter = {};
EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {};
EWRAM_DATA struct TextPrinter gTempTextPrinter = {0};
EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0};
static u16 gFontHalfRowLookupTable[0x51];
static u16 gLastTextBgColor;

View File

@ -2,14 +2,7 @@ gTrainerId: @ 2020000
.space 0x4
.include "src/window.o"
.align 2
gTempTextPrinter: @ 202018C
.space 0x24
gTextPrinters: @ 20201B0
.space 0x480
.include "src/text.o"
.include "src/sprite.o"
.align 2