start decompiling berry tag screen

This commit is contained in:
DizzyEggg 2018-02-02 12:32:12 +01:00
parent eb6aed50e5
commit 14d2caaf8d
12 changed files with 512 additions and 860 deletions

View File

@ -5,824 +5,13 @@
.text
thumb_func_start sub_8177C14
sub_8177C14: @ 8177C14
push {r4,lr}
ldr r4, =gUnknown_0203BCF4
ldr r0, =0x0000180c
bl AllocZeroed
str r0, [r4]
ldr r0, =gSpecialVar_ItemId
ldrh r0, [r0]
bl ItemIdToBerryType
ldr r1, [r4]
lsls r0, 24
lsrs r0, 24
movs r2, 0xC0
lsls r2, 5
adds r1, r2
strh r0, [r1]
ldr r0, =sub_8177C84
bl SetMainCallback2
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8177C14
thumb_func_start sub_8177C54
sub_8177C54: @ 8177C54
push {lr}
bl RunTasks
bl AnimateSprites
bl BuildOamBuffer
bl do_scheduled_bg_tilemap_copies_to_vram
bl UpdatePaletteFade
pop {r0}
bx r0
thumb_func_end sub_8177C54
thumb_func_start sub_8177C70
sub_8177C70: @ 8177C70
push {lr}
bl LoadOam
bl ProcessSpriteCopyRequests
bl TransferPlttBuffer
pop {r0}
bx r0
thumb_func_end sub_8177C70
thumb_func_start sub_8177C84
sub_8177C84: @ 8177C84
push {lr}
_08177C86:
bl sub_81221EC
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _08177CAA
bl sub_8177CB0
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _08177CAA
bl sub_81221AC
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08177C86
_08177CAA:
pop {r0}
bx r0
thumb_func_end sub_8177C84
thumb_func_start sub_8177CB0
sub_8177CB0: @ 8177CB0
push {lr}
sub sp, 0x4
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
ldrb r0, [r0]
cmp r0, 0xF
bls _08177CC4
b _08177DF4
_08177CC4:
lsls r0, 2
ldr r1, =_08177CD8
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08177CD8:
.4byte _08177D18
.4byte _08177D26
.4byte _08177D2C
.4byte _08177D40
.4byte _08177D46
.4byte _08177D4C
.4byte _08177D5C
.4byte _08177D78
.4byte _08177D84
.4byte _08177D8A
.4byte _08177D90
.4byte _08177D96
.4byte _08177D9C
.4byte _08177DA6
.4byte _08177DB4
.4byte _08177DC2
_08177D18:
bl SetVBlankHBlankCallbacksToNull
bl ResetVramOamAndBgCntRegs
bl clear_scheduled_bg_copies_to_vram
b _08177DDC
_08177D26:
bl ScanlineEffect_Stop
b _08177DDC
_08177D2C:
bl ResetPaletteFade
ldr r2, =gPaletteFade
ldrb r0, [r2, 0x8]
movs r1, 0x80
orrs r0, r1
b _08177DDA
.pool
_08177D40:
bl ResetSpriteData
b _08177DDC
_08177D46:
bl FreeAllSpritePalettes
b _08177DDC
_08177D4C:
bl sub_81221AC
lsls r0, 24
cmp r0, 0
bne _08177DDC
bl ResetTasks
b _08177DDC
_08177D5C:
bl sub_8177E14
ldr r0, =gUnknown_0203BCF4
ldr r0, [r0]
ldr r1, =0x00001808
adds r0, r1
movs r1, 0
strh r1, [r0]
b _08177DDC
.pool
_08177D78:
bl sub_8177E88
lsls r0, 24
cmp r0, 0
beq _08177E0C
b _08177DDC
_08177D84:
bl sub_8178008
b _08177DDC
_08177D8A:
bl sub_8178090
b _08177DDC
_08177D90:
bl sub_81780F4
b _08177DDC
_08177D96:
bl sub_8178338
b _08177DDC
_08177D9C:
bl sub_817839C
bl sub_8178404
b _08177DDC
_08177DA6:
ldr r0, =sub_8178654
movs r1, 0
bl CreateTask
b _08177DDC
.pool
_08177DB4:
movs r0, 0x1
negs r0, r0
movs r1, 0x10
movs r2, 0
bl BlendPalettes
b _08177DDC
_08177DC2:
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
ldr r2, =gPaletteFade
ldrb r1, [r2, 0x8]
movs r0, 0x7F
ands r0, r1
_08177DDA:
strb r0, [r2, 0x8]
_08177DDC:
ldr r1, =gMain
movs r0, 0x87
lsls r0, 3
adds r1, r0
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
b _08177E0C
.pool
_08177DF4:
ldr r0, =sub_8177C70
bl SetVBlankCallback
ldr r0, =sub_8177C54
bl SetMainCallback2
movs r0, 0x1
b _08177E0E
.pool
_08177E0C:
movs r0, 0
_08177E0E:
add sp, 0x4
pop {r1}
bx r1
thumb_func_end sub_8177CB0
thumb_func_start sub_8177E14
sub_8177E14: @ 8177E14
push {r4,lr}
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_085EFCF0
movs r0, 0
movs r2, 0x4
bl InitBgsFromTemplates
ldr r4, =gUnknown_0203BCF4
ldr r1, [r4]
movs r0, 0x2
bl SetBgTilemapBuffer
ldr r1, [r4]
movs r0, 0x80
lsls r0, 4
adds r1, r0
movs r0, 0x3
bl SetBgTilemapBuffer
bl ResetAllBgsCoordinates
movs r0, 0x2
bl schedule_bg_copy_tilemap_to_vram
movs r0, 0x3
bl schedule_bg_copy_tilemap_to_vram
movs r1, 0x82
lsls r1, 5
movs r0, 0
bl SetGpuReg
movs r0, 0x50
movs r1, 0
bl SetGpuReg
movs r0, 0
bl ShowBg
movs r0, 0x1
bl ShowBg
movs r0, 0x2
bl ShowBg
movs r0, 0x3
bl ShowBg
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8177E14
thumb_func_start sub_8177E88
sub_8177E88: @ 8177E88
push {r4-r7,lr}
sub sp, 0x4
ldr r1, =gUnknown_0203BCF4
ldr r0, [r1]
ldr r2, =0x00001808
adds r0, r2
ldrh r0, [r0]
adds r7, r1, 0
cmp r0, 0x5
bls _08177E9E
b _08177FEC
_08177E9E:
lsls r0, 2
ldr r1, =_08177EB4
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08177EB4:
.4byte _08177ECC
.4byte _08177EF8
.4byte _08177F1C
.4byte _08177F3C
.4byte _08177FA8
.4byte _08177FC8
_08177ECC:
bl reset_temp_tile_data_buffers
ldr r1, =gUnknown_08D9BB44
movs r0, 0
str r0, [sp]
movs r0, 0x2
movs r2, 0
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
ldr r0, =gUnknown_0203BCF4
ldr r1, [r0]
ldr r0, =0x00001808
adds r1, r0
b _08177FD6
.pool
_08177EF8:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08177F06
b _08177FFC
_08177F06:
ldr r0, =gUnknown_08D9BF98
ldr r4, =gUnknown_0203BCF4
ldr r1, [r4]
bl LZDecompressWram
ldr r1, [r4]
b _08177FD2
.pool
_08177F1C:
ldr r0, =gUnknown_08D9C13C
ldr r1, [r7]
movs r2, 0x80
lsls r2, 5
adds r1, r2
bl LZDecompressWram
ldr r1, [r7]
ldr r0, =0x00001808
adds r1, r0
b _08177FD6
.pool
_08177F3C:
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldrb r0, [r0, 0x8]
cmp r0, 0
bne _08177F78
movs r2, 0
ldr r6, =gUnknown_0203BCF4
movs r5, 0x80
lsls r5, 4
ldr r4, =0x00004042
ldr r3, =0x000003ff
_08177F52:
ldr r0, [r6]
lsls r1, r2, 1
adds r0, r5
adds r0, r1
strh r4, [r0]
adds r0, r2, 0x1
lsls r0, 16
lsrs r2, r0, 16
cmp r2, r3
bls _08177F52
b _08177F98
.pool
_08177F78:
movs r2, 0
ldr r6, =gUnknown_0203BCF4
movs r5, 0x80
lsls r5, 4
ldr r4, =0x00005042
ldr r3, =0x000003ff
_08177F84:
ldr r0, [r6]
lsls r1, r2, 1
adds r0, r5
adds r0, r1
strh r4, [r0]
adds r0, r2, 0x1
lsls r0, 16
lsrs r2, r0, 16
cmp r2, r3
bls _08177F84
_08177F98:
ldr r1, [r7]
b _08177FD2
.pool
_08177FA8:
ldr r0, =gUnknown_08D9BEF0
movs r1, 0
movs r2, 0xC0
bl LoadCompressedPalette
ldr r0, =gUnknown_0203BCF4
ldr r1, [r0]
ldr r0, =0x00001808
adds r1, r0
b _08177FD6
.pool
_08177FC8:
ldr r0, =gUnknown_0857FDEC
bl LoadCompressedObjectPic
ldr r0, =gUnknown_0203BCF4
ldr r1, [r0]
_08177FD2:
ldr r2, =0x00001808
adds r1, r2
_08177FD6:
ldrh r0, [r1]
adds r0, 0x1
strh r0, [r1]
b _08177FFC
.pool
_08177FEC:
ldr r0, =gUnknown_0857FDF4
bl LoadCompressedObjectPalette
movs r0, 0x1
b _08177FFE
.pool
_08177FFC:
movs r0, 0
_08177FFE:
add sp, 0x4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8177E88
thumb_func_start sub_8178008
sub_8178008: @ 8178008
push {r4,lr}
ldr r0, =gUnknown_085EFD28
bl InitWindows
bl DeactivateAllTextPrinters
ldr r0, =gUnknown_085EFD00
movs r1, 0xF0
movs r2, 0x20
bl LoadPalette
movs r4, 0
_08178020:
lsls r0, r4, 24
lsrs r0, 24
bl PutWindowTilemap
adds r0, r4, 0x1
lsls r0, 16
lsrs r4, r0, 16
cmp r4, 0x3
bls _08178020
movs r0, 0
bl schedule_bg_copy_tilemap_to_vram
movs r0, 0x1
bl schedule_bg_copy_tilemap_to_vram
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8178008
thumb_func_start sub_817804C
sub_817804C: @ 817804C
push {r4-r6,lr}
sub sp, 0x14
ldr r6, [sp, 0x24]
ldr r5, [sp, 0x28]
lsls r0, 24
lsrs r0, 24
lsls r2, 24
lsrs r2, 24
lsls r3, 24
lsrs r3, 24
lsls r5, 24
lsrs r5, 24
movs r4, 0
str r4, [sp]
str r4, [sp, 0x4]
lsls r4, r5, 1
adds r4, r5
ldr r5, =gUnknown_085EFD20
adds r4, r5
str r4, [sp, 0x8]
lsls r6, 24
asrs r6, 24
str r6, [sp, 0xC]
str r1, [sp, 0x10]
movs r1, 0x1
bl AddTextPrinterParameterized2
add sp, 0x14
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_817804C
thumb_func_start sub_8178090
sub_8178090: @ 8178090
push {r4,lr}
sub sp, 0x8
movs r0, 0
bl GetBgTilemapBuffer
ldr r1, =gUnknown_0203BCF4
ldr r1, [r1]
movs r2, 0x80
lsls r2, 5
adds r1, r2
movs r2, 0x80
lsls r2, 4
bl memcpy
movs r0, 0x3
movs r1, 0xFF
bl FillWindowPixelBuffer
ldr r4, =gText_BerryTag
movs r0, 0x1
adds r1, r4, 0
movs r2, 0x40
bl GetStringCenterAlignXOffset
adds r2, r0, 0
lsls r2, 24
lsrs r2, 24
movs r0, 0
str r0, [sp]
movs r0, 0x1
str r0, [sp, 0x4]
movs r0, 0x3
adds r1, r4, 0
movs r3, 0x1
bl sub_817804C
movs r0, 0x3
bl PutWindowTilemap
movs r0, 0
bl schedule_bg_copy_tilemap_to_vram
add sp, 0x8
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8178090
thumb_func_start sub_81780F4
sub_81780F4: @ 81780F4
push {lr}
bl sub_8178110
bl sub_8178174
bl itemid_copy_name
bl sub_81782D0
bl sub_8178304
pop {r0}
bx r0
thumb_func_end sub_81780F4
thumb_func_start sub_8178110
sub_8178110: @ 8178110
push {r4-r6,lr}
sub sp, 0x8
ldr r5, =gUnknown_0203BCF4
ldr r0, [r5]
movs r4, 0xC0
lsls r4, 5
adds r0, r4
ldrb r0, [r0]
bl GetBerryInfo
adds r6, r0, 0
ldr r0, =gStringVar1
ldr r1, [r5]
adds r1, r4
ldrh r1, [r1]
movs r2, 0x2
movs r3, 0x2
bl ConvertIntToDecimalStringN
ldr r0, =gStringVar2
adds r1, r6, 0
bl StringCopy
ldr r4, =gStringVar4
ldr r1, =gText_UnkF908Var1Var2
adds r0, r4, 0
bl StringExpandPlaceholders
movs r0, 0
str r0, [sp]
str r0, [sp, 0x4]
adds r1, r4, 0
movs r2, 0
movs r3, 0x1
bl sub_817804C
add sp, 0x8
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_8178110
thumb_func_start sub_8178174
sub_8178174: @ 8178174
push {r4-r7,lr}
sub sp, 0xC
ldr r0, =gUnknown_0203BCF4
ldr r0, [r0]
movs r1, 0xC0
lsls r1, 5
adds r0, r1
ldrb r0, [r0]
bl GetBerryInfo
adds r4, r0, 0
ldr r2, =gText_SizeSlash
movs r7, 0x1
str r7, [sp]
movs r0, 0xFF
str r0, [sp, 0x4]
movs r6, 0
str r6, [sp, 0x8]
movs r0, 0x1
movs r1, 0x1
movs r3, 0
bl PrintTextOnWindow
ldrh r0, [r4, 0x8]
cmp r0, 0
beq _08178230
adds r1, r0, 0
lsls r0, r1, 5
subs r0, r1
lsls r0, 2
adds r0, r1
lsls r0, 3
movs r1, 0xFE
bl __divsi3
adds r5, r0, 0
movs r1, 0xA
bl __umodsi3
cmp r0, 0x4
bls _081781C8
adds r5, 0xA
_081781C8:
adds r0, r5, 0
movs r1, 0x64
bl __umodsi3
movs r1, 0xA
bl __udivsi3
adds r4, r0, 0
adds r0, r5, 0
movs r1, 0x64
bl __udivsi3
adds r5, r0, 0
ldr r0, =gStringVar1
adds r1, r5, 0
movs r2, 0
movs r3, 0x2
bl ConvertIntToDecimalStringN
ldr r0, =gStringVar2
adds r1, r4, 0
movs r2, 0
movs r3, 0x2
bl ConvertIntToDecimalStringN
ldr r4, =gStringVar4
ldr r1, =gText_Var1DotVar2
adds r0, r4, 0
bl StringExpandPlaceholders
str r7, [sp]
str r6, [sp, 0x4]
str r6, [sp, 0x8]
movs r0, 0x1
movs r1, 0x1
adds r2, r4, 0
movs r3, 0x28
bl PrintTextOnWindow
b _08178242
.pool
_08178230:
ldr r2, =gText_ThreeMarks
str r7, [sp]
str r0, [sp, 0x4]
str r0, [sp, 0x8]
movs r0, 0x1
movs r1, 0x1
movs r3, 0x28
bl PrintTextOnWindow
_08178242:
add sp, 0xC
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8178174
thumb_func_start itemid_copy_name
itemid_copy_name: @ 8178250
push {r4-r6,lr}
sub sp, 0xC
ldr r0, =gUnknown_0203BCF4
ldr r0, [r0]
movs r1, 0xC0
lsls r1, 5
adds r0, r1
ldrb r0, [r0]
bl GetBerryInfo
adds r6, r0, 0
ldr r2, =gText_FirmSlash
movs r5, 0x11
str r5, [sp]
movs r0, 0xFF
str r0, [sp, 0x4]
movs r4, 0
str r4, [sp, 0x8]
movs r0, 0x1
movs r1, 0x1
movs r3, 0
bl PrintTextOnWindow
ldrb r0, [r6, 0x7]
cmp r0, 0
beq _081782B0
ldr r0, =gBerryFirmnessStringPointers
ldrb r1, [r6, 0x7]
subs r1, 0x1
lsls r1, 2
adds r1, r0
ldr r2, [r1]
str r5, [sp]
str r4, [sp, 0x4]
str r4, [sp, 0x8]
movs r0, 0x1
movs r1, 0x1
movs r3, 0x28
bl PrintTextOnWindow
b _081782C2
.pool
_081782B0:
ldr r2, =gText_ThreeMarks
str r5, [sp]
str r0, [sp, 0x4]
str r0, [sp, 0x8]
movs r0, 0x1
movs r1, 0x1
movs r3, 0x28
bl PrintTextOnWindow
_081782C2:
add sp, 0xC
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end itemid_copy_name
thumb_func_start sub_81782D0
sub_81782D0: @ 81782D0
push {lr}
sub sp, 0xC
ldr r0, =gUnknown_0203BCF4
ldr r0, [r0]
movs r1, 0xC0
lsls r1, 5
adds r0, r1
ldrb r0, [r0]
bl GetBerryInfo
ldr r2, [r0, 0xC]
movs r0, 0x1
str r0, [sp]
movs r0, 0
str r0, [sp, 0x4]
str r0, [sp, 0x8]
movs r0, 0x2
movs r1, 0x1
movs r3, 0
bl PrintTextOnWindow
add sp, 0xC
pop {r0}
bx r0
.pool
thumb_func_end sub_81782D0
thumb_func_start sub_8178304
sub_8178304: @ 8178304
push {lr}
sub sp, 0xC
ldr r0, =gUnknown_0203BCF4
ldr r0, [r0]
movs r1, 0xC0
lsls r1, 5
adds r0, r1
ldrb r0, [r0]
bl GetBerryInfo
ldr r2, [r0, 0x10]
movs r0, 0x11
str r0, [sp]
movs r0, 0
str r0, [sp, 0x4]
str r0, [sp, 0x8]
movs r0, 0x2
movs r1, 0x1
movs r3, 0
bl PrintTextOnWindow
add sp, 0xC
pop {r0}
bx r0
.pool
thumb_func_end sub_8178304
thumb_func_start sub_8178338
sub_8178338: @ 8178338
push {r4,lr}
ldr r4, =gUnknown_0203BCF4
ldr r0, [r4]
movs r1, 0xC0
lsls r1, 5
adds r0, r1
ldrb r0, [r0]
subs r0, 0x1
lsls r0, 24
lsrs r0, 24
movs r1, 0x38
movs r2, 0x40
bl sub_80D50D4
ldr r1, [r4]
ldr r2, =0x00001802
adds r1, r2
strb r0, [r1]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8178338
thumb_func_start sub_817836C
sub_817836C: @ 817836C
push {lr}
ldr r0, =gUnknown_0203BCF4
ldr r0, =sBerryTag
ldr r0, [r0]
ldr r1, =0x00001802
adds r0, r1
@ -844,7 +33,7 @@ sub_817839C: @ 817839C
push {r4,lr}
movs r0, 0x40
bl sub_80D518C
ldr r4, =gUnknown_0203BCF4
ldr r4, =sBerryTag
ldr r1, [r4]
ldr r2, =0x00001803
adds r1, r2
@ -882,7 +71,7 @@ sub_817839C: @ 817839C
thumb_func_start sub_8178404
sub_8178404: @ 8178404
push {r4,r5,lr}
ldr r4, =gUnknown_0203BCF4
ldr r4, =sBerryTag
ldr r0, [r4]
movs r1, 0xC0
lsls r1, 5
@ -929,7 +118,7 @@ _08178462:
ldrb r0, [r5, 0x16]
cmp r0, 0
beq _0817849C
ldr r3, =gUnknown_0203BCF4
ldr r3, =sBerryTag
ldr r0, [r3]
ldr r1, =0x00001804
adds r0, r1
@ -946,7 +135,7 @@ _08178462:
b _081784B6
.pool
_0817849C:
ldr r3, =gUnknown_0203BCF4
ldr r3, =sBerryTag
ldr r0, [r3]
ldr r1, =0x00001804
adds r0, r1
@ -1071,7 +260,7 @@ sub_8178594: @ 8178594
push {r4,lr}
movs r4, 0
_08178598:
ldr r0, =gUnknown_0203BCF4
ldr r0, =sBerryTag
ldr r0, [r0]
ldr r1, =0x00001803
adds r0, r1
@ -1137,7 +326,7 @@ sub_8178610: @ 8178610
bne _08178642
bl sub_817836C
bl sub_8178594
ldr r0, =gUnknown_0203BCF4
ldr r0, =sBerryTag
ldr r0, [r0]
bl Free
bl FreeAllWindowBuffers
@ -1312,7 +501,7 @@ _0817877A:
lsls r0, 16
lsrs r0, 16
bl ItemIdToBerryType
ldr r1, =gUnknown_0203BCF4
ldr r1, =sBerryTag
ldr r1, [r1]
lsls r0, 24
lsrs r0, 24
@ -1445,7 +634,7 @@ _0817887E:
movs r0, 0x1
b _0817889A
_08178882:
bl itemid_copy_name
bl sub_8178250
b _081788A6
_08178888:
bl sub_8178174
@ -1476,7 +665,7 @@ _081788B8:
ldrh r5, [r6]
_081788BA:
ldr r2, =gSprites
ldr r3, =gUnknown_0203BCF4
ldr r3, =sBerryTag
ldr r0, [r3]
ldr r1, =0x00001802
adds r0, r1

View File

@ -527,8 +527,8 @@ _080D5082:
.pool
thumb_func_end sub_80D5070
thumb_func_start sub_80D50D4
sub_80D50D4: @ 80D50D4
thumb_func_start CreateBerryTagSprite
CreateBerryTagSprite: @ 80D50D4
push {r4,r5,lr}
adds r4, r1, 0
adds r5, r2, 0
@ -554,7 +554,7 @@ sub_80D50D4: @ 80D50D4
pop {r1}
bx r1
.pool
thumb_func_end sub_80D50D4
thumb_func_end CreateBerryTagSprite
thumb_func_start sub_80D510C
sub_80D510C: @ 80D510C

View File

@ -1,34 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnknown_085EFCF0:: @ 85EFCF0
.4byte 0x000001f0, 0x000011e1, 0x000021d2, 0x000031c3
.align 2
gUnknown_085EFD00:: @ 85EFD00
.incbin "graphics/interface/berry_tag_screen.gbapal"
.align 2
gUnknown_085EFD20:: @ 85EFD20 struct TextColor
.byte 0x00, 0x02, 0x03
.byte 0x0F, 0x0E, 0x0D
.align 2
gUnknown_085EFD28:: @ 85EFD28
window_template 0x01, 0x0b, 0x04, 0x08, 0x02, 0x0f, 0x0045
window_template 0x01, 0x0b, 0x07, 0x12, 0x04, 0x0f, 0x0055
window_template 0x01, 0x04, 0x0e, 0x19, 0x04, 0x0f, 0x009d
window_template 0x00, 0x02, 0x00, 0x08, 0x02, 0x0f, 0x0101
null_window_template
.align 2
gBerryFirmnessStringPointers:: @ 85EFD50
.4byte gBerryFirmnessString_VerySoft
.4byte gBerryFirmnessString_Soft
.4byte gBerryFirmnessString_Hard
.4byte gBerryFirmnessString_VeryHard
.4byte gBerryFirmnessString_SuperHard

