Skip to content

Commit

Permalink
3rdParty: update mupen64plus-core
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Nov 3, 2024
1 parent 37839b0 commit 4cd4f4c
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 166 deletions.
4 changes: 2 additions & 2 deletions Source/3rdParty/mupen64plus-core/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:mupen64plus/mupen64plus-core.git
branch = master
commit = 312a5befde1b44db8beee7868b929c23d896991f
parent = 6e2d29dc603cb221b7409d2cca646f329073dd03
commit = e170c409fb006aa38fd02031b5eefab6886ec125
parent = 37839b0178b42b57a38a040bbf4e1f410e6952a1
method = merge
cmdver = 0.4.6
2 changes: 1 addition & 1 deletion Source/3rdParty/mupen64plus-core/README
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ README Sections

*Binary Package Requirements*

- SDL 1.2 or 2.0
- SDL 2
- libpng
- freetype 2
- zlib
Expand Down
2 changes: 1 addition & 1 deletion Source/3rdParty/mupen64plus-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ as well as a user interface program (called a front-end).

**Binary Package Requirements**

- SDL 1.2 or 2.0
- SDL 2
- libpng
- freetype 2
- zlib
Expand Down
30 changes: 11 additions & 19 deletions Source/3rdParty/mupen64plus-core/projects/unix/Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ SUBDIR = ../../subprojects
# base CFLAGS, LDLIBS, and LDFLAGS
OPTFLAGS ?= -O3 -flto
WARNFLAGS ?= -Wall
CFLAGS += -fno-strict-aliasing -fvisibility=hidden -I$(SRCDIR) -I$(SRCDIR)/asm_defines -DM64P_PARALLEL
CFLAGS += -fvisibility=hidden -I$(SRCDIR) -I$(SRCDIR)/asm_defines -DM64P_PARALLEL
CXXFLAGS += -fvisibility-inlines-hidden
LDLIBS += -lm

Expand Down Expand Up @@ -351,26 +351,18 @@ endif

# test for presence of SDL
ifeq ($(origin SDL_CFLAGS) $(origin SDL_LDLIBS), undefined undefined)
SDL_CONFIG = $(CROSS_COMPILE)sdl2-config
ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
SDL_CONFIG = $(CROSS_COMPILE)sdl-config
ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
$(error No SDL development libraries found!)
else
ifeq ($(NETPLAY), 1)
SDL_LDLIBS += -lSDL_net
endif
# SDL1 doesn't support vulkan
VULKAN = 0
$(warning Using SDL 1.2 libraries)
endif
else
ifeq ($(NETPLAY), 1)
SDL_LDLIBS += -lSDL2_net
ifeq ($(shell $(PKG_CONFIG) --modversion sdl2 2>/dev/null),)
$(error No SDL2 development libraries found!)
endif
ifeq ($(NETPLAY), 1)
ifeq ($(shell $(PKG_CONFIG) --modversion SDL2_net 2>/dev/null),)
$(error No SDL2_net development libraries found!)
endif
SDL_CFLAGS += $(shell $(PKG_CONFIG) --cflags SDL2_net)
SDL_LDLIBS += $(shell $(PKG_CONFIG) --libs SDL2_net)
endif
SDL_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
SDL_LDLIBS += $(shell $(SDL_CONFIG) --libs)
SDL_CFLAGS += $(shell $(PKG_CONFIG) --cflags sdl2)
SDL_LDLIBS += $(shell $(PKG_CONFIG) --libs sdl2)
endif
CFLAGS += $(SDL_CFLAGS)
LDLIBS += $(SDL_LDLIBS)
Expand Down
36 changes: 4 additions & 32 deletions Source/3rdParty/mupen64plus-core/src/api/vidext.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@
#include "m64p_vidext.h"
#include "vidext.h"

#if SDL_VERSION_ATLEAST(2,0,0)
#ifndef USE_GLES
static int l_ForceCompatibilityContext = 1;
#endif
#include "vidext_sdl2_compat.h"
#ifndef USE_GLES
static int l_ForceCompatibilityContext = 1;
#endif

#include "vidext_sdl2_compat.h"

