This commit is contained in:
KDSKardabox 2018-02-27 10:35:17 +05:30
commit 99630e954c
5 changed files with 102 additions and 768 deletions

View File

@ -25,7 +25,7 @@ enum
};
extern u8 gBraillePuzzleCallbackFlag;
extern u8 gUnknown_085EFE74[][2];
extern const u8 gUnknown_085EFE74[][2];
void SealedChamberShakingEffect(u8);
void sub_8179860(void);
@ -375,37 +375,49 @@ bool8 FldEff_UsePuzzleEffect(void)
return FALSE;
}
// can't get this one to match due to the weird macro-like varsets with strange bitshifting.
// to note: 0x10000 is loaded in, and its obviously supposed to be 1, but i cant get 0x80 << 9 to be loaded in without using it directly.
// maybe there's some way of writing it that works?
#ifdef NONMATCHING
// ShouldDoBrailleRegicePuzzle
bool8 ShouldDoBrailleRegicePuzzle(void)
{
u8 i;
if (gSaveBlock1Ptr->location.mapGroup == 0x18 && gSaveBlock1Ptr->location.mapNum == 0x43)
if (gSaveBlock1Ptr->location.mapGroup == 0x18
&& gSaveBlock1Ptr->location.mapNum == 0x43)
{
// _08179A1A
if (FlagGet(FLAG_SYS_BRAILLE_WAIT) != FALSE)
return FALSE;
if (FlagGet(2) == FALSE)
if (FlagGet(FLAG_0x002) == FALSE)
return FALSE;
if (FlagGet(3) == TRUE)
if (FlagGet(FLAG_0x003) == TRUE)
return FALSE;
for (i = 0; i < 36; i++)
{
if (gSaveBlock1Ptr->pos.x == gUnknown_085EFE74[i][0] && gSaveBlock1Ptr->pos.y == gUnknown_085EFE74[i][1])
u8 xPos = gUnknown_085EFE74[i][0];
u8 yPos = gUnknown_085EFE74[i][1];
if (gSaveBlock1Ptr->pos.x == xPos && gSaveBlock1Ptr->pos.y == yPos)
{
if (i < 16)
VarSet(0x403B, (0x10000 << i | VarGet(0x403B) << 16) >> 16); // correct
else if (i < 32)
VarSet(0x403C, (0x10000 << (i - 16) | VarGet(0x403C) << 16) >> 16); // hmm?
else
VarSet(0x403D, (0x10000 << (i - 32) | VarGet(0x403D) << 16) >> 16); // hmm?
u16 varValue;
if (VarGet(0x403B) != 0xFFFF || VarGet(0x403C) != 0xFF || VarGet(0x403D) != 0xF)
if (i < 16)
{
u16 val = VarGet(0x403B);
val |= 1 << i;
VarSet(0x403B, val);
}
else if (i < 32)
{
u16 val = VarGet(0x403C);
val |= 1 << (i - 16);
VarSet(0x403C, val);
}
else
{
u16 val = VarGet(0x403D);
val |= 1 << (i - 32);
VarSet(0x403D, val);
}
varValue = VarGet(0x403B);
if (varValue != 0xFFFF || VarGet(0x403C) != varValue || VarGet(0x403D) != 0xF)
return FALSE;
if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 21)
@ -414,170 +426,10 @@ bool8 ShouldDoBrailleRegicePuzzle(void)
return FALSE;
}
}
FlagSet(FLAG_0x003);
FlagClear(FLAG_0x002);
}
// TODO: Find what flags 2 and 3 are.
FlagSet(3);
FlagClear(2);
return FALSE;
}
#else
ASM_DIRECT
bool8 ShouldDoBrailleRegicePuzzle(void)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r9\n\
mov r6, r8\n\
push {r6,r7}\n\
ldr r4, =gSaveBlock1Ptr\n\
ldr r0, [r4]\n\
ldrh r1, [r0, 0x4]\n\
ldr r0, =0x00004318\n\
cmp r1, r0\n\
beq _08179A1A\n\
b _08179B5A\n\
_08179A1A:\n\
ldr r0, =0x000008b1\n\
bl FlagGet\n\
lsls r0, 24\n\
cmp r0, 0\n\
beq _08179A28\n\
b _08179B5A\n\
_08179A28:\n\
movs r0, 0x2\n\
bl FlagGet\n\
lsls r0, 24\n\
cmp r0, 0\n\
bne _08179A36\n\
b _08179B5A\n\
_08179A36:\n\
movs r0, 0x3\n\
bl FlagGet\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x1\n\
bne _08179A58\n\
b _08179B5A\n\
.pool\n\
_08179A54:\n\
movs r0, 0x1\n\
b _08179B5C\n\
_08179A58:\n\
movs r5, 0\n\
mov r8, r4\n\
ldr r4, =gUnknown_085EFE74\n\
adds r0, r4, 0x1\n\
mov r12, r0\n\
ldr r6, =0x0000403b\n\
ldr r1, =0x0000403c\n\
mov r9, r1\n\
_08179A68:\n\
lsls r0, r5, 1\n\
adds r1, r0, r4\n\
add r0, r12\n\
ldrb r3, [r0]\n\
mov r7, r8\n\
ldr r2, [r7]\n\
movs r7, 0\n\
ldrsh r0, [r2, r7]\n\
ldrb r1, [r1]\n\
cmp r0, r1\n\
bne _08179B44\n\
movs r1, 0x2\n\
ldrsh r0, [r2, r1]\n\
cmp r0, r3\n\
bne _08179B44\n\
cmp r5, 0xF\n\
bhi _08179AB0\n\
adds r0, r6, 0\n\
bl VarGet\n\
lsls r0, 16\n\
movs r1, 0x80\n\
lsls r1, 9\n\
lsls r1, r5\n\
orrs r1, r0\n\
lsrs r1, 16\n\
adds r0, r6, 0\n\
bl VarSet\n\
b _08179AF0\n\
.pool\n\
_08179AB0:\n\
cmp r5, 0x1F\n\
bhi _08179AD2\n\
mov r0, r9\n\
bl VarGet\n\
lsls r0, 16\n\
adds r2, r5, 0\n\
subs r2, 0x10\n\
movs r1, 0x80\n\
lsls r1, 9\n\
lsls r1, r2\n\
orrs r1, r0\n\
lsrs r1, 16\n\
mov r0, r9\n\
bl VarSet\n\
b _08179AF0\n\
_08179AD2:\n\
ldr r4, =0x0000403d\n\
adds r0, r4, 0\n\
bl VarGet\n\
lsls r0, 16\n\
adds r2, r5, 0\n\
subs r2, 0x20\n\
movs r1, 0x80\n\
lsls r1, 9\n\
lsls r1, r2\n\
orrs r1, r0\n\
lsrs r1, 16\n\
adds r0, r4, 0\n\
bl VarSet\n\
_08179AF0:\n\
ldr r0, =0x0000403b\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
ldr r0, =0x0000ffff\n\
cmp r4, r0\n\
bne _08179B5A\n\
ldr r0, =0x0000403c\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r0, 16\n\
cmp r0, r4\n\
bne _08179B5A\n\
ldr r0, =0x0000403d\n\
bl VarGet\n\
lsls r0, 16\n\
lsrs r0, 16\n\
cmp r0, 0xF\n\
bne _08179B5A\n\
ldr r0, =gSaveBlock1Ptr\n\
ldr r0, [r0]\n\
ldr r1, [r0]\n\
ldr r0, =0x00150008\n\
cmp r1, r0\n\
beq _08179A54\n\
b _08179B5A\n\
.pool\n\
_08179B44:\n\
adds r0, r5, 0x1\n\
lsls r0, 24\n\
lsrs r5, r0, 24\n\
cmp r5, 0x23\n\
bls _08179A68\n\
movs r0, 0x3\n\
bl FlagSet\n\
movs r0, 0x2\n\
bl FlagClear\n\
_08179B5A:\n\
movs r0, 0\n\
_08179B5C:\n\
pop {r3,r4}\n\
mov r8, r3\n\
mov r9, r4\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1\n\
.syntax divided");
}
#endif

