decompile text window

This commit is contained in:
DizzyEggg 2017-09-01 19:01:58 +02:00
parent 1d2be3c5e8
commit 6987dd9a21
3 changed files with 134 additions and 687 deletions

View File

@ -1,686 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_8098758
sub_8098758: @ 8098758
push {lr}
lsls r0, 24
lsrs r0, 24
cmp r0, 0x13
bhi _08098770
lsls r0, 3
ldr r1, =gUnknown_0851021C
adds r0, r1
b _08098772
.pool
_08098770:
ldr r0, =gUnknown_0851021C
_08098772:
pop {r1}
bx r1
.pool
thumb_func_end sub_8098758
thumb_func_start copy_textbox_border_tile_patterns_to_vram
@ void copy_textbox_border_tile_patterns_to_vram(u8 rbox_id, u16 tile_pattern_dest_offset, u8 pal_dest_offset)
copy_textbox_border_tile_patterns_to_vram: @ 809877C
push {r4,r5,lr}
adds r4, r1, 0
adds r5, r2, 0
lsls r0, 24
lsrs r0, 24
lsls r4, 16
lsrs r4, 16
lsls r5, 24
lsrs r5, 24
movs r1, 0
bl GetWindowAttribute
lsls r0, 24
lsrs r0, 24
ldr r1, =gUnknown_08DDD748
movs r2, 0xE0
lsls r2, 1
adds r3, r4, 0
bl LoadBgTiles
bl sub_8098C64
adds r1, r5, 0
movs r2, 0x20
bl LoadPalette
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end copy_textbox_border_tile_patterns_to_vram
thumb_func_start box_border_load_tiles_and_pal
box_border_load_tiles_and_pal: @ 80987BC
push {lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 16
lsrs r1, 16
lsls r2, 24
lsrs r2, 24
bl sub_809882C
pop {r0}
bx r0
thumb_func_end box_border_load_tiles_and_pal
thumb_func_start sub_80987D4
sub_80987D4: @ 80987D4
push {r4-r6,lr}
mov r6, r8
push {r6}
adds r4, r1, 0
adds r6, r2, 0
mov r8, r3
lsls r0, 24
lsrs r0, 24
lsls r4, 24
lsrs r4, 24
lsls r6, 16
lsrs r6, 16
mov r1, r8
lsls r1, 24
lsrs r1, 24
mov r8, r1
movs r1, 0
bl GetWindowAttribute
lsls r0, 24
lsrs r0, 24
ldr r5, =gUnknown_0851021C
lsls r4, 3
adds r1, r4, r5
ldr r1, [r1]
movs r2, 0x90
lsls r2, 1
adds r3, r6, 0
bl LoadBgTiles
adds r5, 0x4
adds r4, r5
ldr r0, [r4]
mov r1, r8
movs r2, 0x20
bl LoadPalette
pop {r3}
mov r8, r3
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80987D4
thumb_func_start sub_809882C
sub_809882C: @ 809882C
push {r4,lr}
adds r4, r1, 0
adds r3, r2, 0
lsls r0, 24
lsrs r0, 24
lsls r4, 16
lsrs r4, 16
lsls r3, 24
lsrs r3, 24
ldr r1, =gSaveBlock2Ptr
ldr r1, [r1]
ldrb r1, [r1, 0x14]
lsrs r1, 3
adds r2, r4, 0
bl sub_80987D4
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_809882C
thumb_func_start sub_8098858
sub_8098858: @ 8098858
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x20
adds r4, r0, 0
adds r5, r1, 0
lsls r4, 24
lsrs r4, 24
lsls r5, 16
lsrs r5, 16
lsls r2, 24
lsrs r2, 24
str r2, [sp, 0xC]
adds r0, r4, 0
movs r1, 0
bl GetWindowAttribute
lsls r0, 24
lsrs r7, r0, 24
adds r0, r4, 0
movs r1, 0x1
bl GetWindowAttribute
mov r8, r0
lsls r0, 16
lsrs r0, 16
mov r8, r0
adds r0, r4, 0
movs r1, 0x2
bl GetWindowAttribute
adds r6, r0, 0
lsls r6, 16
lsrs r6, 16
adds r0, r4, 0
movs r1, 0x3
bl GetWindowAttribute
mov r9, r0
mov r2, r9
lsls r2, 16
lsrs r2, 16
mov r9, r2
adds r0, r4, 0
movs r1, 0x4
bl GetWindowAttribute
lsls r0, 16
lsrs r0, 16
str r0, [sp, 0x10]
mov r0, r8
subs r0, 0x1
lsls r2, r0, 24
lsrs r2, 24
str r2, [sp, 0x14]
subs r4, r6, 0x1
lsls r4, 24
lsrs r4, 24
movs r0, 0x1
mov r10, r0
str r0, [sp]
str r0, [sp, 0x4]
ldr r2, [sp, 0xC]
str r2, [sp, 0x8]
adds r0, r7, 0
adds r1, r5, 0
ldr r2, [sp, 0x14]
adds r3, r4, 0
bl FillBgTilemapBufferRect
adds r1, r5, 0x1
lsls r1, 16
lsrs r1, 16
mov r0, r8
lsls r2, r0, 24
lsrs r2, 24
str r2, [sp, 0x18]
mov r2, r9
lsls r0, r2, 24
lsrs r0, 24
str r0, [sp, 0x1C]
str r0, [sp]
mov r0, r10
str r0, [sp, 0x4]
ldr r2, [sp, 0xC]
str r2, [sp, 0x8]
adds r0, r7, 0
ldr r2, [sp, 0x18]
adds r3, r4, 0
bl FillBgTilemapBufferRect
adds r1, r5, 0x2
lsls r1, 16
lsrs r1, 16
add r8, r9
mov r0, r8
lsls r0, 24
lsrs r0, 24
mov r8, r0
mov r2, r10
str r2, [sp]
str r2, [sp, 0x4]
ldr r0, [sp, 0xC]
str r0, [sp, 0x8]
adds r0, r7, 0
mov r2, r8
adds r3, r4, 0
bl FillBgTilemapBufferRect
adds r1, r5, 0x3
lsls r1, 16
lsrs r1, 16
lsls r2, r6, 24
lsrs r2, 24
mov r9, r2
mov r0, r10
str r0, [sp]
ldr r2, [sp, 0x10]
lsls r4, r2, 24
lsrs r4, 24
str r4, [sp, 0x4]
ldr r0, [sp, 0xC]
str r0, [sp, 0x8]
adds r0, r7, 0
ldr r2, [sp, 0x14]
mov r3, r9
bl FillBgTilemapBufferRect
adds r1, r5, 0x5
lsls r1, 16
lsrs r1, 16
mov r2, r10
str r2, [sp]
str r4, [sp, 0x4]
ldr r0, [sp, 0xC]
str r0, [sp, 0x8]
adds r0, r7, 0
mov r2, r8
mov r3, r9
bl FillBgTilemapBufferRect
adds r1, r5, 0x6
lsls r1, 16
lsrs r1, 16
ldr r2, [sp, 0x10]
adds r6, r2
lsls r6, 24
lsrs r6, 24
mov r0, r10
str r0, [sp]
str r0, [sp, 0x4]
ldr r2, [sp, 0xC]
str r2, [sp, 0x8]
adds r0, r7, 0
ldr r2, [sp, 0x14]
adds r3, r6, 0
bl FillBgTilemapBufferRect
adds r1, r5, 0x7
lsls r1, 16
lsrs r1, 16
ldr r0, [sp, 0x1C]
str r0, [sp]
mov r2, r10
str r2, [sp, 0x4]
ldr r0, [sp, 0xC]
str r0, [sp, 0x8]
adds r0, r7, 0
ldr r2, [sp, 0x18]
adds r3, r6, 0
bl FillBgTilemapBufferRect
adds r5, 0x8
lsls r5, 16
lsrs r5, 16
mov r2, r10
str r2, [sp]
str r2, [sp, 0x4]
ldr r0, [sp, 0xC]
str r0, [sp, 0x8]
adds r0, r7, 0
adds r1, r5, 0
mov r2, r8
adds r3, r6, 0
bl FillBgTilemapBufferRect
add sp, 0x20
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_8098858
thumb_func_start sub_80989E0
sub_80989E0: @ 80989E0
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x1C
adds r4, r0, 0
mov r9, r1
lsls r4, 24
lsrs r4, 24
mov r0, r9
lsls r0, 16
lsrs r0, 16
mov r9, r0
lsls r2, 24
lsrs r2, 24
mov r10, r2
adds r0, r4, 0
movs r1, 0
bl GetWindowAttribute
lsls r0, 24
lsrs r7, r0, 24
adds r0, r4, 0
movs r1, 0x1
bl GetWindowAttribute
mov r8, r0
lsls r0, 16
lsrs r0, 16
mov r8, r0
adds r0, r4, 0
movs r1, 0x2
bl GetWindowAttribute
adds r6, r0, 0
lsls r6, 16
lsrs r6, 16
adds r0, r4, 0
movs r1, 0x3
bl GetWindowAttribute
adds r5, r0, 0
lsls r5, 16
lsrs r5, 16
adds r0, r4, 0
movs r1, 0x4
bl GetWindowAttribute
lsls r0, 16
lsrs r0, 16
str r0, [sp, 0xC]
mov r0, r8
lsls r2, r0, 24
lsrs r2, 24
str r2, [sp, 0x10]
lsls r4, r6, 24
lsrs r4, 24
movs r0, 0x1
str r0, [sp]
str r0, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
mov r1, r9
adds r3, r4, 0
bl FillBgTilemapBufferRect
mov r1, r9
adds r1, 0x1
lsls r1, 16
lsrs r1, 16
mov r0, r8
adds r0, 0x1
lsls r2, r0, 24
lsrs r2, 24
str r2, [sp, 0x14]
subs r0, r5, 0x2
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x18]
str r0, [sp]
movs r0, 0x1
str r0, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
adds r3, r4, 0
bl FillBgTilemapBufferRect
mov r1, r9
adds r1, 0x2
lsls r1, 16
lsrs r1, 16
add r8, r5
movs r0, 0x1
negs r0, r0
add r8, r0
mov r0, r8
lsls r0, 24
lsrs r0, 24
mov r8, r0
movs r0, 0x1
str r0, [sp]
str r0, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
mov r2, r8
adds r3, r4, 0
bl FillBgTilemapBufferRect
mov r1, r9
adds r1, 0x3
lsls r1, 16
lsrs r1, 16
adds r5, r6, 0x1
lsls r5, 24
lsrs r5, 24
movs r0, 0x1
str r0, [sp]
ldr r4, [sp, 0xC]
subs r4, 0x2
lsls r4, 24
lsrs r4, 24
str r4, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
ldr r2, [sp, 0x10]
adds r3, r5, 0
bl FillBgTilemapBufferRect
mov r1, r9
adds r1, 0x5
lsls r1, 16
lsrs r1, 16
movs r0, 0x1
str r0, [sp]
str r4, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
mov r2, r8
adds r3, r5, 0
bl FillBgTilemapBufferRect
mov r1, r9
adds r1, 0x6
lsls r1, 16
lsrs r1, 16
ldr r0, [sp, 0xC]
adds r6, r0
subs r6, 0x1
lsls r6, 24
lsrs r6, 24
movs r0, 0x1
str r0, [sp]
str r0, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
ldr r2, [sp, 0x10]
adds r3, r6, 0
bl FillBgTilemapBufferRect
mov r1, r9
adds r1, 0x7
lsls r1, 16
lsrs r1, 16
ldr r0, [sp, 0x18]
str r0, [sp]
movs r0, 0x1
str r0, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
ldr r2, [sp, 0x14]
adds r3, r6, 0
bl FillBgTilemapBufferRect
movs r0, 0x8
add r9, r0
mov r0, r9
lsls r0, 16
lsrs r0, 16
mov r9, r0
movs r0, 0x1
str r0, [sp]
str r0, [sp, 0x4]
mov r0, r10
str r0, [sp, 0x8]
adds r0, r7, 0
mov r1, r9
mov r2, r8
adds r3, r6, 0
bl FillBgTilemapBufferRect
add sp, 0x1C
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_80989E0
thumb_func_start rbox_fill_rectangle
rbox_fill_rectangle: @ 8098B7C
push {r4-r6,lr}
mov r6, r9
mov r5, r8
push {r5,r6}
sub sp, 0xC
adds r6, r0, 0
lsls r6, 24
lsrs r6, 24
adds r0, r6, 0
movs r1, 0
bl GetWindowAttribute
mov r9, r0
lsls r0, 24
lsrs r0, 24
mov r9, r0
adds r0, r6, 0
movs r1, 0x1
bl GetWindowAttribute
mov r8, r0
mov r1, r8
lsls r1, 16
lsrs r1, 16
mov r8, r1
adds r0, r6, 0
movs r1, 0x2
bl GetWindowAttribute
adds r5, r0, 0
lsls r5, 16
lsrs r5, 16
adds r0, r6, 0
movs r1, 0x3
bl GetWindowAttribute
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
adds r0, r6, 0
movs r1, 0x4
bl GetWindowAttribute
movs r1, 0x1
negs r1, r1
add r8, r1
mov r1, r8
lsls r1, 24
lsrs r1, 24
mov r8, r1
subs r5, 0x1
lsls r5, 24
lsrs r5, 24
adds r4, 0x2
lsls r4, 24
lsrs r4, 24
str r4, [sp]
lsls r0, 24
movs r1, 0x80
lsls r1, 18
adds r0, r1
lsrs r0, 24
str r0, [sp, 0x4]
movs r0, 0x11
str r0, [sp, 0x8]
mov r0, r9
movs r1, 0
mov r2, r8
adds r3, r5, 0
bl FillBgTilemapBufferRect
add sp, 0xC
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end rbox_fill_rectangle
thumb_func_start stdpal_get
stdpal_get: @ 8098C18
push {lr}
lsls r0, 24
lsrs r0, 24
cmp r0, 0x4
bhi _08098C54
lsls r0, 2
ldr r1, =_08098C30
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08098C30:
.4byte _08098C44
.4byte _08098C48
.4byte _08098C4C
.4byte _08098C50
.4byte _08098C54
_08098C44:
movs r0, 0
b _08098C56
_08098C48:
movs r0, 0x10
b _08098C56
_08098C4C:
movs r0, 0x20
b _08098C56
_08098C50:
movs r0, 0x30
b _08098C56
_08098C54:
movs r0, 0x40
_08098C56:
lsls r0, 1
ldr r1, =gUnknown_0851017C
adds r0, r1
pop {r1}
bx r1
.pool
thumb_func_end stdpal_get
thumb_func_start sub_8098C64
sub_8098C64: @ 8098C64
ldr r0, =gUnknown_08DDD728
bx lr
.pool
thumb_func_end sub_8098C64
thumb_func_start sub_8098C6C
sub_8098C6C: @ 8098C6C
push {r4,r5,lr}
adds r3, r1, 0
adds r4, r2, 0
lsls r0, 24
lsrs r0, 24
lsls r3, 16
lsrs r3, 16
lsls r4, 24
lsrs r4, 24
ldr r2, =gUnknown_0851021C
ldr r5, =gSaveBlock2Ptr
ldr r1, [r5]
ldrb r1, [r1, 0x14]
lsrs r1, 3
lsls r1, 3
adds r1, r2
ldr r1, [r1]
movs r2, 0x90
lsls r2, 1
bl LoadBgTiles
ldr r0, [r5]
ldrb r0, [r0, 0x14]
lsrs r0, 3
bl sub_8098758
ldr r0, [r0, 0x4]
adds r1, r4, 0
movs r2, 0x20
bl LoadPalette
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8098C6C
.align 2, 0 @ Don't pad with nop.

