aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxgte/initgeom.s
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2022-11-15 08:07:24 +0100
committerspicyjpeg <thatspicyjpeg@gmail.com>2022-11-15 08:07:24 +0100
commit85d765f30595fe7f27c1b065c5a1934c3d389cef (patch)
treeb2a30eaa7f61b8238fdcdfd33867a5e44a4efbf0 /libpsn00b/psxgte/initgeom.s
parent4139331d233b7a962e747c5564fa68a285f81cc8 (diff)
downloadpsn00bsdk-85d765f30595fe7f27c1b065c5a1934c3d389cef.tar.gz
Misc. libpsn00b bugfixes, new critical section macros
Diffstat (limited to 'libpsn00b/psxgte/initgeom.s')
-rw-r--r--libpsn00b/psxgte/initgeom.s51
1 files changed, 26 insertions, 25 deletions
diff --git a/libpsn00b/psxgte/initgeom.s b/libpsn00b/psxgte/initgeom.s
index 6d1e36a..ccda7f1 100644
--- a/libpsn00b/psxgte/initgeom.s
+++ b/libpsn00b/psxgte/initgeom.s
@@ -1,43 +1,44 @@
.set noreorder
+.include "hwregs_a.inc"
.include "gtereg.inc"
.section .text.InitGeom
.global InitGeom
.type InitGeom, @function
InitGeom:
- addiu $sp, -4
- sw $ra, 0($sp)
+ # 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)
- jal EnterCriticalSection
+ mfc0 $a0, $12
+ lui $a1, 0x4000
+ or $a1, $a0
+ mtc0 $a1, $12
nop
+ #nop
- mfc0 $v0, $12 # Get SR
- lui $v1, 0x4000 # Set bit to enable cop2
- or $v0, $v1
- mtc0 $v0, $12 # Set new SR
+ # Re-enable interrupts, then load default values into some GTE registers.
+ sh $v1, IRQ_MASK($v0)
- jal ExitCriticalSection
+ ctc2 $0, C2_OFX
nop
+ ctc2 $0, C2_OFY
- ctc2 $0 , $24 # Reset GTE offset
- ctc2 $0 , $25
-
- li $v0, 320 # Set default projection plane
- ctc2 $v0, $26
+ li $a0, 320
+ ctc2 $a0, C2_H
- li $v0, 0x155 # Set ZSF3 and ZSF4 defaults
- ctc2 $v0, $29
- li $v0, 0x100
- ctc2 $v0, $30
+ li $a0, 0x155
+ ctc2 $a0, C2_ZSF3
+ li $a0, 0x100
+ ctc2 $a0, C2_ZSF4
- li $v0, 0xef9e # DQA and DQB defaults
- lui $v1, 0x0140
- ctc2 $v0, C2_DQA
- ctc2 $v1, C2_DQB
+ li $a0, 0xef9e
+ ctc2 $a0, C2_DQA
+ lui $a0, 0x0140
+ ctc2 $a0, C2_DQB
- lw $ra, 0($sp)
- addiu $sp, 4
- jr $ra
+ jr $ra
nop
-