Exemplo n.º 1
0
void Outrun::tick(Packet* packet, bool tick_frame)
{
    this->tick_frame = tick_frame;
    
    if (cannonball::tick_frame)
        tick_counter++;

    if (game_state >= GS_START1 && game_state <= GS_INGAME)
    {
        if (input.has_pressed(Input::VIEWPOINT))
        {
            int mode = oroad.get_view_mode() + 1;
            if (mode > ORoad::VIEW_INCAR)
                mode = ORoad::VIEW_ORIGINAL;

            oroad.set_view_mode(mode);
        }
    }

    // Only tick the road cpu twice for every time we tick the main cpu
    // The timing here isn't perfect, as normally the road CPU would run in parallel with the main CPU.
    // We can potentially hack this by calling the road CPU twice.
    // Most noticeable with clipping sprites on hills.
      
    // 30 FPS 
    // Updates Game Logic 1/2 frames
    // Updates V-Blank 1/2 frames
    if (config.fps == 30 && config.tick_fps == 30)
    {
        jump_table(packet);
        oroad.tick();
        vint();
        vint();
    }
    // 30/60 FPS Hybrid. (This is the same as the original game)
    // Updates Game Logic 1/2 frames
    // Updates V-Blank 1/1 frames
    else if (config.fps == 60 && config.tick_fps == 30)
    {
        if (cannonball::tick_frame)
        {
            jump_table(packet);
            oroad.tick();
        }
        vint();
    }
    // 60 FPS. Smooth Mode. 
    // Updates Game Logic 1/1 frames
    // Updates V-Blank 1/1 frames
    else
    {
        jump_table(packet);
        oroad.tick();
        vint();
    }

    // Draw FPS
    if (config.video.fps_count)
        ohud.draw_fps_counter(cannonball::fps_counter);
}
Exemplo n.º 2
0
void Outrun::tick(bool tick_frame)
{
    this->tick_frame = tick_frame;

    /*if (input.has_pressed(Input::LEFT))
    {
        game_state = GS_INIT_BONUS;
        oroad.road_width = 0x90;
        ostats.time_counter = 2;
        oroad.stage_lookup_off = 0x23;
        oinitengine.route_selected = -1;
        oinitengine.init_bonus();
    }*/

    if (cannonball::tick_frame)
    {
        tick_counter++;       
        controls();      // Analogue Controls
    }
    oinputs.do_gear();   // Digital Gear

    // Only tick the road cpu twice for every time we tick the main cpu
    // The timing here isn't perfect, as normally the road CPU would run in parallel with the main CPU.
    // We can potentially hack this by calling the road CPU twice.
    // Most noticeable with clipping sprites on hills.
      
    // 30 FPS 
    // Updates Game Logic 1/2 frames
    // Updates V-Blank 1/2 frames
    if (config.fps == 30 && config.tick_fps == 30)
    {
        jump_table();
        oroad.tick();
        vint();
        vint();
    }
    // 30/60 FPS Hybrid. (This is the same as the original game)
    // Updates Game Logic 1/2 frames
    // Updates V-Blank 1/1 frames
    else if (config.fps == 60 && config.tick_fps == 30)
    {
        if (cannonball::tick_frame)
        {
            jump_table();
            oroad.tick();
        }
        vint();
    }
    // 60 FPS. Smooth Mode. 
    // Updates Game Logic 1/1 frames
    // Updates V-Blank 1/1 frames
    else
    {
        jump_table();
        oroad.tick();
        vint();
    }
}
Exemplo n.º 3
0
int main(int argc, char* argv[]) {
	signal(SIGTERM, terminar);
	srand(time(NULL));
	forn(i, argc) {
		if(strcmp(argv[i], "--help") == 0) do_help(argv[0]);
		else if(strcmp(argv[i], "--profiling") == 0 || strcmp(argv[i], "-p") == 0) profiling = true;
		else if(strcmp(argv[i], "--alphabeta") == 0 || strcmp(argv[i], "-ab") == 0) alphabeta = true;
		else if(strcmp(argv[i], "--height") == 0 && argc > i+1) height = atoi(argv[i+1]);
		else if(strcmp(argv[i], "--funcion") == 0 && argc > i+1) funcion = atoi(argv[i+1]);
		else if(strcmp(argv[i], "--adaptive") == 0 && argc > i+2) do_adaptive(argv, i);
		else if(strcmp(argv[i], "--params") == 0) fill_player(def_player, argv, i, argc);
	}
       /* Si c==1, arrancamos leyendo una jugada del otro */
	int c;
	cin >> n >> c;
	if(adaptive) {
		nx = (int) pow((float) n, x);	
		adaptive_info();
	}
	tablero.resize(n, vint(n, VACIO));
	if(profiling) ENABLE_PROFILING(n)
	else DISABLE_PROFILING()
	if(height <= 0) height = n*n/2+1;
	if (n>1 && c) lee_movida();
	while (hay_movida()) {	
		juega_movida();
		// Si no hay movida para hacer se cuelga leyendo, pero el judge nos mata el proceso con SIGTERM
		lee_movida();
	}
	return 0;
}
Exemplo n.º 4
0
	void VScrollTemplate::OnHandleMouseUp(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiMouseEventArgs& arguments)
	{
		if (draggingHandle)
		{
			vint totalPixels = handle->GetParent()->GetBounds().Height();
			vint currentOffset = handle->GetBounds().Top();
			vint newOffset = currentOffset + (arguments.y - draggingStartLocation.y);
			vint totalSize = GetTotalSize();
			double ratio = (double)newOffset / totalPixels;
			vint newPosition = (vint)(ratio * totalSize);

			vint offset1 = (vint)(((double)newPosition / totalSize) * totalPixels);
			vint offset2 = vint(((double)(newPosition + 1) / totalSize) * totalPixels);
			vint delta1 = abs((int)(offset1 - newOffset));
			vint delta2 = abs((int)(offset2 - newOffset));

			if(delta1 < delta2)
			{
				GetCommands()->SetPosition(newPosition);
			}
			else
			{
				GetCommands()->SetPosition(newPosition + 1);
			}
		}
	}