View File

@ -2507,30 +2507,27 @@ void sub_812A040(u8 left, u8 top, u8 right, u8 bottom)
}
}
#ifdef NONMATCHING
void sub_812A0E8(u8 taskId)
{
u8 i;
u8 xOff;
u8 yOff;
u8 decor;
register u8 decor asm("r1");
struct DecorRearrangementDataBuffer *data;
u8 var1;
u32 var2;
sCurDecorSelectedInRearrangement = 0;
if (sub_8129FC8(taskId) != TRUE)
{
for (i = 0; i < gUnknown_0203A17C.size; i ++)
for (i = 0; i < gUnknown_0203A17C.size; i++)
{
decor = gUnknown_0203A17C.items[i];
if (decor != DECOR_NONE)
var1 = gUnknown_0203A17C.items[i];
if (var1 != DECOR_NONE)
{
data = &sDecorRearrangementDataBuffer[0];
sub_8129D8C(decor, data);
if (sub_8129E74(taskId, i, data) == TRUE)
sub_8129D8C(var1, &sDecorRearrangementDataBuffer[0]);
if (sub_8129E74(taskId, i, &sDecorRearrangementDataBuffer[0]) == TRUE)
{
data->idx = i;
sCurDecorSelectedInRearrangement ++;
sDecorRearrangementDataBuffer[0].idx = i;
sCurDecorSelectedInRearrangement++;
break;
}
}
@ -2539,95 +2536,13 @@ void sub_812A0E8(u8 taskId)
{
xOff = gUnknown_0203A17C.pos[sDecorRearrangementDataBuffer[0].idx] >> 4;
yOff = gUnknown_0203A17C.pos[sDecorRearrangementDataBuffer[0].idx] & 0x0F;
sub_812A040(xOff, yOff - sDecorRearrangementDataBuffer[0].height + 1, xOff + sDecorRearrangementDataBuffer[0].width - 1, yOff); // Arithmetic register swap at the r2 argument: `add r2, r0, r2` instead of `add r2, r2, r0`
var1 = yOff - sDecorRearrangementDataBuffer[0].height + 1;
var2 = sDecorRearrangementDataBuffer[0].width + xOff - 1;
sub_812A040(xOff, var1, var2, yOff);
}
}
}
#else
ASM_DIRECT void sub_812A0E8(u8 taskId)
{
asm_unified("\tpush {r4-r7,lr}\n"
"\tlsls r0, 24\n"
"\tlsrs r6, r0, 24\n"
"\tldr r4, =sCurDecorSelectedInRearrangement\n"
"\tmovs r0, 0\n"
"\tstrb r0, [r4]\n"
"\tadds r0, r6, 0\n"
"\tbl sub_8129FC8\n"
"\tlsls r0, 24\n"
"\tlsrs r0, 24\n"
"\tcmp r0, 0x1\n"
"\tbeq _0812A18C\n"
"\tmovs r5, 0\n"
"\tldr r0, =gUnknown_0203A17C\n"
"\tldrb r1, [r0, 0x8]\n"
"\tcmp r5, r1\n"
"\tbcs _0812A15A\n"
"\tadds r7, r4, 0\n"
"_0812A10E:\n"
"\tldr r0, [r0]\n"
"\tadds r0, r5\n"
"\tldrb r1, [r0]\n"
"\tcmp r1, 0\n"
"\tbeq _0812A14C\n"
"\tldr r4, =sDecorRearrangementDataBuffer\n"
"\tadds r0, r1, 0\n"
"\tadds r1, r4, 0\n"
"\tbl sub_8129D8C\n"
"\tadds r0, r6, 0\n"
"\tadds r1, r5, 0\n"
"\tadds r2, r4, 0\n"
"\tbl sub_8129E74\n"
"\tlsls r0, 24\n"
"\tlsrs r0, 24\n"
"\tcmp r0, 0x1\n"
"\tbne _0812A14C\n"
"\tstrb r5, [r4]\n"
"\tldrb r0, [r7]\n"
"\tadds r0, 0x1\n"
"\tstrb r0, [r7]\n"
"\tb _0812A15A\n"
"\t.pool\n"
"_0812A14C:\n"
"\tadds r0, r5, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r5, r0, 24\n"
"\tldr r0, =gUnknown_0203A17C\n"
"\tldrb r1, [r0, 0x8]\n"
"\tcmp r5, r1\n"
"\tbcc _0812A10E\n"
"_0812A15A:\n"
"\tldr r0, =sCurDecorSelectedInRearrangement\n"
"\tldrb r0, [r0]\n"
"\tcmp r0, 0\n"
"\tbeq _0812A18C\n"
"\tldr r0, =gUnknown_0203A17C\n"
"\tldr r2, =sDecorRearrangementDataBuffer\n"
"\tldrb r1, [r2]\n"
"\tldr r0, [r0, 0x4]\n"
"\tadds r0, r1\n"
"\tldrb r1, [r0]\n"
"\tlsrs r0, r1, 4\n"
"\tmovs r3, 0xF\n"
"\tands r3, r1\n"
"\tldrb r1, [r2, 0x2]\n"
"\tsubs r1, r3, r1\n"
"\tadds r1, 0x1\n"
"\tlsls r1, 24\n"
"\tlsrs r1, 24\n"
"\tldrb r2, [r2, 0x1]\n"
"\tadds r2, r0\n"
"\tsubs r2, 0x1\n"
"\tlsls r2, 24\n"
"\tlsrs r2, 24\n"
"\tbl sub_812A040\n"
"_0812A18C:\n"
"\tpop {r4-r7}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.pool");
}
#endif
void sub_812A1A0(u8 taskId)
{

View File

@ -529,16 +529,17 @@ void DoRippleFieldEffect(struct MapObject *mapObject, struct Sprite *sprite)
FieldEffectStart(FLDEFF_RIPPLE);
}
#ifdef NONMATCHING
bool32 sub_8097E50(struct MapObject *mapObject, struct Sprite *sprite)
{
u32 one;
bool32 ableToStore = FALSE;
if (gUnknown_020375B8 == NULL)
{
gUnknown_020375B8 = AllocZeroed(0x14);
gUnknown_020375B8[0] = mapObject->localId;
gUnknown_020375B8[16] = 1;
ableToStore = TRUE;
// needed to match
gUnknown_020375B8[16] = (one = 1);
ableToStore = one;
}
else
{
@ -561,7 +562,7 @@ bool32 sub_8097E50(struct MapObject *mapObject, struct Sprite *sprite)
{
gUnknown_020375B8[firstFreeSlot] = mapObject->localId;
gUnknown_020375B8[16]++;
ableToStore = TRUE; // the nonmatching problem is that ableToStore == TRUE isnt being merged with the above ableToStore = TRUE assignment.
ableToStore = TRUE;
}
}
@ -574,174 +575,34 @@ bool32 sub_8097E50(struct MapObject *mapObject, struct Sprite *sprite)
sprite->data[2] = 1;
return TRUE;
}
#else
__attribute__((naked))
bool32 sub_8097E50(struct MapObject *mapObject, struct Sprite *sprite)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r8\n\
push {r7}\n\
adds r4, r0, 0\n\
mov r8, r1\n\
movs r0, 0\n\
mov r12, r0\n\
ldr r0, =gUnknown_020375B8\n\
ldr r1, [r0]\n\
adds r6, r0, 0\n\
cmp r1, 0\n\
bne _08097E80\n\
movs r0, 0x14\n\
bl AllocZeroed\n\
str r0, [r6]\n\
ldrb r1, [r4, 0x8]\n\
strb r1, [r0]\n\
ldr r1, [r6]\n\
movs r0, 0x1\n\
strb r0, [r1, 0x10]\n\
b _08097ECC\n\
.pool\n\
_08097E80:\n\
movs r2, 0x10\n\
movs r5, 0\n\
movs r1, 0\n\
adds r3, r6, 0\n\
b _08097E90\n\
_08097E8A:\n\
adds r0, r1, 0x1\n\
lsls r0, 24\n\
lsrs r1, r0, 24\n\
_08097E90:\n\
cmp r1, 0xF\n\
bhi _08097EB2\n\
cmp r2, 0x10\n\
bne _08097EA4\n\
ldr r0, [r3]\n\
adds r0, r1\n\
ldrb r0, [r0]\n\
cmp r0, 0\n\
bne _08097EA4\n\
adds r2, r1, 0\n\
_08097EA4:\n\
ldr r0, [r3]\n\
adds r0, r1\n\
ldrb r0, [r0]\n\
ldrb r7, [r4, 0x8]\n\
cmp r0, r7\n\
bne _08097E8A\n\
movs r5, 0x1\n\
_08097EB2:\n\
cmp r5, 0\n\
bne _08097ECE\n\
cmp r2, 0x10\n\
beq _08097ECE\n\
ldr r0, [r6]\n\
adds r0, r2\n\
ldrb r1, [r4, 0x8]\n\
strb r1, [r0]\n\
ldr r1, [r6]\n\
ldrb r0, [r1, 0x10]\n\
adds r0, 0x1\n\
strb r0, [r1, 0x10]\n\
movs r0, 0x1\n\
_08097ECC:\n\
mov r12, r0\n\
_08097ECE:\n\
mov r1, r12\n\
cmp r1, 0x1\n\
bne _08097EE0\n\
ldrb r0, [r4, 0x1]\n\
movs r1, 0x10\n\
orrs r0, r1\n\
movs r1, 0x2\n\
orrs r0, r1\n\
strb r0, [r4, 0x1]\n\
_08097EE0:\n\
movs r0, 0x1\n\
mov r7, r8\n\
strh r0, [r7, 0x32]\n\
pop {r3}\n\
mov r8, r3\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1\n\
.syntax divided");
}
#endif
// this function is very similar to the above one and I don't want to decompile this one until the above is matching.
__attribute__((naked))
bool32 sub_8097EF0(struct MapObject *mapObject, struct Sprite *sprite)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r8\n\
push {r7}\n\
adds r6, r0, 0\n\
mov r8, r1\n\
movs r0, 0x1\n\
strh r0, [r1, 0x32]\n\
ldr r5, =gUnknown_020375B8\n\
ldr r0, [r5]\n\
cmp r0, 0\n\
beq _08097F68\n\
movs r7, 0\n\
adds r0, r6, 0\n\
bl sub_8097F78\n\
lsls r0, 24\n\
lsrs r1, r0, 24\n\
cmp r1, 0x10\n\
beq _08097F28\n\
ldr r0, [r5]\n\
adds r0, r1\n\
movs r1, 0\n\
strb r1, [r0]\n\
ldr r1, [r5]\n\
ldrb r0, [r1, 0x10]\n\
subs r0, 0x1\n\
strb r0, [r1, 0x10]\n\
movs r7, 0x1\n\
_08097F28:\n\
ldr r0, [r5]\n\
ldrb r4, [r0, 0x10]\n\
cmp r4, 0\n\
bne _08097F36\n\
bl Free\n\
str r4, [r5]\n\
_08097F36:\n\
cmp r7, 0x1\n\
bne _08097F68\n\
ldrb r0, [r6, 0x5]\n\
bl GetFieldObjectGraphicsInfo\n\
ldrb r1, [r0, 0xC]\n\
lsls r1, 25\n\
lsrs r1, 31\n\
lsls r1, 4\n\
ldrb r2, [r6, 0x1]\n\
movs r0, 0x11\n\
negs r0, r0\n\
ands r0, r2\n\
orrs r0, r1\n\
movs r1, 0x3\n\
negs r1, r1\n\
ands r0, r1\n\
strb r0, [r6, 0x1]\n\
mov r2, r8\n\
adds r2, 0x2C\n\
ldrb r1, [r2]\n\
movs r0, 0x41\n\
negs r0, r0\n\
ands r0, r1\n\
strb r0, [r2]\n\
_08097F68:\n\
movs r0, 0x1\n\
pop {r3}\n\
mov r8, r3\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1\n\
.pool\n\
.syntax divided");
bool32 ableToStore;
u8 id;
sprite->data[2] = 1;
if (gUnknown_020375B8 != NULL)
{
ableToStore = FALSE;
id = sub_8097F78(mapObject);
if (id != 16)
{
gUnknown_020375B8[id] = 0;
gUnknown_020375B8[16]--;
ableToStore = TRUE;
}
if (gUnknown_020375B8[16] == 0)
FREE_AND_SET_NULL(gUnknown_020375B8);
if (ableToStore == TRUE)
{
mapObject->mapobj_bit_12 = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->inanimate;
mapObject->mapobj_bit_9 = 0;
sprite->animPaused = 0;
}
}
return TRUE;
}
u8 sub_8097F78(struct MapObject *mapObject)

