Idea for small data files

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Idea for small data files

Post by mrtinb »

The ZX81 is missing the feature to save data files.

Can't it be done this way?
  • The program has to have a REM line on line 1 with 790 spaces.
  • Data to be saved is written to screen.
  • PUSH D_FILE
  • PUSH VARS
  • PUSH E_LINE
  • LD D_FILE,16509
  • Copy content of screen to 16509 and forward
  • LD VARS,16509+793
  • LD E_LINE, 16509+793
  • CALL SAVE
  • MOVE 1 REM to 16509 to 16911
  • MOVE space to 16511 to 16509+793
  • POP E_LINE
  • POP VARS
  • POP D_FILE
Last edited by mrtinb on Thu Aug 04, 2016 12:28 pm, edited 1 time in total.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
XavSnap
Posts: 1941
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Idea for small data files

Post by XavSnap »

Just save the D_file (+793) in a DIM A$(793)
And move the Dfile to this variable...
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Idea for small data files

Post by mrtinb »

I'm trying to avoid saving the whole program in the data file. So system variables needs to be modified, so only the data portion is saved. Then the system variables needs to be restored, so the program can continue.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
XavSnap
Posts: 1941
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Idea for small data files

Post by XavSnap »

I'm trying to avoid saving the whole program in the data file.
You had to code a data filler (as a Fast-Load), to get only datas.
So system variables needs to be modified
The DIM variable isn't occurred by a VARS change... except a CLEAR and DIM function.
IF the DIM is set in the program Header.
, so only the data portion is saved. Then the system variables needs to be restored, so the program can continue.
Just set the RAM_top to get room in memory, code a loader to the upper memory (above the RAMTOP), and load the main program.
A new, or a load won't affect this memory part... but, you had to code a program to save the "loader" how will recall the main program.
LOADER->NEW or LOAD->MAIN PRG->NEW or LOAD->SAVER (SAVE LOADER[^RAM-TOP^]).
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1941
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Idea for small data files

Post by XavSnap »

Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Thoughts om ZX81 data files

Post by mrtinb »

Hi :)

When creating data files on the ZX81, you can create your own custom format, but then it will only work with a tape recorder, and other storage devices won't work.

A better approach would be to save in the standard ".P"-format, even though there's some overhead.

Data can be stored in REM line, in screen or in a variable.

Code: Select all

Data file | Data file | Data file
in REM    | in screen | in variable
----------|-----------|------------
System    | System    | System
variables | variables | variables
125 bytes | 125 bytes | 125 bytes
----------|-----------|------------
5 bytes   | 0 bytes   | 0 bytes
+ data    |           |
          |           |
----------|-----------|------------
25 bytes  | 25 bytes  | 25 bytes
with      | with      | with
CHR 118   | CHR 118   | CHR 118
          | + data    |
          | between   |
          | newlines  |
----------|-----------|------------
0 bytes   | 0 bytes   | 3 bytes
          |           | + data
----------|-----------|------------
Data can't| Data can't|
be CHR 118| be 118    |
or CHR 126|           |
without   |           |
making src|           |
unLISTable|           |
----------|-----------|------------
Data can  |           | Data can
be viewed |           | be viewed
and edited|           | with PRINT.
in BASIC  |           |
editor    |           |
Are my assumptions correct?
Last edited by mrtinb on Sat Aug 20, 2016 10:40 am, edited 3 times in total.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Idea for small data files

Post by PokeMon »

In REM lines you can store 118 or 126 chars as well. There might be a problem or wrong display when accessing the listing. But this can be avoided when adding two extra bytes like $76,$76 (=118) or $76,$FF or similar. The first $76 let BASIC lister think it is the end of line, the second byte is an invalid line number and interpreted as end of listing (beginning of Display File assumed). After these two extra bytes you can put as many code and any chars, no restriction to data 118 or 126. See:
viewtopic.php?f=6&t=1064&start=20#p11110

Also keep in mind, that the empty display file consists of 25 NEWLINE chars only on ZX81 with 1k or 2k RAM - whenever RAM is 4k or greater the display file will be automatically expanded to it's full size (24*33+1=793 bytes).

Data file in screen can be of course 118 and is just interpreted as end of line and not fully displayed but you should be careful using other data values with bit 6 set ($40-$7F and $C0-$FF). All data with bit 6 will be not displayed from the ULA but executed as code from the CPU which may give unpredicted results (usually crashing).

I don't think that all data in REM lines can be edited in BASIC. Especially included 118 will result in prematurely end of line but could have other unpredicted results as well. I think you can never edit a string variable in system directly. It would be possible to change parts of it or single chars but that is not easy, you need to know exact position. Anyway it wouldn't be comfortable to use.
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Thoughts om ZX81 data files

Post by mrtinb »

Data file
in variable

Data can
be viewed
with PRINT.
Editing is
possible

(Corrected in original post)
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Thoughts om ZX81 data files

Post by mrtinb »

Data file
in REM

Data can't
be CHR 118
or CHR 126
without
making src
unLISTable

(Corrected in original post)
Last edited by mrtinb on Sat Aug 20, 2016 1:21 pm, edited 1 time in total.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Thoughts om ZX81 data files

Post by mrtinb »

PokeMon wrote:Also keep in mind, that the empty display file consists of 25 NEWLINE chars only on ZX81 with 1k or 2k RAM - whenever RAM is 4k or greater the display file will be automatically expanded to it's full size (24*33+1=793 bytes).

Data file in screen can be of course 118 and is just interpreted as end of line and not fully displayed but you should be careful using other data values with bit 6 set ($40-$7F and $C0-$FF). All data with bit 6 will be not displayed from the ULA but executed as code from the CPU which may give unpredicted results (usually crashing).
But if file is stored compact, the loading will automatically expand it, right?

The problem would be to compact the screen before save. (To make the data files as small as possible. This would be ideal in all cases weather data is stored in REM, screen or variable.)
Last edited by mrtinb on Sat Aug 20, 2016 1:21 pm, edited 1 time in total.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
Post Reply