Ejemplo n.º 1
0
/***************************************************************************

  Stop the video hardware emulation.

***************************************************************************/
void lwings_vh_stop(void)
{
	osd_free_bitmap(tmpbitmap2);
	gp2x_free(dirtybuffer2);
	gp2x_free(dirtybuffer4);
	generic_vh_stop();
}
Ejemplo n.º 2
0
/* AM 980919 */
static int checksum_file(const char* file, unsigned char **p, unsigned int *size, unsigned int *crc) {
	int length;
	unsigned char *data;
	FILE* f;

	f = fopen(file,"rb");
	if (!f) {
		return -1;
	}

	/* determine length of file */
	if (fseek (f, 0L, SEEK_END)!=0) {
		fclose(f);
		return -1;
	}

	length = ftell(f);
	if (length == -1L) {
		fclose(f);
		return -1;
	}

	/* allocate space for entire file */
	data = (unsigned char*)gp2x_malloc(length);
	if (!data) {
		fclose(f);
		return -1;
	}

	/* read entire file into memory */
	if (fseek(f, 0L, SEEK_SET)!=0) {
		gp2x_free(data);
		fclose(f);
		return -1;
	}

	if (fread(data, sizeof (unsigned char), length, f) <length /*FRANXIS 22-01-2005 != length*/) {
		gp2x_free(data);
		fclose(f);
		return -1;
	}

	*size = length;
	*crc = crc32 (0L, data, length);
	if (p)
		*p = data;
	else
		gp2x_free(data);

	fclose(f);

	return 0;
}
Ejemplo n.º 3
0
void osd_free_bitmap(struct osd_bitmap *bitmap)
{
	if (bitmap)
	{
		gp2x_free(bitmap->line);
		bitmap->line=NULL;
		gp2x_free(bitmap->_private);
		bitmap->_private=NULL;
		gp2x_free(bitmap);
		bitmap=NULL;
	}
}
Ejemplo n.º 4
0
void zerowing_vh_stop(void)
{
	int i ;

	gp2x_free(zerowing_videoram1);
	gp2x_free(zerowing_videoram2);
	gp2x_free(zerowing_videoram3);

	for (i=0;i<16;i++)
		{
		gp2x_free(tile_list[i]);
		}

	gp2x_free (paletteram);
}
Ejemplo n.º 5
0
void atarisys2_vh_stop(void)
{
	/* free memory */
	if (alpharam)
		gp2x_free (alpharam);
	alpharam = playfieldram = spriteram = 0;

	/* free bitmaps */
	if (playfieldbitmap)
		osd_free_bitmap (playfieldbitmap);
	playfieldbitmap = 0;

	/* free dirty buffers */
	if (playfielddirty)
		gp2x_free (playfielddirty);
	playfielddirty = 0;

	atarigen_free_display_list();
}
Ejemplo n.º 6
0
void klax_vh_stop (void)
{
	/* free bitmaps */
	if (playfieldbitmap)
		osd_free_bitmap (playfieldbitmap);
	playfieldbitmap = 0;

	/* free dirty buffers */
	if (playfielddirty)
		gp2x_free (playfielddirty);
	playfielddirty = 0;

	atarigen_free_display_list();
}
Ejemplo n.º 7
0
/* JB 980920 update */
void osd_fclose(void *file)
{
	FakeFileHandle *f = (FakeFileHandle *) file;

	switch(f->type)
	{
		case kPlainFile:
			fclose(f->file);
#ifdef GP2X
			sync();
#endif
			f->file=NULL;
			break;
		case kZippedFile:
		case kRAMFile:
			if (f->data) {
				gp2x_free(f->data);
				f->data=NULL;
			}
			break;
	}
	gp2x_free(f);
	f=NULL;
}
Ejemplo n.º 8
0
void *gp2x_realloc(void *ptr, size_t size)
{
	void *ptr_new=NULL;

	if ((ptr==NULL) && (size>0))
	{
		ptr_new=gp2x_malloc (size);
	}
	else if ((ptr!=NULL) && (size==0))
	{
		gp2x_free (ptr);
	}
	else if ((ptr!=NULL) && (size>0))
	{
	  	int i = (((int)ptr) - ((int)uppermem));
	  	if (i < 0 || i >= UPPERMEM_SIZE)
	  	{
  			ptr_new=realloc(ptr,size);
  			if (ptr_new==NULL)
  			{
  				printf("Could not realloc %d\n", size);fflush(stdout);
  			}

	  	}
	  	else
		{
			ptr_new=gp2x_malloc(size);
			if (ptr_new!=NULL)
			{
				memcpy(ptr_new,ptr,uppermap[i/UPPERMEM_BLOCKSIZE]);
				gp2x_free(ptr);
			}
		}
	}
	return ptr_new;
}
Ejemplo n.º 9
0
void game_list_init(void) {
#ifdef GP2X
  	/* Zaq121 07/05/2006 Alternative frontend support -> */
  	extern int no_selector;
  	if(no_selector) {
  		int c;
		for (c=0;(c<game_num && drivers[c]);c++) {
	      		game_avail[c]=1;
	      		game_num_avail++;
	    	}
	    	return;
	}
	/* <- end mod */
#endif
#ifdef PSP
 strcpy(gp2x_path_mame,"");
#ifdef WIFI
 //DownloadFileFTP("roms.txt","roms.txt");

 long lSize;
 char * buffer;

 FILE * pFile = fopen ("roms.txt","rb");
 if (pFile!=NULL)
    {
    fseek (pFile , 0 , SEEK_END);
    lSize = ftell (pFile);
    rewind (pFile);
    
    buffer = (char*)gp2x_malloc(lSize);
    fread (buffer,1,lSize,pFile);
    }

#endif
#endif
	char name[256];
	struct stat stat_buffer;
	unsigned int c;
	/* Check Available Games */
	for (c=0;(c<game_num && drivers[c]);c++) {

		/*
		sprintf(name,"%sroms/%s\0", gp2x_path_mame, drivers[c]->name);
		if (stat(name,&stat_buffer)==0)	{	
			game_avail[c]=1;
			game_num_avail++;
			continue;
		}
		*/

#ifdef WIFI
  //PrintMessage("cargando lista %s",drivers[c]->name);
  sprintf(name,"%s.zip",drivers[c]->name);
  if(strstr(buffer, name)){
  //if(drivers[c]->name == "captcomm"){
#else
		sprintf(name,"%sroms/%s.zip\0", gp2x_path_mame, drivers[c]->name);
		if (stat(name,&stat_buffer)==0)	{
#endif
			game_avail[c]=1;
			game_num_avail++;
			continue;
		}
		sprintf(name,"%sroms/%s\0", gp2x_path_mame,drivers[c]->name);
		if (stat(name,&stat_buffer)==0) {
			game_avail[c]=1;
			game_num_avail++;
			continue;
		}
	}
#ifdef WIFI
 sceKernelDelayThread(2*1000000); // 2 sec to for error?
 fclose (pFile);
 gp2x_free (buffer);
#endif
}
#else
void game_list_init(void) {
#ifdef GP2X
  	/* Zaq121 07/05/2006 Alternative frontend support -> */
  	extern int no_selector;
  	if(no_selector) {
  		int c;
		for (c=0;(c<game_num && drivers[c]);c++) {
	      		game_avail[c]=1;
	      		game_num_avail++;
	    	}
	    	return;
	}
	/* <- end mod */
#endif
#ifdef DREAMCAST
	DIR *d=opendir(ROM_PREFIX "roms");
#else
#ifdef GP2X
	char name[256];
	sprintf(name,"%sroms\0",gp2x_path_mame);
	DIR *d=opendir(name);
#else
	DIR *d=opendir("roms");
#endif
#endif
	if (d)
	{
		struct dirent *actual=readdir(d);
		int min=0;
		int max_total, max;
		int i;
		char **games=(char **)gp2x_malloc(game_num*sizeof(char *));
		for(i=0;i<game_num && drivers[i];i++)
		{
			games[i]=(char *)gp2x_malloc(32);
			strncpy(games[i],drivers[i]->name,32-5);
			strcat(games[i],".zip\0");
		}
		max=max_total=i;
		while(actual)
		{
			int encontrado=0;
			for(i=min;i<max;i++)
				if ((!strcmp(actual->d_name,games[i]))||
((strlen(actual->d_name)==(strlen(games[i])-4))&&((!strncmp(actual->d_name,games[i],strlen(games[i])-4))))) {
					game_avail[i]=1;
					game_num_avail++;
					if (i==min)
						min=i+1;
					else
					if (i==max)
						max=i-1;
//					puts(drivers[i]->description);
					encontrado=1;
					break;
				}
#if !defined(GP2X) && !defined(DREMCAST)
/*
			if ((!encontrado)&&(actual->d_name[0]!='.'))
				printf("SOBRA:%s\n",actual->d_name);
*/
#endif
			actual=readdir(d);
		}
		for(i=0;i<max_total;i++)
		{
#if !defined(GP2X) && !defined(DREMCAST)
/*
			if (!game_avail[i])
				printf("FALTA:%s\n",games[i]);
*/
#endif
			gp2x_free(games[i]);
		}
//		printf("TOTAL %i roms\n",max_total);
		gp2x_free(games);
		closedir(d);
	}
}
#endif

#ifdef GP2X
/* Zaq121 07/05/2006 Alternative frontend support -> */
int set_last_game_selected(char *game)
{
  	int i;
  	last_game_selected=0;
  	for (i=0;i<game_num;i++) {
    		if (game_avail[i]==1)
    		{
      			if(strcasecmp(drivers[i]->name, game) == 0)
        			return(last_game_selected);
      			last_game_selected++;
    		}
  	}
  	return -1;
}
Ejemplo n.º 10
0
void *osd_fopen(const char *game,const char *filename,int filetype,int _write)
{
	char name[256];
	char *gamename;
	int found = 0;
	FakeFileHandle *f;

	f = (FakeFileHandle *)gp2x_malloc(sizeof(FakeFileHandle));
	if (!f)
		return 0;
	fast_memset(f,0,sizeof(FakeFileHandle));

	gamename = (char *)game;

	switch (filetype)
	{
		case OSD_FILETYPE_ROM:

			/* only for reading */
			if (_write)
				break;

			if (!found) {
				/* try with a .zip extension */
				sprintf(name,"%s.zip\0", gamename);
				/*if (cache_stat(name)==0)*/ {
					sprintf(name,"%sroms/%s.zip\0", gp2x_path_mame, gamename);
					if (load_zipped_file(name, filename, &f->data, &f->length)==0) {
						f->type = kZippedFile;
						f->offset = 0;
						f->crc = crc32 (0L, f->data, f->length);
						found = 1;
					}
				}
			}
			if (!found) {
				if (cache_stat(gamename)==0) {
					sprintf(name,"%sroms/%s/%s\0",gp2x_path_mame, gamename, filename);
					if (checksum_file (name, &f->data, &f->length, &f->crc)==0) {
						f->type = kRAMFile;
						f->offset = 0;
						found = 1;
					}
				}
			}


			break;
		case OSD_FILETYPE_SAMPLE:
			if (!found) {
				/* try with a .zip extension */
				sprintf(name,"%s.zip\0", gamename);
				/*if (cache_stat_sample(name)==0)*/ {
					sprintf(name,"%ssamples/%s.zip\0", gp2x_path_mame, gamename);
					if (load_zipped_file(name, filename, &f->data, &f->length)==0) {
						f->type = kZippedFile;
						f->offset = 0;
						f->crc = crc32 (0L, f->data, f->length);
						found = 1;
					}
				}
			}
			if (!found) {
				sprintf(name,"%ssamples/%s/%s\0",gp2x_path_mame, gamename, filename);
				if (checksum_file (name, &f->data, &f->length, &f->crc)==0) {
					f->type = kRAMFile;
					f->offset = 0;
					found = 1;
				}
			}
			break;
		case OSD_FILETYPE_HIGHSCORE:
			if (!found) {
				sprintf(name,"%shi/%s.hi", gp2x_path_mame, gamename);
				f->type = kPlainFile;
				f->file = fopen(name,_write ? "wb" : "rb");
				found = f->file!=0;
			}
			break;
		case OSD_FILETYPE_CONFIG:
			break;
		case OSD_FILETYPE_INPUTLOG:
			break;
		case OSD_FILETYPE_STATE:
			break;
		case OSD_FILETYPE_ARTWORK:
			break;
	}

	if (!found) {
		gp2x_free(f);
		return 0;
	}

	return f;
}
Ejemplo n.º 11
0
/***************************************************************************

  Stop the video hardware emulation.

***************************************************************************/
void spiders_vh_stop(void)
{
	osd_free_bitmap(tmpbitmap);
	gp2x_free(screenbuffer);
}
Ejemplo n.º 12
0
/* routines don't clip at boundaries of the bitmap. */
struct osd_bitmap *osd_new_bitmap(int width,int height,int depth)       /* ASG 980209 */
{
	struct osd_bitmap *bitmap;
	
	if (Machine->orientation & ORIENTATION_SWAP_XY)
	{
		int temp;

		temp = width;
		width = height;
		height = temp;
	}
	

	if ((bitmap = (struct osd_bitmap*)gp2x_malloc(sizeof(struct osd_bitmap))) != 0)
	{
		int i,rowlen,rdwidth;
		unsigned char *bm;
		int safety;

		if (width > 32) safety = 8;
		else safety = 0;        /* don't create the safety area for GfxElement bitmaps */

		if (depth != 8 && depth != 16) depth = 8;

		bitmap->depth = depth;
		bitmap->width = width;
		bitmap->height = height;

		rdwidth = (width + 7) & ~7;     /* round width to a quadword */
		if (depth == 16)
			rowlen = 2 * (rdwidth + 2 * safety) * sizeof(unsigned char);
		else
			rowlen =     (rdwidth + 2 * safety) * sizeof(unsigned char);

		if (!(bitmap->_private = gp2x_malloc((height + 2 * safety) * rowlen)))
		{
#ifndef DREAMCAST
			gp2x_text_log("osd_new_bitmap(): Out of Memory");
			gp2x_free(bitmap);
#endif
			return 0;
		}

		bm = (unsigned char*)bitmap->_private;
		fast_memset(bm,0,(height + 2 * safety) * rowlen);

		if (!(bitmap->line = (unsigned char**)gp2x_malloc(height * sizeof(unsigned char *))))
		{
#ifndef DREAMCAST
			gp2x_text_log("osd_new_bitmap(): Out of Memory");
			gp2x_free(bm);
			gp2x_free(bitmap);
#endif
			return 0;
		}

		for (i = 0;i < height;i++)
			bitmap->line[i] = &bm[(i + safety) * rowlen + safety];
	}
#ifndef DREAMCAST
	if(!bitmap)
		gp2x_text_log("osd_new_bitmap(): Out of Memory");
#endif
	return bitmap;
}
Ejemplo n.º 13
0
/***************************************************************************

  Start the video hardware emulation.

***************************************************************************/
int lwings_vh_start(void)
{
	int i;


	if (generic_vh_start() != 0)
		return 1;

        if ((dirtybuffer2 = (unsigned char *)gp2x_malloc(lwings_backgroundram_size)) == 0)
	{
		generic_vh_stop();
		return 1;
	}
        fast_memset(dirtybuffer2,1,lwings_backgroundram_size);

        if ((dirtybuffer4 = (unsigned char *)gp2x_malloc(lwings_backgroundram_size)) == 0)
	{
		generic_vh_stop();
		return 1;
	}
        fast_memset(dirtybuffer4,1,lwings_backgroundram_size);

	/* the background area is twice as tall as the screen */
        if ((tmpbitmap2 = osd_new_bitmap(2*Machine->drv->screen_width,
                2*Machine->drv->screen_height,Machine->scrbitmap->depth)) == 0)
	{
		gp2x_free(dirtybuffer2);
		generic_vh_stop();
		return 1;
	}


#define COLORTABLE_START(gfxn,color_code) Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + \
				color_code * Machine->gfx[gfxn]->color_granularity
#define GFX_COLOR_CODES(gfxn) Machine->gfx[gfxn]->total_colors
#define GFX_ELEM_COLORS(gfxn) Machine->gfx[gfxn]->color_granularity

	fast_memset(palette_used_colors,PALETTE_COLOR_UNUSED,Machine->drv->total_colors * sizeof(unsigned char));
	/* chars */
	for (i = 0;i < GFX_COLOR_CODES(0);i++)
	{
		fast_memset(&palette_used_colors[COLORTABLE_START(0,i)],
				PALETTE_COLOR_USED,
				GFX_ELEM_COLORS(0));
		palette_used_colors[COLORTABLE_START(0,i) + GFX_ELEM_COLORS(0)-1] = PALETTE_COLOR_TRANSPARENT;
	}
	/* bg tiles */
	for (i = 0;i < GFX_COLOR_CODES(1);i++)
	{
		fast_memset(&palette_used_colors[COLORTABLE_START(1,i)],
				PALETTE_COLOR_USED,
				GFX_ELEM_COLORS(1));
	}
	/* sprites */
	for (i = 0;i < GFX_COLOR_CODES(2);i++)
	{
		fast_memset(&palette_used_colors[COLORTABLE_START(2,i)],
				PALETTE_COLOR_USED,
				GFX_ELEM_COLORS(2));
	}

	return 0;
}
Ejemplo n.º 14
0
int starforc_sh_start(void)
{
	int i;


	if (SN76496_sh_start(&interface) != 0)
		return 1;

	/* z80 ctc init */
	ctc_intf.baseclock[0] = Machine->drv->cpu[1].cpu_clock;
	z80ctc_init (&ctc_intf);

	/* z80 pio init */
	z80pio_init (&pio_intf);

	/* setup daisy chain connection */
	{
		static Z80_DaisyChain daisy_chain[] =
		{
			{ z80pio_reset , z80pio_interrupt, z80pio_reti , 0 }, /* device 0 = PIO_0 , low  priority */
			{ z80ctc_reset , z80ctc_interrupt, z80ctc_reti , 0 }, /* device 1 = CTC_0 , high priority */
			{ 0,0,0,-1}        /* end mark */
		};
		cpu_setdaisychain (1,daisy_chain );
/*
	daisy_chain is connect link for Z80 daisy-chain .
	paramater is
	{ pointer of reset , pointer of interrupt entry,pointer of RETI handler , device paramater }

	reset           : This function is called when z80 cpu reset
	interrupt entry : This function is called when z80 interrupt entry for this device
	                  It shoud be change interrupt status and
	                  set new status with cpu_cause_interrupt function
	                  return value is interrupt vector

	RETI handler    : This function is called when z80 reti operation for this device
	                  It shoud be change interrupt status and
	                  set new status with cpu_cause_interrupt function

	handler shoud be allocate static.
	Because this pointers is used when reset cpu.

	The daisy chain link is build by this pointers.

	daisy chain priority:
		As for Priority , the top side is lower , bottom side is higher

*/
	}

	if ((_single = (signed char *)gp2x_malloc(SINGLE_LENGTH)) == 0)
	{
		SN76496_sh_stop();
		gp2x_free(_single);
		return 1;
	}
	for (i = 0;i < SINGLE_LENGTH;i++)		/* freq = ctc2 zco / 8 */
		_single[i] = ((i/SINGLE_DIVIDER)&0x01)*(SINGLE_VOLUME/2);

	/* CTC2 single tone generator */
	osd_play_sample(4,_single,SINGLE_LENGTH,single_rate,single_volume,1);

	return 0;
}
Ejemplo n.º 15
0
void starforc_sh_stop(void)
{
	SN76496_sh_stop();
	gp2x_free(_single);
}