Homebrew libnds noob question, loading sprites

_V1qY

Well-Known Member
OP
Member
Joined
May 31, 2012
Messages
138
Trophies
0
XP
166
Country
I am trying to load a sprite, but just I can't get it to work.

My code is based on http://www.dev-scene.com/NDS/Tutorials_Day_5 .

Here is the simplified version, nothing shows up.

Code:
  consoleDemoInit();
 
  videoSetMode(MODE_0_2D);
  vramSetPrimaryBanks(VRAM_A_MAIN_SPRITE, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
     
  oamInit(&oamMain, SpriteMapping_Bmp_1D_128, false);
  u16 *gfx = oamAllocateGfx(&oamMain, SpriteSize_32x32, SpriteColorFormat_256Color);
 
  dmaCopy(tile_data, gfx, sizeof(tile_data));
  dmaCopy(palette, SPRITE_PALETTE, sizeof(palette));
 
  while(1) {
      scanKeys();
     
      oamSet(&oamMain, 0, 64, 32, 0, 0, SpriteSize_32x32, SpriteColorFormat_256Color, gfx, 0, false, false, false, false, false);
      oamUpdate(&oamMain);
     
      swiWaitForVBlank();
  }
 

Plainscript

Well-Known Member
Member
Joined
Nov 18, 2012
Messages
110
Trophies
0
XP
81
Country
Netherlands
Just tested it:

It's not you - I get the same results.. That is, on the referenced page.

In your code, I don't think the
Code:
consoleDemoInit();

..gonna work, because you want to display sprites. Not a text-based console. But I could be missing something. :)

EDIT: Try the examples\nds\Graphics\Sprites\animate_simple\source route from your Devkitpro folder to see something like this, but working. ;)
 

_V1qY

Well-Known Member
OP
Member
Joined
May 31, 2012
Messages
138
Trophies
0
XP
166
Country
I used the consoleDemoInit so that I could print some debug text before I tried to display the sprite. This was just a simplified version of my code.

I've removed the consoleDemoInit and all printf calls but I still can't get it to display.

I've had a look at the few examples which come with devkitPro, but I can't tell the difference between mine and theirs.

This is such simple code, are you sure that there's nothing obvious that you can see which is wrong? Plainscript
 

Plainscript

Well-Known Member
Member
Joined
Nov 18, 2012
Messages
110
Trophies
0
XP
81
Country
Netherlands
Just took a second look at it.

Try this:

At the last lines, during the while loop:

Code:
while (1) //infinite loop
{
oamSet(&oamMain,0,64,32,0,0,SpriteSize_64x64,SpriteColorFormat_256Color,gfx,0,false,false,false,false,false);
swiWaitForVBlank();
oamUpdate(&oamMain);
}

It's still based on the link in the first post.

Notice how it is placed:

oamSet
swiWaitForVBlank
oamUpdate

It works now. :)
 

_V1qY

Well-Known Member
OP
Member
Joined
May 31, 2012
Messages
138
Trophies
0
XP
166
Country
Just took a second look at it.

Try this:

At the last lines, during the while loop:

Code:
while (1) //infinite loop
{
oamSet(&oamMain,0,64,32,0,0,SpriteSize_64x64,SpriteColorFormat_256Color,gfx,0,false,false,false,false,false);
swiWaitForVBlank();
oamUpdate(&oamMain);
}

It's still based on the link in the first post.

Notice how it is placed:

oamSet
swiWaitForVBlank
oamUpdate

It works now. :)

Thanks very much for your help, unfortunately I still can not get this to work. I've sent you some complete code to check, hopefully there is just something simple wrong with my code.
 

_V1qY

Well-Known Member
OP
Member
Joined
May 31, 2012
Messages
138
Trophies
0
XP
166
Country
Whoops, remember to uncomment this part so it looks like this:

if(!fatInitDefault()) {
// printf(" Failed!\n");
return 1;
}

I accidentally removed that bit when removing printf calls.

The result is slightly better now, something appears on the top screen, and I think the palette is right! The tiles seem wrong though.
 

_V1qY

Well-Known Member
OP
Member
Joined
May 31, 2012
Messages
138
Trophies
0
XP
166
Country
I have read that NDS icons are just standard tiles and palettes, so that shouldn't be the issue.
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,841
Country
Poland
There's a sprite example that comes with libnds, y'know. Don't rely on online resources that may or may not be up-to-date, always consult the included documentation.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: I am the cancer!!! lol