Fundamentals of GBA Programming - Fundamentals of GBA...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Fundamentals of GBA Programming NetBeans Version Concepts Each of the following discussions is divided into two sections: the specifics of GBA hardware requirements and in general the C programming concepts required. Basic Operation of the GBA GBA Specifics Write a program that sets up the GBA and then waits indefinitely. The program actually stops when you turn power off the GBA. The simulator stops when you close the simulator window. C Coding Write a C program containing the function: int main() { // where the program starts, // and at the end of the function put: while(1) { } Paint a Pixel a certain Color in True Color mode GBA Specifics set Mode 3 and BG2 data bits in the display control register (address 0X4000000) calculate the memory offset for the appropriate pixel calculate a color word set the color value offset from the video buffer at 0X6000000 C Coding typedef #define to create your own language tools Pointers hexadecimal arithmetic logical operators | (or) (and) and << (shift)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Draw a Rectangle on the Screen GBA Specifics starting at the top left of the rectangle: for each row of the rectangle for each column of the rectangle set the pixel at that row and column to the appropriate color C Coding for loops: // define an index variable int i;// the for loop has three parts // separated by semicolons for( i = 0; // initialization i < n; // the test to keep doing it i++) { // the increment part // the code body } After initialization, the parts are repeatedly executed in the following order until the test fails. Note that if the test fails immediately, the code body is never executed. 1. test - finish if false 2. code body 3. increment part To Wait for the Right Time to Draw GBA Specifics We want to change the display when the display processor is not drawing. scanlineCounter is a volatile register at 0X4000006 that tells us where the display processor is currently looking To draw at the right time: 1. wait until the display is drawing (scanlineCounter < 160) 2. wait until it is not drawing (scanlineCounter > 159) C Coding While loops stop the processor until a condition is met.
Background image of page 2
Create a "bouncing ball" effect GBA Specifics 1. Wait for the right time to draw 2. Draw a background color rectangle where the ball was last time to erase it 3. change the ball coordinates 4. paint a rectangle where the ball now is 5. check the screen edges and reverse direction where necessary C Coding Abstraction: Things are getting messy enough to start using function calls rather than in-line code for everything. Get a button pressed input GBA Specifics Buttons are in one memory location (0x4000130) in different bit positions. (
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/23/2011 for the course COMPUTER S 1372 taught by Professor Smith,david during the Spring '11 term at Georgia Institute of Technology.

Page1 / 20

Fundamentals of GBA Programming - Fundamentals of GBA...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online