Advertisement
Ham62

VESA DrawString.asm

Mar 29th, 2017
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ORG 0h
  2.  
  3. ;DB 0CCh    ;INT 3
  4.  
  5. PUSH DS         ;Screen will be DS:DI
  6.  
  7. MOV DS, [wVesaSegment]  ;Load screen segment into DS
  8.             ;DI passed with pointer to start of print area
  9.  
  10. LGS SI, [FontTablePtr]  ;Load pointer to font table into GS:SI
  11.  
  12. ;String passed on FS:BP
  13. ;Length passed on CX
  14. ;Color passed on BL
  15.  
  16.  
  17. ReadChar:
  18. MOV AH, 00h     ;clear AH for pointer math
  19. MOV AL, BYTE [FS:BP]    ;Read a char from the string
  20. SHL AX, 3       ;Multiply character by 8 (8 bytes per char)
  21.  
  22. MOV DX, SI      ;Save start position of font table
  23. ADD SI, AX      ;Move table pointer to character we just read
  24.  
  25. MOV BH, 8       ;8 lines per char
  26.  
  27. .NextLine:
  28. MOV AL, [ES:SI]     ;Read a row of pixels from the char
  29.  
  30. .Pixel1:
  31. TEST AL, 1      ;Is there a pixel at bit 1?
  32. JZ .Pixel2      ;No? Jump to pixel 2
  33. MOV [DI+7], BL      ;Draw pixel 1
  34.  
  35. .Pixel2:
  36. TEST AL, 2      ;Is there a pixel at bit 2?
  37. JZ .Pixel3      ;No? jump to pixel 3
  38.  
  39. MOV [DI+6], BL      ;Draw pixel 2
  40.  
  41. .Pixel3:
  42. TEST AL, 4      ;Is there a pixel at bit 3?
  43. JZ .Pixel4      ;No? Jump to pixel 4
  44. MOV [DI+5], BL      ;Draw pixel 3
  45.  
  46. .Pixel4:
  47. TEST AL, 8      ;Is there a pixel at bit 4?
  48. JZ .Pixel5      ;No? Jump to pixel 5
  49. MOV [DI+4], BL      ;Draw pixel 4
  50.  
  51. .Pixel5:
  52. TEST AL, 16     ;Is there a pixel at bit 5?
  53. JZ .Pixel6      ;No? Jump to pixel 6
  54. MOV [DI+3], BL      ;Draw pixel 5
  55.  
  56. .Pixel6:
  57. TEST AL, 32     ;Is there a pixel at bit 6?
  58. JZ .Pixel7      ;No? Jump to pixel 7
  59. MOV [DI+2], BL      ;Draw pixel 6
  60.  
  61. .Pixel7:
  62. TEST AL, 64     ;Is there a pixel at bit 7?
  63. JZ .Pixel8      ;No? Jump to pixel 8
  64. MOV [DI+1], BL      ;Draw pixel 7
  65.  
  66. .Pixel8:
  67. TEST AL, 128        ;Is there a pixel at bit 8?
  68. JZ .EndOfRow        ;No? Skip drawing pixel
  69. MOV [DI], BL        ;Draw pixel 8
  70.  
  71. .EndOfRow:
  72. INC SI          ;Next byte on font table
  73. ADD DI, 640     ;Go to next line on bank
  74.  
  75. DEC BH          ;Done all 8 lines of char?
  76. JNZ .NextLine       ;No? Start over on next line
  77.  
  78. MOV SI, DX      ;Restore to start of table
  79. SUB DI, 2560-8      ;Done a char, return to top line and move
  80.             ;8 pixels forward for next character
  81.  
  82. INC BP          ;Next char in string pointer
  83. DEC CX          ;Are we done the string?
  84. JNZ ReadChar        ;No? Repeat until done
  85.  
  86.  
  87. End:
  88. POP DS
  89. RET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement