Advertisement
Guest User

Untitled

a guest
Dec 7th, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. p_HorizLine:
  2. .db __HorizLineEnd-$-1
  3. ld de,plotSScreen
  4.  
  5. x_HorizLineEntry:
  6. ;; de=buff, hl=x2, (sp)=ret, (sp+2)=x1, (sp+4)=y
  7. pop af
  8. pop bc
  9. ld h,c
  10. pop bc
  11. push af
  12.  
  13. ;; c=y, de=buff, h=x1, l=x2
  14. ;; Check if x1 is offscreen left; if so, note and fix it
  15. ld b,0
  16. ld a,h
  17. rla
  18. jr nc,$+3
  19. ld h,b
  20.  
  21. ;; carry=x1 offscreen, b=0, c=y, de=buff, h=left-fixed x1, l=x2
  22. ;; Check if x2 is offscreen left; if so, abort if x1 was too, then fix it
  23. bit 7,l
  24. jr z,$+4
  25. ret c
  26. ld l,b
  27.  
  28. ;; b=0, c=y, de=buff, h=left-fixed x1, l=left-fixed x2
  29. ;; Check if x1 is offscreen right, and if so, abort if x2 is too, then fix it
  30. ld a,95
  31. cp h
  32. jr nc,$+5
  33. cp l
  34. ret nc
  35. ld h,a
  36.  
  37. ;; a=95, b=0, c=y, de=buff, h=fixed x1, l=left-fixed x2
  38. ;; Check if x2 is offscreen right, and if so, fix it
  39. cp l
  40. jr nc,$+3
  41. ld l,a
  42.  
  43. ;; X Clipping complete; x1 and x2 guaranteed to be onscreen
  44. ;; a=95, b=0, c=y, de=buff, h=x1, l=x2
  45. ;; Ensure that x1<=x2
  46. ld a,h
  47. cp l
  48. jr c,$+5
  49. ld a,l
  50. ld l,h
  51. ld h,a
  52.  
  53. x_HorizLineEntry2:
  54. ;; a=x1, b=0, c=y, de=buff, h=x1, l=x2
  55. ;; Abort if y is offscreen, add y*12 to buffer, and add x1/8 to buffer
  56. ;; y is rotated left while x1 is rotated right so rra can be used for x1
  57. sla c
  58. ret c
  59. rra
  60. sla c
  61. ret c
  62. rra
  63. ex de,hl
  64. add hl,bc
  65. rra
  66. add hl,bc
  67. add hl,bc
  68. ld c,a
  69. add hl,bc
  70.  
  71. ;; y no longer needed
  72. ;; a=x1/8, b=0, c=x1/8, d=x1, e=x2, hl=y*12+(x/8)+buff
  73. ld c,7
  74. ld a,d
  75. and c
  76. jr z,__HorizLineLeft8
  77. ld b,a
  78. ld a,1
  79. __HorizLineLeftLoop:
  80. rrca
  81. djnz __HorizLineFirstLoop
  82. __HorizLineLeft8:
  83. dec a
  84. or (hl)
  85. ld b,a
  86. ld a,d
  87. or c
  88. inc c
  89. sub e
  90. jr c,__HorizLineRight ;???
  91. __HorizLineMidLoop:
  92. ld (hl),b
  93. inc hl
  94. ld b,$FF
  95. sub c
  96. jr nc,__HorizLineMidLoop
  97. __HorizLineRight:
  98. add a,c ;???
  99. ret z ;???
  100. ld b,a
  101. ld a,1
  102. __HorizLineRightLoop:
  103. rlca
  104. djnz __HorizLineRightLoop
  105. dec a
  106. and b
  107. or (hl)
  108. ld (hl),a
  109. ret
  110. __HorizLineEnd:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement