Detecting the TUBE

From Retrosoftware

(Difference between revisions)
Jump to: navigation, search
m (Detecting the TUBE - Changed the code formatting to monospaced type)
m (Detecting the TUBE - Changed 'EQUB 13' to 'EQUB &0D' for consistency)
Line 27: Line 27:
190 RTS
190 RTS
200.message EQUS "TUBE detected!"
200.message EQUS "TUBE detected!"
-
210 EQUB 13
+
210 EQUB &0D
220.routine \ rest of program here
220.routine \ rest of program here
230 RTS
230 RTS

Revision as of 19:31, 25 July 2008

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%