GP2X Pssst!


Mr.Jabberwocky

Bloke with a brick on his head
Joined
Sep 27, 2005
Messages
402
Website
Visit site
Having run out of socks, pants and all that other stuff society expects you to hide your shame with, I was forced to do laundry. While pulling apart the congealed mass of socks and boxers, out fell a hard object. After parting it from a particularly crusty pair of shorts I realised it was my old GP2X.

Seeing the great remakes of old Spectrum games like Camelot Warriors and Knight Lore I thought it must be time to ruin it all with a remake of my own.

I have noticed a couple of threads where people show interest in getting into homebrew.

The best advice would be not to bother. 97% of the monkeys who bought a GP2X will never look at a homebrew title, 'coz its all about ROMZ and frameskips and transparencies that don't work, running at half speed. Of the remaining 3%, 2% will download your hard graft just to tell you it is crap and they deleted it after 5 minutes. The remaining 1% will be another sad git like yourself who also writes homebrew who may leave a nice comment while secretly laughing at your efforts. So it is really not worth it if you want to 'give' to the 'community'.

If you are just doing it for your own edification then it is a fantastic past time that allows you to waste the precious hours of your life and excuses you from all that distasteful interaction with other human beings (Especially women. Yuck!).

I made a thread before, logging the painful progress of a previous project. If I do the same here I hope it may be of help to someone.

As the bloke who downloaded my last effort is all too aware, I am not particularly gifted in the homebrew department. Sadly that is not enough to put me off and subsequently I will be tackling what looks to be the simplest game (bar pong).

The great thing about writing for a 'nobody' device like the GP2X is that remaking old classics is not going to come to the attention of the copyright holders. And if it does I doubt they will care.

I have elected to remake something so dire it is astonishing that a successful company still exists that was built upon selling this sort of cack. Unlike last time, I have actually done some research and played the game a few times before deciding to remake it. A couple of the worst aspects of this game is the horrendous colour clash on the Spectrum (Sadly it would be too much of an effort on my part to reproduce it) and the fact you can get huge scores by just making sure you never progress past the first 'level'. ( That should be no problem ).

The best part of this company's games was the loading screens. This was the secret of their success, as you spent more time waiting for it to load than actually playing the game. This left you with an overall impression of it being better than it was. So I will probably give the loading screen a miss. Alternatively I could display it and force the player to wait 5 minutes before starting the game. Nostalgia ain't what it used to be.

I have actually got things going by making a start on the graphics. Below is a mock up of what it should end up looking like.


jabber-1.gif


For extra authenticity I am cramming it into a 256 X 192 screen. Great, huh!
 
Nice speech... and what the hell of a game are you talking about? I wanna see some original screenies XD
 
Quiest said:
Nice speech... and what the hell of a game are you talking about? I wanna see some original screenies XD
It is called PSSST by Ultimate Play the Game who later went on to create Knight Lore and Alien8 etc.

The amazing loading image :
title.gif

The not so amazing game :
scrshot0.gif


The idea is to control the owl-robot(?) to defend the plant from the bugs. There are three types of bug and three bug-sprays. Each type of bug requires a specific spray to kill it. Each spray kills one type of bug and temporarily paralyses one other type.

If one bug reaches your plant it stops to feed on it and the growth of the plant halts. If more than one bug attatches itself, the plant regresses. If left too long your plant will get eaten and you lose a life. You also lose a life if your robot collides with a bug.

Bonuses randomly appear that are worth a lot of points but you have to put down your spray to collect them.

Much as I put this game down, I actually think it is quite a fun little timewaster.

I guess Orkie's wikipedia link says it better.
 
Last edited by a moderator:
Encore! Bravo!

I always thought that the wild devs were going to a kind of devs cemetary once they finished their programs... Hated by everyone for another pong release ("but that was a revolutionary pong")... misunderstood.

I think that there is enough people interested in homebrew for the GP2X.
Recently we had a lot of quality homebrew games.
Personally I don't get the Emu vs Homebrew thing because I really enjoy the feeling of playing an old classic and the pleasure of a brand new game.
I want to have both :)
Perhaps an Emu release is attracting more people, but they are volatile (the people :) ). Once they have tried their favorite games for more than 5 minutes, they disapear. It's like that.
But for me the best part is to see how the devs manage to get things running.
The betas, Alphas, test versions, reading threads in which I didn't understand a lot, trying to be helpful...
Both Emu and Homebrew have this in common.
I'm not a dev, even if I try to learn as much as I can from what I'm reading.
But I try to be as supportive as I can.
I wish you good luck with your project and looking forward to test this 5 minutes wait madness :)

