; Console I/O for Tube Flex - 6809 Flex running in an Acorn Tube environment ; ========================================================================== ; ; v0.00 10-Feb-2015 JGH: Initial version ; Console I/O done, Spooler timer routine not yet done. ; Host error reports and drops to Warm Start. ; Pending Escape never handled. ; v0.01 17-Feb-2015 JGH: Escape handled by CONIN. Was also using JSR BIOS ; instead of JSR [BIOS]. Sketched out RTC reading, but ; not enough space. ; v0.02 18-Jan-2017 JGH: Escape handler preserves X. ; v0.03 19-Jan-2017 JGH: CONINIT sets Escape to ASCII, CONIN/OUT vectors directly to BIOS ; 6809 BIOS entry block ; --------------------- COLD: EQU $F800 ; cold start WARM: EQU $F802 ; warm start INCH: EQU $F804 ; char input INCHE: EQU $F806 ; char input with echo INCHECK: EQU $F808 ; test for char input OUTCH: EQU $F80A ; char output PDATA: EQU $F80C ; output string until $04 PCRLF: EQU $F80E ; output CR/LF PSTRING: EQU $F810 ; output CR/LF then string until $04 LRA: EQU $F812 ; Load Real Address MONITOR: EQU $F814 ; return to monitor - for FLEX compatibility ; FLEX addresses ; ------------ INPBUF: EQU $C080 ; Line input buffer PROCESS: EQU $C700 ; Spooler process switcher GETDATE: EQU $CA02 ; Prompt user to enter date ; Tube MOS addresses ; ------------------ INITERR: EQU $FFBF ; Initialise error handlers PRSTRNG: EQU $FFC5 ; Print 0-terminated string at X OSWORD: EQU $FFF1 OSBYTE: EQU $FFF4 ORG $D370 ; ------------------------ ; Pass on directly to BIOS ; ------------------------ CONIN: JMP [INCH] ; Call BIOS CONECHO: JMP [INCHE] ; Read input character with echo CONCHK: JMP [INCHECK] ; Pass on to BIOS CONOUT: JMP [OUTCH] ; Pass directly to BIOS CONSPL: JMP PROCESS ; Pass straight on to Spooler process switcher ; -------------------------------- ; CONINIT - Console initialisation ; -------------------------------- CONINIT: JSR INITERR ; Initialise MOS error handlers ; Returns X=BRKV, Y=ERRFLG LDD #CONERR STD ,X ; Set [BRKV] to our error handler ; STY CONESC-2 ; Store address of ESCFLG ; LDD GETDATE ; Get Flex date prompt address ; CMPD GETRTC4-2 ; Compare to current fall-through address ; BEQ CONINIT2 ; Already set, don't overwrite it ; STD GETRTC4-2 ;CONINIT2: ; LDD #GETRTC ; STD GETDATE ; Redirect GETDATE to read RTC ; LDD #$7F15 ; TTYBS =$7F - DEL LDD #$0815 ; TTYBS =$08 - BS STD $CC00 ; TTYDEL=$15 - Ctrl-U STA $CC07 ; TTYBE =$08 - BS,SPC,BS LDY #0000 ; TTYWID=$00 STY $CC04 ; TTYNUL=$00 LDX #1 ; Y=0 from above LDA #229 JMP OSBYTE ; Set Escape to ASCII ; No space for this - move to DiskIO? ;; ---------------------------------- ;; GETRTC - Read RTC to get time/date ;; ---------------------------------- ;; Set $CC0E=month, $CC0F=day, $CC10=year-1900 ;GETRTC: LEAS -8,S ; Allocate 8 bytes on stack ; TFR S,X ; X=>control block on stack ; LDD #$0100 ; $01=Read RTC as BCD ; STD ,X ; Also preloads month=0 ; LDA #$0E ; JSR OSWORD ; Read RTC ;; Returns: ;; 0,X=year ($00-$99) ;; 1,X=month ($01-$12) ;; 2,X=date ($01-$31) ; LDA 1,X ; Check returned month ; BEQ GETRTC3 ; Still zero, no RTC ; JSR BCDtoBIN ; STA $CC0E ; Store month ; LDA 2,X ; JSR BCDtoBIN ; STA $CC0F ; Store day ; LDA ,X ; JSR BCDtoBIN ; CMPA #80 ; BCC GETRTC2 ; year>79 -> 1980+ ; ADDA #100 ; year<80 -> 2000+ ;GETRTC2: STA $CC10 ; Store year-1900 ; LEAS 8,S ; Drop block from stack ; RTS ;GETRTC3: LEAS 8,S ; Drop block from stack ; JMP >$FFFF ; Pass on to prompt user ;GETRTC4: ; ;BCDtoBIN: ; RTS ; ------------------ ; Handle host errors ; ------------------ CONERR: JSR PCRLF LDA ,X+ ; Step past error number JSR PRSTRNG ; Print error string JSR PCRLF JMP WARM ; Do a Warm Start ; --------------------------- ; TINT - Timer initialisation ; --------------------------- CONTINIT: RTS ; ---------------------------------------------- ; CONTON - Turn timer on - use 20ms VSync event? ; ---------------------------------------------- CONTON: RTS ; ------------------------ ; CONTOFF - Turn timer off ; ------------------------ CONTOFF: RTS ; ---------------- ; Interupt vectors ; ---------------- CONSWI: FDB $0000 ; Currently unused CONIRQ: FDB $0000 ; Currently unused ; Console entry block ; ------------------- RMB $D3E5-$ FDB CONIN ; $D3E5 - Console character input without echo IHNDLR: FDB CONSPL ; $D3E7 - Spooler IRQ handler SWIVEC: FDB CONSWI ; $D3E9 - SWI3 vector address IRQVEC: FDB CONIRQ ; $D3EB - IRQ vector address TMOFF: FDB CONTOFF ; $D3ED - Timer Off TMON: FDB CONTON ; $D3EF - Timer On TMINT: FDB CONTINIT ; $D3F1 - Timer initialisation MONITR: FDB MONITOR ; $D3F3 - Quit process - return to monitor TINIT: FDB CONINIT ; $D3F5 - Console initialisation STAT: FDB CONCHK ; $D3F7 - Check input status OUTPUT: FDB CONOUT ; $D3F9 - Console character output INPUT: FDB CONECHO ; $D3FB - Console character input with echo ; RTS ; FDB $CA00 ; Is this significant?