home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
JSAGE
/
ZSUS
/
PROGPACK
/
ARRAYS10.LBR
/
ARRAYC.ZZ0
/
ARRAYC.Z80
Wrap
Text File
|
2000-06-30
|
4KB
|
148 lines
;Library Name: ARRAYLIB
;Module Name: AXLATE
;Author: Al Hawley
;Date: 31 Mar 1987
;Version number: 1.0c
;Version History:
;Program Function: ARRAYLIB is a collection of subroutines which
; implement the management of byte arrays in programs written
; for Z80 or HD64180 based computers. This module is one of the
; set, and may require the presence of others.
;***************************************************
; COPYRIGHT NOTICE
;ARRAYLIB is copyright by A. E. Hawley on March 4, 1987.
;It may be freely distributed, but it must not be sold
;either separately or as part of a package without the
;written consent of the author. The author may be reached
;via electronic mail at the Ladera Z-Node in Los Angeles,
;213-670-9465, or by Voice Phone at: 213-649-3575
;
;***************************************************
MACLIB ARRHDR
name axlate
;This module contains the following routines:
public arxltbit,arrxltrc
;..and uses the following external routines:
ext mulhd ;from SYSLIB or HD180
arxltbit:
;translates a row,bit address to a column address
; and a bit position for a row in the matrix.
;on input,
; b = row number
; c = bit number (0...max allowed)
;on exit,
; b = row number
; c = column number
; e = bit position (0-7) in column (c)
; a = e
;other registers are preserved
;
;this is an integer division by 8 (bits/byte),
; accomplished by shifting c right 3 times.
;the bit position is the 3 least significant bits
; of reg c, which are first saved in reg e.
ld a,c
and a,7 ;bit position
ld e,a ;offset, for return
srl c ;divide by 8 (bits/byte)
srl c
srl c
ld a,(hicol)
cp a,c ;=< max num of columns?
ld a,e
ret ;ret cy set if out of range
;**********************************************
arrxltrc:
;translate row/column input data to the absolute
;address of the byte being specified.
;on input,
; b = row number
; c = column number
;on exit,
; hl = address of the byte
;error condition:
; no error: a=0, z, nc
; if error: a = error code, carry set
; a = 1 if bitmap not yet defined
; a = 2 if address is out of range
;bc and de are preserved
push bc
push de
ld hl,rownum ;save requested indexes
ld (hl),b ;in local memory
inc hl
inc hl
ld (hl),c
;test for row number beyond array
ld a,(hirow)
cp a,b ;b must be =< (hirow)
ld a,2 ;in case of error, code 2
jr c,xerror ;if address out of bounds
;test for undefined bitmap
ld hl,(bitmap)
ld a,h
or a,l ;test. 0 if undefined
ld a,1 ;error code
jr z,xerror ;if bitmap undefined
ld de,(hicol) ;highest column number
inc de ;number of columns
;calculate relative address of array element
ld hl,(rownum) ;row number
call mulhd ;multiply row number by cols/row
;overflow test not needed, high bytes are 00.
ld bc,(colnum)
add hl,bc ;relative addr of element
;calc absolute address of the array element
ld de,(bitmap) ;base addr of bitmap
add hl,de ;absolute addr of target byte
xor a ;reset carry
pop de
pop bc
ret ;normal return
xerror: pop de
pop bc
scf
ret ;error return, cy set
rownum: dw 0
colnum: dw 0
;**********************************************
IF ZAS
COMMON ;common block for ZAS
ELSE
COMMON /ADATA/ ;common block for M80, SLR
ENDIF
;COMMON data area - contains default values for a 64
;byte array useful for disk/user bitmapping.
bitmap: ds 2 ;..filled in by ARRAYDEF
hicol: ds 2 ;default is 4 columns: 0,1,2,3
hirow: ds 2 ;default is 16 rows (0....15)
dumaplen:
ds 2 ;default is (3+1)*(15+1)
maxdu: ds 2 ;transient d/u data
curloc: ds 2 ;NDR entry pointer
;**********************************************
end