A2osX/FNT2FON.S.txt

427 lines
11 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.BUILD
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/FNT2FON
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/LIBGUI.I
*--------------------------------------
S.FNT.dfVersion .EQ 0
S.FNT.dfSize .EQ 2
S.FNT.dfCopyright .EQ 6
S.FNT.dfType .EQ 66
S.FNT.dfPoints .EQ 68
S.FNT.dfVertRes .EQ 70
S.FNT.dfHorizRes .EQ 72
S.FNT.dfAscent .EQ 74
S.FNT.dfInternalLeading .EQ 76
S.FNT.dfExternalLeading .EQ 78
S.FNT.dfItalic .EQ 80
S.FNT.dfUnderline .EQ 81
S.FNT.dfStrikeOut .EQ 82
S.FNT.dfWeight .EQ 83
S.FNT.dfCharSet .EQ 85
S.FNT.dfPixWidth .EQ 86
S.FNT.dfPixHeight .EQ 88
S.FNT.dfPitchAndFamily .EQ 90
S.FNT.dfAvgWidth .EQ 91
S.FNT.dfMaxWidth .EQ 93
S.FNT.dfFirstChar .EQ 95
S.FNT.dfLastChar .EQ 96
S.FNT.dfDefaultChar .EQ 97
S.FNT.dfBreakChar .EQ 98
S.FNT.dfWidthBytes .EQ 99
S.FNT.dfDevice .EQ 101
S.FNT.dfFace .EQ 105
S.FNT.dfBitsPointer .EQ 109
S.FNT.dfBitsOffset .EQ 113
S.FNT.dfReserved .EQ 117
S.FNT.dfCharTable2 .EQ 118
*S.FNT.dfFlags3 .EQ 118
*S.FNT.dfAspace3 .EQ 122
*S.FNT.dfBspace3 .EQ 124
*S.FNT.dfCspace3 .EQ 126
*S.FNT.dfColorPointer3 .EQ 128
*S.FNT.dfReserved13 .EQ 132
S.FNT.dfCharTable3 .EQ 148
*--------------------------------------
ZPPTR1 .EQ ZPBIN
ZPInputBufPtr .EQ ZPBIN+2
ZPInputBufLen .EQ ZPBIN+4
ZPInputTblPtr .EQ ZPBIN+6
ZPInputBMPtr .EQ ZPBIN+8
ZPOutPutTblPtr .EQ ZPBIN+10
ZPOutPutBMPtr .EQ ZPBIN+12
ZPBufPtr .EQ ZPBIN+14
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #16 ZP
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.FILE.OK .DA MSG.FILE.OK
L.MSG.HEADER.OK .DA MSG.HEADER.OK
L.MSG.HEADER.KO .DA MSG.HEADER.KO
L.MSG.RANGE .DA MSG.RANGE
L.MSG.DONE .DA MSG.DONE
.DA 0
*--------------------------------------
CS.INIT
.1 >INC.G ArgCount
>SYSCALL GetArg.A
bcs .7
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
ldx OptionList
.2 cmp OptionList,x
beq .3
dex
bne .2
.99 >LDYA L.MSG.USAGE
>SYSCALL PrintF.YA
lda #K.E.SYN
sec
rts
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra .1
.4 >LDA.G hInputBuf
bne .5
jsr CS.INIT.OPENINPUT
bcc .1 scan for any other args
rts
.5 >LDA.G hOutputFile
bne .99
jsr CS.INIT.CREATEOUTPUT
bcc .1 scan for any other args
rts
.7 >LDA.G hOutputFile
beq .99
>LDYAI 8192 max 256x256 pixels
>SYSCALL GetMem.YA
bcs CS.INIT.RTS
>STYA ZPBufPtr
txa
>STA.G hBuf
.8 clc
CS.INIT.RTS rts
*--------------------------------------
CS.INIT.OPENINPUT
>PUSHWI 0 Aux type
>PUSHBI 0 Type
>PUSHBI SYS.FOpen.R
>PUSHW ZPPtr1
>SYSCALL LoadFile
bcs CS.INIT.RTS
>STYA ZPInputBufLen
>PUSHYA
txa
>STA.G hInputBuf
>SYSCALL GetMemPtr.A
>STYA ZPInputBufPtr
>LDYA L.MSG.FILE.OK
>SYSCALL PrintF.YA
ldy #S.FNT.dfVersion
lda (ZPInputBufPtr),y
bne .99
iny
lda (ZPInputBufPtr),y
cmp #2
beq .1
cmp #3
bne .99
.1 asl *2 = Entry Len in Tbl
>STA.G FNT.Version
pha
ldy #S.FNT.dfAscent
lda (ZPInputBufPtr),y
>STA.G FON.Header+S.FON.Ascent
>PUSHA
ldy #S.FNT.dfPixHeight
lda (ZPInputBufPtr),y
>STA.G FON.Header+S.FON.PixH
>PUSHA
ldy #S.FNT.dfPixWidth
lda (ZPInputBufPtr),y
>STA.G FON.Header+S.FON.PixW
>PUSHA
pla
>PUSHA
>LDYA L.MSG.HEADER.OK
>SYSCALL PrintF.YA
clc
rts
.99 >LDYA L.MSG.HEADER.KO
>SYSCALL PrintF.YA
lda #K.E.IBIN
sec
rts
*--------------------------------------
CS.INIT.CREATEOUTPUT
>PUSHWI 0 Aux type
>PUSHBI $CC FON Type
>PUSHBI SYS.FOpen.W+SYS.FOpen.X
>PUSHW ZPPtr1
>SYSCALL FOpen
bcs .9
>STA.G hOutputFile
.9 rts
*--------------------------------------
CS.RUN ldy #S.FNT.dfBreakChar
lda (ZPInputBufPtr),y
>STA.G FON.Header+S.FON.Break
>PUSHA
ldy #S.FNT.dfDefaultChar
lda (ZPInputBufPtr),y
>STA.G FON.Header+S.FON.Default
>PUSHA
ldy #S.FNT.dfLastChar
lda (ZPInputBufPtr),y
>STA.G FON.Header+S.FON.Last
>PUSHA
ldy #S.FNT.dfFirstChar
lda (ZPInputBufPtr),y
>STA.G FON.Header+S.FON.First
>PUSHA
>LDYA L.MSG.RANGE
>SYSCALL PrintF.YA
>LDA.G FON.Header+S.FON.Last
>SBC.G FON.Header+S.FON.First
>STA.G CharCount
>LDA.G FNT.Version
ldx #S.FNT.dfCharTable2
cmp #4
bne .1
ldx #S.FNT.dfCharTable3
.1 txa
clc
adc ZPInputBufPtr
sta ZPInputTblPtr
lda #0
adc ZPInputBufPtr+1
sta ZPInputTblPtr+1
.2 ldy #2
lda (ZPInputTblPtr),y Get Char BitMap Offset
clc
adc ZPInputBufPtr
sta ZPInputBMPtr
iny
lda (ZPInputTblPtr),y
adc ZPInputBufPtr+1
sta ZPInputBMPtr+1
lda (ZPInputTblPtr) Get Char PixW
jsr CS.RUN.GetChar
>DEC.G CharCount
beq .8
lda ZPInputTblPtr
clc
>ADC.G FNT.Version
sta ZPInputTblPtr
bcc .2
inc ZPInputTblPtr+1
bra .2
.8 >LDYA L.MSG.DONE
>SYSCALL PrintF.YA
lda #0
sec
CS.RUN.RTS rts
*--------------------------------------
* A=PixW, ZPInputBMPtr->DATA
*--------------------------------------
CS.RUN.GetChar pha
lsr
lsr
lsr
tax
pla
and #7
beq .1
inx
txa
>STA.G CharByteW
ldx #0 0 > X > CharByteW
.1 >LDA.G ON.Header+S.FON.PixH
.2 pha
clc
adc ZPBufPtr
sta ZPPTR1
lda #0
adc ZPBufPtr+1
sta ZPPTR1+1
.3 lda (ZPInputBMPtr)
inc ZPInputBMPtr
bne .4
inc ZPInputBMPtr+1
.4 sta (ZPPTR1)
lda ZPPTR1
clc
>ADC.G CharByteW
sta ZPPTR1
bcc .5
inc ZPPTR1+1
.5 inx
txa
pla
dec
bne .1
clc
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT >LDA.G hOutputFile
beq .1
>SYSCALL FClose.A
.1 >LDA.G hInputBuf
beq .1
>SYSCALL FreeMem.A
.2 >LDA.G hBuf
beq .1
>SYSCALL FreeMem.A
.8 clc
rts
*--------------------------------------
CS.END
TWIST .DA #%00000000,#%10000000,#%01000000,#%11000000,#%00100000,#%10100000,#%01100000,#%11100000
.DA #%00010000,#%10010000,#%01010000,#%11010000,#%00110000,#%10110000,#%01110000,#%11110000
.DA #%00001000,#%10001000,#%01001000,#%11001000,#%00101000,#%10101000,#%01101000,#%11101000
.DA #%00011000,#%10011000,#%01011000,#%11011000,#%00111000,#%10111000,#%01111000,#%11111000
.DA #%00000100,#%10000100,#%01000100,#%11000100,#%00100100,#%10100100,#%01100100,#%11100100
.DA #%00010100,#%10010100,#%01010100,#%11010100,#%00110100,#%10110100,#%01110100,#%11110100
.DA #%00001100,#%10001100,#%01001100,#%11001100,#%00101100,#%10101100,#%01101100,#%11101100
.DA #%00011100,#%10011100,#%01011100,#%11011100,#%00111100,#%10111100,#%01111100,#%11111100
.DA #%00000010,#%10000010,#%01000010,#%11000010,#%00100010,#%10100010,#%01100010,#%11100010
.DA #%00010010,#%10010010,#%01010010,#%11010010,#%00110010,#%10110010,#%01110010,#%11110010
.DA #%00001010,#%10001010,#%01001010,#%11001010,#%00101010,#%10101010,#%01101010,#%11101010
.DA #%00011010,#%10011010,#%01011010,#%11011010,#%00111010,#%10111010,#%01111010,#%11111010
.DA #%00000110,#%10000110,#%01000110,#%11000110,#%00100110,#%10100110,#%01100110,#%11100110
.DA #%00010110,#%10010110,#%01010110,#%11010110,#%00110110,#%10110110,#%01110110,#%11110110
.DA #%00001110,#%10001110,#%01001110,#%11001110,#%00101110,#%10101110,#%01101110,#%11101110
.DA #%00011110,#%10011110,#%01011110,#%11011110,#%00111110,#%10111110,#%01111110,#%11111110
.DA #%00000001,#%10000001,#%01000001,#%11000001,#%00100001,#%10100001,#%01100001,#%11100001
.DA #%00010001,#%10010001,#%01010001,#%11010001,#%00110001,#%10110001,#%01110001,#%11110001
.DA #%00001001,#%10001001,#%01001001,#%11001001,#%00101001,#%10101001,#%01101001,#%11101001
.DA #%00011001,#%10011001,#%01011001,#%11011001,#%00111001,#%10111001,#%01111001,#%11111001
.DA #%00000101,#%10000101,#%01000101,#%11000101,#%00100101,#%10100101,#%01100101,#%11100101
.DA #%00010101,#%10010101,#%01010101,#%11010101,#%00110101,#%10110101,#%01110101,#%11110101
.DA #%00001101,#%10001101,#%01001101,#%11001101,#%00101101,#%10101101,#%01101101,#%11101101
.DA #%00011101,#%10011101,#%01011101,#%11011101,#%00111101,#%10111101,#%01111101,#%11111101
.DA #%00000011,#%10000011,#%01000011,#%11000011,#%00100011,#%10100011,#%01100011,#%11100011
.DA #%00010011,#%10010011,#%01010011,#%11010011,#%00110011,#%10110011,#%01110011,#%11110011
.DA #%00001011,#%10001011,#%01001011,#%11001011,#%00101011,#%10101011,#%01101011,#%11101011
.DA #%00011011,#%10011011,#%01011011,#%11011011,#%00111011,#%10111011,#%01111011,#%11111011
.DA #%00000111,#%10000111,#%01000111,#%11000111,#%00100111,#%10100111,#%01100111,#%11100111
.DA #%00010111,#%10010111,#%01010111,#%11010111,#%00110111,#%10110111,#%01110111,#%11110111
.DA #%00001111,#%10001111,#%01001111,#%11001111,#%00101111,#%10101111,#%01101111,#%11101111
.DA #%00011111,#%10011111,#%01011111,#%11011111,#%00111111,#%10111111,#%01111111,#%11111111
*--------------------------------------
OptionList >PSTR "Vv"
OptionVars .DA #bVerbose,#bVerbose
MSG.USAGE >CSTR "Usage : FNT2FON FNT-File \r\n -V : Verbose Mode\r\n"
MSG.FILE.OK >CSTR "FNT File Loaded, %D Bytes Read\r\n"
MSG.HEADER.OK >CSTR "FNT File Version : %d, Size : %d x %d pixels, Ascent : %d\r\n"
MSG.HEADER.KO >CSTR "Invalid Input File Format\r\n"
MSG.RANGE >CSTR "First/Last Char : %d/%d, Default : %d, Break : %d\r\n"
MSG.DONE >CSTR "All Done!!!\r\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
FNT.Version .BS 1
FON.Header .BS S.FON
ArgCount .BS 1
hInputBuf .BS 1
hOutputFile .BS 1
bVerbose .BS 1
hBuf .BS 1
CharCount .BS 1
CharByteW .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE /A2OSX.BUILD/FNT2FON.S
ASM