trunk/src/mess/includes/c128.h
| r31284 | r31285 | |
| 40 | 40 | class c128_state : public driver_device |
| 41 | 41 | { |
| 42 | 42 | public: |
| 43 | | c128_state(const machine_config &mconfig, device_type type, const char *tag) |
| 44 | | : driver_device(mconfig, type, tag), |
| 45 | | m_maincpu(*this, Z80A_TAG), |
| 46 | | m_subcpu(*this, M8502_TAG), |
| 47 | | m_mmu(*this, MOS8722_TAG), |
| 48 | | m_pla(*this, MOS8721_TAG), |
| 49 | | m_vdc(*this, MOS8563_TAG), |
| 50 | | m_vic(*this, MOS8564_TAG), |
| 51 | | m_sid(*this, MOS6581_TAG), |
| 52 | | m_cia1(*this, MOS6526_1_TAG), |
| 53 | | m_cia2(*this, MOS6526_2_TAG), |
| 54 | | m_iec(*this, CBM_IEC_TAG), |
| 55 | | m_joy1(*this, CONTROL1_TAG), |
| 56 | | m_joy2(*this, CONTROL2_TAG), |
| 57 | | m_exp(*this, C64_EXPANSION_SLOT_TAG), |
| 58 | | m_user(*this, PET_USER_PORT_TAG), |
| 59 | | m_ram(*this, RAM_TAG), |
| 60 | | m_cassette(*this, PET_DATASSETTE_PORT_TAG), |
| 61 | | m_rom(*this, M8502_TAG), |
| 62 | | m_from(*this, "from"), |
| 63 | | m_charom(*this, "charom"), |
| 64 | | m_color_ram(*this, "color_ram"), |
| 65 | | m_row0(*this, "ROW0"), |
| 66 | | m_row1(*this, "ROW1"), |
| 67 | | m_row2(*this, "ROW2"), |
| 68 | | m_row3(*this, "ROW3"), |
| 69 | | m_row4(*this, "ROW4"), |
| 70 | | m_row5(*this, "ROW5"), |
| 71 | | m_row6(*this, "ROW6"), |
| 72 | | m_row7(*this, "ROW7"), |
| 73 | | m_k0(*this, "K0"), |
| 74 | | m_k1(*this, "K1"), |
| 75 | | m_k2(*this, "K2"), |
| 76 | | m_lock(*this, "LOCK"), |
| 77 | | m_caps(*this, "CAPS"), |
| 78 | | m_40_80(*this, "40_80"), |
| 79 | | m_z80en(0), |
| 80 | | m_loram(1), |
| 81 | | m_hiram(1), |
| 82 | | m_charen(1), |
| 83 | | m_game(1), |
| 84 | | m_exrom(1), |
| 85 | | m_va14(1), |
| 86 | | m_va15(1), |
| 87 | | m_clrbank(0), |
| 88 | | m_cnt1(1), |
| 89 | | m_sp1(1), |
| 90 | | m_iec_data_out(1), |
| 91 | | m_restore(1), |
| 92 | | m_cia1_irq(CLEAR_LINE), |
| 93 | | m_cia2_irq(CLEAR_LINE), |
| 94 | | m_vic_irq(CLEAR_LINE), |
| 95 | | m_exp_irq(CLEAR_LINE), |
| 96 | | m_exp_nmi(CLEAR_LINE), |
| 97 | | m_cass_rd(1), |
| 98 | | m_iec_srq(1), |
| 99 | | m_vic_k(0x07), |
| 100 | | m_caps_lock(1) |
| 43 | c128_state(const machine_config &mconfig, device_type type, const char *tag) : |
| 44 | driver_device(mconfig, type, tag), |
| 45 | m_maincpu(*this, Z80A_TAG), |
| 46 | m_subcpu(*this, M8502_TAG), |
| 47 | m_mmu(*this, MOS8722_TAG), |
| 48 | m_pla(*this, MOS8721_TAG), |
| 49 | m_vdc(*this, MOS8563_TAG), |
| 50 | m_vic(*this, MOS8564_TAG), |
| 51 | m_sid(*this, MOS6581_TAG), |
| 52 | m_cia1(*this, MOS6526_1_TAG), |
| 53 | m_cia2(*this, MOS6526_2_TAG), |
| 54 | m_iec(*this, CBM_IEC_TAG), |
| 55 | m_joy1(*this, CONTROL1_TAG), |
| 56 | m_joy2(*this, CONTROL2_TAG), |
| 57 | m_exp(*this, C64_EXPANSION_SLOT_TAG), |
| 58 | m_user(*this, PET_USER_PORT_TAG), |
| 59 | m_ram(*this, RAM_TAG), |
| 60 | m_cassette(*this, PET_DATASSETTE_PORT_TAG), |
| 61 | m_rom(*this, M8502_TAG), |
| 62 | m_from(*this, "from"), |
| 63 | m_charom(*this, "charom"), |
| 64 | m_color_ram(*this, "color_ram"), |
| 65 | m_row0(*this, "ROW0"), |
| 66 | m_row1(*this, "ROW1"), |
| 67 | m_row2(*this, "ROW2"), |
| 68 | m_row3(*this, "ROW3"), |
| 69 | m_row4(*this, "ROW4"), |
| 70 | m_row5(*this, "ROW5"), |
| 71 | m_row6(*this, "ROW6"), |
| 72 | m_row7(*this, "ROW7"), |
| 73 | m_k0(*this, "K0"), |
| 74 | m_k1(*this, "K1"), |
| 75 | m_k2(*this, "K2"), |
| 76 | m_lock(*this, "LOCK"), |
| 77 | m_caps(*this, "CAPS"), |
| 78 | m_40_80(*this, "40_80"), |
| 79 | m_z80en(0), |
| 80 | m_loram(1), |
| 81 | m_hiram(1), |
| 82 | m_charen(1), |
| 83 | m_game(1), |
| 84 | m_exrom(1), |
| 85 | m_va14(1), |
| 86 | m_va15(1), |
| 87 | m_clrbank(0), |
| 88 | m_cnt1(1), |
| 89 | m_sp1(1), |
| 90 | m_iec_data_out(1), |
| 91 | m_restore(1), |
| 92 | m_cia1_irq(CLEAR_LINE), |
| 93 | m_cia2_irq(CLEAR_LINE), |
| 94 | m_vic_irq(CLEAR_LINE), |
| 95 | m_exp_irq(CLEAR_LINE), |
| 96 | m_exp_nmi(CLEAR_LINE), |
| 97 | m_cass_rd(1), |
| 98 | m_iec_srq(1), |
| 99 | m_vic_k(0x07), |
| 100 | m_caps_lock(1) |
| 101 | 101 | { } |
| 102 | 102 | |
| 103 | 103 | required_device<cpu_device> m_maincpu; |
| r31284 | r31285 | |
| 139 | 139 | virtual void machine_reset(); |
| 140 | 140 | |
| 141 | 141 | inline void check_interrupts(); |
| 142 | | void read_pla(offs_t offset, offs_t ca, offs_t vma, int ba, int rw, int aec, int z80io, int ms3, int ms2, int ms1, int ms0, |
| 143 | | int *sden, int *dir, int *gwe, int *rom1, int *rom2, int *rom3, int *rom4, int *charom, int *colorram, int *vic, |
| 144 | | int *from1, int *romh, int *roml, int *dwe, int *ioacc, int *clrbank, int *iocs, int *casenb); |
| 142 | int read_pla(offs_t offset, offs_t ca, offs_t vma, int ba, int rw, int aec, int z80io, int ms3, int ms2, int ms1, int ms0); |
| 145 | 143 | UINT8 read_memory(address_space &space, offs_t offset, offs_t vma, int ba, int aec, int z80io); |
| 146 | 144 | void write_memory(address_space &space, offs_t offset, offs_t vma, UINT8 data, int ba, int aec, int z80io); |
| 147 | 145 | inline void update_iec(); |
trunk/src/mess/drivers/c128.c
| r31284 | r31285 | |
| 33 | 33 | #define VMA5 BIT(vma, 13) |
| 34 | 34 | #define VMA4 BIT(vma, 12) |
| 35 | 35 | |
| 36 | enum |
| 37 | { |
| 38 | PLA_OUT_SDEN = 0, |
| 39 | PLA_OUT_ROM4 = 1, |
| 40 | PLA_OUT_ROM2 = 2, |
| 41 | PLA_OUT_DIR = 3, |
| 42 | PLA_OUT_ROML = 4, |
| 43 | PLA_OUT_ROMH = 5, |
| 44 | PLA_OUT_CLRBANK = 6, |
| 45 | PLA_OUT_FROM1 = 7, |
| 46 | PLA_OUT_ROM3 = 8, |
| 47 | PLA_OUT_ROM1 = 9, |
| 48 | PLA_OUT_IOCS = 10, |
| 49 | PLA_OUT_DWE = 11, |
| 50 | PLA_OUT_CASENB = 12, |
| 51 | PLA_OUT_VIC = 13, |
| 52 | PLA_OUT_IOACC = 14, |
| 53 | PLA_OUT_GWE = 15, |
| 54 | PLA_OUT_COLORRAM = 16, |
| 55 | PLA_OUT_CHAROM = 17 |
| 56 | }; |
| 36 | 57 | |
| 37 | 58 | |
| 38 | 59 | QUICKLOAD_LOAD_MEMBER( c128_state, cbm_c64 ) |
| r31284 | r31285 | |
| 40 | 61 | return general_cbm_loadsnap(image, file_type, quickload_size, m_maincpu->space(AS_PROGRAM), 0, cbm_quick_sethiaddress); |
| 41 | 62 | } |
| 42 | 63 | |
| 64 | |
| 43 | 65 | //************************************************************************** |
| 44 | 66 | // INTERRUPTS |
| 45 | 67 | //************************************************************************** |
| r31284 | r31285 | |
| 72 | 94 | // read_pla - |
| 73 | 95 | //------------------------------------------------- |
| 74 | 96 | |
| 75 | | void c128_state::read_pla(offs_t offset, offs_t ca, offs_t vma, int ba, int rw, int aec, int z80io, int ms3, int ms2, int ms1, int ms0, |
| 76 | | int *sden, int *dir, int *gwe, int *rom1, int *rom2, int *rom3, int *rom4, int *charom, int *colorram, int *vic, |
| 77 | | int *from1, int *romh, int *roml, int *dwe, int *ioacc, int *clrbank, int *iocs, int *casenb) |
| 97 | int c128_state::read_pla(offs_t offset, offs_t ca, offs_t vma, int ba, int rw, int aec, int z80io, int ms3, int ms2, int ms1, int ms0) |
| 78 | 98 | { |
| 79 | 99 | int _128_256 = 1; |
| 80 | 100 | int dmaack = 1; |
| r31284 | r31285 | |
| 89 | 109 | m_exrom << 15 | m_game << 14 | rw << 13 | aec << 12 | A10 << 11 | A11 << 10 | A12 << 9 | A13 << 8 | |
| 90 | 110 | A14 << 7 | A15 << 6 | z80io << 5 | m_z80en << 4 | ms3 << 3 | vicfix << 2 | dmaack << 1 | _128_256; |
| 91 | 111 | |
| 92 | | UINT32 data = m_pla->read(input); |
| 93 | | |
| 94 | | *sden = BIT(data, 0); |
| 95 | | *rom4 = BIT(data, 1); |
| 96 | | *rom2 = BIT(data, 2); |
| 97 | | *dir = BIT(data, 3); |
| 98 | | *roml = BIT(data, 4); |
| 99 | | *romh = BIT(data, 5); |
| 100 | | *clrbank = BIT(data, 6); |
| 101 | | *from1 = BIT(data, 7); |
| 102 | | *rom3 = BIT(data, 8); |
| 103 | | *rom1 = BIT(data, 9); |
| 104 | | *iocs = BIT(data, 10); |
| 105 | | *dwe = BIT(data, 11); |
| 106 | | *casenb = BIT(data, 12); |
| 107 | | *vic = BIT(data, 13); |
| 108 | | *ioacc = BIT(data, 14); |
| 109 | | *gwe = BIT(data, 15); |
| 110 | | *colorram = BIT(data, 16); |
| 111 | | *charom = BIT(data, 17); |
| 112 | | |
| 113 | | m_clrbank = *clrbank; |
| 112 | return m_pla->read(input); |
| 114 | 113 | } |
| 115 | 114 | |
| 116 | 115 | |
| r31284 | r31285 | |
| 121 | 120 | UINT8 c128_state::read_memory(address_space &space, offs_t offset, offs_t vma, int ba, int aec, int z80io) |
| 122 | 121 | { |
| 123 | 122 | int rw = 1, ms0 = 1, ms1 = 1, ms2 = 1, ms3 = 1, cas0 = 1, cas1 = 1; |
| 124 | | int sden = 1, dir = 1, gwe = 1, rom1 = 1, rom2 = 1, rom3 = 1, rom4 = 1, charom = 1, colorram = 1, vic = 1, |
| 125 | | from1 = 1, romh = 1, roml = 1, dwe = 1, ioacc = 1, clrbank = 1, iocs = 1, casenb = 1; |
| 126 | 123 | int io1 = 1, io2 = 1; |
| 127 | 124 | int sphi2 = m_vic->phi0_r(); |
| 128 | 125 | |
| r31284 | r31285 | |
| 148 | 145 | |
| 149 | 146 | offs_t ca = ta | sa; |
| 150 | 147 | |
| 151 | | read_pla(offset, ca, vma, ba, rw, aec, z80io, ms3, ms2, ms1, ms0, |
| 152 | | &sden, &dir, &gwe, &rom1, &rom2, &rom3, &rom4, &charom, &colorram, &vic, |
| 153 | | &from1, &romh, &roml, &dwe, &ioacc, &clrbank, &iocs, &casenb); |
| 148 | int plaout = read_pla(offset, ca, vma, ba, rw, aec, z80io, ms3, ms2, ms1, ms0); |
| 154 | 149 | |
| 155 | | if (!casenb) |
| 150 | m_clrbank = BIT(plaout, PLA_OUT_CLRBANK); |
| 151 | |
| 152 | if (!BIT(plaout, PLA_OUT_CASENB)) |
| 156 | 153 | { |
| 157 | 154 | if (!cas0) |
| 158 | 155 | { |
| r31284 | r31285 | |
| 163 | 160 | data = m_ram->pointer()[0x10000 | ma]; |
| 164 | 161 | } |
| 165 | 162 | } |
| 166 | | if (!rom1) |
| 163 | if (!BIT(plaout, PLA_OUT_ROM1)) |
| 167 | 164 | { |
| 168 | 165 | // CR: data = m_rom1[(ms3 << 14) | ((BIT(ta, 14) && BIT(offset, 13)) << 13) | (ta & 0x1000) | (offset & 0xfff)]; |
| 169 | 166 | data = m_rom->base()[((BIT(ta, 14) && BIT(offset, 13)) << 13) | (ta & 0x1000) | (offset & 0xfff)]; |
| 170 | 167 | } |
| 171 | | if (!rom2) |
| 168 | if (!BIT(plaout, PLA_OUT_ROM2)) |
| 172 | 169 | { |
| 173 | 170 | data = m_rom->base()[0x4000 | (offset & 0x3fff)]; |
| 174 | 171 | } |
| 175 | | if (!rom3) |
| 172 | if (!BIT(plaout, PLA_OUT_ROM3)) |
| 176 | 173 | { |
| 177 | 174 | // CR: data = m_rom3[(BIT(offset, 15) << 14) | (offset & 0x3fff)]; |
| 178 | 175 | data = m_rom->base()[0x8000 | (offset & 0x3fff)]; |
| 179 | 176 | } |
| 180 | | if (!rom4) |
| 177 | if (!BIT(plaout, PLA_OUT_ROM4)) |
| 181 | 178 | { |
| 182 | 179 | data = m_rom->base()[0xc000 | (ta & 0x1000) | (offset & 0x2fff)]; |
| 183 | 180 | } |
| 184 | | if (!charom) |
| 181 | if (!BIT(plaout, PLA_OUT_CHAROM)) |
| 185 | 182 | { |
| 186 | 183 | data = m_charom->base()[(ms3 << 12) | (ta & 0xf00) | sa]; |
| 187 | 184 | } |
| 188 | | if (!colorram && aec) |
| 185 | if (!BIT(plaout, PLA_OUT_COLORRAM) && aec) |
| 189 | 186 | { |
| 190 | | data = m_color_ram[(clrbank << 10) | (ta & 0x300) | sa] & 0x0f; |
| 187 | data = m_color_ram[(m_clrbank << 10) | (ta & 0x300) | sa] & 0x0f; |
| 191 | 188 | } |
| 192 | | if (!vic) |
| 189 | if (!BIT(plaout, PLA_OUT_VIC)) |
| 193 | 190 | { |
| 194 | 191 | data = m_vic->read(space, offset & 0x3f); |
| 195 | 192 | } |
| 196 | | if (!from1) |
| 193 | if (!BIT(plaout, PLA_OUT_FROM1)) |
| 197 | 194 | { |
| 198 | 195 | data = m_from->base()[offset & 0x7fff]; |
| 199 | 196 | } |
| 200 | | if (!iocs && BIT(offset, 10)) |
| 197 | if (!BIT(plaout, PLA_OUT_IOCS) && BIT(offset, 10)) |
| 201 | 198 | { |
| 202 | 199 | switch ((BIT(offset, 11) << 2) | ((offset >> 8) & 0x03)) |
| 203 | 200 | { |
| r31284 | r31285 | |
| 234 | 231 | } |
| 235 | 232 | } |
| 236 | 233 | |
| 234 | int roml = BIT(plaout, PLA_OUT_ROML); |
| 235 | int romh = BIT(plaout, PLA_OUT_ROMH); |
| 236 | |
| 237 | 237 | data = m_exp->cd_r(space, ca, data, sphi2, ba, roml, romh, io1, io2); |
| 238 | 238 | |
| 239 | 239 | return m_mmu->read(offset, data); |
| r31284 | r31285 | |
| 247 | 247 | void c128_state::write_memory(address_space &space, offs_t offset, offs_t vma, UINT8 data, int ba, int aec, int z80io) |
| 248 | 248 | { |
| 249 | 249 | int rw = 0, ms0 = 1, ms1 = 1, ms2 = 1, ms3 = 1, cas0 = 1, cas1 = 1; |
| 250 | | int sden = 1, dir = 1, gwe = 1, rom1 = 1, rom2 = 1, rom3 = 1, rom4 = 1, charom = 1, colorram = 1, vic = 1, |
| 251 | | from1 = 1, romh = 1, roml = 1, dwe = 1, ioacc = 1, clrbank = 1, iocs = 1, casenb = 1; |
| 252 | 250 | int io1 = 1, io2 = 1; |
| 253 | 251 | int sphi2 = m_vic->phi0_r(); |
| 254 | 252 | |
| r31284 | r31285 | |
| 257 | 255 | offs_t ma = ta | (offset & 0xff); |
| 258 | 256 | offs_t sa = offset & 0xff; |
| 259 | 257 | |
| 260 | | read_pla(offset, ca, vma, ba, rw, aec, z80io, ms3, ms2, ms1, ms0, |
| 261 | | &sden, &dir, &gwe, &rom1, &rom2, &rom3, &rom4, &charom, &colorram, &vic, |
| 262 | | &from1, &romh, &roml, &dwe, &ioacc, &clrbank, &iocs, &casenb); |
| 258 | int plaout = read_pla(offset, ca, vma, ba, rw, aec, z80io, ms3, ms2, ms1, ms0); |
| 263 | 259 | |
| 264 | | if (!casenb && !dwe) |
| 260 | m_clrbank = BIT(plaout, PLA_OUT_CLRBANK); |
| 261 | |
| 262 | if (!BIT(plaout, PLA_OUT_CASENB) && !BIT(plaout, PLA_OUT_DWE)) |
| 265 | 263 | { |
| 266 | 264 | if (!cas0) |
| 267 | 265 | { |
| r31284 | r31285 | |
| 272 | 270 | m_ram->pointer()[0x10000 | ma] = data; |
| 273 | 271 | } |
| 274 | 272 | } |
| 275 | | if (!colorram && !gwe) |
| 273 | if (!BIT(plaout, PLA_OUT_COLORRAM) && !BIT(plaout, PLA_OUT_GWE)) |
| 276 | 274 | { |
| 277 | | m_color_ram[(clrbank << 10) | (ta & 0x300) | sa] = data & 0x0f; |
| 275 | m_color_ram[(m_clrbank << 10) | (ta & 0x300) | sa] = data & 0x0f; |
| 278 | 276 | } |
| 279 | | if (!vic) |
| 277 | if (!BIT(plaout, PLA_OUT_VIC)) |
| 280 | 278 | { |
| 281 | 279 | m_vic->write(space, offset & 0x3f, data); |
| 282 | 280 | } |
| 283 | | if (!iocs && BIT(offset, 10)) |
| 281 | if (!BIT(plaout, PLA_OUT_IOCS) && BIT(offset, 10)) |
| 284 | 282 | { |
| 285 | 283 | switch ((BIT(offset, 11) << 2) | ((offset >> 8) & 0x03)) |
| 286 | 284 | { |
| r31284 | r31285 | |
| 317 | 315 | } |
| 318 | 316 | } |
| 319 | 317 | |
| 318 | int roml = BIT(plaout, PLA_OUT_ROML); |
| 319 | int romh = BIT(plaout, PLA_OUT_ROMH); |
| 320 | |
| 320 | 321 | m_exp->cd_w(space, ca, data, sphi2, ba, roml, romh, io1, io2); |
| 321 | 322 | |
| 322 | 323 | m_mmu->write(space, offset, data); |