GP2X minimal library v0.B

Written by rlyeh, © 2005.

Please check readme for licensing and other conditions.

Summary
Written by rlyeh, © 2005.
This type definition is used to blit bitmaps and/or sprites into screen.
This type definition is used to create a custom font.
This enumeration contains all the possible values which gp2x_joystick_read may return.
This macro retrieves or sets a value into a shared address; it works for both 920T and 940T cores.
Internal variable which holds current conversion between desired ticks and GP2X ticks.
This struct allows you to work directly with YUV video layer.
This struct allows you to work directly with RGB video layer.
This function halts the program until a vertical sync is done.
This function halts the program until an horizontal sync is done.
This function sets the Gamma correction value for the whole display.
This function sets the dithering values for all the video layers.
This function sets the contrast/brigness values for the YUV/OSD layers.
This function shows or hides the cursor.
This function updates the cursor coordinates.
This function sets the alpha blending of both background and foreground cursor colors.
This function sets the shape, size, colour and alpha blending of the cursor.
This function displays the minimal logo watermarked at bottom right of screen.
This function sets the palettized color entry C to a given triad of R,G,B components.
This function returns the 16bits color for a given triad of R,G,B components.
This function returns the 16bits color for a given triad of R,G,B components.
This function updates the whole 8 bits palette into screen.
This function sets the colorkey transparent value for all RGB colorkeyed regions.
This function adjusts a given resolution to fit the whole display (320,240).
This function flips video buffers.
This function enables, disables and sets screen up to four RGB windows.
This function returns a YUY2 (Cr0/Y1/Cb0/Y0) 32bits color pixel from a given R,G,B triad.
This function adjusts a given resolution to fit the whole display (320,240).
This function flips video buffers.
This function enables, disables and sets up screen to four YUV parts.
This function blits a gp2x_rect into screen.
This function returns the active GP2X joystick values.
This function halts the program for a given delay in gp2x_ticks units.
This function returns elapsed ticks in gp2x_ticks units since last gp2x_init call.
This function is automatically called by the library, and expects a sound buffer to be filled in.
This function sets the sound volume.
This function pauses and unpauses the sound.
This function pauses the secondary ARM 940T coprocessor.
This function halts the 920T code until the 940T has finished all its tasks.
This function executes a 940T command.
This function sets the 940T program, and launchs it.
This function sets the 940T program, and launchs it.
To be written
To be written
This function printfs a string into the RGB layer.
This function allows you to set your own fixed gp2x_font.
This function sets up the whole library.
This function unsets the whole library and returns to GP2X menu.

Types

gp2x_rect

This type definition is used to blit bitmaps and/or sprites into screen.  It contains the following public fields { x,y,w,h,solid,*data; }

Note

  • Set and use the fields manually.
  • gp2x_blitter_rect expects the gp2x_rect to be filled ok.

Fields

xHorizontal coordinate in pixels.
yVertical coordinate in pixels.
wWidth size in pixels.
hHeight size in pixels.
solid0 for transparent sprites (black is transparent).  1 for solid rects.
datapointer to your sprite/rect data.

See also

gp2x_blitter_rect

gp2x_font

This type definition is used to create a custom font.  It contains the following public fields { x,y,w,h,fg,bg,solid,*data; }

Note

  • Use gp2x_printf_init to set the variables into a gp2x_font struct.  Do not set them manually.

Fields

wWidth of each character, in pixels.
hHeight of each character, in pixels.
fgForeground font color.
bgBackground font color (when solid is not 0).
solidWhen 1, background font color is used.  When 0, transparent background font is used.
dataPointer to your font bitmap.

See also

gp2x_printf, gp2x_printf_init

Enumerations

GP2X joystick values

This enumeration contains all the possible values which gp2x_joystick_read may return.

Constants

GP2X_UPjoystick up
GP2X_DOWNjoystick down
GP2X_LEFTjoystick left
GP2X_RIGHTjoystick right
GP2X_PUSHjoystick push
GP2X_Lbutton L
GP2X_Rbutton R
GP2X_Abutton A
GP2X_Bbutton B
GP2X_Xbutton X
GP2X_Ybutton Y
GP2X_STARTbutton START
GP2X_SELECTbutton SELECT
GP2X_VOL_DOWNbutton volume down (-)
GP2X_VOL_UPbutton volume up (+)

