areyoumad / vba-rerecording

Automatically exported from code.google.com/p/vba-rerecording
GNU General Public License v2.0
0 stars 0 forks source link

Lua hex-supplied color fails if over 0x00FFFFFF #55

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Any draw to a gui command with a color greater than 0x00FFFFFF will fail.

Other methods of supplying colors (e.g. via table) will work.

Example:

while true do
  gui.text(10, 10, "Test 1", 0xFFFFFFFF, 0x000000FF);
  gui.text(10, 20, "Test 2", 0x00FFFFFF, 0x000000FF);
  emu.frameadvance();
end;

The first test will fail (only show an outline, not the actual text) while the 
second line will appear as expected, cyan with a black outline.

Original issue reported on code.google.com by xkeeper@gmail.com on 26 Jul 2010 at 4:07

GoogleCodeExporter commented 8 years ago
Actually, what triggers it is that the highest bit is set, so it's greater that 
0x7fffffff jhaj will fail.

A workaround for this is to enter the value as a "HTML" color string, 
  gui.text(10, 10, "Test 1", "#FFFFFFFF", "#000000FF");
  gui.text(10, 20, "Test 2", "#00FFFFFF", "#000000FF");

Original comment by nitro2...@gmail.com on 7 Dec 2010 at 3:22

GoogleCodeExporter commented 8 years ago
This has to do with using lua_tointeger() which returns a lua_Integer, which on 
most 32-bit machines is a signed int. A workaround is to use doubles and cast 
manually:
uint32 colour = (uint32)lua_tonumber(L, n);
Since lua_Number is normally a double, it can hold a 32-bit integer losslessly.

Original comment by hyperhac...@gmail.com on 27 Jun 2011 at 8:29

GoogleCodeExporter commented 8 years ago
I think this has been fixed.

Original comment by aquan...@gmail.com on 5 Apr 2013 at 9:37