aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxgte/initgeom.S
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-07-05 02:34:11 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-07-05 02:34:11 +0200
commitbeb76e4dd362374b8f42cd971d394bba1074cd8d (patch)
tree3ea4cc342737afb9225c01160c92647ba66c78bd /libpsn00b/psxgte/initgeom.S
parent5d9aa2d3dfc7d6e51c2eb942ab4cdbae5571a40a (diff)
downloadpsn00bsdk-fix-include.tar.gz
Replace .include with #includefix-include
For some reason, both mipsel-unknown-elf-gcc 8.2.0 and mipsel-non-elf 15.1.0 were unable to resolve .include assembler directives. As a workaround, it is still possible to use the preprocessor, and therefore the usual #include preprocessor directive. However, this requires the assembly files to use the uppercase .S file extension.
Diffstat (limited to 'libpsn00b/psxgte/initgeom.S')
-rw-r--r--libpsn00b/psxgte/initgeom.S44
1 files changed, 44 insertions, 0 deletions
diff --git a/libpsn00b/psxgte/initgeom.S b/libpsn00b/psxgte/initgeom.S
new file mode 100644
index 0000000..d2f7ef4
--- /dev/null
+++ b/libpsn00b/psxgte/initgeom.S
@@ -0,0 +1,44 @@
+.set noreorder
+
+#include "hwregs_a.inc"
+#include "gtereg.inc"
+
+.section .text.InitGeom
+.global InitGeom
+.type InitGeom, @function
+InitGeom:
+ # Disable interrupts and make sure the GTE is enabled in COP0.
+ lui $v0, IOBASE
+ lhu $v1, IRQ_MASK($v0)
+ nop
+ sh $0, IRQ_MASK($v0)
+
+ mfc0 $a0, $12
+ lui $a1, 0x4000
+ or $a1, $a0
+ mtc0 $a1, $12
+ nop
+ #nop
+
+ # Re-enable interrupts, then load default values into some GTE registers.
+ sh $v1, IRQ_MASK($v0)
+
+ ctc2 $0, C2_OFX
+ nop
+ ctc2 $0, C2_OFY
+
+ li $a0, 320
+ ctc2 $a0, C2_H
+
+ li $a0, 0x155
+ ctc2 $a0, C2_ZSF3
+ li $a0, 0x100
+ ctc2 $a0, C2_ZSF4
+
+ li $a0, 0xef9e
+ ctc2 $a0, C2_DQA
+ lui $a0, 0x0140
+ ctc2 $a0, C2_DQB
+
+ jr $ra
+ nop