gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Help Please, 2 rootation screens ?

#134177 - jonnyhilly - Wed Jul 11, 2007 9:53 am

Hi, Just trying to write my first DS homebrew project.
I'm trying to get 2 rotation screens showing up, but to no avail.
The top/map sceen shows up fine, and I can alter pixels, but the bottom screen, is always blank.
Here is the setup demo code, what am I doing wrong please ?
help appreciated, thanks


// Turn on everything
powerON(POWER_ALL);


//MODE_5_2D is extended rotation mode.. can be used like framebuffer, with direct write to pixels
videoSetMode(MODE_5_2D | DISPLAY_BG2_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);


// set up bitmap backgrounds 8 bit,paletted
BG2_CR = BG_BMP8_256x256;
BG3_CR = BG_BMP8_256x256;

// set the rotation attributes:
BG2_XDX = 1 << 8;
BG2_XDY = 0;
BG2_YDX = 0;
BG2_YDY = 1 << 8;
BG2_CX = 0;
BG2_CY = 0 ;

BG3_XDX = 1 << 8;
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = 1 << 8;
BG3_CX = 0;
BG3_CY = 0;

//make up 2 random palettes, one for each screen
int i;
for(i=0;i<256; i++)
{
BG_PALETTE_SUB[i]=rand()&0xFFFF;
BG_PALETTE[i]=rand()&0xFFFF;
}

for(i=0;i<256; i++)
{
//draw some Junk on top screen (THIS WORKS)
BG_GFX[i+25*256]=rand()&0xFF;
//draw some Junk on Bot screen (THIS DOESN'T)
BG_GFX_SUB[i+60*256]=rand()&0xFF;
}

#134190 - tepples - Wed Jul 11, 2007 12:49 pm

Based on my reading of nds/arm9/video.h, you can start to fix the bottom screen by changing the BG3_whatever to SUB_BG3_whatever when you set up bitmap backgrounds and rotation attributes.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#134205 - jonnyhilly - Wed Jul 11, 2007 4:35 pm

thanks, that did the trick :)

#134218 - knight0fdragon - Wed Jul 11, 2007 6:39 pm

just to let you know jonnyhilly, each screen has its own set of 4 backgrounds
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#134227 - jonnyhilly - Wed Jul 11, 2007 7:38 pm

Thanks, yes I found out about the multiple screens on the DS wiki
Though I can't find a good description of all the registers and defines though. and a clear guide on setting up screens.

I'm trying to do text with various sized fonts including asian characters, onto both screen, so I figured the rotation backgrounds were the best way to go.

Next... is doing some research on the memory and file system, and figuring how much space the code has to fit into for home brew...

Interested to know, with the file system... does the data stay on the rom cart, but the exe portion gets loaded into ram ? or does it all get loaded into ram ?
and whats the speed difference between drawing graphics from ram and from the rom....
saw something about only 64k for home brew exe ?

anyways.... thanks for the help.. :)

#134238 - tepples - Wed Jul 11, 2007 9:41 pm

jonnyhilly wrote:
I'm trying to do text with various sized fonts including asian characters, onto both screen, so I figured the rotation backgrounds were the best way to go.

By "asian characters" do you mean kana and hangul, or do you mean CJK ideograms? Are you going to need UTF-8 handling code?

Quote:
Next... is doing some research on the memory and file system, and figuring how much space the code has to fit into for home brew...

Homebrew needs to fit into 4 MB unless it reads the file system. There isn't a generalized way to make code overlays, apart from the plug-in systems used by DSOrganize and MoonShell.

Quote:
Interested to know, with the file system... does the data stay on the rom cart, but the exe portion gets loaded into ram ?

Yes, just like on a PC.

Quote:
and whats the speed difference between drawing graphics from ram and from the rom....

Everything needs to be loaded into RAM first, like on a PC.

Quote:
saw something about only 64k for home brew exe ?

There is no 64 KB limit. There is a 64 KB limit for GBA SRAM, which translates to a 64 KB limit for writable files in FCSR (FAT on traditional GBA flash cards), but most memory card adapters (SuperCard, M3, R4, etc.) let you use a gigabyte or more of files.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#134337 - jonnyhilly - Thu Jul 12, 2007 4:40 pm

tepples, thanks for all that cool info.
Yes, I want to draw, english, kana, and kanji characters. utf-8 encoding.
bitmap font. (CKJ ideograms)

I have the file system working already, so more than 4mb should be OK, but the main problem will be kanji database as it is bigger than 4mb, so I'd have to load it in parts at a time. Can the file system do partial file loads ?
e.g. specify file to load, +start offset, +length to load and destination addr to copy to.
I guess that wouldn't be a problem

thanks again

#134430 - tepples - Fri Jul 13, 2007 2:33 am

jonnyhilly wrote:
I have the file system working already, so more than 4mb should be OK, but the main problem will be kanji database as it is bigger than 4mb, so I'd have to load it in parts at a time. Can the file system do partial file loads ? e.g. specify file to load, +start offset, +length to load and destination addr to copy to.

No problem: fopen(), fseek(), fread(), fseek(), fread(), fseek(), fread(), fclose().
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#134433 - jonnyhilly - Fri Jul 13, 2007 2:51 am

sweet!
np then
thanks

#134635 - jonnyhilly - Sun Jul 15, 2007 2:00 am

OK, I got alot of stuff working now....
2 rotation screens setup in mode MODE_5_2D
some sprite rendering routines sorted out, with some transparency and palette FX.
Overlaid text screen for some debug printf's

But there is one strange thing....
the vram for the main text screen and the Extended background seem to use up the same space ? and corrupt each other.

What should I do about this ? move the text screen some place else ?
(not sure how to do this)
or scroll the background up to hide the corruption (seems cheap)

help appreciated, thanks

videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG1_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);

// set up bitmap backgrounds 8 bit paletted
BG2_CR = BG_BMP8_256x256;
SUB_BG3_CR = BG_BMP8_256x256;

//setup the text background
BG1_CR = BG_MAP_BASE(31); //??? what does this do ?

//clear the 2 rotation screens
memset(topScreen,0,256*256);
memset(botScreen,0,256*256);

//consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16);
iprintf("Test Text!...\n");
iprintf("Debug Print Info...\n");

#135005 - jonnyhilly - Thu Jul 19, 2007 9:53 am

ok sorted this out by just moving the BG screen down a bit 32 pixels.
The text screen seems to fit into the 32 pixels VRAM at the top nicely.

I just add the offset to my Sprite Blit routine so its all transparent.