From 277e8210e00d295a064b7a888947ff1cd8d16e8e Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 5 Mar 2024 05:22:43 +0200 Subject: [PATCH] attempt at building a cd image (failed) --- Makefile | 11 +++++++++++ cd/cd.xml | 15 +++++++++++++++ cd/system.cnf | 4 ++++ psx.ld | 2 +- src/startup.S | 18 ++++++++---------- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 cd/cd.xml create mode 100644 cd/system.cnf diff --git a/Makefile b/Makefile index 5da7d41..c0a1ea4 100644 --- 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 index 0000000..1ba46d7 --- /dev/null +++ b/cd/cd.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/cd/system.cnf b/cd/system.cnf new file mode 100644 index 0000000..b5b5d30 --- /dev/null +++ b/cd/system.cnf @@ -0,0 +1,4 @@ +BOOT=cdrom:\psx.exe;1 +TCB=4 +EVENT=10 +STACK=801ffff0 diff --git a/psx.ld b/psx.ld index 4f6d4cd..fc5a306 100644 --- 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; diff --git a/src/startup.S b/src/startup.S index 3df6b83..afce04b 100644 --- a/src/startup.S +++ b/src/startup.S @@ -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 -- 1.7.10.4