Decompile overlay_01_021EF7A0 -> field/draw_map_name

This commit is contained in:
tgsm 2024-12-01 20:06:02 -06:00
parent e4918dabdd
commit 80efa0af9b
15 changed files with 251 additions and 557 deletions

View File

@ -154,9 +154,9 @@
.public ov01_021EB234
.public ov01_021EB260
.public FieldWeatherUpdate_UsedFlash
.public ov01_021EF9E0
.public ov01_021EFA1C
.public ov01_021EFAF8
.public FieldDrawMapNameInfo_Create
.public FieldDrawMapNameInfo_Destroy
.public FieldSystem_DrawMapNameAnimation
.public ov01_021F1348
.public ov01_021F1384
.public ov01_021F1390

View File

@ -1,33 +0,0 @@
#include <nitro/fs/overlay.h>
#pragma once
.public GfGfxLoader_GetCharData
.public GfGfxLoader_GetPlttData
.public NewMsgDataFromNarc
.public DestroyMsgData
.public SysTask_CreateOnMainQueue
.public SysTask_Destroy
.public AllocFromHeap
.public FreeToHeap
.public BgSetPosTextAndCommit
.public BG_LoadCharTilesData
.public AddWindowParameterized
.public RemoveWindow
.public CopyWindowToVram
.public ClearWindowTilemapAndCopyToVram
.public FillWindowPixelBuffer
.public BlitBitmapRectToWindow
.public AddTextPrinterParameterizedWithColor
.public GF_AssertFail
.public String_New
.public String_Delete
.public MapHeader_GetMapSec
.public MapHeader_GetAreaIcon
.public sub_0203B58C
.public sub_02068F84
.public GX_LoadBGPltt
.public DC_FlushRange
.public _s32_div_f
.public ov01_021EF9E0
.public ov01_021EFA1C
.public ov01_021EFACC
.public ov01_021EFAF8

View File

@ -16,4 +16,4 @@
.public CallTask_FadeFromBlack
.public sub_020553B0
.public sub_02055408
.public ov01_021EFAF8
.public FieldSystem_DrawMapNameAnimation

View File

