Update to latest version (0.9.44.1)

This commit is contained in:
twinaphex 2017-04-22 22:29:05 +02:00
parent e299962612
commit e49e5fedec
30 changed files with 778 additions and 292 deletions

View File

@ -349,7 +349,7 @@ LDFLAGS += $(fpic) $(SHARED)
FLAGS += $(fpic) $(NEW_GCC_FLAGS)
FLAGS += $(INCFLAGS)
FLAGS += $(ENDIANNESS_DEFINES) -DSIZEOF_DOUBLE=8 $(WARNINGS) -DMEDNAFEN_VERSION=\"0.9.38.6\" -DPACKAGE=\"mednafen\" -DMEDNAFEN_VERSION_NUMERIC=9386 -DPSS_STYLE=1 -DMPC_FIXED_POINT $(CORE_DEFINE) -DSTDC_HEADERS -D__STDC_LIMIT_MACROS -D__LIBRETRO__ -D_LOW_ACCURACY_ $(EXTRA_INCLUDES) $(SOUND_DEFINE) -D__STDC_CONSTANT_MACROS
FLAGS += $(ENDIANNESS_DEFINES) -DSIZEOF_DOUBLE=8 $(WARNINGS) -DMEDNAFEN_VERSION=\"0.9.44.1\" -DPACKAGE=\"mednafen\" -DMEDNAFEN_VERSION_NUMERIC=9441 -DPSS_STYLE=1 -DMPC_FIXED_POINT $(CORE_DEFINE) -DSTDC_HEADERS -D__STDC_LIMIT_MACROS -D__LIBRETRO__ -D_LOW_ACCURACY_ $(EXTRA_INCLUDES) $(SOUND_DEFINE) -D__STDC_CONSTANT_MACROS
ifeq ($(HAVE_RUST),1)
FLAGS += -DHAVE_RUST

View File

@ -105,6 +105,13 @@ ifneq ($(HAVE_GRIFFIN), 1)
$(CORE_EMU_DIR)/input/keyboard.cpp \
$(CORE_EMU_DIR)/input/wheel.cpp
SOURCES_CXX += \
$(CORE_EMU_DIR)/cart/backup.cpp \
$(CORE_EMU_DIR)/cart/cs1ram.cpp \
$(CORE_EMU_DIR)/cart/debug.cpp \
$(CORE_EMU_DIR)/cart/extram.cpp \
$(CORE_EMU_DIR)/cart/rom.cpp
SOURCES_CXX += $(MEDNAFEN_DIR)/hw_cpu/m68k/m68k.cpp
SOURCES_C += $(CORE_DIR)/libretro_cbs.c

View File

@ -30,7 +30,7 @@
#define MEDNAFEN_CORE_NAME_MODULE "ss"
#define MEDNAFEN_CORE_NAME "Mednafen Saturn"
#define MEDNAFEN_CORE_VERSION "v0.9.43"
#define MEDNAFEN_CORE_VERSION "v0.9.44.1"
#define MEDNAFEN_CORE_EXTENSIONS "cue|ccd"
#define MEDNAFEN_CORE_TIMING_FPS 59.82
#define MEDNAFEN_CORE_GEOMETRY_BASE_W 320
@ -587,6 +587,8 @@ static MDFN_COLD void InitEvents(void)
events[SS_EVENT_SOUND].event_handler = SOUND_Update;
events[SS_EVENT_CART].event_handler = CART_GetEventHandler();
events[SS_EVENT_MIDSYNC].event_handler = MidSync;
events[SS_EVENT_MIDSYNC].event_time = SS_EVENT_DISABLED_TS;
}
@ -839,6 +841,7 @@ static void Emulate(EmulateSpecStruct* espec_arg)
cur_clock_div = SMPC_StartFrame(espec);
UpdateSMPCInput(0);
VDP2::StartFrame(espec, cur_clock_div == 61);
CART_SetCPUClock(EmulatedSS.MasterClock / MDFN_MASTERCLOCK_FIXED(1), cur_clock_div);
espec->SoundBufSize = 0;
espec->MasterCycles = 0;
espec->soundmultiplier = 1;
@ -867,6 +870,7 @@ static void Emulate(EmulateSpecStruct* espec_arg)
VDP2::AdjustTS(-end_ts);
SMPC_ResetTS();
SCU_AdjustTS(-end_ts);
CART_AdjustTS(-end_ts);
UpdateInputLastBigTS -= (int64)end_ts * cur_clock_div * 1000 * 1000;
@ -1187,6 +1191,8 @@ static bool InitCommon(const unsigned cart_type, const unsigned smpc_area)
{ CART_EXTRAM_4M, "4MiB Extended RAM" },
{ CART_KOF95, "King of Fighters '95 ROM" },
{ CART_ULTRAMAN, "Ultraman ROM" },
{ CART_CS1RAM_16M, _("16MiB CS1 RAM") },
{ CART_NLMODEM, _("Netlink Modem") },
{ CART_MDFN_DEBUG, "Mednafen Debug" }
};
const char* cn = "Unknown";
@ -1477,6 +1483,7 @@ static MDFN_COLD bool Load(MDFNFILE* fp)
if(MDFN_GetSettingS("ss.dbg_exe_cdpath") != "")
{
RMD_Drive dr;
RMD_DriveDefaults drdef;
dr.Name = std::string("Virtual CD Drive");
dr.PossibleStates.push_back(RMD_State({"Tray Open", false, false, true}));
@ -1485,7 +1492,12 @@ static MDFN_COLD bool Load(MDFNFILE* fp)
dr.CompatibleMedia.push_back(0);
dr.MediaMtoPDelay = 2000;
drdef.State = 2; // Tray Closed
drdef.Media = 0;
drdef.Orientation = 0;
MDFNGameInfo->RMD->Drives.push_back(dr);
MDFNGameInfo->RMD->DrivesDefaults.push_back(drdef);
MDFNGameInfo->RMD->MediaTypes.push_back(RMD_MediaType({"CD"}));
MDFNGameInfo->RMD->Media.push_back(RMD_Media({"Test CD", 0}));
@ -1642,7 +1654,7 @@ static MDFN_COLD bool LoadCD(std::vector<CDIF *>* CDInterfaces)
{
log_cb(RETRO_LOG_INFO, "Trying to lookup cartridge from DB...\n");
cart_type = CART_BACKUP_MEM;
DB_LookupCartDB(sgid, &cart_type);
DB_LookupCartDB(sgid, fd_id, &cart_type);
}
if(MDFN_GetSettingB("ss.cd_sanity"))
@ -1767,6 +1779,7 @@ static MDFN_COLD void LoadRTC(void)
int StateAction(StateMem *sm, int load, int data_only)
{
CART_StateAction(sm, load, data_only);
return 0;
}
@ -1845,6 +1858,8 @@ static const MDFNSetting_EnumList Cart_List[] =
{ "backup", CART_BACKUP_MEM, "Backup Memory(512KiB)" },
{ "extram1", CART_EXTRAM_1M, "1MiB Extended RAM" },
{ "extram4", CART_EXTRAM_4M, "4MiB Extended RAM" },
{ "cs1ram16", CART_CS1RAM_16M, "16MiB RAM mapped in A-bus CS1" },
// { "nlmodem", CART_NLMODEM, "NetLink Modem" },
{ NULL, 0 },
};

View File

@ -2,7 +2,7 @@
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* cart.cpp - Expansion cart emulation
** Copyright (C) 2016 Mednafen Team
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
@ -22,101 +22,23 @@
#include "ss.h"
#include <mednafen/mednafen.h>
#include <mednafen/FileStream.h>
#include <mednafen/settings.h>
#include <mednafen/general.h>
#include "../mednafen-endian.h"
#include "cart.h"
#include "cart/backup.h"
#include "cart/cs1ram.h"
#include "cart/debug.h"
#include "cart/extram.h"
//#include "cart/nlmodem.h"
#include "cart/rom.h"
static uint16 ExtRAM[0x200000]; // Also used for cart ROM
static size_t ExtRAM_Mask;
static uint8 ExtBackupRAM[0x80000];
static bool ExtBackupRAM_Dirty;
static uint8 Cart_ID;
static int CartType;
CartInfo Cart;
template<typename T, bool IsWrite>
static void Debug_RW_DB(uint32 A, uint16* DB)
{
//
// printf-related debugging
//
if((A &~ 0x3) == 0x02100000)
{
if(IsWrite)
{
if(A == 0x02100001)
{
fputc(*DB, stderr);
fflush(stderr);
}
}
else
*DB = 0;
return;
}
}
static void CartID_Read_DB(uint32 A, uint16* DB)
{
if((A & ~1) == 0x04FFFFFE)
*DB = Cart_ID;
}
template<typename T, bool IsWrite>
static void ExtRAM_RW_DB(uint32 A, uint16* DB)
{
const uint32 mask = (sizeof(T) == 2) ? 0xFFFF : (0xFF << (((A & 1) ^ 1) << 3));
uint16* const ptr = (uint16*)((uint8*)ExtRAM + (A & ExtRAM_Mask));
//printf("Barf %zu %d: %08x\n", sizeof(T), IsWrite, A);
if(IsWrite)
*ptr = (*ptr & ~mask) | (*DB & mask);
else
*DB = *ptr;
}
// TODO: Check mirroring.
template<typename T, bool IsWrite>
static void ExtBackupRAM_RW_DB(uint32 A, uint16* DB)
{
uint8* const ptr = ExtBackupRAM + ((A >> 1) & 0x7FFFF);
if(IsWrite)
{
if(A & 1)
{
ExtBackupRAM_Dirty = true;
*ptr = *DB;
}
}
else
{
*DB = (*ptr << 0) | 0xFF00;
if((A & ~1) == 0x04FFFFFE)
*DB = 0x21;
}
}
static void ROM_Read(uint32 A, uint16* DB)
{
// TODO: Check mirroring.
//printf("ROM: %08x\n", A);
*DB = *(uint16*)((uint8*)ExtRAM + (A & ExtRAM_Mask));
}
template<typename T>
static void DummyRead(uint32 A, uint16* DB)
{
// Don't set *DB here.
SS_DBG(SS_DBG_WARNING, "[CART] Unknown %zu-byte read from 0x%08x\n", sizeof(T), A);
}
@ -126,154 +48,139 @@ static void DummyWrite(uint32 A, uint16* DB)
SS_DBG(SS_DBG_WARNING, "[CART] Unknown %zu-byte write to 0x%08x(DB=0x%04x)\n", sizeof(T), A, *DB);
}
void CART_Reset(bool powering_up)
static sscpu_timestamp_t DummyUpdate(sscpu_timestamp_t timestamp)
{
if(powering_up)
{
if(CartType == CART_EXTRAM_1M || CartType == CART_EXTRAM_4M)
memset(ExtRAM, 0, sizeof(ExtRAM)); // TODO: Test.
}
return SS_EVENT_DISABLED_TS;
}
void CART_Init(const int cart_type)
static void DummyAdjustTS(const int32 delta)
{
CartType = cart_type;
for(auto& p : Cart.CS0_RW)
{
p.Read16 = DummyRead<uint16>;
p.Write8 = DummyWrite<uint8>;
p.Write16 = DummyWrite<uint16>;
}
for(auto& p : Cart.CS1_RW)
{
p.Read16 = DummyRead<uint16>;
p.Write8 = DummyWrite<uint8>;
p.Write16 = DummyWrite<uint16>;
}
if(cart_type == CART_NONE)
{
}
else if(cart_type == CART_KOF95 || cart_type == CART_ULTRAMAN)
{
const std::string path_cxx = MDFN_GetSettingS((cart_type == CART_KOF95) ? "ss.cart.kof95_path" : "ss.cart.ultraman_path");
const char *path = MDFN_MakeFName(MDFNMKF_FIRMWARE, 0, path_cxx.c_str());
FileStream fp(path, MODE_READ);
fp.read(ExtRAM, 0x200000);
for(unsigned i = 0; i < 0x100000; i++)
{
ExtRAM[i] = MDFN_de16msb<true>(&ExtRAM[i]);
}
ExtRAM_Mask = 0x1FFFFE;
SS_SetPhysMemMap(0x02000000, 0x03FFFFFF, ExtRAM, 0x200000, false);
for(uint32 A = 0x02000000; A < 0x04000000; A += (1U << 20))
{
CartInfo::A &cs0rw = Cart.CS0_RW[(A - 0x02000000) >> 20];
cs0rw.Read16 = ROM_Read;
}
}
else if(cart_type == CART_BACKUP_MEM)
{
static const uint8 init[0x10] = { 0x42, 0x61, 0x63, 0x6B, 0x55, 0x70, 0x52, 0x61, 0x6D, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74 };
memset(ExtBackupRAM, 0x00, sizeof(ExtBackupRAM));
for(unsigned i = 0; i < 0x200; i += 0x10)
memcpy(ExtBackupRAM + i, init, 0x10);
ExtBackupRAM_Dirty = false;
for(uint32 A = 0x04000000; A < 0x05000000; A += (1U << 20))
{
CartInfo::B &cs1rw = Cart.CS1_RW[(A - 0x04000000) >> 20];
cs1rw.Read16 = ExtBackupRAM_RW_DB<uint16, false>;
cs1rw.Write8 = ExtBackupRAM_RW_DB<uint8, true>;
cs1rw.Write16 = ExtBackupRAM_RW_DB<uint16, true>;
}
}
else if(cart_type == CART_EXTRAM_1M || cart_type == CART_EXTRAM_4M)
{
if(cart_type == CART_EXTRAM_4M)
{
Cart_ID = 0x5C;
ExtRAM_Mask = 0x3FFFFE;
}
else
{
Cart_ID = 0x5A;
ExtRAM_Mask = 0x27FFFE;
}
SS_SetPhysMemMap(0x02400000, 0x025FFFFF, ExtRAM + (0x000000 / sizeof(uint16)), ((cart_type == CART_EXTRAM_4M) ? 0x200000 : 0x080000), true);
SS_SetPhysMemMap(0x02600000, 0x027FFFFF, ExtRAM + (0x200000 / sizeof(uint16)), ((cart_type == CART_EXTRAM_4M) ? 0x200000 : 0x080000), true);
for(uint32 A = 0x02400000; A < 0x02800000; A += (1U << 20))
{
CartInfo::A& cs0rw = Cart.CS0_RW[(A - 0x02000000) >> 20];
cs0rw.Read16 = ExtRAM_RW_DB<uint16, false>;
cs0rw.Write8 = ExtRAM_RW_DB<uint8, true>;
cs0rw.Write16 = ExtRAM_RW_DB<uint16, true>;
}
for(uint32 A = 0x04FFFFFE; A < 0x05000000; A += (1U << 20))
{
CartInfo::B& cs1rw = Cart.CS1_RW[(A - 0x04000000) >> 20];
cs1rw.Read16 = CartID_Read_DB;
}
}
else if(cart_type == CART_MDFN_DEBUG)
{
for(uint32 A = 0x02100000; A < 0x02100002; A += (1U << 20))
{
CartInfo::A& cs0rw = Cart.CS0_RW[(A - 0x02000000) >> 20];
cs0rw.Read16 = Debug_RW_DB<uint16, false>;
cs0rw.Write8 = Debug_RW_DB<uint8, true>;
cs0rw.Write16 = Debug_RW_DB<uint16, true>;
}
}
else
abort();
}
bool CART_GetClearNVDirty(void)
static void DummySetCPUClock(const int32 master_clock, const int32 divider)
{
if(CartType == CART_BACKUP_MEM)
{
bool ret = ExtBackupRAM_Dirty;
ExtBackupRAM_Dirty = false;
return ret;
}
else
return false;
}
void CART_GetNVInfo(const char** ext, void** nv_ptr, uint64* nv_size)
static MDFN_COLD void DummyReset(bool powering_up)
{
}
static MDFN_COLD void DummyStateAction(StateMem* sm, const unsigned load, const bool data_only)
{
}
static MDFN_COLD bool DummyGetClearNVDirty(void)
{
return false;
}
static MDFN_COLD void DummyGetNVInfo(const char** ext, void** nv_ptr, uint64* nv_size)
{
*ext = nullptr;
*nv_ptr = nullptr;
*nv_size = 0;
if(CartType == CART_BACKUP_MEM)
{
*ext = "bcr";
*nv_ptr = ExtBackupRAM;
*nv_size = sizeof(ExtBackupRAM);
}
}
void CART_Kill(void)
static MDFN_COLD void DummyKill(void)
{
}
void CartInfo::CS01_SetRW8W16(uint32 Astart, uint32 Aend, void (*r16)(uint32 A, uint16* DB), void (*w8)(uint32 A, uint16* DB), void (*w16)(uint32 A, uint16* DB))
{
assert(Astart >= 0x02000000 && Aend <= 0x04FFFFFF);
assert(!(Astart & ((1U << 20) - 1)));
assert(!((Aend + 1) & ((1U << 20) - 1)));
for(unsigned i = (Astart - 0x02000000) >> 20; i <= (Aend - 0x02000000) >> 20; i++)
{
auto& rw = Cart.CS01_RW[i];
if(r16) rw.Read16 = r16;
if(w8) rw.Write8 = w8;
if(w16) rw.Write16 = w16;
}
}
void CartInfo::CS2M_SetRW8W16(uint8 Ostart, uint8 Oend, void (*r16)(uint32 A, uint16* DB), void (*w8)(uint32 A, uint16* DB), void (*w16)(uint32 A, uint16* DB))
{
assert(!(Ostart & 0x1));
assert(Oend & 0x1);
assert(Ostart < 0x40);
assert(Oend < 0x40);
for(int i = Ostart >> 1; i <= Oend >> 1; i++)
{
auto& rw = Cart.CS2M_RW[i];
if(r16) rw.Read16 = r16;
if(w8) rw.Write8 = w8;
if(w16) rw.Write16 = w16;
}
}
void CART_Init(const int cart_type)
{
Cart.CS01_SetRW8W16(0x02000000, 0x04FFFFFF, DummyRead<uint16>, DummyWrite<uint8>, DummyWrite<uint16>);
Cart.CS2M_SetRW8W16(0x00, 0x3F, DummyRead<uint16>, DummyWrite<uint8>, DummyWrite<uint16>);
Cart.Reset = DummyReset;
Cart.Kill = DummyKill;
Cart.GetNVInfo = DummyGetNVInfo;
Cart.GetClearNVDirty = DummyGetClearNVDirty;
Cart.StateAction = DummyStateAction;
Cart.EventHandler = DummyUpdate;
Cart.AdjustTS = DummyAdjustTS;
Cart.SetCPUClock = DummySetCPUClock;
switch(cart_type)
{
default:
case CART_NONE:
break;
case CART_BACKUP_MEM:
CART_Backup_Init(&Cart);
break;
case CART_EXTRAM_1M:
case CART_EXTRAM_4M:
CART_ExtRAM_Init(&Cart, cart_type == CART_EXTRAM_4M);
break;
case CART_KOF95:
case CART_ULTRAMAN:
{
const std::string path_cxx = MDFN_GetSettingS((cart_type == CART_KOF95) ? "ss.cart.kof95_path" : "ss.cart.ultraman_path");
const char *path = MDFN_MakeFName(MDFNMKF_FIRMWARE, 0, path_cxx.c_str());
FileStream fp(path, MODE_READ);
CART_ROM_Init(&Cart, &fp);
}
break;
case CART_CS1RAM_16M:
CART_CS1RAM_Init(&Cart);
break;
case CART_MDFN_DEBUG:
CART_Debug_Init(&Cart);
break;
// case CART_NLMODEM:
// CART_NLModem_Init(&Cart);
// break;
}
for(auto& m : Cart.CS01_RW)
assert(m.Read16 != nullptr && m.Write8 != nullptr && m.Write16 != nullptr);
for(auto& m : Cart.CS2M_RW)
assert(m.Read16 != nullptr && m.Write8 != nullptr && m.Write16 != nullptr);
}

View File

@ -2,7 +2,7 @@
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* cart.h - Expansion cart emulation
** Copyright (C) 2016 Mednafen Team
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
@ -22,37 +22,51 @@
#ifndef __MDFN_SS_CART_H
#define __MDFN_SS_CART_H
#include <mednafen/state.h>
struct CartInfo
{
void (*Reset)(bool powering_up);
void (*Kill)(void);
void (*GetNVInfo)(const char** ext, void** nv_ptr, uint64* nv_size);
bool (*GetClearNVDirty)(void);
void (*StateAction)(StateMem* sm, const unsigned load, const bool data_only);
void (*AdjustTS)(const int32 delta);
// For calculating clock ratios.
void (*SetCPUClock)(const int32 master_clock, const int32 cpu_divider);
ss_event_handler EventHandler;
// A >> 20
struct A
struct
{
void (*Read16)(uint32 A, uint16* DB);
void (*Write8)(uint32 A, uint16* DB);
void (*Write16)(uint32 A, uint16* DB);
} CS0_RW[0x20];
} CS01_RW[0x30];
struct B
struct
{
void (*Read16)(uint32 A, uint16* DB);
void (*Write8)(uint32 A, uint16* DB);
void (*Write16)(uint32 A, uint16* DB);
} CS1_RW[0x10];
} CS2M_RW[0x20];
void CS01_SetRW8W16(uint32 Astart, uint32 Aend, void (*r16)(uint32 A, uint16* DB), void (*w8)(uint32 A, uint16* DB) = nullptr, void (*w16)(uint32 A, uint16* DB) = nullptr);
void CS2M_SetRW8W16(uint8 Ostart, uint8 Oend, void (*r16)(uint32 A, uint16* DB), void (*w8)(uint32 A, uint16* DB) = nullptr, void (*w16)(uint32 A, uint16* DB) = nullptr);
};
extern CartInfo Cart;
static INLINE void CART_CS01_Read16_DB(uint32 A, uint16* DB) { extern CartInfo Cart; Cart.CS01_RW[(size_t)(A >> 20) - (0x02000000 >> 20)].Read16 (A, DB); }
static INLINE void CART_CS01_Write8_DB(uint32 A, uint16* DB) { extern CartInfo Cart; Cart.CS01_RW[(size_t)(A >> 20) - (0x02000000 >> 20)].Write8 (A, DB); }
static INLINE void CART_CS01_Write16_DB(uint32 A, uint16* DB) { extern CartInfo Cart; Cart.CS01_RW[(size_t)(A >> 20) - (0x02000000 >> 20)].Write16(A, DB); }
static INLINE void CART_CS0_Read16_DB(uint32 A, uint16* DB) { Cart.CS0_RW[(size_t)(A >> 20) - (0x02000000 >> 20)].Read16 (A, DB); }
static INLINE void CART_CS0_Write8_DB(uint32 A, uint16* DB) { Cart.CS0_RW[(size_t)(A >> 20) - (0x02000000 >> 20)].Write8 (A, DB); }
static INLINE void CART_CS0_Write16_DB(uint32 A, uint16* DB) { Cart.CS0_RW[(size_t)(A >> 20) - (0x02000000 >> 20)].Write16(A, DB); }
static INLINE void CART_CS1_Read16_DB(uint32 A, uint16* DB) { Cart.CS1_RW[(size_t)(A >> 20) - (0x04000000 >> 20)].Read16 (A, DB); }
static INLINE void CART_CS1_Write8_DB(uint32 A, uint16* DB) { Cart.CS1_RW[(size_t)(A >> 20) - (0x04000000 >> 20)].Write8 (A, DB); }
static INLINE void CART_CS1_Write16_DB(uint32 A, uint16* DB) { Cart.CS1_RW[(size_t)(A >> 20) - (0x04000000 >> 20)].Write16(A, DB); }
static INLINE void CART_CS2_Read16_DB(uint32 A, uint16* DB) { extern CartInfo Cart; Cart.CS2M_RW[(A >> 1) & 0x1F].Read16 (A, DB); }
static INLINE void CART_CS2_Write8_DB(uint32 A, uint16* DB) { extern CartInfo Cart; Cart.CS2M_RW[(A >> 1) & 0x1F].Write8 (A, DB); }
static INLINE void CART_CS2_Write16_DB(uint32 A, uint16* DB) { extern CartInfo Cart; Cart.CS2M_RW[(A >> 1) & 0x1F].Write16(A, DB); }
enum
{
@ -65,14 +79,21 @@ enum
CART_KOF95,
CART_ULTRAMAN,
CART_CS1RAM_16M,
CART_NLMODEM,
CART_MDFN_DEBUG
};
void CART_Init(const int cart_type) MDFN_COLD;
void CART_Kill(void) MDFN_COLD;
void CART_GetNVInfo(const char** ext, void** nv_ptr, uint64* nv_size) MDFN_COLD;
bool CART_GetClearNVDirty(void);
void CART_Reset(bool powering_up) MDFN_COLD;
static INLINE ss_event_handler CART_GetEventHandler(void) { extern CartInfo Cart; return Cart.EventHandler; }
static INLINE void CART_AdjustTS(const int32 delta) { extern CartInfo Cart; Cart.AdjustTS(delta); }
static INLINE void CART_SetCPUClock(const int32 master_clock, const int32 cpu_divider) { extern CartInfo Cart; Cart.SetCPUClock(master_clock, cpu_divider); }
static INLINE void CART_Kill(void) { extern CartInfo Cart; Cart.Kill(); }
static INLINE void CART_StateAction(StateMem* sm, const unsigned load, const bool data_only) { extern CartInfo Cart; Cart.StateAction(sm, load, data_only); }
static INLINE void CART_GetNVInfo(const char** ext, void** nv_ptr, uint64* nv_size) { extern CartInfo Cart; Cart.GetNVInfo(ext, nv_ptr, nv_size); }
static INLINE bool CART_GetClearNVDirty(void) { extern CartInfo Cart; return Cart.GetClearNVDirty(); }
static INLINE void CART_Reset(bool powering_up) { extern CartInfo Cart; Cart.Reset(powering_up); }
#endif