See also

gp2x_joystick_read

Macros

gp2x_dualcore_data(address)

This macro retrieves or sets a value into a shared address; it works for both 920T and 940T cores.

Memory map for our shared area for the current library

range 0x00000000-0x00000FFF (4 kb) is reserved

range 0x00001000-0x00007FFF (8 kb) is free, and non-cacheable

range 0x00008000-0x00F00000 (15 Mb) is free, and cacheable

Usage

To be written

See also

gp2x_dualcore_pause, gp2x_dualcore_sync, gp2x_dualcore_exec

Variables

gp2x_ticks

Internal variable which holds current conversion between desired ticks and GP2X ticks.

Note

  • Do not modify this variable directly.  Use gp2x_init instead.

See also

gp2x_timer_read, gp2x_timer_delay

gp2x_video_YUV

gp2x_video_layer gp2x_video_YUV[4]

This struct allows you to work directly with YUV video layer.  It contains three pointers which are updated in each gp2x_video_YUV_flip call.  There are for YUV regions, each one with its own framebuffer.  Each framebuffer orientation is top-left (common orientation).

Contains

screen808 bits pointer to the hidden video surface.
screen1616 bits pointer to the hidden video surface.
screen3232 bits pointer to the hidden video surface.  This is the default pointer when working in Y/Cb/Cr video mode.

Note

Example

gp2x_video_YUV[1].screen32[160+120*320]=gp2x_video_YUV_color(255,255,255);  //write white at (160,120)
gp2x_video_YUV_flip(1);

gp2x_video_RGB

gp2x_video_layer gp2x_video_RGB[1]

This struct allows you to work directly with RGB video layer.  It contains three pointers which are updated in each gp2x_video_RGB_flip call.  There is a single RGB region, with a single framebuffer.  The framebuffer orientation is top-left (common orientation).

Contains

screen808 bits pointer to the hidden video surface.  This is the default pointer when working in palettized video mode.
screen1616 bits pointer to the hidden video surface.  This is the default pointer when working in hicolor video mode.
screen3232 bits pointer to the hidden video surface.

Note

Example

gp2x_video_RGB[0].screen16[160+120*320]=gp2x_video_RGB_color15(255,255,255, 0); //write white at (160,120)
gp2x_video_RGB_flip(0);

or...

gp2x_video_RGB_color8(255,255,255, 1);
gp2x_video_RGB_setpalette();
gp2x_video_RGB[0].screen8[160+120*320]=1; //write white at (160,120)
gp2x_video_RGB_flip(0);

Functions

gp2x_video_waitvsync

void gp2x_video_waitvsync(void)

This function halts the program until a vertical sync is done.

See also

gp2x_video_waithsync

gp2x_video_waithsync

void gp2x_video_waithsync(void)

This function halts the program until an horizontal sync is done.

See also

gp2x_video_waitvsync

gp2x_video_setgammacorrection

void gp2x_video_setgammacorrection(float gamma)

This function sets the Gamma correction value for the whole display.

Parameters

gamma (0.00 ..  2.00)from 0.00 (darkest) to 2.00 (brightest).

Default

  • gamma is set to 1.00

gp2x_video_setdithering

void gp2x_video_setdithering(int mode)

This function sets the dithering values for all the video layers.

Note

  • This function only works when merging layers of different bits per pixel.

Parameters

mode (0,1,2)set mode to 0 for 2x2 dithering, 1 for 4x4 dithering, and 2 to disable dithering.

Default

  • mode is set to 0 (2x2 dithering).

gp2x_video_setluminance

void gp2x_video_setluminance(int contrast,
int brightness)

This function sets the contrast/brigness values for the YUV/OSD layers.

Parameters

contrast (0..7)adjusts contrast where as 0=1.00, 1=1.125...  7=1.875 are contrast values.
brightness (0..255)adjusts brightness.

Default

  • contrast is set to 0
  • brightness is set to 0

gp2x_video_cursor_show

void gp2x_video_cursor_show(int yes)

