Page 1 of 1

Auto-run on Load?

Posted: Tue Sep 01, 2020 3:34 pm
by Robbie
Hello all.

I'm sure this is really simple, but I'm still very proud of just having learnt to POKE 45 and 46 with the address for the end of my machine code, so I can SAVE and LOAD it as part of the program. Then, a simple...

10 SYS4110 (or 4622 if we're expanded)

...is all I need, and we're up and running. :D

Next question which is stumping me though... How do I get something to auto-run upon loading?

Can anyone help me out? I know my old C64 games used to auto-run, but I can't recall my Vic-20 games doing that - admittedly, it was 38 years ago, so my memory might be lying.

Thank you,
Robbie

Re: Auto-run on Load?

Posted: Wed Sep 02, 2020 1:00 am
by wimoos
Hello Robbie,

On a VIC with no further extensions, the key combination SHIFT-RUN/STOP does this. Only from tape, though.
On VICE, there is an 'Autostart' feature that loads and runs a program from disk #8.


Regards,

Wim

Re: Auto-run on Load?

Posted: Wed Sep 02, 2020 1:18 am
by Mike
Autostart on VIC-20 works the same way as on C64, the most popular method overwrites certain vectors at $03xx upon load and later, restores them so everything works again the normal way.

On tape, you can force the load to a certain address, so it doesn't matter whether the user just specified ",1" or ",1,1" on load. With disk, an autostart with any of those methods always requires you load the file with ",8,1".

As an example for disk, take a look at the file "BOOT" in my Games Collection. If you load it ",8,1", it will autostart.

Re: Auto-run on Load?

Posted: Wed Sep 02, 2020 10:28 am
by tlr
There are several ways to autostart, for example:
  • Overloading the vectors at $0300 and up as Mike suggested. For example $0302 like you wrote, but also $0314, or others like $0326.
  • Overloading the stack ($0100 and up) with all $01. Upon doing the next RTS the address will be pop:ed from stack as PC=$0101+1=$0102.]

Re: Auto-run on Load?

Posted: Wed Sep 02, 2020 2:03 pm
by Robbie
Thanks all. I'd forgotten about SHIFT-RUN/STOP, which I must have used a million times as a kid!

The stack overload is quite a clever trick, but I like the $0302 overloading so I think I'll go for that. It's on disk so will need ,8,1.

Is there something specific you need to do to force tape to load to a certain address with just a simple LOAD (SHIFT-RUN/STOP)?

I wish this forum had existed when I was 11, it would have saved a whole lot of messing.

Re: Auto-run on Load?

Posted: Thu Sep 03, 2020 12:23 am
by srowe
Robbie wrote: Wed Sep 02, 2020 2:03 pm Is there something specific you need to do to force tape to load to a certain address with just a simple LOAD (SHIFT-RUN/STOP)?
Save with a secondary address of 1.

Re: Auto-run on Load?

Posted: Thu Sep 03, 2020 1:03 am
by Mike
Robbie wrote:Is there something specific you need to do to force tape to load to a certain address with just a simple LOAD (SHIFT-RUN/STOP)?
srowe wrote:Save with a secondary address of 1.
More details to be found in the sticky thread "ROM calls and other tricks", also in the Programming section.

BTW, on the keys labeled "CLR HOME", "INST DEL" and "RUN STOP", the three captions HOME, DEL(ete) and STOP denote the unshifted action, and CL(er)R, INS(er)T and RUN denote the shifted action - with RUN meaning "load and RUN the first/next program from default mass storage". ;)

Re: Auto-run on Load?

Posted: Thu Sep 03, 2020 10:06 am
by Noizer
Mike wrote: Thu Sep 03, 2020 1:03 am... RUN denote the shifted action - with RUN meaning "load and RUN the first/next program from default mass storage". ;)
Right. But did you know this? Try loading some programm what doesn't autostart at the usual way (no matter disk or tape) and type in successively: letter "A" and "shift+run".
Not bad, or?

Re: Auto-run on Load?

Posted: Thu Sep 03, 2020 2:39 pm
by Mike
Mike wrote:... RUN denote the shifted action - with RUN meaning "load and RUN the first/next program from default mass storage". ;)
Noizer wrote:Right. But did you know this? [...]
Yes. Look here.
[..] Try loading some programm what doesn't autostart at the usual way (no matter disk or tape) and type in successively: letter "A" and "shift+run". Not bad, or?
The point of the OP most probably was how to enforce an autostart, as a means of program protection, or the like.

Re: Auto-run on Load?

Posted: Fri Sep 04, 2020 2:00 pm
by Robbie
Mike wrote: Thu Sep 03, 2020 1:03 amBTW, on the keys labeled "CLR HOME", "INST DEL" and "RUN STOP", the three captions HOME, DEL(ete) and STOP denote the unshifted action, and CL(er)R, INS(er)T and RUN denote the shifted action - with RUN meaning "load and RUN the first/next program from default mass storage". ;)
I'm pretty sure it was 1990 before I realised that! Mind you, I used shift-lock (not shift) for upper-case for at least two years, so perhaps not a bright 8-year-old!

Thanks for the heads-up on the 1 command ( SAVE "TEST",1,1 etc). Are there commands other than null/0 and 1?

Re: Auto-run on Load?

Posted: Fri Sep 04, 2020 4:04 pm
by Noizer
Mike wrote: Thu Sep 03, 2020 2:39 pm The point of the OP most probably was how to enforce an autostart, as a means of program protection, or the like.
Yes, stating the opposite strengthens right things even more, maybe