On desktop machines, this reads in a signed number. Unfortunately on the Pre, READBYTE reads in an unsigned number, so -1 becomes 255
I discovered this whilst wondering why 255 moves were allowed on a level in Spots :) I use -1 to specify that there are unlimited moves, although I check for a negative number...
There is a problem somewhere, but not sure exactly where. I had to change my data loading in Palm B'lox!, but in my current game READBYTE seems to work fine.
Mine returns 255 instead of -1, although with positive numbers, everything is fine, of course...
READBYTE only reads 0-255 properly anyway, doesn't it?
From the Help files
QuoteReads the value val%% from the file that has been opened on channel channel%.
BYTE = 1 Byte, (0..255)
Integer numbers will be loaded without sign (unsigned). Thus the value -127 will be BYTE 255.
It should be signed -127 to +128. READUBYTE is the unsigned version...
Strange is, that the code was the same for win/pre.
LOCAL n%
wrap(n)
PRINT "n="+n%, 0,0
SHOWSCREEN
KEYWAIT
SUB fo:
ENDSUB
INLINE
void Assign(void* pC)
{
*(unsigned char*)pC = -1;
}
void wrap(int& l)
{
char c;
Assign(&c);
l = c;
}
ENDINLINE
IMPORT void wrap(int&)
That should print -1 on all platforms.