#18795 - s00p - Mon Apr 05, 2004 5:31 pm
edit: I solved my problem. Thanks for the help guys.
My sprite isn't showing up. I looked at a lot of tutorials before finally posting here and couldn't get anything to happen.
Background:
Code: |
int main()
{
ham_Init();
unsigned short color;
Print(1, 0, " LIVES:3 %:100 STAGE:15", GREEN);
color = RGB(0,0,255);
DrawBox3(0, 10, 240, 160, color);
color = RGB(0,0,0);
DrawBox3(1, 11, 239, 159, color);
ham_StartIntHandler(INT_TYPE_VBL,(void*)&vbl_func);
unsigned short* videoBuffer = (unsigned short*)0x6000000;
*(unsigned long*)0x4000000 = (0x3 | 0x400);
videoBuffer[posy * 240 + posx] = 0xFFFF;
|
Sprite:
Code: |
SetMode( SCREENMODE4 | OBJENABLE );
ham_LoadObjPal((void*)master_Palette, 256);
alien[0] = ham_CreateObj((void*)alien_Bitmap,0,2,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,110,50);
ham_CopyObjToOAM(); |
Last edited by s00p on Mon Apr 05, 2004 10:05 pm; edited 1 time in total
#18796 - Lupin - Mon Apr 05, 2004 5:35 pm
Set the BG priority to 3 when using bitmap modes. Your sprites should work, they are just behind the BG.
_________________
Team Pokeme
My blog and PM ASM tutorials
#18797 - s00p - Mon Apr 05, 2004 5:54 pm
Sprite shows up then disappears as soon as the background is drawn. I changed the bg priority attribute to 3:
Code: |
int main()
{
ham_Init();
ham_SetBgMode(4);
ham_LoadObjPal((void*)master_Palette, 256);
alien[0] = ham_CreateObj((void*)alien_Bitmap,OBJ_SIZE_8X8,OBJ_MODE_NORMAL,1,0,0,0,0,3,0,110,50);
ham_CopyObjToOAM();
unsigned short color;
Print(1, 0, " LIVES:3 %:100 STAGE:15", GREEN);
color = RGB(0,0,255);
DrawBox3(0, 10, 240, 160, color);
color = RGB(0,0,0);
DrawBox3(1, 11, 239, 159, color);
ham_StartIntHandler(INT_TYPE_VBL,(void*)&vbl_func);
unsigned short* videoBuffer = (unsigned short*)0x6000000;
*(unsigned long*)0x4000000 = (0x3 | 0x400);
videoBuffer[posy * 240 + posx] = 0xFFFF;
while(1) {}
return 0;
} |
#18799 - batblaster - Mon Apr 05, 2004 6:38 pm
The BG prioprity not the Obj priority...
_________________
Batblaster / 7 Raven Studios Co. Ltd
------------------------------------------
#18800 - s00p - Mon Apr 05, 2004 6:42 pm
batblaster wrote: |
The BG prioprity not the Obj priority... |
prioprity? Well if it isn't right then could you tell me which value is the obj priority?
#18802 - sajiimori - Mon Apr 05, 2004 7:24 pm
You want to make fun of people and then ask them for help?
#18805 - s00p - Mon Apr 05, 2004 7:57 pm
No I was just stating that I didn't know which word that supposed to be, property or priority.
#18806 - Lupin - Mon Apr 05, 2004 8:27 pm
Put this somewhere in your code (at startup would be good):
REG_BG2CNT = 3;
This will of course overwrite all other BG settings but you most likely don't need any of the other BG settings in bitmap mode
_________________
Team Pokeme
My blog and PM ASM tutorials
#18809 - s00p - Mon Apr 05, 2004 9:17 pm
Putting that in the header caused an error. Putting that in main() did nothing.
I also tried putting
Code: |
#define REG_BG2CNT *(u16*)0x400000C |
into the header.
#18810 - dagamer34 - Mon Apr 05, 2004 9:33 pm
Try copying the OAM memory every frame. That might be why it flickers for a mement then disappears.
Is there a particular reason why you are mixing HAM code with your own functions? I just find it odd.
_________________
Little kids and Playstation 2's don't mix. :(
#18811 - s00p - Mon Apr 05, 2004 9:37 pm
It's because I just started doing this yesterday and don't know any better.
#18813 - dagamer34 - Mon Apr 05, 2004 9:46 pm
I only started 3 months ago so don't stress out. But you might want to stick with 1 set of functions or the other. Mixing leads to spending more time to solve problems.
By the way, does anybody know why the time is off by an hour? Are the boards not going by Daylight Savings Time?
_________________
Little kids and Playstation 2's don't mix. :(
#18814 - s00p - Mon Apr 05, 2004 9:58 pm
Code: |
unsigned short* videoBuffer = (unsigned short*)0x6000000;
*(unsigned long*)0x4000000 = (0x3 | 0x400);
videoBuffer[posy * 240 + posx] = 0xFFFF; |
= CRAP.
That's what was causing the problem.
Code: |
void DrawPixel3(int x, int y, unsigned short color)
{
videoBuffer[y * 240 + x] = color;
} |
= Good. I have the sprite showing up over my other layers easily now. It works perfectly now.
#18834 - dagamer34 - Tue Apr 06, 2004 10:23 pm
You might want to go pick up a gba.h header and use it's macros.
Setting the display mode like this:
Code: |
*(unsigned long*)0x4000000 = (0x3 | 0x400);
|
is just ASKING for trouble seeing as you might forget what the 0x3 and 0x4000 represents (even I don't know off the top of my head) and you have to look it up. This makes it a pain in the @$$ to find bugs because of human error. You've had first-hand experience and I think everyone here will agree with me, it's something to avoid.
_________________
Little kids and Playstation 2's don't mix. :(
#18917 - Cearn - Thu Apr 08, 2004 8:58 am
dagamer34 wrote: |
You might want to go pick up a gba.h header and use it's macros.
Setting the display mode like this:
Code: |
*(unsigned long*)0x4000000 = (0x3 | 0x400);
|
is just ASKING for trouble seeing as you might forget what the 0x3 and 0x4000 represents (even I don't know off the top of my head) and you have to look it up. This makes it a pain in the @$$ to find bugs because of human error. You've had first-hand experience and I think everyone here will agree with me, it's something to avoid. |
Yeah, Using named constants is prefereable to using the actual numbers. It'll also clear up little typos like 0x4000 (3 zeros) when it's 0x400 (2 zeros) than enables BG2 :P (sorry about that, dagamer34, but this is probably your point anyway).
Do something like
Code: |
typedef unsigned int u32;
#define REG_DISPCNT *(volatile u32*)0x04000000
#define BG2_ENABLE 0x0400
#define VID_MODE3 0x0003
// to enable BG2 and video mode 3:
REG_DISPCNT = BG2_ENABLE | VID_MODE3;
|
Just about every demo comes with header files with defines for the registers and flags. Save yourself a lot of grief and get one.
#18969 - dagamer34 - Thu Apr 08, 2004 10:03 pm
That accident was on purpose.
_________________
Little kids and Playstation 2's don't mix. :(