;*****************
;* Program Tests *
;*****************

; This is a set of programming tests. 

; To Compile:
; zmac -i -m -o ProgramTests.bin -x ProgramTests.lst ProgramTests.asm

; Lance F. Squire 2002

INCLUDE HVGLIB.H

BALMNU	EQU	0218H		;LINK POINT TO BALLY
				;STANDARD MENU.
B1VEC	EQU	4F00H		;VECTOR BLOCK FOR BALL TEST
B2VEC	EQU	B1VEC+VBOAH+1	;VECTOR BLOCKS FOR MULTI TEST
B3VEC	EQU	B2VEC+VBOAH+1
C1VEC	EQU	B3VEC+VBOAH+1

	ORG	2000H		;Start of Cart memory

	DEFB	55H		;NORMAL (MENUED) CART 'SENTENAL'
	DEFW	NEXT		;NEXT NODE IN MENU CHAIN
	DEFW	LABEL		;ADDRESS OF MENU TEXT
	DEFW	PROG1		;WHERE TO GO IF SELECTED.
NEXT	DEFW	NEXT2		
	DEFW	LABEL2		;MENU TEXT
	DEFW	PROG2
NEXT2	DEFW	BALMNU		;(START OF ONBOARD MENU)
	DEFW	LABEL3
	DEFW	2008H

LABEL	DEFB	'BALL TEST',0	;NULL DELIMITED STRINGS
LABEL2	DEFB	'3 BALL TEST',0
LABEL3	DEFB	'BLANK',0

;*****************
;* Bouncing ball *
;*****************

PROG1	SYSSUK	FILL		;CLEAR SCREEN
	DEFW	4000H		;START OF SCREEN RAM
	DEFW	95*40		;95 LINES (40 BYTES)
	DEFB	0		;ZERO VALUE

	LD	IX,B1VEC	;BEGIN SETUP OF VECTOR BLOCK
	LD	(IX+VBMR),8	;MAGIC: EXPAND
	LD	(IX+VBSTAT),192	;STATUS: ACTIVE+BLANKING
	LD	(IX+VBTIMB),1	;TIMES: 1 (NUMBER OF TIMES DELTA IS ADDED TO POSITION)
	LD	(IX+VBDXL),0	;DELTA (DIRECTION)X LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBDXH),1	;1 PIXEL PER CALL MOTION (RIGHT)
	LD	(IX+VBXL),0	;INITIAL POSITION LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBXH),0	;ACTUAL X POSITION ON SCREEN
	LD	(IX+VBXCHK),3	;X LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBDYL),0	;DELTA (DIRECTION)Y LOW ORDER BYTE (FRACTION)
	LD	(IX+VBDYH),1	;1 PIXEL PER CALL MOTION (DOWN)
	LD	(IX+VBYL),0	;INITIAL POSSITION LOW ORDER BYTE (FRACTION)
	LD	(IX+VBYH),0	;ACTUAL Y POSITION ON SCREEN
	LD	(IX+VBYCHK),3	;Y LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBOAL),0	;OLD ADDRESS: CLEARED FOR NOW
	LD	(IX+VBOAH),0	;END VECTOR BLOCK SETUP

	LD	A,0CH		;COLOURS TO EXPAND TO
	OUT	(XPAND),A	;INTO EXPANSION PORT

LOOP	SYSSUK	VWRITR		;DRAW BALL
	DEFW	B1VEC		;VECTOR BLOCK TO USE
	DEFW	BALL1		;IMAGE TO DRAW

	LD	IX,B1VEC
	LD	(IX+VBOAL),E	;COPY SCREEN ADDRESS TO VECTORBLOCK?
	LD	(IX+VBOAH),D	;

	SYSSUK	PAWS		;PAUSE FOR
	DEFB	1		;ONE CYCLE

	SYSSUK	VBLANK		;ERASE BALL
	DEFW	B1VEC		;VECTOR BLOCK
	DEFB	2		;X SIZE IN BYTES
	DEFB	6		;Y SIZE

	SYSSUK	VECT		;MOVE BALL
	DEFW	B1VEC		;VECTOR BLOCK TO USE
	DEFW	BLMT		;LIMITS TABLE TO USE

	LD	IX,B1VEC
	LD	(IX+VBTIMB),1	;RE ACTIVATE?
	JR	LOOP		;BACK TO DRAW BALL

;*********************
;* Bouncing ball 3 +1*
;*********************

PROG2	SYSSUK	FILL		;CLEAR SCREEN
	DEFW	4000H		;START OF SCREEN RAM
	DEFW	95*40		;95 LINES (40 BYTES)
	DEFB	0		;ZERO VALUE

	LD	IX,B1VEC	;BEGIN SETUP OF VECTOR BLOCK
	LD	(IX+VBMR),40	;MAGIC: EXPAND+XOR
	LD	(IX+VBSTAT),192	;STATUS: ACTIVE+BLANKING
	LD	(IX+VBTIMB),1	;TIMES: 1
	LD	(IX+VBDXL),0	;DELTA (DIRECTION)X LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBDXH),1	;1 PIXEL PER CALL MOTION (RIGHT)
	LD	(IX+VBXL),0	;INITIAL POSITION LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBXH),0	;ACTUAL X POSITION ON SCREEN
	LD	(IX+VBXCHK),3	;X LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBDYL),0	;DELTA (DIRECTION)Y LOW ORDER BYTE (FRACTION)
	LD	(IX+VBDYH),1	;1 PIXEL PER CALL MOTION (DOWN)
	LD	(IX+VBYL),0	;INITIAL POSSITION LOW ORDER BYTE (FRACTION)
	LD	(IX+VBYH),0	;ACTUAL Y POSITION ON SCREEN
	LD	(IX+VBYCHK),3	;Y LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBOAL),0	;OLD ADDRESS: CLEARED FOR NOW
	LD	(IX+VBOAH),0	;END VECTOR BLOCK SETUP

	LD	IX,B2VEC	;BEGIN SETUP OF VECTOR BLOCK
	LD	(IX+VBMR),40	;MAGIC: EXPAND+XOR
	LD	(IX+VBSTAT),192	;STATUS: ACTIVE+BLANKING
	LD	(IX+VBTIMB),1	;TIMES: 1
	LD	(IX+VBDXL),128	;DELTA (DIRECTION)X LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBDXH),0	;.5? PIXEL PER CALL MOTION (RIGHT)
	LD	(IX+VBXL),0	;INITIAL POSITION LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBXH),0	;ACTUAL X POSITION ON SCREEN
	LD	(IX+VBXCHK),3	;X LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBDYL),192	;DELTA (DIRECTION)Y LOW ORDER BYTE (FRACTION)
	LD	(IX+VBDYH),1	;1.75? PIXEL PER CALL MOTION (DOWN)
	LD	(IX+VBYL),0	;INITIAL POSSITION LOW ORDER BYTE (FRACTION)
	LD	(IX+VBYH),0	;ACTUAL Y POSITION ON SCREEN
	LD	(IX+VBYCHK),3	;Y LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBOAL),0	;OLD ADDRESS: CLEARED FOR NOW
	LD	(IX+VBOAH),0	;END VECTOR BLOCK SETUP

	LD	IX,B3VEC	;BEGIN SETUP OF VECTOR BLOCK
	LD	(IX+VBMR),40	;MAGIC: EXPAND+XOR
	LD	(IX+VBSTAT),192	;STATUS: ACTIVE+BLANKING
	LD	(IX+VBTIMB),1	;TIMES: 1
	LD	(IX+VBDXL),0	;DELTA (DIRECTION)X LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBDXH),2	;2 PIXEL PER CALL MOTION (RIGHT)
	LD	(IX+VBXL),0	;INITIAL POSITION LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBXH),0	;ACTUAL X POSITION ON SCREEN
	LD	(IX+VBXCHK),3	;X LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBDYL),128	;DELTA (DIRECTION)Y LOW ORDER BYTE (FRACTION)
	LD	(IX+VBDYH),1	;1.5? PIXEL PER CALL MOTION (DOWN)
	LD	(IX+VBYL),0	;INITIAL POSSITION LOW ORDER BYTE (FRACTION)
	LD	(IX+VBYH),0	;ACTUAL Y POSITION ON SCREEN
	LD	(IX+VBYCHK),3	;Y LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBOAL),0	;OLD ADDRESS: CLEARED FOR NOW
	LD	(IX+VBOAH),0	;END VECTOR BLOCK SETUP

	LD	IX,C1VEC	;BEGIN SETUP OF VECTOR BLOCK
	LD	(IX+VBMR),32	;MAGIC: XOR
	LD	(IX+VBSTAT),192	;STATUS: ACTIVE+BLANKING
	LD	(IX+VBTIMB),1	;TIMES: 1
	LD	(IX+VBDXL),182	;.5 X MOTION
	LD	(IX+VBDXH),0	;
	LD	(IX+VBXL),0	;INITIAL POSITION LOW ORDER BYTE (FRACTIONS)
	LD	(IX+VBXH),0	;ACTUAL X POSITION ON SCREEN
	LD	(IX+VBXCHK),3	;X LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBDYL),128	;.5 Y MOTION
	LD	(IX+VBDYH),0	;
	LD	(IX+VBYL),0	;INITIAL POSSITION LOW ORDER BYTE (FRACTION)
	LD	(IX+VBYH),0	;ACTUAL Y POSITION ON SCREEN
	LD	(IX+VBYCHK),3	;Y LIMIT CHECKING: ON + REVERSING (BOUNCE)
	LD	(IX+VBOAL),0	;OLD ADDRESS: CLEARED FOR NOW
	LD	(IX+VBOAH),0	;END VECTOR BLOCK SETUP

