Structure in C
/* The S3M file header */
char name[28]; // song name
unsigned char eofchar, typ, dummy[2];
unsigned short ordnum, insnum, patnum, flags, cwtv, ffi;
char scrm[4];
unsigned char Vxx, Axx, Txx, mastervolume, uc,dp,dummy2[8];
unsigned short special;
unsigned char channelsettings[32];
-------------------------------------------------------------
fread(name, 1, 0x60, fp); // Read S3M file header
With "name" being limited to 28 Bytes, the other bytes (96-28=68) will be also read into memory. And because of the defined Structure, all following bytes in the File will stored into the memory, but also at the right variables.
There is no AGK2-Tier-1-Command, which could do MyTypeFromMemBlock() or something.
So in the File there are the first 28 Characters for a String. And after that, there are some other Variables. But without having "Byte" or a limited String, I have to use
integer GetMemblockByte( memID, offset )
integer GetMemblockByteSigned( memID, offset )
integer GetMemblockShort( memID, offset ) ... and integer GetMemblockUnsignedShort( memID, offset ) (Had to write it myself)
string GetMemblockString( memID, offset, length )
I can't say: MyType = GetMemblockByType(memID, offset, Type)
Type MyType
i as Integer
b as Byte
... a as Byte[10] // array of 10 Bytes for later M.a[i]=...
EndType
M as MyType
M = GetMemBlockByType(0,0,MyType) // this is one line
But I have to do: M.i = GetMemBlock... M.b=GetMemBlock ... and so on, for every Variable in MyType. And with Arrays of something, I would have to do Loops.
I you wish, you can look here. I am trying to "convert" that code. There is also a PDF linked at this video description
How Strings work in Pascal http://wiki.freepascal.org/String
The next problem is, that I don't know, if the Command reads Characters or Bytes from the MemBlock in AGK2-Tier-1-Basic. A Character can be 1 or 2 Bytes. Because of ANSI / ASCII, UTF8, Unicode. So what would happend, if I had a bunch of Bytes which are UTF8? I don't have to save the lenght of a String in my File. I could do so, but I don't have to and a lot of the old DOS/Amiga file Formats are not so dynamic.