Program that adds statements to a BASIC program

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Program that adds statements to a BASIC program

Post by mrtinb »

Hi :)

I would like to modify a BASIC program via BASIC (or ML).

It’s easy to read from the BASIC program, as that starts at address PROGRAM 16509/407D.

It should also be relatively simple to modify the program, as long as it’s modifying from one char to another.

The problem arises when you want to insert new lines into the BASIC program. Then the whole memory has to be pushed forward in memory.

Is there any subroutines in ROM that does this, I can use?

I know from Commodore 64 it was possible to fill the keyboard buffer with chars e.g. “50 PRINT A$<NL>” and this statement would be executed resulting in a new line added to the program.

From reading the ‘ROM Disassembled’-book for ZX81, it seems like there’s no keyboard buffer, and routine that inserts statements into the BASIC program, reads directly from the keyboard.

Any thoughts on this?

/Martin
Last edited by mrtinb on Thu Mar 17, 2016 4:21 pm, edited 1 time in total.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Program that adds statements to a BASIC program

Post by siggi »

Yes, there is a ROM routine, which can be used (of course in FAST mode) to make space anywhere (e. g. in program or variable section) and which also updates the pointers in the system variables, which are affected by that. I used this routine in MEFISDOS (m/c) to insert BASIC lines into an existing BASIC program.
I will post the code later ...

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Program that adds statements to a BASIC program

Post by siggi »

Hi Martin
the routine to make space is located at $99E in ROM. BC register must hold the size of the memory block needed, HL points to the address, where the space is needed.

Code: Select all

ld BC, length
ld HL, address
call $99e
After that, you can "poke" that space to get the new BASIC line there.

Wilf Rigter's RAMDOS is an example, how to insert a BASIC-program or variables to an existing program:
http://www.user.dccnet.com/wrigter/inde ... RAMDOS.htm

See label "LOADB" in the RAMDOS listing:
http://www.user.dccnet.com/wrigter/inde ... RD2SRC.txt

HTH Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Program that adds statements to a BASIC program

Post by mrtinb »

Thank you very much.

It was just What I needed.

/Martin
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
Math123
Posts: 44
Joined: Sun May 11, 2008 11:14 pm
Location: Germany Wuppertal
Contact:

Re: Program that adds statements to a BASIC program

Post by Math123 »

Hi Martin,

some times ago I made a Basic program that can add Basic-lines at its end. It uses only PEEK and POKE and a tricky hack to make space.
genline.p
(2.16 KiB) Downloaded 234 times
I am still looking to find a way for deleting lines...
If there is a solution, then someone could make a Basic-program that ist able to replicate and/or modify itself. :shock:

Matthias
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: Program that adds statements to a BASIC program

Post by Andy Rea »

Haha cool, could this.be the beginning of a virus for zx81 ?::
what's that Smell.... smells like fresh flux and solder fumes...
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Program that adds statements to a BASIC program

Post by 1024MAK »

ZeddySkyNet :shock: :?
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Program that adds statements to a BASIC program

Post by siggi »

Math123 wrote:Hi Martin,

some times ago I made a Basic program that can add Basic-lines at its end. It uses only PEEK and POKE and a tricky hack to make space.
genline.p
I am still looking to find a way for deleting lines...
Did you try "THE 'RECLAIMING' SUBROUTINES"?

http://k1.spdns.de/Vintage/Sinclair/80/ ... ra%29.html

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
Post Reply