Last active
May 31, 2016 07:25
-
-
Save MtShadow/2475715d7ea2513db44cd34bf1807e22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "gba.h" | |
typedef struct __attribute__((packed)) { | |
hword data[ 16 ]; // Sprite graphic data | |
} character16; | |
character16 characters[] = | |
{ | |
{ | |
{ | |
0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, | |
0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111 | |
} | |
}, // Ball | |
{ | |
{ | |
0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, | |
0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111 | |
} | |
}, | |
{ | |
{ | |
0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, | |
0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111 | |
} | |
} // Racket | |
}; | |
int main() | |
{ | |
int i, j; | |
volatile hword *ptr; | |
volatile character16* chptr; | |
volatile sprite* sp; | |
// Initialize background (green) | |
gba_register(LCD_CTRL) = LCD_OBJMAP1D | LCD_MODE0 | LCD_OBJEN; | |
ptr = (hword*) BG_PALETTE; | |
ptr[0] = BGR(0, 31, 0); // backdrop color | |
// Initialize ball and racket | |
// Set pallet | |
ptr = (hword*) OBJ_PALETTE; | |
ptr[0] = BGR(0, 0, 0); | |
ptr[1] = BGR(31, 31, 31); | |
// Set characters | |
chptr = (character16*) OBJ_CHAR_TILE; | |
for (i = 0; i < 3; i++) | |
{ | |
for (j = 0; j < 16; j++) | |
chptr[i].data[j] = characters[i].data[j]; | |
} | |
// Set ball OAM | |
sp = (sprite*) OAM; | |
sp[0].attr0 = OBJ_SHAPE_SQ + 50; | |
sp[0].attr1 = 0x0000 + 50; | |
sp[0].attr2 = 0x0000; | |
sp[0].padd = 0x0000; | |
// Set racket OAM | |
sp[1].attr0 = OBJ_SHAPE_HR + 50; | |
sp[1].attr1 = 0x0000 + 50; | |
sp[1].attr2 = 0x0000 + 1; | |
sp[1].padd = 0x0000; | |
while(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment