Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
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: 26
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: 2062
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: 2062
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: 5017
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: 2062
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
MAT64
MCM/ONSLAUGHT
zscs
Walt/Bonzai
Didi/Laxity
wil
Oswald/Resource
sebalozlepsi
Arcane/Glance
Guests online: 162
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.039 sec.