Allegro for PSP

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

Moderators: cheriff, TyRaNiD

Post Reply
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Allegro for PSP

Post by diedel »

Hi all,
I would like to share my Allegro PSP WIP :)
A simple graphic driver and the a mini keyboard driver using the PSP controller are implemented by now. It compiles and links with success some Allegro examples and the excellent Humphrey remake (the main reason for converting the library :P )

Two Allegro examples:
http://album.miarroba.com/diedel/0/6/
http://album.miarroba.com/diedel/0/7/


The Humphrey remake:
http://retrospec.sgn.net/users/ignacio/humpi.htm

In PSP:
http://album.miarroba.com/diedel/0/8/
http://album.miarroba.com/diedel/0/9/

Greetings!
Wraggster
Posts: 121
Joined: Fri Aug 26, 2005 7:40 am
Contact:

Post by Wraggster »

ooh awesome, awesome indeed, opens up a lot of releases and even a possible virtual boy emu and FreeCNC :)
Webmaster of http://www.dcemu.co.uk

DCEMU The Worlds Only Homebrew & Gaming Network of Sites.
[wl]
Posts: 13
Joined: Fri May 05, 2006 2:16 am

Post by [wl] »

looks like now "KQ - the console-style roleplaying game" can be ported to psp?
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Post by diedel »

Hi,
a beta version of the library is ready to use. It is possible to add it to the ps2dev svn?

Thanks.
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Allegro 4.2.2 PSP alpha version

Post by diedel »

TehSausage
Posts: 3
Joined: Mon Sep 29, 2008 7:41 pm
Location: Australia
Contact:

Post by TehSausage »

Great job, I know how much work it is. (Well, I had no prior PSP programming experience)
You don't seem to have an IR keyboard driver, you can use mine if you want ( Shouldn't be too hard to fix up. Requires kernel mode :( ) - http://tehsausage.com/allegro-psp/download

I think I've pretty much given up on mine now, too lazy to implement scaling etc.

Edit: You could use the timer (and possibly analog mouse) driver from there too, they're not perfect (thread synchronization mainly) but better than nothing.
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Post by diedel »

This is my first PSP programming experience too.
As you say it gets much time but actually I have enough of it to spend :) I like this project.
I think I've pretty much given up on mine now, too lazy to implement scaling etc.
You know the projects are never finished :) so you can continue anytime.
You don't seem to have an IR keyboard driver, you can use mine if you want ( Shouldn't be too hard to fix up. Requires kernel mode :( ) - http://tehsausage.com/allegro-psp/download
Edit: You could use the timer (and possibly analog mouse) driver from there too, they're not perfect (thread synchronization mainly) but better than nothing.
Thanks man, I appreciate your friendly help. Technically, joining our codes the port is near complete :)

Greetings!
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Allegro 4.3.10plus PSP port

Post by diedel »

Finally the PSP port of the Allegro library (4.3.10plus version) is ready:

http://diedel.blogcindario.com/2009/01/ ... rsion.html

Feedback is welcome.
NoEffex
Posts: 106
Joined: Thu Nov 27, 2008 6:48 am

Post by NoEffex »

Very, very good deal.
Programming with:
Geany + Latest PSPSDK from svn
blu_eye4
Posts: 37
Joined: Sun Oct 26, 2008 8:41 pm

Post by blu_eye4 »

Great!!!


Now, I need to ask you a question... Can you work a porting of your library for Nanodesktop? I hope that you accept... You can contact me at cameracafffe@live.it for further informations...
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Post by diedel »

What's Nanodesktop?
Gefa
Posts: 11
Joined: Wed Aug 13, 2008 8:31 pm
Location: Italy
Contact:

Post by Gefa »

diedel wrote:What's Nanodesktop?
Nanodesktop is an SDK for PSP. More info here: http://visilab.unime.it/~filippo/Nanode ... esktop.htm
this if the official forum: http://www.psp-ita.com/forum/viewforum.php?f=23

