Problem testing PrintConsole
Posted: Fri Jan 02, 2009 12:20 am
I was successfully able to get an 8bit background on layer 2 with some transparency spots showing a 16 bit background on layer 3 underneath. Once I figured out how to set the mapbase offset correctly (at least I'm pretty sure I did) so that one would load into BANK A and the other into BANK B things seemed fine.
Now, I've removed the 8bit layer and am trying to put a print Console on a layer above the 16 bit one, 0 in this case. There are a handful of problems, but I think I'm close. EDIT - I have looked at the post a little bit down from here and tried to use it as a reference since it's pretty much the same scenario (I'm using 2 VRAM banks though...) but it didn't help much...
1. If I put up text before loading the background's graphics, that text is not shown.
2. Text displayed afterward shows up, but there are artifact characters elsewhere on the screen.
3. Clearing the console (Pressing and releasing A button) and trying to display more text results in a blue horizontal bar across
the top of the screen and more text is displayed successfully. The other artifacts are gone. I've had varying results as I've tried to get the right
mapbase and tilebase values. If I understand correctly... I need to get those into VRAM_B, so the mapbase must be 64 or higher and the tilebase 8 or higher. Outputting the gfx location (as long as I'm doing even that part right) seems to verify my assumption, but still... the results aren't quite right.
4. Here's the code as it stands. The only compiler warning is the output of bgGetGfxPtr(topScreen.bgId) which it says is a u16 ** when it expects an unsigned int. I couldn't seem to get that to cast down right... but it still shows outputs what I expect to see.
Now, I've removed the 8bit layer and am trying to put a print Console on a layer above the 16 bit one, 0 in this case. There are a handful of problems, but I think I'm close. EDIT - I have looked at the post a little bit down from here and tried to use it as a reference since it's pretty much the same scenario (I'm using 2 VRAM banks though...) but it didn't help much...
1. If I put up text before loading the background's graphics, that text is not shown.
2. Text displayed afterward shows up, but there are artifact characters elsewhere on the screen.
3. Clearing the console (Pressing and releasing A button) and trying to display more text results in a blue horizontal bar across
the top of the screen and more text is displayed successfully. The other artifacts are gone. I've had varying results as I've tried to get the right
mapbase and tilebase values. If I understand correctly... I need to get those into VRAM_B, so the mapbase must be 64 or higher and the tilebase 8 or higher. Outputting the gfx location (as long as I'm doing even that part right) seems to verify my assumption, but still... the results aren't quite right.
4. Here's the code as it stands. The only compiler warning is the output of bgGetGfxPtr(topScreen.bgId) which it says is a u16 ** when it expects an unsigned int. I couldn't seem to get that to cast down right... but it still shows outputs what I expect to see.
Code: Select all
#include <nds.h>
#include <stdio.h>
#include "spriteinfo.h"
#include "test1_bin.h"
int main(void) {
//---------------------------------------------------------------------------------
int i = 0;
int width = 16, length = 16, frame = 0, max_frame = 2;
int sp2x = 120, sp2y = 80;
u8 lcdswapped = 0;
touchPosition touch;
videoSetMode(MODE_5_2D);
videoSetModeSub(MODE_0_2D);
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankB(VRAM_B_MAIN_BG);
vramSetBankD(VRAM_D_SUB_SPRITE);
// 16 bit background on layer 3 using VRAM A
int bg3id = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
// Print console on layer 0, mapbase should be 64*2k = 128 and at 0x06020000
// tilebase is at 9 * 16k = 144, should be offset enough from mapbase and in VRAMB... I think...
PrintConsole topScreen = *consoleInit(0, 0, BgType_Text4bpp, BgSize_T_256x256, 64, 9, true);
consoleSelect(&topScreen);
oamInit(&oamSub, SpriteMapping_1D_128, false);
u16* gfxSub = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_256Color);
u16* gfxSub2 = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_256Color);
for(i = 0; i < 4; i++) SPRITE_PALETTE_SUB[i] = face_Pal[i]-32768;
//This text is not seen
iprintf("\tsometest\n");
DC_FlushAll();
dmaCopyWords(3, face_Sprite + length*width*frame, gfxSub, 256);
dmaCopyWords(3, face_Sprite + length*width*frame, gfxSub2, 256);
dmaCopyWords(3, test1_bin, bgGetGfxPtr(bg3id), test1_bin_size);
oamSet(&oamSub, 1, sp2x, sp2y, 0, 0, SpriteSize_16x16, SpriteColorFormat_256Color, gfxSub2, -1, false, false);
iprintf("\n\n\tHello DS dev'rs\n");
iprintf("\twww.drunkencoders.com\n");
iprintf("\twww.devkitpro.org\n");
iprintf("\tprint console bgId\n\tgfx are at: 0x%x", bgGetGfxPtr(topScreen.bgId));
while(1) {
scanKeys();
if(keysHeld() & KEY_TOUCH){
touchRead(&touch);
}
if(keysUp() & KEY_A){
frame++;
if(frame > max_frame) frame = 0;
DC_FlushRange(face_Sprite + length*width*frame, 256);
dmaCopyWords(3, face_Sprite + length*width*frame, gfxSub, 256);
consoleClear();
iprintf("\n\n\tHello DS dev'rs\n");
iprintf("\twww.drunkencoders.com\n");
iprintf("\twww.devkitpro.org\n");
}
if(keysHeld() & KEY_RIGHT)
sp2x++;
if(keysHeld() & KEY_LEFT)
sp2x--;
if(keysHeld() & KEY_UP)
sp2y--;
if(keysHeld() & KEY_DOWN)
sp2y++;
if(keysUp() & KEY_L){
lcdSwap();
if(lcdswapped)lcdswapped = 1; else lcdswapped = 0;
}
oamSet(&oamSub,
0,
touch.px,
touch.py,
0,
0,
SpriteSize_16x16,
SpriteColorFormat_256Color,
gfxSub,
-1,
false,
false);
oamSet(&oamSub,
1,
sp2x,
sp2y,
0,
0,
SpriteSize_16x16,
SpriteColorFormat_256Color,
gfxSub2,
-1,
false,
false);
swiWaitForVBlank();
oamUpdate(&oamSub);
}
return 0;
}