Jump to content
IGNORED

AdvSkelVic65/Atari disk: save game locks up emulator


Recommended Posts

Hi!  I've been updating AdvSkelVic65 with save game support, and the CBM versions seem to be working properly but not the Atari disk version.  :(  The program locks up between getting the game letter and opening the file.  The erroneous code follows:

[code]

char gamefilename[]="D1:SAVEADVA.ADV";
static const unsigned char gamefilenumpos=10;
static unsigned char __fastcall__ GetSaveLetter (unsigned char issave)
{
    printtok ("Insert game disk.\n"
        "Type in letter of the game to ");
    printtokcr (issave?"save":"load");
    i=getkey();
    if (i<'a' || i>='z'+1) {gamefilename[gamefilenumpos]=i|0x60; return 0;}
    return 1;
}

void vSave (void)
{
    if (!GetSaveLetter(1)) return;
    // s=c;
    printu(cio_open (3, &gamefilename, 4));
    // cbm_open (CBM_WRITE);
    cio_write (3, &Player, sizeof (Player));
    cio_write (3, &CRoom, 1);
    cio_close (3);
}

void vLoad (void)
{
    if (!GetSaveLetter(0)) return;
    // s=c;
    if (cio_open (4, &gamefilename, 8)) goto err;
    // cbm_open (CBM_WRITE);
    if (cio_read (4, &Player, sizeof (Player))) goto err;
    if (cio_read (4, &CRoom, 1)) goto err;
    if (cio_close (4)) goto err;
    printtokcr ("Loading succcessful!"); vLook2(); return;
err:
    printtokcr ("Error during load: player info might be corrupt!");

}[/code]I'm using cc65 and my AtaDisk65 library.

Link to comment
Share on other sites

gamefilename is a char pointer, so you don't need address of &gamefilename, shouldn't be the issue, but just thought I would let you know.

 

Have no idea what your functions expect, so I think help on this will be limited.

 

As a first step, I would change the I/O functions to the built in ones and see if you still have the issue.

This line seems to put a lowercase letter into the filename:- if (i<'a' || i>='z'+1) {gamefilename[gamefilenumpos]=i|0x60

 

Again as I don't know what your functions are doing, this may cause an issue.

Link to comment
Share on other sites

I tried fopen() and fwrite() and got the same result.  :(  Following is the vew save code:

[code]

void vSave (void)
{
    FILE* f;
    if (!GetSaveLetter(1)) return;
//printc ('.');
printscr (&gamefilename);
    // s=c;
    //printu(cio_open (3, &gamefilename, 4));
    f=fopen (gamefilename, "rb");
    fwrite (&Player, sizeof (Player), 1, f);
    fwrite (&CRoom, 1, 1, f);
    fclose (f);
    // cbm_open (CBM_WRITE);
    // cio_write (3, &Player, sizeof (Player));
    // cio_write (3, &CRoom, 1);
    // cio_close (3);
}[/code]

Maybe it's the DOS I'm using.  Should I post the disk image?

 

BTW, if you want, I can post a link to AtaDisk65 so you can try it out.

Link to comment
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...