n64: fix race bug introduced in previous revision. also turn display upside down
This commit is contained in:
parent
1abb7cf91a
commit
54ff07fbfc
|
@ -22,6 +22,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
public int[] frameBuffer = new int[800 * 600];
|
public int[] frameBuffer = new int[800 * 600];
|
||||||
public int[] GetVideoBuffer()
|
public int[] GetVideoBuffer()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
for (int row = 0; row < 600; row++)
|
for (int row = 0; row < 600; row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < 800; col++)
|
for (int col = 0; col < 800; col++)
|
||||||
|
@ -30,6 +31,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
frameBuffer[(599 - row) * 800 + col] = (m64p_FrameBuffer[(i * 3)] << 16) + (m64p_FrameBuffer[(i * 3) + 1] << 8) + (m64p_FrameBuffer[(i * 3) + 2]);
|
frameBuffer[(599 - row) * 800 + col] = (m64p_FrameBuffer[(i * 3)] << 16) + (m64p_FrameBuffer[(i * 3) + 1] << 8) + (m64p_FrameBuffer[(i * 3) + 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return frameBuffer;
|
return frameBuffer;
|
||||||
}
|
}
|
||||||
public int VirtualWidth { get { return 800; } }
|
public int VirtualWidth { get { return 800; } }
|
||||||
|
@ -301,7 +303,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
|
|
||||||
// Graphics plugin specific
|
// Graphics plugin specific
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate void ReadScreen2(byte[] framebuffer, ref int width, ref int height, int buffer);
|
private delegate void ReadScreen2(int[] framebuffer, ref int width, ref int height, int buffer);
|
||||||
ReadScreen2 GFXReadScreen2;
|
ReadScreen2 GFXReadScreen2;
|
||||||
|
|
||||||
// Audio plugin specific
|
// Audio plugin specific
|
||||||
|
@ -343,13 +345,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void FrameCallback();
|
public delegate void FrameCallback();
|
||||||
FrameCallback m64pFrameCallback;
|
FrameCallback m64pFrameCallback;
|
||||||
|
|
||||||
byte[] m64p_FrameBuffer = new byte[800 * 600 * 3];
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public delegate void StartupCallback();
|
||||||
|
|
||||||
|
//byte[] m64p_FrameBuffer = new byte[800 * 600 * 3];
|
||||||
public void Getm64pFrameBuffer()
|
public void Getm64pFrameBuffer()
|
||||||
{
|
{
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
GFXReadScreen2(m64p_FrameBuffer, ref width, ref height, 0);
|
//GFXReadScreen2(m64p_FrameBuffer, ref width, ref height, 0);
|
||||||
|
GFXReadScreen2(frameBuffer, ref width, ref height, 0);
|
||||||
//m64pFrameComplete = true;
|
//m64pFrameComplete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +398,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
|
|
||||||
AutoResetEvent m64pFrameComplete = new AutoResetEvent(false);
|
AutoResetEvent m64pFrameComplete = new AutoResetEvent(false);
|
||||||
|
|
||||||
|
ManualResetEvent m64pStartupComplete = new ManualResetEvent(false);
|
||||||
|
|
||||||
public N64(CoreComm comm, GameInfo game, byte[] rom)
|
public N64(CoreComm comm, GameInfo game, byte[] rom)
|
||||||
{
|
{
|
||||||
if (AttachedCore != null)
|
if (AttachedCore != null)
|
||||||
|
@ -496,6 +504,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
} while (state != (int)m64p_emu_state.M64EMU_PAUSED);
|
} while (state != (int)m64p_emu_state.M64EMU_PAUSED);
|
||||||
*/
|
*/
|
||||||
//m64pFrameComplete.WaitOne();
|
//m64pFrameComplete.WaitOne();
|
||||||
|
m64pStartupComplete.WaitOne();
|
||||||
|
|
||||||
// because of when we're doing this, we can't call this yet
|
// because of when we're doing this, we can't call this yet
|
||||||
m64pSamplingRate = 32000; // (uint)AudGetAudioRate();
|
m64pSamplingRate = 32000; // (uint)AudGetAudioRate();
|
||||||
|
@ -510,7 +519,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
public void ExecuteEmulator()
|
public void ExecuteEmulator()
|
||||||
{
|
{
|
||||||
emulator_running = true;
|
emulator_running = true;
|
||||||
m64pCoreDoCommandPtr(m64p_command.M64CMD_EXECUTE, 0, IntPtr.Zero);
|
m64pCoreDoCommandPtr(m64p_command.M64CMD_EXECUTE, 0,
|
||||||
|
Marshal.GetFunctionPointerForDelegate(new StartupCallback(() => m64pStartupComplete.Set())));
|
||||||
emulator_running = false;
|
emulator_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -211,7 +211,7 @@ EXPORT m64p_error CALL CoreDoCommand(m64p_command Command, int ParamInt, void *P
|
||||||
/* print out plugin-related warning messages */
|
/* print out plugin-related warning messages */
|
||||||
plugin_check();
|
plugin_check();
|
||||||
/* the main_run() function will not return until the player has quit the game */
|
/* the main_run() function will not return until the player has quit the game */
|
||||||
rval = main_run();
|
rval = main_run((void (*)(void))ParamPtr);
|
||||||
return rval;
|
return rval;
|
||||||
case M64CMD_STOP:
|
case M64CMD_STOP:
|
||||||
if (!g_EmulatorRunning)
|
if (!g_EmulatorRunning)
|
||||||
|
|
|
@ -722,7 +722,7 @@ void new_vi(void)
|
||||||
/*********************************************************************************************************
|
/*********************************************************************************************************
|
||||||
* emulation thread - runs the core
|
* emulation thread - runs the core
|
||||||
*/
|
*/
|
||||||
m64p_error main_run(void)
|
m64p_error main_run(void (*startcb)(void))
|
||||||
{
|
{
|
||||||
/* take the r4300 emulator mode from the config file at this point and cache it in a global variable */
|
/* take the r4300 emulator mode from the config file at this point and cache it in a global variable */
|
||||||
r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator");
|
r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator");
|
||||||
|
@ -790,7 +790,7 @@ m64p_error main_run(void)
|
||||||
/* call r4300 CPU core and run the game */
|
/* call r4300 CPU core and run the game */
|
||||||
r4300_reset_hard();
|
r4300_reset_hard();
|
||||||
r4300_reset_soft();
|
r4300_reset_soft();
|
||||||
r4300_execute();
|
r4300_execute(startcb);
|
||||||
|
|
||||||
/* now begin to shut down */
|
/* now begin to shut down */
|
||||||
#ifdef WITH_LIRC
|
#ifdef WITH_LIRC
|
||||||
|
|
|
@ -43,7 +43,7 @@ void new_vi(void);
|
||||||
int main_set_core_defaults(void);
|
int main_set_core_defaults(void);
|
||||||
void main_message(m64p_msg_level level, unsigned int osd_corner, const char *format, ...);
|
void main_message(m64p_msg_level level, unsigned int osd_corner, const char *format, ...);
|
||||||
|
|
||||||
m64p_error main_run(void);
|
m64p_error main_run(void (*startcb)(void));
|
||||||
void main_stop(void);
|
void main_stop(void);
|
||||||
void main_toggle_pause(void);
|
void main_toggle_pause(void);
|
||||||
void main_advance_one(void);
|
void main_advance_one(void);
|
||||||
|
|
|
@ -975,7 +975,7 @@ static void dynarec_setup_code(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void r4300_execute(void)
|
void r4300_execute(void (*startcb)(void))
|
||||||
{
|
{
|
||||||
#if defined(COUNT_INSTR) || (defined(DYNAREC) && defined(PROFILE_R4300))
|
#if defined(COUNT_INSTR) || (defined(DYNAREC) && defined(PROFILE_R4300))
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -999,6 +999,9 @@ void r4300_execute(void)
|
||||||
next_interupt = 624999;
|
next_interupt = 624999;
|
||||||
init_interupt();
|
init_interupt();
|
||||||
|
|
||||||
|
if (startcb)
|
||||||
|
startcb();
|
||||||
|
|
||||||
// now that everything has been set up, we stop here to wait for the first frame
|
// now that everything has been set up, we stop here to wait for the first frame
|
||||||
WaitForSingleObject(rompausesem, INFINITE);
|
WaitForSingleObject(rompausesem, INFINITE);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ void init_blocks(void);
|
||||||
void free_blocks(void);
|
void free_blocks(void);
|
||||||
void r4300_reset_hard(void);
|
void r4300_reset_hard(void);
|
||||||
void r4300_reset_soft(void);
|
void r4300_reset_soft(void);
|
||||||
void r4300_execute(void);
|
void r4300_execute(void (*startcb)(void));
|
||||||
void pure_interpreter(void);
|
void pure_interpreter(void);
|
||||||
void compare_core(void);
|
void compare_core(void);
|
||||||
void jump_to_func(void);
|
void jump_to_func(void);
|
||||||
|
|
|
@ -936,7 +936,7 @@ EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int bFront)
|
||||||
else
|
else
|
||||||
glReadBuffer( GL_BACK );
|
glReadBuffer( GL_BACK );
|
||||||
glReadPixels( 0, 0, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight,
|
glReadPixels( 0, 0, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight,
|
||||||
GL_RGB, GL_UNSIGNED_BYTE, dest );
|
GL_BGRA, GL_UNSIGNED_BYTE, dest );
|
||||||
glReadBuffer( oldMode );
|
glReadBuffer( oldMode );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue