> BMPSave/s 1.06 ! Save display as bitmap file ) v1.00 12-Jul-2010 Non-shadow MODE 0 (1 v1.01 16-Jun-2010 Non-shadow MODE 0, MODE 1 20 v1.02 16-Jun-2010 Can outputs small pixels <= v1.03 16-Jun-2010 MODE 2, pages in shadow screen memory F= v1.04 12-Jun-2014 Checks if overwriting Master NetFS WS PB v1.05 14-Jun-2014 Code moved to avoid Master NetWS workspace ZJ MODEs 3-6 work, no zebra, removed small pixel code d* v1.06 16-Jun-2014 Zebra stripes work n: x7OSBYTE=&FFF4:OSARGS=&FFDA:OSFIND=&FFCE:OSFILE=&FFDD 'OSGBPB=&FFD1:OSWORD=&FFF1:BRKV=&202 : -ver$="1.06": mcode% &300:load%=&FFFF0880 #NOSMALL%= : No -s capability -STACKCOL%= : Build colour table at &100 : Gfname=&A8:addr=&A8:cols=&AA:rows=&AB:num=&AC:sq=&AD:zeb=&AE:tmp=&AF : P=0 1 P%=load%:O%=mcode% [OPT P*3+4 .Abort !BRK:EQUB 17:EQUS "Escape":BRK : .Osbyte108 ! #16:TAX:LDA #108:JMP OSBYTE ": ,.SaveRaster 6 LDY zeb @ .SaveRasterLp0 JJ\\LDA sq:\PHA :\ Save square pixel count TE LDA #2:STA sq :\ Square pixel count ^ .SaveRasterLp1 hE LDA addr+1:PHA:LDA addr+0:PHA :\ Save start of line rT LDA num:PHA :\ Save number of column subsections | .SaveRasterLp2 C BIT &FF:BMI Abort :\ Check for Escape I LDA cols:PHA :\ Save number of columns B TYA:PHA :\ Save pixel line A LDA &D0:JSR Osbyte108 :\ Page in screen L LDX #0 :\ X=bytes written to buffer  .SaveRasterLp3 > PLA:PHA:TAY :\ Y=pixel row U LDA #0:CPY #8:BCS P%+4:LDA (addr),Y :\ Get byte from screen if not stripe C JSR PutByte :\ Output to buffer A LDA addr+0:CLC:ADC #8:STA addr+0 :\ Update address  BCC P%+4:INC addr+1 ] DEC cols:BNE SaveRasterLp3 :\ Do part of pixel line, screen bytes B TXA:PHA:LDA #0:JSR Osbyte108 :\ Page out screen F PLA:TAX:JSR WrBuffer :\ Output bitmap bytes F PLA:TAY :\ Get pixel line back M PLA:STA cols :\ Get number of columns back &a DEC num:BNE SaveRasterLp2 :\ Do one screen row, * screen bytes 0X PLA:STA num :\ Get number of column subsections back :Z PLA:STA addr+0:PLA:STA addr+1 :\ Get address of start of pixel line back DK DEC sq:BNE SaveRasterLp1 :\ Output double pixel line NN\\PLA:\STA sq :\ Get square pixel count back XK DEY:BPL SaveRasterLp0 :\ Loop for each pixel line b: lWLDA addr:SEC:SBC &352:STA addr+0 :\ Subtract bytes per character line to vRLDA addr+1:SBC &353:STA addr+1 :\ step up to next character line DDEC rows:BNE SaveRaster :\ Loop for all rows : LDX #gbpbSize 255 ALDA #1:JSR CallGBPB:JSR SwapClose :\ Write FileSize PLA:STA ctrl:PLA:STA ctrl+1 #LDX #ctrl 255:LDY #ctrl 256 JLDA #2:JMP OSFILE :\ Write filetype and exit :  .PutByte ABNE PutByte2Raw :\ Store it twice H: R .PutByte4 \DSTA tmp:LDY #4 :\ Rotate 4*2 pixels f.PutByte4Lp p LDA tmp z< #&08:BEQ P%+4:LDA #1 :\ b0 of pixel =ROL tmp:BCC P%+4:A #2 :\ b1 of pixel DJSR PutByteDouble :\ Store two nybbles .PHA:LDA &356:CMP #2:PLA:BCC PutByte4Single JSR PutByte2Raw .PutByte4Single DEY:BNE PutByte4Lp:RTS :  .PutByte2 #LDY &356:CPY #2:BCC PutByte2Raw ASTA tmp:JSR PutByte2Double :\ 2 colours wide .PutByte2Double  LDY #4 .PutByte2Lp ROL tmp:PHP:ROL A:PLP:ROL A DEY:BNE PutByte2Lp .PutByte2Raw $LDX &360:INX:STX ColoursUsed:STX cols :\ ColoursUsed =TXA:ASL A:ASL A:ADC #54:STA DataOffset :\ DataOffset ;LDA #1:CPX #2:BEQ P%+4:LDA #4:STA BitCount :\ BitCount @LDX #54:JSR WrData :\ Write Headers : LDX #0:LDY #0 &.RdColourLp1 0ETYA:PHA:LDA &36F,Y:LDY #3 :\ Read palette entry :.RdColourLp2 D>PHA: #4:BEQ P%+4:LDA #&FF:STA ColourTable,X:INX:PLA:ASL A N4DEY:BNE RdColourLp2:LDA #0:STA ColourTable,X:INX X(PLA:TAY:INY:CPY cols:BNE RdColourLp1 b.z% l%LDA #ColourTable 255:STA gbpb+1 v%LDA #ColourTable 256:STA gbpb+2 EJSR WrData :\ Write colour table A]: ColourTable=DataBuffer:z%=(P%-z%)&FFFF:P%=P%-z%:O%=O%-z% [OPT P*3+4 .z% EJSR WrBuffer :\ Write colour table B]: ColourTable<>DataBuffer:z%=(P%-z%)&FFFF:P%=P%-z%:O%=O%-z% [OPT P*3+4 : =LDX &356 :\ Screen map ILDA AddrLo,X:STA addr+0 :\ Bottom row, first byte LDA AddrHi,X:STA addr+1 LDA NumRow,X:STA rows LDA Zebra,X:STA zeb QLDA #20:LDX #2:\\STX sq :\ Output each pixel line 2 times  ALDY &355:BEQ SetMode80x1 :\ 0 - 80x1 ACPY #5:BEQ SetMode20x2 :\ 5 - 20x2  ACPY #3:BCC SetMode40x2 :\ 1,2 - 40x2 *ABNE SetMode40x1 :\ 4,6 - 40x1 4.SetMode80x1 >:ASL A :\ cols=80 H.SetMode40x1 R8DEX :\ num=1 \.SetMode40x2 f ASL A p.SetMode20x2 zSTX num:STA cols PLDY zeb:CPY #8:BCC P%+4:LDY #15 :\ Initial number of pixel lines JMP SaveRasterLp0 : <\ ?&355 Start addr ?&356 &360 cols num BMP/line :\ 0 &7D80 0 1 80 1 80 in 1x80 ;\ 1 &7D80 0 3 40 2 320 in 2x160 ;\ 2 &7D80 0 15 40 2 320 in 2x160 :\ 3 &7C00 1 1 80 1 80 in 1x80 :\ 4 &7EC0 2 1 40 1 80 in 1x80 ;\ 5 &7EC0 2 3 20 2 320 in 2x160 :\ 6 &7E00 3 1 40 1 80 in 1x80 : /.AddrLo:EQUB &80:EQUB &00:EQUB &C0:EQUB &00 /.AddrHi:EQUB &7D:EQUB &7C:EQUB &7E:EQUB &7E /.NumRow:EQUB 32:EQUB 25:EQUB 32:EQUB 25 /.Zebra :EQUB 7:EQUB 9:EQUB 7:EQUB 9 $: .1\ cols - number of byte columns per pixel row 8:\ num - number of pixel rows can fit in output buffer B#\ rows - number of pixel rows/8 L: V EQUS ver$ `: j] tColoursUsed=BitCount+18 ~U ColourTable=ColourTableInline:ColourEnd=RdColourLp1 ColourEnd=ColourTable+&80 : 7:"DataBuffer size: ";&B00-DataBuffer;" bytes ("; @;(&B00-DataBuffer)80;"x80, ";(&B00-DataBuffer)160;"x160)" >"ColourTable size: ";(ColourEnd-ColourTable)4;" colours" D (ColourEnd-ColourTable)4<16:"WARNING: Colour table overflow" : F"*SAVE BMPSave ";~mcode%;" ";~O%;" ";~start%&FFFF0000;" ";~load%