In my program I'm emulating the nametables by creating a single texture that is all four nametables (512x480 px). It is working right now with all tiles having attribute 0.
Now I'm having trouble with coming up with a formula to get and apply the correct tile attributes.
The wiki has this but I don't know what to make of it. I see the << are bit shifts, but other than that I have no idea what is going on.
edit: ah ok, I guess this is what is used to generate the attribute table. Not quite what I want. Maybe reversing this solves my problem #2?
So, what I can't do in a simple formula is, knowing a tile's coordinates:
1 - know which byte to read.
2 - get the attribute for it from that byte.
I've managed to get it done by creating 64 case switches, but needless to say that is incredibly slow.
I'm programming in GML but I guess a solution in any language would be all I need.
edit2: Is a lookup table the answer to problem #1?
Now I'm having trouble with coming up with a formula to get and apply the correct tile attributes.
The wiki has this but I don't know what to make of it. I see the << are bit shifts, but other than that I have no idea what is going on.
Code:
value = (bottomright << 6) | (bottomleft << 4) | (topright << 2) | (topleft << 0)
edit: ah ok, I guess this is what is used to generate the attribute table. Not quite what I want. Maybe reversing this solves my problem #2?
So, what I can't do in a simple formula is, knowing a tile's coordinates:
1 - know which byte to read.
2 - get the attribute for it from that byte.
I've managed to get it done by creating 64 case switches, but needless to say that is incredibly slow.
I'm programming in GML but I guess a solution in any language would be all I need.
edit2: Is a lookup table the answer to problem #1?