any idea how to automatically check if Zoomfloppy parallel cable is available?

24 views
Skip to first unread message

Thomas Winkler

unread,
Jul 1, 2021, 11:46:46 AMJul 1
to ZoomFloppy Users
In d64copy sourcecode is a function cbm_identify_xp1541().
If this give TRUE automatically "parallel transfermode" is set.

I would like to see same for Zoomfloppy with parallel cable ...

Of cource we could upload a mini drive code to check parallel cable.
But this need time for upload every time I start an OpenCBM tool.

Is there a way for solving this?
Or do you have an idea to do this best?


best regards
Tommy


Spiro Trikaliotis

unread,
Jul 1, 2021, 1:16:45 PMJul 1
to ZoomFloppy Users
Hello,

* On Thu, Jul 01, 2021 at 08:46:45AM -0700 Thomas Winkler wrote:
> In d64copy sourcecode is a function cbm_identify_xp1541().
> If this give TRUE automatically "parallel transfermode" is set.

This function is part of the shared lib, not of d64copy.

> I would like to see same for Zoomfloppy with parallel cable ...

Just use the function cbm_identify_xp1541() from above.
I have to admit, that the name of this function not very good.

> Of cource we could upload a mini drive code to check parallel cable.
> But this need time for upload every time I start an OpenCBM tool.

The function above does exactly what you are saying, in a limited way
(cf. opencbm/lib/detectxp1541.c):

- check if a 1541 or 1570/1571 is present.
If none is there, abort and return "no"
If yes, get the address of the parallel port ($1801 on 1541, $4001 on
1570/1571)

- then use M-W to set the address $1801/$4001 to $55 (and $1803/$4003,
the DDR, to output), and check if the values arrives on the PC side.

- do the same with $AA.

- if there was a problem with one of the two steps above, abort and
return "no"
(make sure to set the DDR of the floppy, $1803/$4003, to input mode
before aborting!)

- set the DDR to input again and return "yes"


You see, the name of the function is misleading, as it is not XP1541
specific. The reason for this name is as follows: At the time this
function was written, there was no USB device avaible yet.

> Is there a way for solving this?
> Or do you have an idea to do this best?

As said, the function above works "good enough". However, it does not
test very thoroughly (it only tests two bit patterns and only in one
direction), and it is slow (using 5 rounds of M-W commands for a
successfull test, instead of uploading some code and letting the floppy
do it on its own).

The nibtools do a more sophisticated test, but it needs more time to
finish.

The function d64copy_check_auto_transfer_mode() in
opencbm/libd64copy/d64copy.c tries to determine the best transfer mode
if the user did not specify any.

It does the following::

1. parallel if available (via cbm_identify_xp1541())

2. if there is only one drive connected, use s2

3. otherwise, use s1


The test for other connected drives (step #2) takes much time, as it
sends a cbm_identify() (and, thus, a LISTEN) to every device number
from 4 to 31 on the bus.

Regards,
Spiro.

--
Spiro R. Trikaliotis
https://spiro.trikaliotis.net/

Thomas Winkler

unread,
Jul 1, 2021, 4:20:00 PMJul 1
to ZoomFloppy Users
Hi Spiro

Thanks for your answer.

> Just use the function cbm_identify_xp1541() from above.
> I have to admit, that the name of this function not very good.

Oh, this should work already?


I do use this function and D64COPY does also use this function.
But it doesn recognize parallel cable on my ZOOMFLOPPY connected to my Dolphin 1541?

So D64COPY automatically use S2 and not parallel cable.
It uses parallel cable only if I set it with "-t p".

Maybe Dolphin DOS avoid cbm_identify_xp1541() to recognize parallel cable?
Will test it with an 1541 drive and normal DOS ...


best regards

Thomas Winkler

unread,
Jul 1, 2021, 4:29:42 PMJul 1
to ZoomFloppy Users
Okay, you are right!

Function  cbm_identify_xp1541() does recognize parallel cable fine on a normal 1541 drive (standard DOS).

But this does not work on a 1541 drive with Dolphin DOS 2 ...

It also works fine on Speed DOS.
And it finally also works on Professional DOS!

It does NOT work on Turbo Access ...

So it is maybe a problem of Dolphin and Turbo Access ...

Thanks for your help!

best regards
Tommy

Spiro Trikaliotis

unread,
Jul 1, 2021, 4:54:02 PMJul 1
to ZoomFloppy Users
Hello Thommy,

* On Thu, Jul 01, 2021 at 01:29:42PM -0700 Thomas Winkler wrote:

> Function cbm_identify_xp1541() does recognize parallel cable fine on a normal
> 1541 drive (standard DOS).
>
> But this does not work on a 1541 drive with Dolphin DOS 2 ...
>
> It also works fine on Speed DOS.
> And it finally also works on Professional DOS!
>
> It does NOT work on Turbo Access ...
>
> So it is maybe a problem of Dolphin and Turbo Access ...

The function cbm_identify() (file opencbm/lib/detect.c) is not very
good. It seems it cannot recognize Dolphin and Turbo Access.

It relies primarily on the 2 byte at $FF40. In some cases, it also uses
the 2 byte at $FFFE (IRQ vector).

You could try to print out the values of the variable 'magic' at line
103 ("switch(magic)") and send them to me, so we can add the DOS
versions in the recognition.

Thomas Winkler

unread,
Jul 1, 2021, 7:49:41 PMJul 1
to ZoomFloppy Users
Hi Spiro


> You could try to print out the values of the variable 'magic' at line
> 103 ("switch(magic)") and send them to me, so we can add the DOS
> versions in the recognition.

Yes of course, your code give "magic" back encoded as  "footprint" in the deviceString.
Is this okay or does you need the real value of magic?


Strange, OpenCBM does recognize Dolphin DOS, but auto transfer decides to use S2 instead of parallel ...



--- Dolphin DOS 2 ---
[Info] Trying to identify drive type
[Debug] device type: DolphinDOS 1541


--- Turbo Access ---
[Info] Trying to identify drive type
[Debug] device type: *unknown*, footprint=<AH@M>
[Warning] Unknown drive, assuming 1541


--- Turbo Trans ---
[Info] Trying to identify drive type
[Debug] device type: *unknown*, footprint=<AH@M>
[Warning] Unknown drive, assuming 1541


--- Prologic DOS ---
[Info] Trying to identify drive type
[Debug] device type: *unknown*, footprint=<@IDL>
[Warning] Unknown drive, assuming 1541


All other will detected fine, including QuickDOS, SpeedDOS Expert, JIFFY and S-Jiffy.


best regards
Tommy

Spiro Trikaliotis

unread,
Jul 2, 2021, 9:49:44 AMJul 2
to ZoomFloppy Users
Hello Thommy,

* On Thu, Jul 01, 2021 at 04:49:41PM -0700 Thomas Winkler wrote:
> Yes of course, your code give "magic" back encoded as "footprint" in the
> deviceString.
> Is this okay or does you need the real value of magic?

See commit ac7a321e, it should work now. Can you test for me (as I do
not have these ROMs here)?

> Strange, OpenCBM does recognize Dolphin DOS, but auto transfer decides to use
> S2 instead of parallel ...

Note that the parallel port is put to output mode via a M-W to $1803. If
Dolphin restores it back to input, my test will fail.

This is my most likely suspect.

Are the ROMs of Dolphin (and, by the way, of the other ROMs) available
somewhere?

Spiro Trikaliotis

unread,
Jul 2, 2021, 12:05:48 PMJul 2
to ZoomFloppy Users
Hello again,

* On Fri, Jul 02, 2021 at 03:49:42PM +0200 I wrote:

> > Strange, OpenCBM does recognize Dolphin DOS, but auto transfer decides to use
> > S2 instead of parallel ...

is this a Dolphi Dos 1, 2 or 3?

According to this source
https://e4aws.silverdr.com/projects/dolphindos3/ (and others) DD3
changed the hardware w.r.t. the older ones:

RAM: DD1 and DD2 at $8000-$9FFF
DD3 at $6000-$7FFF

Parallelport: DD1 and DD2 with VIA 6522 at $1800 (using $1801 / $1803)
DD3 with PIA 6821 at $5000 - $5FFF (PA at $5000, DDRA at $5001)

Thus, my routines cannot detect a Dolphin DOS 3 parallel cable at the
moment.

Spiro Trikaliotis

unread,
Jul 2, 2021, 12:07:42 PMJul 2
to ZoomFloppy Users
Hello again,

* On Fri, Jul 02, 2021 at 06:05:45PM +0200 I wrote:

> Parallelport: DD1 and DD2 with VIA 6522 at $1800 (using $1801 / $1803)
> DD3 with PIA 6821 at $5000 - $5FFF (PA at $5000, DDRA at $5001)

I forgot, the PIA only has 4 registers. PA and DDRA are both at $5000,
they are selected by bit 2 of CRA ($5001). It's even more complicated
here.

Thus, no DDRA at $5001.

Thomas Winkler

unread,
Jul 2, 2021, 2:42:49 PMJul 2
to ZoomFloppy Users
Hi Spiro

Thanks for the update.
Yes I will download and test it. :)

Okay, you are right, DD3 has an own PIA for parallel cable.
But mine is only a simple DD2 using normal VIA from 1541 as SpeedDOS does.
Maybe DD2 restores values ...

> Are the ROMs of Dolphin (and, by the way, of the other ROMs) available somewhere?


best regards
tommy

Thomas Winkler

unread,
Jul 2, 2021, 2:52:40 PMJul 2
to ZoomFloppy Users
Perfectly, Turbo Acces and Turbo Trans working fine!

[Debug] -- testing cable ...
[Debug] -- use parallel mode ...
[Debug] decided to use transfer mode 4
[Debug] read CBM drive memory and write it into file
[Debug] download CBM drive memory ...
[Info] Trying to identify drive type
[Debug] device type: Turbo Access / Turbo Trans

          :                  :


Prologic DOS is now automatically recognized, very good!

But is uses S2, is same as for DD2:

[Debug] -- testing cable ...
[Debug] decided to use transfer mode 3
[Debug] read CBM drive memory and write it into file
[Debug] download CBM drive memory ...
[Info] Trying to identify drive type
[Debug] device type: Prologic DOS

Spiro Trikaliotis

unread,
Jul 2, 2021, 3:39:12 PMJul 2
to ZoomFloppy Users
Hi again,

* On Fri, Jul 02, 2021 at 11:42:48AM -0700 Thomas Winkler wrote:


> But mine is only a simple DD2 using normal VIA from 1541 as SpeedDOS does.
> Maybe DD2 restores values ...

I took a DD2 ROM and did some tests in VICE. Yes, I know, the emulator
does not have to be accurate. However, I set a watchpoint on store at
$1803 and $1801 in the floppy and had a look.

I could not find any difference in the behaviour of a standard floppy
(1541) and a DD2 equipped 1541.

Both set DDRA ($1803) to $FF (output!) at $FF10 and do not care change
these addresses (or PA, $1801) at all afterwards.

PA, $1801, is read at $E853 to clear the interrupt condition for ATN IN
(CA1). It is also read (with BIT) in newer drives (1541C with
-02 ROM and above) in a patch at $FF50 before going to the bus
processing at $E85B. Obviously, it wants to clear the IRQ flag, too.
This patch is also present in Dolphin DOS.

I cannot see a reason why the cable is not recognized.

Well.... In detectxp1541.c, line 134, there is a usleep with the magic
number 10000 (that is, 10 ms) after executing the M-W command and before
reading the answer. This might not be enough, you could try to increate
this number. For testing purposes, even something ridulous like 1s
might be feasible.

Otherwise, if I were you, I would do the following:

1. Add an output to the line 139 of detectxp1541.c to give the value of
cbm_pp_read(HandleDevice).

2. Replace lines 302 - 306 with a loop, going from 0 to 0xff,
outputting every byte pattern, and do not break if it does not
succeed.

Now, run the detect command and have a look at the values the PC
receives. Do you see any pattern?

Thomas Winkler

unread,
Jul 2, 2021, 4:28:43 PMJul 2
to ZoomFloppy Users
strange ... 


>  1. Add an output to the line 139 of detectxp1541.c to give the value of
>  cbm_pp_read(HandleDevice).

It never reach this point ...

[Debug] -- testing cable ...
enter cbm_identify_xp1541()
1
11
[Debug] decided to use transfer mode 3


It fails to determine the device type?????

But later it can determine the device type??



        if (!CbmDeviceType)
            CbmDeviceType = &localDummyDeviceType;

        if (*CbmDeviceType == cbm_dt_unknown)
        {
            ret = cbm_identify(HandleDevice, DeviceAddress,
                 CbmDeviceType, NULL);
        }
