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
/
ARRAY2.ZZ0
/
ARRAY2.Z80
Wrap
Text File
|
2000-06-30
|
3KB
|
109 lines
;Library Name: ARRAYLIB
;Module Name: REVERSE
;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 reverse
;This module contains the following routines:
public arinvert
arinvert:
;invert the order of the bits in each byte of a (dumaplen)
;byte disk/user map from row 0, column 0 to the end.
ld hl,(bitmap) ;address of row 0, col 0
ld a,h
or a,l
ld a,1 ;error code - undef array
scf ;in case hl = 0 (undef array)
ret z ;return if undef array
ld a,(dumaplen)
ld b,a ;length of du map
invrt1: call armirror ;invert bits at (hl). bc preserved
inc hl
djnz invrt1
ret
;*************************************
armirror:
;invert the order of the bits at (hl)
;input: hl = addr of byte to invert
;output: mirror image in (hl)
; swap bits 0-7,1-6,2-5,3-4
; reg a is destroyed
;all other registers preserved
;test for common symetrical cases and
;do nothing (it's faster)
ld a,(hl)
or a ;00000000b?
ret z
cp 0ffh ;11111111b?
ret z
;probably not symetrical. make mirror image.
push bc
rra ;lsb->cy, rotate right
rl c ;cy-lsb, rotate left
rra ;..repeat 7 more times
rl c
rra
rl c ;this code would be shorter
rra ;..if done in a loop, but
rl c ;..also slower
rra
rl c
rra
rl c
rra
rl c
rra
rl c ;reversed pattern in c
ld (hl),c ;store at memory loc
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