Basic <-> C data exchanges
Posted: Sun May 04, 2014 10:45 am
I'm working with Maximus on his RPG.
I've rewritten some code in C (drawing a labyrinth in HIRES with the line assembler routines found on miniserve) and I need to exchange some data with the rest of the application which is coded in Basic.
After some thoughts here is what we have planned:
- First we load a Basic program from a Sedoric disk;
- From this Basic program you can either start other Basic programs (loading them from the Sedoric disk) or the C program;
- Then from any program you can start other Basic or C programs.
Therefore we need to exchange some data from program to program.
It contains basically the position and orientation in the labyrinth (3 bytes) and the characters data (about 400 bytes).
Currently Basic programs do the following:
- position and orientation are kept at #BFE0 and the two next addresses ;
- characters data are first written at #A000 (while in text mode obviously) and saved to disk ;
- the new program then get the small data from #BFE0, then loads the characters data and read them into arrays.
Is it safe to write data at #BFE0 and above (it's marked as reserved in the manual) ?
When we switch programs with a LOAD, does the HIRES memory get wiped (provided we are in text mode when we do that) ?
If it doesn't then I'm inclined to put everything there, switch programs and get everything from there before doing anything else in the new program (switching to HIRES for example).
Of course if you have better solutions I'm interested.
Oh and one last question, in order to load/save data from/to a Sedoric disk in C should I better use the assembler code found here:
http://forum.defence-force.org/viewtopic.php?f=4&t=222
or call Sedoric !LOAD with the sedoric function found in lib.h like this:
sedoric("!LOAD(\"TEAM.BIN\")");
Sorry for the length of my message and thank you for reading through here.
I've rewritten some code in C (drawing a labyrinth in HIRES with the line assembler routines found on miniserve) and I need to exchange some data with the rest of the application which is coded in Basic.
After some thoughts here is what we have planned:
- First we load a Basic program from a Sedoric disk;
- From this Basic program you can either start other Basic programs (loading them from the Sedoric disk) or the C program;
- Then from any program you can start other Basic or C programs.
Therefore we need to exchange some data from program to program.
It contains basically the position and orientation in the labyrinth (3 bytes) and the characters data (about 400 bytes).
Currently Basic programs do the following:
- position and orientation are kept at #BFE0 and the two next addresses ;
- characters data are first written at #A000 (while in text mode obviously) and saved to disk ;
- the new program then get the small data from #BFE0, then loads the characters data and read them into arrays.
Is it safe to write data at #BFE0 and above (it's marked as reserved in the manual) ?
When we switch programs with a LOAD, does the HIRES memory get wiped (provided we are in text mode when we do that) ?
If it doesn't then I'm inclined to put everything there, switch programs and get everything from there before doing anything else in the new program (switching to HIRES for example).
Of course if you have better solutions I'm interested.
Oh and one last question, in order to load/save data from/to a Sedoric disk in C should I better use the assembler code found here:
http://forum.defence-force.org/viewtopic.php?f=4&t=222
or call Sedoric !LOAD with the sedoric function found in lib.h like this:
sedoric("!LOAD(\"TEAM.BIN\")");
Sorry for the length of my message and thank you for reading through here.