101
mednafen/ss/cart/backup.cpp Normal file
View File

@ -0,0 +1,101 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* backup.cpp - Backup memory(512KiB) cart emulation
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "common.h"
#include "backup.h"
static uint8 ExtBackupRAM[0x80000];
static bool ExtBackupRAM_Dirty;
// TODO: Check mirroring.
template<typename T, bool IsWrite>
static void ExtBackupRAM_RW_DB(uint32 A, uint16* DB)
{
uint8* const ptr = ExtBackupRAM + ((A >> 1) & 0x7FFFF);
if(IsWrite)
{
if(A & 1)
{
ExtBackupRAM_Dirty = true;
*ptr = *DB;
}
}
else
{
*DB = (*ptr << 0) | 0xFF00;
if((A & ~1) == 0x04FFFFFE)
*DB = 0x21;
}
}
static MDFN_COLD bool GetClearNVDirty(void)
{
bool ret = ExtBackupRAM_Dirty;
ExtBackupRAM_Dirty = false;
return ret;
}
static MDFN_COLD void GetNVInfo(const char** ext, void** nv_ptr, uint64* nv_size)
{
*ext = "bcr";
*nv_ptr = ExtBackupRAM;
*nv_size = sizeof(ExtBackupRAM);
}
static MDFN_COLD void StateAction(StateMem* sm, const unsigned load, const bool data_only)
{
SFORMAT StateRegs[] =
{
SFARRAYN(ExtBackupRAM, 0x80000, "ExtBackupRAM"),
SFEND
};
MDFNSS_StateAction(sm, load, data_only, StateRegs, "CART_BACKUP");
if(load)
{
ExtBackupRAM_Dirty = true;
}
}
void CART_Backup_Init(CartInfo* c)
{
static const uint8 init[0x10] = { 0x42, 0x61, 0x63, 0x6B, 0x55, 0x70, 0x52, 0x61, 0x6D, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74 };
memset(ExtBackupRAM, 0x00, sizeof(ExtBackupRAM));
for(unsigned i = 0; i < 0x200; i += 0x10)
memcpy(ExtBackupRAM + i, init, 0x10);
ExtBackupRAM_Dirty = false;
c->CS01_SetRW8W16(0x04000000, 0x04FFFFFF,
ExtBackupRAM_RW_DB<uint16, false>,
ExtBackupRAM_RW_DB<uint8, true>,
ExtBackupRAM_RW_DB<uint16, true>);
c->GetClearNVDirty = GetClearNVDirty;
c->GetNVInfo = GetNVInfo;
c->StateAction = StateAction;
}

