Previous 15994 Revisions Next

r5960 Sunday 4th October, 2009 at 17:55:07 UTC by Miodrag Milanović
Fixed at least some multi session issues with PC and AT drivers
[src/mess/drivers]at.c pc.c
[src/mess/includes]at.h pc.h
[src/mess/machine]at.c pc.c pc_hdc.c pc_hdc.h

src/mess/includes/at.h
r5959r5960
99#ifndef AT_H_
1010#define AT_H_
1111
12typedef struct _at_state at_state;
13struct _at_state
14{
15   const device_config *maincpu;
16   const device_config   *pic8259_master;
17   const device_config   *pic8259_slave;
18   const device_config   *dma8237_1;
19   const device_config   *dma8237_2;
20   const device_config   *pit8254;
21};
1222
23
1324/*----------- defined in machine/at.c -----------*/
1425
1526extern const struct pic8259_interface at_pic8259_master_config;
src/mess/includes/pc.h
r5959r5960
99
1010#include "machine/ins8250.h"
1111#include "machine/i8255a.h"
12   
13typedef struct _pc_state pc_state;
14struct _pc_state
15{
16   const device_config *maincpu;
17   const device_config   *pic8259;
18   const device_config   *dma8237;
19   const device_config   *pit8253;
20   /* U73 is an LS74 - dual flip flop */
21   /* Q2 is set by OUT1 from the 8253 and goes to DRQ1 on the 8237 */
22   UINT8   u73_q2;
23   UINT8   out1;
24   UINT8 dma_offset[2][4];   
25   UINT8 pc_spkrdata;
26   UINT8 pc_input;     
1227
28   int                  ppi_portc_switch_high;
29   int                  ppi_speaker;
30   int                  ppi_keyboard_clear;
31   UINT8               ppi_keyb_clock;
32   UINT8               ppi_portb;
33   UINT8               ppi_clock_signal;
34   UINT8               ppi_data_signal;
35   UINT8               ppi_shift_register;
36   UINT8               ppi_shift_enable;
37   write8_space_func      ppi_clock_callback;
38   write8_space_func      ppi_data_callback;   
39};
40
1341/*----------- defined in machine/pc.c -----------*/
1442
1543extern const struct dma8237_interface ibm5150_dma8237_config;
r5959r5960
2351extern const i8255a_interface pc_ppi8255_interface;
2452extern const i8255a_interface pcjr_ppi8255_interface;
2553
26UINT8 pc_speaker_get_spk(void);
54UINT8 pc_speaker_get_spk(running_machine *machine);
2755void pc_speaker_set_spkrdata(running_machine *machine, UINT8 data);
2856void pc_speaker_set_input(running_machine *machine, UINT8 data);
2957
30void mess_init_pc_common( running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(running_machine *, int), void (*set_hdc_int_func)(int,int));
58void mess_init_pc_common( running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(running_machine *, int), void (*set_hdc_int_func)(running_machine *,int,int));
3159
3260WRITE8_HANDLER( pc_nmi_enable_w );
3361READ8_HANDLER( pcjr_nmi_enable_r );
src/mess/machine/at.c
r5959r5960
3636#define LOG_PORT80   0
3737#define LOG_KBDC   0
3838
39static struct {
40   const device_config *maincpu;
41   const device_config   *pic8259_master;
42   const device_config   *pic8259_slave;
43   const device_config   *dma8237_1;
44   const device_config   *dma8237_2;
45   const device_config   *pit8254;
46} at_devices;
47
4839static const SOUNDBLASTER_CONFIG soundblaster = { 1,5, {1,0} };
4940
5041
r5959r5960
6051
6152
6253static PIC8259_SET_INT_LINE( at_pic8259_slave_set_int_line ) {
63   pic8259_set_irq_line( at_devices.pic8259_master, 2, interrupt);
54   at_state *st = device->machine->driver_data;
55   pic8259_set_irq_line( st->pic8259_master, 2, interrupt);
6456}
6557
6658
r5959r5960
115107
116108static PIT8253_OUTPUT_CHANGED( at_pit8254_out0_changed )
117109{
118   if ( at_devices.pic8259_master ) {
119      pic8259_set_irq_line(at_devices.pic8259_master, 0, state);
110   at_state *st = device->machine->driver_data;
111   if ( st->pic8259_master ) {
112      pic8259_set_irq_line(st->pic8259_master, 0, state);
120113   }
121114}
122115
r5959r5960
151144}
152145
153146
154static void at_set_irq_line(int irq, int state) {
155   pic8259_set_irq_line(at_devices.pic8259_master, irq, state);
147static void at_set_irq_line(running_machine *machine,int irq, int state) {
148   at_state *st = machine->driver_data;
149   pic8259_set_irq_line(st->pic8259_master, irq, state);
156150}
157151
158152
159153static void at_set_keyb_int(running_machine *machine, int state) {
160   pic8259_set_irq_line(at_devices.pic8259_master, 1, state);
154   at_state *st = machine->driver_data;
155   pic8259_set_irq_line(st->pic8259_master, 1, state);
161156}
162157
163158
r5959r5960
182177
183178static void at_keyboard_interrupt(running_machine *machine, int state)
184179{
185   pic8259_set_irq_line(at_devices.pic8259_master, 1, state);
180   at_state *st = machine->driver_data;
181   pic8259_set_irq_line(st->pic8259_master, 1, state);
186182}
187183
188184
r5959r5960
248244
249245static DMA8237_HRQ_CHANGED( pc_dma_hrq_changed )
250246{
251   cpu_set_input_line(at_devices.maincpu, INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE);
247   at_state *st = device->machine->driver_data;
248   cpu_set_input_line(st->maincpu, INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE);
252249
253250   /* Assert HLDA */
254251   dma8237_set_hlda( device, state );
r5959r5960
337334/* called when a interrupt is set/cleared from com hardware */
338335static INS8250_INTERRUPT( at_com_interrupt_1 )
339336{
340   pic8259_set_irq_line(at_devices.pic8259_master, 4, state);
337   at_state *st = device->machine->driver_data;
338   pic8259_set_irq_line(st->pic8259_master, 4, state);
341339}
342340
343341static INS8250_INTERRUPT( at_com_interrupt_2 )
344342{
345   pic8259_set_irq_line(at_devices.pic8259_master, 3, state);
343   at_state *st = device->machine->driver_data;
344   pic8259_set_irq_line(st->pic8259_master, 3, state);
346345}
347346
348347/* called when com registers read/written - used to update peripherals that
r5959r5960
404403
405404static void at_fdc_interrupt(running_machine *machine, int state)
406405{
407   pic8259_set_irq_line(at_devices.pic8259_master, 6, state);
406   at_state *st = machine->driver_data;
407   pic8259_set_irq_line(st->pic8259_master, 6, state);
408408//if ( mess_ram[0x0490] == 0x74 )
409409//  mess_ram[0x0490] = 0x54;
410410}
r5959r5960
412412
413413static void at_fdc_dma_drq(running_machine *machine, int state, int read_)
414414{
415   dma8237_drq_write( at_devices.dma8237_1, FDC_DMA, state);
415   at_state *st = machine->driver_data;
416   dma8237_drq_write( st->dma8237_1, FDC_DMA, state);
416417}
417418
418419static const device_config *at_get_device(running_machine *machine)
r5959r5960
430431
431432
432433static int at_get_out2(running_machine *machine) {
433   return pit8253_get_output(at_devices.pit8254, 2 );
434   at_state *st = machine->driver_data;
435   return pit8253_get_output(st->pit8254, 2 );
434436}
435437
436438
r5959r5960
494496
495497static WRITE8_HANDLER( at_kbdc8042_p2_w )
496498{
499   at_state *st = space->machine->driver_data;
500   
497501   logerror("%04x: writing $%02x to P2\n", cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")), data );
498502
499503   at_set_gate_a20( space->machine, ( data & 0x02 ) ? 1 : 0 );
r5959r5960
501505   cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_RESET, ( data & 0x01 ) ? CLEAR_LINE : ASSERT_LINE );
502506
503507   /* OPT BUF FULL is connected to IR1 on the master 8259 */
504   if ( at_devices.pic8259_master )
505      pic8259_set_irq_line(at_devices.pic8259_master, 1, ( data & 0x10 ) ? ASSERT_LINE : CLEAR_LINE );
508   if ( st->pic8259_master )
509      pic8259_set_irq_line(st->pic8259_master, 1, ( data & 0x10 ) ? ASSERT_LINE : CLEAR_LINE );
506510
507511   at_kbdc8042.clock_signal = ( data & 0x40 ) ? 1 : 0;
508512   at_kbdc8042.data_signal = ( data & 0x80 ) ? 1 : 0;
r5959r5960
562566{
563567   static int poll_delay = 4;
564568    UINT8 data = 0;
565
569   at_state *st = space->machine->driver_data;
570   
566571   switch ( offset )
567572   {
568573   case 0:      /* A2 is wired to 8042 A0 */
r5959r5960
581586      }
582587      data = (data & ~0x10) | ( at_kbdc8042.offset1 & 0x10 );
583588
584      if ( pit8253_get_output(at_devices.pit8254, 2 ) )
589      if ( pit8253_get_output(st->pit8254, 2 ) )
585590         data |= 0x20;
586591      else
587592         data &= ~0x20; /* ps2m30 wants this */
r5959r5960
607612
608613WRITE8_HANDLER(at_kbdc8042_w)
609614{
615   at_state *st = space->machine->driver_data;
610616   if (LOG_KBDC)
611617      logerror("kbdc8042_8_w(): ofset=%d data=0x%02x\n", offset, data);
612618
r5959r5960
617623
618624   case 1:
619625      at_kbdc8042.speaker = data;
620      pit8253_gate_w( at_devices.pit8254, 2, data & 1);
626      pit8253_gate_w( st->pit8254, 2, data & 1);
621627      at_speaker_set_spkrdata( space->machine, data & 0x02 );
622628      break;
623629
r5959r5960
769775
770776static IRQ_CALLBACK(at_irq_callback)
771777{
772   return pic8259_acknowledge( at_devices.pic8259_master);
778   at_state *st = device->machine->driver_data;
779   return pic8259_acknowledge( st->pic8259_master);
773780}
774781
775782
r5959r5960
784791
785792MACHINE_RESET( at )
786793{
787   at_devices.maincpu = devtag_get_device(machine, "maincpu");
788   at_devices.pic8259_master = devtag_get_device(machine, "pic8259_master");
789   at_devices.pic8259_slave = devtag_get_device(machine, "pic8259_slave");
790   at_devices.dma8237_1 = devtag_get_device(machine, "dma8237_1");
791   at_devices.dma8237_2 = devtag_get_device(machine, "dma8237_2");
792   at_devices.pit8254 = devtag_get_device(machine, "pit8254");
794   at_state *st = machine->driver_data;
795   st->maincpu = devtag_get_device(machine, "maincpu");
796   st->pic8259_master = devtag_get_device(machine, "pic8259_master");
797   st->pic8259_slave = devtag_get_device(machine, "pic8259_slave");
798   st->dma8237_1 = devtag_get_device(machine, "dma8237_1");
799   st->dma8237_2 = devtag_get_device(machine, "dma8237_2");
800   st->pit8254 = devtag_get_device(machine, "pit8254");
793801   pc_mouse_set_serial_port( devtag_get_device(machine, "ns16450_0") );
794802}
795803
src/mess/machine/pc_hdc.c
r5959r5960
110110static UINT8 *buffer;               /* data buffer */
111111static UINT8 *buffer_ptr = 0;         /* data pointer */
112112static UINT8 hdc_control;
113static void (*hdc_set_irq)(int,int);
113static void (*hdc_set_irq)(running_machine *,int,int);
114114static const device_config *pc_hdc_dma8237;
115115
116116
r5959r5960
177177
178178static TIMER_CALLBACK(pc_hdc_command);
179179
180int pc_hdc_setup(running_machine *machine, void (*hdc_set_irq_func)(int,int))
180int pc_hdc_setup(running_machine *machine, void (*hdc_set_irq_func)(running_machine *,int,int))
181181{
182182   int i;
183183
r5959r5960
237237   return mess_hd_get_hard_disk_file(img);
238238}
239239
240static void pc_hdc_result(int n, int set_error_info)
240static void pc_hdc_result(running_machine *machine,int n, int set_error_info)
241241{
242242   int irq;
243243
r5959r5960
245245   irq = (dip[n] & 0x40) ? 5 : 2;
246246
247247   if ( ( hdc_control & 0x02 ) && hdc_set_irq ) {
248      hdc_set_irq( irq, 1 );
248      hdc_set_irq( machine, irq, 1 );
249249   }
250250
251251   if (LOG_HDC_STATUS)
r5959r5960
591591         break;
592592
593593   }
594   pc_hdc_result(n, set_error_info);
594   pc_hdc_result(machine, n, set_error_info);
595595}
596596
597597
r5959r5960
656656            data_cnt = 0;
657657            status[n] |= STA_INPUT;
658658            csb[n] |= CSB_ERROR | 0x20; /* unknown command */
659            pc_hdc_result(n, 1);
659            pc_hdc_result(machine, n, 1);
660660            break;
661661      }
662662      if( data_cnt )
r5959r5960
720720   hdc_control = data;
721721
722722   if ( ! ( hdc_control & 0x02 ) && hdc_set_irq ) {
723      hdc_set_irq( irq, 0 );
723      hdc_set_irq( machine, irq, 0 );
724724   }
725725}
726726
src/mess/machine/pc_hdc.h
r5959r5960
33
44#include "driver.h"
55
6int pc_hdc_setup(running_machine *machine, void (*hdc_set_irq_func)(int,int));
6int pc_hdc_setup(running_machine *machine, void (*hdc_set_irq_func)(running_machine *,int,int));
77
88READ8_HANDLER  ( pc_HDC1_r );
99WRITE8_HANDLER ( pc_HDC1_w );
src/mess/machine/pc.c
r5959r5960
5858      } \
5959   } while (0)
6060
61static struct {
62   const device_config *maincpu;
63   const device_config   *pic8259;
64   const device_config   *dma8237;
65   const device_config   *pit8253;
66   /* U73 is an LS74 - dual flip flop */
67   /* Q2 is set by OUT1 from the 8253 and goes to DRQ1 on the 8237 */
68   UINT8   u73_q2;
69   UINT8   out1;
70} pc_devices;
71
7261/*************************************************************************
7362 *
7463 *      PC DMA stuff
7564 *
7665 *************************************************************************/
7766
78static UINT8 dma_offset[2][4];
79
80
8167READ8_HANDLER(pc_page_r)
8268{
8369   return 0xFF;
r5959r5960
8672
8773WRITE8_HANDLER(pc_page_w)
8874{
75   pc_state *st = space->machine->driver_data;
8976   switch(offset % 4)
9077   {
9178   case 1:
92      dma_offset[0][2] = data;
79      st->dma_offset[0][2] = data;
9380      break;
9481   case 2:
95      dma_offset[0][3] = data;
82      st->dma_offset[0][3] = data;
9683      break;
9784   case 3:
98      dma_offset[0][0] = dma_offset[0][1] = data;
85      st->dma_offset[0][0] = st->dma_offset[0][1] = data;
9986      break;
10087   }
10188}
r5959r5960
10390
10491static DMA8237_HRQ_CHANGED( pc_dma_hrq_changed )
10592{
106   cpu_set_input_line(pc_devices.maincpu, INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE);
93   pc_state *st = device->machine->driver_data;
94   cpu_set_input_line(st->maincpu, INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE);
10795
10896   /* Assert HLDA */
10997   dma8237_set_hlda( device, state );
r5959r5960
113101static DMA8237_MEM_READ( pc_dma_read_byte )
114102{
115103   UINT8 result;
116   offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16)
104   pc_state *st = device->machine->driver_data;
105   offs_t page_offset = (((offs_t) st->dma_offset[0][channel]) << 16)
117106      & 0x0F0000;
118107
119108   result = memory_read_byte( cpu_get_address_space( device->machine->firstcpu, ADDRESS_SPACE_PROGRAM ), page_offset + offset);
r5959r5960
123112
124113static DMA8237_MEM_WRITE( pc_dma_write_byte )
125114{
126   offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16)
115   pc_state *st = device->machine->driver_data;
116   offs_t page_offset = (((offs_t) st->dma_offset[0][channel]) << 16)
127117      & 0x0F0000;
128118
129119   memory_write_byte( cpu_get_address_space( device->machine->firstcpu, ADDRESS_SPACE_PROGRAM ), page_offset + offset, data);
r5959r5960
156146
157147static DMA8237_CHANNEL_WRITE( pc_dma8237_0_dack_w )
158148{
159   pc_devices.u73_q2 = 0;
160   dma8237_drq_write( pc_devices.dma8237, 0, pc_devices.u73_q2 );
149   pc_state *st = device->machine->driver_data;
150   st->u73_q2 = 0;
151   dma8237_drq_write( st->dma8237, 0, st->u73_q2 );
161152}
162153
163154
r5959r5960
247238 *      PC Speaker related
248239 *
249240 *************************************************************************/
250
251static UINT8 pc_spkrdata = 0;
252static UINT8 pc_input = 0;
253
254UINT8 pc_speaker_get_spk(void)
241UINT8 pc_speaker_get_spk(running_machine *machine)
255242{
256   return pc_spkrdata & pc_input;
243   pc_state *st = machine->driver_data;
244   return st->pc_spkrdata & st->pc_input;
257245}
258246
259247
260248void pc_speaker_set_spkrdata(running_machine *machine, UINT8 data)
261249{
262250   const device_config *speaker = devtag_get_device(machine, "speaker");
263   pc_spkrdata = data ? 1 : 0;
264   speaker_level_w( speaker, pc_speaker_get_spk() );
251   pc_state *st = machine->driver_data;
252   st->pc_spkrdata = data ? 1 : 0;
253   speaker_level_w( speaker, pc_speaker_get_spk(machine) );
265254}
266255
267256
268257void pc_speaker_set_input(running_machine *machine, UINT8 data)
269258{
270259   const device_config *speaker = devtag_get_device(machine, "speaker");
271   pc_input = data ? 1 : 0;
272   speaker_level_w( speaker, pc_speaker_get_spk() );
260   pc_state *st = machine->driver_data;
261   st->pc_input = data ? 1 : 0;
262   speaker_level_w( speaker, pc_speaker_get_spk(machine) );
273263}
274264
275265
r5959r5960
281271
282272static PIT8253_OUTPUT_CHANGED( ibm5150_pit8253_out0_changed )
283273{
284   pic8259_set_irq_line(pc_devices.pic8259, 0, state);
274   pc_state *st = device->machine->driver_data;
275   pic8259_set_irq_line(st->pic8259, 0, state);
285276}
286277
287278
288279static PIT8253_OUTPUT_CHANGED( ibm5150_pit8253_out1_changed )
289280{
281   pc_state *st = device->machine->driver_data;
290282    /* Trigger DMA channel #0 */
291   if ( pc_devices.out1 == 0 && state == 1 && pc_devices.u73_q2 == 0 )
283   if ( st->out1 == 0 && state == 1 && st->u73_q2 == 0 )
292284   {
293      pc_devices.u73_q2 = 1;
294      dma8237_drq_write( pc_devices.dma8237, 0, pc_devices.u73_q2 );
285      st->u73_q2 = 1;
286      dma8237_drq_write( st->dma8237, 0, st->u73_q2 );
295287   }
296   pc_devices.out1 = state;
288   st->out1 = state;
297289}
298290
299291
r5959r5960
351343/* called when a interrupt is set/cleared from com hardware */
352344static INS8250_INTERRUPT( pc_com_interrupt_1 )
353345{
354   pic8259_set_irq_line(pc_devices.pic8259, 4, state);
346   pc_state *st = device->machine->driver_data;
347   pic8259_set_irq_line(st->pic8259, 4, state);
355348}
356349
357350static INS8250_INTERRUPT( pc_com_interrupt_2 )
358351{
359   pic8259_set_irq_line(pc_devices.pic8259, 3, state);
352   pc_state *st = device->machine->driver_data;
353   pic8259_set_irq_line(st->pic8259, 3, state);
360354}
361355
362356/* called when com registers read/written - used to update peripherals that
r5959r5960
493487
494488static void pcjr_set_keyb_int(running_machine *machine, int state)
495489{
490   pc_state *st = machine->driver_data;
496491   if ( state )
497492   {
498493      UINT8   data = pc_keyb_read();
r5959r5960
530525         pcjr_keyb.latch = 1;
531526         if ( nmi_enabled & 0x80 )
532527         {
533            cpu_set_input_line( pc_devices.pit8253->machine->firstcpu, INPUT_LINE_NMI, PULSE_LINE );
528            cpu_set_input_line( st->pit8253->machine->firstcpu, INPUT_LINE_NMI, PULSE_LINE );
534529         }
535530      }
536531   }
r5959r5960
605600 *
606601 **********************************************************/
607602
608static struct {
609   int                  portc_switch_high;
610   int                  speaker;
611   int                  keyboard_clear;
612   UINT8               keyb_clock;
613   UINT8               portb;
614   UINT8               clock_signal;
615   UINT8               data_signal;
616   UINT8               shift_register;
617   UINT8               shift_enable;
618   write8_space_func      clock_callback;
619   write8_space_func      data_callback;
620} pc_ppi={ 0 };
621
622
623603static READ8_DEVICE_HANDLER (ibm5150_ppi_porta_r)
624604{
625605   int data = 0xFF;
626606   running_machine *machine = device->machine;
627
607   pc_state *st = device->machine->driver_data;
608   
628609   /* KB port A */
629   if (pc_ppi.keyboard_clear)
610   if (st->ppi_keyboard_clear)
630611   {
631612      /*   0  0 - no floppy drives
632613         *   1  Not used
r5959r5960
656637   }
657638   else
658639   {
659      data = pc_ppi.shift_register;
640      data = st->ppi_shift_register;
660641   }
661642    PIO_LOG(1,"PIO_A_r",("$%02x\n", data));
662643    return data;
r5959r5960
676657
677658static READ8_DEVICE_HANDLER ( ibm5150_ppi_portc_r )
678659{
679   int timer2_output = pit8253_get_output( pc_devices.pit8253, 2 );
660   pc_state *st = device->machine->driver_data;
661   int timer2_output = pit8253_get_output( st->pit8253, 2 );
680662   int data=0xff;
681663   running_machine *machine = device->machine;
682664
683665   data&=~0x80; // no parity error
684666   data&=~0x40; // no error on expansion board
685667   /* KB port C: equipment flags */
686   if (pc_ppi.portc_switch_high)
668   if (st->ppi_portc_switch_high)
687669   {
688670      /* read hi nibble of SW2 */
689671      data = data & 0xf0;
r5959r5960
718700      PIO_LOG(1,"PIO_C_r (lo)",("$%02x\n", data));
719701   }
720702
721   if ( ! ( pc_ppi.portb & 0x08 ) )
703   if ( ! ( st->ppi_portb & 0x08 ) )
722704   {
723705      double tap_val = cassette_input( devtag_get_device(device->machine, "cassette") );
724706
r5959r5960
733715   }
734716   else
735717   {
736      if ( pc_ppi.portb & 0x01 )
718      if ( st->ppi_portb & 0x01 )
737719      {
738720         data = ( data & ~0x10 ) | ( timer2_output ? 0x10 : 0x00 );
739721      }
r5959r5960
755737
756738static WRITE8_DEVICE_HANDLER ( ibm5150_ppi_portb_w )
757739{
740   pc_state *st = device->machine->driver_data;
758741   /* KB controller port B */
759   pc_ppi.portb = data;
760   pc_ppi.portc_switch_high = data & 0x08;
761   pc_ppi.keyboard_clear = data & 0x80;
762   pc_ppi.keyb_clock = data & 0x40;
763   pit8253_gate_w( pc_devices.pit8253, 2, data & 1);
742   st->ppi_portb = data;
743   st->ppi_portc_switch_high = data & 0x08;
744   st->ppi_keyboard_clear = data & 0x80;
745   st->ppi_keyb_clock = data & 0x40;
746   pit8253_gate_w( st->pit8253, 2, data & 1);
764747   pc_speaker_set_spkrdata( device->machine, data & 0x02 );
765748
766749   cassette_change_state( devtag_get_device(device->machine, "cassette"), ( data & 0x08 ) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
767750
768   pc_ppi.clock_signal = ( pc_ppi.keyb_clock ) ? 1 : 0;
751   st->ppi_clock_signal = ( st->ppi_keyb_clock ) ? 1 : 0;
769752
770   pc_ppi.clock_callback( cpu_get_address_space( device->machine->firstcpu, ADDRESS_SPACE_PROGRAM ), 0, pc_ppi.clock_signal );
753   st->ppi_clock_callback( cpu_get_address_space( device->machine->firstcpu, ADDRESS_SPACE_PROGRAM ), 0, st->ppi_clock_signal );
771754
772755   /* If PB7 is set clear the shift register and reset the IRQ line */
773   if ( pc_ppi.keyboard_clear )
756   if ( st->ppi_keyboard_clear )
774757   {
775      pic8259_set_irq_line(pc_devices.pic8259, 1, 0);
776      pc_ppi.shift_register = 0;
777      pc_ppi.shift_enable = 1;
758      pic8259_set_irq_line(st->pic8259, 1, 0);
759      st->ppi_shift_register = 0;
760      st->ppi_shift_enable = 1;
778761   }
779762}
780763
r5959r5960
790773
791774static WRITE8_HANDLER( ibm5150_kb_set_clock_signal )
792775{
793   if ( pc_ppi.clock_signal != data )
776   pc_state *st = space->machine->driver_data;
777   if ( st->ppi_clock_signal != data )
794778   {
795      if ( pc_ppi.keyb_clock && pc_ppi.shift_enable )
779      if ( st->ppi_keyb_clock && st->ppi_shift_enable )
796780      {
797         pc_ppi.clock_signal = data;
798         if ( ! pc_ppi.keyboard_clear )
781         st->ppi_clock_signal = data;
782         if ( ! st->ppi_keyboard_clear )
799783         {
800784            /* Data is clocked in on a high->low transition */
801785            if ( ! data )
802786            {
803               UINT8   trigger_irq = pc_ppi.shift_register & 0x01;
787               UINT8   trigger_irq = st->ppi_shift_register & 0x01;
804788
805               pc_ppi.shift_register = ( pc_ppi.shift_register >> 1 ) | ( pc_ppi.data_signal << 7 );
789               st->ppi_shift_register = ( st->ppi_shift_register >> 1 ) | ( st->ppi_data_signal << 7 );
806790               if ( trigger_irq )
807791               {
808                  pic8259_set_irq_line(pc_devices.pic8259, 1, 1);
809                  pc_ppi.shift_enable = 0;
810                  pc_ppi.clock_signal = 0;
811                  pc_ppi.clock_callback( space, 0, 0 );
792                  pic8259_set_irq_line(st->pic8259, 1, 1);
793                  st->ppi_shift_enable = 0;
794                  st->ppi_clock_signal = 0;
795                  st->ppi_clock_callback( space, 0, 0 );
812796               }
813797            }
814798         }
815799      }
816800   }
817801
818   pc_ppi.clock_callback( space, 0, pc_ppi.clock_signal );
802   st->ppi_clock_callback( space, 0, st->ppi_clock_signal );
819803}
820804
821805
822806static WRITE8_HANDLER( ibm5150_kb_set_data_signal )
823807{
824   pc_ppi.data_signal = data;
808   pc_state *st = space->machine->driver_data;
809   
810   st->ppi_data_signal = data;
825811
826   pc_ppi.data_callback( space, 0, pc_ppi.data_signal );
812   st->ppi_data_callback( space, 0, st->ppi_data_signal );
827813}
828814
829815
830816static void ibm5150_set_keyboard_interface( running_machine *machine, write8_space_func clock_cb, write8_space_func data_cb )
831817{
832   pc_ppi.clock_callback = clock_cb;
833   pc_ppi.data_callback = data_cb;
818   pc_state *st = machine->driver_data;
819   
820   st->ppi_clock_callback = clock_cb;
821   st->ppi_data_callback = data_cb;
834822}
835823
836824
r5959r5960
851839{
852840   int data = 0xFF;
853841   running_machine *machine = device->machine;
854
842   pc_state *st = device->machine->driver_data;
843   
855844   /* KB port A */
856   if (pc_ppi.keyboard_clear)
845   if (st->ppi_keyboard_clear)
857846   {
858847      /*   0  0 - no floppy drives
859848         *   1  Not used
r5959r5960
868857   }
869858   else
870859   {
871      data = pc_ppi.shift_register;
860      data = st->ppi_shift_register;
872861   }
873862    PIO_LOG(1,"PIO_A_r",("$%02x\n", data));
874863    return data;
r5959r5960
877866
878867static READ8_DEVICE_HANDLER ( ibm5160_ppi_portc_r )
879868{
880   int timer2_output = pit8253_get_output( pc_devices.pit8253, 2 );
869   pc_state *st = device->machine->driver_data;
870   int timer2_output = pit8253_get_output( st->pit8253, 2 );
881871   int data=0xff;
882872   running_machine *machine = device->machine;
883873
r5959r5960
885875   data&=~0x40; // no error on expansion board
886876   /* KB port C: equipment flags */
887877//  if (pc_port[0x61] & 0x08)
888   if (pc_ppi.portc_switch_high)
878   if (st->ppi_portc_switch_high)
889879   {
890880      /* read hi nibble of S2 */
891881      data = (data & 0xf0) | ((input_port_read(device->machine, "DSW0") >> 4) & 0x0f);
r5959r5960
898888      PIO_LOG(1,"PIO_C_r (lo)",("$%02x\n", data));
899889   }
900890
901   if ( pc_ppi.portb & 0x01 )
891   if ( st->ppi_portb & 0x01 )
902892   {
903893      data = ( data & ~0x10 ) | ( timer2_output ? 0x10 : 0x00 );
904894   }
r5959r5960
910900
911901static WRITE8_DEVICE_HANDLER( ibm5160_ppi_portb_w )
912902{
903   pc_state *st = device->machine->driver_data;
913904   /* PPI controller port B*/
914   pc_ppi.portb = data;
915   pc_ppi.portc_switch_high = data & 0x08;
916   pc_ppi.keyboard_clear = data & 0x80;
917   pc_ppi.keyb_clock = data & 0x40;
918   pit8253_gate_w( pc_devices.pit8253, 2, data & 0x01 );
905   st->ppi_portb = data;
906   st->ppi_portc_switch_high = data & 0x08;
907   st->ppi_keyboard_clear = data & 0x80;
908   st->ppi_keyb_clock = data & 0x40;
909   pit8253_gate_w( st->pit8253, 2, data & 0x01 );
919910   pc_speaker_set_spkrdata( device->machine, data & 0x02 );
920911
921   pc_ppi.clock_signal = ( pc_ppi.keyb_clock ) ? 1 : 0;
922   pc_ppi.clock_callback( cpu_get_address_space( device->machine->firstcpu, ADDRESS_SPACE_PROGRAM ), 0, pc_ppi.clock_signal );
912   st->ppi_clock_signal = ( st->ppi_keyb_clock ) ? 1 : 0;
913   st->ppi_clock_callback( cpu_get_address_space( device->machine->firstcpu, ADDRESS_SPACE_PROGRAM ), 0, st->ppi_clock_signal );
923914
924915   /* If PB7 is set clear the shift register and reset the IRQ line */
925   if ( pc_ppi.keyboard_clear )
916   if ( st->ppi_keyboard_clear )
926917   {
927      pic8259_set_irq_line(pc_devices.pic8259, 1, 0);
928      pc_ppi.shift_register = 0;
929      pc_ppi.shift_enable = 1;
918      pic8259_set_irq_line(st->pic8259, 1, 0);
919      st->ppi_shift_register = 0;
920      st->ppi_shift_enable = 1;
930921   }
931922}
932923
r5959r5960
944935
945936static READ8_DEVICE_HANDLER (pc_ppi_porta_r)
946937{
947   int data = 0xFF;
938   int data = 0xFF;   
948939   running_machine *machine = device->machine;
940   pc_state *st = device->machine->driver_data;
949941
950942   /* KB port A */
951   if (pc_ppi.keyboard_clear)
943   if (st->ppi_keyboard_clear)
952944   {
953945      /*   0  0 - no floppy drives
954946         *   1  Not used
r5959r5960
972964
973965static WRITE8_DEVICE_HANDLER( pc_ppi_portb_w )
974966{
967   pc_state *st = device->machine->driver_data;
975968   /* PPI controller port B*/
976   pc_ppi.portb = data;
977   pc_ppi.portc_switch_high = data & 0x08;
978   pc_ppi.keyboard_clear = data & 0x80;
979   pc_ppi.keyb_clock = data & 0x40;
980   pit8253_gate_w( pc_devices.pit8253, 2, data & 0x01 );
969   st->ppi_portb = data;
970   st->ppi_portc_switch_high = data & 0x08;
971   st->ppi_keyboard_clear = data & 0x80;
972   st->ppi_keyb_clock = data & 0x40;
973   pit8253_gate_w( st->pit8253, 2, data & 0x01 );
981974   pc_speaker_set_spkrdata( device->machine, data & 0x02 );
982   pc_keyb_set_clock( pc_ppi.keyb_clock );
975   pc_keyb_set_clock( st->ppi_keyb_clock );
983976
984   if ( pc_ppi.keyboard_clear )
977   if ( st->ppi_keyboard_clear )
985978      pc_keyb_clear();
986979}
987980
r5959r5960
999992
1000993static WRITE8_DEVICE_HANDLER ( pcjr_ppi_portb_w )
1001994{
995   pc_state *st = device->machine->driver_data;
1002996   /* KB controller port B */
1003   pc_ppi.portb = data;
1004   pc_ppi.portc_switch_high = data & 0x08;
997   st->ppi_portb = data;
998   st->ppi_portc_switch_high = data & 0x08;
1005999   pit8253_gate_w( devtag_get_device(device->machine, "pit8253"), 2, data & 1);
10061000   pc_speaker_set_spkrdata( device->machine, data & 0x02 );
10071001
r5959r5960
10361030 */
10371031static READ8_DEVICE_HANDLER ( pcjr_ppi_portc_r )
10381032{
1033   pc_state *st = device->machine->driver_data;
10391034   int timer2_output = pit8253_get_output( devtag_get_device(device->machine, "pit8253"), 2 );
10401035   int data=0xff;
10411036
r5959r5960
10441039   if ( mess_ram_size > 64 * 1024 )   /* more than 64KB ram installed */
10451040      data &= ~0x08;
10461041   data = ( data & ~0x01 ) | ( pcjr_keyb.latch ? 0x01: 0x00 );
1047   if ( ! ( pc_ppi.portb & 0x08 ) )
1042   if ( ! ( st->ppi_portb & 0x08 ) )
10481043   {
10491044      double tap_val = cassette_input( devtag_get_device(device->machine, "cassette") );
10501045
r5959r5960
10591054   }
10601055   else
10611056   {
1062      if ( pc_ppi.portb & 0x01 )
1057      if ( st->ppi_portb & 0x01 )
10631058      {
10641059         data = ( data & ~0x10 ) | ( timer2_output ? 0x10 : 0x00 );
10651060      }
r5959r5960
10921087
10931088static void pc_fdc_interrupt(running_machine *machine, int state)
10941089{
1095   if ( pc_devices.pic8259 ) {
1096      pic8259_set_irq_line(pc_devices.pic8259, 6, state);
1090   pc_state *st = machine->driver_data;
1091   if ( st->pic8259 ) {
1092      pic8259_set_irq_line(st->pic8259, 6, state);
10971093   }
10981094}
10991095
11001096static void pc_fdc_dma_drq(running_machine *machine, int state, int read_)
11011097{
1102   dma8237_drq_write( pc_devices.dma8237, FDC_DMA, state);
1098   pc_state *st = machine->driver_data;
1099   dma8237_drq_write( st->dma8237, FDC_DMA, state);
11031100}
11041101
11051102static const device_config * pc_get_device(running_machine *machine )
r5959r5960
11251122};
11261123
11271124
1128static void pc_set_irq_line(int irq, int state) {
1129   pic8259_set_irq_line(pc_devices.pic8259, irq, state);
1125static void pc_set_irq_line(running_machine *machine,int irq, int state) {
1126   pc_state *st = machine->driver_data;
1127   pic8259_set_irq_line(st->pic8259, irq, state);
11301128}
11311129
11321130static void pc_set_keyb_int(running_machine *machine, int state)
11331131{
1134   pc_set_irq_line( 1, state );
1132   pc_set_irq_line( machine, 1, state );
11351133}
11361134
11371135
r5959r5960
11411139 *
11421140 **********************************************************/
11431141
1144void mess_init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(running_machine *, int), void (*set_hdc_int_func)(int,int))
1142void mess_init_pc_common(running_machine *machine, UINT32 flags, void (*set_keyb_int_func)(running_machine *, int), void (*set_hdc_int_func)(running_machine *,int,int))
11451143{
11461144   if ( set_keyb_int_func != NULL )
11471145      init_pc_common(machine, flags, set_keyb_int_func);
r5959r5960
13351333
13361334static IRQ_CALLBACK(pc_irq_callback)
13371335{
1338   return pic8259_acknowledge( pc_devices.pic8259 );
1336   pc_state *st = device->machine->driver_data;
1337   return pic8259_acknowledge( st->pic8259 );
13391338}
13401339
13411340
r5959r5960
13481347MACHINE_RESET( pc )
13491348{
13501349   const device_config *speaker = devtag_get_device(machine, "speaker");
1350   pc_state *st = machine->driver_data;
1351   memset(st,0,sizeof(st));
1352   st->maincpu = devtag_get_device(machine, "maincpu" );
1353   cpu_set_irq_callback(st->maincpu, pc_irq_callback);
13511354
1352   pc_devices.maincpu = devtag_get_device(machine, "maincpu" );
1353   cpu_set_irq_callback(pc_devices.maincpu, pc_irq_callback);
1354
1355   pc_devices.pic8259 = devtag_get_device(machine, "pic8259");
1356   pc_devices.dma8237 = devtag_get_device(machine, "dma8237");
1357   pc_devices.pit8253 = devtag_get_device(machine, "pit8253");
1358   pc_devices.u73_q2 = 0;
1359   pc_devices.out1 = 0;
1355   st->pic8259 = devtag_get_device(machine, "pic8259");
1356   st->dma8237 = devtag_get_device(machine, "dma8237");
1357   st->pit8253 = devtag_get_device(machine, "pit8253");
1358   st->u73_q2 = 0;
1359   st->out1 = 0;
1360   st->pc_spkrdata = 0;
1361   st->pc_input = 0;
13601362   pc_mouse_set_serial_port( devtag_get_device(machine, "ins8250_0") );
1361   pc_hdc_set_dma8237_device( pc_devices.dma8237 );
1363   pc_hdc_set_dma8237_device( st->dma8237 );
13621364   speaker_level_w( speaker, 0 );
13631365}
13641366
r5959r5960
13721374MACHINE_RESET( pcjr )
13731375{
13741376   const device_config *speaker = devtag_get_device(machine, "speaker");
1377   pc_state *st = machine->driver_data;
1378   memset(st,0,sizeof(st));
1379   st->maincpu = devtag_get_device(machine, "maincpu" );
1380   cpu_set_irq_callback(st->maincpu, pc_irq_callback);
13751381
1376   pc_devices.maincpu = devtag_get_device(machine, "maincpu" );
1377   cpu_set_irq_callback(pc_devices.maincpu, pc_irq_callback);
1378
1379   pc_devices.pic8259 = devtag_get_device(machine, "pic8259");
1380   pc_devices.dma8237 = NULL;
1381   pc_devices.pit8253 = devtag_get_device(machine, "pit8253");
1382   pc_devices.u73_q2 = 0;
1383   pc_devices.out1 = 0;
1382   st->pic8259 = devtag_get_device(machine, "pic8259");
1383   st->dma8237 = NULL;
1384   st->pit8253 = devtag_get_device(machine, "pit8253");
1385   st->u73_q2 = 0;
1386   st->out1 = 0;
1387   st->pc_spkrdata = 0;
1388   st->pc_input = 0;
13841389   pc_mouse_set_serial_port( devtag_get_device(machine, "ins8250_0") );
1385   pc_hdc_set_dma8237_device( pc_devices.dma8237 );
1390   pc_hdc_set_dma8237_device( st->dma8237 );
13861391   speaker_level_w( speaker, 0 );
13871392
13881393   pcjr_keyb_init(machine);
src/mess/drivers/at.c
r5959r5960
449449};
450450
451451static MACHINE_DRIVER_START( ibm5170 )
452   MDRV_DRIVER_DATA(at_state)
452453   /* basic machine hardware */
453454   MDRV_CPU_ADD("maincpu", I80286, 6000000 /*6000000*/)
454455   MDRV_CPU_PROGRAM_MAP(at16_map)
r5959r5960
518519
519520
520521static MACHINE_DRIVER_START( ibm5162 )
522   MDRV_DRIVER_DATA(at_state)
521523   /* basic machine hardware */
522524   MDRV_CPU_ADD("maincpu", I80286, 6000000 /*6000000*/)
523525   MDRV_CPU_PROGRAM_MAP(at16_map)
r5959r5960
577579
578580
579581static MACHINE_DRIVER_START( ps2m30286 )
582   MDRV_DRIVER_DATA(at_state)
580583   /* basic machine hardware */
581584   MDRV_CPU_ADD("maincpu", I80286, 12000000)
582585   MDRV_CPU_PROGRAM_MAP(at16_map)
r5959r5960
644647
645648
646649static MACHINE_DRIVER_START( atvga )
650   MDRV_DRIVER_DATA(at_state)
647651   /* basic machine hardware */
648652   MDRV_CPU_ADD("maincpu", I80286, 12000000)
649653   MDRV_CPU_PROGRAM_MAP(at16_map)
r5959r5960
713717
714718
715719static MACHINE_DRIVER_START( at386 )
720   MDRV_DRIVER_DATA(at_state)
716721    /* basic machine hardware */
717722   /* original at 6 MHz, at03 8 megahertz */
718723   MDRV_CPU_ADD("maincpu", I386, 12000000)
src/mess/drivers/pc.c
r5959r5960
13871387
13881388
13891389static MACHINE_DRIVER_START( pcmda )
1390   MDRV_DRIVER_DATA(pc_state)
13901391   /* basic machine hardware */
13911392   MDRV_CPU_ADD("maincpu", V20, 4772720)
13921393   MDRV_CPU_PROGRAM_MAP(pc8_map)
r5959r5960
14481449
14491450
14501451static MACHINE_DRIVER_START( pcherc )
1452   MDRV_DRIVER_DATA(pc_state)
14511453   /* basic machine hardware */
14521454   MDRV_CPU_ADD("maincpu", V20, 4772720)
14531455   MDRV_CPU_PROGRAM_MAP(pc8_map)
r5959r5960
15141516};
15151517
15161518static MACHINE_DRIVER_START( ibm5150 )
1519   MDRV_DRIVER_DATA(pc_state)
15171520   /* basic machine hardware */
15181521   MDRV_CPU_ADD("maincpu", I8088, XTAL_14_31818MHz/3)
15191522   MDRV_CPU_PROGRAM_MAP(pc8_map)
r5959r5960
15771580
15781581
15791582static MACHINE_DRIVER_START( pccga )
1583   MDRV_DRIVER_DATA(pc_state)
15801584   /* basic machine hardware */
15811585   MDRV_CPU_PC(pc8, pc8, I8088, 4772720, pc_frame_interrupt)   /* 4,77 MHz */
15821586
r5959r5960
16351639
16361640
16371641static MACHINE_DRIVER_START( europc )
1642   MDRV_DRIVER_DATA(pc_state)
16381643   /* basic machine hardware */
16391644   MDRV_CPU_PC(europc, europc, I8088, 4772720*2, pc_frame_interrupt)
16401645
r5959r5960
16841689
16851690
16861691static MACHINE_DRIVER_START( ibm5160 )
1692   MDRV_DRIVER_DATA(pc_state)
16871693   /* basic machine hardware */
16881694   MDRV_CPU_PC(pc8, pc8, I8088, XTAL_14_31818MHz/3, pc_frame_interrupt)
16891695
r5959r5960
17401746
17411747
17421748static MACHINE_DRIVER_START( pc200 )
1749   MDRV_DRIVER_DATA(pc_state)
17431750   /* basic machine hardware */
17441751   MDRV_CPU_PC(pc1640, pc200, I8086, 8000000, pc_frame_interrupt)
17451752
r5959r5960
17821789
17831790
17841791static MACHINE_DRIVER_START( pc1512 )
1792   MDRV_DRIVER_DATA(pc_state)
17851793   /* basic machine hardware */
17861794   MDRV_CPU_PC(pc1640, pc1640, I8086, 8000000, pc_frame_interrupt)
17871795
r5959r5960
18261834
18271835
18281836static MACHINE_DRIVER_START( pc1640 )
1837   MDRV_DRIVER_DATA(pc_state)
18291838   /* basic machine hardware */
18301839   MDRV_CPU_PC(pc1640, pc1640, I8086, 8000000, pc_vga_frame_interrupt)
18311840
r5959r5960
18701879
18711880
18721881static MACHINE_DRIVER_START( xtvga )
1882   MDRV_DRIVER_DATA(pc_state)
18731883   /* basic machine hardware */
18741884   MDRV_CPU_PC(pc16, pc16, I8086, 12000000, pc_vga_frame_interrupt)
18751885
r5959r5960
19261936
19271937
19281938static MACHINE_DRIVER_START( t1000hx )
1939   MDRV_DRIVER_DATA(pc_state)
19291940   /* basic machine hardware */
19301941   MDRV_CPU_PC(tandy1000, tandy1000, I8088, 8000000, pc_frame_interrupt)
19311942
r5959r5960
19701981
19711982
19721983static MACHINE_DRIVER_START( t1000_16 )
1984   MDRV_DRIVER_DATA(pc_state)
19731985   /* basic machine hardware */
19741986   MDRV_CPU_PC(tandy1000_16, tandy1000_16, I8086, XTAL_28_63636MHz / 3, pc_frame_interrupt)
19751987
r5959r5960
20142026
20152027
20162028static MACHINE_DRIVER_START( ibmpcjr )
2029   MDRV_DRIVER_DATA(pc_state)
20172030   /* basic machine hardware */
20182031   MDRV_CPU_PC(ibmpcjr, ibmpcjr, I8088, 4900000, pcjr_frame_interrupt)   /* TODO: Get correct cpu frequency, probably XTAL_14_31818MHz/3 */
20192032

Previous 15994 Revisions Next


© 1998-2018 The MESS Team