Re: [cc65] dio density detection

From: Christian Groessler <chris1groessler.org>
Date: 2005-02-16 22:16:15
Hi,

On Tue, 15 Feb 2005, Shawn Jefferson wrote:

> Can we/you put in a short routine to detect SD or DD
> during dio_open?

Good idea.

> I've been doing a little research and it should be a
> matter of:
>
> 1. Sending $53 (status) to the disk drive with the
> buffer address set at $2EA.
>
> 2. Test $2EA: Bit 7=ED (not useful for us), Bit 5 on
> indicates DD (according to information I have.)
>
> 3. Set the density/sector size in the dio structure.

Does the buffer need to be set to $2EA? I know of
http://www2.asw.cz/~kubecj/asio.htm as SIO reference and
there is nothing mentioned about a specific buffer address
for the $53 function.

I get the same results regardless whether I set the buffer
to $2EA or something else.

But it doesn't seem to work for me on a real machine :-(

Using SpartaDOS and the atari800 emulator I get $98 for
the drive status byte. This is for a 130k atr image and seems
to be correct (this also means "motor on" and "readonly", but
this is not relevant here).

On a real Atari with SpartaDOS, both with 1050 and xf551
(a DD disk inside the xf551), the request returns without
error but doesn't touch the output buffer... ??

I've attached my test program to check for yourself.

Has anyone (I mostly mean other Atari guys :-) have an idea
why it doesn't work on the real Atari? Maybe I need to set
some more fields in the DCB structure?

regards,
chris


-----------------------------
/* $Id$
 *
 * detect disk density / test
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <atari.h>

static void (*sio)(void) = (void (*)(void))0xe459;

unsigned char *DVSTAT = (unsigned char *)0x2ea;

char buf[5];
char dstr[][4] = {
    "D1:","D2:","D3:","D4:"
};

int main(int argc,char **argv)
{
    char *dnumstr;
    int drvnum;

    //char test[4];
    //DVSTAT = test;

    memset(&DCB, 0, sizeof(DCB));

    if (argc > 1) {
        dnumstr = *(argv+1);
    }
    else {
        printf("Enter drive num (0-D1,1-D2,...): ");
        dnumstr = fgets(buf, 5, stdin);
        printf("\n");
    }
    drvnum = atoi(dnumstr);
    if (drvnum > 3) drvnum = 0;

    printf("Using %s...\n", dstr[drvnum]);

    *DVSTAT = 0xaa;  /* does the buffer get changed? */

    DCB.command = 0x53;       /* status */
    DCB.device = 0x31;        /* disk drive */
    DCB.unit = drvnum + 1;    /* sub unit */
    DCB.timeout = 15;         /* from DOS source */
    DCB.buffer = DVSTAT;
    DCB.xfersize = 4;

    sio();
    printf("SIO returned %d\n", DCB.status);

    if (DCB.status == 1)
        printf("device status: %u ($%02X)\n", *DVSTAT, *DVSTAT);

    if (_dos_type != 1) cgetc();
    return(0);
}
/* Local Variables: */
/* c-file-style: "cpg" */
/* c-basic-offset: 4 */
/* End: */
-----------------------------

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Feb 16 22:15:41 2005

This archive was generated by hypermail 2.1.8 : 2005-02-16 22:15:52 CET