home *** CD-ROM | disk | FTP | other *** search
/ CD-X 1 / cdx_01.iso / demodisc / basq / dualmodp / fastext.asm < prev    next >
Encoding:
Assembly Source File  |  1994-05-09  |  8.4 KB  |  331 lines

  1. ;/************************************************************************
  2. ; *
  3. ; *     File        : FASTEXT.ASM
  4. ; *
  5. ; *     Description : Fast text routines for C
  6. ; *
  7. ; *     Copyright (C) 1993 Otto Chrons
  8. ; *
  9. ; ************************************************************************/
  10.  
  11.         IDEAL
  12.         MODEL LARGE,C
  13.         JUMPS
  14.         P286
  15.  
  16. DATASEG
  17.     PUBLIC screenSegment, quietMode
  18.  
  19.     screenSegment DW 0B800h
  20.     quietMode     DB 0
  21.  
  22. CODESEG
  23.  
  24.         PUBLIC initFastext, updateBuffer
  25.         PUBLIC writeBuf
  26.         PUBLIC moveBuf, moveChar, moveStr, moveCStr, writeStr, writeCStr
  27.         PUBLIC putChar, putAttr
  28.         PUBLIC cursorxy
  29.  
  30. ;/*************************************************************************
  31. ; *
  32. ; *     Function    :   initFastext();
  33. ; *
  34. ; *     Description :   Initializes fastext
  35. ; *
  36. ; ************************************************************************/
  37.  
  38. PROC    initFastext FAR USES di
  39.  
  40.         mov     ax,0F00h
  41.         int     10h                     ; Get screenmode
  42.         and     ax,007Fh
  43.         push    ax
  44.         cmp     al,7
  45.         jne     @@notMono
  46.         mov     [screenSegment],0B000h
  47. @@notMono:
  48.         mov     ah,0FEh
  49.         sub     di,di
  50.         mov     es,[screenSegment]
  51.         int     10h
  52.         mov     [screenSegment],es
  53.         pop     ax
  54.         ret
  55. ENDP
  56.  
  57. ;/*************************************************************************
  58. ; *
  59. ; *     Function    :   updateBuffer(ushort start, ushort count);
  60. ; *
  61. ; *     Description :   Updates screen buffer under DV
  62. ; *
  63. ; ************************************************************************/
  64.  
  65. PROC    updateBuffer FAR USES di, start:WORD, count:WORD
  66.  
  67.         mov     ah,0FFh
  68.         mov     cx,[count]
  69.         mov     di,[start]
  70.         mov     es,[screenSegment]
  71.         int     10h
  72.         ret
  73. ENDP
  74.  
  75. ;/*************************************************************************
  76. ; *
  77. ; *     Function    :   void writeBuf(void *buf, ushort x, ushort y, ushort count)
  78. ; *
  79. ; *     Description :   Writes a buffer to screen
  80. ; *
  81. ; ************************************************************************/
  82.  
  83. PROC    writeBuf FAR USES si di, buf:DWORD, x:WORD, y:WORD, count:WORD
  84.  
  85.     cmp    [quietmode],1
  86.     je    @@exit
  87.     push    ds
  88.     mov     ax,[screenSegment]
  89.     mov     es,ax
  90.         lds     si,[buf]
  91.         mov     cx,[count]
  92.         jcxz    @@99
  93.         mov     ax,160
  94.         mul     [y]
  95.         add     ax,[x]
  96.         add     ax,[x]
  97.         mov     di,ax
  98.         mov     bx,di
  99.         cld
  100.         rep     movsw
  101. @@99:
  102.         pop     ds
  103.         cmp     [screenSegment],0B800h
  104.         je      @@exit
  105.         mov     di,bx
  106.         mov     cx,[count]
  107.         mov     ah,0FFh
  108.         int     10h
  109. @@exit:
  110.         ret
  111. ENDP
  112.  
  113. ;/*************************************************************************
  114. ; *
  115. ; *     Function    :    void moveBuf(void far *buf, ushort indent, const void far *src, ushort count)
  116. ; *
  117. ; *     Description :
  118. ; *
  119. ; ************************************************************************/
  120.  
  121. PROC    moveBuf FAR USES ds si di, buf:DWORD, indent:WORD, src:DWORD, count:WORD
  122.  
  123.         mov     cx,[count]
  124.         jcxz    @@99
  125.  
  126.         les     di,[buf]
  127.         lds     si,[src]
  128.         add     di,[indent]
  129.         add     di,[indent]
  130.     cld
  131.         rep     movsw
  132. @@99:
  133.         ret
  134. ENDP
  135.  
  136.  
  137. ;/*************************************************************************
  138. ; *
  139. ; *     Function    :    void moveChar(void *buf, ushort indent, char c, ushort attr, ushort count)
  140. ; *
  141. ; *     Description :
  142. ; *
  143. ; ************************************************************************/
  144.  
  145. PROC    moveChar FAR USES di,buf:DWORD, indent:WORD, c:BYTE, attr:WORD, count:WORD
  146.  
  147.         mov     cx,[count]
  148.         jcxz    @@99
  149.  
  150.         les     di,[buf]
  151.         add     di,[indent]
  152.         add     di,[indent]
  153.         mov     al,[c]
  154.         mov     ah,[BYTE PTR attr]
  155.         cld
  156.         rep     stosw
  157. @@99:
  158.         ret
  159. ENDP
  160.  
  161. ;/*************************************************************************
  162. ; *
  163. ; *     Function    :    void moveStr(void far *buf, ushort indent, const char far *stri, ushort attr)
  164. ; *
  165. ; *     Description :
  166. ; *
  167. ; ************************************************************************/
  168.  
  169. PROC    moveStr FAR USES ds si di,buf:DWORD,indent:WORD,stri:DWORD,attr:WORD
  170.  
  171.         les     di,[buf]
  172.         lds     si,[stri]
  173.     add     di,[indent]
  174.         add     di,[indent]
  175.         mov     ah,[BYTE PTR attr]
  176.         cld
  177.         mov     cx,132
  178. @@1:
  179.         lodsb
  180.         or      al,al
  181.         jz      @@99
  182.         stosw
  183.         loop    @@1
  184. @@99:
  185.         ret
  186. ENDP
  187.  
  188. ;/*************************************************************************
  189. ; *
  190. ; *     Function    :    void moveCStr(void far *buf, ushort indent, const char far *stri, ushort attr1, ushort attr2)
  191. ; *
  192. ; *     Description :
  193. ; *
  194. ; ************************************************************************/
  195.  
  196. PROC    moveCStr FAR USES ds si di,buf:DWORD,indent:WORD,stri:DWORD,attr1:WORD,attr2:WORD
  197.  
  198.  
  199.         les     di,[buf]
  200.         lds     si,[stri]
  201.         add     di,[indent]
  202.         add     di,[indent]
  203.         mov     ah,[BYTE PTR attr1]
  204.         mov     bx,1
  205.         cld
  206.         mov     cx,132
  207. @@1:
  208.         lodsb
  209.         or      al,al
  210.         jz      @@99
  211.         cmp     al,'~'
  212.         jne     @@4
  213.         mov     ah,[BYTE PTR attr2]
  214.         neg     bx
  215.         js      @@3
  216.     mov     ah,[BYTE PTR attr1]
  217. @@3:    loop    @@1
  218. @@4:
  219.         stosw
  220.         loop    @@1
  221. @@99:
  222.         ret
  223. ENDP
  224.  
  225. ;/*************************************************************************
  226. ; *
  227. ; *     Function    :    void putChar(void far *buf, ushort indent, char c)
  228. ; *
  229. ; *     Description :
  230. ; *
  231. ; ************************************************************************/
  232.  
  233. PROC    putChar FAR USES di,buf:DWORd,indent:WORD,c:BYTE
  234.  
  235.         les     di,[buf]
  236.         add     di,[indent]
  237.         add     di,[indent]
  238.         mov     al,[c]
  239.         mov     [es:di],al
  240.         ret
  241. ENDP
  242.  
  243. ;/*************************************************************************
  244. ; *
  245. ; *     Function    :    void putAttribute(void far *buf, ushort indent, ushort attr)
  246. ; *
  247. ; *     Description :
  248. ; *
  249. ; ************************************************************************/
  250.  
  251. PROC    putAttr FAR USES di,buf:DWORD,indent:WORD,attr:WORD
  252.  
  253.         les     di,[buf]
  254.         add     di,[indent]
  255.         add     di,[indent]
  256.         mov     al,[BYTE PTR attr]
  257.         mov     [es:di+1],al
  258.         ret
  259. ENDP
  260.  
  261. ;/*************************************************************************
  262. ; *
  263. ; *     Function    :    void cursorxy(int x, int y)
  264. ; *
  265. ; *     Description :
  266. ; *
  267. ; ************************************************************************/
  268.  
  269. PROC    cursorxy FAR x:WORD,y:WORD
  270.  
  271.     cmp    [quietMode],1
  272.     je    @@exit
  273.     mov     ah,2
  274.     mov     bx,0
  275.     mov     dh,[byte ptr y]
  276.     mov     dl,[byte ptr x]
  277.     int     10h
  278. @@exit:
  279.         ret
  280. ENDP
  281.  
  282. ;/*************************************************************************
  283. ; *
  284. ; *     Function    :    void writeStr(const char far *stri, ushort x, ushort y, ushort attr, ushort count)
  285. ; *
  286. ; *     Description :
  287. ; *
  288. ; ************************************************************************/
  289.  
  290. PROC    writeStr FAR stri:DWORD,x:WORD,y:WORD,attr:WORD,count:WORD
  291.         LOCAL   buf:WORD:160
  292.  
  293.         cmp     [count],160
  294.         jle     @@cntOK
  295.         mov     [count],160
  296. @@cntOK:
  297.         lea     bx,[buf]
  298.         call    moveChar C,ss bx,0,' ',[attr],80
  299.         lea     bx,[buf]
  300.         call    moveStr C,ss bx,0,[stri],[attr]
  301.         lea     bx,[buf]
  302.     call    writeBuf C,ss bx,[x],[y],[count]
  303.     ret
  304. ENDP
  305.  
  306. ;/*************************************************************************
  307. ; *
  308. ; *     Function    :    void writeCStr(const char far *stri, ushort x, ushort y, ushort attr1, ushort attr2, ushort count)
  309. ; *
  310. ; *     Description :
  311. ; *
  312. ; ************************************************************************/
  313.  
  314. PROC    writeCStr FAR stri:DWORD,x:WORD,y:WORD,attr1:WORD,attr2:WORD,count:WORD
  315.         LOCAL   buf:WORD:160
  316.  
  317.         cmp     [count],160
  318.         jle     @@cntOK
  319.         mov     [count],160
  320. @@cntOK:
  321.         lea     bx,[buf]
  322.         call    moveChar C,ss bx,0,' ',[attr1],80
  323.         lea     bx,[buf]
  324.         call    moveCStr C,ss bx,0,[stri],[attr1],[attr2]
  325.         lea     bx,[buf]
  326.         call    writeBuf C,ss bx,[x],[y],[count]
  327.         ret
  328. ENDP
  329.  
  330. END
  331.