#163298 - Talen - Mon Sep 29, 2008 1:42 am
im having a bit of a style delima
im working on some NDS code involving 64x64 tile BG's
and what im wondering is i have 2 ways to deal with my position 2 memory index converter.
its a bit of a delima for me just want to know what someone else thinks
first way is
the second way is
im working on some NDS code involving 64x64 tile BG's
and what im wondering is i have 2 ways to deal with my position 2 memory index converter.
its a bit of a delima for me just want to know what someone else thinks
first way is
Code: |
#define POS2IDX(x, y) ((((x/32)+((y/32)+(y/32)))*32*32) + ((x%32) + ((y%32)*32))) memoryMap[POS2IDX(x,y)] = tileId; |
the second way is
Code: |
// Number of tiles in a `small' map (i. e. not the full 64x64 one) const int _TILE_W = 32; const int _TILE_H = 32; // Sets a tile in 64x64 map // It takes care of the fact that the DS puts 4 32x32 maps after each other void setTile(u16* memoryMap, int x, int y, const u16 tileId) { int n; if(x >= _TILE_W && y >= _TILE_H) { n = 3; x -= _TILE_W; y -= _TILE_H; } else if(x >= _TILE_W) { n = 1; x -= _TILE_W; } else if(y >= _TILE_H) { n = 2; y -= _TILE_H; } else { n = 0; } memoryMap[n * _TILE_W * _TILE_H + x + y*_TILE_W] = tileId; } |