mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Begin disassembling text.s
This commit is contained in:
parent
b2ec63d69e
commit
20358c4c96
@ -101253,7 +101253,7 @@ _081BA340:
|
||||
ldrb r0, [r6, 0x6]
|
||||
strb r0, [r6, 0x8]
|
||||
ldrb r1, [r6, 0x5]
|
||||
ldr r0, =gUnknown_03002F80
|
||||
ldr r0, =gFonts
|
||||
ldr r2, [r0]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
@ -101559,7 +101559,7 @@ _081BA590:
|
||||
adds r0, r6, 0
|
||||
bl TextPrinterClearDownArrow
|
||||
ldrb r1, [r6, 0x5]
|
||||
ldr r0, =gUnknown_03002F80
|
||||
ldr r0, =gFonts
|
||||
ldr r2, [r0]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
|
251
asm/text.s
251
asm/text.s
@ -5,245 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start SetFontsPointer
|
||||
@ void SetFontsPointer(struct FontInfo *fonts)
|
||||
SetFontsPointer: @ 80045A4
|
||||
ldr r1, =gUnknown_03002F80
|
||||
str r0, [r1]
|
||||
bx lr
|
||||
.pool
|
||||
thumb_func_end SetFontsPointer
|
||||
|
||||
thumb_func_start DeactivateAllTextPrinters
|
||||
@ void DeactivateAllTextPrinters()
|
||||
DeactivateAllTextPrinters: @ 80045B0
|
||||
push {lr}
|
||||
ldr r1, =gUnknown_020201B0
|
||||
movs r2, 0
|
||||
ldr r3, =0x0000045c
|
||||
adds r0, r1, r3
|
||||
_080045BA:
|
||||
strb r2, [r0, 0x1B]
|
||||
subs r0, 0x24
|
||||
cmp r0, r1
|
||||
bge _080045BA
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end DeactivateAllTextPrinters
|
||||
|
||||
thumb_func_start Print
|
||||
@ u16 Print(u8 windowId, u8 fontId, u8 *str, u8 x, u8 y, u8 speed, void ( *callback)(u16, struct TextPrinter *))
|
||||
Print: @ 80045D0
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
sub sp, 0x10
|
||||
ldr r4, [sp, 0x28]
|
||||
ldr r5, [sp, 0x2C]
|
||||
ldr r7, [sp, 0x30]
|
||||
lsls r1, 24
|
||||
lsrs r1, 24
|
||||
lsls r3, 24
|
||||
lsrs r3, 24
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
lsls r5, 24
|
||||
lsrs r5, 24
|
||||
mov r8, r5
|
||||
str r2, [sp]
|
||||
mov r2, sp
|
||||
strb r0, [r2, 0x4]
|
||||
mov r0, sp
|
||||
strb r1, [r0, 0x5]
|
||||
strb r3, [r0, 0x6]
|
||||
strb r4, [r0, 0x7]
|
||||
strb r3, [r0, 0x8]
|
||||
strb r4, [r0, 0x9]
|
||||
ldr r0, =gUnknown_03002F80
|
||||
ldr r0, [r0]
|
||||
lsls r3, r1, 1
|
||||
adds r3, r1
|
||||
lsls r3, 2
|
||||
adds r3, r0
|
||||
ldrb r0, [r3, 0x6]
|
||||
strb r0, [r2, 0xA]
|
||||
mov r1, sp
|
||||
ldrb r0, [r3, 0x7]
|
||||
strb r0, [r1, 0xB]
|
||||
mov r5, sp
|
||||
ldrb r1, [r3, 0x8]
|
||||
lsls r1, 28
|
||||
movs r6, 0xF
|
||||
lsrs r1, 28
|
||||
ldrb r4, [r5, 0xC]
|
||||
movs r2, 0x10
|
||||
negs r2, r2
|
||||
adds r0, r2, 0
|
||||
ands r0, r4
|
||||
orrs r0, r1
|
||||
strb r0, [r5, 0xC]
|
||||
mov r4, sp
|
||||
ldrb r1, [r3, 0x8]
|
||||
lsrs r1, 4
|
||||
lsls r1, 4
|
||||
ands r0, r6
|
||||
orrs r0, r1
|
||||
strb r0, [r4, 0xC]
|
||||
ldrb r0, [r3, 0x9]
|
||||
lsls r0, 28
|
||||
lsrs r0, 28
|
||||
adds r1, r6, 0
|
||||
ands r1, r0
|
||||
ldrb r0, [r4, 0xD]
|
||||
ands r2, r0
|
||||
orrs r2, r1
|
||||
strb r2, [r4, 0xD]
|
||||
mov r1, sp
|
||||
ldrb r0, [r3, 0x9]
|
||||
lsrs r0, 4
|
||||
lsls r0, 4
|
||||
ands r2, r6
|
||||
orrs r2, r0
|
||||
strb r2, [r1, 0xD]
|
||||
mov r0, sp
|
||||
mov r1, r8
|
||||
adds r2, r7, 0
|
||||
bl AddTextPrinter
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
add sp, 0x10
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end Print
|
||||
|
||||
thumb_func_start AddTextPrinter
|
||||
@ u16 AddTextPrinter(struct TextPrinter *textPrinter, u8 speed, void ( *callback)(u16, struct TextPrinter *))
|
||||
AddTextPrinter: @ 800467C
|
||||
push {r4-r7,lr}
|
||||
adds r6, r0, 0
|
||||
mov r12, r2
|
||||
lsls r1, 24
|
||||
lsrs r5, r1, 24
|
||||
ldr r0, =gUnknown_03002F80
|
||||
ldr r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _08004698
|
||||
movs r0, 0
|
||||
b _08004766
|
||||
.pool
|
||||
_08004698:
|
||||
ldr r0, =gUnknown_0202018C
|
||||
movs r2, 0
|
||||
movs r1, 0x1
|
||||
strb r1, [r0, 0x1B]
|
||||
strb r2, [r0, 0x1C]
|
||||
strb r5, [r0, 0x1D]
|
||||
strb r2, [r0, 0x1E]
|
||||
strb r2, [r0, 0x1F]
|
||||
adds r4, r0, 0
|
||||
movs r1, 0x6
|
||||
adds r0, 0x1A
|
||||
_080046AE:
|
||||
strb r2, [r0]
|
||||
subs r0, 0x1
|
||||
subs r1, 0x1
|
||||
cmp r1, 0
|
||||
bge _080046AE
|
||||
adds r1, r4, 0
|
||||
adds r0, r6, 0
|
||||
ldm r0!, {r2,r3,r7}
|
||||
stm r1!, {r2,r3,r7}
|
||||
ldr r0, [r0]
|
||||
str r0, [r1]
|
||||
mov r0, r12
|
||||
str r0, [r4, 0x10]
|
||||
adds r0, r4, 0
|
||||
adds r0, 0x20
|
||||
movs r1, 0
|
||||
strb r1, [r0]
|
||||
adds r0, 0x1
|
||||
strb r1, [r0]
|
||||
ldrb r0, [r6, 0xC]
|
||||
lsrs r0, 4
|
||||
ldrb r2, [r6, 0xD]
|
||||
lsls r1, r2, 28
|
||||
lsrs r1, 28
|
||||
lsrs r2, 4
|
||||
bl GenerateFontHalfRowLookupTable
|
||||
cmp r5, 0xFF
|
||||
beq _08004718
|
||||
cmp r5, 0
|
||||
beq _08004718
|
||||
ldrb r0, [r4, 0x1D]
|
||||
subs r0, 0x1
|
||||
strb r0, [r4, 0x1D]
|
||||
ldr r2, =gUnknown_020201B0
|
||||
ldrb r0, [r6, 0x4]
|
||||
lsls r1, r0, 3
|
||||
adds r1, r0
|
||||
lsls r1, 2
|
||||
adds r1, r2
|
||||
adds r0, r4, 0
|
||||
ldm r0!, {r2-r4}
|
||||
stm r1!, {r2-r4}
|
||||
ldm r0!, {r2,r3,r7}
|
||||
stm r1!, {r2,r3,r7}
|
||||
ldm r0!, {r2,r4,r7}
|
||||
stm r1!, {r2,r4,r7}
|
||||
b _0800475E
|
||||
.pool
|
||||
_08004718:
|
||||
ldr r1, =gUnknown_0202018C
|
||||
movs r0, 0
|
||||
strb r0, [r1, 0x1D]
|
||||
movs r4, 0
|
||||
ldr r7, =0x000003ff
|
||||
b _08004732
|
||||
.pool
|
||||
_0800472C:
|
||||
adds r0, r4, 0x1
|
||||
lsls r0, 16
|
||||
lsrs r4, r0, 16
|
||||
_08004732:
|
||||
cmp r4, r7
|
||||
bhi _08004740
|
||||
ldr r0, =gUnknown_0202018C
|
||||
bl RenderFont
|
||||
cmp r0, 0x1
|
||||
bne _0800472C
|
||||
_08004740:
|
||||
cmp r5, 0xFF
|
||||
beq _0800474E
|
||||
ldr r0, =gUnknown_0202018C
|
||||
ldrb r0, [r0, 0x4]
|
||||
movs r1, 0x2
|
||||
bl CopyWindowToVram
|
||||
_0800474E:
|
||||
ldr r2, =gUnknown_020201B0
|
||||
ldrb r1, [r6, 0x4]
|
||||
lsls r0, r1, 3
|
||||
adds r0, r1
|
||||
lsls r0, 2
|
||||
adds r0, r2
|
||||
movs r1, 0
|
||||
strb r1, [r0, 0x1B]
|
||||
_0800475E:
|
||||
ldr r1, =gUnknown_03002F84
|
||||
movs r0, 0
|
||||
strb r0, [r1]
|
||||
movs r0, 0x1
|
||||
_08004766:
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.pool
|
||||
thumb_func_end AddTextPrinter
|
||||
|
||||
thumb_func_start RunTextPrinters
|
||||
@ void RunTextPrinters()
|
||||
RunTextPrinters: @ 8004778
|
||||
@ -254,7 +15,7 @@ RunTextPrinters: @ 8004778
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _080047F6
|
||||
ldr r0, =gUnknown_020201B0
|
||||
ldr r0, =gTextPrinters
|
||||
movs r6, 0
|
||||
adds r5, r0, 0x4
|
||||
mov r8, r0
|
||||
@ -284,7 +45,7 @@ _080047BE:
|
||||
movs r1, 0x2
|
||||
bl CopyWindowToVram
|
||||
_080047C6:
|
||||
ldr r1, =gUnknown_020201B0
|
||||
ldr r1, =gTextPrinters
|
||||
adds r0, r1, 0
|
||||
adds r0, 0x10
|
||||
adds r0, r6, r0
|
||||
@ -320,7 +81,7 @@ _080047F6:
|
||||
IsTextPrinterActive: @ 8004800
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
ldr r2, =gUnknown_020201B0
|
||||
ldr r2, =gTextPrinters
|
||||
lsls r1, r0, 3
|
||||
adds r1, r0
|
||||
lsls r1, 2
|
||||
@ -337,7 +98,7 @@ RenderFont: @ 8004818
|
||||
adds r4, r0, 0
|
||||
_0800481C:
|
||||
ldrb r1, [r4, 0x5]
|
||||
ldr r0, =gUnknown_03002F80
|
||||
ldr r0, =gFonts
|
||||
ldr r2, [r0]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
@ -2549,7 +2310,7 @@ _080058B8:
|
||||
ldrb r0, [r6, 0x6]
|
||||
strb r0, [r6, 0x8]
|
||||
ldrb r1, [r6, 0x5]
|
||||
ldr r0, =gUnknown_03002F80
|
||||
ldr r0, =gFonts
|
||||
ldr r2, [r0]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
@ -3064,7 +2825,7 @@ _08005CC6:
|
||||
adds r0, r6, 0
|
||||
bl TextPrinterClearDownArrow
|
||||
ldrb r1, [r6, 0x5]
|
||||
ldr r0, =gUnknown_03002F80
|
||||
ldr r0, =gFonts
|
||||
ldr r2, [r0]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef GUARD_TASK_H
|
||||
#define GUARD_TASK_H
|
||||
|
||||
#define NUM_TASKS 16
|
||||
|
||||
typedef void (*TaskFunc)(u8 taskId);
|
||||
|
||||
struct Task
|
||||
|
@ -11,4 +11,64 @@
|
||||
#define CHAR_NEWLINE 0xFE
|
||||
#define EOS 0xFF // end of string
|
||||
|
||||
#define NUM_TEXT_PRINTERS 32
|
||||
|
||||
struct TextWindow {
|
||||
u8* current_text_offset;
|
||||
u8 windowId;
|
||||
u8 fontId;
|
||||
u8 x;
|
||||
u8 y;
|
||||
u8 currentX; // 0x8
|
||||
u8 currentY;
|
||||
u8 letterSpacing;
|
||||
u8 lineSpacing;
|
||||
u8 fontColor_l:4; // 0xC
|
||||
u8 fontColor_h:4;
|
||||
u8 bgColor:4;
|
||||
u8 shadowColor:4;
|
||||
};
|
||||
|
||||
struct TextPrinter
|
||||
{
|
||||
struct TextWindow window;
|
||||
|
||||
void (*callback)(u16, struct TextWindow *); // 0x10
|
||||
|
||||
union {
|
||||
struct
|
||||
{
|
||||
u8 field_0; // 0x14
|
||||
u8 field_1;
|
||||
u8 field_2;
|
||||
u8 field_3;
|
||||
u8 field_4; // 0x18
|
||||
u8 field_5;
|
||||
u8 field_6;
|
||||
u8 field_7;
|
||||
} sub;
|
||||
u8 sub_fields[8];
|
||||
} sub_union;
|
||||
|
||||
u8 state; // 0x1C
|
||||
u8 text_speed;
|
||||
u8 delayCounter;
|
||||
u8 scrollDistance;
|
||||
u8 minLetterSpacing; // 0x20
|
||||
u8 japanese;
|
||||
};
|
||||
|
||||
struct FontInfo
|
||||
{
|
||||
u16 (*fontFunction)(struct TextPrinter *x);
|
||||
u8 maxLetterWidth;
|
||||
u8 maxLetterHeight;
|
||||
u8 letterSpacing;
|
||||
u8 lineSpacing;
|
||||
u8 fontColor_l:4;
|
||||
u8 fontColor_h:4;
|
||||
u8 bgColor:4;
|
||||
u8 shadowColor:4;
|
||||
};
|
||||
|
||||
#endif // GUARD_TEXT_H
|
||||
|
@ -48,6 +48,7 @@ SECTIONS {
|
||||
asm/bg.o(.text);
|
||||
asm/blit.o(.text);
|
||||
asm/window.o(.text);
|
||||
src/text.o(.text);
|
||||
asm/text.o(.text);
|
||||
asm/sprite.o(.text);
|
||||
src/string_util.o(.text);
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "task.h"
|
||||
|
||||
#define NUM_TASKS 16
|
||||
|
||||
#define HEAD_SENTINEL 0xFE
|
||||
#define TAIL_SENTINEL 0xFF
|
||||
|
||||
@ -214,7 +212,7 @@ void SetWordTaskArg(u8 taskId, u8 dataElem, u32 value)
|
||||
|
||||
u32 GetWordTaskArg(u8 taskId, u8 dataElem)
|
||||
{
|
||||
if (dataElem <= 0xE)
|
||||
if (dataElem <= 14)
|
||||
return (u16)gTasks[taskId].data[dataElem] | (gTasks[taskId].data[dataElem + 1] << 16);
|
||||
else
|
||||
return 0;
|
||||
|
99
src/text.c
Normal file
99
src/text.c
Normal file
@ -0,0 +1,99 @@
|
||||
#include "global.h"
|
||||
#include "text.h"
|
||||
#include "battle.h"
|
||||
#include "main.h"
|
||||
#include "palette.h"
|
||||
#include "string_util.h"
|
||||
|
||||
EWRAM_DATA struct TextPrinter gTempTextPrinter;
|
||||
EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS];
|
||||
|
||||
extern u8 gUnknown_03002F84[];
|
||||
|
||||
extern struct FontInfo *gFonts;
|
||||
|
||||
u16 AddTextPrinter(struct TextWindow *textWindow, u8 speed, void (*callback)(u16, struct TextWindow *));
|
||||
void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
|
||||
u32 RenderFont(struct TextPrinter *textPrinter);
|
||||
void CopyWindowToVram(u8 windowId, u8 mode);
|
||||
|
||||
void SetFontsPointer(struct FontInfo *fonts)
|
||||
{
|
||||
gFonts = fonts;
|
||||
}
|
||||
|
||||
void DeactivateAllTextPrinters (void)
|
||||
{
|
||||
int printer;
|
||||
for (printer = 0; printer < NUM_TEXT_PRINTERS; ++printer)
|
||||
gTextPrinters[printer].sub_union.sub.field_7 = 0;
|
||||
}
|
||||
|
||||
u16 Print(u8 windowId, u8 fontId, u8 *str, u8 x, u8 y, u8 speed, void (*callback)(u16, struct TextWindow *))
|
||||
{
|
||||
struct TextWindow window;
|
||||
|
||||
window.current_text_offset = str;
|
||||
window.windowId = windowId;
|
||||
window.fontId = fontId;
|
||||
window.x = x;
|
||||
window.y = y;
|
||||
window.currentX = x;
|
||||
window.currentY = y;
|
||||
window.letterSpacing = gFonts[fontId].letterSpacing;
|
||||
window.lineSpacing = gFonts[fontId].lineSpacing;
|
||||
window.fontColor_l = gFonts[fontId].fontColor_l;
|
||||
window.fontColor_h = gFonts[fontId].fontColor_h;
|
||||
window.bgColor = gFonts[fontId].bgColor;
|
||||
window.shadowColor = gFonts[fontId].shadowColor;
|
||||
return AddTextPrinter(&window, speed, callback);
|
||||
}
|
||||
|
||||
u16 AddTextPrinter(struct TextWindow *textWindow, u8 speed, void (*callback)(u16, struct TextWindow *))
|
||||
{
|
||||
int i;
|
||||
u16 j;
|
||||
|
||||
if (!gFonts)
|
||||
return FALSE;
|
||||
|
||||
gTempTextPrinter.sub_union.sub.field_7 = 1;
|
||||
gTempTextPrinter.state = 0;
|
||||
gTempTextPrinter.text_speed = speed;
|
||||
gTempTextPrinter.delayCounter = 0;
|
||||
gTempTextPrinter.scrollDistance = 0;
|
||||
|
||||
for (i = 0; i < 7; ++i)
|
||||
{
|
||||
gTempTextPrinter.sub_union.sub_fields[i] = 0;
|
||||
}
|
||||
|
||||
gTempTextPrinter.window = *textWindow;
|
||||
gTempTextPrinter.callback = callback;
|
||||
gTempTextPrinter.minLetterSpacing = 0;
|
||||
gTempTextPrinter.japanese = 0;
|
||||
|
||||
GenerateFontHalfRowLookupTable(textWindow->fontColor_h, textWindow->bgColor, textWindow->shadowColor);
|
||||
if (speed != 0xFF && speed != 0x0)
|
||||
{
|
||||
--gTempTextPrinter.text_speed;
|
||||
gTextPrinters[textWindow->windowId] = gTempTextPrinter;
|
||||
}
|
||||
else
|
||||
{
|
||||
gTempTextPrinter.text_speed = 0;
|
||||
for (j = 0; j < 0x400; ++j)
|
||||
{
|
||||
if (RenderFont(&gTempTextPrinter) == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
if (speed != 0xFF)
|
||||
CopyWindowToVram(gTempTextPrinter.window.windowId, 2);
|
||||
gTextPrinters[textWindow->windowId].sub_union.sub.field_7 = 0;
|
||||
}
|
||||
gUnknown_03002F84[0] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// struct means TextWindow, no struct means TextPrinter
|
@ -48,7 +48,7 @@ gUnknown_03002F60: @ 3002F60
|
||||
gUnknown_03002F70: @ 3002F70
|
||||
.space 0x10
|
||||
|
||||
gUnknown_03002F80: @ 3002F80
|
||||
gFonts: @ 3002F80
|
||||
.space 0x4
|
||||
|
||||
gUnknown_03002F84: @ 3002F84
|
||||
|
@ -10,10 +10,10 @@ gUnknown_02020184: @ 2020184
|
||||
gUnknown_02020188: @ 2020188
|
||||
.space 0x4
|
||||
|
||||
gUnknown_0202018C: @ 202018C
|
||||
gTempTextPrinter: @ 202018C
|
||||
.space 0x24
|
||||
|
||||
gUnknown_020201B0: @ 20201B0
|
||||
gTextPrinters: @ 20201B0
|
||||
.space 0x480
|
||||
|
||||
gUnknown_02020630: @ 2020630
|
||||
|
Loading…
Reference in New Issue
Block a user