19781  > 6502.Serial65/srcTINTREM Generated from HostFS sourceTINTTINTREM Source for Single P
 8308 Tube Client MOS for 6502TINTREM ===============================================TINTREM This code may be freely reuse
30496 ith acknowledgementsTINT:TINTREM This implemen
24864  Tube client communicating with a hostTINTREM via a single port, such as a serial port, a parallel port,TINTREM or ev
24864  single Tube register, all in less than 2K.TINT:TINTREM The link is a text channel that escapes out to send comm
29540 TINTREM and receive data transfers. This version assumes a clean,TINTREM error-free link channelTINT:TINTREM Can be bu
 8308 as a BBC filing system, with code to accessTINTREM BBC memory map.TINT:TINTREM v0.16 16-Nov-2010 J.G.HarstonTINTREM 
12590 7 09-Mar-2013 Added additional Tube entry po
29556 ,TINTREM                   EXECUTE enters code with A=0/1, SEC/CLC.TINTREM v0.18 07-Apr-2013 Moved some code tha
30319 erlapped I/O area.TINTREM      
11577 Nov-2016 Edited slightly to allow conversion
 8303 as65 source.TINTREM v0.19 11-Nov-2016 Added conditionals for sideways ROM code.TINTREM v0.20 18-Mar-2017 Added option 
 8306 local RDLINE, optimised OSCLI.TINTREM v0.21 23-Feb-2018 *HOSTFS ON sets WRCHV/RDCHV.TINTREM                   Ser
29216 esponds to returned boot option.TINTREM v0.22 13-J
12845 020 Speed up Tube transfer and I/O.TINTREM v0.23 15-Jan-2020 Tweeked 6551 code, hardware fix to check for CTS
 2618 tweek1
16710 LSE:REM Pre-check RxRDYTINTtweek2%=TRUE :REM Tube transferTINTt
27493 3%=TRUE :REM Load to I/O accesses hardware directlyTINTtweek4%=FALSETINTtweek%=tweek1% OR tweek2% OR tw
13163 % OR tweek4%TINT:TINT:TINTREM Specify targetTINTREM ==============TINTver$="0.21":date$=" (23 Feb 2018)"TINTIF twee
30266 er$="0.23":date$=" (15 Jan 2020)"
21079 OM% =FALSE :REM Build 6502 Client ROMTINTRDLINE%=TRUE  :REM Implement RDLINE local
21002 DLINE%=FALSE :REM Pass RDLINE to hostTINT:TINTREM I/O values, these should work for BenEaterTINTREM ==========================
15677 ============TINTACIA=6551:PORT=&5000:MAXRAM%=&4000:name$="Be
29793 er" : REM I/O values, these are suitable for a 6850 REM =========
15677 ============================TINTACIA=6850:PORT=&FEF0:MAXRAM%
18698 F SWROM%:name$="HostFS" ELSE name$="Serial65
 2618 REM Bo
29285 plateTINTREM ===========TINTIF HIMEM>&FFFF:SYS "OS_GetEnv"TOA$:IFLEFT$(A$,5)<>"B6502":OSCLI"B6502"+MID$(A$,INS
16680 $," "))TINTON ERROR REPORT:PRINT" at line ";ERL:ENDTINTDEFFNif(A%):IFA%:z%=-1:=opt% 
17747  z%=P%:=opt%TINTDEFFNendif:IFz%=-1:=opt% ELSE z%=P%-z%:P%=P%-z%:O%=O%-z%:=o
 2597 DEFFNelse:IFz%=-1:z%=P%:=opt% ELSE z%=P%-z%:P%=P%-z%:O%=O%-z%:z%=-1:=opt%TINTDIM mcode% &FFF, L% &7FTINT:TINTREM Declare 
25956  start and spaceTINTREM ============================TINTIF SWROM%=0:tweek3%=0TINTIF SWROM%=0:load%=&F800TINTIF SWROM%  
24943 d%=&8000TINT:TINTREM System vectorsTINTREM ==============TINTUSERV=&200:BRKV =&202:IRQ1V=&204:IRQ2V=&206:CLIV =&208:
17748 V=&20ATINTWORDV=&20C:WRCHV=&20E:RDCHV=&210:FILEV=&212:ARGSV=&214:BGetV=&216TINTBPutV=&218:G
22082 =&21A:FINDV=&21C:FSCV =&21E:EVNTV=&220TINT:TINTREM System addressesTINTREM ==========
15677 ==TINTROMSTART%=&F800         :REM Start of ROM code to copy
 8303 RAMTINTIOSPACE% =&FEF0         :REM Start of I/O spaceTINTERRBUF=&236             :REM Error bufferTINTINPBUF=&236:INPEND
12339 0 :REM Supervisor string bufferTINT:TINT
18255    =&EE:REM &EE/F = PROG   - Current programTINTNUM    =&F0:REM &F0/1 = NUM    - 
 8312 accumulatorTINTMEMTOP =&F2:REM &F2/3 = MEMTOP - top of memoryTINTTRANS  =&F4:REM &F4/5 = ADDR   - Data 
28257 sfer address (assembler doesn't like 'INC ADDR')TINTTRANShi=&F6:REM &F6/7 = ADDR+2 - Data transfer address high w
 2660 LPTR   =&F8:REM &F8/9 = String pointer, OSWORD control blockTINTCTRL   =&FA:REM &FA/B = CTRL   - OSFILE, OSGBPB c
29300 ol blockTINTCMD    =&FA:REM         CMD    - Address of command line parametersTINTTEXT   =&FA:REM &FA/B = TEXT 
 8237 PrText string pointerTINTIRQA  
17958 C:REM &FC   = IRQ A storeTINTFAULT  =&FD:REM &FD/E => last e
29295 TINTESCFLG =&FF:REM &FF   = Escape flagTINT:TINTREM Serial Tube system valuesTINTREM =========================TINTpfx=&9BTINT:TINTI
30580 eek%:name$=name$+"v"+MID$(ve
13100 ,2)TINTFOR P=0 TO 1:opt%=P*3+4TINTP%=l
 9572 :O%=mcode%TINTPROCasmROMHeaderTINTPROCasmTubeCodeTINTNEXT:IF O%>L%:PRINT "ERROR: Code overrun"TINTPRINT"S
28265 g ";LEFT$(name$,10); OSCLI"Save "+LEFT$(name$,10)+" "+STR$~mcode%+" "+STR$~O%+" "+STR$~load%+" "+STR$~load% PRINT:
17696 RROR ON ERROR OFF:ENDTINTIF SWROM%:OSCLI"SetType "+name$+" BBC"TINT*QuitTINTENDTINT:TINT:
17989 FNerror:IF SWROM%:[OPT P*3+4:JSR Error:]:=opt% ELSE [OPT P*3+4:B
23866 :=opt%TINT:TINTDEFPROCasmTubeCodeTINTREM I/O values for communications portTINTREM 
15677 ==============================TINTIF ACIA=6850:TxStatus=PORT
21562 xRDY=2:TxData=PORT+1:RxControl=PORT+0:RxStop
13621 TINTIF ACIA=6850:RxStatus=PORT+0:RxRD
14897 RxData=PORT+1:TxControl=PORT+0:RxCont=&15TINTIF ACIA=6850:Tx
25971 t=0:RxInit=&13:TxInit=&55:TxDelay=0:REM &55=8N1, clock/16TINT:TINTIF ACIA=6551:TxStatus=PORT+1:TxRDY=-6
30804 Data=PORT+0:RxControl=PORT+2:RxStop=&02TINTIF ACIA=6551:R
24948 tus=PORT+1:RxRDY=+08:RxData=PORT+0:TxControl=PORT+3:RxCont=&0BTINTIF ACIA=6551:TxR
29797 =PORT+1:RxInit=&02:TxInit=&1E:TxDelay=203:REM TxDelay 9600 at 1MHzTINT:TINT[OPT opt%TINT\ Start of Tube system codeTINT\ ==
15677 ===================TINT\ On hardware reset all of memory rea
25376 ome from ROM, all writes go to RAM.TINT\ Accessing any I/O location pages ROM out of memory map, thence all readsTINT
28515 me from RAM.TINT\TINT.LF800TINTJMP RE
 2644 .PrBannerTINTJSR PrTextTINT.BANNERTINTEQUB 13:EQUS "SERIAL TUBE 6502 64K "
21841 S LEFT$(ver$+" ",5)TINTEQUB 13:EQUB 0TINTRTSTINTTINT\ Tube Client Startup Cod
 8284 ======
15677 ==============TINT.RESETTINTSEI:LDX #&00               :\ Disab
26912 nteruptsTINT.LF802TINTLDA &FF00,X:STA &FF00,X    :\ Copy entry block to RAMTINTDEX:BNE LF802TINTTINT\ The follow
 8295 code copies the page with the I/O registers inTINT\ it without accessing the I/O registers. Modify IOSPACE% a
29295 dingTINT\ to where the I/O registers actually are.TINTTINTLDX #IOSPACE% AND 255TINT.LF819TINTLDA &FDFF,X:STA &
17990 ,X    :\ Copy &FE00-&FEEF to RAM, avoidingTINTDEX:BNE LF819        
 8224   :\  IO space at &FEFxTINT:TINTLD
21027 OMSTART% AND 255:STY LPTR+0 
20512 oint to start of ROMTINTLDA #ROMSTART% DIV 256:STA LPTR+1TINT.LF82A                     :\ Cop
25970 st of ROM to RAMTINTLDA (LPTR),
21587 A (LPTR),Y  :\ Copy a page to RAMTINTINY:BNE LF82A       
 8224    :\ Loop for 256 bytesTINTINC
21584 R+1:LDA LPTR+1      :\ Inc. address high byteTINTCMP #&FE:BNE LF82A        
 8284 Loop up to &FDFFTINT:TINT.STARTUPTINTSEI:LDX #&35TINT.LF80DTINTLDA LF
11312 X:STA USERV,X    :\ Set up default vectorsTINTD
16954 PL LF80D:TXS          :\  and clear stackTINT:TINTOPT FNif(TxReset)TINT  STA TxResetTINTOPT FNen
 2662 LDA #RxInit:STA RxControl :\ Initialise port and page ROM outTINTLDA #TxInit:STA TxControlTINT\ Accessing I
29216 egisters will page ROM out if runningTINT\ from RAM. Once ROM is paged out we 
 8302 do subroutineTINT\ calls as we can now read from stack in RAM.TINT\TINTINX:STX ESCFLG:STX MEMTOP+0    
 8224    :\ Clear Escape flagTINTOPT 
26217 (MAXRAM%=0)TINT  LDA #ROMSTART% DIV 256:STA MEMTOP+1 :\ Set memtop to start o
20306 MTINTOPT FNelseTINT  LDA #MAXRAM% 
 8278 256:STA MEMTOP+1   :\ Set memtop to top of RAMTINTOPT FNendifTINTJSR InitEr
 8306                       :\ Claim error handlerTINTLDA PROG+0:STA TRANS+0              :\ Copy PROG to TRANS addr
 2675 LDA PROG+1:STA TRANS+1TINTTINT\ Tell the Host that we've restartedTINT\ ----------------------------------TINT\ Tube data  
 8248 &00 &FF &FF  --  Cy Y XTINT\            followed
 8313 stringTINT\TINT\ Note for Host authors, Host MUST NOT respond by echoing back a SoftResetTINT\ as the C
28261 t will be trapped in an infinite STARTUP loop. If Host wantsTINT\ to read Client to determine CPU this w
 8300 change TRANS so must only beTINT\ done if a later transaction will set TRANS after a language transfer, egTINT
28271  Hard Reset.TINT\TINTOPT FNif(RDLI
10533 TINT  LDA #0TINTOPT FNelseTINT  LDX #0:LDA #&FF:TAY      :\ As we are usin
 8289 serial link, send Soft Reset
18976 SR osFSC:TXA            :\ S
29540  A=&FF, X=0 Soft Reset, Y=&FF no bootTINTOPT FNendifTINT.STARTUP2TINTPHA                        :\ Save returned Ac
31074 te, will be &00 if no respon
18954 SR PrBanner:JSR OSNEWL    :\ Display startup bannerTINTLDA #CmdPrompt AND 255     :\ Next time RESET
 8307 soft entered,TINTSTA LF800+1                :\  banner not printedTINTLDA #CmdPrompt DIV 256TINTSTA LF800+2TINTPL
19523 C:JSR WaitCheckCode  :\ Check Ack code, if &80 enter c
11365 TINT:                          :\  else enter command prompt loopTINTTINTTINT\ Supervisor Command promptTINT\ =
15677 ====================TINT.CmdPromptTINTLDX #&FF:TXS:JSR InitErro
 8224      :\ Reset stack, claim e
29295  handlerTINTLDA #CmdPrompt AND 255:STA PROG+0 :\ Make Command Prompt the current programTINTLDA #CmdPrompt DIV 256:S
20512 ROG+1TINT.CmdOSLoopTINTLDA #ASC"*":JSR OSWRCH     :\ Print '*' prom
19466 DX #LF95D AND 255TINTLDY #LF95D DIV 256TINTLDA #&00:JSR OSWORD        :\ Read line to INPBUFTINTBCS CmdOSEscapeTINTLDX #INPB
16672 ND 255TINTLDY #INPBUF DIV 256        :\ Execute commandTINTJSR OS_CLI:JM
27971 dOSLoop   :\  and loop back 
 8306 anotherTINT.CmdOSEscapeTINTLDA #&7E:JSR OSBYTE        :\ Acknowledge Escape stateTINTOPT FNerror:EQUB 17:EQUS "Escap
16954 RKTINTTINT\ Control block for comman
29296 ompt inputTINT\ ---------------
11565 -------------------TINT.LF95DTINTEQUW INPBUF   
 8224          :\ Input text to IN
18005 TINTEQUB INPEND-INPBUF         :\ Maximum number of charactersTINTEQ
 9760 20:EQUB &FF          :\ Min=&20, Max=&FFTINTTINTTINT\ Error handlerTINT\ =
15677 ========TINT.InitErrorTINTLDA #ErrorHandler AND 255:STA BRKV+0 
17184 laim error handlerTINTLDA #ErrorHandler DIV 256:STA BRKV+1TINTRTSTINTTINT.ErrorHandlerTINTLDX #&FF:TXS 
 8224           :\ Reset stackTINTJSR
20051 EWLTINTLDX FAULT+0:LDY FAULT+1TINTINX:BNE P%+3:INY           :\ XY=>error stringTINT
 8274 PRSTRNG                :\ Print error stringTINTJSR OSNEWL:JMP CmdPrompt   :\ Jump
 8303 command promptTINTTINTTINT\ Interrupt handlersTINT\ ==================TINT.IRQHandlerTINTSTA IRQA:PLA:PHA           :\ Save A, get
24940 gs from stackTINTAND #&10:BNE BRKHandler    :\ If BRK, jump to BRK handlerTINTJMP (IRQ1V)               
 8284 Continue via IRQ1V handlerTINT.IRQ1HandlerTINTJMP (IRQ2V)   
 8224          :\ Pass on to IRQ2V
21058 KHandlerTINTTXA:PHA                    :\ Sav
 2648 TSX:LDA &0103,X            :
25927 t address from stackTINTCLD:SEC
17218  #&01:STA FAULT+0TINTLDA &0104,XTINTSBC #&00:STA FAULT+1       :\ &FD/E=>after BRK op
25956 TINTPLA:TAX:LDA IRQA           :\ Restore X, get saved ATINTCLI:JMP (BRKV)             :\ Restore IRQs, jump to E
29295  HandlerTINT.IRQ2HandlerTINTLDA IRQA                   :\ Restore saved ATINT.NMIHandlerTINTRTITINTTINTTINT\ Skip SpacesTINT\ ========
 2621 .SkipSpaces1TINTINYTINT.SkipSpacesTINTLDA (LPTR),Y:CMP #&20:BEQ Sk
28755 aces1TINT.NullReturnTINTRTSTINTTINT\ Scan hexTINT\ ========TINT.ScanHexTINTLDX #&00:STX NUM+0:STX NUM+1 :\ Clear hex accumulatorTINT
14662 8CTINTLDA (LPTR),Y                :\ Get current characterTINTCMP #&30:BCC LF9
 8224         :\ <'0', exitTINTCMP #&3A:BCC LF9A0     
 8224  :\ '0'..'9', add to accumul
29295 TINTAND #&DF:SBC #&07:BCC LF9B1 :\ Convert letter, if <'A', exitTINTCMP #&40:BCS LF9B1          :\ >'F', exitTINT.LF9A0TINTA
16672 :ASL A:ASL A:ASL A     :\ *16TINTLDX #&03                    :\ Prepare to 
25974  3+1 bitsTINT.LF9A6TINTASL A:ROL NUM+0:ROL NUM+1   :\ Move bits into accumulatorTINTDEX:BPL LF9A6               :\ L
 8304 for four bits, no overflow checkTINTINY:BNE LF98C               :\ Move to next characterTINT.LF9B1TINTRTSTINTTINTTINT\ MOS I
21061 FACETINT\ ~~~~~~~~~~~~~TINT\TINT\TINT\ OSRDCH - Wait for character from input streamTINT\ =====
15677 ====================================TINT\ On exit, A =char, 
17725 scape flagTINT\TINT.osRDCHTINTJSR WaitByte:PHA           :\ Wait for characterTINTLDA ESCFLG:ASL A           :\ Get Escape flag t
24931 rryTINTPLA:RTS                 
14880 \ Get character to A and ret
 2670 TINTTINT\ OSRDCH - Request character via TubeTINT\ ===================================TINT\ On exit, A =char, Cy=Escape fl
23562 TINT\ Tube data  &00  --  Carry CharTINT\TINT.osRDCH_IOTINTLDA #&00:JSR SendCommand   :\ Send command &00 - OSR
 2632 .WaitCarryChar             :\ Wait for Carry and ATINTJSR WaitByte
19539  A         :\ Wait for carryTINTJMP WaitByteTINTTINTTINT\ OSCLI - Execute
28015 mandTINT\ =======================TINT\ On entry, XY=>command stringTINT\ On exit,  All registers corrupt
 2570 \ Local *commandsTINT\ ---------------TINT.CmdTableTINTEQUS "GO":EQUB &80TINTEQUS "HELP":EQUB &81TINTEQUB 0TINTTINT.o
18764 TINTSTX LPTR+0:STY LPTR+1      :\ LPTR=>command stringTINTLDY #&FFTINT.o
18764 lp0TINTJSR SkipSpaces1TINTCMP #ASC"*":BEQ osCLIlp0   :\ Skip spaces a
29472 tarsTINTCMP #ASC"A":BCC osCLI_IO   :\ Doesn't start with a letterTINTLDX #&FF:DEY               :\ Poi
29728 o before start of stringsTINT.osCLIlp1TINTTYA:PHA                    :\ Save start of command lineTINT.osCLIlp2TINTINX:INY  
 8224                  :\ Step to 
29816  charactersTINTLDA CmdTable,X:BMI osCLImatch :\ Check for end of commandTINTLDA (LPTR),YTINTCMP #ASC".":BE
29551 CLIskip     :\ EQ+CS = abbre
29793 ed commandTINTAND #&DF                      :\ Force upper caseTINTCMP CmdTable,X:BEQ osCLIlp2   :\ Check m
 8293 charactersTINTCLC                           :\ CC=skip this commandTINT.osCLIskipTINTINXTINTLDA CmdTable,X:BPL osCLIskip  
21280 tep to end of entryTINTBCS osCLIdot                  :\ CS=abbreviated commandTINT.osCLInomatc
19536 A:TAY 
 8224                   :\ Restore
28265 e pointerTINTLDA CmdTable+1,X:BNE osCLIlp1 :\ Not at end of tableTINTBEQ osCLI_IO                  :\ End of t
25964 , pass to TubeTINT.osCLImatchTINTLDA (LPTR),YTINTCMP #ASC"A":BCS osCLInomatch  :\ More letters, check n
 8308 entryTINTDEY                           :\ Prepare to skip any spacesTINT.osCLIdotTINTPLA:JSR SkipSpaces1        :\ Drop saved
26991 nter, step past dot, skip spacesTINTLDA CmdTable,X             :\ Get command byteTINTCMP #&81:BEQ CmdHelp       :
14374 1, jump to *HelpTINT           
 8224             :\ Fall through 
10784 GoTINTTINT\ *GO - call machine codeTINT\ -----------------------TINT.CmdGoTINTJSR ScanHex:JSR SkipSpaces   :\ Read hex val
24864 nd move past spacesTINTCMP #&0D:BNE osCLI_IO        :\ More parameters, pass to Tube to deal withTINTTX
17730 Q CmdGo2:LDX #NUM-PROG :\ If no parameters, jump to PR
 8236 else jump to NUMTINT.CmdGo2TINTLDA PROG+0,X:STA TRANS+0   :\ Set address 
27168 ump toTINTLDA PROG+1,X:STA TRANS+1TINTBCS SaveEnterCode          :\ CS set from CMP earlierTINTTINT\ *Help - Display he
26912 nformationTINT\ --------------------------------TINT.CmdHelpTINTJSR PrBanner               :\ Print help messageTINT    
 8224                    :\ Contin
29728 o pass '*Help' command to TubeTINTTINT\ OSCLI - Send command line to hostTINT\ ===========================
15677 ==TINT\ On entry, &F8/9=>command stringTINT\TINT\ Tube data  &02 s
28265 g &0D  --  &7F or &80TINT\TINT.osCLI_IOTINTLDA #&02:JSR SendCommand   :\ Send command &02 - OSCLITINTJSR SendStringF8     
 8224   :\ Send command string at 
21076 TINT:                          :\ Drop through to wait for Ack and enter codeTINTTINT
26977 tEnterCodeTINTJSR WaitByte:SEC           :\ Wait for Ack from TubeTINT.WaitCheckCodeTINTROL 
17218 C SaveEnterDone    :\ If <&80, exitTINTROR A             
 8224      :\ Restore Carry, CC=RE
11348  CS=OSCLITINT.SaveEnterCodeTINTLDA PROG+1:PHA:LDA PROG+0:PHA :\ Save cu
28261 t programTINTJSR EnterCode:\TAX            :\ Enter code, save return valueTINTPLA:STA PROG+0:STA MEMTOP+0   :\ Rest
 8293 current programTINTPLA:STA PROG+1:STA MEMTOP+1   :\  and set top of memory to itTINTLDA #0:\TXA                   :\
29245 eturn valueTINT.SaveEnterDoneTINTRTSTINTTINTTINT\ FSC - FSC FunctionsTINT\ ====
15677 ===========TINT\ On entry, A, X, Y=FSC parametersTINT\ On exit,
11329  X, Y=return valuesTINT\TINT\ Tube
29793 a  &18 X Y A  --  &FF Y X orTINT\                           &7F then string -- respsonseTINT\TINT.osFSCTINTP
19514 DA #&18:SEC:BCS ByteHi2TINTTINTTINT\ OSBYTE - Byte MOS functionsTINT\ ===
15677 ====================TINT\ On entry, A, X, Y=OSBYTE parameter
 8284 On exi
 8224 A  preservedTINT\           If A<&80, X=ret
25966 d valueTINT\           If A>&7F, X, Y, Carry=returned valuesTINT\TINT.osBYTETINTCMP #&80:BCS ByteHigh      :\ Jump for lon
21327 BYTEsTINT\TINT\ BYTELOTINT\ Tube data
12326 4 X A    --  XTINT\TINTPHA:LDA #&0
21322 R SendCommand  :\ Send command &04 - BYTELOTINTTXA:JSR Se
31042 te           :\ Send single parameterTINTPLA:PHA:JSR SendByte       :\ Send functionTINTJSR WaitByte:T
 8224          :\ Get return valueTINTPLA:RTS                    :\ Restore A and returnTINTTINT.By
26952 ghTINTCMP #&82:BEQ Byte82        :\ Read memory high wordTINTCMP #&83:BEQ Byte83        :\ Read bottom 
27936 emoryTINTCMP #&84:BEQ Byte84        :\ Read top of memoryTINT\TINT\ BYTEHITINT\ Tube data  &06 X Y A  --  Cy Y
23562 TINTPHA:LDA #&06:CLCTINT.ByteHi2TINTPHP:JSR SendCommand:PLP    :\ Send command &06 or &18 - B
18501 I or FSCTINTTXA:JSR SendByte           :\ Send first parameterTINTTYA:JSR SendByte    
 8224    :\ Send second parameterTINT
14913 JSR SendByte           :\ Send functionTINTBCS ByteHi3                :\ Sk
20256 SBYTE checksTINTCMP #&8E:BEQ WaitEnterCode :\ If select language, check to enter codeTINTCMP #&9D:BEQ LFAEF:CLC   
23610  Fast return with Fast BPUTTINT
29817 eHi3TINTPHA:JSR WaitByte:BCC ByteHi4 :\ Get Carry or byte/string 
28787 onseTINTASL A:BCC FSCString          :\ Jump to send FSC stringTINT.ByteHi4TINTASL A:JSR WaitByte:TAY     
18208 et return high byteTINTJSR WaitByte:TAX:PLA       :\ Get return low byteTINT.LFAEFTINTRTSTINTTINTOPT FN
19752 AXRAM%=0)TINT  .Byte84:LDX MEMTOP+0:LDY MEMTOP+1:RTS :\ Read top of memoryTINTOPT FNelseTINT  .Byte84:LDX #
21080 AM% AND 255:LDY #MAXRAM% DIV 256:RTS :\ Read top of memoryTINTOP
20038 endifTINT.Byte83:LDX #&00:LDY #
14904 RTS  :\ Read bottom of memoryTINT.Byte82:LDX #&
19514 DY #&00:RTS  :\ Return &0000 as memory high 
25714 TINTTINT.FSCStringTINTPLA:JSR SendString         :\ Send stringTINTLDY #&FFTINT.FSCStrLp2TINTINY:LDA (LPTR),YTINTCMP #ASC"!":BCS
17235 StrLp2  :\ Skip to ' ' or <cr>TINTDEYTINT\ Check - does this cope with *
 8292 *RUN */ *space/space ? .FSCStrLp3 INY:LDA (LPTR),Y CMP #ASC" ":BEQ FSCStrLp3  :\ Skip to non-' ' TYA:CLC:
 8259 LPTR+0:STA CMD+0TINTLDA LPTR+1:ADC #0:STA CMD+1:\ Point to command 
24946 metersTINTJSR WaitEnterCode          :\ Wait for Ack, enter code if neededTINTBPL LFAEF            
 8224   :\ Response=<&40, all done
25970 turn responseTINT:             
 8224          :\ Response=&40 (&8
29793  this point), print textTINT.FS
29300 ChrTINTJSR WaitByte               :\ Wait for a characterTINTCMP #&00:BEQ LFAEF      
14880 \ &00 terminates stringTINTJSR 
21079 CH:JMP FSCStrChr   :\ Print characterTINTTINTTINT\ OSWORD - Various functionsTINT\ ========
15677 ==============TINT\ On entry, A =functionTINT\           XY=>co
28530 l blockTINT\TINT.osWORDTINTSTX LPTR+0:STY LPTR+1      :\ LPTR=>control blockTINTTAY:BEQ RDLINE             :\ OSWORD 0, jump
 8303 read lineTINT\TINT\ Tube data  &08 A in_length block out_length  --  blockTINT\TINTPHA:PHA                    :\ Save functi
19466 DA #&08:JSR SendCommand   :\ Send command &08 - OSWORDTINTPLA:JSR SendByte           :\ Send functionTINTTAX:BPL
29295 dSendLow        :\ Jump with functions<&80TINTLDY #&00:LDA (LPTR),Y      :\ Get send b
27491  length from control blockTINTTAY:JMP WordSend           :\ Jump to send control blockTINTTINT.WordSendLowTINTLDY WordL
29799 hsTx-1,X      :\ Get send block length from tableTINTCPX #&15:BCC WordSend      :\ Use this length for OSWORD
29728 o &14TINTLDY #&10                   :\ Send 16 b
29541  for OSWORD &15 to &7FTINT.WordSendTINTTYA:JSR SendByte           :\ Send send block lengthTINTDEY:BMI LFB45             
 8284 Zero or &81..&FF length, nothing to sendTINT.LFB38TINTLDA (L
10578 ,Y:JSR SendByte  :\ Send byte from control blockTINTDEY:BPL LFB38              :\ L
 8304 for number to be sentTINT.LFB45TINTTXA:BPL WordRecvLow        :\ Jump with functions<&80TINTLDY #&01:LDA (LPTR),Y   
14880 \ Get receive block length f
 8301 control blockTINTTAY:JMP WordRecv           :\ Jump to receive control blockTINTTINT.WordRecvLowTINTLDY WordLengthsRx-1
 8224     :\ Get receive length from tableTINTCPX #&15:BCC WordRecv      :\ Use this length f
20256 SWORD 1 to &14TINTLDY #&10                   :\ Receive 16 bytes for OSWORD &15 to &7FTINT.WordRecvTINTTYA:JSR SendByte
 8224        :\ Send receive block
28261 gthTINTDEY:BMI LFB71              :\ Zero of &81..&FF length, nothing to receiveTINT.LFB64TINTJSR WaitByte:STA (L
10578 ,Y  :\ Get byte to control blockTINTDEY:BPL LFB64              :\ Loop for number t
25970 ceiveTINT.LFB71TINTLDY LPTR+1:LDX 
21076 +0:PLA  :\ Restore registersTINTRTSTINTTINTTINT\ RDLINE - Read a line of textTINT\ ========
15677 ================TINT\ On entry, A =0TINT\           XY=>control
28524 ckTINT\ On exit,  A =undefinedTINT\           Y =length of returned stringTINT\           Cy=0 ok, Cy=1
25459 apeTINT\TINT\ Tube data  &0A block  --  &FF or &7F string &0DTINT\TINT.RDLINE
21584  FNif(RDLINE%)          :\ Perform RDLINE locallyTINT  LDY #2TINT  LDA (LPTR),Y:S
19488 PTR+2  :\ Copy control block to w/sTINT  DEY:LDA (LPTR),Y:TAXTINT  
14937 LDA (LPTR),YTINT  STA LPTR+0:STX LPTR+1    :\ (LPTR)=>string buffer,
21584 R+2=max lengthTINT  .Word00Lp1TINT  JSR OSRDCH:BCS Word00Esc :\ Wait for chara
29285 TINT  CMP #&7F:BNE Word00Char  :\ Not DeleteTINT  .Word00DeleteTINT  TYA:BEQ Word00Lp1        :\ Nothing to deleteTINT  LDA 
17975 :JSR OSWRCH      :\ VDU 127TINT  DEY:
 8272 Word00Lp1        :\ Dec. counter, loop backTINT  .Word00CharTINT  CMP #&08:BEQ 
25714 00Delete:\ BS is also DeleteTINT  CMP #&15:BNE Word00Ins   :\ Not Ctrl-UTINT  TYA:BEQ Word00Lp1        :\ Nothing
 8303 deleteTINT  LDA #&7FTINT  .Word00Lp2TINT  JSR OSWRCH:DEY           :\ Delete charactersTINT  BNE Word00Lp2TINT  BEQ Word00Lp1  
 8224       :\ Jump back to startTINT
22318 ord00InsTINT  STA (LPTR),Y     
 8224     :\ Store characterTINT  CMP
12326 D:CLC:BEQ Word00cr:\ Return - f
29545 hTINT  CPY LPTR+2:BCS Word00max :\ Maximum lengthTINT  CMP #&20:BCS Word00ctrl  :\ Control characterTINT  DEY      
 8224             :\ Cancel follow
 8295 INYTINT  .Word00ctrlTINT  INY:JSR OSWRCH           :\ Inc. counter, print characterTINT  .Word00maxTINT  JMP Word00Lp1
 8224         :\ Loop for moreTINT  .
25714 00crTINT  JSR OSNEWL:CLC           :\ Return with CC, Y=lengthTINT  .Word00EscTINT  RTSTINTOPT FNelseTINT  LDA #&0A:JSR Se
28483 mmand :\ Send command &0A - RDLINETINT  LDY #&04TINT  .LFB7ETINT  LDA (LPTR),Y:JSR SendByte:\ Send contro
27746 ockTINT  DEY:CPY #&01:BNE LFB7E
14880 \ Loop for 4, 3, 2TINT  LDA #&0
21322 R SendByte    :\ Send &07 as address high byteTINT  LDA (
21076 ),Y:PHA         :\ Get text buffer address high byteTINT  DEY:TYA:JSR SendByte 
 8224 :\ Send &00 as address low b
 2661   LDA (LPTR),Y:PHA         :\ Get text buffer address low byteTINT  LDX #&FF:JSR WaitByte    :\ Wait for responseTINT 
19539  A:BCS RdLineEscape   :\ Jump if Escape returnedTINT  PLA:STA LP
12331 :PLATINT  STA LPTR+1:LDY #&00      :\ Set &F8/9=>text bufferTINT  .RdLineLpTINT  JSR Wa
31042 te:STA (LPTR),Y:\ Store returned characterTINT  INY:CMP #&0D:BNE RdLineLp:\ Loop until <cr>TINT  LDA #&00:DEY:CLC:INX 
 8224 :\ Return A=0, Y=len, X=00, 
12349 TINT  RTSTINT  .RdLineEscapeTINT  PLA:PLA:LDA #&00         :\ Return A=0, Y=len, X=FF, Cy=1TINT  RTSTINTOPT FNendifTINTTINT\ OSWORD contro
27746 ock lengthsTINT\ --------------
11565 ----------TINT.WordLengthsTxTINTEQUB &00:EQUB &
17722 QUB &00:EQUB &05TINTEQUB &04:EQUB &05:EQUB &08:EQUB 
 2629 EQUB &04:EQUB &01:EQUB &01:EQUB &05TINTEQUB &00
21841 B &08:EQUB &20:EQUB &10TINTEQUB &0D:EQUB &00:EQUB &04:EQUB &80TINT.Word
26478 thsRxTINTEQUB &05:EQUB &00:EQUB &05:EQUB &00TINTEQUB &05:EQUB &00:EQUB &00:EQUB &00TINTEQUB &05:EQUB &09:E
 8258 &05:EQUB &00TINTEQUB &08:EQUB &19:EQUB &00:EQUB &01TINTEQUB &0D:EQUB &80:EQUB &04:EQUB 
 2608 TINTTINT\ OSARGS - Read info on open fileTINT\ ==============
15677 =============TINT\ On entry, A =functionTINT\           X =>dat
28535 rd in zero pageTINT\           
26685 andleTINT\ On exit,  A =returne
24950 lueTINT\           X  preserved
 8224          Y  preservedTINT\TINT\ Tube data  &0C handle block function  --  result blockTINT\TINT.osAR
20490 HA:LDA #&0C:JSR SendCommand :\ Send command &0C - OSARGSTINTTYA:JSR SendByte      
 8224  :\ Send handleTINTLDA &03,X:JS
25939 ndByte     :\ Send data word
16708  &02,X:JSR SendByteTINTLDA &01,X:JSR SendByteTINTLDA &00,X:JSR SendByteTINTPLA:JS
25939 ndByte           :\ Send fun
28521 nTINTJSR WaitByte:PHA           :\ Get and save resultTINTJSR WaitByte:STA &03,X     :\ Receive data wordTINTJSR WaitByte
16724  &02,XTINTJSR WaitByte:STA &01,XTINTJSR WaitByte:STA &00,XTINTPLA:RTS                   
 8284 Get result back and returnTINTTINTTINT\ OSBGET - Get a byte fro
28783 en fileTINT\ ==================
15677 ============TINT\ On entry, Y =handleTINT\ On exit,  A =byte Re
23562            Y =preservedTINT\           Cy set if EOFTINT\TINT\ Tube data  &0E handle --  Carry byteTINT\TINT.os
21573 TINTLDA #&0E:JSR SendCommand   :\ Send command &0E - OSBGETTINTTYA:JSR Se
31042 te           :\ Send handleTINTJMP WaitCarryChar          :\ Jump to wait for Carry and byteTINTTINTTINT\ OS
21589  - Put a byte to an open fileTINT\ ===================================TINT\ On ent
 8236 A =byte to writeTINT\           Y =handleTINT\ On exit,  A =preservedTINT\           Y =preservedTINT\TINT\ Tube data  &10 handle by
 8224 --  &7FTINT\TINT.osBPUTTINTPHA:LDA #&10:JSR SendCommand :\ Send command &10 - OSBPUTTINTTYA:JSR SendByte     
 8224   :\ Send handleTINTPLA:JSR Sen
29817 e           :\ Send byteTINTPHA:JSR WaitByte:PLA:RTS   :\ Wait fo
25441 knowledge and returnTINTTINTTINT\ OSF
 8260 - Open or Close a fileTINT\ =============================TINT\ On entry, A =func
28271 TINT\           Y =handle or XY=>filenameTINT\ On exit,  A =zero or handleTINT\TINT\ Tube data  &12 function stri
 9760 0D  --  handleTINT\            &12 &00 handle  --  &7FTINT\TINT.osFINDTINTPHA:LDA #&12:JSR SendCommand :\ Send 
28013 and &12 - OSFINDTINTPLA:JSR SendByte           :\ Send functionTINTCMP #&00:BNE OPEN          :\ If <>0, jump to 
20256 PENTINT\ CLOSETINTPHA:TYA:JSR SendByte       :\ Send handleTINTJSR WaitByte:PLA:RTS       :\ Wait for acknowledge, r
28532 re regs and returnTINT.OPENTINTJSR SendString             :\ Send pathnameTINTJMP WaitByte               :\ Wait for and
29797 urn handleTINTTINTTINT\ OSFILE - Operate on whole filesTINT\ ===============================TINT\ On entry, A =functionTINT\    
 8224    XY=>control blockTINT\ On ex
 8236  A =resultTINT\           control block updatedTINT\TINT\ Tube data  &14 block string <cr> function  --  result blockTINT\TINT.
18758 LETINTSTX CTRL+0:STY CTRL+1        :\ CTRL=>control blockTINTPHA:LDA #&14:JSR SendCommand :\ Send command &14 - OSFIL
17484 Y #&11
17996 C5FTINTLDA (CTRL),Y:JSR SendByte  :\ Send con
27759  blockTINTDEY:CPY #&01:BNE LFC5F     :\ Loop for &11..&02TINTDEY:LDA (CTRL),Y:TAXTINTINY:LDA (CTRL),Y:TAY       :\ Get 
26740 name address to XYTINTJSR SendString             :\ Send pathnameTINTPLA:JSR SendByte           :\ 
25710  functionTINTJSR WaitByte:PHA           :\ Wait for resultTINTLDY #&11TINT.LFC7ETINTJSR WaitByte:STA (CTRL),Y
23610  Get control block backTINTDEY:
 8281 #&01:BNE LFC7E     :\ Loop for &11..&02TINTLDY CTRL+1:LDX CTRL+0      :\ Restor
25970 gistersTINTPLA:RTS             
 8224    :\ Get result and returnTINT
 8284 OSGBPB
19744 ultiple byte Read and writeTINT\ ===========
15677 ======================TINT\ On entry, A =functionTINT\         
22872 =>control blockTINT\ On exit,  
29245 eturned valueTINT\             
28271 trol block updatedTINT\TINT\ Tube data  &16 block function  --   block Carry resultTINT\TINT.osGBPBTINTSTX CTR
14896 STY CTRL+1        :\ CTRL=>control bloc
18512 A:LDA 
13873 :JSR SendCommand :\ Send command &
11552  OSGBPBTINTLDY #&0CTINT.LFC9ATINTLDA (CTRL),Y:JSR SendByte 
 8284 Send control blockTINTDEY:BPL LFC9A              :\ Loop 
 8306 &0C..&00TINTPLA:JSR SendByte           :\ Send functionTINTLDY #&0CTINT.LFCA8TINTJSR WaitByte:STA (CTRL),Y  :\ Get cont
 8300 block backTINTDEY:BPL LFCA8              :\ Loop for &0C..&00TINTLDY CTRL+1:LDX CTRL+0      :\ Restore registersTINT
 8272 WaitCarryChar          :\ Jump to get Carry and resultTINTTINTTINT\ Tube I/O routi
 2675 \ =================TINTTINT\ Send a stringTINT\ -------------TINT.SendStringTINTSTX LPTR+0:STY LPTR+1      :\ Se
20556 TR=>stringTINT.SendStringF8TINTLDY
12326 0TINT.LF9B8TINTLDA (LPTR),Y:JSR SendB
 8293  :\ Send character to I/OTINTINY:CMP #&0D:BNE LF9B8     :\ Loop until <cr> sentTINTLDY LPTR+1:RTS             :\ Resto
22816  from &F9 and returnTINTTINTTINT\ OSWRCH - Send character to output streamTINT\ =============================
15677 =======TINT\ On entry, A =characterTINT\ On exit,  A =preserved
23562  Tube data  character  --TINT\TINT.osWRCH                    :\ WRCH is simply SendByteTINTTINTTINT\ Tu
17184 ore I/O RoutinesTINT\ ======================TINT\ Characters and commands are sent over the same single
29295 tTINT\ Outward commands are prefixed, and inward responses are prefixedTINT\TINT\ OutwardTINT\   x                 VDU x
 8224  pfx,pfx           VDU pfxTINT\   pfx,n             MOS function, control block followsTINT\TINT\
30574 ardTINT\   x                 char/byte xTINT\   pfx,pfx           char/byte
30822 TINT\   pfx,&00           BRK, error number+text+null followsTINT\   pfx,<&80          read returned control block
29797  lengthTINT\   pfx,&8n           Escape change, b0=new stateTINT\   pfx,&9x,Y,X,A     EventTINT\   pfx,&Ax           res
25974 d for networkingTINT\   pfx,&Bx           end transferTINT\   pfx,&Cx,addr      set addressTINT\   pfx,&Dx,addr      ex
29813 e addressTINT\   pfx,&Ex,addr      start load from addressTINT\   pfx,&Fx,addr      start save from a
25970 ssTINT\   All commands are data inward, except pfx,&Fx which is data outwardTINTTINTTINT\ Send a byte, prefi
26478  it if neededTINT\ -----------------------------------TINT\ On entry, A=byte to sendTINT\ On exit,  A,P preser
 2660 \TINT.SendByteTINTPHP:JSR SendData           :\ Send byteTINTCMP #pfx:BNE SendByte2     :\ If not pfx, don
21322 R Send
24948                :\ If pfx, send twice to prefix itTINT.SendByte2TINTPLP:RTSTINTTINT\ Send a prefixed comma
23562  -----------------------TINT\ On entry, A=commandTINT\ On exit,  A,X,Y preserved, P corruptedTINT.SendCom
25710 TINTPHATINT.SendCmdLpTINTJSR ReadByte:BCS SendCmdLp :\ Flush inputTINTLDA #pfx:JSR SendData      :\ Send 
 8312 prefixTINTPLA:JMP SendData           :\ Send command byte (always <&80)TINTTINT\ Check if a byte is waiting
28257 d read it if thereTINT\ -------
11565 -------------------------------------TINT\ O
30821 it, P=EQ CC - nothing waitin
 8284       
20512 =NE CS - byte waiting, retur
 8292 in ATINT\TINT.ReadByteTINTJSR ReadData               :\ See if data presentTINTPHP:BCS WaitByte2          :\ 
24948  present, continue with itTINTPLP:LDA #0:RTS             :\ No data presentTINTTINT\ Wait for a byte, 
28515 ding prefixed dataTINT\ ---------------------------------------TINT\ On exit, A =byteTINT\          P =pre
30322 edTINT\TINT.WaitByteTINTPHPTINT.WaitByteLpTINTJSR WaitData               :\ Wait for data presentTINT.WaitByte2TINTBNE
26977 tByteOk             :\ Not esc, return itTINTJSR WaitData:BEQ WaitByteOk:\ pfx,pfx, re
28274  as pfxTINTPHA:TYA:PHA:TXA:PHA:TSX    :\ Save registersTINTLDA &103,X:JSR WaitCommand :\ Decode prefixed commandTINTPLA:TA
19536 A:TAY:PLA        :\ Restore registersTINTJMP WaitByteLp  
 8224        :\ Loop back to wait 
 8306 a byteTINT.WaitByteOkTINTPLP                        :\ Restore flagsTINT.WaitByteOk2TINTRTS                        :\ R
29301 n byteTINTTINT\ Wait for raw byte of dataTINT\ -------------------------TINT\ On exit, A =byteTINT\          P =EQ byte=pfx, NE
29817 e<>pfxTINT\TINT.WaitDataTINTJSR ReadData:BCC WaitData  :\ Loop until data presentTINTRTSTINTTINT\ Decode prefixe
28515 mmandTINT\ --------------------
 2605 \ On entry, A=command, P set accordinglyTINT
27713 l registers can be trashedTINT\
24919 itCommandTINTBEQ WaitError              :\ pf
12326 0 - errorTINTBMI WaitTransfer           :\ 
11384 >&7F - data transferTINTTINT\ pfx,1..127 - read a control blockTINT\ ---------------------------------TINTTAY 
 8224                    :\ Move c
29806  to YTINT.WaitLengthTINTJSR WaitByte               :\ Wait for a byteTINTDEY:STA (CTRL),Y           :\ Store itTINTBPL WaitLe
26740 :RTSTINTTINT\ pfx,&00 - errorTINT\ ---------------TINT.WaitErrorTINTSTA ERRBUF:TAY             :\ Store error BRKTINT
 8274 WaitByte:STA ERRBUF+1  :\ Store error numberTINT.WaitErrorLpTINTJSR WaitByte:STA ERRB
12843 ,Y:\ Store error characterTINTINY:CMP #0:BNE WaitErrorLp :\ Loop unti
26982 nal &00TINT:TINT\\ This doesn't wo
23562 \ .WaitErr1TINT\\ LDA #&1E:\JSR SendCommand   :\ Send a SYNC commandTINT\\ JSR ReadByte:\BCC WaitErr1  :\ Wai
28277 til Host respondsTINT\\ .WaitEr
23562 \ JSR ReadByte:\BCS WaitErr2  :\ Flush everyth
 8295 from hostTINT:TINTLDX #16:TAYTINT.WaitErr1TINTDEY:BNE WaitErr1           :\ Pause a while to let HostTINTDEX:BNE WaitErr1
 8224        :\  reconnect after a
29285 rorTINT:TINTJSR WaitExitRelease   
 8224  :\ Release Tube, restore Sc
28261 TINTLDA ERRBUF+1:ORA ERRBUF+2  :\ Check for error 0,""TINTBEQ P%+5:JMP ERRBUF        :\ Jump to error, 
29216 eturnTINTJMP STARTUP2               :\ Error 0,"" is RESETTINTTINT\ pfx,&8n - Escape changeTINT\ ----------------------
22318 aitTra
25958 rTINTCMP #&C0:BCS WaitStartTINTCMP #&A0:BCS WaitEndTINTCMP #&90:BCS WaitEventTINTLSR A:ROR ESCFLG:RTS       :\ Set error fl
26144 rom b0TINTTINT\ pfx,&9x - EventTINT\ ---------------TINT.WaitEventTINTJSR WaitByte:TAY           :\ Fetch event Y 
24946 meterTINTJSR WaitByte:TAX           :\ Fetch event X parameterTINTJSR WaitByte               :\ Fet
25888 vent A parameterTINTJMP (EVNTV)                :\ Dispatch to event vectorTINTTINT\ pfx,&Ax - ReservedTINT\ ----
11565 ----------TINT.WaitEndTINTCMP #&B0:BCC WaitExit
 8224   :\ Return to WaitByteTINTTINT\ p
 9772 Bx - End transferTINT\ ----------------------TINTPLA:PLA:PLA:PLA:PLA:PLA    :\ Pop JSR WaitCommand, A,Y,X,ATINTPLA:PLA       
 8224          :\ Pop JSR Wait/Rea
29817 e in Load/SaveLoopTINT.WaitExitSaveTINTPLA:BPL WaitExitRelease    :\
28783  transfer flag, b0=0 - Tube releaseTINTROR A:BCS WaitExitScreen   :\ b0=1, Scre
29216 eleaseTINT.WaitExitTINTRTSTINT.WaitExitReleaseTINT.WaitExitScreenTINTRTSTINTTINT\ pfx,&C0+ - Start transferTINT\ -----------------
11565 ----TINT.WaitStartTINTPHA:LDY #4               
23610  Save command, point to TRAN
22318 aitSta
28748 TINTJSR WaitByte:STA TRANS-1,Y :\ Wait for 4-byte data addressTINTDEY:BNE WaitStartLpTINTPLA:CMP #&D0:BCC WaitExit  :\ pf
17190 x - set address for later entryTINT\CMP #&E
16988 CC CallCode    :\ pfx,&Dx - enter code immediatelyTINTCMP
17702 0:BCS TransData     :\ pfx,&Ex 
29300 ansfer dataTINTTINT\ pfx,&D0+ - En
 8306 codeTINT\ ---------------------TINT.CallCodeTINTLDA #&00:SEC:JMP (TRANS)   :\ Enter code with A=0, SECTINTTINT
26979 de what local memory to transfer data to/fromTINT\ -------------------------------------------------
16672 =&Ex/&Fx - Load/SaveTINT\TINT.TransDataTINT.WaitTransIOTINTAND #&F0                   :\ A=transfer 
26465  with b7=1 for IO transferTINTPHA:LDY #0                 :\ Stack IO/Screen flag, init Y=0TINTCMP #&F0:BCS Wai
30305 eIO    :\ pfx,&Fx - save dataTINTTINT\ Load data from remote hostTINT\ -----------------
11565 -----TINT.WaitLoadIO                :\ pfx,&
11552  load dataTINTOPT FNif(tweek3%=0)TINT  JSR WaitByte             :\ Fetch byteTINTOPT FNelseTINT  \ Within this loop, A and X are
29283 atch registers and can be trashedTINT  JSR WaitLoadByteTINT  BNE WaitLoadIOput          :\ Not <pfx>, raw byteTINT  JSR 
29801 LoadByteTINT  BNE WaitLoadEscape         :\ <pfx><command>TINT  .WaitLoadIOputTINTOPT FNendifTINTSTA (TRA
11305 Y              :\ Store in I/O memoryTINTINY:BNE WaitLoadIOTINTINC TRANS+1:JMP WaitLo
20297  :\ Loop until terminated by pfx,&BxTINTTINT.WaitLoadEscapeTINTTINT\ Save data to remote hostTINT\ ------------
11565 --------TINT.WaitSaveIOTINTLDA (TRANS),Y:JSR Se
31042 te     :\ pfx,&Fx - save dataTINTJSR ReadByte:BCS WaitSaveExit  :\ Poll input for terminationTINTINY:B
22304 aitSaveIO             :\ Update checksum for 256 bytesTINTINC TRANS+
19786 P WaitSaveIO     :\ Loop until terminated by pfx,&BxTINT.
29801 SaveExitTINTJMP WaitExitSaveTINTTINTTINT.WaitLoadByteTINT\ A and X are scratch, Y needs to be preservedTINTTINTTINTTINTTINT
28229 ter Code pointed to by TRANS
24946 nsfer addressTINT\ ===============================================TINT\ Checks to see if code has a ROM header, and ve
26982 es itTINT\ if it has. CC=entered from RESET, CS=entered from OSCLITINT.EnterCodeTINT.EnterCodeIOTINTPHP:LDY #&07:
 8257 (TRANS),Y         :\ Get copyright offsetTINTCLD:CLC:ADC TRANS+0:ST
16710 ULT+0TINTLDA #0:TAY:ADC TRANS+1
16724  FAULT+1 :\ &FD/E=>copyright messageTINT\TINT\ Now check for &00,"(C)"TINTLDY #&00:LDX #
17710 nterCh
 2667 LDA (FAULT),Y:CMP CheckCopy,X:BNE LF8FATINTINY:DEX:BPL EnterCheck             :\ Check for &00,"(C
23562 TINT\ &00,"(C)" exists, check ROM
28793 e byteTINT\ -------------------------------------TINTLDY #&06:LDA (TRANS),Y             :\ Get ROM typeTINTAND #&4F:CMP #
14896 BCC NotLanguage  :\ b6=0, not a languageTINTAND #&0
20034 E Not6502Code           :\ type<>0 and <>2, not 6502 c
 2661 .LF8FATINTTXA:ROL A:ROL A:AND #1             :\ A=0 - raw, A=1 - headerTINTLDX TRANS+0:LDY TRANS+1:BPL
14662 04  :\ Entered code<&8000, don't move memtopTINTSTX MEMTOP+0:STY MEMTOP+1  
 8224     :\ Set memtop to current
28530 gramTINTSTX PROG+0:STY PROG+1              :\ Set current program to address enteredTINT.LF904TINTPLP:JMP (TRANS)    
 8224             :\ Enter code wi
16672 =raw/code, Cy=RESET/OSCLI flagTINT.CheckCopyTINTEQUS ")C(":EQUB 0TINT\TINT\ Any existing error handler will prob
31084  have been overwrittenTINT\ So, set up new error handler before generating an errorTINT.NotLanguageTINT
 8274 InitErrorTINTOPT FNerror:EQUB 249:EQUS "This is not a language":EQUB 0TINTTINT.Not6502Co
18954 SR InitErrorTINTOPT FNerror:EQUB 249:EQUS "This is not 6502 code":EQUB 0TINTTINTTINT\ Low level I/O routinesTINT
15677 ====================TINT\ This 
30496 here detailed playful frobbing is done to ensure a cleanTINT\ error-free reliable link channel. All calling code a
28021 es theseTINT\ routines are 100% error-free and reliable. Any handshaking,TINT\ retries, error correction, etc must be
28271 e at this level.TINT\TINT\ Code can be made faster by migrating knowledge about the hardwareTINT\ up to t
21536 ube I/O layer.TINT\TINTTINT\ Send a raw byte of dataTINT\ -----------------------TINT\ On entry, A=byte to sendTINT
28239  exit,  A,X,Y preserved, P c
30066 ptedTINT\TINT.SendDataTINTPHATINTOPT FNif(TxDelay)TINT  LDA #TxDelay:SEC         :\ 6551-style TxRDY bugfixTINT  .SendWaitTINT  SBC
14897 BNE SendWaitTINTOPT FNendifTINTOPT FN
21544 xRDY)TINT  .SendWaitTINT  LDA TxStatus             :\ Get StatusTINTOPT FNendifTINTOPT FNif(TxRDY>0)TINT  AND #Tx
 8281 AND 255TINT  BEQ SendWait             :\ Wait until data can be sen
20559 T FNen
 2662 OPT FNif(TxRDY<0)TINT  AND #-TxRDY AND 255TINT  BNE SendWait             :\ Wait until data can be sentTINTOPT
25934 ndifTINTPLA:STA TxData:RTS         :\ Send dataTINTTINT\ Read raw dataTINT\ --
11565 -------TINT\ On exit, P =CC, no dataTINT\      
 8224   =CS, data present, EQ=pfx,
15685 not pfxTINT\TINT.ReadDataTINTOPT FNif(tweek1%)TINT\ Check if anything squeezed in befo
30496 e managed to raise RTSTINT  LDA RxStatus               :\ Get RxStatusTINT  AND #RxRDY:BNE ReadDataRx  
17440 ata already presentTINTOPT FNendifTINTPHP:SEI                      :\ Speed up by disabling IR
20234 PT FNif(RxControl)TINT  TYA:PHATINT  LDY #RxCont:STY RxControl  :\ Lower RTS to allow inputTINT  LDY #RxStopTINTOPT FNendif
16708  RxStatus                 :\ Get RxStatusTINTAND #RxRDY:BNE ReadDataOk    :
24900 ta presentTINTOPT FNif(RxContro
 8202  PLA:STY RxControl:TAY      :\ Pause,
26977 se RTS, restore YTINTOPT FNendifTINTPLP:CLC:RTS                  :\ CC=No data prese
11786 ReadDataOkTINTOPT FNif(RxControl)TINT  PLA:STY RxControl:TAY      :\ Pause, Raise RTS, restore YTINTOPT FNendifTINTPLP      
 8224                 :\ Restore I
 2675 .ReadDataRxTINTLDA RxData:CMP #pfxTINTSEC:RTS                      :\ CS=Data prese
 8236 EQ/NE=pfxTINTTINTTINT]:IF(P%>IOSPACE%)AND(SWROM%=0):ERROR 1,"Code overrun"TINT[OPT P*3+4TINT\ Spare spaceTINT\ ===========TINTEQUS ST
18254 $((IOSPACE%-P%)AND255,CHR$255)TINTTINT\ I/O SpaceTINT\ =========TINTEQUS STRING$(
18499 R$0)TINTTINT\ Tube I/O RegistersTINT\ ===========
15677 ===TINT.TubeS1 :\ &FEF8 :EQUB 0TINT.TubeR1 :\ &FEF9 :EQUB 0TINT.Tu
12883  :\ &FEFA :EQUB 0TINT.TubeR2 :\ &FEFB :EQUB 0TINT.TubeS3 :\ &FEFC :EQUB 0TINT.TubeR3 :\ &FEFD :EQUB 0TINT.Tub
 8244 :\ &FEFE :EQUB 0TINT.TubeR4 :\ &FEFF :EQUB 0TINTTINTTINT\ DEFAULT VECTOR TABLETINT\ ==========
15677 ======TINT.LFF00TINTEQUW NullReturn      :\ &200 - USERVTINTEQUW E
29295 Handler    :\ &202 - BRKVTINTEQUW IRQ1Handler     :\ &204 - IRQ1VTINTEQUW IRQ2Handler     :\ &206 - IRQ2VTINTEQUW osCLI
 8224        :\ &208 - CLIVTINTEQUW o
21593 E          :\ &20A - BYTEVTINTEQUW osWORD          :\ &20C - WORD
20805 UW osW
 8264          :\ &20E - WRCHVTINTEQUW osRDCH          :\ &210 - RDCHVTINTE
 8279 osFILE          :\ &212 - FILEVTINTEQUW osARGS          :\ &214 - ARGSVTINTEQUW osBGET 
 8224      :\ &216 - BGetVTINTEQUW os
21589           :\ &218 - BPutVTINTEQUW osGBPB          :\ &21A - GBPBVTINTEQUW osFIND  
 8224     :\ &21C - FINDVTINTEQUW Nul
29797 urn      :\ &21E - FSCVTINTEQUW NullReturn      :\ &220 - EVNTVTINTEQUW NullReturn  
 8224 :\ &222 - UPTVTINTEQUW NullRetu
 8224     :\ &224 - NETVTINTEQUW NullReturn      :\ &226 - VduVTINTEQUW NullReturn      :\ &228 - KEYVTINTEQUW NullReturn
 8224   :\ &22A - INSVTINTEQUW NullRe
28274       :\ &22C - RemVTINTEQUW NullReturn      :\ &22E - CNPVTINTEQUW NullReturn      :\ &230 - IND1VTINTEQUW NullReturn    
23610  &232 - IND2VTINTEQUW NullRetur
 8224    :\ &234 - IND3VTINTTINT\ Print 
 8312 numbersTINT\ =================TINT.PrHexXYTINTTYA:JSR PrHex:TXATINT.PrHexTINTPHA:LSR A:LSR A:LSR A:LSR ATINTJSR PrN
27746 e:PLATINT.PrNybbleTINTAND #15:CMP #10:BCC PrDigit:ADC #6TINT.PrDigitTINTADC #ASC"0":JMP OSWRCHTINTTINT\ Print em
25700 ed stringTINT\ =====================TINT\ Mustn't use LPTR so can be called from OSCLITINT.PrTextTINTPLA:STA 
21592 +0:PLA:STA TEXT+1 :\ CTRL=>embedded stringTINTJSR PrString2:JMP (TEX
 8224     :\ Print string and jump back to 
25956 TINT:TINT.PrStringTINTSTX TEXT+0:STY TEXT+1      :\ CTRL=>string at YXTINT.PrStringLpTINTLDY #&00:LDA (TEXT),Y      :\ Get
24936 racterTINTBEQ PrString2:JSR OSASCI   :\ Print character if not &00TINT.PrString2TINTINC TEXT+0:BNE LFEA6
17230  TEXT+1 :\ Increment addressTINT.LFEA6TINTTAY:BNE PrStringLp         :\ Loo
24930 ck if not &00TINT.NullReturnTINTRT
 2570 \ Stan
25714  Tube entry pointsTINT\ ==========================TINT\ NB! All API entry points must be called in 
16718 RY modeTINT\TINTEQUS STRING$((&FF95-P%)AND255,CHR$255)TINT.LFF95  :JMP NullRet
 8302        :\ &FF95TINT.OSCOLD :JMP NullReturn        :\ &FF98TINT.PRSTRNG:JMP PrString          :\ &FF9B  Print zero-te
28265 ated text at YX, returns A=0, Y corruptedTINT.LFF9E  :JMP NullReturn        :\ &FF9ETINT.SCANHEX:JMP ScanHex   
 8224     :\ &FFA1  Scan hex strin
29793  (&F8), returned in &F0/1TINT.D
16715 CC:JMP NullReturn        :\ &FFA4TINT.DISKCCP:JMP NullReturn        :\ &FFA7  Quit
29301 rent programTINT.PRHEX  :JMP PrHex             :\ &FFAA  Print A in hex, A corruptedTINT.PR2HEX :JMP 
25928 xXY           :\ &FFAD  Print YX in hex, A corruptedTINT.USERINT:JMP NullReturn        :\ &FFB0TINT.PRTEXT :JMP PrTe
 8224           :\ &FFB3  Print zero-terminated inline text, returns A=0, Y corruptedTINT.VECDEF :EQUB &36:EQUW LFF00   :
17958 FB6TINT.OSQUIT :JMP CmdPrompt  
 8224    :\ &FFB9  Enter superviso
25386 ommand promptTINT.OSERROR:JMP N
21100 eturn        :\ &FFBCTINT.OSINIT :JMP InitError         :\ &FFBF  Initialise MOS error handler, A corrupted
18756 SKRST:JMP NullReturn        :\ &FFC2TINT.LFFC
14880 JMP NullReturn        :\ &FF
11786 NVRDCH :JMP osRDCH            :\ &FFC8TINT.NVWRCH :J
28448 sWRCH            :\ &FFCBTINTTINT.OSFIND :JMP (FINDV)           :\ &FFCETINT.OSGBPB :
 8272 (GBPBV)           :\ &FFD1TINT.OSBPUT :JMP (BPutV)           :\ &FFD4TINT.OSBGE
19002 MP (BGetV)           :\ &FFD
20270 SARGS 
20557  (ARGSV)           :\ &FFDATINT.OSFILE :JMP (FILEV)           :\ &FFDDTINTTINT.
17490 CH :JMP (RDCHV)           :\ &FFE0TINT.OSASCI :CMP #&0D:BNE _WRCH    :\ &FFE3TINT.OSN
 8268 :LDA #&0A:JSR OSWRCH   :\ &FFE7TINT.OSWRCR :LDA #&0D              :\ &FFECTINT._WRCHTINT.OSW
 8264 :JMP (WRCHV)           :\ &FFEETINT.OSWORD :JMP (WORDV)           
 9760 FFF1TINT.OSBYTE :JMP (BYTEV)           :\ &FFF4TINT.OS_CLI :JMP (CLIV)            :\ &FFF7TINTTINT.N
 8278   :EQUW NMIHandler       :\ &FFFA  NMI VectorTINT.RESETV :EQUW RESET    
 8224     :\ &FFFC  RESET VectorTINT.
22097    :EQUW IRQHandler       :\ &FFFE  IRQ VectorTINT]:ENDPROCTINT:TINT:TINTDEFPROCasmROMHead
17674 NDPROCTINT