27
mednafen/ss/cart/backup.h Normal file
View File

@ -0,0 +1,27 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* backup.h - Backup memory(512KiB) cart emulation
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MDFN_SS_CART_BACKUP_H
#define __MDFN_SS_CART_BACKUP_H
void CART_Backup_Init(CartInfo* c) MDFN_COLD;
#endif

View File

@ -0,0 +1,5 @@
#include "../ss.h"
#include "../cart.h"
#include <mednafen/mednafen.h>
#include <mednafen/FileStream.h>
#include "../mednafen-endian.h"

View File

@ -0,0 +1,78 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* cs1ram.cpp - CS1 RAM(16MiB) cart emulation
** Copyright (C) 2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "common.h"
#include "cs1ram.h"
static uint16* CS1RAM = nullptr;
template<typename T, bool IsWrite>
static void CS1RAM_RW_DB(uint32 A, uint16* DB)
{
const uint32 mask = (sizeof(T) == 2) ? 0xFFFF : (0xFF << (((A & 1) ^ 1) << 3));
uint16* const ptr = (uint16*)((uint8*)CS1RAM + (A & 0x00FFFFFE));
if(IsWrite)
*ptr = (*ptr & ~mask) | (*DB & mask);
else
*DB = *ptr;
}
static MDFN_COLD void Reset(bool powering_up)
{
if(powering_up)
memset(CS1RAM, 0, 0x1000000);
}
static MDFN_COLD void Kill(void)
{
if(CS1RAM)
{
delete[] CS1RAM;
CS1RAM = nullptr;
}
}
static MDFN_COLD void StateAction(StateMem* sm, const unsigned load, const bool data_only)
{
SFORMAT StateRegs[] =
{
SFARRAY16N(CS1RAM, 0x800000, "RAM"),
SFEND
};
MDFNSS_StateAction(sm, load, data_only, StateRegs, "CART_CS1RAM");
}
void CART_CS1RAM_Init(CartInfo* c)
{
CS1RAM = new uint16[0x1000000 / sizeof(uint16)];
SS_SetPhysMemMap (0x04000000, 0x04FFFFFF, CS1RAM, 0x1000000, true);
c->CS01_SetRW8W16(0x04000000, 0x04FFFFFF,
CS1RAM_RW_DB<uint16, false>,
CS1RAM_RW_DB<uint8, true>,
CS1RAM_RW_DB<uint16, true>);
c->Reset = Reset;
c->Kill = Kill;
c->StateAction = StateAction;
}

27
mednafen/ss/cart/cs1ram.h Normal file
View File

@ -0,0 +1,27 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* cs1ram.h - CS1 RAM(16MiB) cart emulation
** Copyright (C) 2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MDFN_SS_CART_CS1RAM_H
#define __MDFN_SS_CART_CS1RAM_H
void CART_CS1RAM_Init(CartInfo* c) MDFN_COLD;
#endif

View File

@ -0,0 +1,55 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* debug.cpp - Mednafen debug cart emulation
** Copyright (C) 2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "common.h"
#include "debug.h"
template<typename T, bool IsWrite>
static void Debug_RW_DB(uint32 A, uint16* DB)
{
//
// printf-related debugging
//
if((A &~ 0x3) == 0x02100000)
{
if(IsWrite)
{
if(A == 0x02100001)
{
fputc(*DB, stderr);
fflush(stderr);
}
}
else
*DB = 0;
return;
}
}
void CART_Debug_Init(CartInfo* c)
{
c->CS01_SetRW8W16(0x02100000, /*0x02100001*/ 0x021FFFFF,
Debug_RW_DB<uint16, false>,
Debug_RW_DB<uint8, true>,
Debug_RW_DB<uint16, true>);
}

27
mednafen/ss/cart/debug.h Normal file
View File

@ -0,0 +1,27 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* debug.h - Mednafen debug cart emulation
** Copyright (C) 2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MDFN_SS_CART_DEBUG_H
#define __MDFN_SS_CART_DEBUG_H
void CART_Debug_Init(CartInfo* c) MDFN_COLD;
#endif

View File

@ -0,0 +1,94 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* extram.cpp - Extended RAM(1MiB and 4MiB) cart emulation
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "common.h"
#include "extram.h"
static uint16 ExtRAM[0x200000];
static size_t ExtRAM_Mask;
static uint8 Cart_ID;
template<typename T, bool IsWrite>
static void ExtRAM_RW_DB(uint32 A, uint16* DB)
{
const uint32 mask = (sizeof(T) == 2) ? 0xFFFF : (0xFF << (((A & 1) ^ 1) << 3));
uint16* const ptr = (uint16*)((uint8*)ExtRAM + (A & ExtRAM_Mask));
//printf("Barf %zu %d: %08x\n", sizeof(T), IsWrite, A);
if(IsWrite)
*ptr = (*ptr & ~mask) | (*DB & mask);
else
*DB = *ptr;
}
static void CartID_Read_DB(uint32 A, uint16* DB)
{
if((A & ~1) == 0x04FFFFFE)
*DB = Cart_ID;
}
static MDFN_COLD void Reset(bool powering_up)
{
if(powering_up)
memset(ExtRAM, 0, sizeof(ExtRAM)); // TODO: Test.
}
static MDFN_COLD void StateAction(StateMem* sm, const unsigned load, const bool data_only)
{
const size_t pcount = (Cart_ID == 0x5C) ? 0x100000 : 0x040000;
SFORMAT StateRegs[] =
{
SFARRAY16N(&ExtRAM[0x000000], pcount, "LO"),
SFARRAY16N(&ExtRAM[0x100000], pcount, "HI"),
SFEND
};
MDFNSS_StateAction(sm, load, data_only, StateRegs, "CART_EXTRAM");
}
void CART_ExtRAM_Init(CartInfo* c, bool R4MiB)
{
if(R4MiB)
{
Cart_ID = 0x5C;
ExtRAM_Mask = 0x3FFFFE;
}
else
{
Cart_ID = 0x5A;
ExtRAM_Mask = 0x27FFFE;
}
SS_SetPhysMemMap(0x02400000, 0x025FFFFF, ExtRAM + (0x000000 / sizeof(uint16)), (R4MiB ? 0x200000 : 0x080000), true);
SS_SetPhysMemMap(0x02600000, 0x027FFFFF, ExtRAM + (0x200000 / sizeof(uint16)), (R4MiB ? 0x200000 : 0x080000), true);
c->CS01_SetRW8W16(0x02400000, 0x027FFFFF,
ExtRAM_RW_DB<uint16, false>,
ExtRAM_RW_DB<uint8, true>,
ExtRAM_RW_DB<uint16, true>);
c->CS01_SetRW8W16(/*0x04FFFFFE*/0x04F00000, 0x04FFFFFF, CartID_Read_DB);
c->Reset = Reset;
c->StateAction = StateAction;
}

27
mednafen/ss/cart/extram.h Normal file
View File

@ -0,0 +1,27 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* extram.h - Extended RAM(1MiB and 4MiB) cart emulation
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MDFN_SS_CART_EXTRAM_H
#define __MDFN_SS_CART_EXTRAM_H
void CART_ExtRAM_Init(CartInfo* c, bool R4MiB) MDFN_COLD;
#endif

45
mednafen/ss/cart/rom.cpp Normal file
View File

@ -0,0 +1,45 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* rom.cpp - ROM cart emulation
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "common.h"
#include "rom.h"
static uint16 ROM[0x100000];
static void ROM_Read(uint32 A, uint16* DB)
{
// TODO: Check mirroring.
//printf("ROM: %08x\n", A);
*DB = *(uint16*)((uint8*)ROM + (A & 0x1FFFFE));
}
void CART_ROM_Init(CartInfo* c, Stream* str)
{
str->read(ROM, 0x200000);
for(unsigned i = 0; i < 0x100000; i++)
{
ROM[i] = MDFN_de16msb<true>(&ROM[i]);
}
SS_SetPhysMemMap (0x02000000, 0x03FFFFFF, ROM, 0x200000, false);
c->CS01_SetRW8W16(0x02000000, 0x03FFFFFF, ROM_Read);
}

27
mednafen/ss/cart/rom.h Normal file
View File

