Implementing CHAIN
Posted: Fri Dec 22, 2023 8:16 am
I have been thinking about CHAIN. Which is available in GW-BASIC. http://www.antonis.de/qbebooks/gwbasman/chain.html Its there to allow BASIC programs to be larger than the available RAM. While there is < .001 % chance of this being implemented in CBM(x16) 2.0 but we do have an option that will give near the same functionality.
.... I'm at about 4k FRE on HANGMAN right now ... And I'm just now implementing the MUSIC and SOUND Effects code. So I have a serious reason to think about this ....
When LOAD (ing) a program from within a running BASIC program the LOAD(ed) program overwrites the current one and unlike immediate mode LOAD the program goes ahead and starts. That is the Core functionality of CHAIN. However it does not allow the carry over of variables like CHAIN does.
Unlike the C64 the Commander X16 has lots of places to store information that can be used to pass between programs. We have 512kb to 2mb of paged Hi-Ram. 1 kb of "Golden Ram" between $0400 & $07FF and the 32 bytes of Zero Page registers (R0-R15). Thats a lot of area to implement communications between "CHAINED"/"LOADED" programs. None of the mentioned areas are changed by the LOAD command so thats where we have to store COMMON data when Pseudo-CHAINING...
Besides the above area. If resetting the TOP of BASIC Ram to load Machine Code then that upper BASIC memory also remains unchanged on subsequent loads. I'm probably going to write a little program that just does that and loads and initializes ZSMKIT and move that little bit of code out to a separate .PRG. I'll probably pass the fact that it is loaded back to the main program in the Rx registers.
.... I'm at about 4k FRE on HANGMAN right now ... And I'm just now implementing the MUSIC and SOUND Effects code. So I have a serious reason to think about this ....
When LOAD (ing) a program from within a running BASIC program the LOAD(ed) program overwrites the current one and unlike immediate mode LOAD the program goes ahead and starts. That is the Core functionality of CHAIN. However it does not allow the carry over of variables like CHAIN does.
Unlike the C64 the Commander X16 has lots of places to store information that can be used to pass between programs. We have 512kb to 2mb of paged Hi-Ram. 1 kb of "Golden Ram" between $0400 & $07FF and the 32 bytes of Zero Page registers (R0-R15). Thats a lot of area to implement communications between "CHAINED"/"LOADED" programs. None of the mentioned areas are changed by the LOAD command so thats where we have to store COMMON data when Pseudo-CHAINING...
Besides the above area. If resetting the TOP of BASIC Ram to load Machine Code then that upper BASIC memory also remains unchanged on subsequent loads. I'm probably going to write a little program that just does that and loads and initializes ZSMKIT and move that little bit of code out to a separate .PRG. I'll probably pass the fact that it is loaded back to the main program in the Rx registers.