Пример #1
0
neosplash(){
    disp_off();
    cls();
    load_palette(16,neosprpal,1);
    load_vram(0x5000,neospr,0x400);
    load_palette(0,badge1pal,1);
    set_tile_data(neotiles);
    load_tile(0x1000);
    for(j=0;j<14;j++){
        for(i=0;i<14;i++){
            put_tile(j*14+i,i+1,j);
        }
    }

    for(i=0;i<8;i++){
        spr_set(i);
        spr_pal(0);
        spr_pri(1);
        spr_ctrl(SIZE_MAS,SZ_32x16);
        spr_pattern(0x5000+0x80*i);
        spr_y(224-24);
        spr_x(i*32);
    }
    disp_on();
    t=0;
    for(;;){
        t++;

        vsync();
        joy0=joy(0);
        satb_update();
        if(joy0&JOY_STRT){
            break;
        }
        if(t>144)break;
    }
    psgPlay(0);
    disp_off();
    for(i=0;i<8;i++){
        spr_set(i);
        spr_hide();
    }
    satb_update();
    cls();
    set_color(0,0);
    set_color(256,0);
    disp_on();

    while(joy0&JOY_STRT){
        vsync();
        joy0=joy(0);
    }


}
Пример #2
0
void RedrawMain()
{
	ResetVideo();
	setupFont();

#ifndef CDROM1
	set_tile_data(MB_bg);
	load_tile(0x1000);
	load_palette(0, MB_pal, 1);  
	set_map_data(MB_map, 40, 30);
	load_map(0, 0, 0, 0, 40, 30);	
#ifdef SGFX
	if(sgx_detect())
	{
		vpc_win_size(VPC_WIN_A, 0x01ff);
		vpc_win_size(VPC_WIN_B, 0x01ff);
		vpc_win_reg(VPC_WIN_A, VDC_ON+VPC_NORM);
		vpc_win_reg(VPC_WIN_B, VDC_ON+VPC_NORM);
		vpc_win_reg(VPC_WIN_AB, VDC_ON+VPC_NORM);
		vpc_win_reg(VPC_WIN_NONE, VDC_ON+VPC_NORM);

		sgx_set_screen_size(SCR_SIZE_32x32);
		sgx_disp_off();
		
		sgx_set_tile_data(SMPTE75_bg);
		sgx_load_tile(0x1000);		
		sgx_set_map_data(SMPTE75_map, 40, 30);
		sgx_load_map(0, 0, 0, 0, 40, 30);	
		//load_palette(0, SMPTE75_pal, 16);
		sgx_disp_on();
		sgx_scroll(40, 40);
	}
#endif
#else
	set_screen_size(SCR_SIZE_64x32); 
	cd_loaddata(GPHX_OVERLAY, OFS_mainbg_PAL_bin, palCD, SIZE_mainbg_PAL_bin); 
	load_palette(0, palCD, 1); 
	cd_loadvram(GPHX_OVERLAY, OFS_mainbg_DATA_bin, 0x1000, SIZE_mainbg_DATA_bin);
	cd_loadvram(GPHX_OVERLAY, OFS_mainbg_BAT_bin, 0x0000, SIZE_mainbg_BAT_bin);
#endif
   
	init_satb();
	DrawSP();
	satb_update();
	
	Center224in240();
	DisplaySystemInfo();		
}
Пример #3
0
static MagickBooleanType load_level(Image *image,XCFDocInfo *inDocInfo,
  XCFLayerInfo *inLayerInfo)
{
  ExceptionInfo
    *exception;

  int
    destLeft = 0,
    destTop = 0;

  Image*
    tile_image;

  MagickBooleanType
    status;

  MagickOffsetType
    saved_pos,
    offset,
    offset2;

  register ssize_t
    i;

  size_t
    width,
    height,
    ntiles,
    ntile_rows,
    ntile_cols,
    tile_image_width,
    tile_image_height;

  /* start reading the data */
  exception=inDocInfo->exception;
  width=ReadBlobMSBLong(image);
  height=ReadBlobMSBLong(image);

  /* read in the first tile offset.
   *  if it is '0', then this tile level is empty
   *  and we can simply return.
   */
  offset=(MagickOffsetType) ReadBlobMSBLong(image);
  if (offset == 0)
    return(MagickTrue);
  /* Initialise the reference for the in-memory tile-compression
   */
  ntile_rows=(height+TILE_HEIGHT-1)/TILE_HEIGHT;
  ntile_cols=(width+TILE_WIDTH-1)/TILE_WIDTH;
  ntiles=ntile_rows*ntile_cols;
  for (i = 0; i < (ssize_t) ntiles; i++)
  {
    status=MagickFalse;
    if (offset == 0)
      ThrowBinaryException(CorruptImageError,"NotEnoughTiles",image->filename);
    /* save the current position as it is where the
     *  next tile offset is stored.
     */
    saved_pos=TellBlob(image);
    /* read in the offset of the next tile so we can calculate the amount
       of data needed for this tile*/
    offset2=(MagickOffsetType)ReadBlobMSBLong(image);
    /* if the offset is 0 then we need to read in the maximum possible
       allowing for negative compression */
    if (offset2 == 0)
      offset2=(MagickOffsetType) (offset + TILE_WIDTH * TILE_WIDTH * 4* 1.5);
    /* seek to the tile offset */
    offset=SeekBlob(image, offset, SEEK_SET);

      /* allocate the image for the tile
        NOTE: the last tile in a row or column may not be a full tile!
      */
      tile_image_width=(size_t) (destLeft == (int) ntile_cols-1 ?
        (int) width % TILE_WIDTH : TILE_WIDTH);
      if (tile_image_width == 0) tile_image_width=TILE_WIDTH;
      tile_image_height = (size_t) (destTop == (int) ntile_rows-1 ?
        (int) height % TILE_HEIGHT : TILE_HEIGHT);
      if (tile_image_height == 0) tile_image_height=TILE_HEIGHT;
      tile_image=CloneImage(inLayerInfo->image,tile_image_width,
        tile_image_height,MagickTrue,exception);

      /* read in the tile */
      switch (inDocInfo->compression)
      {
        case COMPRESS_NONE:
          if (load_tile(image,tile_image,inDocInfo,inLayerInfo,(size_t) (offset2-offset)) == 0)
            status=MagickTrue;
          break;
        case COMPRESS_RLE:
          if (load_tile_rle (image,tile_image,inDocInfo,inLayerInfo,
              (int) (offset2-offset)) == 0)
            status=MagickTrue;
          break;
        case COMPRESS_ZLIB:
          ThrowBinaryException(CoderError,"ZipCompressNotSupported",
            image->filename)
        case COMPRESS_FRACTAL:
          ThrowBinaryException(CoderError,"FractalCompressNotSupported",
            image->filename)
      }

      /* composite the tile onto the layer's image, and then destroy it */
      (void) CompositeImage(inLayerInfo->image,CopyCompositeOp,tile_image,
        destLeft * TILE_WIDTH,destTop*TILE_HEIGHT);
      tile_image=DestroyImage(tile_image);

      /* adjust tile position */
      destLeft++;
      if (destLeft >= (int) ntile_cols)
        {
          destLeft = 0;
          destTop++;
        }
      if (status != MagickFalse)
        return(MagickFalse);
      /* restore the saved position so we'll be ready to
       *  read the next offset.
       */
      offset=SeekBlob(image, saved_pos, SEEK_SET);
      /* read in the offset of the next tile */
      offset=(MagickOffsetType) ReadBlobMSBLong(image);
    }
  if (offset != 0)
    ThrowBinaryException(CorruptImageError,"CorruptImage",image->filename)
  return(MagickTrue);
}
Пример #4
0
void scene_buildings::init_gpu_stuff(const base::source_location &loc){
	assert(_prg == 0);

	char inject_buf[512];

	std::string cfg;

	cfg += "#version 430\n";

	sprintf(&inject_buf[0], "#define BLOCKS_PER_IDC %d\n", base::cfg().blocks_per_idc);
	cfg += inject_buf;

	_prg = base::create_program(
		base::create_and_compile_shader(
		SRC_LOCATION,
		cfg,
		"shaders/buildings_v_n.glsl",
		GL_VERTEX_SHADER),
		0,/*base::create_and_compile_shader(
		  SRC_LOCATION, "shaders/buildings_g.glsl", GL_GEOMETRY_SHADER),*/
		  base::create_and_compile_shader(
		  SRC_LOCATION,
		  cfg,
		  "shaders/buildings_f.glsl",
		  GL_FRAGMENT_SHADER));
	base::link_program(loc, _prg);

	_prg_tb_blocks = get_uniform_location(loc, _prg, "tb_blocks");
	_prg_tile_offset = get_uniform_location(loc, _prg, "tile_offset");
	_prg_mvp = get_uniform_location(loc, _prg, "mvp");
	_prg_total_count = get_uniform_location(loc, _prg, "total_count");

	load_tile(glm::ivec2(0, 0));
	/*load_tile(glm::ivec2(0, 1));
	load_tile(glm::ivec2(0, 2));
	load_tile(glm::ivec2(0, 3));
	load_tile(glm::ivec2(0, 4));
	load_tile(glm::ivec2(0, 5));
	load_tile(glm::ivec2(1, 0));
	load_tile(glm::ivec2(1, 1));
	load_tile(glm::ivec2(1, 2));
	load_tile(glm::ivec2(1, 3));
	load_tile(glm::ivec2(1, 4));
	load_tile(glm::ivec2(1, 5));
	load_tile(glm::ivec2(2, 0));
	load_tile(glm::ivec2(2, 1));
	load_tile(glm::ivec2(2, 2));
	load_tile(glm::ivec2(2, 3));
	load_tile(glm::ivec2(2, 4));
	load_tile(glm::ivec2(2, 5));
	load_tile(glm::ivec2(3, 0));
	load_tile(glm::ivec2(3, 1));
	load_tile(glm::ivec2(3, 2));
	load_tile(glm::ivec2(3, 3));
	load_tile(glm::ivec2(3, 4));
	load_tile(glm::ivec2(3, 5));
	load_tile(glm::ivec2(4, 0));
	load_tile(glm::ivec2(4, 1));
	load_tile(glm::ivec2(4, 2));
	load_tile(glm::ivec2(4, 3));
	load_tile(glm::ivec2(4, 4));
	load_tile(glm::ivec2(4, 5));
	load_tile(glm::ivec2(5, 0));
	load_tile(glm::ivec2(5, 1));
	load_tile(glm::ivec2(5, 2));
	load_tile(glm::ivec2(5, 3));
	load_tile(glm::ivec2(5, 4));
	load_tile(glm::ivec2(5, 5));*/
	//base::stats()._ntriangles = 25 * _tiles[0]._blocks_count * 10;

	const uint32 indices_base[][3] = { { 0, 1, 4 }, { 1, 5, 4 }, { 1, 2, 5 }, { 2, 6, 5 }, { 2, 3, 6 }, { 3, 7, 6 }, { 3, 0, 7 }, { 0, 4, 7 }, { 4, 5, 6 }, { 6, 7, 4 } };

	std::vector<uint32> indices;
	indices.resize(10 * 3 * base::cfg().blocks_per_idc);

	for (int b = 0; b < base::cfg().blocks_per_idc; b++){
		int offset = b * 8;
		for (int i = 0; i < 30; i++){
			indices[b * 30 + i] = (&indices_base[0][0])[i] + offset;
		}
	}

	_indices_vbo = base::create_buffer<uint32>(30 * base::cfg().blocks_per_idc, 0, indices.begin()._Ptr);
}
Пример #5
0
void DrawCredits()
{
	unsigned char end = 0;
	int counter = 0;

	redraw = 1;
	refresh = 1;
    while(!end)
    {   
		vsync();
		
        if(redraw)
        {
			ResetVideo();
			setupFont();
			
			SetFontColors(15, RGB(3, 3, 3), RGB(0, 6, 0), 0);
			SetFontColors(13, RGB(3, 3, 3), RGB(1, 6, 6), 0);

			set_xres(512, xres_flags);
			
#ifndef CDROM1			
			set_map_data(MB512_map, 64, 30);
			set_tile_data(MB512_bg);
			load_tile(0x1000);
			load_map(0, 0, 0, 0, 64, 30);
			load_palette(0, MB512_pal, 1);  
#else		
			set_screen_size(SCR_SIZE_64x32); 
			cd_loaddata(GPHX_OVERLAY, OFS_back512_PAL_bin, palCD, SIZE_back512_PAL_bin); 
			load_palette(0, palCD, 1);
			cd_loadvram(GPHX_OVERLAY, OFS_back512_DATA_bin, 0x1000, SIZE_back512_DATA_bin);			
			cd_loadvram(GPHX_OVERLAY, OFS_back512_BAT_bin, 0, SIZE_back512_BAT_bin);
#endif
			
			Center224in240();
			
            redraw = 0;
			refresh = 1;
			disp_on();
        }
		
		if(refresh)
		{
			RefreshCredits();

			refresh = 0;
		}
		
		set_font_pal(14);
		if(counter == 1)
			put_string("Artemio Urbina      ", HPOS+2, 8);
		if(counter == 60*4)
			put_string("@Artemio (twitter)  ", HPOS+2, 8);
		if(counter == 60*8)
			put_string("*****@*****.**", HPOS+2, 8);
		if(counter == 60*16)
			counter = 0;
			
		counter++;

        controller = joytrg(0);
        
		if (controller & JOY_II)
			end = 1;
			
		if (controller & JOY_SEL)
		{
			DrawN();
			redraw = 1;
		}
    }	
}
Пример #6
0
void
fill_tiles_pixel(	int pixel_x,
			int pixel_y,
			int zoom,
			gboolean force_refresh)
{
	GtkWidget *widget;
	int i,j, i_corrected, width, height, tile_x0, tile_y0, tiles_nx, tiles_ny;
	int max_pixel;
	int offset_xn = 0;
	int offset_yn = 0;
	int offset_x;
	int offset_y;
	repo_t *repo = global_curr_repo->data;
	
	
	if (!hash_table)
	{
		hash_table = g_hash_table_new_full (g_str_hash,
						    g_str_equal,
						    hash_destroy_key_func,
						    hash_destroy_value_func);
	}
	
	if(force_refresh)
	{
		g_hash_table_remove_all(hash_table);	
	}
	
	widget = lookup_widget(window1,"drawingarea1");
	

	
	max_pixel = (int) exp2(zoom) * TILESIZE; 

	if(pixel_x < 0)
		pixel_x += max_pixel;
	
	else if (pixel_x > max_pixel)
		pixel_x -= max_pixel;	

	
	offset_x = - pixel_x % TILESIZE;
	offset_y = - pixel_y % TILESIZE;
	if (offset_x > 0) offset_x -= 256;
	if (offset_y > 0) offset_y -= 256;
	
	global_x = pixel_x;
	global_y = pixel_y;
	global_zoom = zoom;
	
	offset_xn = offset_x; 
	offset_yn = offset_y;

	width  = map_drawable->allocation.width;
	height = map_drawable->allocation.height;

	tiles_nx = floor((width  - offset_x) / TILESIZE) + 1;
	tiles_ny = floor((height - offset_y) / TILESIZE) + 1;
	
	tile_x0 =  floor((float)pixel_x / (float)TILESIZE);
	tile_y0 =  floor((float)pixel_y / (float)TILESIZE);
	
	

	for (i=tile_x0; i<(tile_x0+tiles_nx); i++)
	{
		for (j=tile_y0;  j<(tile_y0+tiles_ny); j++)
		{
			
			

			
			if(j<0 || j>=exp2(zoom))
			{
				gdk_draw_rectangle (
					pixmap,
					widget->style->white_gc,
					TRUE,
					offset_xn, offset_yn,
					TILESIZE,
					TILESIZE);
				
				gtk_widget_queue_draw_area (
					widget, 
					offset_xn,offset_yn,
					TILESIZE,TILESIZE);
			}
			else
			{	
				i_corrected = (i>=exp2(zoom)) ? i-exp2(zoom) : i;
				
				load_tile(
					repo->dir,
					zoom,
					i_corrected,j,
					offset_xn,offset_yn);
			}
			offset_yn += TILESIZE;
		}
		offset_xn += TILESIZE;
		offset_yn = offset_y;
	}

	g_hash_table_foreach_remove (hash_table, hash_sieve_func, NULL);

	gconf_client_set_int(
			global_gconfclient,
			GCONF"/global_x",
			global_x,
			NULL);
	gconf_client_set_int(
			global_gconfclient,
			GCONF"/global_y",
			global_y,
			NULL);
	gconf_client_set_int(
			global_gconfclient,
			GCONF"/global_zoom",
			global_zoom,
			NULL);
}
Пример #7
0
void
view_tile(data_of_thread /*tile_threads* data*/ *local)
{
	gchar filename[256];

	local->x_glob=global_x;
	local->y_glob=global_y;//Чтобы отследить изменилось ли положение карты
	local->zoom=global_zoom;
	local->repo=global_curr_repo->data;
	number_threads = update_thread_number(1);
	printf("\n\n # of threads: %i \n\n", number_threads );

	if(!pixmap)
	{
		printf("no drawable -> NULL\n");
		return;
	}
	int mercator_x,mercator_y;	
//--------Yandex offset----------
	mercator_offset(local->zoom, local->x_glob, local->y_glob, &mercator_x, &mercator_y);
//--------Yandex offset----------

	printf("---repo dir: %s \n",g_strdup(local->repo->dir));

   	if (strcasestr(local->repo->name,"Yandex")!=NULL)
	{
		local->offset_x = - (mercator_x) % TILESIZE;
		local->offset_y = - (mercator_y) % TILESIZE;
		local->x =  floor((float)mercator_x / (float)TILESIZE) + local->i;
		local->y =  floor((float)mercator_y / (float)TILESIZE) + local->j;
	}
	else
	{
		local->offset_x = - global_x % TILESIZE;
		local->offset_y = - global_y % TILESIZE;
		local->x =  floor((float)(local->x_glob) / (float)TILESIZE) + local->i;
		local->y =  floor((float)(local->y_glob) / (float)TILESIZE) + local->j;
	}
	if (local->offset_x > 0) local->offset_x -= 256;
	if (local->offset_y > 0) local->offset_y -= 256;
	local->offset_x += TILESIZE*local->i;
	local->offset_y += TILESIZE*local->j;

//	if (load_tile(&local))
//	{
//number_threads = update_thread_number(-1);
//		return;
//	}
	load_tile(local);
/*
gdk_threads_enter();
	showed_tiles=g_slist_append(showed_tiles,filename);
gdk_threads_leave();
*/
	gchar* key;
	key = g_strdup_printf("%s/%d/%d/%d", local->repo->dir, local->zoom, local->x, local->y);
	g_hash_table_replace(ht,key,"MAP showing okay");

//----------Trafic visualization---------------
	if (global_trf_show)
	{
		printf("\n----------Trafic visualization---------------\n");
		printf("\n\nshow=%d ,auto=%d ,down=%d\n",global_trf_show,global_trf_auto,global_auto_download);

		if (strcasestr(curr_trf->name,"Yandex")!=NULL)
		{
			local->offset_x = - (mercator_x) % TILESIZE;
			local->offset_y = - (mercator_y) % TILESIZE;
			local->x =  floor((float)mercator_x / (float)TILESIZE) + local->i;
			local->y =  floor((float)mercator_y / (float)TILESIZE) + local->j;
		}
		else
		{
			local->offset_x = - local->x_glob % TILESIZE;
			local->offset_y = - local->y_glob % TILESIZE;
			local->x =  floor((float)(local->x_glob) / (float)TILESIZE) + local->i;
			local->y =  floor((float)(local->y_glob) / (float)TILESIZE) + local->j;
		}
		if (local->offset_x > 0) local->offset_x -= 256;
		if (local->offset_y > 0) local->offset_y -= 256;
		local->offset_x += TILESIZE*local->i;
		local->offset_y += TILESIZE*local->j;

		if (load_trf(local)==LOAD_OK)
		{
			load_tile(local);
			load_trf(local);
		}
//----------Trafic visualization---------------
	}

	if (number_threads==1)
	{
		printf ("load_tracks returned %d",load_tracks(local));
		printf ("load_tracks returned %d",load_current_track(local));
	}

//g_object_unref(data);
number_threads = update_thread_number(-1);
}
Пример #8
0
title(){
    psgPlay(2);
    cls();

    set_tile_data(title_tiles);
    load_tile(0x1000);
    load_palette(15,title_pal,1);
    for(i=0;i<16;i++){
        for(j=0;j<4;j++){
            put_tile(j*16+i,i,j+1);
        }
    }

    for(i=0;i<8;i++){
        set_color_rgb(241+i,0,7-i,0);
        set_color_rgb(248+i,i,7,i);
        if(248+7+i<256)set_color_rgb(248+7+i,7,i,7);
    }

    draw_win(1,21,30,6);
    put_string(" HI-SCORE       00         LV 0",0,1);
    put_number(hiscore,5,11,1);
    put_number(hilevel,1,30,1);
    put_string("PC Engine version by cabbage",2,22);
    put_string(" NEO Retro Coding Compo 2013",2,24);
    put_string("  http://www.neoflash.com/  ",2,25);
    put_string("PUSH RUN BUTTON !",8,15);

    foo=1;
    t=0;
    while(1){
        rs++;
        lastjoy0=joy0;
        vsync();
        joy0=joy(0);
        t++;
        if(t>30){
            if(foo==0){
                put_string("                 ",8,15);
                foo=1;
                t=0;
            }else{
                put_string("PUSH RUN BUTTON !",8,15);
                foo=0;
                t=0;
            }
        }

        if(joy0&JOY_STRT){
            break;
        }

        title_color_cycle();

    }

    while(joy0&JOY_STRT){
        vsync(); joy0=joy(0);
    }

    put_string("                 ",8,15);
    srand(rs);
    config();

}