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 / SH_IFF < prev   
Encoding:
Text File  |  1994-07-07  |  3.0 KB  |  162 lines

  1. ; IFF PBM 320 * 200 * 256 loading procedure.
  2. ; Unreal of SURPRISE!
  3. ; Use it if You want whoever You are, I'd be also very pleased if You
  4. ; would mention me in credits :) (Anyway,if You don't want,You don't have to)
  5.  
  6.  
  7. ;-----------------------------------------------------------------------
  8. ;- Show2Sc - includes Searching4CMAP, SettingColors, Seatching4BODY,   -
  9. ;- and finally Showing 320*200*256 IFF PBM to Screen.                  -
  10. ;- IN: DS:[SI] - address in segment and offset to the PBM picture data -
  11. ;-----------------------------------------------------------------------
  12.  
  13. Offset2BODY dw 0    ;There will be stored offset to the BODY chunk
  14. Offset2CMAP dw 0    ;And there to CMAP
  15. CurrentSi   dw 0    ;Save the si
  16.  
  17. Show2Sc:
  18. ;--------------------------------------: Searching for CMAP signature
  19.     mov    CurrentSi,si
  20.     mov    cx,5000            ;Test only 1st 5000 bytes of IFF
  21. CMAPSearch:mov    ax,word ptr ds:[si]
  22.     cmp    ax,'MC'            ; after XCHG ah,al='CM'
  23.     je    CM_Found        ; jump if You found the CM part of
  24.                     ; "CMAP" signature
  25.     add    si,2
  26.  
  27.     dec    cx
  28.     jnz    CMAPSearch
  29.  
  30. TheEnd:    ret
  31.  
  32. CM_Found:
  33.     add    si,2
  34.     mov    ax,word ptr ds:[si]
  35.     cmp    ax,'PA'            ; after xchg ah,al='AP'
  36.     jne    TheEnd
  37.     add    si,2
  38.     mov    Offset2CMAP,si        ; store offset 
  39. ;--------------------------------------------------------------
  40.     mov    si,CurrentSi
  41. ;--------------------------------------: Here is the part which sets colors
  42. SetColors:
  43.     mov    si,Offset2CMAP
  44.     add    si,4            ;skip the header of chunk
  45.  
  46.     cli                ; It's quite good 2 disable int. here
  47.     mov    ax,0
  48.     mov     dx,3c8h 
  49.     out      dx,al 
  50.     mov    cx,0300h        ; 768 times [palette size]
  51.     inc      dx 
  52.     
  53. CSET:    mov    al,[si]
  54.     shr    al,2            ; Always divide by 4!
  55.     out      dx,al 
  56.     inc    si
  57.     dec    cx
  58.     jnz    CSET
  59.     sti
  60.  
  61. ;--------------------------------------: Search for BODY signature
  62. Search4BODY:
  63.     mov    si,CurrentSi
  64.     mov    cx,5000
  65. Search:    mov    ax,word ptr ds:[si]
  66.     cmp    ax,'OB'
  67.     je    BO_Found
  68.     add    si,2
  69.     dec    cx
  70.     jnz    Search
  71.     jmp    TheEnd
  72. BO_Found:
  73.     mov    ax,word ptr ds:[si+2]
  74.     cmp    ax,'YD'
  75.     jne    TEnd
  76.     mov    Offset2BODY,si
  77. TEND:
  78.  
  79.     mov    si,CurrentSi
  80.  
  81. ;--------------------------------------: Finally show the picture
  82. show256:
  83.     mov    dx,3c4h
  84.     mov    al,1
  85.     out    dx,al
  86.     inc    dx
  87.     mov    al,100011b
  88.     out    dx,al
  89.  
  90.     mov    si,Offset2BODY
  91.     add    si,8
  92.  
  93.     mov    ax,0a000h
  94.     mov    es,ax
  95.     mov    di,0
  96.     mov    cx,64000
  97.  
  98. Show1Ln:
  99.     mov    al,byte ptr ds:[si]
  100.     cmp    al,0
  101.     jl    lower
  102.     jge    higher
  103.  
  104. NoMatt: 
  105.     dec    cx
  106.     jnz    Show1Ln
  107.  
  108. Kn:    mov    dx,3c4h
  109.     mov    al,1
  110.     out    dx,al
  111.     inc    dx
  112.     mov    al,000011b
  113.     out    dx,al            ; Turn the screen on
  114.  
  115.     ret
  116.  
  117. higher:    
  118.     cbw
  119.     mov    dx,cx            ;Store counter
  120.     inc    dx            ; And increase that stored one
  121.  
  122.     inc    ax            ; Increase copy-loop length
  123.  
  124. WPUNR:    inc    si
  125.     mov    bl,byte ptr ds:[si]    ;get byte from PBM
  126.     mov    byte ptr es:[di],bl    ;copy to screen
  127.     inc    di
  128.  
  129.     dec    dx
  130.     cmp    dx,0            ; if that's all, get owt
  131.     je    Kn
  132.  
  133.     dec    ax
  134.     jnz    WPUNR
  135.     inc    si
  136.  
  137.     mov    cx,dx            ; restore cx
  138.     jmp    NoMatt
  139.  
  140.     
  141. lower:
  142.     neg    al
  143.     cbw
  144.     mov    dx,cx
  145.     inc    dx
  146.  
  147.     inc    si
  148.     inc    ax
  149.     mov    bl,byte ptr ds:[si]
  150. WPUNR1:    mov    byte ptr es:[di],bl
  151.     inc    di
  152.     dec    dx
  153.     cmp    dx,0
  154.     je    Kn
  155.  
  156.     dec    ax
  157.     jnz    WPUNR1
  158.     inc    si
  159.  
  160.     mov    cx,dx
  161.     jmp    NoMatt
  162.