GP32 Help wanted with REALLY basic GP32 examples


GoatersLeftShin

Still Fresh
Joined
Apr 26, 2003
Messages
7
Hello all,

I am not sure this is the right forum, but if not please excuse me! :)

Anyway, I have some experience programming in C - especially using the Allegro libraries which I found really helpful. I've been programming games for years on the Spectrum, AtariST and PC. One was even put on the main cover disk of ST Action which I was well chuffed with! :)

Ok, what I am looking for is some REALLY basic examples of some sprite routines. Something I could download, compile and play straight away.

I've had a look around some sites looking for sample code, or even code that others have written that I could look at.

Could anyone point me in the right direction as to where I should be looking as I'd love to start writing some games for the GP32. I've got the tools but nothing really that I can start playing with straight away.

I apologise in advance if this is a daft question!
 
on the official site there is the source code to the tetris/poyo/hexa clones that are on www.gp32x.de

try those.
 
Last edited by a moderator:
Code:
#include <gpstdio.h>

void GpMain (void *arg)
{
  printf("Hello World!\n");
}

:D

No seriously you have many options - game sources, Craig's example, and also Gamepark's official example. (Links coming up)...
 
Craig's example code:
http://207.44.176.77/~admin28/cgi-bin/dgp3...ilename=example 1.zip

devkitadv for gba with gp32 libs, test program:
http://www.thaworx.co.uk/ninja/devkitadv.rar (or .zip)

This devkit has everything you need to start compiling and has a test program, whilst the example code above has stuff like blitting in it.

There's a tutorial, but it might be too obvious for you:
http://www.thaworx.co.uk/ninja/tut1.htm

If you need to know how to do specific stuff in gp32 there are developers to help you, you can certainly contact me if you have questions...

- Rico
 
Very nice tuturial, Rico. Mind making a simple proggraming tutorial? Some people might pay you up to 20$ for it, because there are about 5-10 people who applied to the kokohead studiod tutorials. Easy 100-200 dollars if yuo ask me.
 
Thanks for the link to that devkitadv + tutorial Rico! Just what I wanted, it only took me like 15 minutes to have my first GP32 program (a color-tunnel! :D ) up and running.
Now I really REALLY want to get an actual GP32 unit and start coding for real! I'm very tempted to just head over to gbax.com and make an impulse buy...
 
I mentioned this tut earlier, but people still don't seem to know about it. I could about my mod powers and sticky it :) but I won't.
 
Sdw posted on May 8 2003 said:
Thanks for the link to that devkitadv + tutorial Rico! Just what I wanted, it only took me like 15 minutes to have my first GP32 program (a color-tunnel! :D ) up and running.
Would there be any chance you could post your code so I could have a look at it?

I think what would be very useful for a lot of us would be something along the lines of allegro. Is there are anything similar around or planned for the future?
 
Last edited by a moderator:
Thanks for all your replies people - especially Rico as I found that very useful.

When I get my first GP game done you will all be able to take some credit for it! :)

Cheers!
 
Allegro has been partially ported, only a few select routines...for personal projects.

A public Allegro port would be a good idea, with stuff like sprite rotation, poly routines etc. which aren't in Gamepark's SDK. However rather than port the entire thing it would be sensible to make a few special effects functions for use in games, and maintain compatiblity with the SDK.

- Rico
 
GoatersLeftShin posted on May 9 2003 said:
Sdw posted on May 8 2003 said:
Thanks for the link to that devkitadv + tutorial Rico! Just what I wanted, it only took me like 15 minutes to have my first GP32 program (a color-tunnel! :D ) up and running.
Would there be any chance you could post your code so I could have a look at it?
Sure, but don't expect much! I don't even know if it runs on a real GP32 (or it might run too fast or too slow). I couldn't figure out how to change the palette either, so the colors aren't very nice...
But I ordered a GP32 from gbax.com yesterday, so in a week or so I'll be doing some REAL stuff! B)

Code:
/*
** Color Tunnel for GamePark32
** The first GP32 program by Andreas Gustafsson :)
*/

#include <stdlib.h>
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"
#include "gpstdio.h"

int tunnelTab[65536];

