1 /******************************************************************************/
2 /* Mednafen NEC PC-FX Emulation Module                                        */
3 /******************************************************************************/
4 /* king.h:
5 **  Copyright (C) 2006-2016 Mednafen Team
6 **
7 ** This program is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU General Public License
9 ** as published by the Free Software Foundation; either version 2
10 ** of the License, or (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software Foundation, Inc.,
19 ** 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 */
21 
22 #ifndef __PCFX_KING_H
23 #define __PCFX_KING_H
24 
25 namespace MDFN_IEN_PCFX
26 {
27 
28 //
29 // Be sure to keep the numbered/lettered *_GSREG_* registers(MPROG0*, AFFIN*, etc.) here in contiguous sequential order(since we do stuff like "- KING_GSREG_MPROG0"
30 // in king.cpp.
31 //
32 
33 void KING_StartFrame(VDC **, EmulateSpecStruct *espec);
34 void KING_SetPixelFormat(const MDFN_PixelFormat &format);
35 uint16 FXVCE_Read16(uint32 A);
36 void FXVCE_Write16(uint32 A, uint16 V);
37 
38 #ifdef WANT_DEBUGGER
39 enum
40 {
41  FXVCE_GSREG_Line = 0,
42 
43  FXVCE_GSREG_PRIO0,
44  FXVCE_GSREG_PRIO1,
45 
46  FXVCE_GSREG_PICMODE,
47  FXVCE_GSREG_PALRWOF,
48  FXVCE_GSREG_PALRWLA,
49 
50  FXVCE_GSREG_PALOFS0,
51  FXVCE_GSREG_PALOFS1,
52  FXVCE_GSREG_PALOFS2,
53  FXVCE_GSREG_PALOFS3,
54 
55  FXVCE_GSREG_CCR,
56  FXVCE_GSREG_BLE,
57  FXVCE_GSREG_SPBL,
58 
59  FXVCE_GSREG_COEFF0,
60  FXVCE_GSREG_COEFF1,
61  FXVCE_GSREG_COEFF2,
62  FXVCE_GSREG_COEFF3,
63  FXVCE_GSREG_COEFF4,
64  FXVCE_GSREG_COEFF5,
65 
66  FXVCE_GSREG_CKeyY,
67  FXVCE_GSREG_CKeyU,
68  FXVCE_GSREG_CKeyV
69 };
70 
71 uint32 FXVCE_GetRegister(const unsigned int id, char* special, const uint32 special_len);
72 void FXVCE_SetRegister(const unsigned int id, uint32 value);
73 #endif
74 
75 uint8 KING_Read8(const v810_timestamp_t timestamp, uint32 A);
76 uint16 KING_Read16(const v810_timestamp_t timestamp, uint32 A);
77 
78 void KING_Write8(const v810_timestamp_t timestamp, uint32 A, uint8 V);
79 void KING_Write16(const v810_timestamp_t timestamp, uint32 A, uint16 V);
80 void KING_Init(void) MDFN_COLD;
81 void KING_Close(void) MDFN_COLD;
82 void KING_Reset(const v810_timestamp_t timestamp) MDFN_COLD;
83 
84 uint16 KING_GetADPCMHalfWord(int ch);
85 
86 uint8 KING_MemPeek(uint32 A);
87 
88 uint8 KING_RB_Fetch();
89 
90 void KING_SetLayerEnableMask(uint64 mask);
91 
92 void KING_StateAction(StateMem *sm, const unsigned load, const bool data_only);
93 
94 #ifdef WANT_DEBUGGER
95 enum
96 {
97  KING_GSREG_AR = 0,
98  KING_GSREG_MPROGADDR,
99  KING_GSREG_MPROGCTRL,
100 
101  KING_GSREG_PAGESET,
102  KING_GSREG_RTCTRL,
103  KING_GSREG_RKRAMA,
104  KING_GSREG_RSTART,
105  KING_GSREG_RCOUNT,
106  KING_GSREG_RIRQLINE,
107  KING_GSREG_KRAMWA,
108  KING_GSREG_KRAMRA,
109  KING_GSREG_DMATA,
110  KING_GSREG_DMATS,
111  KING_GSREG_DMASTT,
112  KING_GSREG_ADPCMCTRL,
113 
114  KING_GSREG_ADPCMBM0,
115  KING_GSREG_ADPCMBM1,
116 
117  KING_GSREG_ADPCMPA0,
118  KING_GSREG_ADPCMPA1,
119 
120  KING_GSREG_ADPCMSA0,
121  KING_GSREG_ADPCMSA1,
122 
123  KING_GSREG_ADPCMIA0,
124  KING_GSREG_ADPCMIA1,
125 
126  KING_GSREG_ADPCMEA0,
127  KING_GSREG_ADPCMEA1,
128 
129  KING_GSREG_ADPCMStat,
130  KING_GSREG_Reg01,
131  KING_GSREG_Reg02,
132  KING_GSREG_Reg03,
133  KING_GSREG_SUBCC,
134  KING_GSREG_DB,
135  KING_GSREG_BSY,
136  KING_GSREG_REQ,
137  KING_GSREG_ACK,
138  KING_GSREG_MSG,
139  KING_GSREG_IO,
140  KING_GSREG_CD,
141  KING_GSREG_SEL,
142 
143  KING_GSREG_BGMODE,
144  KING_GSREG_BGPRIO,
145  KING_GSREG_BGSCRM,
146 
147  KING_GSREG_BGSIZ0,
148  KING_GSREG_BGSIZ1,
149  KING_GSREG_BGSIZ2,
150  KING_GSREG_BGSIZ3,
151 
152  KING_GSREG_BGXSC0,
153  KING_GSREG_BGXSC1,
154  KING_GSREG_BGXSC2,
155  KING_GSREG_BGXSC3,
156 
157  KING_GSREG_BGYSC0,
158  KING_GSREG_BGYSC1,
159  KING_GSREG_BGYSC2,
160  KING_GSREG_BGYSC3,
161 
162  KING_GSREG_BGBATS,
163  KING_GSREG_BGBAT0,
164  KING_GSREG_BGBAT1,
165  KING_GSREG_BGBAT2,
166  KING_GSREG_BGBAT3,
167 
168  KING_GSREG_BGCGS,
169  KING_GSREG_BGCG0,
170  KING_GSREG_BGCG1,
171  KING_GSREG_BGCG2,
172  KING_GSREG_BGCG3,
173 
174  KING_GSREG_AFFINA,
175  KING_GSREG_AFFINB,
176  KING_GSREG_AFFINC,
177  KING_GSREG_AFFIND,
178 
179  KING_GSREG_AFFINX,
180  KING_GSREG_AFFINY,
181 
182  KING_GSREG_MPROG0,
183  KING_GSREG_MPROG1,
184  KING_GSREG_MPROG2,
185  KING_GSREG_MPROG3,
186  KING_GSREG_MPROG4,
187  KING_GSREG_MPROG5,
188  KING_GSREG_MPROG6,
189  KING_GSREG_MPROG7,
190  KING_GSREG_MPROG8,
191  KING_GSREG_MPROG9,
192  KING_GSREG_MPROGA,
193  KING_GSREG_MPROGB,
194  KING_GSREG_MPROGC,
195  KING_GSREG_MPROGD,
196  KING_GSREG_MPROGE,
197  KING_GSREG_MPROGF
198 };
199 
200 uint32 KING_GetRegister(const unsigned int id, char* special, const uint32 special_len);
201 void KING_SetRegister(const unsigned int id, uint32 value);
202 #endif
203 
204 void KING_SetGraphicsDecode(MDFN_Surface *surface, int line, int which, int xscroll, int yscroll, int pbn);
205 
206 void KING_NotifyOfBPE(bool read, bool write);
207 
208 void KING_SetLogFunc(void (*logfunc)(const char *, const char *, ...));
209 
210 void KING_EndFrame(v810_timestamp_t timestamp);
211 void KING_ResetTS(v810_timestamp_t ts_base);
212 
213 v810_timestamp_t MDFN_FASTCALL KING_Update(const v810_timestamp_t timestamp);
214 
215 }
216 
217 #endif
218