	.code
	.bank 82
	.org $7826
;-----------------------------------------------------------------------
; Check for memory base 128 presence
; ($7826)
; out: A = $00 if there is a memory base 128.
;          $ff otherwise.
l7826_07:
          PHX     
          CLX     
l7828_07:
          ; Transfer byte #$a8.
          LDA     #$a8
          JSR     l7770_07
          ; Transfer bit 0.
          CLA     
          JSR     l7754_07
          ; Read first nibble and store it in $fe. 
          LDA     $1000
          ASL     A
          ASL     A
          ASL     A
          ASL     A
          STA     <$fe
          ; Transfer bit 1.
          LDA     #$01
          JSR     l7754_07
          ; Read second nibble and store it in $fe.
          LDA     $1000
          AND     #$0f
          ORA     <$fe
          ; There is a memoby base 128 if $fe is equal to #$04.
          CMP     #$04
          BNE     l784f_07
          ; There is a memory base 128. Clear A, restore X and leave. 
          CLA     
          PLX     
          RTS
          ; How are we supposed to get there? 
          BRA     l785c_07
l784f_07:
          ; Make 3 tries before giving up.
          INX     
          CPX     #$03
          BCS     l7858_07
          BRA     l7828_07
          ; How are we supposed to get there? 
          BRA     l785c_07
l7858_07:
          ; There is no memory base 128. 
          LDA     #$ff
          PLX     
          RTS

l785c_07:
          ; Save A and send bit 0.  
          PHA
          CLA     
          JSR     l7754_07
          PLA     
          RTS     
