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 JGH: Added additional Tube ent
28704 oints,TINTREM                        EXECUTE enters code with A=0/1, SEC/CLC.TINTREM v0.18 07-Apr-2013 JGH: Moved some code
24936 t overlapped I/O area.TINTREM       09-Nov-2016 JGH: Edited slightly to allow conversion to as65 source.TINTREM v0.19 
20013 ov-2016 JGH: Added conditionals for sideways 
 8269 code.TINTREM v0.20 18-Mar-2017 JGH: Added option for local RDLINE, optimised O
18764 .TINTREM v0.21 23-Feb-2018 JGH: *HOSTFS ON sets WRCHV/RDCHV. REM  
 8224                   Serv3 resp
29540  to returned boot option.TINTREM To do:TINTREM TxRDY should also check for outgoing CTS/RTSTINT:TINTREM v0.22TINTtweek1%=
21324 E:REM ReadDataTINTtweek2%=TRUE :REM Tube transferTINTtweek3%=TRUE :
 8269 Load to I/O accesses hardware directlyTINTtweek4%=FALSETINTtweek%=tweek
20256 R tweek2% OR tweek3% OR tweek4%TINT:
21002 EM Specify targetTINTREM ==============TINTver$="0.21":date$
10272 23 Feb 2018)" IF tweek%:ver$="
12850 ":date$=" (13 Jan 2020)" SWROM% =FALSE:REM
26997 ld 6502 Client ROMTINTRDLINE%=FALSE:REM Pass RDLINE to hostTINTRDLIN
21565 RUE :REM Implement RDLINE locally
21002 EM BoilerplateTINTREM ===========TINTIF HIMEM>&FFFF:SYS "OS_
17780 nv"TOA$:IFLEFT$(A$,5)<>"B6502":OSCLI"B6502"+MID$(A$,INSTR(A$," ")) ON ERROR REPORT:PRINT" at line
17723 RL:ENDTINTDEFFNif(A%):IFA%:z%=-1:
29808 % ELSE z%=P%:=opt%TINTDEFFNendif:IFz%=-1:=opt% ELSE z%=P%-z%:P%=P%-z%:O%=O%-z%:=opt%TINTDEFFNelse:IFz%=-1:z%=P%:=
 9588  ELSE z%=P%-z%:P%=P%-z%:O%=O%-z%:z%=-1:=opt%TINTDIM mcode% &FFF, L% &7FTINT:TINTREM Declare code start and spaceTINTREM 
15677 ========================TINTIF SWROM%=0:tweek3%=0TINTIF SWROM%=
28524 ad%=&F800TINTIF SWROM%  :load%=&8000TINT:TINTREM System vectors
19781  ==============TINTUSERV=&200:BRKV =&202:IRQ1V=&204:IRQ2V=&206:CLIV =&208:BYTEV=&
 2625 WORDV=&20C:WRCHV=&20E:RDCHV=&210:FILEV=&212:
21319 V=&214:BGetV=&216TINTBPutV=&218:GBPBV=&21A:FINDV=&21C:FSCV =&21E:EVNTV=&220TINT:TINTREM
29561 tem addressesTINTREM ================TINTROMSTART%=&F800         :REM Start of ROM co
29728 o copy to RAMTINTIOSPACE% =&FEF0         :REM Start of I/O spaceTINTERRBUF=&236             :REM Error 
26214 erTINTINPBUF=&236:INPEND=&300 :REM Supervisor string bufferTINT:TINTPROG   =&EE:REM &EE/F = PROG   - Current programTINTNUM  
 9789 F0:REM &F0/1 = NUM    - hex 
