Auto-run on Load?

Basic and Machine Language

Moderator: Moderators

Post Reply
Robbie
Vic 20 Dabbler
Posts: 84
Joined: Tue Aug 11, 2020 4:36 am
Location: England

Auto-run on Load?

Post 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
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: Auto-run on Load?

Post 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
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Auto-run on Load?

Post 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.
tlr
Vic 20 Nerd
Posts: 567
Joined: Mon Oct 04, 2004 10:53 am

Re: Auto-run on Load?

Post 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.]
Robbie
Vic 20 Dabbler
Posts: 84
Joined: Tue Aug 11, 2020 4:36 am
Location: England

Re: Auto-run on Load?

Post 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.
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Auto-run on Load?

Post 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.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Auto-run on Load?

Post 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". ;)
User avatar
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: Auto-run on Load?

Post 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?
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Auto-run on Load?

Post 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.
Robbie
Vic 20 Dabbler
Posts: 84
Joined: Tue Aug 11, 2020 4:36 am
Location: England

Re: Auto-run on Load?

Post 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?
User avatar
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: Auto-run on Load?

Post 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
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
Post Reply