Previous 15994 Revisions Next

r9235 Monday 27th September, 2010 at 05:43:24 UTC by R. Belmont
[MAC] IIci now boots to Finder and runs apps. Do not attempt to set to 256 colors; there's still an issue there. 16 is fine.
[src/emu/cpu/m68000]m68000.h m68kcpu.c m68kcpu.h m68kmmu.h
[src/mess/drivers]mac.c
[src/mess/includes]mac.h
[src/mess/machine]mac.c ncr5380.c

src/emu/cpu/m68000/m68000.h
r9234r9235
3333   M68K_CPU_TYPE_SCC68070
3434};
3535
36/* HMMU enable types for use with m68k_set_hmmu_enable() */
37#define M68K_HMMU_DISABLE   0   /* no translation */
38#define M68K_HMMU_ENABLE_II   1   /* Mac II style fixed translation */
39#define M68K_HMMU_ENABLE_LC   2   /* Mac LC style fixed translation */
3640
3741/* Special interrupt acknowledge values.
3842 * Use these as special returns from the interrupt acknowledge callback
r9234r9235
7983DECLARE_LEGACY_CPU_DEVICE(M68EC020, m68ec020);
8084DECLARE_LEGACY_CPU_DEVICE(M68020, m68020);
8185DECLARE_LEGACY_CPU_DEVICE(M68020PMMU, m68020pmmu);
86DECLARE_LEGACY_CPU_DEVICE(M68020HMMU, m68020hmmu);
8287DECLARE_LEGACY_CPU_DEVICE(M68EC030, m68ec030);
8388DECLARE_LEGACY_CPU_DEVICE(M68030, m68030);
8489DECLARE_LEGACY_CPU_DEVICE(M68EC040, m68ec040);
r9234r9235
8994
9095void m68k_set_encrypted_opcode_range(running_device *device, offs_t start, offs_t end);
9196
97void m68k_set_hmmu_enable(running_device *device, int enable);
98
9299unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type);
93100
94101void m68k_set_reset_callback(running_device *device, m68k_reset_func callback);
src/emu/cpu/m68000/m68kcpu.h
r9234r9235
100100#define RUN_MODE_NORMAL          0
101101#define RUN_MODE_BERR_AERR_RESET 1
102102
103/* MMU constants */
104#define MMU_ATC_ENTRIES   (22)   // 68851 has 64, 030 has 22
103105
104106/* ======================================================================== */
105107/* ================================ MACROS ================================ */
r9234r9235
558560   void init16(address_space &space);
559561   void init32(address_space &space);
560562   void init32mmu(address_space &space);
563   void init32hmmu(address_space &space);
561564
562565   offs_t   opcode_xor;                  // Address Calculation
563566   m68k_readimm16_delegate readimm16;      // Immediate read 16 bit
r9234r9235
581584   UINT32 readlong_d32_mmu(offs_t address);
582585   void writelong_d32_mmu(offs_t address, UINT32 data);
583586
587   UINT8 read_byte_32_hmmu(offs_t address);
588   void write_byte_32_hmmu(offs_t address, UINT8 data);
589   UINT16 read_immediate_16_hmmu(offs_t address);
590   UINT16 readword_d32_hmmu(offs_t address);
591   void writeword_d32_hmmu(offs_t address, UINT16 data);
592   UINT32 readlong_d32_hmmu(offs_t address);
593   void writelong_d32_hmmu(offs_t address, UINT32 data);
594
584595   address_space *m_space;
585596   direct_read_data *m_direct;
586597   m68ki_cpu_core *m_cpustate;
r9234r9235
622633   UINT32 instr_mode;   /* Stores whether we are in instruction mode or group 0/1 exception mode */
623634   UINT32 run_mode;     /* Stores whether we are processing a reset, bus error, address error, or something else */
624635   int    has_pmmu;     /* Indicates if a PMMU available (yes on 030, 040, no on EC030) */
636   int    has_hmmu;     /* Indicates if an Apple HMMU is available in place of the 68851 (020 only) */
625637   int    pmmu_enabled; /* Indicates if the PMMU is enabled */
638   int    hmmu_enabled; /* Indicates if the HMMU is enabled */
626639   int    fpu_just_reset; /* Indicates the FPU was just reset */
627640
628641   /* Clocks required for instructions / exceptions */
r9234r9235
683696   UINT32 mmu_srp_aptr, mmu_srp_limit;
684697   UINT32 mmu_tc;
685698   UINT16 mmu_sr;
699   UINT32 mmu_atc_tag[MMU_ATC_ENTRIES], mmu_atc_data[MMU_ATC_ENTRIES];
700   UINT32 mmu_atc_rr;
701   UINT32 mmu_tt0, mmu_tt1;
686702};
687703
688704
src/emu/cpu/m68000/m68kmmu.h
r9234r9235
11/*
22    m68kmmu.h - PMMU implementation for 68851/68030/68040
3          HMMU implementation for 68020 (II and LC variants)
34
45    By R. Belmont
56
r9234r9235
78    Visit http://mamedev.org for licensing and usage restrictions.
89*/
910
11/* decodes the effective address */
12static UINT32 DECODE_EA_32(m68ki_cpu_core *m68k, int ea)
13{
14   int mode = (ea >> 3) & 0x7;
15   int reg = (ea & 0x7);
16
17   switch (mode)
18   {
19      case 2:      // (An)
20      {
21         return REG_A[reg];
22      }
23      case 3:      // (An)+
24      {
25         UINT32 ea = EA_AY_PI_32(m68k);
26         return ea;
27      }
28      case 5:      // (d16, An)
29      {
30         UINT32 ea = EA_AY_DI_32(m68k);
31         return ea;
32      }
33      case 6:      // (An) + (Xn) + d8
34      {
35         UINT32 ea = EA_AY_IX_32(m68k);
36         return ea;
37      }
38      case 7:
39      {
40         switch (reg)
41         {
42            case 0:      // (xxx).W
43            {
44               UINT32 ea = (UINT32)OPER_I_16(m68k);
45               return ea;
46            }
47            case 1:      // (xxx).L
48            {
49               UINT32 d1 = OPER_I_16(m68k);
50               UINT32 d2 = OPER_I_16(m68k);
51               UINT32 ea = (d1 << 16) | d2;
52               return ea;
53            }
54            case 2:      // (d16, PC)
55            {
56               UINT32 ea = EA_PCDI_32(m68k);
57               return ea;
58            }
59            default:   fatalerror("m68k: DECODE_EA_32: unhandled mode %d, reg %d at %08X\n", mode, reg, REG_PC);
60         }
61         break;
62      }
63      default:   fatalerror("m68k: DECODE_EA_32: unhandled mode %d, reg %d at %08X\n", mode, reg, REG_PC);
64   }
65   return 0;
66}
67
1068/*
69    pmmu_atc_add: adds this address to the ATC
70*/
71void pmmu_atc_add(m68ki_cpu_core *m68k, UINT32 logical, UINT32 physical)
72{
73   int i, found, curfc;
74
75   curfc = (m68ki_get_sr(m68k) & 0x2000) ? 4 : 0;
76   curfc |= 1;   // program vs. data space is not implemented
77
78   // first see if this is already in the cache
79   for (i = 0; i < MMU_ATC_ENTRIES; i++)
80   {
81      // if tag bits and function code match, don't add
82      if (((m68k->mmu_atc_tag[i] & 0xffffff) == (logical>>8)) && (((m68k->mmu_atc_tag[i]>>24) & 7) == curfc))
83      {
84          return;
85      }
86   }
87
88   // find an open entry
89   found = -1;
90   for (i = 0; i < MMU_ATC_ENTRIES; i++)
91   {
92      if (!(m68k->mmu_atc_tag[i] & 0x80000000))
93      {
94         found = i;
95         break;
96      }
97   }
98
99   // did we find an entry?  steal one by round-robin then
100   if (found == -1)
101   {
102      found = m68k->mmu_atc_rr++;
103
104      if (m68k->mmu_atc_rr >= MMU_ATC_ENTRIES)
105      {
106         m68k->mmu_atc_rr = 0;
107      }
108   }
109
110   // add the entry
111//   logerror("ATC[%d] add: log %08x -> phys %08x\n", found, logical, physical);
112   m68k->mmu_atc_tag[found] = (logical>>8) | (curfc<<24) | 0x80000000;
113   m68k->mmu_atc_data[found] = (physical>>8);
114}
115
116/*
117    pmmu_atc_flush: flush entire ATC
118
119    7fff0003 001ffd10 80f05750 is what should load
120*/
121void pmmu_atc_flush(m68ki_cpu_core *m68k)
122{
123   int i;
124
125   for (i = 0; i < MMU_ATC_ENTRIES; i++)
126   {
127      m68k->mmu_atc_tag[i] = 0;
128   }
129
130   m68k->mmu_atc_rr = 0;
131}   
132
133/*
11134    pmmu_translate_addr: perform 68851/68030-style PMMU address translation
12135*/
13136INLINE UINT32 pmmu_translate_addr(m68ki_cpu_core *m68k, UINT32 addr_in)
r9234r9235
15138   UINT32 addr_out, tbl_entry = 0, tbl_entry2, tamode = 0, tbmode = 0, tcmode = 0;
16139   UINT32 root_aptr, root_limit, tofs, is, abits, bbits, cbits;
17140   UINT32 resolved, tptr, shift;
141   int curfc, i;
142//   int verbose = 0;
18143
19144   resolved = 0;
20145   addr_out = addr_in;
21146
147   curfc = (m68ki_get_sr(m68k) & 0x2000) ? 4 : 0;
148   curfc |= 1;   // program vs. data space is not implemented
149
150   // first see if this is already in the ATC
151   for (i = 0; i < MMU_ATC_ENTRIES; i++)
152   {
153      // if tag bits and function code match, we've got it
154      if (((m68k->mmu_atc_tag[i] & 0xffffff) == (addr_in>>8)) && (((m68k->mmu_atc_tag[i]>>24) & 7) == curfc))
155      {
156         addr_out = (m68k->mmu_atc_data[i]<<8) | (addr_in & 0xff);
157//         logerror("ATC[%d] hit: log %08x -> phys %08x\n", i, addr_in, addr_out);
158         return addr_out;
159      }
160   }
161
162//   if (addr_in == 0x5fa04c) verbose = 1;
163
22164   // if SRP is enabled and we're in supervisor mode, use it
23165   if ((m68k->mmu_tc & 0x02000000) && (m68ki_get_sr(m68k) & 0x2000))
24166   {
r9234r9235
37179   bbits = (m68k->mmu_tc>>8)&0xf;
38180   cbits = (m68k->mmu_tc>>4)&0xf;
39181
40//  logerror("PMMU: tcr %08x limit %08x aptr %08x is %x abits %d bbits %d cbits %d\n", m68k->mmu_tc, root_limit, root_aptr, is, abits, bbits, cbits);
182   //logerror("PMMU: tcr %08x limit %08x aptr %08x is %x abits %d bbits %d cbits %d\n", m68k->mmu_tc, root_limit, root_aptr, is, abits, bbits, cbits);
41183
42184   // get table A offset
43185   tofs = (addr_in<<is)>>(32-abits);
r9234r9235
47189   {
48190      case 0:   // invalid, should cause MMU exception
49191      case 1:   // page descriptor, should cause direct mapping
50         fatalerror("680x0 PMMU: Unhandled root mode\n");
192         logerror("680x0 PMMU: Unhandled root mode %d, not translating (addr_in %x)\n", root_limit & 3, addr_in);
193         logerror("          : aptr %08x limit %08x\n", root_aptr, root_limit);
194         return addr_in;
51195         break;
52196
53197      case 2:   // valid 4 byte descriptors
54198         tofs *= 4;
55//         logerror("PMMU: reading table A entry at %08x\n", tofs + (root_aptr & 0xfffffffc));
199//         if (verbose) logerror("PMMU: reading table A entry at %08x\n", tofs + (root_aptr & 0xfffffffc));
56200         tbl_entry = m68k->program->read_dword(tofs + (root_aptr & 0xfffffffc));
57201         tamode = tbl_entry & 3;
58//         logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tamode, tofs);
202//         if (verbose) logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tamode, tofs);
59203         break;
60204
61205      case 3: // valid 8 byte descriptors
62206         tofs *= 8;
63//          logerror("PMMU: reading table A entries at %08x\n", tofs + (root_aptr & 0xfffffffc));
207//          if (verbose) logerror("PMMU: reading table A entries at %08x\n", tofs + (root_aptr & 0xfffffffc));
64208         tbl_entry2 = m68k->program->read_dword(tofs + (root_aptr & 0xfffffffc));
65209         tbl_entry = m68k->program->read_dword(tofs + (root_aptr & 0xfffffffc)+4);
66210         tamode = tbl_entry2 & 3;
67//          logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tamode, tofs);
211//          if (verbose) logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tamode, tofs);
68212         break;
69213   }
70214
r9234r9235
76220   switch (tamode)
77221   {
78222      case 0: // invalid, should cause MMU exception
79         fatalerror("680x0 PMMU: Unhandled Table A mode %d (addr_in %08x)\n", tamode, addr_in);
223         fatalerror("680x0 PMMU: Unhandled Table A mode %d (addr_in %08x PC %x)\n", tamode, addr_in, m68k->pc);
80224         break;
81225
82226      case 2: // 4-byte table B descriptor
83227         tofs *= 4;
84//          logerror("PMMU: reading table B entry at %08x\n", tofs + tptr);
228//          if (verbose) logerror("PMMU: reading table B entry at %08x\n", tofs + tptr);
85229         tbl_entry = m68k->program->read_dword(tofs + tptr);
86230         tbmode = tbl_entry & 3;
87//          logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tbmode, tofs);
231//          if (verbose) logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tbmode, tofs);
88232         break;
89233
90234      case 3: // 8-byte table B descriptor
91235         tofs *= 8;
92//          logerror("PMMU: reading table B entries at %08x\n", tofs + tptr);
236//          if (verbose) logerror("PMMU: reading table B entries at %08x\n", tofs + tptr);
93237         tbl_entry2 = m68k->program->read_dword(tofs + tptr);
94238         tbl_entry = m68k->program->read_dword(tofs + tptr + 4);
95239         tbmode = tbl_entry2 & 3;
96//          logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tbmode, tofs);
240//          if (verbose) logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tbmode, tofs);
97241         break;
98242
99243      case 1:   // early termination descriptor
r9234r9235
120264
121265         case 2: // 4-byte table C descriptor
122266            tofs *= 4;
123//              logerror("PMMU: reading table C entry at %08x\n", tofs + tptr);
267//              if (verbose) logerror("PMMU: reading table C entry at %08x\n", tofs + tptr);
124268            tbl_entry = m68k->program->read_dword(tofs + tptr);
125269            tcmode = tbl_entry & 3;
126//              logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tbmode, tofs);
270//              if (verbose) logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tbmode, tofs);
127271            break;
128272
129273         case 3: // 8-byte table C descriptor
130274            tofs *= 8;
131//              logerror("PMMU: reading table C entries at %08x\n", tofs + tptr);
275//              if (verbose) logerror("PMMU: reading table C entries at %08x\n", tofs + tptr);
132276            tbl_entry2 = m68k->program->read_dword(tofs + tptr);
133277            tbl_entry = m68k->program->read_dword(tofs + tptr + 4);
134278            tcmode = tbl_entry2 & 3;
135//              logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tbmode, tofs);
279//              if (verbose) logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tbmode, tofs);
136280            break;
137281
138282         case 1: // termination descriptor
r9234r9235
150294      switch (tcmode)
151295      {
152296         case 0:   // invalid, should cause MMU exception
153         case 2: // 4-byte ??? descriptor
154         case 3: // 8-byte ??? descriptor
155            fatalerror("680x0 PMMU: Unhandled Table B mode %d (addr_in %08x PC %x)\n", tbmode, addr_in, m68k->pc);
297         case 2: // 4-byte table D descriptor
298         case 3: // 8-byte table D descriptor
299            fatalerror("680x0 PMMU: Unhandled Table C mode %d (addr_in %08x PC %x)\n", tbmode, addr_in, m68k->pc);
156300            break;
157301
158302         case 1: // termination descriptor
r9234r9235
165309      }
166310   }
167311
312   pmmu_atc_add(m68k, addr_in, addr_out);
168313
169//  logerror("PMMU: [%08x] => [%08x]\n", addr_in, addr_out);
314   //logerror("PMMU: [%08x] => [%08x]\n", addr_in, addr_out);
170315
171316   return addr_out;
172317}
r9234r9235
202347
203348            if ((modes & 0xfde0) == 0x2000)   // PLOAD
204349            {
205               logerror("680x0: unhandled PLOAD\n");
350               UINT32 ltmp = DECODE_EA_32(m68k, ea);
351               UINT32 ptmp;
352
353               ptmp = ltmp;
354               if (m68k->pmmu_enabled)
355               {
356                  ptmp = pmmu_translate_addr(m68k, ltmp);
357               }
358
359//               logerror("680x0: PLOADing ATC with logical %08x => phys %08x\n", ltmp, ptmp);
360
361               pmmu_atc_add(m68k, ltmp, ptmp);
206362               return;
207363            }
208364            else if ((modes & 0xe200) == 0x2000)   // PFLUSH
209365            {
210               logerror("680x0: unhandled PFLUSH PC=%x\n", m68k->pc);
366               pmmu_atc_flush(m68k);
211367               return;
212368            }
213369            else if (modes == 0xa000)   // PFLUSHR
214370            {
215               logerror("680x0: unhandled PFLUSHR\n");
371               pmmu_atc_flush(m68k);
216372               return;
217373            }
218374            else if (modes == 0x2800)   // PVALID (FORMAT 1)
r9234r9235
257413                              break;
258414                        }
259415                     }
260                     else
416                     else   // top 3 bits of modes: 010 for this, 011 for status, 000 for transparent translation regs
261417                     {
262                        switch ((modes>>10) & 7)
418                        switch ((modes>>13) & 7)
263419                        {
264                           case 0:   // translation control register
265                              m68k->mmu_tc = READ_EA_32(m68k, ea);
420                           case 0:
421                              {
422                                  UINT32 temp = READ_EA_32(m68k, ea);
266423
267                              if (m68k->mmu_tc & 0x80000000)
268                              {
269                                 m68k->pmmu_enabled = 1;
424                                 if (((modes>>10) & 7) == 2)
425                                 {
426                                    m68k->mmu_tt0 = temp;
427                                 }
428                                 else if (((modes>>10) & 7) == 3)
429                                 {
430                                    m68k->mmu_tt1 = temp;
431                                 }
270432                              }
271                              else
272                              {
273                                 m68k->pmmu_enabled = 0;
274                              }
275433                              break;
276434
277                           case 2:   // supervisor root pointer
278                              temp64 = READ_EA_64(m68k, ea);
279                              m68k->mmu_srp_limit = (temp64>>32) & 0xffffffff;
280                              m68k->mmu_srp_aptr = temp64 & 0xffffffff;
435                           case 1:
436                              logerror("680x0: unknown PMOVE case 1, PC %x\n", m68k->pc);
281437                              break;
282438
283                           case 3:   // CPU root pointer
284                              temp64 = READ_EA_64(m68k, ea);
285                              m68k->mmu_crp_limit = (temp64>>32) & 0xffffffff;
286                              m68k->mmu_crp_aptr = temp64 & 0xffffffff;
439                           case 2:
440                              switch ((modes>>10) & 7)
441                              {
442                                 case 0:   // translation control register
443                                    m68k->mmu_tc = READ_EA_32(m68k, ea);
444//                                    logerror("PMMU: TC = %08x\n", m68k->mmu_tc);
445
446                                    if (m68k->mmu_tc & 0x80000000)
447                                    {
448                                       m68k->pmmu_enabled = 1;
449//                                       logerror("PMMU enabled\n");
450                                    }
451                                    else
452                                    {
453                                       m68k->pmmu_enabled = 0;
454//                                       logerror("PMMU disabled\n");
455                                    }
456
457                                    if (!(modes & 0x100))   // flush ATC on moves to TC, SRP, CRP with FD bit clear
458                                    {
459                                       pmmu_atc_flush(m68k);
460                                    }
461                                    break;
462
463                                 case 2:   // supervisor root pointer
464                                    temp64 = READ_EA_64(m68k, ea);
465                                    m68k->mmu_srp_limit = (temp64>>32) & 0xffffffff;
466                                    m68k->mmu_srp_aptr = temp64 & 0xffffffff;
467//                                    logerror("PMMU: SRP limit = %08x aptr = %08x\n", m68k->mmu_srp_limit, m68k->mmu_srp_aptr);
468                                    if (!(modes & 0x100))
469                                    {
470                                       pmmu_atc_flush(m68k);
471                                    }
472                                    break;
473
474                                 case 3:   // CPU root pointer
475                                    temp64 = READ_EA_64(m68k, ea);
476                                    m68k->mmu_crp_limit = (temp64>>32) & 0xffffffff;
477                                    m68k->mmu_crp_aptr = temp64 & 0xffffffff;
478//                                    logerror("PMMU: CRP limit = %08x aptr = %08x\n", m68k->mmu_crp_limit, m68k->mmu_crp_aptr);
479                                    if (!(modes & 0x100))
480                                    {
481                                       pmmu_atc_flush(m68k);
482                                    }
483                                    break;
484
485                                 default:
486                                    logerror("680x0: PMOVE to unknown MMU register %x, PC %x\n", (modes>>10) & 7, m68k->pc);
487                                    break;
488                              }
287489                              break;
288490
289                           default:
290                              logerror("680x0: PMOVE to unknown MMU register %x, PC %x\n", (modes>>10) & 7, m68k->pc);
491                           case 3:   // MMU status
492                              {
493                                  UINT32 temp = READ_EA_32(m68k, ea);
494                                 logerror("680x0: unsupported PMOVE %x to MMU status, PC %x\n", temp, m68k->pc);
495                              }
291496                              break;
292497                        }
293498                     }
r9234r9235
307512                  default:
308513                     logerror("680x0: unknown PMOVE mode %x (modes %04x) (PC %x)\n", (modes>>13) & 0x7, modes, m68k->pc);
309514                     break;
515                 
310516               }
311517            }
312518            break;
r9234r9235
318524   }
319525}
320526
527
528/* Apple HMMU translation is much simpler */
529INLINE UINT32 hmmu_translate_addr(m68ki_cpu_core *m68k, UINT32 addr_in)
530{
531   UINT32 addr_out;
532
533   addr_out = addr_in;
534
535   // check if LC mode is enabled
536   if (m68k->hmmu_enabled == M68K_HMMU_ENABLE_LC)
537   {
538      addr_in &= 0xffffff;
539      addr_out &= 0xffffff;
540
541      if ((addr_in >= 0xa00000) && (addr_in <= 0xdfffff))
542      {
543         addr_out |= 0x40000000;
544      }
545      if ((addr_in >= 0xe00000) && (addr_in <= 0xefffff))
546      {
547         addr_out &= 0xfffff;
548         addr_out |= 0xfe000000;
549      }
550      else if (addr_in >= 0xf00000)
551      {
552         addr_out |= 0x50000000;
553      }
554   }
555
556   return addr_out;
557}
src/emu/cpu/m68000/m68kcpu.c
r9234r9235
571571   return TRUE;
572572}
573573
574/* translate logical to physical addresses for Apple HMMU */
575static CPU_TRANSLATE( m68khmmu )
576{
577   m68ki_cpu_core *m68k = get_safe_token(device);
578
579   /* only applies to the program address space and only does something if the MMU's enabled */
580   if (m68k)
581   {
582      if ((space == ADDRESS_SPACE_PROGRAM) && (m68k->hmmu_enabled))
583      {
584         *address = hmmu_translate_addr(m68k, *address);
585      }
586   }
587   return TRUE;
588}
589
574590/* Execute some instructions until we use up cycles clock cycles */
575591static CPU_EXECUTE( m68k )
576592{
r9234r9235
633649   m68k->program = device->space(AS_PROGRAM);
634650   m68k->int_ack_callback = irqcallback;
635651
652   /* disable all MMUs */
653   m68k->has_pmmu          = 0;
654   m68k->has_hmmu          = 0;
655   m68k->pmmu_enabled     = 0;
656   m68k->hmmu_enabled     = 0;
657
636658   /* The first call to this function initializes the opcode handler jump table */
637659   if(!emulation_initialized)
638660   {
r9234r9235
667689{
668690   m68ki_cpu_core *m68k = get_safe_token(device);
669691
670   /* Disable the PMMU on reset */
692   /* Disable the PMMU/HMMU on reset, if any */
671693   m68k->pmmu_enabled = 0;
694   m68k->hmmu_enabled = 0;
672695
673696   /* Clear all stop levels and eat up all remaining cycles */
674697   m68k->stopped = 0;
r9234r9235
702725   m68k->run_mode = RUN_MODE_NORMAL;
703726
704727   m68k->reset_cycles = m68k->cyc_exception[EXCEPTION_RESET];
728
729   /* flush the MMU's cache */
730   pmmu_atc_flush(m68k);
705731}
706732
707733static CPU_DISASSEMBLE( m68k )
r9234r9235
940966   m68k->encrypted_end = end;
941967}
942968
969void m68k_set_hmmu_enable(running_device *device, int enable)
970{
971   m68ki_cpu_core *m68k = get_safe_token(device);
972
973   m68k->hmmu_enabled = enable;
974}
975
943976/****************************************************************************
944977 * 8-bit data memory interface
945978 ****************************************************************************/
r9234r9235
11431176}
11441177
11451178
1179/* interface for 32-bit data bus with PMMU (68EC020, 68020) */
1180UINT8 m68k_memory_interface::read_byte_32_hmmu(offs_t address)
1181{
1182   if (m_cpustate->hmmu_enabled)
1183   {
1184      address = hmmu_translate_addr(m_cpustate, address);
1185   }
1186
1187   return m_space->read_byte(address);
1188}
1189
1190void m68k_memory_interface::write_byte_32_hmmu(offs_t address, UINT8 data)
1191{
1192   if (m_cpustate->hmmu_enabled)
1193   {
1194      address = hmmu_translate_addr(m_cpustate, address);
1195   }
1196
1197   m_space->write_byte(address, data);
1198}
1199
1200UINT16 m68k_memory_interface::read_immediate_16_hmmu(offs_t address)
1201{
1202   if (m_cpustate->hmmu_enabled)
1203   {
1204      address = hmmu_translate_addr(m_cpustate, address);
1205   }
1206
1207   return m_direct->read_decrypted_word((address) ^ m_cpustate->memory.opcode_xor);
1208}
1209
1210/* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */
1211UINT16 m68k_memory_interface::readword_d32_hmmu(offs_t address)
1212{
1213   UINT16 result;
1214
1215   if (m_cpustate->hmmu_enabled)
1216   {
1217      address = hmmu_translate_addr(m_cpustate, address);
1218   }
1219
1220   if (!(address & 1))
1221      return m_space->read_word(address);
1222   result = m_space->read_byte(address) << 8;
1223   return result | m_space->read_byte(address + 1);
1224}
1225
1226/* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */
1227void m68k_memory_interface::writeword_d32_hmmu(offs_t address, UINT16 data)
1228{
1229   if (m_cpustate->hmmu_enabled)
1230   {
1231      address = hmmu_translate_addr(m_cpustate, address);
1232   }
1233
1234   if (!(address & 1))
1235   {
1236      m_space->write_word(address, data);
1237      return;
1238   }
1239   m_space->write_byte(address, data >> 8);
1240   m_space->write_byte(address + 1, data);
1241}
1242
1243/* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */
1244UINT32 m68k_memory_interface::readlong_d32_hmmu(offs_t address)
1245{
1246   UINT32 result;
1247
1248   if (m_cpustate->hmmu_enabled)
1249   {
1250      address = hmmu_translate_addr(m_cpustate, address);
1251   }
1252
1253   if (!(address & 3))
1254      return m_space->read_dword(address);
1255   else if (!(address & 1))
1256   {
1257      result = m_space->read_word(address) << 16;
1258      return result | m_space->read_word(address + 2);
1259   }
1260   result = m_space->read_byte(address) << 24;
1261   result |= m_space->read_word(address + 1) << 8;
1262   return result | m_space->read_byte(address + 3);
1263}
1264
1265/* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */
1266void m68k_memory_interface::writelong_d32_hmmu(offs_t address, UINT32 data)
1267{
1268   if (m_cpustate->hmmu_enabled)
1269   {
1270      address = hmmu_translate_addr(m_cpustate, address);
1271   }
1272
1273   if (!(address & 3))
1274   {
1275      m_space->write_dword(address, data);
1276      return;
1277   }
1278   else if (!(address & 1))
1279   {
1280      m_space->write_word(address, data >> 16);
1281      m_space->write_word(address + 2, data);
1282      return;
1283   }
1284   m_space->write_byte(address, data >> 24);
1285   m_space->write_word(address + 1, data >> 8);
1286   m_space->write_byte(address + 3, data);
1287}
1288
1289void m68k_memory_interface::init32hmmu(address_space &space)
1290{
1291   m_space = &space;
1292   m_direct = &space.direct();
1293   m_cpustate = get_safe_token(&space.device());
1294   opcode_xor = WORD_XOR_BE(0);
1295
1296   readimm16 = m68k_readimm16_delegate(m68k_readimm16_proto_delegate::create_member(m68k_memory_interface, read_immediate_16_hmmu), *this);
1297   read8 = m68k_read8_delegate(m68k_read8_proto_delegate::create_member(m68k_memory_interface, read_byte_32_hmmu), *this);
1298   read16 = m68k_read16_delegate(m68k_read16_proto_delegate::create_member(m68k_memory_interface, readword_d32_hmmu), *this);
1299   read32 = m68k_read32_delegate(m68k_read32_proto_delegate::create_member(m68k_memory_interface, readlong_d32_hmmu), *this);
1300   write8 = m68k_write8_delegate(m68k_write8_proto_delegate::create_member(m68k_memory_interface, write_byte_32_hmmu), *this);
1301   write16 = m68k_write16_delegate(m68k_write16_proto_delegate::create_member(m68k_memory_interface, writeword_d32_hmmu), *this);
1302   write32 = m68k_write32_delegate(m68k_write32_proto_delegate::create_member(m68k_memory_interface, writelong_d32_hmmu), *this);
1303}
1304
11461305void m68k_set_reset_callback(running_device *device, m68k_reset_func callback)
11471306{
11481307   m68ki_cpu_core *m68k = get_safe_token(device);
r9234r9235
12531412   m68k->cyc_shift        = 1;
12541413   m68k->cyc_reset        = 132;
12551414   m68k->has_pmmu          = 0;
1415   m68k->has_hmmu          = 0;
12561416
12571417   define_state(device);
12581418}
r9234r9235
14031563   m68k->cyc_movem_l      = 2;
14041564   m68k->cyc_shift        = 0;
14051565   m68k->cyc_reset        = 518;
1406   m68k->has_pmmu          = 0;
14071566
14081567   define_state(device);
14091568}
r9234r9235
14591618   }
14601619}
14611620
1621// 68020 with Apple HMMU
1622static CPU_INIT( m68020hmmu )
1623{
1624   m68ki_cpu_core *m68k = get_safe_token(device);
1625
1626   CPU_INIT_CALL(m68020);
1627
1628   m68k->has_hmmu = 1;
1629// hack alert: we use placement new to ensure we are properly initialized
1630// because we live in the device state which is allocated as bytes
1631// remove me when we have a real C++ device
1632   new(&m68k->memory) m68k_memory_interface;
1633   m68k->memory.init32mmu(*m68k->program);
1634}
1635
1636CPU_GET_INFO( m68020hmmu )
1637{
1638   switch (state)
1639   {
1640      /* --- the following bits of info are returned as pointers to data or functions --- */
1641      case CPUINFO_FCT_INIT:      info->init = CPU_INIT_NAME(m68020hmmu);         break;
1642      case CPUINFO_FCT_TRANSLATE:   info->translate = CPU_TRANSLATE_NAME(m68khmmu);      break;
1643
1644      /* --- the following bits of info are returned as NULL-terminated strings --- */
1645      case DEVINFO_STR_NAME:      strcpy(info->s, "68020, Apple HMMU");         break;
1646
1647      default:         CPU_GET_INFO_CALL(m68020);            break;
1648   }
1649}
1650
14621651/****************************************************************************
14631652 * M680EC20 section
14641653 ****************************************************************************/
r9234r9235
18031992DEFINE_LEGACY_CPU_DEVICE(M68EC020, m68ec020);
18041993DEFINE_LEGACY_CPU_DEVICE(M68020, m68020);
18051994DEFINE_LEGACY_CPU_DEVICE(M68020PMMU, m68020pmmu);
1995DEFINE_LEGACY_CPU_DEVICE(M68020HMMU, m68020hmmu);
18061996DEFINE_LEGACY_CPU_DEVICE(M68EC030, m68ec030);
18071997DEFINE_LEGACY_CPU_DEVICE(M68030, m68030);
18081998DEFINE_LEGACY_CPU_DEVICE(M68EC040, m68ec040);
src/mess/machine/ncr5380.c
r9234r9235
1515 * This implementation is tied closely to the drivers found in the Mac Plus ROM and the routines in Mac
1616 * System 6 and 7 that it patches out the ROM traps with.  While attempts have been made to
1717 * have the behavior work according to the manual and not the specific Apple driver code,
18 * there are almost certainly areas where that is true.  In particular, IRQs are not implemented
19 * as they are unused on the Mac Plus.
18 * there are almost certainly areas where that is true.
2019 *
2120 */
2221
r9234r9235
170169   m_d_ptr = 0;
171170   m_d_limit = 0;
172171   m_last_id = 0;
172
173   ncr5380_scan_devices();
173174}
174175
175176//-------------------------------------------------
src/mess/machine/mac.c
r9234r9235
7878#include "devices/messram.h"
7979#include "debugger.h"
8080
81#define ADB_IS_BITBANG   (mac->mac_model >= MODEL_MAC_SE && mac->mac_model <= MODEL_MAC_CLASSIC) || (mac->mac_model >= MODEL_MAC_II && mac->mac_model <= MODEL_MAC_IICX) || (mac->mac_model == MODEL_MAC_SE30)
81#define ADB_IS_BITBANG   ((mac->mac_model == MODEL_MAC_SE || mac->mac_model == MODEL_MAC_CLASSIC) || (mac->mac_model >= MODEL_MAC_II && mac->mac_model <= MODEL_MAC_IICI) || (mac->mac_model == MODEL_MAC_SE30))
8282#define ADB_IS_EGRET   (mac->mac_model >= MODEL_MAC_LC && mac->mac_model <= MODEL_MAC_COLOR_CLASSIC) || (mac->mac_model == MODEL_MAC_IISI)
8383#define ADB_IS_PM   (mac->mac_model >= MODEL_MAC_PORTABLE && mac->mac_model <= MODEL_MAC_PB100)
8484
r9234r9235
113113
114114static TIMER_CALLBACK(mac_scanline_tick);
115115static TIMER_CALLBACK(mac_adb_tick);
116static TIMER_CALLBACK(mac_6015_tick);
116117static emu_timer *mac_scanline_timer, *mac_adb_timer;
117118static int scan_keyboard(running_machine *machine);
118119static TIMER_CALLBACK(inquiry_timeout_func);
r9234r9235
292293}
293294
294295
295static void set_via2_interrupt(running_machine *machine, int value)
296void mac_set_via2_interrupt(running_machine *machine, int value)
296297{
297298   via2_interrupt = value;
298299
r9234r9235
26832684
26842685static void mac_via2_irq(running_device *device, int state)
26852686{
2686   set_via2_interrupt(device->machine, state);
2687   mac_set_via2_interrupt(device->machine, state);
26872688}
26882689
26892690READ16_HANDLER ( mac_via2_r )
r9234r9235
26962697
26972698   data = via_1->read(*space, offset);
26982699
2699   if (LOG_VIA)
2700//   if (LOG_VIA)
27002701      logerror("mac_via2_r: offset=0x%02x = %02x (PC=%x)\n", offset*2, data, cpu_get_pc(space->machine->device("maincpu")));
27012702
27022703   return (data & 0xff) | (data << 8);
r9234r9235
27092710   offset >>= 8;
27102711   offset &= 0x0f;
27112712
2712   if (LOG_VIA)
2713//   if (LOG_VIA)
27132714      logerror("mac_via2_w: offset=%x data=0x%08x (PC=%x)\n", offset, data, cpu_get_pc(space->machine->device("maincpu")));
27142715
27152716   if (ACCESSING_BITS_8_15)
r9234r9235
27242725
27252726   result |= mac->mac_nubus_irq_state;
27262727
2727   if ((mac->mac_model == MODEL_MAC_IICI) || (mac->mac_model == MODEL_MAC_IISI))
2728   {
2729      result &= ~0x40;   // RBV wants this clear to boot
2730   }
2731
27322728   return result;
27332729}
27342730
r9234r9235
27622758
27632759//  logerror("VIA2 OUT B: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu")));
27642760
2765//  printf("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08);
2761   logerror("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08);
27662762
27672763   // chain 60.15 Hz to VIA1
27682764   via_0->write_ca1(data>>7);
27692765}
27702766
2767// This signal is generated internally on RBV, V8, Sonora, VASP, Eagle, etc.
2768static TIMER_CALLBACK(mac_6015_tick)
2769{
2770   via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
2771
2772   via_0->write_ca1(0);
2773   via_0->write_ca1(1);
2774}
2775
27712776/* *************************************************************************
27722777 * Main
27732778 * *************************************************************************/
r9234r9235
27822787   }
27832788   mac_scanline_timer = timer_alloc(machine, mac_scanline_tick, NULL);
27842789   timer_adjust_oneshot(mac_scanline_timer, machine->primary_screen->time_until_pos(0, 0), 0);
2790
2791   mac->mac6015_timer = timer_alloc(machine, mac_6015_tick, NULL);
2792   timer_adjust_oneshot(mac->mac6015_timer, attotime_never, 0);
27852793}
27862794MACHINE_RESET(mac)
27872795{
r9234r9235
27892797   mac_model_t model_save;
27902798   emu_timer *timer_save;
27912799
2800   // stop 60.15 Hz timer
2801   timer_adjust_oneshot(mac->mac6015_timer, attotime_never, 0);
2802
2803   // start 60.15 Hz timer for IIci/IIsi (and eventually others)
2804   if ((mac->mac_model == MODEL_MAC_IICI) || (mac->mac_model == MODEL_MAC_IISI))
2805   {
2806      timer_adjust_periodic(mac->mac6015_timer, ATTOTIME_IN_HZ(60.15), 0, ATTOTIME_IN_HZ(60.15));
2807   }
2808
27922809   // clear mac state struct
27932810   model_save = mac->mac_model;
27942811   timer_save = mac->inquiry_timeout;
r9234r9235
28262843
28272844   if (mac->mac_model >= MODEL_MAC_PLUS)
28282845   {
2829      ncr5380_scan_devices(machine->device("ncr5380"));
2846//      ncr5380_scan_devices(machine->device("ncr5380"));
28302847   }
28312848
28322849   if ((mac->mac_model == MODEL_MAC_SE) || (mac->mac_model == MODEL_MAC_CLASSIC))
r9234r9235
30253042
30263043DRIVER_INIT(maciici)
30273044{
3028   UINT32 *ROM = (UINT32 *)memory_region(machine, "bootrom");
3029
3030   ROM[0x4569c/4] = 0x4ed64e71;   // jmp (a6) / nop (skip FPU test)
3031   ROM[0x446b4/4] = 0x4e714e71;   // nop nop - disable ROM checksum
3032   ROM[0x446b8/4] = 0x4e714ed6;   // nop jmp (a6) - disable ROM checksum
3033
30343045   mac_driver_init(machine, MODEL_MAC_IICI);
30353046}
30363047
src/mess/includes/mac.h
r9234r9235
150150
151151void mac_asc_irq(running_device *device, int state);
152152
153void mac_set_via2_interrupt(running_machine *machine, int value);
154
153155/*----------- defined in video/mac.c -----------*/
154156
155157extern UINT32 *mac_se30_vram;
r9234r9235
259261   // Apple Sound Chip
260262   UINT8 mac_asc_regs[0x2000];
261263   INT16 xfersamples[0x800];
264
265   // 60.15 Hz timer for RBV/V8/Sonora/Eagle/VASP/etc.
266   emu_timer *mac6015_timer;
262267};
263268
264269#endif /* MAC_H_ */
src/mess/drivers/mac.c
r9234r9235
7171
7272// IIci/IIsi RAM-Based Video (RBV)
7373
74// 512x384x1 framebuffer at fb008000?
75// 640x480x1 framebuffer at fee00000?
74static UINT8 rbv_regs[256], rbv_ier, rbv_ifr;
75static UINT32 rbv_colors[3], rbv_count, rbv_clutoffs, rbv_immed10wr;
76static UINT32 rbv_palette[256];
7677
77static UINT32 *rbv_vram;
78static VIDEO_START( macrbv )
79{
80   memset(rbv_regs, 0, sizeof(rbv_regs));
7881
79static UINT32 rbv_colors[3], rbv_count, rbv_clutoffs;
80static UINT32 rbv_palette[256];
82   rbv_count = 0;
83   rbv_clutoffs = 0;
84   rbv_immed10wr = 0;
8185
86   rbv_regs[2] = 0xff;
87}
88
8289static VIDEO_UPDATE( macrbv )
8390{
8491   UINT32 *scanline;
8592   int x, y;
86   UINT8 *vram8 = (UINT8 *)rbv_vram;
87   UINT8 pixels;
8893
89   for (y = 0; y < 480; y++)
94   rbv_regs[2] &= ~0x40;   // set vblank signal
95
96   if ((rbv_regs[0x12] & 0x40) && (rbv_ier & 0x2))
9097   {
91      scanline = BITMAP_ADDR32(bitmap, y, 0);
92      for (x = 0; x < 640; x+=8)
98      rbv_ifr |= 0x82;
99      mac_set_via2_interrupt(screen->machine, 1);
100   }
101
102   switch (rbv_regs[0x10] & 7)
103   {
104      case 0:   // 1bpp
93105      {
94         pixels = vram8[(y * 1024) + ((x/8)^3)];
106         UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
107         UINT8 pixels;
95108
96         *scanline++ = rbv_palette[(pixels>>7)^1];
97         *scanline++ = rbv_palette[((pixels>>6)&1)^1];
98         *scanline++ = rbv_palette[((pixels>>5)&1)^1];
99         *scanline++ = rbv_palette[((pixels>>4)&1)^1];
100         *scanline++ = rbv_palette[((pixels>>3)&1)^1];
101         *scanline++ = rbv_palette[((pixels>>2)&1)^1];
102         *scanline++ = rbv_palette[((pixels>>1)&1)^1];
103         *scanline++ = rbv_palette[(pixels&1)^1];
109         for (y = 0; y < 480; y++)
110         {
111            scanline = BITMAP_ADDR32(bitmap, y, 0);
112            for (x = 0; x < 640; x+=8)
113            {
114               pixels = vram8[(y * 80) + ((x/8)^3)];
115
116               *scanline++ = rbv_palette[0xfe|(pixels>>7)];
117               *scanline++ = rbv_palette[0xfe|((pixels>>6)&1)];
118               *scanline++ = rbv_palette[0xfe|((pixels>>5)&1)];
119               *scanline++ = rbv_palette[0xfe|((pixels>>4)&1)];
120               *scanline++ = rbv_palette[0xfe|((pixels>>3)&1)];
121               *scanline++ = rbv_palette[0xfe|((pixels>>2)&1)];
122               *scanline++ = rbv_palette[0xfe|((pixels>>1)&1)];
123               *scanline++ = rbv_palette[0xfe|(pixels&1)];
124            }
125         }
104126      }
127      break;
128
129      case 1:   // 2bpp
130      {
131         UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
132         UINT8 pixels;
133
134         for (y = 0; y < 480; y++)
135         {
136            scanline = BITMAP_ADDR32(bitmap, y, 0);
137            for (x = 0; x < 640/4; x++)
138            {
139               pixels = vram8[(y * 160) + (BYTE4_XOR_BE(x))];
140
141               *scanline++ = rbv_palette[0xfc|((pixels>>6)&3)];
142               *scanline++ = rbv_palette[0xfc|((pixels>>4)&3)];
143               *scanline++ = rbv_palette[0xfc|((pixels>>2)&3)];
144               *scanline++ = rbv_palette[0xfc|(pixels&3)];
145            }
146         }
147      }
148      break;
149
150      case 2: // 4bpp
151      {
152         UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
153         UINT8 pixels;
154
155         for (y = 0; y < 480; y++)
156         {
157            scanline = BITMAP_ADDR32(bitmap, y, 0);
158
159            for (x = 0; x < 640/2; x++)
160            {
161               pixels = vram8[(y * 320) + (BYTE4_XOR_BE(x))];
162
163               *scanline++ = rbv_palette[0xf0|(pixels>>4)];
164               *scanline++ = rbv_palette[0xf0|(pixels&0xf)];
165            }
166         }
167      }
168      break;
105169   }
106170
107171   return 0;
r9234r9235
120184
121185      if (rbv_count == 3)
122186      {
123         rbv_count = 0;
124187         palette_set_color(space->machine, rbv_clutoffs, MAKE_RGB(rbv_colors[0], rbv_colors[1], rbv_colors[2]));
125188         rbv_palette[rbv_clutoffs] = MAKE_RGB(rbv_colors[0], rbv_colors[1], rbv_colors[2]);
126189         rbv_clutoffs++;
190         rbv_count = 0;
127191      }
128192   }
129193}
130194
131
132static UINT32 rbv_toggle = 0;
133static READ16_HANDLER ( mac_rbv_r )
195static READ8_HANDLER ( mac_rbv_r )
134196{
135   int data;
136   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
197   int data = 0;
198   
199   if (offset < 0x100)
200   {   
201      data = rbv_regs[offset];
137202
138   logerror("rbv_r: %x, mask %x\n", offset, mem_mask);
203      if (offset == 0x02)
204      {
205         if (!space->machine->primary_screen->vblank())
206         {
207            data |= 0x40;
208         }
209      }
139210
140   if (offset == 1)
141   {
142      rbv_toggle ^= 0x4040;
143      return rbv_toggle;
211      if (offset == 0x10)
212      {
213         if (!rbv_immed10wr)
214         {
215            data &= ~0x38;
216            data |= (6<<3);   // 13" RGB monitor at 640x480
217         }
218         else
219         {
220            rbv_immed10wr = 0;
221         }
222      }
223
224      // bit 7 of these registers always reads as 0 on RBV
225      if ((offset == 0x12) || (offset == 0x13))
226      {
227         data &= ~0x80;
228      }
144229   }
145
146   if (offset == 0x0010)
230   else
147231   {
148      logerror("RBV: Read monitor type (PC=%x)\n", cpu_get_pc(space->cpu));
232      offset >>= 9;
149233
150      data = (6<<3) | 3;   // 13" RGB, 8 bits per pixel
234      switch (offset)
235      {
236         case 13:   // IFR
237            return rbv_ifr;
238            break;
151239
152      return (data & 0xff) | (data << 8);
240         case 14:   // IER
241            return rbv_ier;
242            break;
243
244         default:
245            logerror("rbv_r: Unknown extended RBV VIA register %d access\n", offset);
246            break;
247      }
153248   }
154249
155   offset >>= 8;
156   offset &= 0x0f;
250//   if (offset != 2) printf("rbv_r: %x = %02x (PC=%x)\n", offset, data, cpu_get_pc(space->cpu));
157251
158   data = via_1->read(*space, offset);
159
160   return (data & 0xff) | (data << 8);
252   return data;
161253}
162254
163static WRITE16_HANDLER ( mac_rbv_w )
255static WRITE8_HANDLER ( mac_rbv_w )
164256{
165   via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1");
257   if (offset < 0x100)
258   {
259//      if ((offset != 3) && (offset != 0x12)) printf("rbv_w: %02x to offset %x (PC=%x)\n", data, offset, cpu_get_pc(space->cpu));
260      switch (offset)
261      {
262         case 0x03:
263            mac_set_via2_interrupt(space->machine, 0);
264            rbv_regs[offset] = data;
265            break;
166266
167   logerror("rbv_w: %x to offset %x, mask %x\n", data, offset, mem_mask);
267         case 0x10:
268            rbv_immed10wr = 1;
269            rbv_regs[offset] = data;
270            break;
168271
169   offset >>= 8;
170   offset &= 0x0f;
272         case 0x12:
273            if (data & 0x80)   // 1 bits write 1s
274            {
275               rbv_regs[offset] |= data & 0x7f;
276            }
277            else         // 1 bits write 0s
278            {
279               rbv_regs[offset] &= ~(data & 0x7f);
280            }
281            break;
171282
172   if (ACCESSING_BITS_8_15)
173      via_1->write(*space, offset, (data >> 8) & 0xff);
283         case 0x13:
284            if (data & 0x80)   // 1 bits write 1s
285            {
286               rbv_regs[offset] |= data & 0x7f;
287
288               if (data == 0xff) rbv_regs[offset] = 0x1f;   // I don't know why this is special, but the IIci ROM's POST demands it
289            }
290            else         // 1 bits write 0s
291            {
292               rbv_regs[offset] &= ~(data & 0x7f);
293            }
294            break;
295
296         default:
297            rbv_regs[offset] = data;
298            break;
299      }
300   }
301   else
302   {
303      offset >>= 9;
304
305      switch (offset)
306      {
307         case 13:   // IFR
308//            printf("rbv_w: %02x to IFR\n", data);
309            rbv_ifr = data;
310            mac_set_via2_interrupt(space->machine, 0);
311            break;
312
313         case 14:   // IER
314            if (data & 0x80)   // 1 bits write 1s
315            {
316               rbv_ier |= data & 0x7f;
317            }
318            else       // 1 bits write 0s
319            {
320               rbv_ier &= ~(data & 0x7f);
321            }
322
323//            printf("rbv_w: %02x to IER => %02x\n", data, rbv_ier);
324            break;
325
326         default:
327            logerror("rbv_w: Unknown extended RBV VIA register %d access\n", offset);
328            break;
329      }
330   }
174331}
175332
176333// LC/LC II "V8" video and friends
r9234r9235
473630   AM_RANGE(0x50010000, 0x50011fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000)
474631   AM_RANGE(0x50012060, 0x50012063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000)
475632   AM_RANGE(0x50014000, 0x50015fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) AM_MIRROR(0x00f00000)
476   AM_RANGE(0x50016000, 0x50017fff) AM_READ(mac_swim_r) AM_WRITENOP AM_MIRROR(0x00f00000)
633   AM_RANGE(0x50016000, 0x50017fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000)
477634   AM_RANGE(0x50024000, 0x50024007) AM_WRITE( rbv_ramdac_w ) AM_MIRROR(0x00f00000)
478635   AM_RANGE(0x50026000, 0x50027fff) AM_READWRITE16(mac_rbv_r, mac_rbv_w, 0xffffffff) AM_MIRROR(0x00f00000)
479636   AM_RANGE(0x50040000, 0x50041fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000)
480
481   // mirror video declaration ROM
482   AM_RANGE(0xfee00000, 0xfee7ffff) AM_RAM AM_BASE(&rbv_vram)
483//  AM_RANGE(0xfeff8000, 0xfeffffff) AM_ROM AM_REGION("bootrom", 0x78000)
484637ADDRESS_MAP_END
485638
486639static ADDRESS_MAP_START(macse30_map, ADDRESS_SPACE_PROGRAM, 32)
r9234r9235
8801033
8811034static MACHINE_CONFIG_DERIVED( maciici, macii )
8821035
883   MDRV_CPU_REPLACE("maincpu", M68030, 7833600*2)
1036   MDRV_CPU_REPLACE("maincpu", M68030, 25000000)
8841037   MDRV_CPU_PROGRAM_MAP(maciici_map)
8851038
8861039   MDRV_PALETTE_LENGTH(256)
8871040
888   MDRV_VIDEO_START(maclc)
1041   MDRV_VIDEO_START(macrbv)
8891042   MDRV_VIDEO_UPDATE(macrbv)
8901043
1044   MDRV_SCREEN_MODIFY("screen")
1045   MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
1046
8911047   /* internal ram */
8921048   MDRV_RAM_MODIFY("messram")
8931049   MDRV_RAM_DEFAULT_SIZE("2M")
r9234r9235
13661522COMP( 1989, maciici,  0,   0,   maciici,  macadb,   maciici,         "Apple Computer", "Macintosh IIci",  GAME_NOT_WORKING )
13671523COMP( 1990, macclasc, 0,   0,   macse,    macadb,   macclassic,         "Apple Computer", "Macintosh Classic",  GAME_NOT_WORKING )
13681524COMP( 1990, maclc,    0,   0,   maclc,    macadb,   maclc,             "Apple Computer", "Macintosh LC",  GAME_NOT_WORKING )
1369COMP( 1990, maciisi,  0,   0,   maciisi,  macadb,   maciici,         "Apple Computer", "Macintosh IIsi",  GAME_NOT_WORKING )
1525COMP( 1990, maciisi,  0,   0,   maciisi,  macadb,   maciisi,         "Apple Computer", "Macintosh IIsi",  0 )
13701526COMP( 1991, macpb100, 0,        0,      macprtb,  macadb,   macprtb,  "Apple Computer", "Macintosh PowerBook 100", GAME_NOT_WORKING )
13711527COMP( 1991, macclas2, 0,   0,   macclas2, macadb,   macclassic2,      "Apple Computer", "Macintosh Classic II",  GAME_NOT_WORKING )
13721528COMP( 1991, maclc2,   0,   0,   maclc2,   macadb,   maclc2,             "Apple Computer", "Macintosh LC II",  GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team