Match some functions

This commit is contained in:
DizzyEggg 2018-11-25 20:16:41 +01:00
parent dc7764f60c
commit 8e10d7c0e5
7 changed files with 634 additions and 1656 deletions

View File

@ -70,14 +70,14 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset);
void CopyBgTilemapBufferToVram(u8 bg);
void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height);
void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette);
void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2);
void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset);
void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height);
void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta);
u16 GetBgMetricTextMode(u8 bg, u8 whichMetric);
u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric);
u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 screenHeight);
void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2);
void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2);
u32 GetBgType(u8 bg);
bool32 IsInvalidBg32(u8 bg);
bool32 IsTileMapOutsideWram(u8 bg);

View File

@ -465,7 +465,6 @@ extern const u8 gUnknown_08329D2A[];
extern const u8 gStatStageRatios[][2];
extern const u16 gUnknown_08329D54[];
extern const struct SpriteTemplate gUnknown_08329D98[];
extern const struct CompressedSpritePalette gMonPaletteTable[];
extern const s8 gNatureStatTable[][5];
void ZeroBoxMonData(struct BoxPokemon *boxMon);

395
src/bg.c
View File

@ -279,6 +279,7 @@ bool8 IsInvalidBg(u8 bg)
{
if (bg > 3)
return TRUE;
else
return FALSE;
}
@ -434,7 +435,6 @@ u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset)
return (u8)cursor;
}
#ifdef NONMATCHING // Matches everything but r5 and r6 are flipped, rrr
bool8 IsDma3ManagerBusyWithBgCopy(void)
{
u8 mod;
@ -462,60 +462,6 @@ bool8 IsDma3ManagerBusyWithBgCopy(void)
return FALSE;
}
#else
NAKED
bool8 IsDma3ManagerBusyWithBgCopy(void)
{
asm("push {r4-r7,lr}\n\
mov r5, #0\n\
mov r7, #0x1\n\
neg r7, r7\n\
_08001ADC:\n\
add r0, r5, #0\n\
cmp r5, #0\n\
bge _08001AE4\n\
add r0, #0x1F\n\
_08001AE4:\n\
asr r0, #5\n\
lsl r2, r0, #24\n\
lsl r0, #5\n\
sub r0, r5, r0\n\
lsl r0, #24\n\
lsr r0, #24\n\
ldr r1, =sDmaBusyBitfield\n\
lsr r2, #22\n\
add r4, r2, r1\n\
mov r6, #0x1\n\
lsl r6, r0\n\
ldr r0, [r4]\n\
and r0, r6\n\
cmp r0, #0\n\
beq _08001B22\n\
lsl r0, r5, #16\n\
asr r0, #16\n\
bl CheckForSpaceForDma3Request\n\
lsl r0, #24\n\
asr r0, #24\n\
cmp r0, r7\n\
bne _08001B1C\n\
mov r0, #0x1\n\
b _08001B2A\n\
.pool\n\
_08001B1C:\n\
ldr r0, [r4]\n\
bic r0, r6\n\
str r0, [r4]\n\
_08001B22:\n\
add r5, #0x1\n\
cmp r5, #0x7F\n\
ble _08001ADC\n\
mov r0, #0\n\
_08001B2A:\n\
pop {r4-r7}\n\
pop {r1}\n\
bx r1\n");
}
#endif // NONMATCHING
void ShowBg(u8 bg)
{
@ -668,8 +614,9 @@ u32 GetBgX(u8 bg)
{
if (IsInvalidBg32(bg) != FALSE)
return -1;
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
return -1;
else
return sGpuBgConfigs2[bg].bg_x;
}
@ -818,8 +765,9 @@ u32 GetBgY(u8 bg)
{
if (IsInvalidBg32(bg) != FALSE)
return -1;
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
return -1;
else
return sGpuBgConfigs2[bg].bg_y;
}
@ -923,8 +871,9 @@ void* GetBgTilemapBuffer(u8 bg)
{
if (IsInvalidBg32(bg) != FALSE)
return NULL;
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
return NULL;
else
return sGpuBgConfigs2[bg].tilemap;
}
@ -933,15 +882,11 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset)
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
{
if (mode != 0)
{
CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode);
}
else
{
LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)));
}
}
}
void CopyBgTilemapBufferToVram(u8 bg)
{
@ -1005,295 +950,49 @@ void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u
{
CopyRectToBgTilemapBufferRect(bg, src, 0, 0, rectWidth, rectHeight, destX, destY, rectWidth, rectHeight, palette, 0, 0);
}
// Skipping for now, it probably uses structs passed by value
/*
void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2)
{
u16 attribute;
u16 mode;
u16 mode2;
void* srcCopy;
u16 destX16;
u16 destY16;
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset)
{
attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
mode = GetBgMetricTextMode(bg, 0x1) * 0x20;
mode2 = GetBgMetricTextMode(bg, 0x2) * 0x20;
u16 screenWidth, screenHeight, screenSize;
u16 var;
const void *srcPtr;
u16 i, j;
if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{
screenSize = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
screenWidth = GetBgMetricTextMode(bg, 0x1) * 0x20;
screenHeight = GetBgMetricTextMode(bg, 0x2) * 0x20;
switch (GetBgType(bg))
{
case 0:
srcCopy = src;
for (destY16 = destY; destY16 < (destY + rectHeight); destY16++)
srcPtr = src + ((srcY * srcWidth) + srcX) * 2;
for (i = destX; i < (destX + rectWidth); i++)
{
for (destX16 = destX; destX16 < (destX + rectWidth); destX16++)
for (j = srcHeight; j < (srcHeight + destY); j++)
{
CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)sGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2);
u16 index = GetTileMapIndexFromCoords(j, i, screenSize, screenWidth, screenHeight);
CopyTileMapEntry(srcPtr, sGpuBgConfigs2[bg].tilemap + (index * 2), rectHeight, palette1, tileOffset);
srcPtr += 2;
}
srcPtr += (srcWidth - destY) * 2;
}
break;
case 1:
srcCopy = src;
mode = GetBgMetricAffineMode(bg, 0x1);
for (destY16 = destY; destY16 < (destY + rectHeight); destY16++)
srcPtr = src + ((srcY * srcWidth) + srcX);
var = GetBgMetricAffineMode(bg, 0x1);
for (i = destX; i < (destX + rectWidth); i++)
{
for (destX16 = destX; destX16 < (destX + rectWidth); destX16++)
for (j = srcHeight; j < (srcHeight + destY); j++)
{
CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)sGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2);
*(u8*)(sGpuBgConfigs2[bg].tilemap + ((var * i) + j)) = *(u8*)(srcPtr) + palette1;
srcPtr++;
}
srcPtr += (srcWidth - destY);
}
break;
}
}
}*/
NAKED
void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2)
{
asm("push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, #0x40\n\
str r1, [sp, #0x8]\n\
ldr r1, [sp, #0x60]\n\
ldr r4, [sp, #0x68]\n\
ldr r5, [sp, #0x6C]\n\
ldr r6, [sp, #0x70]\n\
ldr r7, [sp, #0x74]\n\
mov r8, r7\n\
ldr r7, [sp, #0x78]\n\
mov r9, r7\n\
ldr r7, [sp, #0x7C]\n\
mov r10, r7\n\
ldr r7, [sp, #0x80]\n\
mov r12, r7\n\
lsl r0, #24\n\
lsr r0, #24\n\
str r0, [sp, #0x4]\n\
lsl r2, #24\n\
lsr r2, #24\n\
str r2, [sp, #0xC]\n\
lsl r3, #24\n\
lsr r3, #24\n\
str r3, [sp, #0x10]\n\
lsl r1, #24\n\
lsr r7, r1, #24\n\
lsl r4, #24\n\
lsr r4, #24\n\
str r4, [sp, #0x14]\n\
lsl r5, #24\n\
lsr r5, #24\n\
lsl r6, #24\n\
lsr r6, #24\n\
str r6, [sp, #0x18]\n\
mov r0, r8\n\
lsl r0, #24\n\
lsr r4, r0, #24\n\
mov r1, r9\n\
lsl r1, #24\n\
lsr r1, #24\n\
str r1, [sp, #0x1C]\n\
mov r2, r10\n\
lsl r2, #16\n\
lsr r2, #16\n\
str r2, [sp, #0x20]\n\
mov r0, r12\n\
lsl r0, #16\n\
lsr r0, #16\n\
str r0, [sp, #0x24]\n\
ldr r0, [sp, #0x4]\n\
bl IsInvalidBg32\n\
cmp r0, #0\n\
beq _08002592\n\
b _080026EE\n\
_08002592:\n\
ldr r0, [sp, #0x4]\n\
bl IsTileMapOutsideWram\n\
cmp r0, #0\n\
beq _0800259E\n\
b _080026EE\n\
_0800259E:\n\
ldr r0, [sp, #0x4]\n\
mov r1, #0x4\n\
bl GetBgControlAttribute\n\
lsl r0, #16\n\
lsr r0, #16\n\
str r0, [sp, #0x30]\n\
ldr r0, [sp, #0x4]\n\
mov r1, #0x1\n\
bl GetBgMetricTextMode\n\
lsl r0, #21\n\
lsr r0, #16\n\
str r0, [sp, #0x28]\n\
ldr r0, [sp, #0x4]\n\
mov r1, #0x2\n\
bl GetBgMetricTextMode\n\
lsl r0, #21\n\
lsr r0, #16\n\
str r0, [sp, #0x2C]\n\
ldr r0, [sp, #0x4]\n\
bl GetBgType\n\
cmp r0, #0\n\
beq _080025D8\n\
cmp r0, #0x1\n\
beq _08002674\n\
b _080026EE\n\
_080025D8:\n\
ldr r1, [sp, #0x10]\n\
add r0, r1, #0\n\
mul r0, r7\n\
ldr r2, [sp, #0xC]\n\
add r0, r2\n\
lsl r0, #1\n\
ldr r1, [sp, #0x8]\n\
add r6, r1, r0\n\
add r0, r5, r4\n\
cmp r5, r0\n\
blt _080025F0\n\
b _080026EE\n\
_080025F0:\n\
ldr r2, [sp, #0x18]\n\
sub r2, r7, r2\n\
str r2, [sp, #0x34]\n\
str r0, [sp, #0x38]\n\
_080025F8:\n\
ldr r4, [sp, #0x14]\n\
ldr r7, [sp, #0x18]\n\
add r0, r4, r7\n\
add r1, r5, #0x1\n\
str r1, [sp, #0x3C]\n\
cmp r4, r0\n\
bge _0800265A\n\
ldr r2, [sp, #0x4]\n\
lsl r0, r2, #4\n\
ldr r1, =sGpuBgConfigs2+4\n\
add r0, r1\n\
mov r10, r0\n\
ldr r7, [sp, #0x20]\n\
lsl r7, #16\n\
mov r9, r7\n\
ldr r1, [sp, #0x24]\n\
lsl r0, r1, #16\n\
asr r0, #16\n\
mov r8, r0\n\
_0800261E:\n\
ldr r2, [sp, #0x2C]\n\
str r2, [sp]\n\
add r0, r4, #0\n\
add r1, r5, #0\n\
ldr r2, [sp, #0x30]\n\
ldr r3, [sp, #0x28]\n\
bl GetTileMapIndexFromCoords\n\
lsl r0, #16\n\
lsr r0, #15\n\
mov r7, r10\n\
ldr r1, [r7]\n\
add r1, r0\n\
mov r0, r8\n\
str r0, [sp]\n\
add r0, r6, #0\n\
ldr r2, [sp, #0x1C]\n\
mov r7, r9\n\
asr r3, r7, #16\n\
bl CopyTileMapEntry\n\
add r6, #0x2\n\
add r0, r4, #0x1\n\
lsl r0, #16\n\
lsr r4, r0, #16\n\
ldr r1, [sp, #0x14]\n\
ldr r2, [sp, #0x18]\n\
add r0, r1, r2\n\
cmp r4, r0\n\
blt _0800261E\n\
_0800265A:\n\
ldr r5, [sp, #0x34]\n\
lsl r0, r5, #1\n\
add r6, r0\n\
ldr r7, [sp, #0x3C]\n\
lsl r0, r7, #16\n\
lsr r5, r0, #16\n\
ldr r0, [sp, #0x38]\n\
cmp r5, r0\n\
blt _080025F8\n\
b _080026EE\n\
.pool\n\
_08002674:\n\
ldr r1, [sp, #0x10]\n\
add r0, r1, #0\n\
mul r0, r7\n\
ldr r2, [sp, #0xC]\n\
add r0, r2\n\
ldr r1, [sp, #0x8]\n\
add r6, r1, r0\n\
ldr r0, [sp, #0x4]\n\
mov r1, #0x1\n\
bl GetBgMetricAffineMode\n\
lsl r0, #16\n\
lsr r0, #16\n\
mov r9, r0\n\
add r0, r5, r4\n\
cmp r5, r0\n\
bge _080026EE\n\
ldr r2, [sp, #0x18]\n\
sub r2, r7, r2\n\
str r2, [sp, #0x34]\n\
str r0, [sp, #0x38]\n\
ldr r7, =sGpuBgConfigs2+4\n\
mov r10, r7\n\
ldr r0, [sp, #0x4]\n\
lsl r0, #4\n\
mov r8, r0\n\
_080026A8:\n\
ldr r4, [sp, #0x14]\n\
ldr r1, [sp, #0x18]\n\
add r0, r4, r1\n\
add r2, r5, #0x1\n\
str r2, [sp, #0x3C]\n\
cmp r4, r0\n\
bge _080026DE\n\
mov r3, r8\n\
add r3, r10\n\
mov r7, r9\n\
mul r7, r5\n\
mov r12, r7\n\
add r2, r0, #0\n\
_080026C2:\n\
ldr r1, [r3]\n\
mov r5, r12\n\
add r0, r5, r4\n\
add r1, r0\n\
ldrb r0, [r6]\n\
ldr r7, [sp, #0x20]\n\
add r0, r7\n\
strb r0, [r1]\n\
add r6, #0x1\n\
add r0, r4, #0x1\n\
lsl r0, #16\n\
lsr r4, r0, #16\n\
cmp r4, r2\n\
blt _080026C2\n\
_080026DE:\n\
ldr r0, [sp, #0x34]\n\
add r6, r0\n\
ldr r1, [sp, #0x3C]\n\
lsl r0, r1, #16\n\
lsr r5, r0, #16\n\
ldr r2, [sp, #0x38]\n\
cmp r5, r2\n\
blt _080026A8\n\
_080026EE:\n\
add sp, #0x40\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\n");
}
void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height)
@ -1471,32 +1170,33 @@ u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32
x -= 0x20;
y += 0x20;
}
break;
}
return (y * 0x20) + x;
}
#ifdef NONMATCHING // This one has some weird switch statement cases that refuse to cooperate
void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2)
void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2)
{
u16 test;
u16 var;
switch (palette1)
{
default:
if (palette1 > 0x10 || palette1 < 0)
test = *src + tileOffset + (palette2 << 12);
case 0 ... 16:
if (palette1 != 16)
var = ((*src + tileOffset) & 0xFFF) + ((palette1 + palette2) << 12);
else
test = ((*src + tileOffset) & 0xFFF) + ((palette1 + palette2) << 12);
var = ((*dest & 0xFC00) + (palette2 << 12)) | ((*src + tileOffset) & 0x3FF);
break;
case 0x10:
test = ((*dest & 0xFC00) + (palette2 << 12)) | ((*src + tileOffset) & 0x3FF);
default:
var = *src + tileOffset + (palette2 << 12);
break;
}
*dest = test;
*dest = var;
}
#else
NAKED
void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2)
void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2)
{
asm("push {r4-r6,lr}\n\
add r4, r0, #0\n\
@ -1550,10 +1250,7 @@ _08002B3C:\n\
u32 GetBgType(u8 bg)
{
u8 mode;
mode = GetBgMode();
u8 mode = GetBgMode();
switch (bg)
{
@ -1594,6 +1291,7 @@ bool32 IsInvalidBg32(u8 bg)
{
if (bg > 3)
return TRUE;
else
return FALSE;
}
@ -1601,7 +1299,8 @@ bool32 IsTileMapOutsideWram(u8 bg)
{
if (sGpuBgConfigs2[bg].tilemap > (void*)IWRAM_END)
return TRUE;
if (sGpuBgConfigs2[bg].tilemap == 0x0)
else if (sGpuBgConfigs2[bg].tilemap == NULL)
return TRUE;
else
return FALSE;
}

View File

@ -32,6 +32,8 @@
#define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))}
extern struct CompressedSpritePalette gMonPaletteTable[]; // GF made a mistake and did not extern it as const.
EWRAM_DATA s32 gFieldEffectArguments[8] = {0};
// Static type declarations
@ -755,67 +757,15 @@ u8 AddNewGameBirchObject(s16 x, s16 y, u8 subpriority)
return CreateSprite(&gNewGameBirchObjectTemplate, x, y, subpriority);
}
#ifdef NONMATCHING
u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority)
{
u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag);
s32 spriteId = CreateMonPicSprite_HandleDeoxys(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag);
PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10);
if (spriteId == 0xFFFF)
return MAX_SPRITES;
else
return spriteId;
}
#else
NAKED
u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority)
{
asm_unified("push {r4,r5,lr}\n\
sub sp, 0x10\n\
lsls r0, 16\n\
lsrs r0, 16\n\
movs r3, 0x80\n\
lsls r3, 8\n\
lsls r1, 16\n\
asrs r1, 16\n\
str r1, [sp]\n\
lsls r2, 16\n\
asrs r2, 16\n\
str r2, [sp, 0x4]\n\
movs r1, 0\n\
str r1, [sp, 0x8]\n\
ldr r1, =gMonPaletteTable\n\
lsls r4, r0, 3\n\
adds r4, r1\n\
ldrh r1, [r4, 0x4]\n\
str r1, [sp, 0xC]\n\
movs r1, 0\n\
adds r2, r3, 0\n\
movs r3, 0x1\n\
bl CreateMonPicSprite_HandleDeoxys\n\
lsls r0, 16\n\
lsrs r5, r0, 16\n\
ldrh r0, [r4, 0x4]\n\
bl IndexOfSpritePaletteTag\n\
adds r0, 0x10\n\
lsls r0, 24\n\
lsrs r0, 24\n\
bl PreservePaletteInWeather\n\
ldr r0, =0x0000ffff\n\
cmp r5, r0\n\
beq _080B5FDC\n\
lsls r0, r5, 24\n\
lsrs r0, 24\n\
b _080B5FDE\n\
.pool\n\
_080B5FDC:\n\
movs r0, 0x40\n\
_080B5FDE:\n\
add sp, 0x10\n\
pop {r4,r5}\n\
pop {r1}\n\
bx r1");
}
#endif //NONMATCHING
u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subpriority)
{
@ -824,7 +774,7 @@ u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subprio
PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10);
if (spriteId == 0xFFFF)
return 0x40;
else
return spriteId;
}

