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.

Beginners > probably an easy answer...

#15856 - gobojacobs - Sun Feb 01, 2004 8:43 pm

Hey everyone.. relative newb to this forum, as well as the entire gba dev community. Just picked up VisualHAM and the DevKitAdvance, and was just trying to get a sprite to display. My code compiles, and BoycotAdvance will run it, but nothing happens. I assume there's just a tiny little error somewhere (not enabling a background, not copying a sprite to the right OAM spot, etc.), and was hoping you folks could steer me in the right direction.

I'm using the mygba.h header from the visual ham library. I haven't included thecheat.h (it was generated using pcx2sprite).

Code:

#include "mygba.h"
#include "thecheat.h"

MULTIBOOT

int main(void)
{

    //set to mode 2, enable sprites, set the map to 1d
    M_DISCNT_BGMODE_SET(2);
    M_DISCNT_HBLOBJ_ENA;
    M_DISCNT_OBJMAP_1D;
   
    //move all of the sprites offscreen
    int i;
    for(i = 0; i < 128; i++)
    {
        TOOL_OAM_OBJ_SET_XPOS(i, 160);
        TOOL_OAM_OBJ_SET_YPOS(i, 240);
    }
   
    //set the pallete
    for(i = 0; i < 256; i++)
    {
        (MEM_PAL_OBJ_PTR)[i] = thecheatPalette[i];
    }
   
    //load thecheat
    for(i = 0; i < 256 * 8; i++)
    {
        (MEM_OBJ_PTR)[i] = thecheatData[i];
    }

    TOOL_OAM_OBJ_CREATE(0, 0, 50, 50, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0);
   
   
   while(1)
   {
   }

   return 0;
}


Any advice / recomendations would be greatly appreciated :) Thanks much, and enjoy the lovely weather (we got up to 10 today! woohoo!),

gobojacobs

#15857 - jenswa - Sun Feb 01, 2004 8:49 pm

I am not familair with the hamdlib so i have no idea what happens here:
TOOL_OAM_OBJ_CREATE(0, 0, 50, 50, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0);

My gues is, if that line doesn't set an x and y positon from a sprite on screen. Your sprite probably still hangs around in the non-visible part of the screen.

What i am trying to say is:

Move your sprite to the center (120,80) of the screen and then you will either see your sprite, see some screwed sprite or see nothing at all.
_________________
It seems this wasn't lost after all.

#15858 - gobojacobs - Sun Feb 01, 2004 8:55 pm

here's a copy of the define for that..

#define MEM_OAM 0x07000000

Code:

#define TOOL_OAM_OBJ_CREATE(obj_number,char_number,xpos,ypos,obj_mode,obj_shape,obj_size,color_mode,pal_number,prio_to_bg,vflip,hflip,mosaic,rotation,rotation_no,dblsize) \
                        \
                        ACCESS_16(MEM_OAM+8*obj_number)= \
                        (obj_shape<<14)  | \
                        (color_mode<<13) | \
                        (mosaic<<12)     | \
                        (obj_mode<<10)   | \
                        (rotation<<8)    | \
                        (dblsize<<9)     | \
                        (ypos); \
                        \
                        ACCESS_16(MEM_OAM+8*obj_number+2)= \
                        (obj_size<<14)   |\
                        (vflip<<13)      |\
                        (hflip<<12)      |\
                        (rotation_no<<9) |\
                        (xpos);\
                        \
                        ACCESS_16(MEM_OAM+8*obj_number+4)= \
                        (pal_number<<12) |\
                        (prio_to_bg<<10) |\
                        (char_number);


it's pretty ugly, and i guess i should just set the info that's needed on its own; but it does set to a position (50, 50 in this case).

#20701 - ThePhoenix - Sat May 15, 2004 12:22 pm

Wait, hold up. thecheat.h?
You're making some sort of Homestarrunner clone, aren't you?

Yay, the Cheat gets his GBA debut! (Almost)

#20707 - yaustar - Sat May 15, 2004 1:34 pm

Check with VBA to see if the sprite is loaded into the memory.. then start worrying about the code :P
_________________
[Blog] [Portfolio]