-
Notifications
You must be signed in to change notification settings - Fork 470
/
Copy pathsrtc.cpp
73 lines (56 loc) · 1.48 KB
/
srtc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*****************************************************************************\
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.
\*****************************************************************************/
/*****
* S-RTC emulation code
* Copyright (c) byuu
*****/
#include <limits>
#include "snes9x.h"
#include "memmap.h"
#include "srtc.h"
#include "display.h"
#define memory_cartrtc_read(a) RTCData.reg[(a)]
#define memory_cartrtc_write(a, b) { RTCData.reg[(a)] = (b); }
#define cpu_regs_mdr OpenBus
static inline unsigned max (unsigned a, unsigned b)
{
return ((a > b) ? a : b);
}
static inline unsigned min (unsigned a, unsigned b)
{
return ((a < b) ? a : b);
}
#include "srtcemu.h"
#include "srtcemu.cpp"
static SRTC srtcemu;
void S9xInitSRTC (void)
{
srtcemu.power();
memset(RTCData.reg, 0, 20);
}
void S9xResetSRTC (void)
{
srtcemu.reset();
}
void S9xSetSRTC (uint8 data, uint16 address)
{
srtcemu.mmio_write(address, data);
}
uint8 S9xGetSRTC (uint16 address)
{
return (srtcemu.mmio_read(address));
}
void S9xSRTCPreSaveState (void)
{
srtcsnap.rtc_mode = (int32) srtcemu.rtc_mode;
srtcsnap.rtc_index = (int32) srtcemu.rtc_index;
}
void S9xSRTCPostLoadState (int)
{
srtcemu.rtc_mode = (SRTC::RTC_Mode) srtcsnap.rtc_mode;
srtcemu.rtc_index = (signed) srtcsnap.rtc_index;
srtcemu.update_time();
}