home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / DISKMAGS / IMPHOB_8.ZIP / IMP8_EX!.ZIP / IFF_EX.ZIP / IFFLOAD.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-07-07  |  3.6 KB  |  193 lines

  1. ; IFF PBM 320 * 200 * 256 loading procedure
  2. ; Unreal of SURPRISE!
  3. ; This is quite fast procedure for loading 320*200*256 PBM pictures (DPIIE)
  4. ; You can use it freely, as long as You want, in any way You want.
  5.  
  6. CODE SEGMENT PUBLIC
  7. ASSUME CS:CODE
  8. JUMPS
  9. .286C                ; I am using some 286>> codes here
  10.  
  11. ;======================================================================
  12.  
  13. Start:    
  14.     mov    ax,13h        ; 320*200*256, 1 byte = 1 point, no planes
  15.     int    10h        ; set with clearing video-memory
  16.  
  17.     mov    ax,seg DATA
  18.     mov    ds,ax
  19.     mov    si,offset PICTURE
  20.     call    Show2sc    
  21.  
  22. ASD:    in    al,60h
  23.     cmp    al,1
  24.     jne    ASD
  25.     mov    ax,03        ;back to text screen mode
  26.     int    10h
  27.     mov    ax,4c00h    ;End of program, 00=return value, no errors
  28.     int    21h
  29.  
  30. ;-----------------------------------------------------------------------
  31. ;- Show2Sc - includes Searching4CMAP, SettingColors, Seatching4BODY,   -
  32. ;- and finally Showing 320*200*256 IFF PBM to Screen.                  -
  33. ;- IN: DS:[SI] - address in segment and offset to the PBM picture data -
  34. ;-----------------------------------------------------------------------
  35.  
  36. Offset2BODY dw 0    ;There will be stored offset to the BODY chunk
  37. Offset2CMAP dw 0    ;And there to CMAP
  38. CurrentSi   dw 0    ;Save the si
  39.  
  40. Show2Sc:
  41. ;--------------------------------------: Searching for CMAP signature
  42.     mov    CurrentSi,si
  43.     mov    cx,5000            ;Test only 1st 5000 bytes of IFF
  44. CMAPSearch:mov    ax,word ptr ds:[si]
  45.     cmp    ax,'MC'            ; after XCHG ah,al='CM'
  46.     je    CM_Found        ; jump if You found the CM part of
  47.                     ; "CMAP" signature
  48.     add    si,2
  49.  
  50.     dec    cx
  51.     jnz    CMAPSearch
  52.  
  53. TheEnd:    ret
  54.  
  55. CM_Found:
  56.     add    si,2
  57.     mov    ax,word ptr ds:[si]
  58.     cmp    ax,'PA'            ; after xchg ah,al='AP'
  59.     jne    TheEnd
  60.     add    si,2
  61.     mov    Offset2CMAP,si        ; store offset 
  62. ;--------------------------------------------------------------
  63.     mov    si,CurrentSi
  64. ;--------------------------------------: Here is the part which sets colors
  65. SetColors:
  66.     mov    si,Offset2CMAP
  67.     add    si,4            ;skip the header of chunk
  68.  
  69.     cli                ; It's quite good 2 disable int. here
  70.     mov    ax,0
  71.     mov     dx,3c8h 
  72.     out      dx,al 
  73.     mov    cx,0300h        ; 768 times [palette size]
  74.     inc      dx 
  75.     
  76. CSET:    mov    al,[si]
  77.     shr    al,2            ; Always divide by 4!
  78.     out      dx,al 
  79.     inc    si
  80.     dec    cx
  81.     jnz    CSET
  82.     sti
  83.  
  84. ;--------------------------------------: Search for BODY signature
  85. Search4BODY:
  86.     mov    si,CurrentSi
  87.     mov    cx,5000
  88. Search:    mov    ax,word ptr ds:[si]
  89.     cmp    ax,'OB'
  90.     je    BO_Found
  91.     add    si,2
  92.     dec    cx
  93.     jnz    Search
  94.     jmp    TheEnd
  95. BO_Found:
  96.     mov    ax,word ptr ds:[si+2]
  97.     cmp    ax,'YD'
  98.     jne    TEnd
  99.     mov    Offset2BODY,si
  100. TEND:
  101.  
  102.     mov    si,CurrentSi
  103.  
  104. ;--------------------------------------: Finally show the picture
  105. show256:
  106.     mov    dx,3c4h
  107.     mov    al,1
  108.     out    dx,al
  109.     inc    dx
  110.     mov    al,100011b
  111.     out    dx,al
  112.  
  113.     mov    si,Offset2BODY
  114.     add    si,8
  115.  
  116.     mov    ax,0a000h
  117.     mov    es,ax
  118.     mov    di,0
  119.     mov    cx,64000
  120.  
  121. Show1Ln:
  122.     mov    al,byte ptr ds:[si]
  123.     cmp    al,0
  124.     jl    lower
  125.     jge    higher
  126.  
  127. NoMatt: 
  128.     dec    cx
  129.     jnz    Show1Ln
  130.  
  131. Kn:    mov    dx,3c4h
  132.     mov    al,1
  133.     out    dx,al
  134.     inc    dx
  135.     mov    al,000011b
  136.     out    dx,al            ; Turn the screen on
  137.  
  138.     ret
  139.  
  140. higher:    
  141.     cbw
  142.     mov    dx,cx            ;Store counter
  143.     inc    dx            ; And increase that stored one
  144.  
  145.     inc    ax            ; Increase copy-loop length
  146.  
  147. WPUNR:    inc    si
  148.     mov    bl,byte ptr ds:[si]    ;get byte from PBM
  149.     mov    byte ptr es:[di],bl    ;copy to screen
  150.     inc    di
  151.  
  152.     dec    dx
  153.     cmp    dx,0            ; if that's all, get owt
  154.     je    Kn
  155.  
  156.     dec    ax
  157.     jnz    WPUNR
  158.     inc    si
  159.  
  160.     mov    cx,dx            ; restore cx
  161.     jmp    NoMatt
  162.  
  163.     
  164. lower:
  165.     neg    al
  166.     cbw
  167.     mov    dx,cx
  168.     inc    dx
  169.  
  170.     inc    si
  171.     inc    ax
  172.     mov    bl,byte ptr ds:[si]
  173. WPUNR1:    mov    byte ptr es:[di],bl
  174.     inc    di
  175.     dec    dx
  176.     cmp    dx,0
  177.     je    Kn
  178.  
  179.     dec    ax
  180.     jnz    WPUNR1
  181.     inc    si
  182.  
  183.     mov    cx,dx
  184.     jmp    NoMatt
  185.  
  186. CODE ENDS
  187. DATA SEGMENT
  188. ; There lies picture
  189. PICTURE label
  190.      include pic.asm
  191. DATA ENDS
  192. End Start
  193.