#145556 - speedemon35 - Sun Nov 18, 2007 1:05 am
Hello all. Name is Daniel and i'm currently studying computer games technology. As the name implies at some point in the near future i'll be programming games. I'm in first year and sadly i need help with programming the gba. I'm using dev kit pro if that will make any difference btw. A few things you should know before hand: My current games technology teacher is possibly the last person you'll ever want to meet or have teaching you. Only support he ever gives is the word google so that will probably explain why i don't have a clue on what to actually look for in the gba tutorials.
Anyway i'm hoping someone here can give me some serious help as i've been trying to figure this out for a full week and i still can't get any of it right:
The tasks i was was set seem simple enough:
1. Write a function or macro, which takes three values between 0 and 31, and converts this to BGR 16 bit format. For example, the function prototype should look like u16 BGR(u16 b, u16 g, u16 r);
^ my actual problem^
2. Draw a yellow pixel in the centre of the screen (in mode3).
^done this one as it was just a guessing numbers game^
3. Allow the pixel to be moved around using the D-Pad (make sure it doesn?t go past the boundaries of the screen). (guessing something like offset limit will do the trick here)
4. Change pixel colour using A and B buttons.
^no clue about that either as i haven't even looked at any possible tutorial on how to do it^
anyway here is the code:
the actual macro is here:
and i'm supposed to edit it inside the code so that it does what task 1 asks
Write a function or macro, which takes three values between 0 and 31, and converts this to BGR 16 bit format.
As you might have guessed by now i honestly don't have the smallest clue on how to properly edit the code without messing things up.
That entire thing was programmed in C, and the closest thing i know to c is C++. But between C++, C, and actual gba programming there are quite fine differences.
I know how to do what the task asks me in C++ as its just a simple matter of defining the macro, passing parameters with a cin user input in the middle. I wasn't quite able to do the same thing in C since parameters are handled a bit differently in C and i couldn't quite get the cout and cin part in C either since i don't know what the reserved keywords are for it.
With all that i still did try to edit the code to make it work on the gba but I'm never able to do anything correctly. NO matter what i write i keep on getting error not in scope of function regardless of where I put it in. I tried declaring my stuff globally but even then it complained about not in scope of function and just said ERROR 1 and fails to load the gba correctly.
I'm terribly sorry for wasting your time as this must sound pretty pathetic and its probably something basic for all of you but i simply got stuck with the worst possible imbecile for a teacher who is unable to provide any actual support what so ever.
Thank you for your time,
Sincerely
Daniel
Anyway i'm hoping someone here can give me some serious help as i've been trying to figure this out for a full week and i still can't get any of it right:
The tasks i was was set seem simple enough:
1. Write a function or macro, which takes three values between 0 and 31, and converts this to BGR 16 bit format. For example, the function prototype should look like u16 BGR(u16 b, u16 g, u16 r);
^ my actual problem^
2. Draw a yellow pixel in the centre of the screen (in mode3).
^done this one as it was just a guessing numbers game^
3. Allow the pixel to be moved around using the D-Pad (make sure it doesn?t go past the boundaries of the screen). (guessing something like offset limit will do the trick here)
4. Change pixel colour using A and B buttons.
^no clue about that either as i haven't even looked at any possible tutorial on how to do it^
anyway here is the code:
Code: |
//================ // HEADERS //================ #include "gba.h" //================ // CONSTANTS //================ #define BG2_ENABLE 0x400 #define MODE3 0x3 #define FRONTBUFFER (u16*)0x6000000 #define RGB(r,g,b) ((b<<10)+(g<<5)+r) //u16 --> unsigned short, this is macro for RGB() 15bit color format #define ScreenWidth 240 #define ScreenHeight 160 //================ // GLOBALS //================ u16* g_uspVideoBuffer = FRONTBUFFER; //This is were we are currently drawing //================ // FUNCTIONS //================ //================ // Function: PlotPixel16(int, int, unsigned short int) // Notes: Plots a pixel in the specified colour // Date: 14/2/2002 //================ void PlotPixel16(int in_iX,int in_iY, unsigned short int in_usColour) { g_uspVideoBuffer[(in_iY) * ScreenWidth + (in_iX)] = (in_usColour); } //================ // Function: main() // Notes: Main entry point into rom // Date: 14/2/2002 //================ int main() { //REG_DISPCNT (defined in gba.h) is the main display register that controls //the mode of operation which backgrounds are enabled and which buffer is //currently being drawn by the GPU. //this sets the screen mode to mode three and enables background 2 //background 2 is required for all bitmap modes(3-5) REG_DISPCNT = MODE3 | BG2_ENABLE; unsigned short yellow = RGB(31,31,15); //unsigned short green= RGB(0,31,0); //unsigned short blue = RGB(0,0,31); //unsigned short white= RGB(31,31,31); //draw a pixel on GBA screen PlotPixel16(120,80,yellow); //PlotPixel16(130,70,green); //PlotPixel16(110,90,blue); //PlotPixel16(130,90,white); while(1){} return 0; } |
the actual macro is here:
Code: |
#define RGB(r,g,b) ((b<<10)+(g<<5)+r) |
and i'm supposed to edit it inside the code so that it does what task 1 asks
Write a function or macro, which takes three values between 0 and 31, and converts this to BGR 16 bit format.
As you might have guessed by now i honestly don't have the smallest clue on how to properly edit the code without messing things up.
That entire thing was programmed in C, and the closest thing i know to c is C++. But between C++, C, and actual gba programming there are quite fine differences.
I know how to do what the task asks me in C++ as its just a simple matter of defining the macro, passing parameters with a cin user input in the middle. I wasn't quite able to do the same thing in C since parameters are handled a bit differently in C and i couldn't quite get the cout and cin part in C either since i don't know what the reserved keywords are for it.
With all that i still did try to edit the code to make it work on the gba but I'm never able to do anything correctly. NO matter what i write i keep on getting error not in scope of function regardless of where I put it in. I tried declaring my stuff globally but even then it complained about not in scope of function and just said ERROR 1 and fails to load the gba correctly.
I'm terribly sorry for wasting your time as this must sound pretty pathetic and its probably something basic for all of you but i simply got stuck with the worst possible imbecile for a teacher who is unable to provide any actual support what so ever.
Thank you for your time,
Sincerely
Daniel