attempt at building a cd image (failed)
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 5 Mar 2024 03:22:43 +0000 (05:22 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 5 Mar 2024 03:22:43 +0000 (05:22 +0200)
Makefile
cd/cd.xml [new file with mode: 0644]
cd/system.cnf [new file with mode: 0644]
psx.ld
src/startup.S

index 5da7d41..c0a1ea4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ dep = $(csrc:.c=.d) $(ssrc:.S=.d)
 
 elf = test1.elf
 bin = test1.psx
+iso = test1.iso
 
 TCPREFIX = mipsel-linux-gnu-
 
@@ -25,11 +26,17 @@ $(bin): $(elf)
 $(elf): $(obj)
        $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
 
+$(iso): cd/cd.xml cd/system.cnf $(bin)
+       mkpsxiso -o $@ -y $<
+
 -include $(dep)
 
 %.s: %.c
        $(CC) $(CFLAGS) -S -o $@ $<
 
+.PHONY: iso
+iso: $(iso)
+
 .PHONY: clean
 clean:
        rm -f $(obj) $(bin) $(elf) link.map
@@ -41,3 +48,7 @@ cleandep:
 .PHONY: run
 run: $(bin)
        mednafen $<
+
+.PHONY: runiso
+runiso: $(iso)
+       mednafen test1.cue
diff --git a/cd/cd.xml b/cd/cd.xml
new file mode 100644 (file)
index 0000000..1ba46d7
--- /dev/null
+++ b/cd/cd.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<iso_project image_name="test1.iso" cue_sheet="test1.cue" no_xa="0">
+       <track type="data">
+               <identifiers system="PLAYSTATION" application="PLAYSTATION" publisher="SCEE"/>
+               <license file="licensee.dat"/>
+               <directory_tree>
+                       <file name="system.cnf" source="system.cnf" type="data"/>
+                       <file name="psx.exe" source="../test1.psx" type="data"/>
+                       <dummy sectors="1024"/>
+               </directory_tree>
+       </track>
+
+       <!--track type="audio" trackid="02" source="myaudio.wav"/-->
+</iso_project>
diff --git a/cd/system.cnf b/cd/system.cnf
new file mode 100644 (file)
index 0000000..b5b5d30
--- /dev/null
@@ -0,0 +1,4 @@
+BOOT=cdrom:\psx.exe;1\r
+TCB=4\r
+EVENT=10\r
+STACK=801ffff0\r
diff --git a/psx.ld b/psx.ld
index 4f6d4cd..fc5a306 100644 (file)
--- a/psx.ld
+++ b/psx.ld
@@ -5,7 +5,7 @@ MEMORY {
        dcache : ORIGIN = 0x1f800000, LENGTH = 0x400
 }
 
-_stacktop = ORIGIN(ram) + LENGTH(ram);
+_stacktop = ORIGIN(ram) + LENGTH(ram) - 16;
 _dcache = ORIGIN(dcache);
 _dcache_end = ORIGIN(dcache) + LENGTH(dcache);
 _progsize = _imgend - _start;
index 3df6b83..afce04b 100644 (file)
@@ -14,8 +14,7 @@ _start:
        lui a0, REG_BASE
 
        # setup screen mode
-       li t0, 0
-       sw t0, REG_GP1(a0)      # GP1 0: reset
+       sw zero, REG_GP1(a0)    # GP1 0: reset
 
        li t0, 0x03000000       # GP1 3: display enable
        sw t0, REG_GP1(a0)
@@ -38,25 +37,24 @@ _start:
        # clear screen
        li t0, 0x02302010       # cmd 2: fill area (BBGGRR)
        sw t0, REG_GP0(a0)
-       li t0, 0
-       sw t0, REG_GP0(a0)      # ... top left 0,0 (YYYYXXXX)
+       sw zero, REG_GP0(a0)    # ... top left 0,0 (YYYYXXXX)
        li t0, 0x00ef013f       # ... size 319x239 (HHHHWWWW)
        sw t0, REG_GP0(a0)
 
        # draw gouraud triangle
-       li t0, 0x30ff0000
+       li t0, 0x30ff0000       # cmd 30: draw gouraud triangle (+BBGGRR vert0)
        sw t0, REG_GP0(a0)
-       li t0, 160 | (16 << 16)
+       li t0, 160 | (16 << 16) # ... vertex(160, 16)
        sw t0, REG_GP0(a0)
 
-       li t0, 0x0000ff00
+       li t0, 0x0000ff00       # ... color vert1
        sw t0, REG_GP0(a0)
-       li t0, 32 | (180 << 16)
+       li t0, 32 | (180 << 16) # ... vertex(32, 180)
        sw t0, REG_GP0(a0)
 
-       li t0, 0x000000ff
+       li t0, 0x000000ff       # ... color vert2
        sw t0, REG_GP0(a0)
-       li t0, 280 | (220 << 16)
+       li t0, 280 | (220 << 16) # ... vertex(220, 280)
        sw t0, REG_GP0(a0)
 
        #jal main