aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxgpu
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-07-17 11:30:07 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-07-17 11:30:07 +0800
commit0d4345a9bf2623df079c50a3bc73cbb7deca1176 (patch)
tree6cda70b844f39fc2d65a806b91a6010066433b56 /libpsn00b/psxgpu
parentb956c5391b955e793a4d54572aa58872b4c66c30 (diff)
downloadpsn00bsdk-0d4345a9bf2623df079c50a3bc73cbb7deca1176.tar.gz
Added C++ support, updated build instructions and makefiles, consolidated libc and libgcc (during build process), libraries now v0.12b and more
Diffstat (limited to 'libpsn00b/psxgpu')
-rw-r--r--libpsn00b/psxgpu/drawsynccallback.s4
-rw-r--r--libpsn00b/psxgpu/getinterruptcallback.s6
-rw-r--r--libpsn00b/psxgpu/makefile8
-rw-r--r--libpsn00b/psxgpu/resetgraph.s17
-rw-r--r--libpsn00b/psxgpu/restartcallback.s50
-rw-r--r--libpsn00b/psxgpu/storeimage.s76
6 files changed, 146 insertions, 15 deletions
diff --git a/libpsn00b/psxgpu/drawsynccallback.s b/libpsn00b/psxgpu/drawsynccallback.s
index c1e28fe..37c0375 100644
--- a/libpsn00b/psxgpu/drawsynccallback.s
+++ b/libpsn00b/psxgpu/drawsynccallback.s
@@ -17,9 +17,12 @@ DrawSyncCallback:
beqz $a0, .Luninstall
nop
+
la $a1, _drawsync_handler
+ lw $a1, 4($sp)
jal DMACallback
li $a0, 2
+
b .Lcontinue
nop
@@ -52,7 +55,6 @@ DrawSyncCallback:
_drawsync_handler:
.Ldma_wait:
-
la $v0, _drawsync_func
lw $v0, 0($v0)
nop
diff --git a/libpsn00b/psxgpu/getinterruptcallback.s b/libpsn00b/psxgpu/getinterruptcallback.s
index b465567..510447f 100644
--- a/libpsn00b/psxgpu/getinterruptcallback.s
+++ b/libpsn00b/psxgpu/getinterruptcallback.s
@@ -11,7 +11,9 @@ GetInterruptCallback:
la $a1, _irq_func_table
sll $a0, 2
addu $a1, $a0
-
- jr $ra
lw $v0, 0($a1)
+ nop
+ jr $ra
+ nop
+
\ No newline at end of file
diff --git a/libpsn00b/psxgpu/makefile b/libpsn00b/psxgpu/makefile
index 5eb6265..7a7de5d 100644
--- a/libpsn00b/psxgpu/makefile
+++ b/libpsn00b/psxgpu/makefile
@@ -2,7 +2,7 @@
# Part of the PSn00bSDK Project
# 2019 Lameguy64 / Meido-Tek Productions
-PREFIX = mipsel-unknown-elf-
+include ../common.mk
TARGET = ../libpsxgpu.a
@@ -10,10 +10,8 @@ CFILES = $(notdir $(wildcard ./*.c))
AFILES = $(notdir $(wildcard ./*.s))
OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o))
-INCLUDE = -I../include
-
-CFLAGS = -O2 -msoft-float -fno-builtin -Wa,--strip-local-absolute
-AFLAGS = -msoft-float -Wa,--strip-local-absolute
+CFLAGS = -g -O2 -msoft-float -fno-builtin -Wa,--strip-local-absolute
+AFLAGS = -g -msoft-float -Wa,--strip-local-absolute
CC = $(PREFIX)gcc
AS = $(PREFIX)as
diff --git a/libpsn00b/psxgpu/resetgraph.s b/libpsn00b/psxgpu/resetgraph.s
index ff0b353..93ce185 100644
--- a/libpsn00b/psxgpu/resetgraph.s
+++ b/libpsn00b/psxgpu/resetgraph.s
@@ -4,6 +4,7 @@
.section .text
+.set ISR_STACK_SIZE, 1024
.global ResetGraph # Resets the GPU and installs a
.type ResetGraph, @function # VSync event handler
@@ -306,11 +307,12 @@ _vsync_irq_callback:
.type _global_isr, @function
_global_isr:
-
- lui $a0, IOBASE # Get IRQ status
.Lisr_loop:
+ #la $gp, _gp # Keep restoring GP since it gets
+ # changed elsewhere sometimes
+
lui $a0, IOBASE # Get IRQ status
lw $v0, IMASK($a0)
nop
@@ -392,10 +394,11 @@ _irq_func_table:
.word 0
# Global ISR hook structure
+.global _custom_exit
.type _custom_exit, @object
_custom_exit:
.word _global_isr # pc
- .word _custom_exit_stack # sp
+ .word _custom_exit_stack+ISR_STACK_SIZE # sp
.word 0 # fp
.word _irq_func_table # s0
.word 0 # s1
@@ -408,10 +411,10 @@ _custom_exit:
.word _gp # gp
# Global ISR stack
- .fill 124
-_custom_exit_stack:
- .fill 4
-
+# .fill 1024
+#_custom_exit_stack:
+# .fill 4
+.comm _custom_exit_stack, ISR_STACK_SIZE+4
.type vsynctimeout_msg, @object
vsynctimeout_msg:
diff --git a/libpsn00b/psxgpu/restartcallback.s b/libpsn00b/psxgpu/restartcallback.s
new file mode 100644
index 0000000..ffdeecd
--- /dev/null
+++ b/libpsn00b/psxgpu/restartcallback.s
@@ -0,0 +1,50 @@
+.set noreorder
+
+.include "hwregs_a.h"
+
+.section .text
+
+.global RestartCallback
+.type RestartCallback, @function
+RestartCallback:
+
+ addiu $sp, -4
+ sw $ra, 0($sp)
+
+ la $a0, _custom_exit
+ jal SetCustomExitFromException
+ addiu $sp, -12
+
+ jal ChangeClearPAD
+ move $a0, $0
+
+ li $a0, 3
+ jal ChangeClearRCnt
+ move $a1, $0
+
+
+ la $a0, _irq_func_table
+ move $a1, $0
+ move $v0, $0
+
+.Lcheck_cbs:
+ lw $v1, 0($a0)
+ nop
+ beqz $v1, .Lno_cb
+ addiu $a0, 4
+ li $v1, 1
+ sll $v1, $a1
+ or $v0, $v1
+.Lno_cb:
+ blt $a1, 10, .Lcheck_cbs
+ addiu $a1, 1
+
+ lui $a0, IOBASE
+ sw $0 , ISTAT($a0)
+ sw $v0, IMASK($a0)
+
+ addiu $sp, 12
+ lw $ra, 0($sp)
+ nop
+ jr $ra
+ nop \ No newline at end of file
diff --git a/libpsn00b/psxgpu/storeimage.s b/libpsn00b/psxgpu/storeimage.s
new file mode 100644
index 0000000..5d4c793
--- /dev/null
+++ b/libpsn00b/psxgpu/storeimage.s
@@ -0,0 +1,76 @@
+.set noreorder
+
+.include "hwregs_a.h"
+
+.set RECT_x, 0
+.set RECT_y, 2
+.set RECT_w, 4
+.set RECT_h, 6
+
+.section .text
+
+
+.global StoreImage
+.type StoreImage, @function
+StoreImage:
+ addiu $sp, -8
+ sw $ra, 0($sp)
+ sw $s0, 4($sp)
+
+ lui $s0, 0x1f80 # Set I/O segment base address
+
+.Lgpu_wait: # Wait for GPU to be ready for commands and DMA
+ jal ReadGPUstat
+ nop
+ srl $v0, 0x1a
+ andi $v0, 0x5
+ li $v1, 5
+ bne $v0, $v1, .Lgpu_wait
+ nop
+
+ lui $v0, 0x400 # Set DMA direction to off
+ sw $v0, GP1($s0)
+
+ lui $v0, 0x0100 # Clear GPU cache
+ sw $v0, GP0($s0)
+
+ lui $v1, 0xc000 # Store image from VRAM
+ sw $v1, GP0($s0)
+ lw $v0, RECT_x($a0) # Set XY and dimensions of image
+ lw $v1, RECT_w($a0)
+ sw $v0, GP0($s0)
+ sw $v1, GP0($s0)
+
+ lui $v0, 0x400 # Set DMA direction to VRAMtoCPU
+ ori $v0, 0x3
+ sw $v0, GP1($s0)
+
+ lhu $v0, RECT_w($a0) # Get rectangle size
+ lhu $v1, RECT_h($a0)
+ nop
+ mult $v0, $v1 # Calculate BCR value
+ mflo $v1
+ srl $v1, 0x4
+ sll $v1, 0x10
+ ori $v1, 0x8
+
+ sw $a1, D2_MADR($s0) # Set DMA base address and transfer length
+ sw $v1, D2_BCR($s0)
+
+.Lgpu_wait_2: # Wait for GPU to be ready for commands and DMA
+ jal ReadGPUstat
+ nop
+ srl $v0, 27
+ andi $v0, 0x1
+ beqz $v0, .Lgpu_wait_2
+ nop
+
+ lui $v0, 0x100 # Start DMA transfer
+ ori $v0, 0x200
+ sw $v0, D2_CHCR($s0)
+
+ lw $ra, 0($sp)
+ lw $s0, 4($sp)
+ jr $ra
+ addiu $sp, 8
+