how is load""code autostart implemented?
how is load""code autostart implemented?
cant see anything on google about it. any help would be appreciated.
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
1 plot rnd*255,rnd*175
2 goto 1
-
- Microbot
- Posts: 100
- Joined: Wed Feb 03, 2021 5:18 am
Re: how is load""code autostart implemented?
If I'm correct, I think that *in general* you can't.
Say, imagine you LOAD "" CODE a block at $8000, you need to call USR 32768.
However, if you're loading over the system variables area, you can overwrite the variables that contain the immediate command being executed.
Say you save with:
SAVE "block" CODE 23296,30000: RANDOMIZE USR 28000
When you LOAD "" CODE, you load the program, but also the system variables and the SAVE:RANDOMIZE commands. When the LOAD routine returns, it's like you just returned from the SAVE routine, and go into the RANDOMIZE USR.
Does this answer your question?
Say, imagine you LOAD "" CODE a block at $8000, you need to call USR 32768.
However, if you're loading over the system variables area, you can overwrite the variables that contain the immediate command being executed.
Say you save with:
SAVE "block" CODE 23296,30000: RANDOMIZE USR 28000
When you LOAD "" CODE, you load the program, but also the system variables and the SAVE:RANDOMIZE commands. When the LOAD routine returns, it's like you just returned from the SAVE routine, and go into the RANDOMIZE USR.
Does this answer your question?
Re: how is load""code autostart implemented?
i think so. thank you
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
1 plot rnd*255,rnd*175
2 goto 1
Re: how is load""code autostart implemented?
In general, you can.
Let's examine Eric and the floaters loader
TZX itself contains these files:
So, by CLEAR it is changing where "safe" area of memory starts. It means, Basic do not touch anything after that address.
Additionally, stack is moved there.
Code block loaded from address 32722 overlaps stack area, and after loading is finished, just jumps to address, that was loaded with code block.
Here goes hex dump of beginning of file:
You can see $9FD0 address, and if we examine what is there in memory...
Yeah, this is decryptor. When it finishes, execution jumps to $8000, or 32768 decimal, what is equal to address, where is original game entry point.
Last edited by Bedazzle on Wed Nov 09, 2022 4:10 pm, edited 2 times in total.
-
- Microbot
- Posts: 100
- Joined: Wed Feb 03, 2021 5:18 am
Re: how is load""code autostart implemented?
Oh yes I missed that case, sorry. Overwriting the stack so the return from LOAD "" CODE goes to the game.
Re: how is load""code autostart implemented?
I remember this back then, when one of my tapes wore out I tried to load the code somewhere else in memory and save it back to a fresh tape. Then, after franctically fiddling with my 'new'-but-just-reused tape and the recorder's audio, it finally loaded but just refused to run. Quite mind-boggling for me as I had no idea of the concept.TheMartian wrote: ↑Wed Nov 09, 2022 3:01 pm When you LOAD "" CODE, you load the program, but also the system variables and the SAVE:RANDOMIZE commands. When the LOAD routine returns, it's like you just returned from the SAVE routine, and go into the RANDOMIZE USR.
POKE 23614,10: STOP 1..0 hold, SS/m/n colors, b/spc toggle
Re: how is load""code autostart implemented?
Interesting stuff. I remember now that I had one such tape and I used to wonder what kind of sorcery had been used
Re: how is load""code autostart implemented?
Easiest way is to do something like
10 SAVE "GAME" CODE 16384,49152
20 RANDOMIZE USR whatever
When you load the code back in it will resume from line 20.
10 SAVE "GAME" CODE 16384,49152
20 RANDOMIZE USR whatever
When you load the code back in it will resume from line 20.
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: how is load""code autostart implemented?
I explained it here.
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Re: how is load""code autostart implemented?
One of those games was Pogo.
I remember it because it was packaged with the ZX 48K here in Germany.
It featured a small Basic program that loaded a huge code chunk from 16384 to 65535.
This took around 5 minutes to load and you were praying to the recorder that it got the audio right.
If something was tripped up you mostly wouldn't notice until the last bit was read in and you were left with an error screen.
I had no idea how to hack this. And tape to tape copying used to detoriate the signal further.
The cheap cassette players that you could get hold of with your pocket money used to wear out tapes quite easily.
https://spectrumcomputing.co.uk/entry/3 ... ctrum/Pogo
I remember it because it was packaged with the ZX 48K here in Germany.
It featured a small Basic program that loaded a huge code chunk from 16384 to 65535.
This took around 5 minutes to load and you were praying to the recorder that it got the audio right.
If something was tripped up you mostly wouldn't notice until the last bit was read in and you were left with an error screen.
I had no idea how to hack this. And tape to tape copying used to detoriate the signal further.
The cheap cassette players that you could get hold of with your pocket money used to wear out tapes quite easily.
https://spectrumcomputing.co.uk/entry/3 ... ctrum/Pogo
POKE 23614,10: STOP 1..0 hold, SS/m/n colors, b/spc toggle
Re: how is load""code autostart implemented?
How to hack POGO, POLE POSITION and A VIEW TO A KILLsn3j wrote: ↑Sun Nov 20, 2022 2:53 pm One of those games was Pogo.
I remember it because it was packaged with the ZX 48K here in Germany.
It featured a small Basic program that loaded a huge code chunk from 16384 to 65535.
This took around 5 minutes to load and you were praying to the recorder that it got the audio right.
If something was tripped up you mostly wouldn't notice until the last bit was read in and you were left with an error screen.
I had no idea how to hack this. And tape to tape copying used to detoriate the signal further.
The cheap cassette players that you could get hold of with your pocket money used to wear out tapes quite easily.
https://spectrumcomputing.co.uk/entry/3 ... ctrum/Pogo
Re: how is load""code autostart implemented?
Back in time real jedi did this from machine code
loading game file to address 25000
save "first" code from 25000 with length 40536
(screen can be saved separately to 6912, and crunched)
load game code again, but to an address 0 (ROM)
save "second" code from 40536 with length 8616
then these data blocks can be easily loaded and explored with any disassembler, like MONS or STS.
Re: how is load""code autostart implemented?
I see a few flaws hereBedazzle wrote: ↑Mon Nov 28, 2022 9:49 am Back in time real jedi did this from machine code
loading game file to address 25000
save "first" code from 25000 with length 40536
(screen can be saved separately to 6912, and crunched)
load game code again, but to an address 0 (ROM)
save "second" code from 40536 with length 8616
then these data blocks can be easily loaded and explored with any disassembler, like MONS or STS.
1) loading first blocks could cause basic to make code run which is not loaded (second block)
2) second block could overload stackpointer and make it run as well.
3) still knowledge needed to make it loadable
My program only needs pressing space and the use of a taperecorder.
Re: how is load""code autostart implemented?
CODE 23552, length
Can calc length although these days I cheat and truncate it with ZXBE, with care.
Here:
Tape contains loader in Basic:
And the 'Basic' in the code:
Download here > https://ufile.io/ppzxz0en (should stay "alive" for about 30 days) long enough for what it is.
Can calc length although these days I cheat and truncate it with ZXBE, with care.
Here:
Tape contains loader in Basic:
Code: Select all
10 LOAD "" CODE
Code: Select all
10 REM
20 REM BORING TEST PROGRAM
30 REM
40 POKE (RND*767),RND*127
50 IF INKEY$<>"" THEN CLS
60 GOTO 40
Re: how is load""code autostart implemented?
There was another way of autostarting the CODE block which was not mentioned. While loading the data would overwrite ERRSP system variable and then an error was caused intentionally by the code stored on tape being one byte shorter that it should be so the parity byte was missing.
chupocro
F3 CD AF 0D CD 52 00 3B 3B E1 11 12 00 19 06 0B 7E EE
7E D7 23 10 F9 FB C9 1C 07 5E 3D 16 0B 0E 11 1D 0C 11
F3 CD AF 0D CD 52 00 3B 3B E1 11 12 00 19 06 0B 7E EE
7E D7 23 10 F9 FB C9 1C 07 5E 3D 16 0B 0E 11 1D 0C 11