home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / cdfm.zip / VGA50.BAK < prev    next >
Text File  |  1996-06-10  |  11KB  |  473 lines

  1.   PUTSTR                = 1
  2.   TEXTBOX0              = 1
  3.   TEXTBOX1              = 1
  4.   PUSHPOPTEXT           = 1
  5.   SETCHARS              = 1
  6.   GETSTR                = 1
  7.  
  8.         .386p
  9. code32  segment para public use32
  10.         assume cs:code32, ds:code32
  11.  
  12. include pmode.inc
  13.  
  14. public  _initvga50, _vgatextptr, _textstakptr, _vgadefcolorz
  15.  
  16. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  17. ; DATA
  18. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  19. SCRX            = 80                    ; 80 or 90 columns wide
  20. DEFTEXTSB       = 0b8000h+(50*SCRX)*2
  21. stak    struc
  22.         dd      ?
  23. lx      db      ?
  24. ly      db      ?
  25. dlx     db      ?
  26. dly     db      ?
  27. ends
  28.  
  29. crtc90colregs   dw      0e11h,2d13h,6b00h,5901h,5a02h,5e04h
  30.  
  31. _textstakptr    dd      ?       ; ptr to video stack, MUST set this first
  32. _vgatextptr     dd      ?       ; text vidmem adjusted base pointer
  33. _vgadefcolorz   db      0,0,0,0,0,42,0,42,0,0,42,42,42,0,0,42
  34.                 db      0,42,42,21,0,42,42,42,21,21,21,21,21,63,21,63
  35.                 db      21,21,63,63,63,21,21,63,21,63,63,63,21,63,63,63
  36.  
  37. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  38. ; CODE
  39. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  40.  
  41. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  42. ; Init VGA 50 line text mode and set color numbers
  43. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  44. _initvga50:
  45.         push eax dx esi
  46.         @rlp eax,0b8000h
  47.         mov _vgatextptr,eax
  48.         @rlp eax,DEFTEXTSB
  49.         mov _textstakptr,eax
  50.         mov dword ptr [eax],0
  51.         mov v86r_ax,3
  52.         mov al,10h
  53.         int 33h
  54.         mov v86r_ax,1102h
  55.         mov v86r_bl,0
  56.         int 33h
  57.         mov v86r_ax,1003h
  58.         int 33h
  59.         mov dx,3d4h
  60.         mov ax,709h
  61.         out dx,ax
  62.         mov dx,3dah
  63.         in al,dx
  64.         test al,8
  65.         jz short $-3
  66.         mov dx,3c0h
  67.         xor ah,ah
  68. initvga50l1:
  69.         mov al,ah
  70.         out dx,al
  71.         jmp short $+2
  72.         out dx,al
  73.         inc ah
  74.         cmp ah,10h
  75.         jb initvga50l1
  76.         mov al,20h
  77.         out dx,al
  78.         mov dx,3dah
  79.         in al,dx
  80.         mov esi,offset _vgadefcolorz
  81.         mov dx,3c8h
  82.         xor al,al
  83.         out dx,al
  84.         inc dx
  85. initvga50l2:
  86.         lodsb
  87.         out dx,al
  88.         cmp esi,offset _vgadefcolorz+30h
  89.         jb initvga50l2
  90. if SCRX eq 90
  91.         mov dx,3c4h
  92.         mov ax,101h
  93.         out dx,ax
  94.         mov dl,0d4h
  95.         mov esi,offset crtc90colregs
  96.         outsw
  97.         outsw
  98.         outsw
  99.         outsw
  100.         outsw
  101.         outsw
  102. endif
  103.         pop esi dx eax
  104.         ret
  105.  
  106. ifdef   PUTSTR
  107. public  _putstr
  108. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  109. ; Put ASCIIZ string to screen
  110. ; In:
  111. ;   AH - attribute
  112. ;   BL - X
  113. ;   BH - Y
  114. ;   EDX -> ASCIIZ string
  115. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  116. _putstr:
  117.         push ax esi edi
  118.         movzx edi,bh
  119.         imul edi,SCRX*2
  120.         movzx si,bl
  121.         shl si,1
  122.         add di,si
  123.         add edi,_vgatextptr
  124.         mov esi,edx
  125. putstrl0:
  126.         lodsb
  127.         or al,al
  128.         jz short putstrd
  129.         stosw
  130.         jmp putstrl0
  131. putstrd:
  132.         pop edi esi ax
  133.         ret
  134. endif
  135.  
  136. ifdef   PUSHPOPTEXT
  137. public  _pushtext, _poptext
  138. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  139. ; Save an area of the screen to video stack
  140. ; In:
  141. ;   BL - X
  142. ;   BH - Y
  143. ;   CL - delta X
  144. ;   CH - delta Y
  145. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  146. _pushtext:
  147.         pushad
  148.         mov ebp,_textstakptr
  149.         mov word ptr ds:[ebp].lx,bx
  150.         mov word ptr ds:[ebp].dlx,cx
  151.         lea edi,[ebp+8]
  152.         movzx esi,bh
  153.         imul esi,SCRX*2
  154.         movzx eax,bl
  155.         lea esi,[esi+eax*2]
  156.         add esi,_vgatextptr
  157.         movzx edx,cl
  158.         lea ebx,[edx*2-SCRX*2]
  159.         mov al,ch
  160. pushtextl0:
  161.         mov ecx,edx
  162.         rep movsw
  163.         sub esi,ebx
  164.         dec al
  165.         jnz pushtextl0
  166.         mov [edi],ebp
  167.         mov _textstakptr,edi
  168.         popad
  169.         ret
  170.  
  171. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  172. ; Restore last pushed area of the screen from video stack
  173. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  174. _poptext:
  175.         pushad
  176.         mov ebp,_textstakptr
  177.         mov eax,ds:[ebp]
  178.         or eax,eax
  179.         jz short poptextdone
  180.         mov ebp,eax
  181.         lea esi,[ebp+8]
  182.         movzx edi,ds:[ebp].ly
  183.         imul edi,SCRX*2
  184.         movzx eax,ds:[ebp].lx
  185.         lea edi,[edi+eax*2]
  186.         add edi,_vgatextptr
  187.         movzx edx,ds:[ebp].dlx
  188.         lea ebx,[edx*2-SCRX*2]
  189.         movzx eax,ds:[ebp].dly
  190. poptextl0:
  191.         mov ecx,edx
  192.         rep movsw
  193.         sub edi,ebx
  194.         dec eax
  195.         jnz poptextl0
  196. poptextdone:
  197.         mov _textstakptr,ebp
  198.         popad
  199.         ret
  200. endif
  201.  
  202. ifdef   TEXTBOX0
  203. public  _textbox0
  204. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  205. ; Put box filled with character to screen
  206. ; In:
  207. ;   AL - character to fill with
  208. ;   AH - attribute
  209. ;   BL - X
  210. ;   BH - Y
  211. ;   CL - delta X
  212. ;   CH - delta Y
  213. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  214. _textbox0:
  215.         pushad
  216.         movzx ebp,ch
  217.         movzx edx,cl
  218.         movzx edi,bh
  219.         imul edi,SCRX*2
  220.         movzx ebx,bl
  221.         shl ebx,1
  222.         add edi,ebx
  223.         add edi,_vgatextptr
  224.         lea esi,[edx*2-SCRX*2]
  225. textbox0l0:
  226.         mov ecx,edx
  227.         rep stosw
  228.         sub edi,esi
  229.         dec ebp
  230.         jnz textbox0l0
  231.         popad
  232.         ret
  233. endif
  234.  
  235. ifdef   TEXTBOX1
  236. public  _textbox1
  237. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  238. ; Put outlined box to screen
  239. ; In:
  240. ;   AH - attribute
  241. ;   BL - X
  242. ;   BH - Y
  243. ;   CL - delta X
  244. ;   CH - delta Y
  245. ;   EDX -> outlining characters in the following order '─│┌┐└┘f'
  246. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  247. _textbox1:
  248.         pushad
  249.         movzx edi,bh
  250.         imul edi,SCRX*2
  251.         movzx ebx,bl
  252.         lea edi,[edi+ebx*2]
  253.         add edi,_vgatextptr
  254.         lea ebx,[ecx-202h]
  255.         movzx ebp,bl
  256.         movzx esi,cl
  257.         lea esi,[esi*2-SCRX*2]
  258.         mov al,[edx+2]
  259.         stosw
  260.         mov al,[edx]
  261.         mov ecx,ebp
  262.         rep stosw
  263.         mov al,[edx+3]
  264.         stosw
  265.         sub edi,esi
  266. textbox1l0:
  267.         mov al,[edx+1]
  268.         stosw
  269.         mov al,[edx+6]
  270.         mov ecx,ebp
  271.         rep stosw
  272.         mov al,[edx+1]
  273.         stosw
  274.         sub edi,esi
  275.         dec bh
  276.         jnz textbox1l0
  277.         mov al,[edx+4]
  278.         stosw
  279.         mov al,[edx]
  280.         mov ecx,ebp
  281.         rep stosw
  282.         mov al,[edx+5]
  283.         stosw
  284.         popad
  285.         ret
  286. endif
  287.  
  288. ifdef   SETCHARS
  289. public  _setchars
  290. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  291. ; Set a group of character bitmaps
  292. ; In:
  293. ;   AL - first ASCII character to set
  294. ;   BL - number of bytes (lines) per character
  295. ;   CL - number of characters to set minus 1
  296. ;   EDX -> bitmap data for characters
  297. ; Notes:
  298. ;   Remember that in 80 column mode, character column 9 will be the same as
  299. ;    column 8 only for characters 0c0h-0dfh, in all other characters column 9
  300. ;    will be empty.
  301. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  302. _setchars:
  303.         push ax ecx edx esi edi
  304.         mov esi,edx
  305.         movzx edi,al
  306.         shl edi,5
  307.         add edi,0b8000h
  308.         sub edi,_code32a
  309.         mov dx,3c4h
  310.         mov ax,00402h
  311.         out dx,ax
  312.         mov ax,00604h
  313.         out dx,ax
  314.         mov dx,3ceh
  315.         mov ax,00c06h
  316.         out dx,ax
  317.         mov al,cl
  318.         movzx edx,bl
  319.         dec dl
  320.         xor dl,1fh
  321. setcharsl0:
  322.         movzx ecx,bl
  323.         rep movsb
  324.         add edi,edx
  325.         sub al,1
  326.         jnc setcharsl0
  327.         mov dx,3c4h
  328.         mov ax,00302h
  329.         out dx,ax
  330.         mov ax,00204h
  331.         out dx,ax
  332.         mov dx,3ceh
  333.         mov ax,00e06h
  334.         out dx,ax
  335.         pop edi esi edx ecx ax
  336.         ret
  337. endif
  338.  
  339. ifdef   GETSTR
  340. public  _getstr
  341. lowercasetbl    db      '`1234567890-=\qwertyuiop[]asdfghjkl;''zxcvbnm,./'
  342. lowercasetbllen=$-lowercasetbl
  343. uppercasetbl    db      '~!@#$%^&*()_+|QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?'
  344. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  345. ; Read string from keyboard to screen
  346. ; In:
  347. ;   AH - screen attribute
  348. ;   AL - input attribute bit 0 = make all letters uppercase
  349. ;   BL - X
  350. ;   BH - Y
  351. ;   CL - max count for string
  352. ;   EDX -> string buffer
  353. ;   EBP -> ASCIIZ list of characters to accept (first byte is # present)
  354. ; Out:
  355. ;   CF=0 string completed fine
  356. ;   CF=1 string entry aborted
  357. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  358. _getstr:
  359.         pushad
  360.         movzx edi,bh
  361.         imul edi,160
  362.         movzx ebx,bl
  363.         lea edi,[edi+ebx*2]
  364.         add edi,_vgatextptr
  365.         mov esi,edx
  366.         mov bh,cl
  367.         xor bl,bl
  368.         mov edx,eax
  369. getstrl0:
  370.         lodsb
  371.         or al,al
  372.         jz short getstrl0d
  373.         stosw
  374.         inc bl
  375.         jmp getstrl0
  376. getstrl0d:
  377.         mov esi,edi
  378.         mov cl,bl
  379.         mov al,' '
  380. getstrl1:
  381.         cmp cl,bh
  382.         jae short getstrml
  383.         stosw
  384.         inc cl
  385.         jmp getstrl1
  386. getstrml:
  387.         cmp bl,bh
  388.         je short getstrmlf0
  389.         mov ah,dh
  390.         mov al,'▒'
  391.         mov [esi],ax
  392. getstrmlf0:
  393.         call _getch
  394.         cmp al,14
  395.         je short getstrabort
  396.         cmp al,16
  397.         je short getstrbs
  398.         cmp al,13
  399.         je short getstrdone
  400.         cmp bl,bh
  401.         jae getstrmlf0
  402.         test dl,1
  403.         jz short getstrmlf1
  404.         cmp al,'a'
  405.         jb short getstrmlf1
  406.         cmp al,'z'
  407.         ja short getstrmlf1
  408.         or ah,1
  409. getstrmlf1:
  410.         test ah,1
  411.         jz short getstrmlf2
  412.         mov edi,offset lowercasetbl
  413.         mov ecx,lowercasetbllen
  414.         repnz scasb
  415.         jnz getstrmlf0
  416.         mov al,[edi+lowercasetbllen-1]
  417. getstrmlf2:
  418.         lea edi,[ebp+1]
  419.         movzx ecx,byte ptr [ebp]
  420.         repnz scasb
  421.         jnz getstrmlf0
  422.         mov al,[edi-1]
  423.         mov ah,dh
  424.         mov [esi],ax
  425.         add esi,2
  426.         inc bl
  427.         jmp getstrml
  428. getstrbs:
  429.         or bl,bl
  430.         jz getstrmlf0
  431.         call getstrremove
  432.         dec bl
  433.         sub esi,2
  434.         jmp getstrml
  435. getstrabort:
  436.         call getstrremove
  437.         popad
  438.         stc
  439.         ret
  440. getstrremove:
  441.         cmp bl,bh
  442.         je short getstrremovef0
  443.         mov ah,dh
  444.         mov al,' '
  445.         mov [esi],ax
  446. getstrremovef0:
  447.         ret
  448. getstrdone:
  449.         call getstrremove
  450.         mov edi,[esp+20]
  451.         movzx ebx,bl
  452.         sub esi,ebx
  453.         sub esi,ebx
  454. getstrdonel0:
  455.         or bl,bl
  456.         jz short getstrdonel0d
  457.         movsb
  458.         inc esi
  459.         dec bl
  460.         jmp getstrdonel0
  461. getstrdonel0d:
  462.         xor al,al
  463.         stosb
  464.         popad
  465.         clc
  466.         ret
  467. endif
  468.  
  469.  
  470. code32  ends
  471.         end
  472.  
  473.