void GpMain(void *arg)
{
	int i,scrOff,x,xx,y,t;
	
	GpClockSpeedChange(132000000, 0x24001, 2);        /* speed = 133 Mhz */	
	nflip = 1;
	/* Enable and clear LCD screen */	
	for(i = 0; i < 2; i++)
	{
  GpLcdSurfaceGet(&gpDraw[i], i); 
	}  
	GpSurfaceSet(&gpDraw[0]);	
	for(i=0;i<65536;i++) tunnelTab[i]=65535/(i+1);	/*init tunnel distance table*/  
	while(1)
	{
  scrOff=0;
  for(x=-160;x<160;x++)
  {
  	xx=x*x; 
  	for(y=-120;y<120;y++)
  	{
    gpDraw[nflip].o_buffer[scrOff]=(tunnelTab[(xx+y*y)]+t)&255;
    scrOff++;
  	}
  }
  t=(t+1)&255; /* Increase tunnel position */
  /* flip the page */
  GpSurfaceFlip(&gpDraw[nflip++]);
    	nflip &= 0x01;    	
	}
}
 
Last edited by a moderator:
Move the tunnel left/right/up/down :
Silly but it works !!

tunnel.c
----------

/*
** Color Tunnel for GamePark32
** The first GP32 program by Andreas Gustafsson :)
** useless tunnel steering by HugoFurst :0
*/

#include <stdlib.h>
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"
#include "gpstdio.h"

int tunnelTab[65536];

void GpMain(void *arg)
{
int i,scrOff,x,xx,y,t,deltax,deltay,ExKey;
unsigned char keydata;

GpClockSpeedChange(132000000, 0x24001, 2); /* speed = 133 Mhz */
nflip = 1;
/* Enable and clear LCD screen */
for(i = 0; i < 2; i++)
{
GpLcdSurfaceGet(&gpDraw, i);
}
GpSurfaceSet(&gpDraw[0]);
for(i=0;i<65536;i++) tunnelTab=65535/(i+1); /*init tunnel distance table*/

deltax = 0; /* init tunnel left-right delta */
deltay = 0; /* init tunnel up-down delta */
while(1)
{
GpKeyGetEx(&ExKey);
keydata=ExKey & 0xff;

if((keydata & GPC_VK_LEFT)==GPC_VK_LEFT)
{
deltax -=1;
}
if((keydata & GPC_VK_RIGHT)==GPC_VK_RIGHT)
{
deltax +=1;
}
if((keydata & GPC_VK_UP)==GPC_VK_UP)
{
deltay +=1;
}
if((keydata & GPC_VK_DOWN)==GPC_VK_DOWN)
{
deltay -=1;
}


scrOff=0;
for(x=-160+deltax;x<160+deltax;x++)
{
xx=x*x;
for(y=-120+deltay;y<120+deltay;y++)
{
gpDraw[nflip].o_buffer[scrOff]=(tunnelTab[(xx+y*y)]+t)&255;
scrOff++;
}
}
t=(t+1)&255; /* Increase tunnel position */
/* flip the page */
GpSurfaceFlip(&gpDraw[nflip++]);
nflip &= 0x01;
}
}

-------
Makefile
-------
# devkitadv base dir
export CCBASE=c:/devkitadv
# User options passed to the compiler
export CUSER=-DLITTLE_ENDIAN -DGP32 -W -Wall -ansi -pedantic
include $(CCBASE)/gp32.mk
#------------------------------

all: tunnel.fxe

tunnel.o: tunnel.c

tunnel.elf: tunnel.o
$(LINK)

tunnel.fxe: tunnel.gxb


clean:
del tunnel.gxb tunnel.fxe tunnel.elf tunnel.o

--------

I'm sure I'm doing something "wrong", but it makes & runs on my GP32.
Now for some sound toys !!
 
Ulp - forgot 2 things:
1 -
gpmain.h
-------------

#ifndef __gpmain_h__
#define __gpmain_h__

void GpMain(void * arg);
int nflip, ExKey;

GPDRAWSURFACE gpDraw[2]; /* buffers */

#endif /*__gpmain_h__*/

------------

2 - If you overscroll, the resulting patterns are atarilicious !
 
