Start frontier pass

This commit is contained in:
DizzyEggg 2019-01-25 23:32:45 +01:00
parent 29b9483f39
commit 08a3533682
5 changed files with 453 additions and 865 deletions

View File

@ -8,867 +8,6 @@
thumb_func_start sub_80C51C4
sub_80C51C4: @ 80C51C4
push {lr}
bl sub_80C51F0
ldr r0, =sub_80C544C
bl SetMainCallback2
pop {r0}
bx r0
.pool
thumb_func_end sub_80C51C4
thumb_func_start sub_80C51D8
sub_80C51D8: @ 80C51D8
push {lr}
ldr r0, =gUnknown_02039CEC
ldr r0, [r0]
ldr r0, [r0]
bl SetMainCallback2
bl sub_80C52E4
pop {r0}
bx r0
.pool
thumb_func_end sub_80C51D8
thumb_func_start sub_80C51F0
sub_80C51F0: @ 80C51F0
push {r4-r6,lr}
adds r4, r0, 0
ldr r5, =gUnknown_02039CEC
ldr r0, [r5]
cmp r0, 0
beq _080C5204
movs r0, 0x1
b _080C52C8
.pool
_080C5204:
movs r0, 0x18
bl AllocZeroed
str r0, [r5]
cmp r0, 0
bne _080C5214
movs r0, 0x2
b _080C52C8
_080C5214:
str r4, [r0]
bl GetCurrentRegionMapSectionId
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x3A
beq _080C5232
cmp r4, 0xCA
beq _080C5232
ldr r0, [r5]
movs r1, 0xB0
strh r1, [r0, 0x8]
movs r1, 0x68
strh r1, [r0, 0xA]
b _080C5240
_080C5232:
ldr r2, =gUnknown_02039CEC
ldr r1, [r2]
movs r0, 0xB0
strh r0, [r1, 0x8]
movs r0, 0x30
strh r0, [r1, 0xA]
adds r5, r2, 0
_080C5240:
ldr r1, [r5]
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r2, =0x00000eb8
adds r0, r2
ldrh r0, [r0]
strh r0, [r1, 0x6]
bl CanCopyRecordedBattleSaveData
ldr r3, [r5]
movs r1, 0x1
ands r0, r1
ldrb r2, [r3, 0xE]
movs r1, 0x2
negs r1, r1
ands r1, r2
orrs r1, r0
strb r1, [r3, 0xE]
ldr r2, [r5]
ldrb r1, [r2, 0xE]
movs r0, 0xF
negs r0, r0
ands r0, r1
strb r0, [r2, 0xE]
bl CountPlayerTrainerStars
ldr r3, [r5]
lsls r0, 4
ldrb r2, [r3, 0xE]
movs r1, 0xF
ands r1, r2
orrs r1, r0
strb r1, [r3, 0xE]
movs r4, 0
adds r6, r5, 0
_080C5286:
lsls r5, r4, 1
ldr r1, =0x000008c4
adds r0, r5, r1
bl FlagGet
lsls r0, 24
cmp r0, 0
beq _080C52A2
ldr r1, [r6]
adds r1, 0xF
adds r1, r4
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
_080C52A2:
ldr r2, =0x000008c5
adds r0, r5, r2
bl FlagGet
lsls r0, 24
cmp r0, 0
beq _080C52BC
ldr r1, [r6]
adds r1, 0xF
adds r1, r4
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
_080C52BC:
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x6
bls _080C5286
movs r0, 0
_080C52C8:
pop {r4-r6}
pop {r1}
bx r1
.pool
thumb_func_end sub_80C51F0
thumb_func_start sub_80C52E4
sub_80C52E4: @ 80C52E4
push {r4,lr}
ldr r4, =gUnknown_02039CEC
ldr r0, [r4]
cmp r0, 0
beq _080C5308
movs r1, 0
movs r2, 0x18
bl memset
ldr r0, [r4]
bl Free
movs r0, 0
str r0, [r4]
b _080C530A
.pool
_080C5308:
movs r0, 0x1
_080C530A:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_80C52E4
thumb_func_start sub_80C5310
sub_80C5310: @ 80C5310
push {r4,lr}
ldr r4, =gUnknown_02039CF0
ldr r0, [r4]
cmp r0, 0
beq _080C5324
movs r0, 0x1
b _080C533A
.pool
_080C5324:
ldr r0, =0x00002434
bl AllocZeroed
str r0, [r4]
cmp r0, 0
beq _080C5338
movs r0, 0
b _080C533A
.pool
_080C5338:
movs r0, 0x2
_080C533A:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_80C5310
thumb_func_start sub_80C5340
sub_80C5340: @ 80C5340
push {r4,lr}
bl FreeAllWindowBuffers
ldr r4, =gUnknown_02039CF0
ldr r0, [r4]
cmp r0, 0
bne _080C5358
movs r0, 0x1
b _080C53A0
.pool
_080C5358:
ldr r0, [r0, 0x28]
cmp r0, 0
beq _080C5368
bl Free
ldr r1, [r4]
movs r0, 0
str r0, [r1, 0x28]
_080C5368:
ldr r0, [r4]
ldr r0, [r0, 0x24]
cmp r0, 0
beq _080C537A
bl Free
ldr r1, [r4]
movs r0, 0
str r0, [r1, 0x24]
_080C537A:
ldr r0, [r4]
ldr r0, [r0, 0x20]
cmp r0, 0
beq _080C538C
bl Free
ldr r1, [r4]
movs r0, 0
str r0, [r1, 0x20]
_080C538C:
ldr r0, [r4]
ldr r2, =0x00002434
movs r1, 0
bl memset
ldr r0, [r4]
bl Free
movs r0, 0
str r0, [r4]
_080C53A0:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sub_80C5340
thumb_func_start pokemon_details
pokemon_details: @ 80C53AC
push {r4-r7,lr}
sub sp, 0x10
ldr r0, =gUnknown_02039CF0
ldr r6, [r0]
adds r0, r6, 0
adds r0, 0x2C
ldrb r0, [r0]
cmp r0, 0
beq _080C5416
ldr r3, =gUnknown_085713E0
ldr r0, =gUnknown_02039CEC
ldr r0, [r0]
ldrb r4, [r0, 0xE]
lsls r4, 28
lsrs r0, r4, 29
subs r0, 0x1
lsls r0, 2
adds r0, r3
movs r2, 0
ldrsh r1, [r0, r2]
lsls r1, 8
lsrs r0, r4, 29
subs r0, 0x1
lsls r0, 2
adds r5, r3, 0x2
adds r0, r5
movs r7, 0
ldrsh r2, [r0, r7]
lsls r2, 8
lsrs r0, r4, 29
subs r0, 0x1
lsls r0, 2
adds r0, r3
movs r7, 0
ldrsh r3, [r0, r7]
lsrs r4, 29
subs r4, 0x1
lsls r4, 2
adds r4, r5
movs r5, 0
ldrsh r0, [r4, r5]
str r0, [sp]
movs r7, 0x2E
ldrsh r0, [r6, r7]
str r0, [sp, 0x4]
movs r4, 0x30
ldrsh r0, [r6, r4]
str r0, [sp, 0x8]
movs r0, 0
str r0, [sp, 0xC]
movs r0, 0x2
bl SetBgAffine
_080C5416:
bl LoadOam
bl ProcessSpriteCopyRequests
bl TransferPlttBuffer
add sp, 0x10
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end pokemon_details
thumb_func_start sub_80C5438
sub_80C5438: @ 80C5438
push {lr}
bl RunTasks
bl AnimateSprites
bl BuildOamBuffer
pop {r0}
bx r0
thumb_func_end sub_80C5438
thumb_func_start sub_80C544C
sub_80C544C: @ 80C544C
push {lr}
bl sub_80C5484
cmp r0, 0
beq _080C5464
ldr r0, =sub_80C5A48
movs r1, 0
bl CreateTask
ldr r0, =sub_80C5438
bl SetMainCallback2
_080C5464:
pop {r0}
bx r0
.pool
thumb_func_end sub_80C544C
thumb_func_start sub_80C5470
sub_80C5470: @ 80C5470
push {lr}
bl sub_80C570C
cmp r0, 0
beq _080C547E
bl sub_80C51D8
_080C547E:
pop {r0}
bx r0
thumb_func_end sub_80C5470
thumb_func_start sub_80C5484
sub_80C5484: @ 80C5484
push {r4,r5,lr}
sub sp, 0xC
movs r0, 0
str r0, [sp, 0x8]
ldr r0, =gUnknown_02039CEC
ldr r0, [r0]
ldrh r0, [r0, 0x4]
cmp r0, 0xA
bls _080C5498
b _080C56F4
_080C5498:
lsls r0, 2
ldr r1, =_080C54AC
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_080C54AC:
.4byte _080C54D8
.4byte _080C54EE
.4byte _080C54F4
.4byte _080C550A
.4byte _080C5510
.4byte _080C5560
.4byte _080C5570
.4byte _080C55D0
.4byte _080C5624
.4byte _080C5684
.4byte _080C56D0
_080C54D8:
movs r0, 0
bl SetVBlankCallback
bl ScanlineEffect_Stop
bl SetVBlankHBlankCallbacksToNull
movs r0, 0x2
bl DisableInterrupts
b _080C56F4
_080C54EE:
bl sub_80C50D0
b _080C56F4
_080C54F4:
bl ResetTasks
bl ResetSpriteData
bl FreeAllSpritePalettes
bl ResetPaletteFade
bl reset_temp_tile_data_buffers
b _080C56F4
_080C550A:
bl sub_80C5310
b _080C56F4
_080C5510:
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_085713E8
movs r0, 0x1
movs r2, 0x3
bl InitBgsFromTemplates
ldr r4, =gUnknown_02039CF0
ldr r1, [r4]
adds r1, 0x32
movs r0, 0x1
bl SetBgTilemapBuffer
ldr r1, [r4]
ldr r0, =0x00001032
adds r1, r0
movs r0, 0x2
bl SetBgTilemapBuffer
ldr r1, [r4]
ldr r0, =0x00002032
adds r1, r0
movs r0, 0x3
bl SetBgTilemapBuffer
movs r0, 0x2
movs r1, 0x6
movs r2, 0x1
bl SetBgAttribute
b _080C56F4
.pool
_080C5560:
ldr r0, =gUnknown_08571400
bl InitWindows
bl DeactivateAllTextPrinters
b _080C56F4
.pool
_080C5570:
ldr r0, =gUnknown_085712F8
add r1, sp, 0x8
bl malloc_and_decompress
ldr r4, =gUnknown_02039CF0
ldr r1, [r4]
str r0, [r1, 0x20]
ldr r0, =gUnknown_08571060
add r1, sp, 0x8
bl malloc_and_decompress
ldr r1, [r4]
str r0, [r1, 0x24]
ldr r0, =gUnknown_085712C0
add r1, sp, 0x8
bl malloc_and_decompress
ldr r1, [r4]
str r0, [r1, 0x28]
ldr r1, =gUnknown_08DE08C8
movs r4, 0
str r4, [sp]
movs r0, 0x1
movs r2, 0
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
ldr r1, =gUnknown_08DE2084
str r4, [sp]
movs r0, 0x2
movs r2, 0
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
b _080C56F4
.pool
_080C55D0:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
cmp r0, 0
beq _080C55DC
b _080C56FE
_080C55DC:
movs r5, 0x1E
str r5, [sp]
movs r4, 0x14
str r4, [sp, 0x4]
movs r0, 0
movs r1, 0
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect_Palette0
str r5, [sp]
str r4, [sp, 0x4]
movs r0, 0x1
movs r1, 0
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect_Palette0
str r5, [sp]
str r4, [sp, 0x4]
movs r0, 0x2
movs r1, 0
movs r2, 0
movs r3, 0
bl FillBgTilemapBufferRect_Palette0
movs r0, 0
bl CopyBgTilemapBufferToVram
movs r0, 0x1
bl CopyBgTilemapBufferToVram
movs r0, 0x2
bl CopyBgTilemapBufferToVram
b _080C56F4
_080C5624:
ldr r4, =gUnknown_08DE07C8
movs r2, 0xD0
lsls r2, 1
adds r0, r4, 0
movs r1, 0
bl LoadPalette
ldr r5, =gUnknown_02039CEC
ldr r0, [r5]
ldrb r0, [r0, 0xE]
lsrs r0, 4
lsls r0, 5
adds r4, 0x20
adds r0, r4
movs r1, 0x10
movs r2, 0x20
bl LoadPalette
movs r0, 0
bl stdpal_get
movs r1, 0xF0
movs r2, 0x20
bl LoadPalette
bl sub_80C629C
ldr r1, [r5]
ldrb r0, [r1, 0xC]
ldrb r1, [r1, 0xD]
bl sub_80C6104
ldr r5, [r5]
ldrb r0, [r5, 0xE]
movs r1, 0xE
ands r1, r0
cmp r1, 0x2
beq _080C5674
cmp r1, 0x4
bne _080C56F4
_080C5674:
movs r0, 0
strh r0, [r5, 0x4]
movs r0, 0x1
b _080C5700
.pool
_080C5684:
movs r1, 0x82
lsls r1, 5
movs r0, 0
bl SetGpuReg
movs r0, 0
bl ShowBg
movs r0, 0x1
bl ShowBg
movs r0, 0x2
bl ShowBg
bl sub_80C62DC
ldr r0, =pokemon_details
bl SetVBlankCallback
movs r4, 0x1
negs r4, r4
adds r0, r4, 0
movs r1, 0x10
movs r2, 0
bl BlendPalettes
movs r0, 0
str r0, [sp]
adds r0, r4, 0
movs r1, 0
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
b _080C56F4
.pool
_080C56D0:
bl AnimateSprites
bl BuildOamBuffer
bl UpdatePaletteFade
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0
bne _080C56FE
ldr r0, =gUnknown_02039CEC
ldr r0, [r0]
strh r1, [r0, 0x4]
movs r0, 0x1
b _080C5700
.pool
_080C56F4:
ldr r0, =gUnknown_02039CEC
ldr r1, [r0]
ldrh r0, [r1, 0x4]
adds r0, 0x1
strh r0, [r1, 0x4]
_080C56FE:
movs r0, 0
_080C5700:
add sp, 0xC
pop {r4,r5}
pop {r1}
bx r1
.pool
thumb_func_end sub_80C5484
thumb_func_start sub_80C570C
sub_80C570C: @ 80C570C
push {lr}
sub sp, 0x4
ldr r1, =gUnknown_02039CEC
ldr r0, [r1]
ldrh r0, [r0, 0x4]
adds r2, r1, 0
cmp r0, 0x5
bhi _080C57E4
lsls r0, 2
ldr r1, =_080C5730
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_080C5730:
.4byte _080C5748
.4byte _080C5770
.4byte _080C577C
.4byte _080C57A6
.4byte _080C57AC
.4byte _080C57BE
_080C5748:
ldr r0, [r2]
ldrb r0, [r0, 0xE]
movs r1, 0xE
ands r1, r0
cmp r1, 0x2
beq _080C576A
cmp r1, 0x4
beq _080C576A
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
b _080C57E4
_080C576A:
ldr r1, [r2]
movs r0, 0x2
b _080C57EC
_080C5770:
bl UpdatePaletteFade
lsls r0, 24
cmp r0, 0
beq _080C57E4
b _080C57EE
_080C577C:
movs r0, 0
movs r1, 0
bl SetGpuReg
movs r0, 0
bl HideBg
movs r0, 0x1
bl HideBg
movs r0, 0x2
bl HideBg
movs r0, 0
bl SetVBlankCallback
bl ScanlineEffect_Stop
bl SetVBlankHBlankCallbacksToNull
b _080C57E4
_080C57A6:
bl sub_80C63FC
b _080C57E4
_080C57AC:
bl sub_80C50D0
bl ResetTasks
bl ResetSpriteData
bl FreeAllSpritePalettes
b _080C57E4
_080C57BE:
movs r0, 0
bl UnsetBgTilemapBuffer
movs r0, 0x1
bl UnsetBgTilemapBuffer
movs r0, 0x2
bl UnsetBgTilemapBuffer
bl sub_80C5340
ldr r0, =gUnknown_02039CEC
ldr r1, [r0]
movs r0, 0
strh r0, [r1, 0x4]
movs r0, 0x1
b _080C57F0
.pool
_080C57E4:
ldr r0, =gUnknown_02039CEC
ldr r1, [r0]
ldrh r0, [r1, 0x4]
adds r0, 0x1
_080C57EC:
strh r0, [r1, 0x4]
_080C57EE:
movs r0, 0
_080C57F0:
add sp, 0x4
pop {r1}
bx r1
.pool
thumb_func_end sub_80C570C
thumb_func_start sub_80C57FC
sub_80C57FC: @ 80C57FC
push {r4-r7,lr}
lsls r0, 16
lsrs r6, r0, 16
movs r4, 0
ldr r7, =gUnknown_08571454
lsls r1, 16
asrs r5, r1, 16
_080C580A:
lsls r0, r4, 3
adds r3, r0, r7
movs r1, 0
ldrsh r0, [r3, r1]
cmp r0, r5
bgt _080C5854
movs r1, 0x2
ldrsh r0, [r3, r1]
cmp r0, r5
blt _080C5854
movs r0, 0x4
ldrsh r1, [r3, r0]
lsls r0, r6, 16
asrs r2, r0, 16
cmp r1, r2
bgt _080C5854
movs r1, 0x6
ldrsh r0, [r3, r1]
cmp r0, r2
blt _080C5854
cmp r4, 0x5
bls _080C5842
ldr r0, =gUnknown_02039CEC
ldr r0, [r0]
adds r0, r4
ldrb r0, [r0, 0x9]
cmp r0, 0
beq _080C585E
_080C5842:
adds r0, r4, 0x1
lsls r0, 24
lsrs r0, 24
b _080C5860
.pool
_080C5854:
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0xC
bls _080C580A
_080C585E:
movs r0, 0
_080C5860:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80C57FC
thumb_func_start sub_80C5868
sub_80C5868: @ 80C5868
push {lr}
bl sub_80C5484
cmp r0, 0
beq _080C58C6
ldr r1, =gUnknown_02039CEC
ldr r0, [r1]
ldrb r0, [r0, 0xE]
lsls r0, 28
lsrs r0, 29
cmp r0, 0x1
blt _080C58AC
cmp r0, 0x2
bgt _080C58AC
ldr r0, =sub_80C5BD8
movs r1, 0
bl CreateTask
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
movs r0, 0x1
strh r0, [r1, 0x8]
b _080C58C0
.pool
_080C58AC:
ldr r2, [r1]
ldrb r1, [r2, 0xE]
movs r0, 0xF
negs r0, r0
ands r0, r1
strb r0, [r2, 0xE]
ldr r0, =sub_80C5A48
movs r1, 0
bl CreateTask
_080C58C0:
ldr r0, =sub_80C5438
bl SetMainCallback2
_080C58C6:
pop {r0}
bx r0
.pool
thumb_func_end sub_80C5868
thumb_func_start sub_80C58D4
sub_80C58D4: @ 80C58D4
push {r4,lr}
ldr r4, =gUnknown_02039CF8
ldr r0, [r4]
bl sub_80C51F0
ldr r0, =gUnknown_02039CEC
ldr r1, [r0]
ldrh r0, [r4, 0x4]
strh r0, [r1, 0x8]
ldrh r0, [r4, 0x6]
strh r0, [r1, 0xA]
adds r0, r4, 0
movs r1, 0
movs r2, 0x8
bl memset
bl InBattlePyramid
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _080C5914
cmp r0, 0x2
beq _080C591C
bl Overworld_PlaySpecialMapMusic
b _080C5924
.pool
_080C5914:
ldr r0, =0x000001cd
b _080C5920
.pool
_080C591C:
movs r0, 0xE7
lsls r0, 1
_080C5920:
bl PlayBGM
_080C5924:
ldr r0, =sub_80C5868
bl SetMainCallback2
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_80C58D4
thumb_func_start sub_80C5934
sub_80C5934: @ 80C5934
push {lr}
@ -1269,7 +408,7 @@ _080C5C4C:
movs r0, 0x2
bl ShowBg
bl sub_80C62DC
ldr r0, =pokemon_details
ldr r0, =sub_80C53AC
bl SetVBlankCallback
movs r5, 0x1
negs r5, r5
@ -2385,7 +1524,7 @@ _080C6628:
movs r0, 0x2
bl ShowBg
bl sub_80C6974
ldr r0, =pokemon_details
ldr r0, =sub_80C53AC
bl SetVBlankCallback
movs r5, 0x1
negs r5, r5