Ps: sorry for my engrish :)
 
Looks good, look forward to giving it a try. I have been playing the Knight Lore remake a huge amount and it really is superbly done. I like Pssst and the near identical Cookie but like most Ultimate games they were pretty hard. I think that if you want to bash a 16k game by Ultimate then Tranz Am is probably a better target.
 
Looking forward to it, cool :D

I remember the original back in the day and often play it on gp2xspectrum.

Nice post, although to appreciate the game I think you may of had to be there when it was a 'hot new release' :p

ps - I am not that old, its my birthday today (31) :)
 
Hi thanks for posting this. I'm looking forward to seeing and playing you're game... I'm sure you're going to have loads of fun making this little black box do it's stuff. I'm also working on a gp2x project, i've just got the screen redrawing and the input mechanics working so I know how tough it can be. Anyway good luck and keep us updated with you're progress...Looks like a fun game.

I was just wondering how much code reuse you think you might get from you're previous project? Are you looking at adapting or just reusing you're existing code/engine from you're other game?

Sorry for another edit, but I was just wondering if you should put an option into the game perhaps disabled by default allowing you to sit through the loading screen. I guess if it's like one of them c64 loading screens with the music and the loading graphics it could be interesting....


Rgds
:)
 
Uprising said:
I enjoyed reading How not to write a game. ;)

Good luck with your new project. :)
I am glad someone enjoyed it. I will endevour to make this more useful. Thanks.
twojame said:
Hi thanks for posting this. <snip>
Unfortunately there is very little useful code in Fire that would apply to this. No animation. No sprite movement. I will probably refer to it to remind myself about C and SDL.
If I did do the loading wait, it would have to be five minutes of spectrum tape loading screech - there is no other way.
Good luck with your game too !
dosteridge said:
<snip>... to appreciate the game I think you may of had to be there when it was a 'hot new release' :p

ps - I am not that old, its my birthday today (31) :)
Happy birthday dosteridge. I am only having a laugh when I diss the game. I would not be hoping to remake it if it was as bad as I make out.
WhizzBang said:
Looks good, look forward to giving it a try. I have been playing the Knight Lore remake a huge amount and it really is superbly done. I like Pssst and the near identical Cookie but like most Ultimate games they were pretty hard. I think that if you want to bash a 16k game by Ultimate then Tranz Am is probably a better target.
Knight Lore is a jewel in the GP2X homebrew crown - I am with you on that. This I fear may not be.
synkro said:
Hell yeah! Fuck those emu kids, keep it real! homebrew!
Homebrew for teh win11111!!!
virusx said:
Encore! Bravo!
<snip> ...
Personally I don't get the Emu vs Homebrew thing because I really enjoy the feeling of playing an old classic and the pleasure of a brand new game.
I want to have both :)
...<snip>
You must not take anything I say too seriously. There is room for both.
virusx said:
Encore! Bravo!
<snip> ...
I'm not a dev, even if I try to learn as much as I can from what I'm reading.
But I try to be as supportive as I can.
...<snip>
This could be your chance to learn a bit more - even if it is how not to put a game together. I am thinking of providing snippets of code and a guide so that you can build it yourself.
 
Last edited by a moderator:
Sweet idea!

I wasn't specifically talking about your post when I said "Emu Vs Homebrew".

I learnt a bit of locomotive basic back in my Amstrad cpc days, enjoyed the creation part of it.
But it was easier to learn than actual coding I presume.
 
The mere mention of TranzAm was enough to bring on some flashbacks of one of many unfinished projects. If you play the game these days then it does become apparent, at least to me, that "piss poor" is one of many phrases that can be applied to it, but I still think it's ripe for a 2X remake with a GB theme including a secret tunnel connecting the mainland to Ireland (below is my first draft sprite that haunts me at nights).

tranzam.png


There's always bias about these things depending on your childhood but the speccy provides fertile ground for remakes and PSSST will be a great addition to the roster, especially with the diary element thrown in.

