| |
zzarko
Registered: Feb 2003 Posts: 77 |
Starting a program after copying from cartridge
I am working on a 3.0 version of Magic Desk Cartridge Generator and I have come up with a problem with three programs (testing is done in VICE 3.3, and on a real C64):
Turbocopy V5.0
Turbo Nibbler V5.0
64 Tester
that simply would not start when copied from cartridge to $0801 (the other ~140 programs that I have tried worked just fine).
Anyhow, cold start is like this:
stx $d016
jsr $FDA3 // IOINIT, init CIA,IRQ
jsr $FD50 // RAMTAS, init memory
jsr $FD15 // RESTOR, init I/O
jsr $FF5B // SCINIT, init video
cli
jsr $E453 // load BASIC vectors
jsr $E3BF // init BASIC RAM
jsr $E422 // print BASIC start up messages
ldx #$FB // init BASIC stack
txs
Then I setup IRQ, VIC and CIA registers to my liking. After a program is selected from cartridge menu, I restore original IRQ and call these:
jsr $FDA3 // IOINIT, init CIA,IRQ
jsr $FD15 // RESTOR, init I/O
jsr $FF5B // SCINIT, init video
cli
jsr $E453 // load BASIC vectors
jsr $E3BF // init BASIC RAM
jsr $A68E // set current character pointer to start of basic - 1
ldx #$FB
txs
then I copy the program to its address ($0801), set $2d/2e to end of program, and then:
jsr $A871 // clr
jsr $A533 // re-link
jmp $A7AE // run
Does someone knows what initialization am I missing here (or have too much of it)? Complete source code will be available soon, but I would like to fix this before the release, if possible. |
|
... 11 posts hidden. Click here to view all posts.... |
| |
Claus_2015
Registered: Oct 2012 Posts: 53 |
Another guess: two of the programs are disk tools, maybe they want to see an 8 in $ba? |
| |
zzarko
Registered: Feb 2003 Posts: 77 |
Cartridge code messes up some zero page locations and cassette buffer, otherwise it runs from ROM. $BA is set to first found active drive, and if none is found, it is set to 8. I have tried to save zero page locations before messing them up, and restoring them afterwards, but to no avail. |
| |
zzarko
Registered: Feb 2003 Posts: 77 |
I have also tried to just transfer 64 Tester right after cold start, messing only $FB-$FD and cassette buffer ($0340-0398), but it still won't run this way. |
| |
zzarko
Registered: Feb 2003 Posts: 77 |
Ahhh, finally... I have put end address also in ae/af and now those 3 work :)
And that leaves only one that still misbehaves (from those that I tested): Basic 64 Compiler 1.03. This one was captured with action replay, and runs fine when loaded from disk. But, when run from cartridge, it shows the menu, but pressing any option does nothing. |
| |
zzarko
Registered: Feb 2003 Posts: 77 |
For Basic 64 compiler, I have tried this: I saved the memory blocks 0002-00ff and 0200-03ff when program loads from disk (with bs from VICE), started program form cartridge, put a breakpoint at program start, inserted saved memory blocks (with bl), and continued to run the program, but it still doesn't work...
So, my guess is that it isn't a problem with zeropage or 0200-0400 area. What else? |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
find out why it doesnt works? see where it crashes and trace it back. |
| |
zzarko
Registered: Feb 2003 Posts: 77 |
Huh, I tried that but it seems that Basic 64 Compiler is written in BASIC and compiled by itself. I cannot make sense of tracing its code (I'm not that good with C64 assembly)... |
| |
zzarko
Registered: Feb 2003 Posts: 77 |
It doesn't crash, it just redraws the menu when I press any key (when loaded from disk, it does that when I press wrong key).
Weird thing is that if I press any combination of keys 87 times (don't ask...), it displays the prompt for filename, but it doesn't work afterwards as it should. |
| |
AlexC
Registered: Jan 2008 Posts: 299 |
I would bet - especially if this was freeze using AR - VIC/IO registers are not set correctly. Also make sure 00 and 01 are set as needed too. |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Since you have both a working and a failing setup for the same program, you can do a side-by-side comparison.
Get both invocations (from cartridge and from disk) in two VICE instances to the same point, that is, some loop where it waits for user input, same program counter, at least.
Then inject a keypress. I guess writing something into the keyboard buffer would do, but you'll see how it checks for input anyways.*
Then step through both instances simultaneously until they diverge, at which point you might have a vague idea what the problem might be. Watch out for stray or spurious interrupts, too.
Analyse memory and other state, redo for more hints, repeat until success. =)
* Finding out how to inject a keypress with the program performing the desired action can be done beforehand with the working setup. |
Previous - 1 | 2 | 3 - Next |