MOD59_021D7D7C

This commit is contained in:
red031000 2022-10-26 18:35:49 +01:00
parent aac20ae613
commit b0d3a3c4d5
No known key found for this signature in database
GPG Key ID: A3C87CFF2DC536C2
5 changed files with 84 additions and 202 deletions

View File

@ -9,198 +9,7 @@
.extern MOD59_TilemapChangePalette
.extern MOD59_021D7C44
.extern MOD59_021D7D7C
thumb_func_start MOD59_021D7ECC
MOD59_021D7ECC: ; 0x021D7ECC
push {r4, r5, r6, r7, lr}
sub sp, #0x1c
add r4, r0, #0
str r1, [sp, #0x10]
ldr r1, [r4, #0x54]
add r6, r2, #0
add r7, r3, #0
mov r5, #0
cmp r1, #5
bls _021D7EE2
b _021D803C
_021D7EE2:
add r1, r1, r1
add r1, pc
ldrh r1, [r1, #6]
lsl r1, r1, #0x10
asr r1, r1, #0x10
add pc, r1
_021D7EEE: ; jump table
.short _021D7EFA - _021D7EEE - 2 ; case 0
.short _021D7FD8 - _021D7EEE - 2 ; case 1
.short _021D7FE4 - _021D7EEE - 2 ; case 2
.short _021D7FF6 - _021D7EEE - 2 ; case 3
.short _021D8016 - _021D7EEE - 2 ; case 4
.short _021D8028 - _021D7EEE - 2 ; case 5
_021D7EFA:
add r0, r5, #0
add r1, r5, #0
bl ToggleBgLayer
mov r0, #1
ldr r1, [r4]
lsl r0, r0, #0xa
bl String_ctor
str r0, [r4, #0x5c]
ldr r0, [r4, #0x4c]
ldr r1, [sp, #0x10]
ldr r2, [r4, #0x5c]
bl ReadMsgDataIntoString
cmp r6, #1
add r0, sp, #0x14
bne _021D7F7C
ldr r1, _021D8044 ; =0x021D9D90
ldrh r2, [r1, #8]
strh r2, [r0]
ldrh r2, [r1, #0xa]
strh r2, [r0, #2]
ldrh r2, [r1, #0xc]
ldrh r1, [r1, #0xe]
strh r2, [r0, #4]
strh r1, [r0, #6]
ldr r0, [r4, #0x5c]
bl FUN_02002F90
mov r1, #0xc
sub r2, r1, r0
add r1, sp, #0x14
strb r2, [r1, #2]
lsl r0, r0, #1
strb r0, [r1, #4]
add r1, r4, #0
ldr r0, [r4, #0x18]
add r1, #0x1c
add r2, sp, #0x14
bl AddWindow
add r1, r5, #0
mov r0, #0xc0
str r0, [sp]
str r0, [sp, #4]
add r0, r4, #0
add r0, #0x1c
add r2, r1, #0
add r3, r1, #0
bl FillWindowPixelRect
add r1, r5, #0
str r1, [sp]
ldr r0, _021D8048 ; =0x00010200
str r1, [sp, #4]
str r0, [sp, #8]
str r1, [sp, #0xc]
add r0, r4, #0
ldr r2, [r4, #0x5c]
add r0, #0x1c
add r3, r1, #0
bl AddTextPrinterParameterized2
b _021D7FCC
_021D7F7C:
ldr r1, _021D8044 ; =0x021D9D90
add r2, sp, #0x14
ldrh r3, [r1]
strh r3, [r0]
ldrh r3, [r1, #2]
strh r3, [r0, #2]
ldrh r3, [r1, #4]
ldrh r1, [r1, #6]
strh r3, [r0, #4]
strh r1, [r0, #6]
ldr r1, [sp, #0x30]
strb r7, [r0, #2]
strb r1, [r0, #4]
add r1, r4, #0
ldr r0, [r4, #0x18]
add r1, #0x1c
bl AddWindow
add r1, r5, #0
mov r0, #0xc0
str r0, [sp]
str r0, [sp, #4]
add r0, r4, #0
add r0, #0x1c
add r2, r1, #0
add r3, r1, #0
bl FillWindowPixelRect
add r1, r5, #0
str r1, [sp]
ldr r0, _021D804C ; =0x000F0200
str r1, [sp, #4]
str r0, [sp, #8]
str r1, [sp, #0xc]
add r0, r4, #0
ldr r2, [r4, #0x5c]
add r0, #0x1c
add r3, r1, #0
bl AddTextPrinterParameterized2
_021D7FCC:
ldr r0, [r4, #0x5c]
bl String_dtor
mov r0, #1
str r0, [r4, #0x54]
b _021D803C
_021D7FD8:
add r0, #0x1c
bl CopyWindowToVram
mov r0, #2
str r0, [r4, #0x54]
b _021D803C
_021D7FE4:
add r1, r5, #0
add r2, r5, #0
bl MOD59_021D7A68
cmp r0, #1
bne _021D803C
mov r0, #3
str r0, [r4, #0x54]
b _021D803C
_021D7FF6:
ldr r0, _021D8050 ; =gMain
ldr r1, [r0, #0x48]
mov r0, #1
and r0, r1
cmp r0, #1
beq _021D800A
mov r0, #2
and r0, r1
cmp r0, #2
bne _021D803C
_021D800A:
ldr r0, _021D8054 ; =0x000005DC
bl PlaySE
mov r0, #4
str r0, [r4, #0x54]
b _021D803C
_021D8016:
add r1, r5, #0
mov r2, #1
bl MOD59_021D7A68
cmp r0, #1
bne _021D803C
mov r0, #5
str r0, [r4, #0x54]
b _021D803C
_021D8028:
add r0, #0x1c
bl RemoveWindow
ldr r0, [r4, #0x18]
add r1, r5, #0
bl BgClearTilemapBufferAndCommit
add r0, r5, #0
str r0, [r4, #0x54]
mov r5, #1
_021D803C:
add r0, r5, #0
add sp, #0x1c
pop {r4, r5, r6, r7, pc}
nop
_021D8044: .word MOD59_021D9D90
_021D8048: .word 0x00010200
_021D804C: .word 0x000F0200
_021D8050: .word gMain
_021D8054: .word 0x000005DC
thumb_func_end MOD59_021D7ECC
.extern MOD59_021D7ECC
thumb_func_start MOD59_021D8058
MOD59_021D8058: ; 0x021D8058

View File

@ -59,7 +59,13 @@ typedef struct MOD59_OverlayData
struct MOD59_ListStruct021D9E0C
{
u32 msgNo;
u32 val;
s32 val;
};
struct MOD59_WindowTemplateGroup
{
struct WindowTemplate template1;
struct WindowTemplate template2;
};
BOOL MOD59_Init(struct UnkStruct_02006234 *param0);

View File

@ -39,6 +39,8 @@ extern const struct MOD59_ListStruct021D9E0C MOD59_021D9F40;
extern const struct MOD59_ListStruct021D9E0C MOD59_021D9F68;
extern const struct ListMenuTemplate MOD59_021D9EF8;
extern const struct MOD59_WindowTemplateGroup MOD59_021D9D90;
extern void MOD59_021D8058(MOD59_OverlayData *data);
extern u32 MOD59_021D8920(MOD59_OverlayData *data);
@ -607,3 +609,68 @@ THUMB_FUNC BOOL MOD59_021D7D7C(MOD59_OverlayData *data, u32 param1, u32 param2,
}
return ret;
}
THUMB_FUNC BOOL MOD59_021D7ECC(MOD59_OverlayData *data, u32 msgNo, u32 param2, u32 tilemapTop, u32 height)
{
BOOL ret = 0;
switch (data->unk54)
{
case 0:
ToggleBgLayer(GF_BG_LYR_MAIN_0, GX_LAYER_TOGGLE_OFF);
data->string = String_ctor(1024, data->heap_id);
ReadMsgDataIntoString(data->msgData, msgNo, data->string);
struct WindowTemplate template;
if (param2 == 1)
{
template = MOD59_021D9D90.template2;
u32 count = FUN_02002F90(data->string);
template.tilemapTop = 12 - count;
template.height = count * 2;
AddWindow(data->bgConfig, &data->window, &template);
FillWindowPixelRect(&data->window, 0, 0, 0, 192, 192);
AddTextPrinterParameterized2(&data->window, 0, data->string, 0, 0, 0, MakeFontColor(1, 2, 0), NULL);
}
else
{
template = MOD59_021D9D90.template1;
template.tilemapTop = tilemapTop;
template.height = height;
AddWindow(data->bgConfig, &data->window, &template);
FillWindowPixelRect(&data->window, 0, 0, 0, 192, 192);
AddTextPrinterParameterized2(&data->window, 0, data->string, 0, 0, 0, MakeFontColor(15, 2, 0), NULL);
}
String_dtor(data->string);
data->unk54 = 1;
break;
case 1:
CopyWindowToVram(&data->window);
data->unk54 = 2;
break;
case 2:
if (MOD59_021D7A68(data, 0, 0) == TRUE)
{
data->unk54 = 3;
}
break;
case 3:
if((gMain.newKeys & 1) != 1 && (gMain.newKeys & 2) != 2)
{
break;
}
PlaySE(SEQ_SE_DP_SELECT);
data->unk54 = 4;
break;
case 4:
if (MOD59_021D7A68(data, 0, 1) == TRUE)
{
data->unk54 = 5;
}
break;
case 5:
RemoveWindow(&data->window);
BgClearTilemapBufferAndCommit(data->bgConfig, 0);
data->unk54 = 0;
ret = TRUE;
}
return ret;
}

View File

@ -10,15 +10,6 @@ void ListMenuDrawCursor(struct ListMenu * list);
BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown);
void ListMenuCallSelectionChangedCallback(struct ListMenu * list, u8 onInit);
static inline u32 MakeFontColor(u32 fgPal, u32 shdwPal, u32 bgPal)
{
return (u32)(
((u32)(fgPal << 24) >> 8)
| ((u32)(shdwPal << 24) >> 16)
| ((u32)(bgPal << 24) >> 24)
);
}
THUMB_FUNC struct ListMenu * ListMenuInit(const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u32 heap_id)
{
struct ListMenu * list = AllocFromHeap(heap_id, sizeof(struct ListMenu));

View File

@ -4,6 +4,15 @@
#include "global.h"
#include "text.h"
static inline u32 MakeFontColor(u32 fgPal, u32 shdwPal, u32 bgPal)
{
return (u32)(
((u32)(fgPal << 24) >> 8)
| ((u32)(shdwPal << 24) >> 16)
| ((u32)(bgPal << 24) >> 24)
);
}
struct UnkStruct_02002C14_sub
{
const char buf[0x80];