you can see from http://visilab.unime.it/~filippo/Nanode ... shoots.htm some screenshots of some nd features: as you can see, nanodesktop is a very very good SDK, and his developer (Filippo Battaglia aka "pegasus2000") wants to port Allegro library on his library: can you help him?
For my PSP project, visit my web site: www.gefa.altervista.org

PaintMIXER v2.6.0 released: http://www.neoflash.com/forum/index.php ... 253.0.html
blu_eye4
Posts: 37
Joined: Sun Oct 26, 2008 8:41 pm

Post by blu_eye4 »

Gefa wrote:
diedel wrote:What's Nanodesktop?
Nanodesktop is an SDK for PSP. More info here: http://visilab.unime.it/~filippo/Nanode ... esktop.htm
this if the official forum: http://www.psp-ita.com/forum/viewforum.php?f=23

you can see from http://visilab.unime.it/~filippo/Nanode ... shoots.htm some screenshots of some nd features: as you can see, nanodesktop is a very very good SDK, and his developer (Filippo Battaglia aka "pegasus2000") wants to port Allegro library on his library: can you help him?
Exact! Nanodesktop is the most important PSPSDK... your Allegro Library is very very important... if you accept, we can create all what we want... scientific application, games, emulators :)
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

Just done the mouse driver for the psp allegro port
available at: http://fileupload.filetac.com/file/82b0 ... 8f12943be2
and here http://online-sharing.net/5w2ogfwx5f2f/allegro.tgz.html

file modified makefile.lst
src/psp/pdriver.c
new file src/psp/pmouse.c
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Post by diedel »

Thanks sauron_le_noir.

I'll add it to the last version of the library.

I wrote you a PM.

Cya.
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

you are welcome. Allegro is a great library
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Re: Allegro 4.3.10plus PSP port

Post by J.F. »

diedel wrote:Finally the PSP port of the Allegro library (4.3.10plus version) is ready:

http://diedel.blogcindario.com/2009/01/ ... rsion.html

Feedback is welcome.
Download link on the above page no longer works.
diedel
Posts: 13
Joined: Mon Sep 22, 2008 4:04 am

Post by diedel »

The download links from the entire blog are working again.

Big thanks J.F.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

The link is indeed working again. Thanks! :)
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

Just a little correction in de mouse driver.

Code: Select all

/*         ______   ___    ___
 *        /\  _  \ /\_ \  /\_ \
 *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
 *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
 *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
 *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
 *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
 *                                           /\____/
 *                                           \_/__/
 *
 *      PSP mouse driver.
 *      TODO:.
 *
 *      By sauron_le_noir some part of psp_mouse_timer_poll based on
 *                        the sdl code of Nekuz0r
 *
 *      See readme.txt for copyright information.
 */

#include "allegro.h"
#include "allegro/internal/aintern.h"
#include "allegro/platform/aintpsp.h"

#include "math.h"
#include <pspctrl.h>

#ifndef ALLEGRO_PSP
#error something is wrong with the makefile
#endif

static int  psp_mouse_init&#40;void&#41;;
static void psp_mouse_exit&#40;void&#41;;
static void psp_mouse_position&#40;int, int&#41;;
static void psp_mouse_set_range&#40;int, int, int, int&#41;;
static void psp_mouse_get_mickeys&#40;int *, int *&#41;;
static void psp_mouse_timer_poll&#40;void&#41;;


MOUSE_DRIVER mouse_psp =
&#123;
   MOUSE_PSP,
   empty_string,
   empty_string,
   "psp mouse",
   psp_mouse_init,
   psp_mouse_exit,
   NULL,       // AL_METHOD&#40;void, poll, &#40;void&#41;&#41;;
   psp_mouse_timer_poll,                 // AL_METHOD&#40;void, timer_poll, &#40;void&#41;&#41;;
   psp_mouse_position,
   psp_mouse_set_range,
   NULL,       // AL_METHOD&#40;void, set_speed, &#40;int xspeed, int yspeed&#41;&#41;;
   psp_mouse_get_mickeys,
   NULL,       // AL_METHOD&#40;int,  analyse_data, &#40;AL_CONST char *buffer, int size&#41;&#41;;
   NULL,       // AL_METHOD&#40;void,  enable_hardware_cursor, &#40;AL_CONST int mode&#41;&#41;;
   NULL        // AL_METHOD&#40;int,  select_system_cursor, &#40;AL_CONST int cursor&#41;&#41;;
