This commit is contained in:
Michaelangel007 2016-02-17 15:42:00 -08:00
parent 17c138f8ed
commit ea442989bf

View File

@ -111,7 +111,7 @@ TEXT
APPLE "X=" APPLE "X="
.byte "#" .byte "#"
APPLE " Y=" APPLE " Y="
.byte "#" .byte "d"
APPLE " $=" APPLE " $="
.byte "x" .byte "x"
APPLE ":" APPLE ":"
@ -182,7 +182,7 @@ NextArg
; x Hex 2 Byte ; x Hex 2 Byte
; $ Hex 4 Byte ; $ Hex 4 Byte
; =-=-=-=-=-=-=-=-=-=- ;========================================================================
PrintHex4 PrintHex4
LDA #4 LDA #4
BNE _PrintHex BNE _PrintHex
@ -222,16 +222,20 @@ HexNibbles
CPX #0 ; _nHexNibbles NOTE: self-modifying! CPX #0 ; _nHexNibbles NOTE: self-modifying!
BNE _HexDigit BNE _HexDigit
PrintHexDigit ; PHX
; PLY
; Intentional fall into reverse BCD
PrintReverseBCD
DEX DEX
BMI NextFormat BMI NextFormat
LDA _bcd, X LDA _bcd, X
JSR PutChar JSR PutChar
BRA PrintHexDigit BRA PrintReverseBCD
; @ Ptr 2 Byte ; @ Ptr 2 Byte
; & Ptr 4 Byte ; & Ptr 4 Byte
; =-=-=-=-=-=-=-=-=-=- ;========================================================================
PrintPtr4 PrintPtr4
LDA #4 LDA #4
BNE _PrintPtr BNE _PrintPtr
@ -259,8 +263,12 @@ _PrintPtr
Print Print
JSR PutChar JSR PutChar
; Adjust pointer to next char in format
NextFormat NextFormat
JSR IncFormat INC _pFormat+0
BNE GetFormat
INC _pFormat+1
GetFormat GetFormat
LDA $C0DE ; _pFormat NOTE: self-modifying! LDA $C0DE ; _pFormat NOTE: self-modifying!
BEQ _Done BEQ _Done
@ -282,9 +290,10 @@ _Done
; === Meta Ops === ; === Meta Ops ===
; # Dec 1 Byte (max 3 digits) ; # Dec 1 Byte (max 2 digits)
; d Dec 2 Byte (max 5 digits) ; d Dec 2 Byte (max 3 digits)
; =-=-=-=-=-=-=-=-=-=- ; u Dec 2 Byte (max 5 digits)
;========================================================================
PrintDec2 PrintDec2
LDA #2 ; skip first 2 digits LDA #2 ; skip first 2 digits
_PrintDec _PrintDec
@ -344,33 +353,17 @@ _BCD2Char
DEX DEX
BPL _BCD2Char BPL _BCD2Char
LDX _bcd+0
LDY _bcd+1
LDA _bcd+2
STX $600
STY $601
STA $602
RTS
DecDigits DecDigits
LDY #0 ; _DecDigits LDX #0 ; _DecDigits
_PrintDecDigit JMP PrintReverseBCD
LDA _bcd,Y
JSR PutChar
INY
CPY #6
BNE _PrintDecDigit
_JumpNextFormat
; BRA NextFormat ; always
JMP NextFormat ; JMP :-(
PrintDec4 PrintDec4
LDA #0 ; skip 0 digits LDA #4 ; skip 0 digits
BNE _PrintDec ; always BNE _PrintDec ; always
; % Bin 1 Byte normal 1 ; % Bin 1 Byte normal 1
; d Bin 1 Byte inverse 1 ; d Bin 1 Byte inverse 1
; =-=-=-=-=-=-=-=-=-=- ;========================================================================
PrintBinInv PrintBinInv
LDA #$81 LDA #$81
BNE _PrintBin BNE _PrintBin
@ -395,8 +388,10 @@ _FlipBit
TAX TAX
DEY DEY
BNE _Bit2Asc BNE _Bit2Asc
BRA _JumpNextFormat ; always _JumpNextFormat
; BRA NextFormat ; always
JMP NextFormat ; JMP :-(
/* /*
JSR GetWidth JSR GetWidth
JSR NxtArgXY GetArgAddr JSR NxtArgXY GetArgAddr
@ -404,6 +399,17 @@ _FlipBit
JSR PrintBuf JSR PrintBuf
*/ */
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;DEBUG
;LDX _bcd+0
;LDY _bcd+1
;LDA _bcd+2
;STX $600
;STY $601
;STA $602
;RTS
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; === Utility === ; === Utility ===
/* /*
_CmpMeta = CmpMeta+1 _CmpMeta = CmpMeta+1
@ -426,17 +432,20 @@ CmpMeta
BRA IncWidth BRA IncWidth
*/ */
;========================================================================
PutChar PutChar
STA $400 ; NOTE: self-modifying! STA $400 ; NOTE: self-modifying!
INC PutChar+1 ; inc lo INC PutChar+1 ; inc lo
RTS RTS
;========================================================================
; @return &aArg[ iArg ] -> XY ; @return &aArg[ iArg ] -> XY
GetArgAddr GetArgAddr
LDX _pArg+0 ; Low Byte LDX _pArg+0 ; Low Byte
LDY _pArg+1 ; High Byte LDY _pArg+1 ; High Byte
RTS RTS
;========================================================================
; @return _Arg[ _Num ] ; @return _Arg[ _Num ]
NxtArgByte NxtArgByte
LDY #00 ; _iArg NOTE: self-modifying! LDY #00 ; _iArg NOTE: self-modifying!
@ -448,6 +457,7 @@ IncArg
@_SamePage @_SamePage
RTS RTS
;========================================================================
; @return X,Y 16-bit arg value ; @return X,Y 16-bit arg value
NxtArgXY NxtArgXY
JSR NxtArgByte JSR NxtArgByte
@ -456,16 +466,6 @@ NxtArgXY
TAY TAY
RTS RTS
; printf( format, ... )
; Adjust pointer to next char in format
IncFormat
INC _pFormat+0
BNE _SamePage
INC _pFormat+1
_SamePage
RTS
ToHexXY
; Hex2/Hex4 temp ; Hex2/Hex4 temp
_bcd ds 6 ; 6 chars for printing dec _bcd ds 6 ; 6 chars for printing dec
_val dw 0 _val dw 0