Files
BFM-decomp/src/gsgap5.c
T
Drew T 5f38df2368 feat(decomp): main lane m22 — 6 banked
One clean whole-EXE rebuild verified the batch (gate_main), and main re-checked
BYTE-IDENTICAL against config/check.us.sha before anything was credited.

  DsReadyCallback
  SetIR123
  func_8001D074
  func_80028E00
  func_800538BC
  func_8005FBA8
2026-08-25 07:01:31 -06:00

124 lines
3.0 KiB
C

#include "common.h"
INCLUDE_ASM("asm/nonmatchings/gsgap5", SetVertex0);
INCLUDE_ASM("asm/nonmatchings/gsgap5", SetVertex1);
INCLUDE_ASM("asm/nonmatchings/gsgap5", SetVertex2);
void SetVertexTri(long *r0, long *r1, long *r2)
{
__asm__ volatile(
"lwc2 $0, 0( %0 );"
"lwc2 $1, 4( %0 );"
"lwc2 $2, 0( %1 );"
"lwc2 $3, 4( %1 );"
"lwc2 $4, 0( %2 );"
"lwc2 $5, 4( %2 )"
:
: "r"(r0), "r"(r1), "r"(r2));
}
void SetRGBfifo(void* r0, void* r1, void* r2)
{
__asm__ __volatile__ (
"lwc2 $20, 0( %0 );"
"lwc2 $21, 0( %1 );"
"lwc2 $22, 0( %2 )"
:
: "r"( r0 ), "r"( r1 ), "r"( r2 )
: "memory" );
}
void SetIR123(long r0, long r1, long r2)
{
__asm__ __volatile__(
"mtc2 %0, $9\n"
"mtc2 %1, $10\n"
"mtc2 %2, $11"
:
: "r"(r0), "r"(r1), "r"(r2));
}
INCLUDE_ASM("asm/nonmatchings/gsgap5", SetIR0);
/* SetSZfifo3 (0x80053A4C) -- handwritten GTE fifo-load wrapper (splat marks it
* "Handwritten function"): three mtc2 stores of the incoming $a0-$a2 words into
* cop2 data registers SZ1/SZ2/SZ3 ($17/$18/$19), then the frameless leaf return.
* gcc-2.7.2 -O2 cannot emit bare cop2 register writes from C, so the body is
* transcribed verbatim as a file-scope asm block (cookbook §265 lane 1,
* func_800D0440 form @ src/md_MAIN_003/md_MAIN_003.c:329): the block carries the
* .globl/.ent directives and the explicit jr $ra + nop tail -- no C codegen and
* no declaration surface at all. No relocations, no symbol references.
*/
__asm__(".text\n.align 2\n.globl SetSZfifo3\n.ent\tSetSZfifo3\n"
"SetSZfifo3:\n"
".set\tnoreorder\n"
"mtc2 $4, $17\n"
"mtc2 $5, $18\n"
"mtc2 $6, $19\n"
"jr $ra\n"
"nop\n"
".set\treorder\n"
".end\tSetSZfifo3\n");
/* probe: naive spelling -- no volatile, no .set noreorder */
void SetSZfifo4()
{
__asm__(
"mtc2 $4, $16\n"
"mtc2 $5, $17\n"
"mtc2 $6, $18\n"
"mtc2 $7, $19\n");
}
void SetSXSYfifo(long r0, long r1, long r2)
{
__asm__ __volatile__(
"mtc2 %0, $12\n"
"mtc2 %1, $13\n"
"mtc2 %2, $14"
:
: "r"(r0), "r"(r1), "r"(r2));
}
void SetRii()
{
__asm__ __volatile__(
".set\tnoreorder\n"
"ctc2 $4, $0\n"
"ctc2 $5, $2\n"
"ctc2 $6, $4\n"
".set\treorder\n");
}
void SetMAC123(long r0, long r1, long r2)
{
__asm__ __volatile__(
"mtc2 %0, $25\n"
"mtc2 %1, $26\n"
"mtc2 %2, $27"
:
: "r"(r0), "r"(r1), "r"(r2));
}
INCLUDE_ASM("asm/nonmatchings/gsgap5", SetData32);
INCLUDE_ASM("asm/nonmatchings/gsgap5", SetDQA);
INCLUDE_ASM("asm/nonmatchings/gsgap5", SetDQB);
void func_80053AD8()
{
__asm__ __volatile__(
".set\tnoreorder\n"
"sll $4, $4, 4\n"
"sll $5, $5, 4\n"
"sll $6, $6, 4\n"
"ctc2 $4, $21\n"
"ctc2 $5, $22\n"
"ctc2 $6, $23\n"
".set\treorder\n"
);
}