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 > Ok... WHAT am I doing wrong?

#119615 - Lupi - Sat Feb 24, 2007 8:16 pm

My situation:
I'm doing a text engine for my adventure game. I know I could make it with console.h functions, but I need more flexibility to work with the text.

I have taken the font from the libnds examples, the one in Graphics/2D/custom_font
I realized I had to transform the caracters into 16 bits words. My pallette number is also the first one (0) and I don't need to flip the tiles. So I get in bits:

Code:
0 0 0 0       0        0         0 0 A B C D E F G H
Pal         Horiz.   Verti.       Tile index
               Flip      Flip


Where ABCDEFGH is the code of the ASCII character.

Because of the problems I was having, I decided to do a SIMPLE example:
Load 6 characters in a line. The character is '!', this is 0000 0001 in my tiles...

Code:
u16 Admiraciones [6]= {0x01,0x01,0x01,0x01,0x01,0x01};

dmaCopy((void *)Admiraciones, (u16 *)BG_MAP_RAM(16), 6*2);


This does work on emulators, but doesn't work on hardware

I have been a few days working an engine adapted for my game, it ALWAYS worked on any emulator, but today I decided to go and try on real Hardware, but strange symbols appeared. Every time I started the game, different symbols, some of them were correct, but most of them were not.
My question is, WHAT am I doing wrong?

Thanks in advance

EDIT
A copy of my .nds file:
http://www.megaupload.com/es/?d=BI6KG4W5

Now try on a emulator...
then try in DS hardware...
??

#119634 - Nelzon - Sat Feb 24, 2007 11:08 pm

I'm not sure if that's the problem, but have you flushed the memory before the DMA copy call?

#119636 - Lupi - Sat Feb 24, 2007 11:22 pm

Well, every time I load a new background with text I load 0 in the places where there is no text, to hide old letters.

If that's not flushing memory then I have no idea what is it :S
What is it for? How can I do it?

PD: Excuse my ignorance, my english vocabulary is a bit poor ^_^;;

#119637 - Dark Knight ez - Sat Feb 24, 2007 11:25 pm

Try memcpy. Dmacopy is not the safest of ways.
_________________
AmplituDS website

#119639 - Nelzon - Sat Feb 24, 2007 11:43 pm

The RAM of the DS is mirrored, the first part is cached, the other is not. When you e.g. want to share parts of the cached memory between ARM9 and ARM7 you must flush the cache to make sure both processors read the same memory contents. You can do that by simply call DC_FlushAll();
I think the problems you may have with DMACopy are related to this matter.

#119640 - Lupi - Sat Feb 24, 2007 11:50 pm

Thanks :D
It works now :)

But why does this happen? Doesn't memcpy do the same that dmacopy?

Lupi

Edit: Sorry Nelzon, I couldn't read your post when I was posting, but thanks :-)

#119641 - Dark Knight ez - Sun Feb 25, 2007 12:01 am

Sort of, but in a different way.
I found dmaCopy to be unreliable, but maybe Delzon's suggestion -- DC_FlushAll(); -- would've fixed the severe problems I experienced with it. I don't know.
memcpy has always treated me nice though, so I stick with that.
_________________
AmplituDS website