Load / save data (e.g. save game) from within machine code?

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: Load / save data (e.g. save game) from within machine code?

Post by sirmorris »

You need a later version, I think. Hardware menu, enable ZXPand option. Rampack 32k, enable RAM at 8K. You should have a folder MMC_CARD, which is where your files live.

C
Lardo Boffin
Posts: 2176
Joined: Sat Nov 26, 2016 2:42 am

Re: Load / save data (e.g. save game) from within machine code?

Post by Lardo Boffin »

sirmorris wrote:You need a later version, I think. Hardware menu, enable ZXPand option. Rampack 32k, enable RAM at 8K. You should have a folder MMC_CARD, which is where your files live.

C
I have saving and loading basically working now thanks but I am getting an error in EightyOne - if the file already exists the program instantly crashes out. If I delete the save file prior to running EightyOne it is fine - it creates the save file as expected.

I have basically used your code as is but changed the file name declaration as below: -

saveName
DEFB _GT,_S,_A,_V,_E,_DT,_S,_A,_V,_SC,_1,_6,_6,_3,_9,_CM,_7,_9,$9E

Not quite as easy to do in TASM...

Do you happen to know if the save file overwriting (if file name is prefixed with >) behaviour extends to EightyOne? This obviously means EightyOne physically overwriting a file under Windows.

Thanks,
Lardo
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: Load / save data (e.g. save game) from within machine code?

Post by sirmorris »

It does indeed apply.
Add '>' to the start of the name and you'll be golden. You're using an up-to-date EO yes? V1.2.
Lardo Boffin
Posts: 2176
Joined: Sat Nov 26, 2016 2:42 am

Re: Load / save data (e.g. save game) from within machine code?

Post by Lardo Boffin »

sirmorris wrote:It does indeed apply.
Add '>' to the start of the name and you'll be golden. You're using an up-to-date EO yes? V1.2.
Thanks.

I downloaded the version from your link above so should be the correct version. When it boots in ZXPand mode it comes up with version 2.3 at the top of the screen.

The save name is defined by:-

DEFB _GT,_S,_A,_V,_E,_DT,_S,_A,_V,_SC,_1,_6,_6,_3,_9,_CM,_7,_9,$9E

Where _GT is the code for '>' (_DT is dot etc.). I guess I must have gone wrong somewhere else or it could be the paranoia settings of my PC?

Does the file name need to be enclosed in quotes?
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: Load / save data (e.g. save game) from within machine code?

Post by sirmorris »

No quotes. Should work. EO's not creating the files in read-only mode is it? :( :?
Lardo Boffin
Posts: 2176
Joined: Sat Nov 26, 2016 2:42 am

Re: Load / save data (e.g. save game) from within machine code?

Post by Lardo Boffin »

sirmorris wrote:No quotes. Should work. EO's not creating the files in read-only mode is it? :( :?
I have had a look at the file that was created and it has the windows property of 'Read-only' set to yes so it is creating files read only from code.

I have double checked the value saved to DE and it is the address of the character > so this is at the start of the file name.

Do you happen to have a working .p that saves using this method you can post so that I can prove whether it is my code that is wrong please?

I tried saving a snapshot from the menu and that is not read only.

Thanks as ever!
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
Lardo Boffin
Posts: 2176
Joined: Sat Nov 26, 2016 2:42 am

Re: Load / save data (e.g. save game) from within machine code?

Post by Lardo Boffin »

sirmorris wrote:No quotes. Should work. EO's not creating the files in read-only mode is it? :( :?
I tried using just the save command:-

SAVE ">test;0;4000"

and this produced a read only file so I guess my code is ok.

Snapshots save without the read-only flag set so it may be a bug with EightyOne?

I'm running v1.2.

Lardo
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: Load / save data (e.g. save game) from within machine code?

Post by sirmorris »

Almost certainly an EO bug. I will have a look-see.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: Load / save data (e.g. save game) from within machine code?

Post by sirmorris »

I can't reproduce this - but looking at the code I have here reveals a comment:

Code: Select all

// CR  fix the fstat bug so that the read-only-forces-overlay-off works,
   // use stat(name,...) instead of fstat(handle,...)
So I suspect that this particular booboo is fixed in the source that I have. There was talk of an update, I should get on to that.
Lardo Boffin
Posts: 2176
Joined: Sat Nov 26, 2016 2:42 am

Re: Load / save data (e.g. save game) from within machine code?

Post by Lardo Boffin »

A fix would be cool thanks but in the meantime I have just had to remember to remove the read only tick.

Not done much recently though - bad case of man-flu. So bad in fact I have called it man-thrax. :(

Lardo
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
Post Reply