home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug094.arc
/
FIX-256.ARC
/
QUIX.MAC
< prev
next >
Wrap
Text File
|
1988-06-14
|
8KB
|
587 lines
; Quix, by Vaughan Clarkson 12/1/88
.z80
aseg
org 100h
bios equ 0000h
bdos equ 0005h
screen equ 0f000h
grafix equ 0f800h
row equ 64
vmlatch equ 1ch
attrib equ 144
char equ 16
c_port equ 8
c_swtch equ 40h
speakr equ 2
outbit equ 40h
pstring equ 9
; The equates below are starting options and may be freely altered.
no_line equ 120 ; no of lines in the quix
x1_1st equ 80 ; initial x1 coordinate
y1_1st equ 120 ; initial y1 coordinate
x2_1st equ 200 ; initial x2 coordinate
y2_1st equ 20 ; initial y2 coordinate
v1x1st equ 3 ; initial x1 increment
v1y1st equ 3 ; initial y1 increment
v2x1st equ 4 ; initial x2 increment
v2y1st equ 2 ; initial y2 increment
begin: ld hl,screen+32*row-1
ld (hl),-1
ld a,attrib ; Test whether Premium model or later
out (vmlatch),a
ld (hl),0
ld a,80h
out (vmlatch),a
ld a,(hl)
or a
jr nz,start
ld de,m_prem ; 'QUIX works only on Premium ...'
ld c,pstring
call bdos
jp bios
start: ld hl,screen
ld (hl),' '
ld de,screen+1
ld bc,32*row-1
ldir
call reform
ld bc,0
rfwait: dec bc
ld a,b
or c
jp nz,rfwait
ld b,8
ld a,80h
clgrfx: push bc
out (vmlatch),a
ld hl,grafix
ld (hl),0
ld de,grafix+1
ld bc,128*char
ldir
inc a
pop bc
djnz clgrfx
ld a,80h ; draw border
s_bord: out (vmlatch),a
ld hl,grafix
ld (hl),80h
ld de,grafix+1
ld bc,char-1
ldir
ld hl,grafix+63*char
ld (hl),1
ld de,grafix+63*char+1
ld bc,char
ldir
inc a
cp 88h
jr nc,tbbord
ld (hl),80h
ld bc,char-1
ldir
ld hl,grafix+127*char
ld (hl),1
ld de,grafix+127*char+1
ld bc,char-1
ldir
jr s_bord
tbbord: xor a
ld (de),a
ld a,80h
out (vmlatch),a
ld hl,grafix
ld de,char
ld b,64
ld a,-1
topbrd: ld (hl),a
add hl,de
djnz topbrd
ld a,87h
out (vmlatch),a
ld hl,grafix+char-1
ld b,64
ld a,-1
botbrd: ld (hl),a
add hl,de
djnz botbrd
ld a,c_swtch ; set up initial screen colours
out (c_port),a
ld hl,grafix
ld (hl),12 ; light blue on black
ld de,grafix+1
ld bc,15*row
ldir
ld (hl),0afh ; white on light green
ld bc,row-1
ldir
xor a
out (c_port),a
ld b,8 ; set up screen & attributes
ld hl,screen
ld de,screen+1
ld a,attrib
out (vmlatch),a
xor a
setatt: push bc
ld bc,2*row
ld (hl),a
ldir
inc a
pop bc
djnz setatt
ld a,80h
out (vmlatch),a
ld hl,screen
ld c,8
setscn: ld b,2*row
ld a,80h
setrow: ld (hl),a
inc a
inc hl
djnz setrow
dec c
jr nz,setscn
ld hl,m_quix ; 'QUIX demo ...'
ld de,screen+15*row+10
ld bc,35
ldir
ld hl,ltable
ld (hl),-1
ld de,ltable+1
ld bc,no_line*8-1
ldir
ld hl,x1_1st
ld (from_x),hl
ld hl,y1_1st
ld (from_y),hl
ld hl,x2_1st
ld (to_x),hl
ld hl,y2_1st
ld (to_y),hl
ld hl,from_x
ld de,ltable+no_line*8
ld bc,8
ldir
ld hl,v1x1st
ld (comp1x),hl
ld hl,v1y1st
ld (comp1y),hl
ld hl,v2x1st
ld (comp2x),hl
ld hl,v2y1st
ld (comp2y),hl
ld ix,ltable
qxloop: ld a,-1 ; draw the quix
ld (set),a
push ix
pop de
ld hl,from_x
ld bc,8
ldir
call line
ld de,8
add ix,de
ld l,(ix)
ld h,(ix+1)
inc hl
ld a,h
or l
jp z,qxinit
xor a
ld (set),a
push ix
pop hl
ld de,from_x
ld bc,8
ldir
call line
qxinit: ld l,(ix-8)
ld h,(ix-7)
ld de,(comp1x)
add hl,de
ld (from_x),hl
call fix_x
jp m,x1_ok
ld (comp1x),hl
ld (from_x),bc
call beep
x1_ok: ld l,(ix-6)
ld h,(ix-5)
ld de,(comp1y)
add hl,de
ld (from_y),hl
call fix_y
jp m,y1_ok
ld (comp1y),hl
ld (from_y),bc
call beep
y1_ok: ld l,(ix-4)
ld h,(ix-3)
ld de,(comp2x)
add hl,de
ld (to_x),hl
call fix_x
jp m,x2_ok
ld (comp2x),hl
ld (to_x),bc
call beep
x2_ok: ld l,(ix-2)
ld h,(ix-1)
ld de,(comp2y)
add hl,de
ld (to_y),hl
call fix_y
jp m,y2_ok
ld (comp2y),hl
ld (to_y),bc
call beep
y2_ok: push ix
pop hl
ld de,ltable+no_line*8
or a
sbc hl,de
jp c,qxloop
ld ix,ltable
ld hl,from_x
ld de,ltable+no_line*8
ld bc,8
ldir
jp qxloop
fix_x: ld bc,1
or a
sbc hl,bc
jp p,xbounc
call neg16
xor a
ret
xbounc: ld bc,510
or a
sbc hl,bc
ret m
call neg16
xor a
ret
fix_y: ld bc,1
or a
sbc hl,bc
jp p,ybounc
call neg16
xor a
ret
ybounc: ld bc,238
or a
sbc hl,bc
ret m
call neg16
xor a
ret
neg16: ld hl,0 ; Negate de and place result in hl
or a
sbc hl,de
ret
line:
; This routine draws a straight line from (from_x, from_y) to (to_x, to_y)
call calcxy
ex af,af'
ld a,(set)
ex af,af'
ld hl,(from_x)
ld de,(to_x)
call subabs
ld b,h
ld c,l
ld hl,pix_lt
jp nc,cupok
ld hl,pix_rt
cupok: ld (vect_1),hl
ld hl,(from_y)
ld de,(to_y)
call subabs
ld d,h
ld e,l
ld hl,pix_up
jp nc,crtok
ld hl,pix_dn
crtok: ld (vect_2),hl
ld h,b
ld l,c
or a
sbc hl,de
jp nc,swaphd
ld hl,(vect_1)
ld iy,(vect_2)
ld (vect_2),hl
ld (vect_1),iy
ld h,b
ld l,c
ex de,hl
ld b,h
ld c,l
swaphd: push bc
push bc
ld hl,0
srl b
rr c
or a
sbc hl,bc
push hl
pop iy
dec iy
pop bc
ld hl,0
or a
sbc hl,bc
ld b,h
ld c,l
pop hl
ld a,h
or l
jr z,conend
smline: exx
call c_plot
smmove: call pix_rt
exx
add iy,de
jp nc,endmov
add iy,bc
exx
bgmove: call pix_dn
exx
endmov: dec hl
ld a,h
or l
jp nz,smline
conend: exx
call c_plot
exx
ret
vect_1 equ smmove+1
vect_2 equ bgmove+1
calcxy: exx
ld hl,(from_x) ; calculate initial data for line drawing
ld a,7
and l
ld b,a
ld a,80h
jr z,noshft
shftpx: srl a
djnz shftpx
noshft: ld c,a
ld a,0f8h
and l
ld l,a
add hl,hl
ex de,hl
ld hl,(from_y)
ld a,15
and l
ld b,a
ld a,0e0h
and l
rlca
rlca
rlca
ld (bank),a
or 80h
out (vmlatch),a
bit 4,l
ld l,b
ld h,0
jr z,hlfblk
ld h,4
hlfblk: add hl,de
ld de,grafix
add hl,de
exx
ret
; The next two routines set and reset the pixel at the current location
c_plot: ex af,af'
or a
jp z,creset
ex af,af'
ld a,c
or (hl)
ld (hl),a
ret
creset: ex af,af'
ld a,c
or (hl)
xor c
ld (hl),a
ret
; The following routines, pix_lt, pix_rt, pix_up, pix_dn, move the current
; pixel location left, right, up and down respectively
pix_lt: sla c
ret nc
ld c,1
ld de,-char
add hl,de
ret
pix_rt: srl c
ret nc
ld c,80h
ld de,char
add hl,de
ret
pix_up: ld a,b
or a
jr z,chr_up
dec b
dec hl
ret
chr_up: ld de,char-1
ld b,e
add hl,de
ld a,4
xor h
ld h,a
bit 2,h
ret z
ld a,(bank)
dec a
ld (bank),a
or 80h
out (vmlatch),a
ret
pix_dn: ld a,b
inc a
cp char
jr nc,chr_dn
ld b,a
inc hl
ret
chr_dn: xor a
ld b,a
ld de,-char+1
add hl,de
ld a,4
xor h
ld h,a
bit 2,h
ret nz
ld a,(bank)
inc a
ld (bank),a
or 80h
out (vmlatch),a
ret
subabs: ld a,h ;perform absolute of hl - de
cp d
jp c,abshls
jp nz,absdes
ld a,l
cp e
jp c,abshls
absdes: or a
sbc hl,de
ret
abshls: ex de,hl
or a
sbc hl,de
scf
ret
beep: ld hl,begin ; make a clicking noise
ld c,speakr
ld b,0
otir
xor a
out (speakr),a
ld a,r ; get pseudo-random number
and 7 ; and decide whether to change colour
ret nz
ld a,r
and 38h
srl a
srl a
srl a
ld hl,q_col
add a,(hl)
and 7
ld (hl),a
add a,8
ld b,a
ld a,c_swtch
out (c_port),a
ld hl,grafix
ld (hl),b
ld de,grafix+1
ld bc,15*row-1
ldir
xor a
out (c_port),a
ret
reform: ld hl,v_64+15 ;routine to set up 64*16
refrm2: push bc
push hl
ld b,10h
format: ld a,b
dec a
out (0ch),a
ld a,(hl)
out (0dh),a
dec hl
djnz format
ld b,4bh
call leee3
pop hl
pop bc
ret
leee3: push hl ;routine for 64*16
leee4: ld hl,007ah
leee7: dec hl
ld a,h
or l
jr nz,leee7
djnz leee4
pop hl
ret
v_64: db 6bh,64,51h,37h,12h,9,16,12h,48h,0fh,2fh,0fh,0,0,0,0
m_prem: db 'QUIX works only on Premium and later model Microbees.'
db 0dh,0ah,'$'
m_quix: db 'QUIX demo, by Vaughan Clarkson 1988'
from_x: dw 0
from_y: dw 0
to_x: dw 0
to_y: dw 0
bank: db 0
set: db 0
q_col: db 0
comp1x: dw 0
comp1y: dw 0
comp2x: dw 0
comp2y: dw 0
ltable: ds (no_line+1)*8,0
end begin