2018-12-03 12:26:02 +01:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2010-01-27 23:08:56 +01:00
|
|
|
|
|
|
|
/*****
|
|
|
|
* S-RTC emulation code
|
|
|
|
* Copyright (c) byuu
|
|
|
|
*****/
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
#include <limits>
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "snes9x.h"
|
2009-11-30 09:14:38 +01:00
|
|
|
#include "memmap.h"
|
2010-01-27 23:08:56 +01:00
|
|
|
#include "srtc.h"
|
|
|
|
#include "display.h"
|
2009-11-30 09:14:38 +01:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
#define memory_cartrtc_read(a) RTCData.reg[(a)]
|
|
|
|
#define memory_cartrtc_write(a, b) { RTCData.reg[(a)] = (b); }
|
|
|
|
#define cpu_regs_mdr OpenBus
|
2009-11-30 09:14:38 +01:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
static inline unsigned max (unsigned a, unsigned b)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
return ((a > b) ? a : b);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
static inline unsigned min (unsigned a, unsigned b)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
return ((a < b) ? a : b);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
#define _SRTCEMU_CPP_
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
#include "srtcemu.h"
|
|
|
|
#include "srtcemu.cpp"
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
static SRTC srtcemu;
|
2009-11-30 09:14:38 +01:00
|
|
|
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xInitSRTC (void)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
srtcemu.power();
|
|
|
|
memset(RTCData.reg, 0, 20);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xResetSRTC (void)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
srtcemu.reset();
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xSetSRTC (uint8 data, uint16 address)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
srtcemu.mmio_write(address, data);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
uint8 S9xGetSRTC (uint16 address)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
return (srtcemu.mmio_read(address));
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xSRTCPreSaveState (void)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
srtcsnap.rtc_mode = (int32) srtcemu.rtc_mode;
|
|
|
|
srtcsnap.rtc_index = (int32) srtcemu.rtc_index;
|
2009-11-30 09:14:38 +01:00
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xSRTCPostLoadState (int)
|
2009-11-30 09:14:38 +01:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
srtcemu.rtc_mode = (SRTC::RTC_Mode) srtcsnap.rtc_mode;
|
|
|
|
srtcemu.rtc_index = (signed) srtcsnap.rtc_index;
|
2009-11-30 09:14:38 +01:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
srtcemu.update_time();
|
|
|
|
}
|