Now with more key control - Start "resets" tunnel steering, "select" reboots GP32 (continue holding to drop into Mr.Spiv's MuliFW !)

Simple but fun - Sorry if I'm chatbursting, it finally just clicked for me !!!
Hugo
--------
tunnel.c
--------
/*
** Color Tunnel for GamePark32
** The first GP32 program by Andreas Gustafsson :)
** useless tunnel steering by HugoFurst :0
*/

#include <stdlib.h>
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"
#include "gpstdio.h"

int tunnelTab[65536];

void GpMain(void *arg)
{
int i,scrOff,x,xx,y,t,deltax,deltay,ExKey;
unsigned char keydata;

GpClockSpeedChange(132000000, 0x24001, 2); /* speed = 133 Mhz */
nflip = 1;
/* Enable and clear LCD screen */
for(i = 0; i < 2; i++)
{
GpLcdSurfaceGet(&gpDraw, i);
}
GpSurfaceSet(&gpDraw[0]);
for(i=0;i<65536;i++) tunnelTab=65535/(i+1); /*init tunnel distance table*/

deltax = 0; /* init tunnel left-right delta */
deltay = 0; /* init tunnel up-down */

while(1)
{
GpKeyGetEx(&ExKey);
keydata=ExKey & 0xff;

if((keydata & GPC_VK_LEFT)==GPC_VK_LEFT)
{
deltax -=1;
}
if((keydata & GPC_VK_RIGHT)==GPC_VK_RIGHT)
{
deltax +=1;
}
if((keydata & GPC_VK_UP)==GPC_VK_UP)
{
deltay +=1;
}
if((keydata & GPC_VK_DOWN)==GPC_VK_DOWN)
{
deltay -=1;
}
if(ExKey & GPC_VK_START)
{
deltax=0; /* reset tunnel right-left */
deltay=0; /* reset tunnel up-down */
}
if(ExKey & GPC_VK_SELECT)
{
GpAppExit(); /* reboot GP32 */
}

scrOff=0;
for(x=-160+deltax;x<160+deltax;x++)
{
xx=x*x;
for(y=-120+deltay;y<120+deltay;y++)
{
gpDraw[nflip].o_buffer[scrOff]=(tunnelTab[(xx+y*y)]+t)&255;
scrOff++;
}
}
t=(t+1)&255; /* Increase tunnel position */
/* flip the page */
GpSurfaceFlip(&gpDraw[nflip++]);
nflip &= 0x01;
}
}
 
Thanks for the code! For me it's amazing how this thing works, as I am a not so good programmer. For several weeks I try to programm a simple "slide show" like routine, which fades in and out some 8bit images. And till today I havn't finished this one.
 
hugofurst : nice, I didn't know how to look for joy/button-input, but from your code it looks real easy!
Btw. the reason overscrolling makes it look strange is when x*x+y*y is greater than 65535 or less than 0, which will result in reads in undefined memory outside of the distance table.

Anyone know how to change the palette definition? that would make things look nicer aswell?
 
how is the gpDraw function working? I can see the two loops that draw the screen in x and y, but where is the call to actually draw the pixels?

me=somesortofnewbie
 
Ok - not much of a coder, myself

However, this discussion board is a WEALTH of code/info/insights/help.
Many more worthy than myself have contributed code + time to make this a kick-ass platform/board

All I did was D/L the "startup_en.pdf" -> It contains a wealth of code examples & explanations.
It also has very elaborate instructions on how to use/config ADW/APM dev environment
(Sorry - clueless here, I use the devkitadv linked at the beginning of this post)

Then I looked at other programmers code & began to piece together my own frankenstein
with bits of code from other programmers work.

Trial & error + Educated guesses + Programming examples/demos = Your First GP32 program !!
Keep at it - - It is rare that you can enjoy learning something new.
And did I mention the games ?!

(p.s. I'm a Mac person. Yes, I am aware of Mr. Spivs amazing contributions. Yes, I did build a PC to dev/code with. Use the best tool for you & for the task at hand. Yes I will eventually move the whole show over to my Mac when I have a better understanding of what the Hell I'm doing)

Keep at it - - When if finally "clicks" the rush is intense !
Keep asking question - - The community is very helpful/supportive.

We all begin at the beginning.
 
hugo, i am a coder. i'm just unfamiliar with the GP/GBA SDK. is there documentation for that.

I am assuming each call to gpDraw draws the subsequent pixel? but that could be clearer! Where did you get that PDF from?

matt
 
Not "not a coder" just "not much of a coder" ;)

Try here:

http://www.gp32x.de/download/development/.../startup-en.rar

sez it's for ARM development, but contains clean clear examples of the SDK in action.


There is also another document that is exhaustive on the GP32 SDK here:

http://gp32.emu.pl/download/development/api.pdf


Troll the usual suspects for GP info/docs/demos/code:
http://www.gp32news.com/
http://www.gp32emu.com/
http://gamepark.tk/
http://users.raketnet.nl/darkfader/http://...fader.net/gp32/
http://www.devrs.com/gp32/
http://www.deadcoderssociety.tk/

and, of course, our favorite GP32 site:
http://www.gp32x.de/
 
Last edited by a moderator:
Back
Top