GetPixelLoc.z80 554 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. pixLUT:
  2. .db $80,$40,$20,$10,$08,$04,$02,$01
  3. GetPixelLoc:
  4. ;Input:
  5. ; b is X
  6. ; c is y
  7. ;Output:
  8. ; HL points to byte
  9. ; A is the mask
  10. ; nc if not computed, c if computed
  11. ;Speed: 192+17{1,2,3,4,5,6,7,8}
  12. ;Avg: 268.5cc
  13. ;185cc
  14. ld a,c
  15. cp 64
  16. ret nc
  17. add a,a
  18. add a,a
  19. ld c,a
  20. ld a,b
  21. cp 96
  22. ret nc
  23. ld b,0
  24. ld hl,(gbuf_temp)
  25. add hl,bc
  26. add hl,bc
  27. add hl,bc
  28. ld c,a
  29. srl c
  30. srl c
  31. srl c
  32. add hl,bc
  33. and 7
  34. ld b,pixLUT>>8
  35. add a,pixLUT&255
  36. ld c,a
  37. #if pixLUT&255>249
  38. jr nc,$+3
  39. inc b
  40. #endif
  41. ld a,(bc)
  42. scf
  43. ret