| |
wbochar
Registered: May 2002 Posts: 29 |
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
-------------------------------- |
|
| |
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. |
| |
Repose
Registered: Oct 2010 Posts: 225 |
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. |
| |
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. |
| |
Stryyker
Registered: Dec 2001 Posts: 468 |
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. |
| |
wbochar
Registered: May 2002 Posts: 29 |
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). |
| |
wbochar
Registered: May 2002 Posts: 29 |
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? |
| |
Martin Piper
Registered: Nov 2007 Posts: 722 |
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. |
| |
wbochar
Registered: May 2002 Posts: 29 |
Thanks for that; you have cleared it up for me.
Everyone else, thanks as well for the help :) |