Match more functions

This commit is contained in:
PokeCodec 2020-09-02 14:14:29 -04:00
parent 24b607b9da
commit d4158e490a
13 changed files with 144 additions and 1323 deletions

View File

@ -1,6 +1,10 @@
#ifndef GUARD_RGB_H
#define GUARD_RGB_H
#define R(color) ((color) & 0x1F)
#define G(color) (((color) >> 5) & 0x1F)
#define B(color) (((color) >> 10) & 0x1F)
#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10))
#define RGB2(r, g, b) (((b) << 10) | ((g) << 5) | (r))
#define _RGB(r, g, b) ((((b) & 0x1F) << 10) + (((g) & 0x1F) << 5) + ((r) & 0x1F))

View File

@ -313,7 +313,7 @@ bool32 WaitForHelpBar(void);
void sub_81C78A0(void);
bool32 MainMenuLoopedTaskIsBusy(void);
void sub_81C7FDC(void);
void sub_81C79BC(const u16 *a0, const u16 *a1, u32 a2, u32 a3, u32 a4, u16 *a5);
void sub_81C79BC(const u16 *a0, const u16 *a1, s32 a2, s32 a3, s32 a4, u16 *palette);
void sub_81C7B40(void);
struct Sprite *PauseSpinningPokenavSprite(void);
void ResumeSpinningPokenavSprite(void);

View File

@ -1126,7 +1126,7 @@ void DrawBattleEntryBackground(void)
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
LZDecompressVram(gUnknown_08D778F0, (void*)(BG_CHAR_ADDR(1)));
LZDecompressVram(gVsLettersGfx, (void*)(VRAM + 0x10000));
LZDecompressVram(gVsLettersGfx, (void*)(OBJ_VRAM0));
LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20);
SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1);
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);

View File

@ -2731,9 +2731,6 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom)
#define TYPE_x2 40
#define TYPE_x4 80
// Functionally equivalent, while loop is impossible to match.
// arg2 is either 2, a personality, or an OTID
#ifdef NONMATCHING
static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
{
int defType1, defType2, defAbility, moveType;
@ -2762,13 +2759,15 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
i += 3;
continue;
}
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
// BUG: * 2 is not necessary and makes the condition always false if the ability is wonder guard.
if (TYPE_EFFECT_DEF_TYPE(i) == defType1 && (defAbility != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2))
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2 && (defAbility != ABILITY_WONDER_GUARD || TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE * 2))
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
// BUG: TYPE_x2 is not necessary and makes the condition always false if the ability is wonder guard.
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = typePower * TYPE_EFFECT_MULTIPLIER(i) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = typePower * TYPE_EFFECT_MULTIPLIER(i) / 10;
}
i += 3;
}
@ -2779,10 +2778,10 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
case 0:
switch (typePower)
{
case TYPE_x0_50:
case TYPE_x0_25:
case TYPE_x0:
default:
case TYPE_x0:
case TYPE_x0_25:
case TYPE_x0_50:
typePower = 0;
break;
case TYPE_x1:
@ -2799,19 +2798,19 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
case 1:
switch (typePower)
{
default:
case TYPE_x1:
typePower = 0;
case TYPE_x0:
typePower = 8;
break;
case TYPE_x0_25:
typePower = 4;
break;
case TYPE_x0:
typePower = 8;
break;
case TYPE_x0_50:
typePower = 2;
break;
default:
case TYPE_x1:
typePower = 0;
break;
case TYPE_x2:
typePower = -2;
break;
@ -2829,8 +2828,8 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
case TYPE_x0_25:
typePower = -8;
break;
case TYPE_x0_50:
default:
case TYPE_x0_50:
typePower = 0;
break;
case TYPE_x1:
@ -2848,246 +2847,6 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
return typePower;
}
#else
NAKED
static int GetTypeEffectivenessPoints(int move, int species, int arg2)
{
asm_unified(
"push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x8\n\
adds r3, r0, 0\n\
adds r4, r1, 0\n\
str r2, [sp]\n\
movs r6, 0\n\
movs r2, 0x14\n\
cmp r3, 0\n\
beq _0818FFF0\n\
ldr r0, =0x0000ffff\n\
cmp r3, r0\n\
beq _0818FFF0\n\
ldr r0, =gBattleMoves\n\
lsls r1, r3, 1\n\
adds r1, r3\n\
lsls r1, 2\n\
adds r3, r1, r0\n\
ldrb r0, [r3, 0x1]\n\
cmp r0, 0\n\
bne _0818FFFC\n\
_0818FFF0:\n\
movs r0, 0\n\
b _08190156\n\
.pool\n\
_0818FFFC:\n\
ldr r1, =gBaseStats\n\
lsls r0, r4, 3\n\
subs r0, r4\n\
lsls r0, 2\n\
adds r0, r1\n\
ldrb r1, [r0, 0x6]\n\
mov r10, r1\n\
ldrb r1, [r0, 0x7]\n\
mov r9, r1\n\
ldrb r0, [r0, 0x16]\n\
mov r8, r0\n\
ldrb r3, [r3, 0x2]\n\
str r3, [sp, 0x4]\n\
cmp r0, 0x1A\n\
bne _0819002C\n\
cmp r3, 0x4\n\
bne _0819002C\n\
ldr r0, [sp]\n\
cmp r0, 0x1\n\
bne _081900AA\n\
movs r2, 0x8\n\
b _081900A4\n\
.pool\n\
_0819002C:\n\
ldr r0, =gTypeEffectiveness\n\
adds r1, r6, r0\n\
ldrb r0, [r1]\n\
ldr r7, =gTypeEffectiveness\n\
cmp r0, 0xFF\n\
beq _081900A4\n\
adds r4, r1, 0\n\
_0819003A:\n\
ldrb r0, [r4]\n\
cmp r0, 0xFE\n\
beq _08190096\n\
ldrb r0, [r4]\n\
ldr r1, [sp, 0x4]\n\
cmp r0, r1\n\
bne _08190096\n\
ldrb r0, [r4, 0x1]\n\
adds r5, r6, 0x1\n\
cmp r0, r10\n\
bne _0819006C\n\
adds r1, r6, 0x2\n\
mov r0, r8\n\
cmp r0, 0x19\n\
bne _0819005E\n\
ldrb r0, [r4, 0x2]\n\
cmp r0, 0x28\n\
bne _0819006C\n\
_0819005E:\n\
adds r0, r1, r7\n\
ldrb r0, [r0]\n\
muls r0, r2\n\
movs r1, 0xA\n\
bl __divsi3\n\
adds r2, r0, 0\n\
_0819006C:\n\
adds r0, r5, r7\n\
ldrb r0, [r0]\n\
cmp r0, r9\n\
bne _08190096\n\
cmp r10, r9\n\
beq _08190096\n\
adds r1, r6, 0x2\n\
mov r0, r8\n\
cmp r0, 0x19\n\
bne _08190088\n\
adds r0, r1, r7\n\
ldrb r0, [r0]\n\
cmp r0, 0x28\n\
bne _08190096\n\
_08190088:\n\
adds r0, r1, r7\n\
ldrb r0, [r0]\n\
muls r0, r2\n\
movs r1, 0xA\n\
bl __divsi3\n\
adds r2, r0, 0\n\
_08190096:\n\
adds r4, 0x3\n\
adds r6, 0x3\n\
ldr r1, =gTypeEffectiveness\n\
adds r0, r6, r1\n\
ldrb r0, [r0]\n\
cmp r0, 0xFF\n\
bne _0819003A\n\
_081900A4:\n\
ldr r0, [sp]\n\
cmp r0, 0x1\n\
beq _081900E0\n\
_081900AA:\n\
ldr r1, [sp]\n\
cmp r1, 0x1\n\
bgt _081900BC\n\
cmp r1, 0\n\
beq _081900C4\n\
b _08190154\n\
.pool\n\
_081900BC:\n\
ldr r0, [sp]\n\
cmp r0, 0x2\n\
beq _08190114\n\
b _08190154\n\
_081900C4:\n\
cmp r2, 0xA\n\
beq _08190146\n\
cmp r2, 0xA\n\
ble _08190146\n\
cmp r2, 0x28\n\
beq _0819014A\n\
cmp r2, 0x28\n\
bgt _081900DA\n\
cmp r2, 0x14\n\
beq _08190104\n\
b _08190146\n\
_081900DA:\n\
cmp r2, 0x50\n\
bne _08190146\n\
b _08190100\n\
_081900E0:\n\
cmp r2, 0xA\n\
beq _08190104\n\
cmp r2, 0xA\n\
bgt _081900F2\n\
cmp r2, 0\n\
beq _08190100\n\
cmp r2, 0x5\n\
beq _0819014A\n\
b _08190146\n\
_081900F2:\n\
cmp r2, 0x28\n\
beq _08190108\n\
cmp r2, 0x28\n\
ble _08190146\n\
cmp r2, 0x50\n\
beq _0819010E\n\
b _08190146\n\
_08190100:\n\
movs r2, 0x8\n\
b _08190154\n\
_08190104:\n\
movs r2, 0x2\n\
b _08190154\n\
_08190108:\n\
movs r2, 0x2\n\
negs r2, r2\n\
b _08190154\n\
_0819010E:\n\
movs r2, 0x4\n\
negs r2, r2\n\
b _08190154\n\
_08190114:\n\
cmp r2, 0xA\n\
beq _08190146\n\
cmp r2, 0xA\n\
bgt _08190126\n\
cmp r2, 0\n\
beq _0819013A\n\
cmp r2, 0x5\n\
beq _08190140\n\
b _08190146\n\
_08190126:\n\
cmp r2, 0x28\n\
beq _0819014E\n\
cmp r2, 0x28\n\
bgt _08190134\n\
cmp r2, 0x14\n\
beq _0819014A\n\
b _08190146\n\
_08190134:\n\
cmp r2, 0x50\n\
beq _08190152\n\
b _08190146\n\
_0819013A:\n\
movs r2, 0x10\n\
negs r2, r2\n\
b _08190154\n\
_08190140:\n\
movs r2, 0x8\n\
negs r2, r2\n\
b _08190154\n\
_08190146:\n\
movs r2, 0\n\
b _08190154\n\
_0819014A:\n\
movs r2, 0x4\n\
b _08190154\n\
_0819014E:\n\
movs r2, 0xC\n\
b _08190154\n\
_08190152:\n\
movs r2, 0x14\n\
_08190154:\n\
adds r0, r2, 0\n\
_08190156:\n\
add sp, 0x8\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1");
}
#endif // NONMATCHING
// Duplicate of GetFrontierTrainerFixedIvs
// NOTE: In CreateDomeOpponentMon a tournament trainer ID (0-15) is passed instead, resulting in all IVs of 3

View File

@ -957,7 +957,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
}
src = gMonSpritesGfxPtr->sprites[position];
dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
dst = (void *)(OBJ_VRAM0 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
DmaCopy32(3, src, dst, 0x800);
paletteOffset = 0x100 + battlerAtk * 16;
lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue);