View File

@ -1476,20 +1476,14 @@ bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx)
return TRUE;
}
// Lots of math, can't figure it out.
/*
bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
{
u8 *ptr = (u8 *)ScriptReadWord(ctx);
struct WindowTemplate template1;
struct WindowTemplate template2;
int i;
u8 width;
u8 height;
int temp1;
int temp2;
u8 x;
u8 y;
struct WindowTemplate winTemplate;
s32 i;
u8 width, height;
u8 xWindow, yWindow, xText, yText;
u8 temp;
StringExpandPlaceholders(gStringVar4, ptr + 6);
@ -1507,168 +1501,30 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
if (height > 0x12)
height = 0x12;
x = width + 2;
temp1 = (0x1E - x) / 2;
x = temp1 + 1;
temp1 = ((x - temp1 - 1) * 8 + 3);
temp = width + 2;
xWindow = (0x1E - temp) / 2;
y = height + 2;
temp2 = (0x14 - y) / 2;
y = temp2 + 2;
temp2 = ((y - temp2 - 1) * 8);
temp = height + 2;
yText = (0x14 - temp) / 2;
sub_8198A50(&template1, 0, x, y, width, height, 0xF, 0x1);
template2 = template1;
gUnknown_03000F30 = AddWindow(&template2);
xText = xWindow;
xWindow += 1;
yWindow = yText;
yText += 2;
xText = (xWindow - xText - 1) * 8 + 3;
yText = (yText - yWindow - 1) * 8;
winTemplate = sub_8198A50(0, xWindow, yWindow + 1, width, height, 0xF, 0x1);
gUnknown_03000F30 = AddWindow(&winTemplate);
sub_809882C(gUnknown_03000F30, 0x214, 0xE0);
NewMenuHelpers_DrawStdWindowFrame(gUnknown_03000F30, 0);
PutWindowTilemap(gUnknown_03000F30);
FillWindowPixelBuffer(gUnknown_03000F30, 0x11);
PrintTextOnWindow(gUnknown_03000F30, 6, gStringVar4, temp1, temp2, 0xFF, 0x0);
PrintTextOnWindow(gUnknown_03000F30, 6, gStringVar4, xText, yText, 0xFF, 0x0);
CopyWindowToVram(gUnknown_03000F30, 3);
return FALSE;
}*/
ASM_DIRECT
bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
{
asm("push {r4-r7,lr}\n\
mov r7, r8\n\
push {r7}\n\
sub sp, #0x20\n\
bl ScriptReadWord\n\
add r1, r0, #0\n\
ldr r4, =gStringVar4\n\
add r1, #0x6\n\
add r0, r4, #0\n\
bl StringExpandPlaceholders\n\
mov r2, #0x1\n\
neg r2, r2\n\
mov r0, #0x6\n\
add r1, r4, #0\n\
bl GetStringWidth\n\
lsr r0, #3\n\
lsl r0, #24\n\
lsr r7, r0, #24\n\
cmp r7, #0x1C\n\
bls _0809AE9C\n\
mov r7, #0x1C\n\
_0809AE9C:\n\
mov r5, #0x4\n\
ldrb r0, [r4]\n\
add r2, r7, #0x2\n\
add r1, sp, #0x18\n\
mov r8, r1\n\
cmp r0, #0xFF\n\
beq _0809AEC0\n\
add r1, r4, #0\n\
_0809AEAC:\n\
ldrb r0, [r1]\n\
add r1, #0x1\n\
cmp r0, #0xFE\n\
bne _0809AEBA\n\
add r0, r5, #0x3\n\
lsl r0, #24\n\
lsr r5, r0, #24\n\
_0809AEBA:\n\
ldrb r0, [r1]\n\
cmp r0, #0xFF\n\
bne _0809AEAC\n\
_0809AEC0:\n\
cmp r5, #0x12\n\
bls _0809AEC6\n\
mov r5, #0x12\n\
_0809AEC6:\n\
lsl r0, r2, #24\n\
lsr r0, #24\n\
mov r2, #0x1E\n\
sub r2, r0\n\
lsr r0, r2, #31\n\
add r2, r0\n\
asr r2, #1\n\
lsl r2, #24\n\
add r0, r5, #0x2\n\
lsl r0, #24\n\
lsr r0, #24\n\
mov r4, #0x14\n\
sub r4, r0\n\
lsr r0, r4, #31\n\
add r4, r0\n\
asr r4, #1\n\
lsl r4, #24\n\
lsr r6, r2, #24\n\
mov r0, #0x80\n\
lsl r0, #17\n\
add r2, r0\n\
lsr r2, #24\n\
lsr r3, r4, #24\n\
mov r1, #0x80\n\
lsl r1, #18\n\
add r4, r1\n\
lsr r4, #24\n\
sub r6, r2, r6\n\
sub r6, #0x1\n\
lsl r6, #3\n\
add r6, #0x3\n\
lsl r6, #24\n\
lsr r6, #24\n\
sub r4, r3\n\
sub r4, #0x1\n\
lsl r4, #27\n\
lsr r4, #24\n\
add r3, #0x1\n\
lsl r3, #24\n\
lsr r3, #24\n\
str r7, [sp]\n\
str r5, [sp, #0x4]\n\
mov r0, #0xF\n\
str r0, [sp, #0x8]\n\
mov r0, #0x1\n\
str r0, [sp, #0xC]\n\
add r0, sp, #0x10\n\
mov r1, #0\n\
bl sub_8198A50\n\
ldr r0, [sp, #0x10]\n\
ldr r1, [sp, #0x14]\n\
str r0, [sp, #0x18]\n\
str r1, [sp, #0x1C]\n\
ldr r5, =gUnknown_03000F30\n\
mov r0, r8\n\
bl AddWindow\n\
strb r0, [r5]\n\
ldrb r0, [r5]\n\
mov r1, #0x85\n\
lsl r1, #2\n\
mov r2, #0xE0\n\
bl sub_809882C\n\
ldrb r0, [r5]\n\
mov r1, #0\n\
bl NewMenuHelpers_DrawStdWindowFrame\n\
ldrb r0, [r5]\n\
bl PutWindowTilemap\n\
ldrb r0, [r5]\n\
mov r1, #0x11\n\
bl FillWindowPixelBuffer\n\
ldrb r0, [r5]\n\
ldr r2, =gStringVar4\n\
str r4, [sp]\n\
mov r1, #0xFF\n\
str r1, [sp, #0x4]\n\
mov r1, #0\n\
str r1, [sp, #0x8]\n\
mov r1, #0x6\n\
add r3, r6, #0\n\
bl PrintTextOnWindow\n\
ldrb r0, [r5]\n\
mov r1, #0x3\n\
bl CopyWindowToVram\n\
mov r0, #0\n\
add sp, #0x20\n\
pop {r3}\n\
mov r8, r3\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1\n\
.pool");
}
bool8 ScrCmd_cmdDA(struct ScriptContext *ctx)

