[release] PSPHBC - homebrew common

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

Moderators: cheriff, TyRaNiD

Post Reply
anmabagima
Posts: 87
Joined: Thu Oct 01, 2009 8:43 pm

[release] PSPHBC - homebrew common

Post by anmabagima »

Hi there,

I've always got very good support in this community and I guess it's time to give something back ;o)

I've seen that there are very often always the same steps needed to get started with a homebrew...As I'm using objec oriented C to develop I've created a "hombrew common" library which provides base classes doing most of the initialization stuff which from my point of view is common to the most homebrews. It's my first "release" and I would still see myself as newbie - so if you have any suggestions, please do not hesitate to provide valuable feedback :o)

Hope you enjoy

However, enough words...
Here is the link to the library and header files:
http://psp.anmabagima.de/__oneclick_upl ... common.zip
The library was created using eclipse and minimalist PSPSDK on windows. I'm not sure if it works with cygwin as well.
To use this you could simply extract the zip file to the pspsdk folder:

x:\pspsdk\psp\sdk\

To give you in addition a sample how to use eg. the 3dHomebrew base class for your GU applications please have a look at the following code:

Code: Select all

/*
 * HbcGuSampleApp.h
 * 			Sample implementation of the 3dHomebrew base class
 *          to demonstrate it's usage
 *
 * (c) André Borrmann 2010
 * Permission to copy, use, modify and distribute of this software is
 * granted provided this copyright notice appears in all copies.
 * This software is provided "as is" without express or implied warranty,
 * and with no claim as to it's suitability for any purpose
 */

#ifndef HBCGUSAMPLEAPP_H_
#define HBCGUSAMPLEAPP_H_

#include <3dHomebrew.h>

class ClHbcGuSampleApp &#58; public Cl3dHomebrew &#123;
public&#58;
	static ClHbcGuSampleApp* getInstance&#40;&#41;;
	static void releaseInstance&#40;&#41;;

	bool init&#40;&#41;;
	void render&#40;&#41;;

protected&#58;
	ClHbcGuSampleApp&#40;&#41;;
	virtual ~ClHbcGuSampleApp&#40;&#41;;
	static ClHbcGuSampleApp* _instance;
&#125;;

#endif /* HBCGUSAMPLEAPP_H_ */

Code: Select all

/*
 * HbcGuSampleApp.cpp
 * 			Sample implementation of the 3dHomebrew base class
 *          to demonstrate it's usage
 *
 * &#40;c&#41; André Borrmann 2010
 * Permission to copy, use, modify and distribute of this software is
 * granted provided this copyright notice appears in all copies.
 * This software is provided "as is" without express or implied warranty,
 * and with no claim as to it's suitability for any purpose
 */

extern "C"&#123;
#include <pspgu.h>
#include <pspgum.h>
&#125;
#include "HbcGuSampleApp.h"

ClHbcGuSampleApp* ClHbcGuSampleApp&#58;&#58;_instance = 0;

ClHbcGuSampleApp *ClHbcGuSampleApp&#58;&#58;getInstance&#40;&#41;&#123;
	if&#40;!_instance&#41;&#123;
		_instance = new ClHbcGuSampleApp&#40;&#41;;
	&#125;

	return _instance;
&#125;

void ClHbcGuSampleApp&#58;&#58;releaseInstance&#40;&#41;&#123;
	if &#40;_instance&#41; &#123;
		delete&#40;_instance&#41;;
		_instance = 0;
	&#125;
&#125;

bool ClHbcGuSampleApp&#58;&#58;init&#40;&#41;&#123;
	if &#40;!Cl3dHomebrew&#58;&#58;init&#40;&#41;&#41; return false;
	return true;
&#125;

/*
 * sample rendering implementation just render a triangle ;o&#41;
 */
