Previous 15994 Revisions Next

r3211 Monday 8th September, 2008 at 22:53:21 UTC by Fabio Priuli
[PET] Very preliminary tape code (2 datasettes!). It's not possible to load/save data, but motor & buttons are recognized
[src/mess/drivers]pet.c
[src/mess/machine]pet.c

src/mess/machine/pet.c
r3210r3211
1717#include "includes/pet.h"
1818
1919#include "devices/cartslot.h"
20#include "devices/cassette.h"
2021
2122#define VERBOSE_LEVEL 0
2223#define DBG_LOG(N,M,A) \
r3210r3211
4142UINT8 *pet_videoram;
4243static UINT8 *pet80_bank1_base;
4344
45static emu_timer *datasette1_timer;
46static emu_timer *datasette2_timer;
47
48
4449static READ8_HANDLER( pet_mc6845_register_r )
4550{
4651   device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, "crtc");
r3210r3211
7782{
7883   int data = 0xf0 | pet_keyline_select;
7984
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
8091   if (!cbm_ieee_eoi_r())
81      data&=~0x40;
92      data &= ~0x40;
93
8294   return data;
8395}
8496
r3210r3211
131143   return data;
132144}
133145
146/* NOT WORKING - Just placeholder */
147static 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
134154static WRITE8_HANDLER( pet_pia0_ca2_out )
135155{
136156   cbm_ieee_eoi_w(0, data);
137157}
138158
159static 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
139174static void pet_irq (running_machine *machine, int level)
140175{
141176   static int old_level = 0;
r3210r3211
192227{
193228   pet_pia0_port_a_read,      /* in_a_func */
194229   pet_pia0_port_b_read,      /* in_b_func */
195   NULL,                  /* in_ca1_func */
230   pet_pia0_ca1_in,         /* in_ca1_func */
196231   NULL,                  /* in_cb1_func */
197232   NULL,                  /* in_ca2_func */
198233   NULL,                  /* in_cb2_func */
199234   pet_pia0_port_a_write,      /* out_a_func */
200235   NULL,                  /* out_b_func */
201236   pet_pia0_ca2_out,         /* out_ca2_func */
202   NULL,                  /* out_cb2_func */
237   pet_pia0_cb2_out,         /* out_cb2_func */
203238   NULL,                  /* irq_a_func */
204239   pet_irq                  /* irq_b_func */
205240};
r3210r3211
208243{
209244   pet_pia0_port_a_read,      /* in_a_func */
210245   petb_pia0_port_b_read,      /* in_b_func */
211   NULL,                  /* in_ca1_func */
246   pet_pia0_ca1_in,         /* in_ca1_func */
212247   NULL,                  /* in_cb1_func */
213248   NULL,                  /* in_ca2_func */
214249   NULL,                  /* in_cb2_func */
215250   pet_pia0_port_a_write,      /* out_a_func */
216251   NULL,                  /* out_b_func */
217252   pet_pia0_ca2_out,         /* out_ca2_func */
218   NULL,                  /* out_cb2_func */
253   pet_pia0_cb2_out,         /* out_cb2_func */
219254   NULL,                  /* irq_a_func */
220255   pet_irq                  /* irq_b_func */
221256};
r3210r3211
262297{
263298   UINT8 data = 0;
264299
265   if (cbm_ieee_ndac_r()) data |= 1;
300   if (cbm_ieee_ndac_r()) data |= 0x01;
266301
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
267315   if (cbm_ieee_nrfd_r()) data |= 0x40;
268316
269317   if (cbm_ieee_dav_r()) data |= 0x80;
r3210r3211
271319   return data;
272320}
273321
322/* NOT WORKING - Just placeholder */
323static 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
274330static WRITE8_HANDLER( pet_via_port_b_w )
275331{
276332   cbm_ieee_nrfd_w(0, data & 2);
r3210r3211
283339   NULL,               /* in_a_func */
284340   pet_via_port_b_r,      /* in_b_func */
285341   NULL,               /* in_ca1_func */
286   NULL,               /* in_cb1_func */
342   pet_via_cb1_r,         /* in_cb1_func */
287343   NULL,               /* in_ca2_func */
288344   NULL,               /* in_cb2_func */
289345   NULL,               /* out_a_func */
r3210r3211
499555   level = !level;
500556}
501557
558
559/* NOT WORKING - Just placeholder */
560static 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 */
568static 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
502576static void pet_common_driver_init(running_machine *machine)
503577{
504578   int i;
r3210r3211
526600   /* pet clock */
527601   timer_pulse(ATTOTIME_IN_MSEC(10), NULL, 0, pet_interrupt);
528602
603   /* datasette */
604   datasette1_timer = timer_alloc(pet_tape1_timer, NULL);
605   datasette2_timer = timer_alloc(pet_tape2_timer, NULL);
606
607
529608   via_config(0, &pet_via);
530609   pia_config(1, &pet_pia1);
531610
src/mess/drivers/pet.c
r3210r3211
721721#define rom_cbm80 rom_pet80
722722#define rom_cbm80pal rom_pet80pal
723723
724
725
726void 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
724737static SYSTEM_CONFIG_START(pet)
725738   CONFIG_DEVICE(pet_cartslot_getinfo)
739   CONFIG_DEVICE(pet_datasette_getinfo)
726740   CONFIG_DEVICE(cbmfloppy_device_getinfo)
727741   CONFIG_RAM(4 * 1024)
728742   CONFIG_RAM(8 * 1024)
r3210r3211
732746
733747static SYSTEM_CONFIG_START(pet2)
734748   CONFIG_DEVICE(pet_cartslot_getinfo)
749   CONFIG_DEVICE(pet_datasette_getinfo)
735750   CONFIG_DEVICE(cbmfloppy_device_getinfo)
736751   CONFIG_RAM(4 * 1024)
737752   CONFIG_RAM(8 * 1024)
r3210r3211
741756
742757static SYSTEM_CONFIG_START(pet4)
743758   CONFIG_DEVICE(pet4_cartslot_getinfo)
759   CONFIG_DEVICE(pet_datasette_getinfo)
744760   CONFIG_DEVICE(cbmfloppy_device_getinfo)
745761   CONFIG_RAM(4 * 1024)
746762   CONFIG_RAM(8 * 1024)
r3210r3211
750766
751767static SYSTEM_CONFIG_START(pet4_32)
752768   CONFIG_DEVICE(pet4_cartslot_getinfo)
769   CONFIG_DEVICE(pet_datasette_getinfo)
753770   CONFIG_DEVICE(cbmfloppy_device_getinfo)
754771   CONFIG_RAM_DEFAULT(32 * 1024)
755772SYSTEM_CONFIG_END

Previous 15994 Revisions Next


© 1998-2018 The MESS Team