158
src/tv.c
View File

@ -2088,7 +2088,6 @@ void sub_80EDE84(u16 nCoinsSpent)
sFindThatGamerCoinsSpent = nCoinsSpent;
}
#ifdef NONMATCHING // FIXME: Register allocation shenanigans
void sub_80EDE98(TVShow *show)
{
u8 i;
@ -2140,11 +2139,11 @@ void sub_80EDE98(TVShow *show)
default:
for (k = 0; k < n * n; k ++)
{
i = Random() % n;
deco = Random() % n;
j = Random() % n;
x = sTV_DecorationsBuffer[i];
sTV_DecorationsBuffer[i] = sTV_DecorationsBuffer[j];
sTV_DecorationsBuffer[j] = x;
i = sTV_DecorationsBuffer[deco];
sTV_DecorationsBuffer[deco] = sTV_DecorationsBuffer[j];
sTV_DecorationsBuffer[j] = i;
}
for (i = 0; i < show->secretBaseVisit.nDecorations; i ++)
{
@ -2153,155 +2152,6 @@ void sub_80EDE98(TVShow *show)
break;
}
}
#else
ASM_DIRECT
void sub_80EDE98(TVShow *show)
{
asm_unified("\tpush {r4-r7,lr}\n"
"\tmov r7, r9\n"
"\tmov r6, r8\n"
"\tpush {r6,r7}\n"
"\tmov r8, r0\n"
"\tmovs r3, 0\n"
"\tldr r6, =sTV_DecorationsBuffer\n"
"\tldr r7, =gSaveBlock1Ptr\n"
"\tadds r2, r6, 0\n"
"\tmovs r1, 0\n"
"_080EDEAC:\n"
"\tadds r0, r3, r2\n"
"\tstrb r1, [r0]\n"
"\tadds r0, r3, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r3, r0, 24\n"
"\tcmp r3, 0xF\n"
"\tbls _080EDEAC\n"
"\tmovs r3, 0\n"
"\tmovs r5, 0\n"
"_080EDEBE:\n"
"\tldr r0, [r7]\n"
"\tldr r1, =0x00001aae\n"
"\tadds r0, r1\n"
"\tadds r0, r3\n"
"\tldrb r4, [r0]\n"
"\tadds r3, 0x1\n"
"\tcmp r4, 0\n"
"\tbeq _080EDF0A\n"
"\tmovs r1, 0\n"
"\tldrb r0, [r6]\n"
"\tcmp r0, 0\n"
"\tbne _080EDEE8\n"
"\tstrb r4, [r6]\n"
"\tb _080EDF04\n"
"\t.pool\n"
"_080EDEE8:\n"
"\tadds r0, r1, r6\n"
"\tldrb r0, [r0]\n"
"\tcmp r0, r4\n"
"\tbeq _080EDF0A\n"
"\tadds r0, r1, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r1, r0, 24\n"
"\tcmp r1, 0xF\n"
"\tbhi _080EDF0A\n"
"\tadds r2, r1, r6\n"
"\tldrb r0, [r2]\n"
"\tcmp r0, 0\n"
"\tbne _080EDEE8\n"
"\tstrb r4, [r2]\n"
"_080EDF04:\n"
"\tadds r0, r5, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r5, r0, 24\n"
"_080EDF0A:\n"
"\tlsls r0, r3, 24\n"
"\tlsrs r3, r0, 24\n"
"\tcmp r3, 0xF\n"
"\tbls _080EDEBE\n"
"\tcmp r5, 0x4\n"
"\tbls _080EDF1E\n"
"\tmovs r0, 0x4\n"
"\tmov r1, r8\n"
"\tstrb r0, [r1, 0x3]\n"
"\tb _080EDF22\n"
"_080EDF1E:\n"
"\tmov r0, r8\n"
"\tstrb r5, [r0, 0x3]\n"
"_080EDF22:\n"
"\tmov r1, r8\n"
"\tldrb r0, [r1, 0x3]\n"
"\tcmp r0, 0\n"
"\tbeq _080EDFA4\n"
"\tcmp r0, 0x1\n"
"\tbne _080EDF34\n"
"\tldrb r0, [r6]\n"
"\tstrb r0, [r1, 0x4]\n"
"\tb _080EDFA4\n"
"_080EDF34:\n"
"\tmovs r6, 0\n"
"\tadds r7, r5, 0\n"
"\tmuls r7, r5\n"
"\tcmp r6, r7\n"
"\tbge _080EDF7E\n"
"\tldr r0, =sTV_DecorationsBuffer\n"
"\tmov r9, r0\n"
"_080EDF42:\n"
"\tbl Random\n"
"\tlsls r0, 16\n"
"\tlsrs r0, 16\n"
"\tadds r1, r5, 0\n"
"\tbl __modsi3\n"
"\tlsls r0, 24\n"
"\tlsrs r4, r0, 24\n"
"\tbl Random\n"
"\tlsls r0, 16\n"
"\tlsrs r0, 16\n"
"\tadds r1, r5, 0\n"
"\tbl __modsi3\n"
"\tlsls r0, 24\n"
"\tlsrs r1, r0, 24\n"
"\tmov r0, r9\n"
"\tadds r2, r4, r0\n"
"\tldrb r3, [r2]\n"
"\tadd r1, r9\n"
"\tldrb r0, [r1]\n"
"\tstrb r0, [r2]\n"
"\tstrb r3, [r1]\n"
"\tadds r0, r6, 0x1\n"
"\tlsls r0, 16\n"
"\tlsrs r6, r0, 16\n"
"\tcmp r6, r7\n"
"\tblt _080EDF42\n"
"_080EDF7E:\n"
"\tmovs r3, 0\n"
"\tmov r1, r8\n"
"\tldrb r1, [r1, 0x3]\n"
"\tcmp r3, r1\n"
"\tbcs _080EDFA4\n"
"\tmov r2, r8\n"
"\tadds r2, 0x4\n"
"\tldr r4, =sTV_DecorationsBuffer\n"
"_080EDF8E:\n"
"\tadds r1, r2, r3\n"
"\tadds r0, r3, r4\n"
"\tldrb r0, [r0]\n"
"\tstrb r0, [r1]\n"
"\tadds r0, r3, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r3, r0, 24\n"
"\tmov r0, r8\n"
"\tldrb r0, [r0, 0x3]\n"
"\tcmp r3, r0\n"
"\tbcc _080EDF8E\n"
"_080EDFA4:\n"
"\tpop {r3,r4}\n"
"\tmov r8, r3\n"
"\tmov r9, r4\n"
"\tpop {r4-r7}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.pool");
}
#endif
void sub_80EDFB4(TVShow *show)
{