Skip to content

Commit

Permalink
Added example1
Browse files Browse the repository at this point in the history
Also fixed raster, pipeline and texture code in backface culling, enforced some code definition.
  • Loading branch information
TheMachine02 committed Sep 25, 2017
1 parent 73c01f8 commit cc69cc8
Show file tree
Hide file tree
Showing 19 changed files with 34,191 additions and 12,533 deletions.
Binary file added bin/SUZAN0.8xv
Binary file not shown.
Binary file added bin/SUZAN1.8xv
Binary file not shown.
Binary file modified bin/TEST.8xp
Binary file not shown.
888 changes: 443 additions & 445 deletions bin/TEST.lab

Large diffs are not rendered by default.

23,926 changes: 11,942 additions & 11,984 deletions bin/TEST.lst

Large diffs are not rendered by default.

Binary file added bin/TEST1.8xp
Binary file not shown.
4,676 changes: 4,676 additions & 0 deletions bin/TEST1.lab

Large diffs are not rendered by default.

11,458 changes: 11,458 additions & 0 deletions bin/TEST1.lst

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions build_example.bat
@@ -1,6 +1,11 @@
@echo off
color 0F
:Loop
echo -----------------------------------
echo Building example.ez80...
tools\spasm -L -T -E -A -S -I include/ example.ez80 bin/TEST.8xp
echo -----------------------------------
echo Building example1.ez80...
tools\spasm -L -T -E -A -S -I include/ example1.ez80 bin/TEST1.8xp
pause
goto Loop
7 changes: 6 additions & 1 deletion build_model.bat
Expand Up @@ -2,10 +2,15 @@
color 0F
:Loop

echo Converting TONYBOSS_TR2.obj...
tools\mdlconv file\TONYBOSS_TR2.obj -T -N -S -B
tools\spasm file\TONYBOSS_TR20.inc bin\TONY0.8xv -E -S
tools\spasm file\TONYBOSS_TR21.inc bin\TONY1.8xv -E -S
pause

echo "Converting Suzanne.obj..."
tools\mdlconv file\Suzanne.obj -C -N -S -B
tools\spasm file\Suzanne0.inc bin\SUZAN0.8xv -E -S
tools\spasm file\Suzanne1.inc bin\SUZAN1.8xv -E -S

tools\xmlconv
pause
219 changes: 219 additions & 0 deletions example1.ez80
@@ -0,0 +1,219 @@
#include "vx3D.inc"

#define DELTA 4096

.org userMem - 2
.db tExtTok, tAsm84CeCmp
.assume ADL=1

; init the virtual 3d library
call vxEngineInit
ret c ; qui if error at init

ld hl, VertexName
call vxFindFile
ret c
ld (Vertex), hl

ld hl, TriangleName
call vxFindFile
ret c
ld (Triangle), hl


; setup global variable for rendering, euler angle and the translation of WorldMatrix

ld hl, 0
ld (EulerAngle), hl

ld ix, WorldMatrix
lea hl, ix+0
call vxMatrixLoadIdentity
ld hl, 65536
ld (ix+15), hl ; Z translation of the matrix

MainLoop:

call vxTimerStart

ld hl, (EulerAngle)
ld iy, Quaternion
ld ix, UnitVector
call vxQuaternionRotationAxis
ld ix, WorldMatrix
call vxQuaternionGetMatrix
lea iy, ix+0
ld ix, ScaleMatrix
ld hl, WorldMatrix
call vxMatrixMlt

ld a, VX_GEOMETRY_CI9
ld ix, WorldMatrix
ld iy, ModelMatrix
ld bc, VX_VERTEX_BUFFER
ld hl, (Vertex)
ld de, (Triangle)
call vxCmdDraw

ld hl, (vxGeometrySize)
ld (triangle_count), hl

call vxCmdDepthSort

ld c, %00000000
call vxClearBuffer
call vxCmdExecute

; timer & counter

ld bc, 320*8-1
ld de, (vxFramebuffer)
or a, a
sbc hl, hl
add hl, de
inc de
ld (hl), 0
ldir

ld hl, 0
ld (TextXPos_SMC), hl
ld a, 0
ld (TextYPos_SMC), a

call vxTimerRead
; do (ade/256)/187
ld (Temp), de
ld (Temp+3), a
ld de, (Temp+1)
; divide de by 187
ex de, hl
ld bc, 187
call __idivs_ASM
ld de, 4
push de
push hl
call _PrintUInt
pop de
pop hl

ld hl, (TextXPos_SMC)
ld de, 8
add hl, de
ld (TextXPos_SMC), hl

triangle_count=$+1
ld hl, 0
ld de, 4
push de
push hl
call _PrintUInt
pop de
pop hl

call vxFlushLCD

KeyboardTest:
ld hl,$F50000
ld (hl),2
xor a,a
kwait:
cp a,(hl)
jr nz,kwait

ld de, 8
ld a, ($F5001E)
bit 1, a
jr z, _kskip
ld hl, (EulerAngle)
add hl, de
ld (EulerAngle), hl
_kskip:
ld de, -8
ld a, ($F5001E)
bit 2, a
jr z, _kskip2
ld hl, (EulerAngle)
add hl, de
ld (EulerAngle), hl
_kskip2:
ld a, ($F5001E)
bit 0, a
jr z, _kskip5
ld hl, (WorldMatrix+12)
ld de, DELTA
add hl, de
ld (WorldMatrix+12), hl
_kskip5:

ld a, ($F5001E)
bit 3, a
jr z, _kskip6
ld hl, (WorldMatrix+12)
ld de, -DELTA
add hl, de
ld (WorldMatrix+12), hl
_kskip6:

ld hl, (WorldMatrix+15)

ld a, ($F50012)
bit 0,a
jr z, _kskip3
ld de, DELTA
add hl, de
_kskip3:

bit 4,a
jr z, _kskip4
ld de, -DELTA
add hl, de
_kskip4:

ld (WorldMatrix+15), hl

ld a,($F5001C)
bit 6,a

jp z, MainLoop
ret

#include "vxMain.ez80"
#include "graphics_lib.asm"

posX:
.dw 0
posY:
.dw 0
posZ:
.dw 0
Temp:
.dl 0,0

VertexName:
.db AppVarObj, "SUZAN0",0
Vertex:
.dl 0
TriangleName:
.db AppVarObj, "SUZAN1", 0
Triangle:
.dl 0

ScaleMatrix:
.db 77,0,0 ; 44
.db 0,102,0 ; 58
.db 0,0,64 ; 37
UnitVector:
.dl 0,16384,0
Quaternion:
.dl 0,0,0,0
QuatMatrix:
.dl 0,0,0,0,0,0
WorldMatrix:
.dl 0,0,0,0,0,0
ModelMatrix:
.db 64,0,0
.db 0,64,0
.db 0,0,64
.dw 0,0,0
EulerAngle:
.dl 0,0,0
22 changes: 22 additions & 0 deletions file/Suzanne.mtl
@@ -0,0 +1,22 @@
# Blender MTL File: 'None'
# Material Count: 2

newmtl Material.001
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.000000 0.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.002
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.006859 0.640000 0.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

0 comments on commit cc69cc8

Please sign in to comment.