| |
Kabuto Account closed
Registered: Sep 2004 Posts: 58 |
Starting BASIC programs from decompression routine
I've made just another packer for C64 :) it works fine with most machine code programs but not with BASIC programs.
In some other packer I've seen a sequence of 2*JSR and 1*JMP to the BASIC interpreter to set up some things but these don't work because my routine overwrites $0001-$0120 and $0300-$07FF so the BASIC interpreter reads unexpected values there and hangs.
Is there a simple way to restore information there without losing the BASIC program or control?
|
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
check the kernal listings, find the basic reset subroutine..., also you must set some ptrs which point to the start end of the basic prg or smth like that. |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
you definitely need to initialize the zeropage and the vector tables. not only basic programs need them, also a lot of machine code programs use rom routines and they can heavily crash if some zeropage value is wrong. for example, clearing the screen with JSR $E544 etc. |
| |
White Flame
Registered: Sep 2002 Posts: 136 |
Just copy $0000-$03ff out to $fb00 or something, and copy it back after the depack. I presume this is the code that you were looking at? It's what exomizer adds to the beginning of a compressed BASIC file, so that a jmp $0801 will run the BASIC program from ml.
0801: Entry00 lda#$1B
0803: sta $zTXTTAB (002B)
0805: lda#$08
0807: sta $002C
0809: lda#$F7
080B: sta $zVARTAB (002D)
080D: lda#$92
080F: sta $002E
0811: jsr $SA659 (A659)
0814: jsr $bLINKPRG (A533)
0817: jmp $bNEWSTT (A7AE)
081A: 00 43 50 01 00 43 50 B2 31 3A 57 41 B2 34 3A 46
082A: B2 34 3A 4D B2 34 30 3A 99 22 93 22 3B 00 8D 36
083A: 02 00 8D 36 35 37 3A 4F 42 24 28 38 33 29 B2 22 |