printf("1\n");  

        if (ret)
        {
            /*
             * We could not even determine the device type;
             * we do not dare trying to determine the cable
             * type, as writing into wrong locations can
             * make the drive hang.
             */
         printf("11\n");  
            *CableType = cbm_ct_unknown;
            break;
        }





Spiro Trikaliotis

unread,
Jul 2, 2021, 4:53:53 PMJul 2
to ZoomFloppy Users
Hello,

* On Fri, Jul 02, 2021 at 01:28:43PM -0700 Thomas Winkler wrote:
>
> It fails to determine the device type?????

[...]
> if (*CbmDeviceType == cbm_dt_unknown)
> {
> ret = cbm_identify(HandleDevice, DeviceAddress,
> CbmDeviceType, NULL);

So cbm_identify(9 returns something != 0. Can you please try to find out
which path it takes? I looked at the code, but I cannot figure out what
might be wrong here.

> }
> printf("1\n");
>
> if (ret)
> {
> /*
> * We could not even determine the device type;
> * we do not dare trying to determine the cable
> * type, as writing into wrong locations can
> * make the drive hang.
> */
> printf("11\n");
> *CableType = cbm_ct_unknown;
> break;
> }
>


Thomas Winkler

unread,
Jul 2, 2021, 4:57:13 PMJul 2
to ZoomFloppy Users
Da hat wohl was anderes gesponnen.
Jetzt läuft es brav durch.

Aber das Muster 55 kommt als FF zurück:

D:\Work\cbm\opencbm-03\opencbm\bin>cbmctrl  detect
enter cbm_identify()
call cbm_raw_read()
magic: 10CA
enter cbm_identify_xp1541()
1
12
PIA adress: 1801
enter output_pia()
cbm_pp_read() :: FF - 55
 8: DolphinDOS 1541


Dabei habe ich den Wert schon erhöht auf 100.000

        arch_usleep(100000);

Thomas Winkler

unread,
Jul 2, 2021, 5:00:09 PMJul 2
to ZoomFloppy Users
Ich denke ich werde einfach einen kleinen Code für 0x500 (Buffer #2) schreiben, der auf IEC_CLK achtet und $55 oder $AA ausgibt.

Und wenn ATN kommt sich automatisch beendet ...

Thomas Winkler

unread,
Jul 3, 2021, 5:27:40 AMJul 3
to ZoomFloppy Users
Also es funktioniert für: 1541 + parallel Kabel am VIA $180x
Läuft mit allen Betriebssystemen.

Ich teste es noch genauer und sende den Code dann.


Ich hab auch den Code für die 1571, aber den kann ich halt leider nicht testen.
Deshalb lasse ich den 1571 Teil als Remark und lasse mal den alten Code laufen, der ja sicher funktioniert.

Für die anderen Dinge, wo parallel Kabel an einem PIA liegt an verschiedenen Adressen ...

Meine Idee dazu:
- Muster 55/AA für normale Parallel Lösung am VIA $1800
- Muster 54/AB für für PIA Lösung

Man gibt einfach beides aus.
Am PC kommt ein Muster an.
Am Muster erkennt man dann, wie das parallel Kabel angeschlossen ist.

Blöde Idee oder könnte man das so machen??

Thomas Winkler

unread,
Jul 3, 2021, 5:30:54 AMJul 3
to ZoomFloppy Users
Der Drive Code sieht momentan so aus:

        sei
lda #PP_DDR_OUT
sta PP_DDR

ldx #$55
ldy #$AA

@l0
        tya
@l1
sta PP_DATA

lda IEC_PORT
        bmi end
        and #IEC_PORT_CLK_IN
bne @l0

txa
bne @l1

end
lda #PP_DDR_IN
sta PP_DDR
cli
rts


Mir will es nicht gelingen es kürzer zu machen.
Und es fällt mir auch kein Problem auf, das damit sein könnte.

Aber ich bin offen für Verbesserungs Vorschläge ...

Thomas Winkler

unread,
Jul 3, 2021, 1:15:45 PMJul 3
to ZoomFloppy Users
Hi Spiro

Cannot upload a ZIP file here.
It is not allowed ...

Have send it to:  www-202004 AT spiro.trikaliotis.net

1570/1571 code should work also, but I cannot test it currently.
But if it fails old code should work ...


best regards
Tommy
Reply all
Reply to author
Forward
0 new messages