[Coco] Re: MPI Detection in BASIC

Rodney V Hamilton Rodney_Hamilton at GBRonline.com
Tue Mar 16 12:50:51 EST 2004


In article <36B5B964-774D-11D8-B6C6-0003939F08E6 at boisypitre.com>, 
boisy at boisypitre.com says...
>I've come up with what I think is a foolproof way to detect a Multi-Pak 
>in a Color Computer, and would like others to try it on their systems.
>
>10 POKE &HFF7F,PEEK(&HFF7F) AND &H33
>20 IF PEEK(&HFF7F) > &H33 THEN PRINT "NO MPI" ELSE PRINT "MPI"
>
>The idea here is that when a CoCo doesn't have a MPI present, the value 
>at &HFF7F always seems to be 126 or higher... since bits 7-6 and 3-2 
>are ignored, then IF there is an MPI, we safely keep the values at bits 
>5-4 and 1-0, while turning off the others when we POKE.  If the read 
>comes back greater than &H33 (slot 4) then it's likely that there is no 
>MPI.
>
>I would be curious if this could be tried on a CoCo 1 and 2, as I don't 
>have an MPI for mine.
>
>Boisy

It works fine on my CoCo3 and CoCo2 with and without MPIs, Boisy.

I think it would be even better if you inverted bits 2-3 and 6-7 and
test for equality instead.  The effect would be the same but with an
even smaller chance for error.  Something like this:

10 X=&HFF7F:A=PEEK(X):A=&HFF-(&HCC AND A)+(&H33 AND A)
20 POKE X,A:IF PEEK(X)<>A THEN PRINT"NO MPI" ELSE PRINT"MPI"

The logic statement in line 10 is just a simulated EOR bit flip.
In ASM, this would be:

 LDX #$FF7F
 LDA ,X
 EORA #$CC
 STA ,X
 CMPA ,X
 BNE NO_MPI

I made a quick OS9 module based on this that also works fine.
If buss capacitance becomes an issue, add an alternate access
before the CMPA (eg: 'TST 1,X') to fix.  I hope this helps.

Rodney





More information about the Coco mailing list