src/mess/machine/c65.c
| r4736 | r4737 | |
| 12 | 12 | #include "machine/6526cia.h" |
| 13 | 13 | #include "video/vic4567.h" |
| 14 | 14 | |
| 15 | #include "includes/cbm.h" |
| 15 | 16 | #include "includes/cbmserb.h" |
| 16 | 17 | #include "includes/cbmdrive.h" |
| 17 | | #include "cbmipt.h" /* we need cbm_common_interrupt & c64_keyline for input reading */ |
| 18 | 18 | |
| 19 | 19 | #include "includes/c65.h" |
| 20 | 20 | #include "includes/c64.h" |
| r4736 | r4737 | |
| 34 | 34 | |
| 35 | 35 | static int c64mode = 0; |
| 36 | 36 | |
| 37 | static UINT8 c65_6511_port = 0xff; |
| 37 | 38 | static UINT8 c65_keyline = { 0xff }; |
| 38 | 39 | |
| 40 | static UINT8 serial_clock, serial_data, serial_atn; |
| 41 | static UINT8 vicirq = 0; |
| 39 | 42 | |
| 40 | 43 | /*UINT8 *c65_basic; */ |
| 41 | 44 | /*UINT8 *c65_kernal; */ |
| r4736 | r4737 | |
| 45 | 48 | UINT8 *c65_interface; |
| 46 | 49 | /*UINT8 *c65_graphics; */ |
| 47 | 50 | |
| 51 | |
| 52 | static void c65_nmi(running_machine *machine) |
| 53 | { |
| 54 | static int nmilevel = 0; |
| 55 | const device_config *cia_1 = devtag_get_device(machine, "cia_1"); |
| 56 | int cia1irq = cia_get_irq(cia_1); |
| 57 | |
| 58 | if (nmilevel != (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq) /* KEY_RESTORE */ |
| 59 | { |
| 60 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq); |
| 61 | |
| 62 | nmilevel = (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | |
| 67 | /*********************************************** |
| 68 | |
| 69 | CIA Interfaces |
| 70 | |
| 71 | ***********************************************/ |
| 72 | |
| 73 | /* |
| 74 | * CIA 0 - Port A keyboard line select |
| 75 | * CIA 0 - Port B keyboard line read |
| 76 | * |
| 77 | * flag cassette read input, serial request in |
| 78 | * irq to irq connected |
| 79 | * |
| 80 | * see machine/cbm.c |
| 81 | */ |
| 82 | |
| 83 | static READ8_DEVICE_HANDLER( c65_cia0_port_a_r ) |
| 84 | { |
| 85 | UINT8 cia0portb = cia_get_output_b(devtag_get_device(device->machine, "cia_0")); |
| 86 | |
| 87 | return common_cia0_port_a_r(device, cia0portb); |
| 88 | } |
| 89 | |
| 90 | static READ8_DEVICE_HANDLER( c65_cia0_port_b_r ) |
| 91 | { |
| 92 | UINT8 value = 0xff; |
| 93 | UINT8 cia0porta = cia_get_output_a(devtag_get_device(device->machine, "cia_0")); |
| 94 | |
| 95 | value &= common_cia0_port_b_r(device, cia0porta); |
| 96 | |
| 97 | if (!(c65_6511_port & 0x02)) |
| 98 | value &= c65_keyline; |
| 99 | |
| 100 | return value; |
| 101 | } |
| 102 | |
| 103 | static WRITE8_DEVICE_HANDLER( c65_cia0_port_b_w ) |
| 104 | { |
| 105 | // was there lightpen support in c65 video chip? |
| 106 | // vic2_lightpen_write(data & 0x10); |
| 107 | } |
| 108 | |
| 109 | static void c65_irq (running_machine *machine, int level) |
| 110 | { |
| 111 | static int old_level = 0; |
| 112 | |
| 113 | if (level != old_level) |
| 114 | { |
| 115 | DBG_LOG (3, "mos6510", ("irq %s\n", level ? "start" : "end")); |
| 116 | cputag_set_input_line(machine, "maincpu", M6510_IRQ_LINE, level); |
| 117 | old_level = level; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | static void c65_cia0_interrupt (const device_config *device, int level) |
| 122 | { |
| 123 | c65_irq (device->machine, level || vicirq); |
| 124 | } |
| 125 | |
| 126 | void c65_vic_interrupt (running_machine *machine, int level) |
| 127 | { |
| 128 | const device_config *cia_0 = devtag_get_device(machine, "cia_0"); |
| 129 | #if 1 |
| 130 | if (level != vicirq) |
| 131 | { |
| 132 | c65_irq (machine, level || cia_get_irq(cia_0)); |
| 133 | vicirq = level; |
| 134 | } |
| 135 | #endif |
| 136 | } |
| 137 | |
| 138 | const cia6526_interface c65_ntsc_cia0 = |
| 139 | { |
| 140 | DEVCB_LINE(c65_cia0_interrupt), |
| 141 | DEVCB_NULL, /* pc_func */ |
| 142 | 60, |
| 143 | |
| 144 | { |
| 145 | { DEVCB_HANDLER(c65_cia0_port_a_r), DEVCB_NULL }, |
| 146 | { DEVCB_HANDLER(c65_cia0_port_b_r), DEVCB_HANDLER(c65_cia0_port_b_w) } |
| 147 | } |
| 148 | }; |
| 149 | |
| 150 | const cia6526_interface c65_pal_cia0 = |
| 151 | { |
| 152 | DEVCB_LINE(c65_cia0_interrupt), |
| 153 | DEVCB_NULL, /* pc_func */ |
| 154 | 50, |
| 155 | |
| 156 | { |
| 157 | { DEVCB_HANDLER(c65_cia0_port_a_r), DEVCB_NULL }, |
| 158 | { DEVCB_HANDLER(c65_cia0_port_b_r), DEVCB_HANDLER(c65_cia0_port_b_w) } |
| 159 | } |
| 160 | }; |
| 161 | |
| 162 | /* |
| 163 | * CIA 1 - Port A |
| 164 | * bit 7 serial bus data input |
| 165 | * bit 6 serial bus clock input |
| 166 | * bit 5 serial bus data output |
| 167 | * bit 4 serial bus clock output |
| 168 | * bit 3 serial bus atn output |
| 169 | * bit 2 rs232 data output |
| 170 | * bits 1-0 vic-chip system memory bank select |
| 171 | * |
| 172 | * CIA 1 - Port B |
| 173 | * bit 7 user rs232 data set ready |
| 174 | * bit 6 user rs232 clear to send |
| 175 | * bit 5 user |
| 176 | * bit 4 user rs232 carrier detect |
| 177 | * bit 3 user rs232 ring indicator |
| 178 | * bit 2 user rs232 data terminal ready |
| 179 | * bit 1 user rs232 request to send |
| 180 | * bit 0 user rs232 received data |
| 181 | * |
| 182 | * flag restore key or rs232 received data input |
| 183 | * irq to nmi connected ? |
| 184 | */ |
| 185 | static READ8_DEVICE_HANDLER( c65_cia1_port_a_r ) |
| 186 | { |
| 187 | UINT8 value = 0xff; |
| 188 | |
| 189 | if (!serial_clock || !cbm_serial_clock_read (device->machine)) |
| 190 | value &= ~0x40; |
| 191 | |
| 192 | if (!serial_data || !cbm_serial_data_read (device->machine)) |
| 193 | value &= ~0x80; |
| 194 | |
| 195 | return value; |
| 196 | } |
| 197 | |
| 198 | static WRITE8_DEVICE_HANDLER( c65_cia1_port_a_w ) |
| 199 | { |
| 200 | static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000}; |
| 201 | |
| 202 | cbm_serial_clock_write (device->machine, serial_clock = !(data & 0x10)); |
| 203 | cbm_serial_data_write (device->machine, serial_data = !(data & 0x20)); |
| 204 | cbm_serial_atn_write (device->machine, serial_atn = !(data & 0x08)); |
| 205 | c64_vicaddr = c64_memory + helper[data & 0x03]; |
| 206 | } |
| 207 | |
| 208 | static void c65_cia1_interrupt (const device_config *device, int level) |
| 209 | { |
| 210 | c65_nmi(device->machine); |
| 211 | } |
| 212 | |
| 213 | |
| 214 | const cia6526_interface c65_ntsc_cia1 = |
| 215 | { |
| 216 | DEVCB_LINE(c65_cia1_interrupt), |
| 217 | DEVCB_NULL, /* pc_func */ |
| 218 | 60, |
| 219 | |
| 220 | { |
| 221 | { DEVCB_HANDLER(c65_cia1_port_a_r), DEVCB_HANDLER(c65_cia1_port_a_w) }, |
| 222 | { DEVCB_NULL, DEVCB_NULL } |
| 223 | } |
| 224 | }; |
| 225 | |
| 226 | const cia6526_interface c65_pal_cia1 = |
| 227 | { |
| 228 | DEVCB_LINE(c65_cia1_interrupt), |
| 229 | DEVCB_NULL, /* pc_func */ |
| 230 | 50, |
| 231 | |
| 232 | { |
| 233 | { DEVCB_HANDLER(c65_cia1_port_a_r), DEVCB_HANDLER(c65_cia1_port_a_w) }, |
| 234 | { DEVCB_NULL, DEVCB_NULL } |
| 235 | } |
| 236 | }; |
| 237 | |
| 238 | /*********************************************** |
| 239 | |
| 240 | Memory Handlers |
| 241 | |
| 242 | ***********************************************/ |
| 243 | |
| 48 | 244 | /* processor has only 1 mega address space !? */ |
| 49 | 245 | /* and system 8 megabyte */ |
| 50 | 246 | /* dma controller and bankswitch hardware ?*/ |
| r4736 | r4737 | |
| 820 | 1016 | |
| 821 | 1017 | /*memset(c64_memory+0x40000, 0, 0x800000-0x40000); */ |
| 822 | 1018 | |
| 823 | | vic4567_init(machine, c64_pal, c65_dma_read, c65_dma_read_color, |
| 824 | | c64_vic_interrupt, c65_bankswitch_interface); |
| 1019 | vic4567_init(machine, c64_pal, c65_dma_read, c65_dma_read_color, c65_vic_interrupt, c65_bankswitch_interface); |
| 825 | 1020 | } |
| 826 | 1021 | |
| 827 | 1022 | DRIVER_INIT( c65 ) |
| r4736 | r4737 | |
| 856 | 1051 | } |
| 857 | 1052 | |
| 858 | 1053 | |
| 859 | | static void c65_nmi(running_machine *machine) |
| 860 | | { |
| 861 | | static int nmilevel = 0; |
| 862 | | const device_config *cia_1 = devtag_get_device(machine, "cia_1"); |
| 863 | | int cia1irq = cia_get_irq(cia_1); |
| 864 | | |
| 865 | | if (nmilevel != (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq) /* KEY_RESTORE */ |
| 866 | | { |
| 867 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq); |
| 868 | | |
| 869 | | nmilevel = (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq; |
| 870 | | } |
| 871 | | } |
| 872 | | |
| 873 | | |
| 874 | 1054 | INTERRUPT_GEN( c65_frame_interrupt ) |
| 875 | 1055 | { |
| 876 | 1056 | int value; |
src/mess/machine/c128.c
| r4736 | r4737 | |
| 15 | 15 | #include "sound/sid6581.h" |
| 16 | 16 | #include "machine/6526cia.h" |
| 17 | 17 | |
| 18 | #include "includes/cbm.h" |
| 18 | 19 | #include "includes/cbmserb.h" |
| 19 | 20 | #include "includes/vc1541.h" |
| 20 | 21 | #include "video/vic6567.h" |
| 21 | 22 | #include "video/vdc8563.h" |
| 22 | 23 | |
| 23 | | #include "cbmipt.h" /* we need cbm_common_interrupt & c64_keyline for input reading */ |
| 24 | 24 | |
| 25 | 25 | #include "includes/c128.h" |
| 26 | 26 | #include "includes/c64.h" |
| r4736 | r4737 | |
| 74 | 74 | |
| 75 | 75 | static UINT8 c128_keyline[3] = {0xff, 0xff, 0xff}; |
| 76 | 76 | |
| 77 | static int c128_va1617; |
| 78 | static UINT8 serial_clock, serial_data, serial_atn; |
| 79 | static UINT8 vicirq = 0; |
| 80 | |
| 81 | static void c128_nmi(running_machine *machine) |
| 82 | { |
| 83 | static int nmilevel = 0; |
| 84 | const device_config *cia_1 = devtag_get_device(machine, "cia_1"); |
| 85 | int cia1irq = cia_get_irq(cia_1); |
| 86 | |
| 87 | if (nmilevel != (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq) /* KEY_RESTORE */ |
| 88 | { |
| 89 | if (1) // this was never valid, there is no active CPU during a timer firing! cpu_getactivecpu() == 0) |
| 90 | { |
| 91 | /* z80 */ |
| 92 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq); |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | cputag_set_input_line(machine, "m8502", INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq); |
| 97 | } |
| 98 | |
| 99 | nmilevel = (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /*********************************************** |
| 104 | |
| 105 | CIA Interfaces |
| 106 | |
| 107 | ***********************************************/ |
| 108 | |
| 109 | /* |
| 110 | * CIA 0 - Port A keyboard line select |
| 111 | * CIA 0 - Port B keyboard line read |
| 112 | * |
| 113 | * flag cassette read input, serial request in |
| 114 | * irq to irq connected |
| 115 | * |
| 116 | * see machine/cbm.c |
| 117 | */ |
| 118 | |
| 119 | static READ8_DEVICE_HANDLER( c128_cia0_port_a_r ) |
| 120 | { |
| 121 | UINT8 cia0portb = cia_get_output_b(devtag_get_device(device->machine, "cia_0")); |
| 122 | |
| 123 | return common_cia0_port_a_r(device, cia0portb); |
| 124 | } |
| 125 | |
| 126 | static READ8_DEVICE_HANDLER( c128_cia0_port_b_r ) |
| 127 | { |
| 128 | UINT8 value = 0xff; |
| 129 | UINT8 cia0porta = cia_get_output_a(devtag_get_device(device->machine, "cia_0")); |
| 130 | |
| 131 | value &= common_cia0_port_b_r(device, cia0porta); |
| 132 | |
| 133 | if (!vic2e_k0_r()) |
| 134 | value &= c128_keyline[0]; |
| 135 | if (!vic2e_k1_r()) |
| 136 | value &= c128_keyline[1]; |
| 137 | if (!vic2e_k2_r()) |
| 138 | value &= c128_keyline[2]; |
| 139 | |
| 140 | return value; |
| 141 | } |
| 142 | |
| 143 | static WRITE8_DEVICE_HANDLER( c128_cia0_port_b_w ) |
| 144 | { |
| 145 | vic2_lightpen_write(data & 0x10); |
| 146 | } |
| 147 | |
| 148 | static void c128_irq (running_machine *machine, int level) |
| 149 | { |
| 150 | static int old_level = 0; |
| 151 | |
| 152 | if (level != old_level) |
| 153 | { |
| 154 | DBG_LOG (3, "mos6510", ("irq %s\n", level ? "start" : "end")); |
| 155 | |
| 156 | if (0) // && (cpu_getactivecpu() == 0)) |
| 157 | { |
| 158 | cputag_set_input_line(machine, "maincpu", 0, level); |
| 159 | } |
| 160 | else |
| 161 | { |
| 162 | cputag_set_input_line(machine, "m8502", M6510_IRQ_LINE, level); |
| 163 | } |
| 164 | |
| 165 | old_level = level; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | static void c128_cia0_interrupt (const device_config *device, int level) |
| 170 | { |
| 171 | c128_irq (device->machine, level || vicirq); |
| 172 | } |
| 173 | |
| 174 | void c128_vic_interrupt (running_machine *machine, int level) |
| 175 | { |
| 176 | const device_config *cia_0 = devtag_get_device(machine, "cia_0"); |
| 177 | #if 1 |
| 178 | if (level != vicirq) |
| 179 | { |
| 180 | c128_irq (machine, level || cia_get_irq(cia_0)); |
| 181 | vicirq = level; |
| 182 | } |
| 183 | #endif |
| 184 | } |
| 185 | |
| 186 | const cia6526_interface c128_ntsc_cia0 = |
| 187 | { |
| 188 | DEVCB_LINE(c128_cia0_interrupt), |
| 189 | DEVCB_NULL, /* pc_func */ |
| 190 | 60, |
| 191 | |
| 192 | { |
| 193 | { DEVCB_HANDLER(c128_cia0_port_a_r), DEVCB_NULL }, |
| 194 | { DEVCB_HANDLER(c128_cia0_port_b_r), DEVCB_HANDLER(c128_cia0_port_b_w) } |
| 195 | } |
| 196 | }; |
| 197 | |
| 198 | const cia6526_interface c128_pal_cia0 = |
| 199 | { |
| 200 | DEVCB_LINE(c128_cia0_interrupt), |
| 201 | DEVCB_NULL, /* pc_func */ |
| 202 | 50, |
| 203 | |
| 204 | { |
| 205 | { DEVCB_HANDLER(c128_cia0_port_a_r), DEVCB_NULL }, |
| 206 | { DEVCB_HANDLER(c128_cia0_port_b_r), DEVCB_HANDLER(c128_cia0_port_b_w) } |
| 207 | } |
| 208 | }; |
| 209 | |
| 210 | |
| 211 | /* |
| 212 | * CIA 1 - Port A |
| 213 | * bit 7 serial bus data input |
| 214 | * bit 6 serial bus clock input |
| 215 | * bit 5 serial bus data output |
| 216 | * bit 4 serial bus clock output |
| 217 | * bit 3 serial bus atn output |
| 218 | * bit 2 rs232 data output |
| 219 | * bits 1-0 vic-chip system memory bank select |
| 220 | * |
| 221 | * CIA 1 - Port B |
| 222 | * bit 7 user rs232 data set ready |
| 223 | * bit 6 user rs232 clear to send |
| 224 | * bit 5 user |
| 225 | * bit 4 user rs232 carrier detect |
| 226 | * bit 3 user rs232 ring indicator |
| 227 | * bit 2 user rs232 data terminal ready |
| 228 | * bit 1 user rs232 request to send |
| 229 | * bit 0 user rs232 received data |
| 230 | * |
| 231 | * flag restore key or rs232 received data input |
| 232 | * irq to nmi connected ? |
| 233 | */ |
| 234 | static READ8_DEVICE_HANDLER( c128_cia1_port_a_r ) |
| 235 | { |
| 236 | UINT8 value = 0xff; |
| 237 | |
| 238 | if (!serial_clock || !cbm_serial_clock_read (device->machine)) |
| 239 | value &= ~0x40; |
| 240 | |
| 241 | if (!serial_data || !cbm_serial_data_read (device->machine)) |
| 242 | value &= ~0x80; |
| 243 | |
| 244 | return value; |
| 245 | } |
| 246 | |
| 247 | static WRITE8_DEVICE_HANDLER( c128_cia1_port_a_w ) |
| 248 | { |
| 249 | static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000}; |
| 250 | |
| 251 | cbm_serial_clock_write (device->machine, serial_clock = !(data & 0x10)); |
| 252 | cbm_serial_data_write (device->machine, serial_data = !(data & 0x20)); |
| 253 | cbm_serial_atn_write (device->machine, serial_atn = !(data & 0x08)); |
| 254 | c64_vicaddr = c64_memory + helper[data & 0x03]; |
| 255 | c128_vicaddr = c64_memory + helper[data & 0x03] + c128_va1617; |
| 256 | } |
| 257 | |
| 258 | static void c128_cia1_interrupt (const device_config *device, int level) |
| 259 | { |
| 260 | c128_nmi(device->machine); |
| 261 | } |
| 262 | |
| 263 | const cia6526_interface c128_ntsc_cia1 = |
| 264 | { |
| 265 | DEVCB_LINE(c128_cia1_interrupt), |
| 266 | DEVCB_NULL, /* pc_func */ |
| 267 | 60, |
| 268 | |
| 269 | { |
| 270 | { DEVCB_HANDLER(c128_cia1_port_a_r), DEVCB_HANDLER(c128_cia1_port_a_w) }, |
| 271 | { DEVCB_NULL, DEVCB_NULL } |
| 272 | } |
| 273 | }; |
| 274 | |
| 275 | const cia6526_interface c128_pal_cia1 = |
| 276 | { |
| 277 | DEVCB_LINE(c128_cia1_interrupt), |
| 278 | DEVCB_NULL, /* pc_func */ |
| 279 | 50, |
| 280 | |
| 281 | { |
| 282 | { DEVCB_HANDLER(c128_cia1_port_a_r), DEVCB_HANDLER(c128_cia1_port_a_w) }, |
| 283 | { DEVCB_NULL, DEVCB_NULL } |
| 284 | } |
| 285 | }; |
| 286 | |
| 287 | /*********************************************** |
| 288 | |
| 289 | Memory Handlers |
| 290 | |
| 291 | ***********************************************/ |
| 292 | |
| 77 | 293 | static void c128_set_m8502_read_handler(running_machine *machine, UINT16 start, UINT16 end, read8_space_func rh) |
| 78 | 294 | { |
| 79 | 295 | const device_config *cpu; |
| r4736 | r4737 | |
| 880 | 1096 | data |= 0x10; |
| 881 | 1097 | |
| 882 | 1098 | if (input_port_read(device->machine, "SPECIAL") & 0x20) /* Check Caps Lock */ |
| 883 | | { |
| 884 | 1099 | data &= ~0x40; |
| 885 | | } else { |
| 1100 | else |
| 886 | 1101 | data |= 0x40; |
| 887 | | } |
| 888 | 1102 | |
| 889 | 1103 | return data; |
| 890 | 1104 | } |
| r4736 | r4737 | |
| 921 | 1135 | { |
| 922 | 1136 | c64_tape_on = 1; |
| 923 | 1137 | c128_common_driver_init(machine); |
| 924 | | vic6567_init (1, c64_pal, |
| 925 | | c128_dma_read, c128_dma_read_color, c64_vic_interrupt); |
| 1138 | vic6567_init (1, c64_pal, c128_dma_read, c128_dma_read_color, c128_vic_interrupt); |
| 926 | 1139 | vic2_set_rastering(0); |
| 927 | 1140 | vdc8563_init(0); |
| 928 | 1141 | vdc8563_set_rastering(1); |
| r4736 | r4737 | |
| 933 | 1146 | c64_tape_on = 1; |
| 934 | 1147 | c64_pal = 1; |
| 935 | 1148 | c128_common_driver_init(machine); |
| 936 | | vic6567_init (1, c64_pal, |
| 937 | | c128_dma_read, c128_dma_read_color, c64_vic_interrupt); |
| 1149 | vic6567_init (1, c64_pal, c128_dma_read, c128_dma_read_color, c128_vic_interrupt); |
| 938 | 1150 | vic2_set_rastering(1); |
| 939 | 1151 | vdc8563_init(0); |
| 940 | 1152 | vdc8563_set_rastering(0); |
| r4736 | r4737 | |
| 952 | 1164 | // drive_config (machine, type_1541, 0, 0, 1, 8); |
| 953 | 1165 | } |
| 954 | 1166 | |
| 1167 | #if 0 |
| 1168 | // This was in MACHINE_START( c64 ), but never called |
| 1169 | // TO DO: find its correct use, when fixing c64 mode |
| 1170 | MACHINE_START( c128 ) |
| 1171 | { |
| 1172 | if (c64mode) |
| 1173 | c128_bankswitch_64(machine, 1); |
| 1174 | } |
| 1175 | #endif |
| 955 | 1176 | |
| 956 | 1177 | MACHINE_RESET( c128 ) |
| 957 | 1178 | { |
| r4736 | r4737 | |
| 964 | 1185 | } |
| 965 | 1186 | |
| 966 | 1187 | |
| 967 | | static void c128_nmi(running_machine *machine) |
| 968 | | { |
| 969 | | static int nmilevel = 0; |
| 970 | | const device_config *cia_1 = devtag_get_device(machine, "cia_1"); |
| 971 | | int cia1irq = cia_get_irq(cia_1); |
| 972 | | |
| 973 | | if (nmilevel != (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq) /* KEY_RESTORE */ |
| 974 | | { |
| 975 | | if (1) // this was never valid, there is no active CPU during a timer firing! cpu_getactivecpu() == 0) |
| 976 | | { |
| 977 | | /* z80 */ |
| 978 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq); |
| 979 | | } |
| 980 | | else |
| 981 | | { |
| 982 | | cputag_set_input_line(machine, "m8502", INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq); |
| 983 | | } |
| 984 | | |
| 985 | | nmilevel = (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq; |
| 986 | | } |
| 987 | | } |
| 988 | | |
| 989 | 1188 | INTERRUPT_GEN( c128_frame_interrupt ) |
| 990 | 1189 | { |
| 991 | 1190 | static int monitor = -1; |
src/mess/machine/cbmipt.c
| r4736 | r4737 | |
| 20 | 20 | #include "machine/cbmipt.h" |
| 21 | 21 | |
| 22 | 22 | |
| 23 | | |
| 24 | | |
| 25 | | /*********************************************** |
| 26 | | |
| 27 | | Input Reading - Common Components |
| 28 | | |
| 29 | | ***********************************************/ |
| 30 | | |
| 31 | | /* These are needed by c64, c65 and c128, each machine has also additional specific |
| 32 | | components in its INTERRUPT_GEN */ |
| 33 | | |
| 34 | | /* keyboard lines */ |
| 35 | | UINT8 c64_keyline[10] = |
| 36 | | { |
| 37 | | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 38 | | }; |
| 39 | | |
| 40 | | |
| 41 | | static TIMER_CALLBACK( lightpen_tick ) |
| 42 | | { |
| 43 | | if ((input_port_read(machine, "CTRLSEL") & 0x07) == 0x04) |
| 44 | | { |
| 45 | | /* enable lightpen crosshair */ |
| 46 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); |
| 47 | | } |
| 48 | | else |
| 49 | | { |
| 50 | | /* disable lightpen crosshair */ |
| 51 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); |
| 52 | | } |
| 53 | | } |
| 54 | | |
| 55 | | void cbm_common_interrupt( const device_config *device ) |
| 56 | | { |
| 57 | | int value, i; |
| 58 | | int controller1 = input_port_read(device->machine, "CTRLSEL") & 0x07; |
| 59 | | int controller2 = input_port_read(device->machine, "CTRLSEL") & 0x70; |
| 60 | | static const char *const c64ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" }; |
| 61 | | |
| 62 | | /* Lines 0-7 : common keyboard */ |
| 63 | | for (i = 0; i < 8; i++) |
| 64 | | { |
| 65 | | value = 0xff; |
| 66 | | value &= ~input_port_read(device->machine, c64ports[i]); |
| 67 | | |
| 68 | | /* Shift Lock is mapped on Left Shift */ |
| 69 | | if ((i == 1) && (input_port_read(device->machine, "SPECIAL") & 0x40)) |
| 70 | | value &= ~0x80; |
| 71 | | |
| 72 | | c64_keyline[i] = value; |
| 73 | | } |
| 74 | | |
| 75 | | |
| 76 | | value = 0xff; |
| 77 | | switch(controller1) |
| 78 | | { |
| 79 | | case 0x00: |
| 80 | | value &= ~input_port_read(device->machine, "JOY1_1B"); /* Joy1 Directions + Button 1 */ |
| 81 | | break; |
| 82 | | |
| 83 | | case 0x01: |
| 84 | | if (input_port_read(device->machine, "OTHER") & 0x40) /* Paddle2 Button */ |
| 85 | | value &= ~0x08; |
| 86 | | if (input_port_read(device->machine, "OTHER") & 0x80) /* Paddle1 Button */ |
| 87 | | value &= ~0x04; |
| 88 | | break; |
| 89 | | |
| 90 | | case 0x02: |
| 91 | | if (input_port_read(device->machine, "OTHER") & 0x02) /* Mouse Button Left */ |
| 92 | | value &= ~0x10; |
| 93 | | if (input_port_read(device->machine, "OTHER") & 0x01) /* Mouse Button Right */ |
| 94 | | value &= ~0x01; |
| 95 | | break; |
| 96 | | |
| 97 | | case 0x03: |
| 98 | | value &= ~(input_port_read(device->machine, "JOY1_2B") & 0x1f); /* Joy1 Directions + Button 1 */ |
| 99 | | break; |
| 100 | | |
| 101 | | case 0x04: |
| 102 | | /* was there any input on the lightpen? where is it mapped? */ |
| 103 | | // if (input_port_read(device->machine, "OTHER") & 0x04) /* Lightpen Signal */ |
| 104 | | // value &= ?? ; |
| 105 | | break; |
| 106 | | |
| 107 | | case 0x07: |
| 108 | | break; |
| 109 | | |
| 110 | | default: |
| 111 | | logerror("Invalid Controller 1 Setting %d\n", controller1); |
| 112 | | break; |
| 113 | | } |
| 114 | | |
| 115 | | c64_keyline[8] = value; |
| 116 | | |
| 117 | | |
| 118 | | value = 0xff; |
| 119 | | switch(controller2) |
| 120 | | { |
| 121 | | case 0x00: |
| 122 | | value &= ~input_port_read(device->machine, "JOY2_1B"); /* Joy2 Directions + Button 1 */ |
| 123 | | break; |
| 124 | | |
| 125 | | case 0x10: |
| 126 | | if (input_port_read(device->machine, "OTHER") & 0x10) /* Paddle4 Button */ |
| 127 | | value &= ~0x08; |
| 128 | | if (input_port_read(device->machine, "OTHER") & 0x20) /* Paddle3 Button */ |
| 129 | | value &= ~0x04; |
| 130 | | break; |
| 131 | | |
| 132 | | case 0x20: |
| 133 | | if (input_port_read(device->machine, "OTHER") & 0x02) /* Mouse Button Left */ |
| 134 | | value &= ~0x10; |
| 135 | | if (input_port_read(device->machine, "OTHER") & 0x01) /* Mouse Button Right */ |
| 136 | | value &= ~0x01; |
| 137 | | break; |
| 138 | | |
| 139 | | case 0x30: |
| 140 | | value &= ~(input_port_read(device->machine, "JOY2_2B") & 0x1f); /* Joy2 Directions + Button 1 */ |
| 141 | | break; |
| 142 | | |
| 143 | | case 0x40: |
| 144 | | /* was there any input on the lightpen? where is it mapped? */ |
| 145 | | // if (input_port_read(device->machine, "OTHER") & 0x04) /* Lightpen Signal */ |
| 146 | | // value &= ?? ; |
| 147 | | break; |
| 148 | | |
| 149 | | case 0x70: |
| 150 | | break; |
| 151 | | |
| 152 | | default: |
| 153 | | logerror("Invalid Controller 2 Setting %d\n", controller2); |
| 154 | | break; |
| 155 | | } |
| 156 | | |
| 157 | | c64_keyline[9] = value; |
| 158 | | |
| 159 | | // vic2_frame_interrupt does nothing so this is not necessary |
| 160 | | // vic2_frame_interrupt (device); |
| 161 | | |
| 162 | | /* check if lightpen has been chosen as input: if so, enable crosshair */ |
| 163 | | timer_set(device->machine, attotime_zero, NULL, 0, lightpen_tick); |
| 164 | | |
| 165 | | set_led_status (1, input_port_read(device->machine, "SPECIAL") & 0x40 ? 1 : 0); /* Shift Lock */ |
| 166 | | set_led_status (0, input_port_read(device->machine, "CTRLSEL") & 0x80 ? 1 : 0); /* Joystick Swap */ |
| 167 | | } |
| 168 | | |
| 169 | | |
| 170 | | |
| 171 | | |
| 172 | | /*********************************************** |
| 173 | | |
| 174 | | Input Ports |
| 175 | | |
| 176 | | ***********************************************/ |
| 177 | | |
| 178 | 23 | /***************************** Commodore 64 **************************************** |
| 179 | 24 | * |
| 180 | 25 | * - common_cbm_keyboard: C64 keyboard; used by C16, C65 and C128 as well |
| r4736 | r4737 | |
| 190 | 35 | ------------------- |
| 191 | 36 | |
| 192 | 37 | CLR INST |
| 193 | | <- 1! 2" 3# 4$ 5% 6& 7' 8( 9) 0 + - £ HOME DEL f 1 |
| 38 | <- 1! 2" 3# 4$ 5% 6& 7' 8( 9) 0 + - £ HOME DEL f 1 |
| 194 | 39 | |
| 195 | 40 | |
| 196 | 41 | CTRL Q W E R T Y U I O P @ * UP RESTORE f 3 |
| r4736 | r4737 | |
| 205 | 50 | SPACEBAR |
| 206 | 51 | |
| 207 | 52 | |
| 208 | | Notes: “C=� is a key with the Commodore logo, “UP� is an arrow pointing up, the “CRSR� keys at the |
| 53 | Notes: "C=" is a key with the Commodore logo, "UP" is an arrow pointing up, the "CRSR" keys at the |
| 209 | 54 | bottom-right corner are used to move the cursor on screen (Up/Down and Left/Right resp.). |
| 210 | 55 | */ |
| 211 | 56 | |
| r4736 | r4737 | |
| 278 | 123 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 279 | 124 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Home Clr") PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(HOME)) |
| 280 | 125 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';') PORT_CHAR(']') |
| 281 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('*') |
| 126 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('*') |
| 282 | 127 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xA3') |
| 283 | 128 | |
| 284 | 129 | PORT_START( "ROW7" ) |
| r4736 | r4737 | |
| 295 | 140 | |
| 296 | 141 | INPUT_PORTS_START( c64_special ) |
| 297 | 142 | PORT_START( "SPECIAL" ) /* special keys */ |
| 298 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 143 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 299 | 144 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 300 | 145 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 301 | 146 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| r4736 | r4737 | |
| 319 | 164 | // PORT_CATEGORY_ITEM( 0x30, "Mouse (Non Proportional) 1350", 23 ) |
| 320 | 165 | PORT_CATEGORY_ITEM( 0x70, "No Device Connected", 27 ) |
| 321 | 166 | PORT_CONFNAME( 0x80, 0x00, "Swap Gameport A and B") PORT_CODE(KEYCODE_F1) PORT_TOGGLE |
| 322 | | PORT_CONFSETTING( 0x00, DEF_STR( No ) ) |
| 323 | | PORT_CONFSETTING( 0x80, DEF_STR( Yes ) ) |
| 167 | PORT_CONFSETTING( 0x00, DEF_STR( No ) ) |
| 168 | PORT_CONFSETTING( 0x80, DEF_STR( Yes ) ) |
| 324 | 169 | |
| 325 | 170 | PORT_START("JOY1_1B") |
| 326 | 171 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_CATEGORY(10) |
| r4736 | r4737 | |
| 328 | 173 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_CATEGORY(10) |
| 329 | 174 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_CATEGORY(10) |
| 330 | 175 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CATEGORY(10) |
| 331 | | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 176 | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 332 | 177 | |
| 333 | 178 | PORT_START("JOY2_1B") |
| 334 | 179 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(20) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) |
| r4736 | r4737 | |
| 336 | 181 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(20) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) |
| 337 | 182 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(20) PORT_CODE(KEYCODE_PGDN) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) |
| 338 | 183 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CATEGORY(20) PORT_CODE(KEYCODE_INSERT) PORT_CODE(JOYCODE_BUTTON1) |
| 339 | | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 184 | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 340 | 185 | |
| 341 | 186 | /* Mouse Commodore 1350 was basically working as a Joystick */ |
| 342 | 187 | PORT_START("JOY1_2B") |
| r4736 | r4737 | |
| 346 | 191 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("Mouse 1350 Right") PORT_CATEGORY(13) |
| 347 | 192 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 1") PORT_CATEGORY(13) |
| 348 | 193 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("Mouse 1350 Button 2") PORT_CATEGORY(13) |
| 349 | | PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 194 | PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 350 | 195 | |
| 351 | 196 | /* Still to verify how many mices you were able to plug into a c64 */ |
| 352 | 197 | /* Only one, for now */ |
| 353 | 198 | PORT_START("JOY2_2B") |
| 354 | | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 199 | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 355 | 200 | /* PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(23) PORT_CODE(KEYCODE_HOME) PORT_CODE(JOYCODE_Y_UP_SWITCH) |
| 356 | 201 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(23) PORT_CODE(KEYCODE_END) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) |
| 357 | 202 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(23) PORT_CODE(KEYCODE_DEL) PORT_CODE(JOYCODE_X_LEFT_SWITCH) |
| r4736 | r4737 | |
| 421 | 266 | STOP LOCK A S D F G H J K L :[ ;] * RETURN f 5 |
| 422 | 267 | |
| 423 | 268 | |
| 424 | | C= SHIFT Z X C V B N M ,< .> /? SHIFT £ = HELP |
| 269 | C= SHIFT Z X C V B N M ,< .> /? SHIFT £ = HELP |
| 425 | 270 | |
| 426 | 271 | |
| 427 | 272 | SPACEBAR |
| r4736 | r4737 | |
| 459 | 304 | ESC 1! 2" 3# 4$ 5% 6& 7' 8( 9) 0^ + - = HOME DEL || @ + - = |
| 460 | 305 | || |
| 461 | 306 | || |
| 462 | | CONTROL Q W E R T Y U I O P @ £ * CONTROL || 7 8 9 * |
| 307 | CONTROL Q W E R T Y U I O P @ £ * CONTROL || 7 8 9 * |
| 463 | 308 | || |
| 464 | 309 | RUN SHIFT || |
| 465 | 310 | STOP LOCK A S D F G H J K L :[ ;] RETURN || 4 5 6 / |
| r4736 | r4737 | |
| 544 | 389 | ESC TAB ALT LOCK HELP FEED DISPLAY SCROLL UP DOWN LEFT RIGHT F1 F3 F5 F7 |
| 545 | 390 | |
| 546 | 391 | CLR INST |
| 547 | | <- 1! 2" 3# 4$ 5% 6& 7' 8( 9) 0 + - £ HOME DEL 7 8 9 + |
| 392 | <- 1! 2" 3# 4$ 5% 6& 7' 8( 9) 0 + - £ HOME DEL 7 8 9 + |
| 548 | 393 | |
| 549 | 394 | |
| 550 | 395 | CONTROL Q W E R T Y U I O P @ * UP RESTORE 4 5 6 - |
| r4736 | r4737 | |
| 565 | 410 | |
| 566 | 411 | INPUT_PORTS_START( c128_special ) |
| 567 | 412 | PORT_START( "SPECIAL" ) /* special keys */ |
| 568 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 413 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 569 | 414 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 570 | 415 | PORT_DIPNAME( 0x20, 0x00, "Caps Lock (switch)") |
| 571 | 416 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| r4736 | r4737 | |
| 619 | 464 | */ |
| 620 | 465 | INPUT_PORTS_START( c65_special ) |
| 621 | 466 | PORT_START( "SPECIAL" ) /* special keys */ |
| 622 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 467 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 623 | 468 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 624 | 469 | PORT_DIPNAME( 0x20, 0x00, "(C65) Caps Lock (switch)") PORT_CODE(KEYCODE_F3) |
| 625 | 470 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| r4736 | r4737 | |
| 899 | 744 | |
| 900 | 745 | |
| 901 | 746 | INPUT_PORTS_START( pet_config ) |
| 902 | | PORT_START("CFG") |
| 747 | PORT_START("CFG") |
| 903 | 748 | PORT_DIPNAME( 0x180, 0x180, "Memory") |
| 904 | 749 | PORT_DIPSETTING( 0x000, "4 KByte" ) |
| 905 | 750 | PORT_DIPSETTING( 0x080, "8 KByte" ) |
| r4736 | r4737 | |
| 933 | 778 | F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 DOWN UP LEFT RIGHT HOME/CLEAR DEL/INST |
| 934 | 779 | |
| 935 | 780 | INS |
| 936 | | ESC 1! 2" 3# 4$ 5% 6^ 7& 8* 9( 0) - =+ <-£ DEL ? CE . / |
| 781 | ESC 1! 2" 3# 4$ 5% 6^ 7& 8* 9( 0) - =+ <-£ DEL ? CE . / |
| 937 | 782 | |
| 938 | 783 | ________ |
| 939 | 784 | TAB Q W E R T Y U I O P [ ] | RETURN | 7 8 9 - |
| r4736 | r4737 | |
| 948 | 793 | CTRL SPACEBAR 0 . 00 r |
| 949 | 794 | |
| 950 | 795 | |
| 951 | | Notes: "C=" is a key with the Commodore logo, Shift+6 produces an arrow pointing up (''^'' above). |
| 796 | Notes: "C=" is a key with the Commodore logo, Shift+6 produces an arrow pointing up ("^" above). |
| 952 | 797 | |
| 953 | 798 | |
| 954 | 799 | */ |
| r4736 | r4737 | |
| 1103 | 948 | --------------------- |
| 1104 | 949 | |
| 1105 | 950 | CLR INST |
| 1106 | | <- 1! 2" 3# 4$ 5% 6& 7' 8( 9) 0 + - £ HOME DEL f 1 |
| 951 | <- 1! 2" 3# 4$ 5% 6& 7' 8( 9) 0 + - £ HOME DEL f 1 |
| 1107 | 952 | |
| 1108 | 953 | |
| 1109 | 954 | CTRL Q W E R T Y U I O P @ * UP RESTORE f 3 |
| r4736 | r4737 | |
| 1118 | 963 | SPACEBAR |
| 1119 | 964 | |
| 1120 | 965 | |
| 1121 | | Notes: “C=� is a key with the Commodore logo, “UP� is an arrow pointing up, the “CRSR� keys at the |
| 966 | Notes: "C=" is a key with the Commodore logo, "UP" is an arrow pointing up, the "CRSR" keys at the |
| 1122 | 967 | bottom-right corner are used to move the cursor on screen (Up/Down and Left/Right respectively). |
| 1123 | 968 | Notice that this is exactly the same layout of C64 keyboard. |
| 1124 | 969 | |
| r4736 | r4737 | |
| 1209 | 1054 | |
| 1210 | 1055 | INPUT_PORTS_START( vic_special ) |
| 1211 | 1056 | PORT_START( "SPECIAL" ) /* special keys */ |
| 1212 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 1057 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) |
| 1213 | 1058 | PORT_DIPNAME( 0x01, 0x00, "Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE |
| 1214 | 1059 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 1215 | 1060 | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
src/mess/machine/cbm.c
| r4736 | r4737 | |
| 8 | 8 | |
| 9 | 9 | /*********************************************** |
| 10 | 10 | |
| 11 | Input Reading - Common Components |
| 12 | |
| 13 | ***********************************************/ |
| 14 | |
| 15 | /* These are needed by c64, c65 and c128, each machine has also additional specific |
| 16 | components in its INTERRUPT_GEN */ |
| 17 | |
| 18 | /* keyboard lines */ |
| 19 | UINT8 c64_keyline[10] = |
| 20 | { |
| 21 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 22 | }; |
| 23 | |
| 24 | |
| 25 | static TIMER_CALLBACK( lightpen_tick ) |
| 26 | { |
| 27 | if ((input_port_read(machine, "CTRLSEL") & 0x07) == 0x04) |
| 28 | { |
| 29 | /* enable lightpen crosshair */ |
| 30 | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); |
| 31 | } |
| 32 | else |
| 33 | { |
| 34 | /* disable lightpen crosshair */ |
| 35 | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | void cbm_common_interrupt( const device_config *device ) |
| 40 | { |
| 41 | int value, i; |
| 42 | int controller1 = input_port_read(device->machine, "CTRLSEL") & 0x07; |
| 43 | int controller2 = input_port_read(device->machine, "CTRLSEL") & 0x70; |
| 44 | static const char *const c64ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" }; |
| 45 | |
| 46 | /* Lines 0-7 : common keyboard */ |
| 47 | for (i = 0; i < 8; i++) |
| 48 | { |
| 49 | value = 0xff; |
| 50 | value &= ~input_port_read(device->machine, c64ports[i]); |
| 51 | |
| 52 | /* Shift Lock is mapped on Left Shift */ |
| 53 | if ((i == 1) && (input_port_read(device->machine, "SPECIAL") & 0x40)) |
| 54 | value &= ~0x80; |
| 55 | |
| 56 | c64_keyline[i] = value; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | value = 0xff; |
| 61 | switch(controller1) |
| 62 | { |
| 63 | case 0x00: |
| 64 | value &= ~input_port_read(device->machine, "JOY1_1B"); /* Joy1 Directions + Button 1 */ |
| 65 | break; |
| 66 | |
| 67 | case 0x01: |
| 68 | if (input_port_read(device->machine, "OTHER") & 0x40) /* Paddle2 Button */ |
| 69 | value &= ~0x08; |
| 70 | if (input_port_read(device->machine, "OTHER") & 0x80) /* Paddle1 Button */ |
| 71 | value &= ~0x04; |
| 72 | break; |
| 73 | |
| 74 | case 0x02: |
| 75 | if (input_port_read(device->machine, "OTHER") & 0x02) /* Mouse Button Left */ |
| 76 | value &= ~0x10; |
| 77 | if (input_port_read(device->machine, "OTHER") & 0x01) /* Mouse Button Right */ |
| 78 | value &= ~0x01; |
| 79 | break; |
| 80 | |
| 81 | case 0x03: |
| 82 | value &= ~(input_port_read(device->machine, "JOY1_2B") & 0x1f); /* Joy1 Directions + Button 1 */ |
| 83 | break; |
| 84 | |
| 85 | case 0x04: |
| 86 | /* was there any input on the lightpen? where is it mapped? */ |
| 87 | // if (input_port_read(device->machine, "OTHER") & 0x04) /* Lightpen Signal */ |
| 88 | // value &= ?? ; |
| 89 | break; |
| 90 | |
| 91 | case 0x07: |
| 92 | break; |
| 93 | |
| 94 | default: |
| 95 | logerror("Invalid Controller 1 Setting %d\n", controller1); |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | c64_keyline[8] = value; |
| 100 | |
| 101 | |
| 102 | value = 0xff; |
| 103 | switch(controller2) |
| 104 | { |
| 105 | case 0x00: |
| 106 | value &= ~input_port_read(device->machine, "JOY2_1B"); /* Joy2 Directions + Button 1 */ |
| 107 | break; |
| 108 | |
| 109 | case 0x10: |
| 110 | if (input_port_read(device->machine, "OTHER") & 0x10) /* Paddle4 Button */ |
| 111 | value &= ~0x08; |
| 112 | if (input_port_read(device->machine, "OTHER") & 0x20) /* Paddle3 Button */ |
| 113 | value &= ~0x04; |
| 114 | break; |
| 115 | |
| 116 | case 0x20: |
| 117 | if (input_port_read(device->machine, "OTHER") & 0x02) /* Mouse Button Left */ |
| 118 | value &= ~0x10; |
| 119 | if (input_port_read(device->machine, "OTHER") & 0x01) /* Mouse Button Right */ |
| 120 | value &= ~0x01; |
| 121 | break; |
| 122 | |
| 123 | case 0x30: |
| 124 | value &= ~(input_port_read(device->machine, "JOY2_2B") & 0x1f); /* Joy2 Directions + Button 1 */ |
| 125 | break; |
| 126 | |
| 127 | case 0x40: |
| 128 | /* was there any input on the lightpen? where is it mapped? */ |
| 129 | // if (input_port_read(device->machine, "OTHER") & 0x04) /* Lightpen Signal */ |
| 130 | // value &= ?? ; |
| 131 | break; |
| 132 | |
| 133 | case 0x70: |
| 134 | break; |
| 135 | |
| 136 | default: |
| 137 | logerror("Invalid Controller 2 Setting %d\n", controller2); |
| 138 | break; |
| 139 | } |
| 140 | |
| 141 | c64_keyline[9] = value; |
| 142 | |
| 143 | // vic2_frame_interrupt does nothing so this is not necessary |
| 144 | // vic2_frame_interrupt (device); |
| 145 | |
| 146 | /* check if lightpen has been chosen as input: if so, enable crosshair */ |
| 147 | timer_set(device->machine, attotime_zero, NULL, 0, lightpen_tick); |
| 148 | |
| 149 | set_led_status (1, input_port_read(device->machine, "SPECIAL") & 0x40 ? 1 : 0); /* Shift Lock */ |
| 150 | set_led_status (0, input_port_read(device->machine, "CTRLSEL") & 0x80 ? 1 : 0); /* Joystick Swap */ |
| 151 | } |
| 152 | |
| 153 | |
| 154 | /*********************************************** |
| 155 | |
| 156 | CIA Common Handlers |
| 157 | |
| 158 | ***********************************************/ |
| 159 | |
| 160 | /* These are shared by c64, c65 and c128. c65 and c128 also have additional specific |
| 161 | components (to select/read additional keyboard lines) */ |
| 162 | |
| 163 | /* |
| 164 | * CIA 0 - Port A |
| 165 | * bits 7-0 keyboard line select |
| 166 | * bits 7,6: paddle select( 01 port a, 10 port b) |
| 167 | * bit 4: joystick a fire button |
| 168 | * bits 3,2: Paddles port a fire button |
| 169 | * bits 3-0: joystick a direction |
| 170 | * |
| 171 | * CIA 0 - Port B |
| 172 | * bits 7-0: keyboard raw values |
| 173 | * bit 4: joystick b fire button, lightpen select |
| 174 | * bits 3,2: paddle b fire buttons (left,right) |
| 175 | * bits 3-0: joystick b direction |
| 176 | * |
| 177 | * flag cassette read input, serial request in |
| 178 | * irq to irq connected |
| 179 | */ |
| 180 | |
| 181 | UINT8 common_cia0_port_a_r( const device_config *device, UINT8 output_b ) |
| 182 | { |
| 183 | UINT8 value = 0xff; |
| 184 | |
| 185 | if (!(output_b & 0x80)) |
| 186 | { |
| 187 | UINT8 t = 0xff; |
| 188 | if (!(c64_keyline[7] & 0x80)) t &= ~0x80; |
| 189 | if (!(c64_keyline[6] & 0x80)) t &= ~0x40; |
| 190 | if (!(c64_keyline[5] & 0x80)) t &= ~0x20; |
| 191 | if (!(c64_keyline[4] & 0x80)) t &= ~0x10; |
| 192 | if (!(c64_keyline[3] & 0x80)) t &= ~0x08; |
| 193 | if (!(c64_keyline[2] & 0x80)) t &= ~0x04; |
| 194 | if (!(c64_keyline[1] & 0x80)) t &= ~0x02; |
| 195 | if (!(c64_keyline[0] & 0x80)) t &= ~0x01; |
| 196 | value &= t; |
| 197 | } |
| 198 | |
| 199 | if (!(output_b & 0x40)) |
| 200 | { |
| 201 | UINT8 t = 0xff; |
| 202 | if (!(c64_keyline[7] & 0x40)) t &= ~0x80; |
| 203 | if (!(c64_keyline[6] & 0x40)) t &= ~0x40; |
| 204 | if (!(c64_keyline[5] & 0x40)) t &= ~0x20; |
| 205 | if (!(c64_keyline[4] & 0x40)) t &= ~0x10; |
| 206 | if (!(c64_keyline[3] & 0x40)) t &= ~0x08; |
| 207 | if (!(c64_keyline[2] & 0x40)) t &= ~0x04; |
| 208 | if (!(c64_keyline[1] & 0x40)) t &= ~0x02; |
| 209 | if (!(c64_keyline[0] & 0x40)) t &= ~0x01; |
| 210 | value &= t; |
| 211 | } |
| 212 | |
| 213 | if (!(output_b & 0x20)) |
| 214 | { |
| 215 | UINT8 t = 0xff; |
| 216 | if (!(c64_keyline[7] & 0x20)) t &= ~0x80; |
| 217 | if (!(c64_keyline[6] & 0x20)) t &= ~0x40; |
| 218 | if (!(c64_keyline[5] & 0x20)) t &= ~0x20; |
| 219 | if (!(c64_keyline[4] & 0x20)) t &= ~0x10; |
| 220 | if (!(c64_keyline[3] & 0x20)) t &= ~0x08; |
| 221 | if (!(c64_keyline[2] & 0x20)) t &= ~0x04; |
| 222 | if (!(c64_keyline[1] & 0x20)) t &= ~0x02; |
| 223 | if (!(c64_keyline[0] & 0x20)) t &= ~0x01; |
| 224 | value &= t; |
| 225 | } |
| 226 | |
| 227 | if (!(output_b & 0x10)) |
| 228 | { |
| 229 | UINT8 t = 0xff; |
| 230 | if (!(c64_keyline[7] & 0x10)) t &= ~0x80; |
| 231 | if (!(c64_keyline[6] & 0x10)) t &= ~0x40; |
| 232 | if (!(c64_keyline[5] & 0x10)) t &= ~0x20; |
| 233 | if (!(c64_keyline[4] & 0x10)) t &= ~0x10; |
| 234 | if (!(c64_keyline[3] & 0x10)) t &= ~0x08; |
| 235 | if (!(c64_keyline[2] & 0x10)) t &= ~0x04; |
| 236 | if (!(c64_keyline[1] & 0x10)) t &= ~0x02; |
| 237 | if (!(c64_keyline[0] & 0x10)) t &= ~0x01; |
| 238 | value &= t; |
| 239 | } |
| 240 | |
| 241 | if (!(output_b & 0x08)) |
| 242 | { |
| 243 | UINT8 t = 0xff; |
| 244 | if (!(c64_keyline[7] & 0x08)) t &= ~0x80; |
| 245 | if (!(c64_keyline[6] & 0x08)) t &= ~0x40; |
| 246 | if (!(c64_keyline[5] & 0x08)) t &= ~0x20; |
| 247 | if (!(c64_keyline[4] & 0x08)) t &= ~0x10; |
| 248 | if (!(c64_keyline[3] & 0x08)) t &= ~0x08; |
| 249 | if (!(c64_keyline[2] & 0x08)) t &= ~0x04; |
| 250 | if (!(c64_keyline[1] & 0x08)) t &= ~0x02; |
| 251 | if (!(c64_keyline[0] & 0x08)) t &= ~0x01; |
| 252 | value &= t; |
| 253 | } |
| 254 | |
| 255 | if (!(output_b & 0x04)) |
| 256 | { |
| 257 | UINT8 t = 0xff; |
| 258 | if (!(c64_keyline[7] & 0x04)) t &= ~0x80; |
| 259 | if (!(c64_keyline[6] & 0x04)) t &= ~0x40; |
| 260 | if (!(c64_keyline[5] & 0x04)) t &= ~0x20; |
| 261 | if (!(c64_keyline[4] & 0x04)) t &= ~0x10; |
| 262 | if (!(c64_keyline[3] & 0x04)) t &= ~0x08; |
| 263 | if (!(c64_keyline[2] & 0x04)) t &= ~0x04; |
| 264 | if (!(c64_keyline[1] & 0x04)) t &= ~0x02; |
| 265 | if (!(c64_keyline[0] & 0x04)) t &= ~0x01; |
| 266 | value &= t; |
| 267 | } |
| 268 | |
| 269 | if (!(output_b & 0x02)) |
| 270 | { |
| 271 | UINT8 t = 0xff; |
| 272 | if (!(c64_keyline[7] & 0x02)) t &= ~0x80; |
| 273 | if (!(c64_keyline[6] & 0x02)) t &= ~0x40; |
| 274 | if (!(c64_keyline[5] & 0x02)) t &= ~0x20; |
| 275 | if (!(c64_keyline[4] & 0x02)) t &= ~0x10; |
| 276 | if (!(c64_keyline[3] & 0x02)) t &= ~0x08; |
| 277 | if (!(c64_keyline[2] & 0x02)) t &= ~0x04; |
| 278 | if (!(c64_keyline[1] & 0x02)) t &= ~0x02; |
| 279 | if (!(c64_keyline[0] & 0x02)) t &= ~0x01; |
| 280 | value &= t; |
| 281 | } |
| 282 | |
| 283 | if (!(output_b & 0x01)) |
| 284 | { |
| 285 | UINT8 t = 0xff; |
| 286 | if (!(c64_keyline[7] & 0x01)) t &= ~0x80; |
| 287 | if (!(c64_keyline[6] & 0x01)) t &= ~0x40; |
| 288 | if (!(c64_keyline[5] & 0x01)) t &= ~0x20; |
| 289 | if (!(c64_keyline[4] & 0x01)) t &= ~0x10; |
| 290 | if (!(c64_keyline[3] & 0x01)) t &= ~0x08; |
| 291 | if (!(c64_keyline[2] & 0x01)) t &= ~0x04; |
| 292 | if (!(c64_keyline[1] & 0x01)) t &= ~0x02; |
| 293 | if (!(c64_keyline[0] & 0x01)) t &= ~0x01; |
| 294 | value &= t; |
| 295 | } |
| 296 | |
| 297 | if ( input_port_read(device->machine, "CTRLSEL") & 0x80 ) |
| 298 | value &= c64_keyline[8]; |
| 299 | else |
| 300 | value &= c64_keyline[9]; |
| 301 | |
| 302 | return value; |
| 303 | } |
| 304 | |
| 305 | UINT8 common_cia0_port_b_r( const device_config *device, UINT8 output_a ) |
| 306 | { |
| 307 | UINT8 value = 0xff; |
| 308 | |
| 309 | if (!(output_a & 0x80)) value &= c64_keyline[7]; |
| 310 | if (!(output_a & 0x40)) value &= c64_keyline[6]; |
| 311 | if (!(output_a & 0x20)) value &= c64_keyline[5]; |
| 312 | if (!(output_a & 0x10)) value &= c64_keyline[4]; |
| 313 | if (!(output_a & 0x08)) value &= c64_keyline[3]; |
| 314 | if (!(output_a & 0x04)) value &= c64_keyline[2]; |
| 315 | if (!(output_a & 0x02)) value &= c64_keyline[1]; |
| 316 | if (!(output_a & 0x01)) value &= c64_keyline[0]; |
| 317 | |
| 318 | if ( input_port_read(device->machine, "CTRLSEL") & 0x80 ) |
| 319 | value &= c64_keyline[9]; |
| 320 | else |
| 321 | value &= c64_keyline[8]; |
| 322 | |
| 323 | return value; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | /*********************************************** |
| 328 | |
| 11 | 329 | CBM Quickloads |
| 12 | 330 | |
| 13 | 331 | ***********************************************/ |
src/mess/machine/c64.c
| r4736 | r4737 | |
| 26 | 26 | #include "includes/cbmserb.h" |
| 27 | 27 | #include "includes/cbmdrive.h" |
| 28 | 28 | #include "includes/vc1541.h" |
| 29 | | #include "cbmipt.h" /* we need cbm_common_interrupt & c64_keyline for input reading */ |
| 30 | 29 | |
| 31 | 30 | #include "includes/c64.h" |
| 32 | | #include "includes/c128.h" /* we need c128_bankswitch_64 in MACHINE_START */ |
| 33 | 31 | |
| 34 | 32 | #include "devices/cassette.h" |
| 35 | 33 | #include "devices/cartslot.h" |
| r4736 | r4737 | |
| 45 | 43 | } \ |
| 46 | 44 | } while (0) |
| 47 | 45 | |
| 48 | | /* still needed for CIA interfaces, will be factored out soon... */ |
| 49 | | UINT8 c65_6511_port = 0xff; |
| 50 | | static UINT8 c65_keyline = { 0xff }; |
| 51 | | static UINT8 c128_keyline[3] = {0xff, 0xff, 0xff}; |
| 52 | 46 | |
| 53 | 47 | /* expansion port lines input */ |
| 54 | 48 | int c64_pal = 0; |
| 55 | 49 | UINT8 c64_game = 1, c64_exrom = 1; |
| 56 | 50 | |
| 57 | 51 | /* cpu port */ |
| 58 | | int c128_va1617; |
| 59 | 52 | UINT8 *c64_vicaddr, *c128_vicaddr; |
| 60 | 53 | UINT8 *c64_memory; |
| 61 | 54 | UINT8 *c64_colorram; |
| r4736 | r4737 | |
| 83 | 76 | return !strncmp(machine->gamedrv->name, "c65", 3); |
| 84 | 77 | } |
| 85 | 78 | |
| 86 | | static int is_c128(running_machine *machine) |
| 87 | | { |
| 88 | | return !strncmp(machine->gamedrv->name, "c128", 4); |
| 89 | | } |
| 90 | | |
| 91 | | /* Needed to initialize correctly the floppy drive emulation */ |
| 92 | | /*static int is_c128d(running_machine *machine) |
| 93 | | { |
| 94 | | return !strncmp(machine->gamedrv->name, "c128d", 5); |
| 95 | | }*/ |
| 96 | | |
| 97 | 79 | static void c64_nmi(running_machine *machine) |
| 98 | 80 | { |
| 99 | 81 | static int nmilevel = 0; |
| r4736 | r4737 | |
| 109 | 91 | } |
| 110 | 92 | |
| 111 | 93 | |
| 94 | /*********************************************** |
| 95 | |
| 96 | CIA Interfaces |
| 97 | |
| 98 | ***********************************************/ |
| 99 | |
| 112 | 100 | /* |
| 113 | | * cia 0 |
| 114 | | * port a |
| 115 | | * 7-0 keyboard line select |
| 116 | | * 7,6: paddle select( 01 port a, 10 port b) |
| 117 | | * 4: joystick a fire button |
| 118 | | * 3,2: Paddles port a fire button |
| 119 | | * 3-0: joystick a direction |
| 120 | | * port b |
| 121 | | * 7-0: keyboard raw values |
| 122 | | * 4: joystick b fire button, lightpen select |
| 123 | | * 3,2: paddle b fire buttons (left,right) |
| 124 | | * 3-0: joystick b direction |
| 125 | | * flag cassette read input, serial request in |
| 126 | | * irq to irq connected |
| 101 | * CIA 0 - Port A keyboard line select |
| 102 | * CIA 0 - Port B keyboard line read |
| 103 | * |
| 104 | * flag cassette read input, serial request in |
| 105 | * irq to irq connected |
| 106 | * |
| 107 | * see machine/cbm.c |
| 127 | 108 | */ |
| 109 | |
| 128 | 110 | static READ8_DEVICE_HANDLER( c64_cia0_port_a_r ) |
| 129 | 111 | { |
| 130 | | UINT8 value = 0xff; |
| 131 | 112 | UINT8 cia0portb = cia_get_output_b(devtag_get_device(device->machine, "cia_0")); |
| 132 | 113 | |
| 133 | | if (!(cia0portb & 0x80)) |
| 134 | | { |
| 135 | | UINT8 t = 0xff; |
| 136 | | if (!(c64_keyline[7] & 0x80)) t &= ~0x80; |
| 137 | | if (!(c64_keyline[6] & 0x80)) t &= ~0x40; |
| 138 | | if (!(c64_keyline[5] & 0x80)) t &= ~0x20; |
| 139 | | if (!(c64_keyline[4] & 0x80)) t &= ~0x10; |
| 140 | | if (!(c64_keyline[3] & 0x80)) t &= ~0x08; |
| 141 | | if (!(c64_keyline[2] & 0x80)) t &= ~0x04; |
| 142 | | if (!(c64_keyline[1] & 0x80)) t &= ~0x02; |
| 143 | | if (!(c64_keyline[0] & 0x80)) t &= ~0x01; |
| 144 | | value &= t; |
| 145 | | } |
| 146 | | |
| 147 | | if (!(cia0portb & 0x40)) |
| 148 | | { |
| 149 | | UINT8 t = 0xff; |
| 150 | | if (!(c64_keyline[7] & 0x40)) t &= ~0x80; |
| 151 | | if (!(c64_keyline[6] & 0x40)) t &= ~0x40; |
| 152 | | if (!(c64_keyline[5] & 0x40)) t &= ~0x20; |
| 153 | | if (!(c64_keyline[4] & 0x40)) t &= ~0x10; |
| 154 | | if (!(c64_keyline[3] & 0x40)) t &= ~0x08; |
| 155 | | if (!(c64_keyline[2] & 0x40)) t &= ~0x04; |
| 156 | | if (!(c64_keyline[1] & 0x40)) t &= ~0x02; |
| 157 | | if (!(c64_keyline[0] & 0x40)) t &= ~0x01; |
| 158 | | value &= t; |
| 159 | | } |
| 160 | | |
| 161 | | if (!(cia0portb & 0x20)) |
| 162 | | { |
| 163 | | UINT8 t = 0xff; |
| 164 | | if (!(c64_keyline[7] & 0x20)) t &= ~0x80; |
| 165 | | if (!(c64_keyline[6] & 0x20)) t &= ~0x40; |
| 166 | | if (!(c64_keyline[5] & 0x20)) t &= ~0x20; |
| 167 | | if (!(c64_keyline[4] & 0x20)) t &= ~0x10; |
| 168 | | if (!(c64_keyline[3] & 0x20)) t &= ~0x08; |
| 169 | | if (!(c64_keyline[2] & 0x20)) t &= ~0x04; |
| 170 | | if (!(c64_keyline[1] & 0x20)) t &= ~0x02; |
| 171 | | if (!(c64_keyline[0] & 0x20)) t &= ~0x01; |
| 172 | | value &= t; |
| 173 | | } |
| 174 | | |
| 175 | | if (!(cia0portb & 0x10)) |
| 176 | | { |
| 177 | | UINT8 t = 0xff; |
| 178 | | if (!(c64_keyline[7] & 0x10)) t &= ~0x80; |
| 179 | | if (!(c64_keyline[6] & 0x10)) t &= ~0x40; |
| 180 | | if (!(c64_keyline[5] & 0x10)) t &= ~0x20; |
| 181 | | if (!(c64_keyline[4] & 0x10)) t &= ~0x10; |
| 182 | | if (!(c64_keyline[3] & 0x10)) t &= ~0x08; |
| 183 | | if (!(c64_keyline[2] & 0x10)) t &= ~0x04; |
| 184 | | if (!(c64_keyline[1] & 0x10)) t &= ~0x02; |
| 185 | | if (!(c64_keyline[0] & 0x10)) t &= ~0x01; |
| 186 | | value &= t; |
| 187 | | } |
| 188 | | |
| 189 | | if (!(cia0portb & 0x08)) |
| 190 | | { |
| 191 | | UINT8 t = 0xff; |
| 192 | | if (!(c64_keyline[7] & 0x08)) t &= ~0x80; |
| 193 | | if (!(c64_keyline[6] & 0x08)) t &= ~0x40; |
| 194 | | if (!(c64_keyline[5] & 0x08)) t &= ~0x20; |
| 195 | | if (!(c64_keyline[4] & 0x08)) t &= ~0x10; |
| 196 | | if (!(c64_keyline[3] & 0x08)) t &= ~0x08; |
| 197 | | if (!(c64_keyline[2] & 0x08)) t &= ~0x04; |
| 198 | | if (!(c64_keyline[1] & 0x08)) t &= ~0x02; |
| 199 | | if (!(c64_keyline[0] & 0x08)) t &= ~0x01; |
| 200 | | value &= t; |
| 201 | | } |
| 202 | | |
| 203 | | if (!(cia0portb & 0x04)) |
| 204 | | { |
| 205 | | UINT8 t = 0xff; |
| 206 | | if (!(c64_keyline[7] & 0x04)) t &= ~0x80; |
| 207 | | if (!(c64_keyline[6] & 0x04)) t &= ~0x40; |
| 208 | | if (!(c64_keyline[5] & 0x04)) t &= ~0x20; |
| 209 | | if (!(c64_keyline[4] & 0x04)) t &= ~0x10; |
| 210 | | if (!(c64_keyline[3] & 0x04)) t &= ~0x08; |
| 211 | | if (!(c64_keyline[2] & 0x04)) t &= ~0x04; |
| 212 | | if (!(c64_keyline[1] & 0x04)) t &= ~0x02; |
| 213 | | if (!(c64_keyline[0] & 0x04)) t &= ~0x01; |
| 214 | | value &= t; |
| 215 | | } |
| 216 | | |
| 217 | | if (!(cia0portb & 0x02)) |
| 218 | | { |
| 219 | | UINT8 t = 0xff; |
| 220 | | if (!(c64_keyline[7] & 0x02)) t &= ~0x80; |
| 221 | | if (!(c64_keyline[6] & 0x02)) t &= ~0x40; |
| 222 | | if (!(c64_keyline[5] & 0x02)) t &= ~0x20; |
| 223 | | if (!(c64_keyline[4] & 0x02)) t &= ~0x10; |
| 224 | | if (!(c64_keyline[3] & 0x02)) t &= ~0x08; |
| 225 | | if (!(c64_keyline[2] & 0x02)) t &= ~0x04; |
| 226 | | if (!(c64_keyline[1] & 0x02)) t &= ~0x02; |
| 227 | | if (!(c64_keyline[0] & 0x02)) t &= ~0x01; |
| 228 | | value &= t; |
| 229 | | } |
| 230 | | |
| 231 | | if (!(cia0portb & 0x01)) |
| 232 | | { |
| 233 | | UINT8 t = 0xff; |
| 234 | | if (!(c64_keyline[7] & 0x01)) t &= ~0x80; |
| 235 | | if (!(c64_keyline[6] & 0x01)) t &= ~0x40; |
| 236 | | if (!(c64_keyline[5] & 0x01)) t &= ~0x20; |
| 237 | | if (!(c64_keyline[4] & 0x01)) t &= ~0x10; |
| 238 | | if (!(c64_keyline[3] & 0x01)) t &= ~0x08; |
| 239 | | if (!(c64_keyline[2] & 0x01)) t &= ~0x04; |
| 240 | | if (!(c64_keyline[1] & 0x01)) t &= ~0x02; |
| 241 | | if (!(c64_keyline[0] & 0x01)) t &= ~0x01; |
| 242 | | value &= t; |
| 243 | | } |
| 244 | | |
| 245 | | if ( input_port_read(device->machine, "CTRLSEL") & 0x80 ) |
| 246 | | value &= c64_keyline[8]; |
| 247 | | else |
| 248 | | value &= c64_keyline[9]; |
| 249 | | |
| 250 | | return value; |
| 114 | return common_cia0_port_a_r(device, cia0portb); |
| 251 | 115 | } |
| 252 | 116 | |
| 253 | 117 | static READ8_DEVICE_HANDLER( c64_cia0_port_b_r ) |
| 254 | 118 | { |
| 255 | | UINT8 value = 0xff; |
| 256 | 119 | UINT8 cia0porta = cia_get_output_a(devtag_get_device(device->machine, "cia_0")); |
| 257 | 120 | |
| 258 | | if (!(cia0porta & 0x80)) value &= c64_keyline[7]; |
| 259 | | if (!(cia0porta & 0x40)) value &= c64_keyline[6]; |
| 260 | | if (!(cia0porta & 0x20)) value &= c64_keyline[5]; |
| 261 | | if (!(cia0porta & 0x10)) value &= c64_keyline[4]; |
| 262 | | if (!(cia0porta & 0x08)) value &= c64_keyline[3]; |
| 263 | | if (!(cia0porta & 0x04)) value &= c64_keyline[2]; |
| 264 | | if (!(cia0porta & 0x02)) value &= c64_keyline[1]; |
| 265 | | if (!(cia0porta & 0x01)) value &= c64_keyline[0]; |
| 266 | | |
| 267 | | if ( input_port_read(device->machine, "CTRLSEL") & 0x80 ) |
| 268 | | value &= c64_keyline[9]; |
| 269 | | else |
| 270 | | value &= c64_keyline[8]; |
| 271 | | |
| 272 | | if (is_c128(device->machine)) |
| 273 | | { |
| 274 | | if (!vic2e_k0_r ()) |
| 275 | | value &= c128_keyline[0]; |
| 276 | | if (!vic2e_k1_r ()) |
| 277 | | value &= c128_keyline[1]; |
| 278 | | if (!vic2e_k2_r ()) |
| 279 | | value &= c128_keyline[2]; |
| 280 | | } |
| 281 | | if (is_c65(device->machine)) |
| 282 | | { |
| 283 | | if (!(c65_6511_port & 0x02)) |
| 284 | | value &= c65_keyline; |
| 285 | | } |
| 286 | | |
| 287 | | return value; |
| 121 | return common_cia0_port_b_r(device, cia0porta); |
| 288 | 122 | } |
| 289 | 123 | |
| 290 | 124 | static WRITE8_DEVICE_HANDLER( c64_cia0_port_b_w ) |
| 291 | 125 | { |
| 292 | | vic2_lightpen_write (data & 0x10); |
| 126 | vic2_lightpen_write(data & 0x10); |
| 293 | 127 | } |
| 294 | 128 | |
| 295 | 129 | static void c64_irq (running_machine *machine, int level) |
| r4736 | r4737 | |
| 299 | 133 | if (level != old_level) |
| 300 | 134 | { |
| 301 | 135 | DBG_LOG (3, "mos6510", ("irq %s\n", level ? "start" : "end")); |
| 302 | | if (is_c128(machine)) |
| 303 | | { |
| 304 | | if (0) // && (cpu_getactivecpu() == 0)) |
| 305 | | { |
| 306 | | cputag_set_input_line(machine, "maincpu", 0, level); |
| 307 | | } |
| 308 | | else |
| 309 | | { |
| 310 | | cputag_set_input_line(machine, "m8502", M6510_IRQ_LINE, level); |
| 311 | | } |
| 312 | | } |
| 313 | | else |
| 314 | | { |
| 315 | | cputag_set_input_line(machine, "maincpu", M6510_IRQ_LINE, level); |
| 316 | | } |
| 136 | cputag_set_input_line(machine, "maincpu", M6510_IRQ_LINE, level); |
| 317 | 137 | old_level = level; |
| 318 | 138 | } |
| 319 | 139 | } |
| r4736 | r4737 | |
| 335 | 155 | #endif |
| 336 | 156 | } |
| 337 | 157 | |
| 158 | const cia6526_interface c64_ntsc_cia0 = |
| 159 | { |
| 160 | DEVCB_LINE(c64_cia0_interrupt), |
| 161 | DEVCB_NULL, /* pc_func */ |
| 162 | 60, |
| 163 | |
| 164 | { |
| 165 | { DEVCB_HANDLER(c64_cia0_port_a_r), DEVCB_NULL }, |
| 166 | { DEVCB_HANDLER(c64_cia0_port_b_r), DEVCB_HANDLER(c64_cia0_port_b_w) } |
| 167 | } |
| 168 | }; |
| 169 | |
| 170 | const cia6526_interface c64_pal_cia0 = |
| 171 | { |
| 172 | DEVCB_LINE(c64_cia0_interrupt), |
| 173 | DEVCB_NULL, /* pc_func */ |
| 174 | 50, |
| 175 | |
| 176 | { |
| 177 | { DEVCB_HANDLER(c64_cia0_port_a_r), DEVCB_NULL }, |
| 178 | { DEVCB_HANDLER(c64_cia0_port_b_r), DEVCB_HANDLER(c64_cia0_port_b_w) } |
| 179 | } |
| 180 | }; |
| 181 | |
| 182 | |
| 338 | 183 | /* |
| 339 | | * cia 1 |
| 340 | | * port a |
| 341 | | * 7 serial bus data input |
| 342 | | * 6 serial bus clock input |
| 343 | | * 5 serial bus data output |
| 344 | | * 4 serial bus clock output |
| 345 | | * 3 serial bus atn output |
| 346 | | * 2 rs232 data output |
| 347 | | * 1-0 vic-chip system memory bank select |
| 184 | * CIA 1 - Port A |
| 185 | * bit 7 serial bus data input |
| 186 | * bit 6 serial bus clock input |
| 187 | * bit 5 serial bus data output |
| 188 | * bit 4 serial bus clock output |
| 189 | * bit 3 serial bus atn output |
| 190 | * bit 2 rs232 data output |
| 191 | * bits 1-0 vic-chip system memory bank select |
| 348 | 192 | * |
| 349 | | * port b |
| 350 | | * 7 user rs232 data set ready |
| 351 | | * 6 user rs232 clear to send |
| 352 | | * 5 user |
| 353 | | * 4 user rs232 carrier detect |
| 354 | | * 3 user rs232 ring indicator |
| 355 | | * 2 user rs232 data terminal ready |
| 356 | | * 1 user rs232 request to send |
| 357 | | * 0 user rs232 received data |
| 193 | * CIA 1 - Port B |
| 194 | * bit 7 user rs232 data set ready |
| 195 | * bit 6 user rs232 clear to send |
| 196 | * bit 5 user |
| 197 | * bit 4 user rs232 carrier detect |
| 198 | * bit 3 user rs232 ring indicator |
| 199 | * bit 2 user rs232 data terminal ready |
| 200 | * bit 1 user rs232 request to send |
| 201 | * bit 0 user rs232 received data |
| 202 | * |
| 358 | 203 | * flag restore key or rs232 received data input |
| 359 | 204 | * irq to nmi connected ? |
| 360 | 205 | */ |
| r4736 | r4737 | |
| 379 | 224 | cbm_serial_data_write (device->machine, serial_data = !(data & 0x20)); |
| 380 | 225 | cbm_serial_atn_write (device->machine, serial_atn = !(data & 0x08)); |
| 381 | 226 | c64_vicaddr = c64_memory + helper[data & 0x03]; |
| 382 | | if (is_c128(device->machine)) |
| 383 | | { |
| 384 | | c128_vicaddr = c64_memory + helper[data & 0x03] + c128_va1617; |
| 385 | | } |
| 386 | 227 | } |
| 387 | 228 | |
| 388 | 229 | static void c64_cia1_interrupt (const device_config *device, int level) |
| r4736 | r4737 | |
| 390 | 231 | c64_nmi(device->machine); |
| 391 | 232 | } |
| 392 | 233 | |
| 393 | | const cia6526_interface c64_ntsc_cia0 = |
| 394 | | { |
| 395 | | DEVCB_LINE(c64_cia0_interrupt), |
| 396 | | DEVCB_NULL, /* pc_func */ |
| 397 | | 60, |
| 398 | | |
| 399 | | { |
| 400 | | { DEVCB_HANDLER(c64_cia0_port_a_r), DEVCB_NULL }, |
| 401 | | { DEVCB_HANDLER(c64_cia0_port_b_r), DEVCB_HANDLER(c64_cia0_port_b_w) } |
| 402 | | } |
| 403 | | }; |
| 404 | | |
| 405 | | const cia6526_interface c64_pal_cia0 = |
| 406 | | { |
| 407 | | DEVCB_LINE(c64_cia0_interrupt), |
| 408 | | DEVCB_NULL, /* pc_func */ |
| 409 | | 50, |
| 410 | | |
| 411 | | { |
| 412 | | { DEVCB_HANDLER(c64_cia0_port_a_r), DEVCB_NULL }, |
| 413 | | { DEVCB_HANDLER(c64_cia0_port_b_r), DEVCB_HANDLER(c64_cia0_port_b_w) } |
| 414 | | } |
| 415 | | }; |
| 416 | | |
| 417 | 234 | const cia6526_interface c64_ntsc_cia1 = |
| 418 | 235 | { |
| 419 | 236 | DEVCB_LINE(c64_cia1_interrupt), |
| r4736 | r4737 | |
| 438 | 255 | } |
| 439 | 256 | }; |
| 440 | 257 | |
| 258 | /*********************************************** |
| 259 | |
| 260 | Memory Handlers |
| 261 | |
| 262 | ***********************************************/ |
| 263 | |
| 441 | 264 | static UINT8 *c64_io_ram_w_ptr; |
| 442 | 265 | static UINT8 *c64_io_ram_r_ptr; |
| 443 | 266 | |
| r4736 | r4737 | |
| 1052 | 875 | |
| 1053 | 876 | void c64_common_init_machine (running_machine *machine) |
| 1054 | 877 | { |
| 1055 | | if (is_sx64 /* || is_c128d(machine) */) |
| 878 | if (is_sx64) |
| 1056 | 879 | { |
| 1057 | 880 | cbm_serial_config(machine, &cbm_emu_drive_interface); |
| 1058 | | drive_reset (); |
| 881 | drive_reset(); |
| 1059 | 882 | } |
| 1060 | 883 | |
| 1061 | 884 | else if (c64_cia1_on) |
| r4736 | r4737 | |
| 1078 | 901 | c64_io_mirror = auto_alloc_array(machine, UINT8, 0x1000 ); |
| 1079 | 902 | c64_common_init_machine (machine); |
| 1080 | 903 | |
| 1081 | | if (is_c128(machine)) |
| 1082 | | c128_bankswitch_64(machine, 1); |
| 1083 | | |
| 1084 | 904 | if (!ultimax) |
| 1085 | 905 | c64_bankswitch(machine, 1); |
| 1086 | 906 | } |