;Library Name: ARRAYLIB ;Module Name: AWRITE ;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 awrite ;This module contains the following routines: public arrfr0$e,arrfrc$e,arfrc1$2,arrc1$c2 ;..and uses the following external routines: ext arrxltrc,visit arrfr0$e: ;write the contents of a into the array, ;starting with row 0, column 0 and ending ;with the last byte in the array ;on entry, ; a = value with which to fill array ;all registers destroyed on exit ld bc,0 ;row 0, col 0 ;fall through.. ;********************************************** arrfrc$e: ;write as above, starting at row(b), col(c) ;on entry, ; a = value with which to fill array ; b = starting row number ; c = starting column number ;all registers destroyed on exit ex af,af' ld a,(hirow) ld d,a ld a,(hicol) ld e,a ex af,af' ;fall through.. ;********************************************** arfrc1$2: ;write the contents of a into contiguous array ;locations starting with row(b), column(c) and ;ending with row(d), column(e). ;on entry, ; a = value with which to fill array ; b = starting row number ; c = starting column number ; d = ending row number ; e = ending column number ;all registers destroyed on exit ; returns CY set if undefined array, address out of range, or ; starting address greater than ending address. ex af,af' push de call arrxltrc ;bc->start addr in hl ld d,h ld e,l ;..and in de pop bc ;ending r,c jr c,xerc1$2 ;jmp if bad addr or undef. array call arrxltrc ;ending addr in hl jr c,xerc1$2 ;jmp if bad addr or a ;calc number of bytes sbc hl,de ;..to fill ld a,3 ;possible error code: jr c,xerc1$2 ;jmp if start > end addr ld b,h ;transfer number of fill bytes ld c,l ;..to bc, ready for ldir ld h,d ;copy start address to hl ld l,e inc de ;destination for chase ex af,af' ld (hl),a ;install the fill byte ldir ;chase it through (bc) bytes xor a xerc1$2: ret ;********************************************** arrc1$c2: ;visit 1 or more contiguous columns in a row, ;from column c1 through column c2 ;on entry, arvisiti: has already been called to ;establish the function to perform, and ; b = starting row number ; c = starting column number ; e = ending column number ;on exit, ;registers preserved: bc, de ;CY set if undefined array, address out of range, or ending address ; less than starting address. ;all others may be destroyed ld a,e sub c ;end addr - start addr ld a,3 ;error code if start>end ret c ;abort if start > end push bc push de call arrxltrc ;start addr in hl jr c,xerc1c2 ;jmp if undef array or bad addr push hl ;addr 1 ld d,a ;to ignore row number ld b,a sbc hl,bc ;hl -> start of row adc hl,de ;hl -> col c2 pop de ex de,hl ;c1 addr in hl, c2 in de call visit xor a ;clear carry xerc1c2: ;here with cy set on error pop de pop bc ret ;********************************************** 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