Decomp map_name_popup

This commit is contained in:
PikalaxALT
2019-11-11 21:46:57 -05:00
parent f316b22f96
commit 734cbfdb20
14 changed files with 294 additions and 528 deletions
+1 -1
View File
@@ -5826,7 +5826,7 @@ UseRegisteredKeyItemOnField: @ 810AD10
movs r0, 0
b _0810ADA0
_0810AD1E:
bl sub_80982EC
bl DismissMapNamePopup
movs r0, 0
movs r1, 0
movs r2, 0
-490
View File
@@ -1,490 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_8098110
sub_8098110: @ 8098110
push {r4-r6,lr}
adds r6, r0, 0
movs r0, 0x80
lsls r0, 7
bl FlagGet
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _080981A2
ldr r0, _08098178 @ =gUnknown_203ADFA
ldrb r0, [r0]
subs r0, 0x2
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bls _080981A2
ldr r5, _0809817C @ =sub_80981AC
adds r0, r5, 0
bl FindTaskIdByFunc
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0xFF
bne _08098188
adds r0, r5, 0
movs r1, 0x5A
bl CreateTask
lsls r0, 24
lsrs r4, r0, 24
movs r0, 0
movs r1, 0
movs r2, 0
bl ChangeBgX
ldr r1, _08098180 @ =0xffffef7f
movs r0, 0
movs r2, 0
bl ChangeBgY
ldr r1, _08098184 @ =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r1
movs r1, 0
strh r1, [r0, 0x8]
strh r1, [r0, 0xC]
strh r6, [r0, 0x18]
b _080981A2
.align 2, 0
_08098178: .4byte gUnknown_203ADFA
_0809817C: .4byte sub_80981AC
_08098180: .4byte 0xffffef7f
_08098184: .4byte gTasks
_08098188:
ldr r0, _080981A8 @ =gTasks
lsls r1, r4, 2
adds r1, r4
lsls r1, 3
adds r1, r0
movs r2, 0x8
ldrsh r0, [r1, r2]
cmp r0, 0x4
beq _0809819E
movs r0, 0x4
strh r0, [r1, 0x8]
_0809819E:
movs r0, 0x1
strh r0, [r1, 0xE]
_080981A2:
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_080981A8: .4byte gTasks
thumb_func_end sub_8098110
thumb_func_start sub_80981AC
sub_80981AC: @ 80981AC
push {r4,r5,lr}
lsls r0, 24
lsrs r2, r0, 24
lsls r0, r2, 2
adds r0, r2
lsls r0, 3
ldr r1, _080981D0 @ =gTasks
adds r4, r0, r1
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0x8
bls _080981C6
b _080982DE
_080981C6:
lsls r0, 2
ldr r1, _080981D4 @ =_080981D8
adds r0, r1
ldr r0, [r0]
mov pc, r0
.align 2, 0
_080981D0: .4byte gTasks
_080981D4: .4byte _080981D8
.align 2, 0
_080981D8:
.4byte _080981FC
.4byte _0809820E
.4byte _08098218
.4byte _08098234
.4byte _0809824C
.4byte _080982DE
.4byte _0809827E
.4byte _080982A6
.4byte _080982D6
_080981FC:
movs r1, 0x18
ldrsh r0, [r4, r1]
bl sub_8098340
strh r0, [r4, 0x10]
movs r0, 0x1
strh r0, [r4, 0x12]
strh r0, [r4, 0x8]
b _080982DE
_0809820E:
bl IsDma3ManagerBusyWithBgCopy
lsls r0, 24
cmp r0, 0
bne _080982DE
_08098218:
ldrh r0, [r4, 0xC]
subs r0, 0x2
strh r0, [r4, 0xC]
lsls r0, 16
asrs r0, 16
movs r1, 0x18
negs r1, r1
cmp r0, r1
bgt _080982DE
movs r0, 0x3
strh r0, [r4, 0x8]
movs r0, 0
strh r0, [r4, 0xA]
b _080982DE
_08098234:
ldrh r0, [r4, 0xA]
adds r0, 0x1
strh r0, [r4, 0xA]
lsls r0, 16
asrs r0, 16
cmp r0, 0x78
ble _080982DE
movs r0, 0
strh r0, [r4, 0xA]
movs r0, 0x4
strh r0, [r4, 0x8]
b _080982DE
_0809824C:
ldrh r0, [r4, 0xC]
adds r0, 0x2
strh r0, [r4, 0xC]
lsls r0, 16
cmp r0, 0
blt _080982DE
movs r1, 0xE
ldrsh r0, [r4, r1]
cmp r0, 0
beq _08098278
ldrh r0, [r4, 0x10]
bl sub_8098400
ldrb r0, [r4, 0x10]
movs r1, 0x2
bl CopyWindowToVram
movs r0, 0x1
strh r0, [r4, 0x8]
movs r0, 0
strh r0, [r4, 0xE]
b _080982DE
_08098278:
movs r0, 0x6
strh r0, [r4, 0x8]
b _080982E6
_0809827E:
movs r1, 0x12
ldrsh r0, [r4, r1]
cmp r0, 0
beq _080982A0
movs r1, 0x14
ldrsh r0, [r4, r1]
cmp r0, 0
bne _080982A0
ldrb r0, [r4, 0x10]
bl rbox_fill_rectangle
ldrb r0, [r4, 0x10]
movs r1, 0x1
bl CopyWindowToVram
movs r0, 0x1
strh r0, [r4, 0x14]
_080982A0:
movs r0, 0x7
strh r0, [r4, 0x8]
b _080982E6
_080982A6:
bl IsDma3ManagerBusyWithBgCopy
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0
bne _080982E6
movs r1, 0x12
ldrsh r0, [r4, r1]
cmp r0, 0
beq _080982C6
ldrb r0, [r4, 0x10]
bl RemoveWindow
strh r5, [r4, 0x12]
movs r0, 0x1
strh r0, [r4, 0x16]
_080982C6:
movs r0, 0x8
strh r0, [r4, 0x8]
movs r0, 0
movs r1, 0
movs r2, 0
bl ChangeBgY
b _080982E6
_080982D6:
adds r0, r2, 0
bl DestroyTask
b _080982E6
_080982DE:
ldrh r1, [r4, 0xC]
movs r0, 0x12
bl SetGpuReg
_080982E6:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_80981AC
thumb_func_start sub_80982EC
sub_80982EC: @ 80982EC
push {lr}
ldr r0, _08098318 @ =sub_80981AC
bl FindTaskIdByFunc
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0xFF
beq _08098312
lsls r0, r1, 2
adds r0, r1
lsls r0, 3
ldr r1, _0809831C @ =gTasks+0x8
adds r1, r0, r1
movs r2, 0
ldrsh r0, [r1, r2]
cmp r0, 0x5
bgt _08098312
movs r0, 0x6
strh r0, [r1]
_08098312:
pop {r0}
bx r0
.align 2, 0
_08098318: .4byte sub_80981AC
_0809831C: .4byte gTasks+0x8
thumb_func_end sub_80982EC
thumb_func_start sub_8098320
sub_8098320: @ 8098320
push {lr}
ldr r0, _0809833C @ =sub_80981AC
bl FindTaskIdByFunc
lsls r0, 24
lsrs r0, 24
movs r1, 0xFF
eors r0, r1
negs r1, r0
orrs r1, r0
lsrs r1, 31
adds r0, r1, 0
pop {r1}
bx r1
.align 2, 0
_0809833C: .4byte sub_80981AC
thumb_func_end sub_8098320
thumb_func_start sub_8098340
sub_8098340: @ 8098340
push {r4-r6,lr}
sub sp, 0x8
adds r4, r0, 0
ldr r0, _08098378 @ =gUnknown_83D4164
ldr r1, [r0, 0x4]
ldr r0, [r0]
str r0, [sp]
str r1, [sp, 0x4]
movs r6, 0x1D
ldr r0, _0809837C @ =gMapHeader
ldrb r0, [r0, 0x1A]
lsls r0, 24
asrs r0, 24
cmp r0, 0
beq _08098396
cmp r0, 0x7F
beq _08098384
ldr r2, [sp]
lsrs r1, r2, 24
adds r1, 0x5
lsls r1, 24
ldr r0, _08098380 @ =0x00ffffff
ands r0, r2
orrs r0, r1
str r0, [sp]
movs r6, 0x27
b _08098396
.align 2, 0
_08098378: .4byte gUnknown_83D4164
_0809837C: .4byte gMapHeader
_08098380: .4byte 0x00ffffff
_08098384:
ldr r2, [sp]
lsrs r1, r2, 24
adds r1, 0x8
lsls r1, 24
ldr r0, _080983B4 @ =0x00ffffff
ands r0, r2
orrs r0, r1
str r0, [sp]
movs r6, 0x2D
_08098396:
mov r0, sp
bl AddWindow
lsls r0, 16
lsrs r5, r0, 16
cmp r4, 0
beq _080983B8
movs r0, 0x3
bl stdpal_get
movs r1, 0xD0
movs r2, 0x20
bl LoadPalette
b _080983C6
.align 2, 0
_080983B4: .4byte 0x00ffffff
_080983B8:
movs r0, 0x3
bl stdpal_get
ldr r1, _080983FC @ =gPlttBufferUnfaded + 0x1A0
movs r2, 0x10
bl CpuSet
_080983C6:
lsls r4, r5, 24
lsrs r4, 24
adds r0, r4, 0
adds r1, r6, 0
bl sub_814FF6C
adds r0, r4, 0
adds r1, r6, 0
movs r2, 0xD
bl DrawTextBorderOuter
adds r0, r4, 0
bl PutWindowTilemap
adds r0, r5, 0
bl sub_8098400
adds r0, r4, 0
movs r1, 0x3
bl CopyWindowToVram
adds r0, r5, 0
add sp, 0x8
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
_080983FC: .4byte gPlttBufferUnfaded + 0x1A0
thumb_func_end sub_8098340
thumb_func_start sub_8098400
sub_8098400: @ 8098400
push {r4-r6,lr}
sub sp, 0x28
lsls r0, 16
lsrs r6, r0, 16
movs r5, 0x70
ldr r4, _08098478 @ =gMapHeader
ldrb r1, [r4, 0x14]
add r0, sp, 0xC
movs r2, 0
bl GetMapName
adds r2, r0, 0
movs r0, 0x1A
ldrsb r0, [r4, r0]
cmp r0, 0
beq _08098434
adds r1, r0, 0
adds r0, r2, 0
bl sub_809847C
movs r0, 0x1A
ldrsb r0, [r4, r0]
movs r5, 0xB0
cmp r0, 0x7F
beq _08098434
movs r5, 0x98
_08098434:
movs r2, 0x1
negs r2, r2
movs r0, 0x2
add r1, sp, 0xC
bl GetStringWidth
adds r4, r0, 0
subs r4, r5, r4
lsrs r4, 1
lsls r5, r6, 24
lsrs r5, 24
adds r0, r5, 0
movs r1, 0x11
bl FillWindowPixelBuffer
lsls r4, 24
lsrs r4, 24
movs r0, 0x2
str r0, [sp]
movs r0, 0xFF
str r0, [sp, 0x4]
movs r0, 0
str r0, [sp, 0x8]
adds r0, r5, 0
movs r1, 0x2
add r2, sp, 0xC
adds r3, r4, 0
bl AddTextPrinterParameterized
add sp, 0x28
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_08098478: .4byte gMapHeader
thumb_func_end sub_8098400
thumb_func_start sub_809847C
sub_809847C: @ 809847C
push {lr}
adds r2, r0, 0
lsls r1, 24
lsrs r3, r1, 24
asrs r1, 24
cmp r1, 0
beq _080984D2
movs r0, 0
strb r0, [r2]
adds r2, 0x1
cmp r1, 0x7F
bne _080984A4
ldr r1, _080984A0 @ =gUnknown_841D18D
adds r0, r2, 0
bl StringCopy
b _080984D2
.align 2, 0
_080984A0: .4byte gUnknown_841D18D
_080984A4:
cmp r1, 0
bge _080984B4
movs r0, 0xBC
strb r0, [r2]
adds r2, 0x1
negs r0, r1
lsls r0, 24
lsrs r3, r0, 24
_080984B4:
lsls r1, r3, 24
asrs r1, 24
adds r0, r2, 0
movs r2, 0
movs r3, 0x2
bl ConvertIntToDecimalStringN
adds r2, r0, 0
adds r1, r2, 0
movs r0, 0xC0
strb r0, [r2]
adds r2, 0x1
movs r0, 0xFF
strb r0, [r1, 0x1]
adds r0, r2, 0
_080984D2:
pop {r1}
bx r1
thumb_func_end sub_809847C
.align 2, 0 @ Don't pad with nop.
+5 -5
View File
@@ -1747,7 +1747,7 @@ _080558D4:
cmp r0, r1
beq _08055914
movs r0, 0x1
bl sub_8098110
bl CreateMapNamePopupIfNotAlreadyRunning
_08055914:
add sp, 0x4
pop {r4,r5}
@@ -3282,7 +3282,7 @@ sub_805644C: @ 805644C
bl sub_81127F8
_0805649E:
bl ScriptContext2_Enable
bl sub_80982EC
bl DismissMapNamePopup
b _080564BA
.align 2, 0
_080564A8: .4byte gUnknown_3005E88
@@ -3323,7 +3323,7 @@ sub_80564C8: @ 80564C8
cmp r0, 0x1
bne _0805650C
bl ScriptContext2_Enable
bl sub_80982EC
bl DismissMapNamePopup
b _08056522
.align 2, 0
_08056508: .4byte gUnknown_3005E90
@@ -3824,7 +3824,7 @@ sub_8056918: @ 8056918
cmp r0, 0x4
bne _0805692C
movs r0, 0
bl sub_8098110
bl CreateMapNamePopupIfNotAlreadyRunning
_0805692C:
bl sub_807DF7C
pop {r0}
@@ -4223,7 +4223,7 @@ _08056CA8:
cmp r0, 0x4
bne _08056CCA
movs r0, 0
bl sub_8098110
bl CreateMapNamePopupIfNotAlreadyRunning
b _08056CCA
.align 2, 0
_08056CBC: .4byte gMapHeader
BIN
View File
Binary file not shown.
-15
View File
@@ -1,15 +0,0 @@
#include "constants/maps.h"
#include "constants/species.h"
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
.incbin "baserom.gba", 0x3E27B4, 0x1A0
gUnknown_83E2954:: @ 83E2954
.4byte sub_8124C8C
.4byte CB2_ReturnToField
.4byte NULL
.4byte NULL
-10
View File
@@ -1,10 +0,0 @@
#include "constants/maps.h"
#include "constants/species.h"
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnknown_83D4164:: @ 83D4164
.incbin "baserom.gba", 0x3D4164, 0x8
+1 -1
View File
@@ -163,7 +163,7 @@ struct MapHeader
/* 0x17 */ u8 mapType;
/* 0x18 */ u8 filler_18;
/* 0x19 */ u8 escapeRope;
/* 0x1A */ u8 flags;
/* 0x1A */ s8 flags;
/* 0x1B */ u8 battleType;
};
+1 -1
View File
@@ -9,6 +9,6 @@
// Exported ROM declarations
void HideMapNamePopUpWindow(void);
void sub_8098110(u8);
void CreateMapNamePopupIfNotAlreadyRunning(u8);
#endif //GUARD_MAP_NAME_POPUP_H
+3
View File
@@ -738,4 +738,7 @@ extern const u8 gText_GiveUpTryingToTeachNewMove[];
// pokemon_size_record
extern const u8 gText_DecimalPoint[];
// map_name_popup
extern const u8 gUnknown_841D18D[];
#endif //GUARD_STRINGS_H
+1
View File
@@ -29,5 +29,6 @@ void DrawTextBorderOuter(u8 windowId, u16 tileStart, u8 palette);
void TextWindow_LoadTilesStdFrame1(u8 windowId, u16 destOffset);
void sub_814FE6C(u8 windowId, u16 destOffset, u8 palIdx);
void sub_814FEEC(u8 windowId, u16 destOffset, u8 palIdx);
void sub_814FF6C(u8 windowId, u16 destOffset);
#endif // GUARD_TEXT_WINDOW_H
+3 -3
View File
@@ -136,7 +136,7 @@ SECTIONS {
asm/script_movement.o(.text);
asm/fldeff_cut.o(.text);
src/mail_data.o(.text);
asm/map_name_popup.o(.text);
src/map_name_popup.o(.text);
src/item_menu_icons.o(.text);
src/battle_anim_mon_movement.o(.text);
src/item.o(.text);
@@ -438,7 +438,7 @@ SECTIONS {
data/pokemon_storage_system.o(.rodata);
src/pokemon_icon.o(.rodata);
data/fldeff_cut.o(.rodata);
data/map_name_popup.o(.rodata);
src/map_name_popup.o(.rodata);
src/item_menu_icons.o(.rodata);
src/battle_anim_mon_movement.o(.rodata);
src/item.o(.rodata);
@@ -447,7 +447,7 @@ SECTIONS {
src/script_menu.o(.rodata);
data/naming_screen.o(.rodata);
src/pokemon_size_record.o(.rodata);
data/item_use.o(.rodata);
src/item_use.o(.rodata);
data/battle_anim_effects_misc.o(.rodata);
src/flying.o(.rodata);
src/psychic.o(.rodata);
+62 -1
View File
@@ -76,7 +76,68 @@ void sub_80A1D68(u8 taskId);
void Task_BattleUse_StatBooster_DelayAndPrint(u8 taskId);
void Task_BattleUse_StatBooster_WaitButton_ReturnToBattle(u8 taskId);
extern void (*const gUnknown_83E2954[])(void);
// No clue what this is
static const u8 sUnref_83E27B4[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x21, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0x00, 0xe0, 0x03, 0x00, 0x7c,
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void (*const gUnknown_83E2954[])(void) = {
sub_8124C8C,
CB2_ReturnToField,
NULL,
NULL
};
void sub_80A0FBC(u8 taskId)
{
+216
View File
@@ -0,0 +1,216 @@
#include "global.h"
#include "bg.h"
#include "gpu_regs.h"
#include "window.h"
#include "palette.h"
#include "task.h"
#include "event_data.h"
#include "text_window.h"
#include "quest_log.h"
#include "region_map.h"
#include "text.h"
#include "strings.h"
#include "string_util.h"
#include "constants/flags.h"
static void Task_MapNamePopup(u8 taskId);
static u16 MapNamePopupCreateWindow(int a0);
static void MapNamePopupPrintMapNameOnWindow(u16 a0);
static u8 *MapNamePopupAppendFloorNum(u8 *dest, s8 flags);
void CreateMapNamePopupIfNotAlreadyRunning(int a0)
{
u8 taskId;
if (FlagGet(FLAG_SPECIAL_FLAG_0x4000) != TRUE && !(gUnknown_203ADFA == 2 || gUnknown_203ADFA == 3))
{
taskId = FindTaskIdByFunc(Task_MapNamePopup);
if (taskId == 0xFF)
{
taskId = CreateTask(Task_MapNamePopup, 90);
ChangeBgX(0, 0x00000000, 0);
ChangeBgY(0, 0xFFFFEF7F, 0);
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[2] = 0;
gTasks[taskId].data[8] = a0;
}
else
{
if (gTasks[taskId].data[0] != 4)
gTasks[taskId].data[0] = 4;
gTasks[taskId].data[3] = 1;
}
}
}
static void Task_MapNamePopup(u8 taskId)
{
struct Task * task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
task->data[4] = MapNamePopupCreateWindow(task->data[8]);
task->data[5] = 1;
task->data[0] = 1;
break;
case 1:
if (IsDma3ManagerBusyWithBgCopy())
break;
// fallthrough
case 2:
task->data[2] -= 2;
if (task->data[2] <= -24)
{
task->data[0] = 3;
task->data[1] = 0;
}
break;
case 3:
task->data[1]++;
if (task->data[1] > 120)
{
task->data[1] = 0;
task->data[0] = 4;
}
break;
case 4:
task->data[2] += 2;
if (task->data[2] >= 0)
{
if (task->data[3])
{
MapNamePopupPrintMapNameOnWindow(task->data[4]);
CopyWindowToVram(task->data[4], 2);
task->data[0] = 1;
task->data[3] = 0;
}
else
{
task->data[0] = 6;
return;
}
}
case 5:
break;
case 6:
if (task->data[5] && !task->data[6])
{
rbox_fill_rectangle(task->data[4]);
CopyWindowToVram(task->data[4], 1);
task->data[6] = 1;
}
task->data[0] = 7;
return;
case 7:
if (!IsDma3ManagerBusyWithBgCopy())
{
if (task->data[5])
{
RemoveWindow(task->data[4]);
task->data[5] = 0;
task->data[7] = 1;
}
task->data[0] = 8;
ChangeBgY(0, 0x00000000, 0);
}
return;
case 8:
DestroyTask(taskId);
return;
}
SetGpuReg(REG_OFFSET_BG0VOFS, task->data[2]);
}
void DismissMapNamePopup(void)
{
u8 taskId;
s16 *data;
taskId = FindTaskIdByFunc(Task_MapNamePopup);
if (taskId != 0xFF)
{
data = gTasks[taskId].data;
if (data[0] < 6)
data[0] = 6;
}
}
bool32 IsMapNamePopupTaskActive(void)
{
return FindTaskIdByFunc(Task_MapNamePopup) != 0xFF ? TRUE : FALSE;
}
static u16 MapNamePopupCreateWindow(int a0)
{
struct WindowTemplate windowTemplate = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 29,
.width = 14,
.height = 2,
.paletteNum = 0xD,
.baseBlock = 0x001
};
u16 windowId;
u16 r6 = 0x01D;
if (gMapHeader.flags)
{
if (gMapHeader.flags != 0x7F)
{
windowTemplate.width += 5;
r6 = 0x027;
}
else
{
windowTemplate.width += 8;
r6 = 0x02D;
}
}
windowId = AddWindow(&windowTemplate);
if (a0)
{
LoadPalette(stdpal_get(3), 0xd0, 0x20);
}
else
{
CpuCopy16(stdpal_get(3), &gPlttBufferUnfaded[0xd0], 0x20);
}
sub_814FF6C(windowId, r6);
DrawTextBorderOuter(windowId, r6, 0xD);
PutWindowTilemap(windowId);
MapNamePopupPrintMapNameOnWindow(windowId);
CopyWindowToVram(windowId, 3);
return windowId;
}
static void MapNamePopupPrintMapNameOnWindow(u16 windowId)
{
u8 mapName[25];
u32 maxWidth = 112;
u32 xpos;
u8 *ptr = GetMapName(mapName, gMapHeader.regionMapSectionId, 0);
if (gMapHeader.flags)
{
ptr = MapNamePopupAppendFloorNum(ptr, gMapHeader.flags);
maxWidth = gMapHeader.flags != 0x7F ? 152 : 176;
}
xpos = (maxWidth - GetStringWidth(2, mapName, -1)) / 2;
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
AddTextPrinterParameterized(windowId, 2, mapName, xpos, 2, 0xFF, NULL);
}
static u8 *MapNamePopupAppendFloorNum(u8 *dest, s8 flags)
{
if (flags == 0)
return dest;
*dest++ = CHAR_SPACE;
if (flags == 0x7F)
return StringCopy(dest, gUnknown_841D18D);
if (flags < 0)
{
*dest++ = CHAR_B;
flags *= -1;
}
dest = ConvertIntToDecimalStringN(dest, flags, STR_CONV_MODE_LEFT_ALIGN, 2);
*dest++ = CHAR_F;
*dest = EOS;
return dest;
}
+1 -1
View File
@@ -1425,7 +1425,7 @@ static void sub_81120AC(u8 taskId)
break;
default:
if (gUnknown_203AE94.unk_0_6 == 1)
sub_8098110(1);
CreateMapNamePopupIfNotAlreadyRunning(1);
CpuCopy16(gUnknown_203AE90, gPlttBufferUnfaded, 0x400);
Free(gUnknown_203AE90);
gUnknown_203AE94 = (struct UnkStruct_203AE94){};