#110263 - mysteryegg - Mon Nov 27, 2006 9:44 am
I hate being a resident n00b, but I'd like to know if there is any established "standard" for touchscreen based menus. I have run into a big problem creating my own menu:
I am using Mode 5 on the touchscreen (set as main) and have used it as a framebuffer to draw simple button fields onto the screen. The buttons change color on click like any standard GUI button behavior to indicate being depressed. I need to label these buttons, so since I am terrible at graphic design, I thought I'd just iprintf() some text on top of BG3 where I've drawn my menu.
Problem is, doing any kind of BG0 initialization including ConsoleInitDefault() scrambles the image from BG3. Do people not use a console on top of other layers? Does everybody just make tiled menus? Looking for some examples.
#110267 - Lick - Mon Nov 27, 2006 9:51 am
You need more VRAM. You need to learn about the map, tile and bmp bases. Bases are basically blocks of VRAM. Map and bmp bases are 2kb and tile bases are 16kb. Using bases, you can play with the VRAM.
Check out these defines: BG_MAP_BASE(), BG_TILE_BASE(), BG_BMP_BASE().
And these: BG_MAP_RAM[_SUB](), BG_TILE_RAM[_SUB](), BG_BMP_RAM[_SUB]().
The first 3 are for setting the BGx_CR. The last three are for copying the data to that base.
BG3_CR |= BG_BMP_BASE(8)...
memcpy((u16*)BG_BMP_RAM(8), bmp_data, bmp_data_size);
_________________
http://licklick.wordpress.com
#110301 - thegamefreak0134 - Mon Nov 27, 2006 6:59 pm
Basically, it sounds like you have a VRAM conflict. Remember that all VRAM really doesn't exist independantly, but is rather mapped to the locations the hardware can read from. You have the console using the same VRAM as your BG, and the easiest thing to do here is to change where your BG is being stored. (ie, pick another compatable bank.)
-gamefreak
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#110322 - mysteryegg - Mon Nov 27, 2006 9:43 pm
OK, there doesn't seem to be any conflict between the framebuffer and the console anymore, but I can only see the framebuffer if it has a higher priority, and I get a black screen (with no text) otherwise. Assuming I don't need a custom font, how should I fix this code? (I am very tempted, if I can't get this to work with minimal effort, to scrap it all and just switch to a tiled menu or write directly to the OAM...)
Code: |
powerON(POWER_ALL_2D);
...
videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE | DISPLAY_BG0_ACTIVE);
videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
vramSetMainBanks (
VRAM_A_MAIN_BG_0x6000000,
VRAM_B_MAIN_BG_0x6020000,
VRAM_C_SUB_BG_0x6200000,
VRAM_D_LCD);
BG3_CR = BG_BMP16_256x256 | BG_PRIORITY_3; //set up frame buffer
BG3_XDX = 1 << 8;
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = 1 << 8;
BG3_CX = 0;
BG3_CY = 0;
//this is where I'm probably messing up...
BG0_CR = BG_MAP_BASE(31) | BG_PRIORITY_0;
BG_PALETTE[255] = RGB15(0,31,0); //green
consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16);
SUB_BG3_CR = BG_BMP8_256x256;
...
lcdMainOnBottom();
//sub screen "splash" up top
dmaCopy(Splash_bin, BG_GFX_SUB, 256*256);
dmaCopy(palette_bin, BG_PALETTE_SUB, 256*2);
//clear touchscreen
for(i = 0; i < 256*192; i++)
BG_GFX[i] = RGB15(15,15,15) | BIT(15);
//draw a couple of red buttons
rectfill(40, 40, 176, 40, BG_GFX, RGB15(31,0,0) | BIT(15));
rectfill(40, 112, 176, 40, BG_GFX, RGB15(31,0,0) | BIT(15));
//write something
iprintf("testing..."); |
Yeah, I know I'm clueless when it comes to consoles, palettes, maps, the whole shabang. It's hard starting on the DS not having done GBA before because there's no knowing how much attention I should pay to GBA tutorials without knowing "does it not work because I'm doing it wrong, or is there a difference in the way the DS does it? I figured, since I have a time shortage, and since I'm making a simple application rather than a game, there's not much reason for me to take the time to get into sprites.
#110355 - mysteryegg - Tue Nov 28, 2006 1:21 am
I give up. I've managed to get sprites to show up on top of the menu, so I will just make the menu out of sprites instead of trying to get the console working. I assume this is what most developers do anyway to have those nice "buttons flying across the screen" effects :-P