src/mess/machine/pet.c
| r3210 | r3211 | |
| 17 | 17 | #include "includes/pet.h" |
| 18 | 18 | |
| 19 | 19 | #include "devices/cartslot.h" |
| 20 | #include "devices/cassette.h" |
| 20 | 21 | |
| 21 | 22 | #define VERBOSE_LEVEL 0 |
| 22 | 23 | #define DBG_LOG(N,M,A) \ |
| r3210 | r3211 | |
| 41 | 42 | UINT8 *pet_videoram; |
| 42 | 43 | static UINT8 *pet80_bank1_base; |
| 43 | 44 | |
| 45 | static emu_timer *datasette1_timer; |
| 46 | static emu_timer *datasette2_timer; |
| 47 | |
| 48 | |
| 44 | 49 | static READ8_HANDLER( pet_mc6845_register_r ) |
| 45 | 50 | { |
| 46 | 51 | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, "crtc"); |
| r3210 | r3211 | |
| 77 | 82 | { |
| 78 | 83 | int data = 0xf0 | pet_keyline_select; |
| 79 | 84 | |
| 85 | if ((cassette_get_state(image_from_devtype_and_index(IO_CASSETTE, 0)) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 86 | data &= ~0x10; |
| 87 | |
| 88 | if ((cassette_get_state(image_from_devtype_and_index(IO_CASSETTE, 1)) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 89 | data &= ~0x20; |
| 90 | |
| 80 | 91 | if (!cbm_ieee_eoi_r()) |
| 81 | | data&=~0x40; |
| 92 | data &= ~0x40; |
| 93 | |
| 82 | 94 | return data; |
| 83 | 95 | } |
| 84 | 96 | |
| r3210 | r3211 | |
| 131 | 143 | return data; |
| 132 | 144 | } |
| 133 | 145 | |
| 146 | /* NOT WORKING - Just placeholder */ |
| 147 | static READ8_HANDLER( pet_pia0_ca1_in ) |
| 148 | { |
| 149 | // cassette 1 read |
| 150 | return (cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) > +0.0) ? 1 : 0; |
| 151 | } |
| 152 | |
| 153 | |
| 134 | 154 | static WRITE8_HANDLER( pet_pia0_ca2_out ) |
| 135 | 155 | { |
| 136 | 156 | cbm_ieee_eoi_w(0, data); |
| 137 | 157 | } |
| 138 | 158 | |
| 159 | static WRITE8_HANDLER( pet_pia0_cb2_out ) |
| 160 | { |
| 161 | if (!data) |
| 162 | { |
| 163 | cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); |
| 164 | timer_adjust_periodic(datasette1_timer, attotime_zero, 0, ATTOTIME_IN_HZ(48000)); // I put 48000 because I was given some .wav with this freq |
| 165 | } |
| 166 | else |
| 167 | { |
| 168 | cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR); |
| 169 | timer_reset(datasette1_timer, attotime_never); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | |
| 139 | 174 | static void pet_irq (running_machine *machine, int level) |
| 140 | 175 | { |
| 141 | 176 | static int old_level = 0; |
| r3210 | r3211 | |
| 192 | 227 | { |
| 193 | 228 | pet_pia0_port_a_read, /* in_a_func */ |
| 194 | 229 | pet_pia0_port_b_read, /* in_b_func */ |
| 195 | | NULL, /* in_ca1_func */ |
| 230 | pet_pia0_ca1_in, /* in_ca1_func */ |
| 196 | 231 | NULL, /* in_cb1_func */ |
| 197 | 232 | NULL, /* in_ca2_func */ |
| 198 | 233 | NULL, /* in_cb2_func */ |
| 199 | 234 | pet_pia0_port_a_write, /* out_a_func */ |
| 200 | 235 | NULL, /* out_b_func */ |
| 201 | 236 | pet_pia0_ca2_out, /* out_ca2_func */ |
| 202 | | NULL, /* out_cb2_func */ |
| 237 | pet_pia0_cb2_out, /* out_cb2_func */ |
| 203 | 238 | NULL, /* irq_a_func */ |
| 204 | 239 | pet_irq /* irq_b_func */ |
| 205 | 240 | }; |
| r3210 | r3211 | |
| 208 | 243 | { |
| 209 | 244 | pet_pia0_port_a_read, /* in_a_func */ |
| 210 | 245 | petb_pia0_port_b_read, /* in_b_func */ |
| 211 | | NULL, /* in_ca1_func */ |
| 246 | pet_pia0_ca1_in, /* in_ca1_func */ |
| 212 | 247 | NULL, /* in_cb1_func */ |
| 213 | 248 | NULL, /* in_ca2_func */ |
| 214 | 249 | NULL, /* in_cb2_func */ |
| 215 | 250 | pet_pia0_port_a_write, /* out_a_func */ |
| 216 | 251 | NULL, /* out_b_func */ |
| 217 | 252 | pet_pia0_ca2_out, /* out_ca2_func */ |
| 218 | | NULL, /* out_cb2_func */ |
| 253 | pet_pia0_cb2_out, /* out_cb2_func */ |
| 219 | 254 | NULL, /* irq_a_func */ |
| 220 | 255 | pet_irq /* irq_b_func */ |
| 221 | 256 | }; |
| r3210 | r3211 | |
| 262 | 297 | { |
| 263 | 298 | UINT8 data = 0; |
| 264 | 299 | |
| 265 | | if (cbm_ieee_ndac_r()) data |= 1; |
| 300 | if (cbm_ieee_ndac_r()) data |= 0x01; |
| 266 | 301 | |
| 302 | // data & 0x08 -> cassette write (it seems to BOTH cassettes from schematics) |
| 303 | |
| 304 | if (!(data & 0x10)) |
| 305 | { |
| 306 | cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 1),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); |
| 307 | timer_adjust_periodic(datasette2_timer, attotime_zero, 0, ATTOTIME_IN_HZ(48000)); // I put 48000 because I was given some .wav with this freq |
| 308 | } |
| 309 | else |
| 310 | { |
| 311 | cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 1),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR); |
| 312 | timer_reset(datasette2_timer, attotime_never); |
| 313 | } |
| 314 | |
| 267 | 315 | if (cbm_ieee_nrfd_r()) data |= 0x40; |
| 268 | 316 | |
| 269 | 317 | if (cbm_ieee_dav_r()) data |= 0x80; |
| r3210 | r3211 | |
| 271 | 319 | return data; |
| 272 | 320 | } |
| 273 | 321 | |
| 322 | /* NOT WORKING - Just placeholder */ |
| 323 | static READ8_HANDLER( pet_via_cb1_r ) |
| 324 | { |
| 325 | // cassette 2 read |
| 326 | return (cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) > +0.0) ? 1 : 0; |
| 327 | } |
| 328 | |
| 329 | |
| 274 | 330 | static WRITE8_HANDLER( pet_via_port_b_w ) |
| 275 | 331 | { |
| 276 | 332 | cbm_ieee_nrfd_w(0, data & 2); |
| r3210 | r3211 | |
| 283 | 339 | NULL, /* in_a_func */ |
| 284 | 340 | pet_via_port_b_r, /* in_b_func */ |
| 285 | 341 | NULL, /* in_ca1_func */ |
| 286 | | NULL, /* in_cb1_func */ |
| 342 | pet_via_cb1_r, /* in_cb1_func */ |
| 287 | 343 | NULL, /* in_ca2_func */ |
| 288 | 344 | NULL, /* in_cb2_func */ |
| 289 | 345 | NULL, /* out_a_func */ |
| r3210 | r3211 | |
| 499 | 555 | level = !level; |
| 500 | 556 | } |
| 501 | 557 | |
| 558 | |
| 559 | /* NOT WORKING - Just placeholder */ |
| 560 | static TIMER_CALLBACK( pet_tape1_timer ) |
| 561 | { |
| 562 | // cassette 1 |
| 563 | UINT8 data = (cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) > +0.0) ? 1 : 0; |
| 564 | pia_0_ca1_w(machine, 0, data); |
| 565 | } |
| 566 | |
| 567 | /* NOT WORKING - Just placeholder */ |
| 568 | static TIMER_CALLBACK( pet_tape2_timer ) |
| 569 | { |
| 570 | // cassette 2 |
| 571 | UINT8 data = (cassette_input(image_from_devtype_and_index(IO_CASSETTE, 1)) > +0.0) ? 1 : 0; |
| 572 | via_0_cb1_w(machine, 0, data); |
| 573 | } |
| 574 | |
| 575 | |
| 502 | 576 | static void pet_common_driver_init(running_machine *machine) |
| 503 | 577 | { |
| 504 | 578 | int i; |
| r3210 | r3211 | |
| 526 | 600 | /* pet clock */ |
| 527 | 601 | timer_pulse(ATTOTIME_IN_MSEC(10), NULL, 0, pet_interrupt); |
| 528 | 602 | |
| 603 | /* datasette */ |
| 604 | datasette1_timer = timer_alloc(pet_tape1_timer, NULL); |
| 605 | datasette2_timer = timer_alloc(pet_tape2_timer, NULL); |
| 606 | |
| 607 | |
| 529 | 608 | via_config(0, &pet_via); |
| 530 | 609 | pia_config(1, &pet_pia1); |
| 531 | 610 | |
src/mess/drivers/pet.c
| r3210 | r3211 | |
| 721 | 721 | #define rom_cbm80 rom_pet80 |
| 722 | 722 | #define rom_cbm80pal rom_pet80pal |
| 723 | 723 | |
| 724 | |
| 725 | |
| 726 | void pet_datasette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 727 | { |
| 728 | switch(state) |
| 729 | { |
| 730 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 731 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 732 | |
| 733 | default: datasette_device_getinfo(devclass, state, info); |
| 734 | } |
| 735 | } |
| 736 | |
| 724 | 737 | static SYSTEM_CONFIG_START(pet) |
| 725 | 738 | CONFIG_DEVICE(pet_cartslot_getinfo) |
| 739 | CONFIG_DEVICE(pet_datasette_getinfo) |
| 726 | 740 | CONFIG_DEVICE(cbmfloppy_device_getinfo) |
| 727 | 741 | CONFIG_RAM(4 * 1024) |
| 728 | 742 | CONFIG_RAM(8 * 1024) |
| r3210 | r3211 | |
| 732 | 746 | |
| 733 | 747 | static SYSTEM_CONFIG_START(pet2) |
| 734 | 748 | CONFIG_DEVICE(pet_cartslot_getinfo) |
| 749 | CONFIG_DEVICE(pet_datasette_getinfo) |
| 735 | 750 | CONFIG_DEVICE(cbmfloppy_device_getinfo) |
| 736 | 751 | CONFIG_RAM(4 * 1024) |
| 737 | 752 | CONFIG_RAM(8 * 1024) |
| r3210 | r3211 | |
| 741 | 756 | |
| 742 | 757 | static SYSTEM_CONFIG_START(pet4) |
| 743 | 758 | CONFIG_DEVICE(pet4_cartslot_getinfo) |
| 759 | CONFIG_DEVICE(pet_datasette_getinfo) |
| 744 | 760 | CONFIG_DEVICE(cbmfloppy_device_getinfo) |
| 745 | 761 | CONFIG_RAM(4 * 1024) |
| 746 | 762 | CONFIG_RAM(8 * 1024) |
| r3210 | r3211 | |
| 750 | 766 | |
| 751 | 767 | static SYSTEM_CONFIG_START(pet4_32) |
| 752 | 768 | CONFIG_DEVICE(pet4_cartslot_getinfo) |
| 769 | CONFIG_DEVICE(pet_datasette_getinfo) |
| 753 | 770 | CONFIG_DEVICE(cbmfloppy_device_getinfo) |
| 754 | 771 | CONFIG_RAM_DEFAULT(32 * 1024) |
| 755 | 772 | SYSTEM_CONFIG_END |