Page 2 of 2

Re: ZX81 Basic programs loading from shadow ROM

Posted: Thu May 21, 2020 7:38 pm
by dr beep
Try #676..... I do that in my emulator, but AFTER manually decreasing FRAMES 1x for my games to load.

Re: ZX81 Basic programs loading from shadow ROM

Posted: Thu May 21, 2020 7:59 pm
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.

Re: ZX81 Basic programs loading from shadow ROM

Posted: Thu May 21, 2020 11:23 pm
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?

Re: ZX81 Basic programs loading from shadow ROM

Posted: Sat May 23, 2020 8:53 pm
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.

Re: ZX81 Basic programs loading from shadow ROM

Posted: Sun May 24, 2020 5:12 pm
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.

Re: ZX81 Basic programs loading from shadow ROM

Posted: Tue May 26, 2020 12:50 am
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