initial upstream import
[drnoksnes] / srtc.h
1 /*
2  * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3  *
4  * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5  *                           Jerremy Koot (jkoot@snes9x.com)
6  *
7  * Super FX C emulator code 
8  * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
9  *                           Gary Henderson.
10  * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
11  *
12  * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13  * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14  * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
15  *
16  * DOS port code contains the works of other authors. See headers in
17  * individual files.
18  *
19  * Snes9x homepage: http://www.snes9x.com
20  *
21  * Permission to use, copy, modify and distribute Snes9x in both binary and
22  * source form, for non-commercial purposes, is hereby granted without fee,
23  * providing that this license information and copyright notice appear with
24  * all copies and any derived work.
25  *
26  * This software is provided 'as-is', without any express or implied
27  * warranty. In no event shall the authors be held liable for any damages
28  * arising from the use of this software.
29  *
30  * Snes9x is freeware for PERSONAL USE only. Commercial users should
31  * seek permission of the copyright holders first. Commercial use includes
32  * charging money for Snes9x or software derived from Snes9x.
33  *
34  * The copyright holders request that bug fixes and improvements to the code
35  * should be forwarded to them so everyone can benefit from the modifications
36  * in future versions.
37  *
38  * Super NES and Super Nintendo Entertainment System are trademarks of
39  * Nintendo Co., Limited and its subsidiary companies.
40  */
41 #ifndef _srtc_h_
42 #define _srtc_h_
43
44 #if !defined(_SNESPPC) && !defined(__GIZ__) && !defined(__GP2X__)
45 #include <time.h>
46 #endif
47
48 #define MAX_RTC_INDEX       0xC
49
50 #define MODE_READ           0
51 #define MODE_LOAD_RTC       1
52 #define MODE_COMMAND        2
53 #define MODE_COMMAND_DONE   3
54
55 #define COMMAND_LOAD_RTC    0
56 #define COMMAND_CLEAR_RTC   4
57
58
59 /***   The format of the rtc_data structure is:
60
61 Index Description     Range (nibble)
62 ----- --------------  ---------------------------------------
63
64   0   Seconds low     0-9
65   1   Seconds high    0-5
66
67   2   Minutes low     0-9
68   3   Minutes high    0-5
69
70   4   Hour low        0-9
71   5   Hour high       0-2
72
73   6   Day low         0-9
74   7   Day high        0-3
75
76   8   Month           1-C (0xC is December, 12th month)
77
78   9   Year ones       0-9
79   A   Year tens       0-9
80   B   Year High       9-B  (9=19xx, A=20xx, B=21xx)
81
82   C   Day of week     0-6  (0=Sunday, 1=Monday,...,6=Saturday)
83
84 ***/
85
86 typedef struct
87 {
88     bool8_32 needs_init;
89     bool8_32 count_enable;      // Does RTC mark time or is it frozen
90     uint8 data [MAX_RTC_INDEX+1];
91     int8  index;
92     uint8 mode;
93
94     time_t system_timestamp;    // Of latest RTC load time
95     uint32 pad;
96 } SRTC_DATA;
97
98 extern SRTC_DATA           rtc;
99
100 void    S9xUpdateSrtcTime ();
101 void    S9xSetSRTC (uint8 data, uint16 Address);
102 uint8   S9xGetSRTC (uint16 Address);
103 void    S9xSRTCPreSaveState ();
104 void    S9xSRTCPostLoadState ();
105 void    S9xResetSRTC ();
106 void    S9xHardResetSRTC ();
107
108 #define SRTC_SRAM_PAD (4 + 8 + 1 + MAX_RTC_INDEX)
109
110 #endif  // _srtc_h