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


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

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

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

Registered: Apr 2015
Posts: 33
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
Repose

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
Karmic

Registered: Apr 2015
Posts: 33
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 11:11
Stryyker

Registered: Dec 2001
Posts: 455
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
wbochar

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
        
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 20:32
wbochar

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: 374
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
wbochar

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
Advanced
Users Online
Alakran_64
Sentinel/Excess
Yogibear/Protovision
GI-Joe/MYD
Acidchild/Padua
Seven
Docster/Megastyle
Guests online: 41
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 The Shores of Reflec..  (9.6)
4 Coma Light 13  (9.6)
5 Lunatico  (9.6)
6 Comaland 100%  (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 Dawnfall V1.1  (9.5)
2 SidRok  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Treu Love [reu]  (9.4)
5 Tunnel Vision  (9.3)
6 Dawnfall  (9.3)
7 One-Der  (9.2)
8 Hardware Accelerated..  (9.2)
9 Globe 2016 [reu]  (9.2)
10 Safe VSP  (9.1)
Top Groups
1 Booze Design  (9.4)
2 Oxyron  (9.4)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 Camelot  (9.2)
Top Crackers
1 Mr. Z  (9.9)
2 Mitch  (9.8)
3 Mr Zero Page  (9.8)
4 Snacky  (9.8)
5 Janitor  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2017
Page generated in: 0.194 sec.