Commodore 128 Alive!

Commodore 128 => 128 programmers => Assembly => Topic started by: MIRKOSOFT on February 22, 2010, 12:04 PM

Title: How to detect that diskette is not in drive?
Post by: MIRKOSOFT on February 22, 2010, 12:04 PM
Hi!

I want to ask how to check that diskette is not in drive in assembler.

Thanks for every help.

Miro
Title: Re: How to detect that diskette is not in drive?
Post by: Hydrophilic on February 22, 2010, 03:51 PM
The easiest way, I think, is to issue disk command "I0:" (initialize drive 0).  If no disk is present, or if disk is not CBM format (maybe Apple or foreign CP/M format), you will usually get error: 21, READ ERROR, 18, 00.

Error 21 means no sync mark was detected.  Because Apple and foreign CP/M disks (Kaypro, Osborne, etc.) do not write GCR sync marks, you will likely get this error if such a disk is inserted.  Another error you sometimes get is 74, DRIVE NOT READY.

I don't know why sometimes you get one error or the other.  Best to check for both error 21 and error 74.  I hope this helps!

Edit
If disk is Commodore CP/M format, then you will get no error.  Be careful!
/Edit
Title: Re: How to detect that diskette is not in drive?
Post by: MIRKOSOFT on February 22, 2010, 04:22 PM
Hi!
Yes, I tried this.
But don't understand why error channel reading returns OK also when is disk not in drive...
Can you explain me this?
Thanks
Miro
Title: Re: How to detect that diskette is not in drive?
Post by: airship on February 23, 2010, 04:47 AM
You have to try to access the disk first before you'll get the error.
Title: Re: How to detect that diskette is not in drive?
Post by: cbmguy on February 23, 2010, 03:43 PM
Is this what you're looking for?:

print#15,"m-r";chr$(0)chr$(28)chr$(1):get#15,a$:a = asc(a$)and16

if a = 16 there is a disk in the drive.  if a is clear, then there is no disk in the drive

I did this years ago with a 1541.   I used to check for a disk in the drive and then wait until one was present.  One thing about this is that you cannot tell if the drive door is shut or not...  still not 100% fool proof.
Title: Re: How to detect that diskette is not in drive?
Post by: BigDumbDinosaur on February 24, 2010, 03:04 PM
Initializing is the most foolproof way to determine if a readable disk is present.
EhPortal 1.34 © 2025, WebDev