Harry Potter Posted November 24, 2023 Share Posted November 24, 2023 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. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 24, 2023 Share Posted November 24, 2023 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. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted November 24, 2023 Author Share Posted November 24, 2023 When I add code to print out the filename fed to the cio_open() function, everything is in caps. I can use the standard functions to open and write to the files. I'll look into my docs for open() and write() now. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted November 24, 2023 Author Share Posted November 24, 2023 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. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted November 24, 2023 Author Share Posted November 24, 2023 I forgot to say that, upon startup, the stub loaded into low memory seems to load properly. I'm using AtaDisk65's cio_load2() function to load the stub, and it in turn should be using cio_open() to open the stub. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted November 24, 2023 Author Share Posted November 24, 2023 I just tried AtaDisk65's cio_save2() function, and it still doesn't work. Converting the filename string to a char* doesn't work, either. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 24, 2023 Share Posted November 24, 2023 21 minutes ago, Harry Potter said: f=fopen (gamefilename, "rb"); You are opening the file for read ??? then you try to write to it. fwrite (&Player, sizeof (Player), 1, f); fwrite (&CRoom, 1, 1, f); Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted November 24, 2023 Author Share Posted November 24, 2023 You're right, and I'm sorry. I'll try it now. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted November 24, 2023 Author Share Posted November 24, 2023 I fixed it and got the same result. It seems to happen while opening the file, but I see nothing wrong with the filename. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted November 24, 2023 Author Share Posted November 24, 2023 I found the problem: removing the & before the filename in cio_open() worked, but now, I'm getting an error message, error code 130. It was also displaying garbage after the #, but I fixed that. I'll try a different mode code in cio_open(). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.