ROM Hack Newbie need a hand.

jimmcass

New Member
OP
Newbie
Joined
Nov 26, 2012
Messages
1
Trophies
0
Age
31
XP
51
Country
Im currently trying to learn a bit of GBA programming and im going insane just trying to display a simple sprite on the screen. Ive got the object palettes set and ive written the sprite data into memory but i cant get my head around writting it to the OAM?

Can anyone tell me what im doing wrong. My code is:


#include <gba_console.h>
#include <gba_video.h>
#include <gba_interrupt.h>
#include <gba_systemcalls.h>

#include <stdio.h>

#define SPRITE ((unsigned int*) 0x06010000)
#define OBJHOLDER ((unsigned int*) 0x07000000)


extern void myfunc(int* answer);

//---------------------------------------------------------------------------------
// Program entry point
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------

// the vblank interrupt must be enabled for VBlankIntrWait() to work
irqInit();
irqEnable(IRQ_VBLANK);

// generic setup function
consoleDemoInit();

// Display Control Register
unsigned short* DISPCNT = (unsigned short*) 0x04000000;

DISPCNT[0] = (1<<12)|(0<<11)|(0<<10)|(0<<9)|(1<<8)|(1<<6)|(0<<2)|(0<<1)|(0<<0);


// BG Controllers
unsigned short* BG0CNT = (unsigned short*) 0x04000008;

BG0CNT [0] = (15<<0)|(14<<0)|(13<<0)|(12<<0)|(11<<9)|(10<<0)|(9<<0)|(8<<0)|(6<<0)|(2<<0)|(1<<0)|(0<<0);

unsigned short* BG1CNT = (unsigned short*) 0x0400000A;
BG1CNT [1] = (15<<0)|(14<<0)|(13<<0)|(12<<0)|(11<<0)|(10<<9)|(9<<0)|(8<<0)|(6<<0)|(2<<0)|(1<<0)|(0<<0);

unsigned short* BG2CNT = (unsigned short*) 0x0400000C;
BG2CNT [2] = (15<<0)|(14<<0)|(13<<0)|(12<<0)|(11<<0)|(10<<0)|(9<<9)|(8<<0)|(6<<0)|(2<<0)|(1<<0)|(0<<0);

unsigned short* BG3CNT = (unsigned short*) 0x0400000E;
BG3CNT [3] = (15<<0)|(14<<0)|(13<<0)|(12<<0)|(11<<0)|(10<<0)|(9<<0)|(8<<9)|(6<<0)|(2<<0)|(1<<0)|(0<<0);


// Object Colour Pallete
unsigned short* OBJPAL = (unsigned short*) 0x5000200;

OBJPAL[0] = ((15<<10)|(8<<5)|(31<<0));
OBJPAL[1] = ((0<<10)|(31<<5)|(0<<0));
OBJPAL[2] = ((15<<10)|(8<<5)|(0<<0));
OBJPAL[3] = ((5<<10)|(8<<5)|(9<<0));


//Raw Sprite Data

int n = 1;

SPRITE[(n*8)+0] = (0<<28)|(0<<24)|(1<<20)|(1<<20)|(1<<16)|(0<<12)|(0<<8)|(0<<4);
SPRITE[(n*8)+1] = (0<<28)|(1<<24)|(1<<20)|(1<<20)|(1<<16)|(1<<12)|(0<<8)|(0<<4);
SPRITE[(n*8)+2] = (0<<28)|(1<<24)|(0<<20)|(0<<20)|(0<<16)|(1<<12)|(0<<8)|(0<<4);
SPRITE[(n*8)+3] = (0<<28)|(1<<24)|(0<<20)|(0<<20)|(0<<16)|(1<<12)|(0<<8)|(0<<4);
SPRITE[(n*8)+4] = (0<<28)|(1<<24)|(0<<20)|(0<<20)|(0<<16)|(1<<12)|(0<<8)|(0<<4);
SPRITE[(n*8)+5] = (0<<28)|(1<<24)|(1<<20)|(1<<20)|(1<<16)|(1<<12)|(0<<8)|(0<<4);
SPRITE[(n*8)+6] = (0<<28)|(0<<24)|(1<<20)|(0<<20)|(1<<16)|(0<<12)|(0<<8)|(0<<4);
SPRITE[(n*8)+7] = (0<<28)|(0<<24)|(1<<20)|(0<<20)|(1<<16)|(0<<12)|(0<<8)|(0<<4);

OBJHOLDER[0] = ((0<<16)|(0<<14)|(2<<8));
OBJHOLDER[1] = ((0<<16)|(0<<14)|(0<<13)|(0<<12)|(60<<9));
OBJHOLDER[2] = ((0<<16)|(0<<12)|(1<<10));
OBJHOLDER[3] = (0);


//TEST MAP DATA








// main loop
while (1)
{
// ansi escape sequence to clear screen and home cursor
// /x1b[line;columnH
iprintf("\x1b[2J");

// ansi escape sequence to set print co-ordinates
// /x1b[line;columnH
iprintf("\x1b[10;10HDolce Gusto");




VBlankIntrWait();
}
}
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    Jaws is on a diet
  • K3Nv2 @ K3Nv2:
    Damn power went out
  • BigOnYa @ BigOnYa:
    Ok xdqwerty, your little bro prob tripped On the cord and unplugged you
  • K3Nv2 @ K3Nv2:
    Ya I'm afraid of the dark hug me
  • BigOnYa @ BigOnYa:
    Grab and hold close your AncientBoi doll.
  • K3Nv2 @ K3Nv2:
    Damn didn't charge my external battery either
  • BigOnYa @ BigOnYa:
    Take the batteries out of your SuperStabber3000... Or is it gas powered?
  • K3Nv2 @ K3Nv2:
    I stole batteries from your black mamba
    +1
  • K3Nv2 @ K3Nv2:
    My frozen food better hold up for an hour I know that
  • BigOnYa @ BigOnYa:
    Or else gonna be a big lunch and dinner tomorrow.
  • BigOnYa @ BigOnYa:
    Did you pay your power bill? Or give all yo money to my wife, again.
  • K3Nv2 @ K3Nv2:
    Oh good the estimated time is the same exact time they just said
    +1
  • BigOnYa @ BigOnYa:
    Load up your pc and monitor, and head to a McDonalds dining room, they have free WiFi
  • K3Nv2 @ K3Nv2:
    Sir please watch your porn in the bathroom
    +2
  • BigOnYa @ BigOnYa:
    No sir we can not sell you anymore apple pies, after what you did with the last one.
  • K3Nv2 @ K3Nv2:
    We ran out
  • HiradeGirl @ HiradeGirl:
    for your life
    +1
  • K3Nv2 @ K3Nv2:
    My life has no value my fat ass is staying right here
  • K3Nv2 @ K3Nv2:
    Nearly 4 hours without power :(
  • Veho @ Veho:
    SO POWERLESS
  • K3Nv2 @ K3Nv2:
    Tell Kanye I need power
  • DinohScene @ DinohScene:
    Better start running in your hamster wheel
    DinohScene @ DinohScene: Better start running in your hamster wheel