Advertisement
Guest User

ConwayGfx.asm

a guest
Oct 7th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. DrawCell: ; Draws cell at x=b, y=c, color=A; destroys AF, HL, DE
  2. push bc
  3. push af
  4. dec b
  5. dec c
  6. or a
  7. sbc hl,hl
  8. ld l,b
  9. call HLMult8
  10. inc hl
  11. push hl
  12. pop de ; end of X
  13. ld a,c
  14. call AMult8
  15. inc a
  16. ld l,a ; end of Y
  17. pop af
  18. ld h,CellSize-2 ; height
  19. ld bc,CellSize-2 ; width
  20. push de
  21. push hl
  22. call FillRect
  23. pop hl
  24. pop de
  25. pop bc
  26. ret
  27.  
  28. RedrawCell:
  29. call GetCell
  30. ld a,(hl)
  31. cp OnCellData
  32. call z,LdOnColor
  33. call nz,LdOffColor
  34. jp DrawCell
  35.  
  36. DrawCursor:
  37. push bc
  38. call GetCell
  39. ld a,(hl)
  40. cp OnCellData
  41. call z,LdOnColor
  42. call nz,LdOffColor
  43. push af
  44. ld a,CursorColor
  45. call DrawCell
  46. pop af
  47. inc de ; X
  48. inc l ; Y
  49. ld bc,CellSize-4 ; Width
  50. dec h
  51. dec h
  52. call FillRect
  53. pop bc
  54. xor a ; Prevents accidental "keypresses"
  55. ret
  56.  
  57. LdOnColor:
  58. ld a,OnCellColor
  59. ret
  60. LdOffColor:
  61. ld a,OffCellColor
  62. ret
  63.  
  64. RenderBoard:
  65. ld hl,Board+BoardSize
  66. ld b,Rows
  67. RenderRowLoop:
  68. push bc
  69. ld c,b
  70. ld b,Cols
  71. RenderColLoop:
  72. push bc
  73. dec hl
  74. push hl
  75.  
  76. call RedrawCell
  77.  
  78. pop hl
  79. pop bc
  80. djnz RenderColLoop
  81. pop bc
  82. djnz RenderRowLoop
  83. ret
  84.  
  85. FillRect: ; A=color, BC=width, DE=x, H=height, L=y
  86. ld (FillRect_Color),a
  87. ld a,h
  88. ld h,160
  89. mlt hl
  90. add hl,hl
  91. add hl,de
  92. ld de,vRam
  93. add hl,de
  94. dec bc
  95. FillRect_Loop:
  96. FillRect_Color = $+1
  97. ld (hl),0
  98. push hl
  99. pop de
  100. inc de
  101. push bc
  102. ldir
  103. pop bc
  104. ld de,lcdWidth
  105. add hl,de
  106. sbc hl,bc
  107. dec a
  108. jr nz,FillRect_Loop
  109. ret
  110.  
  111. Setup8bppMode:
  112. ld a,lcdBpp8
  113. ld (mpLcdCtrl),a
  114. ret
  115.  
  116. LoadxLIBCPalette:
  117. ld de,mpLcdPalette
  118. ld b,l
  119. LoadxLIBCPalette_Loop:
  120. ld a,b
  121. rrca
  122. xor b
  123. and %11100000
  124. xor b
  125. ld (de),a
  126. inc de
  127. ld a,b
  128. rra
  129. ld (de),a
  130. inc de
  131. inc b
  132. jr nz,LoadxLIBCPalette_Loop
  133. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement