Please, do you have an idea of how it would be possible to load an array in C (the one used in OSDK) previously created in BASIC and saved with the STORE command ?
Thank you very much
STOREd oric arrays and C
You can have a program convert the data to a predefined array that would look something like this where your data would be the byte values of your data:
unsigned char data[] = {
0,1,23,44,255
}
You could use a basic program to convert the data to a separate file of ascii numbers separated by commas. If you want to load files... you'll have to set up an array large enough to hold the stuff and they call the appropriate routines to read the file. I'm not an Oric guru so someone else will have to discuss the read specifics but here is how you would define a 256 byte block of memory to put the data in. Were you talking from tape or disk btw? That may impact other people's responses.
unsigned char data[256];
unsigned char data[] = {
0,1,23,44,255
}
You could use a basic program to convert the data to a separate file of ascii numbers separated by commas. If you want to load files... you'll have to set up an array large enough to hold the stuff and they call the appropriate routines to read the file. I'm not an Oric guru so someone else will have to discuss the read specifics but here is how you would define a 256 byte block of memory to put the data in. Were you talking from tape or disk btw? That may impact other people's responses.
unsigned char data[256];
Re: STOREd oric arrays and C
I'm not sure of what is the format used by the STORE command.waskol wrote:Please, do you have an idea of how it would be possible to load an array in C (the one used in OSDK) previously created in BASIC and saved with the STORE command ?
It's probably a better idea to for example write your array in some area of memory (example: HIRES memory), and CSAVE the whole buffer.
Code: Select all
FOR I=0 TO SIZE
POKE #A000+I,ARRAY(I)
NEXT I
CSAVE"data.tap",A#A000,E#A000+SIZE-1
Code: Select all
%osdk%\bin\header -h0 data.tap array.bin
Code: Select all
%osdk%\bin\bin2txt -s1 -f1 -n16
(This will save in C format, as bytes, with 16 entries per line)
Hope this helps
Thank you very much both of you.
in order to enlight the things, I should precise (because I have forgotten) that :
1) the file array was created via the PUT command of the SEDORIC
2) since the array is bidimensionnal (36 cols, 48 rows)
and since an integer itakes two byte, the hires screen is too small (I am in TEXT mode, with a GRAB in order to have a maximum for the program ! )
3) the fact is that with the C of the OSDK, it is possible to call the SEDORIC commands, TAKE for example, it works, it loads the file but where does it go in memory ?
Moreover, there is a risk that the variables of my c program collide with this huge array (3290 bytes !).
And I can tell you, the space is really optimized since the 16 bits of each integer has its role to play in
my program (1 bit for this, 1 for that, 2 for this, 4 for that, 3 for this, and so forth)
4) I cannot permit to waste some space :
3 Ko in memory for the the array itself added to the 3 or 4 Ko corresponding to the lines of data. Shoold I precise that this array can be saved and loaded back since the data in it can change !
That is a cool challenge, isn't it ?
In fact I develop at this moment in BASIC, but if I could develop my thing in C, that would be a bit easier : the basic does not bring the ease a procedural langage like C can be....
If I solve that out, I will definetly leave aside the BASIC and keep concentrated on it in C.
If I don't, well, thats OK, I will do with what I have...
By the way, while I am answering, I finalize one utility (for Windows 9x/2000/XP) :
- A Text screen editor wich permit to create a TEXT page that you can save on a .tap or a .dsk file as a memory block, so that you can (C)LOAD it back when you need it. Very usefull for a text based adventure game with a lot of text !
And to come back in the subject and refering to some recent posts between DBUG and MYSELF about some evolution of the OSDK that inspired me just right now, I have the idea of a small BASIC preprocessor ... It just came to me right now
you write you basic program without numbering, but with a particular syntax like this :
Yes, you understood, a line that start with a & is a label, and when you click on the magic button, the program supress the Labels and the calls to those labels, and do the numbering for you :
Not that difficult to do (it is a bunch of strings replace)
in order to enlight the things, I should precise (because I have forgotten) that :
1) the file array was created via the PUT command of the SEDORIC
2) since the array is bidimensionnal (36 cols, 48 rows)
Code: Select all
DIM T%(35,48)
3) the fact is that with the C of the OSDK, it is possible to call the SEDORIC commands, TAKE for example, it works, it loads the file but where does it go in memory ?
Moreover, there is a risk that the variables of my c program collide with this huge array (3290 bytes !).
And I can tell you, the space is really optimized since the 16 bits of each integer has its role to play in
my program (1 bit for this, 1 for that, 2 for this, 4 for that, 3 for this, and so forth)
4) I cannot permit to waste some space :
3 Ko in memory for the the array itself added to the 3 or 4 Ko corresponding to the lines of data. Shoold I precise that this array can be saved and loaded back since the data in it can change !
That is a cool challenge, isn't it ?
In fact I develop at this moment in BASIC, but if I could develop my thing in C, that would be a bit easier : the basic does not bring the ease a procedural langage like C can be....
If I solve that out, I will definetly leave aside the BASIC and keep concentrated on it in C.
If I don't, well, thats OK, I will do with what I have...
By the way, while I am answering, I finalize one utility (for Windows 9x/2000/XP) :
- A Text screen editor wich permit to create a TEXT page that you can save on a .tap or a .dsk file as a memory block, so that you can (C)LOAD it back when you need it. Very usefull for a text based adventure game with a lot of text !
And to come back in the subject and refering to some recent posts between DBUG and MYSELF about some evolution of the OSDK that inspired me just right now, I have the idea of a small BASIC preprocessor ... It just came to me right now
you write you basic program without numbering, but with a particular syntax like this :
Code: Select all
&start
PRINT "Are you a (b)oy or a (g)irl ?"
GET A$
IF A$="B" THEN GOSUB &boy ELSE GOSUB &girl
PRINT "Hello"
GOTO &start
&boy
B$="boy":RETURN
&girl
B$="girl":RETURN
Code: Select all
10 PRINT "Are you a (b)oy or a (g)irl ?"
20 GET A$
30 IF A$="B" THEN GOSUB 60 ELSE GOSUB 70
40 PRINT "Hello"
50 GOTO 10
60 B$="boy":RETURN
70 B$="girl":RETURN
Is it 35*48, or 36*48 ? In any case, it's more than 3290 bytes, because 3290 is 35*47*2.waskol wrote: (...)
2) since the array is bidimensionnal (36 cols, 48 rows)
(...)(...)Code: Select all
DIM T%(35,48)
Moreover, there is a risk that the variables of my c program collide with this huge array (3290 bytes !).
(...)
And well, it's not that huge
Most of our demos are using a lot more memory than this, to the point where I even use the 16k of overlay memory, and have to use hand made code to access the disc drive
Well, it's the way I was planning to do it.waskol wrote: And to come back in the subject and refering to some recent posts between DBUG and MYSELF about some evolution of the OSDK that inspired me just right now, I have the idea of a small BASIC preprocessor ... It just came to me right now
you write you basic program without numbering, but with a particular syntax like this :
(...)
I was not planning to use &, but it was definitely the idea
(but not as a preprocessor, just as a feature of Bas2Tap)