WBStartup Dim c$(5),con$(3),r$(3),t$(3) c$(0)="Assembler" c$(1)="C" c$(2)="BlitzBasic2" c$(3)="Basic" c$(4)="RAW" c$(5)="RAW(splitted)" con$(0)="dc.w " con$(1)="" con$(2)="Data.w " con$(3)="Data " r$(0)="; " r$(1)="/* " r$(2)="; " r$(3)="REM " t$(0)="$" t$(1)="0x" t$(2)="$" t$(3)="$" pos=0 w$=" 0" h$=" 0" p$="0" i.f MaxLen pa$=160 MaxLen fi$=64 Statement cgadget{win,glist,gadget,txt$,col} ; win = Window# ; glist = GadgetList# ; gadget = Gadget ID ; txt$ = Text der im Gadget erscheinen soll... ; col = Farbe mit der das Gadget gelscht wird... *win.Window=Peek.l(Addr Window(win)) ; Window Adresse *gad.Gadget=*win\FirstGadget ; Erstes Gadget If gadget>1 For x=1 To gadget-1 ; Bis wir beim gewnchten Gadget sind *gad.Gadget=*gad\NextGadget Next x EndIf *x.w=*gad\LeftEdge ; Position der Gadgets (frs lschen...) *y.w=*gad\TopEdge *w.w=*gad\Width *h.w=*gad\Height *txt.IntuiText=*gad\GadgetText ; Adresse Gadget Text ; *txt\IText=txt$ ; GURU!!! Poke$ *txt\IText,txt$ Use Window win ; Unser GadgetWindow WBox *x,*y,*x+*w,*y+*h,col ; Altes Gadget bermalen r.l=RefreshGadgets_(Peek.l(Addr TextGadget(glist)),*win,0) ; Und die Gadgets neubasteln! Redraw 0,6 Redraw 0,7 End Statement Statement refresh{} SHARED w$,h$,p$ GadgetBorder 12,14,296,44 GadgetBorder 16,32,96,8 GadgetBorder 120,32,104,8 GadgetBorder 232,32,72,8 GadgetBorder 12,62,296,30 GadgetBorder 16,66,56,8 GadgetBorder 80,66,224,8 GadgetBorder 16,80,56,8 GadgetBorder 80,80,224,8 GadgetBorder 12,96,296,30 GadgetBorder 16,100,88,8 GadgetBorder 16,114,64,8 GadgetBorder 12,130,296,16 GadgetBorder 12,150,296,16 GadgetBorder 16,154,288,8 WLocate 12,21 Print "Width: "+w$ WLocate 116,21 Print "Height: "+h$ WLocate 228,21 Print "Planes: "+p$ WLocate 12,55 Print "Planes:" WLocate 116,55 Print "Words of Bitplane:" WLocate 12,89 Print "Convert to:" WLocate 12,103 Print "Convert:" WLocate 12,143 Print "Status:" End Statement Statement status{txt$} WBox 17,155,287+17,7+155,0 WLocate 12,143 Print "Status: "+Centre$(txt$,28) End Statement WBenchToFront_ WbToScreen 0 TextGadget 0,12,16,0,1,"IFF File:" StringGadget 0,92,16,0,2,257,208 TextGadget 0,12,44,0,3,"Source:" StringGadget 0,76,44,0,4,257,224 TextGadget 0,108,98,0,5,Centre$(c$(pos),24) TextGadget 0,84,112,1,6," Palette " TextGadget 0,196,112,1,7," Bitmap " TextGadget 0,12,132,0,8," Go to do it!!! " SizeLimits 100,20,320,180 Window 0,0,0,320,180,$1|$2|$4|$8|$20|$1000,"IFF TO SOURCE V0.1",2,1,0 CatchDosErrs refresh{} Repeat e.l=WaitEvent If e=$4 refresh{} EndIf If e=$40 Select GadgetHit Case 1 iff$=FileRequest$("Choose IFF bitmap:",pa$,fi$) If iff$<>"" Gosub iffcheck status{status$} EndIf Case 2 iff$=StringText$(0,2) If iff$<>"" Gosub iffcheck status{status$} EndIf SetString 0,2,sfile$ Redraw 0,2 ActivateString 0,4 Case 3 iff$=FileRequest$("Choose source file:",pa$,fi$) If iff$<>"" dfile$=iff$ SetString 0,4,dfile$ Redraw 0,4 EndIf Case 4 iff$=StringText$(0,4) If iff$<>"" dfile$=iff$ EndIf ActivateString 0,2 Case 5 pos+1 If pos=6 pos=0 EndIf cgadget{0,0,5,Centre$(c$(pos),24),0} Case 6 If col=On col=Off Else col=On EndIf Case 7 If map=On map=Off Else map=On EndIf Case 8 If map=Off AND col=Off status$="What shall I do?" Else If sfile$="" status$="No bitmap choosen!" Pop If: Pop If: Goto skip EndIf If dfile$="" status$="No source file choosen!" Pop If: Pop If: Goto skip EndIf If pos=0 OR pos=1 OR pos=2 OR pos=3 Gosub converta EndIf If pos=4 Gosub convertb EndIf If pos=5 Gosub convertc EndIf EndIf .skip: status{status$} End Select EndIf Until e=$200 End .converta: status{"Converting..."} BitMap 0,ILBMWidth,ILBMHeight,ILBMDepth LoadBitMap 0,sfile$,0 If WriteFile (0,dfile$) FileOutput 0 If pos=1 w$=" */" Else w$="" EndIf NPrint r$(pos)+"Source created with IFF2SOURCE"+w$ NPrint r$(pos)+"(c) 1992 by Andre Bergmann"+w$ If col k$="" *pal.palette=Addr Palette(0) NPrint Chr$(10)+r$(pos)+"Colourmap infos:"+w$ NPrint r$(pos)+"Number of colours: "+Str$(*pal\_numcols)+w$ If pos=1 NPrint "UWORD PaletteData[] = {"+Chr$(10) Else NPrint "Colourmap:"+Chr$(10) EndIf For x=0 To *pal\_numcols-1 Step 2 Print con$(pos) For v=0 To 1 k$=k$+t$(pos)+Right$(Hex$(*pal\_colours[x+v]),4)+"," Next v If pos=1 NPrint k$ Else NPrint Left$(k$,Len(k$)-1) EndIf k$="" Next x If pos=1 NPrint "};" EndIf EndIf If map k$="" *bmap.bitmap=Addr BitMap(0) NPrint Chr$(10)+r$(pos)+"Bitmap infos:"+w$ NPrint r$(pos)+"BitmapWidth : "+Str$(ILBMWidth)+w$ NPrint r$(pos)+"BitmapHeight: "+Str$(ILBMHeight)+w$ NPrint r$(pos)+"BitmapDepth : "+Str$(ILBMDepth)+w$ If pos=1 NPrint "UWORD PlaneData[] = {"+Chr$(10) Else NPrint "Bitplanes:"+Chr$(10) EndIf For x=0 To *bmap\_depth-1 WBox 14,79,16+(x/ILBMDepth*56),88,2 WBox 78,79,80+224,88,0 NPrint r$(pos)+" BitPlane "+Str$(x)+w$ ptr.l=*bmap\_data[x] For i=0 To *bmap\_ebwidth**bmap\_height-16 Step 16 Print con$(pos) For v=0 To 15 Step 2 k$=k$+t$(pos)+Right$(Hex$(Peek.w(ptr+i+v)),4)+"," WBox 78,79,80+((i+v)/(*bmap\_ebwidth**bmap\_height-16)*224),88,2 Next v If pos=1 NPrint k$ Else NPrint Left$(k$,Len(k$)-1) EndIf k$="" Next i Next x If pos=1 NPrint "};" EndIf WBox 14,79,72,88,0 WBox 78,79,80+224,88,0 EndIf CloseFile 0 status$="OK!!!" Else status$="Couldn' t open source file!" EndIf WindowOutput 0 Return .convertb: status{"Converting..."} BitMap 0,ILBMWidth,ILBMHeight,ILBMDepth LoadBitMap 0,sfile$,0 If col Gosub cpalette EndIf If map bfile$=dfile$+".b" fh.l=Open_(&bfile$,1006) If fh *bmap.bitmap=Addr BitMap(0) For x=0 To *bmap\_depth-1 WBox 14,79,16+(x/ILBMDepth*56),88,2 WBox 78,79,80+224,88,0 ptr.l=*bmap\_data[x] For i=0 To *bmap\_ebwidth**bmap\_height-16 Step 16 For v=0 To 15 Step 2 r.l=Write_(fh,ptr+i+v,2) WBox 78,79,80+((i+v)/(*bmap\_ebwidth**bmap\_height-16)*224),88,2 Next v Next i Next x WBox 14,79,72,88,0 WBox 78,79,80+224,88,0 Close_(fh) status$="OK!!!" Else status$="Couldn' t open source file!" EndIf EndIf WindowOutput 0 Return .convertc: status{"Converting..."} BitMap 0,ILBMWidth,ILBMHeight,ILBMDepth LoadBitMap 0,sfile$,0 If col Gosub cpalette EndIf If map *bmap.bitmap=Addr BitMap(0) For x=0 To *bmap\_depth-1 bfile$=dfile$+".b"+Str$(x) fh.l=Open_(&bfile$,1006) If fh WBox 14,79,16+(x/ILBMDepth*56),88,2 WBox 78,79,80+224,88,0 ptr.l=*bmap\_data[x] For i=0 To *bmap\_ebwidth**bmap\_height-16 Step 16 For v=0 To 15 Step 2 r.l=Write_(fh,ptr+i+v,2) WBox 78,79,80+((i+v)/(*bmap\_ebwidth**bmap\_height-16)*224),88,2 Next v Next i Close_(fh) Next x EndIf WBox 14,79,72,88,0 WBox 78,79,80+224,88,0 status$="OK!!!" Else status$="Couldn' t open source file!" EndIf WindowOutput 0 Return .iffcheck: status$="OK!!!" If OpenFile(0,iff$) FileInput 0 head$=Edit$(4) CloseFile 0 If UCase$(head$)="FORM" sfile$=iff$ SetString 0,2,sfile$ Redraw 0,2 ILBMInfo sfile$ Format "#####" w$=Str$(ILBMWidth) h$=Str$(ILBMHeight) Format "" p$=Str$(ILBMDepth) WLocate 68,21 Print w$ WLocate 180,21 Print h$ WLocate 292,21 Print p$ Else status$="Sorry, no IFF file!" EndIf Else status$="Couldn' t open IFF bitmap!" EndIf WindowOutput 0 Return .cpalette: cfile$=dfile$+".p" fh.l=Open_(&cfile$,1006) If fh *pal.palette=Addr Palette(0) For x=0 To *pal\_numcols-1 Step 2 For v=0 To 1 r.l=Write_(fh,*pal\_colours[x+v],1) Next v Next x Close_(fh) status$="OK!!!" Else status$="Couldn' t open source file!" EndIf Return