This function shows or hides the cursor.

Parameters

yes (0,1)set 1 for showing cursor, and 0 to hiding it.

Default

  • yes is set to 0 (hide).

See also

gp2x_video_cursor_move, gp2x_video_cursor_setalpha, gp2x_video_cursor_setup

gp2x_video_cursor_move

void gp2x_video_cursor_move(int x,
int y)

This function updates the cursor coordinates.

Parameters

x (-32767..32768)x cursor position.
y (-32767..32768)y cursor position.

Default

  • (x,y) are set to center of screen.

See also

gp2x_video_cursor_show, gp2x_video_cursor_setalpha, gp2x_video_cursor_setup

gp2x_video_cursor_setalpha

void gp2x_video_cursor_setalpha(int FG_A,
int BG_A)

This function sets the alpha blending of both background and foreground cursor colors.

Parameters

FG_A (0..15)Foreground alpha blending value.
BG_A (0..15)Background alpha blending value.

Default

  • FG_A and BG_A both are set to 15 (100% solid, no transparency).

See also

gp2x_video_cursor_show, gp2x_video_cursor_move, gp2x_video_cursor_setup

gp2x_video_cursor_setup

void gp2x_video_cursor_setup(unsigned char *src,
int size,
unsigned char FG,
int FG_R,
int FG_G,
int FG_B,
int FG_A,
unsigned char BG,
int BG_R,
int BG_G,
int BG_B,
int BG_A)

This function sets the shape, size, colour and alpha blending of the cursor.

Parameters

*srcpointer to a data area containing the cursor shape. each byte in the area corresponds to a pixel in the cursor shape. you can define your own foreground (FG), background (BG) and transparent (any other else) colors.
size (8,16,32,64)square size of the cursor shape.
FG (0..255)byte which identifies foreground pixels in your *src area.  Usually set to 1.
FG_R (0..255)red component for your foreground shape color
FG_B (0..255)green component for your foreground shape color
FG_G (0..255)blue component for your foreground shape color
FG_A (0..15)alpha blending for foreground shape color
BG (0..255)byte which identifies foreground pixels in your *src area.  Usually set to 0 or 2.
BG_R (0..255)red component for background shape color
BG_B (0..255)green component for background shape color
BG_G (0..255)blue component for background shape color
BG_A (0..15)alpha blending for background shape color

Default

  • The default cursor holds an arrow sprite of 16 pixels.  Its foreground color defaults to white, and background one to black.  There is no transparency set for the default cursor.

See also

gp2x_video_cursor_show, gp2x_video_cursor_move, gp2x_video_cursor_setalpha

gp2x_video_logo_enable

void gp2x_video_logo_enable(int yes)

This function displays the minimal logo watermarked at bottom right of screen.  Adding this logo to your application makes rlyeh (me) happier and glad with you :-)

Note

  • Note that this function uses the cursor layer to work, so you cannot display a cursor and the minimal logo at same time.

Parameters

yes (0,1)1 enables logo.  0 disables it.

Default

  • yes is set to 0.  Logo is disabled by default.

gp2x_video_RGB_color8

void gp2x_video_RGB_color8 (int R,
int G,
int B,
int C)

This function sets the palettized color entry C to a given triad of R,G,B components.  All color changes will get updated at next gp2x_video_RGB_setpalette call.

Note

Parameters

C (0..255)Palettized color entry to change
R (0..255)Red component
G (0..255)Green component
B (0..255)Blue component

See also

gp2x_video_RGB_setpalette

gp2x_video_RGB_color15

unsigned short gp2x_video_RGB_color15(int R,
int G,
int B,
int A)

This function returns the 16bits color for a given triad of R,G,B components.  It returns a short in 5515:RGAB format.

Parameters

R (0..255)Red component
G (0..255)Green component
B (0..255)Blue component
A (0,1)General purpose boolean value.  Usually sets to 0.

gp2x_video_RGB_color16

unsigned short gp2x_video_RGB_color16(int R,
int G,
int B)

This function returns the 16bits color for a given triad of R,G,B components.  It returns a short in 565:RGB format.

Parameters

R (0..255)Red component
G (0..255)Green component
B (0..255)Blue component

