        TTL     > TOS05 - OSByte

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

tim_byte ROUT

        PHA                     ; OSByte preserves A (except on Turbo)

        CMPIM   &82             ; Standard interceptions
        BEQ     byte_82
        CMPIM   &83
        BEQ     byte_83
        CMPIM   &84
        BEQ     byte_84

        CMPIM   &85             ; Tweaks as we have no IOProc
        BEQ     byte_85
        CMPIM   &8E
        BEQ     byte_8E

        CMPIM   163             ; Claim View fx163's even on Tube versions
        BNE     dobyte
        CPXIM   254             ; Don't claim all; we use 163,243,n for EMU
        BCC     dobyte          ; Just 254 and 255
        PLA                     ; Restore A
        RTS

dobyte  =       sv_byte
        PLA                     ; Restore A
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Read machine high order address

byte_82
        LDXIM   0
        LDYIM   0
        PLA                     ; Restore A
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Read OSHWM

byte_83 ROUT

        PLA                     ; Restore (or skip) stacked A

        LDX     turflag
        BEQ     #FT50

        LDAIM   1
        LDXIM   0
        LDYIM   0
        RTS

50      LDXIM   0
        LDY     pagevalue
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Read HIMEM

byte_84 ROUT

        PLA                     ; Restore (or skip) stacked A

        LDX     turflag
        BEQ     #FT50

        LDAIM   4
        LDXIM   0
        LDYIM   0
        RTS

50      LDX     himemptr
        LDY     himemptr+1
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Read what HIMEM will be if given mode is set

byte_85 ROUT

        LDXIM   :LSB: &8000
        LDYIM   :MSB: &8000
        PLA                     ; Restore A
        RTS

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Start ROM X as language

byte_8E ROUT

        JMP     language_star   ; As useful as I can be on de Tube

        LNK     TOS06
