Exemplo n.º 1
0
// technically, num is ignored in favor of finding the first
// available slot
void systemScreenCapture(int num)
{
	GameArea* panel = wxGetApp().frame->GetPanel();
	wxFileName fn = wxFileName(wxGetApp().frame->GetGamePath(gopts.scrshot_dir), wxEmptyString);

	do
	{
		wxString bfn;
		bfn.Printf(wxT("%s%02d"), panel->game_name().c_str(),
		           num++);

		if (captureFormat == 0)
			bfn.append(wxT(".png"));
		else // if(gopts.cap_format == 1)
			bfn.append(wxT(".bmp"));

		fn.SetFullName(bfn);
	}
	while (fn.FileExists());

	fn.Mkdir(0777, wxPATH_MKDIR_FULL);

	if (captureFormat == 0)
		panel->emusys->emuWritePNG(fn.GetFullPath().mb_fn_str());
	else // if(gopts.cap_format == 1)
		panel->emusys->emuWriteBMP(fn.GetFullPath().mb_fn_str());

	wxString msg;
	msg.Printf(_("Wrote snapshot %s"), fn.GetFullPath().c_str());
	systemScreenMessage(msg);
}
Exemplo n.º 2
0
void Game_Init()
{  
   g_hdcBuffer = CreateCompatibleDC(0);
   g_hbmBuffer = CreateCompatibleBitmap(g_hdcBuffer, 
                                        g_gameArea.GetEastWall(), 
                                        g_gameArea.GetSouthWall());
   SelectObject(g_hdcBuffer, g_hbmBuffer);
   if(!g_hbmBuffer){
      MessageBox(g_hwnd, "Buffer creation failed.", "Error", MB_OK | MB_ICONEXCLAMATION);
      exit(-1);
   }

   
   g_balls.TakeBall(new Ball(BallDefaults::RADIUS, 
                             BallDefaults::X, BallDefaults::Y, 
                             BallDefaults::SPEED, 
                             BallDefaults::VECTOR_X, BallDefaults::VECTOR_Y ));
   g_balls.TakeBall(new Ball(BallDefaults::RADIUS,
                             BallDefaults::X, BallDefaults::Y, 
                             BallDefaults::SPEED,
                             -1* BallDefaults::VECTOR_X, -1* BallDefaults::VECTOR_Y));

   // fill background   
   RECT rect;
   GetClientRect(g_hwnd, &rect);
   FillRect(g_hdcBuffer,&rect,(HBRUSH)GetStockObject(WHITE_BRUSH));
}
Exemplo n.º 3
0
void system10Frames(int rate)
{
	GameArea* panel = wxGetApp().frame->GetPanel();
	int fs = frameSkip;

	if (fs < 0)
	{
		// I don't know why this algorithm isn't in common somewhere
		// as is, I copied it from SDL
		static u32 prevclock = 0;
		static int speedadj = 0;
		u32 t = systemGetClock();

		if (!panel->was_paused && prevclock && (t - prevclock) != 10000 / rate)
		{
			int speed = t == prevclock ? 100 * 10000 / rate - (t - prevclock) : 100;

			// why 98??
			if (speed >= 98)
				speedadj++;
			else if (speed < 80)
				speedadj -= (90 - speed) / 5;
			else
				speedadj--;

			if (speedadj >= 3)
			{
				speedadj = 0;

				if (systemFrameSkip > 0)
					systemFrameSkip--;
			}
			else if (speedadj <= -2)
			{
				speedadj += 2;

				if (systemFrameSkip < 9)
					systemFrameSkip++;
			}
		}

		prevclock = t;
		panel->was_paused = false;
	}

	if (gopts.rewind_interval)
	{
		if (!panel->rewind_time)
			panel->rewind_time = gopts.rewind_interval * 6;
		else if (!--panel->rewind_time)
			panel->do_rewind = true;
	}

	if (--systemSaveUpdateCounter == SYSTEM_SAVE_NOT_UPDATED)
		panel->SaveBattery();
	else if (systemSaveUpdateCounter < SYSTEM_SAVE_NOT_UPDATED)
		systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
}
Exemplo n.º 4
0
void systemStartGamePlayback(const wxString& fname)
{
    GameArea* panel = wxGetApp().frame->GetPanel();

    if (!panel || panel->game_type() == IMAGE_UNKNOWN || !panel->emusys->emuReadState) {
        wxLogError(_("No game in progress to record"));
        return;
    }

    if (game_recording) {
        wxLogError(_("Cannot play game recording while recording"));
        return;
    }

    systemStopGamePlayback();
    wxString fn = fname;

    if (fn.size() < 4 || !wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".vmv"), false))
        fn.append(wxT(".vmv"));

    u32 version;

    if (!game_file.Open(fn.c_str(), wxT("rb")) || game_file.Read(&version, sizeof(version)) != sizeof(version) || wxUINT32_SWAP_ON_BE(version) != 1) {
        wxLogError(_("Cannot open recording file %s"), fname.c_str());
        return;
    }

    u32 gf, jp;

    if (game_file.Read(&gf, sizeof(gf)) != sizeof(gf) || game_file.Read(&jp, sizeof(jp)) != sizeof(jp)) {
        wxLogError(_("Error reading game recording"));
        game_file.Close();
        return;
    }

    game_next_frame = wxUINT32_SWAP_ON_BE(gf);
    game_next_joypad = wxUINT32_SWAP_ON_BE(jp);
    fn[fn.size() - 1] = wxT('0');

    if (!panel->emusys->emuReadState(fn.mb_fn_str())) {
        wxLogError(_("Error reading game recording"));
        game_file.Close();
        return;
    }

    game_frame = 0;
    game_joypad = 0;
    game_playback = true;
    MainFrame* mf = wxGetApp().frame;
    mf->cmd_enable &= ~(CMDEN_NGREC | CMDEN_GREC | CMDEN_NGPLAY);
    mf->cmd_enable |= CMDEN_GPLAY;
    mf->enable_menus();
}
Exemplo n.º 5
0
void systemDrawScreen()
{
	frames++;
	MainFrame* mf = wxGetApp().frame;
	mf->UpdateViewers();
	// FIXME: Sm60FPS crap and sondBufferLow crap
	GameArea* ga = mf->GetPanel();
#ifndef NO_FFMPEG

	if (ga)
		ga->AddFrame(pix);

#endif

	if (ga && ga->panel)
		ga->panel->DrawArea(&pix);
}
Exemplo n.º 6
0
void systemStartGameRecording(const wxString &fname)
{
	GameArea* panel = wxGetApp().frame->GetPanel();

	if (!panel || panel->game_type() == IMAGE_UNKNOWN ||
	        !panel->emusys->emuWriteState)
	{
		wxLogError(_("No game in progress to record"));
		return;
	}

	systemStopGamePlayback();
	wxString fn = fname;

	if (fn.size() < 4 || !wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".vmv"), false))
		fn.append(wxT(".vmv"));

	u32 version = 1;

	if (!game_file.Open(fn.c_str(), wxT("wb")) ||
	        game_file.Write(&version, sizeof(version)) != sizeof(version))
	{
		wxLogError(_("Cannot open output file %s"), fname.c_str());
		return;
	}

	fn[fn.size() - 1] = wxT('0');

	if (!panel->emusys->emuWriteState(fn.mb_fn_str()))
	{
		wxLogError(_("Error writing game recording"));
		game_file.Close();
		return;
	}

	game_frame = 0;
	game_joypad = 0;
	game_recording = true;
	MainFrame* mf = wxGetApp().frame;
	mf->cmd_enable &= ~(CMDEN_NGREC | CMDEN_GPLAY | CMDEN_NGPLAY);
	mf->cmd_enable |= CMDEN_GREC;
	mf->enable_menus();
}
Exemplo n.º 7
0
void Game_Main()
{
   HDC hdc = GetDC(g_hwnd);
   RECT rect;
   Ball* ball = NULL;
   static Archnoid::USHORT birthRate = 0;

   // white out the playing bounds
   GetClientRect(g_hwnd,&rect);
   FillRect(g_hdcBuffer,&rect,(HBRUSH)GetStockObject(WHITE_BRUSH));
   
   // draw the playing bounds
   SelectObject( g_hdcBuffer, GetStockObject( WHITE_BRUSH ) );
   Rectangle(g_hdcBuffer, g_gameArea.GetWestWall(), g_gameArea.GetNorthWall(), 
                          g_gameArea.GetEastWall(), g_gameArea.GetSouthWall());

   //g_blockCollection.RandomMoveAll();
   //g_blockCollection.RandomGravitateToCenterAll();
   // HAUKAP - which ball to gravitate to?
   g_blockCollection.RandomGravitateToPointAll( g_balls.GetFirstBall()->GetCntrX(), g_balls.GetFirstBall()->GetCntrY() );

   if( ++birthRate >= GamePlayDefaults::RESPAWN_RATE )
   {
      birthRate = 0;
      g_blockCollection.NewGenerations();
   }
   
   ball = g_balls.GetFirstBall();
   while( ball )
   {
      ball->Move();

      // did ball go out of bounds?
      CollisionType collision = g_gameArea.OutOfBounds(*ball);
      if( !collision )
      {
         // did ball collide with one of the blocks?
         collision = g_blockCollection.IsCollision(*ball);
      }

      if( collision )
      {
         ball->UnMove();
         if( VERTICAL_COLLISION(collision) )
            ball->ResolveCollision(Vertical);
         else if( HORIZONTAL_COLLISION(collision) )
            ball->ResolveCollision(Horizontal);
      }

      ball = g_balls.GetNextBall();
   }


      
   // draw the blocks   
   SelectObject( g_hdcBuffer, GetStockObject( LTGRAY_BRUSH ) );
   const Block* block = g_blockCollection.GetFirstBlock();
   while( block )
   {
      switch(BlockDefaults::SHAPE)
      {
      case ShapeCircle: 
         Ellipse(g_hdcBuffer, block->GetX(), block->GetY(),
                              block->GetX() + block->GetWidth(),
                              block->GetY() + block->GetHeight());
         break;
      case ShapeRect: 
         Rectangle(g_hdcBuffer,block->GetX(),block->GetY(),
                               block->GetX()+block->GetWidth(),
                               block->GetY()+block->GetHeight());
         break;
      default: assert(!"invalid shape");
      }
      block = g_blockCollection.GetNextBlock();
   }

   // draw the ball
   SelectObject( g_hdcBuffer, GetStockObject( BLACK_BRUSH ) );
   ball = g_balls.GetFirstBall();
   while( ball )
   {
      Ellipse( g_hdcBuffer, ball->GetULX(), ball->GetULY(),
                            ball->GetLRX(), ball->GetLRY());
      ball = g_balls.GetNextBall();
   }

   // draw debug/info text
   const char escMsg[] = "Hit any key to exit";
   TextOut(g_hdcBuffer,5,5,escMsg, (int)strlen(escMsg));


   char buf[256];
   std::string buf1( "Blocks: " );
   buf1 += _itoa_s( g_blockCollection.GetNumBlocks(), buf, 10);
   TextOut(g_hdcBuffer,5,20,buf1.c_str(), (int)buf1.size());

   Archnoid::USHORT y = 40;
   Archnoid::USHORT i = 1;
   ball = g_balls.GetFirstBall();
   while( ball )
   {
      sprintf_s( buf, "Ball[%d] [x:%d y:%d sp:%f vX:%f vY:%f]", i, 
               ball->GetCntrX(), ball->GetCntrY(),
               ball->GetSpeed(), ball->GetVectX(), ball->GetVectY() );
      TextOut(g_hdcBuffer, 5, y, buf, (int)strlen(buf) );

      ball = g_balls.GetNextBall();
      y += 15;
      ++i;
   }

   // copy the game area over to the main hdc
   BitBlt(hdc,0,0,g_gameArea.GetEastWall(),g_gameArea.GetSouthWall(),
          g_hdcBuffer,0,0,SRCCOPY);    

   ReleaseDC(g_hwnd,hdc);
   Sleep(GamePlayDefaults::SLEEPTIME);
}