PSP GameLibrary
PSP GameLibrary
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:
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:
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 inomine@gmail.com
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
Here is a zip containting my framework code, so you allready can look in to it :)
SpeedPlay 2d PSP GameLibrary
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!
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!
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:
Notice the entry function (GameLibraryMain) wich make a instace of CMyGame and sends it to a RunGame function... that's it :)
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);
}
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...
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...