#118749 - AdolescentFred - Fri Feb 16, 2007 11:54 am
I've been working through tutorials and examples trying to learn gba programming and I can't get the tile mapping to work. My code (below) is copied and adapted from the PERN Project day five and doesn't seem to work properly.
as I understand it this should show a screen of mainly tile 1 (all green) with some of tile 2 (all blue) in the pattern of map[]. Instead I get this:
[Images not permitted - Click here to view it]
I don't think it's actually reading the map because it looks like that whatever I do to the map (change it or omit it). Anybody know what I am missing?
Thanks in advance
~Fred
Code: |
#include <gba.h>
u16 tileSet[8*8*2] = {1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2}; u16 map[16*16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,2,1,1,2,2,1,1,1,2,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1}; int main() { u16* vramMap = (u16*)SCREEN_BASE_BLOCK(32); u16* vramTiles = (u16*)CHAR_BASE_BLOCK(0); int i; for (i = 0;i<(8*8*2);i++) vramTiles[i] = tileSet[i]; for (i = 0;i<(16*16);i++) vramMap[i] = map[i]; BG_PALETTE[0] = RGB16(31,0,0); BG_PALETTE[1] = RGB16(0,31,0); BG_PALETTE[2] = RGB16(0,0,31); SetMode(MODE_2 | BG2_ENABLE); REG_BG2CNT = BG_256_COLOR | ROTBG_SIZE_128x128 | (32 << 8) | (0 << 2); } |
as I understand it this should show a screen of mainly tile 1 (all green) with some of tile 2 (all blue) in the pattern of map[]. Instead I get this:
[Images not permitted - Click here to view it]
I don't think it's actually reading the map because it looks like that whatever I do to the map (change it or omit it). Anybody know what I am missing?
Thanks in advance
~Fred