gp2x_video_RGB_setpalette

void gp2x_video_RGB_setpalette(void)

This function updates the whole 8 bits palette into screen.  To change each palette color use gp2x_video_RGB_color8

See also

gp2x_video_RGB_color8

gp2x_video_RGB_setcolorkey

void gp2x_video_RGB_setcolorkey(int R,
int G,
int B)

This function sets the colorkey transparent value for all RGB colorkeyed regions.

Notes

  • This R,G,B triad uses 0..15 units instead of 0..255.
  • All regions marked as 0x10 will transparent those pixels which match the given R,G,B triad.

Parameters

R (0..15)red component
G (0..15)green component
B (0..15)blue component

Default

  • R,G,B are set to 0.

See also

gp2x_video_RGB_setwindows

gp2x_video_RGB_setscaling

void gp2x_video_RGB_setscaling(int W,
int H)

This function adjusts a given resolution to fit the whole display (320,240).

Notes

  • Draw at (0,0) coordinates always, whatever resolution you are working with.
  • Call this function once.  Do not call this function in every frame.

Parameters

W (1..)virtual width in pixels to scale to 320.
H (1..)virtual height in pixels to scale to 240.

Default

  • (W,H) are set to (320,240).

gp2x_video_RGB_flip

void gp2x_video_RGB_flip(int layer)

This function flips video buffers.  It updates pointers located at gp2x_video_RGB struct too.  The current pointers will point to the hidden display until a new gp2x_video_RGB_flip() call is done.

Note

  • This function does not wait for the vertical/horizontal retraces.  You should use gp2x_video_waitvsync or gp2x_video_waithsync if needed.
  • RGB has one layer, one region and four windows.  Everything works merged in the same layer.
  • It is a mistake confusing ‘layer’, ‘region’, ‘part’ and ‘window’.  They are not the same.

Parameters

layer (0)RGB layer to flip.  Note that currently there is support for RGB layer 0 only.

See also

gp2x_video_YUV_flip

gp2x_video_RGB_setwindows

void gp2x_video_RGB_setwindows(int window0,
int window1,
int window2,
int window3,
int x,
int y)

This function enables, disables and sets screen up to four RGB windows.

Notes

  • You can disable a window by setting a negative value.
  • Any positive value will cause the window to be alpha blended (0..0x0F), to act as a sprite (0x10), or to be solid (0x11).
  • Alpha values are in 0..15 range.  Think about it like a 0% to 100% blending in steps of 6.25%.
  • gp2x_video_RGB_setcolorkey sets the transparent pixel color for all regions.

Parameters

window0 (-1..17)-1 to disable window0, 0..0xF for alpha blending window0, 0x10 for transparent window0, 0x11 for solid window0
window1 (-1..17)-1 to disable window1, 0..0xF for alpha blending window1, 0x10 for transparent window1, 0x11 for solid window1
window2 (-1..17)-1 to disable window2, 0..0xF for alpha blending window2, 0x10 for transparent window2, 0x11 for solid window2
window3 (-1..17)-1 to disable window3, 0..0xF for alpha blending window3, 0x10 for transparent window3, 0x11 for solid window3
x,y ((0,0)..(320,240))Screen coordinate which breaks resolution into 4 regions.  Check diagrams below for a few examples.
+-------+-------+ (x,y) = (160,120)  +-----------+---+ (x,y) = (240,180)  +---------------+ (x,y) = (319,239)
| | | | | | | |
| 0 | 1 | | | | | |
| | | | 0 | 1 | | |
+-------P-------+ | | | | 0 |
| | | | | | | |
| 2 | 3 | +-----------P---+ | |
| | | | 2 | 3 | | |
+-------+-------+ +-----------+---+ +---------------P


+-------+-------+ (x,y) = (160,239) +---------------+ (x,y) = (0,239) +---------------+ (x,y) = (0,120)
| | | | | | |
| | | | | | 1 |
| | | | | | |
| 0 | 1 | | 1 | P---------------+
| | | | | | |
| | | | | | 3 |
| | | | | | |
+-------P-------+ P---------------+ +---------------+


