Merge remote-tracking branch 'libretro/master'
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
commit
08b5685049
|
@ -14,6 +14,7 @@ vcpkg/*
|
|||
*.so
|
||||
*.dll
|
||||
*.exe
|
||||
.vscode
|
||||
|
||||
# vim swap files
|
||||
*.sw?
|
||||
|
|
|
@ -2581,8 +2581,7 @@ static INSN_REGPARM void armA00(uint32_t opcode)
|
|||
armNextPC = reg[15].I;
|
||||
reg[15].I += 4;
|
||||
ARM_PREFETCH;
|
||||
clockTicks = codeTicksAccessSeq32(armNextPC) + 1;
|
||||
clockTicks = (clockTicks * 2) + codeTicksAccess32(armNextPC) + 1;
|
||||
clockTicks = (codeTicksAccessSeq32(armNextPC) * 2) + codeTicksAccess32(armNextPC) + 3;
|
||||
busPrefetchCount = 0;
|
||||
}
|
||||
|
||||
|
@ -2595,8 +2594,7 @@ static INSN_REGPARM void armB00(uint32_t opcode)
|
|||
armNextPC = reg[15].I;
|
||||
reg[15].I += 4;
|
||||
ARM_PREFETCH;
|
||||
clockTicks = codeTicksAccessSeq32(armNextPC) + 1;
|
||||
clockTicks = (clockTicks * 2) + codeTicksAccess32(armNextPC) + 1;
|
||||
clockTicks = (codeTicksAccessSeq32(armNextPC) * 2) + codeTicksAccess32(armNextPC) + 3;
|
||||
busPrefetchCount = 0;
|
||||
}
|
||||
|
||||
|
@ -2612,8 +2610,7 @@ static INSN_REGPARM void armE01(uint32_t opcode)
|
|||
// SWI <comment>
|
||||
static INSN_REGPARM void armF00(uint32_t opcode)
|
||||
{
|
||||
clockTicks = codeTicksAccessSeq32(armNextPC) + 1;
|
||||
clockTicks = (clockTicks * 2) + codeTicksAccess32(armNextPC) + 1;
|
||||
clockTicks = (codeTicksAccessSeq32(armNextPC) * 2) + codeTicksAccess32(armNextPC) + 3;
|
||||
busPrefetchCount = 0;
|
||||
CPUSoftwareInterrupt(opcode & 0x00FFFFFF);
|
||||
}
|
||||
|
|
|
@ -1146,9 +1146,9 @@ static INSN_REGPARM void thumb43_1(uint32_t opcode)
|
|||
reg[dest].I = reg[(opcode >> 3) & 7].I * rm;
|
||||
if (((int32_t)rm) < 0)
|
||||
rm = ~rm;
|
||||
if ((rm & 0xFFFFFF00) == 0)
|
||||
clockTicks += 0;
|
||||
else if ((rm & 0xFFFF0000) == 0)
|
||||
if ((rm & 0xFFFFFF00) == 0) {
|
||||
// clockTicks += 0;
|
||||
} else if ((rm & 0xFFFF0000) == 0)
|
||||
clockTicks += 1;
|
||||
else if ((rm & 0xFF000000) == 0)
|
||||
clockTicks += 2;
|
||||
|
@ -1625,7 +1625,7 @@ static INSN_REGPARM void thumbBD(uint32_t opcode)
|
|||
reg[13].I = temp;
|
||||
THUMB_PREFETCH;
|
||||
busPrefetchCount = 0;
|
||||
clockTicks += 3 + codeTicksAccess16(armNextPC) + codeTicksAccess16(armNextPC);
|
||||
clockTicks += 3 + (codeTicksAccess16(armNextPC) * 2);
|
||||
}
|
||||
|
||||
// Load/store multiple ////////////////////////////////////////////////////
|
||||
|
@ -1703,7 +1703,7 @@ static INSN_REGPARM void thumbC8(uint32_t opcode)
|
|||
#define THUMB_CONDITIONAL_BRANCH(COND) \
|
||||
UPDATE_OLDREG; \
|
||||
clockTicks = codeTicksAccessSeq16(armNextPC) + 1; \
|
||||
if (COND) { \
|
||||
if ((bool)COND) { \
|
||||
uint32_t offset = (uint32_t)((int8_t)(opcode & 0xFF)) << 1; \
|
||||
reg[15].I += offset; \
|
||||
armNextPC = reg[15].I; \
|
||||
|
|
|
@ -103,16 +103,17 @@ static inline uint32_t CPUReadMemory(uint32_t address)
|
|||
case 5:
|
||||
value = READ32LE(((uint32_t*)&paletteRAM[address & 0x3fC]));
|
||||
break;
|
||||
case 6:
|
||||
address = (address & 0x1fffc);
|
||||
if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) {
|
||||
case 6: {
|
||||
unsigned addr = (address & 0x1fffc);
|
||||
if (((DISPCNT & 7) > 2) && ((addr & 0x1C000) == 0x18000)) {
|
||||
value = 0;
|
||||
break;
|
||||
}
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
value = READ32LE(((uint32_t*)&vram[address]));
|
||||
if ((addr & 0x18000) == 0x18000)
|
||||
addr &= 0x17fff;
|
||||
value = READ32LE(((uint32_t*)&vram[addr]));
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
value = READ32LE(((uint32_t*)&oam[address & 0x3FC]));
|
||||
break;
|
||||
|
@ -253,16 +254,17 @@ static inline uint32_t CPUReadHalfWord(uint32_t address)
|
|||
case 5:
|
||||
value = READ16LE(((uint16_t*)&paletteRAM[address & 0x3fe]));
|
||||
break;
|
||||
case 6:
|
||||
address = (address & 0x1fffe);
|
||||
if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) {
|
||||
case 6: {
|
||||
unsigned addr = (address & 0x1fffe);
|
||||
if (((DISPCNT & 7) > 2) && ((addr & 0x1C000) == 0x18000)) {
|
||||
value = 0;
|
||||
break;
|
||||
}
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
value = READ16LE(((uint16_t*)&vram[address]));
|
||||
if ((addr & 0x18000) == 0x18000)
|
||||
addr &= 0x17fff;
|
||||
value = READ16LE(((uint16_t*)&vram[addr]));
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
value = READ16LE(((uint16_t*)&oam[address & 0x3fe]));
|
||||
break;
|
||||
|
@ -293,11 +295,10 @@ static inline uint32_t CPUReadHalfWord(uint32_t address)
|
|||
if (cpuDmaHack) {
|
||||
value = cpuDmaLast & 0xFFFF;
|
||||
} else {
|
||||
if (armState) {
|
||||
value = CPUReadHalfWordQuick(reg[15].I + (address & 2));
|
||||
} else {
|
||||
value = CPUReadHalfWordQuick(reg[15].I);
|
||||
}
|
||||
int param = reg[15].I;
|
||||
if (armState)
|
||||
param += (address & 2);
|
||||
value = CPUReadHalfWordQuick(param);
|
||||
}
|
||||
#ifdef GBA_LOGGING
|
||||
if (systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
|
|
|
@ -42,6 +42,11 @@ int16_t sineTable[256] = {
|
|||
(int16_t)0xF384, (int16_t)0xF50F, (int16_t)0xF69C, (int16_t)0xF82B, (int16_t)0xF9BB, (int16_t)0xFB4B, (int16_t)0xFCDD, (int16_t)0xFE6E
|
||||
};
|
||||
|
||||
// 2020-08-12 - negativeExponent
|
||||
// Fix ArcTan and ArcTan2 based on mgba's hle bios fixes
|
||||
// https://github.com/mgba-emu/mgba/commit/14dc01409c9e971ea0697f5017b45d0db6a7faf5#diff-8f06a143a9fd912c83209f935d3aca25
|
||||
// https://github.com/mgba-emu/mgba/commit/b154457857d3367a4c0196a4abadeeb6c850ffdf#diff-8f06a143a9fd912c83209f935d3aca25
|
||||
|
||||
void BIOS_ArcTan()
|
||||
{
|
||||
#ifdef GBA_LOGGING
|
||||
|
@ -53,7 +58,7 @@ void BIOS_ArcTan()
|
|||
#endif
|
||||
|
||||
int32_t i = reg[0].I;
|
||||
int32_t a = -((i*i) >> 14);
|
||||
int32_t a = -((i * i) >> 14);
|
||||
int32_t b = ((0xA9 * a) >> 14) + 0x390;
|
||||
b = ((b * a) >> 14) + 0x91C;
|
||||
b = ((b * a) >> 14) + 0xFB6;
|
||||
|
@ -111,6 +116,7 @@ void BIOS_ArcTan2()
|
|||
}
|
||||
}
|
||||
reg[0].I = res;
|
||||
reg[3].I = 0x170;
|
||||
|
||||
#ifdef GBA_LOGGING
|
||||
if (systemVerbose & VERBOSE_SWI) {
|
||||
|
|
|
@ -59,3 +59,8 @@ SOURCES_CXX += \
|
|||
$(CORE_DIR)/gb/gbMemory.cpp \
|
||||
$(CORE_DIR)/gb/gbSGB.cpp \
|
||||
$(CORE_DIR)/gb/gbSound.cpp
|
||||
|
||||
# Filters
|
||||
SOURCES_CXX += \
|
||||
$(CORE_DIR)/filters/interframe.cpp \
|
||||
$(CORE_DIR)/gba/gbafilter.cpp
|
||||
|
|
|
@ -232,17 +232,25 @@ void utilUpdateSystemColorMaps(bool lcd)
|
|||
{
|
||||
int i = 0;
|
||||
|
||||
(void)lcd;
|
||||
|
||||
switch (systemColorDepth) {
|
||||
case 16:
|
||||
for (i = 0; i < 0x10000; i++)
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd)
|
||||
gbafilter_pal(systemColorMap16, 0x10000);
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
for (i = 0; i < 0x10000; i++)
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd)
|
||||
gbafilter_pal32(systemColorMap32, 0x10000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "../gb/gbSGB.h"
|
||||
#include "../gb/gbSound.h"
|
||||
|
||||
#include "../filters/interframe.hpp"
|
||||
|
||||
#define FRAMERATE (16777216.0 / 280896.0) // 59.73
|
||||
#define SAMPLERATE 32768.0
|
||||
|
||||
|
@ -56,6 +58,9 @@ static bool option_forceRTCenable = false;
|
|||
static bool option_showAdvancedOptions = false;
|
||||
static double option_sndFiltering = 0.5;
|
||||
static unsigned option_gbPalette = 0;
|
||||
static bool option_lcdfilter = false;
|
||||
// filters
|
||||
static IFBFilterFunc ifb_filter_func = NULL;
|
||||
|
||||
static unsigned retropad_device[4] = {0};
|
||||
static unsigned systemWidth = gbaWidth;
|
||||
|
@ -66,7 +71,7 @@ static IMAGE_TYPE type = IMAGE_UNKNOWN;
|
|||
// global vars
|
||||
uint16_t systemColorMap16[0x10000];
|
||||
uint32_t systemColorMap32[0x10000];
|
||||
int RGB_LOW_BITS_MASK = 0;
|
||||
int RGB_LOW_BITS_MASK = 0x821; // used for 16bit inter-frame filters
|
||||
int systemRedShift = 0;
|
||||
int systemBlueShift = 0;
|
||||
int systemGreenShift = 0;
|
||||
|
@ -189,7 +194,7 @@ static struct palettes_t defaultGBPalettes[] = {
|
|||
},
|
||||
{
|
||||
"Weird Colors",
|
||||
{ 0x621F, 0x401F, 0x001F, 0x2010, 0x621F, 0x401F, 0x001F, 0x2010 }
|
||||
{ 0x621F, 0x401F, 0x001F, 0x2010, 0x621F, 0x401F, 0x001F, 0x2010 },
|
||||
},
|
||||
{
|
||||
"Real GB Colors",
|
||||
|
@ -630,9 +635,9 @@ void retro_init(void)
|
|||
bool yes = true;
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &yes);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble)) {
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
|
||||
rumble_cb = rumble.set_rumble_state;
|
||||
} else
|
||||
else
|
||||
rumble_cb = NULL;
|
||||
}
|
||||
|
||||
|
@ -1211,6 +1216,40 @@ static void update_variables(bool startup)
|
|||
gbColorOption = (!strcmp(var.value, "enabled")) ? 1 : 0;
|
||||
}
|
||||
|
||||
var.key = "vbam_lcdfilter";
|
||||
var.value = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
bool prev_lcdfilter = option_lcdfilter;
|
||||
option_lcdfilter = (!strcmp(var.value, "enabled")) ? true : false;
|
||||
if (prev_lcdfilter != option_lcdfilter)
|
||||
utilUpdateSystemColorMaps(option_lcdfilter);
|
||||
}
|
||||
|
||||
var.key = "vbam_interframeblending";
|
||||
var.value = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (!strcmp(var.value, "smart"))
|
||||
{
|
||||
if (systemColorDepth == 16)
|
||||
ifb_filter_func = SmartIB;
|
||||
else
|
||||
ifb_filter_func = SmartIB32;
|
||||
}
|
||||
else if (!strcmp(var.value, "motion blur"))
|
||||
{
|
||||
if (systemColorDepth == 16)
|
||||
ifb_filter_func = MotionBlurIB;
|
||||
else
|
||||
ifb_filter_func = MotionBlurIB32;
|
||||
}
|
||||
else
|
||||
ifb_filter_func = NULL;
|
||||
}
|
||||
else
|
||||
ifb_filter_func = NULL;
|
||||
|
||||
var.key = "vbam_show_advanced_options";
|
||||
var.value = NULL;
|
||||
|
||||
|
@ -1285,6 +1324,7 @@ static void update_variables(bool startup)
|
|||
#define ROUND(x) floor((x) + 0.5)
|
||||
#define ASTICK_MAX 0x8000
|
||||
static int analog_x, analog_y, analog_z;
|
||||
static uint32_t input_buf[MAX_PLAYERS] = { 0 };
|
||||
|
||||
static void updateInput_MotionSensors(void)
|
||||
{
|
||||
|
@ -1366,6 +1406,45 @@ void updateInput_SolarSensor(void)
|
|||
}
|
||||
}
|
||||
|
||||
// Update joypads
|
||||
static void updateInput_Joypad(void)
|
||||
{
|
||||
unsigned max_buttons = MAX_BUTTONS - ((type == IMAGE_GB) ? 2 : 0); // gb only has 8 buttons
|
||||
|
||||
for (unsigned port = 0; port < MAX_PLAYERS; port++)
|
||||
{
|
||||
// Reset input states
|
||||
input_buf[port] = 0;
|
||||
|
||||
if (retropad_device[port] == RETRO_DEVICE_JOYPAD) {
|
||||
for (unsigned button = 0; button < max_buttons; button++)
|
||||
input_buf[port] |= input_cb(port, RETRO_DEVICE_JOYPAD, 0, binds[button]) << button;
|
||||
|
||||
if (option_turboEnable) {
|
||||
/* Handle Turbo A & B buttons */
|
||||
for (unsigned tbutton = 0; tbutton < TURBO_BUTTONS; tbutton++) {
|
||||
if (input_cb(port, RETRO_DEVICE_JOYPAD, 0, turbo_binds[tbutton])) {
|
||||
if (!turbo_delay_counter[port][tbutton])
|
||||
input_buf[port] |= 1 << tbutton;
|
||||
turbo_delay_counter[port][tbutton]++;
|
||||
if (turbo_delay_counter[port][tbutton] > option_turboDelay)
|
||||
/* Reset the toggle if delay value is reached */
|
||||
turbo_delay_counter[port][tbutton] = 0;
|
||||
}
|
||||
else
|
||||
/* If the button is not pressed, just reset the toggle */
|
||||
turbo_delay_counter[port][tbutton] = 0;
|
||||
}
|
||||
}
|
||||
// Do not allow opposing directions
|
||||
if ((input_buf[port] & 0x30) == 0x30)
|
||||
input_buf[port] &= ~(0x30);
|
||||
else if ((input_buf[port] & 0xC0) == 0xC0)
|
||||
input_buf[port] &= ~(0xC0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool firstrun = true;
|
||||
static unsigned has_frame;
|
||||
|
||||
|
@ -1402,6 +1481,7 @@ void retro_run(void)
|
|||
|
||||
poll_cb();
|
||||
|
||||
updateInput_Joypad();
|
||||
updateInput_SolarSensor();
|
||||
updateInput_MotionSensors();
|
||||
|
||||
|
@ -1539,8 +1619,8 @@ bool retro_load_game(const struct retro_game_info *game)
|
|||
return false;
|
||||
}
|
||||
|
||||
utilUpdateSystemColorMaps(option_lcdfilter);
|
||||
update_variables(true);
|
||||
utilUpdateSystemColorMaps(false);
|
||||
soundInit();
|
||||
|
||||
if (type == IMAGE_GBA) {
|
||||
|
@ -1701,6 +1781,8 @@ bool systemCanChangeSoundQuality(void)
|
|||
void systemDrawScreen(void)
|
||||
{
|
||||
unsigned pitch = systemWidth * (systemColorDepth >> 3);
|
||||
if (ifb_filter_func)
|
||||
ifb_filter_func(pix, pitch, systemWidth, systemHeight);
|
||||
video_cb(pix, systemWidth, systemHeight, pitch);
|
||||
}
|
||||
|
||||
|
@ -1742,40 +1824,9 @@ void systemMessage(int, const char* fmt, ...)
|
|||
|
||||
uint32_t systemReadJoypad(int which)
|
||||
{
|
||||
uint32_t J = 0;
|
||||
unsigned i, buttons = MAX_BUTTONS - ((type == IMAGE_GB) ? 2 : 0); // gb only has 8 buttons
|
||||
|
||||
if (which == -1)
|
||||
which = 0;
|
||||
|
||||
if (retropad_device[which] == RETRO_DEVICE_JOYPAD) {
|
||||
for (i = 0; i < buttons; i++)
|
||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds[i]) << i;
|
||||
|
||||
if (option_turboEnable) {
|
||||
/* Handle Turbo A & B buttons */
|
||||
for (i = 0; i < TURBO_BUTTONS; i++) {
|
||||
if (input_cb(which, RETRO_DEVICE_JOYPAD, 0, turbo_binds[i])) {
|
||||
if (!turbo_delay_counter[which][i])
|
||||
J |= 1 << i;
|
||||
turbo_delay_counter[which][i]++;
|
||||
if (turbo_delay_counter[which][i] > option_turboDelay)
|
||||
/* Reset the toggle if delay value is reached */
|
||||
turbo_delay_counter[which][i] = 0;
|
||||
} else
|
||||
/* If the button is not pressed, just reset the toggle */
|
||||
turbo_delay_counter[which][i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do not allow opposing directions
|
||||
if ((J & 0x30) == 0x30)
|
||||
J &= ~(0x30);
|
||||
else if ((J & 0xC0) == 0xC0)
|
||||
J &= ~(0xC0);
|
||||
|
||||
return J;
|
||||
return input_buf[which];
|
||||
}
|
||||
|
||||
static void systemUpdateSolarSensor(int v)
|
||||
|
|
|
@ -189,6 +189,29 @@ struct retro_core_option_definition option_defs_us[] = {
|
|||
},
|
||||
"disabled"
|
||||
},
|
||||
{
|
||||
"vbam_lcdfilter",
|
||||
"LCD Color Filter",
|
||||
"TODO:",
|
||||
{
|
||||
{ "disabled", NULL },
|
||||
{ "enabled", NULL },
|
||||
{ NULL, NULL },
|
||||
},
|
||||
"disabled"
|
||||
},
|
||||
{
|
||||
"vbam_interframeblending",
|
||||
"Interframe Blending",
|
||||
"TODO:",
|
||||
{
|
||||
{ "disabled", NULL },
|
||||
{ "smart", NULL },
|
||||
{ "motion blur", NULL },
|
||||
{ NULL, NULL },
|
||||
},
|
||||
"disabled"
|
||||
},
|
||||
{
|
||||
"vbam_turboenable",
|
||||
"Enable Turbo Buttons",
|
||||
|
|
Loading…
Reference in New Issue