View File

@ -0,0 +1,6 @@
#ifndef GUARD_BERRY_TAG_SCREEN_H
#define GUARD_BERRY_TAG_SCREEN_H
void BerryTagScreen_814625C(u8 taskId);
#endif // GUARD_BERRY_TAG_SCREEN_H

View File

@ -2654,6 +2654,12 @@ extern const u8 gBattleTerrainPalette_StadiumWallace[];
extern const u8 gPokedexMenu2_Gfx[];
extern const u8 gPokedexText_Pal[];
// berry tag screen
extern const u8 gUnknown_08D9BB44[];
extern const u8 gUnknown_08D9BF98[];
extern const u8 gUnknown_08D9C13C[];
extern const u8 gUnknown_08D9BEF0[];
// rayquaza scene gfx
extern const u8 gRaySceneGroudon_Gfx[];
extern const u8 gRaySceneGroudon2_Gfx[];

View File

@ -1,6 +1,10 @@
#ifndef GUARD_ITEM_MENU_ICONS
#define GUARD_ITEM_MENU_ICONS
extern const struct CompressedSpriteSheet gUnknown_0857FDEC;
extern const struct CompressedSpritePalette gUnknown_0857FDF4;
u8 sub_80D511C(u8 a0, u8 a1, u8 a2, u8 a3);
u8 CreateBerryTagSprite(u8 id, s16 x, s16 y);
#endif // GUARD_ITEM_MENU_ICONS

