01-12-2006, 01:04 AM
I'm taking a course in GBA programming, and decided to try to get it to show pixels on the screen.
ERRORS ALERT!!!! I get over loaded with errors and i don't know what i am doing wrong.
ERRORS ALERT!!!! I get over loaded with errors and i don't know what i am doing wrong.
Code:
//Copied From The Header File
#ifndef GBA_HEAD
#define GBA_HEAD
// GBA Type Header File - Draft 1
#ifndef GBA_TYPE
#define GBA_TYPE
// Types
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef signed char s8;
typedef signed short s16;
typedef signed long s32;
typedef unsigned char byte;
typedef unsigned short hword;
typedef unsigned long word;
typedef volatile unsigned char vu8;
typedef volatile unsigned short vu16;
typedef volatile unsigned long vu32;
typedef volatile signed char vs8;
typedef volatile signed short vs16;
typedef volatile signed long vs32;
// BITS
#define BIT0 1
#define BIT1 (1<<1)
#define BIT2 (1<<2)
#define BIT3 (1<<3)
#define BIT4 (1<<4)
#define BIT5 (1<<5)
#define BIT6 (1<<6)
#define BIT7 (1<<7)
#define BIT8 (1<<8)
#define BIT9 (1<<9)
#define BIT10 (1<<10)
#define BIT11 (1<<11)
#define BIT12 (1<<12)
#define BIT13 (1<<13)
#define BIT14 (1<<14)
#define BIT15 (1<<15)
#define BIT16 (1<<16)
#define BITA (1<<10)
#define BITB (1<<11)
#define BITC (1<<12)
#define BITD (1<<13)
#define BITE (1<<14)
#define BITF (1<<15)
#define BIT16 (1<<16)
#define BIT17 (1<<17)
#define BIT18 (1<<18)
#define BIT19 (1<<19)
#define BIT20 (1<<20)
#define BIT21 (1<<21)
#define BIT22 (1<<22)
#define BIT23 (1<<23)
#define BIT24 (1<<24)
#define BIT25 (1<<25)
#define BIT26 (1<<26)
#define BIT27 (1<<27)
#define BIT28 (1<<28)
#define BIT29 (1<<29)
#define BIT30 (1<<30)
#define BIT31 (1<<31)
#define BIT(n) (1<<(n))
#endif
// Some Misc Stuff
#define NULL 0
// RGB Macro
#define RGB16(r,g,b) ((r)|((g)<<5)|((b)<<10))
// Registers
#define REG_DISPCNT (*(vu32*)0x4000000)
// Background Sizes
#define VidWidth 240
#define VidHeight 160
// Modes and Backgrounds
#define Mode0 0
#define Mode1 1
#define Mode2 2
#define Mode3 3
#define Mode4 4
#define Mode5 5
#define Bg0_Enable BIT(0x8)
#define Bg1_Enable BIT(0x9)
#define Bg2_Enable BIT(0xA)
#define Bg3_Enable BIT(0xB)
#define SetMode(mode) REG_DISPCNT = (mode)
// Memory Access
#define VidMemory ((u16*)0x6000000)
#endif
// End copied stuff
int __gba_multiboot; // Dunno why i have to do this...
// The main section of the code
int main();
{
// Set the memory access to the video memory, which is where we draw our pixels
u16* vid_mem = VidMemory;
// Set the screen mode and enable BackGround 2
SetMode(Mode3 | Bg2_Enable);
// Declare a integer array to use for the pixel r, g and b colours
int npixelcolour[3];
// use a for loop to plot the pixels in a diagonal line.
int nx;
nx = 1;
int ny = 1
for (; ny < 10; ny+=1)
{
// This bit was mostly hard for me to figure out. It SHOULD change the colours of the RGB values.
if ( ny >= 7 ) {
npixelcolour[2] = 31;
npixelcolour[1] = 0;
npixelcolour[0] = 0;
} // if 2
if ( ny >= 3 ) && ( ny < 7 ) {
npixelcolour[2] = 0;
npixelcolour[1] = 31;
npixelcolour[0] = 0;
} // if 1
if ( ny < 3 ) {
npixelcolour[2] = 0;
npixelcolour[1] = 0;
npixelcolour[0] = 31;
} // if 0
vid_mem[nx+ny*VidWidth] = RGB16(npixelcolour[0],npixelcolour[1],npixelcolour[2]);
nx+=1;
} // for y
while(1);
return 0;
}
url=http://www.sloganizer.net/en/][/url]