Exemplo n.º 1
0
int zerowing_vh_start(void)
{
	int i;

	zerowing_videoram1 = (unsigned char *)gp2x_malloc (VIDEORAM1_SIZE);
	zerowing_videoram2 = (unsigned char *)gp2x_malloc (VIDEORAM2_SIZE);
	zerowing_videoram3 = (unsigned char *)gp2x_malloc (VIDEORAM3_SIZE * 4); /* 4 layers */
	fast_memset(zerowing_videoram1,0,VIDEORAM1_SIZE);
	fast_memset(zerowing_videoram2,0,VIDEORAM2_SIZE);
	fast_memset(zerowing_videoram3,0,VIDEORAM3_SIZE*4);
	

	paletteram = (unsigned char *)gp2x_malloc (colorram1_size + colorram2_size);
	fast_memset(paletteram,0,colorram1_size + colorram2_size);

	for ( i=0; i<16; i++ )
		{
		max_list_size[i]=512;
		tile_list[i]=(tile_struct *)gp2x_malloc(max_list_size[i]*sizeof(tile_struct)) ;
		fast_memset(tile_list[i],0,max_list_size[i]*sizeof(tile_struct));
		}

	num_tiles = (Machine->drv->screen_width/8+1)*(Machine->drv->screen_height/8) ;

	video_ofs = video_ofs3 = fdflag = 0;

	return 0;
}
Exemplo n.º 2
0
ROM_END

/* HSC 12/02/98 */
static int hiload(void)
{

	static int firsttime =0;
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];
	if (firsttime == 0)
		{
			fast_memset(&RAM[0x4014],0xff,5); /* hi score */
			fast_memset(&RAM[0x417d],0xff,12); /* name */
			firsttime = 1;
		}

    /* check if the hi score table has already been initialized */
    if (memcmp(&RAM[0x4014],"\x00\x00\x00\x00\x00",5) == 0 &&
		memcmp(&RAM[0x417f],"\x11\x12\x29\x1c\x0c\x18\x1b\x0e\x00\x00",10) == 0  )
    {
        void *f;

        if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
        {
            osd_fread(f,&RAM[0x4014],5);
			osd_fread(f,&RAM[0x417d],12);
			osd_fclose(f);
        }
		firsttime = 0;
        return 1;
    }
    else return 0;  /* we can't load the hi scores yet */
}
Exemplo n.º 3
0
void gp2x_clear_screen(void)
{
	/* Clean screens */
   	gp2x_video_flip();
   	fast_memset(gp2x_screen8, 0, GP2X_BYTE_SIZE_SCREEN);
   	gp2x_video_flip();
   	fast_memset(gp2x_screen8, 0, GP2X_BYTE_SIZE_SCREEN);
   	gp2x_video_flip_single();
}
Exemplo n.º 4
0
/* set the bitmap to black */
void osd_clearbitmap(struct osd_bitmap *bitmap)
{
	if (bitmap->_private==bitmap->line[0])
		fast_memset(bitmap->_private,0,bitmap->width*bitmap->height);
	else
		fast_memset(bitmap->_private,0,(bitmap->width+16)*(bitmap->height+16));
/*
	int i;
	for (i = 0;i < bitmap->height;i++)
		fast_memset(bitmap->line[i],0,bitmap->width);
*/
}
Exemplo n.º 5
0
void pkunwar_flipscreen_w(int offset,int data)
{
	if (flipscreen[0] != (data & 1))
	{
		flipscreen[0] = data & 1;
		fast_memset(dirtybuffer,1,videoram_size);
	}
	if (flipscreen[1] != (data & 2))
	{
		flipscreen[1] = data & 2;
		fast_memset(dirtybuffer,1,videoram_size);
	}
}
Exemplo n.º 6
0
/* Show FPS Counter */
INLINE void frame_counter (void)
{
	static unsigned int gp2x_fc=0; /* Elapsed frame counter */
	static unsigned int gp2x_fc_v=0; /* Frame Counter to show */
	static unsigned long gp2x_fc_t0; /* Last T0 */
	unsigned long gp2x_fc_t1=gp2x_timer_read_real();
	char texto[8];
	int offsetx=0;
	int offsety=0;
	gp2x_fc++;
	if (gp2x_fc_t1-gp2x_fc_t0>=1000*gp2x_timer_read_scale()) {
		gp2x_fc_t0=gp2x_fc_t1;
		gp2x_fc_v=gp2x_fc;
		gp2x_fc=0;
	}
	sprintf(texto,"%d/%d",gp2x_fc_v,gp2x_fps);
	if (gp2x_bordertvout) {
		offsetx+=((((gp2x_bordertvout_width*gp2x_text_width)/100)+7)&~7)/2;
		offsety+=((((gp2x_bordertvout_height*(gp2x_rotate&1?visible_game_width:visible_game_height))/100)+7)&~7)/2;
	}
	fast_memset(&gp2x_screen8[(0+offsety)*gp2x_text_width]+offsetx,0,48);
	fast_memset(&gp2x_screen8[(1+offsety)*gp2x_text_width]+offsetx,0,48);
	fast_memset(&gp2x_screen8[(2+offsety)*gp2x_text_width]+offsetx,0,48);
	fast_memset(&gp2x_screen8[(3+offsety)*gp2x_text_width]+offsetx,0,48);
	fast_memset(&gp2x_screen8[(4+offsety)*gp2x_text_width]+offsetx,0,48);
	fast_memset(&gp2x_screen8[(5+offsety)*gp2x_text_width]+offsetx,0,48);
	fast_memset(&gp2x_screen8[(6+offsety)*gp2x_text_width]+offsetx,0,48);
	fast_memset(&gp2x_screen8[(7+offsety)*gp2x_text_width]+offsetx,0,48);
	gp2x_text(gp2x_screen8,1,1,texto,0);
	gp2x_text(gp2x_screen8,0,0,texto,1);
}
Exemplo n.º 7
0
int klax_vh_start(void)
{
	static struct atarigen_modesc klax_modesc =
	{
		256,                 /* maximum number of MO's */
		8,                   /* number of bytes per MO entry */
		2,                   /* number of bytes between MO words */
		0,                   /* ignore an entry if this word == 0xffff */
		0, 0, 0xff,          /* link = (data[linkword] >> linkshift) & linkmask */
		0                    /* render in reverse link order */
	};

	/* allocate dirty buffers */
	if (!playfielddirty)
		playfielddirty = (unsigned char *)gp2x_malloc (atarigen_playfieldram_size / 2);
	if (!playfielddirty)
	{
		klax_vh_stop ();
		return 1;
	}
	fast_memset (playfielddirty, 1, atarigen_playfieldram_size / 2);

	/* allocate bitmaps */
	if (!playfieldbitmap)
		playfieldbitmap = osd_new_bitmap (XDIM, YDIM, Machine->scrbitmap->depth);
	if (!playfieldbitmap)
	{
		klax_vh_stop ();
		return 1;
	}

	/* initialize the displaylist system */
	return atarigen_init_display_list (&klax_modesc);
}
Exemplo n.º 8
0
static void hisave(void)
{
    void *f;
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];


    if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0)
    {
	 	osd_fwrite(f,&RAM[0x4014],5);
		osd_fwrite(f,&RAM[0x417d],12);
        osd_fclose(f);
    	fast_memset(&RAM[0x4014],0xff,5); /* hi score */
		fast_memset(&RAM[0x417d],0xff,12); /* name */

	}
}
Exemplo n.º 9
0
void Cz80_Init(cz80_struc *cpu)
{
    u32 i, j, p;

    fast_memset(cpu, 0, sizeof(cz80_struc));
    
    // flags tables initialisation
    for (i = 0; i < 256; i++)
    {
        SZXY[i] = i & (CZ80_SF | CZ80_YF | CZ80_XF);
        if (!i) SZXY[i] |= CZ80_ZF;

        SZXY_BIT[i] = i & (CZ80_SF | CZ80_YF | CZ80_XF);
        if (!i) SZXY_BIT[i] |= CZ80_ZF | CZ80_PF;
        
        for (j = 0, p = 0; j < 8; j++) if (i & (1 << j)) p++;
        SZXYP[i] = SZXY[i];
        if (!(p & 1)) SZXYP[i] |= CZ80_PF;
        
        SZXYHV_inc[i] = SZXY[i];
        if(i == 0x80) SZXYHV_inc[i] |= CZ80_VF;
        if((i & 0x0F) == 0x00) SZXYHV_inc[i] |= CZ80_HF;
        
        SZXYHV_dec[i] = SZXY[i] | CZ80_NF;
        if (i == 0x7F) SZXYHV_dec[i] |= CZ80_VF;
        if ((i & 0x0F) == 0x0F) SZXYHV_dec[i] |= CZ80_HF;
    }
}
Exemplo n.º 10
0
/* memmove */
void HELPER(mvc)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src)
{
    int i = 0;

    HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
               __func__, l, dest, src);

    /* mvc with source pointing to the byte after the destination is the
       same as memset with the first source byte */
    if (dest == (src + 1)) {
        fast_memset(env, dest, cpu_ldub_data(env, src), l + 1);
        return;
    }

    /* mvc and memmove do not behave the same when areas overlap! */
    if ((dest < src) || (src + l < dest)) {
        fast_memmove(env, dest, src, l + 1);
        return;
    }

    /* slow version with byte accesses which always work */
    for (i = 0; i <= l; i++) {
        cpu_stb_data(env, dest + i, cpu_ldub_data(env, src + i));
    }
}
Exemplo n.º 11
0
int pia_startup (struct pia6821_interface *intf)
{
	int i;

	fast_memset (pia, 0, sizeof (pia));
	for (i = 0; i < intf->num; i++)
	{
		pia[i].in_a_func = intf->in_a_func[i];
		pia[i].in_ca1_func = intf->in_ca1_func[i];
		pia[i].in_ca2_func = intf->in_ca2_func[i];
		pia[i].out_a_func = intf->out_a_func[i];
		pia[i].out_ca2_func = intf->out_ca2_func[i];
		pia[i].irq_a_func = intf->irq_a_func[i];

		pia[i].in_b_func = intf->in_b_func[i];
		pia[i].in_cb1_func = intf->in_cb1_func[i];
		pia[i].in_cb2_func = intf->in_cb2_func[i];
		pia[i].out_b_func = intf->out_b_func[i];
		pia[i].out_cb2_func = intf->out_cb2_func[i];
		pia[i].irq_b_func = intf->irq_b_func[i];
	}
	fast_memcpy (pia_offsets, intf->offsets, sizeof (pia_offsets));

	return 1;
}
Exemplo n.º 12
0
/* xor on array */
uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, uint64_t dest,
                    uint64_t src)
{
    int i;
    unsigned char x;
    uint32_t cc = 0;

    HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
               __func__, l, dest, src);

    /* xor with itself is the same as memset(0) */
    if (src == dest) {
        fast_memset(env, dest, 0, l + 1);
        return 0;
    }

    for (i = 0; i <= l; i++) {
        x = cpu_ldub_data(env, dest + i) ^ cpu_ldub_data(env, src + i);
        if (x) {
            cc = 1;
        }
        cpu_stb_data(env, dest + i, x);
    }
    return cc;
}
Exemplo n.º 13
0
/***************************************************************************

  Draw the game screen in the given osd_bitmap.
  Do NOT call osd_update_display() from this function, it will be called by
  the main emulation engine.

***************************************************************************/
void vigilant_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
	int i;


	if (rear_disable)	 /* opaque foreground */
	{
		for (i = 0;i < 8;i++)
			palette_used_colors[256 + 16*i] = PALETTE_COLOR_USED;
	}
	else
	{
		for (i = 0;i < 8;i++)
			palette_used_colors[256 + 16*i] = PALETTE_COLOR_TRANSPARENT;
	}


	/* copy the background palette */
	for (i = 0;i < 16;i++)
	{
		int r,g,b;


		r = (paletteram[0x400 + 16 * rear_color + i] << 3) & 0xFF;
		g = (paletteram[0x500 + 16 * rear_color + i] << 3) & 0xFF;
		b = (paletteram[0x600 + 16 * rear_color + i] << 3) & 0xFF;

		palette_change_color(512 + i,r,g,b);

		r = (paletteram[0x400 + 16 * rear_color + 32 + i] << 3) & 0xFF;
		g = (paletteram[0x500 + 16 * rear_color + 32 + i] << 3) & 0xFF;
		b = (paletteram[0x600 + 16 * rear_color + 32 + i] << 3) & 0xFF;

		palette_change_color(512 + 16 + i,r,g,b);
	}

	if (palette_recalc())
	{
		fast_memset(dirtybuffer,1,videoram_size);
		rear_refresh = 1;
	}

	if (rear_disable)	 /* opaque foreground */
	{
		draw_foreground(bitmap,0,1);
		draw_sprites(bitmap);
		draw_foreground(bitmap,1,1);
	}
	else
	{
		draw_background(bitmap);
		draw_foreground(bitmap,0,0);
		draw_sprites(bitmap);
		draw_foreground(bitmap,1,0); 
	}
}
Exemplo n.º 14
0
static void driver_init(void)
{
	/* This game doesn't like all memory to be initialized to zero, it won't
	   initialize the high scores */

	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];

	fast_memset(&RAM[0xe000], 0, 0x100);
	RAM[0xe000] = 1;
}
Exemplo n.º 15
0
void atarisys2_hscroll_w (int offset, int data)
{
	int oldword = READ_WORD (&atarigen_hscroll[offset]);
	int newword = COMBINE_WORD (oldword, data);
	WRITE_WORD (&atarigen_hscroll[offset], newword);

	/* if we changed the bank, we need to rerender the playfield */
	if (offset == 0 && (oldword & 15) != (newword & 15))
		fast_memset (playfielddirty, 1, playfieldram_size / 2);
}
Exemplo n.º 16
0
/* Debug Log information funcion */
void gp2x_text_log_int(int entero) {
	if (!log)
	{
#if !defined(GP2X) && !defined(NO_SPLASH)
		load_bmp_8bpp(gp2x_screen8,gp2xsplash_bmp);
#else
		fast_memset(gp2x_screen8,0,GP2X_BYTE_SIZE_SCREEN);
#endif
	}
	gp2x_text_out_int(0,log,entero);
	log+=8;
#ifdef PSP_RES
	if(log>271) log=0;
#else
	if(log>239) log=0;
#endif
}
Exemplo n.º 17
0
u32 Cz80_Reset(cz80_struc *cpu)
{
    cz80_struc *CPU = cpu;
    
    fast_memset(CPU, 0, (u32)(&(CPU->CycleSup)) - (u32)(&(CPU->BC)));

    Cz80_Set_PC(CPU, 0);
    zIX = 0xFFFF;
    zIY = 0xFFFF;
#if CZ80_DEBUG
    zF = CZ80_ZF;
#else
    zSP = 0xFFFF;
    zFA = 0xFFFF;
#endif

    return CPU->Status;
}
Exemplo n.º 18
0
ROM_END


/***************************************************************************

  Hi Score Routines

***************************************************************************/

static int hiload(void)
{

      unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];
	static int firsttime = 0;


	/* check if the hi score table has already been initialized */
	/* the high score table is intialized to all 0, so first of all */
	/* we dirty it, then we wait for it to be cleared again */
	if (firsttime == 0)
	{
		fast_memset(&RAM[0x0037],0xff,4);
		firsttime = 1;
	}


        if(memcmp(&RAM[0x0037],"\x00\x00\x00\x00",4) == 0)
	{
              void *f;
              if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
              {
                      osd_fread(f,&RAM[0x0037],4);
                      osd_fclose(f);
              }

              return 1;
	}
        else return 0;   /* we can't load the hi scores yet */
 }
Exemplo n.º 19
0
/* Pause Text Message */
void gp2x_text_pause(void) {
	gp2x_video_flip_single();
#ifdef GP2X
	if (gp2x_showfps) {
		int offsetx=0;
		int offsety=0;
		if (gp2x_bordertvout) {
			offsetx+=((((gp2x_bordertvout_width*gp2x_text_width)/100)+7)&~7)/2;
			offsety+=((((gp2x_bordertvout_height*(gp2x_rotate&1?visible_game_width:visible_game_height))/100)+7)&~7)/2;
		}
		fast_memset(&gp2x_screen8[(0+offsety)*gp2x_text_width]+offsetx,0,48);
		fast_memset(&gp2x_screen8[(1+offsety)*gp2x_text_width]+offsetx,0,48);
		fast_memset(&gp2x_screen8[(2+offsety)*gp2x_text_width]+offsetx,0,48);
		fast_memset(&gp2x_screen8[(3+offsety)*gp2x_text_width]+offsetx,0,48);
		fast_memset(&gp2x_screen8[(4+offsety)*gp2x_text_width]+offsetx,0,48);
		fast_memset(&gp2x_screen8[(5+offsety)*gp2x_text_width]+offsetx,0,48);
		fast_memset(&gp2x_screen8[(6+offsety)*gp2x_text_width]+offsetx,0,48);
		fast_memset(&gp2x_screen8[(7+offsety)*gp2x_text_width]+offsetx,0,48);
	}
	gp2x_text(gp2x_screen8,1,1,"PAUSE\0",0);
	gp2x_text(gp2x_screen8,0,0,"PAUSE\0",1);
#else
#ifdef PSP_RES
	gp2x_text(gp2x_screen8,190,160,"Arcade  Paused!\0",0);
	gp2x_text(gp2x_screen8,190,160,"Arcade  Paused!\0",1);
	gp2x_text(gp2x_screen8,190,170,"L+R to Continue\0",0);
	gp2x_text(gp2x_screen8,190,170,"L+R to Continue\0",1);
	gp2x_text(gp2x_screen8,190,180,"or HOME to Quit\0",0);
	gp2x_text(gp2x_screen8,190,180,"or HOME to Quit\0",1);
#else
	gp2x_text(gp2x_screen8,141,111,"PAUSE\0",0);
	gp2x_text(gp2x_screen8,140,110,"PAUSE\0",1);
#endif
#endif
	gp2x_video_flip_single();
}
Exemplo n.º 20
0
/***************************************************************************

  Start the video hardware emulation.

***************************************************************************/
int spiders_vh_start(void)
{
	int loop;

	if ((tmpbitmap = osd_create_bitmap(Machine->drv->screen_width,Machine->drv->screen_height)) == 0) return 1;

	for(loop=0;loop<256;loop++)
	{
		bitflip[loop]=(loop&0x01)?0x80:0x00;
		bitflip[loop]|=(loop&0x02)?0x40:0x00;
		bitflip[loop]|=(loop&0x04)?0x20:0x00;
		bitflip[loop]|=(loop&0x08)?0x10:0x00;
		bitflip[loop]|=(loop&0x10)?0x08:0x00;
		bitflip[loop]|=(loop&0x20)?0x04:0x00;
		bitflip[loop]|=(loop&0x40)?0x02:0x00;
		bitflip[loop]|=(loop&0x80)?0x01:0x00;
	}

	if ((screenbuffer = (int *)gp2x_malloc(SCREENBUFFER_SIZE*sizeof(int))) == 0) return 1;
	fast_memset(screenbuffer,1,SCREENBUFFER_SIZE*sizeof(int));

	return 0;
}
Exemplo n.º 21
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;
}
Exemplo n.º 22
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;
}
Exemplo n.º 23
0
void lwings_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
	int offs;


	if (palette_recalc())
	{
		fast_memset(dirtybuffer2,1,lwings_backgroundram_size);
		fast_memset(dirtybuffer4,1,lwings_backgroundram_size);
	}


	for (offs = lwings_backgroundram_size - 1;offs >= 0;offs--)
	{
		int sx,sy, colour;
		/*
		Tiles
		=====
		0x80 Tile code MSB
		0x40 Tile code MSB
		0x20 Tile code MSB
		0x10 X flip
		0x08 Y flip
		0x04 Colour
		0x02 Colour
		0x01 Colour
		*/

		colour=(lwings_backgroundattribram[offs] & 0x07);
		if (dirtybuffer2[offs] != 0 || dirtybuffer4[offs] != 0)
		{
			int code;
			dirtybuffer2[offs] = dirtybuffer4[offs] = 0;

			sx = offs / 32;
			sy = offs % 32;
			code=lwings_backgroundram[offs];
			code+=((((int)lwings_backgroundattribram[offs]) &0xe0) <<3);

			drawgfx(tmpbitmap2,Machine->gfx[1],
					code,
					colour,
					(lwings_backgroundattribram[offs] & 0x08),
					(lwings_backgroundattribram[offs] & 0x10),
					16 * sx,16 * sy,
					0,TRANSPARENCY_NONE,0);
		}
	}


	/* copy the background graphics */
	{
		int scrollx,scrolly;


		scrolly = -(lwings_scrollx[0] + 256 * lwings_scrollx[1]);
		scrollx = -(lwings_scrolly[0] + 256 * lwings_scrolly[1]);

		copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
	}


	/* Draw the sprites. */
	for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
	{
		int code,sx,sy;

		/*
		Sprites
		=======
		0x80 Sprite code MSB
		0x40 Sprite code MSB
		0x20 Colour
		0x10 Colour
		0x08 Colour
		0x04 Y flip
		0x02 X flip
		0x01 X MSB
		*/
		sx = spriteram[offs + 3] - 0x100 * (spriteram[offs + 1] & 0x01);
		sy = spriteram[offs + 2];
		if (sx && sy)
		{
			code = spriteram[offs];
			code += (spriteram[offs + 1] & 0xc0) << 2;

			drawgfx(bitmap,Machine->gfx[2],
					code,
					(spriteram[offs + 1] & 0x38) >> 3,
					spriteram[offs + 1] & 0x02,spriteram[offs + 1] & 0x04,
					sx,sy,
					&Machine->drv->visible_area,TRANSPARENCY_PEN,15);
		}
	}