P---------------+ (x,y) = (0,0) +---+-----------+ (x,y) = (80,60) +-------P-------+ (x,y) = (160,0)
| | | 0 | 1 | | | |
| | +---P-----------+ | | |
| | | | | | | |
| 3 | | | | | 2 | 3 |
| | | 2 | 3 | | | |
| | | | | | | |
| | | | | | | |
+---------------+ +---+-----------+ +-------+-------+


+---------------P (x,y) = (319,0) +---------------+ (x,y) = (319,120)
| | | |
| | | 0 |
| | | |
| 2 | +---------------P
| | | |
| | | 2 |
| | | |
+---------------+ +---------------+ etc...

Default

  • (window0,window1,window2,window3) are set to (0x11,-1,-1,-1).
  • (x,y) are set to (319,239).

See also

gp2x_video_RGB_setcolorkey

gp2x_video_YUV_color

unsigned long gp2x_video_YUV_color(int R,
int G,
int B)

This function returns a YUY2 (Cr0/Y1/Cb0/Y0) 32bits color pixel from a given R,G,B triad.

Parameters

R (0..255)red component
G (0..255)green component
B (0..255)blue component

Credits

RobBrown

gp2x_video_YUV_setscaling

void gp2x_video_YUV_setscaling(int region,
int W,
int H)

This function adjusts a given resolution to fit the whole display (320,240).

Notes

  • Draw at (0,0) coordinates of each framebuffer always, whatever resolution you are working with.
  • Call this function once.  Do not call this function in every frame.

Parameters

region (0..3)YUV region (0..3)
W (1..)virtual width in pixels to scale to 320.
H (1..)virtual height in pixels to scale to 240.

Default

  • (W,H) are set to (320,240) for each region.

gp2x_video_YUV_flip

void gp2x_video_YUV_flip(int region)

This function flips video buffers.  It updates pointers located at gp2x_video_YUV struct too.  The current pointers will point to the hidden display until a new gp2x_video_YUV_flip() call is done.

Note

  • This function does not wait for the vertical/horizontal retraces.  You should use gp2x_video_waitvsync or gp2x_video_waithsync if needed.
  • YUV has 2 layers (A/B), 4 regions and no windows.
  • It is a mistake confusing ‘window’, ‘region’, ‘part’ and ‘layer’.  They are not the same.

Parameters

region (0..3)YUV layer to flip

See also

gp2x_video_RGB_flip

gp2x_video_YUV_setparts

void gp2x_video_YUV_setparts(int part0,
int part1,
int part2,
int part3,
int x,
int y)

This function enables, disables and sets up screen to four YUV parts.

Notes

  • You can disable a region by setting a negative value.
  • Any positive value will active the region, and force mirroring or not.

Parameters

part0 (-1..3)-1 disables part0, 0 sets no mirroring, 1 sets vertical mirroring, 2 sets horizontal mirroring, 3 sets both mirrors
part1 (-1..3)-1 disables part1, 0 sets no mirroring, 1 sets vertical mirroring, 2 sets horizontal mirroring, 3 sets both mirrors
part2 (-1..3)-1 disables part2, 0 sets no mirroring, 1 sets vertical mirroring, 2 sets horizontal mirroring, 3 sets both mirrors
part3 (-1..3)-1 disables part3, 0 sets no mirroring, 1 sets vertical mirroring, 2 sets horizontal mirroring, 3 sets both mirrors
x,y ((0,0)..(320,240))Screen coordinate which breaks resolution into 4 parts.  Check diagrams below for a few examples.
+-------+-------+ (x,y) = (160,120)  +-----------+---+ (x,y) = (240,180)  +---------------+ (x,y) = (319,239)
| | | | | | | |
| 0 | 1 | | | | | |
| | | | 0 | 1 | | |
+-------P-------+ | | | | 0 |
| | | | | | | |
| 2 | 3 | +-----------P---+ | |
| | | | 2 | 3 | | |
+-------+-------+ +-----------+---+ +---------------P


+-------+-------+ (x,y) = (160,239) +---------------+ (x,y) = (0,239) +---------------+ (x,y) = (0,120)
| | | | | | |
| | | | | | 1 |
| | | | | | |
| 0 | 1 | | 1 | P---------------+
| | | | | | |
| | | | | | 3 |
| | | | | | |
+-------P-------+ P---------------+ +---------------+


