diff --git a/include/stdiox.a02 b/include/stdiox.a02 index 90fe58d..8daeaf7 100644 --- a/include/stdiox.a02 +++ b/include/stdiox.a02 @@ -3,18 +3,21 @@ ANYKEP: DC "PRESS ANY KEY...",0 ; -;char anykey() - wait for character with ANY KEY prompt +;char anykey(nls) - wait for character with ANY KEY prompt +;Args: A = Print Newlines (0 = No, otherwise Yes) ;Calls: GETCPR, NEWLIN - Print Newline to Screen ;Affects: C,N,Z ;Returns: A = Character code of keypress ANYKEY: JSR NEWLIN ;Start at Beginning of Next Line - LDY #>ANYKEP ;Load Prompt High Byte +.NONL LDY #>ANYKEP ;Load Prompt High Byte LDX #= Zero + BPL .ILOOP ;Loop if >= Zero RTS ;putnyb(b) - PUT NYBble PUTNYB EQU PRHEX ;Print Nybble as Hexadecimal -;putsqb(&word) - PUT SesQuiByte +;putsqb(&.HEXW) - PUT SesQuiByte ;Args: Y = High Nybble ; X = Low Byte -;Calls: PRBYTE = Print Byte -; PRHEZ = Print Hex Digit +;Calls: PUTHEX = Print Byte +; PRHEX = Print Hex Digit ; SAVRXY = Save X and Y Registers ;Affects: A,Y,X,N,Z,C PUTSQB: JSR SAVRXY ;Save Address -PUTSQA: LDA TEMP2 ;Load Address MSB +.PUTSQB LDA TEMP2 ;Load Address MSB JSR PRHEX ;Print High Nybble LDA TEMP1 ;Load Address LSB - JMP PRBYTE ;Print and Return` + JMP PUTHEX ;Print and Return` -;putexh(&word) - PUT EXtended Hexadecimal +;putexh(&.HEXW) - PUT EXtended Hexadecimal ;Args: A = Value Extended Byte ; Y = Value High Byte ; X = Value Low Byte -;Calls: PRBYTE = Print Byte +;Calls: PUTHEX = Print Byte ; SAVRXY = Save X and Y Registers -; PUTWRA = Put Word (Alternate Entry Point) +; .PUTWRD = Put .HEXW (Alternate Entry Point) ;Affects: A,Y,X,N,Z,C PUTEXH: JSR SAVRXY ;Save High and Low Bytes - JSR PRBYTE ;Print Extended Byte - JMP PUTWRA ;Print High and Low Bytes + JSR PUTHEX ;Print Extended Byte + JMP .PUTWRD ;Print High and Low Bytes -;putwrd(&word) - PUT WoRD -;Args: Y = Word MSB -; X = Word LSB -;Calls: PRBYTE = Print Byte +;putwrd(&.HEXW) - PUT .HEXW +;Args: Y = .HEXW MSB +; X = .HEXW LSB +;Calls: PUTHEX = Print Byte ; SAVRXY = Save X and Y Registers ;Affects: A,Y,X,N,Z,C -PUTWRD: JSR SAVRXY ;Save Word -PUTWRA: LDA TEMP2 ;Load Word MSB - JSR PRBYTE ;Print as Hexadecimal - LDA TEMP1 ;Load Word LSB - JMP PRBYTE ;Print and Return` +PUTWRD: JSR SAVRXY ;Save .HEXW +.PUTWRD LDA TEMP2 ;Load .HEXW MSB + JSR PUTHEX ;Print as Hexadecimal + LDA TEMP1 ;Load .HEXW LSB + JMP PUTHEX ;Print and Return` ;Print a Space PUTSPC: LDA #32 ;Load Space Character @@ -181,97 +212,116 @@ PUTRPT: JSR PUTCHR ;Print Space Character ;Returns: A,Y = Total number of characters printed PRINTF: STA TEMP3 ;Save Byte to Format JSR SETSRC ;Initialize Source String -PRINTL: LDA (SRCLO),Y ;Read next character in string - BEQ PRINTX ;If Not 0 - CMP #'% ;' If Format Specified - BEQ PRINTP ; Jump to Formatter -PRINTC: JSR PUTCHR ; Print character at offset, -PRINTY: INY ; increment offset, and - BPL PRINTL ; loop if less than 128 -PRINTX: RTS ; characters printed +.FLOOP LDA (SRCLO),Y ;Read next character in string + BEQ .FDONE ;If Not 0 + CMP #'%' ; If Format Specified + BEQ .FEVAL ; Jump to Formatter +.FPUTC JSR PUTCHR ; Print character at offset, +.FNEXT INY ; increment offset, and + BPL .FLOOP ; loop if less than 128 +.FDONE TYA ;Return Number of + RTS ; characters printed ;Process Format Specifier -PRINTP: INY ;Increment Offset +.FEVAL: INY ;Increment Offset LDA (SRCLO),Y ;Get Formatting Character - BEQ PRINTX ;If NUL, then Exit - CMP #'% ;'If Percent Sign - BEQ PRINTC ; Print it and Continue + BEQ .FDONE ;If NUL, then Exit + CMP #'%' ;If Percent Sign + BEQ .FPUTC ; Print it and Continue AND #$DF ;Convert to Upper Case - CMP #'L ;'If "l" or "L" - BNE PRINTR +.HNDRD CMP #'H' ;If "z" or "Z" + BNE .ZEROF LDA TEMP3 ; Load Byte to Format - JSR PUTDEM ; Print Left Justified - JMP PRINTY ; and Continue Printing String -PRINTR: CMP #'R ;'If "r" or "R" - BNE PRINTD + JSR PUTDEH ; Print Zero Filled + JMP .FNEXT ; and Continue .INTGRng String +.ZEROF CMP #'Z' ;If "z" or "Z" + BNE .LJUST LDA TEMP3 ; Load Byte to Format - JSR PUTDES ; Print Right Justified - JMP PRINTY ; and Continue Printing String -PRINTD: CMP #'D ;'Else If "d" or "D" - BNE PRINTG + JSR PUTDEZ ; Print Zero Filled + JMP .FNEXT ; and Continue .INTGRng String +.LJUST CMP #'L' ;If "l" or "L" + BNE .RJUST + LDA TEMP3 ; Load Byte to Format + JSR .PUTDEL ; Print Left Justified + JMP .FNEXT ; and Continue .INTGRng String +.RJUST CMP #'R' ;If "r" or "R" + BNE .DECML + LDA TEMP3 ; Load Byte to Format + JSR .PUTDER ; Print Right Justified + JMP .FNEXT ; and Continue .INTGRng String +.DECML CMP #'D' ;Else If "d" or "D" + BNE .NYBBL LDA TEMP3 ; Load Byte to Format JSR PUTDEC ; Print as Decimal - JMP PRINTY ; and Continue Printing String -PRINTG: CMP #'G ;'Else If "g" or "G" - BNE PRINTH + JMP .FNEXT ; and Continue .INTGRng String +.NYBBL CMP #'Y' ;Else If "y" or "Y" + BNE .HEXB LDA TEMP3 ; Load Byte to Format JSR PUTNYB ; Print as Low Nybble as Hexadecimal - JMP PRINTY ; and Continue Printing String -PRINTH: CMP #'H ;'Else If "h" or "H" - BNE PRINTB + JMP .FNEXT ; and Continue .INTGRng String +.HEXB CMP #'X' ;Else If "x" or "Y" + BNE .BNRY LDA TEMP3 ; Load Byte to Format JSR PUTHEX ; Print as Hexadecimal - JMP PRINTY ; and Continue Printing String -PRINTB: CMP #'B ;'Else If "b" or "B" - BNE PRINTN + JMP .FNEXT ; and Continue .INTGRng String +.BNRY CMP #'B' ;Else If "b" or "B" + BNE .NEWLN STY TEMP0 ; Save Index LDA TEMP3 ; Load Byte to Format JSR PUTBIN ; Print as Binary LDY TEMP0 ; Restore Index - JMP PRINTY ; and Continue Printing String -PRINTN: CMP #'N ;'Else If "n" or "N" - BNE PRINTS + JMP .FNEXT ; and Continue .INTGRng String +.NEWLN CMP #'N' ;Else If "n" or "N" + BNE .STRNG STY TEMP0 ; Save Index JSR NEWLIN ; Execute Newline Function LDY TEMP0 ; Restore Index - JMP PRINTY ; and Continue Printing String -PRINTS: CMP #'S ;'Else If "s" or "S" - BNE PRINTQ - STY TEMP0 ; Save Index - JSR PUTDST ; Print Destination String - LDY TEMP0 ; Restore Index - JMP PRINTY ; -PRINTQ: CMP #'Q ;'Else If "w" or "W" - BNE PRINTW - STY TEMP0 ; Save Index - JSR SAVDST ; Save Destination Address - JSR PUTSQA ; Print MSB and LSB as Hex - LDY TEMP0 ; Restore Index - JMP PRINTY ; -PRINTW: CMP #'W ;'Else If "w" or "W" - BNE PRINTI - STY TEMP0 ; Save Index - JSR SAVDST ; Save Destination Address - JSR PUTWRA ; Print MSB and LSB as Hex - LDY TEMP0 ; Restore Index - JMP PRINTY ; -PRINTI: CMP #'I ;'Else If "i" or "I" - BNE PRINTZ - TYA ; Save Index + JMP .FNEXT ; and Continue .INTGRng String +.STRNG CMP #'S' ;Else If "s" or "S" + BEQ .FDEST ; Print Destination String +.SQBYT CMP #'Q' ;Else If "w" or "W" + BEQ .FDEST ; Print Sesquibyte as Hex +.HEXW CMP #'W' ;Else If "w" or "W" + BEQ .FDEST ; Print Word as Hex +.INTGR CMP #'I' ;Else If "i" or "I" + BEQ .FDEST ; Print Decimal Integer +.IJUST CMP #'J' ;Else If "j" or "J" + BEQ .FDEST ; Print Right-Justified Decimal +.FECHO LDA TEMP3 ;Else + JMP .FPUTC ; Print Raw Byte and Continue + +;Process Value in DSTPTR +.FDEST TAX ;Save Specifier + TYA ;Save Index PHA - JSR GETDST ; Get Integer in DSTLO, DSTHI - JSR PUTINT ; Print Integer as Decimal - PLA ; Restore Index + TXA ;Restore Specifier + JSR GETDST ;Get Integer in DSTLO, DSTHI + CMP #'I' ;If 'i' or 'I' + BNE .FDESTJ + JSR PUTINT ; Print Integer Right Justified + BMI .FSKIP +.FDESTJ CMP #'J' ;Else If 'J' or 'J' + BNE .FDESTQ + JSR PUTINR ;Print Integer Right Justified + BMI .FSKIP +.FDESTQ CMP #'Q' ;Else If 'q' or 'Q' + BNE .FDESTW + JSR .PUTSQB ; Print MSB and LSB as Hex + BNE .FSKIP +.FDESTW CMP #'W' ;Else If 'w' or 'J' + BNE .FDESTS + JSR PUTWRD ; Print MSB and LSB as Hex + BNE .FSKIP +.FDESTS JSR PUTDST ;Else Print Destination String +.FSKIP PLA ;Restore Index TAY - JMP PRINTY ; -PRINTZ: LDA TEMP3 ;Else - JMP PRINTC ; Print Raw Byte and Continue + JMP .FNEXT ;char putdst() -PUTDST: LDY #0 ;Initialize character offset -PUTDSL: LDA (DSTLO),Y ;Read next character in string - BEQ PUTDSX ;If Not 0 +PUTDST LDY #0 ;Initialize character offset +.DLOOP LDA (DSTLO),Y ;Read next character in string + BEQ .DRETY ;If Not 0 JSR PUTC ; Print character at offset, INY ; increment offset, and - BPL PUTDSL ; loop if less than 128 -PUTDSX: TYA ;Return number of + BPL .DLOOP ; loop if less than 128 +.DRETY TYA ;Return number of RTS ; characters printed