beginner's question on libnds

Post Reply
tonma
Posts: 3
Joined: Thu Jul 02, 2020 9:38 am

beginner's question on libnds

Post by tonma » Thu Jul 02, 2020 3:14 pm

Hi,
I'm new on Nintendo ds. I just begin to code with libnds this week and have some questions. I'll keep a single thread to ask new questions.

I have understand the basic and look some of the example. So I can add image in VRAM, load image, Draw on the main / sub screen, use layer priority ...

I have 2 questions for beginning my journey. I wish to make a dating novel game.

Transparency problem with 16 bit image. The original file is a 32bits with transparency.
My Code :

Code: Select all

int bg2 = bgInit(2, BgType_Bmp16, BgSize_B16_128x128, 0, 0);
decompress(chloe_angryBitmap, (u16*)0x06000000,  LZ77Vram);
My Grit :

Code: Select all

# alpha for 16 bit or magenta for palette
-gT!
# use lz77 compression
-gzl
# 16 bit bitmap
-gB16
-gb
The debug

Code: Select all

grit /d/devkitPro/examples/nds/tuto/tuto02_gfx/data/chloe-angry.png -fts -ochloe-angry
STATUS: ---grit v0.8.16 ---
STATUS: Individual runs.
STATUS: Input file D:/devkitPro/examples/nds/tuto/tuto02_gfx/data/chloe-angry.png
STATUS: Output file: 'chloe-angry'.
STATUS: Started run at: 2020-07-02, 15:38:09
STATUS: Validating gr.
WARNING:   No explicit symbol name. In overwrite mode, so using dst title.
STATUS: Validation succeeded.
STATUS: Preparing data.
STATUS: Work-DIB creation.
WARNING:   converting from 32 bpp to 16 bpp.
STATUS: converting to: 16bpp BGR, alpha=1.
STATUS: Work-DIB creation complete: 128x128@16.
STATUS: Graphics preparation.
STATUS: Compressing: 01
STATUS: Graphics preparation complete.
STATUS: Data preparation complete.
STATUS: Export to GNU asm: chloe_angry into chloe-angry.s .
STATUS: Run completed :).
STATUS: Done!
Image

I tried the grit -gT[000000] with a black background picture and it's work but without semi transparency. So we can see black border.

Image

-----------

Another question is the position of the picture in layer 2. I can change the origin with the adress in layer2 / BG2

Code: Select all

decompress(chloe_angryBitmap, (u16*)0x06000000,  LZ77Vram); 
Changing (u16*)0x06000000 to (u16*)0x06000080. I write the picture lower on screen. But when I try to move it horizontally
Image
It's because i have create an BG/layer with the size : BgSize_B16_128x128. but in this case, how can move the position of origin of the layer ?
Or maybe we can't and need to use tile ?

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 103
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: beginner's question on libnds

Post by fincs » Thu Jul 02, 2020 5:13 pm

The DS's non-paletted bitmap modes only support RGB5551, with only 1-bit transparency. This means pixels are either fully opaque or fully transparent.

I think you might have to use the 3D engine with a texture in A3I5 or A5I3 format; however those are paletted formats with only 32 or 8 colors available (respectively).

You can use bgSetScroll() to move a background to a position on the screen.
Donate to devkitPro - help us stay alive!

tonma
Posts: 3
Joined: Thu Jul 02, 2020 9:38 am

Re: beginner's question on libnds

Post by tonma » Fri Jul 03, 2020 10:21 am

Thanks a lot. It's works well.

I have made some tests and found I need to add a bgupdate() to have the scrolling done, after the bgSetScroll
Image

Now I'll work on the Hud and text menu.

tonma
Posts: 3
Joined: Thu Jul 02, 2020 9:38 am

Re: beginner's question on libnds

Post by tonma » Thu Jul 23, 2020 5:14 pm

Ok. I think I understand more after few more tests.
When you use a BgSize_T_512x256, you have a "screen of 512 pixels wide". The left part begin at 0 and the right part at 1024 (32*32).

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest