Resolve fakematch CopyGlyphToWindow.

This commit is contained in:
ProjectRevoTPP 2020-09-28 07:22:47 -04:00 committed by huderlem
parent cb69835536
commit 7c697e9536

View File

@ -462,40 +462,37 @@ u8 GetLastTextColor(u8 colorType)
} }
} }
#define GLYPH_COPY(fromY_, toY_, fromX_, toX_, unk) \ inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *ptr, s32 width, s32 height) //
{ \ {
u32 i, j, *ptr, toY, fromX, toX, r5, bits; \ // WHYYYYYYYYY is dummyX needed aaaaaaaaaaaaaaaaaaaaa
u8 *dst; \ u32 xAdd, yAdd, r5, bits, toOrr, dummyX;
j = fromX_; \ u8 *dst;
i = fromY_; \
ptr = unk; \ xAdd = j + width;
toX = toX_; \ yAdd = i + height;
toY = toY_; \ dummyX = j; // :masuda:
fromX = fromX_; \ for (; i < yAdd; i++)
\ {
for (; i < toY; i++) \ r5 = *ptr++;
{ \ for (j = dummyX; j < xAdd; j++)
asm("":::"sl"); /* NONMATCHING */ \ {
r5 = *(ptr++); \ // This inline assignent turns out to be needed as well.
for (j = fromX; j < toX; j++) \ if ((toOrr = r5 & 0xF))
{ \ {
const u32 toOrr = r5 & 0xF; \ dst = windowTiles + ((j / 8) * 32) + ((j % 8) / 2) + ((i / 8) * widthOffset) + ((i % 8) * 4);
if (toOrr) \ bits = ((j & 1) * 4);
{ \ *dst = (toOrr << bits) | (*dst & (0xF0 >> bits));
dst = windowTiles + ((j / 8) * 32) + ((j % 8) / 2) + ((i / 8) * widthOffset) + ((i % 8) * 4); \ }
bits = ((j & 1) * 4); \ r5 >>= 4;
*dst = (toOrr << bits) | (*dst & (0xF0 >> bits)); \ }
} \
r5 >>= 4; \
} \
} \
} }
}
void CopyGlyphToWindow(struct TextPrinter *textPrinter) void CopyGlyphToWindow(struct TextPrinter *textPrinter)
{ {
struct Window *win; struct Window *win;
struct WindowTemplate *winTempl; struct WindowTemplate *winTempl;
struct Struct_03002F90 *unkStruct; u32 *unkStruct;
u32 currX, currY, widthOffset; u32 currX, currY, widthOffset;
s32 r4, r0; s32 r4, r0;
u8 *windowTiles; u8 *windowTiles;
@ -503,17 +500,18 @@ void CopyGlyphToWindow(struct TextPrinter *textPrinter)
win = &gWindows[textPrinter->printerTemplate.windowId]; win = &gWindows[textPrinter->printerTemplate.windowId];
winTempl = &win->window; winTempl = &win->window;
r4 = (winTempl->width * 8) - textPrinter->printerTemplate.currentX; // these inline assignments are required as well to match. Compiler is super fucking sensitive and needs like SEVERAL changes.
if (r4 > gUnknown_03002F90.width) if ((r4 = (winTempl->width * 8) - textPrinter->printerTemplate.currentX) > gUnknown_03002F90.width)
r4 = gUnknown_03002F90.width; r4 = gUnknown_03002F90.width;
r0 = (winTempl->height * 8) - textPrinter->printerTemplate.currentY; if ((r0 = (winTempl->height * 8) - textPrinter->printerTemplate.currentY) > gUnknown_03002F90.height)
if (r0 > gUnknown_03002F90.height)
r0 = gUnknown_03002F90.height; r0 = gUnknown_03002F90.height;
currX = textPrinter->printerTemplate.currentX; currX = textPrinter->printerTemplate.currentX;
currY = textPrinter->printerTemplate.currentY; currY = textPrinter->printerTemplate.currentY;
unkStruct = &gUnknown_03002F90; // i could only get this to work as a u32 due to lvalue bullshit and the macro
// really needs to be an inline to avoid temp bullshit below. It might work as a macro too, but...
unkStruct = (u32 *)&gUnknown_03002F90.unk0;
windowTiles = win->tileData; windowTiles = win->tileData;
widthOffset = winTempl->width * 32; widthOffset = winTempl->width * 32;
@ -521,45 +519,31 @@ void CopyGlyphToWindow(struct TextPrinter *textPrinter)
{ {
if (r0 < 9) if (r0 < 9)
{ {
GLYPH_COPY(currY, currY + r0, currX, currX + r4, unkStruct->unk0); GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, r0);
} }
else else
{ {
u32 temp; GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, 8);
GLYPH_COPY(currY, currY + 8, currX, currX + r4, unkStruct->unk0); GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, r4, r0 - 8);
temp = currY + 8;
GLYPH_COPY(temp, (temp - 8) + r0, currX, currX + r4, unkStruct->unk40);
} }
} }
else else
{ {
u32 temp;
if (r0 < 9) if (r0 < 9)
{ {
GLYPH_COPY(currY, currY + r0, currX, currX + 8, unkStruct->unk0); GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, r0);
GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, r0);
temp = currX + 8;
GLYPH_COPY(currY, currY + r0, temp, (temp - 8) + r4, unkStruct->unk20);
} }
else else
{ {
GLYPH_COPY(currY, currY + 8, currX, currX + 8, unkStruct->unk0); GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, 8);
GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, 8);
temp = currX + 8; GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, 8, r0 - 8);
GLYPH_COPY(currY, currY + 8, temp, temp - 8 + r4, unkStruct->unk20); GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY + 8, unkStruct + 24, r4 - 8, r0 - 8);
temp = currY + 8;
GLYPH_COPY(temp, temp - 8 + r0, currX, currX + 8, unkStruct->unk40);
{
u32 tempX, tempY;
tempX = currX + 8;
tempY = currY + 8;
GLYPH_COPY(tempY, tempY - 8 + r0, tempX, tempX - 8 + r4, unkStruct->unk60);
}
} }
} }
} }
void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
{ {
struct Window *window; struct Window *window;