A2osX/BIN/BMP2PIX.S.txt

791 lines
15 KiB
Plaintext
Raw Normal View History

NEW
2019-04-06 18:43:33 +00:00
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
2020-04-13 17:04:02 +00:00
.TF bin/bmp2pix
*--------------------------------------
2020-06-27 18:30:09 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/io.i
.INB inc/gfx.i
.INB inc/libgui.i
*--------------------------------------
2019-04-08 06:07:19 +00:00
S.BMP.SIG .EQ 0
2019-04-06 18:43:33 +00:00
S.BMP.SIZE .EQ 2
S.BMP.DATA.OFS .EQ $A
S.BMP.HDR.SIZE .EQ $E
S.BMP.W .EQ $12
S.BMP.H .EQ $16
S.BMP.PLANES .EQ $1A
S.BMP.BPP .EQ $1C
*
S.BMP .EQ $36
*--------------------------------------
.DUMMY
.OR ZPBIN
2019-10-03 06:25:27 +00:00
ZS.START
2020-08-19 19:39:43 +00:00
ZPPtr1 .BS 2
2019-04-08 06:07:19 +00:00
ZPInputBuf .BS 2
2019-04-06 18:43:33 +00:00
ZPInputBufPtr .BS 2
2019-04-08 06:07:19 +00:00
ZPInputRowBytes .BS 2
2019-04-06 18:43:33 +00:00
ZPLineCount .BS 2
2019-04-08 06:07:19 +00:00
ZPPixelCount .BS 2
ZPOutputBuf .BS 2
ZPOutputRowBytes .BS 2
2019-04-06 18:43:33 +00:00
ZPPixel24 .BS 3
ZPPixelScore .BS 3
2020-07-03 20:55:40 +00:00
ZPCntX .BS 1
ZPCntY .BS 1
2019-04-08 06:07:19 +00:00
2020-07-03 20:55:40 +00:00
ZPPixelBest .BS 3
2019-04-06 18:43:33 +00:00
ZPPixelIndex16 .BS 1
2019-04-08 06:07:19 +00:00
2020-07-03 20:55:40 +00:00
ZBTmpW1 .BS 2
ZBTmpW2 .BS 2
2019-04-06 18:43:33 +00:00
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2019-04-06 18:43:33 +00:00
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
2019-04-06 18:43:33 +00:00
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
2020-07-04 19:00:47 +00:00
.DA CS.DOEVENT
.DA CS.QUIT
2020-07-04 19:00:47 +00:00
L.MSG.USAGE .DA MSG.USAGE
L.MSG.HEADER.OK .DA MSG.HEADER.OK
L.MSG.HEADER.KO .DA MSG.HEADER.KO
L.MSG.DONE .DA MSG.DONE
.DA 0
*--------------------------------------
2019-04-06 18:43:33 +00:00
CS.INIT clc
rts
*--------------------------------------
CS.RUN
.1 >INC.G ArgCount
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
bcs .7
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
2020-07-04 19:00:47 +00:00
ldy #1
lda (ZPPtr1),y
2020-08-30 17:50:57 +00:00
ldx #OptionVars-OptionList
.2 cmp OptionList-1,x
beq .3
dex
bne .2
2020-07-04 19:00:47 +00:00
2020-04-13 17:04:02 +00:00
.99 >PUSHW L.MSG.USAGE
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2018-10-21 20:54:07 +00:00
lda #E.SYN
sec
rts
2020-07-04 19:00:47 +00:00
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra .1
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
.4 >LDA.G hInputFile
bne .5
2020-04-13 17:04:02 +00:00
2019-04-11 05:56:05 +00:00
jsr CS.RUN.OpenInput
bcc .1 scan for any other args
2020-04-13 17:04:02 +00:00
rts
2020-04-13 17:04:02 +00:00
.5 >LDA.G hOutputFile
bne .99
2020-04-13 17:04:02 +00:00
2019-04-11 05:56:05 +00:00
jsr CS.RUN.CreateOutput
bcc .1 scan for any other args
2019-04-06 18:43:33 +00:00
.9 rts
2020-04-13 17:04:02 +00:00
.7 >LDA.G hOutputFile
beq .99
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
>LDA.G BMP.Header+S.BMP.BPP
2020-08-19 19:39:43 +00:00
cmp #1
2019-04-06 18:43:33 +00:00
beq CS.RUN.1
jmp CS.RUN.24
*--------------------------------------
2019-04-06 18:43:33 +00:00
CS.RUN.1 lda #S.BM.F.BBP1
>STA.G PIX.Header+S.BM.F
2019-04-08 06:07:19 +00:00
* >LDA.G PIX.Header+S.BM.W
* sta ZPBMPRowBytes
* sta ZPPIXRowBytes
* iny
* lda (pData),y
* sta ZPBMPRowBytes+1
* sta ZPPIXRowBytes+1
* lda ZPBMPRowBytes
* and #%00011111
* beq .1
* lda ZPBMPRowBytes
* and #%11100000
* clc
* adc #%00100000
* bcc .1
* inc ZPBMPRowBytes+1
*.1 lsr ZPBMPRowBytes+1
* ror
* lsr ZPBMPRowBytes+1
* ror
* lsr ZPBMPRowBytes+1
* ror
* sta ZPBMPRowBytes
* lda ZPPIXRowBytes
* and #%00000111
* beq .2
* lda ZPPIXRowBytes
* and #%11111000
* clc
* adc #%00001000
* bcc .2
* inc ZPPIXRowBytes+1
2020-04-13 17:04:02 +00:00
*.2 lsr ZPPIXRowBytes+1
2019-04-08 06:07:19 +00:00
* ror
* lsr ZPPIXRowBytes+1
* ror
* lsr ZPPIXRowBytes+1
* ror
* sta ZPPIXRowBytes
* >STA.G PIX.Header+S.BM.RowBytes
* lda ZPInputBufPtr
* clc
* adc ZPInputBufLen
* sta ZPInputDataPtr
* lda ZPInputBufPtr+1
* adc ZPInputBufLen+1
* sta ZPInputDataPtr+1
* jsr CS.RUN.WRITE.HDR
* bcs CS.RUN.RTS
*CS.RUN.1.LOOP inc ZPLineCount
* bne .1
* inc ZPLineCount+1
* beq .8
*.1 lda ZPInputDataPtr
* sec
* sbc ZPBMPRowBytes
* sta ZPInputDataPtr
* lda ZPInputDataPtr+1
* sbc ZPBMPRowBytes+1
* sta ZPInputDataPtr+1
* >LDYA ZPBufPtr
2020-08-19 19:39:43 +00:00
* >STYA ZPPtr1
2019-04-08 06:07:19 +00:00
* ldy #0
*.2 lda (ZPInputDataPtr),y
* tax
* lda TWIST,x
2020-08-19 19:39:43 +00:00
* sta (ZPPtr1)
* inc ZPPtr1
2019-04-08 06:07:19 +00:00
* bne .3
2020-08-19 19:39:43 +00:00
* inc ZPPtr1+1
2019-04-08 06:07:19 +00:00
*.3 iny
* cpy ZPPIXRowBytes
* bne .2
* >PUSHW ZPPIXRowBytes
* >PUSHW ZPOutputBufPtr
* >LDA.G hOutputFile
* >SYSCALL FWrite
* bcs CS.RUN.RTS
* bra CS.RUN.1.LOOP
*.8 >LDYA L.MSG.DONE
2020-02-28 07:21:46 +00:00
* >SYSCALL PutS
2019-04-08 06:07:19 +00:00
* lda #0
* sec
CS.RUN.RTS rts
*--------------------------------------
2019-04-06 18:43:33 +00:00
CS.RUN.24 lda #S.BM.F.BBP4
>STA.G PIX.Header+S.BM.F
2019-04-08 06:07:19 +00:00
>LDA.G BMP.Header+S.BMP.W
asl
sta ZPInputRowBytes
>LDA.G BMP.Header+S.BMP.W+1
rol
sta ZPInputRowBytes+1
lda ZPInputRowBytes
2019-04-06 18:43:33 +00:00
clc
2019-04-08 06:07:19 +00:00
>ADC.G BMP.Header+S.BMP.W
pha
lda ZPInputRowBytes+1
>ADC.G BMP.Header+S.BMP.W+1
2019-04-06 18:43:33 +00:00
tax
2019-04-08 06:07:19 +00:00
pla
bit #%00000011
beq .1
and #%11111100
clc
adc #4
bcc .1
2019-04-06 18:43:33 +00:00
2019-04-08 06:07:19 +00:00
inx
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
.1 sta ZPInputRowBytes
stx ZPInputRowBytes+1
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
>LDYA ZPInputRowBytes
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2019-04-08 06:07:19 +00:00
bcs CS.RUN.RTS
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
>STYA ZPInputBuf
txa
>STA.G hInputBuf
>LDA.G PIX.Header+S.BM.W+1
lsr
tax
>LDA.G PIX.Header+S.BM.W
ror
bcc .2
inc
bne .2
inx
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
.2 sta ZPOutputRowBytes
stx ZPOutputRowBytes+1
2019-04-11 05:56:05 +00:00
>STA.G PIX.Header+S.BM.RowBytes
* txa
* >STA.G PIX.Header+S.BM.RowBytes+1
2019-04-08 06:07:19 +00:00
jsr CS.RUN.GetOutputBuf
2019-04-10 15:51:47 +00:00
bcs CS.RUN.RTS
2019-04-06 18:43:33 +00:00
jsr DEBUG.ClrScr
2019-04-08 06:07:19 +00:00
lda #$ff
2019-04-06 18:43:33 +00:00
sta ZPCntY
2019-04-08 06:07:19 +00:00
CS.RUN.24.LOOP inc ZPLineCount
bne .1
2020-07-03 20:55:40 +00:00
2019-04-08 06:07:19 +00:00
inc ZPLineCount+1
beq .8
2020-07-03 20:55:40 +00:00
2019-04-08 06:07:19 +00:00
.1 inc ZPCntY
lda #$ff
sta ZPCntX
2019-04-11 05:56:05 +00:00
jsr CS.RUN.ReadInput
2019-04-08 06:07:19 +00:00
bcs .9
2020-07-03 20:55:40 +00:00
2019-04-08 06:07:19 +00:00
lda ZPOutputBuf
sec
sbc ZPOutputRowBytes
sta ZPOutputBuf
lda ZPOutputBuf+1
sbc ZPOutputRowBytes+1
sta ZPOutputBuf+1
.2 inc ZPPixelCount
bne .3
inc ZPPixelCount+1
beq CS.RUN.24.LOOP
.3 inc ZPCntX
ldx #2
2019-04-06 18:43:33 +00:00
ldy #0
2019-04-08 06:07:19 +00:00
.4 lda (ZPInputBufPtr),y
2019-04-06 18:43:33 +00:00
sta ZPPixel24,x
iny
dex
2019-04-08 06:07:19 +00:00
bpl .4
2019-04-06 18:43:33 +00:00
lda ZPInputBufPtr
clc
adc #3
sta ZPInputBufPtr
2019-04-08 06:07:19 +00:00
bcc .5
2019-04-06 18:43:33 +00:00
inc ZPInputBufPtr+1
2019-04-08 06:07:19 +00:00
.5 jsr CS.RUN.GetNearestColor
2019-04-06 18:43:33 +00:00
2019-04-10 15:51:47 +00:00
pha
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
jsr DEBUG.PLOT
2020-07-03 20:55:40 +00:00
2019-04-10 15:51:47 +00:00
lda ZPCntX
2020-07-04 19:00:47 +00:00
lsr
2019-04-10 15:51:47 +00:00
tay
pla
2019-04-11 05:56:05 +00:00
bcs .6
2020-07-04 19:00:47 +00:00
2019-04-10 15:51:47 +00:00
sta (ZPOutputBuf),y
bra .2
2020-07-04 19:00:47 +00:00
2019-04-10 15:51:47 +00:00
.6 asl
asl
asl
asl
ora (ZPOutputBuf),y
sta (ZPOutputBuf),y
2020-07-04 19:00:47 +00:00
bra .2
2019-04-06 18:43:33 +00:00
2019-04-11 05:56:05 +00:00
.8 jsr CS.RUN.WriteOutput
2019-04-08 06:07:19 +00:00
bcs .9
2019-04-06 18:43:33 +00:00
lda #0
sec
2019-04-08 06:07:19 +00:00
.9 rts
2019-04-06 18:43:33 +00:00
*--------------------------------------
2019-04-08 06:07:19 +00:00
CS.RUN.GetNearestColor
2019-04-06 18:43:33 +00:00
stz ZPPixelIndex16
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda #$ff
sta ZPPixelBest
sta ZPPixelBest+1
sta ZPPixelBest+2
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
ldy #63
.30 stz ZPPixelScore
stz ZPPixelScore+1
stz ZPPixelScore+2
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
ldx #2
2020-07-03 20:55:40 +00:00
.40 phx A = |c - C|
2020-07-04 19:00:47 +00:00
2020-07-03 20:55:40 +00:00
dey
lda PALETTE.RGB,y
2019-04-06 18:43:33 +00:00
sec
sbc ZPPixel24,x
bcs .5
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
eor #$ff
inc
2020-07-03 20:55:40 +00:00
.5 sta ZBTmpW1
stz ZBTmpW1+1
2019-04-06 18:43:33 +00:00
2020-07-03 20:55:40 +00:00
stz ZBTmpW2
stz ZBTmpW2+1
ldx #8 compute A²
.1 lsr
2019-04-06 18:43:33 +00:00
bcc .2
2020-07-03 20:55:40 +00:00
pha
lda ZBTmpW1
2019-04-06 18:43:33 +00:00
clc
2020-07-03 20:55:40 +00:00
adc ZBTmpW2
sta ZBTmpW2
lda ZBTmpW1+1
adc ZBTmpW2+1
sta ZBTmpW2+1
pla
.2 asl ZBTmpW1
rol ZBTmpW1+1
2019-04-06 18:43:33 +00:00
dex
bne .1
2020-07-03 20:55:40 +00:00
lda ZPPixelScore compute A²+b+c²
2019-04-06 18:43:33 +00:00
clc
2020-07-03 20:55:40 +00:00
adc ZBTmpW2
2019-04-06 18:43:33 +00:00
sta ZPPixelScore
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelScore+1
2020-07-03 20:55:40 +00:00
adc ZBTmpW2+1
2019-04-06 18:43:33 +00:00
sta ZPPixelScore+1
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
bcc .3
inc ZPPixelScore+2
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
.3 plx
dex
bpl .40
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelBest
cmp ZPPixelScore
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelBest+1
sbc ZPPixelScore+1
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelBest+2
sbc ZPPixelScore+2
bcc .8
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelScore
sta ZPPixelBest
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelScore+1
sta ZPPixelBest+1
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelScore+2
sta ZPPixelBest+2
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
tya
lsr
lsr
sta ZPPixelIndex16
.8 dey
bpl .30
2020-07-04 19:00:47 +00:00
2019-04-06 18:43:33 +00:00
lda ZPPixelIndex16
2019-10-03 06:25:27 +00:00
CS.RUN.GetIndexInPalette.RTS
2019-04-06 18:43:33 +00:00
rts
*--------------------------------------
2019-04-11 05:56:05 +00:00
CS.RUN.OpenInput
2020-04-13 17:04:02 +00:00
>PUSHW ZPPtr1
2020-07-04 19:00:47 +00:00
>PUSHBI O.RDONLY
2020-04-13 17:04:02 +00:00
>PUSHBI 0 Type
>PUSHWZ Aux type
2020-03-09 16:24:08 +00:00
>SYSCALL FOpen
2019-04-06 18:43:33 +00:00
bcs CS.RUN.GetIndexInPalette.RTS
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
>STA.G hInputFile
>PUSHWI S.BMP
>PUSHEA.G BMP.Header
>LDA.G hInputFile
>SYSCALL FRead
bcs CS.RUN.GetIndexInPalette.RTS
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
>LDA.G BMP.Header+S.BMP.SIG
2019-04-06 18:43:33 +00:00
cmp #'B'
bne .99
2019-04-08 06:07:19 +00:00
iny
lda (pData),y
2019-04-06 18:43:33 +00:00
cmp #'M'
bne .99
2019-04-08 06:07:19 +00:00
>LDA.G BMP.Header+S.BMP.BPP+1
2019-04-06 18:43:33 +00:00
bne .99
dey
2019-04-08 06:07:19 +00:00
lda (pData),y
2019-04-06 18:43:33 +00:00
cmp #1
beq .1
cmp #24
bne .99
2020-07-04 19:00:47 +00:00
2020-04-13 17:04:02 +00:00
.1 >PUSHW L.MSG.HEADER.OK
2020-07-04 19:00:47 +00:00
2020-04-13 17:04:02 +00:00
>LDA.G BMP.Header+S.BMP.W
>STA.G PIX.Header+S.BM.W
pha
>LDA.G BMP.Header+S.BMP.W+1
>STA.G PIX.Header+S.BM.W+1
>PUSHA
pla
>PUSHA
2019-04-08 06:07:19 +00:00
>LDA.G BMP.Header+S.BMP.H
2019-04-06 18:43:33 +00:00
>STA.G PIX.Header+S.BM.H
pha
eor #$ff
sta ZPLineCount
2020-07-04 19:00:47 +00:00
2019-04-08 06:07:19 +00:00
>LDA.G BMP.Header+S.BMP.H+1
2019-04-06 18:43:33 +00:00
>STA.G PIX.Header+S.BM.H+1
>PUSHA
eor #$ff
sta ZPLineCount+1
pla
>PUSHA
2020-07-04 19:00:47 +00:00
2020-04-13 17:04:02 +00:00
>PUSHB.G BMP.Header+S.BMP.BPP
2020-07-04 19:00:47 +00:00
2019-04-06 18:43:33 +00:00
>PUSHBI 5
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-04-06 18:43:33 +00:00
.9 rts
2020-04-13 17:04:02 +00:00
2019-04-06 18:43:33 +00:00
.99 >LDYA L.MSG.HEADER.KO
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2019-04-06 18:43:33 +00:00
lda #E.IBIN
sec
2019-10-03 06:25:27 +00:00
rts
2019-04-06 18:43:33 +00:00
*--------------------------------------
2019-04-11 05:56:05 +00:00
CS.RUN.ReadInput
2019-04-08 06:07:19 +00:00
>PUSHW ZPInputRowBytes
>PUSHW ZPInputBuf
>LDA.G hInputFile
>SYSCALL FRead
bcs .9
2020-04-13 17:04:02 +00:00
2019-04-08 06:07:19 +00:00
>LDYA ZPInputBuf
>STYA ZPInputBufPtr
>LDA.G BMP.Header+S.BMP.W
eor #$ff
sta ZPPixelCount
>LDA.G BMP.Header+S.BMP.W+1
eor #$ff
sta ZPPixelCount+1
.9 rts
*--------------------------------------
2019-04-11 05:56:05 +00:00
CS.RUN.CreateOutput
2020-04-13 17:04:02 +00:00
>PUSHW ZPPtr1
2020-07-04 19:00:47 +00:00
>PUSHBI O.WRONLY+O.CREATE
2020-04-13 17:04:02 +00:00
>PUSHBI $CB PIX Type
>PUSHWZ Aux type
2019-04-06 18:43:33 +00:00
>SYSCALL FOpen
bcs .9
>STA.G hOutputFile
2019-10-03 06:25:27 +00:00
.9 rts
2019-04-06 18:43:33 +00:00
*--------------------------------------
2019-04-08 06:07:19 +00:00
CS.RUN.GetOutputBuf
stz ZPPtr1
stz ZPPtr1+1
ldy ZPLineCount
ldx ZPLineCount+1
.1 iny
bne .2
inx
beq .8
.2 lda ZPPtr1
clc
adc ZPOutputRowBytes
sta ZPPtr1
lda ZPPtr1+1
adc ZPOutputRowBytes+1
sta ZPPtr1+1
bra .1
2019-04-11 05:56:05 +00:00
.8 >LDYA ZPPtr1
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2019-04-10 15:51:47 +00:00
bcs .9
2019-04-11 05:56:05 +00:00
2019-04-10 15:51:47 +00:00
>STYA ZPOutputBuf
txa
>STA.G hOutputBuf
2019-04-11 05:56:05 +00:00
2019-04-10 15:51:47 +00:00
lda ZPPtr1
2019-04-08 06:07:19 +00:00
>STA.G OutputDataLen
clc
adc ZPOutputBuf
sta ZPOutputBuf
lda ZPPtr1+1
>STA.G OutputDataLen+1
adc ZPOutputBuf+1
sta ZPOutputBuf+1
clc
2019-04-10 15:51:47 +00:00
.9 rts
2019-04-08 06:07:19 +00:00
*--------------------------------------
2019-04-11 05:56:05 +00:00
CS.RUN.WriteOutput
2020-08-30 17:50:57 +00:00
>LDA.G bNoHeader
bmi .1
2019-04-11 05:56:05 +00:00
>PUSHWI S.BM
2019-04-06 18:43:33 +00:00
>PUSHEA.G PIX.Header
>LDA.G hOutputFile
>SYSCALL FWrite
2019-04-08 06:07:19 +00:00
bcs .9
2020-08-30 17:50:57 +00:00
.1 >PUSHW.G OutputDataLen
2019-04-08 06:07:19 +00:00
>PUSHW ZPOutputBuf
>LDA.G hOutputFile
>SYSCALL FWrite
.9 rts
2019-04-06 18:43:33 +00:00
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
2019-04-08 06:07:19 +00:00
CS.QUIT >LDA.G hOutputBuf
beq .1
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2019-04-06 18:43:33 +00:00
.1 >LDA.G hInputBuf
beq .2
>SYSCALL FreeMem
.2 >LDA.G hOutputFile
2019-04-08 06:07:19 +00:00
beq .3
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
2019-04-08 06:07:19 +00:00
.3 >LDA.G hInputFile
beq .8
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
.8 clc
rts
*--------------------------------------
2019-04-06 18:43:33 +00:00
DEBUG.ClrScr sta SETMIXED
sta CLRTEXT
ldx #19
.1 lda SCR.BASEL,x
2020-08-19 19:39:43 +00:00
sta ZPPtr1
2019-04-06 18:43:33 +00:00
lda SCR.BASEH,x
2020-08-19 19:39:43 +00:00
sta ZPPtr1+1
2019-04-06 18:43:33 +00:00
lda #0
ldy #39
.2 sta SETPAGE2
2020-08-19 19:39:43 +00:00
sta (ZPPtr1),y
2019-04-06 18:43:33 +00:00
sta CLRPAGE2
2020-08-19 19:39:43 +00:00
sta (ZPPtr1),y
2019-04-06 18:43:33 +00:00
dey
bpl .2
dex
bpl .1
rts
*--------------------------------------
2019-04-08 06:07:19 +00:00
DEBUG.PLOT php
sei
2020-07-03 20:55:40 +00:00
2019-04-08 06:07:19 +00:00
pha
2020-07-03 20:55:40 +00:00
tax
2020-07-04 19:00:47 +00:00
2020-07-03 20:55:40 +00:00
lda ZPCntY
cmp #40
bcs .9
2019-04-06 18:43:33 +00:00
lda ZPCntX
2019-04-08 06:07:19 +00:00
cmp #80
bcs .9
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
lsr
tay
2019-04-08 06:07:19 +00:00
2019-04-06 18:43:33 +00:00
bcs .1 CS = main
2020-07-03 20:55:40 +00:00
2019-04-06 18:43:33 +00:00
sta SETPAGE2
2019-04-09 15:47:33 +00:00
lda PALETTE.AUX,x
2020-07-03 20:55:40 +00:00
bra .2
2020-07-04 19:00:47 +00:00
2020-07-03 20:55:40 +00:00
.1 sta CLRPAGE2
lda PALETTE.MAIN,x
.2 pha
2019-04-08 06:07:19 +00:00
lda #39
sec
sbc ZPCntY
2019-04-06 18:43:33 +00:00
lsr
tax
lda SCR.BASEL,x
2020-08-19 19:39:43 +00:00
sta ZPPtr1
2019-04-06 18:43:33 +00:00
lda SCR.BASEH,x
2020-08-19 19:39:43 +00:00
sta ZPPtr1+1
2019-04-06 18:43:33 +00:00
pla
2020-07-03 20:55:40 +00:00
bcc .3
2019-04-06 18:43:33 +00:00
asl
asl
asl
asl
2020-07-03 20:55:40 +00:00
2020-08-19 19:39:43 +00:00
.3 ora (ZPPtr1),y
sta (ZPPtr1),y
2019-04-06 18:43:33 +00:00
sta CLRPAGE2
2020-07-03 20:55:40 +00:00
2019-04-08 06:07:19 +00:00
.9 pla
plp
2019-04-06 18:43:33 +00:00
rts
*--------------------------------------
SCR.BASEL .HS 00.80.00.80.00.80.00.80.28.A8.28.A8.28.A8.28.A8.50.D0.50.D0.50.D0.50.D0
SCR.BASEH .HS 04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07
*--------------------------------------
CS.END
2017-12-12 07:27:36 +00:00
*--------------------------------------
2020-06-27 18:30:09 +00:00
.INB usr/src/shared/x.twist.g
2020-07-04 19:00:47 +00:00
*--------------------------------------
2020-08-30 17:50:57 +00:00
OptionList .AS "VvHh"
OptionVars .DA #bVerbose,#bVerbose,#bNoHeader,#bNoHeader
2019-04-06 18:43:33 +00:00
MSG.USAGE .AS "Usage : BMP2PIX BMP-File \r\n"
.AZ " -V : Verbose Mode\r\n"
2020-07-04 19:00:47 +00:00
MSG.HEADER.OK .AZ "BMP Size : %D x %D pixels, %d bit(s)/pixel\r\n"
MSG.HEADER.KO .AZ "Invalid Input File Format"
MSG.DONE .AZ "All Done!!!"
2018-11-19 07:43:00 +00:00
*--------------------------------------
* LOWRES Patette : https://comp.sys.apple2.narkive.com/lTSrj2ZI/apple-ii-colour-rgb
*--------------------------------------
2020-07-03 20:55:40 +00:00
*PALETTE.RGB .HS 00000000 BLACK
* .HS ffffff00 WHITE
* .HS 7e7e7e00 DARK.GRAY
2019-04-08 06:07:19 +00:00
* .HS 9c9c9c00 DARK.GRAY
2020-07-03 20:55:40 +00:00
* .HS 604ebd00 DARK.BLUE
2019-04-08 06:07:19 +00:00
* .HS 14cffd00 BLUE
* .HS d0c3ff00 LIGHT.BLUE
2020-07-03 20:55:40 +00:00
* .HS 00a36000 DARK.GREEN
* .HS 14f53c00 LIGHT.GREEN
* .HS 72ffd000 AQUA
* .HS e31e6000 RED
* .HS ff44fd00 PURPLE
* .HS ffa0d000 PINK
2019-04-08 06:07:19 +00:00
* .HS 60720300 BROWN
* .HS ff6a3c00 ORANGE
* .HS d0dd8d00 YELLOW
*--------------------------------------
2020-07-04 19:00:47 +00:00
*PALETTE.RGB .DA #0,#0,#0,#0 0 Black
* .DA #255,#255,#255,#0 15 White
* .DA #126,#126,#126,#0 5 Grey1
* .DA #156,#156,#156,#0 10 Grey2
2020-07-03 20:55:40 +00:00
* .DA #96,#78,#189,#0 8 Dark Blue
2020-07-04 19:00:47 +00:00
* .DA #20,#207,#253,#0 12 Medium Blue
* .DA #208,#195,#255,#0 13 Light Blue
2020-07-03 20:55:40 +00:00
* .DA #0,#163,#96,#0 4 Dark Green
2020-07-04 19:00:47 +00:00
* .DA #20,#245,#60,#0 6 Green
* .DA #114,#255,#208,#0 14 Aqua
* .DA #255,#68,#253,#0 9 Violet
* .DA #255,#160,#208,#0 11 Pink
* .DA #227,#30,#96,#0 1 Magenta
* .DA #96,#114,#3,#0 2 Brown
* .DA #255,#106,#60,#0 3 Orange
* .DA #208,#221,#141,#0 7 Yellow
*--------------------------------------
PALETTE.RGB .HS 00000000 BLACK
.HS 1f35D300 DARK.BLUE
.HS 00760c00 DARK.GREEN
.HS 07a8e000 BLUE
.HS 624c0000 BROWN
.HS 7e7e7e00 DARK.GRAY
.HS 43c80000 LIGHT.GREEN
.HS 5df78400 AQUA
.HS 930B7c00 RED
.HS bb36ff00 PURPLE
.HS 9c9c9c00 LIGHT.GRAY
.HS b5afff00 LIGHT.BLUE
.HS f9561d00 ORANGE
.HS ff81ec00 PINK
.HS dccd1600 YELLOW
.HS ffffff00 WHITE
*--------------------------------------
PALETTE.MAIN .HS 00.02.04.06.08.0A.0C.0E
.HS 01.03.05.07.09.0B.0D.0F
PALETTE.AUX .HS 00.01.02.03.04.05.06.07
.HS 08.09.0A.0B.0C.0D.0E.0F
2020-07-03 20:55:40 +00:00
*PALETTE.AUX .HS 00.08.01.09.02.0A.03.0B
* .HS 04.0C.05.0D.06.0E.07.0F
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgCount .BS 1
2019-04-08 06:07:19 +00:00
bVerbose .BS 1
2020-08-30 17:50:57 +00:00
bNoHeader .BS 1
2019-04-08 06:07:19 +00:00
hInputFile .BS 1
hInputBuf .BS 1
hOutputFile .BS 1
2019-04-08 06:07:19 +00:00
hOutputBuf .BS 1
OutputDataLen .BS 2
BMP.Header .BS S.BMP
PIX.Header .BS S.BM
DS.END
.ED
*--------------------------------------
MAN
2020-06-27 18:30:09 +00:00
SAVE usr/src/bin/bmp2pix.s
ASM