Exemplo n.º 5
0
void SearchDirectoriesAndFiles(const WString& path, List<WString>& directories, List<WString>& files)
{
	// Use FindFirstFile, FindNextFile and FindClose to enumerate all directories and files
	WIN32_FIND_DATA findData;
	HANDLE findHandle=INVALID_HANDLE_VALUE;

	while(true)
	{
		if(findHandle==INVALID_HANDLE_VALUE)
		{
			WString searchPath=path+L"\\*";
			findHandle=FindFirstFile(searchPath.Buffer(), &findData);
			if(findHandle==INVALID_HANDLE_VALUE)
			{
				break;
			}
		}
		else
		{
			BOOL result=FindNextFile(findHandle, &findData);
			if(result==0)
			{
				FindClose(findHandle);
				break;
			}
		}

		if(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			if(wcscmp(findData.cFileName, L".")!=0 && wcscmp(findData.cFileName, L"..")!=0)
			{
				directories.Add(findData.cFileName);
			}
		}
		else
		{
			files.Add(findData.cFileName);
		}
	}

	Func<vint(WString a, WString b)> comparer=[](WString a, WString b){return _wcsicmp(a.Buffer(), b.Buffer());};
	CopyFrom(directories, From(directories).OrderBy(comparer));
	CopyFrom(files, From(files).OrderBy(comparer));
}
Exemplo n.º 6
0
int main(int argc, char ** argv)
{
  try 
  {
    if (argc < 4)
    {
      std::cerr << argv[0] << " needs 3 arguments: [nb thread] [vector size] [test_vector|test_tabc]" << std::endl; 
      return EXIT_FAILURE;
    }

    boost::uint64_t nbProc = boost::lexical_cast<boost::uint64_t>(argv[1]);
    boost::uint64_t size = boost::lexical_cast<boost::uint64_t>(argv[2]);

    if (strcmp(argv[3], "test_vector") == 0) // Test 1
    {
      std::cout << size << std::endl;
      vint_t vint(size);

      //
      // fill
      {
        std::cout << "fill vector" << std::endl;
        boost::timer::auto_cpu_timer t; // timer from now
        for (boost::uint64_t i = 0; i < size; i++)
        {
          vint[i] = i;
        }
      }

      std::cout << "================" << std::endl;

      //
      // execute
      {
        std::cout << "process vector with " << nbProc << " threads" << std::endl;
        boost::timer::auto_cpu_timer t; // timer from now
        ParallelProcess<boost::uint64_t>(vint, function1, nbProc);
      }
    }
    else if (strcmp(argv[3], "test_tabc") == 0) // Test 2
    {
      std::cout << "================" << std::endl;
      std::cout << "================" << std::endl;
      std::cout << size << std::endl;
      boost::uint64_t * vint = new boost::uint64_t[size];

      //
      // fill
      {
        std::cout << "fill vector" << std::endl;
        boost::timer::auto_cpu_timer t; // timer from now
        for (boost::uint64_t i = 0; i < size; i++)
        {
          vint[i] = i;
        }
      }
			
      std::cout << "================" << std::endl;

      //
      // execute
      {
        std::cout << "process tabc with " << nbProc << " threads" << std::endl;
        boost::timer::auto_cpu_timer t; // timer from now
        ParallelProcess<boost::uint64_t>(vint, size, function1, nbProc);
      }
    }
    else
    {
      std::cerr << "no test available" << std::endl;
      return EXIT_FAILURE;
    }
  }
  catch (const std::exception& ex)
  {
    std::cerr << ex.what() << std::endl;
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}