Programs: Added a program that will draw a spinning cube on the vector display but currently only does the perspective calculations

This commit is contained in:
(Tim) Efthimis Kritikos 2024-02-16 18:11:58 +00:00
parent 31a26c14ad
commit 2c07ced789
3 changed files with 236 additions and 3 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
*.o
first
test.rom
*.rom
make.deps

View File

@ -3,6 +3,8 @@ QUIET=1
all:first
OBJECT_FILES=gui.o main.o simdata.o assembly.o cpu.o
MAIN_ROM=programs/3d_renderer.rom
ROMS=test.rom ${MAIN_ROM}
make.deps: $(subst .o,.c,${OBJECT_FILES}) $(wildcard *.h)
@$(CC) -MM $(subst .o,.c,${OBJECT_FILES}) > make.deps
@ -20,7 +22,7 @@ else
Q =
endif
all:test.rom
all:${MAIN_ROM}
first: ${OBJECT_FILES}
${QUIET_LINK}
@ -37,4 +39,4 @@ first: ${OBJECT_FILES}
.PHONY: clean
clean:
${QUIET_CLEAN}
${Q} rm -f ${OBJECT_FILES} first
${Q} rm -f ${OBJECT_FILES} first ${ROMS}

231
programs/3d_renderer.asm Normal file
View File

@ -0,0 +1,231 @@
MOV $0xFF0000,%SP
#Set up vector mode
MOV $0xFFFC,%R4l
MOV $0x00FF,%R4h
MOV $0xFFFF,%R1l
MOV $0xFFFF,%R1h
MOV %R1,(%R4)
CALL $RENDER
:RENDER
MOV $>DATA_START,%R0l
MOV $<DATA_START,%R0h
MOV $0x000D,%R7l
MOV $0x0000,%R7h
MOV $0x0001,%R6l
MOV $0x0000,%R6h
MOV $0x0004,%R5l
MOV $0x0000,%R5h
:RENDER_LOOP
MOV $0xFFFF,%R1l
MOV $0xFFFF,%R1h
MOV %R1,(%R4)
#Read in a point R1:x R2:y R3:z
MOV $0x3f4c,%R4h #0.8
MOV $0xcccd,%R4l
MOV (%R0),%R1
ADD %R5,%R0
MOV (%R0),%R2
ADD %R5,%R0
MOV (%R0),%R3
ADD %R5,%R0
FSUB %R4,%R1
FSUB %R4,%R2
MOV $0x3e99,%R4h
MOV $0x999a,%R4l
FADD %R4,%R3
FADD %R4,%R3
FADD %R4,%R1
FADD %R4,%R2
FDIV %R3,%R1
FDIV %R3,%R2
MOV $0xFFFC,%R4l
MOV $0x00FF,%R4h
MOV %R1,(%R4)
MOV %R2,(%R4)
MOV $0x3f4c,%R4h #0.8
MOV $0xcccd,%R4l
MOV (%R0),%R1
ADD %R5,%R0
MOV (%R0),%R2
ADD %R5,%R0
MOV (%R0),%R3
ADD %R5,%R0
FSUB %R4,%R1
FSUB %R4,%R2
MOV $0x3e99,%R4h
MOV $0x999a,%R4l
FADD %R4,%R3
FADD %R4,%R3
FADD %R4,%R1
FADD %R4,%R2
FDIV %R3,%R1
FDIV %R3,%R2
MOV $0xFFFC,%R4l
MOV $0x00FF,%R4h
MOV %R1,(%R4)
MOV %R2,(%R4)
SUB %R6,%R7
JMP,NZ $RENDER_LOOP
HALT
:DATA_START
#0,0,0
DDW $0x00000000
DDW $0x00000000
DDW $0x00000000
#0,0,1
DDW $0x00000000
DDW $0x00000000
DDW $0x3f800000
#0,0,0
DDW $0x00000000
DDW $0x00000000
DDW $0x00000000
#1,0,0
DDW $0x3f800000
DDW $0x00000000
DDW $0x00000000
#0,0,0
DDW $0x00000000
DDW $0x00000000
DDW $0x00000000
#0,1,0
DDW $0x00000000
DDW $0x3f800000
DDW $0x00000000
#1,1,1
DDW $0x3f800000
DDW $0x3f800000
DDW $0x3f800000
#1,1,0
DDW $0x3f800000
DDW $0x3f800000
DDW $0x00000000
#1,1,1
DDW $0x3f800000
DDW $0x3f800000
DDW $0x3f800000
#1,0,1
DDW $0x3f800000
DDW $0x00000000
DDW $0x3f800000
#1,1,1
DDW $0x3f800000
DDW $0x3f800000
DDW $0x3f800000
#0,1,1
DDW $0x00000000
DDW $0x3f800000
DDW $0x3f800000
#0,1,1
DDW $0x00000000
DDW $0x3f800000
DDW $0x3f800000
#0,1,0
DDW $0x00000000
DDW $0x3f800000
DDW $0x00000000
#0,1,1
DDW $0x00000000
DDW $0x3f800000
DDW $0x3f800000
#0,0,1
DDW $0x00000000
DDW $0x00000000
DDW $0x3f800000
#0,1,0
DDW $0x00000000
DDW $0x3f800000
DDW $0x00000000
#1,1,0
DDW $0x3f800000
DDW $0x3f800000
DDW $0x00000000
#0,1,0
DDW $0x00000000
DDW $0x3f800000
DDW $0x00000000
#1,1,0
DDW $0x3f800000
DDW $0x3f800000
DDW $0x00000000
#0,0,1
DDW $0x00000000
DDW $0x00000000
DDW $0x3f800000
#1,0,1
DDW $0x3f800000
DDW $0x00000000
DDW $0x3f800000
#1,0,0
DDW $0x3f800000
DDW $0x00000000
DDW $0x00000000
#1,1,0
DDW $0x3f800000
DDW $0x3f800000
DDW $0x00000000
#1,0,0
DDW $0x3f800000
DDW $0x00000000
DDW $0x00000000
#1,0,1
DDW $0x3f800000
DDW $0x00000000
DDW $0x3f800000