Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to carve up ZX Basic into different ORG values
#6
There are no magic and universal anwser!  Big Grin

The first thing is what's the platform target: ZX Spectrum 128K or ZX Spectrum Next?
Also the addresses are not fixed at $6000, $8000, etc., every program has his own demands.

1.a.- I have several variables that are set up as CONST and set a value, e.g. CONST printwidth as UBYTE = 42 but this can't can't be used due to compiling errors but DIM can be used so not a major problem.

There should be no problem using CONST in Vars.bas. What error are you getting?

1.b.- I would need to assign all 100+ variables as $7ff0 but having to start $8000 - 100bytes to enable each variable to be allocated a unique address?

It's only a sample, you can also reserve the space in the main module:
Code:
MyVarsSpace:
asm
     defs 1024   ; Put here the desired space
end asm
Put it at the end of the code, or at the start with a GOTO before, avoid the program runs over MySpaceVars

Then, in Vars:
Code:
DIM moduleLoad as ubyte AT @MyVarsSpace
DIM moduleParameter1 as ubyte at @MyVarsSpace+1
DIM moduleParameter2 as ubyte at @MyVarsSpace+2

DIM Lives as ubyte at @MyVarsSpace+3
DIM Score as uinteger at @MyVarSpace+4
DIM Level as ubyte at @MYVarSpace+6
DIM HighScore as uinteger at @MyVarSpace+7
Take a look at the + value, byte/ubyte add 1, integer/uinteger add 2, etc...

2.a.- Are you saying that the above sub routine should be in the Main.bas or in a module-nnn.bas or both?
The ExecModule must be only in Main.bas

2.b.- What is LoadSD () ? I don't have this but I do get what this is trying to do i.e. load in the Module.1.bin into $8000, with 16384k
The LoadSD is a command form NextLib library for ZX Spectrum Next, and you must replace by memory bank swtich or tape/disk load on Spectrum 128K.

2.c.- The last bit seems to be a mixture of two things.
The point are to set moduleLoad and moduleParameterX before to call the next module. Then you must set before returning to main.bas from moduleX.bas
moduleLoad = Next module to load
moduleParameterX = Optional values for the Next module.


3.a -  How to return variables or just use the vars.bas as shared anyway?
Set at least "moduleLoad" before return to main module in MOduleX.bas

3.b.- the setting of the next module to load and parameter - This bit I am not sure how this all fits in with my Main.bas , VARS.bas and Module.nnn.bas ?
This is architecture, not coding!

A sample of all:

Sample program:
  • Main.bas: Main module with ExecModule method. Apart from system initialisation, his only funcion is to load and execute the module.
  • Module1.bas: Intro of the game. IN: moduleLoad=1, OUT: moduleLoad=2 (menu)
  • Module2.bas: Menu of the game. IN: moduleLoad=2, OUT: moduleLoad=depending on the selected option (3-New game, 4-Define keys, 5-Help)
  • Module3.bas: Game Phase 1. IN: moduleLoad=3, OUT: moduleLoad=depending on action (6-Game Phase 2, 10-Game over)
  • Module4.bas: Define keys. IN: moduleLoad=4, OUT: moduleLoad=2
  • Module5.bas: Help of the game. IN: moduleLoad=5, moduleParameter1=module to return (menu or phase if is called inside a gameplay)
  • Module6.bas: Game Phase 2. IN: moduleLoad=6, OUT: moduleLoad=depending on action (7-Game Phase 7, 10-Game over)
  • Module7.bas: Game Phase 3. IN: moduleLoad=7, OUT: moduleLoad=depending on action (8-Game Phase 8, 10-Game over)
  • ....
  • Module10.bas: Game over. IN: moduleLoad=10, OUT: moduleLoad=2 (load menu of the game)

All modules includes Vars:

Code:
#include "Vars.bas"

And all modules set at least moduleLoad value before return, moduleParameters are optional.

Hope it helps!
Duefectu
https://zx.duefectucorp.com
duefectucorp@gmail.com
Reply


Messages In This Thread
RE: How to carve up ZX Basic into different ORG values - by Duefectu - 05-22-2021, 09:58 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)