ZX81 Basic programs loading from shadow ROM

Discussion about ZX80 / ZX81 Software
dr beep
Posts: 1296
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZX81 Basic programs loading from shadow ROM

Post by dr beep »

Try #676..... I do that in my emulator, but AFTER manually decreasing FRAMES 1x for my games to load.
dr beep
Posts: 1296
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZX81 Basic programs loading from shadow ROM

Post by dr beep »

This is the RET-address after LINE-RUN.
If a line holds SAVE then the next line is run.
LOAD continues then where SAVE ended.

Normally a LOAD ends in a screendisplay at #207 which will decrease FRAMES 1x, that is why I suggest doing that too.
You will need it to load my 1K games.
User avatar
Pip
Posts: 6
Joined: Tue May 19, 2020 6:54 pm

Re: ZX81 Basic programs loading from shadow ROM

Post by Pip »

dr beep wrote: Thu May 21, 2020 7:38 pm Try #676..... I do that in my emulator, but AFTER manually decreasing FRAMES 1x for my games to load.
No, this just crashes the ZX81.

The entry point you are proposing is mid way in the NEXT-LINE routine at #066C
So I can't see how this will work.
Or am I missing something here?
dr beep
Posts: 1296
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZX81 Basic programs loading from shadow ROM

Post by dr beep »

where do you ldir your program, must be #4009.
#676 is after LINERUN so you execute the next BASIC line of the program.
User avatar
Pip
Posts: 6
Joined: Tue May 19, 2020 6:54 pm

Re: ZX81 Basic programs loading from shadow ROM

Post by Pip »

dr beep wrote: Sat May 23, 2020 8:53 pm where do you ldir your program, must be #4009.
#676 is after LINERUN so you execute the next BASIC line of the program.
OK I see what you are doing with #676
I can also see that I can manipulate NXTLIN to start at any address within the program.

In answer to your question, at the moment I am testing by using the space between #2000-#3ffff for now. I will be doing some ROM page swapping when I have sorted out the basic load and run problem.
I am sure the issue I am having is on the return, as the Z80 pops the return address of the stack into the program counter and then continues execution. If in the mean time the basic program and variables have been changed then this return address will not be valid, so I need to work out a direct jump to address to continue from.
User avatar
Pip
Posts: 6
Joined: Tue May 19, 2020 6:54 pm

Re: ZX81 Basic programs loading from shadow ROM

Post by Pip »

I finally got to the bottom of my problem.

I looked at the Z80s stack in a monitor and could see the number of items were pushed on at any one time.

It would appear that when the ZX81 is in SLOW mode, the stack holds information related to the screen display, because when I went FAST the stack decreased in size by 8 bytes.

Therefor it is important to be in FAST mode when copying the system variables into storage, and the same when bringing them back into RAM. It is also important not to have PUSHed anything onto the stack at the point of copying the program/data, else this would screw up the return address.

This is not so much an issue if you are just copying the basic program on its own, as the problem is to do with the system variables that are included in a tape save.

In the end I used CALL 3875 to go fast, then I re-entered basic via slow with a JP 3883,
or for those who only speak hex CALL f23h to go fast, then I re-entered basic via slow with a JP f2bh

I will now have to experiment with the ZX81 with the ROM paged out altogether, making sure that the NMI and INT are both disabled. I am hoping that I will be able to use the lower block of ROM for data storage, thus removing the need to have multiple copies of the original ROM in the lower 8k of various ROM banks.

Thanks to all those who contributed. You were a help as it was good to have other peoples input.

Cheers

-Pip
Post Reply