&#125;;

static int mouse_minx = 0;
static int mouse_miny = 0;
static int mouse_maxx = 479;  /* 0 to 479 = 480 */
static int mouse_maxy = 271;  /* 0 to 272 = 272 */   /* 480x272 is the resolution of the psp display */

static int mymickey_x = 0;
static int mymickey_y = 0;

static SceCtrlData pad;
static int aStickX = 0;
static int aStickY = 0;
static float aStickR;
static float aStickA;
static int x,y;
static float Precision = 360.0f;

static int getSqrRadius&#40;int X, int Y&#41; 
&#123;
   return sqrt&#40;&#40;X * X&#41; + &#40;Y * Y&#41;&#41;;
&#125;
static int psp_mouse_init&#40;void&#41;
&#123;
  sceCtrlSetSamplingCycle&#40;0&#41;;
  sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;
&#125;

static void psp_mouse_timer_poll&#40;void&#41;
&#123;
   sceCtrlPeekBufferPositive&#40;&pad, 1&#41;;

   if &#40;pad.Buttons != 0&#41;
   &#123;
     sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
     _mouse_b = 0;
     if &#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41; _mouse_b = 1;
     if &#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41; _mouse_b = 2;
     if &#40; &#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41; && &#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41;&#41; _mouse_b = 4;
   &#125;
   aStickX = pad.Ly - 128;
   aStickY = pad.Lx - 128;
   
   aStickR = getSqrRadius&#40;aStickX, aStickY&#41;;
   if &#40;aStickR > 100&#41; &#123;
      if &#40;getSqrRadius&#40;aStickX, aStickY&#41; > 30&#41; &#123;
         aStickA = &#40;&#40;atan2f&#40;aStickX, -aStickY&#41; + M_PI&#41; / &#40;M_PI * 2&#41;&#41; * Precision;
      &#125; else &#123;
         aStickA = -1;     
      &#125;
   
      //1° a 89°
      if &#40;aStickA >= 1 && aStickA <= &#40;89 * &#40;Precision / 360.0f&#41;&#41;&#41; &#123;
         x += &#40;10 * &#40;1 - &#40;aStickA / &#40;Precision / 360.0f&#41; / 90&#41;&#41;&#41;;
         y -= &#40;10 * &#40;0 + &#40;aStickA / &#40;Precision / 360.0f&#41; / 90&#41;&#41;&#41;;
      &#125;
      else if &#40;aStickA >= &#40;91 * &#40;Precision / 360.0f&#41;&#41; && aStickA <= &#40;179 * &#40;Precision / 360.0f&#41;&#41;&#41; &#123;
         x -= &#40;10 * &#40;0 + &#40;&#40;&#40;aStickA / &#40;Precision / 360.0f&#41;&#41; - 89&#41; / 90&#41;&#41;&#41;;
         y -= &#40;10 * &#40;1 - &#40;&#40;&#40;aStickA / &#40;Precision / 360.0f&#41;&#41; - 89&#41; / 90&#41;&#41;&#41;;
      &#125;
      else if &#40;aStickA >= &#40;181 * &#40;Precision / 360.0f&#41;&#41; && aStickA <= &#40;269 * &#40;Precision / 360.0f&#41;&#41;&#41; &#123;
         x -= &#40;10 * &#40;1 - &#40;&#40;&#40;aStickA / &#40;Precision / 360.0f&#41;&#41; - 179&#41; / 90&#41;&#41;&#41;;
         y += &#40;10 * &#40;0 + &#40;&#40;&#40;aStickA / &#40;Precision / 360.0f&#41;&#41; - 179&#41; / 90&#41;&#41;&#41;;
      &#125;
      else if &#40;aStickA >= &#40;271 * &#40;Precision / 360.0f&#41;&#41; && aStickA <= &#40;359 * &#40;Precision / 360.0f&#41;&#41;&#41; &#123;
         x += &#40;10 * &#40;0 + &#40;&#40;&#40;aStickA / &#40;Precision / 360.0f&#41;&#41; - 269&#41; / 90&#41;&#41;&#41;;
         y += &#40;10 * &#40;1 - &#40;&#40;&#40;aStickA / &#40;Precision / 360.0f&#41;&#41; - 269&#41; / 90&#41;&#41;&#41;;
      &#125;
      else if &#40;aStickA == 0&#41; &#123;
         x += 10;
      &#125;
      else if &#40;aStickA == &#40;90 * &#40;Precision / 360.0f&#41;&#41;&#41; &#123;
         y -= 10;
      &#125;
      else if &#40;aStickA == &#40;180 * &#40;Precision / 360.0f&#41;&#41;&#41; &#123;
         x -= 10;
      &#125;
      else if &#40;aStickR == &#40;270 * &#40;Precision / 360.0f&#41;&#41;&#41; &#123;
         y += 10;
      &#125;
   &#125;
   if &#40;x < 0&#41;
      x = 0;

   if &#40;x > 479&#41;
      x = 479;

   if &#40;y < 0&#41;
     y = 0;

   if &#40;y > 271&#41;
     y = 271;

   _mouse_x = x;
   _mouse_y = y;