View File

@ -61,7 +61,7 @@ s32 GetBgX(u8 bg);
s32 ChangeBgY(u8 bg, s32 value, u8 op);
s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op);
s32 GetBgY(u8 bg);
void SetBgAffine(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle);
void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle);
u8 Unused_AdjustBgMosaic(u8 a1, u8 a2);
void SetBgTilemapBuffer(u8 bg, void *tilemap);
void UnsetBgTilemapBuffer(u8 bg);

View File

@ -4860,4 +4860,9 @@ extern const u32 gUnknown_08DD228C[];
extern const u32 gUnknown_08DD2E5C[];
extern const u32 gUnknown_08DD1F78[];
// Frontier Pass
extern const u32 gUnknown_08DE08C8[];
extern const u32 gUnknown_08DE2084[];
extern const u16 gUnknown_08DE07C8[][16];
#endif //GUARD_GRAPHICS_H

View File

@ -1,7 +1,103 @@
#include "global.h"
#include "gpu_regs.h"
#include "main.h"
#include "trainer_card.h"
#include "event_data.h"
#include "recorded_battle.h"
#include "alloc.h"
#include "sprite.h"
#include "scanline_effect.h"
#include "text_window.h"
#include "task.h"
#include "graphics.h"
#include "palette.h"
#include "window.h"
#include "menu_helpers.h"
#include "menu.h"
#include "bg.h"
#include "sound.h"
#include "battle_pyramid.h"
#include "overworld.h"
#include "constants/battle_frontier.h"
#include "constants/rgb.h"
#include "constants/region_map_sections.h"
#include "constants/songs.h"
enum
{
CURSOR_AREA_NOTHING,
CURSOR_AREA_MAP,
CURSOR_AREA_CARD,
CURSOR_AREA_RECORD,
CURSOR_AREA_CANCEL,
CURSOR_AREA_POINTS,
CURSOR_AREA_EARNED_SYMBOLS, // The window.
CURSOR_AREA_SYMBOL, // All 7 symbols.
CURSOR_AREA_COUNT = CURSOR_AREA_SYMBOL + NUM_FRONTIER_FACILITIES,
};
struct FrontierPassData
{
void (*callback)(void);
u16 state;
u16 battlePoints;
s16 x;
s16 y;
u8 cursorArea;
u8 previousCursorArea;
u8 hasBattleRecord:1;
u8 unkE:3;
u8 trainerStars:4;
u8 facilitySymbols[NUM_FRONTIER_FACILITIES];
};
struct FrontierPassUnk
{
u32 unk0[8];
u8 *unk20;
u8 *unk24;
u8 *unk28;
bool8 unk2C;
s16 unk2E;
s16 unk30;
u8 tilemapBuff1[0x1000];
u8 tilemapBuff2[0x1000];
u8 tilemapBuff3[0x400];
};
struct FrontierPassSaved
{
void (*callback)(void);
s16 x;
s16 y;
};
extern struct FrontierPassData *gUnknown_02039CEC;
extern struct FrontierPassUnk *gUnknown_02039CF0;
extern struct FrontierPassSaved gUnknown_02039CF8;
// This file's functions.
u32 sub_80C51F0(void (*callback)(void));
void sub_80C544C(void);
void sub_80C629C(void);
void sub_80C63FC(void);
void sub_80C62DC(void);
u32 sub_80C52E4(void);
bool32 sub_80C5484(void);
bool32 sub_80C570C(void);
void sub_80C5A48(u8 taskId);
void sub_80C5BD8(u8 taskId);
void sub_80C6104(u8 cursorArea, u8 previousCursorArea);
// Const rom data.
extern const s16 gUnknown_085713E0[][2];
extern const struct BgTemplate gUnknown_085713E8[3];
extern const struct WindowTemplate gUnknown_08571400[];
extern const u32 gUnknown_085712F8[];
extern const u32 gUnknown_085712C0[];
extern const u32 gUnknown_08571060[];
// code
void sub_80C50D0(void)
{
SetGpuReg(REG_OFFSET_DISPCNT, 0);
@ -29,3 +125,351 @@ void sub_80C50D0(void)
CpuFill16(0, (void *)VRAM, VRAM_SIZE);
CpuFill32(0, (void *)OAM, OAM_SIZE);
}
void sub_80C51C4(void (*callback)(void))
{
sub_80C51F0(callback);
SetMainCallback2(sub_80C544C);
}
void sub_80C51D8(void)
{
SetMainCallback2(gUnknown_02039CEC->callback);
sub_80C52E4();
}
u32 sub_80C51F0(void (*callback)(void))
{
u8 i;
if (gUnknown_02039CEC != NULL)
return 1;
gUnknown_02039CEC = AllocZeroed(sizeof(*gUnknown_02039CEC));
if (gUnknown_02039CEC == NULL)
return 2;
gUnknown_02039CEC->callback = callback;
i = GetCurrentRegionMapSectionId();
if (i != MAPSEC_BATTLE_FRONTIER && i != MAPSEC_ARTISAN_CAVE)
{
gUnknown_02039CEC->x = 176;
gUnknown_02039CEC->y = 104;
}
else
{
gUnknown_02039CEC->x = 176;
gUnknown_02039CEC->y = 48;
}
gUnknown_02039CEC->battlePoints = gSaveBlock2Ptr->frontier.battlePoints;
gUnknown_02039CEC->hasBattleRecord = CanCopyRecordedBattleSaveData();
gUnknown_02039CEC->unkE = 0;
gUnknown_02039CEC->trainerStars = CountPlayerTrainerStars();
for (i = 0; i < 7; i++)
{
if (FlagGet(FLAG_SYS_TOWER_SILVER + i * 2))
gUnknown_02039CEC->facilitySymbols[i]++;
if (FlagGet(FLAG_SYS_TOWER_GOLD + i * 2))
gUnknown_02039CEC->facilitySymbols[i]++;
}
return 0;
}
u32 sub_80C52E4(void)
{
if (gUnknown_02039CEC == NULL)
return 1;
memset(gUnknown_02039CEC, 0, sizeof(*gUnknown_02039CEC)); // Why clear data, if it's going to be freed anyway?
FREE_AND_SET_NULL(gUnknown_02039CEC);
return 0;
}
u32 sub_80C5310(void)
{
if (gUnknown_02039CF0 != NULL)
return 1;
gUnknown_02039CF0 = AllocZeroed(sizeof(*gUnknown_02039CF0));
if (gUnknown_02039CF0 == NULL)
return 2;
return 0;
}
u32 sub_80C5340(void)
{
FreeAllWindowBuffers();
if (gUnknown_02039CF0 == NULL)
return 1;
if (gUnknown_02039CF0->unk28 != NULL)
FREE_AND_SET_NULL(gUnknown_02039CF0->unk28);
if (gUnknown_02039CF0->unk24 != NULL)
FREE_AND_SET_NULL(gUnknown_02039CF0->unk24);
if (gUnknown_02039CF0->unk20 != NULL)
FREE_AND_SET_NULL(gUnknown_02039CF0->unk20);
memset(gUnknown_02039CF0, 0, sizeof(*gUnknown_02039CF0)); // Why clear data, if it's going to be freed anyway?
FREE_AND_SET_NULL(gUnknown_02039CF0);
return 0;
}
void sub_80C53AC(void)
{
if (gUnknown_02039CF0->unk2C)
{
SetBgAffine(2,
gUnknown_085713E0[gUnknown_02039CEC->unkE - 1][0] << 8,
gUnknown_085713E0[gUnknown_02039CEC->unkE - 1][1] << 8,
gUnknown_085713E0[gUnknown_02039CEC->unkE - 1][0],
gUnknown_085713E0[gUnknown_02039CEC->unkE - 1][1],
gUnknown_02039CF0->unk2E,
gUnknown_02039CF0->unk30,
0);
}
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void sub_80C5438(void)
{
RunTasks();
AnimateSprites();
BuildOamBuffer();
}
void sub_80C544C(void)
{
if (sub_80C5484())
{
CreateTask(sub_80C5A48, 0);
SetMainCallback2(sub_80C5438);
}
}
void sub_80C5470(void)
{
if (sub_80C570C())
{
sub_80C51D8();
}
}
bool32 sub_80C5484(void)
{
u32 sizeOut = 0;
switch (gUnknown_02039CEC->state)
{
case 0:
SetVBlankCallback(NULL);
ScanlineEffect_Stop();
SetVBlankHBlankCallbacksToNull();
DisableInterrupts(INTR_FLAG_HBLANK);
break;
case 1:
sub_80C50D0();
break;
case 2:
ResetTasks();
ResetSpriteData();
FreeAllSpritePalettes();
ResetPaletteFade();
reset_temp_tile_data_buffers();
break;
case 3:
sub_80C5310();
break;
case 4:
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(1, gUnknown_085713E8, ARRAY_COUNT(gUnknown_085713E8));
SetBgTilemapBuffer(1, gUnknown_02039CF0->tilemapBuff1);
SetBgTilemapBuffer(2, gUnknown_02039CF0->tilemapBuff2);
SetBgTilemapBuffer(3, gUnknown_02039CF0->tilemapBuff3);
SetBgAttribute(2, BG_ATTR_WRAPAROUND, 1);
break;
case 5:
InitWindows(gUnknown_08571400);
DeactivateAllTextPrinters();
break;
case 6:
gUnknown_02039CF0->unk20 = malloc_and_decompress(gUnknown_085712F8, &sizeOut);
gUnknown_02039CF0->unk24 = malloc_and_decompress(gUnknown_08571060, &sizeOut);
gUnknown_02039CF0->unk28 = malloc_and_decompress(gUnknown_085712C0, &sizeOut);
decompress_and_copy_tile_data_to_vram(1, gUnknown_08DE08C8, 0, 0, 0);
decompress_and_copy_tile_data_to_vram(2, gUnknown_08DE2084, 0, 0, 0);
break;
case 7:
if (free_temp_tile_data_buffers_if_possible())
return FALSE;
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20);
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20);
FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 30, 20);
CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
break;
case 8:
LoadPalette(gUnknown_08DE07C8[0], 0, 0x1A0);
LoadPalette(gUnknown_08DE07C8[1 + gUnknown_02039CEC->trainerStars], 0x10, 0x20);
LoadPalette(stdpal_get(0), 0xF0, 0x20);
sub_80C629C();
sub_80C6104(gUnknown_02039CEC->cursorArea, gUnknown_02039CEC->previousCursorArea);
if (gUnknown_02039CEC->unkE == 1 || gUnknown_02039CEC->unkE == 2)
{
gUnknown_02039CEC->state = 0;
return TRUE;
}
break;
case 9:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(1);
ShowBg(2);
sub_80C62DC();
SetVBlankCallback(sub_80C53AC);
BlendPalettes(0xFFFFFFFF, 0x10, 0);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK);
break;
case 10:
AnimateSprites();
BuildOamBuffer();
if (UpdatePaletteFade())
return FALSE;
gUnknown_02039CEC->state = 0;
return TRUE;
}
gUnknown_02039CEC->state++;
return FALSE;
}
bool32 sub_80C570C(void)
{
switch (gUnknown_02039CEC->state)
{
case 0:
if (gUnknown_02039CEC->unkE != 1 && gUnknown_02039CEC->unkE != 2)
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
}
else
{
gUnknown_02039CEC->state = 2;
return FALSE;
}
break;
case 1:
if (UpdatePaletteFade())
return FALSE;
break;
case 2:
SetGpuReg(REG_OFFSET_DISPCNT, 0);
HideBg(0);
HideBg(1);
HideBg(2);
SetVBlankCallback(NULL);
ScanlineEffect_Stop();
SetVBlankHBlankCallbacksToNull();
break;
case 3:
sub_80C63FC();
break;
case 4:
sub_80C50D0();
ResetTasks();
ResetSpriteData();
FreeAllSpritePalettes();
break;
case 5:
UnsetBgTilemapBuffer(0);
UnsetBgTilemapBuffer(1);
UnsetBgTilemapBuffer(2);
sub_80C5340();
gUnknown_02039CEC->state = 0;
return TRUE;
}
gUnknown_02039CEC->state++;
return FALSE;
}
struct
{
s16 yStart;
s16 yEnd;
s16 xStart;
s16 xEnd;
}
extern const gUnknown_08571454[];
u8 sub_80C57FC(s16 x, s16 y)
{
u8 i;
// Minus/Plus 1, because the table doesn't take into account the nothing field.
for (i = 0; i < CURSOR_AREA_COUNT - 1; i++)
{
if (gUnknown_08571454[i].yStart <= y && gUnknown_08571454[i].yEnd >= y
&& gUnknown_08571454[i].xStart <= x && gUnknown_08571454[i].xEnd >= x)
{
if (i >= CURSOR_AREA_SYMBOL - 1 && gUnknown_02039CEC->facilitySymbols[i - CURSOR_AREA_SYMBOL + 1] == 0)
break;
return i + 1;
}
}
return 0;
}
void sub_80C5868(void)
{
u8 taskId;
if (!sub_80C5484())
return;
switch (gUnknown_02039CEC->unkE)
{
case 1:
case 2:
taskId = CreateTask(sub_80C5BD8, 0);
gTasks[taskId].data[0] = 1;
break;
case 3:
default:
gUnknown_02039CEC->unkE = 0;
taskId = CreateTask(sub_80C5A48, 0);
break;
}
SetMainCallback2(sub_80C5438);
}
void sub_80C58D4(void)
{
sub_80C51F0(gUnknown_02039CF8.callback);
gUnknown_02039CEC->x = gUnknown_02039CF8.x;
gUnknown_02039CEC->y = gUnknown_02039CF8.y;
memset(&gUnknown_02039CF8, 0, sizeof(gUnknown_02039CF8));
switch (InBattlePyramid())
{
case 1:
PlayBGM(MUS_PYRAMID);
break;
case 2:
PlayBGM(MUS_PYRAMID_TOP);
break;
default:
Overworld_PlaySpecialMapMusic();
break;
}
SetMainCallback2(sub_80C5868);
}

View File

@ -1590,7 +1590,7 @@ const u32 gUnknown_08DE0644[] = INCBIN_U32("graphics/title_screen/title_screen2.
// more trainer card stuff
const u16 gUnknown_08DE07C8[] = INCBIN_U16("graphics/frontier_pass/tiles.gbapal");// size in LoadPalette calls is reported as 0xD0 << 1, which is 0x1A0, but palette is only 0x100 bytes long so it loads garbage as well
const u16 gUnknown_08DE07C8[][16] = INCBIN_U16("graphics/frontier_pass/tiles.gbapal");// size in LoadPalette calls is reported as 0xD0 << 1, which is 0x1A0, but palette is only 0x100 bytes long so it loads garbage as well
const u32 gUnknown_08DE08C8[] = INCBIN_U32("graphics/frontier_pass/tiles.4bpp.lz");
const u32 gUnknown_08DE2084[] = INCBIN_U32("graphics/frontier_pass/tiles2.8bpp.lz");
const u32 gUnknown_08DE3060[] = INCBIN_U32("graphics/frontier_pass/tiles.bin.lz");