home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PIXELATE.ZIP / PIXELATE.TXT < prev   
Internet Message Format  |  1993-04-13  |  20KB

  1. Path: pdxgate!usenet.ee.pdx.edu!reed!ogicse!decwrl!wupost!howland.reston.ans.net!bogus.sura.net!news-feed-1.peachnet.edu!umn.edu!gaia.ucs.orst.edu!ucs.orst.edu!ketrenoj
  2. From: ketrenoj@ucs.orst.edu (Lord Logics)
  3. Newsgroups: comp.sys.ibm.pc.demos
  4. Subject: Scaling code in ASM . . .
  5. Message-ID: <1q568m$hdv@gaia.ucs.orst.edu>
  6. Date: 10 Apr 93 01:01:10 GMT
  7. Organization: University Computing Services - OSU
  8. Lines: 97
  9. NNTP-Posting-Host: ucs.orst.edu
  10.  
  11. Fellow netters, coders, and other people . . .
  12.  
  13. Finally a decent news group for exchanging source code . . .  here's
  14. my first contribution.  I wrote the code in the beginning of last 
  15. summer.  It was the first code I wrote that implemented the VGA (I had 
  16. just purchased VGA)  Anyway, this is the fastest method I could come up 
  17. with for scaling an image.  If there is a faster way, please post, or if 
  18. you make any optimizations to this routine, please post them as well.
  19.  
  20. Sorry if it is hard to follow, and if the comments are confusing.
  21.  
  22. Oh yeah, I don't know what the normal message limit is, so I'll split 
  23. this up into 100 line increments.  Should be a total of 3 posts.
  24.  
  25. NOTE:  I haven't tested this routine in quite a while, and I can't 
  26. remember if I had made any changes since I last used it.  If it doesn't 
  27. work, let me know and I'll work on it.
  28.  
  29.  
  30. James
  31. -=[ Lord Logics ]=-
  32.  
  33. ketrenoj@ucs.orst.edu
  34.  
  35.  
  36.  
  37. ;----------
  38.  
  39. .model huge,c
  40. .data
  41.  
  42.         X_SIZE          dw      0
  43.         Y_SIZE          dw      0
  44.         X_SKIP          dw      0
  45.  
  46. .code
  47. ;*************************************************************************
  48. ;** PROC: pixelate()
  49. ;** PURP: To put an image onto the screen from VGA memory w/ pitching
  50. ;** USAG: pixelate(char *buffer,int x,int y,int ratio);
  51. ;**       Ratio is a word.  The value is in a ratio of 256.  So,
  52. ;**       the ratio of 520 would result in 49% of the original size.
  53. ;**       (In other words, 256/Ratio = New Size)
  54. ;**
  55. ;**       Buffer is broken down as follows:
  56. ;**       X Size (2), Y Size (2), then the image. 
  57. ;**
  58. ;**       NOTE:  No clipping is done for this, and it is currently
  59. ;**              only written to support chained mode.  I am rewriting
  60. ;**              it to perform clipping and support for unchained video
  61. ;**              modes.  Questions or comments email:
  62. ;**            
  63. ;**              ketrenoj@ucs.orst.edu
  64. ;**              -=[ Lord Logics ]=-      
  65. ;**       Group: None.  Want me?  Contact me . . .
  66. ;**
  67. ;*************************************************************************
  68. pixelate        proc far
  69.         push    bp
  70.         mov     bp,sp
  71.         push    es
  72.         push    ds
  73.         push    si
  74.         push    di
  75.  
  76.         cld
  77.  
  78.         mov     ax,@data
  79.         mov     ds,ax
  80.  
  81.         mov     di,[bp+8]       ; Set ES:[DI] to point to the buffer . . .
  82.         mov     es,di           ; :
  83.         mov     di,[bp+6]       ; :
  84.  
  85.         mov     dx,es:[di]      ; X_SIZE is stored in DX
  86.         mov     cx,es:[di+2]    ; Y_SIZE is stored in CX
  87.  
  88.         mov     ax,[bp+14]      ; We will now do some adjustemnts via ratio
  89.         push    dx              ; Set up the ratio factor to adjust the
  90.         push    ax              ; : X_SIZE and Y_SIZE, and X and Y POS.
  91.         mul     dx              ; :
  92.         mov     bx,0100h        ; :
  93.         div     bx              ; :
  94.         mov     X_SIZE,ax       ; : Newly adjusted X_SIZE (after pitching)
  95.         pop     ax              ; :
  96.         mul     cx              ; :
  97.         div     bx              ; :
  98.         mov     Y_SIZE,ax       ; : Newly adjusted Y_SIZE (after pitching)
  99.         pop     dx              ; :
  100.  
  101. ;** Now check to make sure that there is indeed something to display . . .
  102.         cmp     X_SIZE,0        ; Check to see if there is still an image.
  103.         jz      px_d            ; :
  104.         cmp     Y_SIZE,0        ; :
  105.         jz      px_d            ; :
  106.  
  107. ; Continued in next post . . .
  108.  
  109. Path: pdxgate!usenet.ee.pdx.edu!reed!ogicse!flop.ENGR.ORST.EDU!gaia.ucs.orst.edu!ucs.orst.edu!ketrenoj
  110. From: ketrenoj@ucs.orst.edu (Lord Logics)
  111. Newsgroups: comp.sys.ibm.pc.demos
  112. Subject: Scaling code in ASM [2/3]
  113. Message-ID: <1q56d9$ho7@gaia.ucs.orst.edu>
  114. Date: 10 Apr 93 01:03:37 GMT
  115. References: <1q568m$hdv@gaia.ucs.orst.edu>
  116. Organization: University Computing Services - OSU
  117. Lines: 87
  118. NNTP-Posting-Host: ucs.orst.edu
  119.  
  120. ; Continued from last post . . .
  121.  
  122. ;** Now we will figure out how much the X and Y POS will be changed . . .
  123. ;** On entry:
  124. ;** AX - Nothing
  125. ;** BX - Nothing
  126. ;** CX - Y_SIZE (no pitching)
  127. ;** DX - X_SIZE (no pitching)
  128. ;** ES:[DI] - Image Buffer
  129. ;** DS:[SI] - Nothing
  130. px_sx:  sub     dx,X_SIZE       ; Set up the X_SIZE variance . . .
  131.         jge     px_xn           ; : Variance = 1/2 the size difference . . .
  132.         neg     dx              ; :
  133.         shr     dx,1            ; :
  134.         neg     dx              ; :
  135.         jmp     px_sy           ; :
  136. px_xn:  shr     dx,1            ; :
  137. px_sy:  sub     cx,Y_SIZE       ; Set up the Y_SIZE variance . . .
  138.         jge     px_yn           ; :
  139.         neg     cx              ; :
  140.         shr     cx,1            ; :
  141.         neg     cx              ; :
  142.         jmp     px_si           ; :
  143. px_yn:  shr     cx,1            ; :
  144.  
  145. px_si:  xor     bx,bx           ; Clear initial DI displacement.
  146.         push    dx
  147.         mov     ax,[bp+12]      ; Set up the starting point and check
  148.         add     ax,cx           ; : to make sure that the image will fit
  149.         cmp     ax,200          ; : within our bounds (ie, the screen).
  150.         jge     px_d            ; :
  151.         cmp     ax,0            ; :
  152.         jge     px_s1           ; :
  153.         push    ax              ; :
  154.         neg     ax              ; :
  155.         sub     Y_SIZE,ax       ; :             THE FOLLOWING MAY CAUSE
  156.         jle     px_ddx          ; :             PROBLEMS DURING CLIPPING.
  157.         mov     dx,es:[di]      ; : Set DX to X_SIZE (no pitching)
  158.         push    ax              ; :
  159.         mul     dx              ; :
  160.         mov     bx,ax           ; : BX stores DI adjustment . . .
  161.         mov     dx,320          ; :
  162.         pop     ax              ; :
  163.         mul     dx              ; :
  164.         mov     si,ax           ; :
  165.         pop     ax              ; :
  166.         jmp     px_s2           ; :
  167.  
  168. ;**
  169. ;** Exit the procedure . . .
  170. ;**
  171. px_ddx: pop     dx
  172. px_dax: pop     ax
  173. px_d:   pop     di
  174.         pop     si
  175.         pop     ds
  176.         pop     es
  177.         pop     bp
  178.         ret
  179.  
  180. px_s1:  mov     dx,320          ; Adjust SI for proper positioning.
  181.         mul     dx              ; :
  182.         mov     si,ax           ; :
  183.  
  184. px_s2:  pop     dx              ; Now do the X Adjusting . . .
  185.         mov     ax,[bp+10]      ; Set up the starting point and check
  186.         add     ax,dx           ; : to make sure that the image will fit
  187.         cmp     ax,320          ; : within our bounds (ie, the screen).
  188.         jge     px_d            ; :
  189.         cmp     ax,0            ; :
  190.         jge     px_s3           ; :
  191.         neg     ax              ; :
  192.         sub     X_SIZE,ax       ; :
  193.         jle     px_d            ; :
  194.         add     bx,ax           ; :
  195.         jmp     px_s4           ; :
  196.  
  197. px_s3:  add     si,ax           ; Set up screen position adjustment
  198. px_s4:  mov     cx,bx
  199.         mov     bx,es:[di]
  200.         add     di,cx
  201.         add     di,4
  202.         mov     cx,Y_SIZE
  203.         mov     dx,X_SIZE
  204.         jmp     px_pixel
  205.  
  206. ; Continued in next post . . .
  207.  
  208. Path: pdxgate!usenet.ee.pdx.edu!reed!ogicse!flop.ENGR.ORST.EDU!gaia.ucs.orst.edu!ucs.orst.edu!ketrenoj
  209. From: ketrenoj@ucs.orst.edu (Lord Logics)
  210. Newsgroups: comp.sys.ibm.pc.demos
  211. Subject: Scaling code in ASM [3/3]
  212. Message-ID: <1q56ii$hrj@gaia.ucs.orst.edu>
  213. Date: 10 Apr 93 01:06:26 GMT
  214. References: <1q568m$hdv@gaia.ucs.orst.edu>
  215. Organization: University Computing Services - OSU
  216. Lines: 87
  217. NNTP-Posting-Host: ucs.orst.edu
  218.  
  219. ; Continued from last post . . .
  220.  
  221. ;**
  222. ;** Display the image as quick as possible.
  223. ;**
  224. ;** On entry:
  225. ;** ES:[DI] Points to image buffer
  226. ;** DS:[SI] Points to screen memory location (start point)
  227. ;** AX - nothing important
  228. ;** BX - X_SIZE w/out any pitching.  This is used to add to the memory
  229. ;**      buffer for each line displayed.
  230. ;** CX - Y_COUNT size.  The number of Y_LINES to display
  231. ;** DX - X_COUNT size.  The number of X_LINES to display
  232. ;**
  233. px_pixel:
  234.         ;** First we must set up our ratio skipping . . .
  235.         push    dx              ; Save X_COUNT
  236.         push    bx              ; Save X_SIZE
  237.         mov     bx,[bp+14]      ; Set skipping bytes . . .
  238.         xor     dx,dx           ; :
  239.         mov     ax,0FFFFh       ; :
  240.         or      bx,bx           ; :
  241.         jz      px_pd           ; :
  242.         div     bx              ; :
  243.         jmp     px_pf           ; :
  244. px_pd:  mov     ax,0100h        ; :
  245. px_pf:  mov     [bp+14],ax      ; :
  246.         pop     bx              ; Restore X_SIZE
  247.         pop     dx              ; Restore X_COUNT
  248.  
  249.  
  250.         ;** Now we must set up our starting points . . .
  251.         mov     ax,es           ; Set DS:[SI] to our image,
  252.         mov     ds,ax           ; : ES:[DI] to the screen position,
  253.         mov     ax,0A000h       ; : BP to point to the ratio skip,
  254.         mov     es,ax           ; : and AX to the skip, roll over . . .
  255.         xchg    si,di           ; :
  256.         add     bp,14           ; :
  257.         mov     al,[bp+1]       ; :
  258.         xor     ah,ah           ; :
  259.         mov     [bp-2],ah       ; :
  260.  
  261.         ;** Now, actually display the image via to for/next loops . . .
  262. pxq_y:  push    cx              ; Save the Y_COUNT
  263.         push    ax              ; Save the Whole Adjustment
  264.         push    bx              ; Save the X_SIZE (no pitching)
  265.         push    dx              ; Save the X_COUNT
  266.         push    si              ; Save the start of line position
  267.  
  268.         ;** Now we will loop through the X_LINE, first setting up the
  269.         ;** : values needed internally though . . .
  270.         mov     cx,dx           ; Set CX to X_COUNT
  271.         mov     dl,[bp]         ; Set DL to Ratio
  272.         xor     dh,dh           ; Clear the Spill Over
  273.  
  274. pxq_x:  movsb                   ; Move one byte
  275.         dec     si              ; : Fix the SI from being incremented.
  276.         add     dh,dl           ; Do pitching . . .
  277.         adc     si,ax           ; :
  278.         loop    pxq_x           ; Do the entire X_LINE
  279.  
  280.         ;** Now we will adjust for the next X_LINE along the Y_LINE . . .
  281.         pop     si              ; Restore start of line position.
  282.         pop     bx              ; Adjust the dest screen position . . .
  283.         add     di,320          ; :
  284.         sub     di,bx           ; :
  285.  
  286.         add     [bp-2],dl       ; Do the pitching . . .
  287.         adc     ax,0            ; :
  288.         mov     dx,ax           ; :
  289.         pop     ax              ; : Restore AX to the X_SIZE
  290.         mov     cx,bx           ; : Set CX to X_COUNT
  291.         mov     bx,ax           ; : Set BX to X_SIZE
  292.         mul     dx              ; :
  293.         add     si,ax           ; :
  294.         pop     ax              ; : Restore Whole Adjustment
  295.         mov     dx,cx           ; : Set DX to X_COUNT
  296.         pop     cx              ; Restore Y_COUNT
  297.         loop    pxq_y           ; Do the entire Y_LINE.
  298.         jmp     px_d            ; Exit the PIXELATE routine.
  299. pixelate        endp            ; END OF PIXELATE
  300.         end
  301.  
  302.  
  303. ; That's it.  It was written using MASM (don't know what version) but i don't
  304. ; think it uses any special pseudo ops from that, so it should work on TASM.
  305.  
  306. Path: pdxgate!usenet.ee.pdx.edu!reed!ogicse!emory!news-feed-1.peachnet.edu!bogus.sura.net!howland.reston.ans.net!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!jas37876
  307. From: jas37876@uxa.cso.uiuc.edu (John A. Slagel)
  308. Newsgroups: comp.sys.ibm.pc.demos
  309. Subject: ModeX Bitmap Scaling Code...
  310. Message-ID: <C58vGz.6Ev@news.cso.uiuc.edu>
  311. Date: 10 Apr 93 01:43:47 GMT
  312. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  313. Organization: University of Illinois at Urbana
  314. Lines: 260
  315.  
  316.  
  317.     Well, seeing how someone posted code to do scaling, here's my
  318.     equivalent code for ModeX.  It requires an input bitmap of
  319.     128x128 and scales up or down, with clipping, and the clipping
  320.     only slows the display down by a constant amount no matter how
  321.     much is clipped.  This only changes the pixel plane once for
  322.     every column, so it is very fast for a ModeX routine.  
  323.  
  324.     I'm posting this in hopes that people unselfishly post some
  325.     of there own code... Anyway, enjoy.   
  326.  
  327.     Oh yeah, erase the .sig at the end.
  328.  
  329. ;=============================================================================
  330. ; XSTRETCHBMP By John A. Slagel,  jas37876@uxa.cso.uiuc.edu
  331. ; Feel free to use this any way you want.  Let me know if you find any
  332. ; bugs or optimizations, and I would be interested in seeing any final
  333. ; projects that use this. Thanks.
  334. ;
  335. ; This routine stretches (or shrinks) a 128x128 bitmap in VGA ModeX.
  336. ;   o Color Indices of 255 are "invisible" or "masked" -- They don't draw.
  337. ;   o Only changes the bitplane 1 time per column, so it is fairly fast.
  338. ;   o Can only be used in 320x??? modes.
  339. ;   o Requires a 128x128 bitmap.
  340. ;   o Will only stretch proportionally.
  341. ;   o Can stretch from 2 up to very large stretching.
  342. ;   o Clips according to ClipLt, ClipRt, ClipTp, ClipBt, which should be
  343. ;     declared in your C routine in another module. You also need to have
  344. ;     the ModeXseg variable declared elsewhere. Normally A000, A800, etc..
  345. ;   o Clipping only takes a constant time when it is neccessary.
  346. ;   o Requires a 386 processor
  347. ;   o Requires MASM 5.1
  348. ;   o C-callable as:
  349. ;       void XSTRETCHBMP( int x, int y, int w, BYTE  *Bitmap );
  350. ;            x,y = Screen Position
  351. ;            w   = Width to stretch it on the screen
  352. ;            Bitmap = Pointer to 128x128 byte array of pixel data 
  353. ;       Needs extern variables,ClipLt, ClipRt, ClipTp, ClipBt, ModeXseg
  354. ;============================================================================
  355. .MODEL LARGE, C
  356. .386
  357.  
  358. .DATA
  359. SC_INDEX1       EQU 03C4h
  360. SC_INDEX2       EQU 03C5h
  361. MAP_MASK        EQU 2
  362. INVISIBLE_COLOR EQU 255
  363.  
  364. extrn ClipTp:word
  365. extrn ClipLt:word
  366. extrn ClipRt:word
  367. extrn ClipBt:word
  368. extrn ModeXseg:word
  369.  
  370. .CODE
  371.  
  372. XSTRETCHBMP PROC FAR USES DI SI, DestXStart:WORD, DestYStart:WORD, DestSize:WORD, Bitmap:FAR PTR
  373. LOCAL DestHeight:WORD, DecisionY:WORD, DestWidth:WORD,  DecisionX:WORD, DestSize2:WORD, Doff:WORD, Soff:WORD
  374.  
  375.         mov     DestHeight,0 
  376.         mov     DecisionY, 0
  377.         mov     DestWidth, 0
  378.         mov     DecisionX, 0
  379.         mov     DestSize2, 0
  380.         mov     Doff, 0
  381.         mov     Soff, 0
  382.  
  383.         cmp     DestSize, 2
  384.         jl      Done        ; If it is too small then exit 
  385.  
  386.         mov     ax, DestYStart
  387.         cmp     ax, ClipBt
  388.         jg      Done        ; If it is too far down then exit 
  389.  
  390.         add     ax, DestSize
  391.         dec     ax
  392.         cmp     ax, ClipTp
  393.         jl      Done        ; If it is too far up then exit
  394.  
  395.         mov     ax, DestXStart
  396.         cmp     ax, ClipRt
  397.         jg      Done        ; If it is too far right then exit 
  398.  
  399.         add     ax, DestSize
  400.         dec     ax 
  401.         cmp     ax, ClipLt
  402.         jl      Done            ; If it is too far left then exit
  403.  
  404.         mov     ax, DestSize
  405.         mov     DestWidth,  ax  ; Initialize DestWidth=DestSize
  406.         mov     DestHeight, ax  ; Initialize DestHeight=DestSize
  407.  
  408.         mov     Soff, 0         ; Point Soff to start of bitmap
  409.  
  410.         mov     DestSize2, ax
  411.         shl     DestSize2, 1    ; Calculate DestSize*2 for later
  412.  
  413.         shl     ax, 1
  414.         neg     ax
  415.         mov     DecisionX, ax   ; DecisionX = -DestSize
  416.         mov     DecisionY, ax   ; DecisionY = -DestSize
  417.  
  418.         movsx   eax, ClipTp
  419.         movsx   ecx, DestYStart
  420.         sub     eax, ecx        ; EAX = ClipTp-DestYStart
  421.         jle     NoTopClip
  422.         ;Clip off the top
  423.         sub     DestHeight, ax  ; DestHeight -= (ClipTp-DestYStart)
  424.         mov     ebx, eax        ; EBX = AmountClippedY
  425.         xor     edx, edx        ; EDX = 0
  426.         shl     eax, 7          ; EDX:EAX = AmountClippedY * 128
  427.         movzx   ecx, DestSize
  428.         div     ecx             ; EAX (SourceStartY) = EDX:EAX / DestSize 
  429.         add     Soff, ax        ; Soff = SourceStartY (EAX) 
  430.         shl     Soff, 7         ;                           * 128
  431.         shl     ebx, 8          ; EBX = AmountClippedY * 256
  432.         shl     ecx, 1          ; ECX = DestSize2
  433.         mul     ecx             ; EDX:EAX = SourceStartY * DestSize2
  434.         sub     ebx, eax
  435.         add     DecisionY, bx
  436.         mov     ax, ClipTp
  437.         mov     DestYStart, ax
  438.  
  439. NoTopClip:  
  440.         mov     ax, DestYStart
  441.         add     ax, DestHeight
  442.         dec     ax
  443.         cmp     ax, ClipBt
  444.         jle NoBottomClip  
  445.         ; Clip off the bottom
  446.         mov     ax, ClipBt
  447.         sub     ax, DestYStart
  448.         inc     ax
  449.         mov     DestHeight, ax
  450.  
  451. NoBottomClip:   
  452.         movsx   eax, ClipLt
  453.         movsx   ecx, DestXStart
  454.         sub     eax, ecx
  455.         jle     NoLeftClip
  456.         ;Clip off the left side
  457.         sub     DestWidth, ax   ; DestWidth -= (ClipLT-DestXStart)
  458.         mov     ebx, eax        ; EBX = AmountClippedX
  459.         xor     edx, edx        ; EDX = 0
  460.         shl     eax, 7          ; EDX:EAX = AmountClippedX * 128
  461.         movzx   ecx, DestSize
  462.         div     ecx             ; EAX (SourceStartX) = EDX:EAX / DestSize 
  463.         add     Soff, ax        ; Soff += SourceStartX (EAX) 
  464.         shl     ebx, 8          ; EBX = AmountClippedX * 256
  465.         shl     ecx, 1          ; ECX = DestSize2
  466.         mul     ecx             ; EDX:EAX = SourceStartX * DestSize2
  467.         sub     ebx, eax
  468.         add     DecisionX, bx
  469.         mov     ax, ClipLt
  470.         mov     DestXStart, ax
  471. NoLeftClip:     
  472.         mov     ax, DestXStart
  473.         add     ax, DestWidth
  474.         dec     ax
  475.         cmp     ax, ClipRt
  476.         jle NoClipRight 
  477.         ; Clip off the right
  478.         mov     ax, ClipRt
  479.         sub     ax, DestXStart
  480.         inc     ax
  481.         mov     DestWidth, ax
  482.  
  483.         ;Calculate starting video address
  484. NoClipRight:    
  485.         mov     ax, ModeXseg 
  486.         mov     gs, ax
  487.         movsx   eax, DestYStart 
  488.         lea     eax, [eax*2]
  489.         lea     eax, [eax*8]
  490.         lea     eax, [eax+eax*4]
  491.         mov     bx, DestXStart
  492.         mov     cx, bx
  493.         shr     bx, 2
  494.         add     ax, bx
  495.         mov     Doff, ax    ; gS:Doff -> VGA memory
  496.  
  497.     mov     dx, SC_INDEX1
  498.         mov     al, MAP_MASK
  499.         out     dx, al
  500.         inc     dx
  501.         and     cx, 3
  502.         mov     al, 11h
  503.         shl     al, cl
  504.     out     dx, al      ; Select the first plane
  505.         
  506.         lfs     si, Bitmap
  507.         add     Soff, si
  508.     mov     dx, DestSize2
  509. ColumnLoop:     
  510.         mov     di, Doff
  511.         mov     si, Soff
  512.         mov     bx, DecisionY
  513.         mov     cx, DestHeight
  514.         inc     cx
  515.  
  516.         jmp     NextPixel
  517. RowLoop:        
  518.         mov     gs:[di], ah
  519.         add     di, 80
  520.         add     bx, 256
  521.     js      Visible
  522. IncSourceY:     
  523.         add     si, 128
  524.     sub     bx, dx
  525.         jns     IncSourceY
  526. NextPixel:      
  527.         mov     ah, fs:[si]
  528.         cmp     ah, INVISIBLE_COLOR
  529.         je      MaskedPixel
  530. Visible:
  531.         loop    RowLoop
  532. DoneWithCol:    
  533.         rol     al, 1
  534.         adc     Doff, 0
  535.     mov     dx, SC_INDEX2
  536.     out     dx, al
  537.     mov     dx, DestSize2
  538.     add     DecisionX, 256
  539.         js      NextCol
  540.         mov     bx, DecisionX
  541. IncSourceX: 
  542.         inc     Soff
  543.     sub     bx, dx
  544.         jns     IncSourceX
  545.         mov     DecisionX, bx
  546. NextCol:        
  547.         dec     DestWidth
  548.         jnz     ColumnLoop
  549. Done:           
  550.         ret
  551.  
  552. MRowLoop:       
  553.         add     di, 80
  554.         add     bx, 256
  555.         js      MaskedPixel
  556. MSourceIncY:    
  557.         add     si, 128
  558.     sub     bx, dx
  559.         jns     MSourceIncY
  560.         mov     ah, fs:[si]
  561.         cmp     ah, INVISIBLE_COLOR
  562.         jne     Visible
  563. MaskedPixel:    
  564.         loop    MRowLoop
  565.         jmp     DoneWithCol
  566.  
  567. XSTRETCHBMP     ENDP
  568.  
  569.  
  570. END
  571. -- 
  572. -----------------------------------------------------------------------------
  573.  John A. Slagel              "My old man used to tell me, before he left this
  574.  j-slagel1@uiuc.edu           shitty world, never chase buses or women- you
  575.  (217) 337-7930               always get left behind." -The Marlboro Man
  576.  
  577.