Detecting the TUBE

From Retrosoftware

(Difference between revisions)
Jump to: navigation, search
(Edit by J.G.Harston)
Current revision (15:49, 25 August 2009) (edit) (undo)
 
Line 36: Line 36:
== Edit by J.G.Harston ==
== Edit by J.G.Harston ==
-
The proper way is to detect which <i>side</i> of the Tube you are executing on. If you're executing in the I/O processor it should be irrelavant whether there's a Tube active or not.
+
The proper way is to detect which <i>side</i> of the Tube you are executing on. If you're executing in the I/O processor it's irrelavant whether there's a Tube active or not.
-
<code>
+
 
-
LDA #130
+
<code > LDA #130:JSR OSBYTE :\ Read address high word
-
JSR OSBYTE :\ Read address high word
+
INX:BNE LangProcessor :\ Not &xxFF
-
INX:BNE LangProcessor :\ Not &xxFF
+
INY:BNE LangProcessor :\ Not &FFxx
-
INY:BNE LangProcessor :\ Not &FFxx
+
\ &FFFFxxxx, executing in I/O processor
-
\ &FFFFxxxx, executing in I/O processor
+
</code>
</code>

Current revision

Detecting the TUBE

Not all software routines are compatible with the TUBE (e.g. the 6502 co-processor) in use so being able to check for this can be handy.

The code below will test for the TUBE and if detected notify the user and end the program. If the TUBE is not detected then the program will branch to the label 'routine' where your own code can go.

The Code

  10 DIM mc% 100
  20 osasci=&FFE3
  30 osbyte=&FFF4
  40 FOR opt%=0 TO 2 STEP 2
  50 P%=mc%
  60[          OPT opt%
  70           LDA #&EA
  80           LDX #&00
  90           LDY #&FF
 100           JSR osbyte
 110           CPX #&00
 120           BEQ routine
 130           LDY #&00
 140.loop      LDA message,Y
 150           JSR osasci
 160           INY
 170           CMP #&0D
 180           BNE loop
 190           RTS
 200.message   EQUS "TUBE detected!"
 210           EQUB &0D
 220.routine   \ rest of program here
 230           RTS
 240]
 250 NEXT
 260 CALL mc%

Edit by J.G.Harston

The proper way is to detect which side of the Tube you are executing on. If you're executing in the I/O processor it's irrelavant whether there's a Tube active or not.

 LDA #130:JSR OSBYTE   :\ Read address high word
 INX:BNE LangProcessor :\ Not &xxFF
 INY:BNE LangProcessor :\ Not &FFxx
 \ &FFFFxxxx, executing in I/O processor