mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2024-11-27 01:50:21 +00:00
commit
e16cfa1da0
95
libretro.cpp
95
libretro.cpp
@ -38,7 +38,7 @@ std::string retro_base_directory;
|
|||||||
|
|
||||||
#define MEDNAFEN_CORE_NAME_MODULE "pce_fast"
|
#define MEDNAFEN_CORE_NAME_MODULE "pce_fast"
|
||||||
#define MEDNAFEN_CORE_NAME "Beetle PCE Fast"
|
#define MEDNAFEN_CORE_NAME "Beetle PCE Fast"
|
||||||
#define MEDNAFEN_CORE_VERSION "v0.9.38.7"
|
#define MEDNAFEN_CORE_VERSION "v1.29.0.0"
|
||||||
#define MEDNAFEN_CORE_EXTENSIONS "pce|cue|ccd|chd|toc|m3u"
|
#define MEDNAFEN_CORE_EXTENSIONS "pce|cue|ccd|chd|toc|m3u"
|
||||||
#define MEDNAFEN_CORE_TIMING_FPS 59.82
|
#define MEDNAFEN_CORE_TIMING_FPS 59.82
|
||||||
#define MEDNAFEN_CORE_GEOMETRY_BASE_W 256
|
#define MEDNAFEN_CORE_GEOMETRY_BASE_W 256
|
||||||
@ -66,6 +66,8 @@ static bool use_palette = false;
|
|||||||
|
|
||||||
std::string setting_pce_fast_cdbios = "syscard3.pce";
|
std::string setting_pce_fast_cdbios = "syscard3.pce";
|
||||||
|
|
||||||
|
static int16_t sound_buf[0x10000];
|
||||||
|
|
||||||
extern MDFNGI EmulatedPCE_Fast;
|
extern MDFNGI EmulatedPCE_Fast;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -738,19 +740,19 @@ static DECLFR(IORead)
|
|||||||
{
|
{
|
||||||
PCEF_CASEL(VDC_00, 0x00):
|
PCEF_CASEL(VDC_00, 0x00):
|
||||||
HuC6280_StealCycle();
|
HuC6280_StealCycle();
|
||||||
return(VDC_Read(0, FALSE));
|
return(VDC_Read(0, false));
|
||||||
|
|
||||||
PCEF_CASEL(VDC_01, 0x01):
|
PCEF_CASEL(VDC_01, 0x01):
|
||||||
HuC6280_StealCycle();
|
HuC6280_StealCycle();
|
||||||
return(VDC_Read(1, FALSE));
|
return(VDC_Read(1, false));
|
||||||
|
|
||||||
PCEF_CASEL(VDC_02, 0x02):
|
PCEF_CASEL(VDC_02, 0x02):
|
||||||
HuC6280_StealCycle();
|
HuC6280_StealCycle();
|
||||||
return(VDC_Read(2, FALSE));
|
return(VDC_Read(2, false));
|
||||||
|
|
||||||
PCEF_CASEL(VDC_03, 0x03):
|
PCEF_CASEL(VDC_03, 0x03):
|
||||||
HuC6280_StealCycle();
|
HuC6280_StealCycle();
|
||||||
return(VDC_Read(3, FALSE));
|
return(VDC_Read(3, false));
|
||||||
|
|
||||||
PCEF_CASEL(VCE_00, 0x04):
|
PCEF_CASEL(VCE_00, 0x04):
|
||||||
PCEF_CASEL(VCE_01, 0x05):
|
PCEF_CASEL(VCE_01, 0x05):
|
||||||
@ -1082,10 +1084,6 @@ static int LoadCommon(void)
|
|||||||
|
|
||||||
PCE_Power();
|
PCE_Power();
|
||||||
|
|
||||||
#if 0
|
|
||||||
MDFNGameInfo->LayerNames = "Background\0Sprites\0";
|
|
||||||
#endif
|
|
||||||
MDFNGameInfo->fps = (uint32)((double)7159090.90909090 / 455 / 263 * 65536 * 256);
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1243,42 +1241,9 @@ static void Emulate(EmulateSpecStruct *espec)
|
|||||||
|
|
||||||
MDFNMP_ApplyPeriodicCheats();
|
MDFNMP_ApplyPeriodicCheats();
|
||||||
|
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
static bool firstcat = true;
|
|
||||||
MDFN_PixelFormat nf;
|
|
||||||
|
|
||||||
nf.bpp = 16;
|
|
||||||
nf.colorspace = MDFN_COLORSPACE_RGB;
|
|
||||||
nf.Rshift = 11;
|
|
||||||
nf.Gshift = 5;
|
|
||||||
nf.Bshift = 0;
|
|
||||||
nf.Ashift = 16;
|
|
||||||
|
|
||||||
nf.Rprec = 5;
|
|
||||||
nf.Gprec = 6;
|
|
||||||
nf.Bprec = 5;
|
|
||||||
nf.Aprec = 8;
|
|
||||||
|
|
||||||
espec->surface->SetFormat(nf, false);
|
|
||||||
espec->VideoFormatChanged = firstcat;
|
|
||||||
firstcat = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(espec->VideoFormatChanged)
|
if(espec->VideoFormatChanged)
|
||||||
VDC_SetPixelFormat(espec->CustomPalette, espec->CustomPaletteNumEntries);
|
VDC_SetPixelFormat(espec->CustomPalette, espec->CustomPaletteNumEntries);
|
||||||
|
|
||||||
if(espec->SoundFormatChanged)
|
|
||||||
{
|
|
||||||
for(int y = 0; y < 2; y++)
|
|
||||||
{
|
|
||||||
Blip_Buffer_set_sample_rate(&sbuf[y],
|
|
||||||
espec->SoundRate ? espec->SoundRate : 44100, 50);
|
|
||||||
Blip_Buffer_set_clock_rate(&sbuf[y], (long)(PCE_MASTER_CLOCK / 3));
|
|
||||||
Blip_Buffer_bass_freq(&sbuf[y], 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VDC_RunFrame(espec, false);
|
VDC_RunFrame(espec, false);
|
||||||
|
|
||||||
if(PCE_IsCD)
|
if(PCE_IsCD)
|
||||||
@ -1288,18 +1253,17 @@ static void Emulate(EmulateSpecStruct *espec)
|
|||||||
|
|
||||||
psg->EndFrame(HuCPU.timestamp / pce_overclocked);
|
psg->EndFrame(HuCPU.timestamp / pce_overclocked);
|
||||||
|
|
||||||
if(espec->SoundBuf)
|
|
||||||
{
|
{
|
||||||
for(int y = 0; y < 2; y++)
|
uint8_t y;
|
||||||
|
for(y = 0; y < 2; y++)
|
||||||
{
|
{
|
||||||
Blip_Buffer_end_frame(&sbuf[y], HuCPU.timestamp / pce_overclocked);
|
Blip_Buffer_end_frame(&sbuf[y], HuCPU.timestamp / pce_overclocked);
|
||||||
espec->SoundBufSize = Blip_Buffer_read_samples(&sbuf[y], espec->SoundBuf + y,
|
espec->SoundBufSize = Blip_Buffer_read_samples(&sbuf[y],
|
||||||
espec->SoundBufMaxSize);
|
espec->SoundBuf + y,
|
||||||
|
sizeof(sound_buf) >> 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
espec->MasterCycles = HuCPU.timestamp * 3;
|
|
||||||
|
|
||||||
INPUT_FixTS();
|
INPUT_FixTS();
|
||||||
|
|
||||||
HuC6280_ResetTS();
|
HuC6280_ResetTS();
|
||||||
@ -1407,9 +1371,6 @@ bool IsBRAMUsed(void)
|
|||||||
|
|
||||||
MDFNGI EmulatedPCE_Fast =
|
MDFNGI EmulatedPCE_Fast =
|
||||||
{
|
{
|
||||||
MDFN_MASTERCLOCK_FIXED(PCE_MASTER_CLOCK),
|
|
||||||
0,
|
|
||||||
|
|
||||||
true, // Multires possible?
|
true, // Multires possible?
|
||||||
|
|
||||||
0, // lcm_width
|
0, // lcm_width
|
||||||
@ -1605,7 +1566,6 @@ static retro_audio_sample_batch_t audio_batch_cb;
|
|||||||
static retro_environment_t environ_cb;
|
static retro_environment_t environ_cb;
|
||||||
static retro_input_poll_t input_poll_cb;
|
static retro_input_poll_t input_poll_cb;
|
||||||
static retro_input_state_t input_state_cb;
|
static retro_input_state_t input_state_cb;
|
||||||
static double last_sound_rate = 0.0;
|
|
||||||
|
|
||||||
static bool libretro_supports_option_categories = false;
|
static bool libretro_supports_option_categories = false;
|
||||||
static bool libretro_supports_bitmasks = false;
|
static bool libretro_supports_bitmasks = false;
|
||||||
@ -1753,7 +1713,6 @@ void retro_init(void)
|
|||||||
audio_latency = 0;
|
audio_latency = 0;
|
||||||
update_audio_latency = false;
|
update_audio_latency = false;
|
||||||
|
|
||||||
last_sound_rate = 0.0;
|
|
||||||
video_width = 0;
|
video_width = 0;
|
||||||
video_height = 0;
|
video_height = 0;
|
||||||
video_frames = 0;
|
video_frames = 0;
|
||||||
@ -2008,6 +1967,7 @@ static void check_variables(bool first_run)
|
|||||||
|
|
||||||
bool retro_load_game(const struct retro_game_info *info)
|
bool retro_load_game(const struct retro_game_info *info)
|
||||||
{
|
{
|
||||||
|
uint8_t y;
|
||||||
unsigned c;
|
unsigned c;
|
||||||
struct retro_input_descriptor desc[] = {
|
struct retro_input_descriptor desc[] = {
|
||||||
#define button_ids(INDEX) \
|
#define button_ids(INDEX) \
|
||||||
@ -2161,6 +2121,14 @@ bool retro_load_game(const struct retro_game_info *info)
|
|||||||
mmaps.num_descriptors = i;
|
mmaps.num_descriptors = i;
|
||||||
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &mmaps);
|
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &mmaps);
|
||||||
|
|
||||||
|
for(y = 0; y < 2; y++)
|
||||||
|
{
|
||||||
|
Blip_Buffer_set_sample_rate(&sbuf[y],
|
||||||
|
44100, 50);
|
||||||
|
Blip_Buffer_set_clock_rate(&sbuf[y], (long)(PCE_MASTER_CLOCK / 3));
|
||||||
|
Blip_Buffer_bass_freq(&sbuf[y], 10);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2329,7 +2297,6 @@ void update_geometry(unsigned width, unsigned height)
|
|||||||
void retro_run(void)
|
void retro_run(void)
|
||||||
{
|
{
|
||||||
static bool last_palette_format;
|
static bool last_palette_format;
|
||||||
static int16_t sound_buf[0x10000];
|
|
||||||
static int32_t rects[FB_HEIGHT];
|
static int32_t rects[FB_HEIGHT];
|
||||||
EmulateSpecStruct spec;
|
EmulateSpecStruct spec;
|
||||||
bool resolution_changed = false;
|
bool resolution_changed = false;
|
||||||
@ -2397,14 +2364,8 @@ void retro_run(void)
|
|||||||
spec.InterlaceOn = false;
|
spec.InterlaceOn = false;
|
||||||
spec.InterlaceField = false;
|
spec.InterlaceField = false;
|
||||||
spec.skip = skip_frame;
|
spec.skip = skip_frame;
|
||||||
spec.SoundFormatChanged = false;
|
|
||||||
spec.SoundRate = 44100;
|
|
||||||
spec.SoundBuf = sound_buf;
|
spec.SoundBuf = sound_buf;
|
||||||
spec.SoundBufMaxSize = sizeof(sound_buf) >> 1;
|
|
||||||
spec.SoundBufSize = 0;
|
spec.SoundBufSize = 0;
|
||||||
spec.SoundBufSizeALMS = 0;
|
|
||||||
spec.MasterCycles = 0;
|
|
||||||
spec.MasterCyclesALMS = 0;
|
|
||||||
spec.SoundVolume = 1.0;
|
spec.SoundVolume = 1.0;
|
||||||
spec.soundmultiplier = 1.0;
|
spec.soundmultiplier = 1.0;
|
||||||
spec.NeedRewind = false;
|
spec.NeedRewind = false;
|
||||||
@ -2412,24 +2373,12 @@ void retro_run(void)
|
|||||||
|
|
||||||
if (last_palette_format != use_palette)
|
if (last_palette_format != use_palette)
|
||||||
{
|
{
|
||||||
spec.VideoFormatChanged = TRUE;
|
spec.VideoFormatChanged = true;
|
||||||
last_palette_format = use_palette;
|
last_palette_format = use_palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spec.SoundRate != last_sound_rate)
|
|
||||||
{
|
|
||||||
spec.SoundFormatChanged = true;
|
|
||||||
last_sound_rate = spec.SoundRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulate(&spec);
|
Emulate(&spec);
|
||||||
|
|
||||||
int16 *const SoundBuf = spec.SoundBuf + spec.SoundBufSizeALMS * 2; /* 2 sound channels */
|
|
||||||
int32 SoundBufSize = spec.SoundBufSize - spec.SoundBufSizeALMS;
|
|
||||||
const int32 SoundBufMaxSize = spec.SoundBufMaxSize - spec.SoundBufSizeALMS;
|
|
||||||
|
|
||||||
spec.SoundBufSize = spec.SoundBufSizeALMS + SoundBufSize;
|
|
||||||
|
|
||||||
if (skip_frame)
|
if (skip_frame)
|
||||||
video_cb(NULL, video_width, video_height, FB_WIDTH * 2);
|
video_cb(NULL, video_width, video_height, FB_WIDTH * 2);
|
||||||
else
|
else
|
||||||
|
@ -83,14 +83,14 @@ int CDIF::ReadSector(uint8_t* buf, int32_t lba, uint32_t sector_count, bool supp
|
|||||||
uint8_t tmpbuf[2352 + 96];
|
uint8_t tmpbuf[2352 + 96];
|
||||||
|
|
||||||
if(!ReadRawSector(tmpbuf, lba))
|
if(!ReadRawSector(tmpbuf, lba))
|
||||||
return(FALSE);
|
return false;
|
||||||
|
|
||||||
if(!ValidateRawSector(tmpbuf))
|
if(!ValidateRawSector(tmpbuf))
|
||||||
{
|
{
|
||||||
if(!suppress_uncorrectable_message)
|
if(!suppress_uncorrectable_message)
|
||||||
MDFN_DispMessage("Uncorrectable data at sector %d", lba);
|
MDFN_DispMessage("Uncorrectable data at sector %d", lba);
|
||||||
|
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int mode = tmpbuf[12 + 3];
|
const int mode = tmpbuf[12 + 3];
|
||||||
|
@ -212,35 +212,14 @@ typedef struct
|
|||||||
// Skip rendering this frame if true. Set by the driver code.
|
// Skip rendering this frame if true. Set by the driver code.
|
||||||
int skip;
|
int skip;
|
||||||
|
|
||||||
//
|
|
||||||
// If sound is disabled, the driver code must set SoundRate to false, SoundBuf to NULL, SoundBufMaxSize to 0.
|
|
||||||
|
|
||||||
// Will be set to TRUE if the sound format(only rate for now, at least) has changed since the last call to Emulate(), FALSE otherwise.
|
|
||||||
// Will be set to TRUE on the first call to the Emulate() function/method
|
|
||||||
bool SoundFormatChanged;
|
|
||||||
|
|
||||||
// Sound rate. Set by driver side.
|
|
||||||
double SoundRate;
|
|
||||||
|
|
||||||
// Pointer to sound buffer, set by the driver code, that the emulation code should render sound to.
|
// Pointer to sound buffer, set by the driver code, that the emulation code should render sound to.
|
||||||
// Guaranteed to be at least 500ms in length, but emulation code really shouldn't exceed 40ms or so. Additionally, if emulation code
|
// Guaranteed to be at least 500ms in length, but emulation code really shouldn't exceed 40ms or so. Additionally, if emulation code
|
||||||
// generates >= 100ms,
|
// generates >= 100ms,
|
||||||
// DEPRECATED: Emulation code may set this pointer to a sound buffer internal to the emulation module.
|
// DEPRECATED: Emulation code may set this pointer to a sound buffer internal to the emulation module.
|
||||||
int16 *SoundBuf;
|
int16 *SoundBuf;
|
||||||
|
|
||||||
// Maximum size of the sound buffer, in frames. Set by the driver code.
|
|
||||||
int32 SoundBufMaxSize;
|
|
||||||
|
|
||||||
// Number of frames currently in internal sound buffer. Set by the system emulation code, to be read by the driver code.
|
// Number of frames currently in internal sound buffer. Set by the system emulation code, to be read by the driver code.
|
||||||
int32 SoundBufSize;
|
int32 SoundBufSize;
|
||||||
int32 SoundBufSizeALMS; // SoundBufSize value at last MidSync(), 0
|
|
||||||
// if mid sync isn't implemented for the emulation module in use.
|
|
||||||
|
|
||||||
// Number of cycles that this frame consumed, using MDFNGI::MasterClock as a time base.
|
|
||||||
// Set by emulation code.
|
|
||||||
int64 MasterCycles;
|
|
||||||
int64 MasterCyclesALMS; // MasterCycles value at last MidSync(), 0
|
|
||||||
// if mid sync isn't implemented for the emulation module in use.
|
|
||||||
|
|
||||||
// Current sound volume(0.000...<=volume<=1.000...). If, after calling Emulate(), it is still != 1, Mednafen will handle it internally.
|
// Current sound volume(0.000...<=volume<=1.000...). If, after calling Emulate(), it is still != 1, Mednafen will handle it internally.
|
||||||
// Emulation modules can handle volume themselves if they like, for speed reasons. If they do, afterwards, they should set its value to 1.
|
// Emulation modules can handle volume themselves if they like, for speed reasons. If they do, afterwards, they should set its value to 1.
|
||||||
@ -276,11 +255,6 @@ typedef enum
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// Time base for EmulateSpecStruct::MasterCycles
|
|
||||||
int64 MasterClock;
|
|
||||||
|
|
||||||
uint32 fps; // frames per second * 65536 * 256, truncated
|
|
||||||
|
|
||||||
// multires is a hint that, if set, indicates that the system has fairly programmable video modes(particularly, the ability
|
// multires is a hint that, if set, indicates that the system has fairly programmable video modes(particularly, the ability
|
||||||
// to display multiple horizontal resolutions, such as the PCE, PC-FX, or Genesis). In practice, it will cause the driver
|
// to display multiple horizontal resolutions, such as the PCE, PC-FX, or Genesis). In practice, it will cause the driver
|
||||||
// code to set the linear interpolation on by default.
|
// code to set the linear interpolation on by default.
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
Arcade Card emulation based on information provided by Ki and David Shadoff
|
Arcade Card emulation based on information provided by Ki and David Shadoff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../../mednafen-types.h"
|
#include "../../mednafen-types.h"
|
||||||
|
@ -104,14 +104,6 @@ typedef uint16 UTF16; /* at least 16 bits */
|
|||||||
typedef uint8 UTF8; /* typically 8 bits */
|
typedef uint8 UTF8; /* typically 8 bits */
|
||||||
typedef unsigned char Boolean; /* 0 or 1 */
|
typedef unsigned char Boolean; /* 0 or 1 */
|
||||||
|
|
||||||
#ifndef FALSE
|
|
||||||
#define FALSE 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MDFN_COLD
|
#define MDFN_COLD
|
||||||
|
|
||||||
#undef require
|
#undef require
|
||||||
|
@ -52,7 +52,7 @@ static std::vector<CHEATF> cheats;
|
|||||||
static int savecheats;
|
static int savecheats;
|
||||||
static uint32 resultsbytelen = 1;
|
static uint32 resultsbytelen = 1;
|
||||||
static bool resultsbigendian = 0;
|
static bool resultsbigendian = 0;
|
||||||
static bool CheatsActive = TRUE;
|
static bool CheatsActive = true;
|
||||||
|
|
||||||
bool SubCheatsOn = 0;
|
bool SubCheatsOn = 0;
|
||||||
std::vector<SUBCHEAT> SubCheats[8];
|
std::vector<SUBCHEAT> SubCheats[8];
|
||||||
|
@ -39,8 +39,8 @@ static int64 mouse_last_meow[5];
|
|||||||
static int32 mouse_x[5], mouse_y[5];
|
static int32 mouse_x[5], mouse_y[5];
|
||||||
static uint16 mouse_rel[5];
|
static uint16 mouse_rel[5];
|
||||||
|
|
||||||
uint8 pce_mouse_button[5];
|
static uint8 pce_mouse_button[5];
|
||||||
uint8 mouse_index[5];
|
static uint8 mouse_index[5];
|
||||||
|
|
||||||
static uint8 sel;
|
static uint8 sel;
|
||||||
static uint8 read_index = 0;
|
static uint8 read_index = 0;
|
||||||
|
@ -217,8 +217,8 @@ static INLINE uint8 read_1808(int32 timestamp)
|
|||||||
{
|
{
|
||||||
if(PCECD_Drive_GetIO())
|
if(PCECD_Drive_GetIO())
|
||||||
{
|
{
|
||||||
PCECD_Drive_SetACK(TRUE);
|
PCECD_Drive_SetACK(true);
|
||||||
ACKStatus = TRUE;
|
ACKStatus = true;
|
||||||
pcecd_drive_ne = PCECD_Drive_Run(timestamp);
|
pcecd_drive_ne = PCECD_Drive_Run(timestamp);
|
||||||
ClearACKDelay = 15 * 3;
|
ClearACKDelay = 15 * 3;
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ bool PCECD_Init(const PCECD_Settings *settings, void (*irqcb)(bool), double mast
|
|||||||
|
|
||||||
ADPCM.bigdivacc = (int64)((double)master_clock * OC_Multiplier * 65536 / 32087.5);
|
ADPCM.bigdivacc = (int64)((double)master_clock * OC_Multiplier * 65536 / 32087.5);
|
||||||
|
|
||||||
return(TRUE);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ void PCECD_Power(uint32 timestamp)
|
|||||||
PCECD_Drive_Power(timestamp);
|
PCECD_Drive_Power(timestamp);
|
||||||
pcecd_drive_ne = 0x7fffffff;
|
pcecd_drive_ne = 0x7fffffff;
|
||||||
|
|
||||||
bBRAMEnabled = FALSE;
|
bBRAMEnabled = false;
|
||||||
memset(_Port, 0, sizeof(_Port));
|
memset(_Port, 0, sizeof(_Port));
|
||||||
ACKStatus = 0;
|
ACKStatus = 0;
|
||||||
ClearACKDelay = 0;
|
ClearACKDelay = 0;
|
||||||
@ -322,7 +322,7 @@ void PCECD_Power(uint32 timestamp)
|
|||||||
Fader.Volume = 0;
|
Fader.Volume = 0;
|
||||||
Fader.CycleCounter = 0;
|
Fader.CycleCounter = 0;
|
||||||
Fader.CountValue = 0;
|
Fader.CountValue = 0;
|
||||||
Fader.Clocked = FALSE;
|
Fader.Clocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCECD_IsBRAMEnabled(void)
|
bool PCECD_IsBRAMEnabled(void)
|
||||||
@ -367,7 +367,7 @@ uint8 PCECD_Read(uint32 timestamp, uint32 A)
|
|||||||
case 0x2: ret = _Port[2];
|
case 0x2: ret = _Port[2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x3: bBRAMEnabled = FALSE;
|
case 0x3: bBRAMEnabled = false;
|
||||||
|
|
||||||
/* switch left/right of digitized cd playback */
|
/* switch left/right of digitized cd playback */
|
||||||
ret = _Port[0x3];
|
ret = _Port[0x3];
|
||||||
@ -511,9 +511,7 @@ void PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)
|
|||||||
|
|
||||||
case 0x7: // $1807: D7=1 enables backup ram
|
case 0x7: // $1807: D7=1 enables backup ram
|
||||||
if (data & 0x80)
|
if (data & 0x80)
|
||||||
{
|
bBRAMEnabled = true;
|
||||||
bBRAMEnabled = TRUE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x8: // Set ADPCM address low
|
case 0x8: // Set ADPCM address low
|
||||||
@ -631,7 +629,7 @@ void PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)
|
|||||||
Fader.Volume = 65536;
|
Fader.Volume = 65536;
|
||||||
Fader.CycleCounter = 0;
|
Fader.CycleCounter = 0;
|
||||||
Fader.CountValue = 0;
|
Fader.CountValue = 0;
|
||||||
Fader.Clocked = FALSE;
|
Fader.Clocked = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -640,7 +638,7 @@ void PCECD_Write(uint32 timestamp, uint32 physAddr, uint8 data)
|
|||||||
if(!Fader.Clocked)
|
if(!Fader.Clocked)
|
||||||
Fader.CycleCounter = Fader.CountValue;
|
Fader.CycleCounter = Fader.CountValue;
|
||||||
|
|
||||||
Fader.Clocked = TRUE;
|
Fader.Clocked = true;
|
||||||
}
|
}
|
||||||
Fader_SyncWhich();
|
Fader_SyncWhich();
|
||||||
break;
|
break;
|
||||||
@ -777,8 +775,8 @@ extern "C" void PCECD_Run(uint32 in_timestamp)
|
|||||||
ClearACKDelay -= chunk_clocks;
|
ClearACKDelay -= chunk_clocks;
|
||||||
if(ClearACKDelay <= 0)
|
if(ClearACKDelay <= 0)
|
||||||
{
|
{
|
||||||
ACKStatus = FALSE;
|
ACKStatus = false;
|
||||||
PCECD_Drive_SetACK(FALSE);
|
PCECD_Drive_SetACK(false);
|
||||||
PCECD_Drive_Run(running_ts);
|
PCECD_Drive_Run(running_ts);
|
||||||
if(PCECD_Drive_GetCD())
|
if(PCECD_Drive_GetCD())
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "../mednafen.h"
|
#include "../mednafen.h"
|
||||||
#include "../mednafen-endian.h"
|
#include "../mednafen-endian.h"
|
||||||
@ -78,7 +77,7 @@ typedef struct
|
|||||||
uint8 command_buffer_pos;
|
uint8 command_buffer_pos;
|
||||||
uint8 command_size_left;
|
uint8 command_size_left;
|
||||||
|
|
||||||
// FALSE if not all pending data is in the FIFO, TRUE if it is.
|
// false if not all pending data is in the FIFO, true if it is.
|
||||||
// Used for multiple sector CD reads.
|
// Used for multiple sector CD reads.
|
||||||
bool data_transfer_done;
|
bool data_transfer_done;
|
||||||
|
|
||||||
@ -350,8 +349,8 @@ static void SendStatusAndMessage(uint8 status, uint8 message)
|
|||||||
|
|
||||||
cd.message_pending = message;
|
cd.message_pending = message;
|
||||||
|
|
||||||
cd.status_sent = FALSE;
|
cd.status_sent = false;
|
||||||
cd.message_sent = FALSE;
|
cd.message_sent = false;
|
||||||
|
|
||||||
|
|
||||||
if(status == STATUS_GOOD)
|
if(status == STATUS_GOOD)
|
||||||
@ -415,8 +414,6 @@ static bool ValidateRawDataSector(uint8 *data, const uint32 lba)
|
|||||||
{
|
{
|
||||||
if(!edc_lec_check_and_correct(data, false))
|
if(!edc_lec_check_and_correct(data, false))
|
||||||
{
|
{
|
||||||
MDFN_DispMessage("Uncorrectable data at sector %u", lba);
|
|
||||||
|
|
||||||
din.Flush();
|
din.Flush();
|
||||||
cd.data_transfer_done = false;
|
cd.data_transfer_done = false;
|
||||||
|
|
||||||
@ -870,16 +867,6 @@ static INLINE void RunCDDA(uint32 system_timestamp, int32 run_time)
|
|||||||
if(cd.TrayOpen)
|
if(cd.TrayOpen)
|
||||||
{
|
{
|
||||||
cdda.CDDAStatus = CDDASTATUS_STOPPED;
|
cdda.CDDAStatus = CDDASTATUS_STOPPED;
|
||||||
|
|
||||||
#if 0
|
|
||||||
cd.data_transfer_done = FALSE;
|
|
||||||
cd.key_pending = SENSEKEY_NOT_READY;
|
|
||||||
cd.asc_pending = ASC_MEDIUM_NOT_PRESENT;
|
|
||||||
cd.ascq_pending = 0x00;
|
|
||||||
cd.fru_pending = 0x00;
|
|
||||||
SendStatusAndMessage(STATUS_CHECK_CONDITION, 0x00);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -953,7 +940,7 @@ static INLINE void RunCDRead(uint32 system_timestamp, int32 run_time)
|
|||||||
if(cd.TrayOpen)
|
if(cd.TrayOpen)
|
||||||
{
|
{
|
||||||
din.Flush();
|
din.Flush();
|
||||||
cd.data_transfer_done = FALSE;
|
cd.data_transfer_done = false;
|
||||||
|
|
||||||
CommandCCError(SENSEKEY_NOT_READY, NSE_TRAY_OPEN);
|
CommandCCError(SENSEKEY_NOT_READY, NSE_TRAY_OPEN);
|
||||||
}
|
}
|
||||||
@ -963,7 +950,7 @@ static INLINE void RunCDRead(uint32 system_timestamp, int32 run_time)
|
|||||||
}
|
}
|
||||||
else if(!Cur_CDIF->ReadRawSector(tmp_read_buf, SectorAddr)) //, SectorAddr + SectorCount))
|
else if(!Cur_CDIF->ReadRawSector(tmp_read_buf, SectorAddr)) //, SectorAddr + SectorCount))
|
||||||
{
|
{
|
||||||
cd.data_transfer_done = FALSE;
|
cd.data_transfer_done = false;
|
||||||
|
|
||||||
CommandCCError(SENSEKEY_ILLEGAL_REQUEST);
|
CommandCCError(SENSEKEY_ILLEGAL_REQUEST);
|
||||||
}
|
}
|
||||||
@ -988,12 +975,12 @@ static INLINE void RunCDRead(uint32 system_timestamp, int32 run_time)
|
|||||||
|
|
||||||
if(SectorCount)
|
if(SectorCount)
|
||||||
{
|
{
|
||||||
cd.data_transfer_done = FALSE;
|
cd.data_transfer_done = false;
|
||||||
CDReadTimer += (uint64) 1 * 2048 * System_Clock / CD_DATA_TRANSFER_RATE;
|
CDReadTimer += (uint64) 1 * 2048 * System_Clock / CD_DATA_TRANSFER_RATE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cd.data_transfer_done = TRUE;
|
cd.data_transfer_done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end else to if(!Cur_CDIF->ReadSector
|
} // end else to if(!Cur_CDIF->ReadSector
|
||||||
@ -1035,7 +1022,7 @@ uint32 PCECD_Drive_Run(pcecd_drive_timestamp_t system_timestamp)
|
|||||||
if(REQ_signal && ACK_signal) // Data bus is valid nowww
|
if(REQ_signal && ACK_signal) // Data bus is valid nowww
|
||||||
{
|
{
|
||||||
cd.command_buffer[cd.command_buffer_pos++] = cd_bus.DB;
|
cd.command_buffer[cd.command_buffer_pos++] = cd_bus.DB;
|
||||||
SetREQ(FALSE);
|
SetREQ(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!REQ_signal && !ACK_signal && cd.command_buffer_pos) // Received at least one byte, what should we do?
|
if(!REQ_signal && !ACK_signal && cd.command_buffer_pos) // Received at least one byte, what should we do?
|
||||||
@ -1079,21 +1066,21 @@ uint32 PCECD_Drive_Run(pcecd_drive_timestamp_t system_timestamp)
|
|||||||
}
|
}
|
||||||
} // end if(cd.command_buffer_pos == RequiredCDBLen[cd.command_buffer[0] >> 4])
|
} // end if(cd.command_buffer_pos == RequiredCDBLen[cd.command_buffer[0] >> 4])
|
||||||
else // Otherwise, get more data for the command!
|
else // Otherwise, get more data for the command!
|
||||||
SetREQ(TRUE);
|
SetREQ(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHASE_STATUS:
|
case PHASE_STATUS:
|
||||||
if(REQ_signal && ACK_signal)
|
if(REQ_signal && ACK_signal)
|
||||||
{
|
{
|
||||||
SetREQ(FALSE);
|
SetREQ(false);
|
||||||
cd.status_sent = TRUE;
|
cd.status_sent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!REQ_signal && !ACK_signal && cd.status_sent)
|
if(!REQ_signal && !ACK_signal && cd.status_sent)
|
||||||
{
|
{
|
||||||
// Status sent, so get ready to send the message!
|
// Status sent, so get ready to send the message!
|
||||||
cd.status_sent = FALSE;
|
cd.status_sent = false;
|
||||||
cd_bus.DB = cd.message_pending;
|
cd_bus.DB = cd.message_pending;
|
||||||
|
|
||||||
ChangePhase(PHASE_MESSAGE_IN);
|
ChangePhase(PHASE_MESSAGE_IN);
|
||||||
@ -1110,32 +1097,32 @@ uint32 PCECD_Drive_Run(pcecd_drive_timestamp_t system_timestamp)
|
|||||||
if(cd.data_transfer_done)
|
if(cd.data_transfer_done)
|
||||||
{
|
{
|
||||||
SendStatusAndMessage(STATUS_GOOD, 0x00);
|
SendStatusAndMessage(STATUS_GOOD, 0x00);
|
||||||
cd.data_transfer_done = FALSE;
|
cd.data_transfer_done = false;
|
||||||
CDIRQCallback(PCECD_Drive_IRQ_DATA_TRANSFER_DONE);
|
CDIRQCallback(PCECD_Drive_IRQ_DATA_TRANSFER_DONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cd_bus.DB = din.ReadUnit();
|
cd_bus.DB = din.ReadUnit();
|
||||||
SetREQ(TRUE);
|
SetREQ(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(REQ_signal && ACK_signal)
|
if(REQ_signal && ACK_signal)
|
||||||
{
|
{
|
||||||
SetREQ(FALSE);
|
SetREQ(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHASE_MESSAGE_IN:
|
case PHASE_MESSAGE_IN:
|
||||||
if(REQ_signal && ACK_signal)
|
if(REQ_signal && ACK_signal)
|
||||||
{
|
{
|
||||||
SetREQ(FALSE);
|
SetREQ(false);
|
||||||
cd.message_sent = TRUE;
|
cd.message_sent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!REQ_signal && !ACK_signal && cd.message_sent)
|
if(!REQ_signal && !ACK_signal && cd.message_sent)
|
||||||
{
|
{
|
||||||
cd.message_sent = FALSE;
|
cd.message_sent = false;
|
||||||
ChangePhase(PHASE_BUS_FREE);
|
ChangePhase(PHASE_BUS_FREE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -29,16 +29,16 @@ extern pcecd_drive_bus_t cd_bus; // Don't access this structure directly by name
|
|||||||
#define PCECD_Drive_kingACK_mask 0x040
|
#define PCECD_Drive_kingACK_mask 0x040
|
||||||
#define PCECD_Drive_kingSEL_mask 0x100
|
#define PCECD_Drive_kingSEL_mask 0x100
|
||||||
|
|
||||||
#define BSY_signal ((const bool)(cd_bus.signals & PCECD_Drive_BSY_mask))
|
#define BSY_signal ((bool)(cd_bus.signals & PCECD_Drive_BSY_mask))
|
||||||
#define ACK_signal ((const bool)(cd_bus.signals & PCECD_Drive_kingACK_mask))
|
#define ACK_signal ((bool)(cd_bus.signals & PCECD_Drive_kingACK_mask))
|
||||||
#define RST_signal ((const bool)(cd_bus.signals & PCECD_Drive_kingRST_mask))
|
#define RST_signal ((bool)(cd_bus.signals & PCECD_Drive_kingRST_mask))
|
||||||
#define MSG_signal ((const bool)(cd_bus.signals & PCECD_Drive_MSG_mask))
|
#define MSG_signal ((bool)(cd_bus.signals & PCECD_Drive_MSG_mask))
|
||||||
#define SEL_signal ((const bool)(cd_bus.signals & PCECD_Drive_kingSEL_mask))
|
#define SEL_signal ((bool)(cd_bus.signals & PCECD_Drive_kingSEL_mask))
|
||||||
#define REQ_signal ((const bool)(cd_bus.signals & PCECD_Drive_REQ_mask))
|
#define REQ_signal ((bool)(cd_bus.signals & PCECD_Drive_REQ_mask))
|
||||||
#define IO_signal ((const bool)(cd_bus.signals & PCECD_Drive_IO_mask))
|
#define IO_signal ((bool)(cd_bus.signals & PCECD_Drive_IO_mask))
|
||||||
#define CD_signal ((const bool)(cd_bus.signals & PCECD_Drive_CD_mask))
|
#define CD_signal ((bool)(cd_bus.signals & PCECD_Drive_CD_mask))
|
||||||
|
|
||||||
#define DB_signal ((const uint8)cd_bus.DB)
|
#define DB_signal ((uint8)cd_bus.DB)
|
||||||
|
|
||||||
#define PCECD_Drive_GetDB() DB_signal
|
#define PCECD_Drive_GetDB() DB_signal
|
||||||
#define PCECD_Drive_GetBSY() BSY_signal
|
#define PCECD_Drive_GetBSY() BSY_signal
|
||||||
@ -68,7 +68,7 @@ enum
|
|||||||
{
|
{
|
||||||
PCECD_Drive_IRQ_DATA_TRANSFER_DONE = 1,
|
PCECD_Drive_IRQ_DATA_TRANSFER_DONE = 1,
|
||||||
PCECD_Drive_IRQ_DATA_TRANSFER_READY,
|
PCECD_Drive_IRQ_DATA_TRANSFER_READY,
|
||||||
PCECD_Drive_IRQ_MAGICAL_REQ,
|
PCECD_Drive_IRQ_MAGICAL_REQ
|
||||||
};
|
};
|
||||||
|
|
||||||
void PCECD_Drive_GetCDDAValues(int16 *left, int16 *right);
|
void PCECD_Drive_GetCDDAValues(int16 *left, int16 *right);
|
||||||
|
@ -613,6 +613,7 @@ int PCEFast_PSG::StateAction(StateMem *sm, int load, int data_only)
|
|||||||
|
|
||||||
SFVARN(vol_update_counter, "vol_update_counter"),
|
SFVARN(vol_update_counter, "vol_update_counter"),
|
||||||
SFVARN(vol_update_which, "vol_update_which"),
|
SFVARN(vol_update_which, "vol_update_which"),
|
||||||
|
SFVARN(vol_update_vllatch, "vol_update_vllatch"),
|
||||||
SFVAR_BOOL(vol_pending),
|
SFVAR_BOOL(vol_pending),
|
||||||
SFEND
|
SFEND
|
||||||
};
|
};
|
||||||
|
@ -98,7 +98,7 @@ static INLINE void FixTileCache(vdc_t *which_vdc, uint16 A)
|
|||||||
int x;
|
int x;
|
||||||
uint32 charname = (A >> 4);
|
uint32 charname = (A >> 4);
|
||||||
uint32 y = (A & 0x7);
|
uint32 y = (A & 0x7);
|
||||||
uint64 *tc = &which_vdc->bg_tile_cache[charname][y];
|
uint64 *tc = which_vdc->bg_tile_cache + (charname * 8) + y;
|
||||||
|
|
||||||
uint32 bitplane01 = which_vdc->VRAM[y + charname * 16];
|
uint32 bitplane01 = which_vdc->VRAM[y + charname * 16];
|
||||||
uint32 bitplane23 = which_vdc->VRAM[y+ 8 + charname * 16];
|
uint32 bitplane23 = which_vdc->VRAM[y+ 8 + charname * 16];
|
||||||
@ -448,8 +448,7 @@ static const uint64 cblock_exlut[16] = {
|
|||||||
CB_EXL(8ULL), CB_EXL(9ULL), CB_EXL(10ULL), CB_EXL(11ULL), CB_EXL(12ULL), CB_EXL(13ULL), CB_EXL(14ULL), CB_EXL(15ULL)
|
CB_EXL(8ULL), CB_EXL(9ULL), CB_EXL(10ULL), CB_EXL(11ULL), CB_EXL(12ULL), CB_EXL(13ULL), CB_EXL(14ULL), CB_EXL(15ULL)
|
||||||
};
|
};
|
||||||
|
|
||||||
static void DrawBG(const vdc_t *vdc, const uint32 count, uint8 *target) NO_INLINE;
|
static NO_INLINE void DrawBG(const vdc_t *vdc, const uint32 count, uint8 *target)
|
||||||
static void DrawBG(const vdc_t *vdc, const uint32 count, uint8 *target)
|
|
||||||
{
|
{
|
||||||
int bat_width_shift = bat_width_shift_tab[(vdc->MWR >> 4) & 3];
|
int bat_width_shift = bat_width_shift_tab[(vdc->MWR >> 4) & 3];
|
||||||
int bat_width_mask = (1U << bat_width_shift) - 1;
|
int bat_width_mask = (1U << bat_width_shift) - 1;
|
||||||
@ -464,7 +463,7 @@ static void DrawBG(const vdc_t *vdc, const uint32 count, uint8 *target)
|
|||||||
int line_sub = vdc->BG_YOffset & 7;
|
int line_sub = vdc->BG_YOffset & 7;
|
||||||
|
|
||||||
const uint16 *BAT_Base = &vdc->VRAM[bat_y];
|
const uint16 *BAT_Base = &vdc->VRAM[bat_y];
|
||||||
const uint64 *CG_Base = &vdc->bg_tile_cache[0][line_sub];
|
const uint64 *CG_Base = vdc->bg_tile_cache + (0 * 8) + line_sub;
|
||||||
|
|
||||||
uint64_t cg_mask = 0xFFFFFFFFFFFFFFFFULL;
|
uint64_t cg_mask = 0xFFFFFFFFFFFFFFFFULL;
|
||||||
|
|
||||||
@ -574,8 +573,7 @@ typedef struct
|
|||||||
#define SPR_HPMASK 0x8000 // High priority bit mask
|
#define SPR_HPMASK 0x8000 // High priority bit mask
|
||||||
|
|
||||||
// DrawSprites will write up to 0x20 units before the start of the pointer it's passed.
|
// DrawSprites will write up to 0x20 units before the start of the pointer it's passed.
|
||||||
static void DrawSprites(vdc_t *vdc, const int32 end, uint16 *spr_linebuf) NO_INLINE;
|
static NO_INLINE void DrawSprites(vdc_t *vdc, const int32 end, uint16 *spr_linebuf)
|
||||||
static void DrawSprites(vdc_t *vdc, const int32 end, uint16 *spr_linebuf)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int active_sprites = 0;
|
int active_sprites = 0;
|
||||||
@ -1078,8 +1076,15 @@ void VDC_Reset(void)
|
|||||||
|
|
||||||
void VDC_Power(void)
|
void VDC_Power(void)
|
||||||
{
|
{
|
||||||
|
unsigned i;
|
||||||
memset(vdc, 0, sizeof(vdc_t));
|
memset(vdc, 0, sizeof(vdc_t));
|
||||||
VDC_Reset();
|
VDC_Reset();
|
||||||
|
|
||||||
|
for(i = 0; i < 0x200; i++)
|
||||||
|
{
|
||||||
|
vce.color_table[i] = ((i ^ (i >> 3)) & 1) ? 0x000 : 0x1FF;
|
||||||
|
FixPCache(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VDC_Init(int sgx)
|
void VDC_Init(int sgx)
|
||||||
|
@ -105,7 +105,7 @@ typedef struct
|
|||||||
uint16 SAT[0x100];
|
uint16 SAT[0x100];
|
||||||
|
|
||||||
uint16 VRAM[65536]; //VRAM_Size];
|
uint16 VRAM[65536]; //VRAM_Size];
|
||||||
uint64 bg_tile_cache[65536][8]; // Tile, y, x
|
uint64 bg_tile_cache[4096 * 8]; // Tile, y, x
|
||||||
uint8 spr_tile_cache[1024][16][16]; // Tile, y, x
|
uint8 spr_tile_cache[1024][16][16]; // Tile, y, x
|
||||||
uint8 spr_tile_clean[1024]; //VRAM_Size / 64];
|
uint8 spr_tile_clean[1024]; //VRAM_Size / 64];
|
||||||
} vdc_t;
|
} vdc_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user