Files
BFM-decomp/src/gsgap5.c
T
Drew T 0828f12df3 feat(decomp): main lane n00 — 9 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.

  ReturnFromException
  SetIR0
  SysDeqIntRP
  func_80012DBC
  func_80012FC8
  func_8002AE60
  func_8003FA54
  func_80049610
  func_800626DC
2026-08-26 11:13:57 -06:00

172 lines
3.5 KiB
C

#include "common.h"
void SetVertex0(long *r0)
{
__asm__ volatile(
"lwc2 $0, 0( %0 );"
"lwc2 $1, 4( %0 )"
:
: "r"(r0));
}
void SetVertex1(long *r0)
{
__asm__ volatile(
"lwc2 $2, 0( %0 );"
"lwc2 $3, 4( %0 )"
:
: "r"(r0));
}
void SetVertex2(long *r0)
{
__asm__ __volatile__(
"lwc2 $4, 0( %0 );"
"lwc2 $5, 4( %0 )"
:
: "r"(r0));
}
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));
}
void SetIR0(long r0)
{
__asm__ __volatile__(
"mtc2 %0, $8"
:
: "r"(r0));
}
/* 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));
}
void SetData32(long r0)
{
__asm__ __volatile__(
"mtc2 %0, $30"
:
: "r"(r0));
}
void SetDQA()
{
__asm__ __volatile__(
".set\tnoreorder\n"
"ctc2 $4, $27\n"
".set\treorder\n"
);
}
void SetDQB()
{
__asm__ __volatile__(
".set\tnoreorder\n"
"ctc2 $4, $28\n"
".set\treorder\n"
);
}
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"
);
}