It's me again... I am sure this has been seen before, but I couldn't find a discussion.
I have tiled generated maps and load them into a Gideros TileMap. Tiled uses the ID of the tile to indicate rotation by setting high bits, which have to be read from the ID, then removed from the ID, then passed on to TileMap. There is code discussing this at tiled, and in the gideros wiki
http://doc.mapeditor.org/en/stable/reference/tmx-map-format/#tile-flippinghttps://wiki.giderosmobile.com/index.php/CBump_TemplateMy problem is that the code similar to the one on that page works in the player on Windows, but not when deployed on Android (Pixel 3)
Here is what I am doing
local FLIPPED_HORIZONTALLY_FLAG = 0x80000000;
local FLIPPED_VERTICALLY_FLAG = 0x40000000;
local FLIPPED_DIAGONALLY_FLAG = 0x20000000;
--
-- for each tile ID gid
-- Read flipping flags
flipHor = gid & FLIPPED_HORIZONTALLY_FLAG
flipVer = gid & FLIPPED_VERTICALLY_FLAG
flipDia = gid & FLIPPED_DIAGONALLY_FLAG
-- Convert flags to gideros style
if(flipHor ~= 0) then flipHor = TileMap.FLIP_HORIZONTAL end
if(flipVer ~= 0) then flipVer = TileMap.FLIP_VERTICAL end
if(flipDia ~= 0) then flipDia = TileMap.FLIP_DIAGONAL end
-- Clear the flags from gid so other information is healthy
local oldgid = gid -- debug
gid = gid & ~ (
FLIPPED_HORIZONTALLY_FLAG |
FLIPPED_VERTICALLY_FLAG |
FLIPPED_DIAGONALLY_FLAG
)
local newgid = gid -- debug
if oldgid ~= newgid then
print("flipped gid", oldgid, newgid)
end |
If I run this in the Windows player, it works as expected and the output looks about like this
flipped gid 1610612812 76
flipped gid 2684354637 77 |
If I run it on the Android Gideros player, it flips all the IDs to 0
flipped gid 1610612812 0
flipped gid 77 0
flipped gid 13 0
flipped gid 2684354637 0 |
Looking for documentation of bitwise operations across different OS? Different architecture? I am pretty sure that my windows box and android are both 64 bit. How do I have to do this so it works across all platforms?
Comments
As hgy29 said: the gideros player includes all the plugins but when you export you need to add the plugins yourself.
It seems to be using unsigned integers on windows, and signed integers on android for bitwise. If you print out B32 in gideros it's 2147483648 both ways, but maybe for bitwise, the underlying C++ code somewhere does the shift thinking they are signed on Android.
windows
Uploading finished.
B1 %x 1
B31 %x 40000000
B32 %x 80000000
B1|B31 %x 40000001
B1|B32 %x 80000001
android
main.lua is uploading.
Uploading finished.
B1 %x 1
B31 %x 40000000
B32 %x 80000000
B1|B31 %x 40000001
B1|B32 %x 80000001
same!
Maybe your android player doesn't include the bitop plugin?
I have a big android player you can try:https://github.com/mokalux/gideros-player-for-android
Are you testing over wifi?
The lighter the apk the less plugins it has
Mine has almost all the plugins 26.3 Mb!
We could post an up to date android player somewhere here in the forum or in the wiki?
Likes: MoKaLux
To overcome the issue with tiled, I first converted the tiled value to int64 in lua, and they applied bitwise ops on this 64 bit number.
Likes: antix
http://docs.giderosmobile.com/reference/lua/int64#int64
So the code now looks like this for reading of the top bits
Then, to clear the top three bits I do this
Here is an extract of my (ugly) code:
Likes: perrochon
(WNF: no variable can be shortened without generating conflict with another)
Likes: MoKaLux