mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
walda phrase is done
This commit is contained in:
parent
cda5c5f925
commit
8c85a27346
@ -1,168 +0,0 @@
|
||||
.include "asm/macros.inc"
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
|
||||
|
||||
thumb_func_start sub_81D9CDC
|
||||
sub_81D9CDC: @ 81D9CDC
|
||||
push {r4-r6,lr}
|
||||
adds r6, r0, 0
|
||||
adds r5, r1, 0
|
||||
lsls r2, 24
|
||||
lsrs r3, r2, 24
|
||||
lsls r0, r3, 4
|
||||
orrs r3, r0
|
||||
lsls r0, r3, 24
|
||||
lsrs r3, r0, 24
|
||||
movs r4, 0
|
||||
cmp r4, r5
|
||||
bcs _081D9D04
|
||||
_081D9CF4:
|
||||
adds r2, r6, r4
|
||||
ldrb r1, [r2]
|
||||
adds r0, r3, 0
|
||||
eors r0, r1
|
||||
strb r0, [r2]
|
||||
adds r4, 0x1
|
||||
cmp r4, r5
|
||||
bcc _081D9CF4
|
||||
_081D9D04:
|
||||
pop {r4-r6}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_81D9CDC
|
||||
|
||||
thumb_func_start sub_81D9D0C
|
||||
sub_81D9D0C: @ 81D9D0C
|
||||
push {lr}
|
||||
lsrs r3, r1, 3
|
||||
movs r2, 0x7
|
||||
ands r2, r1
|
||||
movs r1, 0x80
|
||||
asrs r1, r2
|
||||
adds r0, r3
|
||||
ldrb r0, [r0]
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _081D9D24
|
||||
movs r0, 0x1
|
||||
_081D9D24:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_81D9D0C
|
||||
|
||||
thumb_func_start sub_81D9D28
|
||||
sub_81D9D28: @ 81D9D28
|
||||
lsrs r3, r1, 3
|
||||
movs r2, 0x7
|
||||
ands r2, r1
|
||||
movs r1, 0x80
|
||||
asrs r1, r2
|
||||
lsls r1, 24
|
||||
lsrs r1, 24
|
||||
adds r0, r3
|
||||
ldrb r2, [r0]
|
||||
orrs r1, r2
|
||||
strb r1, [r0]
|
||||
bx lr
|
||||
thumb_func_end sub_81D9D28
|
||||
|
||||
thumb_func_start sub_81D9D40
|
||||
sub_81D9D40: @ 81D9D40
|
||||
lsrs r3, r1, 3
|
||||
movs r2, 0x7
|
||||
ands r2, r1
|
||||
movs r1, 0x80
|
||||
asrs r1, r2
|
||||
mvns r1, r1
|
||||
lsls r1, 24
|
||||
lsrs r1, 24
|
||||
adds r0, r3
|
||||
ldrb r2, [r0]
|
||||
ands r1, r2
|
||||
strb r1, [r0]
|
||||
bx lr
|
||||
thumb_func_end sub_81D9D40
|
||||
|
||||
thumb_func_start sub_81D9D5C
|
||||
sub_81D9D5C: @ 81D9D5C
|
||||
push {r4-r7,lr}
|
||||
mov r7, r9
|
||||
mov r6, r8
|
||||
push {r6,r7}
|
||||
adds r6, r0, 0
|
||||
mov r9, r1
|
||||
adds r1, r2, 0
|
||||
mov r8, r3
|
||||
ldr r7, [sp, 0x1C]
|
||||
movs r5, 0
|
||||
cmp r5, r7
|
||||
bcs _081D9DA0
|
||||
adds r4, r1, 0
|
||||
_081D9D76:
|
||||
mov r0, r8
|
||||
adds r1, r0, r5
|
||||
mov r0, r9
|
||||
bl sub_81D9D0C
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _081D9D90
|
||||
adds r0, r6, 0
|
||||
adds r1, r4, 0
|
||||
bl sub_81D9D28
|
||||
b _081D9D98
|
||||
_081D9D90:
|
||||
adds r0, r6, 0
|
||||
adds r1, r4, 0
|
||||
bl sub_81D9D40
|
||||
_081D9D98:
|
||||
adds r4, 0x1
|
||||
adds r5, 0x1
|
||||
cmp r5, r7
|
||||
bcc _081D9D76
|
||||
_081D9DA0:
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_81D9D5C
|
||||
|
||||
thumb_func_start sub_81D9DAC
|
||||
sub_81D9DAC: @ 81D9DAC
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
mov r8, r0
|
||||
adds r7, r1, 0
|
||||
adds r6, r2, 0
|
||||
movs r4, 0
|
||||
movs r5, 0
|
||||
cmp r4, r6
|
||||
bcs _081D9DD6
|
||||
_081D9DC0:
|
||||
lsls r4, 1
|
||||
adds r1, r7, r5
|
||||
mov r0, r8
|
||||
bl sub_81D9D0C
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
orrs r4, r0
|
||||
adds r5, 0x1
|
||||
cmp r5, r6
|
||||
bcc _081D9DC0
|
||||
_081D9DD6:
|
||||
adds r0, r4, 0
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_81D9DAC
|
||||
|
||||
.align 2, 0 @ Don't pad with nop.
|
7
include/walda_phrase.h
Normal file
7
include/walda_phrase.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef GUARD_WALDA_PHRASE_H
|
||||
#define GUARD_WALDA_PHRASE_H
|
||||
|
||||
void DoWaldaNamingScreen(void);
|
||||
u16 TryGetWallpaperWithWaldaPhrase(void);
|
||||
|
||||
#endif // GUARD_WALDA_PHRASE_H
|
@ -258,7 +258,6 @@ SECTIONS {
|
||||
asm/pokenav.o(.text);
|
||||
asm/rayquaza_scene.o(.text);
|
||||
src/walda_phrase.o(.text);
|
||||
asm/walda_phrase.o(.text);
|
||||
asm/contest_link_81D9DE4.o(.text);
|
||||
asm/trainer_rematch.o(.text);
|
||||
asm/unk_sprite_file.o(.text);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "walda_phrase.h"
|
||||
#include "string_util.h"
|
||||
#include "event_data.h"
|
||||
#include "naming_screen.h"
|
||||
@ -21,13 +22,13 @@ extern void SetWaldaWallpaperColors(u16 backgroundColor, u16 foregroundColor);
|
||||
extern void SetWaldaWallpaperLockedOrUnlocked(bool32 unlocked);
|
||||
|
||||
// this file's functions
|
||||
void CB2_HandleGivenWaldaPhrase(void);
|
||||
u32 GetWaldaPhraseInputCase(u8 *inputPtr);
|
||||
bool32 TryCalculateWallpaper(u16* backgroundClr, u16 *foregroundClr, u8 *iconId, u8 *patternId, u16 trainerId, u8 *phrase);
|
||||
void sub_81D9D5C(u8 *array, u8 *letterTableIds, s32 arg2, s32 arg3, s32 arg4);
|
||||
s32 sub_81D9DAC(u8 *array, s32 arg1, s32 arg2);
|
||||
void sub_81D9C90(u8 *array, s32 arg1, s32 arg2);
|
||||
void sub_81D9CDC(u8 *array, s32 arg1, u8 arg2);
|
||||
static void CB2_HandleGivenWaldaPhrase(void);
|
||||
static u32 GetWaldaPhraseInputCase(u8 *inputPtr);
|
||||
static bool32 TryCalculateWallpaper(u16* backgroundClr, u16 *foregroundClr, u8 *iconId, u8 *patternId, u16 trainerId, u8 *phrase);
|
||||
static void sub_81D9D5C(u8 *array, u8 *letterTableIds, u32 arg2, u32 arg3, u32 loopCount);
|
||||
static u32 sub_81D9DAC(u8 *array, u32 arg1, u32 loopCount);
|
||||
static void sub_81D9C90(u8 *array, s32 arg1, s32 arg2);
|
||||
static void sub_81D9CDC(u8 *array, u32 loopCount, u8 arg2);
|
||||
|
||||
// only consonants are allowed, no vowels, some lowercase letters are missing
|
||||
static const u8 sWaldaLettersTable[] =
|
||||
@ -49,7 +50,7 @@ void DoWaldaNamingScreen(void)
|
||||
DoNamingScreen(NAMING_SCREEN_WALDA, gStringVar2, 0, 0, 0, CB2_HandleGivenWaldaPhrase);
|
||||
}
|
||||
|
||||
void CB2_HandleGivenWaldaPhrase(void)
|
||||
static void CB2_HandleGivenWaldaPhrase(void)
|
||||
{
|
||||
gSpecialVar_0x8004 = GetWaldaPhraseInputCase(gStringVar2);
|
||||
|
||||
@ -73,7 +74,7 @@ void CB2_HandleGivenWaldaPhrase(void)
|
||||
SetMainCallback2(c2_exit_to_overworld_2_switch);
|
||||
}
|
||||
|
||||
u32 GetWaldaPhraseInputCase(u8 *inputPtr)
|
||||
static u32 GetWaldaPhraseInputCase(u8 *inputPtr)
|
||||
{
|
||||
if (inputPtr[0] == EOS)
|
||||
return PHRASE_FIRST_ATTEMPT;
|
||||
@ -101,7 +102,7 @@ u16 TryGetWallpaperWithWaldaPhrase(void)
|
||||
return (bool8)(gScriptResult);
|
||||
}
|
||||
|
||||
u8 GetLetterTableId(u8 letter)
|
||||
static u8 GetLetterTableId(u8 letter)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
@ -114,7 +115,7 @@ u8 GetLetterTableId(u8 letter)
|
||||
return ARRAY_COUNT(sWaldaLettersTable);
|
||||
}
|
||||
|
||||
bool32 TryCalculateWallpaper(u16* backgroundClr, u16 *foregroundClr, u8 *iconId, u8 *patternId, u16 trainerId, u8 *phrase)
|
||||
static bool32 TryCalculateWallpaper(u16* backgroundClr, u16 *foregroundClr, u8 *iconId, u8 *patternId, u16 trainerId, u8 *phrase)
|
||||
{
|
||||
s32 i;
|
||||
ALIGNED(2) u8 array[12];
|
||||
@ -163,7 +164,7 @@ bool32 TryCalculateWallpaper(u16* backgroundClr, u16 *foregroundClr, u8 *iconId,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_81D9C90(u8 *array, s32 arg1, s32 arg2)
|
||||
static void sub_81D9C90(u8 *array, s32 arg1, s32 arg2)
|
||||
{
|
||||
s32 i, j;
|
||||
u8 var1, var2;
|
||||
@ -172,7 +173,7 @@ void sub_81D9C90(u8 *array, s32 arg1, s32 arg2)
|
||||
{
|
||||
var1 = (array[0] & 0x80) >> 7;
|
||||
|
||||
var1++;var1--; // needed to match
|
||||
var1++; var1--; // needed to match
|
||||
|
||||
for (j = arg1 - 1; j >= 0; j--)
|
||||
{
|
||||
@ -183,3 +184,65 @@ void sub_81D9C90(u8 *array, s32 arg1, s32 arg2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_81D9CDC(u8 *array, u32 loopCount, u8 arg2)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
arg2 |= (arg2 << 4);
|
||||
|
||||
for (i = 0; i < loopCount; i++)
|
||||
{
|
||||
array[i] ^= arg2;
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 sub_81D9D0C(u8 *array, u32 arg1)
|
||||
{
|
||||
u32 arrayId = arg1 >> 3;
|
||||
u32 bits = 0x80 >> (7 & arg1);
|
||||
|
||||
return ((array[arrayId] & bits) != 0);
|
||||
}
|
||||
|
||||
static void sub_81D9D28(u8 *array, u32 arg1)
|
||||
{
|
||||
u32 arrayId = arg1 >> 3;
|
||||
u8 bits = 0x80 >> (7 & arg1);
|
||||
|
||||
array[arrayId] |= bits;
|
||||
}
|
||||
|
||||
static void sub_81D9D40(u8 *array, u32 arg1)
|
||||
{
|
||||
u32 arrayId = arg1 >> 3;
|
||||
u8 bits = ~(0x80 >> (7 & arg1));
|
||||
|
||||
array[arrayId] &= bits;
|
||||
}
|
||||
|
||||
static void sub_81D9D5C(u8 *array, u8 *letterTableIds, u32 arg2, u32 arg3, u32 loopCount)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < loopCount; i++)
|
||||
{
|
||||
if (sub_81D9D0C(letterTableIds, arg3 + i))
|
||||
sub_81D9D28(array, arg2 + i);
|
||||
else
|
||||
sub_81D9D40(array, arg2 + i);
|
||||
}
|
||||
}
|
||||
|
||||
static u32 sub_81D9DAC(u8 *array, u32 arg1, u32 loopCount)
|
||||
{
|
||||
u32 ret, i;
|
||||
|
||||
for (ret = 0, i = 0; i < loopCount; i++)
|
||||
{
|
||||
ret <<= 1;
|
||||
ret |= sub_81D9D0C(array, arg1 + i);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user