View File

@ -1022,19 +1022,19 @@ static void SynchroniseSurfAnim(struct EventObject *eventObject, struct Sprite *
StartSpriteAnimIfDifferent(sprite, surfBlobDirectionAnims[eventObject->movementDirection]);
}
#ifdef NONMATCHING
void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite)
{
s16 x;
s16 y;
u8 i;
s16 x = eventObject->currentCoords.x;
s16 y = eventObject->currentCoords.y;
s32 spriteY = sprite->pos2.y;
x = eventObject->currentCoords.x;
y = eventObject->currentCoords.y;
if (sprite->pos2.y == 0 && (x != sprite->data[6] || y != sprite->data[7]))
if (spriteY == 0 && (x != sprite->data[6] || y != sprite->data[7]))
{
sprite->data[5] = sprite->pos2.y;
for (sprite->data[6] = x, sprite->data[7] = y, i = DIR_SOUTH; i <= DIR_EAST; i ++, x = sprite->data[6], y = sprite->data[7])
sprite->data[5] = spriteY;
sprite->data[6] = x;
sprite->data[7] = y;
for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7])
{
MoveCoords(i, &x, &y);
if (MapGridGetZCoordAt(x, y) == 3)
@ -1045,87 +1045,6 @@ void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite)
}
}
}
#else
NAKED void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite)
{
asm_unified("push {r4-r7,lr}\n\
mov r7, r8\n\
push {r7}\n\
sub sp, 0x4\n\
adds r4, r1, 0\n\
ldrh r2, [r0, 0x10]\n\
mov r1, sp\n\
strh r2, [r1]\n\
ldrh r1, [r0, 0x12]\n\
mov r0, sp\n\
adds r0, 0x2\n\
strh r1, [r0]\n\
movs r2, 0x26\n\
ldrsh r3, [r4, r2]\n\
mov r8, r0\n\
cmp r3, 0\n\
bne _08155770\n\
mov r0, sp\n\
movs r5, 0\n\
ldrsh r2, [r0, r5]\n\
movs r5, 0x3A\n\
ldrsh r0, [r4, r5]\n\
cmp r2, r0\n\
bne _08155724\n\
lsls r0, r1, 16\n\
asrs r0, 16\n\
movs r5, 0x3C\n\
ldrsh r1, [r4, r5]\n\
cmp r0, r1\n\
beq _08155770\n\
_08155724:\n\
strh r3, [r4, 0x38]\n\
strh r2, [r4, 0x3A]\n\
mov r1, r8\n\
movs r2, 0\n\
ldrsh r0, [r1, r2]\n\
strh r0, [r4, 0x3C]\n\
movs r5, 0x1\n\
mov r7, r8\n\
mov r6, sp\n\
_08155736:\n\
adds r0, r5, 0\n\
mov r1, sp\n\
adds r2, r7, 0\n\
bl MoveCoords\n\
movs r1, 0\n\
ldrsh r0, [r6, r1]\n\
movs r2, 0\n\
ldrsh r1, [r7, r2]\n\
bl MapGridGetZCoordAt\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x3\n\
bne _0815575C\n\
ldrh r0, [r4, 0x38]\n\
adds r0, 0x1\n\
strh r0, [r4, 0x38]\n\
b _08155770\n\
_0815575C:\n\
adds r0, r5, 0x1\n\
lsls r0, 24\n\
lsrs r5, r0, 24\n\
ldrh r0, [r4, 0x3A]\n\
strh r0, [r6]\n\
ldrh r0, [r4, 0x3C]\n\
mov r1, r8\n\
strh r0, [r1]\n\
cmp r5, 0x4\n\
bls _08155736\n\
_08155770:\n\
add sp, 0x4\n\
pop {r3}\n\
mov r8, r3\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0");
}
#endif
static void CreateBobbingEffect(struct EventObject *eventObject, struct Sprite *linkedSprite, struct Sprite *sprite)
{

View File

@ -15,7 +15,6 @@
#include "task.h"
#include "text.h"
// enums
enum MapPopUp_Themes
{
@ -33,7 +32,7 @@ static void ShowMapNamePopUpWindow(void);
static void LoadMapNamePopUpWindowBg(void);
// EWRAM
static EWRAM_DATA u8 mapNamePopupTaskId = 0;
static EWRAM_DATA u8 sPopupTaskId = 0;
// .rodata
static const u8 gMapPopUp_Table[][960] =
@ -202,7 +201,7 @@ bool8 sub_80D47D4(void)
{
HideStartMenu();
ShowMapNamePopup();
return 1;
return TRUE;
}
void ShowMapNamePopup(void)
@ -211,16 +210,16 @@ void ShowMapNamePopup(void)
{
if (!FuncIsActiveTask(Task_MapNamePopUpWindow))
{
mapNamePopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90);
sPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90);
SetGpuReg(REG_OFFSET_BG0VOFS, 40);
gTasks[mapNamePopupTaskId].data[0] = 6;
gTasks[mapNamePopupTaskId].data[2] = 40;
gTasks[sPopupTaskId].data[0] = 6;
gTasks[sPopupTaskId].data[2] = 40;
}
else
{
if (gTasks[mapNamePopupTaskId].data[0] != 2)
gTasks[mapNamePopupTaskId].data[0] = 2;
gTasks[mapNamePopupTaskId].data[3] = 1;
if (gTasks[sPopupTaskId].data[0] != 2)
gTasks[sPopupTaskId].data[0] = 2;
gTasks[sPopupTaskId].data[3] = 1;
}
}
}
@ -246,7 +245,7 @@ static void Task_MapNamePopUpWindow(u8 taskId)
{
task->data[2] = 0;
task->data[0] = 1;
gTasks[mapNamePopupTaskId].data[1] = 0;
gTasks[sPopupTaskId].data[1] = 0;
}
break;
case 1:
@ -293,7 +292,7 @@ void HideMapNamePopUpWindow(void)
sub_819746C(GetMapNamePopUpWindowId(), TRUE);
RemoveMapNamePopUpWindow();
SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, 0);
DestroyTask(mapNamePopupTaskId);
DestroyTask(sPopupTaskId);
}
}
@ -333,220 +332,47 @@ static void ShowMapNamePopUpWindow(void)
CopyWindowToVram(GetMapNamePopUpWindowId(), 3);
}
#ifdef NONMATCHING
static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused)
{
s32 i;
for(i=0; i<=11; i++)
for (i = 0; i < 12; i++)
{
FillBgTilemapBufferRect(bg, 0x21D + i, x + i - 1, y - 1, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x21D + i, i - 1 + x, y - 1, 1, 1, 0xE);
}
FillBgTilemapBufferRect(bg, 0x229 + i, x - 1, y, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22A + i, deltaX + x, y, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22B + i, x - 1, y + 1 , 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22C + i, deltaX + x, y + 1, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22D + i, x - 1, y + 2, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22E + i, deltaX + x, y + 2, 1, 1, 0xE);
for(i=0; i<=11; i++)
FillBgTilemapBufferRect(bg, 0x229, x - 1, y, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22A, deltaX + x, y, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22B, x - 1, y + 1 , 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22C, deltaX + x, y + 1, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22D, x - 1, y + 2, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22E, deltaX + x, y + 2, 1, 1, 0xE);
for (i = 0; i < 12; i++)
{
FillBgTilemapBufferRect(bg, 0x22F + i, x + i - 1, y + deltaY, 1, 1, 0xE);
FillBgTilemapBufferRect(bg, 0x22F + i, i - 1 + x, y + deltaY, 1, 1, 0xE);
}
}
#else
NAKED
static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused)
{
asm("\n\
.syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x1C\n\
ldr r4, [sp, 0x3C]\n\
lsls r0, 24\n\
lsrs r7, r0, 24\n\
lsls r1, 24\n\
lsrs r1, 24\n\
mov r10, r1\n\
lsls r2, 24\n\
lsls r3, 24\n\
lsrs r3, 24\n\
str r3, [sp, 0x10]\n\
lsls r4, 24\n\
lsrs r4, 24\n\
str r4, [sp, 0x14]\n\
movs r5, 0\n\
lsls r0, r1, 24\n\
asrs r1, r0, 24\n\
lsrs r3, r2, 24\n\
str r3, [sp, 0xC]\n\
movs r6, 0xFF\n\
lsls r6, 24\n\
adds r6, r2\n\
mov r8, r6\n\
str r0, [sp, 0x18]\n\
subs r4, r1, 0x1\n\
_080D4AB4:\n\
ldr r0, =0x0000021d\n\
adds r1, r5, r0\n\
lsls r1, 16\n\
lsrs r1, 16\n\
lsls r2, r4, 24\n\
lsrs r2, 24\n\
movs r3, 0x1\n\
str r3, [sp]\n\
str r3, [sp, 0x4]\n\
movs r6, 0xE\n\
mov r9, r6\n\
str r6, [sp, 0x8]\n\
adds r0, r7, 0\n\
mov r6, r8\n\
lsrs r3, r6, 24\n\
bl FillBgTilemapBufferRect\n\
adds r4, 0x1\n\
adds r5, 0x1\n\
cmp r5, 0xB\n\
ble _080D4AB4\n\
ldr r1, =0x00000229\n\
movs r0, 0x1\n\
negs r0, r0\n\
add r0, r10\n\
lsls r0, 24\n\
lsrs r0, 24\n\
mov r8, r0\n\
movs r5, 0x1\n\
str r5, [sp]\n\
str r5, [sp, 0x4]\n\
mov r2, r9\n\
str r2, [sp, 0x8]\n\
adds r0, r7, 0\n\
mov r2, r8\n\
ldr r3, [sp, 0xC]\n\
bl FillBgTilemapBufferRect\n\
ldr r1, =0x0000022a\n\
ldr r6, [sp, 0x10]\n\
add r6, r10\n\
lsls r6, 24\n\
lsrs r6, 24\n\
str r5, [sp]\n\
str r5, [sp, 0x4]\n\
mov r3, r9\n\
str r3, [sp, 0x8]\n\
adds r0, r7, 0\n\
adds r2, r6, 0\n\
ldr r3, [sp, 0xC]\n\
bl FillBgTilemapBufferRect\n\
ldr r1, =0x0000022b\n\
ldr r4, [sp, 0xC]\n\
adds r4, 0x1\n\
lsls r4, 24\n\
lsrs r4, 24\n\
str r5, [sp]\n\
str r5, [sp, 0x4]\n\
mov r0, r9\n\
str r0, [sp, 0x8]\n\
adds r0, r7, 0\n\
mov r2, r8\n\
adds r3, r4, 0\n\
bl FillBgTilemapBufferRect\n\
movs r1, 0x8B\n\
lsls r1, 2\n\
str r5, [sp]\n\
str r5, [sp, 0x4]\n\
mov r2, r9\n\
str r2, [sp, 0x8]\n\
adds r0, r7, 0\n\
adds r2, r6, 0\n\
adds r3, r4, 0\n\
bl FillBgTilemapBufferRect\n\
ldr r1, =0x0000022d\n\
ldr r4, [sp, 0xC]\n\
adds r4, 0x2\n\
lsls r4, 24\n\
lsrs r4, 24\n\
str r5, [sp]\n\
str r5, [sp, 0x4]\n\
mov r3, r9\n\
str r3, [sp, 0x8]\n\
adds r0, r7, 0\n\
mov r2, r8\n\
adds r3, r4, 0\n\
bl FillBgTilemapBufferRect\n\
ldr r1, =0x0000022e\n\
str r5, [sp]\n\
str r5, [sp, 0x4]\n\
mov r0, r9\n\
str r0, [sp, 0x8]\n\
adds r0, r7, 0\n\
adds r2, r6, 0\n\
adds r3, r4, 0\n\
bl FillBgTilemapBufferRect\n\
movs r5, 0\n\
ldr r1, [sp, 0xC]\n\
ldr r2, [sp, 0x14]\n\
adds r0, r1, r2\n\
lsls r4, r0, 24\n\
movs r6, 0x1\n\
_080D4B8A:\n\
ldr r3, =0x0000022f\n\
adds r1, r5, r3\n\
lsls r1, 16\n\
lsrs r1, 16\n\
subs r0, r5, 0x1\n\
ldr r3, [sp, 0x18]\n\
asrs r2, r3, 24\n\
adds r2, r0\n\
lsls r2, 24\n\
lsrs r2, 24\n\
str r6, [sp]\n\
str r6, [sp, 0x4]\n\
movs r0, 0xE\n\
str r0, [sp, 0x8]\n\
adds r0, r7, 0\n\
lsrs r3, r4, 24\n\
bl FillBgTilemapBufferRect\n\
adds r5, 0x1\n\
cmp r5, 0xB\n\
ble _080D4B8A\n\
add sp, 0x1C\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\n\
.syntax divided");
}
#endif // NONMATCHING
static void LoadMapNamePopUpWindowBg(void)
{
u8 popupWindowId;
u16 regionMapSectionId;
u8 popUpThemeId;
u8 popupWindowId = GetMapNamePopUpWindowId();
u16 regionMapSectionId = gMapHeader.regionMapSectionId;
popupWindowId = GetMapNamePopUpWindowId();
regionMapSectionId = gMapHeader.regionMapSectionId;
if (regionMapSectionId > MAPSEC_DYNAMIC)
{
if (regionMapSectionId > MAPSEC_SPECIAL_AREA)
regionMapSectionId -= (MAPSEC_SPECIAL_AREA - MAPSEC_DYNAMIC);
else
regionMapSectionId = 0; //discard kanto region sections
regionMapSectionId = 0; // Discard kanto region sections;
}
popUpThemeId = gRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId];
LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), &(gMapPopUp_Outline_Table[popUpThemeId][0]), 0x400, 0x21D);
LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), gMapPopUp_Outline_Table[popUpThemeId], 0x400, 0x21D);
CallWindowFunction(popupWindowId, sub_80D4A78);
PutWindowTilemap(popupWindowId);
if(gMapHeader.weather == WEATHER_BUBBLES)
LoadPalette(&gUnknown_0857F444, 0xE0, 0x20);
else
LoadPalette(&(gMapPopUp_Palette_Table[popUpThemeId][0]), 0xE0, 0x20);
BlitBitmapToWindow(popupWindowId, &(gMapPopUp_Table[popUpThemeId][0]), 0, 0, 80, 24);
LoadPalette(gMapPopUp_Palette_Table[popUpThemeId], 0xE0, 0x20);
BlitBitmapToWindow(popupWindowId, gMapPopUp_Table[popUpThemeId], 0, 0, 80, 24);
}