@ -0,0 +1,27 @@
/******************************************************************************/
/* Mednafen Sega Saturn Emulation Module */
/******************************************************************************/
/* rom.h - ROM cart emulation
** Copyright (C) 2016-2017 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MDFN_SS_CART_ROM_H
#define __MDFN_SS_CART_ROM_H
void CART_ROM_Init(CartInfo* c, Stream* str) MDFN_COLD;
#endif

View File

@ -61,7 +61,7 @@ bool DB_LookupRegionDB(const uint8* fd_id, unsigned* const region)
return false;
}
bool DB_LookupCartDB(const char* sgid, int* const cart_type)
bool DB_LookupCartDB(const char* sgid, const uint8 *fd_id, int* const cart_type)
{
// printf(" { \"%s\", CART_EXTRAM_1M },\n", sgid);
// printf(" { \"%s\", CART_EXTRAM_4M },\n", sgid);
@ -71,6 +71,7 @@ bool DB_LookupCartDB(const char* sgid, int* const cart_type)
{
const char* sgid;
int cart_type;
uint8 fd_id[16];
} cartdb[] =
{
#if 0
@ -86,10 +87,21 @@ bool DB_LookupCartDB(const char* sgid, int* const cart_type)
// Modem TODO:
{ "MK-81218", CART_NONE }, // Daytona USA CCE Net Link Edition
{ "MK-81071", CART_NONE }, // Duke Nukem 3D
{ "T-319-01H", CART_NONE }, // PlanetWeb Browser
{ "T-14302G", CART_NONE }, // Saturn Bomberman (Japan)
{ "T-319-01H", CART_NONE }, // PlanetWeb Browser (multiple versions)
{ "MK-81070", CART_NONE }, // Saturn Bomberman
{ "MK-81215", CART_NONE }, // Sega Rally Championship Plus NetLink Edition
{ "MK-81072", CART_NONE }, // Virtual On NetLink Edition
//
//
// Japanese modem TODO:
{ "GS-7106", CART_NONE }, // Dennou Senki Virtual On (SegaNet)
{ "GS-7105", CART_NONE }, // Habitat II
{ "GS-7101", CART_NONE }, // Pad Nifty
{ "GS-7113", CART_NONE }, // Puzzle Bobble 3 (SegaNet)
{ "T-14305G", CART_NONE }, // Saturn Bomberman (SegaNet)
{ "T-31301G", CART_NONE }, // SegaSaturn Internet Vol. 1
//
//
//
@ -131,11 +143,16 @@ bool DB_LookupCartDB(const char* sgid, int* const cart_type)
{ "T-1246G", CART_EXTRAM_4M }, // Street Fighter Zero 3
{ "T-1229G", CART_EXTRAM_4M }, // Vampire Savior
{ "T-1226G", CART_EXTRAM_4M }, // X-Men vs. Street Fighter
//
//
//
{ nullptr, CART_CS1RAM_16M, { 0x4a, 0xf9, 0xff, 0x30, 0xea, 0x54, 0xfe, 0x3a, 0x79, 0xa7, 0x68, 0x69, 0xae, 0xde, 0x55, 0xbb } }
};
for(auto& ca : cartdb)
{
if(!strcmp(ca.sgid, sgid))
if((ca.sgid && !strcmp(ca.sgid, sgid)) || (!ca.sgid && !memcmp(ca.fd_id, fd_id, 16)))
{
*cart_type = ca.cart_type;
return true;

View File

@ -2,7 +2,7 @@
#define __MDFN_SS_DB_H
bool DB_LookupRegionDB(const uint8* fd_id, unsigned* const region);
bool DB_LookupCartDB(const char* sgid, int* const cart_type);
bool DB_LookupCartDB(const char* sgid, const uint8* fd_id, int* const cart_type);
#endif

Binary file not shown.

Binary file not shown.

View File

@ -19,6 +19,8 @@
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// TODO: Debouncing?
//
// PS/2 keyboard adapter seems to do PS/2 processing near/at the end of a Saturn-side read sequence, which creates about 1 frame of extra latency
// in practice. We handle things a bit differently here, to avoid the latency.

Binary file not shown.

View File

@ -66,7 +66,7 @@ struct DMAWriteTabS
uint8 compare;
};
static DMAWriteTabS dma_write_tab[2/*bus*/][8/*add setting*/][4/*write align*/][12/*count*/][5] =
static const DMAWriteTabS dma_write_tab[2/*bus*/][8/*add setting*/][4/*write align*/][12/*count*/][5] =
{
{
#include "scu_actab.inc"
@ -76,7 +76,7 @@ static DMAWriteTabS dma_write_tab[2/*bus*/][8/*add setting*/][4/*write align*/][
}
};
static DMAWriteTabS dma_write_tab_aciv1[4][24][8] =
static const DMAWriteTabS dma_write_tab_aciv1[4][24][8] =
{
#include "scu_aciv1tab.inc"
};
@ -918,10 +918,12 @@ template<typename T, bool IsWrite, bool SH32 = false>
static INLINE void ABusRW_DB(uint32 A, uint16* DB, int32* time_thing, int32* dma_time_thing = NULL, int32* sh2_dma_time_thing = NULL) // add to time_thing, subtract from dma_time_thing
{
//
// A-Bus CS0
// A-Bus CS0 and CS1
//
if(A >= 0x02000000 && A <= 0x03FFFFFF)
if(A >= 0x02000000 && A <= 0x04FFFFFF)
{
// [(bool)(A & 0x04000000)]
if(sh2_dma_time_thing != NULL)
*sh2_dma_time_thing -= 1; // TODO
@ -931,43 +933,23 @@ static INLINE void ABusRW_DB(uint32 A, uint16* DB, int32* time_thing, int32* dma
if(IsWrite)
{
if(sizeof(T) == 1)
CART_CS0_Write8_DB(A, DB);
CART_CS01_Write8_DB(A, DB);
else
CART_CS0_Write16_DB(A, DB);
}
else
CART_CS0_Read16_DB(A, DB);
return;
}
if(A >= 0x04000000 && A <= 0x04FFFFFF)
{
// A-Bus CS1
if(sh2_dma_time_thing != NULL)
*sh2_dma_time_thing -= 1; // TODO
if(dma_time_thing != NULL)
*dma_time_thing -= 1; // TODO
if(IsWrite)
{
if(sizeof(T) == 1)
CART_CS1_Write8_DB(A, DB);
else
CART_CS1_Write16_DB(A, DB);
CART_CS01_Write16_DB(A, DB);
}
else
{
CART_CS1_Read16_DB(A, DB);
CART_CS01_Read16_DB(A, DB);
}
return;
}
if(A >= 0x05000000 && A <= 0x057FFFFF)
//
// A-bus Dummy
//
if(MDFN_UNLIKELY(A >= 0x05000000 && A <= 0x057FFFFF))
{
// A-Bus Dummy
if(sh2_dma_time_thing != NULL)
*sh2_dma_time_thing -= 16;
@ -976,12 +958,15 @@ static INLINE void ABusRW_DB(uint32 A, uint16* DB, int32* time_thing, int32* dma
*dma_time_thing -= 16;
}
#ifdef HAVE_DEBUG
if(IsWrite)
SS_DBG(SS_DBG_WARNING | SS_DBG_SCU, "[A-Bus CSD] Unknown %zu-byte write to 0x%08x(DB=0x%04x)\n", sizeof(T), A, *DB);
{
if(sizeof(T) == 1)
CART_CS2_Write8_DB(A, DB);
else
CART_CS2_Write16_DB(A, DB);
}
else
SS_DBG(SS_DBG_WARNING | SS_DBG_SCU, "[A-Bus CSD] Unknown %zu-byte read from 0x%08x\n", sizeof(T), A);
#endif
CART_CS2_Read16_DB(A, DB);
return;
}
@ -1884,7 +1869,7 @@ static NO_INLINE void DMAInstr(void)
}
}
void (*DSP_DMAFuncTable[2][8][8])(void) =
extern void (*const DSP_DMAFuncTable[2][8][8])(void) =
{
#include "scu_dsp_dmatab.inc"
};

View File

@ -122,7 +122,7 @@ struct DSPS
// X Op: bits 23-25 - * 8
// Y Op: bits 17-19 - * 8
// D1 Op: bits 12-13 - * 4
extern void (*DSP_GenFuncTable[2][16][8][8][4])(void);
extern void (*const DSP_GenFuncTable[2][16][8][8][4])(void);
// Hold/Format/Direction: bits 12-14
// Hold: bit 14
@ -130,25 +130,25 @@ extern void (*DSP_GenFuncTable[2][16][8][8][4])(void);
// Direction: bit 12
// RAM: bits 8-10
//
extern void (*DSP_DMAFuncTable[2][8][8])(void);
extern void (*const DSP_DMAFuncTable[2][8][8])(void);
//
// Dest: bits 26-29
// Condition: bits 19-25
//
extern void (*DSP_MVIFuncTable[2][16][128])(void);
extern void (*const DSP_MVIFuncTable[2][16][128])(void);
//
// Condition: bits 19-25
//
extern void (*DSP_JMPFuncTable[2][128])(void);
extern void (*const DSP_JMPFuncTable[2][128])(void);
//
// LPS, BTM, END, ENDI(bits 29-31 = 0x7)
// bits 27-28
//
extern void (*DSP_MiscFuncTable[2][4])(void);
extern void (*const DSP_MiscFuncTable[2][4])(void);
extern DSPS DSP;

View File

@ -330,7 +330,7 @@ static NO_INLINE void GeneralInstr(void)
DSP.CT32 = (DSP.CT32 + ct_inc) & 0x3F3F3F3F;
}
void (*DSP_GenFuncTable[2][16][8][8][4])(void) =
extern void (*const DSP_GenFuncTable[2][16][8][8][4])(void) =
{
#include "scu_dsp_gentab.inc"
};

