/* ** this code is not a example for well programming :-) ** but for use of amigametaformat.library and parsing AMF files ** compile with 'sc test LINK' */ MODULE 'intuition/screens', 'intuition/intuition', 'graphics/view', 'iffparse', 'libraries/iffparse', 'dos/dos', 'exec/memory', 'amigametaformat/amigametaformat', 'amigametaformat/amigametaformat.const' PROC main() DEF file,iff:PTR TO iffhandle,scr:PTR TO screen,wnd:PTR TO window,myarray:PTR TO LONG DEF amf,function,count,error,sp:PTR TO storedproperty IF iffparsebase:=OpenLibrary('iffparse.library',37) IF amigametaformatbase:=OpenLibrary('amigametaformat.library',6) IF scr:=OpenScreenTagList(NIL, [SA_WIDTH,-1, SA_HEIGHT,-1, SA_DEPTH,4, SA_FULLPALETTE,TRUE, SA_SHAREPENS,TRUE, SA_PENS,[-1], SA_TYPE,CUSTOMSCREEN, NIL]) IF wnd:=OpenWindowTagList(NIL, [WA_CUSTOMSCREEN,scr, WA_IDCMP,IDCMP_MOUSEBUTTONS, WA_TITLE,'AMF file viewer (simple)', NIL]) IF file:=Open(arg,MODE_OLDFILE) IF iff:=AllocIFF() InitIFFasDOS(iff) iff.stream:=file IF OpenIFF(iff,IFFF_READ)=0 IF PropChunks(iff,["AMFF","VERS","AMFF","FVER","AMFF","HEAD","AMFF","BODY"],4)=0 IF StopChunk(iff,"AMFF","BODY")=0 IF ParseIFF(iff,IFFPARSE_SCAN)=0 IF sp:=FindProp(iff,"AMFF","VERS") WriteF('Alte Version: \d.\d\n',Long(sp.data),Long(sp.data+4)) ENDIF IF sp:=FindProp(iff,"AMFF","FVER") WriteF('Neue Version: \s\n',sp.data) ENDIF IF sp:=FindProp(iff,"AMFF","HEAD") WriteF('Dimension: \d x \d\n',Long(sp.data),Long(sp.data+4)) ENDIF IF amf:=AmfOpen(AMF_WINDOW,[wnd,scr.viewport.colormap]) WHILE ReadChunkBytes(iff,{function},4)=4 IF ReadChunkBytes(iff,{count},4)=4 IF myarray:=AllocMem(count*4,MEMF_CLEAR) IF ReadChunkBytes(iff,myarray,count*4)=(count*4) error:=AmfFunction(amf,myarray,function,count) IF error<>0 THEN WriteF('function:\d count:\d error:\d\n',function,count,error) ENDIF FreeMem(myarray,count*4) ENDIF ENDIF ENDWHILE AmfClose(amf) ENDIF ENDIF ENDIF ENDIF CloseIFF(iff) ENDIF FreeIFF(iff) ENDIF Close(file) ELSE WriteF('can`t open file: \s\n',arg) ENDIF WaitPort(wnd.userport) CloseWindow(wnd) ELSE WriteF('no window\n') ENDIF CloseScreen(scr) ELSE WriteF('no screen\n') ENDIF CloseLibrary(amigametaformatbase) ELSE WriteF('no amigametaformat.library 6+\n') ENDIF CloseLibrary(iffparsebase) ELSE WriteF('no iffparse.library 37+\n') ENDIF ENDPROC