Advertisement
Runer112

Untitled

Jul 19th, 2011
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BlackLine:
  2.     call    LineIntro       ; (l,e) = (x1,y1)
  3.     ret nc          ; (c,a) = (x2,y2)
  4.     cp  h
  5.     jr  c,__BlackLineHoriz  ; Line is rather horizontal than vertical
  6. __BlackLineVert:
  7.     ld  b,l         ; Pixel counter
  8.     inc b
  9.     rra             ; nc at this point so (A=E/2)
  10. __BlackLineVLoop:
  11.     push    af
  12.     ld  a,(ix+0)
  13.     or  c           ; Writing pixel to current position
  14.     ld  (ix+0),a
  15.     pop af
  16.     add ix,de
  17.     sub h           ; Handling gradient
  18.     jr  nc,__BlackLineVNext
  19.     add a,l
  20.     rrc c           ; Rotating mask
  21.     jr  nc,__BlackLineVNext ; Handling byte boundary
  22.     inc ix
  23. __BlackLineVNext:
  24.     djnz    __BlackLineVLoop
  25.     ret
  26. __BlackLineHoriz:
  27.     ld  b,h         ; Pixel counter
  28.     inc b
  29.     ld  a,h         ; Setting up gradient counter
  30.     srl a
  31. __BlackLineHLoop:
  32.     push    af          ; Saving A
  33.     ld  a,(ix+0)
  34.     or  c           ; Writing pixel to current position
  35.     ld  (ix+0),a
  36.     pop af          ; Recalling A
  37.     rrc c           ; Rotating mask
  38.     jr  nc,__BlackLineHSkip ; Handling byte boundary
  39.     inc ix
  40. __BlackLineHSkip:
  41.     sub l           ; Handling gradient
  42.     jr  nc,__BlackLineHNext
  43.     add a,h
  44.     add ix,de
  45. __BlackLineHNext:
  46.     djnz __BlackLineHLoop
  47.     ret
  48.  
  49. WhiteLine:
  50.     call    LineIntro       ; (l,e) = (x1,y1)
  51.     ret nc          ; (c,a) = (x2,y2)
  52.     push    af
  53.     ld  a,c
  54.     cpl
  55.     ld  c,a
  56.     pop af
  57.     cp  h
  58.     jr  c,__WhiteLineHoriz  ; Line is rather horizontal than vertical
  59. __WhiteLineVert:
  60.     ld  b,l         ; Pixel counter
  61.     inc b
  62.     rra             ; nc at this point so (A=E/2)
  63. __WhiteLineVLoop:
  64.     push    af
  65.     ld  a,(ix+0)
  66.     and c           ; Writing pixel to current position
  67.     ld  (ix+0),a
  68.     pop af
  69.     add ix,de
  70.     sub h           ; Handling gradient
  71.     jr  nc,__WhiteLineVNext
  72.     add a,l
  73.     rrc c           ; Rotating mask
  74.     jr  c,__WhiteLineVNext  ; Handling byte boundary
  75.     inc ix
  76. __WhiteLineVNext:
  77.     djnz    __WhiteLineVLoop
  78.     ret
  79. __WhiteLineHoriz:
  80.     ld  b,h         ; Pixel counter
  81.     inc b
  82.     ld  a,h         ; Setting up gradient counter
  83.     srl a
  84. __WhiteLineHLoop:
  85.     push    af          ; Saving A
  86.     ld  a,(ix+0)
  87.     and c           ; Writing pixel to current position
  88.     ld  (ix+0),a
  89.     pop af          ; Recalling A
  90.     rrc c           ; Rotating mask
  91.     jr  c,__WhiteLineHSkip  ; Handling byte boundary
  92.     inc ix
  93. __WhiteLineHSkip:
  94.     sub l           ; Handling gradient
  95.     jr  nc,__WhiteLineHNext
  96.     add a,h
  97.     add ix,de
  98. __WhiteLineHNext:
  99.     djnz __WhiteLineHLoop
  100.     ret
  101.  
  102. LineIntro:
  103.     cp  64
  104.     ret nc
  105.     ld  b,a
  106.     ld  a,e
  107.     cp  64
  108.     ret nc
  109.     ld  d,l
  110.     ld  l,b
  111.  
  112.     ld  a,d
  113.     cp  96
  114.     ret nc
  115.     ld  a,c
  116.     cp  96
  117.     ret nc
  118.  
  119.     ld  h,a
  120.     sub d
  121.     jr  nc,__LineIntroSkipRev
  122.     ex  de,hl
  123.     neg
  124. __LineIntroSkipRev:
  125.     push    af          ; Saving DX (it will be popped into DE below)
  126.     ld  a,d         ; IX+=D/8+E*12 (actually E*4+E*4+E*4)
  127.     rra
  128.     rra
  129.     rra
  130.     and %00011111
  131.     ld  c,a
  132.     ld  b,0
  133.     add ix,bc
  134.     ld  a,e
  135.     add a,a
  136.     add a,a
  137.     ld  c,a
  138.     add ix,bc
  139.     add ix,bc
  140.     add ix,bc
  141.     ld  a,d         ; Calculating the starting pixel mask
  142.     and %00000111
  143.     inc a
  144.     ld  b,a
  145.     ld  a,%00000001
  146. __LineIntroMaskLoop:
  147.     rrca
  148.     djnz    __LineIntroMaskLoop
  149.     ld  c,a
  150.     ld  a,l         ; Calculating delta Y and negating the Y increment if necessary
  151.     sub e           ; This is the last instruction for which we need the original data
  152.     ld  de,12
  153.     jr  nc,__LineIntroSkipNeg
  154.     ld  de,-12
  155.     neg
  156. __LineIntroSkipNeg:
  157.     pop hl          ; Recalling DX
  158.     ld  l,a         ; D=DX, E=DY
  159.     scf
  160.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement