I'd written a simple map editor in BlitzPlus which writes out my mapdata as Bytes and when I read it into GLB the values are in the range -127...+127 and I needed them in the range 0...255. Here is a quick and easy way to do that which although not rocket science does help keep your code looking cleaner.
Function Code
// .------------------------------------.
// | Unsign READBYTE value to 0...255 |
// `------------------------------------'
FUNCTION UnsignByte: value%
IF value% < 0 THEN value% = 256 + value%
RETURN value%
ENDFUNCTION
Usage
signed_byte% = UnsignByte(signed_byte%)
Hope you find it useful =)
Nice - but look up READUBYTE in the docs ;)
Noob alert here lol. I guess it's still handy for poeple to see how it's converted even though maybe I should read the docs more next time =D
I only noticed because someone else posted about it a while ago =D
I think we've all been caught out by that one in the past, especially us old Blitz users.
Yep, I'm the original one that got caught out with the problem of reading bytes from a file, Thanks Gernot for fixing it so fast back then :-)
Quote from: Moru on 2011-May-09
Yep, I'm the original one that got caught out with the problem of reading bytes from a file, Thanks Gernot for fixing it so fast back then :-)
Hehe guess we won't be the first, OR the last lol =)