JAVA 1.5 GP2X DEVKIT per Windows
Version 1.0 Beta 2.0
22 October 2006


<<<<<<<<<<<<<<<<<< THE VM EXTENSIONS FOR GP2X:

The jamvm Virtual Machine contains some extensions directly related to the GP2X hardware.

Provided in this DevKIT are two version of the same class, VMGp2x and VMGp2xStub.

The first is the real class included in the Runtime, it contains the definitions of all native methods available inside the jamvm virtual machine on the real GP2X.

The second one is a Stub, with the same methos and values but with no native dependencies, this of it as an emulation class to be used on a PC to interface with a fake GP2X.

To use it you have to remove the original VMGp2x class and rename VMGp2xStub to VMGp2x.

<<<<<<<<<<<<<<<<<< SFont Library:

The current implementation of the SFont library can be used with a single font, found inside jamvm/bin/sfond.bmp.

This guarantees to all applications the presence of at least one font to work with, provided with the Runtime.

Using more than one font is in roadmap for the next version of the Runtime/Devkit.


<<<<<<<<<<<<<<<<<< GP2X METHODS:

Taken directly from the source code of VMGp2x:

	/** Fast Proportional Font **/
	
	/**
	 * Returns the rendered width of the text
	 * 
	 * @param text the text to measure
	 * @return the width in pixel
	 */
	public static native int sFont_TextWidth(String text);
	
	/**
	 * Returns the current font height
	 * 
	 * @return the current font height
	 */
	public static native int sFont_TextHeight();
	
	/**
	 * Writes a text on the passed in Surface identifier, this identifier can be retrieved in this way:
	 * SDLSurface surface = gp2x.getFramebuffer();
	 * SDL_Surface swigSurface = surface.getSwigSurface();
	 * int surfaceId = (int)SDL_Surface.getCPtr(swigSurface);
	 * 
	 * @param x X coordinate
	 * @param y Y coordinate
	 * @param text a string
	 * @param surface the identifier of the surface to write to 
	 */
	public static native void sFont_Write(int x, int y, String text, int surface);

	/**
	 * Writes a text on the passed in Surface identifier, centered on the Surface X axis.
	 * The surface identifier can be retrieved in this way:
	 * SDLSurface surface = gp2x.getFramebuffer();
	 * SDL_Surface swigSurface = surface.getSwigSurface();
	 * int surfaceId = (int)SDL_Surface.getCPtr(swigSurface);
	 * 
	 * @param y Y coordinate
	 * @param text a string
	 * @param surface the identifier of the surface to write to 
	 */
	public static native void sFont_WriteCenter(int y, String text, int surface);

	/**
	 * Scale the current font with the given factor and smooth.
	 * Zoom=100 is the base value, less than 100 reduces, more than 100 enlarges.
	 * The double multiplication value is calculated by dividing the integer value by 100, so it is
	 * possible to scale the font to 0.01 of the original size. 
	 * 
	 * @param zoomx integer X zoom factor.
	 * @param zoomy integer X zoom factor.
	 * @param smooth 0 or 1 value, if smooth=1 the scaled font is antialiased.
	 */
	public static native void sFont_ScaleFont(int zoomx, int zoomy, int smooth);
	
	/**
	 * Reset the scaled font to the original size and form so it can be rescaled another time.
	 */
	public static native void sFont_ResetFont();

	
	/** Battery and GPIO Command control **/
	
	/** Battery codes **/

	public static final int BATTERY_ERROR		=	0;
	public static final int BATTERY_CRITICAL	=	1;
	public static final int BATTERY_LOW		=	2;
	public static final int BATTERY_MEDIUM		=	3;
	public static final int BATTERY_HIGH		=	4;
	public static final int BATTERY_FULL		=	5;
	public static final int BATTERY_AC		=	6;

	/**
	 * Retrieves the Battery status.
	 * 
	 * @return the current battery status
	 */
	public static native int getBatteryStatus();


	/** GPIO Command codes **/

	public static final int BACK_LIGHT_OFF	=	0;
	public static final int BACK_LIGHT_ON	=	1;
	public static final int BATT_LED_ON	=	2;
	public static final int BATT_LED_OFF	=	3;

	public static final int FCLK_200	=	10;
	public static final int FCLK_166	=	11;
	public static final int FCLK_133	=	12;
	public static final int FCLK_100	=	13;
	public static final int FCLK_78		=	14;
	public static final int FCLK_64		=	15;
	
	public static final int FCLK_DEFAULT	=	16;
	
	/**
	 * Sends Control commands to the GPIO device
	 *
	 * @param command the command code
	 */
	public static native void gpioControl(int command);
	
	/**
	 * Tryes to change the CPU Clock to the specified MHz value
	 * 
	 * @param megahertz desired clock, can range from 50 to 300 MHz, if out of range it is rounded to the nearest limit
	 */
	public static native void cpuClockControl(int megahertz);
