Jump to content
Harry Potter

Accessing the drive?

Recommended Posts

Hi!  I am working on a memory enhancement for the 8-bit Atari and cc65 and need to load a file into the extra memory (vocab. check req.!), and it's not working.  I suspect an error in the drive access string.  How do I read a file from the drive?

Share this post


Link to post
Share on other sites

more detail needed
command line to build
are you just running the exe in a emulator or making an ATR image with a DOS upon it and adding/running the file from that?

Share this post


Link to post
Share on other sites

have you tried accessing the file as "D:" or "D1:" rather than "D0:"?

 

Also, what is the spec for this call?

aux_memcpyto (j, &auxbufx, i);

as both i and j are unsigned (integers)?

Edited by Wrathchild

Share this post


Link to post
Share on other sites
3 hours ago, Harry Potter said:

BTW, the error is #132.

132 is "BAD CIO COMMAND", your program is invoking the CIOV with an invalid I/O command code stored in the control block.

Share this post


Link to post
Share on other sites
12 hours ago, Harry Potter said:

Thank you.  aux_memcpyto() copies a block of memory from main memory to the extra memory and has the same prototype as memcpy().

memcpy is called :- memcpy(*dest, *src, size); so if your aux_memcpyto uses the same prototype, it's passing the wrong

parameters, in your call, memcpy (j, auxbufx, i); you are passing an integer for the *dest

 

I tested the file handling using "D:TEST.TXT" which I had created and printed out the read in data and it works fine.

 

I think the problem is the memcpy function

Share this post


Link to post
Share on other sites

The error must be in the crt0.s file, as, when I add a code "while (1);" to the beginning of the main() function, the problem still occurs.  :(  BTW, I'm wondering if the problem is in the config file or the block headers.

Share this post


Link to post
Share on other sites

This is what I used to test:-

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


// #include "memxtatari.h"
unsigned char loadauxmem (char* f);

//#pragma bss-name (push, "XBUFBSS")
static unsigned char auxbufx [128];
char tempbufffortest[128];

void main(void)
{
    char name[40]={"D:TEMP.TXT"};

    loadauxmem(name);
}
unsigned char loadauxmem (char* f)
{
    unsigned i=0, j=0;

    FILE* fi=fopen (f, "rb");
    if (!fi) return 1;
    while (!feof(fi)) {
        i=fread (auxbufx, 1, 128, fi);
        if (i==-1) {fclose (fi); return 1;}
        memcpy(tempbufffortest,auxbufx,i);
        printf("%s\n",tempbufffortest);
        j+=i;
    } fclose (fi);
    return 0;

}

Share this post


Link to post
Share on other sites

let's assume that's ok as he's told us that this is part of the banking so internally I would think the offset is being split to make a bank # and then offset, e.g. into $4000

Share this post


Link to post
Share on other sites
21 minutes ago, danwinslow said:
aux_memcpyto (j, &auxbufx, i);

Aren't you taking an address of an address here?

That will just waste some processing time, the call is just wrong as I explained earlier.

 

When compiling you should be getting this error "Warning: Converting integer to pointer without a cast"

unless your prototype for aux_memcpyto is defined incorrectly

Edited by TGB1718

Share this post


Link to post
Share on other sites
1 hour ago, Wrathchild said:

let's assume that's ok as he's told us that this is part of the banking so internally I would think the offset is being split to make a bank # and then offset, e.g. into $4000

Well I guess. It's been a while and I can't remember if &arrayname gives you the array start anyway, or it gives you an address formed from the contents of the first 2 bytes at arrayname. If you get a ** back he would be overwriting page 0 probably. Anyways, I'm out.

Share this post


Link to post
Share on other sites

Again, auxbufx is an unsigned char array.  j starts at 0 but refers to aux memory.  The problem has to be in the crt0.s file, as, when I put "while (1);" at the beginning of the main() function, the problem still occurs.

Share this post


Link to post
Share on other sites

If as @drac030 says that this is a bad CIO call, then the problem must be in the screen open call.

 

From the code, I cant see what the code for findfreeiocb does, I assume it looks for a free IOCB.

 

also scrdev , how is this formatted, there must be a $9B after the name i.e. scrdev .BYTE "E:",$9B

if your passing in a "C" string as the device, it's going to have a '0' at the end, so will cause problems

Share this post


Link to post
Share on other sites

please just generate a the test xex and lst or label file with it, it'll be far easier to debug.

the only real activity before main is called is the calling of entries in the constructor table but in theory you shouldn't have anything there.

Share this post


Link to post
Share on other sites

I got it to ork a little better: now it displays nothing but a cursor before crashing.  And sanny: I want to add initialized code and data to the XMEM and other low-memory areas as well.

Share this post


Link to post
Share on other sites

Check if the format of your EXE file is ok.

 

And, if you would post a complete project with source code and how you are building it, please might be better able to help. Giving always just pieces of information leaves to much of guesswork to the others.

Share this post


Link to post
Share on other sites
50 minutes ago, Harry Potter said:

And sanny: I want to add initialized code and data to the XMEM and other low-memory areas as well.

Huh?

Loading a file to this area is not having initialized code and data in this area. I guess you want to load it automatically as part of the EXE file loading.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...