Previous 199869 Revisions Next

r18535 Monday 15th October, 2012 at 14:03:10 UTC by Curt Coder
(MESS) c128: MMU fixes. (nw)
[src/mess/machine]mos8722.c mos8722.h

trunk/src/mess/machine/mos8722.c
r18534r18535
5555#define CR_ROM_LO      BIT(m_reg[CR], 1)
5656#define CR_ROM_MID      ((m_reg[CR] >> 2) & 0x03)
5757#define CR_ROM_HI      ((m_reg[CR] >> 4) & 0x03)
58#define CR_RAM         ((m_reg[CR] >> 6) & 0x03)
58#define CR_A16         BIT(m_reg[CR], 6)
5959
6060
6161// mode configuration register
r18534r18535
161161
162162void mos8722_device::device_reset()
163163{
164   for (int i = 0; i < 12; i++)
164   for (int i = 0; i < 16; i++)
165165   {
166166      m_reg[i] = 0;
167167   }
168168
169   m_p0l_written = false;
170   m_p1l_written = false;
169   m_reg[P1L] = 0x01;
171170
171   m_p0h_latch = 0;
172   m_p1h_latch = 0;
173
172174   m_out_z80en_func(MCR_8500);
173175   m_out_fsdir_func(MCR_FSDIR);
174176}
r18534r18535
180182
181183UINT8 mos8722_device::read(offs_t offset, UINT8 data)
182184{
183   if (!MCR_C64)
185   if (MCR_C64) return data;
186
187   if (!CR_IO && offset >= 0xd500 && offset < 0xd50c)
184188   {
185      if (!CR_IO && offset >= 0xd500 && offset < 0xd50c)
189      switch (offset & 0x0f)
186190      {
187         switch (offset & 0x0f)
188         {
189         case MCR:
190            data = m_reg[MCR] & 0x49;
191      case CR:
192         data = m_reg[CR] | 0x80;
193         break;
191194
192            data |= m_in_game_func() << 4;
193            data |= m_in_exrom_func() << 5;
194            data |= m_in_sense40_func() << 7;
195            break;
195      case MCR:
196         data = m_reg[MCR] | 0x06;
196197
197         case VR:
198            data = 0x20;
199            break;
198         data &= ((m_in_game_func() << 4) | ~0x10);
199         data &= ((m_in_exrom_func() << 5) | ~0x20);
200         data &= ((m_in_sense40_func() << 7) | ~0x80);
201         break;
200202
201         default:
202            data = m_reg[offset & 0x0f];
203            break;
204         }
203      case VR:
204         data = 0x20;
205         break;
206
207      default:
208         data = m_reg[offset & 0x0f];
209         break;
205210      }
206      else if (offset == 0xff00)
211   }
212   else if (offset >= 0xff00 && offset < 0xff05)
213   {
214      switch (offset & 0x0f)
207215      {
208         return m_reg[CR];
216      case CR:
217         data = m_reg[CR] | 0x80;
218         break;
219
220      default:
221         data = m_reg[offset & 0x0f];
222         break;
209223      }
210224   }
211225
r18534r18535
219233
220234WRITE8_MEMBER( mos8722_device::write )
221235{
222   if (!MCR_C64)
236   if (MCR_C64) return;
237
238   if (!CR_IO && offset >= 0xd500 && offset < 0xd50c)
223239   {
224      if (!CR_IO && offset >= 0xd500 && offset < 0xd50c)
240      if (LOG) logerror("MOS8722 '%s' Write %01x : %02x\n", tag(), offset & 0x0f, data);
241
242      switch (offset & 0x0f)
225243      {
226         if (LOG) logerror("MOS8722 '%s' Write %01x : %02x\n", tag(), offset & 0x0f, data);
244      case CR:
245         m_reg[CR] = data & 0x7f;
246         break;
227247
228         m_reg[offset & 0x0f] = data;
248      case PCRA:
249      case PCRB:
250      case PCRC:
251      case PCRD:
252         m_reg[offset & 0x0f] = data & 0x7f;
253         break;
229254
230         switch (offset & 0x0f)
231         {
232         case MCR:
233            m_out_z80en_func(MCR_8500);
234            m_out_fsdir_func(MCR_FSDIR);
235            break;
255      case MCR:
256      {
257         int _8500 = MCR_8500;
258         int fsdir = MCR_FSDIR;
236259
237         case P0L:
238            m_p0l_written = true;
239            break;
260         m_reg[MCR] = data;
261         
262         if (_8500 != MCR_8500) m_out_z80en_func(MCR_8500);
263         if (fsdir != MCR_FSDIR) m_out_fsdir_func(MCR_FSDIR);
264         break;
265      }
240266
241         case P0H:
242            m_p0l_written = false;
243            break;
267      case RCR:
268         m_reg[RCR] = data & 0x4f;
269         break;
244270
245         case P1L:
246            m_p1l_written = true;
247            break;
271      case P0L:
272         m_reg[P0L] = data;
273         m_reg[P0H] = m_p0h_latch;
274         break;
248275
249         case P1H:
250            m_p1l_written = false;
251            break;
252         }
276      case P0H:
277         m_p0h_latch = data & 0x01;
278         break;
279
280      case P1L:
281         m_reg[P1L] = data;
282         m_reg[P1H] = m_p1h_latch;
283         break;
284
285      case P1H:
286         m_p1h_latch = data & 0x01;
287         break;
288
289      default:
290         m_reg[offset & 0x0f] = data;
253291      }
254      else if (offset >= 0xff00 && offset < 0xff05)
292   }
293   else if (offset >= 0xff00 && offset < 0xff05)
294   {
295      if (LOG) logerror("MOS8722 '%s' Write %01x : %02x\n", tag(), offset & 0x0f, data);
296
297      switch (offset & 0x0f)
255298      {
256         if (LOG) logerror("MOS8722 '%s' Write %01x : %02x\n", tag(), offset & 0x0f, data);
299      case CR:
300         m_reg[CR] = data & 0x7f;
301         break;
257302
258         switch (offset & 0x0f)
259         {
260         case CR:
261            m_reg[CR] = data;
262            break;
263
264         default:
265            m_reg[CR] = m_reg[offset & 0x0f];
266            break;
267         }
303      default:
304         m_reg[CR] = m_reg[offset & 0x0f];
305         break;
268306      }
269307   }
270308}
r18534r18535
286324
287325offs_t mos8722_device::ta_r(offs_t offset, int aec, int *ms0, int *ms1, int *ms2, int *ms3, int *cas0, int *cas1)
288326{
289   offs_t ta = offset & 0xff00;
327   offs_t ta;
290328
291   if (!aec)
292   {
293      ta = 0xf000 | (offset & 0xf00);
294   }
329   *ms0 = 1;
330   *ms1 = 1;
331   *ms2 = CR_IO;
332   *ms3 = !MCR_C64;
295333
296   if (!MCR_C64)
334   if (aec)
297335   {
298      *ms0 = 1;
299      *ms1 = 1;
300      *ms2 = CR_IO;
336      // CPU access
337      ta = offset & 0xff00;
301338
302      if (offset < 0x1000 && !MCR_8500)
303      {
304         ta = 0xd000 | (offset & 0xf00);
339      *cas0 = CR_A16;
340      *cas1 = !*cas0;
305341
306         *ms0 = 0;
307         *ms1 = 0;
308      }
309      else if (offset >= 0x4000 && offset < 0x8000)
342      if (!MCR_C64)
310343      {
311         *ms0 = CR_ROM_LO;
312         *ms1 = CR_ROM_LO;
313      }
314      else if (offset >= 0x8000 && offset < 0xc000)
315      {
316         *ms0 = BIT(CR_ROM_MID, 0);
317         *ms1 = BIT(CR_ROM_MID, 1);
318      }
319      else if (offset >= 0xc000)
320      {
321         *ms0 = BIT(CR_ROM_HI, 0);
322         *ms1 = BIT(CR_ROM_HI, 1);
323      }
344         if (offset >= 0xff00 && offset < 0xff05)
345         {
346            // MMU registers
347            *cas0 = 1;
348            *cas1 = 1;
349         }
350         else if (!MCR_8500 && !CR_A16 && offset < 0x1000)
351         {
352            // Z80 ROM
353            ta = 0xd000 | (offset & 0xf00);
324354
325      if (*ms0 == 1 && *ms1 == 1)
326      {
327         if (aec)
355            *ms0 = 0;
356            *ms1 = 0;
357         }
358         else
328359         {
329            *cas0 = BIT(CR_RAM, 0);
330            *cas1 = BIT(CR_RAM, 1);
331
332360            if (offset < 0x0100)
333361            {
334               if (m_p0l_written && m_reg[P0L])
335               {
336                  ta = m_reg[P0L] << 8;
362               // page 0 pointer
363               ta = m_reg[P0L] << 8;
337364
338                  *cas0 = P0H_A16 ? 1 : 0;
339                  *cas1 = P0H_A16 ? 0 : 1;
340               }
365               *cas0 = P0H_A16;
366               *cas1 = !*cas0;
341367            }
342368            else if (offset < 0x0200)
343369            {
344               if (m_p1l_written && m_reg[P1L])
370               // page 1 pointer
371               ta = m_reg[P1L] << 8;
372
373               *cas0 = P1H_A16;
374               *cas1 = !*cas0;
375            }
376            else if (offset >= 0x4000 && offset < 0x8000)
377            {
378               // low ROM
379               *ms0 = CR_ROM_LO;
380               *ms1 = CR_ROM_LO;
381            }
382            else if (offset >= 0x8000 && offset < 0xc000)
383            {
384               // middle ROM
385               *ms0 = BIT(CR_ROM_MID, 0);
386               *ms1 = BIT(CR_ROM_MID, 1);
387            }
388            else if (offset >= 0xc000)
389            {
390               // high ROM
391               *ms0 = BIT(CR_ROM_HI, 0);
392               *ms1 = BIT(CR_ROM_HI, 1);
393            }
394
395            if (*ms0 && *ms1)
396            {
397               if ((offset >> 8) == m_reg[P0L])
345398               {
346                  ta = m_reg[P1L] << 8;
347
348                  *cas0 = P1H_A16 ? 1 : 0;
349                  *cas1 = P1H_A16 ? 0 : 1;
399                  ta = 0x0000;
350400               }
401               else if ((offset >> 8) == m_reg[P1L])
402               {
403                  ta = 0x0100;
404               }
351405            }
352406
353407            if ((RCR_BOTTOM && offset < RCR_BOTTOM_ADDRESS[RCR_SHARE]) ||
354408               (RCR_TOP && offset >= RCR_TOP_ADDRESS[RCR_SHARE]))
355409            {
410               // RAM sharing
356411               *cas0 = 0;
357               *cas1 = 1;
412               *cas1 = !*cas0;
358413            }
359414         }
360         else
361         {
362            *cas0 = RCR_VA16 ? 1 : 0;
363            *cas1 = RCR_VA16 ? 0 : 1;
364         }
365415      }
366      else
367      {
368         *cas0 = 1;
369         *cas1 = 1;
370      }
371416   }
372417   else
373418   {
374      *ms0 = 1;
375      *ms1 = 1;
376      *ms2 = 1;
419      // VIC access
420      ta = 0xf000 | (offset & 0xf00);
377421
378      *cas0 = 0;
379      *cas1 = 1;
422      *cas0 = RCR_VA16;
423      *cas1 = !*cas0;
380424   }
381425
382   *ms3 = !MCR_C64;
383
384426   return ta;
385427}
trunk/src/mess/machine/mos8722.h
r18534r18535
102102   devcb_resolved_read_line   m_in_exrom_func;
103103   devcb_resolved_read_line   m_in_sense40_func;
104104
105   UINT8 m_reg[12];
105   UINT8 m_reg[16];
106106
107   bool m_p0l_written;
108   bool m_p1l_written;
107   UINT8 m_p0h_latch;
108   UINT8 m_p1h_latch;
109109};
110110
111111

Previous 199869 Revisions Next


© 1997-2024 The MAME Team