home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / DISKMAGS / IMPHOB_9.ZIP / IMP9_EX!.ZIP / UNR_TWST.ZIP / IFF < prev    next >
Encoding:
Text File  |  1994-12-25  |  1.7 KB  |  93 lines

  1.  
  2. Offset2BODY dw 0    ;There will be stored offset to the BODY chunk
  3. Offset2CMAP dw 0    ;And there to CMAP
  4. CurrentSi   dw 0    ;Save the si
  5. dw 'NU'
  6. Show2Sc:push   es
  7. ;--------------------------------------: Searching for CMAP signature
  8.     mov    CurrentSi,si
  9.     mov    cx,5000         ;Test eventually 5000 bytes of IFF
  10. CMAP_S: lodsw
  11.     cmp    ax,'MC'                 ; after XCHG ah,al='CM'
  12.     je    CM_Found        ; jump if You found the CM part of
  13.     dec    cx
  14.     jnz    CMAP_S
  15.  
  16. TheEnd: ret
  17.  
  18. CM_Found:
  19.     lodsw
  20.     cmp    ax,'PA'                 ; after xchg ah,al='AP'
  21.     jne    TheEnd
  22.     mov    Offset2CMAP,si        ; store offset
  23.  
  24. ;--------------------------------------: Here is the part which sets colors
  25. SetColors:
  26.     mov    si,Offset2CMAP
  27.     add    si,4            ;skip the header of chunk
  28.  
  29.     cli                ; It's quite good 2 disable int. here
  30.     mov    ax,0
  31.     mov    dx,3c8h
  32.     out    dx,al
  33.     inc    dx
  34.     mov    cx,300h
  35. lopez:  mov     al,[si]
  36.     shr    al,2            ; Always divide by 4!
  37.     out    dx,al
  38.     inc    si
  39.     uloop    cx,lopez
  40.     sti
  41.  
  42. ;--------------------------------------: Search for BODY signature
  43. Search4BODY:
  44.     mov    si,CurrentSi
  45.     mov    cx,5000
  46. Search:
  47.     mov    ax,word ptr ds:[si]
  48.     cmp    ax,'OB'
  49.     je    BO_Found
  50.     add    si,2
  51.     dec    cx
  52.     jnz    Search
  53.     jmp    TheEnd
  54. BO_Found:
  55.     mov    ax,word ptr ds:[si+2]
  56.     cmp    ax,'YD'
  57.     jne    DC_FINI
  58.  
  59. ;--------------------------------------: Finally show the picture
  60. show256:                ;si=offset to pict.
  61.     add    si,8
  62.     pop    es
  63.     mov    di,0
  64.     mov    bp,64000        ;how many pixels
  65.     mov    dx,0            ;this is our counter
  66.  
  67. DCRUNC: lodsb
  68.     and    al,al
  69.     js    DC_LOW
  70.  
  71. DC_HI:    cbw
  72.     mov    cx,ax
  73.     inc    cx
  74.     add    dx,cx
  75.     rep    movsb
  76.  
  77.     cmp    dx,bp
  78.     jb    DCRUNC
  79.     jmp    DC_FINI
  80.  
  81. DC_LOW: neg    al
  82.     cbw
  83.     mov    cx,ax
  84.     inc    cx
  85.     add    dx,cx
  86.     lodsb
  87.     rep    stosb
  88.  
  89.     cmp    dx,bp
  90.     jb    DCRUNC
  91. DC_FINI:
  92.     ret
  93.