P---------------+ (x,y) = (0,0) +---+-----------+ (x,y) = (80,60) +-------P-------+ (x,y) = (160,0)
| | | 0 | 1 | | | |
| | +---P-----------+ | | |
| | | | | | | |
| 3 | | | | | 2 | 3 |
| | | 2 | 3 | | | |
| | | | | | | |
| | | | | | | |
+---------------+ +---+-----------+ +-------+-------+


+---------------P (x,y) = (319,0) +---------------+ (x,y) = (319,120)
| | | |
| | | 0 |
| | | |
| 2 | +---------------P
| | | |
| | | 2 |
| | | |
+---------------+ +---------------+ etc...

Default

  • (part0,part1,part2,part3) are set to (-1,-1,-1,-1).
  • (x,y) are set to (319,239).

gp2x_blitter_rect

void (*gp2x_blitter_rect)(gp2x_rect *r)

This function blits a gp2x_rect into screen.

Note

This function does not perform any clipping.

Parameters

*rPointer to a gp2x_rect struct

gp2x_joystick_read

unsigned long gp2x_joystick_read(void)

This function returns the active GP2X joystick values.

Note

Call this function once per frame keep your joystick values updated.

Usage

In order to detect simultaneous values you will have to mask the value.

See also

GP2X joystick values

Example

unsigned long pad=gp2x_joystick_read();

if(pad&GP2X_R) if(pad&GP2X_L) ... //both L and R are pressed.

gp2x_timer_delay

void gp2x_timer_delay(unsigned long ticks)

This function halts the program for a given delay in gp2x_ticks units.

Parameters

ticks (1..)delay in gp2x_ticks units.

See also

gp2x_timer_read, gp2x_ticks

gp2x_timer_read

unsigned long gp2x_timer_read(void)

This function returns elapsed ticks in gp2x_ticks units since last gp2x_init call.

Note

  • There is no currently way to reset gp2x_ticks value to 0.

See also

gp2x_timer_delay, gp2x_ticks

gp2x_sound_frame

extern void gp2x_sound_frame(void *blah,
void *buffer,
int samples)

This function is automatically called by the library, and expects a sound buffer to be filled in.

Notes

  • This function is not included in the library itself.
  • Supply this function in your own program.
  • Do not call this function directly.

Parameters

*blahunused in this release.
*bufferpointer to store the sound data.
samplesnumber of samples, NOT bytes.

Examples

Check samples section.

gp2x_sound_volume

void gp2x_sound_volume(int /*0..100*/,
int /*0..100*/)

This function sets the sound volume.

Parameters

L (0..100)volume percentage for the left channel
R (0..100)volume percentage for the right channel

Note

  • A higher percentage than 100 will distort your sound.

Default

  • L is set to 100.
  • R is set to 100.

See also

gp2x_sound_pause

Credits

snaff

gp2x_sound_pause

void gp2x_sound_pause(int yes)

This function pauses and unpauses the sound.

Parameters

yes (0,1)set it to 1 to enable pause (mute sound), and 0 to disable pause (play sound).

See also

gp2x_sound_volume

gp2x_dualcore_pause

void gp2x_dualcore_pause(int yes)

This function pauses the secondary ARM 940T coprocessor.

Note

  • Call this function only from your 920T program.

Parameters

yes (0,1)set it to 1 to enable pause (halt 940T), and 0 to disable pause (run 940T).

See also

gp2x_dualcore_sync, gp2x_dualcore_exec, gp2x_dualcore_data(address)

gp2x_dualcore_sync

void gp2x_dualcore_sync(void)

This function halts the 920T code until the 940T has finished all its tasks.

Note

  • Call this function only from your 920T program.

See also

gp2x_dualcore_pause, gp2x_dualcore_exec, gp2x_dualcore_data(address)

gp2x_dualcore_exec

void gp2x_dualcore_exec(unsigned long command)

This function executes a 940T command.

Note

  • Call this function only from your 920T program.

See also

gp2x_dualcore_pause, gp2x_dualcore_sync, gp2x_dualcore_data(address)

gp2x_dualcore_launch_program

void gp2x_dualcore_launch_program(unsigned long *area,
unsigned long size)

This function sets the 940T program, and launchs it.

Note

  • Call this function only from your 920T program.

Parameters

*areapointer to the 940T raw binary.
size (1..)size of 940T raw binary, in bytes.

See also

gp2x_dualcore_launch_program_from_disk, gp2x_dualcore_launch_subprogram(name)

gp2x_dualcore_launch_program_from_disk

void gp2x_dualcore_launch_program_from_disk(const char *file,
unsigned long offset,
unsigned long size)

This function sets the 940T program, and launchs it.

Note

  • Call this function only from your 920T program.

Parameters

*filestring to the file which contains the 940T raw binary.
offset (0..)amount of bytes to skip at the beginning of the file.
size (1..)size of 940T raw binary, in bytes.

See also

gp2x_dualcore_launch_program, gp2x_dualcore_launch_subprogram(name)

Macros

gp2x_dualcore_declare_subprogram(name)

To be written

gp2x_dualcore_launch_subprogram(name)

To be written

Functions

gp2x_printf

void gp2x_printf(gp2x_font *f,
int x,
int y,
const char *format,
 ...)

This function printfs a string into the RGB layer.

Note

  • This function does not perform any clipping.

Parameters

*fgp2x_font or NULL.  NULL will use the default 6x10 font.
x (0..320)Horizontal coordinate for the given string If x is negative, gp2x_printf() will continue on last known horizontal position.
y (0..240)Vertical coordinate for the given string If y is negative, gp2x_printf() will continue on last known vertical position.
formatC formatted standard string.

See also

gp2x_printf_init

Example

a=1;
gp2x_printf(NULL, 0, 0,"Hello %dst world\n",a);
gp2x_printf(NULL,-1,-1,"Hello %dnd world\n",++a);

...it outputs...

Hello 1st world (at top-left of screen)
Hello 2nd world (under the previous line)

gp2x_printf_init

void gp2x_printf_init(gp2x_font *f,
int w,
int h,
void *data,
int fg,
int bg,
int solid)

This function allows you to set your own fixed gp2x_font.

Parameters

*fPointer to a gp2x_font struct.
w (1..)Width of each character, in pixels.
h (1..)Height of each character, in pixels.
*dataPointer to your font bitmap.
fgForeground font color.
bgBackground font color (when solid is not 0).
solid (0,1)When 1, background font color is used.  When 0, transparent background font is used.

See also

gp2x_printf

gp2x_init

void gp2x_init(int ticks_per_second,
int bpp,
int rate,
int bits,
int stereo,
int Hz,
int solid_font)

This function sets up the whole library.

Notes

  • You have to call this function before any other function.
  • If you are merging both SDL and Minimal Library in your project, you will have to call gp2x_init after any SDL_Init() / SDL_SetVideoMode() / SDL_CreateRGBSurface() call.

Parameters

ticks_per_second (1..7372800)sets internal gp2x_ticks.  Eg, set it to 1000 to work in milliseconds.
bpp (8,15,16)sets the bits per pixel video mode
rate (11025,22050,44100)sets the sound frequency rate
bits (16)sets the sound bits.  GP2X supports 16 bits only.
stereo (0,1)sets the stereo mode.  1 for stereo, 0 for mono.
Hz (unused)sets sound poll frequency, in hertzs.  Unused in this release.
solid_font (0,1)sets default 6x10 font to have solid background or not.

See also

gp2x_deinit

gp2x_deinit

This function unsets the whole library and returns to GP2X menu.

Note

  • You can exit() your program, or call this function directly.

See also

gp2x_init

