#170165 - Azenris - Sat Sep 05, 2009 1:00 am
Hello I have the following code
Have I done this correctly, I was wanting 3 layers, to one screen (using MODE_0_2D) and a tile set
of (128 - 16*16 size tiles (512 meta tiles)).
Later I have the following
Looking ok so far? :p
I been looking through some of the libnds files and is has
So i use BG_TILE_BASE and BG_MAP_BASE macros when setting up the BG control and BG_MAP_RAM and BG_TILE_RAM
when I want to read and write to those locations?
Basically just wanted to know if I atleast got this bit right and then I can assume the problem
lies within another section of my code. TY
EDIT:
sorry to ask another question, hope you don't mind. I have
It basically loads a tile into the tileset. I made some text output to the lower screen on some variables. It showed:
tile_graphic_size is defined as 256, but the tiles are jumping by 512 bytes.
This decided the writing location, as the index goes up shouldnt it add an additional 256 bytes?
Sorry I posted so many questions lately :/ I am trying on my own too! TY if any helps
EDIT:
its almost 4am, maybe I should sleep im probably doing it all wrong or just not thinking straight!
EDIT Next day:
nevermind I figured it out, i was using u16* instead of u8*. I got my entire screen loading now.
_________________
My Homebrew Games
Code: |
REG_BG0CNT = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY(2); REG_BG1CNT = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(1) | BG_TILE_BASE(3) | BG_PRIORITY(2); REG_BG2CNT = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(2) | BG_TILE_BASE(5) | BG_PRIORITY(2); |
Have I done this correctly, I was wanting 3 layers, to one screen (using MODE_0_2D) and a tile set
of (128 - 16*16 size tiles (512 meta tiles)).
Later I have the following
Code: |
m_pMain_Map = BG_MAP_RAM(0); m_pMain_Tileset = BG_TILE_RAM(1); |
Looking ok so far? :p
I been looking through some of the libnds files and is has
Code: |
#define BG_TILE_BASE(base) ((base) << TILE_BASE_SHIFT) #define BG_MAP_BASE(base) ((base) << MAP_BASE_SHIFT) #define BG_MAP_RAM(base) ((u16*)(((base)*0x800) + 0x06000000)) #define BG_TILE_RAM(base) ((u16*)(((base)*0x4000) + 0x06000000)) #define CHAR_BASE_BLOCK(base) (((base)*0x4000)+ 0x06000000) #define SCREEN_BASE_BLOCK(base) (((base)*0x800) + 0x06000000) |
So i use BG_TILE_BASE and BG_MAP_BASE macros when setting up the BG control and BG_MAP_RAM and BG_TILE_RAM
when I want to read and write to those locations?
Basically just wanted to know if I atleast got this bit right and then I can assume the problem
lies within another section of my code. TY
EDIT:
sorry to ask another question, hope you don't mind. I have
Code: |
void CScreenManager::LoadTileIntoSet(u8 layer, u8 tileIndex, u16 tile) { // add the tileID into the loaded tiles m_loadedTiles[layer][tileIndex] = tile; // locate data on this tile const tileData *pTile = g_pGame->GetTileData(tile); // locate memory location to write to u16 *pMemoryLoc = NULL; if (layer == 0) pMemoryLoc = m_pMain_Tileset0 + (tileIndex * tile_graphic_size); else pMemoryLoc = m_pMain_Tileset1 + (tileIndex * tile_graphic_size); // write it into memory dmaCopy(pTile->pGraphics, pMemoryLoc, tile_graphic_size); } |
It basically loads a tile into the tileset. I made some text output to the lower screen on some variables. It showed:
Code: |
tileIndex: 0, tile: 159, mem: 6004000 tileIndex: 1, tile: 207, mem: 6004200 tileIndex: 2, tile: 343, mem: 6004400 tileIndex: 3, tile: 337, mem: 6004600 tileIndex: 4, tile: 341, mem: 6004800 tileIndex: 5, tile: 339, mem: 6004a00 tileIndex: 6, tile: 166, mem: 6004c00 |
tile_graphic_size is defined as 256, but the tiles are jumping by 512 bytes.
Code: |
pMemoryLoc = m_pMain_Tileset1 + (tileIndex * tile_graphic_size); |
This decided the writing location, as the index goes up shouldnt it add an additional 256 bytes?
Sorry I posted so many questions lately :/ I am trying on my own too! TY if any helps
EDIT:
its almost 4am, maybe I should sleep im probably doing it all wrong or just not thinking straight!
EDIT Next day:
nevermind I figured it out, i was using u16* instead of u8*. I got my entire screen loading now.
_________________
My Homebrew Games