RGB15 does not work

Post Reply
Antoine_935
Posts: 11
Joined: Mon May 11, 2009 1:11 am

RGB15 does not work

Post by Antoine_935 » Tue May 12, 2009 6:11 pm

Hi there.

Still playing around to learn libnds, I'm in trouble understanding some basic things.
Maybe I could avoid lots of these questions if I could find some theory about bg and memory, but I still didn't find any really good :( Do you have some links ?

Ok, here are my problems.
(Note: I'm currently working under the Desmume emulator)

The first one is about MODE_FB, a little misunderstanding...
Consider this code:

Code: Select all

int main() {
    videoSetMode(MODE_FB0);
    vramSetBankA(VRAM_A_LCD);
    lcdMainOnTop();
    
    drawHorizontalLine(VRAM_A, 30, 30, 50, RGB15(31, 31, 31));
    drawVerticalLine(VRAM_A, 30, 30, 50, rand());
    
    drawRect(VRAM_A, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, rand());
    
    while(1) {
        swiWaitForVBlank();
    }
    
    return 0;
}
So far, the above works fine, but maybe you can spot some slight errors ?
When I have a look at the documentation: MODE_FB0
MODE_FB0 video display from main memory
MODE_FB1 video display directly from VRAM_A in LCD mode
Therefore I thought that using MODE_FB1 instead of FB0 would work, but no :( Why ?

My second problem is related to MODE_3_2D. Look for the comments, they contain the questions.
This code has been stolen from another post here, and a little bit changed: that's maybe where my error comes from, but... can't find

Code: Select all

int main(void) {
	PrintConsole console;
	touchPosition touch;
	int bgOffset;
	u16 *gfxBG;
	
	videoSetMode(0); // Disable main screen
	videoSetModeSub(MODE_3_2D);
	
	console = *consoleInit(0, 1, BgType_Text4bpp, BgSize_T_256x256, 0, 1, false, true);
	
	bgOffset = 2; // Why this ?
	
	bgInitSub(BG_PRIORITY_3, BgType_Bmp16, BgSize_B16_256x256, bgOffset, 0 );
	gfxBG = BG_GFX_SUB + ((bgOffset * 16384) >> 1);
	
	iprintf("Console works fine");
	
	while(1) {
		scanKeys();
		
		if(keysHeld() & KEY_TOUCH) {
			touchRead(&touch);
			
			// If I don't shift left RGB15, it will not display at all
			// where on the previous program it worked nicely. Did I miss something ?
			gfxBG[touch.py * SCREEN_WIDTH + touch.px] = RGB15(31, 31, 31) << 1;
		}
		
		swiWaitForVBlank();
	}
}
Edit: mmh, comments are not easy to find, sorry... let me tell questions here.
1. What's the use and meaning of this bgOffset I have to use in bgInitSub ?
2. RGB15 macro works weirdly this time. I have to shift it left in order to get it displayed...

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: RGB15 does not work

Post by vuurrobin » Tue May 12, 2009 8:19 pm

not sure about MODE_FB1 or bgOffset, but if you're not working with the framebuffer, you need to set the alphabit that tells if the pixel is visible or not. if you use RGB16(1, 31, 31, 31) it should work with mode 3.

as for links, have you looked at pataters manual and dev-scenes tutorial? they may be a bit outdated, but there is still some good info on it.

Antoine_935
Posts: 11
Joined: Mon May 11, 2009 1:11 am

Re: RGB15 does not work

Post by Antoine_935 » Tue May 12, 2009 11:23 pm

Compiler can't find RGB16 macro, where is it defined ? (anyway I defined it right now, but duplication is a bad idea...)

I already read Patater's manual, but he's not really talking about this, or I missed it.
However I should have a deeper look at dev-scenes...

Thank you for your answer ;)

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: RGB15 does not work

Post by vuurrobin » Wed May 13, 2009 9:03 pm

its ARGB16(), defined in sprite.h

sorry, my bad :oops:

Antoine_935
Posts: 11
Joined: Mon May 11, 2009 1:11 am

Re: RGB15 does not work

Post by Antoine_935 » Thu May 14, 2009 5:54 pm

Found it :) it was located in nds/arm9/video.h

eKid
Posts: 65
Joined: Sat Dec 06, 2008 6:07 pm
Contact:

Re: RGB15 does not work

Post by eKid » Fri May 15, 2009 7:51 am

Hmm, seems like an error in the docs there. FB0/1/2/3 modes should use VRAM_A,B,C,D, and I think MODE_FIFO should be that other mode it says MODE_FB0 is for.

Antoine_935
Posts: 11
Joined: Mon May 11, 2009 1:11 am

Re: RGB15 does not work

Post by Antoine_935 » Sun May 17, 2009 12:13 pm

Good to know, thx :)

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests