Commit 8f23de40 authored by m4xw's avatar m4xw
Browse files

git subrepo clone --force --branch=new_rebase...

git subrepo clone --force --branch=new_rebase https://github.com/libretro/mupen64plus-core.git mupen64plus-core

subrepo:
  subdir:   "mupen64plus-core"
  merged:   "1e40617a"
upstream:
  origin:   "https://github.com/libretro/mupen64plus-core.git"
  branch:   "new_rebase"
  commit:   "1e40617a"
git-subrepo:
  version:  "0.4.0"
  origin:   "???"
  commit:   "???"
parent b76ea63e
......@@ -5,8 +5,8 @@
;
[subrepo]
remote = https://github.com/libretro/mupen64plus-core.git
branch = master
commit = ca987441cd60c73b6c6a603edad6c274ef13b515
parent = 855d2577d7e900dd619ac00a2b98e3799af5d337
branch = new_rebase
commit = 1e40617ae55aff99ef7f927b8b9f6d0af668106b
parent = b76ea63eeeba4c3b0364504a7cea01f1b826c3ae
method = rebase
cmdver = 0.4.0
......@@ -4097,6 +4097,11 @@ GoodName=Donkey Kong 64 (U) [f3]
CRC=CED986FD 3344AC38
RefMD5=9EC41ABF2519FC386CADD0731F6E868C
[11DA2A2D0E91074BB8FF1FCB029535FD]
GoodName=Donkey Kong 64 - Tag Anywhere (V5) (U)
CRC=31739C69 A99E3CB2
RefMD5=9EC41ABF2519FC386CADD0731F6E868C
[190CCCA6526DC4A1F611E3B40F5131C0]
GoodName=Doom 64 (E) [!]
CRC=2C739EAC 9EF77726
......@@ -13913,6 +13918,16 @@ GoodName=SmashRemix0.9.7
CRC=9D2B9C7F 6D90A8EF
RefMD5=5AAC6E652C5CF1E37A466AC0073E88CA
[8EC29958E0E3EB8C20AB7C9B3ACB07D8]
GoodName=SmashRemix1.0.0
CRC=FD0E716E FB029C8E
RefMD5=5AAC6E652C5CF1E37A466AC0073E88CA
[0A6715A80957DD7C58F12E1F33D75F43]
GoodName=SmashRemix1.0.1
CRC=FDFC3328 A0B2BA23
RefMD5=5AAC6E652C5CF1E37A466AC0073E88CA
[B8D4B92E66A312708626B3216DE07A3A]
GoodName=Snobow Kids (J) [!]
CRC=84FC04FF B1253CE9
......
......@@ -59,6 +59,10 @@ These are standard parameters which are used by the Mupen64Plus Core library. T
|M64TYPE_INT
|Force number of cycles per emulated instruction when set greater than 0.
|-
|CountPerOpDenomPot
|M64TYPE_INT
|Reduce number of cycles per update by power of two when set greater than 0 (overclock).
|-
|}
These configuration parameters are used in the Core's event loop to detect keyboard and joystick commands. They are stored in a configuration section called "CoreEvents" and may be altered by the front-end in order to adjust the behaviour of the emulator. These may be adjusted at any time and the effect of the change should occur immediately. The Keysym value stored is actually <tt>(SDLMod << 16) || SDLKey</tt>, so that keypresses with modifiers like shift, control, or alt may be used.
......
......@@ -82,13 +82,14 @@ The server is responsible for maintaining healthy buffers and also for detecting
** byte[file size] = save file data
* Send settings (sent by client):
** 21 bytes
** 25 bytes
** byte[0] = 3
** byte[1-4] = count_per_op
** byte[5-8] = disable_extra_mem
** byte[9-12] = si_dma_duration
** byte[13-16] = emumode
** byte[17-20] = no_compiled_jump
** byte[5-8] = count_per_op_denom_pot
** byte[9-12] = disable_extra_mem
** byte[13-16] = si_dma_duration
** byte[17-20] = emumode
** byte[21-24] = no_compiled_jump
* Request settings (sent by client):
** 1 byte
......@@ -96,12 +97,13 @@ The server is responsible for maintaining healthy buffers and also for detecting
* Send settings (sent by server):
** Server responds with this data right after the above request
** 20 bytes
** 24 bytes
** byte[0-3] = count_per_op
** byte[4-7] = disable_extra_mem
** byte[8-11] = si_dma_duration
** byte[12-15] = emumode
** byte[16-19] = no_compiled_jump
** byte[4-7] = count_per_op_denom_pot
** byte[8-11] = disable_extra_mem
** byte[12-15] = si_dma_duration
** byte[16-19] = emumode
** byte[20-23] = no_compiled_jump
* Request player registration data (sent by client):
** 1 byte
......
......@@ -135,6 +135,13 @@ ifneq ("$(filter aarch64,$(HOST_CPU))","")
PIC ?= 1
NEW_DYNAREC := 1
endif
ifneq ("$(filter riscv64,$(HOST_CPU))","")
CPU := RISCV64
ARCH_DETECTED := 64BITS
PIC ?= 1
NO_ASM := 1
$(warning Architecture "$(HOST_CPU)" not officially supported.)
endif
ifeq ("$(CPU)","NONE")
$(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'https://github.com/mupen64plus/mupen64plus-core/issues')
endif
......@@ -665,6 +672,10 @@ ifeq ($(LIRC), 1)
LDLIBS += -llirc_client
endif
ifeq ($(KEYBINDINGS), 0)
CFLAGS += -DNO_KEYBINDINGS
endif
ifeq ($(DEBUGGER), 1)
SOURCE += \
$(SRCDIR)/debugger/dbg_debugger.c \
......@@ -727,6 +738,7 @@ targets:
@echo " OSD=(1|0) == Enable/disable build of OpenGL On-screen display"
@echo " NETPLAY=1 == Enable netplay functionality, requires SDL2_net"
@echo " NEW_DYNAREC=1 == Replace dynamic recompiler with Ari64's experimental dynarec"
@echo " KEYBINDINGS=0 == Disables the default keybindings"
@echo " OPENCV=1 == Enable OpenCV support"
@echo " POSTFIX=name == String added to the name of the the build (default: '')"
@echo " Install Options:"
......
......@@ -33,8 +33,8 @@
void poweron_is_viewer(struct is_viewer* is_viewer)
{
memset(is_viewer->data, 0, 0x1000);
memset(is_viewer->output_buffer, 0, 0x200);
memset(is_viewer->data, 0, IS_BUFFER_SIZE);
memset(is_viewer->output_buffer, 0, IS_BUFFER_SIZE);
is_viewer->buffer_pos = 0;
}
......@@ -55,6 +55,16 @@ void write_is_viewer(void* opaque, uint32_t address, uint32_t value, uint32_t ma
{
if (word > 0)
{
/* make sure we don't overflow the buffer */
if (is_viewer->buffer_pos + word > IS_BUFFER_SIZE)
{
/* reset buffer */
memset(is_viewer->output_buffer, 0, IS_BUFFER_SIZE);
is_viewer->buffer_pos = 0;
DebugMessage(M64MSG_WARNING, "IS64: prevented buffer overflow, cleared buffer");
return;
}
memcpy(&is_viewer->output_buffer[is_viewer->buffer_pos], &is_viewer->data[0x20], word);
is_viewer->buffer_pos += word;
char* newline = memchr(is_viewer->output_buffer, '\n', is_viewer->buffer_pos);
......
......@@ -25,10 +25,12 @@
#include <stddef.h>
#include <stdint.h>
#define IS_BUFFER_SIZE 0x1000
struct is_viewer
{
char data[0x1000];
char output_buffer[0x200];
char data[IS_BUFFER_SIZE];
char output_buffer[IS_BUFFER_SIZE];
uint32_t buffer_pos;
};
......
......@@ -83,6 +83,7 @@ void init_device(struct device* dev,
/* r4300 */
unsigned int emumode,
unsigned int count_per_op,
unsigned int count_per_op_denom_pot,
int no_compiled_jump,
int randomize_interrupt,
uint32_t start_address,
......@@ -178,7 +179,7 @@ void init_device(struct device* dev,
init_rdram(&dev->rdram, mem_base_u32(base, MM_RDRAM_DRAM), dram_size, &dev->r4300);
init_r4300(&dev->r4300, &dev->mem, &dev->mi, &dev->rdram, interrupt_handlers,
emumode, count_per_op, no_compiled_jump, randomize_interrupt, start_address);
emumode, count_per_op, count_per_op_denom_pot, no_compiled_jump, randomize_interrupt, start_address);
init_rdp(&dev->dp, &dev->sp, &dev->mi, &dev->mem, &dev->rdram, &dev->r4300);
init_rsp(&dev->sp, mem_base_u32(base, MM_RSP_MEM), &dev->mi, &dev->dp, &dev->ri);
init_ai(&dev->ai, &dev->mi, &dev->ri, &dev->vi, aout, iaout);
......
......@@ -121,6 +121,7 @@ void init_device(struct device* dev,
/* r4300 */
unsigned int emumode,
unsigned int count_per_op,
unsigned int count_per_op_denom_pot,
int no_compiled_jump,
int randomize_interrupt,
uint32_t start_address,
......
......@@ -36,9 +36,10 @@
#endif
/* global functions */
void init_cp0(struct cp0* cp0, unsigned int count_per_op, struct new_dynarec_hot_state* new_dynarec_hot_state, const struct interrupt_handler* interrupt_handlers)
void init_cp0(struct cp0* cp0, unsigned int count_per_op, unsigned int count_per_op_denom_pot, struct new_dynarec_hot_state* new_dynarec_hot_state, const struct interrupt_handler* interrupt_handlers)
{
cp0->count_per_op = count_per_op;
cp0->count_per_op_denom_pot = count_per_op_denom_pot;
#ifdef NEW_DYNAREC
cp0->new_dynarec_hot_state = new_dynarec_hot_state;
#endif
......@@ -134,6 +135,10 @@ void cp0_update_count(struct r4300_core* r4300)
{
#endif
uint32_t count = ((*r4300_pc(r4300) - cp0->last_addr) >> 2) * cp0->count_per_op;
if (r4300->cp0.count_per_op_denom_pot) {
count += (1 << r4300->cp0.count_per_op_denom_pot) - 1;
count >>= r4300->cp0.count_per_op_denom_pot;
}
cp0_regs[CP0_COUNT_REG] += count;
*r4300_cp0_cycle_count(cp0) += count;
cp0->last_addr = *r4300_pc(r4300);
......
......@@ -201,6 +201,7 @@ struct cp0
uint32_t last_addr;
unsigned int count_per_op;
unsigned int count_per_op_denom_pot;
struct tlb tlb;
};
......@@ -215,7 +216,7 @@ struct cp0
offsetof(struct new_dynarec_hot_state, cp0_regs))
#endif
void init_cp0(struct cp0* cp0, unsigned int count_per_op, struct new_dynarec_hot_state* new_dynarec_hot_state, const struct interrupt_handler* interrupt_handlers);
void init_cp0(struct cp0* cp0, unsigned int count_per_op, unsigned int count_per_op_denom_pot, struct new_dynarec_hot_state* new_dynarec_hot_state, const struct interrupt_handler* interrupt_handlers);
void poweron_cp0(struct cp0* cp0);
uint32_t* r4300_cp0_regs(struct cp0* cp0);
......
......@@ -4493,6 +4493,10 @@ static void do_cc(int i,signed char i_regmap[],int *adj,int addr,int taken,int i
emit_jmp(0);
}
else if(*adj==0||invert) {
if(g_dev.r4300.cp0.count_per_op_denom_pot) {
count += (1 << g_dev.r4300.cp0.count_per_op_denom_pot) - 1;
count >>= g_dev.r4300.cp0.count_per_op_denom_pot;
}
emit_addimm_and_set_flags(CLOCK_DIVIDER*(count+2),HOST_CCREG);
jaddr=(intptr_t)out;
emit_jns(0);
......
......@@ -3306,15 +3306,26 @@ static void shift_assemble_x64(int i,struct regstat *i_regs)
emit_cmovne_reg(th==ECX?shift:th,tl==ECX?shift:tl);
if(real_th>=0) emit_cmovne_reg(temp==ECX?shift:temp,th==ECX?shift:th);
}
if(shift!=ECX) {
if(i_regs->regmap[ECX]>=INVCP)
emit_xchg64(shift,ECX);
else
emit_xchg(shift,ECX);
if(real_tl==shift) {
emit_mov(sl,real_tl);
emit_popreg(sl);
if(real_tl==ECX&&sl!=ECX&&shift==real_tl) {
emit_mov(sl,real_tl);
emit_popreg(sl);
}
else if(th==ECX&&sh!=ECX&&shift==real_tl) {
emit_mov(sl,real_tl);
emit_popreg(sl);
}
else
{
if(shift!=ECX) {
if(i_regs->regmap[ECX]>=INVCP)
emit_xchg64(shift,ECX);
else
emit_xchg(shift,ECX);
if(real_tl==shift) {
emit_mov(sl,real_tl);
emit_popreg(sl);
}
}
}
}
......
......@@ -2903,11 +2903,22 @@ static void shift_assemble_x86(int i,struct regstat *i_regs)
emit_cmovne_reg(th==ECX?shift:th,tl==ECX?shift:tl);
if(real_th>=0) emit_cmovne_reg(temp==ECX?shift:temp,th==ECX?shift:th);
}
if(shift!=ECX) {
emit_xchg(shift,ECX);
if(real_tl==shift) {
emit_mov(sl,real_tl);
emit_popreg(sl);
if(real_tl==ECX&&sl!=ECX&&shift==real_tl) {
emit_mov(sl,real_tl);
emit_popreg(sl);
}
else if(th==ECX&&sh!=ECX&&shift==real_tl) {
emit_mov(sl,real_tl);
emit_popreg(sl);
}
else
{
if(shift!=ECX) {
emit_xchg(shift,ECX);
if(real_tl==shift) {
emit_mov(sl,real_tl);
emit_popreg(sl);
}
}
}
}
......
......@@ -41,7 +41,7 @@
#include <time.h>
void init_r4300(struct r4300_core* r4300, struct memory* mem, struct mi_controller* mi, struct rdram* rdram, const struct interrupt_handler* interrupt_handlers,
unsigned int emumode, unsigned int count_per_op, int no_compiled_jump, int randomize_interrupt, uint32_t start_address)
unsigned int emumode, unsigned int count_per_op, unsigned int count_per_op_denom_pot, int no_compiled_jump, int randomize_interrupt, uint32_t start_address)
{
struct new_dynarec_hot_state* new_dynarec_hot_state =
#ifdef NEW_DYNAREC
......@@ -51,7 +51,7 @@ void init_r4300(struct r4300_core* r4300, struct memory* mem, struct mi_controll
#endif
r4300->emumode = emumode;
init_cp0(&r4300->cp0, count_per_op, new_dynarec_hot_state, interrupt_handlers);
init_cp0(&r4300->cp0, count_per_op, count_per_op_denom_pot, new_dynarec_hot_state, interrupt_handlers);
init_cp1(&r4300->cp1, new_dynarec_hot_state);
#ifndef NEW_DYNAREC
......
......@@ -211,7 +211,7 @@ struct r4300_core
offsetof(struct new_dynarec_hot_state, regs))
#endif
void init_r4300(struct r4300_core* r4300, struct memory* mem, struct mi_controller* mi, struct rdram* rdram, const struct interrupt_handler* interrupt_handlers, unsigned int emumode, unsigned int count_per_op, int no_compiled_jump, int randomize_interrupt, uint32_t start_address);
void init_r4300(struct r4300_core* r4300, struct memory* mem, struct mi_controller* mi, struct rdram* rdram, const struct interrupt_handler* interrupt_handlers, unsigned int emumode, unsigned int count_per_op, unsigned int count_per_op_denom_pot, int no_compiled_jump, int randomize_interrupt, uint32_t start_address);
void poweron_r4300(struct r4300_core* r4300);
void run_r4300(struct r4300_core* r4300);
......
......@@ -128,6 +128,11 @@ static void gencp0_update_count(struct r4300_core* r4300, unsigned int addr)
shr_reg32_imm8(EAX, 2);
mov_reg32_m32(EDX, &r4300->cp0.count_per_op);
mul_reg32(EDX);
if (r4300->cp0.count_per_op_denom_pot)
{
add_reg32_imm32(EAX, (1 << g_dev.r4300.cp0.count_per_op_denom_pot) - 1);
shr_reg32_imm8(EAX, g_dev.r4300.cp0.count_per_op_denom_pot);
}
add_m32_reg32((unsigned int*)(&r4300_cp0_regs(&r4300->cp0)[CP0_COUNT_REG]), EAX);
add_m32_reg32((unsigned int*)r4300_cp0_cycle_count(&r4300->cp0), EAX);
#else
......
......@@ -139,6 +139,11 @@ static void gencp0_update_count(struct r4300_core* r4300, unsigned int addr)
shr_reg32_imm8(EAX, 2);
mov_xreg32_m32rel(EDX, (void*)&r4300->cp0.count_per_op);
mul_reg32(EDX);
if (r4300->cp0.count_per_op_denom_pot)
{
add_reg32_imm32(EAX, (1 << g_dev.r4300.cp0.count_per_op_denom_pot) - 1);
shr_reg32_imm8(EAX, g_dev.r4300.cp0.count_per_op_denom_pot);
}
add_m32rel_xreg32((unsigned int*)(&r4300_cp0_regs(&r4300->cp0)[CP0_COUNT_REG]), EAX);
add_m32rel_xreg32((unsigned int*)(r4300_cp0_cycle_count(&r4300->cp0)), EAX);
#else
......
......@@ -80,6 +80,7 @@ typedef enum {joyFullscreen,
joyGameshark
} eJoyCommand;
#ifndef NO_KEYBINDINGS
static const char *JoyCmdName[] = { "Joy Mapping Fullscreen",
"Joy Mapping Stop",
"Joy Mapping Pause",
......@@ -101,6 +102,7 @@ static const int NumJoyCommands = sizeof(JoyCmdName) / sizeof(const char *);
static int JoyCmdActive[16][2]; /* if extra joystick commands are added above, make sure there is enough room in this array */
/* [i][0] is Command Active, [i][1] is Hotkey Active */
#endif /* NO_KEYBINDINGS */
static int GamesharkActive = 0;
......@@ -108,6 +110,7 @@ static int GamesharkActive = 0;
* static functions for eventloop.c
*/
#ifndef NO_KEYBINDINGS
/** MatchJoyCommand
* This function processes an SDL event and updates the JoyCmdActive array if the
* event matches with the given command.
......@@ -257,13 +260,16 @@ static int MatchJoyCommand(const SDL_Event *event, eJoyCommand cmd)
/* nothing found */
return 0;
}
#endif /* NO_KEYBINDINGS */
/*********************************************************************************************************
* sdl event filter
*/
static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
{
#ifndef NO_KEYBINDINGS
int cmd, action;
#endif /* NO_KEYBINDINGS */
switch(event->type)
{
......@@ -323,6 +329,7 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
#endif
#endif
#ifndef NO_KEYBINDINGS
// if joystick action is detected, check if it's mapped to a special function
case SDL_JOYAXISMOTION:
case SDL_JOYBUTTONDOWN:
......@@ -377,6 +384,8 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
return 0;
break;
#endif /* NO_KEYBINDINGS */
}
return 1; // add this event to SDL queue
......@@ -388,6 +397,7 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
void event_initialize(void)
{
#ifndef NO_KEYBINDINGS
int i, j;
/* set initial state of all joystick commands to 'off' */
......@@ -454,6 +464,8 @@ void event_initialize(void)
} /* Iterate over comma-separated config phrases */
}
}
#endif /* NO_KEYBINDINGS */
/* set up SDL event filter and disable key repeat */
#if !SDL_VERSION_ATLEAST(2,0,0)
......@@ -501,6 +513,7 @@ int event_set_core_defaults(void)
ConfigSetDefaultFloat(l_CoreEventsConfig, "Version", CONFIG_PARAM_VERSION, "Mupen64Plus CoreEvents config parameter set version number. Please don't change this version number.");
/* Keyboard presses mapped to core functions */
#ifndef NO_KEYBINDINGS
char kbdSaveSlotStr[sizeof(kbdSaveSlot)+1];
char kbdSaveSlotHelpStr[27];
int key = SDL_SCANCODE_UNKNOWN;
......@@ -548,10 +561,11 @@ int event_set_core_defaults(void)
ConfigSetDefaultString(l_CoreEventsConfig, JoyCmdName[joyForward], "", "Joystick event string for fast-forward");
ConfigSetDefaultString(l_CoreEventsConfig, JoyCmdName[joyAdvance], "", "Joystick event string for advancing by one frame when paused");
ConfigSetDefaultString(l_CoreEventsConfig, JoyCmdName[joyGameshark], "", "Joystick event string for pressing the game shark button");
#endif /* NO_KEYBINDINGS */
return 1;
}
#ifndef NO_KEYBINDINGS
static int get_saveslot_from_keysym(int keysym)
{
char kbdSaveSlotStr[sizeof(kbdSaveSlot)+1];
......@@ -566,6 +580,7 @@ static int get_saveslot_from_keysym(int keysym)
return -1;
}
#endif /* NO_KEYBINDINGS */
/*********************************************************************************************************
* sdl keyup/keydown handlers
......@@ -573,6 +588,7 @@ static int get_saveslot_from_keysym(int keysym)
void event_sdl_keydown(int keysym, int keymod)
{
#ifndef NO_KEYBINDINGS
int slot;
/* check for the only hard-coded key command: Alt-enter for fullscreen */
......@@ -615,6 +631,7 @@ void event_sdl_keydown(int keysym, int keymod)
event_set_gameshark(1);
}
else
#endif /* NO_KEYBINDINGS */
{
/* pass all other keypresses to the input plugin */
input.keyDown(keymod, keysym);
......@@ -624,6 +641,7 @@ void event_sdl_keydown(int keysym, int keymod)
void event_sdl_keyup(int keysym, int keymod)
{
#ifndef NO_KEYBINDINGS
if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdStop)))
{
return;
......@@ -636,8 +654,11 @@ void event_sdl_keyup(int keysym, int keymod)
{
event_set_gameshark(0);
}
else input.keyUp(keymod, keysym);
else
#endif /* NO_KEYBINDINGS */
{
input.keyUp(keymod, keysym);
}
}
int event_gameshark_active(void)
......
......@@ -1287,6 +1287,7 @@ m64p_error main_run(void)
{
size_t i, k;
uint32_t count_per_op;
uint32_t count_per_op_denom_pot;
uint32_t emumode;
uint32_t disable_extra_mem;
int32_t si_dma_duration;
......@@ -1311,9 +1312,11 @@ m64p_error main_run(void)
/* XXX: select type of flashram from db */
uint32_t flashram_type = MX29L1100_ID;
emumode = r4300_emumode;
randomize_interrupt = 0; // We don't want this right now
no_compiled_jump = 0;
count_per_op = CountPerOp;
count_per_op_denom_pot = 0;
disable_extra_mem = ROM_SETTINGS.disableextramem;
uint16_t eeprom_type = JDT_NONE;
......@@ -1334,10 +1337,13 @@ m64p_error main_run(void)
if (count_per_op <= 0)
count_per_op = ROM_SETTINGS.countperop;
if (count_per_op_denom_pot > 11)
count_per_op_denom_pot = 11;
si_dma_duration = ROM_SETTINGS.sidmaduration;
//During netplay, player 1 is the source of truth for these settings
netplay_sync_settings(&count_per_op, &disable_extra_mem, &si_dma_duration, &emumode, &no_compiled_jump);
netplay_sync_settings(&count_per_op, &count_per_op_denom_pot, &disable_extra_mem, &si_dma_duration, &emumode, &no_compiled_jump);
cheat_add_hacks(&g_cheat_ctx, ROM_PARAMS.cheats);
......@@ -1553,6 +1559,7 @@ m64p_error main_run(void)
g_mem_base,
r4300_emumode,
count_per_op,
count_per_op_denom_pot,
no_compiled_jump,
randomize_interrupt,
g_start_address,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment