Unsigned bytes
Is it possible to have a byte (.b) be handled as unsigned rather than signed?
I'm reading a tilemap as a binary file with one byte representing one tile. The values in the tilemap are unsigned (0-255). I read the tilemap into a byte array in Blitz Basic and the values become signed when reading from the array (all values after 128 become negative). Can I overcome this without using a word (.w) array? |
I just figured out one way to do it. If you look at the example:
Code:
; Byte variables in BB2 are signed ( -127..128) |
Yeah, all variables are signed in Blitz unfortunately. The simplest way around it would be to use a Word array, with the obvious downside of doubled memory usage. It shouldn't significantly slow things down however, given the 16-bit bus on even the lowest of Amigas.
|
Quote:
|
Probably not. If the compiler was clever and saw that you were loading multiple 8-bit values from adjacent locations (such as a string or an array), it might be able to load two at once, but I don't think the Blitz compiler is all that smart when you're dealing with each value separately. It would be an interesting benchmark to test, but I can't see there being any difference at all.
|
You can turn off overflow errors in the compiler settings if you know what you're doing.
|
Well hellooooo, it's me going nuts again over some undecipherable bug, and it turns out, it's Blitz pulling the rug from under my feet again and not me doing something wrong :mad
This "all variables are signed" shit is mental. Now I need to do this with a Word variable which was throwing negative values after 65KB :banghead:banghead:banghead Thanks MickGyver and Daedalus for the light thrown on this. |
Quote:
|
All times are GMT +2. The time now is 09:45. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.