Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


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

Registered: May 2002
Posts: 26
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"
:BasicUpstart(Main)
.pc =$080d "Main"
Main:
lda #0
sta $d020
sta $d021
jmp *

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

Registered: Apr 2015
Posts: 66
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 03:12
Repose

Registered: Oct 2010
Posts: 222
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 03:31
Karmic

Registered: Apr 2015
Posts: 66
Here is a little code example:
* = $0326
.word hook
.word $f6ed
.word $f13e
.word $f32f
.word 0
.word $f4a5
.word $f5ed
        
hook:   
sei
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 09:11
Stryyker

Registered: Dec 2001
Posts: 465
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 18:22
wbochar

Registered: May 2002
Posts: 26
Quote: Here is a little code example:
* = $0326
.word hook
.word $f6ed
.word $f13e
.word $f32f
.word 0
.word $f4a5
.word $f5ed
        
hook:   
sei
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 18:32
wbochar

Registered: May 2002
Posts: 26
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 20:28
Martin Piper

Registered: Nov 2007
Posts: 629
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 02:04
wbochar

Registered: May 2002
Posts: 26
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
Advanced
Users Online
Mason/Unicess
iAN CooG/HVSC
hedning/G★P
Freeze/Blazon
Airwolf/F4CG
Matt
algorithm
psych
MAT64
Ax!s/Onslaught - TND
radius75
Guests online: 325
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Jeroen Tel  (9.7)
3 Mutetus  (9.6)
4 Linus  (9.6)
5 Jammer  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.054 sec.