1static uint8 MDFN_FASTCALL port_rbyte(v810_timestamp_t &timestamp, uint32 A)
2{
3 if(A >= 0x000 && A <= 0x0FF)
4  return(FXINPUT_Read8(A, timestamp));
5 else if(A >= 0x100 && A <= 0x1FF) // SOUNDBOX dummy
6 {
7  timestamp += 4;
8 }
9 else if(A >= 0x200 && A <= 0x2FF) // RAINBOW dummy
10 {
11  timestamp += 4;
12 }
13 else if(A >= 0x300 && A <= 0x3FF) // FXVCE
14 {
15  timestamp += 4;
16  return(FXVCE_Read16(A));
17 }
18 else if(A >= 0x400 && A <= 0x5FF) // 0x400-0x4FF: VDC-A ; 0x500-0x5FF: VDC-B
19 {
20  timestamp += 4;
21  return(fx_vdc_chips[(A >> 8) & 0x1]->Read16((A & 4) >> 2));
22 }
23 else if(A >= 0x600 && A <= 0x6FF)
24 {
25  timestamp += 4;
26  return(KING_Read8(timestamp, A));
27 }
28 else if(A >= 0x700 && A <= 0x7FF)
29 {
30  if(!(A & 1))
31  {
32   FXDBG("ExBusReset B Read");
33   return(ExBusReset);
34  }
35  return(0);
36 }
37 else if(A >= 0xc00 && A <= 0xCFF) // Backup memory control
38 {
39  switch(A & 0xC0)
40  {
41   case 0x80: return(BackupControl);
42   case 0x00: return(Last_VDC_AR[0]);
43   case 0x40: return(Last_VDC_AR[1]);
44  }
45 }
46 else if(A >= 0xe00 && A <= 0xeff)
47 {
48  return(PCFXIRQ_Read8(A));
49 }
50 else if(A >= 0xf00 && A <= 0xfff)
51 {
52  return(FXTIMER_Read8(A, timestamp));
53 }
54 else if((A & 0x7FFFFFFF) >= 0x500000 && (A & 0x7FFFFFFF) <= 0x52ffff)
55 {
56  if(WantHuC6273)
57   return(HuC6273_Read8(A));
58 }
59 else if(FXSCSIROM && A >= 0x780000 && A <= 0x7FFFFF)
60 {
61  return(FXSCSIROM[A & 0x7FFFF]);
62 }
63 else if(FXSCSIROM && A >= 0x600000 && A <= 0x6FFFFF)
64 {
65  return(FXSCSI_CtrlRead(A));
66 }
67 FXDBG("Unknown 8-bit port read: %08x", A);
68
69 return(0x00);
70}
71
72static uint16 MDFN_FASTCALL port_rhword(v810_timestamp_t &timestamp, uint32 A)
73{
74 if(A >= 0x000 && A <= 0x0FF)
75  return(FXINPUT_Read16(A, timestamp));
76 else if(A >= 0x100 && A <= 0x1FF) // SOUNDBOX dummy
77 {
78  timestamp += 4;
79 }
80 else if(A >= 0x200 && A <= 0x2FF) // RAINBOW dummy
81 {
82  timestamp += 4;
83 }
84 else if(A >= 0x300 && A <= 0x3FF)
85 {
86  timestamp += 4;
87  return(FXVCE_Read16(A));
88 }
89 else if(A >= 0x400 && A <= 0x5FF) // 0x400-0x4FF: VDC-A ; 0x500-0x5FF: VDC-B
90 {
91  timestamp += 4;
92  return(fx_vdc_chips[(A >> 8) & 0x1]->Read16((A & 4) >> 2));
93 }
94 else if(A >= 0x600 && A <= 0x6FF)
95 {
96  timestamp += 4;
97  return(KING_Read16(timestamp, A));
98 }
99 else if(A >= 0x700 && A <= 0x7FF)
100 {
101  FXDBG("ExBusReset H Read");
102
103  return(ExBusReset);
104 }
105 else if(A >= 0xc00 && A <= 0xCFF) // Backup memory control
106 {
107  switch(A & 0xC0)
108  {
109   case 0x80: return(BackupControl);
110   case 0x00: return(Last_VDC_AR[0]);
111   case 0x40: return(Last_VDC_AR[1]);
112  }
113 }
114 else if(A >= 0xe00 && A <= 0xeff)
115 {
116  return(PCFXIRQ_Read16(A));
117 }
118 else if(A >= 0xf00 && A <= 0xfff)
119 {
120  return(FXTIMER_Read16(A, timestamp));
121 }
122 else if((A & 0x7FFFFFFF) >= 0x500000 && (A & 0x7FFFFFFF) <= 0x52ffff)
123 {
124  if(WantHuC6273)
125   return(HuC6273_Read16(A));
126 }
127 else if(FXSCSIROM && A >= 0x780000 && A <= 0x7FFFFF)
128 {
129  return MDFN_de16lsb<true>(&FXSCSIROM[A & 0x7FFFF]);
130 }
131 else if(FXSCSIROM && A >= 0x600000 && A <= 0x6FFFFF)
132 {
133  puts("FXSCSI 16-bit:");
134  return(FXSCSI_CtrlRead(A));
135 }
136
137 FXDBG("Unknown 16-bit port read: %08x", A);
138
139 return(0x00);
140}
141
142static void MDFN_FASTCALL port_wbyte(v810_timestamp_t &timestamp, uint32 A, uint8 V)
143{
144  if(A >= 0x000 && A <= 0x0FF)
145   FXINPUT_Write8(A, V, timestamp);
146  else if(A >= 0x100 && A <= 0x1FF)
147  {
148   timestamp += 2;
149   SoundBox_Write(A, V, timestamp);
150  }
151  else if(A >= 0x200 && A <= 0x2FF)
152  {
153   timestamp += 2;
154   RAINBOW_Write8(A, V);
155  }
156  else if(A >= 0x300 && A <= 0x3FF) // FXVCE
157  {
158   timestamp += 2;
159   FXVCE_Write16(A, V);
160  }
161  else if(A >= 0x400 && A <= 0x5FF) // 0x400-0x4FF: VDC-A ; 0x500-0x5FF: VDC-B
162  {
163   timestamp += 2;
164
165   if(!(A & 4))
166    Last_VDC_AR[(A >> 8) & 0x1] = V;
167
168   fx_vdc_chips[(A >> 8) & 0x1]->Write16((A & 4) >> 2, V);
169  }
170  else if(A >= 0x600 && A <= 0x6FF)
171  {
172   timestamp += 2;
173   KING_Write8(timestamp, A, V);
174  }
175  else if(A >= 0x700 && A <= 0x7FF)
176  {
177   if(!(A & 1))
178   {
179    FXDBG("ExBusReset B Write: %02x", V & 1);
180    ExBusReset = V & 1;
181   }
182  }
183  else if(A >= 0xc00 && A <= 0xCFF)
184  {
185   switch(A & 0xC1)
186   {
187    case 0x80: BackupControl = V & 0x3;
188               break;
189
190    default:   FXDBG("Port 8-bit write: %08x %02x", A, V);
191               break;
192   }
193  }
194  else if(A >= 0xe00 && A <= 0xeff)
195  {
196   FXDBG("IRQ write8: %08x %02x", A, V);
197   PCFXIRQ_Write16(A, V);
198  }
199  else if((A & 0x7FFFFFFF) >= 0x500000 && (A & 0x7FFFFFFF) <= 0x52ffff)
200  {
201   if(WantHuC6273)
202    HuC6273_Write16(A, V);
203  }
204  else if(FXSCSIROM && A >= 0x600000 && A <= 0x6FFFFF)
205  {
206   FXSCSI_CtrlWrite(A, V);
207  }
208  else
209  {
210   FXDBG("Port 8-bit write: %08x %02x", A, V);
211  }
212}
213
214static void MDFN_FASTCALL port_whword(v810_timestamp_t &timestamp, uint32 A, uint16 V)
215{
216  if(A >= 0x000 && A <= 0x0FF)
217   FXINPUT_Write16(A, V, timestamp);
218  else if(A >= 0x100 && A <= 0x1FF)
219  {
220   timestamp += 2;
221   SoundBox_Write(A, V, timestamp);
222  }
223  else if(A >= 0x200 && A <= 0x2FF)
224  {
225   timestamp += 2;
226   RAINBOW_Write16(A, V);
227  }
228  else if(A >= 0x300 && A <= 0x3FF)
229  {
230   timestamp += 2;
231   FXVCE_Write16(A, V);
232  }
233  else if(A >= 0x400 && A <= 0x5FF) // 0x400-0x4FF: VDC-A ; 0x500-0x5FF: VDC-B
234  {
235   timestamp += 2;
236
237   if(!(A & 4))
238    Last_VDC_AR[(A >> 8) & 0x1] = V;
239
240   fx_vdc_chips[(A >> 8) & 0x1]->Write16((A & 4) >> 2, V);
241  }
242  else if(A >= 0x600 && A <= 0x6FF)
243  {
244   timestamp += 2;
245   KING_Write16(timestamp, A, V);
246  }
247  else if(A >= 0x700 && A <= 0x7FF)
248  {
249   ExBusReset = V & 1;
250   FXDBG("ExBusReset H Write: %04x", V);
251  }
252  else if(A >= 0x800 && A <= 0x8FF) // ?? LIP writes here
253  {
254   FXDBG("Port 16-bit write: %08x %04x", A, V);
255  }
256  else if(A >= 0xc00 && A <= 0xCFF)
257  {
258   switch(A & 0xC0)
259   {
260    case 0x80: BackupControl = V & 0x3;
261	       break;
262
263    default:   FXDBG("Port 16-bit write: %08x %04x", A, V);
264	       break;
265   }
266  }
267  else if(A >= 0xe00 && A <= 0xeff)
268  {
269   PCFXIRQ_Write16(A, V);
270  }
271  else if(A >= 0xF00 && A <= 0xFFF)
272  {
273   FXTIMER_Write16(A, V, timestamp);
274  }
275  else if((A & 0x7FFFFFFF) >= 0x500000 && (A & 0x7FFFFFFF) <= 0x52ffff)
276  {
277   if(WantHuC6273)
278    HuC6273_Write16(A, V);
279  }
280  else if(FXSCSIROM && A >= 0x600000 && A <= 0x6FFFFF)
281  {
282   puts("FXSCSI 16-bit:");
283   FXSCSI_CtrlWrite(A, V);
284  }
285  else
286  {
287   FXDBG("Port 16-bit write: %08x %04x", A, V);
288  }
289}
290
291