@ -540,7 +540,7 @@ _021E5D82:
bl ov01_021F3D50
ldr r0, [r4, #4]
ldr r0, [r0, #8]
bl ov01_021EFA1C
bl FieldDrawMapNameInfo_Destroy
ldr r0, [r4, #4]
ldr r0, [r0, #0xc]
bl ov01_021EB234
@ -750,7 +750,7 @@ _021E5F3E:
cmp r6, r0
beq _021E5FB8
add r0, r5, #0
bl ov01_021EFAF8
bl FieldSystem_DrawMapNameAnimation
_021E5FB8:
mov r0, #1
add sp, #8
@ -1525,7 +1525,7 @@ _021E65D8:
ldr r1, [r4, #4]
str r0, [r1, #0xc]
ldr r0, [r4, #8]
bl ov01_021EF9E0
bl FieldDrawMapNameInfo_Create
ldr r1, [r4, #4]
str r0, [r1, #8]
mov r0, #4

View File

@ -1,498 +0,0 @@
#include "constants/sndseq.h"
#include "constants/moves.h"
#include "constants/std_script.h"
#include "constants/species.h"
#include "constants/sprites.h"
#include "constants/maps.h"
#include "constants/mmodel.h"
#include "constants/items.h"
#include "msgdata/msg/msg_0096_D31R0201.h"
#include "msgdata/msg/msg_0066_D23R0102.h"
.include "asm/macros.inc"
.include "overlay_01_021EF7A0.inc"
.include "global.inc"
.text
thumb_func_start ov01_021EF7A0
ov01_021EF7A0: ; 0x021EF7A0
push {r4, r5, r6, lr}
lsl r6, r1, #5
add r5, r0, #0
add r4, r2, #0
add r1, r6, #0
bl DC_FlushRange
add r0, r5, #0
lsl r1, r4, #5
add r2, r6, #0
bl GX_LoadBGPltt
pop {r4, r5, r6, pc}
.balign 4, 0
thumb_func_end ov01_021EF7A0
thumb_func_start ov01_021EF7BC
ov01_021EF7BC: ; 0x021EF7BC
push {lr}
sub sp, #0x14
mov r3, #0
add r1, r0, #0
str r3, [sp]
mov r0, #0x20
str r0, [sp, #4]
mov r0, #5
str r0, [sp, #8]
mov r0, #0xb
str r0, [sp, #0xc]
ldr r0, _021EF7E4 ; =0x00000197
mov r2, #3
str r0, [sp, #0x10]
ldr r0, [r1, #0x1c]
add r1, #0x20
bl AddWindowParameterized
add sp, #0x14
pop {pc}
.balign 4, 0
_021EF7E4: .word 0x00000197
thumb_func_end ov01_021EF7BC
thumb_func_start ov01_021EF7E8
ov01_021EF7E8: ; 0x021EF7E8
push {r4, r5, r6, r7, lr}
sub sp, #0xc
add r5, r0, #0
str r3, [sp, #4]
add r0, #0x31
ldrb r0, [r0]
add r3, r5, #0
add r6, r2, #0
lsl r0, r0, #0x19
lsr r4, r0, #0x18
mov r0, #4
add r7, r1, #0
str r0, [sp]
mov r0, #0xa3
add r1, r4, #0
mov r2, #0
add r3, #0x34
bl GfGfxLoader_GetCharData
str r0, [r5, #0x38]
ldr r3, [r5, #0x34]
add r1, r7, #0
str r6, [sp]
ldr r2, [r3, #0x14]
ldr r0, [r5, #0x1c]
ldr r3, [r3, #0x10]
bl BG_LoadCharTilesData
mov r0, #0xa3
add r1, r4, #1
add r2, sp, #8
mov r3, #4
bl GfGfxLoader_GetPlttData
add r4, r0, #0
ldr r0, [sp, #8]
ldr r2, [sp, #4]
ldr r0, [r0, #0xc]
mov r1, #1
bl ov01_021EF7A0
add r0, r4, #0
bl FreeToHeap
add sp, #0xc
pop {r4, r5, r6, r7, pc}
thumb_func_end ov01_021EF7E8
thumb_func_start ov01_021EF844
ov01_021EF844: ; 0x021EF844
push {r3, r4, r5, r6, r7, lr}
sub sp, #0x18
mov r2, #0x84
sub r2, r2, r1
lsr r1, r2, #0x1f
add r1, r2, r1
asr r1, r1, #1
add r6, r0, #0
add r2, r1, #4
add r1, r6, #0
add r1, #0x30
strb r2, [r1]
mov r1, #0
str r1, [sp]
ldr r2, _021EF8D0 ; =0x000002D9
mov r1, #3
mov r3, #0xb
bl ov01_021EF7E8
add r0, r6, #0
add r0, #0x20
mov r1, #0
bl FillWindowPixelBuffer
add r7, r6, #0
mov r4, #0
add r7, #0x20
_021EF87A:
add r0, r4, #0
mov r1, #0x11
bl _s32_div_f
add r5, r1, #0
add r0, r4, #0
mov r1, #0x11
bl _s32_div_f
mov r1, #8
str r1, [sp]
str r1, [sp, #4]
lsl r1, r5, #0x13
lsr r1, r1, #0x10
lsl r0, r0, #0x13
add r2, r4, #1
lsl r2, r2, #0x13
str r1, [sp, #8]
lsr r0, r0, #0x10
str r0, [sp, #0xc]
mov r0, #8
str r0, [sp, #0x10]
str r0, [sp, #0x14]
ldr r1, [r6, #0x34]
add r0, r7, #0
ldr r1, [r1, #0x14]
lsr r2, r2, #0x10
mov r3, #0
bl BlitBitmapRectToWindow
add r4, r4, #1
cmp r4, #0x44
blt _021EF87A
add r0, r6, #0
add r0, #0x20
bl CopyWindowToVram
ldr r0, [r6, #0x38]
bl FreeToHeap
add sp, #0x18
pop {r3, r4, r5, r6, r7, pc}
nop
_021EF8D0: .word 0x000002D9
thumb_func_end ov01_021EF844
thumb_func_start ov01_021EF8D4
ov01_021EF8D4: ; 0x021EF8D4
mov r1, #0
str r1, [r0]
strb r1, [r0, #4]
str r1, [r0, #8]
str r1, [r0, #0xc]
strh r1, [r0, #0x10]
str r1, [r0, #0x14]
str r1, [r0, #0x18]
str r1, [r0, #0x1c]
bx lr
thumb_func_end ov01_021EF8D4
thumb_func_start ov01_021EF8E8
ov01_021EF8E8: ; 0x021EF8E8
push {r3, r4, r5, lr}
add r5, r0, #0
add r4, r1, #0
bl ov01_021EF8D4
str r4, [r5, #0x1c]
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end ov01_021EF8E8
thumb_func_start ov01_021EF8F8
ov01_021EF8F8: ; 0x021EF8F8
push {r4, lr}
add r4, r1, #0
ldrb r0, [r4, #4]
cmp r0, #3
bhi _021EF9A4
add r0, r0, r0
add r0, pc
ldrh r0, [r0, #6]
lsl r0, r0, #0x10
asr r0, r0, #0x10
add pc, r0
_021EF90E: ; jump table
.short _021EF9A4 - _021EF90E - 2 ; case 0
.short _021EF916 - _021EF90E - 2 ; case 1
.short _021EF954 - _021EF90E - 2 ; case 2
.short _021EF93E - _021EF90E - 2 ; case 3
_021EF916:
ldr r0, [r4, #0xc]
sub r0, r0, #4
str r0, [r4, #0xc]
bpl _021EF922
mov r0, #0
str r0, [r4, #0xc]
_021EF922:
mov r1, #3
ldr r0, [r4, #0x1c]
ldr r3, [r4, #0xc]
add r2, r1, #0
bl BgSetPosTextAndCommit
ldr r0, [r4, #0xc]
cmp r0, #0
bne _021EF9A4
mov r0, #0
strh r0, [r4, #0x10]
mov r0, #3
strb r0, [r4, #4]
pop {r4, pc}
_021EF93E:
ldrh r0, [r4, #0x10]
add r0, r0, #1
strh r0, [r4, #0x10]
ldrh r0, [r4, #0x10]
cmp r0, #0x3c
blo _021EF9A4
mov r0, #0
strh r0, [r4, #0x10]
mov r0, #2
strb r0, [r4, #4]
pop {r4, pc}
_021EF954:
ldr r0, [r4, #0xc]
add r0, r0, #4
str r0, [r4, #0xc]
cmp r0, #0x26
ble _021EF962
mov r0, #0x26
str r0, [r4, #0xc]
_021EF962:
mov r1, #3
ldr r0, [r4, #0x1c]
ldr r3, [r4, #0xc]
add r2, r1, #0
bl BgSetPosTextAndCommit
ldr r0, [r4, #0xc]
cmp r0, #0x26
bne _021EF9A4
ldr r0, [r4, #0x14]
cmp r0, #0
beq _021EF99E
mov r0, #0
str r0, [r4, #0x14]
ldr r0, [r4, #0x3c]
ldr r1, [r4, #0x18]
ldr r2, [r4, #0x40]
bl sub_02068F84
add r1, r0, #0
add r0, r4, #0
bl ov01_021EF844
ldr r1, [r4, #0x40]
add r0, r4, #0
bl ov01_021EF9A8
mov r0, #1
strb r0, [r4, #4]
pop {r4, pc}
_021EF99E:
add r0, r4, #0
bl ov01_021EFACC
_021EF9A4:
pop {r4, pc}
.balign 4, 0
thumb_func_end ov01_021EF8F8
thumb_func_start ov01_021EF9A8
ov01_021EF9A8: ; 0x021EF9A8
push {r3, lr}
sub sp, #0x10
add r3, r0, #0
mov r0, #8
add r2, r1, #0
str r0, [sp]
mov r1, #0
ldr r0, _021EF9D0 ; =0x00010200
str r1, [sp, #4]
str r0, [sp, #8]
add r0, r3, #0
str r1, [sp, #0xc]
add r3, #0x30
ldrb r3, [r3]
add r0, #0x20
bl AddTextPrinterParameterizedWithColor
add sp, #0x10
pop {r3, pc}
nop
_021EF9D0: .word 0x00010200
thumb_func_end ov01_021EF9A8
thumb_func_start ov01_021EF9D4
ov01_021EF9D4: ; 0x021EF9D4
mov r1, #2
strb r1, [r0, #4]
mov r1, #0
strh r1, [r0, #0x10]
bx lr
.balign 4, 0
thumb_func_end ov01_021EF9D4
thumb_func_start ov01_021EF9E0
ov01_021EF9E0: ; 0x021EF9E0
push {r3, r4, r5, lr}
add r5, r0, #0
mov r0, #4
mov r1, #0x44
bl AllocFromHeap
add r4, r0, #0
mov r0, #0x16
mov r1, #4
bl String_New
str r0, [r4, #0x40]
add r0, r4, #0
add r1, r5, #0
bl ov01_021EF8E8
add r0, r4, #0
bl ov01_021EF7BC
mov r1, #0x1b
add r2, r1, #0
mov r0, #1
add r2, #0xfc
mov r3, #4
bl NewMsgDataFromNarc
str r0, [r4, #0x3c]
add r0, r4, #0
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end ov01_021EF9E0
thumb_func_start ov01_021EFA1C
ov01_021EFA1C: ; 0x021EFA1C
push {r4, lr}
add r4, r0, #0
ldr r0, [r4, #0x3c]
bl DestroyMsgData
add r0, r4, #0
add r0, #0x20
bl RemoveWindow
ldr r0, [r4, #0x40]
bl String_Delete
add r0, r4, #0
bl FreeToHeap
pop {r4, pc}
thumb_func_end ov01_021EFA1C
thumb_func_start ov01_021EFA3C
ov01_021EFA3C: ; 0x021EFA3C
push {r3, r4, r5, lr}
add r4, r0, #0
str r1, [r4, #0x18]
ldr r1, [r4]
add r5, r2, #0
cmp r1, #0
bne _021EFA90
mov r0, #1
str r0, [r4]
mov r1, #3
ldr r0, [r4, #0x1c]
add r2, r1, #0
mov r3, #0x26
bl BgSetPosTextAndCommit
mov r0, #0x26
str r0, [r4, #0xc]
ldr r0, _021EFAC8 ; =ov01_021EF8F8
add r1, r4, #0
mov r2, #0
bl SysTask_CreateOnMainQueue
str r0, [r4, #8]
mov r0, #1
strb r0, [r4, #4]
ldr r0, [r4, #0x3c]
ldr r1, [r4, #0x18]
ldr r2, [r4, #0x40]
bl sub_02068F84
add r1, r0, #0
add r0, r4, #0
add r0, #0x31
strb r5, [r0]
add r0, r4, #0
bl ov01_021EF844
ldr r1, [r4, #0x40]
add r0, r4, #0
bl ov01_021EF9A8
pop {r3, r4, r5, pc}
_021EFA90:
ldrb r1, [r4, #4]
cmp r1, #3
bhi _021EFAC2
add r1, r1, r1
add r1, pc
ldrh r1, [r1, #6]
lsl r1, r1, #0x10
asr r1, r1, #0x10
add pc, r1
_021EFAA2: ; jump table
.short _021EFAC2 - _021EFAA2 - 2 ; case 0
.short _021EFAAA - _021EFAA2 - 2 ; case 1
.short _021EFAB8 - _021EFAA2 - 2 ; case 2
.short _021EFAAA - _021EFAA2 - 2 ; case 3
_021EFAAA:
bl ov01_021EF9D4
mov r0, #1
str r0, [r4, #0x14]
add r4, #0x31
strb r5, [r4]
pop {r3, r4, r5, pc}
_021EFAB8:
mov r0, #1
str r0, [r4, #0x14]
add r4, #0x31
strb r5, [r4]
pop {r3, r4, r5, pc}
_021EFAC2:
bl GF_AssertFail
pop {r3, r4, r5, pc}
.balign 4, 0
_021EFAC8: .word ov01_021EF8F8
thumb_func_end ov01_021EFA3C
thumb_func_start ov01_021EFACC
ov01_021EFACC: ; 0x021EFACC
push {r4, lr}
add r4, r0, #0
ldr r0, [r4, #8]
cmp r0, #0
beq _021EFADA
bl SysTask_Destroy
_021EFADA:
add r0, r4, #0
add r0, #0x20
bl ClearWindowTilemapAndCopyToVram
mov r1, #3
ldr r0, [r4, #0x1c]
add r2, r1, #0
mov r3, #0
bl BgSetPosTextAndCommit
ldr r1, [r4, #0x1c]
add r0, r4, #0
bl ov01_021EF8E8
pop {r4, pc}
thumb_func_end ov01_021EFACC
thumb_func_start ov01_021EFAF8
ov01_021EFAF8: ; 0x021EFAF8
push {r3, r4, r5, lr}
add r5, r0, #0
ldr r0, [r5, #0x20]
ldr r0, [r0]
bl MapHeader_GetAreaIcon
cmp r0, #0
beq _021EFB36
ldr r0, [r5, #0x20]
ldr r0, [r0]
bl sub_0203B58C
cmp r0, #0
bne _021EFB36
ldr r0, [r5, #0x20]
ldr r0, [r0]
bl MapHeader_GetMapSec
add r4, r0, #0
ldr r0, [r5, #0x20]
ldr r0, [r0]
bl MapHeader_GetAreaIcon
add r2, r0, #0
beq _021EFB2C
sub r2, r2, #1
_021EFB2C:
ldr r0, [r5, #4]
add r1, r4, #0
ldr r0, [r0, #8]
bl ov01_021EFA3C
_021EFB36:
pop {r3, r4, r5, pc}
thumb_func_end ov01_021EFAF8

View File

@ -233,7 +233,7 @@ _020553E0:
str r0, [r4]
b _02055404
_020553EE:
bl ov01_021EFAF8
bl FieldSystem_DrawMapNameAnimation
add r0, r5, #0
bl CallTask_FadeFromBlack
ldr r0, [r4]

View File

@ -0,0 +1,29 @@
#ifndef POKEHEARTGOLD_FIELD_DRAW_MAP_NAME_H
#define POKEHEARTGOLD_FIELD_DRAW_MAP_NAME_H
#include "bg_window.h"
#include "msgdata.h"
typedef struct FieldDrawMapNameInfo {
BOOL onScreen;
u8 positionState;
SysTask *task;
int layerY;
u16 framesFullyOnscreen;
BOOL gonnaDrawAnother;
u32 mapsec;
BgConfig *bgConfig;
Window window;
u8 nameX;
u8 areaIcon;
NNSG2dCharacterData *g2dCharData;
void *charData;
MsgData *mapsecMsgData;
String *mapNameString;
} FieldDrawMapNameInfo; // size: 0x44
FieldDrawMapNameInfo *FieldDrawMapNameInfo_Create(BgConfig *bgConfig);
void FieldDrawMapNameInfo_Destroy(FieldDrawMapNameInfo *info);
void FieldDrawMapName_Reset(FieldDrawMapNameInfo *info);
#endif

View File

@ -1,6 +1,7 @@
#ifndef POKEHEARTGOLD_FIELD_SYSTEM_H
#define POKEHEARTGOLD_FIELD_SYSTEM_H
#include "field/draw_map_name.h"
#include "field/overlay_01_021E66E4.h"
#include "bag_cursor.h"
@ -96,7 +97,7 @@ struct FieldSystemUnkSub68 {
typedef struct FieldSystemUnkSub4 {
u32 unk0;
Field3dObjectTaskManager *field3dObjectTaskManager;
u32 unk8;
FieldDrawMapNameInfo *drawMapNameInfo;
void *unk_0C; // weather related?
UnkStruct_ov01_021EB1E8 *unk10;
u32 unk14;

View File

@ -28,7 +28,7 @@ typedef struct UnkStruct_field_021F4360 {
} UnkStruct_field_021F4360;
void ov01_021E636C(int a0);
void ov01_021EFAF8(FieldSystem *fieldSystem);
void FieldSystem_DrawMapNameAnimation(FieldSystem *fieldSystem);
void ov01_021F35C4(FieldSystem *fieldSystem, int a1, int *a2);
u32 GetHoneySweetScentWorkSize(void);
BOOL Task_HoneyOrSweetScent(TaskManager *taskManager);

View File

@ -1,6 +0,0 @@
#ifndef POKEHEARTGOLD_OV_01_021EF7A0_H
#define POKEHEARTGOLD_OV_01_021EF7A0_H
void ov01_021EFACC(u32 a0);
#endif

View File

@ -455,7 +455,7 @@ Overlay field
Object asm/overlay_01_021EB1E8.o
Object asm/overlay_01_021EDAFC.o
Object src/field/scrcmd_message.o
Object asm/overlay_01_021EF7A0.o
Object src/field/draw_map_name.o
Object asm/overlay_01_021EFB38.o
Object asm/overlay_01_021F1348.o
Object asm/overlay_01_021F1AFC.o

202
src/field/draw_map_name.c Normal file
View File

@ -0,0 +1,202 @@
#include "field/draw_map_name.h"
#include <nitro/gx/gx_load.h>
#include <nitro/os/cache.h>
#include "global.h"
#include "constants/map_sections.h"
#include "msgdata/msg.naix"
#include "msgdata/msg/msg_0279.h"
#include "field_system.h"
#include "gf_gfx_loader.h"
#include "overlay_01.h" // FIXME: This is included for FieldSystem_DrawMapNameAnimation, is there a way to do this properly without causing dependency issues with field_system?
#include "text.h"
#include "unk_02068F84.h"
#define POSITION_STATE_INVALID 0
#define POSITION_STATE_DESCENDING 1
#define POSITION_STATE_ASCENDING 2
#define POSITION_STATE_INPLACE 3
static void PrintMapNameOnIcon(FieldDrawMapNameInfo *info, String *name);
static void LoadAreaIconPalette(void *data, u32 size, u32 offset) {
DC_FlushRange(data, size * 32);
GX_LoadBGPltt(data, offset * 32, size * 32);
}
static void FieldDrawMapName_SetupWindow(FieldDrawMapNameInfo *info) {
AddWindowParameterized(info->bgConfig, &info->window, GF_BG_LYR_MAIN_3, 0, 0, 32, 5, 11, 0x197);
}
static void LoadAreaIconGraphics(FieldDrawMapNameInfo *info, u8 layer, u32 tileStart, u8 paletteOffset, u32 unused) {
u8 memberNum = info->areaIcon * 2;
info->charData = GfGfxLoader_GetCharData(NARC_data_gs_areawindow, memberNum, FALSE, &info->g2dCharData, HEAP_ID_4);
BG_LoadCharTilesData(info->bgConfig, layer, info->g2dCharData->pRawData, info->g2dCharData->szByte, tileStart);
NNSG2dPaletteData *g2dPaletteData;
void *paletteData = GfGfxLoader_GetPlttData(NARC_data_gs_areawindow, memberNum + 1, &g2dPaletteData, HEAP_ID_4);
LoadAreaIconPalette(g2dPaletteData->pRawData, 1, paletteOffset);
FreeToHeap(paletteData);
}
static void DrawAreaIcon(FieldDrawMapNameInfo *info, int namePixelWidth) {
info->nameX = ((132 - namePixelWidth) / 2) + 4;
LoadAreaIconGraphics(info, 3, 0x2D9, 11, 0);
FillWindowPixelBuffer(&info->window, 0x0);
for (int i = 0; i < 68; i++) {
BlitBitmapRectToWindow(&info->window, info->g2dCharData->pRawData, (i + 1) * 8, 0, 8, 8, (i % 17) * 8, (i / 17) * 8, 8, 8);
}
CopyWindowToVram(&info->window);
FreeToHeap(info->charData);
}
static void FieldDrawMapName_ResetState(FieldDrawMapNameInfo *info) {
info->onScreen = FALSE;
info->positionState = POSITION_STATE_INVALID;
info->task = NULL;
info->layerY = 0;
info->framesFullyOnscreen = 0;
info->gonnaDrawAnother = FALSE;
info->mapsec = MAPSEC_MYSTERY_ZONE;
info->bgConfig = NULL;
}
static void FieldDrawMapName_Init(FieldDrawMapNameInfo *info, BgConfig *bgConfig) {
FieldDrawMapName_ResetState(info);
info->bgConfig = bgConfig;
}
static void Task_MapNameAndIcon(SysTask *task, FieldDrawMapNameInfo *info) {
switch (info->positionState) {
case POSITION_STATE_DESCENDING:
info->layerY -= 4;
if (info->layerY < 0) {
info->layerY = 0;
}
BgSetPosTextAndCommit(info->bgConfig, GF_BG_LYR_MAIN_3, BG_POS_OP_SET_Y, info->layerY);
if (info->layerY == 0) {
info->framesFullyOnscreen = 0;
info->positionState = POSITION_STATE_INPLACE;
return;
}
break;
case POSITION_STATE_INPLACE:
if (++info->framesFullyOnscreen >= 60) {
info->framesFullyOnscreen = 0;
info->positionState = POSITION_STATE_ASCENDING;
}
break;
case POSITION_STATE_ASCENDING:
info->layerY += 4;
if (info->layerY > 38) {
info->layerY = 38;
}
BgSetPosTextAndCommit(info->bgConfig, GF_BG_LYR_MAIN_3, BG_POS_OP_SET_Y, info->layerY);
if (info->layerY == 38) {
if (info->gonnaDrawAnother) {
info->gonnaDrawAnother = FALSE;
DrawAreaIcon(info, sub_02068F84(info->mapsecMsgData, info->mapsec, info->mapNameString));
PrintMapNameOnIcon(info, info->mapNameString);
info->positionState = POSITION_STATE_DESCENDING;
return;
}
FieldDrawMapName_Reset(info);
}
break;
case POSITION_STATE_INVALID:
break;
}
}
static void PrintMapNameOnIcon(FieldDrawMapNameInfo *info, String *name) {
AddTextPrinterParameterizedWithColor(&info->window, 0, name, info->nameX, 8, TEXT_SPEED_INSTANT, MAKE_TEXT_COLOR(1, 2, 0), NULL);
}
static void FieldDrawMapName_StartAscending(FieldDrawMapNameInfo *info) {
info->positionState = POSITION_STATE_ASCENDING;
info->framesFullyOnscreen = 0;
}
FieldDrawMapNameInfo *FieldDrawMapNameInfo_Create(BgConfig *bgConfig) {
FieldDrawMapNameInfo *ret = AllocFromHeap(HEAP_ID_4, sizeof(FieldDrawMapNameInfo));
ret->mapNameString = String_New(22, HEAP_ID_4);
FieldDrawMapName_Init(ret, bgConfig);
FieldDrawMapName_SetupWindow(ret);
ret->mapsecMsgData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0279_bin, HEAP_ID_4);
return ret;
}
void FieldDrawMapNameInfo_Destroy(FieldDrawMapNameInfo *info) {
DestroyMsgData(info->mapsecMsgData);
RemoveWindow(&info->window);
String_Delete(info->mapNameString);
FreeToHeap(info);
}
static void FieldDrawMapName_Start(FieldDrawMapNameInfo *info, u32 mapsec, u32 areaIcon) {
info->mapsec = mapsec;
if (!info->onScreen) {
info->onScreen = TRUE;
BgSetPosTextAndCommit(info->bgConfig, GF_BG_LYR_MAIN_3, BG_POS_OP_SET_Y, 38);
info->layerY = 38;
info->task = SysTask_CreateOnMainQueue((SysTaskFunc)Task_MapNameAndIcon, info, 0);
info->positionState = POSITION_STATE_DESCENDING;
int width = sub_02068F84(info->mapsecMsgData, info->mapsec, info->mapNameString);
info->areaIcon = areaIcon;
DrawAreaIcon(info, width);
PrintMapNameOnIcon(info, info->mapNameString);
} else {
switch (info->positionState) {
case POSITION_STATE_DESCENDING:
case POSITION_STATE_INPLACE:
FieldDrawMapName_StartAscending(info);
info->gonnaDrawAnother = TRUE;
info->areaIcon = areaIcon;
break;
case POSITION_STATE_ASCENDING:
info->gonnaDrawAnother = TRUE;
info->areaIcon = areaIcon;
break;
case POSITION_STATE_INVALID:
default:
GF_ASSERT(FALSE);
break;
}
}
}
void FieldDrawMapName_Reset(FieldDrawMapNameInfo *info) {
if (info->task != NULL) {
SysTask_Destroy(info->task);
}
ClearWindowTilemapAndCopyToVram(&info->window);
BgSetPosTextAndCommit(info->bgConfig, GF_BG_LYR_MAIN_3, BG_POS_OP_SET_Y, 0);
FieldDrawMapName_Init(info, info->bgConfig);
}
void FieldSystem_DrawMapNameAnimation(FieldSystem *fieldSystem) {
if (MapHeader_GetAreaIcon(fieldSystem->location->mapId) == 0 || sub_0203B58C(fieldSystem->location->mapId)) {
return;
}
u32 mapsec = MapHeader_GetMapSec(fieldSystem->location->mapId);
u32 areaIcon = MapHeader_GetAreaIcon(fieldSystem->location->mapId);
if (areaIcon != 0) { // We've already checked for this
areaIcon--;
}
FieldDrawMapName_Start(fieldSystem->unk4->drawMapNameInfo, mapsec, areaIcon);
}

View File

@ -7,7 +7,6 @@
#include "map_events.h"
#include "math_util.h"
#include "overlay_01_021E6880.h"
#include "overlay_01_021EF7A0.h"
#include "overlay_01_021F1AFC.h"
#include "overlay_01_021F3D38.h"
#include "overlay_01_021F6830.h"
@ -238,14 +237,14 @@ void FieldSystem_Control(FieldSystem *fieldSystem) {
case 4:
if (movementAllowed) {
if (FieldInput_Process_BattleTower(&fieldInput, fieldSystem) == TRUE) {
ov01_021EFACC(fieldSystem->unk4->unk8);
FieldDrawMapName_Reset(fieldSystem->unk4->drawMapNameInfo);
ov01_021F3DFC(fieldSystem, 4);
ov01_021F2F24(fieldSystem->playerAvatar);
ov01_021F6830(fieldSystem, 0, 1);
break;
}
if (gSystem.newKeys & PAD_BUTTON_A) {
ov01_021EFACC(fieldSystem->unk4->unk8);
FieldDrawMapName_Reset(fieldSystem->unk4->drawMapNameInfo);
}
movementAllowed = 0;
if (sub_0203E324()) {
@ -258,7 +257,7 @@ void FieldSystem_Control(FieldSystem *fieldSystem) {
if (movementAllowed) {
u32 newEvent = FieldInput_Process(&fieldInput, fieldSystem);
if (newEvent) {
ov01_021EFACC(fieldSystem->unk4->unk8);
FieldDrawMapName_Reset(fieldSystem->unk4->drawMapNameInfo);
ov01_021F3DFC(fieldSystem, 4);
sub_0205CF44(fieldSystem->playerAvatar);
ov01_021F2F24(fieldSystem->playerAvatar);
@ -268,7 +267,7 @@ void FieldSystem_Control(FieldSystem *fieldSystem) {
}
} else {
if (gSystem.newKeys & PAD_BUTTON_A) {
ov01_021EFACC(fieldSystem->unk4->unk8);
FieldDrawMapName_Reset(fieldSystem->unk4->drawMapNameInfo);
}
u32 flag = 0;
if (sub_0203E324()) {

View File

@ -678,7 +678,7 @@ static BOOL sub_02053A2C(TaskManager *taskManager) {
GF_SndHandleMoveVolume(0, 128, 15);
fieldSystem->unkC4 = -1;
sub_02055110(fieldSystem, fieldSystem->location->mapId, 1);
ov01_021EFAF8(fieldSystem);
FieldSystem_DrawMapNameAnimation(fieldSystem);
sub_02053AA0(taskManager);
(*state_p)++;
break;
@ -793,7 +793,7 @@ static BOOL sub_02053C3C(TaskManager *taskManager) {
(*state_p)++;
break;
case 1:
ov01_021EFAF8(fieldSystem);
FieldSystem_DrawMapNameAnimation(fieldSystem);
sub_02053C90(taskManager);
(*state_p)++;
break;

View File

@ -202,11 +202,11 @@ BOOL sub_02055DBC(TaskManager *man) {
TIMEOFDAY time = GF_RTC_GetTimeOfDay();
MapPreviewGraphic_BeginShowImage(man, index, time, parity); // this should set the specific map icon based on time?
env->state++;
ov01_021EFAF8(fieldSystem); //<= this func specifically gets and displays the area's icon and text
FieldSystem_DrawMapNameAnimation(fieldSystem);
break;
}
}
ov01_021EFAF8(fieldSystem);
FieldSystem_DrawMapNameAnimation(fieldSystem);
env->transitionState = 0;
TaskManager_Call(man, sMapEnterRoutines[env->transitionNo], env);
LocalMapObject *followerMon = FollowMon_GetMapObject(fieldSystem);