As the final minute of my therapy session (£120 an hour ??? It's free at gp32x.de forums ) and for no good reason other than unburdening myself I will throw an early partial mockup of my homage to Manic Miner into the mix - it will never get finished, it will never get released but it's the thought that counts.

Well, actually it's more the finishing things, releasing them and giving people the chance to play them that matters but in lieu of that here's the mockup :

Mummy's Boy starring Teppy (there is a full back story etc but the clock tells me the session is coming to an end).

Mummy's Boy (partial mockup level 1)

Good luck Mr. Jabberwocky and I look forward to your Everyone's A Wally release with baited breath.
 
Last edited by a moderator:
I will be using C and SDL. WARNING - this is my way of doing stuff, it is probably neither the best way or even acceptable coding practice. But it is going to work (even if I have to hit it with hammer) and that's good enough for me.

For those who wish to play along, I will post the code as I go along and you can build it yourself. Hopefully I will be able to explain what is going on and give new devs a start. Old devs are welcome to point out the correct way to do things as I fumble through it.

I will start with yet another 'getting started guide'.

download yaustar's Gp2x Code::blocks Pre-configured Sdk Rc5
READ THE README FILE.
Install it as described in the read me. (basically extract everything to the root of your hard drive).
Then leave a nice post thanking him for his efforts here, send him money, worship the ground he treads...etc.

yaustar's package includes the windows SDL runtime dlls. These are in c:\MinGW\bin and you can add 'c:\MinGW\bin' to your environment path variable so windows builds can be run without copying all the dlls for every project.
Set this thuswise : desktop->start menu->Control Panel->System->Advanced(tab)->Environment variables(button).
You should now have a dialogue box with a scrolly window entitled 'System variables' at the bottom.
One of them is called Path. Select it and press the EDIT button.
Add a semi-colon(;)and the path to the dlls (c:\MinGW\bin) to the end of the existing text. Make sure you don't accidentally delete the existing contents.

Another good thing to have is Rlyeh's gpe compressor that makes the result of your sprawling mass of unstructured spaghetti code into a much smaller final program.
Rlyeh's GPE Compressor
Hero-worship Rlyeh whenever you get a chance, send him money, worship the ground he treads...etc.

You can add a call to this in the post-build window of the 'pre/post build steps' tab of the GP2X Release in code::blocks. Then every time you build it you don't have the extra step of opening a DOS window and compressing it.

You also need a program called bin2h.exe that you can get here

Edit : changed to a better utility. Thanks to Alex for the rec.

Unfortunately the author is anonymous so you can't send them money - just send it to me instead.

You will use this to convert the graphics and sound files into C text files so you can include them in your program. The alternative would be to load these at run time - but this involves having lots of files to keep track of and writing extra (boring) file handling code. Lazy is good.

Dammit! I've run out of waffle and will have to actually do something now.
 
Last edited by a moderator:
Thanks for the recap on installing codeblocks... I've been using an old version on my laptop for monaco, but I recalled it talking at least a day before I was fully setup and had things working.

I'll look at downloading the pre-conf version and trying that on my desktop pc tonight. That should be far easier to get up and running...

I'll be following along with you're code samples as you post them...

<
edit: just tried this pre-conf codeblocks and it's great! Up and running in a click...perfect just what the community needs

>
 
twojame said:
Thanks for the recap on installing codeblocks... I've been using an old version on my laptop for monaco, but I recalled it talking at least a day before I was fully setup and had things working.

I'll look at downloading the pre-conf version and trying that on my desktop pc tonight. That should be far easier to get up and running...

I'll be following along with you're code samples as you post them...

<
edit: just tried this pre-conf codeblocks and it's great! Up and running in a click...perfect just what the community needs

>
It is great, good work by yaustar.

Time to struggle on with the task in hand....

You have copied yaustar's GP2X Template directory structure and project file. You have read his readme file. You have opened the project in code::blocks and changed the project name and renamed the output files to something indicating PSSST. You have the project open in code::blocks.

Now add a directory called 'graphics' in the folder that contains your project file. Extract the bin2h.exe into this 'graphics folder. Download this :

background.gif


... and save it in your new graphics folder.

You will have to load it into paint or whatever and save it out as background.BMP.

Open a dos prompt in this folder and type :

bin2h background.bmp background.c

Move the file produced (background.c) to your project folder.

In code::blocks delete the main.cpp file and proceed to add the following files.

PSSST.cpp
buffers.cpp
game.cpp
ioBasics.cpp

buffers.h
game.h
gp2x.h
ioBasics.h

New files are added from the File drop-down menu by selecting New->empty file. When you add a file add it to all the targets when you are asked.

You also want to add in the background.c file you made earlier by selecting project->Add Files->(select the file)->Open.


Copy the following into PSSST.cpp
CODE
//////////////////////////////////////////////////////
// Name: PSSST.cpp //
// Date: 05/09/07 //
// Description: Ultimate's PSSST //
// for GP2X //
// //
// initialise SDL //
// //
//////////////////////////////////////////////////////
#include <SDL\SDL.h>
#include "buffers.h"
#include "ioBasics.h"
#include "game.h"

int main(int argc, char **argv)
{
// Initialize SDL
SDL_Init( SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ); // Initialize SDL
#ifdef PLATFORM_GP2X
screen = SDL_SetVideoMode( 320, 240, 8, SDL_SWSURFACE | SDL_NOFRAME ); // Set up work screen
#endif
#ifdef PLATFORM_PC
screen = SDL_SetVideoMode( 320, 240, 8, SDL_HWSURFACE | SDL_DOUBLEBUF ); // Set up work screen
const char *cTitle = "PSSST";
SDL_WM_SetCaption (cTitle, NULL);
#endif
SDL_ShowCursor(SDL_DISABLE); // Disable mouse cursor on gp2x
// check the display initialised
if(!screen)
{
printf("SDL_SetVideoMode screen not initialised.\n"); // debug output example for serial cable
WaitForKey();
Shutdown(); // Shutdown program if error
}
// initialise joystick
joystick = SDL_JoystickOpen(0);
// call the game code
game_loop();
//clear the screen
screen = SDL_SetVideoMode( 320, 240, 16, SDL_SWSURFACE | SDL_NOFRAME ); // Set up work screen
SDL_ShowCursor(SDL_DISABLE); // Disable mouse cursor on gp2x
SDL_Flip(screen);
Shutdown(); // Shutdown program - close SDL & clean up

return 0;
}

This contains the special function called main. All C programs must have this - it tells the compile/link process where your code starts running from. At the top there are #include statements that tell the compiler to check the referenced files for information it needs but won't find in the current file. SDL.h tells the compiler the correct syntax for the SDL commands and informs it about SDL's symbols i.e. SDL_INIT_TIMER etc.
This function is initialising SDL, making a call to our game_loop (that is in a seperate file) and shutting SDL down when game_loop() ends.

Copy the following into buffers.cpp
CODE
#include <SDL\SDL.h>

SDL_Joystick *joystick = NULL;

SDL_Surface *screen = NULL; // tells us where the screen is
SDL_Surface *backdrop = NULL; // tells us where the background is


This is just where I am going to store information SDL gives me so I can reference it when needed.

Copy the following into game.cpp
CODE
#include <SDL\SDL.h>
#include <SDL\SDL_rwops.h>
#include "buffers.h"
#include "ioBasics.h"

int game_loop(void) {
int status = 0;
char *buffer = (char *)background;
SDL_Rect dstrect = {32, 24, 256, 192};

//Load the image into a surface using RWops
SDL_RWops *rw = SDL_RWFromMem(buffer, 50230);
SDL_Surface *temp = SDL_LoadBMP_RW(rw, 1);

// Did we get the bitmap?
if (temp == NULL) {
printf("Unable to extract bitmap: %s\n", SDL_GetError());
WaitForKey();
Shutdown(); // Shutdown program if error
}

//Convert the image to optimal display format
backdrop = SDL_DisplayFormat(temp);

//Free the temporary surface
SDL_FreeSurface(temp);

SDL_BlitSurface(backdrop, NULL, screen, &dstrect );
SDL_Flip(screen);
WaitForKey();

return status;
}


This will be the control loop for the game - for now it just gets the background image and displays it.

Copy the following into ioBasics.cpp
CODE
#include <SDL\SDL.h>
#include <stdbool.h>
#include "buffers.h"
#include "ioBasics.h"
#include "gp2x.h"
#ifdef PLATFORM_GP2X
#include <fstream>
#endif

void WaitForKey(void) {
SDL_Event event;
bool bKey = false;

while(!bKey) {
while( SDL_PollEvent( &event ) ) {
switch( event.type ) {
// GP2X buttons
case SDL_JOYBUTTONDOWN:
bKey = true;
break;
// PC buttons
case SDL_KEYDOWN:
bKey = true;
break;
}
}
}
}

void Shutdown(void) {
SDL_FreeSurface(screen); // Release the memory allocated to screen
SDL_Quit();
#ifdef PLATFORM_GP2X
chdir("/usr/gp2x");
execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
#endif
}


This file will hold basic functions such as the two already added.

Copy the following into buffers.h
CODE
extern SDL_Joystick *joystick;

extern SDL_Surface *screen; // tells us where the screen is
extern SDL_Surface *backdrop; // tells us where the background is

extern const unsigned char background[]; // this is the data for the background image


This is the header file for buffers.cpp. It tells other files that include it that these stores exist and what they are.

Copy the following into game.h
CODE
int game_loop(void);


This is the header file for game.cpp. It tells other files that include it that these functions exist and how they should be called.

Copy the following into gp2x.h
CODE
#ifndef _HEADER_GP2X_H
#define _HEADER_GP2X_H

#ifdef PLATFORM_GP2X
#define GP2X_BUTTON_UP (0)
#define GP2X_BUTTON_UPLEFT (1)
#define GP2X_BUTTON_LEFT (2)
#define GP2X_BUTTON_DOWNLEFT (3)
#define GP2X_BUTTON_DOWN (4)
#define GP2X_BUTTON_DOWNRIGHT (5)
#define GP2X_BUTTON_RIGHT (6)
#define GP2X_BUTTON_UPRIGHT (7)
#define GP2X_BUTTON_START (8)
#define GP2X_BUTTON_SELECT (9)
#define GP2X_BUTTON_L (10)
#define GP2X_BUTTON_R (11)
#define GP2X_BUTTON_A (12)
#define GP2X_BUTTON_B (13)
#define GP2X_BUTTON_X (14)
#define GP2X_BUTTON_Y (15)
#define GP2X_BUTTON_VOLUP (16)
#define GP2X_BUTTON_VOLDOWN (17)
#define GP2X_BUTTON_CLICK (18)
#endif
#ifdef PLATFORM_PC
#define GP2X_BUTTON_UP (SDLK_UP)
#define GP2X_BUTTON_UPLEFT (1)
#define GP2X_BUTTON_LEFT (SDLK_LEFT)
#define GP2X_BUTTON_DOWNLEFT (3)
#define GP2X_BUTTON_DOWN (SDLK_DOWN)
#define GP2X_BUTTON_DOWNRIGHT (5)
#define GP2X_BUTTON_RIGHT (SDLK_RIGHT)
#define GP2X_BUTTON_UPRIGHT (7)
#define GP2X_BUTTON_START (SDLK_x)
#define GP2X_BUTTON_SELECT (SDLK_z)
#define GP2X_BUTTON_L (SDLK_q)
#define GP2X_BUTTON_R (SDLK_e)
#define GP2X_BUTTON_A (SDLK_a)
#define GP2X_BUTTON_B (SDLK_d)
#define GP2X_BUTTON_X (SDLK_s)
#define GP2X_BUTTON_Y (SDLK_w)
#define GP2X_BUTTON_VOLUP (SDLK_v)
#define GP2X_BUTTON_VOLDOWN (SDLK_c)
#define GP2X_BUTTON_CLICK (SDLK_f)
#endif

#endif //_HEADER_GP2X_H


This describes the GP2X input values from the buttons and stick and gives them names.

Copy the following into ioBasics.h

CODE
void WaitForKey(void);
void Shutdown(void);


This is the header file for ioBasics.cpp. It tells other files that include it that these functions exist and how they should be called.

If neither of us has been particularly stupid you should be able to generate a program that displays the background image and quits when any input is detected.
 
Last edited by a moderator:
hi

it is great someone is producing a step by step guide!

first noob question - bin2c background.bmp background.c does not seem to work i get the message "bad arguments. you must give me all the parameters"

looked at help it says format is "binc 2c <binary file name> <source filename> <struct>"

then i tried "bin2c background.bmp background.c c" and it says "can't find source file background.bmp"

thx
 
That is a bit of a naff version of bin2c - I had not tried it.

EDIT :
Here is another excellent one suggested by Alex in the next post. http://deadnode.org/sw/bin2h/.

Slight name change to bin2h, but will output to the filename you give it, so bin2h background.bmp background.c gives the desired result.
 
Back
Top