Get rid of everything Minifen will handle for us

This commit is contained in:
twinaphex 2012-11-16 15:12:25 +01:00
parent 5ed02e99cb
commit 3ed64bae92
5 changed files with 65 additions and 241 deletions

View File

@ -186,6 +186,7 @@ endif
ifeq ($(NEED_THREADING), 1)
THREAD_STUBS += thread.cpp stubs_thread.cpp
FLAGS += -DWANT_THREADING
endif
ifeq ($(NEED_CRC32), 1)

View File

@ -1,7 +1,9 @@
#include "mednafen/mednafen-types.h"
#include "mednafen/mednafen.h"
#include "mednafen/git.h"
#include "mednafen/general.h"
#ifdef NEED_DEINTERLACER
#include "mednafen/video/Deinterlacer.h"
#endif
#include <iostream>
#include "libretro.h"
@ -13,6 +15,9 @@ static retro_environment_t environ_cb;
static retro_input_poll_t input_poll_cb;
static retro_input_state_t input_state_cb;
static double last_sound_rate;
static MDFN_PixelFormat last_pixel_format;
static MDFN_Surface *surf;
static bool failed_init;
@ -20,6 +25,11 @@ static bool failed_init;
std::string retro_base_directory;
std::string retro_base_name;
#ifdef NEED_DEINTERLACER
static bool PrevInterlaced;
static Deinterlacer deint;
#endif
#if defined(WANT_PSX_EMU)
#define MEDNAFEN_CORE_NAME_MODULE "psx"
#define MEDNAFEN_CORE_NAME "Mednafen PSX"
@ -120,7 +130,7 @@ void retro_init()
void retro_reset()
{
MDFN_DoSimpleCommand(MDFN_MSC_RESET);
game->DoSimpleCommand(MDFN_MSC_RESET);
}
bool retro_load_game_special(unsigned, const struct retro_game_info *, size_t)
@ -158,9 +168,15 @@ bool retro_load_game(const struct retro_game_info *info)
return false;
MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24);
memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat));
surf = new MDFN_Surface(mednafen_buf, FB_WIDTH, FB_HEIGHT, FB_WIDTH, pix_fmt);
#ifdef NEED_DEINTERLACER
PrevInterlaced = false;
deint.ClearState();
#endif
return game;
}
@ -297,7 +313,7 @@ static void update_input(void)
// Possible endian bug ...
for (unsigned i = 0; i < 5; i++)
MDFNI_SetInput(i, "gamepad", &input_buf[i][0], 0);
game->SetInput(i, "gamepad", &input_buf[i][0], 0);
#elif defined(WANT_WSWAN_EMU)
static uint16_t input_buf;
input_buf = 0;
@ -359,8 +375,47 @@ void retro_run()
spec.SoundBufMaxSize = sizeof(sound_buf) / 2;
spec.SoundVolume = 1.0;
spec.soundmultiplier = 1.0;
spec.SoundBufSize = 0;
spec.VideoFormatChanged = false;
spec.SoundFormatChanged = false;
MDFNI_Emulate(&spec);
if(memcmp(&last_pixel_format, &spec.surface->format, sizeof(MDFN_PixelFormat)))
{
spec.VideoFormatChanged = TRUE;
last_pixel_format = spec.surface->format;
}
if(spec.SoundRate != last_sound_rate)
{
spec.SoundFormatChanged = true;
last_sound_rate = spec.SoundRate;
}
MDFNGameInfo->Emulate(&spec);
#ifdef NEED_DEINTERLACER
if(spec.InterlaceOn)
{
if(!PrevInterlaced)
deint.ClearState();
deint.Process(spec.surface, spec.DisplayRect, spec.LineWidths, spec.InterlaceField);
PrevInterlaced = true;
spec.InterlaceOn = false;
spec.InterlaceField = 0;
}
else
PrevInterlaced = false;
#endif
int16 *const SoundBuf = spec.SoundBuf + spec.SoundBufSizeALMS * MDFNGameInfo->soundchan;
int32 SoundBufSize = spec.SoundBufSize - spec.SoundBufSizeALMS;
const int32 SoundBufMaxSize = spec.SoundBufMaxSize - spec.SoundBufSizeALMS;
spec.SoundBufSize = spec.SoundBufSizeALMS + SoundBufSize;
#if defined(WANT_PSX_EMU)
unsigned width = rects[0].w;

View File

