diff --git a/asm/non_matchings/crash_screen/crash_screen_draw_square.s b/asm/non_matchings/crash_screen/crash_screen_draw_square.s deleted file mode 100644 index 3bb432a8f..000000000 --- a/asm/non_matchings/crash_screen/crash_screen_draw_square.s +++ /dev/null @@ -1,100 +0,0 @@ -glabel crash_screen_draw_square -/* 004D44 80004144 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 004D48 80004148 AFB40028 */ sw $s4, 0x28($sp) -/* 004D4C 8000414C AFB30024 */ sw $s3, 0x24($sp) -/* 004D50 80004150 AFB20020 */ sw $s2, 0x20($sp) -/* 004D54 80004154 AFB00018 */ sw $s0, 0x18($sp) -/* 004D58 80004158 00809825 */ move $s3, $a0 -/* 004D5C 8000415C AFBF002C */ sw $ra, 0x2c($sp) -/* 004D60 80004160 AFB1001C */ sw $s1, 0x1c($sp) -/* 004D64 80004164 2410002E */ li $s0, 46 -/* 004D68 80004168 24120028 */ li $s2, 40 -/* 004D6C 8000416C 2414002C */ li $s4, 44 -/* 004D70 80004170 240D0006 */ li $t5, 6 -/* 004D74 80004174 240C0006 */ li $t4, 6 -/* 004D78 80004178 240B0006 */ li $t3, 6 -/* 004D7C 8000417C 240A0006 */ li $t2, 6 -/* 004D80 80004180 24090006 */ li $t1, 6 -/* 004D84 80004184 3407FFFF */ li $a3, 65535 -/* 004D88 80004188 3406F801 */ li $a2, 63489 -.L8000418C: -/* 004D8C 8000418C 0250082A */ slt $at, $s2, $s0 -/* 004D90 80004190 10200032 */ beqz $at, .L8000425C -/* 004D94 80004194 02408825 */ move $s1, $s2 -/* 004D98 80004198 0250082A */ slt $at, $s2, $s0 -.L8000419C: -/* 004D9C 8000419C 1020002C */ beqz $at, .L80004250 -/* 004DA0 800041A0 02401825 */ move $v1, $s2 -/* 004DA4 800041A4 00117080 */ sll $t6, $s1, 2 -/* 004DA8 800041A8 01D17021 */ addu $t6, $t6, $s1 -/* 004DAC 800041AC 02122023 */ subu $a0, $s0, $s2 -/* 004DB0 800041B0 30880003 */ andi $t0, $a0, 3 -/* 004DB4 800041B4 000E79C0 */ sll $t7, $t6, 7 -/* 004DB8 800041B8 1100000C */ beqz $t0, .L800041EC -/* 004DBC 800041BC 026FF821 */ addu $ra, $s3, $t7 -/* 004DC0 800041C0 0003C040 */ sll $t8, $v1, 1 -/* 004DC4 800041C4 03F81021 */ addu $v0, $ra, $t8 -/* 004DC8 800041C8 01122821 */ addu $a1, $t0, $s2 -.L800041CC: -/* 004DCC 800041CC 15240003 */ bne $t1, $a0, .L800041DC -/* 004DD0 800041D0 24630001 */ addiu $v1, $v1, 1 -/* 004DD4 800041D4 10000002 */ b .L800041E0 -/* 004DD8 800041D8 A4460000 */ sh $a2, ($v0) -.L800041DC: -/* 004DDC 800041DC A4470000 */ sh $a3, ($v0) -.L800041E0: -/* 004DE0 800041E0 14A3FFFA */ bne $a1, $v1, .L800041CC -/* 004DE4 800041E4 24420002 */ addiu $v0, $v0, 2 -/* 004DE8 800041E8 10700019 */ beq $v1, $s0, .L80004250 -.L800041EC: -/* 004DEC 800041EC 00032840 */ sll $a1, $v1, 1 -/* 004DF0 800041F0 03E51021 */ addu $v0, $ra, $a1 -/* 004DF4 800041F4 00104040 */ sll $t0, $s0, 1 -.L800041F8: -/* 004DF8 800041F8 15440003 */ bne $t2, $a0, .L80004208 -/* 004DFC 800041FC 24A50008 */ addiu $a1, $a1, 8 -/* 004E00 80004200 10000002 */ b .L8000420C -/* 004E04 80004204 A4460000 */ sh $a2, ($v0) -.L80004208: -/* 004E08 80004208 A4470000 */ sh $a3, ($v0) -.L8000420C: -/* 004E0C 8000420C 55640004 */ bnel $t3, $a0, .L80004220 -/* 004E10 80004210 A4470002 */ sh $a3, 2($v0) -/* 004E14 80004214 10000002 */ b .L80004220 -/* 004E18 80004218 A4460002 */ sh $a2, 2($v0) -/* 004E1C 8000421C A4470002 */ sh $a3, 2($v0) -.L80004220: -/* 004E20 80004220 55840004 */ bnel $t4, $a0, .L80004234 -/* 004E24 80004224 A4470004 */ sh $a3, 4($v0) -/* 004E28 80004228 10000002 */ b .L80004234 -/* 004E2C 8000422C A4460004 */ sh $a2, 4($v0) -/* 004E30 80004230 A4470004 */ sh $a3, 4($v0) -.L80004234: -/* 004E34 80004234 55A40004 */ bnel $t5, $a0, .L80004248 -/* 004E38 80004238 A4470006 */ sh $a3, 6($v0) -/* 004E3C 8000423C 10000002 */ b .L80004248 -/* 004E40 80004240 A4460006 */ sh $a2, 6($v0) -/* 004E44 80004244 A4470006 */ sh $a3, 6($v0) -.L80004248: -/* 004E48 80004248 14A8FFEB */ bne $a1, $t0, .L800041F8 -/* 004E4C 8000424C 24420008 */ addiu $v0, $v0, 8 -.L80004250: -/* 004E50 80004250 26310001 */ addiu $s1, $s1, 1 -/* 004E54 80004254 5630FFD1 */ bnel $s1, $s0, .L8000419C -/* 004E58 80004258 0250082A */ slt $at, $s2, $s0 -.L8000425C: -/* 004E5C 8000425C 2610FFFF */ addiu $s0, $s0, -1 -/* 004E60 80004260 1690FFCA */ bne $s4, $s0, .L8000418C -/* 004E64 80004264 26520001 */ addiu $s2, $s2, 1 -/* 004E68 80004268 0C033624 */ jal osWritebackDCacheAll -/* 004E6C 8000426C 00000000 */ nop -/* 004E70 80004270 0C033684 */ jal osViSwapBuffer -/* 004E74 80004274 02602025 */ move $a0, $s3 -/* 004E78 80004278 8FBF002C */ lw $ra, 0x2c($sp) -/* 004E7C 8000427C 8FB00018 */ lw $s0, 0x18($sp) -/* 004E80 80004280 8FB1001C */ lw $s1, 0x1c($sp) -/* 004E84 80004284 8FB20020 */ lw $s2, 0x20($sp) -/* 004E88 80004288 8FB30024 */ lw $s3, 0x24($sp) -/* 004E8C 8000428C 8FB40028 */ lw $s4, 0x28($sp) -/* 004E90 80004290 03E00008 */ jr $ra -/* 004E94 80004294 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/src/crash_screen.c b/src/crash_screen.c index 933c6915f..8e009e8cf 100644 --- a/src/crash_screen.c +++ b/src/crash_screen.c @@ -55,32 +55,33 @@ void crash_screen_draw_glyph(u16* framebuffer, s32 x, s32 y, s32 glyph) { } void crash_screen_draw_square(u16* framebuffer); -// Functionally Equivallent. -#ifdef NON_MATCHING -// 0xRGBA (I think A maybe not). #define WHITE_COLOUR 0xFFFF #define RED_COLOUR 0xF801 -/** - * The big mismatch is the handling of the '6' used in the if statement - * In the target assembly that 6 is saved to 5 different temp registers, - * while in this non-matching decomp its only saved to one temp register. - * This seems to be related to how the innermost for loop is unrolled, but - * its not clear why the target assembley would save the same immediate to - * 5 different registers instead of just re-using one - * There's some stack related differences too, maybe that's related? - **/ -void crash_screen_draw_square(u16* framebuffer) { - s32 s0_end; - s32 s2_start; - s32 row; - s32 column; +// (x,y) of top left pixel of square +#define SQUARE_X 40 +#define SQUARE_Y 40 - for (s2_start = 0x28, s0_end = s2_start + 6; s0_end != 0x2C; s0_end--, s2_start++) { - for (row = s2_start; row < s0_end; row++) { - for (column = s2_start; column < s0_end; column++) { - framebuffer[row * 320 + column] = s0_end - s2_start == 6 ? 0xF801 : 0xFFFF; +#define SQUARE_SIZE_X 6 +#define SQUARE_SIZE_Y 6 + +// width of the square's border being drawn. +#define BORDER_WIDTH 1 + +#define SQUARE_X2 SQUARE_X + SQUARE_SIZE_Y +#define SQUARE_Y2 SQUARE_Y + SQUARE_SIZE_X + +// Here's to you, Yoshimoto, for writing this stupid function. 3 years. 3 years to match. +void crash_screen_draw_square(u16* framebuffer) { + s32 h; + s32 i; + s32 j; + + for (h = 0; h < 2; h++) { + for (i = (h * BORDER_WIDTH) + SQUARE_Y; i < (((SQUARE_Y2 - (h * BORDER_WIDTH)))); i++) { + for (j = (h * BORDER_WIDTH) + SQUARE_X; j < (((SQUARE_X2 - (h * BORDER_WIDTH)))); j++) { + framebuffer[(i * 320) + j] = (h == 0) ? (0xF801) : (0xFFFF); } } } @@ -88,9 +89,6 @@ void crash_screen_draw_square(u16* framebuffer) { osWritebackDCacheAll(); osViSwapBuffer(framebuffer); } -#else -GLOBAL_ASM("asm/non_matchings/crash_screen/crash_screen_draw_square.s") -#endif /** * Draws three black boxes then prints crash info in the following format: