home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / z3util / array10b.lbr / ARRAY2.ZZ0 / ARRAY2.Z80
Encoding:
Text File  |  1993-06-07  |  2.9 KB  |  112 lines

  1. ;Library Name: ARRAYLIB
  2. ;Module Name: REVERSE
  3. ;Author: Al Hawley
  4. ;Date: 06 Mar 1987
  5. ;Version number: 1.0a
  6. ;Previous version: 1.0 dated 4 March 1987
  7.  
  8. ;Version History:
  9.     
  10. ;Program Function: ARRAYLIB is a collection of subroutines which
  11. ;    implement the management of byte arrays in programs written
  12. ;    for Z80 or HD64180 based computers. This module is one of the
  13. ;    set, and may require the presence of others.
  14.  
  15. ;***************************************************
  16. ;        COPYRIGHT NOTICE
  17. ;ARRAYLIB is copyright by A. E. Hawley on March 4, 1987.
  18. ;It may be freely distributed, but it must not be sold 
  19. ;either separately or as part of a package without the 
  20. ;written consent of the author.  The author may be reached 
  21. ;via electronic mail at the Ladera Z-Node in Los Angeles,
  22. ;213-670-9465, or by U.S. Mail at:
  23. ;
  24. ;    6032 Chariton Ave.
  25. ;    Los Angeles, CA. 90056
  26. ;    Voice Phone: 213-649-3575
  27. ;
  28. ;        RELEASE NOTICE
  29. ;ARRAYLIB is released for beta test through the Z-system 
  30. ;users group Z-SIG.  It may be reached through the 
  31. ;Lillipute Z-Node in Chicago, 312-649-1730.
  32.  
  33. ;***************************************************
  34.  
  35.     name reverse
  36. ;This module contains the following routines:
  37.     public arinvert
  38.  
  39. arinvert:
  40. ;invert the order of the bits in each byte of a (dumaplen)
  41. ;byte disk/user map from row 0, column 0 to the end.
  42.     ld    hl,(bitmap)    ;address of row 0, col 0
  43.     ld    a,h
  44.     or    a,l
  45.     ld    a,1        ;error code - undef array
  46.     scf            ;in case hl = 0 (undef array)
  47.     ret    z        ;return if undef array
  48.  
  49.     ld    a,(dumaplen)
  50.     ld    b,a        ;length of du map
  51. invrt1:    call    armirror    ;invert bits at (hl). bc preserved
  52.     inc    hl
  53.     djnz    invrt1
  54.     ret
  55.  
  56. ;*************************************
  57.  
  58. armirror:
  59. ;invert the order of the bits at (hl)
  60. ;input: hl = addr of byte to invert
  61. ;output: mirror image in (hl)
  62. ;  swap bits 0-7,1-6,2-5,3-4
  63. ; reg a is destroyed
  64. ;all other registers preserved
  65.  
  66. ;test for common symetrical cases and
  67. ;do nothing (it's faster)
  68.     ld    a,(hl)
  69.     or    a    ;00000000b?
  70.     ret    z
  71.     cp    0ffh    ;11111111b?
  72.     ret    z
  73. ;probably not symetrical. make mirror image.
  74.     push    bc
  75.     rra        ;lsb->cy, rotate right
  76.     rl    c    ;cy-lsb, rotate left
  77.     rra        ;..repeat 7 more times
  78.     rl    c
  79.     rra
  80.     rl    c    ;this code would be shorter
  81.     rra        ;..if done in a loop, but
  82.     rl    c    ;..also slower
  83.     rra
  84.     rl    c
  85.     rra
  86.     rl    c
  87.     rra
  88.     rl    c
  89.     rra
  90.     rl    c    ;reversed pattern in c
  91.     ld    (hl),c    ;store at memory loc
  92.     pop    bc
  93.     ret
  94.  
  95. ;**********************************************
  96.     COMMON /ARDAT/
  97.  
  98. ;COMMON data area - contains default values for a 64
  99. ;byte array useful for disk/user bitmapping.
  100. bitmap:    dw    0    ;..filled in by ARRAYDEF
  101. hicol:    dw    3    ;4 columns: 0,1,2,3
  102. hirow:    dw    15    ;16 rows (0....15)
  103. dumaplen:
  104.     dw    64    ;(3+1)*(15+1)
  105.  
  106. maxdu:    dw    0    ;transient d/u data
  107. curloc:    dw    0    ;NDR entry pointer
  108.  
  109. ;**********************************************
  110.  
  111.     end
  112.