Advertisement
Runer112

Fast grayscale routine for thepenguin77

Jul 10th, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;###################################
  2.  
  3. #define FWAIT   in f, (c) \ jp m, $-2
  4.  
  5. grayCopy:
  6.     push    ix
  7.     ld  bc, (grayBC)
  8.     ld  de, (grayDE)
  9.  
  10.     ld  ixl, C0h
  11.  
  12. outerGray:
  13.     ld  a, ixl
  14.     sub 40h
  15.     FWAIT
  16.     out ($10), a
  17.  
  18.     ld  a, $20
  19.     FWAIT
  20.     out ($10), a
  21.  
  22.     ld  ixh, 4
  23.  
  24. grayLoop:
  25.     ld  a, (hl)
  26.     inc hl
  27.     xor (hl)
  28.     and b
  29.     xor (hl)
  30.     inc hl
  31.    
  32.     FWAIT
  33.     out ($11), a
  34.  
  35.     ld  a, (hl)
  36.     inc hl
  37.     xor (hl)
  38.     and d
  39.     xor (hl)
  40.     inc hl
  41.  
  42.     FWAIT
  43.     out ($11), a
  44.  
  45.     ld  a, (hl)
  46.     inc hl
  47.     xor (hl)
  48.     and e
  49.     xor (hl)
  50.     inc hl
  51.    
  52.     FWAIT
  53.     out ($11), a
  54.  
  55.     dec ixh
  56.     jp  nz, grayLoop
  57.  
  58.     ld  a, b
  59.     ld  b, d
  60.     ld  d, e
  61.     ld  e, a
  62.  
  63.     inc ixl
  64.     jp  nz,outerGray
  65.  
  66.  
  67.  
  68. grayQuit:
  69.     ld  (grayBC), bc
  70.     ld  (grayDE), de
  71.     pop ix
  72.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement