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 > [Fixed] Problem with ROTOSCALE

#158832 - Gardner - Thu Jun 19, 2008 1:41 am

Hi there, i'm starting to learn a thing or two about NDS Game Programming. Just for start, i decided to try PATATER's Tutorial. Everything was great until i reache the sprite part.

When i set the sprite of the ship as rotoscale, it was draw in a wrong way, like is shown in the this image: http://img171.imageshack.us/img171/7708/problemwithrotoscaleuw9.png When I set its rotoscale as false, the problem goes away.

Someone can help-me? Or at least send-me some directions? :)
Bye!
_________________
"Open your eyes and see..."


Last edited by Gardner on Sun Jun 22, 2008 2:58 pm; edited 1 time in total

#158834 - yellowstar - Thu Jun 19, 2008 2:02 am

Post your code. It's usually very difficult for anybody to help you without the code. The exact same thing happens on hardware/actual DS, correct?

#158841 - Gardner - Thu Jun 19, 2008 3:34 am

Sorry, i don't know why i thought that just mention pataters will help. :(

So this is the code:

Code:
void initVideo() {
  vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                   VRAM_B_MAIN_BG_0x06020000,
                   VRAM_C_SUB_BG_0x06200000,
                   VRAM_D_LCD);

  vramSetBankE(VRAM_E_MAIN_SPRITE);

  videoSetMode(MODE_5_2D |
               DISPLAY_BG2_ACTIVE |
               DISPLAY_BG3_ACTIVE |
               DISPLAY_SPR_ACTIVE |
               DISPLAY_SPR_1D);
 
  videoSetModeSub(MODE_5_2D |
                  DISPLAY_BG3_ACTIVE);
}


Code:

void initSprites(tOAM * oam, SpriteInfo *spriteInfo) {

  static const int BYTES_PER_16_COLOR_TILE = 32;
  static const int COLORS_PER_PALETTE = 16;
  static const int BOUNDARY_VALUE = 32;
  static const int OFFSET_MULTIPLIER = BOUNDARY_VALUE / sizeof(SPRITE_GFX[0]);
 
  int nextAvailableTileIdx = 0;
 
  static const int SHUTTLE_OAM_ID = 0;
  assert(SHUTTLE_OAM_ID < SPRITE_COUNT);
  SpriteInfo * shuttleInfo = &spriteInfo[SHUTTLE_OAM_ID];
  SpriteEntry * shuttle = &oam->spriteBuffer[SHUTTLE_OAM_ID];
 
  shuttleInfo->oamId = SHUTTLE_OAM_ID;
  shuttleInfo->width = 64;
  shuttleInfo->height = 64;
  shuttleInfo->angle = 462;
  shuttleInfo->entry = shuttle;
 
  shuttle->posY = SCREEN_HEIGHT / 2 - shuttleInfo->height;
  shuttle->isRotoscale = true;

 
  assert(!shuttle->isRotoscale || (shuttleInfo->oamId < MATRIX_COUNT));
  shuttle->rsDouble = false;
  shuttle->objMode = OBJMODE_NORMAL;
  shuttle->isMosaic = false;
  shuttle->colMode = OBJCOLOR_16;
  shuttle->objShape = OBJSHAPE_SQUARE;
 
  shuttle->posX = SCREEN_WIDTH / 2 - shuttleInfo->width * 2 + shuttleInfo->width / 2;
  shuttle->rsMatrixIdx = ATTR1_ROTDATA(shuttleInfo->oamId);
  shuttle->objSize = OBJSIZE_64;
 
  shuttle->tileIdx = nextAvailableTileIdx;
 
  nextAvailableTileIdx += orangeShuttleTilesLen / BYTES_PER_16_COLOR_TILE;
 
  shuttle->objPriority = OBJPRIORITY_1;
  shuttle->objPal = shuttleInfo->oamId;
 
  rotateSprite(&oam->matrixBuffer[shuttleInfo->oamId], shuttleInfo->angle);

...
 
  dmaCopyHalfWords(SPRITE_DMA_CHANNEL,
                   orangeShuttlePal,
                   &SPRITE_PALETTE[shuttleInfo->oamId * COLORS_PER_PALETTE],
                   orangeShuttlePalLen);
 
  dmaCopyHalfWords(SPRITE_DMA_CHANNEL,
                   orangeShuttleTiles,
                   &SPRITE_GFX[shuttle->tileIdx * OFFSET_MULTIPLIER],
                   orangeShuttleTilesLen);
}


And about your question, the answer is yes, in the console is the same thing. Thanks for yout time!! :)
_________________
"Open your eyes and see..."

#158846 - eKid - Thu Jun 19, 2008 9:51 am

Hmm, very wierd output.. not sure what's causing that. It looks like its skipping some rows when the sprite is drawing. You can see the 'moon' sprite on the bottom of the ship. How are you converting the graphics?

#158891 - Gardner - Fri Jun 20, 2008 10:22 am

All images are converted by "grit". One more screenshot from dualis where is show details about OAM.

http://img264.imageshack.us/img264/1456/rotoscaleoamqb6.png
_________________
"Open your eyes and see..."

#158896 - silent_code - Fri Jun 20, 2008 11:29 am

This is normal with Dualis and 16 color sprites. ;^)
Try it on no$gba and HW, it should work. :^D
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#158905 - eKid - Fri Jun 20, 2008 1:42 pm

Quote:

And about your question, the answer is yes, in the console is the same thing.

I think that means he tested on HW?

Gardner: Could you upload an .nds binary somewhere?

#158906 - silent_code - Fri Jun 20, 2008 1:58 pm

Sorry! Even though I especially looked for that statement, I overlooked it! Damn! :^\

Try:
Code:
shuttle->rsMatrixIdx = shuttleInfo->oamId;

That worked for some others, who also started with Patater's guide. :^)

The sprite structure was changed to work with C bitfields, so the shifting makros aren't needed anymore - even worse: they must not be used, because they will corrupt data, just like in your program!

EDIT @ Gardner: You're welcome. :^)
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.


Last edited by silent_code on Sun Jun 22, 2008 12:04 pm; edited 2 times in total

#158930 - Gardner - Sat Jun 21, 2008 10:25 pm

WoW!!! Worked like magic!! \o/

It works in the HW too, but, as you said, it doesn't work on dualis. I will try the no$gba.

An thanks for the tips about sprite structure.

eKid, i think there is no need for the .nds now, am i correct?

Thanks for all of you!! :)
_________________
"Open your eyes and see..."