Subversion Repositories psp

[/] [branches/] [smsplus_adhoc/] [psp/] [emumain.c] - Diff between revs 353 and 354

Show entire file | Details | Blame | View Log

Rev 353 Rev 354
Line 41... Line 41...
static inline int ParseInput();
static inline int ParseInput();
static inline void RenderVideo();
static inline void RenderVideo();
void AudioCallback(void* buf, unsigned int *length, void *userdata);
void AudioCallback(void* buf, unsigned int *length, void *userdata);
void MixerCallback(int16 **stream, int16 **output, int length);
void MixerCallback(int16 **stream, int16 **output, int length);
 
 
 
/* In ADHOC games, this will differ for client */
 
static EmulatorOptions ActiveOptions;
 
 
typedef struct
typedef struct
{
{
  uint32 Pad;
  uint32 Pad;
  uint32 System;
  uint32 System;
  uint8  Special;
  uint8  Special;
Line 90... Line 93...
 
 
void RunEmulator()
void RunEmulator()
{
{
  float ratio;
  float ratio;
 
 
 
  memcpy(&ActiveOptions, &Options, sizeof(Options));
 
 
 
  if (AdhocMode == ADHOC_HOST)
 
  {
 
    /* Send Options object */
 
    sceKernelDelayThread(1000000);
 
    pspAdhocSendWithAck(OpponentMAC, &ActiveOptions, sizeof(Options));
 
  }
 
  else if (AdhocMode == ADHOC_CLIENT)
 
  {
 
    /* Receive Options object */
 
    pspAdhocRecvWithAck(&ActiveOptions, sizeof(Options));
 
  }
 
 
 
  /* Set clock frequency during emulation */
 
  pspSetClockFrequency(ActiveOptions.ClockFreq);
 
 
  /* Reset viewport */
  /* Reset viewport */
  if (IS_GG)
  if (IS_GG)
  {
  {
    bitmap.viewport.x = Screen->Viewport.X = 48;
    bitmap.viewport.x = Screen->Viewport.X = 48;
    bitmap.viewport.y = Screen->Viewport.Y = 24;
    bitmap.viewport.y = Screen->Viewport.Y = 24;
Line 141... Line 161...
  /* Init performance counter */
  /* Init performance counter */
  pspPerfInitFps(&FpsCounter);
  pspPerfInitFps(&FpsCounter);
 
 
  /* Recompute update frequency */
  /* Recompute update frequency */
  TicksPerSecond = sceRtcGetTickResolution();
  TicksPerSecond = sceRtcGetTickResolution();
  if (Options.UpdateFreq)
  if (ActiveOptions.UpdateFreq)
  {
  {
    TicksPerUpdate = TicksPerSecond
    TicksPerUpdate = TicksPerSecond
      / (Options.UpdateFreq / (Options.Frameskip + 1));
      / (ActiveOptions.UpdateFreq / (ActiveOptions.Frameskip + 1));
    sceRtcGetCurrentTick(&LastTick);
    sceRtcGetCurrentTick(&LastTick);
  }
  }
  Frame = 0;
  Frame = 0;
  ClearScreen = 1;
  ClearScreen = 1;
  ControlSamplingCount = 0;
  ControlSamplingCount = 0;
Line 160... Line 180...
  pspAudioSetChannelCallback(0, AudioCallback, 0);
  pspAudioSetChannelCallback(0, AudioCallback, 0);
 
 
  /* Wait for V. refresh */
  /* Wait for V. refresh */
  pspVideoWaitVSync();
  pspVideoWaitVSync();
 
 
  if (AdhocMode == ADHOC_HOST)
 
  {
 
int foo = 0;
 
    sceKernelDelayThread(1000000);
 
    pspAdhocSendWithAck(OpponentMAC, &foo, sizeof(int));
 
  }
 
  else if (AdhocMode == ADHOC_CLIENT)
 
  {
 
int foo = 0;
 
    pspAdhocRecvWithAck(&foo, sizeof(int));
 
  }
 
 
 
  /* Main emulation loop */
  /* Main emulation loop */
  while (!ExitPSP)
  while (!ExitPSP)
  {
  {
    /* Check input */
    /* Check input */
    if (ParseInput()) break;
    if (ParseInput()) break;
 
 
    /* Run the system emulation for a frame */
    /* Run the system emulation for a frame */
    if (++Frame <= Options.Frameskip)
    if (++Frame <= ActiveOptions.Frameskip)
    {
    {
      /* Skip frame */
      /* Skip frame */
      system_frame(1);
      system_frame(1);
    }
    }
    else
    else
Line 373... Line 381...
  }
  }
 
 
  pspVideoEnd();
  pspVideoEnd();
 
 
  /* Wait if needed */
  /* Wait if needed */
  if (Options.UpdateFreq)// && AdhocMode != ADHOC_CLIENT)
  if (ActiveOptions.UpdateFreq)// && AdhocMode != ADHOC_CLIENT)
  {
  {
    do { sceRtcGetCurrentTick(&CurrentTick); }
    do { sceRtcGetCurrentTick(&CurrentTick); }
    while (CurrentTick - LastTick < TicksPerUpdate);
    while (CurrentTick - LastTick < TicksPerUpdate);
    LastTick = CurrentTick;
    LastTick = CurrentTick;
  }
  }
 
 
  /* Wait for VSync signal */
  /* Wait for VSync signal */
  if (Options.VSync) pspVideoWaitVSync();
  if (ActiveOptions.VSync)
 
    pspVideoWaitVSync();
 
 
  /* Swap buffers */
  /* Swap buffers */
  pspVideoSwapBuffers();
  pspVideoSwapBuffers();
}
}