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 > Very basic thing...but I just CAN'T get it

#120472 - Lupi - Sun Mar 04, 2007 1:27 am

I have been like two entire days trying to figure this out, but I CAN'T.

The situation, I have loaded in memory a set of tiles, that represents the ASCII letters. The difference is that the first letter is the one with ASCII code 32.

I have made a class to read a vector of chars and make lines of text with / and ~ (this is not important I believe) the important part comes here. I want the text to be ready to be loaded in VRAM. So I have to "convert" char into u16. The pallette is the number 0, and I do not want tile flipping, so that's 0 too. For every char I'm adding to my class, I do this operation based on the string I'm "converting"

Code:
u16 letter = 0x00FF & (string[i]-PRIMER_CHAR);

string[i] is the single char I'm turning into a tile to be loaded later
PRIMER_CHAR is the first char, 32
letter is a variable of 16 bits

to load this on VRAM I have tried memcpy and DC_Flush + dmaCopy, BOTH of them works on emulator, NONE of them works on real Nintendo DS.

WHAT is wrong?!. I'm desperate, I don't have a clue of what's going on or how to fix it, I don't know if the problem is the way I'm loading this into memory or the way I'm converting the char :(

#120475 - tepples - Sun Mar 04, 2007 1:57 am

You can try looking at the ARM9 source of AXE to see a working example.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#120514 - Lick - Sun Mar 04, 2007 9:06 am

could you give more code?
_________________
http://licklick.wordpress.com

#120519 - qw3rty - Sun Mar 04, 2007 9:41 am

I doubt you would benefit from a DMA-transfer to copy ONE u16.
The VRAM for TILE-BGs should be writeable all the time (no need to unlock or wait for V-Blank).

there's no need for the "letter" variable (include a check for "legal" letters !):

*(SCREEN_BASE_BLOCK(n) +x+y*32) = (u16)(string[i] - PRIMER_CHAR);

x,y is the column and line. (If I remember right every text-bg has a width of 32 tiles - the 512++ modes have multiple "pages")

#120521 - knight0fdragon - Sun Mar 04, 2007 10:34 am

there are issues when it comes to DMA transferring, try using memcpy and see if that works

qw3rty, in DS, you can have tiled areas larger then 32x32 (32,64,128.256) so your formula would not work for the larger ones.
_________________
http://www.myspace.com/knight0fdragonds

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

#120526 - qw3rty - Sun Mar 04, 2007 12:31 pm

My formula works, if you know how the NDS handles BG's bigger than 32x32
http://www.thepernproject.com/tutorials/GBA/day_5.pdf

page n starts at line y=n*32.
each page has 32 characters per line and 32 lines (256x256 pixels).
page-layout for a 512x512 BG (64x64 tiles)

1 2
3 4


y = 33, x = 0 would map to 2nd page, 2nd line, first char.

#120535 - Lupi - Sun Mar 04, 2007 2:27 pm

Well, the one that I obtained better results was with memcpy.

Normally I did the following:
memcpy(vector_of_u16, Pointer, size_of_vector*2); I did double because it was two Bytes each position of the vector
Then I added 32 to the position for the next line, and so on.

As always worked on emulator, but not on Hardware.

I followed qw3rty's tip and it works now!!!!
I don't know why though, but THANKS!!! That was the only thing that stopped my project, even the Dialogue engine I did works now ^^

Thanks, and sorry for this stupid question, I have to learn more about DS Hardware :P

#120625 - knight0fdragon - Mon Mar 05, 2007 1:26 am

are you sure about this paging, because when I worked with 64x64 tiled backgrounds, 32 gives me (32,0) not (0,1)
_________________
http://www.myspace.com/knight0fdragonds

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

#120642 - tepples - Mon Mar 05, 2007 3:47 am

knight0fdragon wrote:
are you sure about this paging, because when I worked with 64x64 tiled backgrounds, 32 gives me (32,0) not (0,1)

Text or rot/scale?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#120651 - knight0fdragon - Mon Mar 05, 2007 4:30 am

it is a rotation scaling bg
_________________
http://www.myspace.com/knight0fdragonds

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

#120652 - tepples - Mon Mar 05, 2007 5:18 am

Text backgrounds are divided into 32x32 tile pages. Rot/scale backgrounds are not divided into pages.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#120700 - knight0fdragon - Mon Mar 05, 2007 5:49 pm

well nothing was ever specified about it being a text background or not haha, just tiled
_________________
http://www.myspace.com/knight0fdragonds

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

#120716 - qw3rty - Mon Mar 05, 2007 7:37 pm

It was obvious, that Lupi wanted to use text-bg, because he talked about horizontal and vertical flip, which is only possible in text-mode.

#120796 - knight0fdragon - Tue Mar 06, 2007 3:49 am

you can use the rotation matrix to flip it vertically and horizontally, and I thought he said he doesnt want tile flipping
_________________
http://www.myspace.com/knight0fdragonds

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

#120806 - HyperHacker - Tue Mar 06, 2007 5:31 am

It's not much harder to draw flipped characters on a frame buffer than normal ones either.
_________________
I'm a PSP hacker now, but I still <3 DS.