unsigned long gp2x_joystick_read(void)
This function returns the active GP2X joystick values.
gp2x_video_layer gp2x_video_YUV[4]
This struct allows you to work directly with YUV video layer.
gp2x_video_layer gp2x_video_RGB[1]
This struct allows you to work directly with RGB video layer.
void gp2x_video_waitvsync(void)
This function halts the program until a vertical sync is done.
void gp2x_video_waithsync(void)
This function halts the program until an horizontal sync is done.
void gp2x_video_setgammacorrection(float gamma)
This function sets the Gamma correction value for the whole display.
void gp2x_video_setdithering(int mode)
This function sets the dithering values for all the video layers.
void gp2x_video_setluminance(int contrast,
int brightness)
This function sets the contrast/brigness values for the YUV/OSD layers.
void gp2x_video_cursor_show(int yes)
This function shows or hides the cursor.
void gp2x_video_cursor_move(int x,
int y)
This function updates the cursor coordinates.
void gp2x_video_cursor_setalpha(int FG_A,
int BG_A)
This function sets the alpha blending of both background and foreground cursor colors.
void gp2x_video_cursor_setup(unsigned char *src,
int size,
unsigned char FG,
int FG_R,
int FG_G,
int FG_B,
int FG_A,
unsigned char BG,
int BG_R,
int BG_G,
int BG_B,
int BG_A)
This function sets the shape, size, colour and alpha blending of the cursor.
void gp2x_video_logo_enable(int yes)
This function displays the minimal logo watermarked at bottom right of screen.
void gp2x_video_RGB_color8 (int R,
int G,
int B,
int C)
This function sets the palettized color entry C to a given triad of R,G,B components.
unsigned short gp2x_video_RGB_color15(int R,
int G,
int B,
int A)
This function returns the 16bits color for a given triad of R,G,B components.
unsigned short gp2x_video_RGB_color16(int R,
int G,
int B)
This function returns the 16bits color for a given triad of R,G,B components.
void gp2x_video_RGB_setpalette(void)
This function updates the whole 8 bits palette into screen.
void gp2x_video_RGB_setcolorkey(int R,
int G,
int B)
This function sets the colorkey transparent value for all RGB colorkeyed regions.
void gp2x_video_RGB_setscaling(int W,
int H)
This function adjusts a given resolution to fit the whole display (320,240).
void gp2x_video_RGB_flip(int layer)
This function flips video buffers.
void gp2x_video_RGB_setwindows(int window0,
int window1,
int window2,
int window3,
int x,
int y)
This function enables, disables and sets screen up to four RGB windows.
unsigned long gp2x_video_YUV_color(int R,
int G,
int B)
This function returns a YUY2 (Cr0/Y1/Cb0/Y0) 32bits color pixel from a given R,G,B triad.
void gp2x_video_YUV_setscaling(int region,
int W,
int H)
This function adjusts a given resolution to fit the whole display (320,240).
void gp2x_video_YUV_flip(int region)
This function flips video buffers.
void gp2x_video_YUV_setparts(int part0,
int part1,
int part2,
int part3,
int x,
int y)
This function enables, disables and sets up screen to four YUV parts.
void (*gp2x_blitter_rect)(gp2x_rect *r)
This function blits a gp2x_rect into screen.
This type definition is used to blit bitmaps and/or sprites into screen.
This enumeration contains all the possible values which gp2x_joystick_read may return.
void gp2x_timer_delay(unsigned long ticks)
This function halts the program for a given delay in gp2x_ticks units.
Internal variable which holds current conversion between desired ticks and GP2X ticks.
unsigned long gp2x_timer_read(void)
This function returns elapsed ticks in gp2x_ticks units since last gp2x_init call.
void gp2x_init(int ticks_per_second,
int bpp,
int rate,
int bits,
int stereo,
int Hz,
int solid_font)
This function sets up the whole library.
extern void gp2x_sound_frame(void *blah,
void *buffer,
int samples)
This function is automatically called by the library, and expects a sound buffer to be filled in.
void gp2x_sound_volume(int /*0..100*/,
int /*0..100*/)
This function sets the sound volume.
void gp2x_sound_pause(int yes)
This function pauses and unpauses the sound.
void gp2x_dualcore_pause(int yes)
This function pauses the secondary ARM 940T coprocessor.
void gp2x_dualcore_sync(void)
This function halts the 920T code until the 940T has finished all its tasks.
void gp2x_dualcore_exec(unsigned long command)
This function executes a 940T command.
void gp2x_dualcore_launch_program(unsigned long *area,
unsigned long