Tobriand
Well-Known Member
Right... I've finally managd to get Mr Mirko's SDK compiling in Windows, so then I thought I'd have a bash at the tutorials. Which went well for the first one (what I could be bothred to do to start with), before I decided to try and write something pretty basic of my own - a paint program for ASCII characters.
I've got moving of the character working fairly well, but I'm having trouble using a variable character (it always comes out as something other than what brush tries to make it - though I can replace brush with a "<character>" and it'll work in the gp_SetFont8 bits) and changing colours.
I've pasted the entire souce in, and I'm sorry that most of it is riddled with left-overs from previous experiements and thus is somewhat incomprehensible. As you can see, its based on the first of Synkro's tutorials, primarily because I couldn't be bothered to type out my own Framebuffer et al.
Any help would be appreciated. Bar the tutorial, this is my first GP32 project, and my second in C (the first didn't work though lol), so forgive me any blatant blunders I've made.
I've got moving of the character working fairly well, but I'm having trouble using a variable character (it always comes out as something other than what brush tries to make it - though I can replace brush with a "<character>" and it'll work in the gp_SetFont8 bits) and changing colours.
I've pasted the entire souce in, and I'm sorry that most of it is riddled with left-overs from previous experiements and thus is somewhat incomprehensible. As you can see, its based on the first of Synkro's tutorials, primarily because I couldn't be bothered to type out my own Framebuffer et al.
Any help would be appreciated. Bar the tutorial, this is my first GP32 project, and my second in C (the first didn't work though lol), so forgive me any blatant blunders I've made.
Code:
// Based on a heavily heavily modified version of Synkro's "Hello World" tutorial
#include <gp32.h> // Includes the SDK header with all definitions
unsigned short *framebuffer; // A framebuffer pointer
void main(void)
{
framebuffer = (unsigned short*) FRAMEBUFFER;
gp_SetScreen(framebuffer, 16);
int i;
for (i=0; i<320*240; i++) framebuffer[i]=0xFFFF;
gp_SetCpuSpeed(66);
int x_pos = 150; // This int stores the x-position of the text
int y_pos = 110;
int length = 1; // length of the char[] to be drawn
int color = 0x0000; // RGB (RRRRRGGGGGBBBBB0 = 16 bit)
char brushbank[10] = "^*OoE#~+=-5";
int brushnumb = 0;
int brush = brushbank[brushnumb];
int colorchange = 0;
int breaker = 0;
while(breaker == 0)
{
int stopper;
gp_SetFont8(x_pos, y_pos, length, brush, 0xF000, framebuffer);
gp_ButtonInit();
//The next bit of code is for directional movement. No diagonals yet, though.
while (gp_ButtonResult()&BUP)
{
gp_SetFont8(x_pos, y_pos, length, brush, color, framebuffer);
y_pos = y_pos - 8;
gp_SetFont8(x_pos, y_pos, length, brush, 0xF000, framebuffer);
for (stopper = 0; stopper < 1000000; stopper ++) {stopper=stopper;};
};
while (gp_ButtonResult()&BDOWN)
{
gp_SetFont8(x_pos, y_pos, length, brush, color, framebuffer);
y_pos = y_pos + 8;
gp_SetFont8(x_pos, y_pos, length, brush, 0xF000, framebuffer);
for (stopper = 0; stopper < 1000000; stopper ++) {stopper=stopper;};
};
while (gp_ButtonResult()&BLEFT)
{
gp_SetFont8(x_pos, y_pos, length, brush, color, framebuffer);
x_pos = x_pos - 8;
gp_SetFont8(x_pos, y_pos, length, brush, 0xF000, framebuffer);
for (stopper = 0; stopper < 1000000; stopper ++) {stopper=stopper;};
};
while (gp_ButtonResult()&BRIGHT)
{
gp_SetFont8(x_pos, y_pos, length, brush, color, framebuffer);
x_pos = x_pos + 8;
gp_SetFont8(x_pos, y_pos, length, brush, 0xF000, framebuffer);
for (stopper = 0; stopper < 1000000; stopper ++) {stopper=stopper;};
};
//Now we're onto colour changing, which is proving damn hard.
while (gp_ButtonResult()&BA)
{
brushnumb ++;
if (brushnumb = 11) brushnumb = 0;
gp_SetFont8(10, 10, 1, brush, color, framebuffer);
for (stopper = 0; stopper < 1000000; stopper ++) {stopper=stopper;};
}
//So instead we're going to skip to channging ASCII symbols
while (gp_ButtonResult()&BB)
{
brushnumb ++;
if (brushnumb = 11) brushnumb = 0;
gp_SetFont8(10, 10, 1, brush, color, framebuffer);
for (stopper = 0; stopper < 1000000; stopper ++) {stopper=stopper;};
}
if (brushnumb == 0) brush = "^";
if (brushnumb == 1) brush = "A";
// Lets just add some clearing bits quickly
if (gp_ButtonResult()&BSTART)
{
breaker = 1;
}
if (breaker == 1) break;
};
} // End of the "main" function