View File

@ -35,7 +35,7 @@ static NO_INLINE void JMPInstr(void)
DSP.PC = (uint8)instr;
}
void (*DSP_JMPFuncTable[2][128])(void) =
extern void (*const DSP_JMPFuncTable[2][128])(void) =
{
#include "scu_dsp_jmptab.inc"
};

View File

@ -59,7 +59,7 @@ static NO_INLINE void MiscInstr(void)
}
}
void (*DSP_MiscFuncTable[2][4])(void) =
extern void (*const DSP_MiscFuncTable[2][4])(void) =
{
#include "scu_dsp_misctab.inc"
};

View File

@ -65,7 +65,7 @@ static NO_INLINE void MVIInstr(void)
}
void (*DSP_MVIFuncTable[2][16][128])(void) =
extern void (*const DSP_MVIFuncTable[2][16][128])(void) =
{
#include "scu_dsp_mvitab.inc"
};

View File

@ -43,6 +43,7 @@
#include "input/wheel.h"
#include "input/mission.h"
#include "input/keyboard.h"
//#include "input/jpkeyboard.h"
#include <time.h>
#include "input/multitap.h"
@ -205,6 +206,7 @@ static struct
IODevice_Mission mission{false};
IODevice_Mission dualmission{true};
IODevice_Keyboard keyboard;
// IODevice_Keyboard jpkeyboard;
} PossibleDevices[12];
static IODevice_Multitap PossibleMultitaps[2];
@ -302,6 +304,8 @@ void SMPC_SetInput(unsigned port, const char* type, uint8* ptr)
nd = &PossibleDevices[port].dualmission;
else if(!strcmp(type, "keyboard"))
nd = &PossibleDevices[port].keyboard;
// else if(!strcmp(type, "jpkeyboard"))
// nd = &PossibleDevices[port].jpkeyboard;
else
abort();
@ -810,7 +814,7 @@ sscpu_timestamp_t SMPC_Update(sscpu_timestamp_t timestamp)
SMPC_WAIT_UNTIL_COND(PendingCommand >= 0 || PendingVB);
if(PendingVB)
if(PendingVB && PendingCommand < 0)
{
PendingVB = false;
@ -1379,6 +1383,17 @@ static const std::vector<InputDeviceInfoStruct> InputDeviceInfoSSVPort =
IODevice_Keyboard_US101_IDII,
InputDeviceInfoStruct::FLAG_KEYBOARD
},
#if 0
// Keyboard (Japanese)
{
"jpkeyboard",
"Keyboard (JP)",
"89-key Japanese keyboard.",
IODevice_JPKeyboard_IDII,
InputDeviceInfoStruct::FLAG_KEYBOARD
},
#endif
};
static IDIISG IDII_Builtin =

View File

@ -118,18 +118,22 @@
SS_EVENT_SOUND,
SS_EVENT_CART,
SS_EVENT_MIDSYNC,
SS_EVENT__SYNLAST,
SS_EVENT__COUNT,
};
typedef sscpu_timestamp_t (*ss_event_handler)(const sscpu_timestamp_t timestamp);
struct event_list_entry
{
sscpu_timestamp_t event_time;
event_list_entry *prev;
event_list_entry *next;
sscpu_timestamp_t (*event_handler)(const sscpu_timestamp_t timestamp);
ss_event_handler event_handler;
};
extern event_list_entry events[SS_EVENT__COUNT];