View File

@ -713,20 +713,18 @@ void BattleTv_SetDataBasedOnAnimation(u8 animationId)
}
}
#ifdef NONMATCHING
// for loop has an unused stack variable
void TryPutLinkBattleTvShowOnAir(void)
{
u16 playerBestSpecies = 0, opponentBestSpecies = 0;
s16 playerBestSum = 0, opponentBestSum = SHRT_MAX;
u16 playerBestSpecies = 0, opponentBestSpecies = 0, moveId = 0;
s16 sum = 0, playerBestSum = 0, opponentBestSum = SHRT_MAX;
u8 playerBestMonId = 0, opponentBestMonId = 0;
struct BattleTvMovePoints *movePoints = NULL;
u8 countPlayer = 0, countOpponent = 0;
s16 sum = 0;
u16 species = 0;
u16 moveId = 0;
u16 species;
s32 i, j;
int zero = 0, one = 1; // stupid variables needed to match. Feel free to get rid of them.
if (gBattleStruct->anyMonHasTransformed)
return;
@ -748,7 +746,7 @@ void TryPutLinkBattleTvShowOnAir(void)
if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL))
{
for (sum = 0, j = 0; j < MAX_MON_MOVES; j++)
sum += movePoints->points[0][i * 4 + j];
sum += movePoints->points[zero][i * 4 + j];
if (playerBestSum < sum)
{
@ -762,7 +760,7 @@ void TryPutLinkBattleTvShowOnAir(void)
if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL))
{
for (sum = 0, j = 0; j < MAX_MON_MOVES; j++)
sum += movePoints->points[1][i * 4 + j];
sum += movePoints->points[one][i * 4 + j];
if (opponentBestSum == sum)
{
@ -784,9 +782,9 @@ void TryPutLinkBattleTvShowOnAir(void)
for (sum = 0, i = 0, j = 0; j < MAX_MON_MOVES; j++)
{
if (sum < movePoints->points[0][playerBestMonId * 4 + j])
if (sum < movePoints->points[zero][playerBestMonId * 4 + j])
{
sum = movePoints->points[0][playerBestMonId * 4 + j];
sum = movePoints->points[zero][playerBestMonId * 4 + j];
i = j;
}
}
@ -810,333 +808,6 @@ void TryPutLinkBattleTvShowOnAir(void)
}
}
#else
NAKED
void TryPutLinkBattleTvShowOnAir(void)
{
asm_unified(
"push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x20\n\
movs r0, 0\n\
str r0, [sp]\n\
movs r1, 0\n\
str r1, [sp, 0x4]\n\
movs r2, 0\n\
str r2, [sp, 0x8]\n\
ldr r3, =0x00007fff\n\
str r3, [sp, 0xC]\n\
movs r4, 0\n\
str r4, [sp, 0x10]\n\
movs r7, 0\n\
str r7, [sp, 0x14]\n\
mov r8, r0\n\
ldr r0, =gBattleStruct\n\
ldr r1, [r0]\n\
adds r0, r1, 0\n\
adds r0, 0xB3\n\
ldrb r0, [r0]\n\
cmp r0, 0\n\
beq _0817E42A\n\
b _0817E670\n\
_0817E42A:\n\
movs r2, 0xD2\n\
lsls r2, 1\n\
adds r2, r1\n\
mov r10, r2\n\
movs r6, 0\n\
_0817E434:\n\
movs r0, 0x64\n\
adds r4, r6, 0\n\
muls r4, r0\n\
ldr r0, =gPlayerParty\n\
adds r0, r4, r0\n\
movs r1, 0xB\n\
movs r2, 0\n\
bl GetMonData\n\
cmp r0, 0\n\
beq _0817E454\n\
mov r0, r8\n\
adds r0, 0x1\n\
lsls r0, 24\n\
lsrs r0, 24\n\
mov r8, r0\n\
_0817E454:\n\
ldr r5, =gEnemyParty\n\
adds r0, r4, r5\n\
movs r1, 0xB\n\
movs r2, 0\n\
bl GetMonData\n\
cmp r0, 0\n\
beq _0817E46A\n\
adds r0, r7, 0x1\n\
lsls r0, 24\n\
lsrs r7, r0, 24\n\
_0817E46A:\n\
adds r6, 0x1\n\
cmp r6, 0x5\n\
ble _0817E434\n\
ldr r0, =gBattleTypeFlags\n\
ldr r0, [r0]\n\
movs r1, 0x2\n\
ands r0, r1\n\
cmp r0, 0\n\
bne _0817E47E\n\
b _0817E670\n\
_0817E47E:\n\
cmp r8, r7\n\
beq _0817E484\n\
b _0817E670\n\
_0817E484:\n\
movs r6, 0\n\
lsls r3, r6, 1\n\
str r3, [sp, 0x18]\n\
movs r4, 0x64\n\
mov r8, r4\n\
_0817E48E:\n\
mov r1, r8\n\
muls r1, r6\n\
ldr r0, =gPlayerParty\n\
adds r4, r1, r0\n\
adds r0, r4, 0\n\
movs r1, 0xB\n\
movs r2, 0\n\
bl GetMonData\n\
lsls r0, 16\n\
lsrs r7, r0, 16\n\
adds r0, r6, 0x1\n\
mov r9, r0\n\
cmp r7, 0\n\
beq _0817E4EE\n\
adds r0, r4, 0\n\
movs r1, 0x2D\n\
movs r2, 0\n\
bl GetMonData\n\
cmp r0, 0\n\
bne _0817E4EE\n\
movs r4, 0\n\
lsls r0, r6, 3\n\
mov r2, r10\n\
adds r1, r0, r2\n\
movs r3, 0x3\n\
_0817E4C4:\n\
lsls r0, r4, 16\n\
asrs r0, 16\n\
ldrh r4, [r1]\n\
adds r0, r4\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
adds r1, 0x2\n\
subs r3, 0x1\n\
cmp r3, 0\n\
bge _0817E4C4\n\
ldr r1, [sp, 0x8]\n\
lsls r0, r1, 16\n\
lsls r1, r4, 16\n\
cmp r0, r1\n\
bge _0817E4EE\n\
lsls r0, r6, 24\n\
lsrs r0, 24\n\
str r0, [sp, 0x10]\n\
lsrs r1, 16\n\
str r1, [sp, 0x8]\n\
str r7, [sp]\n\
_0817E4EE:\n\
mov r0, r8\n\
muls r0, r6\n\
ldr r2, =gEnemyParty\n\
adds r4, r0, r2\n\
adds r0, r4, 0\n\
movs r1, 0xB\n\
movs r2, 0\n\
bl GetMonData\n\
lsls r0, 16\n\
lsrs r7, r0, 16\n\
ldr r3, [sp, 0x8]\n\
lsls r3, 16\n\
str r3, [sp, 0x1C]\n\
cmp r7, 0\n\
beq _0817E5A0\n\
adds r0, r4, 0\n\
movs r1, 0x2D\n\
movs r2, 0\n\
bl GetMonData\n\
cmp r0, 0\n\
bne _0817E5A0\n\
movs r4, 0\n\
ldr r0, [sp, 0xC]\n\
lsls r2, r0, 16\n\
movs r3, 0x1\n\
lsls r1, r3, 1\n\
adds r1, 0x1\n\
lsls r1, 4\n\
lsls r0, r6, 3\n\
adds r0, r1\n\
mov r3, r10\n\
adds r1, r0, r3\n\
movs r3, 0x3\n\
_0817E534:\n\
lsls r0, r4, 16\n\
asrs r0, 16\n\
ldrh r4, [r1]\n\
adds r0, r4\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
adds r1, 0x2\n\
subs r3, 0x1\n\
cmp r3, 0\n\
bge _0817E534\n\
asrs r1, r2, 16\n\
lsls r5, r4, 16\n\
asrs r0, r5, 16\n\
cmp r1, r0\n\
bne _0817E590\n\
mov r0, r8\n\
muls r0, r6\n\
ldr r1, =gEnemyParty\n\
adds r0, r1\n\
movs r1, 0x19\n\
movs r2, 0\n\
bl GetMonData\n\
adds r4, r0, 0\n\
ldr r2, [sp, 0x14]\n\
mov r0, r8\n\
muls r0, r2\n\
ldr r3, =gEnemyParty\n\
adds r0, r3\n\
movs r1, 0x19\n\
movs r2, 0\n\
bl GetMonData\n\
cmp r4, r0\n\
bls _0817E5A0\n\
b _0817E594\n\
.pool\n\
_0817E590:\n\
cmp r1, r0\n\
ble _0817E5A0\n\
_0817E594:\n\
lsls r0, r6, 24\n\
lsrs r0, 24\n\
str r0, [sp, 0x14]\n\
lsrs r5, 16\n\
str r5, [sp, 0xC]\n\
str r7, [sp, 0x4]\n\
_0817E5A0:\n\
mov r6, r9\n\
cmp r6, 0x5\n\
bgt _0817E5A8\n\
b _0817E48E\n\
_0817E5A8:\n\
movs r4, 0\n\
movs r6, 0\n\
movs r3, 0\n\
ldr r5, =gPlayerParty\n\
ldr r7, [sp, 0x10]\n\
lsls r0, r7, 3\n\
mov r1, r10\n\
adds r2, r0, r1\n\
_0817E5B8:\n\
lsls r0, r4, 16\n\
asrs r0, 16\n\
movs r7, 0\n\
ldrsh r1, [r2, r7]\n\
cmp r0, r1\n\
bge _0817E5C8\n\
ldrh r4, [r2]\n\
adds r6, r3, 0\n\
_0817E5C8:\n\
adds r2, 0x2\n\
adds r3, 0x1\n\
cmp r3, 0x3\n\
ble _0817E5B8\n\
movs r0, 0x64\n\
ldr r1, [sp, 0x10]\n\
muls r0, r1\n\
adds r0, r5\n\
adds r1, r6, 0\n\
adds r1, 0xD\n\
movs r2, 0\n\
bl GetMonData\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
ldr r2, [sp, 0x1C]\n\
cmp r2, 0\n\
beq _0817E670\n\
cmp r4, 0\n\
beq _0817E670\n\
ldr r0, =gBattleTypeFlags\n\
ldr r0, [r0]\n\
movs r1, 0x40\n\
ands r0, r1\n\
cmp r0, 0\n\
beq _0817E65C\n\
ldr r3, [sp, 0x10]\n\
cmp r3, 0x2\n\
bhi _0817E620\n\
ldr r0, =gBattleScripting\n\
adds r0, 0x25\n\
ldrb r0, [r0]\n\
bl GetLinkTrainerFlankId\n\
lsls r0, 16\n\
cmp r0, 0\n\
beq _0817E630\n\
b _0817E670\n\
.pool\n\
_0817E620:\n\
ldr r0, =gBattleScripting\n\
adds r0, 0x25\n\
ldrb r0, [r0]\n\
bl GetLinkTrainerFlankId\n\
lsls r0, 16\n\
cmp r0, 0\n\
beq _0817E670\n\
_0817E630:\n\
movs r3, 0\n\
ldr r7, [sp, 0x14]\n\
cmp r7, 0x2\n\
bls _0817E63A\n\
movs r3, 0x1\n\
_0817E63A:\n\
lsls r0, r3, 24\n\
lsrs r0, 24\n\
ldr r1, =gBattleScripting\n\
adds r1, 0x25\n\
ldrb r1, [r1]\n\
bl sub_806EF84\n\
lsls r0, 24\n\
lsrs r0, 24\n\
adds r1, r4, 0\n\
ldr r2, [sp]\n\
ldr r3, [sp, 0x4]\n\
bl PutBattleUpdateOnTheAir\n\
b _0817E670\n\
.pool\n\
_0817E65C:\n\
ldr r0, =gBattleScripting\n\
adds r0, 0x25\n\
ldrb r1, [r0]\n\
movs r0, 0x1\n\
eors r0, r1\n\
adds r1, r4, 0\n\
ldr r2, [sp]\n\
ldr r3, [sp, 0x4]\n\
bl PutBattleUpdateOnTheAir\n\
_0817E670:\n\
add sp, 0x20\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool");
}
#endif
static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3)
{
struct BattleTvMovePoints *movePoints = &gBattleStruct->tvMovePoints;

View File

@ -4137,12 +4137,12 @@ static u8 CreateContestantBoxBlinkSprites(u8 contestant)
CpuFill32(0, gContestResources->boxBlinkTiles2 + 0x500, 0x300);
RequestDma3Copy(gContestResources->boxBlinkTiles1,
(u8 *)(VRAM + 0x10000 + gSprites[spriteId1].oam.tileNum * 32),
(u8 *)(OBJ_VRAM0 + gSprites[spriteId1].oam.tileNum * 32),
0x800,
1);
RequestDma3Copy(gContestResources->boxBlinkTiles2,
(u8 *)(VRAM + 0x10000 + gSprites[spriteId2].oam.tileNum * 32),
(u8 *)(OBJ_VRAM0 + gSprites[spriteId2].oam.tileNum * 32),
0x800,
1);
@ -4728,8 +4728,8 @@ static void UpdateApplauseMeter(void)
src = &gContestApplauseMeterGfx[64];
else
src = gContestApplauseMeterGfx;
CpuCopy32(src, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32);
CpuCopy32(src + 32, (void *)(VRAM + 0x10000 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32);
CpuCopy32(src, (void *)(OBJ_VRAM0 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32);
CpuCopy32(src + 32, (void *)(OBJ_VRAM0 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32);
if (eContest.applauseLevel > 4)
StartApplauseOverflowAnimation();

View File

@ -1148,350 +1148,71 @@ static void TryCreateWirelessSprites(void)
}
}
// Functionally equivalent, the same except compiler generated variables from
// src are placed on different stack positions.
#ifdef NONMATCHING
static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
{
u8 *windowTilesPtr;
u16 windowId;
int origWidth;
struct WindowTemplate windowTemplate;
int strWidth;
s32 origWidth, strWidth;
u8 *spriteTilePtrs[4];
u8 *dst;
int i;
struct Sprite *sprite;
const u8 *src; // The culprit.
memset(&windowTemplate, 0, sizeof(windowTemplate));
windowTemplate.width = 30;
windowTemplate.height = 2;
windowId = AddWindow(&windowTemplate);
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
origWidth = GetStringWidth(1, text, 0);
strWidth = (origWidth + 9) / 8;
if (strWidth > 30)
strWidth = 30;
AddTextPrinterParameterized3(windowId, 1, (strWidth * 8 - origWidth) / 2, 1, sContestLinkTextColors, -1, text);
windowTilesPtr = (u8 *)(GetWindowAttribute(windowId, WINDOW_TILE_DATA));
src = (u8 *)(sUnknown_0858D6D0);
sprite = &gSprites[spriteId];
spriteTilePtrs[0] = (u8 *)(sprite->oam.tileNum * 32 + VRAM + 0x10000);
for (i = 1; i < 4; i++)
spriteTilePtrs[i] = (void*)(gSprites[sprite->data[i - 1]].oam.tileNum * 32 + VRAM + 0x10000);
for (i = 0; i < 4; i++)
CpuFill32(0, spriteTilePtrs[i], 0x400);
dst = spriteTilePtrs[0];
CpuCopy32(src, dst, 0x20);
CpuCopy32(src + 128, dst + 0x100, 0x20);
CpuCopy32(src + 128, dst + 0x200, 0x20);
CpuCopy32(src + 64, dst + 0x300, 0x20);
for (i = 0; i < strWidth; i++)
{
dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
CpuCopy32(src + 192, dst, 0x20);
CpuCopy32(windowTilesPtr, dst + 0x100, 0x20);
CpuCopy32(windowTilesPtr + 960, dst + 0x200, 0x20);
CpuCopy32(src + 224, dst + 0x300, 0x20);
windowTilesPtr += 0x20;
struct WindowTemplate windowTemplate; //It's important the lifetime of this struct ends after the clear
memset(&windowTemplate, 0, sizeof(windowTemplate));
windowTemplate.width = 30;
windowTemplate.height = 2;
windowId = AddWindow(&windowTemplate);
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
}
dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
CpuCopy32(src + 32, dst, 0x20);
CpuCopy32(src + 160, dst + 0x100, 0x20);
CpuCopy32(src + 160, dst + 0x200, 0x20);
CpuCopy32(src + 96, dst + 0x300, 0x20);
origWidth = GetStringWidth(1, text, 0);
if ((strWidth = (origWidth + 9) / 8) > 30)
strWidth = 30;
AddTextPrinterParameterized3(windowId, 1, (strWidth * 8 - origWidth) / 2, 1, sContestLinkTextColors, -1, text);
{
s32 i;
struct Sprite *sprite;
const u8 *src, *windowTilesPtr;
windowTilesPtr = (const u8 *)(GetWindowAttribute(windowId, WINDOW_TILE_DATA));
src = sUnknown_0858D6D0;
sprite = &gSprites[spriteId];
spriteTilePtrs[0] = (u8 *)((OBJ_VRAM0) + sprite->oam.tileNum * 32);
for (i = 1; i < 4; i++)
spriteTilePtrs[i] = (u8 *)((OBJ_VRAM0) + gSprites[sprite->data[i - 1]].oam.tileNum * 32);
for (i = 0; i < 4; i++)
CpuFill32(0, spriteTilePtrs[i], 0x400);
dst = spriteTilePtrs[0];
CpuCopy32(src, dst, 0x20);
CpuCopy32(src + 128, dst + 0x100, 0x20);
CpuCopy32(src + 128, dst + 0x200, 0x20);
CpuCopy32(src + 64, dst + 0x300, 0x20);
for (i = 0; i < strWidth; i++)
{
dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
CpuCopy32(src + 192, dst, 0x20);
CpuCopy32(windowTilesPtr, dst + 0x100, 0x20);
CpuCopy32(windowTilesPtr + 960, dst + 0x200, 0x20);
CpuCopy32(src + 224, dst + 0x300, 0x20);
windowTilesPtr += 0x20;
}
dst = &spriteTilePtrs[(i + 1) / 8][((i + 1) % 8) * 32];
CpuCopy32(src + 32, dst, 0x20);
CpuCopy32(src + 160, dst + 0x100, 0x20);
CpuCopy32(src + 160, dst + 0x200, 0x20);
CpuCopy32(src + 96, dst + 0x300, 0x20);
}
RemoveWindow(windowId);
return (240 - (strWidth + 2) * 8) / 2;
}
#else
NAKED
static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
{
asm_unified(
"push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x44\n\
adds r5, r0, 0\n\
lsls r1, 24\n\
lsrs r7, r1, 24\n\
add r4, sp, 0x20\n\
adds r0, r4, 0\n\
movs r1, 0\n\
movs r2, 0x8\n\
bl memset\n\
movs r0, 0x1E\n\
strb r0, [r4, 0x3]\n\
movs r0, 0x2\n\
strb r0, [r4, 0x4]\n\
adds r0, r4, 0\n\
bl AddWindow\n\
lsls r6, r0, 24\n\
lsrs r4, r6, 24\n\
adds r0, r4, 0\n\
movs r1, 0x11\n\
bl FillWindowPixelBuffer\n\
movs r0, 0x1\n\
adds r1, r5, 0\n\
movs r2, 0\n\
bl GetStringWidth\n\
adds r2, r0, 0\n\
adds r2, 0x9\n\
cmp r2, 0\n\
bge _080F6BC4\n\
adds r2, 0x7\n\
_080F6BC4:\n\
asrs r2, 3\n\
mov r10, r2\n\
cmp r2, 0x1E\n\
ble _080F6BD0\n\
movs r1, 0x1E\n\
mov r10, r1\n\
_080F6BD0:\n\
mov r1, r10\n\
lsls r2, r1, 3\n\
subs r2, r0\n\
lsrs r0, r2, 31\n\
adds r2, r0\n\
asrs r2, 1\n\
lsls r2, 24\n\
lsrs r2, 24\n\
ldr r0, =sContestLinkTextColors\n\
str r0, [sp]\n\
movs r0, 0x1\n\
negs r0, r0\n\
str r0, [sp, 0x4]\n\
str r5, [sp, 0x8]\n\
adds r0, r4, 0\n\
movs r1, 0x1\n\
movs r3, 0x1\n\
bl AddTextPrinterParameterized3\n\
adds r0, r4, 0\n\
movs r1, 0x7\n\
bl GetWindowAttribute\n\
mov r9, r0\n\
ldr r2, =sUnknown_0858D6D0\n\
mov r8, r2\n\
lsls r1, r7, 4\n\
adds r1, r7\n\
lsls r1, 2\n\
ldr r3, =gSprites\n\
adds r1, r3\n\
ldrh r0, [r1, 0x4]\n\
lsls r0, 22\n\
lsrs r0, 17\n\
ldr r2, =0x06010000\n\
adds r0, r2\n\
str r0, [sp, 0xC]\n\
str r6, [sp, 0x38]\n\
mov r7, sp\n\
adds r7, 0x1C\n\
str r7, [sp, 0x2C]\n\
mov r0, r10\n\
adds r0, 0x2\n\
str r0, [sp, 0x30]\n\
movs r5, 0\n\
add r7, sp, 0x10\n\
mov r12, r7\n\
adds r6, r1, 0\n\
adds r6, 0x2E\n\
movs r4, 0x2\n\
_080F6C34:\n\
adds r0, r6, r5\n\
movs r7, 0\n\
ldrsh r1, [r0, r7]\n\
lsls r0, r1, 4\n\
adds r0, r1\n\
lsls r0, 2\n\
adds r0, r3\n\
ldrh r0, [r0, 0x4]\n\
lsls r0, 22\n\
lsrs r0, 17\n\
adds r0, r2\n\
mov r1, r12\n\
adds r1, 0x4\n\
mov r12, r1\n\
subs r1, 0x4\n\
stm r1!, {r0}\n\
adds r5, 0x2\n\
subs r4, 0x1\n\
cmp r4, 0\n\
bge _080F6C34\n\
mov r7, r8\n\
adds r7, 0x80\n\
mov r2, r8\n\
adds r2, 0x40\n\
str r2, [sp, 0x28]\n\
mov r0, r8\n\
adds r0, 0x20\n\
str r0, [sp, 0x3C]\n\
mov r1, r8\n\
adds r1, 0xA0\n\
str r1, [sp, 0x40]\n\
adds r2, 0x20\n\
str r2, [sp, 0x34]\n\
add r5, sp, 0xC\n\
movs r6, 0\n\
movs r4, 0x3\n\
_080F6C7C:\n\
str r6, [sp, 0x1C]\n\
ldm r5!, {r1}\n\
ldr r0, [sp, 0x2C]\n\
ldr r2, =0x05000100\n\
bl CpuSet\n\
subs r4, 0x1\n\
cmp r4, 0\n\
bge _080F6C7C\n\
ldr r5, [sp, 0xC]\n\
ldr r6, =0x04000008\n\
mov r0, r8\n\
adds r1, r5, 0\n\
adds r2, r6, 0\n\
bl CpuSet\n\
movs r0, 0x80\n\
lsls r0, 1\n\
adds r1, r5, r0\n\
adds r0, r7, 0\n\
adds r2, r6, 0\n\
bl CpuSet\n\
movs r2, 0x80\n\
lsls r2, 2\n\
adds r1, r5, r2\n\
adds r0, r7, 0\n\
adds r2, r6, 0\n\
bl CpuSet\n\
movs r7, 0xC0\n\
lsls r7, 2\n\
adds r1, r5, r7\n\
ldr r0, [sp, 0x28]\n\
adds r2, r6, 0\n\
bl CpuSet\n\
movs r4, 0\n\
cmp r4, r10\n\
bge _080F6D32\n\
adds r7, r6, 0\n\
_080F6CCE:\n\
adds r6, r4, 0x1\n\
adds r0, r6, 0\n\
cmp r6, 0\n\
bge _080F6CDA\n\
adds r0, r4, 0\n\
adds r0, 0x8\n\
_080F6CDA:\n\
asrs r0, 3\n\
lsls r1, r0, 2\n\
add r1, sp\n\
adds r1, 0xC\n\
lsls r0, 3\n\
subs r0, r6, r0\n\
lsls r0, 5\n\
ldr r1, [r1]\n\
adds r5, r1, r0\n\
mov r0, r8\n\
adds r0, 0xC0\n\
adds r1, r5, 0\n\
adds r2, r7, 0\n\
bl CpuSet\n\
movs r0, 0x80\n\
lsls r0, 1\n\
adds r1, r5, r0\n\
mov r0, r9\n\
adds r2, r7, 0\n\
bl CpuSet\n\
movs r0, 0xF0\n\
lsls r0, 2\n\
add r0, r9\n\
movs r2, 0x80\n\
lsls r2, 2\n\
adds r1, r5, r2\n\
adds r2, r7, 0\n\
bl CpuSet\n\
movs r0, 0xC0\n\
lsls r0, 2\n\
adds r1, r5, r0\n\
mov r0, r8\n\
adds r0, 0xE0\n\
adds r2, r7, 0\n\
bl CpuSet\n\
movs r1, 0x20\n\
add r9, r1\n\
adds r4, r6, 0\n\
cmp r4, r10\n\
blt _080F6CCE\n\
_080F6D32:\n\
adds r2, r4, 0x1\n\
adds r0, r2, 0\n\
cmp r2, 0\n\
bge _080F6D3E\n\
adds r0, r4, 0\n\
adds r0, 0x8\n\
_080F6D3E:\n\
asrs r0, 3\n\
lsls r1, r0, 2\n\
add r1, sp\n\
adds r1, 0xC\n\
lsls r0, 3\n\
subs r0, r2, r0\n\
lsls r0, 5\n\
ldr r1, [r1]\n\
adds r5, r1, r0\n\
ldr r4, =0x04000008\n\
ldr r0, [sp, 0x3C]\n\
adds r1, r5, 0\n\
adds r2, r4, 0\n\
bl CpuSet\n\
movs r2, 0x80\n\
lsls r2, 1\n\
adds r1, r5, r2\n\
ldr r0, [sp, 0x40]\n\
adds r2, r4, 0\n\
bl CpuSet\n\
movs r7, 0x80\n\
lsls r7, 2\n\
adds r1, r5, r7\n\
ldr r0, [sp, 0x40]\n\
adds r2, r4, 0\n\
bl CpuSet\n\
movs r0, 0xC0\n\
lsls r0, 2\n\
adds r1, r5, r0\n\
ldr r0, [sp, 0x34]\n\
adds r2, r4, 0\n\
bl CpuSet\n\
ldr r1, [sp, 0x38]\n\
lsrs r0, r1, 24\n\
bl RemoveWindow\n\
ldr r2, [sp, 0x30]\n\
lsls r1, r2, 3\n\
movs r0, 0xF0\n\
subs r0, r1\n\
asrs r0, 1\n\
add sp, 0x44\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1\n\
.pool");
}
#endif // NONMATCHING
static void LoadContestResultSprites(void)
{
int i;

View File

@ -2486,7 +2486,6 @@ void SetFrontierBrainObjEventGfx_2(void)
#define FRONTIER_BRAIN_OTID 61226
#ifdef NONMATCHING
void CreateFrontierBrainPokemon(void)
{
s32 i, j;
@ -2509,11 +2508,13 @@ void CreateFrontierBrainPokemon(void)
{
if (!(selectedMonBits & 1))
continue;
do
{
j = Random32();
} while (IsShinyOtIdPersonality(FRONTIER_BRAIN_OTID, j) || sFrontierBrainsMons[facility][symbol][i].nature != GetNatureFromPersonality(j));
do
{
j = Random32(); //Should be one while loop, but that doesn't match
} while (IsShinyOtIdPersonality(FRONTIER_BRAIN_OTID, j)); //See above comment
} while (sFrontierBrainsMons[facility][symbol][i].nature != GetNatureFromPersonality(j));
CreateMon(&gEnemyParty[monPartyId],
sFrontierBrainsMons[facility][symbol][i].species,
monLevel,
@ -2535,242 +2536,6 @@ void CreateFrontierBrainPokemon(void)
monPartyId++;
}
}
#else
NAKED
void CreateFrontierBrainPokemon(void)
{
asm_unified(
"push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x44\n\
ldr r0, =0x000040cf\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r0, 16\n\
str r0, [sp, 0x20]\n\
bl GetFronterBrainSymbol\n\
str r0, [sp, 0x24]\n\
ldr r0, [sp, 0x20]\n\
cmp r0, 0x1\n\
bne _081A4E44\n\
ldr r0, =0x000003fe\n\
bl TrainerIdToDomeTournamentId\n\
lsls r0, 16\n\
lsrs r0, 16\n\
bl GetDomeTrainerSelectedMons\n\
adds r4, r0, 0\n\
b _081A4E46\n\
.pool\n\
_081A4E44:\n\
movs r4, 0x7\n\
_081A4E46:\n\
bl ZeroEnemyPartyMons\n\
movs r1, 0\n\
str r1, [sp, 0x18]\n\
bl SetFacilityPtrsGetLevel\n\
lsls r0, 24\n\
lsrs r0, 24\n\
str r0, [sp, 0x1C]\n\
movs r2, 0\n\
str r2, [sp, 0x14]\n\
_081A4E5C:\n\
movs r0, 0x1\n\
ands r0, r4\n\
asrs r4, 1\n\
str r4, [sp, 0x30]\n\
ldr r3, [sp, 0x14]\n\
adds r3, 0x1\n\
str r3, [sp, 0x28]\n\
cmp r0, 0\n\
bne _081A4E70\n\
b _081A4FC4\n\
_081A4E70:\n\
ldr r4, [sp, 0x14]\n\
lsls r4, 2\n\
mov r9, r4\n\
ldr r0, [sp, 0x24]\n\
lsls r0, 4\n\
str r0, [sp, 0x38]\n\
ldr r1, [sp, 0x20]\n\
lsls r1, 4\n\
str r1, [sp, 0x34]\n\
ldr r2, [sp, 0x1C]\n\
lsls r2, 24\n\
str r2, [sp, 0x3C]\n\
ldr r3, [sp, 0x18]\n\
adds r3, 0x1\n\
str r3, [sp, 0x2C]\n\
ldr r0, [sp, 0x14]\n\
add r0, r9\n\
lsls r0, 2\n\
mov r8, r0\n\
_081A4E96:\n\
bl Random\n\
adds r4, r0, 0\n\
bl Random\n\
lsls r4, 16\n\
lsrs r7, r4, 16\n\
lsls r0, 16\n\
orrs r7, r0\n\
ldr r0, =0x0000ef2a\n\
adds r1, r7, 0\n\
bl IsShinyOtIdPersonality\n\
lsls r0, 24\n\
cmp r0, 0\n\
bne _081A4E96\n\
ldr r4, [sp, 0x38]\n\
ldr r1, [sp, 0x24]\n\
subs r0, r4, r1\n\
lsls r5, r0, 2\n\
mov r2, r8\n\
adds r4, r2, r5\n\
ldr r3, [sp, 0x34]\n\
ldr r1, [sp, 0x20]\n\
subs r0, r3, r1\n\
lsls r6, r0, 3\n\
adds r4, r6\n\
ldr r2, =sFrontierBrainsMons\n\
adds r4, r2\n\
adds r0, r7, 0\n\
bl GetNatureFromPersonality\n\
ldrb r1, [r4, 0x5]\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r1, r0\n\
bne _081A4E96\n\
ldr r4, [sp, 0x18]\n\
movs r0, 0x64\n\
adds r3, r4, 0\n\
muls r3, r0\n\
mov r8, r3\n\
ldr r1, =gEnemyParty\n\
add r1, r8\n\
mov r10, r1\n\
ldr r4, [sp, 0x14]\n\
add r4, r9\n\
lsls r4, 2\n\
adds r0, r4, r5\n\
adds r0, r6\n\
ldr r2, =sFrontierBrainsMons\n\
adds r0, r2\n\
ldrh r1, [r0]\n\
ldr r3, [sp, 0x3C]\n\
lsrs r2, r3, 24\n\
ldrb r3, [r0, 0x4]\n\
movs r0, 0x1\n\
str r0, [sp]\n\
str r7, [sp, 0x4]\n\
str r0, [sp, 0x8]\n\
ldr r0, =0x0000ef2a\n\
str r0, [sp, 0xC]\n\
mov r0, r10\n\
bl CreateMon\n\
ldr r0, =sFrontierBrainsMons\n\
adds r5, r0\n\
adds r5, r6, r5\n\
adds r4, r5, r4\n\
adds r4, 0x2\n\
mov r0, r10\n\
movs r1, 0xC\n\
adds r2, r4, 0\n\
bl SetMonData\n\
movs r7, 0\n\
mov r6, r8\n\
ldr r3, =gEnemyParty\n\
_081A4F32:\n\
adds r1, r7, 0\n\
adds r1, 0x1A\n\
ldr r0, [sp, 0x14]\n\
add r0, r9\n\
lsls r4, r0, 2\n\
adds r2, r5, r4\n\
adds r0, r7, 0x6\n\
adds r2, r0\n\
adds r0, r6, r3\n\
str r3, [sp, 0x40]\n\
bl SetMonData\n\
adds r7, 0x1\n\
ldr r3, [sp, 0x40]\n\
cmp r7, 0x5\n\
ble _081A4F32\n\
movs r1, 0xFF\n\
add r0, sp, 0x10\n\
strb r1, [r0]\n\
movs r7, 0\n\
ldr r1, [sp, 0x18]\n\
movs r2, 0x64\n\
adds r6, r1, 0\n\
muls r6, r2\n\
ldr r3, =sFrontierBrainsMons + 0xC\n\
mov r8, r3\n\
ldr r3, =gEnemyParty\n\
adds r5, r4, 0\n\
_081A4F6A:\n\
ldr r4, [sp, 0x38]\n\
ldr r0, [sp, 0x24]\n\
subs r1, r4, r0\n\
lsls r1, 2\n\
adds r1, r5, r1\n\
ldr r2, [sp, 0x34]\n\
ldr r4, [sp, 0x20]\n\
subs r0, r2, r4\n\
lsls r0, 3\n\
adds r1, r0\n\
add r1, r8\n\
ldrh r4, [r1]\n\
lsls r2, r7, 24\n\
lsrs r2, 24\n\
adds r0, r6, r3\n\
adds r1, r4, 0\n\
str r3, [sp, 0x40]\n\
bl SetMonMoveSlot\n\
ldr r3, [sp, 0x40]\n\
cmp r4, 0xDA\n\
bne _081A4F9C\n\
movs r1, 0\n\
add r0, sp, 0x10\n\
strb r1, [r0]\n\
_081A4F9C:\n\
adds r5, 0x2\n\
adds r7, 0x1\n\
cmp r7, 0x3\n\
ble _081A4F6A\n\
ldr r0, [sp, 0x18]\n\
movs r1, 0x64\n\
adds r4, r0, 0\n\
muls r4, r1\n\
ldr r0, =gEnemyParty\n\
adds r4, r0\n\
adds r0, r4, 0\n\
movs r1, 0x20\n\
add r2, sp, 0x10\n\
bl SetMonData\n\
adds r0, r4, 0\n\
bl CalculateMonStats\n\
ldr r2, [sp, 0x2C]\n\
str r2, [sp, 0x18]\n\
_081A4FC4:\n\
ldr r4, [sp, 0x30]\n\
ldr r3, [sp, 0x28]\n\
str r3, [sp, 0x14]\n\
cmp r3, 0x2\n\
bgt _081A4FD0\n\
b _081A4E5C\n\
_081A4FD0:\n\
add sp, 0x44\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool");
}
#endif
u16 GetFrontierBrainMonSpecies(u8 monId)
{

View File

@ -824,7 +824,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F1398, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&gUnknown_085F0CFC, 0, 96);
LoadCompressedSpriteSheet(gUnknown_085F5064);
LZ77UnCompVram(gUnknown_085F16A8, (void *)(VRAM + 0x10000));
LZ77UnCompVram(gUnknown_085F16A8, (void *)(OBJ_VRAM0));
LoadPalette(&gUnknown_085F1668, 256, 32);
sub_817B76C();
break;
@ -834,7 +834,7 @@ void sub_817B1C8(u8 a)
LZ77UnCompVram(gUnknown_085F1398, (void *)(BG_SCREEN_ADDR(6)));
LoadPalette(&gUnknown_085F0D5C, 0, 96);
LoadCompressedSpriteSheet(gUnknown_085F5064);
LZ77UnCompVram(gUnknown_085F16A8, (void *)(VRAM + 0x10000));
LZ77UnCompVram(gUnknown_085F16A8, (void *)(OBJ_VRAM0));
LoadPalette(&gUnknown_085F1688, 256, 32);
sub_817B76C();
break;

View File

@ -5238,22 +5238,20 @@ static void Task_ExitSearchWaitForFade(u8 taskId)
void SetSearchRectHighlight(u8 flags, u8 x, u8 y, u8 width)
{
u16 i;
u16 i, temp; //This would have been better as a pointer but here we are
u32 ptr = (u32)GetBgTilemapBuffer(3); //this should be a pointer, but this only matches as a u32.
u16 temp; //This would have been better as a pointer but here we are
for (i = 0; i < width; i++)
{
temp = *(u16 *)(ptr + y * 64 + (x + i) * 2);
temp &= 0xFFF;
temp |= (flags << 12);
*(u16 *)(ptr + (y*64 + (x + i)*2)) = temp;
temp = *(u16 *)(ptr + (y + 1)*64 + (x + i)*2);
temp &= 0xFFF;
temp |= (flags << 12);
*(u16 *)(ptr + (y + 1)*64 + (x + i)*2)) = temp;
temp = *(u16 *)(ptr + (y+0)*64 + (x+i)*2);
temp &= 0x0fff;
temp |= (flags << 12);
*(u16 *)(ptr + (y+0)*64 + (x+i)*2) = temp;
temp = *(u16 *)(ptr + (y+1)*64 + (x+i)*2);
temp &= 0x0fff;
temp |= (flags << 12);
*(u16 *)(ptr + (y+1)*64 + (x+i)*2) = temp;
}
}

View File

@ -471,139 +471,42 @@ void sub_81C7990(u32 a0, u16 a1)
CpuFill16(a1, gPlttBufferFaded + 0x100 + (a0 * 16), 16 * sizeof(u16));
}
NAKED
void sub_81C79BC(const u16 *a0, const u16 *a1, u32 a2, u32 a3, u32 a4, u16 *a5)
void sub_81C79BC(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette)
{
asm_unified(
"push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0xC\n\
str r0, [sp]\n\
str r1, [sp, 0x4]\n\
mov r10, r2\n\
str r3, [sp, 0x8]\n\
ldr r0, [sp, 0x2C]\n\
cmp r0, 0\n\
bne _081C79E4\n\
ldr r2, =0x001fffff\n\
mov r1, r10\n\
ands r2, r1\n\
ldr r0, [sp]\n\
b _081C79F4\n\
.pool\n\
_081C79E4:\n\
ldr r2, [sp, 0x2C]\n\
ldr r0, [sp, 0x8]\n\
cmp r2, r0\n\
blt _081C7A00\n\
ldr r2, =0x001fffff\n\
mov r1, r10\n\
ands r2, r1\n\
ldr r0, [sp, 0x4]\n\
_081C79F4:\n\
ldr r1, [sp, 0x30]\n\
bl CpuSet\n\
b _081C7AAE\n\
.pool\n\
_081C7A00:\n\
movs r2, 0x1\n\
negs r2, r2\n\
add r10, r2\n\
b _081C7AA6\n\
_081C7A08:\n\
ldr r1, [sp]\n\
ldrh r0, [r1]\n\
movs r2, 0x1F\n\
mov r9, r2\n\
mov r1, r9\n\
ands r1, r0\n\
mov r9, r1\n\
lsls r0, 16\n\
lsrs r2, r0, 21\n\
movs r1, 0x1F\n\
ands r1, r2\n\
mov r8, r1\n\
lsrs r7, r0, 26\n\
movs r2, 0x1F\n\
ands r7, r2\n\
ldr r0, [sp, 0x4]\n\
ldrh r4, [r0]\n\
movs r0, 0x1F\n\
ands r0, r4\n\
mov r1, r9\n\
subs r0, r1\n\
lsls r0, 8\n\
ldr r1, [sp, 0x8]\n\
bl __divsi3\n\
ldr r2, [sp, 0x2C]\n\
adds r6, r0, 0\n\
muls r6, r2\n\
asrs r6, 8\n\
lsls r4, 16\n\
lsrs r0, r4, 21\n\
movs r1, 0x1F\n\
ands r0, r1\n\
mov r2, r8\n\
subs r0, r2\n\
lsls r0, 8\n\
ldr r1, [sp, 0x8]\n\
bl __divsi3\n\
ldr r1, [sp, 0x2C]\n\
adds r5, r0, 0\n\
muls r5, r1\n\
asrs r5, 8\n\
lsrs r4, 26\n\
movs r2, 0x1F\n\
ands r4, r2\n\
subs r4, r7\n\
lsls r4, 8\n\
adds r0, r4, 0\n\
ldr r1, [sp, 0x8]\n\
bl __divsi3\n\
ldr r1, [sp, 0x2C]\n\
muls r0, r1\n\
asrs r0, 8\n\
add r6, r9\n\
movs r2, 0x1F\n\
ands r6, r2\n\
add r5, r8\n\
ands r5, r2\n\
adds r0, r7, r0\n\
ands r0, r2\n\
lsls r0, 10\n\
lsls r5, 5\n\
orrs r0, r5\n\
orrs r0, r6\n\
ldr r1, [sp, 0x30]\n\
strh r0, [r1]\n\
ldr r2, [sp]\n\
adds r2, 0x2\n\
str r2, [sp]\n\
ldr r0, [sp, 0x4]\n\
adds r0, 0x2\n\
str r0, [sp, 0x4]\n\
adds r1, 0x2\n\
str r1, [sp, 0x30]\n\
movs r1, 0x1\n\
negs r1, r1\n\
add r10, r1\n\
_081C7AA6:\n\
movs r0, 0x1\n\
negs r0, r0\n\
cmp r10, r0\n\
bne _081C7A08\n\
_081C7AAE:\n\
add sp, 0xC\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0");
if (a4 == 0)
{
CpuCopy16(a0, palette, a2 * 2);
}
else if (a4 >= a3)
{
CpuCopy16(a1, palette, a2 * 2);
}
else
{
int r, g, b;
int r1, g1, b1;
while (a2--)
{
r = R(*a0);
g = G(*a0);
b = B(*a0);
r1 = ((((R(*a1) << 8) - (r << 8)) / a3) * a4) >> 8;
g1 = ((((G(*a1) << 8) - (g << 8)) / a3) * a4) >> 8;
b1 = ((((B(*a1) << 8) - (b << 8)) / a3) * a4) >> 8;
r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of (r + r1 & 0x1F)
g = (g + g1) & 0x1F; //See above
b = (b + b1) & 0x1F; //See above
*palette = RGB2(r, g, b); //See above comment
a0++, a1++;
palette++;
}
}
}
void PokenavFadeScreen(s32 fadeType)
@ -780,7 +683,7 @@ static void LoadLeftHeaderGfxForMenu(u32 menuGfxId)
size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data);
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20);
LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer);
RequestDma3Copy(gDecompressionBuffer, (void *)VRAM + 0x10000 + (GetSpriteTileStartByTag(2) * 32), size, 1);
RequestDma3Copy(gDecompressionBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1);
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].size;
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN)

View File

@ -118,8 +118,8 @@ static u8 GetLetterTableId(u8 letter)
static bool32 TryCalculateWallpaper(u16* backgroundClr, u16 *foregroundClr, u8 *iconId, u8 *patternId, u16 trainerId, u8 *phrase)
{
s32 i;
ALIGNED(2) u8 array[12];
u8 charsByTableId[16];
u8 array[9];
u8 charsByTableId[15];
u16 *ptr;
if (StringLength(phrase) != 15)