30051 mulatorTINTMEMTOP =&F2:REM &F2/3 = MEMTOP - top of memoryTINTTRANS  =&F4:REM &F4/5 = ADDR   - Data tr
26227 er address (assembler doesn't like 'INC ADDR')TINTTRANShi=&F6:REM &F6/7 = ADDR+2 - Data transfer address high
29295 dTINTLPTR   =&F8:REM &F8/9 = String pointer, OSWORD control blockTINTCTRL   =&FA:REM &FA/B = CTRL   - OSFILE, OSGBPB cont
 8300 blockTINTCMD    =&FA:REM         CMD    - Address of command line parametersTINTTEXT   =&FA:REM &FA/B = TEXT   - 
25940 xt string pointerTINTIRQA   =&FC:REM &FC   = IRQ A storeTINTFAULT  =&FD:REM &FD/E => last errorTINTESCFLG =&FF:REM &FF 
 8253 Escape flagTINT:TINTREM I/O values
26740 ese should work for BenEater
19781  ==========================================TINTTxStatus=&5001:TxRDY=0:TxData=&500
30804 Init=&00:TxCommand=&5002:TxCmd=&0A:RxCont=&0ATINTRxStatus
12341 01:RxRDY=8:RxData=&5000:RxInit=&00
17272 ontrol=&5003:TxCtl=&1E:RxStop=&02TINTTxDelay=100:REM *NOTE* 6551 ACIA has bug, TxRD
25966 ver works.TINTMAXRAM%=&4000:nam
 8765 Eater65" : REM I/O values, these
25970  suitable for a 6850TINTREM =========================================TINTTxStatus=&FEF0:TxRDY=2:TxD
15713 &FEF1:TxInit=&13:TxCommand=0:TxCmd=0:RxCont=&15TINTREM &13=Reset ACIA, &15=8N1, clock/16, RTS lowTINTRxStatus=&FEF0:Rx
15705 1:RxData=&FEF1:RxInit=&55:TxControl=0:TxCtl=0:RxStop=&55TINTREM &55
12622 , clock/16, RTS highTINTTxDelay=0TINTMAXRAM%=0:IF SWROM%:n
 9317 ="HostFS" ELSE name$="Serial65"TINT:TINTREM Serial Tube system valuesTINTREM =========================TINTesc=&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:TINTDEFPROCasmTubeCodeTINT[OPT opt%TINT\ Start of Tube system codeTINT\ ===
15677 ==================TINT\ On hardware reset all of memory read
28515 me from ROM, all writes go t
16722 M.TINT\ Accessing any I/O locat
 8302 pages ROM out of memory map, thence all readsTINT\ come from RAM.TINT\TINT.LF800TINTJMP RESETTINT.PrBannerTINTJSR PrTextTINT.BAN
 2642 EQUB 13:EQUS "SERIAL TUBE 6502 64K ":EQUS LEFT$(ver$+" ",5)TINTEQUB 
17722 QUB 0TINTRTSTINTTINT\ Tube Client Startup CodeTINT\ =======
15677 =============TINT.RESETTINTSEI:LDX #&00               :\ Disabl
28265 teruptsTINT.LF802TINTLDA &FF00,X:S
 9760 FF00,X    :\ Copy entry block to RAMTINTDEX:BNE LF802TINTTINT\ The fol
26999 ng code copies the page with the I/O registers inTINT\ it without accessing the I/O registers. Modify IOSPACE%
25443 ordingTINT\ to where the I/O registers actually are.TINTTINTLDX #IOSPACE% AND 255TINT.LF819TINTLDA &FDFF,X:S
 9760 FDFF,X    :\ Copy &FE00-&FEEF to RAM, avoidingTINTDEX:BNE LF819 
 8224          :\  IO space at &FE
14858 TINTLDY #ROMSTART% AND 255:STY LPTR+0 :\ Point to start of ROMTINTLDA #ROMSTART% DIV 256:STA LPTR+1TINT.LF82A                
 8224  :\ Copy rest of ROM to RAMTINT
 8257 (LPTR),Y:STA (LPTR),Y  :\ Copy a page to RAMTINTINY:BNE LF82A      
 8224     :\ Loop for 256 bytesTINTIN
20556 TR+1:LDA LPTR+1      :\ Inc.
25700 ress high byteTINTCMP #&FE:BNE LF82A         :\ Loop up to &FDFFTINT:TINT.STARTUPTINTSEI:LDX #&35TINT.LF80DTINT
 8257 LFF00,X:STA USERV,X    :\ Set up default vectorsTINTDEX:BPL LF80D:T
 8224         :\  and clear stackTINTOPT FNif(TxCommand=0)TINT  LDA #TxInit:STA TxStatus :\
26990 tialise port and page ROM outTINT  LDA #RxInit:STA RxStatusTINTOPT FNelseTINT 
16708  #TxInit:STA TxStatus :\ Initialise port and page ROM outTINT  LDA #TxCmd:S
21536 xCommandTINT  LDA #TxCtl:STA TxControlTINTOPT FNendifTINT             
 8224           :\ Accessing I/O r
29545 ters 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.TINTLDA #
14896 STA ESCFLG:STA MEMTOP+0    :\ Clear Escape f
 2663 OPT FNif(MAXRAM%=0)TINT  LDA #ROMSTART% DIV 256:STA MEMTOP+1 :\ Set memtop to start of ROMTINTOPT F
29548 eTINT  LDA #MAXRAM% DIV 256:STA MEMTOP+1   :\ Set memtop to top of RAMTINTOPT FNendifTINTJSR InitError    
 8224                :\ Claim erro
24936 ndlerTINTLDA PROG+0:STA TRANS+0
 8224           :\ Copy PROG to TR
 8275 addressTINTLDA PROG+1:STA TRANS+1TINTTINT\ Tell the Host that we've restartedTINT\ ---
11565 ---------------------------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 escaped, and inward responses are escapedTINT\TINT\ OutwardTINT\   x                 VDU xTINT\
25888 sc,esc           VDU escTINT\  
25459 ,n             MOS function, control block followsTINT\TINT\ InwardTINT\   x                 char/byte xTINT\
25888 sc,esc           char/byte e
23562    esc,&00           BRK, error number+text+null followsTINT\   esc,<&80          read returned co
28530 l block set lengthTINT\   esc,&8n           Escape change, b0=new stateTINT\   esc,&9x,Y,X,A     EventTINT\   esc,&Ax    
 8224    reserved for networkingTINT\
25888 sc,&Bx           end transfe
 8284   esc,
11384 addr      set addressTINT\   esc,&Dx,addr      execute addressTINT\  
25459 ,&Ex,addr      start load from addressTINT\   esc,&Fx,addr      start save from addressTINT\   All comm
29540  are data inward, except esc,&Fx which is data outwardTINTTINTTINT\ Send a byte, escaping it if neededTINT\ ----------
11565 --------------------TINT\ On entry, A=byte t
25971 ndTINT\ On exit,  A,P preserved
11786 SendByteTINTPHP:JSR SendData           :\ Send byteTINTCMP #esc:BNE SendByte2     :\ If not es
25632 oneTINTJSR SendData               :\ If esc
25971 nd twice to prefix itTINT.SendB
12901 TINTPLP:RTSTINTTINT\ Send an escaped commandTINT\ -----------------------TINT\ On entry, A=commandTINT\ On exit,  A,X,Y preserved,
25376 orruptedTINT.SendCommandTINTPHATINT.SendCmdLpTINTJSR ReadByte:BCS SendCmdLp :\ Flush inp
19466 DA #esc:JSR SendData      :\ Send esc prefixTINTPLA:JMP SendData           :\ Send command byte (always <&80)TINTTINT\ Ch
 8299 if a byte is waiting, and read it if thereTINT\ ------------------------------------------------TINT\
 8302 exit, P=EQ CC - nothing waitingTINT\          P=NE CS - byte waiting, returned
 8302 ATINT\TINT.ReadByteTINTJSR ReadData               :\ See if data presentTINTPHP:BCS WaitByte2          :\ Data pr
28261 t, continue with itTINTPLP:LDA #0:RTS             :\ No data presentTINTTINT\ Wait for a byte, decoding escaped dataTINT\ -
11565 ---------------------------------TINT\ On ex
 8236 A =byteTINT\          P =preservedTINT\TINT.WaitByteTINTPHPTINT.WaitByteLpTINTJSR WaitData               :\ Wait for data presentTINT
26977 tByte2TINTBNE WaitByteOk             :\ Not esc, return itTINTJSR WaitData:BEQ WaitByteOk
25888 sc,esc, return as escTINTPHA:TYA:PHA:TXA:PHA:TSX    :\ Save registersTINTLDA &103,X:JSR WaitCo
28257 d :\ Decode escaped commandTINTPLA:TAX:PLA:TAY:PLA        :\ Restore registersTINTJMP WaitByteLp             :\
28527 p back to wait for a byteTINT.WaitByteOkTINTPLP                        :\ Rest
 8293 flagsTINT.WaitByteOk2TINTRTS                        :\ Return byteTINTTINT\ Wait for raw byte of dataTINT\ ------------------
11565 ---TINT\ On exit, A =byteTINT\          P =EQ b
15717 esc, NE byte<>escTINT\TINT.WaitDataTINTJSR ReadData:BCC WaitData  :\ Loop until data presentTINTRTSTINTTINT\ Decode escaped comman
 8284 ------
11565 ------------TINT\ On entry, A=command, P set
25443 ordinglyTINT\ All registers can be trashedTINT\TINT.WaitCommandTINTBEQ WaitError              :\ esc,&00 
29285 rorTINTBMI WaitTransfer        
14880 \ esc,>&7F - data transferTINTTINT
29541 c,1..127 - read a control bl
 2667 \ ---------------------------------TINTTAY                        :\ Move count to YTINT.WaitLengthTINTJ
22304 aitByte               :\ Wait for a byteTINTDEY:STA (CTRL),Y           :\ Store i
20546 L Wait
26478 th:RTSTINTTINT\ esc,&00 - errorTINT\ ---------------TINT.WaitErrorTINTSTA ERRBUF:TAY             :\ Store error 
 2635 JSR WaitByte:STA ERRBUF+1  :\ Store error numberTINT.WaitErrorLpTINTJSR WaitByte:STA
21074 BUF+2,Y:\ Store error characterTINTINY:CMP #0:BNE WaitErrorLp :\ Loo
28277 til final &00TINT:TINT\\ This does
 8308 workTINT\\ .WaitErr1TINT\\ LDA #&1E:\JSR 
25710 Command   :\ Send a SYNC commandTINT\\ JSR ReadByte:\BCC WaitErr1  :\ Wait until Host respondsTINT\\ .W
17780 rr2TINT\\ JSR ReadByte:\BCS WaitErr2  :\ Flush everything from hostTINT:TINTLDX #16:TAYTINT.WaitErr1TINTDEY:BNE Wait
12658            :\ Pause a while to let HostTINTDEX:BNE WaitErr1           :\  reconnect after an errorTINT:TINTJSR WaitExit
25964 ase        :\ Release Tube, restore ScreenTINTLDA ERRBUF+1:ORA ERRBUF+2  :\ Check for error 0,""TINTBEQ
11045 5:JMP ERRBUF        :\ Jump to error, no returnTINTJMP STARTUP2               :
29253 ror 0,"" is RESETTINTTINT\ esc,&8n
17696 scape changeTINT\ -----------------------TINT.W
21620 ransferTINTCMP #&C0:BCS WaitStartTINTCMP #&A0:BCS WaitEndTINTCMP #&90:BCS WaitEventTINTLSR A:ROR ESCFLG:RTS      
 8284 Set error flag from b0TINTTINT\ esc,&9x - EventTINT\ ----------
11565 -TINT.WaitEventTINTJSR WaitByte:TAY           :
25926 tch event Y parameterTINTJSR Wa
31042 te:TAX           :\ Fetch event X parameterTINTJSR WaitByte               :\ Fetch event A parameterTINTJMP (EVNTV)   
 8224          :\ Dispatch to even
25974 ctorTINTTINT\ esc,&Ax - ReservedTINT\
11565 ---------------TINT.WaitEndTINTCMP #&B0:BCC Wai
27000 t      :\ Return to WaitByteTINTTINT\ esc,&Bx - End transferTINT\ --------
11565 ----------TINTPLA:PLA:PLA:PLA:PLA:PLA    :\ 
 8304 JSR WaitCommand, A,Y,X,ATINTPLA:PLA                    :\ Pop JSR Wait/ReadByte in Load/SaveLoopTINT.WaitExitSave
16716 :BPL WaitExitRelease    :\ Pop transfer flag, b0=0 - Tube releaseTINTROR A:BCS 
29801 ExitScreen   :\ b0=1, Screen releaseTINT.WaitExitTINTRTSTINT.WaitExitReleaseTINT.WaitExitScreenTINTRTSTINTTINT\ es
17190 0+ - Start transferTINT\ ------------------
11565 ---TINT.WaitStartTINTPHA:LDY #4                
 8284 Save command, point to TRANSTINT.WaitStartLpTINTJSR WaitByte
16724  TRANS-1,Y :\ Wait for 4-byte data addressTINTDEY:BNE WaitStartLpTINTPLA:CMP #&D0:BCC
26977 tExit  :\ esc,&Cx - set address for later entryTINT\CMP #&E0:\BCC CallCode    :\ esc,&
11552  enter code immediatelyTINTCMP #&E0:BCS TransData     :\ esc,&Ex - transfer dataTINTTINT\ esc,&D0+ - Enter codeTINT\ -----------
11565 ------TINT.CallCodeTINTLDA #&00:SEC:JMP (TRANS)
14880 \ Enter code with A=0, SECTINTTINT
25924 cide what local memory to tr
26227 er data to/fromTINT\ -------------------------------------------------TINT\ A=&Ex/&Fx - Load/SaveTINT\TINT.TransDataTINT.
29801 TransIOTINTAND #&F0                   :\ A=transfer flag with b7=1 for IO transferTINTPHA:LDY #0   
 8224           :\ Stack IO/Screen
24940 g, init Y=0TINTCMP #&F0:BCS WaitSaveIO    :\ esc,&Fx - save dataTINTTINT\ Load data from remote hostTINT\ ----
11565 ------------------TINT.WaitLoadIO           
 8224  :\ esc,&Ex - load dataTINTOPT 
26217 (tweek3%=0)TINT  JSR WaitByte             :\ Fetch byteTINTOPT FNelseTINT  \ Within
26984 s loop, A and X are scratch registers and can be trashedTINT  JSR WaitLoadByteTINT  BNE WaitLoadIOput          :\ Not 
25459 >, raw byteTINT  JSR WaitLoadByteTINT  BNE WaitLoadEscape         :\ <esc><command>TINT  .WaitLoadIOputTINTOP
20038 endifTINTSTA (TRANS),Y         
 8224  :\ Store in I/O memoryTINTINY:
 8261 WaitLoadIOTINTINC TRANS+1:JMP WaitLoadIO :\ Loop until terminated by esc,&BxTINT
24919 itLoadEscapeTINTTINT\ Save data to remote hostTINT\
11565 ---------------------TINT.WaitSaveIOTINTLDA (TR
10579 ,Y:JSR SendByte     :\ esc,&Fx - save dataTINTJSR ReadByte:BCS WaitSaveExit  
20512 oll input for terminationTINTINY:BNE WaitSaveIO             :\ Update checksum for 256 byte
20041 C TRAN
14897 JMP WaitSaveIO     :\ Loop until termin
25701  by esc,&BxTINT.WaitSaveExitTINTJMP WaitExitSaveTINTTINTTINT.WaitLoadByteTINTTINTTINTTINTTINT\ Enter Code pointed to by TRANS transfer address
15648 ==============================================TINT\ Checks to see if code has a ROM header,
25710  verifies itTINT\ if it has. CC=entered from RESET, CS=entered from OSCLITINT.EnterCodeTINT.EnterCodeI
18512 P:LDY 
14128 :LDA (TRANS),Y         :\ Get copy
26727 t offsetTINTCLD:CLC:ADC TRANS+0:STA FAULT+0TINTLDA #0:TAY:ADC TRANS+1:STA FAULT+1 :\ &FD/E=>copyright messa
23562 TINT\ Now check for &00,"(C)"TINTLDY #&00:LDX #3TINT.EnterCheckTINTLDA (FAULT),Y:CMP CheckCopy,X:BNE LF8FATINTIN
17732 X:BPL EnterCheck             :\ Check for &00,"(C)"TINT\TINT
12326 0,"(C)" exists, check ROM ty
25120 yteTINT\ -------------------------------------TINTLDY #&06:LDA (TRANS),Y             :\ Get ROM typeTINTAN
 9763 4F:CMP #&40:BCC NotLanguage 
 8284 b6=0, not a languageTINTAND #&0D:BNE Not6502Code         
23610  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(TxRDY)TINT  .SendWaitTINT  LDA TxStatus             :\ Get StatusTINT  AND #TxRDY:BEQ Sen
26977 t  :\ Wait until data can be sentTINTOPT FNendifTINTOPT FNif(TxDelay)TINT  LDA #TxDelay:SEC 
 8224     :\ 6551-style TxRDY bugf
 8202  .SendWaitTINT  SBC #1:BNE SendWaitTINTOPT FNendifTINTPLA:STA TxData:RTS         :\ Send dataTINTTINT\ Read raw dataTINT\ ------------
 8284 On exi
20512  =CC, no dataTINT\            =CS, data pre
29806 , EQ=esc, NE=not escTINT\TINT.ReadDataTINTOPT FNif(tweek1%)TINT\ Check if anything squeezed in before we mana
 8292 to raise RTSTINT  LDA RxStatus               :\ Get RxStatusTINT  AND #RxRDY:BNE ReadDataRx  :\ Data al
25697 y presentTINTOPT FNendifTINTPHP:SEI:TYA:PHA              :\ Speed up by disabling IRQsTINTOPT FNif(TxComma
12349 )TINT  LDY #RxCont:STY RxStatus   :\ Lower RTS to allow inputTINTOPT FNelseTINT  LDY #RxCont:STY TxComman
14880 \ Lower RTS to allow inputTINTO
17952 NendifTINTLDY #RxStop:LDA RxStatus     :\ Get RxStatusTINTAND #RxRDY:BNE ReadDataOk   
 8284 Data presentTINTOPT FNif(TxCommand=0)TINT  PLA:STY RxStatus:
14937 PLP   :\ Raise RTS, restore Y,PTINTOPT FNelseTINT  PLA:STY TxComman
16724 Y:PLP  :\ Raise RTS, restore Y,PTINTOPT FNendifTINTCLC:RTS  
 8224                 :\ CC=No dat
29296 esentTINT.ReadDataOkTINTOPT FNif(T
28015 mand=0)TINT  PLA:STY RxStatus:TAY:PLP   :\ Raise RTS, restore Y,PTINT
 8276 FNelseTINT  PLA:STY TxCommand:TAY:PLP  :\ Raise RTS, restore Y,PTINTOPT FNendifTINT.R
17508 ataRxTINTLDA RxData:CMP #esc:SEC:RTS  :\ CS=Data present, EQ/NE=escTINTTINTTINT]:IF(P%>IOSPACE%)AND(SWROM
10544 :ERROR 1,"Code overrun"TINT[OPT P*3+4TINT\ Spare spaceTINT\ ======
15677 =TINTEQUS STRING$((IOSPACE%-P%)AND255,CHR$255)TINTTINT\ I/O SpaceTINT
15677 =======TINTEQUS STRING$(8,CHR$0
23562  Tube 
 8271 RegistersTINT\ ==================TINT.TubeS1 :\ &
14406  :EQUB 0TINT.TubeR1 :\ &FEF9 :EQUB 0TINT.TubeS2 :\ &FEFA :EQUB 0TINT.TubeR
23610  &FEFB :EQUB 0TINT.TubeS3 :\ &F
 8259 :EQUB 0TINT.TubeR3 :\ &FEFD :EQUB 0TINT.TubeS4 :\ &FEFE :EQUB 0TINT.TubeR4 
 9760 FEFF :EQUB 0TINTTINTTINT\ DEFAULT VECTOR TABLETINT\ ====================TINT.LFF00TINTEQUW NullReturn     
 8284 &200 - USERVTINTEQUW ErrorHandler    :\ &202 - BRKVTINTEQUW 
12625 Handler     :\ &204 - IRQ1VTINTEQUW IRQ2Handler     :\ &206 - IRQ2VTINTEQUW osCLI   
 8224     :\ &208 - CLIVTINTEQUW osBY
 8224         :\ &20A - BYTEVTINTEQUW osWORD          :\ &20C - WORDVTINTEQUW
22387 RCH          :\ &20E - WRCHVTINTEQUW osRDCH          :\ &210 - RDCHVTINTEQUW osFILE          :\ &212 - FILEVTINTEQUW
16755 RGS          :\ &214 - ARGSVTINTEQUW osBGET          :\ &216 - BGetVTINTEQUW osBPUT          :\ &218 - BPutVTINTEQUW
18291 BPB          :\ &21A - GBPBVTINTEQUW osFIND          :\ &21C - FINDVTINTEQUW NullReturn      :\ &21E - FSCVTINTEQUW 
27756 Return      :\ &220 - EVNTVTINTEQUW NullReturn      :\ &222 - UPTVTINTEQUW NullReturn      :\ &224 - NETVTINTEQUW NullRetu
 8224     :\ &226 - VduVTINTEQUW NullReturn      :\ &228 - KEYVTINTEQUW NullReturn      :\ &22A - INSVTINTEQUW NullReturn
 8224   :\ &22C - RemVTINTEQUW NullRe
28274       :\ &22E - CNPVTINTEQUW NullReturn      :\ &230 - IND1VTINTEQUW NullReturn      :\ &232 - IND2VTINTEQUW NullReturn   
14880 \ &234 - IND3VTINTTINT\ Print hex 
25197 ersTINT\ =================TINT.PrHexXYTINTTYA:JSR PrHex:TXATINT.PrHexTINTPHA:LSR A:LSR A:LSR A:LSR ATINTJSR PrNybble:PLATINT.PrNybbleTINT
 8260 #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 _OSWRCH  :\ &FFE3TINT.OSN
 8268 :LDA #&0A:JSR OSWRCH   :\ &FFE7TINT.OSWRCR :LDA #&0D              :\ &FFECTINT._OSWRCHTINT.O
17234 H :JMP (WRCHV)           :\ &FFEETINT.OSWORD :JMP (WORDV)           :\ &FFF1TINT.OSBYTE :
 8272 (BYTEV)           :\ &FFF4TINT.OS_CLI :JMP (CLIV)            :\ &FFF7TINTTINT.NMIV
14880 EQUW NMIHandler       :\ &FF
 8224 NMI VectorTINT.RESETV :EQUW RESET            :\ &FFFC  RESET Vec
 2674 .IRQV   :EQUW IRQHandler       :\ &FFFE  IRQ VectorTINT]:ENDPROCTINT:TINT:TINTDEFPROCasmROMHeaderTINTENDPROCTINT