home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / COMMON.ZIP / M13.C < prev    next >
Encoding:
Text File  |  1995-05-10  |  2.7 KB  |  128 lines

  1. /*
  2.  
  3.     m13.c
  4.  
  5.     Internet: alexad3@icebox.iceonline.com
  6.     Copyright 1995, May 10 by Alec Russell, ALL rights reserved
  7.  
  8.     Created - 1995/5/10
  9.  
  10.     History:
  11.         New file
  12.  
  13. */
  14.  
  15.  
  16. /*
  17.  
  18.    damn fast, bitmap drawing routine
  19.  
  20.    x, y, width, height all in pixels, mode 0x13 ONLY
  21.  
  22.    MAX width and height is 255!!!!!
  23.  
  24.    buffer pointer to a width by height array of bytes that are a bitmap
  25.  
  26.    x, y is position to display at, NO checking done for valid
  27.    co-ords etc...
  28.  
  29.    WIDTH MUST BE EVEN!!!!
  30.  
  31. */
  32. /* ---------------------- put_blit() --------------------- March 23,1993 */
  33. void put_blit(FARPTR buffer, short x, short y, short width, short height)
  34. {
  35.    asm   {
  36.          push  ds
  37.          push  di
  38.  
  39.          /* calc start address in vido mem */
  40.          mov   ax, y
  41.          mov   bx, x
  42.          xchg  ah, al
  43.          add   bx, ax
  44.          shr   ax, 1
  45.          shr   ax, 1
  46.          add   bx, ax
  47.  
  48.          /* set up address registers for movsw */
  49.          mov   ax, 0xa000
  50.          mov   es, ax
  51.          mov   di, bx
  52.          lds   si, buffer
  53.  
  54.          /* set up width and adjustment for fast blat */
  55.          mov   dx, width
  56.          shr   dx, 1
  57.          mov   bx, 320
  58.          sub   bx, width
  59.          mov   ax, height
  60.          }
  61.  
  62.          /* blast each line */
  63. l1:
  64.    asm   {
  65.          mov   cx, dx
  66.          rep   movsw
  67.          add   di, bx
  68.          dec   ax
  69.          jnz   l1
  70.  
  71.          /* all done */
  72.          pop   di
  73.          pop   ds
  74.          }   
  75. }
  76.  
  77.  
  78. /* ---------------------- put_blit() --------------------- March 23,1993 */
  79. void put_blit_odd(FARPTR buffer, short x, short y, short width, short height)
  80. {
  81.    asm   {
  82.          push  ds
  83.          push  di
  84.  
  85.          /* calc start address in vido mem */
  86.          mov   ax, y
  87.          mov   bx, x
  88.          xchg  ah, al
  89.          add   bx, ax
  90.          shr   ax, 1
  91.          shr   ax, 1
  92.          add   bx, ax
  93.  
  94.          /* set up address registers for movsw */
  95.          mov   ax, 0xa000
  96.          mov   es, ax
  97.          mov   di, bx
  98.          lds   si, buffer
  99.  
  100.          /* set up width and adjustment for fast blat */
  101.          mov   dx, width
  102.          shr   dx, 1
  103.          mov   bx, 320
  104.          sub   bx, width
  105.          mov   ax, height
  106.          }
  107.  
  108.          /* blast each line */
  109. l1:
  110.    asm   {
  111.          mov   cx, dx
  112.          rep   movsw
  113.           adc   cx,0        /* this trick is the fastest for 386, but a cmp/brn
  114.                               might be faster on the 486 & p5 */ 
  115.           rep   movsb
  116.          add   di, bx
  117.          dec   ax
  118.          jnz   l1
  119.  
  120.          /* all done */
  121.          pop   di
  122.          pop   ds
  123.          }   
  124. }
  125.  
  126. /* ------------------------------ EOF -------------------------------- */
  127.  
  128.