mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
Merge from libretro/master:46902e0 for repo synchronization
This commit is contained in:
parent
9d1ecde692
commit
61d76999d7
74 changed files with 14043 additions and 2094 deletions
|
@ -1817,7 +1817,7 @@ static void REGPARM(3) sh2_write32_dram(u32 a, u32 d, SH2 *sh2)
|
|||
static void REGPARM(3) sh2_write32_sdram(u32 a, u32 d, SH2 *sh2)
|
||||
{
|
||||
u32 a1 = a & 0x3fffc;
|
||||
*(u32 *)(sh2->p_sdram + a1) = (d << 16) | (d >> 16);
|
||||
*(u32 *)((char*)sh2->p_sdram + a1) = (d << 16) | (d >> 16);
|
||||
#ifdef DRC_SH2
|
||||
u8 *p = sh2->p_drcblk_ram;
|
||||
u32 t = p[a1 >> SH2_DRCBLK_RAM_SHIFT];
|
||||
|
@ -1940,7 +1940,7 @@ void *p32x_sh2_get_mem_ptr(u32 a, u32 *mask, SH2 *sh2)
|
|||
} else if ((a & 0xc6000000) == 0x02000000) {
|
||||
// banked ROM. Return bank address
|
||||
u32 bank = carthw_ssf2_banks[(a >> 19) & 7] << 19;
|
||||
ret = sh2->p_rom + bank;
|
||||
ret = (char*)sh2->p_rom + bank;
|
||||
*mask = 0x07ffff;
|
||||
}
|
||||
|
||||
|
@ -1950,7 +1950,7 @@ void *p32x_sh2_get_mem_ptr(u32 a, u32 *mask, SH2 *sh2)
|
|||
int p32x_sh2_memcpy(u32 dst, u32 src, int count, int size, SH2 *sh2)
|
||||
{
|
||||
u32 mask;
|
||||
void *ps, *pd;
|
||||
u8 *ps, *pd;
|
||||
int len, i;
|
||||
|
||||
// check if src and dst points to memory (rom/sdram/dram/da)
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
#include "../unzip/unzip.h"
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef USE_LIBRETRO_VFS
|
||||
#include "file_stream_transforms.h"
|
||||
#endif
|
||||
|
||||
static int rom_alloc_size;
|
||||
static const char *rom_exts[] = { "bin", "gen", "smd", "iso", "sms", "gg", "sg" };
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
#include "cdd.h"
|
||||
#include "cue.h"
|
||||
|
||||
#ifdef USE_LIBRETRO_VFS
|
||||
#include "file_stream_transforms.h"
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 7
|
||||
#pragma GCC diagnostic ignored "-Wformat-truncation"
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#include "../pico_int.h"
|
||||
// #define elprintf(w,f,...) printf(f "\n",##__VA_ARGS__);
|
||||
|
||||
#ifdef USE_LIBRETRO_VFS
|
||||
#include "file_stream_transforms.h"
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
@ -74,9 +78,11 @@ static int get_ext(const char *fname, char ext[4],
|
|||
strcpy(ext, fname + pos);
|
||||
|
||||
if (base != NULL) {
|
||||
len = pos;
|
||||
if (len + 1 < base_size)
|
||||
len = base_size - 1;
|
||||
if (pos + 1 < base_size)
|
||||
pos = base_size - 1;
|
||||
|
||||
len = (pos < len) ? pos : len;
|
||||
|
||||
memcpy(base, fname, len);
|
||||
base[len] = 0;
|
||||
}
|
||||
|
|
|
@ -1587,7 +1587,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
|
|||
for (i = 0; i < 0x40 / 2; i++) {
|
||||
t = spal[i];
|
||||
#ifdef USE_BGR555
|
||||
t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);
|
||||
t = ((t & 0x0e000e00)<< 3) | ((t & 0x00e000e0)<<2) | ((t & 0x000e000e)<<1);
|
||||
#else
|
||||
t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);
|
||||
#endif
|
||||
|
@ -2005,7 +2005,7 @@ void PicoDrawSetOutBufMD(void *dest, int increment)
|
|||
if (dest != NULL) {
|
||||
DrawLineDestBase = dest;
|
||||
DrawLineDestIncrement = increment;
|
||||
Pico.est.DrawLineDest = DrawLineDestBase + Pico.est.DrawScanline * increment;
|
||||
Pico.est.DrawLineDest = (char *)DrawLineDestBase + Pico.est.DrawScanline * increment;
|
||||
}
|
||||
else {
|
||||
DrawLineDestBase = DefOutBuff;
|
||||
|
|
|
@ -338,7 +338,7 @@ void PicoDoHighPal555M4(void)
|
|||
for (i = 0x20/2; i > 0; i--, spal++, dpal++) {
|
||||
t = *spal;
|
||||
#ifdef USE_BGR555
|
||||
t = ((t & 0x00030003)<< 3) | ((t & 0x000c000c)<<7) | ((t & 0x00300030)<<10);
|
||||
t = ((t & 0x00030003)<< 3) | ((t & 0x000c000c)<<6) | ((t & 0x00300030)<<9);
|
||||
#else
|
||||
t = ((t & 0x00030003)<<14) | ((t & 0x000c000c)<<7) | ((t & 0x00300030)>>1);
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#include "memory.h"
|
||||
#include "patch.h"
|
||||
|
||||
#ifdef USE_LIBRETRO_VFS
|
||||
#include "file_stream_transforms.h"
|
||||
#endif
|
||||
|
||||
struct patch
|
||||
{
|
||||
unsigned int addr;
|
||||
|
|
|
@ -102,6 +102,8 @@ typedef struct
|
|||
unsigned short overclockM68k; // overclock the emulated 68k, in %
|
||||
|
||||
int sndRate; // rate in Hz
|
||||
unsigned short sndFilter; // Set low pass sound filter 0: off, 1: on (use integer in case we want to add other filter types later)
|
||||
int32_t sndFilterRange; // Low pass sound filter range [0, 65536]
|
||||
short *sndOut; // PCM output buffer
|
||||
void (*writeSound)(int len); // write .sndOut callback, called once per frame
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#include "pico_int.h"
|
||||
#include "memory.h"
|
||||
|
||||
#ifdef USE_LIBRETRO_VFS
|
||||
#include "file_stream_transforms.h"
|
||||
#endif
|
||||
|
||||
/* context */
|
||||
// Cyclone 68000
|
||||
#ifdef EMU_C68K
|
||||
|
|
|
@ -26,6 +26,73 @@ short cdda_out_buffer[2*1152];
|
|||
// sn76496
|
||||
extern int *sn76496_regs;
|
||||
|
||||
// Low pass filter 'previous' samples
|
||||
static int32_t lpf_lp;
|
||||
static int32_t lpf_rp;
|
||||
|
||||
static void low_pass_filter_stereo(int *buf32, int length)
|
||||
{
|
||||
int samples = length;
|
||||
int *out32 = buf32;
|
||||
// Restore previous samples
|
||||
int32_t lpf_l = lpf_lp;
|
||||
int32_t lpf_r = lpf_rp;
|
||||
|
||||
// Single-pole low-pass filter (6 dB/octave)
|
||||
int32_t factor_a = PicoIn.sndFilterRange;
|
||||
int32_t factor_b = 0x10000 - factor_a;
|
||||
|
||||
do
|
||||
{
|
||||
// Apply low-pass filter
|
||||
lpf_l = (lpf_l * factor_a) + (out32[0] * factor_b);
|
||||
lpf_r = (lpf_r * factor_a) + (out32[1] * factor_b);
|
||||
|
||||
// 16.16 fixed point
|
||||
lpf_l >>= 16;
|
||||
lpf_r >>= 16;
|
||||
|
||||
// Update sound buffer
|
||||
*out32++ = lpf_l;
|
||||
*out32++ = lpf_r;
|
||||
}
|
||||
while (--samples);
|
||||
|
||||
// Save last samples for next frame
|
||||
lpf_lp = lpf_l;
|
||||
lpf_rp = lpf_r;
|
||||
}
|
||||
|
||||
static void low_pass_filter_mono(int *buf32, int length)
|
||||
{
|
||||
int samples = length;
|
||||
int *out32 = buf32;
|
||||
// Restore previous sample
|
||||
int32_t lpf_l = lpf_lp;
|
||||
|
||||
// Single-pole low-pass filter (6 dB/octave)
|
||||
int32_t factor_a = PicoIn.sndFilterRange;
|
||||
int32_t factor_b = 0x10000 - factor_a;
|
||||
|
||||
do
|
||||
{
|
||||
// Apply low-pass filter
|
||||
lpf_l = (lpf_l * factor_a) + (out32[0] * factor_b);
|
||||
|
||||
// 16.16 fixed point
|
||||
lpf_l >>= 16;
|
||||
|
||||
// Update sound buffer
|
||||
*out32++ = lpf_l;
|
||||
}
|
||||
while (--samples);
|
||||
|
||||
// Save last sample for next frame
|
||||
lpf_lp = lpf_l;
|
||||
}
|
||||
|
||||
void (*low_pass_filter)(int *buf32, int length) = low_pass_filter_stereo;
|
||||
|
||||
// ym2413
|
||||
#define YM2413_CLK 3579545
|
||||
OPLL old_opll;
|
||||
|
@ -51,6 +118,11 @@ PICO_INTERNAL void PsndReset(void)
|
|||
// PsndRerate calls YM2612Init, which also resets
|
||||
PsndRerate(0);
|
||||
timers_reset();
|
||||
|
||||
// Reset low pass filter
|
||||
lpf_lp = 0;
|
||||
lpf_rp = 0;
|
||||
|
||||
mix_reset();
|
||||
}
|
||||
|
||||
|
@ -107,6 +179,9 @@ void PsndRerate(int preserve_state)
|
|||
// set mixer
|
||||
PsndMix_32_to_16l = (PicoIn.opt & POPT_EN_STEREO) ? mix_32_to_16l_stereo : mix_32_to_16_mono;
|
||||
|
||||
// set low pass filter
|
||||
low_pass_filter = (PicoIn.opt & POPT_EN_STEREO) ? low_pass_filter_stereo : low_pass_filter_mono;
|
||||
|
||||
if (PicoIn.AHW & PAHW_PICO)
|
||||
PicoReratePico();
|
||||
}
|
||||
|
@ -388,6 +463,11 @@ static int PsndRender(int offset, int length)
|
|||
if ((PicoIn.AHW & PAHW_32X) && (PicoIn.opt & POPT_EN_PWM))
|
||||
p32x_pwm_update(buf32, length-offset, stereo);
|
||||
|
||||
// Apply low pass filter, if required
|
||||
if (PicoIn.sndFilter == 1) {
|
||||
low_pass_filter(buf32, length);
|
||||
}
|
||||
|
||||
// convert + limit to normal 16bit output
|
||||
PsndMix_32_to_16l(PicoIn.sndOut+(offset<<stereo), buf32, length-offset);
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
#include "sound/emu2413/emu2413.h"
|
||||
#include "state.h"
|
||||
|
||||
#ifdef USE_LIBRETRO_VFS
|
||||
#include "file_stream_transforms.h"
|
||||
#endif
|
||||
|
||||
// sn76496 & ym2413
|
||||
extern int *sn76496_regs;
|
||||
extern OPLL old_opll;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue