> M7toBMP v1.00 7 Convert MODE 7 BBC screen image to Windows Bitmap - v1.00 18-Jun-1999 JGH: Initial version. (G v1.01 12-Jul-1999 JGH: Read ScrSave compressed files and palettes 21 v1.02 11-Jul-2009 JGH: Made Windows binary. <, v1.00 Initial verion based on BBCtoBMP F: PF ctrl% 31,name% 79,zp% 5,palette% 15,mem% &3FF:X%=ctrl%:Y%=X%256 Z: d= :Close_All:" at line "+Þ,<>17 <128):exit() n8A$=OS_GetEnv:quit$=cl(" -q",1):os%=32:Win_TextIO x!cl("-?",0):syntax:exit(0) 0vb%=cl("-v",0):in$=cl("",0):out$=cl("",0) >in$="":"BBC MODE 7 image: "in$:"Output bitmap: "out$ (in$="" out$="":syntax:exit(220) $os%=32:in$,".")=0:in$=in$+"." 9file(in$,5)<>1:"File '"in$"' not found":exit(214) Afsize%=X%!10:fsize%>&400:"File '"in$"' too long":exit(255) "LOAD "+in$+" "+~mem% :out%=(out$):out%=0:"Can't open '"out$"'":exit(192) vb%= : 2xs%=2:ys%=2 : 2x2 output pixels :  Define mode variables  --------------------- cols%=40:rows%=25 -BitCount%=4:NumColours%=16:ColoursUsed%=8 ": , Set palette entries 6 ------------------- @" A%=0 15:palette%?A%=A%7: J: T Calculate variables ^ ------------------- h+Width%=cols%*6*xs%:Height%=rows%*10*ys% r#DataOffset%=14+40+4*NumColours% |,FileSize%=DataOffset%+(Width%*Height%)/2 :  File header  ----------- wr16(out%,"B"+"M"*256) wr32(out%,FileSize%) wr32(out%,0) wr32(out%,DataOffset%) :  Info header  ----------- wr32(out%,40) wr32(out%,Width%) wr32(out%,Height%) /wr16(out%,1) : Number of planes wr16(out%,BitCount%) -wr32(out%,0) : No compression &-wr32(out%,0) : No compression 01wr32(out%,0) : X pixels per metre :1wr32(out%,0) : Y pixels per metre D+wr32(out%,ColoursUsed%): Colours used N6wr32(out%,0) : Colours important 0=all X: b Colour table l ------------ v colour%=0 NumColours%-1 -#out%,(((palette%?colour%)4)<>0): blue .#out%,(((palette%?colour%)2)<>0): green ,#out%,(((palette%?colour%)1)<>0): red 1#out%,0 : unused  :  Raster data  ----------- / row%=rows%-1 0 -1:vb%:13;row%;" ";  pix%=10*ys%-1 0 -1  col%=0 cols%-1 2 5ptr%=col%+row%*40:B%=mem%?ptr%: C%=mem%?(ptr%+1) : g MODE 7 is essentially a MODE 2 bitmap, as it needs 16 colours, 4bits per pixel, 2 pixels per byte  :  Temp'y test code  ?X%=B%127:A%=10: &FFF1 *#out%,X%?pix% 4 >2 BPUT#out%,col%:BPUT#out%,row%:BPUT#out%,col% H: IFxs%=2:BPUT#out%,col%:BPUT#out%,row%:BPUT#out%,col% R: \: f:::vb%:13;" ";13; p: z Finished  -------- Close_All: exit(0) 2os%<32:"SetType "+out$+" 69C":"Stamp "+out$ exit(0): : : : 7syntax:"Syntax: M7toBMP -v": 1wr32(O%,A%):!zp%=A%:A%=03:#O%,zp%?A%:: 1wr16(O%,A%):!zp%=A%:A%=01:#O%,zp%?A%:: : ! > BLib.Close 1.00 09Aug1998 Close_All:*EXEC "in%=in%:in%:A%=in%:in%=0:#A% 'out%=out%:out%:A%=out%:out%=0:#A%  $: .# > BLib.ProgEnv 1.05 09Jan2007 8:ݤOS_GetEnv:A$,A%,X%,Y%:X%=1:os%=((&FFF4)&FF00)256 BLos%=32:>&FFFF:X%256:ș"GetModuleFileName",0,X%,255:run$=$$X%:=@cmd$ Los%=32:A$=$&100 VgA$=0:>&FFFF:run$=$&8100:ș16A$,,A%:ș72,"",A%:A$=A$,1+A$+" "," ",1+A$," "))):A$=0:A$=run$ `2A$=0:?(P-3):A$=$&600 A$=0:A$=$(-&300) j*Y%=-10:A$=" "+A$:A$=A$,2):A$<>32 t6Y%:A$=34:A%=A$,"""",2)+1 Y%:A%=A$+" "," ") ~-Y%:run$=A$,A%-1):run$<>"":A$=A$,A%+1)  :=A$ &os(A$):A$=42:A$ A$<>"":A$  Fexit(A%):"FX1,"+(A%255):quit$=quit$:A$=quit$:quit$="":os(A$) os%=32:Ș A% os%<6: *Quit  : # > BLib.CmdLine 1.10 27Jul2009 cݤcl(l$,n%):l$="":A$=s(A$):A$=34:A%=A$+" "" ",""" ",2):l$=A$,2,A%-2):A$=s(A$,A%+1)):=l$ "":A%=A$,l$):A%:A$=s(A$,A%-1)+A$,A$," ",A%)+1)):= n%=0:l$<>"":=  %A%=" ",l$=32)+A$,l$):A%=0:="" 'A$=A$,A%-1)+s(A$,A$," ",A%)+1)) Cl$=32:l$=A$,A%):A$=A$,A%-1):=l$,1-(l$=34),l$+2*(l$=34)) (PA$,A%,1)<>34:l$=A$,A%,A$+" "," ",A%)-A%):A$=A$,A%-1)+A$,A%+l$+1):=l$ 2Jl$=A$,A%+1,A$+""" ",""" ",A%+1)-A%-1):A$=A$,A%-1)+A$,A%+l$+3):=l$ " " F+A$,1)=" ":A$=A$,A$-1):A$,1)<>" " P=A$ Z: d > BLib.Win.TextIO nWin_TextIO x/ș "GetStdHandle",-10 @hfile%(1):*INPUT 1 0ș "GetStdHandle",-11 @hfile%(2):*OUTPUT 2 &ș "SetConsoleMode",@hfile%(1),0: :  > BLib.Generic.FileIO Jݤfile(A$,A%):os%<32:$name%=A$:?X%=name%:X%?1=name%256:=(&FFDD)&FF A$,".")=0:A$=A$+"." ;A%=255 A%=5:X%!14=(A$):X%!14:X%!10=#X%!14:#X%!14 1A%=255:X%?6=0:"LOAD """+A$+""" "+~X%!2:=1 A%=5:X%!14:=1 A%=5:=0 FA%=0:"SAVE """+A$+""" "+~X%!10+" "+~X%!14:X%!10=X%!14-X%!10:=1 BA%=7:"SAVE """+A$+""" "+~+"+"+~X%!10:X%!10=X%!14-X%!10:=1  A%=8  : :=2 "MKDIR "+A$:=2  =0