Merge branch 'master' into decompile_battle_interface

This commit is contained in:
DizzyEggg 2017-10-18 23:05:55 +02:00
commit 7c24b03742
5 changed files with 77 additions and 132 deletions

View File

@ -5,127 +5,6 @@
.text
thumb_func_start GetStringCenterAlignXOffset
@ s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth)
GetStringCenterAlignXOffset: @ 81DB35C
push {lr}
movs r3, 0
bl GetStringCenterAlignXOffsetWithLetterSpacing
pop {r1}
bx r1
thumb_func_end GetStringCenterAlignXOffset
thumb_func_start GetStringRightAlignXOffset
@ s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth)
GetStringRightAlignXOffset: @ 81DB368
push {lr}
movs r3, 0
bl GetStringWidthDifference
pop {r1}
bx r1
thumb_func_end GetStringRightAlignXOffset
thumb_func_start GetStringCenterAlignXOffsetWithLetterSpacing
@ s32 GetStringCenterAlignXOffsetWithLetterSpacing(u8 fontId, u8 *str, s32 totalWidth, s16 letterSpacing)
GetStringCenterAlignXOffsetWithLetterSpacing: @ 81DB374
push {lr}
bl GetStringWidthDifference
lsrs r1, r0, 31
adds r0, r1
asrs r0, 1
pop {r1}
bx r1
thumb_func_end GetStringCenterAlignXOffsetWithLetterSpacing
thumb_func_start GetStringWidthDifference
@ s32 GetStringWidthDifference(u8 fontId, u8 *str, s32 totalWidth, s16 letterSpacing)
GetStringWidthDifference: @ 81DB384
push {r4,lr}
adds r4, r2, 0
adds r2, r3, 0
lsls r0, 24
lsrs r0, 24
lsls r2, 16
asrs r2, 16
bl GetStringWidth
cmp r4, r0
bgt _081DB39E
movs r0, 0
b _081DB3A0
_081DB39E:
subs r0, r4, r0
_081DB3A0:
pop {r4}
pop {r1}
bx r1
thumb_func_end GetStringWidthDifference
thumb_func_start GetMaxWidthInMenuTable
GetMaxWidthInMenuTable: @ 81DB3A8
push {r4-r6,lr}
movs r6, 0
cmp r6, r1
bge _081DB3CC
adds r5, r0, 0
adds r4, r1, 0
_081DB3B4:
ldr r1, [r5]
movs r0, 0x1
movs r2, 0
bl GetStringWidth
cmp r0, r6
ble _081DB3C4
adds r6, r0, 0
_081DB3C4:
adds r5, 0x8
subs r4, 0x1
cmp r4, 0
bne _081DB3B4
_081DB3CC:
adds r0, r6, 0
bl convert_pixel_width_to_tile_width
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end GetMaxWidthInMenuTable
thumb_func_start sub_81DB3D8
sub_81DB3D8: @ 81DB3D8
push {r4-r7,lr}
mov r7, r8
push {r7}
mov r8, r0
adds r7, r1, 0
adds r5, r2, 0
movs r6, 0
movs r4, 0
cmp r6, r5
bge _081DB40A
_081DB3EC:
adds r0, r7, r4
ldrb r0, [r0]
lsls r0, 3
add r0, r8
ldr r1, [r0]
movs r0, 0x1
movs r2, 0
bl GetStringWidth
cmp r0, r6
ble _081DB404
adds r6, r0, 0
_081DB404:
adds r4, 0x1
cmp r4, r5
blt _081DB3EC
_081DB40A:
adds r0, r6, 0
bl convert_pixel_width_to_tile_width
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81DB3D8
thumb_func_start sub_81DB41C
sub_81DB41C: @ 81DB41C

View File

@ -1,13 +1,21 @@
#ifndef GUARD_international_string_util_H
#define GUARD_international_string_util_H
#ifndef GUARD_INTERNATIONAL_STRING_UTIL_H
#define GUARD_INTERNATIONAL_STRING_UTIL_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void TVShowConvertInternationalString(void *dest, const void *src, u8 language);
s32 GetStringCenterAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth);
s32 GetStringRightAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth);
s32 GetStringCenterAlignXOffsetWithLetterSpacing(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing);
s32 GetStringWidthDifference(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing);
s32 GetMaxWidthInMenuTable(const u8 **str, s32 arg1);
s32 sub_81DB3D8(const u8 **str, u8* arg1, s32 arg2);
// sub_81DB41C
// sub_81DB468
// sub_81DB494
// sub_81DB4DC
// sub_81DB52C
// sub_81DB554
// sub_81DB5AC
void TVShowConvertInternationalString(u8 *dest, const u8 *src, u8 language);
u32 sub_81DB604(const u8 *);
// sub_81DB620
#endif //GUARD_international_string_util_H
#endif // GUARD_INTERNATIONAL_STRING_UTIL_H

View File

@ -264,6 +264,7 @@ SECTIONS {
asm/unk_sprite_file.o(.text);
asm/unk_transition.o(.text);
asm/unk_transition_2.o(.text);
src/international_string_util.o(.text);
asm/international_string_util.o(.text);
} =0

View File

@ -5,12 +5,12 @@
#include "text_window.h"
#include "string_util.h"
#include "menu.h"
#include "international_string_util.h"
#define MAX_COINS 9999
EWRAM_DATA u8 sCoinsWindowId = 0;
extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth);
extern void sub_819746C(u8 windowId, bool8 copyToVram);
extern const u8 gText_Coins[];

View File

@ -0,0 +1,57 @@
#include "global.h"
#include "international_string_util.h"
#include "text.h"
extern s32 convert_pixel_width_to_tile_width(s32 a0); // script menu
s32 GetStringCenterAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth)
{
return GetStringCenterAlignXOffsetWithLetterSpacing(fontId, str, totalWidth, 0);
}
s32 GetStringRightAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth)
{
return GetStringWidthDifference(fontId, str, totalWidth, 0);
}
s32 GetStringCenterAlignXOffsetWithLetterSpacing(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing)
{
return GetStringWidthDifference(fontId, str, totalWidth, letterSpacing) / 2;
}
s32 GetStringWidthDifference(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing)
{
s32 stringWidth = GetStringWidth(fontId, str, letterSpacing);
if (totalWidth > stringWidth)
return totalWidth - stringWidth;
else
return 0;
}
s32 GetMaxWidthInMenuTable(const u8 **str, s32 arg1)
{
s32 i, var;
for (var = 0, i = 0; i < arg1; i++)
{
s32 stringWidth = GetStringWidth(1, str[i * 2], 0);
if (stringWidth > var)
var = stringWidth;
}
return convert_pixel_width_to_tile_width(var);
}
s32 sub_81DB3D8(const u8 **str, u8* arg1, s32 arg2)
{
s32 i, var;
for (var = 0, i = 0; i < arg2; i++)
{
s32 stringWidth = GetStringWidth(1, str[arg1[i] * 2], 0);
if (stringWidth > var)
var = stringWidth;
}
return convert_pixel_width_to_tile_width(var);
}