home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / PMODE24.ZIP / LIBS.ZIP / VGA50.ASM < prev    next >
Assembly Source File  |  1994-02-05  |  8KB  |  340 lines

  1.   PUTSTR                = 1
  2.   TEXTBOX0              = 1
  3.   TEXTBOX1              = 1
  4.   PUSHPOPTEXT           = 1
  5.   SETCHARS              = 1
  6.         .386p
  7. code32  segment para public use32
  8.         assume cs:code32, ds:code32
  9.  
  10. include pmode.inc
  11.  
  12. public  _initvga50, _vgatextptr, _textstakptr, _vgadefcolorz
  13.  
  14. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  15. ; DATA
  16. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  17. SCRX            = 80                    ; 80 or 90 columns wide
  18. DEFTEXTSB       = 0b8000h+(50*SCRX)*2
  19. stak    struc
  20.         dd      ?
  21. lx      db      ?
  22. ly      db      ?
  23. dlx     db      ?
  24. dly     db      ?
  25. ends
  26.  
  27. crtc90colregs   dw      0e11h,2d13h,6b00h,5901h,5a02h,5e04h
  28.  
  29. _textstakptr    dd      ?       ; ptr to video stack, MUST set this first
  30. _vgatextptr     dd      ?       ; text vidmem adjusted base pointer
  31. _vgadefcolorz   db      0,0,0,0,0,42,0,42,0,0,42,42,42,0,0,42
  32.                 db      0,42,42,21,0,42,42,42,21,21,21,21,21,63,21,63
  33.                 db      21,21,63,63,63,21,21,63,21,63,63,63,21,63,63,63
  34.  
  35. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  36. ; CODE
  37. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  38.  
  39. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  40. ; Init VGA 50 line text mode and set color numbers
  41. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  42. _initvga50:
  43.         push eax dx esi
  44.         @rlp eax,0b8000h
  45.         mov _vgatextptr,eax
  46.         @rlp eax,DEFTEXTSB
  47.         mov _textstakptr,eax
  48.         mov dword ptr [eax],0
  49.         mov v86r_ax,3
  50.         mov al,10h
  51.         int 33h
  52.         mov v86r_ax,1102h
  53.         mov v86r_bl,0
  54.         int 33h
  55.         mov v86r_ax,1003h
  56.         int 33h
  57.         mov dx,3d4h
  58.         mov ax,709h
  59.         out dx,ax
  60.         mov dx,3dah
  61.         in al,dx
  62.         test al,8
  63.         jz short $-3
  64.         mov dx,3c0h
  65.         xor ah,ah
  66. initvga50l1:
  67.         mov al,ah
  68.         out dx,al
  69.         jmp short $+2
  70.         out dx,al
  71.         inc ah
  72.         cmp ah,10h
  73.         jb initvga50l1
  74.         mov al,20h
  75.         out dx,al
  76.         mov dx,3dah
  77.         in al,dx
  78.         mov esi,offset _vgadefcolorz
  79.         mov dx,3c8h
  80.         xor al,al
  81.         out dx,al
  82.         inc dx
  83. initvga50l2:
  84.         lodsb
  85.         out dx,al
  86.         cmp esi,offset _vgadefcolorz+30h
  87.         jb initvga50l2
  88. if SCRX eq 90
  89.         mov dx,3c4h
  90.         mov ax,101h
  91.         out dx,ax
  92.         mov dl,0d4h
  93.         mov esi,offset crtc90colregs
  94.         outsw
  95.         outsw
  96.         outsw
  97.         outsw
  98.         outsw
  99.         outsw
  100. endif
  101.         pop esi dx eax
  102.         ret
  103.  
  104. ifdef   PUTSTR
  105. public  _putstr
  106. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  107. ; Put ASCIIZ string to screen
  108. ; In:
  109. ;   AH - attribute
  110. ;   BL - X
  111. ;   BH - Y
  112. ;   EDX -> ASCIIZ string
  113. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  114. _putstr:
  115.         push ax esi edi
  116.         movzx edi,bh
  117.         imul edi,SCRX*2
  118.         movzx si,bl
  119.         shl si,1
  120.         add di,si
  121.         add edi,_vgatextptr
  122.         mov esi,edx
  123. putstrl0:
  124.         lodsb
  125.         or al,al
  126.         jz short putstrd
  127.         stosw
  128.         jmp putstrl0
  129. putstrd:
  130.         pop edi esi ax
  131.         ret
  132. endif
  133.  
  134. ifdef   PUSHPOPTEXT
  135. public  _pushtext, _poptext
  136. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  137. ; Save an area of the screen to video stack
  138. ; In:
  139. ;   BL - X
  140. ;   BH - Y
  141. ;   CL - delta X
  142. ;   CH - delta Y
  143. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  144. _pushtext:
  145.         pushad
  146.         mov ebp,_textstakptr
  147.         mov word ptr ds:[ebp].lx,bx
  148.         mov word ptr ds:[ebp].dlx,cx
  149.         lea edi,[ebp+8]
  150.         movzx esi,bh
  151.         imul esi,SCRX*2
  152.         movzx eax,bl
  153.         lea esi,[esi+eax*2]
  154.         add esi,_vgatextptr
  155.         movzx edx,cl
  156.         lea ebx,[edx*2-SCRX*2]
  157.         mov al,ch
  158. pushtextl0:
  159.         mov ecx,edx
  160.         rep movsw
  161.         sub esi,ebx
  162.         dec al
  163.         jnz pushtextl0
  164.         mov [edi],ebp
  165.         mov _textstakptr,edi
  166.         popad
  167.         ret
  168.  
  169. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  170. ; Restore last pushed area of the screen from video stack
  171. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  172. _poptext:
  173.         pushad
  174.         mov ebp,_textstakptr
  175.         mov eax,ds:[ebp]
  176.         or eax,eax
  177.         jz short poptextdone
  178.         mov ebp,eax
  179.         lea esi,[ebp+8]
  180.         movzx edi,ds:[ebp].ly
  181.         imul edi,SCRX*2
  182.         movzx eax,ds:[ebp].lx
  183.         lea edi,[edi+eax*2]
  184.         add edi,_vgatextptr
  185.         movzx edx,ds:[ebp].dlx
  186.         lea ebx,[edx*2-SCRX*2]
  187.         movzx eax,ds:[ebp].dly
  188. poptextl0:
  189.         mov ecx,edx
  190.         rep movsw
  191.         sub edi,ebx
  192.         dec eax
  193.         jnz poptextl0
  194. poptextdone:
  195.         mov _textstakptr,ebp
  196.         popad
  197.         ret
  198. endif
  199.  
  200. ifdef   TEXTBOX0
  201. public  _textbox0
  202. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  203. ; Put box filled with character to screen
  204. ; In:
  205. ;   AL - character to fill with
  206. ;   AH - attribute
  207. ;   BL - X
  208. ;   BH - Y
  209. ;   CL - delta X
  210. ;   CH - delta Y
  211. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  212. _textbox0:
  213.         pushad
  214.         movzx ebp,ch
  215.         movzx edx,cl
  216.         movzx edi,bh
  217.         imul edi,SCRX*2
  218.         movzx ebx,bl
  219.         shl ebx,1
  220.         add edi,ebx
  221.         add edi,_vgatextptr
  222.         lea esi,[edx*2-SCRX*2]
  223. textbox0l0:
  224.         mov ecx,edx
  225.         rep stosw
  226.         sub edi,esi
  227.         dec ebp
  228.         jnz textbox0l0
  229.         popad
  230.         ret
  231. endif
  232.  
  233. ifdef   TEXTBOX1
  234. public  _textbox1
  235. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  236. ; Put outlined box to screen
  237. ; In:
  238. ;   AH - attribute
  239. ;   BL - X
  240. ;   BH - Y
  241. ;   CL - delta X
  242. ;   CH - delta Y
  243. ;   EDX -> outlining characters in the following order '─│┌┐└┘f'
  244. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  245. _textbox1:
  246.         pushad
  247.         movzx edi,bh
  248.         imul edi,SCRX*2
  249.         movzx ebx,bl
  250.         lea edi,[edi+ebx*2]
  251.         add edi,_vgatextptr
  252.         lea ebx,[ecx-202h]
  253.         movzx ebp,bl
  254.         movzx esi,cl
  255.         lea esi,[esi*2-SCRX*2]
  256.         mov al,[edx+2]
  257.         stosw
  258.         mov al,[edx]
  259.         mov ecx,ebp
  260.         rep stosw
  261.         mov al,[edx+3]
  262.         stosw
  263.         sub edi,esi
  264. textbox1l0:
  265.         mov al,[edx+1]
  266.         stosw
  267.         mov al,[edx+6]
  268.         mov ecx,ebp
  269.         rep stosw
  270.         mov al,[edx+1]
  271.         stosw
  272.         sub edi,esi
  273.         dec bh
  274.         jnz textbox1l0
  275.         mov al,[edx+4]
  276.         stosw
  277.         mov al,[edx]
  278.         mov ecx,ebp
  279.         rep stosw
  280.         mov al,[edx+5]
  281.         stosw
  282.         popad
  283.         ret
  284. endif
  285.  
  286. ifdef   SETCHARS
  287. public  _setchars
  288. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  289. ; Set a group of character bitmaps
  290. ; In:
  291. ;   AL - first ASCII character to set
  292. ;   BL - number of bytes (lines) per character
  293. ;   CL - number of characters to set minus 1
  294. ;   EDX -> bitmap data for characters
  295. ; Notes:
  296. ;   Remember that in 80 column mode, character column 9 will be the same as
  297. ;    column 8 only for characters 0c0h-0dfh, in all other characters column 9
  298. ;    will be empty.
  299. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  300. _setchars:
  301.         push ax ecx edx esi edi
  302.         mov esi,edx
  303.         movzx edi,al
  304.         shl edi,5
  305.         add edi,0b8000h
  306.         sub edi,_code32a
  307.         mov dx,3c4h
  308.         mov ax,00402h
  309.         out dx,ax
  310.         mov ax,00604h
  311.         out dx,ax
  312.         mov dx,3ceh
  313.         mov ax,00c06h
  314.         out dx,ax
  315.         mov al,cl
  316.         movzx edx,bl
  317.         dec dl
  318.         xor dl,1fh
  319. setcharsl0:
  320.         movzx ecx,bl
  321.         rep movsb
  322.         add edi,edx
  323.         sub al,1
  324.         jnc setcharsl0
  325.         mov dx,3c4h
  326.         mov ax,00302h
  327.         out dx,ax
  328.         mov ax,00204h
  329.         out dx,ax
  330.         mov dx,3ceh
  331.         mov ax,00e06h
  332.         out dx,ax
  333.         pop edi esi edx ecx ax
  334.         ret
  335. endif
  336.  
  337. code32  ends
  338.         end
  339.  
  340.