home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / blabla / ssic / showsomeiffchunks.e next >
Text File  |  1998-01-24  |  3KB  |  135 lines

  1. /*
  2.     Show Some IFF Chunks v0.001
  3. This little pice of shit was written by
  4.      Kordi/ mainly of blahblah
  5. EnJoy! (If there is sth to enjoy ;-)
  6. */
  7.  
  8. MODULE 'dos/dos'
  9.  
  10. DEF s[10]:STRING
  11. DEF form_id,ilbm_id[4]:STRING
  12. ENUM NO_ERR, NO_ARGS, NO_MEM, NO_FILE, NO_IFF
  13.  
  14. PROC main() HANDLE
  15.  DEF mem:PTR TO CHAR,open,n,v,var,kk,l,camg,resolution,lock,colors
  16.  DEF file[20]:STRING
  17.  DEF get_answer[4]:STRING
  18.  
  19.  StrCopy(form_id,'FORM')
  20.  StrCopy(ilbm_id,'ILBM')
  21.  IF arg[]=0 THEN Raise(NO_ARGS)
  22.  IF (mem:=New(500))=NIL THEN Raise(NO_MEM)
  23.  StrCopy(file,arg,StrLen(arg)-1)
  24.  IF (open:=Open(file,1005))=NIL THEN Raise(NO_FILE)
  25.  lock:=Lock(file,ACCESS_READ)
  26.  Read(open,mem,500)
  27.  IF ((Long(mem)<>Long(form_id)) OR (Long(mem+8)<>Long(ilbm_id))) THEN Raise(NO_IFF)
  28.  
  29. StrCopy(s,'CAMG')
  30. var:=search(mem,s)
  31. camg:=Long(mem+var+5)
  32.  
  33. SELECT camg
  34.  CASE $4080
  35.    resolution:='Lowres (EHB)'
  36.  CASE $C000
  37.    resolution:='Hires'
  38.   CASE $C004
  39.    resolution:='Hires Interlace'
  40.   CASE $4000
  41.    resolution:='Lowres'
  42.   CASE $6000
  43.    resolution:='Lowres'
  44.   CASE $0800
  45.    resolution:='HAM'
  46.   CASE $4800
  47.    resolution:='HAM'
  48.   CASE $4084
  49.    resolution:='EHB + Lace'
  50.   DEFAULT
  51.    resolution:='???'
  52. ENDSELECT
  53. IF var=0 THEN resolution:='Probably Lowres, but I''m not sure...'
  54.  
  55. WriteF('\nPicture width     : \d\n',Int(mem+20))
  56. WriteF('Picture height    : \d\n',Int(mem+22))
  57. WriteF('X position        : \d\n',Int(mem+24))
  58. WriteF('Y position        : \d\n',Int(mem+26))
  59. WriteF('Bitplanes         : \d\n',Char(mem+28))
  60. WriteF('Masking           : \d\n',Char(mem+29))
  61. WriteF('Compression       : \d\n',Char(mem+30))
  62. WriteF('Pad1          : \d\n',Char(mem+31))
  63. WriteF('TransparentColour : \d\n',Int(mem+32))
  64. WriteF('X aspect          : \d\n',Char(mem+34))
  65. WriteF('Y aspect          : \d\n',Char(mem+35))
  66. WriteF('Page width        : \d\n',Int(mem+36))
  67. WriteF('Page height       : \d\n',Int(mem+38))
  68. WriteF('Viewport mode     : \s\n\n',resolution)
  69.  
  70.  stdout:=Output()
  71.  WriteF('Wanna see colours values? [Y if yes] ')
  72.  ReadStr(stdout,get_answer)
  73.  UpperStr(get_answer)
  74.  IF StrCmp(get_answer,'Y')=FALSE THEN Raise(NO_ERR)
  75.  
  76. StrCopy(s,'CMAP')
  77. n:=search(mem,s)
  78. l:=0
  79. colors:=Long(mem+n+1)/3
  80. n:=n+5
  81. FOR v:=0 TO colors-1
  82.  WriteF('Color \z\d[2]: $',v)
  83.  FOR kk:=0 TO 2
  84.    WriteF('\h',Char(mem+n+l)/$10)
  85.   INC l
  86.  ENDFOR
  87. WriteF('\n')
  88. ENDFOR
  89. Raise(NO_ERR)
  90.  
  91. EXCEPT
  92. Dispose(mem)
  93.  IF open
  94.   Close(open)
  95.   UnLock(lock)
  96.  ENDIF
  97.  IF exception
  98.  SELECT exception
  99.    CASE NO_ARGS
  100.      WriteF('Usage: SSIC picture_name\n')
  101.    CASE NO_MEM
  102.      WriteF('Can''t allocate 500 bytes of memory! Sth wrong with your Amiga?\n')
  103.    CASE NO_FILE
  104.      WriteF('Can''t find file \s\n',arg)
  105.    CASE NO_IFF
  106.      WriteF('This is not an IFF ILBM file.\n')
  107.  ENDSELECT
  108.  ENDIF
  109. WriteF('\nYou were using \e[1;33mShowSomeIFFChunks\e[0m by Kordi/DuckRed & blabla.\n')
  110. WriteF('SSIC is one of the \e[4mblabla\e[0m productions (see doc).\n')
  111. ENDPROC
  112.  
  113. PROC search(mem:PTR TO CHAR,ptr:PTR TO CHAR)
  114. -> Szukamy w pamici ciagu s.
  115. DEF ptr1:PTR TO CHAR,v,k
  116.  ptr1:=ptr
  117.  k:=0
  118.  FOR v:=0 TO 499
  119.    IF Char(mem)=Char(ptr)
  120.      ptr++
  121.      INC k
  122.     IF k=EstrLen(s) THEN JUMP end1
  123.     JUMP next
  124.   ENDIF
  125.   IF k<>0
  126.    k:=0
  127.    ptr:=ptr1
  128.   ENDIF
  129. next:
  130.   mem++
  131.  ENDFOR
  132. end1:
  133. ENDPROC v
  134.  
  135.