Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Lotmamordun ! (Registered 2021-05-11) You are not logged in 
CSDb User Forums


Forums > C64 Coding > Merging BASIC program / overlay
2021-03-23 15:44
xlar54

Registered: Dec 2018
Posts: 9
Merging BASIC program / overlay

Hey guys, was wondering if anyone knows how to load in a "sub-program" at runtime while retaining variable data on the 64? Im thinking if the start of BASIC is moved up to reserve space for a program, the overlay is loaded, and basic is called to relink the lines, this ought to work? I think some bbses do this, like Image or CNet. Thanks in advance.
2021-03-23 22:45
Larry

Registered: Feb 2007
Posts: 18
Some Compilers support that f.e. Austro Comp.
Compile your Overlays without Runtime code.
IIRC there is an option to keep Variables or not.
2021-03-23 23:43
TheRyk

Registered: Mar 2009
Posts: 865
Check out Austro aka Blitz as Larry already suggested or BASIC Boss, you find all of them here IIRC.
Blitz/Austro has docs (even in English) here https://www.kmoser.com/bbs/docs-blitz.php
I vaguely remember there was some huge Boss Docs too but can't tell if/where/which Language
2021-03-24 00:34
xlar54

Registered: Dec 2018
Posts: 9
Thanks guys, but Im looking to do this only in BASIC, and not using a compiler. But I appreciate the info.
2021-03-24 22:03
TheRyk

Registered: Mar 2009
Posts: 865
Quote: Thanks guys, but Im looking to do this only in BASIC, and not using a compiler. But I appreciate the info.

in pure/native C= BASIC V2.0 it's the old IF A=... THEN LOAD orgy
20 A=A+1
30 IF A=1 THEN LOAD "MUSIC",8,1
40 IF A=2 THEN LOAD "SPRITES",8,1
50 IF A=3 THEN LOAD "GRAPHICS",8,1
...

source https://www.c64-wiki.com/wiki/LOAD

based on the fact that LOAD command execution is always followed by executing RUN but variables (here A) keep their status, i.e. they are counted upwards and thus, load the different parts to where their file header is pointing.

OR (arguably more professional) you address KERNAL routines via SYS, e.g.:
SYS 57812 "FILENAME",8,0:POKE780,0:POKE781,0:POKE782,64:SYS 65493

or
SYS 57812"FILENAME",8,0:POKE193,00:POKE194,04:POKE780,193:POKE781,232:POKE782,07:SYS 65496

Source https://www.c64-wiki.de/wiki/KERNAL#Disketten-Operationen (sorry, English version of the wiki hasn't got that part)

Cheers
Ryk
2021-03-25 10:26
Oswald

Registered: Apr 2002
Posts: 4698
there is the trick to print commands on the screen, feed the keyboard buffer with RETURNs, and then when exiting the basic program those on screen commands will be executed.

if you set a variable to some special value, then after load when your program reruns you can catch the another prg loaded condition and change basic mem start and run the new prg with the trick above.

no idea if variables will be retained iirc variables goes to used memory top and then downwards, so you might wanna change even basic memtop for your first basic prg..

edit: I guess you wanna change basic memstart before loading the new prg
2021-03-27 17:29
TheRyk

Registered: Mar 2009
Posts: 865
Yeah I've already forgotten _that_ trick :) best used after poking screen/background color into print color
poke646,peek(53281)

so users do not see what's going on ^^
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
wbochar
Skyhawk/Triad
Visage/Lethargy
Axel/Samar/Digital D..
DKT/Samar
TPM/Silicon Ltd
tlr
iceout/Avatar/HF
JEZ
Guests online: 159
Top Demos
1 Edge of Disgrace  (9.6)
2 Comaland 100%  (9.6)
3 Uncensored  (9.6)
4 Coma Light 13  (9.6)
5 Unboxed  (9.6)
6 Lunatico  (9.5)
7 Memento Mori  (9.5)
8 Wonderland XII  (9.5)
9 Christmas Megademo  (9.5)
10 The Shores of Reflec..  (9.5)
Top onefile Demos
1 Copper Booze  (9.8)
2 Daah, Those Acid Pil..  (9.6)
3 To Norah  (9.5)
4 Lovecats  (9.5)
5 Dawnfall V1.1  (9.5)
6 Square Booze  (9.4)
7 Quadrants  (9.4)
8 Elite Code Mechanics  (9.4)
9 For Your Sprites Only  (9.4)
10 Remembrance  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.3)
3 Oxyron  (9.3)
4 Fossil  (9.3)
5 PriorArt  (9.3)
Top Fullscreen Graphicians
1 The Sarge  (9.8)
2 Veto  (9.8)
3 Joe  (9.8)
4 Mirage  (9.7)
5 Facet  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2021
Page generated in: 0.037 sec.