/* local variables */
static m64p_video_extension_functions l_ExternalVideoFuncTable = {17, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
static int l_VideoExtensionActive = 0;
Expand Down Expand Up @@ -134,13 +133,11 @@ EXPORT m64p_error CALL VidExt_InitWithRenderMode(m64p_render_mode RenderMode)
l_RenderMode = RenderMode;
#endif

#if SDL_VERSION_ATLEAST(2,0,0)
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
/* retrieve default swap interval/VSync */
if (RenderMode == M64P_RENDER_OPENGL) {
l_SwapControl = SDL_GL_GetSwapInterval();
}
#endif

#if SDL_VERSION_ATLEAST(2,24,0)
/* fix DPI scaling issues on Windows */
Expand Down Expand Up @@ -188,9 +185,7 @@ EXPORT m64p_error CALL VidExt_Quit(void)
return M64ERR_NOT_INIT;

SDL_ShowCursor(SDL_ENABLE);
#if SDL_VERSION_ATLEAST(2,0,0)
SDL2_DestroyWindow();
#endif
#ifdef VIDEXT_VULKAN
if (l_RenderMode == M64P_RENDER_VULKAN) {
SDL_Vulkan_UnloadLibrary();
Expand Down Expand Up @@ -264,7 +259,6 @@ EXPORT m64p_error CALL VidExt_ListFullscreenRates(m64p_2d_size Size, int *NumRat
if (l_VideoExtensionActive)
return (*l_ExternalVideoFuncTable.VidExtFuncListRates)(Size, NumRates, Rates);

#if SDL_VERSION_ATLEAST(2,0,0)
if (!SDL_WasInit(SDL_INIT_VIDEO))
return M64ERR_NOT_INIT;

Expand Down Expand Up @@ -299,10 +293,6 @@ EXPORT m64p_error CALL VidExt_ListFullscreenRates(m64p_2d_size Size, int *NumRat
*NumRates = rateCount;

return M64ERR_SUCCESS;
#else
// SDL1 doesn't support getting refresh rates
return M64ERR_UNSUPPORTED;
#endif
}

EXPORT m64p_error CALL VidExt_SetVideoMode(int Width, int Height, int BitsPerPixel, m64p_video_mode ScreenMode, m64p_video_flags Flags)
Expand Down Expand Up @@ -377,14 +367,12 @@ EXPORT m64p_error CALL VidExt_SetVideoMode(int Width, int Height, int BitsPerPix

SDL_ShowCursor(SDL_DISABLE);

#if SDL_VERSION_ATLEAST(2,0,0)
/* set swap interval/VSync */
if (l_RenderMode == M64P_RENDER_OPENGL &&
SDL_GL_SetSwapInterval(l_SwapControl) != 0)
{
DebugMessage(M64MSG_ERROR, "SDL swap interval (VSync) set failed: %s", SDL_GetError());
}
#endif

l_Fullscreen = (ScreenMode == M64VIDEO_FULLSCREEN);
l_VideoOutputActive = 1;
Expand All @@ -409,7 +397,6 @@ EXPORT m64p_error CALL VidExt_SetVideoModeWithRate(int Width, int Height, int Re
return rval;
}

#if SDL_VERSION_ATLEAST(2,0,0)
if (!SDL_WasInit(SDL_INIT_VIDEO) || !SDL_VideoWindow)
return M64ERR_NOT_INIT;

Expand Down Expand Up @@ -486,10 +473,6 @@ EXPORT m64p_error CALL VidExt_SetVideoModeWithRate(int Width, int Height, int Re
StateChanged(M64CORE_VIDEO_SIZE, (Width << 16) | Height);

return M64ERR_SUCCESS;
#else
// SDL1 doesn't support setting refresh rates
return M64ERR_UNSUPPORTED;
#endif
}

EXPORT m64p_error CALL VidExt_ResizeWindow(int Width, int Height)
Expand Down Expand Up @@ -643,16 +626,11 @@ static const GLAttrMapNode GLAttrMap[] = {
{ M64P_GL_GREEN_SIZE, SDL_GL_GREEN_SIZE },
{ M64P_GL_BLUE_SIZE, SDL_GL_BLUE_SIZE },
{ M64P_GL_ALPHA_SIZE, SDL_GL_ALPHA_SIZE },
#if !SDL_VERSION_ATLEAST(1,3,0)
{ M64P_GL_SWAP_CONTROL, SDL_GL_SWAP_CONTROL },
#endif
{ M64P_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLEBUFFERS },
{ M64P_GL_MULTISAMPLESAMPLES, SDL_GL_MULTISAMPLESAMPLES }
#if SDL_VERSION_ATLEAST(2,0,0)
,{ M64P_GL_CONTEXT_MAJOR_VERSION, SDL_GL_CONTEXT_MAJOR_VERSION },
{ M64P_GL_CONTEXT_MINOR_VERSION, SDL_GL_CONTEXT_MINOR_VERSION },
{ M64P_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_MASK }
#endif
};
static const int mapSize = sizeof(GLAttrMap) / sizeof(GLAttrMapNode);

Expand All @@ -677,7 +655,6 @@ EXPORT m64p_error CALL VidExt_GL_SetAttribute(m64p_GLattr Attr, int Value)
}

/* translate the GL context type mask if necessary */
#if SDL_VERSION_ATLEAST(2,0,0)
if (Attr == M64P_GL_CONTEXT_PROFILE_MASK)
{
switch (Value)
Expand All @@ -698,7 +675,6 @@ EXPORT m64p_error CALL VidExt_GL_SetAttribute(m64p_GLattr Attr, int Value)
Value = 0;
}
}
#endif

for (i = 0; i < mapSize; i++)
{
Expand Down Expand Up @@ -727,13 +703,11 @@ EXPORT m64p_error CALL VidExt_GL_GetAttribute(m64p_GLattr Attr, int *pValue)
if (!SDL_WasInit(SDL_INIT_VIDEO))
return M64ERR_NOT_INIT;

#if SDL_VERSION_ATLEAST(2,0,0)
if (Attr == M64P_GL_SWAP_CONTROL)
{
*pValue = SDL_GL_GetSwapInterval();
return M64ERR_SUCCESS;
}
#endif

for (i = 0; i < mapSize; i++)
{
Expand All @@ -743,7 +717,6 @@ EXPORT m64p_error CALL VidExt_GL_GetAttribute(m64p_GLattr Attr, int *pValue)
if (SDL_GL_GetAttribute(GLAttrMap[i].sdlAttr, &NewValue) != 0)
return M64ERR_SYSTEM_FAIL;
/* translate the GL context type mask if necessary */
#if SDL_VERSION_ATLEAST(2,0,0)
if (Attr == M64P_GL_CONTEXT_PROFILE_MASK)
{
switch (NewValue)
Expand All @@ -761,7 +734,6 @@ EXPORT m64p_error CALL VidExt_GL_GetAttribute(m64p_GLattr Attr, int *pValue)
NewValue = 0;
}
}
#endif
*pValue = NewValue;
return M64ERR_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/3rdParty/mupen64plus-core/src/device/dd/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ uint8_t* scan_and_expand_disk_format(uint8_t* data, size_t size,

//IPL Load Address
uint32_t ipl_load_addr = big32(sys_data->ipl_load_addr);
if (ipl_load_addr < 0x80000000 && ipl_load_addr >= 0x80800000) continue;
if (ipl_load_addr < 0x80000000 || ipl_load_addr >= 0x80800000) continue;

//Country Code
uint32_t disk_region = big32(sys_data->region);
Expand Down
2 changes: 1 addition & 1 deletion Source/3rdParty/mupen64plus-core/src/device/gb/gb_cart.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static int write_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, const u
/* 0x2000-0x3fff: ROM bank select (low 5 bits) */
case (0x2000 >> 13):
bank = value & 0x1f;
gb_cart->rom_bank = (gb_cart->rom_bank & ~UINT8_C(0x1f)) | (bank == 0) ? 1 : bank;
gb_cart->rom_bank = (gb_cart->rom_bank & ~UINT8_C(0x1f)) | ((bank == 0) ? 1 : bank);
DebugMessage(M64MSG_VERBOSE, "MBC1 set rom bank %02x", gb_cart->rom_bank);
break;

Expand Down
85 changes: 2 additions & 83 deletions Source/3rdParty/mupen64plus-core/src/main/eventloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if ! SDL_VERSION_ATLEAST(1,3,0)

#define SDL_SCANCODE_ESCAPE SDLK_ESCAPE
#define SDL_NUM_SCANCODES SDLK_LAST
#define SDL_SCANCODE_F5 SDLK_F5
#define SDL_SCANCODE_F7 SDLK_F7
#define SDL_SCANCODE_F9 SDLK_F9
#define SDL_SCANCODE_F10 SDLK_F10
#define SDL_SCANCODE_F11 SDLK_F11
#define SDL_SCANCODE_F12 SDLK_F12
#define SDL_SCANCODE_P SDLK_p
#define SDL_SCANCODE_M SDLK_m
#define SDL_SCANCODE_RIGHTBRACKET SDLK_RIGHTBRACKET
#define SDL_SCANCODE_LEFTBRACKET SDLK_LEFTBRACKET
#define SDL_SCANCODE_F SDLK_f
#define SDL_SCANCODE_Y SDLK_y
#define SDL_SCANCODE_SLASH SDLK_SLASH
#define SDL_SCANCODE_G SDLK_g
#define SDL_SCANCODE_RETURN SDLK_RETURN
#define SDL_SCANCODE_0 SDLK_0
#define SDL_SCANCODE_1 SDLK_1
#define SDL_SCANCODE_2 SDLK_2
#define SDL_SCANCODE_3 SDLK_3
#define SDL_SCANCODE_4 SDLK_4
#define SDL_SCANCODE_5 SDLK_5
#define SDL_SCANCODE_6 SDLK_6
#define SDL_SCANCODE_7 SDLK_7
#define SDL_SCANCODE_8 SDLK_8
#define SDL_SCANCODE_9 SDLK_9
#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN

#define SDL_SetEventFilter(func, data) SDL_SetEventFilter(func)
#define event_sdl_filter(userdata, event) event_sdl_filter(const event)

#else
SDL_JoystickID l_iJoyInstanceID[10];
#endif

SDL_JoystickID l_iJoyInstanceID[10];

#define M64P_CORE_PROTOTYPES 1
#include "api/callbacks.h"
Expand Down Expand Up @@ -196,9 +161,7 @@ static int MatchJoyCommand(const SDL_Event *event, eJoyCommand cmd)
else if (phrase_str[1] >= '0' && phrase_str[1] <= '9')
{
dev_number = phrase_str[1] - '0';
#if SDL_VERSION_ATLEAST(2,0,0)
dev_number = l_iJoyInstanceID[dev_number];
#endif
}
else
{
Expand Down Expand Up @@ -319,24 +282,15 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
break;

case SDL_KEYDOWN:
#if SDL_VERSION_ATLEAST(1,3,0)
if (event->key.repeat)
return 0;

event_sdl_keydown(event->key.keysym.scancode, event->key.keysym.mod);
#else
event_sdl_keydown(event->key.keysym.sym, event->key.keysym.mod);
#endif
return 0;
case SDL_KEYUP:
#if SDL_VERSION_ATLEAST(1,3,0)
event_sdl_keyup(event->key.keysym.scancode, event->key.keysym.mod);
#else
event_sdl_keyup(event->key.keysym.sym, event->key.keysym.mod);
#endif
return 0;

#if SDL_VERSION_ATLEAST(1,3,0)
case SDL_WINDOWEVENT:
switch (event->window.event) {
case SDL_WINDOWEVENT_RESIZED:
Expand All @@ -352,22 +306,6 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
break;
}
break;
#else
case SDL_VIDEORESIZE:
// call the video plugin. if the video plugin supports resizing, it will resize its viewport and call
// VidExt_ResizeWindow to update the window manager handling our opengl output window
gfx.resizeVideoOutput(event->resize.w, event->resize.h);
return 0; // consumed the event
break;

#ifdef WIN32
case SDL_SYSWMEVENT:
if(event->syswm.msg->msg == WM_MOVE)
gfx.moveScreen(0,0); // The video plugin is responsible for getting the new window position
return 0; // consumed the event
break;
#endif
#endif

#ifndef NO_KEYBINDINGS
// if joystick action is detected, check if it's mapped to a special function
Expand Down Expand Up @@ -491,13 +429,8 @@ void event_initialize(void)
{
if (!SDL_WasInit(SDL_INIT_JOYSTICK))
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_Joystick *thisJoy = SDL_JoystickOpen(device);
l_iJoyInstanceID[device] = SDL_JoystickInstanceID(thisJoy);
#else
if (!SDL_JoystickOpened(device))
SDL_JoystickOpen(device);
#endif
}

phrase_str = strtok(NULL, ",");
Expand All @@ -508,17 +441,7 @@ void event_initialize(void)


/* set up SDL event filter and disable key repeat */
#if !SDL_VERSION_ATLEAST(2,0,0)
SDL_EnableKeyRepeat(0, 0);
#endif
SDL_SetEventFilter(event_sdl_filter, NULL);

#if defined(WIN32) && !SDL_VERSION_ATLEAST(1,3,0)
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);

if (SDL_EventState(SDL_SYSWMEVENT, SDL_QUERY) != SDL_ENABLE)
DebugMessage(M64MSG_WARNING, "Failed to change event state: %s", SDL_GetError());
#endif
}

int event_set_core_defaults(void)
Expand Down Expand Up @@ -559,11 +482,7 @@ int event_set_core_defaults(void)
int key = SDL_SCANCODE_UNKNOWN;
for (int slot = 0; slot < 10; slot++)
{
#if ! SDL_VERSION_ATLEAST(1,3,0)
key = SDL_SCANCODE_0 + slot;
#else
key = slot == 0 ? SDL_SCANCODE_0 : SDL_SCANCODE_1 + (slot - 1);
#endif
sprintf(kbdSaveSlotStr, "%s%i", kbdSaveSlot, slot);
sprintf(kbdSaveSlotHelpStr, "SDL keysym for save slot %i", slot);
ConfigSetDefaultInt(l_CoreEventsConfig, kbdSaveSlotStr, sdl_native2keysym(key), kbdSaveSlotHelpStr);
Expand Down
Loading

0 comments on commit 4cd4f4c

Please sign in to comment.