&#125;

static void psp_mouse_position&#40;int x, int y&#41;
&#123;
  _mouse_x = x;
  if &#40;_mouse_x <  mouse_minx&#41; _mouse_x = 0;
  if &#40;_mouse_x > mouse_maxx&#41;  _mouse_x = mouse_maxx;
  _mouse_y = y;
  if &#40;_mouse_y < mouse_miny&#41; _mouse_y = 0;
  if &#40;_mouse_y > mouse_maxy&#41; _mouse_y = mouse_maxy;
&#125;

static void psp_mouse_set_range&#40;int x1, int y1, int x2, int y2&#41;
&#123;
&#125;

static void psp_mouse_get_mickeys&#40;int *mickeyx, int *mickeyy&#41;
&#123;
  *mickeyx = 0;
  *mickeyy = 0;
&#125;

static void psp_mouse_exit&#40;void&#41;
&#123;
&#125;
it limit the mouse correctly to 0..479 and 0.271
DanielC
Posts: 40
Joined: Fri Jul 11, 2008 8:10 pm
Location: Australia

Post by DanielC »

Sorry if this is off topic, but i'm just curious...

Is this in anyway related to the legendary Allegro graphics/gaming library from back in the MS-DOS days (which is still maintained today)? Or is the same name purely coincedental..?

EDIT: Sorry, you failed to mention that this is a port of THE Allegro library. WOW. Well done! Very awesome!
Regards,
Daniel C
pegasus2000
Posts: 160
Joined: Wed Jul 12, 2006 7:09 am

Post by pegasus2000 »

@diedel:

In any case, I'm writing a new version of Nanodesktop that shall
support sprites. I thought that this can be useful in an Allegro
porting. I've open a thread in this forum for the proof of concept.

Here a screenshot:

http://img82.imageshack.us/img82/6527/screenshotftk.png

I hope that you can create a version of ndAllegro in the future...
:)
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

DanielC it is indeed this library that have been ported to the psp
slasher2661996
Posts: 91
Joined: Sun Feb 22, 2009 8:32 am
Location: Melbourne Australia ZOMG

Post by slasher2661996 »

Mind telling me what this is used for?
whistler
Posts: 39
Joined: Tue Mar 04, 2008 7:08 am

Post by whistler »

thanks for porting allegro:) btw are you working on making the addons(allegroGL, jpgalleg, loadpng, logg) usable with the psp. From what i can see all the dependencies like libpng, jpeg, zlib, ogg and pspgl(which is basically a subset of opengl) are already in the svn repo
User avatar
Josh1billion
Posts: 32
Joined: Tue Jul 12, 2005 8:45 am
Location: Wisconsin, USA
Contact:

Post by Josh1billion »

Is it possible to install this on Windows alongside MinPSPW?
Josh1billion - PHP, C++, PSP programmer.
Post Reply