void ClHbcGuSampleApp&#58;&#58;render&#40;&#41;&#123;
	typedef struct Vertex &#123;
		int color;
		float x, y, z;
	&#125;Vertex;

	//get memory for 3 vertices
	Vertex* triangle = &#40;Vertex*&#41;sceGuGetMemory&#40;sizeof&#40;Vertex&#41;*3&#41;;
	//set up the vertices for our triangle
	triangle&#91;0&#93;.x = -4.0f;
	triangle&#91;0&#93;.y = -2.0f;
	triangle&#91;0&#93;.z = -10.0f;
	triangle&#91;0&#93;.color = 0xff0000ff;

	triangle&#91;1&#93;.x =  0.0f;
	triangle&#91;1&#93;.y =  2.0f;
	triangle&#91;1&#93;.z = -10.0f;
	triangle&#91;1&#93;.color = 0xffff0000;

	triangle&#91;2&#93;.x =  4.0f;
	triangle&#91;2&#93;.y = -2.0f;
	triangle&#91;2&#93;.z = -10.0f;
	triangle&#91;2&#93;.color = 0xff00ff00;

	//clear the screen with different color than the 3DHomebrew class does
	sceGuClearColor&#40;0xff442222&#41;;
	sceGuClear&#40;GU_COLOR_BUFFER_BIT&#41;;

	// set the View and Model Matrix
	sceGumMatrixMode&#40;GU_VIEW&#41;;
	sceGumLoadIdentity&#40;&#41;;
	sceGumMatrixMode&#40;GU_MODEL&#41;;
	sceGumLoadIdentity&#40;&#41;;

	//set the smooth shade model
	sceGuShadeModel&#40;GU_SMOOTH&#41;;
	//disable textures as we have no
	sceGuDisable&#40;GU_TEXTURE_2D&#41;;
	//render the triangle
	sceGumDrawArray&#40;GU_TRIANGLES, GU_TRANSFORM_3D | GU_VERTEX_32BITF | GU_COLOR_8888, 3, 0, triangle&#41;;
&#125;

ClHbcGuSampleApp&#58;&#58;ClHbcGuSampleApp&#40;&#41; &#123;
	// TODO Auto-generated constructor stub

&#125;


ClHbcGuSampleApp&#58;&#58;~ClHbcGuSampleApp&#40;&#41; &#123;
	// TODO Auto-generated destructor stub
&#125;

Code: Select all

/*
 * main.cpp Sample program to show how the homebrew common classes
 *          can be used for your own homebrews
 *
 * &#40;c&#41; André Borrmann 2010
 * Permission to copy, use, modify and distribute of this software is
 * granted provided this copyright notice appears in all copies.
 * This software is provided "as is" without express or implied warranty,
 * and with no claim as to it's suitability for any purpose
 *
 */

extern "C"&#123;
#include <pspkernel.h>
&#125;

#include "HbcGuSampleApp.h"

PSP_MODULE_INFO&#40;"HBC GU Sample", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;
PSP_HEAP_SIZE_KB&#40;-1024&#41;;


int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
	ClHbcGuSampleApp* myHomebrew = ClHbcGuSampleApp&#58;&#58;getInstance&#40;&#41;;

	if &#40;myHomebrew->init&#40;&#41;&#41;&#123;
		myHomebrew->run&#40;&#41;;
		myHomebrew->exit&#40;&#41;;
	&#125;

	ClHbcGuSampleApp&#58;&#58;releaseInstance&#40;&#41;;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;
In the make file the following is nedded:

Code: Select all

LIBS = -lstdc++ -lpsphbc -lpspgum -lpspgu
The psphbc library should be before pspgu and pspgum.
User avatar
Ameen
Posts: 10
Joined: Sun Jun 14, 2009 6:28 am
Location: Bahrain
Contact:

Post by Ameen »

What a nice piece of contribution..
Thank you.
anmabagima
Posts: 87
Joined: Thu Oct 01, 2009 8:43 pm

Post by anmabagima »

Thanks....
CHERTS
Posts: 15
Joined: Mon Oct 29, 2007 2:23 pm

Post by CHERTS »

show the full Makefile

thanks!
CHERTS
Posts: 15
Joined: Mon Oct 29, 2007 2:23 pm

Post by CHERTS »

everything works, thanks for the library

Code: Select all

TARGET = PSPHBC

OBJS = main.o HbcGuSampleApp.o
CFLAGS = -O2 -g -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR=
LDFLAGS=
LIBS = -lstdc++ -lpsphbc -lpspgum -lpspgu -lm

EXTRA_TARGETS=EBOOT.PBP
PSP_EBOOT_TITLE=PSPHBC
#PSP_EBOOT_ICON=icon.png

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
anmabagima
Posts: 87
Joined: Thu Oct 01, 2009 8:43 pm

Post by anmabagima »

CHERTS wrote:show the full Makefile

thanks!
Hi,

thanks for posting the makefile. It really looks similar to mine ;O)

Sorry that I've missed it.

Regards
Post Reply