Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Vaz ! (Registered 2018-02-19) You are not logged in 
CSDb User Forums

Forums > C64 Coding > Loading and Running on Automatic
2017-03-30 04:15

Registered: May 2002
Posts: 20
Loading and Running on Automatic

I remember a few games that had LOAD"*",8,1: that would execute the program right after. I am not talking about the shift-commodore at the end of a line. SOme of these games also had loading text that would slowly load into the screen area.

How did that work? I keep on thinking about how loaders would *=$400 to have a loading message dumped into the screen. Is there something like Carts, where a specific signature or memory location gets updated and a jmp or something gets triggered at the end of disk load?

/* Kick Assembler */
.pc = $0801 "basic bootstrap"
.pc =$080d "Main"
lda #0
sta $d020
sta $d021
jmp *

.pc = $0400 "Load Screen"
.fill 1024,$31
2017-03-30 05:08

Registered: Apr 2015
Posts: 36
You have the right idea with loading to screen memory- what these programs did is load to the kernal-vectors at $0314-$0333, so when the kernal tries to execute a certain one of these routines, instead it will jump to the desired code by the user.
2017-03-30 05:12
Account closed

Registered: Oct 2010
Posts: 129
You could also load into the stack with 256 bytes of $0202 and then your code at that location. Any return will go to it.
2017-03-30 05:31

Registered: Apr 2015
Posts: 36
Here is a little code example:
* = $0326
.word hook
.word $f6ed
.word $f13e
.word $f32f
.word 0
.word $f4a5
.word $f5ed
inc $d020 ;to prove it worked
jmp *-3

Here I hook the CHROUT vector, since the kernal always prints "READY." after loading completes.
2017-03-30 11:11

Registered: Dec 2001
Posts: 459
Loading to $02a7 is a common way and over write $0302/$0303 to point to $02a7 and your code will auto execute. and you only mess up $0300-$0303

Some would add code to write rU to the keyboard queue, load some other program and rts. The rU will execute a run. I can't remember if $0302/$0303 needs to be repaired.
2017-03-30 20:22

Registered: May 2002
Posts: 20
Quote: Here is a little code example:
* = $0326
.word hook
.word $f6ed
.word $f13e
.word $f32f
.word 0
.word $f4a5
.word $f5ed
inc $d020 ;to prove it worked
jmp *-3

Here I hook the CHROUT vector, since the kernal always prints "READY." after loading completes.

This works great, thanks :)
It's one of those mysteries I kept thinking about over the years but never remembered while I was making something. I am totally putting this into my next project.

I noticed that VICE will throw up if the program is directly injected into memory. The emulator needs "Virtual FS" enabled (or loaded from a device).
2017-03-30 20:32

Registered: May 2002
Posts: 20
Thanks for the posts;

a sideline question on the topic or .pc/* loading

* = $0326
// hook code to main

* = $080d
// d020/21, (load screen colors to $d800)

* = $0400
// .bytes of screen chars

// Now add this in...

* = $d800
// .bytes of colors

The hook and $0400 work together, but if I add *=$d800 for the screen colors the program tanks. Why does this break? I assume it has to do with something with loading to screen mem. When I load things in (Pics, Music, Fonts) they all go in different *=???? load points. Why when $0400 is involved things go weird?
2017-03-30 22:28
Martin Piper

Registered: Nov 2007
Posts: 376
When you use *=$d800 like that your assembler will be initializing all memory up to d800 including VIC registers. So when it loads you're overwriting VIC and SID since they're banked in.

Auto loading code like this should usually be small and load the next data explicitly.
2017-03-31 04:04

Registered: May 2002
Posts: 20
Thanks for that; you have cleared it up for me.

Everyone else, thanks as well for the help :)
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Users Online
Guests online: 42
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Comaland 100%  (9.6)
6 Lunatico  (9.6)
7 Incoherent Nightmare  (9.5)
8 Wonderland XII  (9.5)
9 Comaland  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Pandemoniac Part 2 o..  (9.5)
2 Dawnfall V1.1  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Synthesis  (9.5)
5 Treu Love [reu]  (9.5)
6 FMX Music Demo  (9.4)
7 Dawnfall  (9.4)
8 Merry Xmas 2017  (9.4)
9 Hardware Accelerated..  (9.3)
10 Tribute to Bob Wakelin  (9.3)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 Finnish Gold  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.5)
2 Newscopy  (9.4)
3 Peter  (9.3)
4 A Life in Hell  (9.2)
5 Elwix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.157 sec.