|
Post by signals42 on Dec 13, 2004 18:45:08 GMT -5
I don't know if this is the right place to ask this, but since everyone has renewed interest in the C64 because of the release of the DTV, I thought I might get an answer here. I bought my DTV specifically to program. (I want to play with DMA and 256 colors, etc.)
Anyway, I've never been particularly good at 6510 assembly, but I've always had fun playing with it. One thing I just can't figure out (and can't find any help with on the Internet) is how programs auto-start after a LOAD "*",8,1.
I've been poking around, trying to find a vector that gets jumped to after a load (thinking that I could point it to my code) with no luck. I even tried the CBM80 deal, but that appears to be for cartriges only.
Am I on the right track with putting the address to my own code in a vector address somewhere? Or do I need to change LORAM (bit 0 of $01) to turn the basic ROM off and write my code to the ram where Basic was? Am I completely off here? Any pointers to documentation (even just a memory address to read up on) would be helpful.
I'm just tired of typing SYS XXXX to start my code after loading. It's especially bad in Frodo on my cell phone because there's no keyboard :-)
Thanks, -Kevin
|
|
|
Post by David Murray on Dec 13, 2004 18:54:25 GMT -5
I don't have the entire answer for you.. but to the best of my knowledge, the first two bytes of a PRG file on a commodore disk file tells the kernel where to load the program into RAM. I wish I could tell you more, but I'd have to research it. Anyway, I think the idea is to make sure your code starts at what ever location the kernel returns control to in RAM once the load process is finished. I know there is also a pointer somewhere that also tells the system where to return to, but I don't see how you could modify that one or two bytes without loading a whole bunch of other stuff in there with it. Anyway, anybody feel free to correct me if I'm wrong.
|
|
|
Post by signals42 on Dec 13, 2004 20:29:46 GMT -5
Well, I posted the question too soon. After searching Usenet (with the correct search parameters in Google) I found a post by Steve Bell that I'm going to quote here:
There are 3 types of autoloaders that I'm familiar with. The first one loads to $0100 (the CPU stack) and starts off with 256 $02's, filling the stack. So when the KERNAL routines return, they always read a return address of $0202 from the stack, where the loaded program picks up. I think it's best to keep program code short enough to fit before $0258, where the system input buffer ends.
The second one loads to $02a7, which is unused RAM, followed by an error vector at $0300 and the BASIC warm start vector at $0302. This warm-start vector prints "READY." and goes to the cursor input loop. Change the vector at $0302 to point to $02a7, and your program will start instead of the prompt coming back. I think that this is the most common method.
The last one was used in Wyndex's XIP compressor; he might have been the first to use it. Set the load address to $0326, the CHROUT (or BSOUT, depending on your mem map's labels) vector. Point this to $032a, where your program will start. Make sure to keep the $0328 vector (STOP routine) intact, as the IRQ call it. When the KERNAL tries to print the READY prompt, it'll call CHROUT and hit your code.
I just put together a little test that loads at $02a7, then puts $a7 in $0302 and $02 in $0303, and it worked! Yay!
So, now I have to figure out how to fit my code into 88 bytes or I'll have to figure out how to make a loader fit there and have it load a second program into a larger space, then jump there. Time to learn to use SETLFS, SETNAM and LOAD, I think.
-Kevin
|
|