View File

@ -257,584 +257,169 @@ u32 RenderFont(struct TextPrinter *textPrinter)
}
}
#ifdef NONMATCHING
void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor)
{
u32 fg12, bg12, shadow12;
u32 fg8, bg8, shadow8;
u32 fg4, bg4, shadow4;
u32 temp;
u16 *current = gFontHalfRowLookupTable;
gLastTextBgColor = bgColor;
gLastTextFgColor = fgColor;
gLastTextShadowColor = shadowColor;
*(current++) = (bgColor << 12) | (bgColor << 8) | (bgColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (bgColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (bgColor << 4) | bgColor;
bg12 = bgColor << 12;
fg12 = fgColor << 12;
shadow12 = shadowColor << 12;
*(current++) = (bgColor << 12) | (fgColor << 8) | (bgColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (bgColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (bgColor << 4) | bgColor;
bg8 = bgColor << 8;
bg4 = bgColor << 4;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (bgColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (bgColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (bgColor << 4) | bgColor;
temp = (bg8) | (bg4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (bgColor << 8) | (fgColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (fgColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (fgColor << 4) | bgColor;
fg8 = fgColor << 8;
*(current++) = (bgColor << 12) | (fgColor << 8) | (fgColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (fgColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (fgColor << 4) | bgColor;
temp = (fg8) | (bg4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (fgColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (fgColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (fgColor << 4) | bgColor;
shadow8 = shadowColor << 8;
*(current++) = (bgColor << 12) | (bgColor << 8) | (shadowColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (shadowColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (shadowColor << 4) | bgColor;
temp = (shadow8) | (bg4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (fgColor << 8) | (shadowColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (shadowColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (shadowColor << 4) | bgColor;
fg4 = fgColor << 4;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | bgColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | bgColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | bgColor;
temp = (bg8) | (fg4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (bgColor << 8) | (bgColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (bgColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (bgColor << 4) | fgColor;
temp = (fg8) | (fg4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (fgColor << 8) | (bgColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (bgColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (bgColor << 4) | fgColor;
temp = (shadow8) | (fg4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (bgColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (bgColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (bgColor << 4) | fgColor;
shadow4 = shadowColor << 4;
*(current++) = (bgColor << 12) | (bgColor << 8) | (fgColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (fgColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (fgColor << 4) | fgColor;
temp = (bg8) | (shadow4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (fgColor << 8) | (fgColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (fgColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (fgColor << 4) | fgColor;
temp = (fg8) | (shadow4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (fgColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (fgColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (fgColor << 4) | fgColor;
temp = (shadow8) | (shadow4) | bgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (bgColor << 8) | (shadowColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (shadowColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (shadowColor << 4) | fgColor;
temp = (bg8) | (bg4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (fgColor << 8) | (shadowColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (shadowColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (shadowColor << 4) | fgColor;
temp = (fg8) | (bg4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | fgColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | fgColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | fgColor;
temp = (shadow8) | (bg4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (bgColor << 8) | (bgColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (bgColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (bgColor << 4) | shadowColor;
temp = (bg8) | (fg4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (fgColor << 8) | (bgColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (bgColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (bgColor << 4) | shadowColor;
temp = (fg8) | (fg4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (bgColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (bgColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (bgColor << 4) | shadowColor;
temp = (shadow8) | (fg4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (bgColor << 8) | (fgColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (fgColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (fgColor << 4) | shadowColor;
temp = (bg8) | (shadow4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (fgColor << 8) | (fgColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (fgColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (fgColor << 4) | shadowColor;
temp = (fg8) | (shadow4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (fgColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (fgColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (fgColor << 4) | shadowColor;
temp = (shadow8) | (shadow4) | fgColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (bgColor << 8) | (shadowColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (bgColor << 8) | (shadowColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (bgColor << 8) | (shadowColor << 4) | shadowColor;
temp = (bg8) | (bg4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (fgColor << 8) | (shadowColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (fgColor << 8) | (shadowColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (fgColor << 8) | (shadowColor << 4) | shadowColor;
temp = (fg8) | (bg4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
*(current++) = (bgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor;
*(current++) = (fgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor;
*(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor;
temp = (shadow8) | (bg4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
temp = (bg8) | (fg4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
temp = (fg8) | (fg4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
temp = (shadow8) | (fg4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
temp = (bg8) | (shadow4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
temp = (fg8) | (shadow4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
temp = (shadow8) | (shadow4) | shadowColor;
*(current++) = (bg12) | temp;
*(current++) = (fg12) | temp;
*(current++) = (shadow12) | temp;
}
#else
NAKED
void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor)
{
asm("push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, #0x24\n\
lsl r0, #24\n\
lsr r0, #24\n\
lsl r1, #24\n\
lsr r1, #24\n\
lsl r2, #24\n\
lsr r2, #24\n\
ldr r3, =gFontHalfRowLookupTable\n\
ldr r4, =gLastTextBgColor\n\
strh r1, [r4]\n\
ldr r4, =gLastTextFgColor\n\
strh r0, [r4]\n\
ldr r4, =gLastTextShadowColor\n\
strh r2, [r4]\n\
lsl r5, r1, #12\n\
lsl r6, r0, #12\n\
lsl r4, r2, #12\n\
mov r8, r4\n\
lsl r7, r1, #8\n\
str r7, [sp]\n\
lsl r4, r1, #4\n\
mov r9, r4\n\
orr r7, r4\n\
str r7, [sp, #0x4]\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
lsl r7, r0, #8\n\
mov r10, r7\n\
mov r4, r10\n\
mov r7, r9\n\
orr r4, r7\n\
str r4, [sp, #0x8]\n\
add r7, r4, #0\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
lsl r7, r2, #8\n\
mov r12, r7\n\
mov r4, r12\n\
mov r7, r9\n\
orr r4, r7\n\
str r4, [sp, #0xC]\n\
add r7, r4, #0\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
lsl r7, r0, #4\n\
mov r9, r7\n\
ldr r4, [sp]\n\
orr r4, r7\n\
str r4, [sp, #0x10]\n\
add r7, r4, #0\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
mov r7, r10\n\
add r4, r7, #0\n\
mov r7, r9\n\
orr r4, r7\n\
str r4, [sp, #0x14]\n\
add r7, r4, #0\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
mov r7, r12\n\
add r4, r7, #0\n\
mov r7, r9\n\
orr r4, r7\n\
str r4, [sp, #0x18]\n\
add r7, r4, #0\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
lsl r7, r2, #4\n\
mov r9, r7\n\
mov r4, r9\n\
ldr r7, [sp]\n\
orr r7, r4\n\
str r7, [sp, #0x1C]\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
mov r7, r9\n\
mov r4, r10\n\
orr r4, r7\n\
str r4, [sp, #0x20]\n\
add r7, r4, #0\n\
orr r7, r1\n\
add r4, r5, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
add r4, r6, #0\n\
orr r4, r7\n\
strh r4, [r3]\n\
add r3, #0x2\n\
mov r4, r8\n\
orr r7, r4\n\
strh r7, [r3]\n\
add r3, #0x2\n\
mov r4, r12\n\
mov r7, r9\n\
orr r4, r7\n\
add r7, r4, #0\n\
orr r7, r1\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0x4]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0x8]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0xC]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0x10]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0x14]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0x18]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0x1C]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
ldr r7, [sp, #0x20]\n\
orr r7, r0\n\
add r1, r5, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
add r1, r6, #0\n\
orr r1, r7\n\
strh r1, [r3]\n\
add r3, #0x2\n\
mov r1, r8\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r4, #0\n\
orr r7, r0\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r0, [sp, #0x4]\n\
orr r7, r0\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
orr r7, r1\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r1, [sp, #0x8]\n\
orr r7, r1\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
mov r0, r8\n\
orr r7, r0\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r1, [sp, #0xC]\n\
orr r7, r1\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
mov r0, r8\n\
orr r7, r0\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r1, [sp, #0x10]\n\
orr r7, r1\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
mov r0, r8\n\
orr r7, r0\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r1, [sp, #0x14]\n\
orr r7, r1\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
mov r0, r8\n\
orr r7, r0\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r1, [sp, #0x18]\n\
orr r7, r1\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
mov r0, r8\n\
orr r7, r0\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r1, [sp, #0x1C]\n\
orr r7, r1\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
mov r0, r8\n\
orr r7, r0\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
ldr r1, [sp, #0x20]\n\
orr r7, r1\n\
add r0, r5, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
add r0, r6, #0\n\
orr r0, r7\n\
strh r0, [r3]\n\
add r3, #0x2\n\
mov r0, r8\n\
orr r7, r0\n\
strh r7, [r3]\n\
add r3, #0x2\n\
add r7, r2, #0\n\
orr r7, r4\n\
orr r5, r7\n\
strh r5, [r3]\n\
add r3, #0x2\n\
orr r6, r7\n\
strh r6, [r3]\n\
orr r0, r7\n\
strh r0, [r3, #0x2]\n\
add sp, #0x24\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
void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor)
{