With a little help from a friend overseas (thanks Dan!) I finally got
the Vectrex Adapter spinning a 3D object around its origin.
I'm even including the assembly listing of the program that was
uploaded to the Vec in the video.
http://youtu.be/w9puhgqZJic
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Vectrex Adapter Demo ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Formated for Kingswood compiler ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This program does the following: ;
; ;
; === Rotates a 3D object around X,Y,Z,XYZ axis ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include "vecbios.txt"
AngleX equ $c880 ;2 bytes: X Angle (0-360)
AngleY equ $c882 ;2 bytes: Y Angle (0-360)
AngleZ equ $c884 ;2 bytes: Z Angle (0-360)
Counter equ $c886 ;General Counter
Object1_Add equ $8000 ;Start address of Object 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The following are registers used by Adapter API ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Rot_X equ $c7d0 ;2 bytes: Pointer Rot_X Register
Rot_Y equ $c7d2 ;2 bytes: Pointer Rot_Y Register
Rot_Z equ $c7d4 ;2 bytes: Pointer Rot_Y Register
Vec_Command equ $c7e3 ;Pointer to Command Register
Object_Num equ $c7e4 ;Pointer to Object Number Register
List_Type equ $c7e5 ;Pointer to Object List Type (2D/3D) Register
Num_Points equ $c7e6 ;Pointer to Number of Points in Object List
Register
Object_Pointer equ $c7e7 ;Pointer to Object Relative Vector List
Register
org $0000
; Magic Init Block
fcb $67,$20
fcc "GCE 2011"
fcb $80
fdb Music
fdb $f850
fdb $30b8
fcc "VECTREX 3D TEST"
fcb $80,$0
;*** Copy 3D Point List RAM ***
clrb
ldx #Point1_List ;point to start of point list in ROM
ldy #Object1_Add ;point to start of Object list
Mem_Loop
lda,x ;get point in ROM
sta,y ;store point in RAM
leax 1,x ;next point in ROM
leay 1,y ;next point in RAM
incb
cmpb #66 ;do all points
bne Mem_Loop
clr Counter ;clear general counter
ldd #00 ;Set all angles to 0
std AngleX
std AngleY
std AngleZ
std Rot_X
std Rot_Y
std Rot_Z
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Here we load up params for Object1 ;;;
;;;We fill in info about the Object ;;;
;;;We also tell adapter where we want the vector list saved ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lda #1 ;Vec Command = Fill Object List
sta Vec_Command
lda #1 ;Object Number is 1
sta Object_Num
lda #1 ;Set list type as 3D
sta List_Type
lda #22 ;set number of 3D points in object
sta Num_Points
ldd #Object1_Add ;set pointer to Object address
std Object_Pointer ;Vec will expect vector list to be here when
drawing
lda $C7ff ;A call to this address tells adapter to start working
jsr Wait_PB6 ;Wait for adapter to give RAM back to Vectrex
Main_Loop
jsr Increase_X ;Rotate about X-axis
jsr Increase_Y ;Rotate about Y-axis
jsr Increase_Z ;Rotate about Z-axis
jsr Rotate_XYZ ;Rotate about XYZ
jsr Draw_Ship ;Draw the ship
bra Main_Loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; These routines rotate ship about cardinal axes ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Increase_X
lda Counter ;only go around once
cmpa #0
bne IX_Done
ldd AngleX ;increase Angle-X by 1
addd #1
cmpd #360 ;don't go over 360 degrees
bne Keep_Increasing_X
inc Counter ;we're done... onto Y rotation
ldd #00
Keep_Increasing_X
std AngleX ;save Angle (Vec local)
std Rot_X ;save Angle (Adapter Register)
IX_Done
rts
Increase_Y
lda Counter
cmpa #1
bne IY_Done
ldd AngleY
addd #1
cmpd #360
bne Keep_Increasing_Y
inc Counter
ldd #00
Keep_Increasing_Y
std AngleY
std Rot_Y
IY_Done
rts
Increase_Z
lda Counter
cmpa #2
bne IY_Done
ldd AngleZ
addd #1
cmpd #360
bne Keep_Increasing_Z
inc Counter
ldd #00
Keep_Increasing_Z
std AngleZ
std Rot_Z
IYZDone
rts
Rotate_XYZ
lda Counter
cmpa #3
bne RXYZ_Done
ldd AngleZ
addd #1
cmpd #360
bne RXYZ_Continue
clr Counter
ldd #00
RXYZ_Continue
std AngleZ
std Rot_Z
std Rot_X
std Rot_Y
RXYZ_Done
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; This routine rotates and draws the ship ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Draw_Ship
lda #2 ;Vec Command = Rotate Object Around Center
sta Vec_Command
lda #1 ;Object number = 1
sta Object_Num
lda $C7ff ;A call to this address tells adapter to start working
jsr Wait_PB6 ;wait for adapter to finish
jsr Wait_Recal ;recalibrate
ldb #00 ;now draw the ship...
jsr Moveto_d
jsr Intensity_7F
lda Object1_Add
deca
ldb #128
ldx #Object1_Add+1
jsr Draw_VL_ab
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Here we wait for PB6 to go low ;;;
;;; PB6 High = Adapter has control of extended RAM ;;;
;;; OK to access ROM and local Vec RAM ($c880-$cbea) ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Wait_PB6
lda Via_port_b
anda #%01000000
cmpa #%01000000
beq Wait_PB6
lda #00 ;Reset Vec Command Register
sta Vec_Command
rts
Music
fdb $fee8
fdb $feb8
fcb $0,$80
fcb $0,$80
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This is the 3D object Point List (object space) ;;;
;; It is not a Vector List ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Point1_List
fcb 0,0,0
fcb 0,20,-20
fcb 0,0,-40
fcb 0,-20,-20
fcb 0,0,0
fcb 20,0,-20
fcb 0,0,-40
fcb -20,0,-20
fcb 0,0,0
fcb -40,-20,80
fcb -17,0,80
fcb 17,0,80
fcb 40,-20,80
fcb 0,0,0
fcb -17,0,80
fcb -13,10,60
fcb 13,10,60
fcb 17,0,80
fcb 0,0,0
fcb 13,10,60
fcb -13,10,60
fcb 0,0,0