Commit c236907b authored by M4xw's avatar M4xw 🍗

Merge branch 'switch_upstream' into 'develop'

Switch upstream

See merge request !7
parents 30c588bd 8bf342aa
Pipeline #3959 passed with stage
in 6 minutes and 44 seconds
......@@ -22,7 +22,7 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2017 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2017 qwertymodo
......@@ -140,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2017 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -148,7 +148,7 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2017 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
......
......@@ -22,10 +22,12 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2016 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2017 qwertymodo
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -138,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2016 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -146,14 +148,14 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2016 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2011 zones
Libretro port
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -272,7 +274,7 @@ static void DeStereo (uint8 *buffer, int sample_count)
int16 *buf = (int16 *) buffer;
int32 s1, s2;
for (int i = 0; i < sample_count >> 1; i++)
for (int i = 0; i < (sample_count >> 1); i++)
{
s1 = (int32) buf[2 * i];
s2 = (int32) buf[2 * i + 1];
......@@ -346,7 +348,7 @@ bool8 S9xMixSamples (uint8 *buffer, int sample_count)
if (msu::resampler->avail() >= sample_count)
{
msu::resampler->read((short *)msu::resample_buffer, sample_count);
for (uint32 i = 0; i < sample_count; ++i)
for (int i = 0; i < sample_count; ++i)
*((int16*)(dest+(i * 2))) += *((int16*)(msu::resample_buffer +(i * 2)));
}
else // should never occur
......@@ -756,7 +758,6 @@ void S9xAPULoadState (uint8 *block)
SNES::dsp.clock = SNES::get_le32(ptr);
ptr += sizeof(int32);
memcpy (SNES::cpu.registers, ptr, 4);
ptr += 4;
}
static void to_var_from_buf (uint8 **buf, void *var, size_t size)
......@@ -897,4 +898,3 @@ bool8 S9xSPCDump (const char *filename)
return (TRUE);
}
......@@ -22,10 +22,12 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2011 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2017 qwertymodo
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -122,6 +124,9 @@
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
S-SMP emulator code used in 1.54+
(c) Copyright 2016 byuu
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
......@@ -135,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2011 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -143,14 +148,14 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2011 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2011 zones
Libretro port
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......
......@@ -131,6 +131,9 @@ static short const gauss [512] =
inline int SPC_DSP::interpolate( voice_t const* v )
{
// libretro: alternate methods
if(libretro_get_snes_interp()) return libretro_snes_interp((void*)v);
// Make pointers into gaussian based on fractional position between samples
int offset = v->interp_pos >> 4 & 0xFF;
short const* fwd = gauss + 255 - offset;
......@@ -416,7 +419,8 @@ inline VOICE_CLOCK( V3b )
m.t_brr_byte = m.ram [(v->brr_addr + v->brr_offset) & 0xFFFF];
m.t_brr_header = m.ram [v->brr_addr]; // brr_addr doesn't need masking
}
VOICE_CLOCK( V3c )
inline VOICE_CLOCK( V3c )
{
// Pitch modulation using previous voice's output
if ( m.t_pmon & v->vbit )
......@@ -510,7 +514,8 @@ inline void SPC_DSP::voice_output( voice_t const* v, int ch )
CLAMP16( m.t_echo_out [ch] );
}
}
VOICE_CLOCK( V4 )
inline VOICE_CLOCK( V4 )
{
// Decode BRR
m.t_looped = 0;
......@@ -810,7 +815,7 @@ void SPC_DSP::run( int clocks_remain )
{
loop:
#define PHASE( n ) if ( n && !--clocks_remain ) break; case n:
#define PHASE( n ) if ( n && !--clocks_remain ) break; /* Fall through */ case n:
GEN_DSP_TIMING
#undef PHASE
......
......@@ -51,8 +51,8 @@ void SMP::op_write(uint16 addr, uint8 data) {
void SMP::op_step() {
#define op_readpc() op_read(regs.pc++)
#define op_readdp(addr) op_read((regs.p.p << 8) + (addr & 0xff))
#define op_writedp(addr, data) op_write((regs.p.p << 8) + (addr & 0xff), data)
#define op_readdp(addr) op_read((regs.p.p << 8) + ((addr) & 0xff))
#define op_writedp(addr, data) op_write((regs.p.p << 8) + ((addr) & 0xff), data)
#define op_readaddr(addr) op_read(addr)
#define op_writeaddr(addr, data) op_write(addr, data)
#define op_readstack() op_read(0x0100 | ++regs.sp)
......@@ -62,7 +62,17 @@ void SMP::op_step() {
#if defined(PSEUDO_CYCLE)
if(opcode_cycle == 0)
{
#ifdef DEBUGGER
if (Settings.TraceSMP)
{
disassemble_opcode(tmp, regs.pc);
S9xTraceMessage (tmp);
}
#endif
opcode_number = op_readpc();
}
switch(opcode_number) {
#include "core/oppseudo_misc.cpp"
......
......@@ -373,7 +373,8 @@ case 0xaf: {
switch(++opcode_cycle) {
case 1:
op_io(2);
case 2:
break;
case 2:
op_writedp(regs.x++, regs.B.a);
opcode_cycle = 0;
break;
......
......@@ -288,7 +288,7 @@ void SMP::disassemble_opcode(char *output, uint16 addr) {
strcat(s, t);
sprintf(t, "A:%.2x X:%.2x Y:%.2x SP:01%.2x YA:%.4x ",
regs.a, regs.x, regs.y, regs.sp, (uint16)regs.ya);
regs.B.a, regs.x, regs.B.y, regs.sp, (uint16)regs.ya);
strcat(s, t);
sprintf(t, "%c%c%c%c%c%c%c%c",
......@@ -301,4 +301,9 @@ void SMP::disassemble_opcode(char *output, uint16 addr) {
regs.p.z ? 'Z' : 'z',
regs.p.c ? 'C' : 'c');
strcat(s, t);
sprintf(t, " %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x",
apuram[0xf4], apuram[0xf5], apuram[0xf6], apuram[0xf7],
cpu.port_read(0), cpu.port_read(1), cpu.port_read(2), cpu.port_read(3));
strcat(s, t);
}
#define CYCLE_ACCURATE
#define PSEUDO_CYCLE
#include <snes/snes.hpp>
#define SMP_CPP
namespace SNES {
#if defined(DEBUGGER)
#include "debugger/debugger.cpp"
#include "debugger/disassembler.cpp"
SMPDebugger smp;
#else
SMP smp;
#define CYCLE_ACCURATE
#define PSEUDO_CYCLE
#ifdef DEBUGGER
#include "../../../snes9x.h"
#include "../../../debug.h"
char tmp[1024];
#endif
#include <snes/snes.hpp>
#define SMP_CPP
namespace SNES {
// TODO: reactivate once APU debugger works again
#ifdef DEBUGGER
// #include "debugger/debugger.cpp"
#include "debugger/disassembler.cpp"
SMP smp;
#else
SMP smp;
#endif
#include "algorithms.cpp"
......@@ -152,6 +159,7 @@ SMP::SMP() {
}
SMP::~SMP() {
delete[] apuram;
}
}
......@@ -122,9 +122,15 @@ public:
inline uint8 op_lsr (uint8 x);
inline uint8 op_rol (uint8 x);
inline uint8 op_ror (uint8 x);
#ifdef DEBUGGER
void disassemble_opcode(char *output, uint16 addr);
inline uint8 disassemble_read(uint16 addr);
inline uint16 relb(int8 offset, int op_len);
#endif
};
#if defined(DEBUGGER)
// TODO: reactivate once APU debugger works again
#if 0 // DEBUGGER
#include "debugger/debugger.hpp"
extern SMPDebugger smp;
#else
......
......@@ -66,12 +66,12 @@ class HermiteResampler : public Resampler
void
read (short *data, int num_samples)
{
//If we are outputting the exact same ratio as the input, pull directly from the input buffer
if (r_step == 1.0)
{
ring_buffer::pull((unsigned char*)data, num_samples * sizeof(short));
return;
}
//If we are outputting the exact same ratio as the input, pull directly from the input buffer
if (r_step == 1.0)
{
ring_buffer::pull((unsigned char*)data, num_samples * sizeof(short));
return;
}
int i_position = start >> 1;
int max_samples = buffer_size >> 1;
......@@ -88,7 +88,7 @@ class HermiteResampler : public Resampler
while (r_frac <= 1.0 && o_position < num_samples)
{
hermite_val[0] = hermite (r_frac, r_left [0], r_left [1], r_left [2], r_left [3]);
hermite_val[1] = hermite (r_frac, r_right[0], r_right[1], r_right[2], r_right[3]);
hermite_val[1] = hermite (r_frac, r_right[0], r_right[1], r_right[2], r_right[3]);
data[o_position] = SHORT_CLAMP (hermite_val[0]);
data[o_position + 1] = SHORT_CLAMP (hermite_val[1]);
......@@ -127,13 +127,13 @@ class HermiteResampler : public Resampler
inline int
avail (void)
{
//If we are outputting the exact same ratio as the input, find out directly from the input buffer
if (r_step == 1.0)
{
return (ring_buffer::space_filled() + sizeof(short) - 1) / sizeof(short);
}
//If we are outputting the exact same ratio as the input, find out directly from the input buffer
if (r_step == 1.0)
{
return (ring_buffer::space_filled() + sizeof(short) - 1) / sizeof(short);
}
return (int) floor (((size >> 2) - r_frac) / r_step) * 2;
return (int) floor (((size >> 2) - r_frac) / r_step) * 2;
}
};
......
......@@ -12,7 +12,7 @@ class Resampler : public ring_buffer
virtual void time_ratio (double) = 0;
virtual void read (short *, int) = 0;
virtual int avail (void) = 0;
Resampler (int num_samples) : ring_buffer (num_samples << 1)
{
}
......@@ -33,19 +33,19 @@ class Resampler : public ring_buffer
}
inline int
space_empty (void)
space_empty (void) const
{
return buffer_size - size;
}
inline int
space_filled (void)
space_filled (void) const
{
return size;
}
inline int
max_write (void)
max_write (void) const
{
return space_empty () >> 1;
}
......
......@@ -69,13 +69,13 @@ public:
}
inline int
space_empty (void)
space_empty (void) const
{
return buffer_size - size;
}
inline int
space_filled (void)
space_filled (void) const
{
return size;
}
......@@ -96,7 +96,7 @@ public:
buffer = new unsigned char[buffer_size];
memset (buffer, 0, this->buffer_size);
size = 0;
this->size = 0;
start = 0;
}
......
This diff is collapsed.
......@@ -22,10 +22,12 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2011 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2017 qwertymodo
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -122,6 +124,9 @@
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
S-SMP emulator code used in 1.54+
(c) Copyright 2016 byuu
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
......@@ -135,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2011 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -143,14 +148,14 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2011 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2011 zones
Libretro port
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -188,6 +193,8 @@
#ifndef _BSX_H_
#define _BSX_H_
#include <fstream>
struct SBSX
{
bool8 dirty; // Changed register values
......@@ -205,6 +212,22 @@ struct SBSX
uint8 MMC[16];
uint8 prevMMC[16];
uint8 test2192[32];
bool flash_csr;
bool flash_gsr;
bool flash_bsr;
bool flash_cmd_done;
std::ifstream sat_stream1;
std::ifstream sat_stream2;
bool sat_pf_latch1_enable, sat_dt_latch1_enable;
bool sat_pf_latch2_enable, sat_dt_latch2_enable;
bool sat_stream1_loaded, sat_stream2_loaded;
bool sat_stream1_first, sat_stream2_first;
uint8 sat_stream1_count, sat_stream2_count;
uint16 sat_stream1_queue, sat_stream2_queue;
};
extern struct SBSX BSX;
......
......@@ -22,7 +22,7 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2017 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2017 qwertymodo
......@@ -140,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2017 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -148,7 +148,7 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2017 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
......
......@@ -22,7 +22,7 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2017 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2017 qwertymodo
......@@ -140,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2017 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -148,7 +148,7 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2017 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
......
......@@ -22,7 +22,7 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2017 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2017 qwertymodo
......@@ -140,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2017 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -148,7 +148,7 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2017 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
......@@ -1207,11 +1207,12 @@ void S9xSetC4 (uint8 byte, uint16 Address)
if (Memory.C4RAM[0x1f4d] != 0x0e)
printf("$7f4d=%02x, expected 0e for command 54 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]);
#endif
int64 b = (int64) READ_3WORD(Memory.C4RAM + 0x1f80);
int64 c = b << 40;
int64 a = SAR(c, 30);
// libretro: msvc2005 hack
int64 b = (int64) READ_3WORD(Memory.C4RAM + 0x1f80);
int64 c = b << 40;
int64 a = SAR(c, 30);
//printf("%08X%08X\n", (uint32) (a>>32), (uint32) (a&0xFFFFFFFF));
a = SAR(c, 10);
a = SAR(c, 10);
a *= a;
//printf("%08X%08X\n", (uint32) (a>>32), (uint32) (a&0xFFFFFFFF));
WRITE_3WORD(Memory.C4RAM + 0x1f83, a);
......
......@@ -22,10 +22,12 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2011 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2017 qwertymodo
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -122,6 +124,9 @@
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
S-SMP emulator code used in 1.54+
(c) Copyright 2016 byuu
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
......@@ -135,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2011 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -143,14 +148,14 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2011 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2011 zones
Libretro port
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -256,8 +261,8 @@ const char * S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram,
if (sscanf(tmp, "%x", &address) != 1)
return ("Invalid Gold Finger code.");
//Correct GoldFinger Address
address=(address&0x7FFF)|((address&0x7F8000)<<1)|0x8000;
// Correct GoldFinger Address
address = (address & 0x7FFF) | ((address & 0x7F8000) << 1) | 0x8000;
for (i = 0; i < 3; i++)
{
......
......@@ -22,10 +22,12 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2011 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2017 qwertymodo
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -122,6 +124,9 @@
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
S-SMP emulator code used in 1.54+
(c) Copyright 2016 byuu
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
......@@ -135,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2011 BearOso
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
......@@ -143,14 +148,14 @@
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2011 OV2
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2011 zones
Libretro port
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......
......@@ -22,10 +22,12 @@
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2011 BearOso,
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2011 - 2016 Hans-Kristian Arntzen,
(c) Copyright 2017 qwertymodo
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
......@@ -122,6 +124,9 @@
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
S-SMP emulator code used in 1.54+
(c) Copyright 2016 byuu
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
......@@ -135,7 +140,7 @@
(c) Copyright 2006 - 2007 Shay Green