src/emu/cpu/m68000/m68kmmu.h
| r9234 | r9235 | |
| 1 | 1 | /* |
| 2 | 2 | m68kmmu.h - PMMU implementation for 68851/68030/68040 |
| 3 | HMMU implementation for 68020 (II and LC variants) |
| 3 | 4 | |
| 4 | 5 | By R. Belmont |
| 5 | 6 | |
| r9234 | r9235 | |
| 7 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 8 | 9 | */ |
| 9 | 10 | |
| 11 | /* decodes the effective address */ |
| 12 | static 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 | |
| 10 | 68 | /* |
| 69 | pmmu_atc_add: adds this address to the ATC |
| 70 | */ |
| 71 | void 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 | */ |
| 121 | void 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 | /* |
| 11 | 134 | pmmu_translate_addr: perform 68851/68030-style PMMU address translation |
| 12 | 135 | */ |
| 13 | 136 | INLINE UINT32 pmmu_translate_addr(m68ki_cpu_core *m68k, UINT32 addr_in) |
| r9234 | r9235 | |
| 15 | 138 | UINT32 addr_out, tbl_entry = 0, tbl_entry2, tamode = 0, tbmode = 0, tcmode = 0; |
| 16 | 139 | UINT32 root_aptr, root_limit, tofs, is, abits, bbits, cbits; |
| 17 | 140 | UINT32 resolved, tptr, shift; |
| 141 | int curfc, i; |
| 142 | // int verbose = 0; |
| 18 | 143 | |
| 19 | 144 | resolved = 0; |
| 20 | 145 | addr_out = addr_in; |
| 21 | 146 | |
| 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 | |
| 22 | 164 | // if SRP is enabled and we're in supervisor mode, use it |
| 23 | 165 | if ((m68k->mmu_tc & 0x02000000) && (m68ki_get_sr(m68k) & 0x2000)) |
| 24 | 166 | { |
| r9234 | r9235 | |
| 37 | 179 | bbits = (m68k->mmu_tc>>8)&0xf; |
| 38 | 180 | cbits = (m68k->mmu_tc>>4)&0xf; |
| 39 | 181 | |
| 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); |
| 41 | 183 | |
| 42 | 184 | // get table A offset |
| 43 | 185 | tofs = (addr_in<<is)>>(32-abits); |
| r9234 | r9235 | |
| 47 | 189 | { |
| 48 | 190 | case 0: // invalid, should cause MMU exception |
| 49 | 191 | 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; |
| 51 | 195 | break; |
| 52 | 196 | |
| 53 | 197 | case 2: // valid 4 byte descriptors |
| 54 | 198 | 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)); |
| 56 | 200 | tbl_entry = m68k->program->read_dword(tofs + (root_aptr & 0xfffffffc)); |
| 57 | 201 | 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); |
| 59 | 203 | break; |
| 60 | 204 | |
| 61 | 205 | case 3: // valid 8 byte descriptors |
| 62 | 206 | 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)); |
| 64 | 208 | tbl_entry2 = m68k->program->read_dword(tofs + (root_aptr & 0xfffffffc)); |
| 65 | 209 | tbl_entry = m68k->program->read_dword(tofs + (root_aptr & 0xfffffffc)+4); |
| 66 | 210 | 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); |
| 68 | 212 | break; |
| 69 | 213 | } |
| 70 | 214 | |
| r9234 | r9235 | |
| 76 | 220 | switch (tamode) |
| 77 | 221 | { |
| 78 | 222 | 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); |
| 80 | 224 | break; |
| 81 | 225 | |
| 82 | 226 | case 2: // 4-byte table B descriptor |
| 83 | 227 | 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); |
| 85 | 229 | tbl_entry = m68k->program->read_dword(tofs + tptr); |
| 86 | 230 | 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); |
| 88 | 232 | break; |
| 89 | 233 | |
| 90 | 234 | case 3: // 8-byte table B descriptor |
| 91 | 235 | 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); |
| 93 | 237 | tbl_entry2 = m68k->program->read_dword(tofs + tptr); |
| 94 | 238 | tbl_entry = m68k->program->read_dword(tofs + tptr + 4); |
| 95 | 239 | 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); |
| 97 | 241 | break; |
| 98 | 242 | |
| 99 | 243 | case 1: // early termination descriptor |
| r9234 | r9235 | |
| 120 | 264 | |
| 121 | 265 | case 2: // 4-byte table C descriptor |
| 122 | 266 | 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); |
| 124 | 268 | tbl_entry = m68k->program->read_dword(tofs + tptr); |
| 125 | 269 | 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); |
| 127 | 271 | break; |
| 128 | 272 | |
| 129 | 273 | case 3: // 8-byte table C descriptor |
| 130 | 274 | 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); |
| 132 | 276 | tbl_entry2 = m68k->program->read_dword(tofs + tptr); |
| 133 | 277 | tbl_entry = m68k->program->read_dword(tofs + tptr + 4); |
| 134 | 278 | 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); |
| 136 | 280 | break; |
| 137 | 281 | |
| 138 | 282 | case 1: // termination descriptor |
| r9234 | r9235 | |
| 150 | 294 | switch (tcmode) |
| 151 | 295 | { |
| 152 | 296 | 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); |
| 156 | 300 | break; |
| 157 | 301 | |
| 158 | 302 | case 1: // termination descriptor |
| r9234 | r9235 | |
| 165 | 309 | } |
| 166 | 310 | } |
| 167 | 311 | |
| 312 | pmmu_atc_add(m68k, addr_in, addr_out); |
| 168 | 313 | |
| 169 | | // logerror("PMMU: [%08x] => [%08x]\n", addr_in, addr_out); |
| 314 | //logerror("PMMU: [%08x] => [%08x]\n", addr_in, addr_out); |
| 170 | 315 | |
| 171 | 316 | return addr_out; |
| 172 | 317 | } |
| r9234 | r9235 | |
| 202 | 347 | |
| 203 | 348 | if ((modes & 0xfde0) == 0x2000) // PLOAD |
| 204 | 349 | { |
| 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); |
| 206 | 362 | return; |
| 207 | 363 | } |
| 208 | 364 | else if ((modes & 0xe200) == 0x2000) // PFLUSH |
| 209 | 365 | { |
| 210 | | logerror("680x0: unhandled PFLUSH PC=%x\n", m68k->pc); |
| 366 | pmmu_atc_flush(m68k); |
| 211 | 367 | return; |
| 212 | 368 | } |
| 213 | 369 | else if (modes == 0xa000) // PFLUSHR |
| 214 | 370 | { |
| 215 | | logerror("680x0: unhandled PFLUSHR\n"); |
| 371 | pmmu_atc_flush(m68k); |
| 216 | 372 | return; |
| 217 | 373 | } |
| 218 | 374 | else if (modes == 0x2800) // PVALID (FORMAT 1) |
| r9234 | r9235 | |
| 257 | 413 | break; |
| 258 | 414 | } |
| 259 | 415 | } |
| 260 | | else |
| 416 | else // top 3 bits of modes: 010 for this, 011 for status, 000 for transparent translation regs |
| 261 | 417 | { |
| 262 | | switch ((modes>>10) & 7) |
| 418 | switch ((modes>>13) & 7) |
| 263 | 419 | { |
| 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); |
| 266 | 423 | |
| 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 | } |
| 270 | 432 | } |
| 271 | | else |
| 272 | | { |
| 273 | | m68k->pmmu_enabled = 0; |
| 274 | | } |
| 275 | 433 | break; |
| 276 | 434 | |
| 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); |
| 281 | 437 | break; |
| 282 | 438 | |
| 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 | } |
| 287 | 489 | break; |
| 288 | 490 | |
| 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 | } |
| 291 | 496 | break; |
| 292 | 497 | } |
| 293 | 498 | } |
| r9234 | r9235 | |
| 307 | 512 | default: |
| 308 | 513 | logerror("680x0: unknown PMOVE mode %x (modes %04x) (PC %x)\n", (modes>>13) & 0x7, modes, m68k->pc); |
| 309 | 514 | break; |
| 515 | |
| 310 | 516 | } |
| 311 | 517 | } |
| 312 | 518 | break; |
| r9234 | r9235 | |
| 318 | 524 | } |
| 319 | 525 | } |
| 320 | 526 | |
| 527 | |
| 528 | /* Apple HMMU translation is much simpler */ |
| 529 | INLINE 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
| r9234 | r9235 | |
| 571 | 571 | return TRUE; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | /* translate logical to physical addresses for Apple HMMU */ |
| 575 | static 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 | |
| 574 | 590 | /* Execute some instructions until we use up cycles clock cycles */ |
| 575 | 591 | static CPU_EXECUTE( m68k ) |
| 576 | 592 | { |
| r9234 | r9235 | |
| 633 | 649 | m68k->program = device->space(AS_PROGRAM); |
| 634 | 650 | m68k->int_ack_callback = irqcallback; |
| 635 | 651 | |
| 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 | |
| 636 | 658 | /* The first call to this function initializes the opcode handler jump table */ |
| 637 | 659 | if(!emulation_initialized) |
| 638 | 660 | { |
| r9234 | r9235 | |
| 667 | 689 | { |
| 668 | 690 | m68ki_cpu_core *m68k = get_safe_token(device); |
| 669 | 691 | |
| 670 | | /* Disable the PMMU on reset */ |
| 692 | /* Disable the PMMU/HMMU on reset, if any */ |
| 671 | 693 | m68k->pmmu_enabled = 0; |
| 694 | m68k->hmmu_enabled = 0; |
| 672 | 695 | |
| 673 | 696 | /* Clear all stop levels and eat up all remaining cycles */ |
| 674 | 697 | m68k->stopped = 0; |
| r9234 | r9235 | |
| 702 | 725 | m68k->run_mode = RUN_MODE_NORMAL; |
| 703 | 726 | |
| 704 | 727 | m68k->reset_cycles = m68k->cyc_exception[EXCEPTION_RESET]; |
| 728 | |
| 729 | /* flush the MMU's cache */ |
| 730 | pmmu_atc_flush(m68k); |
| 705 | 731 | } |
| 706 | 732 | |
| 707 | 733 | static CPU_DISASSEMBLE( m68k ) |
| r9234 | r9235 | |
| 940 | 966 | m68k->encrypted_end = end; |
| 941 | 967 | } |
| 942 | 968 | |
| 969 | void 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 | |
| 943 | 976 | /**************************************************************************** |
| 944 | 977 | * 8-bit data memory interface |
| 945 | 978 | ****************************************************************************/ |
| r9234 | r9235 | |
| 1143 | 1176 | } |
| 1144 | 1177 | |
| 1145 | 1178 | |
| 1179 | /* interface for 32-bit data bus with PMMU (68EC020, 68020) */ |
| 1180 | UINT8 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 | |
| 1190 | void 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 | |
| 1200 | UINT16 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) */ |
| 1211 | UINT16 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) */ |
| 1227 | void 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) */ |
| 1244 | UINT32 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) */ |
| 1266 | void 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 | |
| 1289 | void 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 | |
| 1146 | 1305 | void m68k_set_reset_callback(running_device *device, m68k_reset_func callback) |
| 1147 | 1306 | { |
| 1148 | 1307 | m68ki_cpu_core *m68k = get_safe_token(device); |
| r9234 | r9235 | |
| 1253 | 1412 | m68k->cyc_shift = 1; |
| 1254 | 1413 | m68k->cyc_reset = 132; |
| 1255 | 1414 | m68k->has_pmmu = 0; |
| 1415 | m68k->has_hmmu = 0; |
| 1256 | 1416 | |
| 1257 | 1417 | define_state(device); |
| 1258 | 1418 | } |
| r9234 | r9235 | |
| 1403 | 1563 | m68k->cyc_movem_l = 2; |
| 1404 | 1564 | m68k->cyc_shift = 0; |
| 1405 | 1565 | m68k->cyc_reset = 518; |
| 1406 | | m68k->has_pmmu = 0; |
| 1407 | 1566 | |
| 1408 | 1567 | define_state(device); |
| 1409 | 1568 | } |
| r9234 | r9235 | |
| 1459 | 1618 | } |
| 1460 | 1619 | } |
| 1461 | 1620 | |
| 1621 | // 68020 with Apple HMMU |
| 1622 | static 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 | |
| 1636 | CPU_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 | |
| 1462 | 1651 | /**************************************************************************** |
| 1463 | 1652 | * M680EC20 section |
| 1464 | 1653 | ****************************************************************************/ |
| r9234 | r9235 | |
| 1803 | 1992 | DEFINE_LEGACY_CPU_DEVICE(M68EC020, m68ec020); |
| 1804 | 1993 | DEFINE_LEGACY_CPU_DEVICE(M68020, m68020); |
| 1805 | 1994 | DEFINE_LEGACY_CPU_DEVICE(M68020PMMU, m68020pmmu); |
| 1995 | DEFINE_LEGACY_CPU_DEVICE(M68020HMMU, m68020hmmu); |
| 1806 | 1996 | DEFINE_LEGACY_CPU_DEVICE(M68EC030, m68ec030); |
| 1807 | 1997 | DEFINE_LEGACY_CPU_DEVICE(M68030, m68030); |
| 1808 | 1998 | DEFINE_LEGACY_CPU_DEVICE(M68EC040, m68ec040); |
src/mess/machine/mac.c
| r9234 | r9235 | |
| 78 | 78 | #include "devices/messram.h" |
| 79 | 79 | #include "debugger.h" |
| 80 | 80 | |
| 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)) |
| 82 | 82 | #define ADB_IS_EGRET (mac->mac_model >= MODEL_MAC_LC && mac->mac_model <= MODEL_MAC_COLOR_CLASSIC) || (mac->mac_model == MODEL_MAC_IISI) |
| 83 | 83 | #define ADB_IS_PM (mac->mac_model >= MODEL_MAC_PORTABLE && mac->mac_model <= MODEL_MAC_PB100) |
| 84 | 84 | |
| r9234 | r9235 | |
| 113 | 113 | |
| 114 | 114 | static TIMER_CALLBACK(mac_scanline_tick); |
| 115 | 115 | static TIMER_CALLBACK(mac_adb_tick); |
| 116 | static TIMER_CALLBACK(mac_6015_tick); |
| 116 | 117 | static emu_timer *mac_scanline_timer, *mac_adb_timer; |
| 117 | 118 | static int scan_keyboard(running_machine *machine); |
| 118 | 119 | static TIMER_CALLBACK(inquiry_timeout_func); |
| r9234 | r9235 | |
| 292 | 293 | } |
| 293 | 294 | |
| 294 | 295 | |
| 295 | | static void set_via2_interrupt(running_machine *machine, int value) |
| 296 | void mac_set_via2_interrupt(running_machine *machine, int value) |
| 296 | 297 | { |
| 297 | 298 | via2_interrupt = value; |
| 298 | 299 | |
| r9234 | r9235 | |
| 2683 | 2684 | |
| 2684 | 2685 | static void mac_via2_irq(running_device *device, int state) |
| 2685 | 2686 | { |
| 2686 | | set_via2_interrupt(device->machine, state); |
| 2687 | mac_set_via2_interrupt(device->machine, state); |
| 2687 | 2688 | } |
| 2688 | 2689 | |
| 2689 | 2690 | READ16_HANDLER ( mac_via2_r ) |
| r9234 | r9235 | |
| 2696 | 2697 | |
| 2697 | 2698 | data = via_1->read(*space, offset); |
| 2698 | 2699 | |
| 2699 | | if (LOG_VIA) |
| 2700 | // if (LOG_VIA) |
| 2700 | 2701 | logerror("mac_via2_r: offset=0x%02x = %02x (PC=%x)\n", offset*2, data, cpu_get_pc(space->machine->device("maincpu"))); |
| 2701 | 2702 | |
| 2702 | 2703 | return (data & 0xff) | (data << 8); |
| r9234 | r9235 | |
| 2709 | 2710 | offset >>= 8; |
| 2710 | 2711 | offset &= 0x0f; |
| 2711 | 2712 | |
| 2712 | | if (LOG_VIA) |
| 2713 | // if (LOG_VIA) |
| 2713 | 2714 | logerror("mac_via2_w: offset=%x data=0x%08x (PC=%x)\n", offset, data, cpu_get_pc(space->machine->device("maincpu"))); |
| 2714 | 2715 | |
| 2715 | 2716 | if (ACCESSING_BITS_8_15) |
| r9234 | r9235 | |
| 2724 | 2725 | |
| 2725 | 2726 | result |= mac->mac_nubus_irq_state; |
| 2726 | 2727 | |
| 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 | | |
| 2732 | 2728 | return result; |
| 2733 | 2729 | } |
| 2734 | 2730 | |
| r9234 | r9235 | |
| 2762 | 2758 | |
| 2763 | 2759 | // logerror("VIA2 OUT B: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu"))); |
| 2764 | 2760 | |
| 2765 | | // printf("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08); |
| 2761 | logerror("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08); |
| 2766 | 2762 | |
| 2767 | 2763 | // chain 60.15 Hz to VIA1 |
| 2768 | 2764 | via_0->write_ca1(data>>7); |
| 2769 | 2765 | } |
| 2770 | 2766 | |
| 2767 | // This signal is generated internally on RBV, V8, Sonora, VASP, Eagle, etc. |
| 2768 | static 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 | |
| 2771 | 2776 | /* ************************************************************************* |
| 2772 | 2777 | * Main |
| 2773 | 2778 | * *************************************************************************/ |
| r9234 | r9235 | |
| 2782 | 2787 | } |
| 2783 | 2788 | mac_scanline_timer = timer_alloc(machine, mac_scanline_tick, NULL); |
| 2784 | 2789 | 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); |
| 2785 | 2793 | } |
| 2786 | 2794 | MACHINE_RESET(mac) |
| 2787 | 2795 | { |
| r9234 | r9235 | |
| 2789 | 2797 | mac_model_t model_save; |
| 2790 | 2798 | emu_timer *timer_save; |
| 2791 | 2799 | |
| 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 | |
| 2792 | 2809 | // clear mac state struct |
| 2793 | 2810 | model_save = mac->mac_model; |
| 2794 | 2811 | timer_save = mac->inquiry_timeout; |
| r9234 | r9235 | |
| 2826 | 2843 | |
| 2827 | 2844 | if (mac->mac_model >= MODEL_MAC_PLUS) |
| 2828 | 2845 | { |
| 2829 | | ncr5380_scan_devices(machine->device("ncr5380")); |
| 2846 | // ncr5380_scan_devices(machine->device("ncr5380")); |
| 2830 | 2847 | } |
| 2831 | 2848 | |
| 2832 | 2849 | if ((mac->mac_model == MODEL_MAC_SE) || (mac->mac_model == MODEL_MAC_CLASSIC)) |
| r9234 | r9235 | |
| 3025 | 3042 | |
| 3026 | 3043 | DRIVER_INIT(maciici) |
| 3027 | 3044 | { |
| 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 | | |
| 3034 | 3045 | mac_driver_init(machine, MODEL_MAC_IICI); |
| 3035 | 3046 | } |
| 3036 | 3047 | |
src/mess/drivers/mac.c
| r9234 | r9235 | |
| 71 | 71 | |
| 72 | 72 | // IIci/IIsi RAM-Based Video (RBV) |
| 73 | 73 | |
| 74 | | // 512x384x1 framebuffer at fb008000? |
| 75 | | // 640x480x1 framebuffer at fee00000? |
| 74 | static UINT8 rbv_regs[256], rbv_ier, rbv_ifr; |
| 75 | static UINT32 rbv_colors[3], rbv_count, rbv_clutoffs, rbv_immed10wr; |
| 76 | static UINT32 rbv_palette[256]; |
| 76 | 77 | |
| 77 | | static UINT32 *rbv_vram; |
| 78 | static VIDEO_START( macrbv ) |
| 79 | { |
| 80 | memset(rbv_regs, 0, sizeof(rbv_regs)); |
| 78 | 81 | |
| 79 | | static UINT32 rbv_colors[3], rbv_count, rbv_clutoffs; |
| 80 | | static UINT32 rbv_palette[256]; |
| 82 | rbv_count = 0; |
| 83 | rbv_clutoffs = 0; |
| 84 | rbv_immed10wr = 0; |
| 81 | 85 | |
| 86 | rbv_regs[2] = 0xff; |
| 87 | } |
| 88 | |
| 82 | 89 | static VIDEO_UPDATE( macrbv ) |
| 83 | 90 | { |
| 84 | 91 | UINT32 *scanline; |
| 85 | 92 | int x, y; |
| 86 | | UINT8 *vram8 = (UINT8 *)rbv_vram; |
| 87 | | UINT8 pixels; |
| 88 | 93 | |
| 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)) |
| 90 | 97 | { |
| 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 |
| 93 | 105 | { |
| 94 | | pixels = vram8[(y * 1024) + ((x/8)^3)]; |
| 106 | UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram")); |
| 107 | UINT8 pixels; |
| 95 | 108 | |
| 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 | } |
| 104 | 126 | } |
| 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; |
| 105 | 169 | } |
| 106 | 170 | |
| 107 | 171 | return 0; |
| r9234 | r9235 | |
| 120 | 184 | |
| 121 | 185 | if (rbv_count == 3) |
| 122 | 186 | { |
| 123 | | rbv_count = 0; |
| 124 | 187 | palette_set_color(space->machine, rbv_clutoffs, MAKE_RGB(rbv_colors[0], rbv_colors[1], rbv_colors[2])); |
| 125 | 188 | rbv_palette[rbv_clutoffs] = MAKE_RGB(rbv_colors[0], rbv_colors[1], rbv_colors[2]); |
| 126 | 189 | rbv_clutoffs++; |
| 190 | rbv_count = 0; |
| 127 | 191 | } |
| 128 | 192 | } |
| 129 | 193 | } |
| 130 | 194 | |
| 131 | | |
| 132 | | static UINT32 rbv_toggle = 0; |
| 133 | | static READ16_HANDLER ( mac_rbv_r ) |
| 195 | static READ8_HANDLER ( mac_rbv_r ) |
| 134 | 196 | { |
| 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]; |
| 137 | 202 | |
| 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 | } |
| 139 | 210 | |
| 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 | } |
| 144 | 229 | } |
| 145 | | |
| 146 | | if (offset == 0x0010) |
| 230 | else |
| 147 | 231 | { |
| 148 | | logerror("RBV: Read monitor type (PC=%x)\n", cpu_get_pc(space->cpu)); |
| 232 | offset >>= 9; |
| 149 | 233 | |
| 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; |
| 151 | 239 | |
| 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 | } |
| 153 | 248 | } |
| 154 | 249 | |
| 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)); |
| 157 | 251 | |
| 158 | | data = via_1->read(*space, offset); |
| 159 | | |
| 160 | | return (data & 0xff) | (data << 8); |
| 252 | return data; |
| 161 | 253 | } |
| 162 | 254 | |
| 163 | | static WRITE16_HANDLER ( mac_rbv_w ) |
| 255 | static WRITE8_HANDLER ( mac_rbv_w ) |
| 164 | 256 | { |
| 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; |
| 166 | 266 | |
| 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; |
| 168 | 271 | |
| 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; |
| 171 | 282 | |
| 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 | } |
| 174 | 331 | } |
| 175 | 332 | |
| 176 | 333 | // LC/LC II "V8" video and friends |
| r9234 | r9235 | |
| 473 | 630 | AM_RANGE(0x50010000, 0x50011fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 474 | 631 | AM_RANGE(0x50012060, 0x50012063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 475 | 632 | 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) |
| 477 | 634 | AM_RANGE(0x50024000, 0x50024007) AM_WRITE( rbv_ramdac_w ) AM_MIRROR(0x00f00000) |
| 478 | 635 | AM_RANGE(0x50026000, 0x50027fff) AM_READWRITE16(mac_rbv_r, mac_rbv_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 479 | 636 | 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) |
| 484 | 637 | ADDRESS_MAP_END |
| 485 | 638 | |
| 486 | 639 | static ADDRESS_MAP_START(macse30_map, ADDRESS_SPACE_PROGRAM, 32) |
| r9234 | r9235 | |
| 880 | 1033 | |
| 881 | 1034 | static MACHINE_CONFIG_DERIVED( maciici, macii ) |
| 882 | 1035 | |
| 883 | | MDRV_CPU_REPLACE("maincpu", M68030, 7833600*2) |
| 1036 | MDRV_CPU_REPLACE("maincpu", M68030, 25000000) |
| 884 | 1037 | MDRV_CPU_PROGRAM_MAP(maciici_map) |
| 885 | 1038 | |
| 886 | 1039 | MDRV_PALETTE_LENGTH(256) |
| 887 | 1040 | |
| 888 | | MDRV_VIDEO_START(maclc) |
| 1041 | MDRV_VIDEO_START(macrbv) |
| 889 | 1042 | MDRV_VIDEO_UPDATE(macrbv) |
| 890 | 1043 | |
| 1044 | MDRV_SCREEN_MODIFY("screen") |
| 1045 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 1046 | |
| 891 | 1047 | /* internal ram */ |
| 892 | 1048 | MDRV_RAM_MODIFY("messram") |
| 893 | 1049 | MDRV_RAM_DEFAULT_SIZE("2M") |
| r9234 | r9235 | |
| 1366 | 1522 | COMP( 1989, maciici, 0, 0, maciici, macadb, maciici, "Apple Computer", "Macintosh IIci", GAME_NOT_WORKING ) |
| 1367 | 1523 | COMP( 1990, macclasc, 0, 0, macse, macadb, macclassic, "Apple Computer", "Macintosh Classic", GAME_NOT_WORKING ) |
| 1368 | 1524 | COMP( 1990, maclc, 0, 0, maclc, macadb, maclc, "Apple Computer", "Macintosh LC", GAME_NOT_WORKING ) |
| 1369 | | COMP( 1990, maciisi, 0, 0, maciisi, macadb, maciici, "Apple Computer", "Macintosh IIsi", GAME_NOT_WORKING ) |
| 1525 | COMP( 1990, maciisi, 0, 0, maciisi, macadb, maciisi, "Apple Computer", "Macintosh IIsi", 0 ) |
| 1370 | 1526 | COMP( 1991, macpb100, 0, 0, macprtb, macadb, macprtb, "Apple Computer", "Macintosh PowerBook 100", GAME_NOT_WORKING ) |
| 1371 | 1527 | COMP( 1991, macclas2, 0, 0, macclas2, macadb, macclassic2, "Apple Computer", "Macintosh Classic II", GAME_NOT_WORKING ) |
| 1372 | 1528 | COMP( 1991, maclc2, 0, 0, maclc2, macadb, maclc2, "Apple Computer", "Macintosh LC II", GAME_NOT_WORKING ) |