Gp2x On Windows (or Linux) ?, Is This Possible?


xoasis

Still Fresh
Joined
Apr 1, 2006
Messages
2
Will Windows (or Linux) be able to emulate GP2X ?

If we could do so, it will be more easier and quicker to develop game or application for gp2x.

Actually, we have to store the compiled code on the gp2x and start the gp2x in order to test if our development is ok visually. It is time consuming.
 
we have to store the compiled code on the gp2x and start the gp2x in order to test if our development is ok visually
Not really. If you're using the minimal lib, then this will get you started (just link to it instead of minimal.c, compile natively):
Code:
#include <SDL.h>
#include "STD_Types.h"
#include "minimal.h"
#include "SDL_Basic.h"

SDL_Surface *Screen;

u8 *gp2x_screen8, *gp2x_upperRAM;
u32 gp2x_dev[8]={0,0,0,0,0,0,0,0}, gp2x_physvram[8], *gp2x_memregl, gp2x_volume, gp2x_ticks_per_second;
extern volatile unsigned long gp2x_sound_pausei=1, gp2x_ticks=0, gp2x_sound=0, *gp2x_dualcore_ram;
u16 *gp2x_memregs, *gp2x_screen15, *gp2x_logvram15[4], gp2x_sound_buffer[4+((44100/25)*2)*8]; //25 Hz gives our biggest supported sampling buffer
extern volatile unsigned short gp2x_palette[512];
u32 gp2x_sound_thread=0;

unsigned long gp2x_timer_read(void){
  return SDL_GetTicks();
}

void gp2x_video_flip(void){
  SDL_Unlock( Screen );
  SDL_Flip( Screen );
  SDL_Lock( Screen );
}

void gp2x_video_setgamma(unsigned short gamma) /*0..255*/
{
}

void gp2x_video_setpalette(void)
{
}

void gp2x_blitter_rect15(gp2x_rect *r)
{
 int x, y; unsigned short *data=r->data15, *offset=&gp2x_screen15[r->x+r->y*320];

 y=r->h; if(r->solid)
         while(y--) { x=r->w; while(x--) *offset++=*data++; offset+=320-x; }
         else
         while(y--) { x=r->w; while(x--) { if(*data) *offset=*data; offset++, data++; }
                      offset+=320-x; }
}

void gp2x_blitter_rect8(gp2x_rect *r)
{
 int x, y; unsigned char *data=r->data8,   *offset=&gp2x_screen8[r->x+r->y*320]; 

 y=r->h; if(r->solid)
         while(y--) { x=r->w; while(x--) *offset++=*data++; offset+=320-x; }
         else
         while(y--) { x=r->w; while(x--) { if(*data) *offset=*data; offset++, data++; }
                      offset+=320-x; }
}

void gp2x_init(int tickspersecond, int bpp, int rate, int bits, int stereo, int hz){
  SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER );
  Screen = SDL_SetVideoMode( 320, 240, bpp, SDL_SWSURFACE | SDL_NOFRAME );
  gp2x_screen15 = (u16p) Screen->pixels;
  gp2x_screen8 = (u8p) gp2x_screen15;
  SDL_Lock( Screen );
}

unsigned long gp2x_joystick_read( ){
  u32 v=0;
  SDL_Event e;
  SDL_PumpEvents( );
  while( SDL_PollEvent( &e ) )if( e.type == SDL_KEYDOWN  ){
    switch( e.key.keysym.sym ){
      case SDLK_RIGHT: 
        v |= GP2X_RIGHT; break;
      case SDLK_LEFT:  v |= GP2X_LEFT;  break;
      case SDLK_UP:    v |= GP2X_UP;    break;
      case SDLK_DOWN:  v |= GP2X_DOWN;  break;
      case SDLK_RETURN:v |= GP2X_PUSH;  break;
      case SDLK_RSHIFT:v |= GP2X_SELECT;break;
      case SDLK_s:     v |= GP2X_START; break;
      case SDLK_l:     v |= GP2X_L;     break;
      case SDLK_r:     v |= GP2X_R;     break;
      case SDLK_a:     v |= GP2X_A;     break;
      case SDLK_b:     v |= GP2X_B;     break;
      case SDLK_x:     v |= GP2X_X;     break;
      case SDLK_y:     v |= GP2X_Y;     break;
      case SDLK_KP_MINUS:     v |= GP2X_VOL_DOWN;   break;
      case SDLK_KP_PLUS:      v |= GP2X_VOL_UP;     break;
    }
  }
  return v;
}

void gp2x_sound_volume(int l, int r)
{
}

void gp2x_deinit(void){
  SDL_Quit();
}
 
While an emulator could be useful, there are other ways to execute code on the
gp2x, JTAG for example. Simple and fairly quick for smaller applications.
There are some cheap wiggler-ish jtag cables out there for around $20, and
alot of free software.
Another good thing, you won't be bothered with some stupid OS running in the background. :D
 
Back
Top