home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / OMEGA2 / FASTWRIT.CPP < prev    next >
C/C++ Source or Header  |  1992-04-25  |  5KB  |  320 lines

  1. //
  2. // *************************************************************************
  3. // *                                                                       *
  4. // *    OMEGA C++ Windowing Class Library                                  *
  5. // *    =================================                                  *
  6. // *                                                                       *
  7. // *    Copyright 1991,92 Tom Clancy                                       *
  8. // *    Submitted to the public domain, April 1992                         *
  9. // *                                                                       *
  10. // *************************************************************************
  11. // *                                                                       *
  12. // *    Assembly Routines for Fast Screen Writing                          *
  13. // *                                                                       *
  14. // *************************************************************************
  15. //
  16.  
  17. #include <dos.h>
  18. #include <string.h>
  19. #include "fastwrit.hpp"
  20.  
  21. int FWIDTH;
  22.  
  23. void fastwritestr(int x, int y, char fg, char bk, char far *str, int vseg, int voff) {
  24.  
  25.   asm {
  26.     push ax
  27.     push bx
  28.     push si
  29.     push di
  30.     push es
  31.     push ds
  32.     dec  x
  33.     dec  y
  34.     mov  ax,[vseg]
  35.     push ax
  36.     pop  es
  37.     xor  ax,ax
  38.     add  ax,y
  39.     mov  bx,FWIDTH
  40.     mul  bx
  41.     mov  bx,x
  42.     shl  bx,1
  43.  
  44.     add  ax,bx
  45.     add  ax,[voff]
  46.     mov  di,ax
  47.     push es
  48.     push di
  49.   }
  50.  
  51.   _CX=_fstrlen(str);
  52.  
  53.   asm {
  54.     pop  di
  55.     pop  es
  56.     lds  si,str
  57.  
  58.     xor  ax,ax
  59.     mov  ah,bk
  60.     shl  ah,1
  61.     shl  ah,1
  62.     shl  ah,1
  63.     shl  ah,1
  64.     add  ah,fg
  65.   }
  66.  
  67. getnext:
  68.  
  69.   asm {
  70.     lodsb
  71.     stosw
  72.     loop getnext
  73.     pop ds
  74.     pop es
  75.     pop di
  76.     pop si
  77.     pop bx
  78.     pop ax
  79.   }
  80. }
  81.  
  82.  
  83. void plainwritestr(int x, int y, char far *str, int vseg, int voff) {
  84.  
  85.   asm {
  86.     push ax
  87.     push bx
  88.     push si
  89.     push di
  90.     push es
  91.     push ds
  92.     dec  x
  93.     dec  y
  94.     mov  ax,[vseg]
  95.     push ax
  96.     pop  es
  97.     xor  ax,ax
  98.     add  ax,y
  99.     mov  bx,FWIDTH
  100.     mul  bx
  101.     mov  bx,x
  102.     shl  bx,1
  103.  
  104.     add  ax,bx
  105.     add  ax,[voff]
  106.     mov  di,ax
  107.     push es
  108.     push di
  109.   }
  110.  
  111.   _CX=_fstrlen(str);
  112.  
  113.   asm {
  114.     pop  di
  115.     pop  es
  116.     lds  si,str
  117.  
  118.   }
  119.  
  120. getnext:
  121.  
  122.   asm {
  123.     lodsb
  124.     stosb
  125.     inc  di
  126.     loop getnext
  127.     pop ds
  128.     pop es
  129.     pop di
  130.     pop si
  131.     pop bx
  132.     pop ax
  133.   }
  134. }
  135.  
  136. void fastwritech(int x, int y, char fg, char bk, unsigned char c, int vseg, int voff) {
  137.  
  138.  
  139.   asm {
  140.     push ax
  141.     push bx
  142.     push si
  143.     push di
  144.     push es
  145.     push ds
  146.     dec  x
  147.     dec  y
  148.     mov  ax,[vseg]
  149.     push ax
  150.     pop  es
  151.     xor  ax,ax
  152.     add  ax,y
  153.     mov  bx,FWIDTH
  154.     mul  bx
  155.     mov  bx,x
  156.     shl  bx,1
  157.  
  158.     add  ax,bx
  159.     add  ax,[voff]
  160.     mov  di,ax
  161.  
  162.     xor  ax,ax
  163.     mov  ah,bk
  164.     shl  ah,1
  165.     shl  ah,1
  166.     shl  ah,1
  167.     shl  ah,1
  168.     add  ah,fg
  169.     mov  al,c
  170.     stosw
  171.     pop ds
  172.     pop es
  173.     pop di
  174.     pop si
  175.     pop bx
  176.     pop ax
  177.   }
  178. }
  179.  
  180. void plainwritech(int x, int y, unsigned char c, int vseg, int voff) {
  181.  
  182.  
  183.   asm {
  184.     push ax
  185.     push bx
  186.     push si
  187.     push di
  188.     push es
  189.     push ds
  190.     dec  x
  191.     dec  y
  192.     mov  ax,[vseg]
  193.     push ax
  194.     pop  es
  195.     xor  ax,ax
  196.     add  ax,y
  197.     mov  bx,FWIDTH
  198.     mul  bx
  199.     mov  bx,x
  200.     shl  bx,1
  201.  
  202.     add  ax,bx
  203.     add  ax,[voff]
  204.     mov  di,ax
  205.  
  206.     mov  al,c
  207.     stosb
  208.     pop  ds
  209.     pop  es
  210.     pop di
  211.     pop si
  212.     pop bx
  213.     pop ax
  214.   }
  215. }
  216.  
  217. void fastattrib(int y, int x1, int x2, char fg, char bk, int vseg, int voff) {
  218.  
  219.   asm {
  220.     push ax
  221.     push bx
  222.     push si
  223.     push di
  224.     push es
  225.     push ds
  226.     dec  x1
  227.     dec  x2
  228.     dec  y
  229.     mov  ax,[vseg]
  230.     push ax
  231.     pop  es
  232.     xor  ax, ax
  233.     add  ax,y
  234.     mov  bx,FWIDTH
  235.     mul  bx
  236.     mov  bx,x1
  237.     shl  bx,1
  238.  
  239.     add  ax,bx
  240.     add  ax,[voff]
  241.     mov  di,ax
  242.     push es
  243.     push di
  244.   }
  245.  
  246.   _CX=(x2-x1)+1;
  247.  
  248.   asm {
  249.     pop  di
  250.     pop  es
  251.  
  252.     xor  ax,ax
  253.     mov  al,bk
  254.     shl  al,1
  255.     shl  al,1
  256.     shl  al,1
  257.     shl  al,1
  258.     add  al,fg
  259.   }
  260.  
  261. getnext:
  262.  
  263.   asm {
  264.     inc  di
  265.     stosb
  266.     loop getnext
  267.     pop ds
  268.     pop es
  269.     pop di
  270.     pop si
  271.     pop bx
  272.     pop ax
  273.   }
  274. }
  275.  
  276.  
  277. void shadowchar(int x, int y, int vseg, int voff) {
  278.   asm {
  279.     push ax
  280.     push bx
  281.     push si
  282.     push di
  283.     push es
  284.     push ds
  285.     dec  x
  286.     dec  y
  287.     mov  ax,[vseg]
  288.     push ax
  289.     pop  es
  290.     xor  ax,ax
  291.     add  ax,y
  292.     mov  bx,FWIDTH
  293.     mul  bx
  294.     mov  bx,x
  295.     shl  bx,1
  296.  
  297.     add  ax,bx
  298.     add  ax,[voff]
  299.     mov  di,ax
  300.  
  301.     push di
  302.     mov  si,di
  303.     push es
  304.     pop  ds
  305.  
  306.     lodsw
  307.  
  308.     and  ax,2047
  309.  
  310.     pop  di
  311.     stosw
  312.     pop ds
  313.     pop es
  314.     pop di
  315.     pop si
  316.     pop bx
  317.     pop ax
  318.   }
  319. }
  320.