PSP GameLibrary

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
t3ddY
Posts: 12
Joined: Sun May 08, 2005 12:34 am
Location: The Netherlands

PSP GameLibrary

Post by t3ddY »

I was interested in making (2D) games for the PSP ever since it came out. So i made a way to produce games for it, without a emulator or something. I was inspired by the way GapiDRAW did this for mobile phones, the way to do this is easy.

My gamelibrary consits of 3 layers:
- A hardware depended layer for all basic stuff like: drawing pixels, input, timers, playing music.
- A hardware independed layer for the library framework. Support for images, blitting, tiling, sprites, fonts, etc etc
- A game layer wich holds the actual game, making use of the previous layers to run.

The trick is, when you want to program a game, just program it on your pc, and compile it as a win32 gdi/opengl/directx app with MinGW. You can easy debug and develop this way.

Once you're satisfied, compile it for the psp with another makefile and other baseclasses for displaying, input, sound etc.

My whole library is allmost ready for a beta release, the only thing i need a PSP to test this :)

I'm thinking about making it opensource and setup a sourceforge site for it.

Features in my library:
- All platform depended shit seperated from framework/gamecode
- Images, embedded (ass arrays) or non embedded (JPG & BMP loaders written)
- Bitmapfonts monospace as well as non-monospace
- Animted sprites
- Tiles
- a Physics engine (proberly not in de opensource release, not my code)
- a simple StateMachine
- Graphic effects (like snow, scanlines)
- Currently 3 demo's (a metalgear remake, a tetris game and a fade demo)

Of course written in C++ :)


Proof of concept:
Image
inomine
Posts: 53
Joined: Thu May 05, 2005 7:26 pm

Post by inomine »

Wow, looks like some impresive work. If you want me to do some testing on my V1.0 PSP then I will gladly do so, athough I suspect that many other people would also want the priveledge. Send me an email to [email protected]
t3ddY
Posts: 12
Joined: Sun May 08, 2005 12:34 am
Location: The Netherlands

Post by t3ddY »

I am still waiting for that PSP opensource toolchain before i can compile this :)

Here is a zip containting my framework code, so you allready can look in to it :)

SpeedPlay 2d PSP GameLibrary
inomine
Posts: 53
Joined: Thu May 05, 2005 7:26 pm

Post by inomine »

Looking good. This would be quite nice as an open source project (preferbaly under the BSD licence :P ), I for one would be quite interested in helping out. My C++ skills are not great through lack of use but I can learn quickly and in the worst case I can always write documentation. :P

I've been thinking of doing some 2d coding for the PSP once some people manage to get toolchain for it, this looks like it could solve the problem as to what to do in the meantime.

Two things:

1) Any chance of seeing some sourcecode for what a game using this looks like? Your screenshot might indicate that you can't really release the graphics file sbut even the text source would be interesting so that I can piece together how it all works.

2) I notice there is some gba stuff in there, is that because this library was initially meant for that platform is that something you also wish to support in the longrun?

Anyway, good luck!
t3ddY
Posts: 12
Joined: Sun May 08, 2005 12:34 am
Location: The Netherlands

Post by t3ddY »

GBA code was in it, to prove to myself that the library did his job :) I made a small test on my pc and recompiled it for the GBA, and it worked :)

The source for a game is pretty simple:

Code: Select all

#include "PSPGameLibrary.h"
#include "System.h"
#include "Game.h"
#include "StateMachine.h"
#include "Timer.h"


class CMyGame: public CGame
{
public:
	CMyGame() {};
	virtual ~CMyGame() {};

	void GameInit();
	void GameStateMachineUpdate();
	void GamePollInput();
	void GameUpdateLogic();
	void GameDraw();

	void GameCleanUp();
private:
	CTimer timer;
	DWORD color;
};

void CMyGame::GameInit()
{
	color = RGB(155,0,0);
	timer.Start();
}

void CMyGame::GameStateMachineUpdate()
{
}

void CMyGame::GamePollInput()
{
}

void CMyGame::GameUpdateLogic()
{
	timer.Update();
	if (timer >= 500)
	{
		timer.ReStart();
		color = RGB(rand()%255,rand()%255,rand()%255);
		m_pDebug->SetDebugText("Will Smith says: \"Switch!\"");
	}
	m_pDebug->SetDebugText("timer: %d",(long)timer);
}

void CMyGame::GameDraw()
{
	m_pScreen->ClearScreen(color);
}

void CMyGame::GameCleanUp()
{
}


CMyGame *pGame;

void GameLibraryMain(void)
{
	pGame = new CMyGame();
	RunGame(pGame);
}
Notice the entry function (GameLibraryMain) wich make a instace of CMyGame and sends it to a RunGame function... that's it :)
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

nice work! looking forward to see more.

just two things: the framerate seems a bit on the lower side. you should be able to render such scenes way above 1000 fps (on a decent pc) using opengl.

and i think you'll need another thing, namely memory management.
t3ddY
Posts: 12
Joined: Sun May 08, 2005 12:34 am
Location: The Netherlands

Post by t3ddY »

Yeah, my blit method (somewwhere in CScreen) does a pretty slow pixel blit. It's not optimised for speed, but i'm sure if you make a assembly or a optimised c++ blitter, you would get much higher rates.

Also the screenshot used in here, is a GDI version on my athlon 1500 mhz laptop. So that's why its so low (>35 was good enough though for me)

Someone who would like to play with my code, you have a example and you have my library :) The onlything that needs to be filled are the PSPDisplay and PSPInput classes....... The debugfont is embedded in the library, so if you run it, you would be able to see a FPS counter and some debug info...
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

sounds like you're doing 2d blitting. i think if you'd use textured quads and opengl/directx in ortho mode you'd get much better framecounts.
t3ddY
Posts: 12
Joined: Sun May 08, 2005 12:34 am
Location: The Netherlands

Post by t3ddY »

ok, but the library tries to run at a given fps, if you put 1000 as target, it won't sleep, but if you set it to run at 35 fps, it wil sleep in the time between the frame blits (wich is good for battery usage on the PSP :)) So, if it runs at its given speed, i don't really care how its done :)
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

you won't have any problems limiting the framerate to 35fps even if you're able to render at much higher framerates. but you may have problems rendering enough frames if you have multiple sprites, particles and ai/game/cd code running.

but well, just my two cents.
Post Reply