set_gfx_mode(GFX_AUTODETECT, x, y, colour)
Screen blitter fix
There is a problem with the screen, on the GP2X's, using allegro. Due to a blitter problem, the result coders usually get is the screen remains black and nothing is drawn to the screen.
There are two solutions to fix this:
- Solution 1 - Force a hardware blit using another program.
Go to this forum entry and download the source code to the alex4_launcher.
In the code you only need to change:
execl("*name_of_your_program*.gpe","*name_of_your_program*.gpe",NULL);
In the makefile:
In the code you only need to change:
PROG_NAME = *name_of_your_program*_launcher
- Solution 2
Insert the below code before the allegro initialisation code:
// The include files needed for the below code to work
#include <sys/mman.h>
#include <allegro/platform/aintlnx.h>
unsigned long gp2x_dev;
static volatile unsigned long *gp2x_memregl;
volatile unsigned short *gp2x_memregs;
int mmsp2_blit_base;
static struct MAPPED_MEMORY mmsp2_blit;
gp2x_dev = open("/dev/mem", O_RDWR);
gp2x_memregl = (unsigned long *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev, 0xc0000000);
gp2x_memregs = (unsigned short *)gp2x_memregl;
{
//the following is to work around bug in allegro library which causes it to lock up
//if HW blitter hasn't done anything since GP2X was switched on.
gp2x_memregs[0x90a >> 1] = 0xffff; // Enable all video and sound devices
gp2x_memregs[0x904 >> 1] |= 1<<10; // Enable FASTIO for the hardware blitter
#define MESGDSTCTRL 0x0000
#define MESG_BSTBPP 0x60
#define MESG_DSTBPP_16 (1<<5)
#define MESG_DSTENB (1<<6)
#define MESGDSTADDR 0x0004
#define MESGSRCCTRL 0x000c
#define MESG_INVIDEO (1<<8)
#define MESGPATCTRL 0x0020
#define MESGSIZE 0x002c
#define MESG_HEIGHT 16
#define MESGCTRL 0x0030
#define MESG_XDIR_POS (1<<8)
#define MESG_YDIR_POS (1<<9)
#define MESG_FFCLR (1<<10)
#define MESGSTATUS 0x0034
#define MESG_BUSY (1<<0)
#define mmsp2_blit_putl(addr,value) (*(unsigned long volatile *)(mmsp2_blit_base+(addr)) = (value))
#define mmsp2_blit_getl(addr) (*(unsigned long volatile *)(mmsp2_blit_base+(addr)))
mmsp2_blit.base = 0xe0020000;
mmsp2_blit.size = 0x100;
mmsp2_blit.perms = PROT_READ|PROT_WRITE;
mmsp2_blit.data = mmap(0, 0x100, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev, 0xe0020000);
if (mmsp2_blit.data == MAP_FAILED)
exit(EXIT_FAILURE);
mmsp2_blit_base = (int)mmsp2_blit.data;
mmsp2_blit_putl (MESGDSTCTRL, MESG_DSTBPP_16 | MESG_DSTENB);
mmsp2_blit_putl (MESGDSTADDR, 0x3101000);
mmsp2_blit_putl (MESGSRCCTRL, MESG_INVIDEO);
mmsp2_blit_putl (MESGPATCTRL, 0);
mmsp2_blit_putl (MESGSIZE, (1 << MESG_HEIGHT) | 8);
mmsp2_blit_putl (MESGCTRL, (MESG_XDIR_POS) | (MESG_YDIR_POS) | 0xaa | MESG_FFCLR);
mmsp2_blit_putl (MESGSTATUS, 1);
while (mmsp2_blit_getl(MESGSTATUS) & MESG_BUSY);
munmap((void *)&mmsp2_blit_base, 0x100);
}
forum
Joystick
Like SDL, the joystick needs to be initialised in the beginning of the program. After allegro is initialised put:
install_joystick(JOYSTICK_AUTODETECT);
In order for the program to "listen" out for the joystick during runtime the below code needs adding to functions where the joystick calls are used:
Poll_Joystick();
The joystick mappings are below:
- Left
joy[0].stick[0].axis[0].d1
- Right
joy[0].stick[0].axis[0].d2
- Up
joy[0].stick[0].axis[1].d1
- Down
joy[0].stick[0].axis[1].d2
- B
joy[0].button[0].b
- X
joy[0].button[1].b
- Y
joy[0].button[2].b
- A
joy[0].button[3].b
- R
joy[0].button[4].b
- L
joy[0].button[5].b
- Select
joy[0].button[6].b
- Start
joy[0].button[7].b
- Vol Down
joy[0].button[8].b
- Vol Up
joy[0].button[9].b
- Joystick click
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|