Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to carve up ZX Basic into different ORG values
#5
(05-17-2021, 07:50 PM)Duefectu Wrote: Hi @RandomiserUsr,

There aren't a direct way to do this, but there is a workarround that I used in CuadragonNext and now in NextDows OS for Next.
In my case, for the ZX Spectrum Next, I load the modules to $8000 at runtime every time I need, but other approaches are possible.

Modules:
Make a Main module at 24576, as you did.
Make a Vars.bas module that uses a vars zone under $8000 and define the vars like:

Code:
dim moduleLoad as ubyte AT $7ff0
dim moduleParameter1 as ubyte at $7ff1
dim moduleParameter2 as ubyte at $7ff2
dim lives as ubyte at $7ff3
Make all the code modules at $8000. Every module shoul include "Vars.bas". In this way you can share variables from one module to other.

The point id call to set moduleLoad var and moduleParameter1, and so on to the desired module.


Main Module:
Code:
sub ExecModule()
  LoadSD("Module."+str(moduleLoad)+".bin",$8000,16384,0)  ' This is for ZX Next and load the "moduleLoad" in $8000

  ' Save ix register and call $8000
asm
   push ix
   call $8000
   pop ix
end asm

end sub

The code modules can be compiled as standard programs at $8000 and return to Basic when ends...
Code:
' The action to executed is defined by moduleParameter and other variables
if moduleParameter1=1 then
   Command1()
else if moduleParameter=2 then
   Command2()
end if

' Before to exit, set moduloLoad to determite the next module to load and the parameters needed
moduleLoad=2
moduleParameter=3

Try this apporach and share results and apprachs!

Sorry for my bad English, I'm spanish!
1) You said to make all the variables like this in the VARS.BAS

dim moduleLoad as ubyte AT $7ff0
dim moduleParameter1 as ubyte at $7ff1
dim moduleParameter2 as ubyte at $7ff2
dim lives as ubyte at $7ff3

Which is fine but some further questions:
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.
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?


2. You said :-
make a Main module at 24576, as you did.
Make a Vars.bas module that uses a vars zone under $8000
Make all the code modules at $8000. Every module shoul include "Vars.bas".

then I get a bit lost with the below section:-

The point id call to set moduleLoad var and moduleParameter1, and so on to the desired module.
Main Module:
Code:
Code:
sub ExecModule()
LoadSD("Module."+str(moduleLoad)+".bin",$8000,16384,0) ' This is for ZX Next and load the "moduleLoad" in $8000

' Save ix register and call $8000
asm
push ix
call $8000
pop ix
end asm

end sub


a) Are you saying that the above sub routine should be in the Main.bas or in a module-nnn.bas or both?

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

c) The last bit seems to be a mixture of two things.

the code modules can be compiled as standard programs at $8000 and return to Basic when ends...
Code:
Code:
' The action to executed is defined by moduleParameter and other variables
if moduleParameter1=1 then
Command1()
else if moduleParameter=2 then
Command2()
end if

' Before to exit, set moduloLoad to determite the next module to load and the parameters needed
moduleLoad=2
moduleParameter=3

1. the command to run in this module
Q. How to return variables or just use the vars.bas as shared anyway?

2. 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 ?


Once again thank you for you time.
Reply


Messages In This Thread
RE: How to carve up ZX Basic into different ORG values - by RandomiserUsr - 05-22-2021, 08:26 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)