54
include/item_use.h Normal file
View File

@ -0,0 +1,54 @@
#ifndef GUARD_ITEM_USE_H
#define GUARD_ITEM_USE_H
extern u16 gSpecialVar_ItemId;
void ItemUseOutOfBattle_Mail(u8);
void ItemUseOutOfBattle_Bike(u8);
void ItemUseOnFieldCB_Bike(u8);
void ItemUseOutOfBattle_Rod(u8);
void ItemUseOnFieldCB_Rod(u8);
void ItemUseOutOfBattle_Itemfinder(u8);
void ItemUseOnFieldCB_Itemfinder(u8);
void RunItemfinderResults(u8);
void ExitItemfinder(u8);
bool8 ItemfinderCheckForHiddenItems(struct MapEvents *, u8);
void sub_80C9720(u8);
void sub_80C9838(u8, s16, s16);
u8 GetPlayerDirectionTowardsHiddenItem(s16, s16);
void SetPlayerDirectionTowardsItem(u8);
void DisplayItemRespondingMessageAndExitItemfinder(u8);
void RotatePlayerAndExitItemfinder(u8);
void ItemUseOutOfBattle_PokeblockCase(u8);
void ItemUseOutOfBattle_CoinCase(u8);
void ItemUseOutOfBattle_SSTicket(u8);
void sub_80C9D00(u8);
void ItemUseOutOfBattle_WailmerPail(u8);
void sub_80C9D74(u8);
void ItemUseOutOfBattle_Medicine(u8);
void ItemUseOutOfBattle_SacredAsh(u8);
void ItemUseOutOfBattle_PPRecovery(u8);
void ItemUseOutOfBattle_PPUp(u8);
void ItemUseOutOfBattle_RareCandy(u8);
void ItemUseOutOfBattle_TMHM(u8);
void sub_80C9EE4(u8);
void sub_80C9F10(u8);
void sub_80C9F80(u8);
void sub_80C9FC0(u8);
void ItemUseOutOfBattle_Repel(u8);
void ItemUseOutOfBattle_BlackWhiteFlute(u8);
void task08_080A1C44(u8);
u8 CanUseEscapeRopeOnCurrMap(void);
void ItemUseOutOfBattle_EscapeRope(u8);
void ItemUseOutOfBattle_EvolutionStone(u8);
void ItemUseInBattle_PokeBall(u8);
void ItemUseInBattle_StatIncrease(u8);
void ItemUseInBattle_Medicine(u8);
void ItemUseInBattle_PPRecovery(u8);
void ItemUseInBattle_Escape(u8);
void ItemUseOutOfBattle_EnigmaBerry(u8);
void ItemUseInBattle_EnigmaBerry(u8);
void ItemUseOutOfBattle_CannotUse(u8);
u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId);
#endif // GUARD_ITEM_USE_H

View File

@ -17,6 +17,7 @@ void sub_812225C(u16 *, u16 *, u8, u8);
void sub_8122298(u16 *, u16 *, u8, u8, u8);
void sub_8121F68(u8 taskId, const struct YesNoFuncTable *data);
bool8 sub_81221AC(void);
bool8 sub_81221EC(void);
void ResetVramOamAndBgCntRegs(void);
void SetVBlankHBlankCallbacksToNull(void);
void ResetAllBgsCoordinates(void);

View File

@ -210,4 +210,17 @@ extern const u8 gText_LoadingEvent[];
extern const u8 gText_DontRemoveCableTurnOff[];
extern const u8 gText_LinkStandby2[];
// berry tag screen text
extern const u8 gBerryFirmnessString_VerySoft[];
extern const u8 gBerryFirmnessString_Soft[];
extern const u8 gBerryFirmnessString_Hard[];
extern const u8 gBerryFirmnessString_VeryHard[];
extern const u8 gBerryFirmnessString_SuperHard[];
extern const u8 gText_BerryTag[];
extern const u8 gText_UnkF908Var1Var2[];
extern const u8 gText_SizeSlash[];
extern const u8 gText_Var1DotVar2[];
extern const u8 gText_ThreeMarks[];
extern const u8 gText_FirmSlash[];
#endif //GUARD_STRINGS_H

View File

@ -229,6 +229,7 @@ SECTIONS {
asm/credits.o(.text);
src/lottery_corner.o(.text);
src/diploma.o(.text);
src/berry_tag_screen.o(.text);
asm/berry_tag_screen.o(.text);
src/mystery_event_menu.o(.text);
src/save_failed_screen.o(.text);
@ -504,7 +505,7 @@ SECTIONS {
src/lottery_corner.o(.rodata);
src/diploma.o(.rodata);
data/strings.o(.rodata);
data/berry_tag_screen.o(.rodata);
src/berry_tag_screen.o(.rodata);
src/mystery_event_menu.o(.rodata);
src/save_failed_screen.o(.rodata);
data/braille_puzzles.o(.rodata);

412
src/berry_tag_screen.c Normal file
View File

@ -0,0 +1,412 @@
#include "global.h"
#include "berry_tag_screen.h"
#include "berry.h"
#include "decompress.h"
#include "field_map_obj.h"
#include "item_menu.h"
#include "constants/items.h"
#include "item_use.h"
#include "main.h"
#include "menu.h"
#include "text.h"
#include "window.h"
#include "task.h"
#include "menu_helpers.h"
#include "palette.h"
#include "overworld.h"
#include "constants/songs.h"
#include "sound.h"
#include "sprite.h"
#include "string_util.h"
#include "strings.h"
#include "bg.h"
#include "malloc.h"
#include "scanline_effect.h"
#include "gpu_regs.h"
#include "graphics.h"
#include "item_menu_icons.h"
#include "decompress.h"
#include "international_string_util.h"
// const rom data
const struct BgTemplate gUnknown_085EFCF0[] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 0,
.mapBaseIndex = 29,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 0,
.mapBaseIndex = 28,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
const u16 gUnknown_085EFD00[] = INCBIN_U16("graphics/interface/berry_tag_screen.gbapal");
const struct TextColor gUnknown_085EFD20[] =
{
{0, 2, 3},
{15, 14, 13}
};
const struct WindowTemplate gUnknown_085EFD28[] =
{
{0x01, 0x0b, 0x04, 0x08, 0x02, 0x0f, 0x0045},
{0x01, 0x0b, 0x07, 0x12, 0x04, 0x0f, 0x0055},
{0x01, 0x04, 0x0e, 0x19, 0x04, 0x0f, 0x009d},
{0x00, 0x02, 0x00, 0x08, 0x02, 0x0f, 0x0101},
DUMMY_WIN_TEMPLATE
};
const u8 *const gBerryFirmnessStringPointers[] =
{
gBerryFirmnessString_VerySoft,
gBerryFirmnessString_Soft,
gBerryFirmnessString_Hard,
gBerryFirmnessString_VeryHard,
gBerryFirmnessString_SuperHard
};
// this file's functions
void sub_8177C84(void);
void sub_8177E14(void);
void sub_8178008(void);
void sub_8178090(void);
void sub_81780F4(void);
void sub_8178338(void);
void sub_817839C(void);
void sub_8178404(void);
void sub_8178110(void);
void sub_8178174(void);
void sub_8178250(void);
void sub_81782D0(void);
void sub_8178304(void);
bool8 sub_8177CB0(void);
bool8 sub_8177E88(void);
void sub_8178654(u8 taskId);
// code
struct BerryTagScreenStruct
{
u16 tilemapBuffers[3][0x400];
u16 berryId;
u8 berrySpriteId;
u16 field_1804;
u16 field_1806;
u16 field_1808;
};
extern struct BerryTagScreenStruct *sBerryTag;
void sub_8177C14(void)
{
sBerryTag = AllocZeroed(0x180C);
sBerryTag->berryId = ItemIdToBerryType(gSpecialVar_ItemId);
SetMainCallback2(sub_8177C84);
}
void sub_8177C54(void)
{
RunTasks();
AnimateSprites();
BuildOamBuffer();
do_scheduled_bg_tilemap_copies_to_vram();
UpdatePaletteFade();
}
void sub_8177C70(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void sub_8177C84(void)
{
while (1)
{
if (sub_81221EC() == TRUE)
break;
if (sub_8177CB0() == TRUE)
break;
if (sub_81221AC() == TRUE)
break;
}
}
bool8 sub_8177CB0(void)
{
switch (gMain.state)
{
case 0:
SetVBlankHBlankCallbacksToNull();
ResetVramOamAndBgCntRegs();
clear_scheduled_bg_copies_to_vram();
gMain.state++;
break;
case 1:
ScanlineEffect_Stop();
gMain.state++;
break;
case 2:
ResetPaletteFade();
gPaletteFade.bufferTransferDisabled = 1;
gMain.state++;
break;
case 3:
ResetSpriteData();
gMain.state++;
break;
case 4:
FreeAllSpritePalettes();
gMain.state++;
break;
case 5:
if (!sub_81221AC())
ResetTasks();
gMain.state++;
break;
case 6:
sub_8177E14();
sBerryTag->field_1808 = 0;
gMain.state++;
break;
case 7:
if (sub_8177E88())
gMain.state++;
break;
case 8:
sub_8178008();
gMain.state++;
break;
case 9:
sub_8178090();
gMain.state++;
break;
case 10:
sub_81780F4();
gMain.state++;
break;
case 11:
sub_8178338();
gMain.state++;
break;
case 12:
sub_817839C();
sub_8178404();
gMain.state++;
break;
case 13:
CreateTask(sub_8178654, 0);
gMain.state++;
break;
case 14:
BlendPalettes(-1, 0x10, 0);
gMain.state++;
break;
case 15:
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
gPaletteFade.bufferTransferDisabled = 0;
gMain.state++;
break;
default: // done
SetVBlankCallback(sub_8177C70);
SetMainCallback2(sub_8177C54);
return TRUE;
}
return FALSE;
}
void sub_8177E14(void)
{
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_085EFCF0, ARRAY_COUNT(gUnknown_085EFCF0));
SetBgTilemapBuffer(2, sBerryTag->tilemapBuffers[0]);
SetBgTilemapBuffer(3, sBerryTag->tilemapBuffers[1]);
ResetAllBgsCoordinates();
schedule_bg_copy_tilemap_to_vram(2);
schedule_bg_copy_tilemap_to_vram(3);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
ShowBg(0);
ShowBg(1);
ShowBg(2);
ShowBg(3);
}
bool8 sub_8177E88(void)
{
u16 i;
switch (sBerryTag->field_1808)
{
case 0:
reset_temp_tile_data_buffers();
decompress_and_copy_tile_data_to_vram(2, gUnknown_08D9BB44, 0, 0, 0);
sBerryTag->field_1808++;
break;
case 1:
if (free_temp_tile_data_buffers_if_possible() != TRUE)
{
LZDecompressWram(gUnknown_08D9BF98, sBerryTag->tilemapBuffers[0]);
sBerryTag->field_1808++;
}
break;
case 2:
LZDecompressWram(gUnknown_08D9C13C, sBerryTag->tilemapBuffers[2]);
sBerryTag->field_1808++;
break;
case 3:
if (gSaveBlock2Ptr->playerGender == MALE)
{
for (i = 0; i < ARRAY_COUNT(sBerryTag->tilemapBuffers[1]); i++)
sBerryTag->tilemapBuffers[1][i] = 0x4042;
}
else
{
for (i = 0; i < ARRAY_COUNT(sBerryTag->tilemapBuffers[1]); i++)
sBerryTag->tilemapBuffers[1][i] = 0x5042;
}
sBerryTag->field_1808++;
break;
case 4:
LoadCompressedPalette(gUnknown_08D9BEF0, 0, 0xC0);
sBerryTag->field_1808++;
break;
case 5:
LoadCompressedObjectPic(&gUnknown_0857FDEC);
sBerryTag->field_1808++;
break;
default:
LoadCompressedObjectPalette(&gUnknown_0857FDF4);
return TRUE; // done
}
return FALSE;
}
void sub_8178008(void)
{
u16 i;
InitWindows(gUnknown_085EFD28);
DeactivateAllTextPrinters();
LoadPalette(gUnknown_085EFD00, 0xF0, 0x20);
for (i = 0; i < ARRAY_COUNT(gUnknown_085EFD28) - 1; i++)
PutWindowTilemap(i);
schedule_bg_copy_tilemap_to_vram(0);
schedule_bg_copy_tilemap_to_vram(1);
}
void sub_817804C(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed, u8 colorStructId)
{
AddTextPrinterParameterized2(windowId, 1, x, y, 0, 0, &gUnknown_085EFD20[colorStructId], speed, text);
}
void sub_8178090(void)
{
memcpy(GetBgTilemapBuffer(0), sBerryTag->tilemapBuffers[2], sizeof(sBerryTag->tilemapBuffers[2]));
FillWindowPixelBuffer(3, 0xFF);
sub_817804C(3, gText_BerryTag, GetStringCenterAlignXOffset(1, gText_BerryTag, 0x40), 1, 0, 1);
PutWindowTilemap(3);
schedule_bg_copy_tilemap_to_vram(0);
}
void sub_81780F4(void)
{
sub_8178110();
sub_8178174();
sub_8178250();
sub_81782D0();
sub_8178304();
}
void sub_8178110(void)
{
const struct Berry *berry = GetBerryInfo(sBerryTag->berryId);
ConvertIntToDecimalStringN(gStringVar1, sBerryTag->berryId, 2, 2);
StringCopy(gStringVar2, berry->name);
StringExpandPlaceholders(gStringVar4, gText_UnkF908Var1Var2);
sub_817804C(0, gStringVar4, 0, 1, 0, 0);
}
void sub_8178174(void)
{
const struct Berry *berry = GetBerryInfo(sBerryTag->berryId);
PrintTextOnWindow(1, 1, gText_SizeSlash, 0, 1, TEXT_SPEED_FF, NULL);
if (berry->size != 0)
{
u32 inches, fraction;
inches = 1000 * berry->size / 254;
if (inches % 10 > 4)
inches += 10;
fraction = (inches % 100) / 10;
inches /= 100;
ConvertIntToDecimalStringN(gStringVar1, inches, 0, 2);
ConvertIntToDecimalStringN(gStringVar2, fraction, 0, 2);
StringExpandPlaceholders(gStringVar4, gText_Var1DotVar2);
PrintTextOnWindow(1, 1, gStringVar4, 0x28, 1, 0, NULL);
}
else
{
PrintTextOnWindow(1, 1, gText_ThreeMarks, 0x28, 1, 0, NULL);
}
}
void sub_8178250(void)
{
const struct Berry *berry = GetBerryInfo(sBerryTag->berryId);
PrintTextOnWindow(1, 1, gText_FirmSlash, 0, 0x11, TEXT_SPEED_FF, NULL);
if (berry->firmness != 0)
PrintTextOnWindow(1, 1, gBerryFirmnessStringPointers[berry->firmness - 1], 0x28, 0x11, 0, NULL);
else
PrintTextOnWindow(1, 1, gText_ThreeMarks, 0x28, 0x11, 0, NULL);
}
void sub_81782D0(void)
{
const struct Berry *berry = GetBerryInfo(sBerryTag->berryId);
PrintTextOnWindow(2, 1, berry->description1, 0, 1, 0, NULL);
}
void sub_8178304(void)
{
const struct Berry *berry = GetBerryInfo(sBerryTag->berryId);
PrintTextOnWindow(2, 1, berry->description2, 0, 0x11, 0, NULL);
}
void sub_8178338(void)
{
sBerryTag->berrySpriteId = CreateBerryTagSprite(sBerryTag->berryId - 1, 56, 64);
}

View File

@ -1267,7 +1267,7 @@ gUnknown_0203BCE8: @ 203BCE8
.include "src/lottery_corner.o"
.include "src/diploma.o"
gUnknown_0203BCF4: @ 203BCF4
sBerryTag: @ 203BCF4
.space 0x4
.include "src/mystery_event_menu.o"