aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxapi/_initcd.s
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2022-03-25 09:22:20 +0800
committerGitHub <noreply@github.com>2022-03-25 09:22:20 +0800
commit975e614b3c840e2f717adac1d1cb9cee4e5e561b (patch)
tree6584ce5b0dbe27a466c95c81fac61b0d90f627bd /libpsn00b/psxapi/_initcd.s
parent05d44488bd5587786f4bd0286fc0f555c79aa46a (diff)
parent45168ae43e29aa5930ee5a206475ae836078915f (diff)
downloadpsn00bsdk-975e614b3c840e2f717adac1d1cb9cee4e5e561b.tar.gz
Merge pull request #46 from spicyjpeg/psxmdec
Critical ldscript fixes, initial MDEC support and CI updates
Diffstat (limited to 'libpsn00b/psxapi/_initcd.s')
-rw-r--r--libpsn00b/psxapi/_initcd.s37
1 files changed, 37 insertions, 0 deletions
diff --git a/libpsn00b/psxapi/_initcd.s b/libpsn00b/psxapi/_initcd.s
new file mode 100644
index 0000000..c3a2861
--- /dev/null
+++ b/libpsn00b/psxapi/_initcd.s
@@ -0,0 +1,37 @@
+.section .text
+.set noreorder
+
+.include "hwregs_a.h"
+
+.global _InitCd
+.type _InitCd, @function
+_InitCd:
+ addiu $sp, -8
+ sw $ra, 0($sp)
+
+ lui $a0, IOBASE # Load IOBASE value
+
+ lw $v0, DMA_DPCR($a0) # Get current DMA settings
+ nop
+ sw $v0, 4($sp) # Save to stack
+
+ jal _96_init # Init CD subsystem
+ nop
+
+ lui $a0, IOBASE # Load IOBASE again
+
+ lw $v0, 4($sp) # Get old DMA control settings
+ lw $v1, DMA_DPCR($a0) # Get DMA settings by _96_init()
+
+ lui $a1, 0xffff # Mask out settings for CD DMA
+ ori $a1, 0x0f00
+ and $v0, $a1
+
+ or $v0, $v1 # Merge and set new DMA settings
+ sw $v0, DMA_DPCR($a0)
+
+ lw $ra, 0($sp)
+ addiu $sp, 8
+ jr $ra
+ nop
+ \ No newline at end of file