Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2.  
  3. ORG #8000
  4.  
  5. stringposition:
  6. defb 0
  7.  
  8. nextletter:
  9.  
  10. LD B,0 ;y coord of getpixel
  11.  
  12. LD C,200 ; x coord of get pixel
  13.  
  14. LD A,(stringposition) ;get string position
  15.  
  16. SLA A
  17. SLA A
  18. SLA A ;multiply stringposition by 8
  19.  
  20.  
  21. ADD A,C
  22. LD C,A ;add string position to x-coordinate
  23.  
  24. call Get_Pixel_Address
  25. PUSH HL
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. LD IX,font ;load font memory position
  34.  
  35. LD DE,mystring ; load string memory position
  36.  
  37. LD A,(stringposition)
  38.  
  39. LD B,A ;
  40. CP 0 ; add string position and
  41. JP Z,dontinc1 ;mystring memory address together
  42. ;
  43. incagain1: ;
  44. INC DE ;
  45. DJNZ incagain1 ;
  46. dontinc1: ;
  47. LD A,(DE) ;memory address of letter to be printed is in de
  48.  
  49.  
  50. SUB 32 ;ASCII has 31 unprintable characters
  51. LD B,A
  52.  
  53. LD DE,8
  54. POP HL
  55. mLoop:
  56. ADD IX,DE
  57.  
  58. djnz mLoop
  59.  
  60.  
  61.  
  62.  
  63. LD A,(IX)
  64. LD (HL),A
  65.  
  66. INC H
  67. INC IX
  68. LD A,(IX)
  69. LD (HL),A
  70.  
  71. INC H
  72. INC IX
  73. LD A,(IX)
  74. LD (HL),A
  75.  
  76. INC H
  77. INC IX
  78. LD A,(IX)
  79. LD (HL),A
  80.  
  81. INC H
  82. INC IX
  83. LD A,(IX)
  84. LD (HL),A
  85.  
  86. INC H
  87. INC IX
  88. LD A,(IX)
  89. LD (HL),A
  90.  
  91. INC H
  92. INC IX
  93. LD A,(IX)
  94. LD (HL),A
  95.  
  96. INC H
  97. INC IX
  98. LD A,(IX)
  99. LD (HL),A
  100.  
  101. LD HL,stringposition
  102. INC (HL)
  103.  
  104.  
  105.  
  106. LD DE,mystring ;
  107. LD A,(stringposition) ;
  108. LD B,A ;add string position to string
  109. incagain: ;to get current letter
  110. INC DE ;
  111. DJNZ incagain ;
  112.  
  113.  
  114. LD A,(DE)
  115.  
  116.  
  117. CP 0
  118. JP NZ,nextletter
  119.  
  120. ; Get screen address
  121. ; B = Y pixel position
  122. ; C = X pixel position
  123. ; Returns address in HL
  124. ;
  125.  
  126.  
  127. mystring:
  128. defb "hello",#0
  129. screen_address:
  130. defw 0
  131.  
  132. Get_Pixel_Address: LD A,B ; Calculate Y2,Y1,Y0
  133. AND %00000111 ; Mask out unwanted bits
  134. OR %01000000 ; Set base address of screen
  135. LD H,A ; Store in H
  136. LD A,B ; Calculate Y7,Y6
  137. RRA ; Shift to position
  138. RRA
  139. RRA
  140. AND %00011000 ; Mask out unwanted bits
  141. OR H ; OR with Y2,Y1,Y0
  142. LD H,A ; Store in H
  143. LD A,B ; Calculate Y5,Y4,Y3
  144. RLA ; Shift to position
  145. RLA
  146. AND %11100000 ; Mask out unwanted bits
  147. LD L,A ; Store in L
  148. LD A,C ; Calculate X4,X3,X2,X1,X0
  149. RRA ; Shift into position
  150. RRA
  151. RRA
  152. AND %00011111 ; Mask out unwanted bits
  153. OR L ; OR with Y5,Y4,Y3
  154. LD L,A ; Store in L
  155. RET
  156.  
  157. include "font.zas"