@ -22,20 +22,7 @@ void MDFND_Message(const char *s);
uint32 MDFND_GetTime(void);
void MDFND_Sleep(uint32 ms);
// Synchronize virtual time to actual time using members of espec:
//
// MasterCycles and MasterCyclesALMS (coupled with MasterClock of MDFNGI)
// and/or
// SoundBuf, SoundBufSize, and SoundBufSizeALMS
//
// ...and after synchronization, update the data pointed to by the pointers passed to MDFNI_SetInput().
// DO NOT CALL MDFN_* or MDFNI_* functions from within MDFND_MidSync().
// Calling MDFN_printf(), MDFN_DispMessage(),and MDFND_PrintError() are ok, though.
//
// If you do not understand how to implement this function, you can leave it empty at first, but know that doing so
// will subtly break at least one PC Engine game(Takeda Shingen), and raise input latency on some other PC Engine games.
void MDFND_MidSync(const EmulateSpecStruct *espec);
#ifdef WANT_THREADING
/* Being threading support. */
// Mostly based off SDL's prototypes and semantics.
// Driver code should actually define MDFN_Thread and MDFN_Mutex.
@ -53,9 +40,7 @@ int MDFND_LockMutex(MDFN_Mutex *mutex);
int MDFND_UnlockMutex(MDFN_Mutex *mutex);
/* End threading support. */
void MDFNI_Reset(void);
void MDFNI_Power(void);
#endif
/* path = path of game/file to load. returns NULL on failure. */
MDFNGI *MDFNI_LoadGame(const char *force_module, const char *path);
@ -73,15 +58,9 @@ int MDFNI_Initialize(const char *basedir);
below this directory. */
void MDFNI_SetBaseDirectory(const char *dir);
/* Emulates a frame. */
void MDFNI_Emulate(EmulateSpecStruct *espec);
/* Closes currently loaded game */
void MDFNI_CloseGame(void);
/* Deallocates all allocated memory. Call after MDFNI_Emulate() returns. */
void MDFNI_Kill(void);
void MDFN_DispMessage(const char *format, ...);
#define MDFNI_DispMessage MDFN_DispMessage
@ -90,29 +69,6 @@ uint32 MDFNI_CRC32(uint32 crc, uint8 *buf, uint32 len);
// NES hackish function. Should abstract in the future.
int MDFNI_DatachSet(const uint8 *rcode);
void MDFNI_DoRewind(void);
void MDFNI_SetLayerEnableMask(uint64 mask);
void MDFNI_SetInput(int port, const char *type, void *ptr, uint32 dsize);
//int MDFNI_DiskInsert(int oride);
//int MDFNI_DiskEject(void);
//int MDFNI_DiskSelect(void);
// Arcade-support functions
// We really need to reexamine how we should abstract this, considering the initial state of the DIP switches,
// and moving the DIP switch drawing code to the driver side.
void MDFNI_ToggleDIP(int which);
void MDFNI_InsertCoin(void);
void MDFNI_ToggleDIPView(void);
// Disk/Disc-based system support functions
void MDFNI_DiskSelect(int which);
void MDFNI_DiskSelect();
void MDFNI_DiskInsert();
void MDFNI_DiskEject();
void MDFNI_DumpModulesDef(const char *fn);

View File