View File

@ -86,7 +86,7 @@ SECTIONS {
asm/map_obj_8097404.o(.text);
asm/field_message_box.o(.text);
asm/map_obj_lock.o(.text);
asm/text_window.o(.text);
src/text_window.o(.text);
asm/script.o(.text);
asm/scrcmd.o(.text);
asm/field_control_avatar.o(.text);

133
src/text_window.c Normal file
View File

@ -0,0 +1,133 @@
#include "global.h"
#include "text.h"
#include "window.h"
#include "palette.h"
extern u8 LoadBgTiles(u8 bg, const void *src, u16 size, u16 destOffset);
extern void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
struct TilesPal
{
u32* tiles;
u16* pal;
};
extern const struct TilesPal gUnknown_0851021C[];
extern const u32 gUnknown_08DDD748[];
extern const u16 gUnknown_0851017C[];
extern const u16 gUnknown_08DDD728[];
const u16* sub_8098C64(void);
void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset);
const struct TilesPal* sub_8098758(u8 id)
{
if (id > 19)
return &gUnknown_0851021C[0];
else
return &gUnknown_0851021C[id];
}
void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset)
{
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_08DDD748, 0x1C0, destOffset);
LoadPalette(sub_8098C64(), palOffset, 0x20);
}
void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset)
{
sub_809882C(windowId, destOffset, palOffset);
}
void sub_80987D4(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset)
{
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_0851021C[frameId].tiles, 0x120, destOffset);
LoadPalette(gUnknown_0851021C[frameId].pal, palOffset, 0x20);
}
void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset)
{
sub_80987D4(windowId, gSaveBlock2Ptr->optionsWindowFrameType, destOffset, palOffset);
}
void sub_8098858(u8 windowId, u16 tileNum, u8 palNum)
{
u8 bgLayer = GetWindowAttribute(windowId, WINDOW_PRIORITY);
u16 tilemapLeft = GetWindowAttribute(windowId, WINDOW_TILEMAP_LEFT);
u16 tilemapTop = GetWindowAttribute(windowId, WINDOW_TILEMAP_TOP);
u16 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
u16 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
FillBgTilemapBufferRect(bgLayer, tileNum + 0, tilemapLeft - 1, tilemapTop - 1, 1, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 1, tilemapLeft, tilemapTop - 1, width, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 2, tilemapLeft + width, tilemapTop - 1, 1, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 3, tilemapLeft - 1, tilemapTop, 1, height, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 5, tilemapLeft + width, tilemapTop, 1, height, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 6, tilemapLeft - 1, tilemapTop + height, 1, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 7, tilemapLeft, tilemapTop + height, width, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 8, tilemapLeft + width, tilemapTop + height, 1, 1, palNum);
}
void sub_80989E0(u8 windowId, u16 tileNum, u8 palNum)
{
u8 bgLayer = GetWindowAttribute(windowId, WINDOW_PRIORITY);
u16 tilemapLeft = GetWindowAttribute(windowId, WINDOW_TILEMAP_LEFT);
u16 tilemapTop = GetWindowAttribute(windowId, WINDOW_TILEMAP_TOP);
u16 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
u16 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
FillBgTilemapBufferRect(bgLayer, tileNum + 0, tilemapLeft, tilemapTop, 1, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 1, tilemapLeft + 1, tilemapTop, width - 2, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 2, tilemapLeft + width - 1, tilemapTop, 1, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 3, tilemapLeft, tilemapTop + 1, 1, height - 2, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 5, tilemapLeft + width - 1, tilemapTop + 1, 1, height - 2, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 6, tilemapLeft, tilemapTop + height - 1, 1, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 7, tilemapLeft + 1, tilemapTop + height - 1, width - 2, 1, palNum);
FillBgTilemapBufferRect(bgLayer, tileNum + 8, tilemapLeft + width - 1, tilemapTop + height - 1, 1, 1, palNum);
}
void rbox_fill_rectangle(u8 windowId)
{
u8 bgLayer = GetWindowAttribute(windowId, WINDOW_PRIORITY);
u16 tilemapLeft = GetWindowAttribute(windowId, WINDOW_TILEMAP_LEFT);
u16 tilemapTop = GetWindowAttribute(windowId, WINDOW_TILEMAP_TOP);
u16 width = GetWindowAttribute(windowId, WINDOW_WIDTH);
u16 height = GetWindowAttribute(windowId, WINDOW_HEIGHT);
FillBgTilemapBufferRect(bgLayer, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0x11);
}
const u16* stdpal_get(u8 id)
{
switch (id)
{
case 0:
id = 0;
break;
case 1:
id = 0x10;
break;
case 2:
id = 0x20;
break;
case 3:
id = 0x30;
break;
case 4:
default:
id = 0x40;
break;
}
return &gUnknown_0851017C[id];
}
const u16* sub_8098C64(void)
{
return gUnknown_08DDD728;
}
void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset)
{
LoadBgTiles(bg, gUnknown_0851021C[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset);
LoadPalette(sub_8098758(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20);
}