Console problem (bug or feature?)

Post Reply
fcg
Posts: 16
Joined: Wed Nov 24, 2010 10:51 pm

Console problem (bug or feature?)

Post by fcg » Sat Dec 18, 2010 12:12 pm

The following code produces (for me) unexpected results:

Code: Select all

#include <nds.h>
#include <stdio.h>

#include "intro.h"
int main() {
    powerOn(POWER_ALL_2D);
    vramSetMainBanks(	VRAM_A_MAIN_BG,
     					VRAM_B_LCD,
     					VRAM_C_SUB_BG,
					VRAM_D_LCD
	);
    videoSetMode(MODE_5_2D);
    videoSetModeSub(MODE_5_2D);
    
    // Init print consoles
    PrintConsole pcTop = *consoleInit( 0, 1, BgType_Text4bpp, BgSize_T_256x256, 0, 1, true, false);
    PrintConsole pcBtm = *consoleInit( 0, 1, BgType_Text4bpp, BgSize_T_256x256, 0, 1, false, false);

    // Load the font
    ConsoleFont font;
    font.gfx = (u16*)font8x8thinTiles;
    font.pal = (u16*)font8x8thinPal;
    font.numChars = 96;
    font.numColors =  font8x8thinPalLen / 2;
    font.bpp = 4;
    font.asciiOffset = 32;
    font.convertSingleColor = false;
	
    // Top screen typing
    font.pal[1] = RGB15(0,31,0);
    consoleSetFont(&pcTop, &font);
    consoleSetWindow(&pcTop, 2, 12, 28, 20);
    consoleSelect(&pcTop);
    iprintf("PONG - a masterpiece by FCG\n\nThanks for all the help overat #dsdev and devkitpro.org/");

   // Btm screen typing
    consoleSelect(&pcBtm);
    font.pal[1] = RGB15(31,31,31);
    ConsoleSetFont(&pcBtm, &font);
    consoleSetWindow(&pcBtm, 2, 12, 28, 20);
    iprintf("This game was built with thedevkitARM toolchain providedby devkitPro - devkitpro.org");
    iprintf("\ndevkitPro is not responsiblefor the game in any way.");

    while(1) {
	swiWaitForVBlank();
    }
    return 0;
}
I would expect that the order in which you consoleSelect , consoleSetFont and consoleSetWindow shouldn't matter since you always pass around a reference to the console you are dealing with. Apparently you have to first consoleSelect and then you can alter some properties.

/fcg

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Console problem (bug or feature?)

Post by WinterMute » Wed Jan 05, 2011 12:27 pm

I've adjusted a few console functions in libnds for 1.4.9 - this code should hopefully work as expected now.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest