| |
Shadow Account closed
Registered: Apr 2002 Posts: 355 |
Can't the LOAD command be used in a basic program?
1 LOAD"ROUTINE",8,1
2 SYS 49152
RUN
Ends up in a endless loop, so I guess it doesn't do what I expect it to do...
(This may seem stupid, but it would be very handy for me when crossdeving for the DTV, as I need to load the files from 64HDD all the time, with this I could just do "run" to load the lastest routine from disk and execute) |
|
... 23 posts hidden. Click here to view all posts.... |
| |
Frantic
Registered: Mar 2003 Posts: 1648 |
hmm..? :) |
| |
iAN CooG
Registered: May 2002 Posts: 3197 |
Quote: I'm not completely sure how it works, but $37/38 (highest addr used by basic) is being set to $e48a. If you look at the ROM below $e48a it has the string "COMMODORE 64" (part of the startup text). I also think the length of the string "IBM"+"MACINTOSH" has something to do with it.
Anyone? :)
It's simple, the temp var that would contain "IBMMACINTOSH" is being built in the RAM under the ROM, and when retrieved for display it prints the string in ROM at the same address. Normally temp vars are allocated from $9fff down to $0801. |
| |
AüMTRöN
Registered: Sep 2003 Posts: 44 |
Aha! Makes sense :) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
now lets get back to topic, and some1 please explain why does the basic prg restart after using load, and why aren't the variables resetted. |
| |
Devia
Registered: Oct 2004 Posts: 401 |
With danger of sounding very stupid, I quote the C64 Programmers Reference Guide:
"The LOAD closes all open files and, if it is used in direct mode, it performs a CLR (clear) before reading the program. If LOAD is executed from within a program, the program is RUN. This means that you can use LOAD to "chain" several programs together. None of the variables are cleared during a chain operation."
It would appear that LOAD in non-direct mode was intended only for breaking apart large BASIC programs.
I wonder if there is some smart POKE/SYS combo one could do to not make it RUN after loading, but navigating through the BASIC ROM quickly gets quite tiresome...
|
| |
Mace
Registered: May 2002 Posts: 1799 |
I think I found it...
At the end of the loading routine, at $E1B5, there's a JSR to $A68E. There the current character pointer is set to the first BASIC line. So when ending the LOAD command, the next command to be executed is the first one in the first BASIC line.
So, Devia, there's no way around it.
Both in direct and in basic mode, this routine is called.
In direct mode it's JSR'ed a bit earlier, together with the printing of "ready". |
| |
Devia
Registered: Oct 2004 Posts: 401 |
Well, then you CAN do it..
10 POKE43,28
20 LOAD"FILE",8,1
30 POKE43,1
40 SYS4096
If you change the filename in the above, you just have to adjust the first POKE, in this case 28, to match the starting address of line 30
|
| |
Mace
Registered: May 2002 Posts: 1799 |
Devia, yeah, that works :)
So with some effort, it might be possible to calculate the pointers by using the value of 122 and 123 ($7A, $7B).
That would enable you to write a universal routine that works on any location within a basic program. |
| |
Devia
Registered: Oct 2004 Posts: 401 |
something like:
10 POKE43,PEEK(123)+26+04
20 LOAD"CODE",8,1
30 SYS4096
40 POKE43,1
- where the '04' in line 10 just needs to be adjusted to the filename length.
Line 40 is not really necessary unless you want to be able to LIST/RUN/SAVE the program again.
..and it wouldn't work if line 10-30 crossed a page boundary of course.
|
| |
Mace
Registered: May 2002 Posts: 1799 |
Quote:Line 40 is not really necessary unless you want to be able to LIST/RUN/SAVE the program again.
What if there's a GOTO ro GOSUB to lines prior to this LOAD part?
You could also scan for the POKE 43,1 (tokenised) around the calculated address to see where the line is exactly. |
Previous - 1 | 2 | 3 | 4 - Next |