home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / hellsrc.zip / PSBM.RT < prev    next >
Text File  |  1993-10-16  |  7KB  |  245 lines

  1. public  _psbm
  2. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  3. ; Put a damn scaled bitmap to modeX screen (with clipping ofcourse). This one
  4. ; still doesn't use RLE... Just a plain old scaled bitblt with 0 checking in
  5. ; 4 MOD(4) bitmap puts.
  6. ; In:
  7. ;   EAX low word - X loc in 320*200 screen to put at
  8. ;   EAX high word - Y loc in 320*200 screen to put at
  9. ;   EBX low word - actual X size of bitmap
  10. ;   EBX high word - actual Y size of bitmap
  11. ;   ECX low word - X size to put
  12. ;   ECX high word - Y size to put
  13. ;   DS:SI -> bitmap
  14. ;   ES:DI -> physical screen buffer (full 320*200 modeX)
  15. ; Notes:
  16. ;   Don't call this routine with any X or Y sizes of 0.
  17. ;   The index on the VGA sequencer reg is assumed to be 2.
  18. ;   This routine is still not the most optimal for the job.
  19. ;   Will work in real mode, just change '$+6' to '$+5' on line 47.
  20. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  21. VS=34
  22. ysfract         equ word ptr [esp+2]
  23. ysfractcount    equ word ptr [esp+4]
  24. ysdivisor       equ word ptr [esp+VS+26]
  25. ysoneline       equ word ptr [esp+VS+16]
  26. ylineadd        equ word ptr [esp+16]
  27. ylinecount      equ word ptr [esp+6]
  28. srcptr          equ word ptr [esp+8]
  29. dstptr          equ word ptr [esp+10]
  30. ysfractcount2   equ word ptr [esp+18]
  31. ylinecount2     equ word ptr [esp]
  32. srcptr2         equ word ptr [esp+12]
  33. dstptr2         equ word ptr [esp+14]
  34. xsfract         equ word ptr [esp+20]
  35. xsfractcount    equ word ptr [esp+30]
  36. xsfractcounthi  equ dword ptr [esp+28]
  37. xsdivisor       equ word ptr [esp+VS+24]
  38. xpixeladd       equ word ptr [esp+24]
  39. xpixelcount     equ word ptr [esp+22]
  40. xstatword       equ word ptr [esp+26]
  41. xpixelstat      equ byte ptr [esp+32]
  42. ;─────────────────────────────────────────────────────────────────────────────
  43. rept 320
  44. temp=$
  45.         mov al,[si]
  46.         or al,al
  47.         jz short $+6
  48.         mov es:[di],al
  49.         add edi,ecx
  50.         adc si,bp
  51. PSBMPUTCODELEN=$-temp
  52. endm
  53. psbmputcode:
  54.         jmp psbml0c
  55. ;─────────────────────────────────────────────────────────────────────────────
  56. _psbm:
  57.         pushad
  58.         sub esp,VS
  59.  
  60.         cmp ax,140h                     ; out of bounds? (below or right)
  61.         jge psbmd
  62.         cmp eax,0c80000h
  63.         jge psbmd
  64.         mov edx,eax                     ; out of bounds¿ (above or left)
  65.         add dx,cx
  66.         cmp dx,0
  67.         jle psbmd
  68.         xor dx,dx
  69.         add edx,ecx
  70.         cmp edx,0ffffh
  71.         jle psbmd
  72.  
  73. ;-----------------------------------------------------------------------------
  74.         shld eax,ebx,16                 ; figure Y scale stuff (the easy part)
  75.         rol ecx,16
  76.         cwd
  77.         div cx
  78.         mov ysfract,dx
  79.         mul bx
  80.         mov ylineadd,ax
  81.  
  82.         mov bp,[esp+VS+30]              ; figure Y clip stuff (also easy)
  83.         add cx,bp
  84.         xor bx,bx
  85.         cmp bp,0
  86.         jge short psbmf0
  87.         sub bx,bp
  88.         xor bp,bp
  89. psbmf0:
  90.         mov ax,80
  91.         mul bp
  92.         add di,ax
  93.         cmp cx,200
  94.         jb short psbmf1
  95.         mov cx,200
  96. psbmf1:
  97.         sub bp,cx
  98.         neg bp
  99.         mov ylinecount,bp
  100.         mov ax,ysfract
  101.         mov bp,ysdivisor
  102.         mul bx
  103.         div bp
  104.         sub dx,bp
  105.         neg dx
  106.         mov ysfractcount,dx
  107.         mov ax,bx
  108.         mul word ptr [esp+VS+18]
  109.         div bp
  110.         mul ysoneline
  111.         add si,ax
  112.  
  113. ;-----------------------------------------------------------------------------
  114.         mov ax,[esp+VS+16]
  115.         shr ecx,16                      ; figure X scale crap (still easy)
  116.         cwd
  117.         div cx
  118.         mov xsfract,dx
  119.         mov xpixeladd,ax
  120.  
  121.         movzx ebp,word ptr [esp+VS+28]  ; figure X clip crap (more easy)
  122.         lea edx,[ecx+ebp]
  123.         xor bx,bx
  124.         cmp bp,0
  125.         jge short psbmf2
  126.         sub bx,bp
  127.         xor bp,bp
  128. psbmf2:
  129.         mov cx,bp
  130.         and cl,3
  131.         mov ax,401h
  132.         shl al,cl
  133.         mov xstatword,ax
  134.         mov ax,bp
  135.         shr ax,2
  136.         add di,ax
  137.         cmp dx,320
  138.         jb short psbmf3
  139.         mov dx,320
  140. psbmf3:
  141.         sub bp,dx
  142.         neg bp
  143.         add bp,3
  144.         mov ax,bp
  145.         and al,3
  146.         mov xpixelstat,al
  147.         shr bp,2
  148.         neg bp
  149.         imul bp,PSBMPUTCODELEN
  150.         add bp,offset psbmputcode
  151.         mov xpixelcount,bp
  152.         mov ax,xsfract
  153.         mov bp,xsdivisor
  154.         mul bx
  155.         div bp
  156.         mov xsfractcount,dx
  157.         mov ax,bx
  158.         mul word ptr [esp+VS+16]
  159.         div bp
  160.         add si,ax
  161.  
  162. ;-----------------------------------------------------------------------------
  163.     mov cx,xsdivisor        ; figure other misc stuff
  164.         mov dx,xsfractcount
  165.         xor ax,ax
  166.         div cx
  167.         shl eax,16
  168.         mov xsfractcounthi,eax
  169.     mov dx,xsfract
  170.         mov eax,10000h
  171.         div cx
  172.         mov xsfract,ax
  173.     mov bx,ax
  174.         shl bx,2
  175.         movzx ebp,xpixeladd
  176.         shl bp,2
  177.         shr ax,14
  178.         add ebp,eax
  179.         shrd ecx,ebx,16
  180.         mov cx,1
  181.         mov ax,xstatword
  182. ;─────────────────────────────────────────────────────────────────────────────
  183. psbml1:                                 ; main outer loop
  184.         mov srcptr,si
  185.         mov dstptr,di
  186.         mov xstatword,ax
  187.         mov dx,3c5h
  188.         out dx,al
  189.         mov ax,ysfractcount
  190.         mov ysfractcount2,ax
  191.         mov ax,ylinecount
  192.         mov ylinecount2,ax
  193. ;-----------------------------------------------------------------------------
  194. psbml0:
  195.         mov srcptr2,si
  196.         mov dstptr2,di
  197.         movzx edi,di
  198.         or edi,xsfractcounthi
  199.         jmp xpixelcount
  200. ;-----------------------------------------------------------------------------
  201. psbml0c:
  202.         mov si,srcptr2
  203.         mov ax,ysfractcount2
  204.         sub ax,ysfract
  205.         ja short psbml0c2
  206.         add ax,ysdivisor
  207.         add si,ysoneline
  208. psbml0c2:
  209.         mov ysfractcount2,ax
  210.         add si,ylineadd
  211.         mov di,dstptr2
  212.         add di,80
  213.         dec ylinecount2
  214.         jnz psbml0
  215. ;-----------------------------------------------------------------------------
  216. psbml1c:
  217.         sub xpixelstat,1
  218.         jnc short psbml1c2
  219.         mov ax,xpixelcount
  220.         add ax,PSBMPUTCODELEN
  221.         cmp ax,offset psbmputcode
  222.         je short psbmd
  223.         mov xpixelcount,ax
  224. psbml1c2:
  225.         mov si,srcptr
  226.         mov ax,xsfractcount
  227.         add ax,xsfract
  228.         adc si,0
  229.         mov xsfractcount,ax
  230.         add si,xpixeladd
  231.         mov di,dstptr
  232.         mov ax,xstatword
  233.         bt ax,3
  234.         rcl al,1
  235.         btr ax,4
  236.         adc di,0
  237.         dec ah
  238.         jnz psbml1
  239. ;─────────────────────────────────────────────────────────────────────────────
  240. psbmd:
  241.         add esp,VS
  242.         popad
  243.         ret
  244.  
  245.