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
  • No one is chatting at the moment.
  • Materia_tofu @ Materia_tofu:
    im not a very bright individual, but we live and we learn
  • SylverReZ @ SylverReZ:
    @Materia_tofu, We do learn a lot from plenty of talented individuals.
  • Materia_tofu @ Materia_tofu:
    this is true! i learned how to make soundfont remixes from a friend back in 2021
    +1
  • BakerMan @ BakerMan:
    Update on my brother: He's home now, tired and hungry, obviously, but other than that, seems to be doing fine.
    +2
  • Veho @ Veho:
    That's a relief to hear. Do you know what happened?
  • SylverReZ @ SylverReZ:
    @BakerMan, Any idea what happened? I hope that your brother's doing good.
  • BakerMan @ BakerMan:
    Well, from what I've heard from my parents, he had a seizure last night, perhaps an epileptic episode, fucking died, had a near death experience, my dad called the paramedics, they showed up, took him to the hospital, and he woke up covered in tubes, and started complaining.
  • BakerMan @ BakerMan:
    He couldn't eat until after his MRI, when he had a bomb pop.
  • BakerMan @ BakerMan:
    What matters now is that he's doing alright.
  • Veho @ Veho:
    But you still don't know what it was?
  • Veho @ Veho:
    Has he had seizures before?
  • The Real Jdbye @ The Real Jdbye:
    apparently stress can cause seizures, my brother had one during a test once
  • The Real Jdbye @ The Real Jdbye:
    never had one before that, and never had one since
  • Redleviboy123 @ Redleviboy123:
    Question about game texture chanching Do i need an own game id?
  • The Real Jdbye @ The Real Jdbye:
    @Veho for those that want to
    experience being sonic the hedgehog
  • Veho @ Veho:
    Ah, you mean
    furries.
  • The Real Jdbye @ The Real Jdbye:
    well, sonic fans are a whole separate thing from furries
  • The Real Jdbye @ The Real Jdbye:
    like bronys
  • The Real Jdbye @ The Real Jdbye:
    sonic porn is too weird even for me
  • Dumpflam @ Dumpflam:
    bruh
  • Dumpflam @ Dumpflam:
    guys how do i delete a post
  • The Real Jdbye @ The Real Jdbye:
    you don't
  • The Real Jdbye @ The Real Jdbye:
    you can report it and request deletion
    The Real Jdbye @ The Real Jdbye: you can report it and request deletion