LOOP2	LD	A,0CH		;COLOURS TO EXPAND TO
	OUT	(XPAND),A	;INTO EXPANSION PORT

	SYSSUK	VWRITR		;DRAW BALL
	DEFW	B1VEC		;VECTOR BLOCK TO USE
	DEFW	BALL1		;IMAGE TO DRAW

	LD	A,08H		;COLOURS TO EXPAND TO
	OUT	(XPAND),A	;INTO EXPANSION PORT

	SYSSUK	VWRITR		;DRAW BALL
	DEFW	B2VEC		;VECTOR BLOCK TO USE
	DEFW	BALL1		;IMAGE TO DRAW

	LD	A,04H		;COLOURS TO EXPAND TO
	OUT	(XPAND),A	;INTO EXPANSION PORT

	SYSSUK	VWRITR		;DRAW BALL
	DEFW	B3VEC		;VECTOR BLOCK TO USE
	DEFW	BALL1		;IMAGE TO DRAW

	SYSSUK	VWRITR		;DRAW CRITTER
	DEFW	C1VEC		;VECTOR BLOCK TO USE
	DEFW	CRIT1		;IMAGE TO DRAW

	SYSSUK	PAWS		;PAUSE FOR
	DEFB	1		;ONE CYCLE

	LD	A,0CH		;COLOURS TO EXPAND TO
	OUT	(XPAND),A	;INTO EXPANSION PORT

	SYSSUK	VWRITR		;ERASE BALL 1
	DEFW	B1VEC		;VECTOR BLOCK TO USE
	DEFW	BALL1		;IMAGE TO DRAW

	LD	A,08H		;COLOURS TO EXPAND TO
	OUT	(XPAND),A	;INTO EXPANSION PORT

	SYSSUK	VWRITR		;ERASE BALL 2
	DEFW	B2VEC		;VECTOR BLOCK TO USE
	DEFW	BALL1		;IMAGE TO DRAW

	LD	A,04H		;COLOURS TO EXPAND TO
	OUT	(XPAND),A	;INTO EXPANSION PORT

	SYSSUK	VWRITR		;ERASE BALL 3
	DEFW	B3VEC		;VECTOR BLOCK TO USE
	DEFW	BALL1		;IMAGE TO DRAW

	SYSSUK	VWRITR		;ERASE CRITTER
	DEFW	C1VEC		;VECTOR BLOCK TO USE
	DEFW	CRIT1		;IMAGE TO DRAW

	SYSSUK	VECT		;MOVE BALL
	DEFW	B1VEC		;VECTOR BLOCK TO USE
	DEFW	BLMT		;LIMITS TABLE TO USE

	SYSSUK	VECT		;MOVE BALL
	DEFW	B2VEC		;VECTOR BLOCK TO USE
	DEFW	BLMT		;LIMITS TABLE TO USE

	SYSSUK	VECT		;MOVE BALL
	DEFW	B3VEC		;VECTOR BLOCK TO USE
	DEFW	BLMT		;LIMITS TABLE TO USE

	SYSSUK	VECT		;MOVE BALL
	DEFW	C1VEC		;VECTOR BLOCK TO USE
	DEFW	CLMT		;LIMITS TABLE TO USE

	LD	IX,B1VEC
	LD	(IX+VBTIMB),1	;RE ACTIVATE??

	LD	IX,B2VEC
	LD	(IX+VBTIMB),1	;RE ACTIVATE??

	LD	IX,B3VEC
	LD	(IX+VBTIMB),1	;RE ACTIVATE??

	LD	IX,C1VEC
	LD	(IX+VBTIMB),1	;RE ACTIVATE??

	JP	LOOP2		;BACK TO DRAW BALL

;********************
;* BALL IMAGE BLOCK *
;********************

BALL1	DEFB	0	;NO X OFFSET
	DEFB	0	;NO Y OFFSET
	DEFB	1	;1 BYTE WIDE
	DEFB	6	;4 BYTES TALL
	DEFB	01111000B	
	DEFB	11011100B
	DEFB	10111100B	
	DEFB	10111100B
	DEFB	11111100B
	DEFB	01111000B

;***************
;* BALL LIMITS *
;***************

BLMT	DEFB	0	;X LOWER LIMIT (LEFT EDGE)
	DEFB	153	;X UPPER LIMIT (RIGHT EDGE)
			;-8 FOR 8 PIXEL WIDE BALL
	DEFB	0	;Y LOWER LIMIT (TOP EDGE)
	DEFB	89	;Y UPPER LIMIT (BOTTOM EDGE)
			;-6 FOR 6 PIXEL HIGH BALL
;***********
;* CRITTER *
;***********

CRIT1	DEFB	0	;NO X/Y OFFSET
	DEFB	0
	DEFB	2	;2 BYTES WIDE
	DEFB	8	;8 BYTES HIGH
	DEFW	0A00AH
	DEFW	9826H	;3 COLOURS
	DEFW	0AAAAH
	DEFW	0A82AH
	DEFW	2008H
	DEFW	0820H
	DEFW	2008H
	DEFW	0000H

;******************
;* CRITTER LIMITS *
;******************

CLMT	DEFB	0,152	;X LIMITS
	DEFB	0,88	;Y LIMITS
	
