GLBasic forum

Main forum => Bug Reports => Topic started by: MrTAToad on 2011-Mar-19

Title: READBYTE on Palm Pre is slightly wrong
Post by: MrTAToad on 2011-Mar-19
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...
Title: Re: READBYTE on Palm Pre is slightly wrong
Post by: Ian Price on 2011-Mar-20
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.
Title: Re: READBYTE on Palm Pre is slightly wrong
Post by: MrTAToad on 2011-Mar-20
Mine returns 255 instead of -1, although with positive numbers, everything is fine, of course...
Title: Re: READBYTE on Palm Pre is slightly wrong
Post by: Ian Price on 2011-Mar-20
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.
Title: Re: READBYTE on Palm Pre is slightly wrong
Post by: MrTAToad on 2011-Mar-20
It should be signed -127 to +128.  READUBYTE is the unsigned version...
Title: Re: READBYTE on Palm Pre is slightly wrong
Post by: Kitty Hello on 2011-Mar-22
Strange is, that the code was the same for win/pre.

Code (glbasic) Select

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.