#145339 - AshaiRey - Wed Nov 14, 2007 8:49 am
Hi,
Is it possible to have a 512x512 8bit background (not a tile Bg)
I've tried this on several way but i can't figure out how to do it or even if it's possible
If this is possible then an example will be highly appreciated.
_________________
My personal ranting at blog.zoelen.net
#145349 - Lick - Wed Nov 14, 2007 11:24 am
You'll need at least 256 KiB of VRAM for the screen you want the 512x512 8-bit background on. That background has to be an Extended Rotation background (see mode3-mode5). You'll also need to set the BGx_CR to BG_BMP8_512x512. Because you're using an Extended Rotation background, you'll have to set the BGx_XDX, BGx_XDY, BGx_YDX, BGx_YDY, BGx_CX, and BGx_CY.
Also note that you can only write 16-bit (and 32-bit) values to the VRAM. 8-bit writes to the VRAM will give you visual abnormalities. So use bitshifting to create a temporary 16-bit value from two 8-bit values, then write to the VRAM.
If I have time, I can write an example later today, I don't have much time right now.
_________________
http://licklick.wordpress.com
#145352 - AshaiRey - Wed Nov 14, 2007 11:57 am
Thanks lick, i am looking forward to it.
Ps, i've also PM-ed you some additional info.
_________________
My personal ranting at blog.zoelen.net
#145381 - NeX - Wed Nov 14, 2007 5:56 pm
Eh... are you sure about that Lick? I dmaCopied an 8-bit array straight to VRAM in SandScape.
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.
#145385 - DragonMinded - Wed Nov 14, 2007 7:23 pm
Yes, he's sure of it. You cannot write 8bit to VRAM in arm9, only in arm7.
_________________
Enter the mind of the dragon.
http://dragonminded.blogspot.com
Seriously guys, how hard is it to simply TRY something yourself?
#145392 - tepples - Wed Nov 14, 2007 8:39 pm
NeX wrote: |
I dmaCopied an 8-bit array straight to VRAM in SandScape. |
You can use 16-bit or 32-bit copies to copy a properly aligned 8-bit array. I just looked in .../libnds/include/nds/dma.h, and the dmaCopy function appears to use 16-bit ("halfword") writes:
Code: |
static inline void dmaCopy(const void * source, void * dest, uint32 size) {
DMA_SRC(3) = (uint32)source;
DMA_DEST(3) = (uint32)dest;
DMA_CR(3) = DMA_COPY_HALFWORDS | (size>>1);
while(DMA_CR(3) & DMA_BUSY);
}
|
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#145393 - M3d10n - Wed Nov 14, 2007 8:39 pm
NeX wrote: |
Eh... are you sure about that Lick? I dmaCopied an 8-bit array straight to VRAM in SandScape. |
I think the DMA will work if your data is aligned to 16-bit.
#145442 - NeX - Thu Nov 15, 2007 6:45 pm
It's an 8-bit array hardcoded to the last megabyte of main RAM. I haven't told it to use 16 bit anywhere. In fact, I specify 8 bit even when copying the data.
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.
#145450 - AshaiRey - Thu Nov 15, 2007 7:24 pm
This is all quiet interesting but how do i display a 512x512 8bit image?
_________________
My personal ranting at blog.zoelen.net
#145454 - Jim e - Thu Nov 15, 2007 7:36 pm
NeX wrote: |
It's an 8-bit array hardcoded to the last megabyte of main RAM. I haven't told it to use 16 bit anywhere. In fact, I specify 8 bit even when copying the data. |
If you dmacopied then the same issue isn't preset. The arm9 can only write 16bit to the vram. DMA is separate from the cpu so it wont have that issue, however dma seems to also copy 16bit, so it doesn't really matter at all.
Here's some example code. Some one correct me if I made a mistake.
Code: |
//Map to the start of the vram for the main screen
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
//Enable 3rd bg of main screen
videoSetMode( MODE_5_2D | DISPLAY_BG3_ACTIVE );
//The value in bg_bmp_base * 0x4000 says where in the vram the bmp is located
BG3_CR = BG_BMP8_512x512 | BG_BMP_BASE(0x00) | BG_PRIORITY(3);
//No scaling.
BG3_XDX = 1<<8;
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = 1<<8;
BG3_CX = 0;
BG3_CY = 0; |
#145464 - Lick - Fri Nov 16, 2007 12:21 am
bmp8_512x512.zip (21 KiB)
The download contains an example of how to use 8-bit 512x512 bitmaps. It first fills the palette's 256 colors with rainbow values (using some imperfect algorithm I found on the web), then it fills the bitmap with indices to the palette. Use D-pad to move around.
(If you're not familiar with indexed bitmaps:
if bitmap_byte_0 equals 12 then pixel_0 has palette_color_12's color.)
_________________
http://licklick.wordpress.com
#145537 - AshaiRey - Sat Nov 17, 2007 12:25 pm
Thx Lick!
_________________
My personal ranting at blog.zoelen.net