Easy load and save with ToddyForth 1.4

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

Easy load and save with ToddyForth 1.4

Post by mrtinb »

I've made som words for ToddyForth 1.4, to easily load and save 10 pages for the new editor. So this saves and load 769 * 10 bytes with simple commands.

A new word needed is PAD$+ which adds strings with the pad.

Code: Select all

( PAD$+                     #8 )
: PAD$+ ( N_STARTPOS           
      STR_STRING2ADD N_STRLEN --
      N_ENDPOS )
  ROT DUP >R PAD +
  SWAP DUP R> + >R
  CMOVE
  R> ;
If you want to save the 10 pages to NEWPRG.BLK and have it replace the old file with same name, then type:

Code: Select all

BSAVE NEWPRG

Code: Select all

: BSAVE ( -- )
  0 S" >" PAD$+
  BL WORD COUNT PAD$+
  S" .BLK;32768,7690" PAD$+
  PAD SWAP FSAVE ; 
You can load the 10 pages again with:

Code: Select all

BLOAD NEWPRG

Code: Select all

: BLOAD ( -- )
  0 BL WORD COUNT PAD$+
  S" .BLK;32768" PAD$+
  PAD SWAP FLOAD ;
I've also made a little utility, that displays the first line of every 10 pages. This is helpful, if your first line on the page has a comment about the page's content.

Just type

Code: Select all

INDEX

Code: Select all

: INDEX CLS
  10 0 DO
     32768 I 769 * + 32 TYPE
     LOOP
; 
If you want to add them permanently to your ToddyForth, you can load them with FLOAD and LOAD, and save the whole of ToddyForth afterward with this

Code: Select all

S" NEWTF" FSAVE
(FSAVE saves the current vocabulary with the runtime of TForth. So ToddyForth has this new vocabulary next time it is loaded.)
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
kmurta
Posts: 177
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Re: Easy load and save with ToddyForth 1.4

Post by kmurta »

Very good, Martin!

I want to inform you that I made a small change in the block structure excluding the null byte at the end, so in TForth 1.5 the block will have 768 bytes. Sorry for this inconvenience but I believe that using blocks without the null byte is more practical and is how it is used in other Forths too.

That allows the possibility to compile several blocks at once and also makes it possible to start the definition of a word in one block and end it in a next block. To indicate the stop point for the compilation is used the word ;S

Until tomorrow I will make Toddy Forth 1.5 available with the new enhanced Editor.
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Ringo R470, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
User avatar
mrtinb
Posts: 1254
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Easy load and save with ToddyForth 1.4

Post by mrtinb »

For ToddyForth 1.5:

Replace 769 with 768
And 7690 with 7680
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
Post Reply