Exemplo n.º 24
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;
}
Exemplo n.º 25
0
/*!
 ************************************************************************
 * \brief
 *    Generates p_Vid->MapUnitToSliceGroupMap
 *    Has to be called every time a new Picture Parameter Set is used
 *
 * \param p_Vid
 *      video encoding parameters for current picture
 *
 ************************************************************************
 */
static int FmoGenerateMapUnitToSliceGroupMap (VideoParameters *p_Vid, Slice *currSlice)
{
    seq_parameter_set_rbsp_t* sps = p_Vid->active_sps;
    pic_parameter_set_rbsp_t* pps = p_Vid->active_pps;

    unsigned int NumSliceGroupMapUnits;

    NumSliceGroupMapUnits = (sps->pic_height_in_map_units_minus1+1)* (sps->pic_width_in_mbs_minus1+1);

    if (pps->slice_group_map_type == 6)
    {
        if ((pps->pic_size_in_map_units_minus1 + 1) != NumSliceGroupMapUnits)
        {
            error ("wrong pps->pic_size_in_map_units_minus1 for used SPS and FMO type 6", 500);
        }
    }

    // allocate memory for p_Vid->MapUnitToSliceGroupMap
    if (p_Vid->MapUnitToSliceGroupMap)
        free (p_Vid->MapUnitToSliceGroupMap);
    if ((p_Vid->MapUnitToSliceGroupMap = malloc ((NumSliceGroupMapUnits) * sizeof (int))) == NULL)
    {
        printf ("cannot allocated %d bytes for p_Vid->MapUnitToSliceGroupMap, exit\n", (int) ( (pps->pic_size_in_map_units_minus1+1) * sizeof (int)));
        exit (-1);
    }

    if (pps->num_slice_groups_minus1 == 0)    // only one slice group
    {
        fast_memset (p_Vid->MapUnitToSliceGroupMap, 0, NumSliceGroupMapUnits * sizeof (int));
        return 0;
    }

    switch (pps->slice_group_map_type)
    {
    case 0:
        FmoGenerateType0MapUnitMap (p_Vid, NumSliceGroupMapUnits);
        break;
    case 1:
        FmoGenerateType1MapUnitMap (p_Vid, NumSliceGroupMapUnits);
        break;
    case 2:
        FmoGenerateType2MapUnitMap (p_Vid, NumSliceGroupMapUnits);
        break;
    case 3:
        FmoGenerateType3MapUnitMap (p_Vid, NumSliceGroupMapUnits, currSlice);
        break;
    case 4:
        FmoGenerateType4MapUnitMap (p_Vid, NumSliceGroupMapUnits, currSlice);
        break;
    case 5:
        FmoGenerateType5MapUnitMap (p_Vid, NumSliceGroupMapUnits, currSlice);
        break;
    case 6:
        FmoGenerateType6MapUnitMap (p_Vid, NumSliceGroupMapUnits);
        break;
    default:
        printf ("Illegal slice_group_map_type %d , exit \n", (int) pps->slice_group_map_type);
        exit (-1);
    }
    return 0;
}
Exemplo n.º 26
0
int atarisys2_vh_start(void)
{
	static struct atarigen_modesc atarisys2_modesc =
	{
		256,                 /* maximum number of MO's */
		8,                   /* number of bytes per MO entry */
		2,                   /* number of bytes between MO words */
		3,                   /* ignore an entry if this word == 0xffff */
		3, 3, 0xff,          /* link = (data[linkword] >> linkshift) & linkmask */
		0                    /* render in reverse link order */
	};

	/* allocate banked memory */
	alpharam = (unsigned char *)gp2x_malloc (0x8000);
	if (!alpharam)
	{
		atarisys2_vh_stop ();
		return 1;
	}
	fast_memset(alpharam,0,0x8000);
	spriteram = alpharam + alpharam_size;
	playfieldram = alpharam + 0x4000;

	/* reset the videoram banking */
	videoram = alpharam;
	videobank = 0;

	/* allocate dirty buffers */
	if (!playfielddirty)
		playfielddirty = (unsigned char *)gp2x_malloc (playfieldram_size / 2);
	if (!playfielddirty)
	{
		atarisys2_vh_stop ();
		return 1;
	}

	/* allocate bitmaps */
	if (!playfieldbitmap)
		playfieldbitmap = osd_new_bitmap (128*8, 64*8, Machine->scrbitmap->depth);
	if (!playfieldbitmap)
	{
		atarisys2_vh_stop ();
		return 1;
	}

	/*
	 * if we are palette reducing, do the simple thing by marking everything used except for
	 * the transparent sprite and alpha colors; this should give some leeway for machines
	 * that can't give up all 256 colors
	 */
	if (palette_used_colors)
	{
		int i;
		fast_memset (palette_used_colors, PALETTE_COLOR_USED, Machine->drv->total_colors * sizeof(unsigned char));
		for (i = 0; i < 4; i++)
			palette_used_colors[0 + i * 16] = PALETTE_COLOR_TRANSPARENT;
		for (i = 0; i < 8; i++)
			palette_used_colors[64 + i * 4] = PALETTE_COLOR_TRANSPARENT;
	}

	/* initialize the displaylist system */
	return atarigen_init_display_list (&atarisys2_modesc);
}