src/mess/drivers/c64.c
| r15829 | r15830 | |
| 90 | 90 | |
| 91 | 91 | UINT8 c64_state::read_memory(address_space &space, offs_t offset, int ba, int casram, int basic, int kernal, int charom, int io, int roml, int romh) |
| 92 | 92 | { |
| 93 | | int io1 = 1; |
| 94 | | int io2 = 1; |
| 93 | int io1 = 1, io2 = 1; |
| 95 | 94 | |
| 96 | 95 | UINT8 data = 0; |
| 97 | 96 | |
| r15829 | r15830 | |
| 124 | 123 | break; |
| 125 | 124 | |
| 126 | 125 | case 2: // COLOR |
| 127 | | data = m_color_ram[offset & 0x3ff]; |
| 126 | data = m_color_ram[offset & 0x3ff] | 0xf0; |
| 128 | 127 | break; |
| 129 | 128 | |
| 130 | 129 | case 3: // CIAS |
| r15829 | r15830 | |
| 167 | 166 | |
| 168 | 167 | READ8_MEMBER( c64_state::read ) |
| 169 | 168 | { |
| 169 | offs_t va = 0; |
| 170 | int rw = 1, aec = 0, ba = 1, cas = 0; |
| 170 | 171 | int casram, basic, kernal, charom, grw, io, roml, romh; |
| 171 | 172 | |
| 172 | | bankswitch(offset, 0, 1, 0, 1, 0, &casram, &basic, &kernal, &charom, &grw, &io, &roml, &romh); |
| 173 | bankswitch(offset, va, rw, aec, ba, cas, &casram, &basic, &kernal, &charom, &grw, &io, &roml, &romh); |
| 173 | 174 | |
| 174 | | return read_memory(space, offset, 1, casram, basic, kernal, charom, io, roml, romh); |
| 175 | return read_memory(space, offset, ba, casram, basic, kernal, charom, io, roml, romh); |
| 175 | 176 | } |
| 176 | 177 | |
| 177 | 178 | |
| r15829 | r15830 | |
| 181 | 182 | |
| 182 | 183 | WRITE8_MEMBER( c64_state::write ) |
| 183 | 184 | { |
| 184 | | int io1 = 1; |
| 185 | | int io2 = 1; |
| 186 | | |
| 185 | offs_t va = 0; |
| 186 | int rw = 0, aec = 0, ba = 1, cas = 0; |
| 187 | int io1 = 1, io2 = 1; |
| 187 | 188 | int casram, basic, kernal, charom, grw, io, roml, romh; |
| 188 | 189 | |
| 189 | | bankswitch(offset, 0, 0, 0, 1, 0, &casram, &basic, &kernal, &charom, &grw, &io, &roml, &romh); |
| 190 | bankswitch(offset, va, rw, aec, ba, cas, &casram, &basic, &kernal, &charom, &grw, &io, &roml, &romh); |
| 190 | 191 | |
| 191 | 192 | if (!casram) |
| 192 | 193 | { |
| r15829 | r15830 | |
| 205 | 206 | break; |
| 206 | 207 | |
| 207 | 208 | case 2: // COLOR |
| 208 | | if (!grw) m_color_ram[offset & 0x3ff] = 0xf0 | data; |
| 209 | if (!grw) m_color_ram[offset & 0x3ff] = data & 0x0f; |
| 209 | 210 | break; |
| 210 | 211 | |
| 211 | 212 | case 3: // CIAS |
| r15829 | r15830 | |
| 231 | 232 | } |
| 232 | 233 | } |
| 233 | 234 | |
| 234 | | m_exp->cd_w(space, offset, data, 1, roml, romh, io1, io2); |
| 235 | m_exp->cd_w(space, offset, data, ba, roml, romh, io1, io2); |
| 235 | 236 | } |
| 236 | 237 | |
| 237 | 238 | |
| r15829 | r15830 | |
| 243 | 244 | { |
| 244 | 245 | offset = (!m_va15 << 15) | (!m_va14 << 14) | offset; |
| 245 | 246 | |
| 247 | int rw = 1, aec = 1, ba = 0, cas = 0; |
| 246 | 248 | int casram, basic, kernal, charom, grw, io, roml, romh; |
| 247 | | bankswitch(0, offset, 1, 1, 0, 0, &casram, &basic, &kernal, &charom, &grw, &io, &roml, &romh); |
| 249 | bankswitch(0xffff, offset, rw, aec, ba, cas, &casram, &basic, &kernal, &charom, &grw, &io, &roml, &romh); |
| 248 | 250 | |
| 249 | 251 | return read_memory(space, offset, 0, casram, basic, kernal, charom, io, roml, romh); |
| 250 | 252 | } |
| 251 | 253 | |
| 252 | 254 | |
| 253 | | //------------------------------------------------- |
| 254 | | // vic_colorram_r - |
| 255 | | //------------------------------------------------- |
| 256 | 255 | |
| 257 | | READ8_MEMBER( c64_state::vic_colorram_r ) |
| 258 | | { |
| 259 | | return m_color_ram[offset]; |
| 260 | | } |
| 261 | | |
| 262 | | |
| 263 | | |
| 264 | 256 | //************************************************************************** |
| 265 | 257 | // ADDRESS MAPS |
| 266 | 258 | //************************************************************************** |
| r15829 | r15830 | |
| 288 | 280 | //------------------------------------------------- |
| 289 | 281 | |
| 290 | 282 | static ADDRESS_MAP_START( vic_colorram_map, AS_1, 8, c64_state ) |
| 291 | | AM_RANGE(0x000, 0x3ff) AM_READ(vic_colorram_r) |
| 283 | AM_RANGE(0x000, 0x3ff) AM_RAM AM_SHARE("color_ram") |
| 292 | 284 | ADDRESS_MAP_END |
| 293 | 285 | |
| 294 | 286 | |
| r15829 | r15830 | |
| 983 | 975 | check_interrupts(); |
| 984 | 976 | } |
| 985 | 977 | |
| 978 | WRITE_LINE_MEMBER( c64_state::exp_reset_w ) |
| 979 | { |
| 980 | if (state == ASSERT_LINE) |
| 981 | { |
| 982 | machine_reset(); |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | 986 | static C64_EXPANSION_INTERFACE( expansion_intf ) |
| 987 | 987 | { |
| 988 | 988 | DEVCB_DRIVER_MEMBER(c64_state, exp_dma_r), |
| r15829 | r15830 | |
| 990 | 990 | DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_irq_w), |
| 991 | 991 | DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_nmi_w), |
| 992 | 992 | DEVCB_CPU_INPUT_LINE(M6510_TAG, INPUT_LINE_HALT), |
| 993 | | DEVCB_CPU_INPUT_LINE(M6510_TAG, INPUT_LINE_RESET) |
| 993 | DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_reset_w) |
| 994 | 994 | }; |
| 995 | 995 | |
| 996 | 996 | |
| r15829 | r15830 | |
| 1005 | 1005 | DEVCB_DEVICE_LINE(MOS6526_2_TAG, mos6526_sp_w), |
| 1006 | 1006 | DEVCB_DEVICE_LINE(MOS6526_2_TAG, mos6526_cnt_w), |
| 1007 | 1007 | DEVCB_DEVICE_LINE(MOS6526_2_TAG, mos6526_flag_w), |
| 1008 | | DEVCB_CPU_INPUT_LINE(M6510_TAG, INPUT_LINE_RESET) |
| 1008 | DEVCB_DRIVER_LINE_MEMBER(c64_state, exp_reset_w) |
| 1009 | 1009 | }; |
| 1010 | 1010 | |
| 1011 | 1011 | |
| r15829 | r15830 | |
| 1027 | 1027 | m_kernal = memregion("kernal")->base(); |
| 1028 | 1028 | m_charom = memregion("charom")->base(); |
| 1029 | 1029 | |
| 1030 | | // allocate memory |
| 1031 | | m_color_ram = auto_alloc_array(machine(), UINT8, 0x400); |
| 1032 | | |
| 1033 | 1030 | // state saving |
| 1034 | 1031 | save_item(NAME(m_loram)); |
| 1035 | 1032 | save_item(NAME(m_hiram)); |
| 1036 | 1033 | save_item(NAME(m_charen)); |
| 1037 | | save_pointer(NAME(m_color_ram), 0x400); |
| 1038 | 1034 | save_item(NAME(m_va14)); |
| 1039 | 1035 | save_item(NAME(m_va15)); |
| 1040 | 1036 | save_item(NAME(m_cia1_irq)); |
| r15829 | r15830 | |
| 1071 | 1067 | } |
| 1072 | 1068 | |
| 1073 | 1069 | |
| 1070 | //------------------------------------------------- |
| 1071 | // MACHINE_RESET( c64 ) |
| 1072 | //------------------------------------------------- |
| 1074 | 1073 | |
| 1074 | void c64_state::machine_reset() |
| 1075 | { |
| 1076 | m_maincpu->reset(); |
| 1077 | |
| 1078 | m_iec->reset(); |
| 1079 | } |
| 1080 | |
| 1081 | |
| 1082 | |
| 1075 | 1083 | //************************************************************************** |
| 1076 | 1084 | // MACHINE DRIVERS |
| 1077 | 1085 | //************************************************************************** |