mirror of
https://github.com/Michaelangel007/apple2_printm.git
synced 2024-12-29 17:32:23 +00:00
Ver 17
This commit is contained in:
parent
f36af1a8ba
commit
048b04507b
82
printm.s
82
printm.s
@ -1,7 +1,7 @@
|
|||||||
; ca65
|
; ca65
|
||||||
.feature c_comments
|
.feature c_comments
|
||||||
|
|
||||||
/* Version 16
|
/* Version 17
|
||||||
printm - a printf replacement for 65C02
|
printm - a printf replacement for 65C02
|
||||||
Michael Pohoreski
|
Michael Pohoreski
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ Output:
|
|||||||
|
|
||||||
X=39 Y=191 $=2345:D5 11010101~10101011
|
X=39 Y=191 $=2345:D5 11010101~10101011
|
||||||
Bin ASC: 01010111 <- ???
|
Bin ASC: 01010111 <- ???
|
||||||
Bin REV: 01010111
|
Bin REV: 01010111 <- FIXME: Bin INV, Bin REV
|
||||||
Dec2: 99
|
Dec2: 99
|
||||||
Dec3: 999
|
Dec3: 999
|
||||||
Dec5: 65385
|
Dec5: 65385
|
||||||
@ -419,7 +419,7 @@ Pascal: 'Pascal Len 13'
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.org __MAIN ; .org must come after header else offsets are wrong
|
.org __MAIN ; .org must come after header else offsets are wrong
|
||||||
|
|
||||||
; Demo printm
|
; Demo printm
|
||||||
JSR HOME
|
JSR HOME
|
||||||
@ -429,37 +429,39 @@ Pascal: 'Pascal Len 13'
|
|||||||
LDA #$AA
|
LDA #$AA
|
||||||
STA $2001
|
STA $2001
|
||||||
|
|
||||||
LDA DATA+4 ; HGR Y row
|
LDA ARGS_DEMO+4 ;HGR Y row
|
||||||
LDX #$00 ; HGR x.col_lo = 0
|
LDX #$00 ; HGR x.col_lo = 0
|
||||||
LDY #$00 ; x.col_hi = 0
|
LDY #$00 ; x.col_hi = 0
|
||||||
JSR HPOSN
|
JSR HPOSN
|
||||||
CLC
|
CLC
|
||||||
LDA GBASL
|
LDA GBASL
|
||||||
ADC DATA+2 ; HGR x col
|
ADC ARGS_DEMO+2 ; HGR x col
|
||||||
STA GBASL
|
STA GBASL
|
||||||
TAX
|
TAX
|
||||||
LDY GBASH
|
LDY GBASH
|
||||||
|
|
||||||
STX DATA+6 ; aArg[3]
|
STX ARGS_DEMO+6 ; aArg[3]
|
||||||
STY DATA+7
|
STY ARGS_DEMO+7
|
||||||
STX DATA+8 ; aArg[4]
|
STX ARGS_DEMO+8 ; aArg[4]
|
||||||
STY DATA+9
|
STY ARGS_DEMO+9
|
||||||
|
|
||||||
LDA $2000
|
LDA $2000
|
||||||
LDY #0
|
LDY #0
|
||||||
STA (GBASL),Y
|
STA (GBASL),Y
|
||||||
STA DATA+10 ; aArg[5]
|
STA ARGS_DEMO+10 ; aArg[5]
|
||||||
STZ DATA+11
|
STZ ARGS_DEMO+11
|
||||||
|
STA ARGS_BIN_ASC+2
|
||||||
|
|
||||||
JSR ReverseByte
|
JSR ReverseByte
|
||||||
STA DATA+12 ; aArg[6]
|
STA ARGS_DEMO+12 ; aArg[6]
|
||||||
STZ DATA+13
|
STZ ARGS_DEMO+13
|
||||||
|
STA ARGS_BIN_INV+2
|
||||||
|
|
||||||
.if ENABLE_BIN && ENABLE_DEC && ENABLE_HEX
|
.if ENABLE_BIN && ENABLE_DEC && ENABLE_HEX
|
||||||
LDY #0
|
LDY #0
|
||||||
JSR VTABY
|
JSR VTABY
|
||||||
LDX #<DATA ; Low Byte of Address
|
LDX #<ARGS_DEMO ; Low Byte of Address
|
||||||
LDY #>DATA ; High Byte of Address
|
LDY #>ARGS_DEMO ; High Byte of Address
|
||||||
JSR PrintM
|
JSR PrintM
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
@ -571,7 +573,7 @@ Pascal: 'Pascal Len 13'
|
|||||||
LDA #14
|
LDA #14
|
||||||
JSR TABV
|
JSR TABV
|
||||||
|
|
||||||
; old-skool text printing
|
; old-skool text/hex printing
|
||||||
LDY #0
|
LDY #0
|
||||||
@_Text
|
@_Text
|
||||||
LDA PRINTM_TEXT,Y
|
LDA PRINTM_TEXT,Y
|
||||||
@ -582,7 +584,7 @@ Pascal: 'Pascal Len 13'
|
|||||||
@_Size
|
@_Size
|
||||||
|
|
||||||
LDA PRINTM_SIZE+1
|
LDA PRINTM_SIZE+1
|
||||||
JSR PREQHEX
|
JSR PRBYTE
|
||||||
LDA PRINTM_SIZE+0
|
LDA PRINTM_SIZE+0
|
||||||
JSR PRBYTE
|
JSR PRBYTE
|
||||||
LDA #$8D
|
LDA #$8D
|
||||||
@ -631,12 +633,12 @@ SCREEN_HI
|
|||||||
|
|
||||||
; ______________________________________________________________________
|
; ______________________________________________________________________
|
||||||
|
|
||||||
TEXT
|
TEXT_DEMO
|
||||||
;byte "X=## Y=ddd $=xxxx:@@ %%%%%%%%~????????"
|
;byte "X=## Y=ddd $=xxxx:@@ %%%%%%%%~????????"
|
||||||
PRINTM "X=%# Y=%d $=%x:%@ %%~%?", 0
|
PRINTM "X=%# Y=%d $=%x:%@ %%~%?", 0
|
||||||
|
|
||||||
DATA
|
ARGS_DEMO
|
||||||
dw TEXT ; aArg[ 0] text
|
dw TEXT_DEMO; aArg[ 0] text
|
||||||
dw 39 ; aArg[ 1] x
|
dw 39 ; aArg[ 1] x
|
||||||
dw 191 ; aArg[ 2] y
|
dw 191 ; aArg[ 2] y
|
||||||
dw $C0DE ; aArg[ 3] addr ScreenAddr
|
dw $C0DE ; aArg[ 3] addr ScreenAddr
|
||||||
@ -651,11 +653,11 @@ TEXT_BIN_INV PRINTM "Bin INV: %?", 0
|
|||||||
|
|
||||||
ARGS_BIN_ASC
|
ARGS_BIN_ASC
|
||||||
dw TEXT_BIN_ASC
|
dw TEXT_BIN_ASC
|
||||||
dw DATA+10
|
dw $DA1A
|
||||||
|
|
||||||
ARGS_BIN_INV
|
ARGS_BIN_INV
|
||||||
dw TEXT_BIN_INV
|
dw TEXT_BIN_INV
|
||||||
dw DATA+10
|
dw $DA1A
|
||||||
|
|
||||||
; ______________________________________________________________________
|
; ______________________________________________________________________
|
||||||
|
|
||||||
@ -679,17 +681,17 @@ ARGS_DEC_5
|
|||||||
ARGS_DEC_BYTE
|
ARGS_DEC_BYTE
|
||||||
dw TEXT_DEC_BYTE
|
dw TEXT_DEC_BYTE
|
||||||
dw $80 ; -128
|
dw $80 ; -128
|
||||||
dw $FF ; -1
|
dw $FF ; -001
|
||||||
dw $00 ; 0
|
dw $00 ; 000
|
||||||
dw $01 ; +1
|
dw $01 ; +001
|
||||||
dw $7F ; +127
|
dw $7F ; +127
|
||||||
|
|
||||||
; ______________________________________________________________________
|
; ______________________________________________________________________
|
||||||
|
|
||||||
TEXT_HEX_2 PRINTM "Hex2: $%$", 0
|
TEXT_HEX_2 PRINTM "Hex2: %$", 0
|
||||||
TEXT_HEX_4 PRINTM "Hex4: $%x", 0
|
TEXT_HEX_4 PRINTM "Hex4: %x", 0
|
||||||
TEXT_PTR_2 PRINTM "Ptr2: $%x:%@", 0
|
TEXT_PTR_2 PRINTM "Ptr2: %x:%@", 0
|
||||||
TEXT_PTR_4 PRINTM "Ptr4: $%x:%&", 0
|
TEXT_PTR_4 PRINTM "Ptr4: %x:%&", 0
|
||||||
|
|
||||||
ARGS_HEX_2
|
ARGS_HEX_2
|
||||||
dw TEXT_HEX_2
|
dw TEXT_HEX_2
|
||||||
@ -749,7 +751,7 @@ ARGS_STR_PASCAL
|
|||||||
|
|
||||||
; ______________________________________________________________________
|
; ______________________________________________________________________
|
||||||
|
|
||||||
PRINTM_TEXT APPLE "printm().size"
|
PRINTM_TEXT APPLE "printm().size = $"
|
||||||
db 0
|
db 0
|
||||||
PRINTM_SIZE
|
PRINTM_SIZE
|
||||||
dw __END - PrintM
|
dw __END - PrintM
|
||||||
@ -926,10 +928,12 @@ GetFormat
|
|||||||
BEQ _Done ; zero-terminated
|
BEQ _Done ; zero-terminated
|
||||||
BMI Print ; neg = literal
|
BMI Print ; neg = literal
|
||||||
|
|
||||||
; NOTE: If all features are turned off would get a ca65 Range Error
|
; NOTE: If all features are turned off LDX #-1 ca65 throws Range Error
|
||||||
; We can't use this equation since it is not const
|
; NumMeta = _MetaCharEnd - MetaChar
|
||||||
; due to _MetaCharEnd not being defined yet
|
; LDX #NumMeta-1 ; pos = meta
|
||||||
; NumMeta = _MetaCharEnd - MetaChar
|
; We can't use this equation since it is not const due to the assembler
|
||||||
|
; not having defined _MetaCharEnd yet
|
||||||
|
; Instead we count the number of features enabled
|
||||||
.if (NumMeta > 0)
|
.if (NumMeta > 0)
|
||||||
LDX #NumMeta-1 ; pos = meta
|
LDX #NumMeta-1 ; pos = meta
|
||||||
.else
|
.else
|
||||||
@ -1218,13 +1222,13 @@ MetaChar
|
|||||||
.if USE_HEX_4
|
.if USE_HEX_4
|
||||||
db 'x' ; PrintHex4
|
db 'x' ; PrintHex4
|
||||||
.endif
|
.endif
|
||||||
.if USE_HEX_4
|
.if USE_HEX_2
|
||||||
db '$' ; PrintHex2
|
db '$' ; PrintHex2
|
||||||
.endif
|
.endif
|
||||||
.if USE_PTR_2
|
.if USE_PTR_4
|
||||||
db '&' ; PrintPtr4
|
db '&' ; PrintPtr4
|
||||||
.endif
|
.endif
|
||||||
.if USE_PTR_4
|
.if USE_PTR_2
|
||||||
db '@' ; PrintPtr2
|
db '@' ; PrintPtr2
|
||||||
.endif
|
.endif
|
||||||
.endif
|
.endif
|
||||||
|
Loading…
Reference in New Issue
Block a user