char.asm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. .286
  2. .model small
  3. .code
  4. org 100h
  5. ;--------------------
  6. character equ 'G'
  7. ;--------------------
  8. start:
  9. mov ax, 1130h
  10. mov bh, 06h
  11. int 10h
  12. mov FontSeg, es
  13. mov FontOffs, bp
  14. mov ax, 13h
  15. int 10h
  16. push 1
  17. push 0
  18. push character
  19. push 4
  20. push 2
  21. push FontOffs
  22. push FontSeg
  23. call OutCharXY
  24. mov ah, 8h
  25. int 21h
  26. mov ax, 3h
  27. int 10h
  28. int 20h
  29. ;---------------------------------------------
  30. OutCharXY proc near ;OutCharXY(X,Y,Char,Color,bg,TableOffs,TableSeg)
  31. push bp
  32. mov bp, sp
  33. TableSeg equ word ptr [bp+4]
  34. TableOffs equ word ptr [bp+6]
  35. Color equ byte ptr [bp+0Ah]
  36. Bg equ byte ptr [bp+8]
  37. Char equ byte ptr [bp+12]
  38. posY equ word ptr [bp+14]
  39. posX equ word ptr [bp+16]
  40. pusha
  41. push es
  42. ;----------------------------
  43. ; Character Creation
  44. mov di, TableOffs
  45. mov es, TableSeg
  46. mov ah, 0
  47. mov al, Char
  48. shl ax, 4
  49. add di, ax
  50. mov cx, 16
  51. mov si, offset face
  52. MainLoop:
  53. mov bh, es:di
  54. push cx
  55. mov cx, 8
  56. LineLoop:
  57. test bh, 80h
  58. jz BackGround
  59. mov ah, Color
  60. mov byte ptr ds:[si], ah
  61. jmp LoopEnd
  62. BackGround:
  63. mov ah, Bg
  64. mov byte ptr ds:[si], ah
  65. LoopEnd:
  66. shl bh, 1
  67. inc si
  68. loop LineLoop
  69. pop cx
  70. inc di
  71. loop MainLoop
  72. ; End of Character creation
  73. ;=======================================
  74. mov ax, posX
  75. shl ax, 3
  76. push ax ; X position
  77. mov ax, posY
  78. shl ax, 4
  79. push ax ; Y position
  80. push offset face ; Character bitmap
  81. push 8 ; SizeX
  82. push 16 ; SizeY
  83. call WriteSprite ; WriteChar
  84. pop es
  85. popa
  86. pop bp
  87. ret 14
  88. endp
  89. ;-------------------------------------------
  90. WriteSprite proc near ;writesprite(x,y,char *sprt,razmx,razmy)
  91. push bp
  92. mov bp,sp
  93. razmy equ word ptr [bp+4]
  94. razmx equ word ptr [bp+6]
  95. sprt equ word ptr [bp+8]
  96. posy equ word ptr [bp+10]
  97. posx equ word ptr [bp+12]
  98. pusha
  99. push es
  100. mov ax, 0A000h
  101. mov es, ax
  102. mov ax, posy
  103. mov bx, ax
  104. shl ax, 8
  105. shl bx, 6
  106. add ax, bx
  107. add ax, posx
  108. mov di, ax
  109. mov ax, sprt
  110. mov si, ax
  111. mov cx, razmy
  112. lup:
  113. push cx
  114. mov cx, razmx
  115. repe movsb
  116. add di, 320
  117. sub di,razmx
  118. pop cx
  119. loop lup
  120. pop es
  121. popa
  122. pop bp
  123. ret 10
  124. endp
  125. face db 128 dup (?)
  126. FontOffs dw ?
  127. FontSeg dw ?
  128. end start