MediaWiki:Sitenotice:
2024-03-02: The wiki ran out of disk space, so things were not working. This has been resolved by adding another 5GB of quota ;-) Thanks to Tim Lindner for reporting the issues. 2020-05-17: If a page gives you an error about some revision not being found, just EDIT the page and the old page should appear in the editor. If it does, just SAVE that and the page should be restored. OS-9 Al (talk) 12:22, 17 May 2020 (CDT)

Inkey.asm Level 1: Difference between revisions

From CoCopedia - The Tandy/Radio Shack Color Computer Wiki
Jump to navigation Jump to search
(Created page with "*************** * INKEY - a subroutine for BASIC09 by Robert Doggett * Called by: RUN INKEY(StrVar) * RUN INKEY(Path, StrVar) * Inkey determines if a key has been t...")
 
No edit summary
Line 1: Line 1:
***************
***************
* INKEY - a subroutine for BASIC09 by Robert Doggett
* INKEY - a subroutine for BASIC09 by Robert Doggett
* Called by: RUN INKEY(StrVar)
* Called by: RUN INKEY(StrVar)
*            RUN INKEY(Path, StrVar)
*            RUN INKEY(Path, StrVar)
* Inkey determines if a key has been typed on the given path
* Inkey determines if a key has been typed on the given path
* (Standard Input if not specified), and if so, returns the next
* (Standard Input if not specified), and if so, returns the next
* character in the String Variable. If no key has been type, the
* character in the String Variable. If no key has been type, the
* null string is returned. If a path is specified, it must be
* null string is returned. If a path is specified, it must be
* either type BYTE or INTEGER.
* either type BYTE or INTEGER.
TYPE    set  SBRTN+OBJCT
TYPE    set  SBRTN+OBJCT
REVS    set  REENT+1
REVS    set  REENT+1
        mod InKeyEnd,InKeyNam,TYPE,REVS,InKeyEnt,0
          mod InKeyEnd,InKeyNam,TYPE,REVS,InKeyEnt,0
InKeyNam fcs "Inkey"
InKeyNam fcs "Inkey"
        org  0          Parameters
          org  0          Parameters
Return  rmb  2          Return addr of caller
Return  rmb  2          Return addr of caller
PCount  rmb  2          Num of params following
PCount  rmb  2          Num of params following
Param1  rmb  2          1st param addr
Param1  rmb  2          1st param addr
Length1  rmb  2          size
Length1  rmb  2          size
Param2  rmb  2          2nd param addr
Param2  rmb  2          2nd param addr
Length2  rmb  2          size
Length2  rmb  2          size
InKeyEnt leax Param1,S
InKeyEnt leax Param1,S
        ldd  PCount,S  Get parameter count
          ldd  PCount,S  Get parameter count
        cmpd #1        just one parameter?
          cmpd #1        just one parameter?
        beq  InKey20    ..Yes; default path A=0
          beq  InKey20    ..Yes; default path A=0
        cmpd #2        Are there two params?
          cmpd #2        Are there two params?
        bne  ParamErr  No, abort
          bne  ParamErr  No, abort
        ldd  [Param1,S] Get path number
          ldd  [Param1,S] Get path number
        ldx  Length1,S
          ldx  Length1,S
        leax -1,X byte  available?
          leax -1,X byte  available?
        beq  InKey10    ..Yes; (A)=Path number
          beq  InKey10    ..Yes; (A)=Path number
        leax -1,X      Integer?
          leax -1,X      Integer?
        bne  ParamErr  ..No; abort
          bne  ParamErr  ..No; abort
        tfr  B,A
          tfr  B,A
InKey10  leax Param2,S
InKey10  leax Param2,S
InKey20  ldu  2,X        length of string
InKey20  ldu  2,X        length of string
        ldx  0,X        addr of string
          ldx  0,X        addr of string
        ldb  #$FF
          ldb  #$FF
        stb  0,X        Initialize to null str
          stb  0,X        Initialize to null str
        cmpu #2        at least two-byte str?
          cmpu #2        at least two-byte str?
        blo  InKey30    ..No
          blo  InKey30    ..No
        stb  1,X        put str terminator
          stb  1,X        put str terminator
InKey30  ldb  #SS.Ready
InKey30  ldb  #SS.Ready
        OS9  I$GetStt  is there an data ready?
          OS9  I$GetStt  is there an data ready?
        bcs  InKey90    ..No; exit
          bcs  InKey90    ..No; exit
        ldy  #1
          ldy  #1
        OS9  I$Read    Read one byte
          OS9  I$Read    Read one byte
        rts
          rts
InKey90  cmpb #E$NotRdy
InKey90  cmpb #E$NotRdy
        bne  InKeyErr
          bne  InKeyErr
        rts            (carry clear)
          rts            (carry clear)
ParamErr ldb  #E$Param  Parameter Error
ParamErr ldb  #E$Param  Parameter Error
InKeyErr coma
InKeyErr coma
        rts
          rts
        emod
          emod
InKeyEnd equ  *
InKeyEnd equ  *

Revision as of 20:39, 29 November 2013

***************
* INKEY - a subroutine for BASIC09 by Robert Doggett
* Called by: RUN INKEY(StrVar)
*            RUN INKEY(Path, StrVar)
* Inkey determines if a key has been typed on the given path
* (Standard Input if not specified), and if so, returns the next
* character in the String Variable. If no key has been type, the
* null string is returned. If a path is specified, it must be
* either type BYTE or INTEGER.
TYPE     set  SBRTN+OBJCT
REVS     set  REENT+1
         mod InKeyEnd,InKeyNam,TYPE,REVS,InKeyEnt,0
InKeyNam fcs "Inkey"
         org  0          Parameters
Return   rmb  2          Return addr of caller
PCount   rmb  2          Num of params following
Param1   rmb  2          1st param addr
Length1  rmb  2          size
Param2   rmb  2          2nd param addr
Length2  rmb  2          size
InKeyEnt leax Param1,S
         ldd  PCount,S   Get parameter count
         cmpd #1         just one parameter?
         beq  InKey20    ..Yes; default path A=0
         cmpd #2         Are there two params?
         bne  ParamErr   No, abort
         ldd  [Param1,S] Get path number
         ldx  Length1,S
         leax -1,X byte  available?
         beq  InKey10    ..Yes; (A)=Path number
         leax -1,X       Integer?
         bne  ParamErr   ..No; abort
         tfr  B,A
InKey10  leax Param2,S
InKey20  ldu  2,X        length of string
         ldx  0,X        addr of string
         ldb  #$FF
         stb  0,X        Initialize to null str
         cmpu #2         at least two-byte str?
         blo  InKey30    ..No
         stb  1,X        put str terminator
InKey30  ldb  #SS.Ready
         OS9  I$GetStt   is there an data ready?
         bcs  InKey90    ..No; exit
         ldy  #1
         OS9  I$Read     Read one byte
         rts
InKey90  cmpb #E$NotRdy
         bne  InKeyErr
         rts             (carry clear)
ParamErr ldb  #E$Param   Parameter Error
InKeyErr coma
         rts
         emod
InKeyEnd equ  *