@ -28,9 +28,6 @@
#include "state.h"
#include "video.h"
#ifdef NEED_DEINTERLACER
#include "video/Deinterlacer.h"
#endif
#include "file.h"
#include "FileWrapper.h"
@ -49,14 +46,6 @@
MDFNGI *MDFNGameInfo = NULL;
static MDFN_PixelFormat last_pixel_format;
static double last_sound_rate;
#ifdef NEED_DEINTERLACER
static bool PrevInterlaced;
static Deinterlacer deint;
#endif
#ifdef NEED_CD
static std::vector<CDIF *> CDInterfaces; // FIXME: Cleanup on error out.
#endif
@ -335,7 +324,7 @@ MDFNGI *MDFNI_LoadCD(const char *force_module, const char *devicename)
return(0);
}
MDFNI_SetLayerEnableMask(~0ULL);
//MDFNI_SetLayerEnableMask(~0ULL);
#ifdef WANT_DEBUGGER
MDFNDBG_PostGameLoad();
@ -346,9 +335,6 @@ MDFNGI *MDFNI_LoadCD(const char *force_module, const char *devicename)
MDFN_LoadGameCheats(NULL);
MDFNMP_InstallReadPatches();
last_sound_rate = -1;
memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat));
return(MDFNGameInfo);
}
#endif
@ -499,7 +485,7 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
MDFN_LoadGameCheats(NULL);
MDFNMP_InstallReadPatches();
MDFNI_SetLayerEnableMask(~0ULL);
//MDFNI_SetLayerEnableMask(~0ULL);
#ifdef WANT_DEBUGGER
MDFNDBG_PostGameLoad();
@ -525,15 +511,8 @@ MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
*tmp = 0;
}
#ifdef NEED_DEINTERLACER
PrevInterlaced = false;
deint.ClearState();
#endif
last_sound_rate = -1;
memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat));
return(MDFNGameInfo);
return(MDFNGameInfo);
}
#if defined(WANT_PSX_EMU)
@ -641,82 +620,6 @@ int MDFNI_Initialize(const char *basedir)
return(1);
}
void MDFNI_Kill(void)
{
/* save settings */
}
static inline void ProcessAudio(EmulateSpecStruct *espec)
{
int16 *const SoundBuf = espec->SoundBuf + espec->SoundBufSizeALMS * MDFNGameInfo->soundchan;
int32 SoundBufSize = espec->SoundBufSize - espec->SoundBufSizeALMS;
const int32 SoundBufMaxSize = espec->SoundBufMaxSize - espec->SoundBufSizeALMS;
espec->SoundBufSize = espec->SoundBufSizeALMS + SoundBufSize;
}
void MDFN_MidSync(EmulateSpecStruct *espec)
{
ProcessAudio(espec);
MDFND_MidSync(espec);
espec->SoundBufSizeALMS = espec->SoundBufSize;
espec->MasterCyclesALMS = espec->MasterCycles;
}
void MDFNI_Emulate(EmulateSpecStruct *espec)
{
// Initialize some espec member data to zero, to catch some types of bugs.
espec->DisplayRect.x = 0;
espec->DisplayRect.w = 0;
espec->DisplayRect.y = 0;
espec->DisplayRect.h = 0;
assert((bool)(espec->SoundBuf != NULL) == (bool)espec->SoundRate && (bool)espec->SoundRate == (bool)espec->SoundBufMaxSize);
espec->SoundBufSize = 0;
espec->VideoFormatChanged = false;
espec->SoundFormatChanged = false;
if(memcmp(&last_pixel_format, &espec->surface->format, sizeof(MDFN_PixelFormat)))
{
espec->VideoFormatChanged = TRUE;
last_pixel_format = espec->surface->format;
}
if(espec->SoundRate != last_sound_rate)
{
espec->SoundFormatChanged = true;
last_sound_rate = espec->SoundRate;
}
espec->NeedSoundReverse = false;
MDFNGameInfo->Emulate(espec);
#ifdef NEED_DEINTERLACER
if(espec->InterlaceOn)
{
if(!PrevInterlaced)
deint.ClearState();
deint.Process(espec->surface, espec->DisplayRect, espec->LineWidths, espec->InterlaceField);
PrevInterlaced = true;
espec->InterlaceOn = false;
espec->InterlaceField = 0;
}
else
PrevInterlaced = false;
#endif
ProcessAudio(espec);
}
// This function should only be called for state rewinding.
// FIXME: Add a macro for SFORMAT structure access instead of direct access
int MDFN_RawInputStateAction(StateMem *sm, int load, int data_only)
@ -832,90 +735,3 @@ void MDFN_DebugPrintReal(const char *file, const int line, const char *format, .
va_end(ap);
}
void MDFN_DoSimpleCommand(int cmd)
{
MDFNGameInfo->DoSimpleCommand(cmd);
}
void MDFN_QSimpleCommand(int cmd)
{
}
void MDFNI_Power(void)
{
assert(MDFNGameInfo);
MDFN_QSimpleCommand(MDFN_MSC_POWER);
}
void MDFNI_Reset(void)
{
assert(MDFNGameInfo);
MDFN_QSimpleCommand(MDFN_MSC_RESET);
}
// Arcade-support functions
void MDFNI_ToggleDIPView(void)
{
}
void MDFNI_ToggleDIP(int which)
{
assert(MDFNGameInfo);
assert(which >= 0);
MDFN_QSimpleCommand(MDFN_MSC_TOGGLE_DIP0 + which);
}
void MDFNI_InsertCoin(void)
{
assert(MDFNGameInfo);
MDFN_QSimpleCommand(MDFN_MSC_INSERT_COIN);
}
// Disk/Disc-based system support functions
void MDFNI_DiskInsert(int which)
{
assert(MDFNGameInfo);
MDFN_QSimpleCommand(MDFN_MSC_INSERT_DISK0 + which);
}
void MDFNI_DiskSelect()
{
assert(MDFNGameInfo);
MDFN_QSimpleCommand(MDFN_MSC_SELECT_DISK);
}
void MDFNI_DiskInsert()
{
assert(MDFNGameInfo);
MDFN_QSimpleCommand(MDFN_MSC_INSERT_DISK);
}
void MDFNI_DiskEject()
{
assert(MDFNGameInfo);
MDFN_QSimpleCommand(MDFN_MSC_EJECT_DISK);
}
void MDFNI_SetLayerEnableMask(uint64 mask)
{
if(MDFNGameInfo && MDFNGameInfo->SetLayerEnableMask)
{
MDFNGameInfo->SetLayerEnableMask(mask);
}
}
void MDFNI_SetInput(int port, const char *type, void *ptr, uint32 ptr_len_thingy)
{
MDFNGameInfo->SetInput(port, type, ptr);
}

View File

@ -26,10 +26,6 @@ void MDFN_DebugPrintReal(const char *file, const int line, const char *format, .
void MDFN_LoadGameCheats(FILE *override);
void MDFN_FlushGameCheats(int nosave);
void MDFN_DoSimpleCommand(int cmd);
void MDFN_QSimpleCommand(int cmd);
void MDFN_MidSync(EmulateSpecStruct *espec);
#include "state.h"
int MDFN_RawInputStateAction(StateMem *sm, int load, int data_only);