aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxgpu
diff options
context:
space:
mode:
authorlameguy64 <lameguy64@gmail.com>2019-05-23 22:24:56 +0800
committerlameguy64 <lameguy64@gmail.com>2019-05-23 22:24:56 +0800
commit3ffebff2aad2ca438cf76db51fb3459c5639cd67 (patch)
treea234fc6158d3c09904c4c1fb2feee09afb479a4c /libpsn00b/psxgpu
parente70cd149f41ea71f9ca9ee86c03d1e59005dad2a (diff)
downloadpsn00bsdk-3ffebff2aad2ca438cf76db51fb3459c5639cd67.tar.gz
Added BIOS Controller, BIOS CD, 2 new examples and custom exit handler in the works
Diffstat (limited to 'libpsn00b/psxgpu')
-rw-r--r--libpsn00b/psxgpu/readme.txt15
-rw-r--r--libpsn00b/psxgpu/resetgraph.s81
2 files changed, 81 insertions, 15 deletions
diff --git a/libpsn00b/psxgpu/readme.txt b/libpsn00b/psxgpu/readme.txt
index 55fcb68..0d44e72 100644
--- a/libpsn00b/psxgpu/readme.txt
+++ b/libpsn00b/psxgpu/readme.txt
@@ -27,7 +27,7 @@ Todo list:
getting number of vsyncs elapsed and waiting until a specified number of
vsyncs have passed.
- * VSync interrupt handler should be hooked using BIOS function
+ * (old) VSync interrupt handler should be hooked using BIOS function
SetCustomExitFromException() like the official GPU library instead of
hooking an event handler, but said hook never seems to work. Perhaps
something in the kernel area needs to be patched/set or some event/IRQ
@@ -47,4 +47,15 @@ Todo list:
Changelog:
- None thus far...
+ 05-23-2019 by Lameguy64:
+
+ * Got custom exit handler set using SetCustomExitFromException() (BIOS
+ function B(19h)) working. Currently used to acknowledge VSync IRQ but
+ actual VSync handling is still done with events and needs to be
+ transferred to the custom exit handler. At least it lets BIOS
+ controller functions to work now. See doc/dev notes.txt for details
+ on how this handler behaves.
+
+ * Made stack usage a lot less wasteful in ResetGraph() (you only need
+ to allocate N words on stack based on N arguments of the function
+ being called.
diff --git a/libpsn00b/psxgpu/resetgraph.s b/libpsn00b/psxgpu/resetgraph.s
index bc30d3b..189b1ad 100644
--- a/libpsn00b/psxgpu/resetgraph.s
+++ b/libpsn00b/psxgpu/resetgraph.s
@@ -9,9 +9,9 @@
.global ResetGraph # Resets the GPU and installs a
.type ResetGraph, @function # VSync event handler
ResetGraph:
- addiu $sp, -0x20 # C style stack allocation (required if
- sw $ra, 28($sp) # you call BIOS functions from asm)
- sw $a0, 24($sp)
+ addiu $sp, -8 # C style stack allocation (required if
+ sw $ra, 0($sp) # you call BIOS functions from asm)
+ sw $a0, 4($sp)
la $v0, _hooks_installed # Skip installing hooks if this function
lbu $v0, 0($v0) # has already been called before once
@@ -20,8 +20,8 @@ ResetGraph:
nop
# Temporary, may help improve compatibility?
- jal SetDefaultExitFromException
- nop
+ #jal SetDefaultExitFromException
+ #nop
jal ChangeClearPAD # Remove pad handler left by the BIOS
move $a0, $0
@@ -52,13 +52,16 @@ ResetGraph:
jal OpenEvent # Open a VSync event handler
# (PSXSDK style vsync handler)
- nop
+ addiu $sp, -16
+ addiu $sp, 16
la $v1, _vsync_event_desc # Save event descriptor
sw $v0, 0($v1)
- jal EnableEvent # Enable the opened event
move $a0, $v0
+ jal EnableEvent # Enable the opened event
+ addiu $sp, -4
+ addiu $sp, 4
la $v0, _hooks_installed # Set installed flag
li $v1, 0x1
@@ -70,6 +73,11 @@ ResetGraph:
la $v0, _vsync_callback_func # Clear callback function
sw $0 , 0($v0)
+ la $a0, _custom_exit
+ jal SetCustomExitFromException
+ addiu $sp, -4
+ addiu $sp, 4
+
jal ExitCriticalSection # Re-enable interrupts
nop
@@ -87,7 +95,7 @@ ResetGraph:
sw $v0, 0($v1)
.not_pal:
- lw $a0, 24($sp) # Get argument value
+ lw $a0, 4($sp) # Get argument value
lui $a3, 0x1f80 # Set base I/O again (likely destroyed
# by previous calls)
@@ -118,10 +126,10 @@ ResetGraph:
.init_done:
- lw $ra, 28($sp)
- lw $a0, 24($sp) # Return
+ lw $ra, 0($sp)
+ lw $a0, 4($sp) # Return
jr $ra
- addiu $sp, 0x20
+ addiu $sp, 8
.global _vsync_func # VSync event handler, executed on
@@ -142,8 +150,9 @@ _vsync_func:
andi $v0, $v1, 0x1
beqz $v0, .exit
nop
- xori $v1, $v1, 0x1 # Acknowledge the IRQ
- sw $v1, ISTAT($at)
+
+ #xori $v1, $v1, 0x1 # Acknowledge the IRQ
+ #sw $v1, ISTAT($at) # Commented out as it breaks BIOS pads
la $v1, _vsync_counter # Increment VSync counter
lw $v0, 0($v1)
@@ -171,6 +180,32 @@ _vsync_func:
nop
+.global _vsync_func_2
+.type _vsync_func_2, @function
+_vsync_func_2:
+
+ lui $at, 0x1f80 # Check if there's a VSync IRQ
+ lw $v0, IMASK($at)
+ nop
+ andi $v0, $v0, 0x1
+ beqz $v0, .exit_2
+ nop
+
+ lw $v1, ISTAT($at)
+ nop
+ andi $v0, $v1, 0x1
+ beqz $v0, .exit_2
+ nop
+
+ xori $v1, $v1, 0x1 # Acknowledge the IRQ
+ sw $v1, ISTAT($at)
+
+.exit_2:
+
+ j ReturnFromException
+ nop
+
+
.global VSync # VSync function
.type VSync, @function
VSync:
@@ -211,6 +246,26 @@ VSync:
library_credits:
.string "psxgpu programs by Lameguy64"
+
+.type _custom_exit, @object
+_custom_exit:
+ .word _vsync_func_2 # pc
+ .word _vsync_stack # sp
+ .word 0 # fp
+ .word 0 # s0
+ .word 0 # s1
+ .word 0 # s2
+ .word 0 # s3
+ .word 0 # s4
+ .word 0 # s5
+ .word 0 # s6
+ .word 0 # s7
+ .word _gp # gp
+
+ .fill 60
+_vsync_stack:
+ .fill 4
+
.type _vsync_counter, @object
_vsync_counter:
.word 0