        TTL     > FS99 : General utilities

DebugA  ROUT

        JSR     PrintByte

; .............................................................................

DoSpace PHA
        LDAIM   space
        JSR     oswrch
        PLA
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Do2Spaces
        JSR     DoSpace
        BRA     DoSpace

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

DoNewline
        PHA
        JSR     osnewl
        PLA
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Corrupts vstrptr, A

vstring ROUT

        PLA
        STA     vstrptr
        PLA
        STA     vstrptr+1

10      INC     vstrptr
        BNE     #FT20
        INC     vstrptr+1
20      LDAI    vstrptr
        CMPIM   cNOP
        BEQ     #FT90
        JSR     osasci
        BRA     #BT10

90      JMI     vstrptr                 ; Executes the NOP

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; In    YX -> string, CtrlChar

; Corrupts vstrptr, flags

xystring ROUT

        PHA
        STXY    vstrptr

10      LDAI    vstrptr
        CMPIM   " "
        BCC     #FT90
        JSR     osasci
        INC     vstrptr
        BNE     #BT10
        INC     vstrptr+1
        BRA     #BT10

90      PLA
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; In    YX -> 4 bytes to print as hex number

; Out   vstrptr,Y,X,A corrupt

Print8 ROUT

        LDAIM   3

10      JSR     DoSpace

20      STXY    vstrptr
        TAY

50      LDAIY   vstrptr
        JSR     PrintByte
        DEY
        BPL     #BT50
        RTS

; .............................................................................

Print4 ; NOROUT

        LDAIM   1
        BRA     #BT10

; .............................................................................

Print6 ; NOROUT

        LDAIM   2
        BRA     #BT10

; .............................................................................

P8nospace ; NOROUT

        LDAIM   3
        BRA     #BA20

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; In    A = byte

PrintByte ROUT

        PHA
        LSRA
        LSRA
        LSRA
        LSRA
        JSR     #FT90
        PLA
        PHA
        ANDIM   15
        JSR     #FT90
        PLA
        RTS

90      SED
        CMPIM   10
        ADCIM   "0"
        CLD
        JMP     oswrch

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

codelength * .-&8000

 ! 0,"ARFS is ":CC:(:STR:codelength):CC:" bytes long"

 ASSERT codelength <= &4000

        END
