Previous 15994 Revisions Next

r6967 Thursday 7th January, 2010 at 11:44:58 UTC by Curt Coder
[VIA6522] Refactored interface to use devcb properly.
[src/emu/machine]6522via.c 6522via.h
[src/mess/drivers]atom.c bbc.c oric.c vic20.c
[src/mess/machine]aim65.c apple3.c bbc.c c1541.c c1571.c lisa.c mac.c microtan.c oric.c pet.c vectrex.c
[src/mess/video]aim65.c vectrex.c

src/emu/machine/6522via.c
r6966r6967
931931    CA1 input
932932-------------------------------------------------*/
933933
934READ8_DEVICE_HANDLER(via_ca1_r)
934READ_LINE_DEVICE_HANDLER(via_ca1_r)
935935{
936936   via6522_t *v = get_token(device);
937937   return v->in_ca1;
r6966r6967
943943    CA1 input
944944-------------------------------------------------*/
945945
946WRITE8_DEVICE_HANDLER(via_ca1_w)
946WRITE_LINE_DEVICE_HANDLER(via_ca1_w)
947947{
948948   via6522_t *v = get_token(device);
949949
950   /* limit the data to 0 or 1 */
951   data = data ? 1 : 0;
952
953950   /* handle the active transition */
954   if (data != v->in_ca1)
951   if (state != v->in_ca1)
955952    {
956953      if (TRACE_VIA)
957         logerror("%s:6522VIA chip %s: CA1 = %02X\n", cpuexec_describe_context(device->machine), device->tag, data);
954         logerror("%s:6522VIA chip %s: CA1 = %02X\n", cpuexec_describe_context(device->machine), device->tag, state);
958955
959      if ((CA1_LOW_TO_HIGH(v->pcr) && data) || (CA1_HIGH_TO_LOW(v->pcr) && !data))
956      if ((CA1_LOW_TO_HIGH(v->pcr) && state) || (CA1_HIGH_TO_LOW(v->pcr) && !state))
960957      {
961958         if (PA_LATCH_ENABLE(v->acr))
962959         {
r6966r6967
983980         }
984981      }
985982
986      v->in_ca1 = data;
983      v->in_ca1 = state;
987984    }
988985}
989986
r6966r6967
993990    CA2 input
994991-------------------------------------------------*/
995992
996READ8_DEVICE_HANDLER(via_ca2_r)
993READ_LINE_DEVICE_HANDLER(via_ca2_r)
997994{
998995   via6522_t *v = get_token(device);
999996   return v->in_ca2;
r6966r6967
10051002    CA2 input
10061003-------------------------------------------------*/
10071004
1008WRITE8_DEVICE_HANDLER(via_ca2_w)
1005WRITE_LINE_DEVICE_HANDLER(via_ca2_w)
10091006{
10101007   via6522_t *v = get_token(device);
10111008
1012   /* limit the data to 0 or 1 */
1013   data = data ? 1 : 0;
1014
10151009   /* CA2 is in input mode */
10161010   if (CA2_INPUT(v->pcr))
10171011    {
10181012      /* the new state has caused a transition */
1019      if (v->in_ca2 != data)
1013      if (v->in_ca2 != state)
10201014      {
10211015         /* handle the active transition */
1022         if ((data && CA2_LOW_TO_HIGH(v->pcr)) || (!data && CA2_HIGH_TO_LOW(v->pcr)))
1016         if ((state && CA2_LOW_TO_HIGH(v->pcr)) || (!state && CA2_HIGH_TO_LOW(v->pcr)))
10231017         {
10241018            /* mark the IRQ */
10251019            via_set_int (device, INT_CA2);
10261020         }
10271021         /* set the new value for CA2 */
1028         v->in_ca2 = data;
1022         v->in_ca2 = state;
10291023      }
10301024    }
10311025
r6966r6967
10641058    CB1 input
10651059-------------------------------------------------*/
10661060
1067READ8_DEVICE_HANDLER(via_cb1_r)
1061READ_LINE_DEVICE_HANDLER(via_cb1_r)
10681062{
10691063   via6522_t *v = get_token(device);
10701064   return v->in_cb1;
r6966r6967
10761070    CB1 input
10771071-------------------------------------------------*/
10781072
1079WRITE8_DEVICE_HANDLER(via_cb1_w)
1073WRITE_LINE_DEVICE_HANDLER(via_cb1_w)
10801074{
10811075   via6522_t *v = get_token(device);
10821076
1083   /* limit the data to 0 or 1 */
1084   data = data ? 1 : 0;
1085
10861077   /* handle the active transition */
1087   if (data != v->in_cb1)
1078   if (state != v->in_cb1)
10881079    {
1089      if ((CB1_LOW_TO_HIGH(v->pcr) && data) || (CB1_HIGH_TO_LOW(v->pcr) && !data))
1080      if ((CB1_LOW_TO_HIGH(v->pcr) && state) || (CB1_HIGH_TO_LOW(v->pcr) && !state))
10901081      {
10911082         if (PB_LATCH_ENABLE(v->acr))
10921083         {
r6966r6967
11141105            }
11151106         }
11161107      }
1117      v->in_cb1 = data;
1108      v->in_cb1 = state;
11181109    }
11191110}
11201111
r6966r6967
11241115    CB2 input
11251116-------------------------------------------------*/
11261117
1127READ8_DEVICE_HANDLER(via_cb2_r)
1118READ_LINE_DEVICE_HANDLER(via_cb2_r)
11281119{
11291120   via6522_t *v = get_token(device);
11301121   return v->in_cb2;
r6966r6967
11361127    CB2 input
11371128-------------------------------------------------*/
11381129
1139WRITE8_DEVICE_HANDLER(via_cb2_w)
1130WRITE_LINE_DEVICE_HANDLER(via_cb2_w)
11401131{
11411132   via6522_t *v = get_token(device);
11421133
1143   /* limit the data to 0 or 1 */
1144   data = data ? 1 : 0;
1145
11461134   /* CB2 is in input mode */
11471135   if (CB2_INPUT(v->pcr))
11481136    {
11491137      /* the new state has caused a transition */
1150      if (v->in_cb2 != data)
1138      if (v->in_cb2 != state)
11511139      {
11521140         /* handle the active transition */
1153         if ((data && CB2_LOW_TO_HIGH(v->pcr)) || (!data && CB2_HIGH_TO_LOW(v->pcr)))
1141         if ((state && CB2_LOW_TO_HIGH(v->pcr)) || (!state && CB2_HIGH_TO_LOW(v->pcr)))
11541142         {
11551143            /* mark the IRQ */
11561144            via_set_int (device, INT_CB2);
11571145         }
11581146         /* set the new value for CB2 */
1159         v->in_cb2 = data;
1147         v->in_cb2 = state;
11601148      }
11611149    }
11621150}
src/emu/machine/6522via.h
r6966r6967
8282READ8_DEVICE_HANDLER(via_portb_r);
8383WRITE8_DEVICE_HANDLER(via_portb_w);
8484
85READ8_DEVICE_HANDLER(via_ca1_r);
86WRITE8_DEVICE_HANDLER(via_ca1_w);
85READ_LINE_DEVICE_HANDLER(via_ca1_r);
86WRITE_LINE_DEVICE_HANDLER(via_ca1_w);
8787
88READ8_DEVICE_HANDLER(via_ca2_r);
89WRITE8_DEVICE_HANDLER(via_ca2_w);
88READ_LINE_DEVICE_HANDLER(via_ca2_r);
89WRITE_LINE_DEVICE_HANDLER(via_ca2_w);
9090
91READ8_DEVICE_HANDLER(via_cb1_r);
92WRITE8_DEVICE_HANDLER(via_cb1_w);
91READ_LINE_DEVICE_HANDLER(via_cb1_r);
92WRITE_LINE_DEVICE_HANDLER(via_cb1_w);
9393
94READ8_DEVICE_HANDLER(via_cb2_r);
95WRITE8_DEVICE_HANDLER(via_cb2_w);
94READ_LINE_DEVICE_HANDLER(via_cb2_r);
95WRITE_LINE_DEVICE_HANDLER(via_cb2_w);
9696
9797#endif /* __6522VIA_H__ */
src/mess/video/vectrex.c
r6966r6967
9999   if (vectrex_lightpen_port & 1)
100100   {
101101      const device_config *via_0 = devtag_get_device(machine, "via6522_0");
102      via_ca1_w(via_0, 0, 1);
103      via_ca1_w(via_0, 0, 0);
102      via_ca1_w(via_0, 1);
103      via_ca1_w(via_0, 0);
104104   }
105105
106106   if (vectrex_lightpen_port & 2)
src/mess/video/aim65.c
r6966r6967
8686{
8787   const device_config *via_0 = devtag_get_device(machine, "via6522_0");
8888
89   via_cb1_w(via_0, 0, printer_level);
90   via_ca1_w(via_0, 0, !printer_level);
89   via_cb1_w(via_0, printer_level);
90   via_ca1_w(via_0, !printer_level);
9191   printer_level = !printer_level;
9292   aim65_printer_inc();
9393}
r6966r6967
9999   {
100100      aim65_printer_cr();
101101      timer_adjust_periodic(print_timer, attotime_zero, 0, ATTOTIME_IN_USEC(10));
102      via_cb1_w(device, 0, 0);
102      via_cb1_w(device, 0);
103103      printer_level = 1;
104104   }
105105   else
src/mess/machine/apple3.c
r6966r6967
265265{
266266   const device_config *via_1 = devtag_get_device(device->machine, "via6522_1");
267267
268   via_ca2_w(via_1, 0, (AY3600_keydata_strobe_r() & 0x80) ? 1 : 0);
269   via_cb1_w(via_1, 0, video_screen_get_vblank(device->machine->primary_screen));
270   via_cb2_w(via_1, 0, video_screen_get_vblank(device->machine->primary_screen));
268   via_ca2_w(via_1, (AY3600_keydata_strobe_r() & 0x80) ? 1 : 0);
269   via_cb1_w(via_1, video_screen_get_vblank(device->machine->primary_screen));
270   via_cb2_w(via_1, video_screen_get_vblank(device->machine->primary_screen));
271271}
272272
273273
src/mess/machine/aim65.c
r6966r6967
175175   /* Init RAM */
176176   memory_install_ram(space, 0x0000, messram_get_size(ram) - 1, 0, 0, messram_get_ptr(ram));
177177
178   via_cb1_w(via_0, 1, 1);
179   via_ca1_w(via_0, 1, 0);
178   via_cb1_w(via_0, 1);
179   via_ca1_w(via_0, 0);
180180}
181181
182182
src/mess/machine/pet.c
r6966r6967
604604   const device_config *via_0 = devtag_get_device(machine, "via6522_0");
605605//  cassette 2
606606   UINT8 data = (cassette_input(devtag_get_device(machine, "cassette2")) > +0.0) ? 1 : 0;
607   via_cb1_w(via_0, 0, data);
607   via_cb1_w(via_0, data);
608608}
609609
610610
src/mess/machine/oric.c
r6966r6967
302302      data = input_port_9>>4;
303303   }
304304
305   via_cb1_w(via_0, 0, data);
305   via_cb1_w(via_0, data);
306306}
307307
308308static unsigned char previous_portb_data = 0;
src/mess/machine/c1541.c
r6966r6967
283283      int byte_ready = !(byte && c1541->soe);
284284
285285      cpu_set_input_line(c1541->cpu, M6502_SET_OVERFLOW, byte_ready);
286      via_ca1_w(c1541->via1, 0, byte_ready);
286      via_ca1_w(c1541->via1, byte_ready);
287287
288288      c1541->byte = byte;
289289   }
r6966r6967
298298   c1541_t *c1541 = get_safe_token(device);
299299   int data_out = !c1541->data_out && !(c1541->atna ^ !state);
300300
301   via_ca1_w(c1541->via0, 0, !state);
301   via_ca1_w(c1541->via0, !state);
302302
303303   cbm_iec_data_w(c1541->serial_bus, device, data_out);
304304}
r6966r6967
786786   c1541->soe = state;
787787
788788   cpu_set_input_line(c1541->cpu, M6502_SET_OVERFLOW, byte_ready);
789   via_ca1_w(device, 0, byte_ready);
789   via_ca1_w(device, byte_ready);
790790}
791791
792792static WRITE_LINE_DEVICE_HANDLER( mode_w )
src/mess/machine/microtan.c
r6966r6967
344344
345345   LOG(("microtan_read_cassette: %g\n", level));
346346   if (level < -0.07)
347      via_cb2_w(via_0, 0, 0);
347      via_cb2_w(via_0, 0);
348348   else if (level > +0.07)
349      via_cb2_w(via_0, 0, 1);
349      via_cb2_w(via_0, 1);
350350}
351351
352352READ8_HANDLER( microtan_sound_r )
src/mess/machine/mac.c
r6966r6967
570570      {
571571         /* Put data on CB2 if we are sending*/
572572         if (mac->kbd_receive == FALSE)
573            via_cb2_w(via_0, 0, mac->kbd_shift_reg&0x80?1:0);
573            via_cb2_w(via_0, mac->kbd_shift_reg&0x80?1:0);
574574         mac->kbd_shift_reg <<= 1;
575         via_cb1_w(via_0, 0, 0);
576         via_cb1_w(via_0, 0, 1);
575         via_cb1_w(via_0, 0);
576         via_cb1_w(via_0, 1);
577577      }
578578      if (mac->kbd_receive == TRUE)
579579      {
r6966r6967
17821782
17831783   // do one clock transition on CB1 to advance the VIA shifter
17841784   mac->adb_extclock ^= 1;
1785   via_cb1_w(via_0, 0, mac->adb_extclock);
1785   via_cb1_w(via_0, mac->adb_extclock);
17861786   mac->adb_extclock ^= 1;
1787   via_cb1_w(via_0, 0, mac->adb_extclock);
1787   via_cb1_w(via_0, mac->adb_extclock);
17881788
17891789   mac->adb_timer_ticks--;
17901790   if (!mac->adb_timer_ticks)
r6966r6967
25232523//   printf("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08);
25242524
25252525   // chain 60.15 Hz to VIA1
2526   via_ca1_w(via_0, 0, data>>7);
2526   via_ca1_w(via_0, data>>7);
25272527}
25282528
25292529/* *************************************************************************
r6966r6967
28682868      const device_config *via_1 = devtag_get_device(machine, "via6522_1");
28692869
28702870      mac->via2_ca1 ^= 1;
2871      via_ca1_w(via_1, 0, mac->via2_ca1);
2871      via_ca1_w(via_1, mac->via2_ca1);
28722872   }
28732873}
28742874
r6966r6967
29042904   if (mac->mac_model < MODEL_MAC_II)
29052905   {
29062906      ca1_data ^= 1;
2907      via_ca1_w(via_0, 0, ca1_data);
2907      via_ca1_w(via_0, ca1_data);
29082908   }
29092909
29102910   if (++irq_count == 60)
r6966r6967
29132913
29142914      ca2_data ^= 1;
29152915      /* signal 1 Hz irq on CA2 input on the VIA */
2916      via_ca2_w(via_0, 0, ca2_data);
2916      via_ca2_w(via_0, ca2_data);
29172917
29182918      rtc_incticks(mac);
29192919   }
src/mess/machine/vectrex.c
r6966r6967
295295         timer_set (machine, double_to_attotime(rtime * 0.50), NULL, 1, vectrex_imager_eye);
296296
297297         /* Index hole sensor is connected to IO7 which triggers also CA1 of VIA */
298         via_ca1_w(via_0, 0, 1);
299         via_ca1_w(via_0, 0, 0);
298         via_ca1_w(via_0, 1);
299         via_ca1_w(via_0, 0);
300300         vectrex_imager_pinlevel |= 0x80;
301301         timer_set (machine, double_to_attotime(rtime / 360.0), &vectrex_imager_pinlevel, 0, update_level);
302302      }
src/mess/machine/lisa.c
r6966r6967
351351         mouse_data_offset = -1;   /* we just phased out the mouse data in buffer */
352352      fifo_head = (fifo_head+1) & 0x7;
353353      fifo_size--;
354      via_ca1_w(via_0, 0, 1);      /* pulse ca1 so that VIA reads it */
355      via_ca1_w(via_0, 0, 0);      /* BTW, I have no idea how a real COPS does it ! */
354      via_ca1_w(via_0, 1);      /* pulse ca1 so that VIA reads it */
355      via_ca1_w(via_0, 0);      /* BTW, I have no idea how a real COPS does it ! */
356356   }
357357}
358358
src/mess/machine/c1571.c
r6966r6967
163163      int byte_ready = !(byte && c1571->soe);
164164
165165      cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
166      via_ca1_w(c1571->via1, 0, byte_ready);
166      via_ca1_w(c1571->via1, byte_ready);
167167
168168      c1571->byte = byte;
169169   }
r6966r6967
178178   c1571_t *c1571 = get_safe_token(device);
179179   int data_out = !c1571->data_out && !(c1571->atn_ack ^ !state);
180180
181   via_ca1_w(c1571->via0, 0, !state);
181   via_ca1_w(c1571->via0, !state);
182182
183183   cbm_iec_data_w(c1571->serial_bus, device, data_out);
184184}
r6966r6967
547547   c1571->soe = state;
548548
549549   cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
550   via_ca1_w(device, 0, byte_ready);
550   via_ca1_w(device, byte_ready);
551551}
552552
553553static WRITE_LINE_DEVICE_HANDLER( mode_w )
src/mess/machine/bbc.c
r6966r6967
829829                 being pressed on the selected column */
830830         if ((input_port_read(device->machine, colnames[column]) | 0x01) != 0xff)
831831         {
832            via_ca2_w(via_0, 0, 1);
832            via_ca2_w(via_0, 1);
833833         }
834834         else
835835         {
836            via_ca2_w(via_0, 0, 0);
836            via_ca2_w(via_0, 0);
837837         }
838838
839839      }
840840      else
841841      {
842         via_ca2_w(via_0, 0, 0);
842         via_ca2_w(via_0, 0);
843843      }
844844   }
845845}
r6966r6967
869869                 being pressed on the selected column */
870870         if ((input_port_read(device->machine, colnames[column]) | 0x01) != 0xff)
871871         {
872            via_ca2_w(via_0, 0, 1);
872            via_ca2_w(via_0, 1);
873873         }
874874         else
875875         {
876            via_ca2_w(via_0, 0, 0);
876            via_ca2_w(via_0, 0);
877877         }
878878
879879      }
880880      else
881881      {
882         via_ca2_w(via_0, 0, 0);
882         via_ca2_w(via_0, 0);
883883      }
884884   }
885885}
r6966r6967
919919
920920   if ((res | 1) != 0xff)
921921   {
922      via_ca2_w(via_0, 0, 1);
922      via_ca2_w(via_0, 1);
923923   }
924924   else
925925   {
926      via_ca2_w(via_0, 0, 0);
926      via_ca2_w(via_0, 0);
927927   }
928928
929929   return (data & 0x7f) | (bit<<7);
r6966r6967
13431343static UPD7002_EOC(BBC_uPD7002_EOC)
13441344{
13451345   const device_config *via_0 = devtag_get_device(device->machine, "via6522_0");
1346   via_cb1_w(via_0, 0,data);
1346   via_cb1_w(via_0, data);
13471347}
13481348
13491349const uPD7002_interface bbc_uPD7002 =
src/mess/drivers/vic20.c
r6966r6967
149149   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
150150 
151151   PORT_START( "SPECIAL" )  /* special keys */
152//   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) PORT_WRITE_LINE_DEVICE(M6522_0_TAG, via_ca1_w)
152   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Restore") PORT_CODE(KEYCODE_PRTSCR) PORT_WRITE_LINE_DEVICE(M6522_0_TAG, via_ca1_w)
153153   PORT_DIPNAME( 0x01, 0x00, "Shift Lock (switch)") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE
154154   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
155155   PORT_DIPSETTING(   0x01, DEF_STR( On ) )
r6966r6967
455455   vic20_state *state = timer->machine->driver_data;
456456   int data = (cassette_input(state->cassette) > +0.0) ? 1 : 0;
457457   
458   via_ca1_w(state->via1, 0, data);
458   via_ca1_w(state->via1, data);
459459}
460460 
461461/* IEC Serial Bus */
r6966r6967
463463static CBM_IEC_DAISY( cbm_iec_daisy )
464464{
465465   { M6522_0_TAG },
466   { M6522_1_TAG, DEVCB_DEVICE_HANDLER(M6522_1_TAG, via_cb1_w) },
466   { M6522_1_TAG, DEVCB_DEVICE_LINE(M6522_1_TAG, via_cb1_w) },
467467   { C1541_IEC(C1540_TAG) },
468468   { NULL}
469469};
src/mess/drivers/oric.c
r6966r6967
355355static const centronics_interface oric_centronics_config =
356356{
357357   FALSE,
358   DEVCB_DEVICE_HANDLER("via6522_0", via_ca1_w),
358   DEVCB_DEVICE_LINE("via6522_0", via_ca1_w),
359359   DEVCB_NULL,
360360   DEVCB_NULL
361361};
src/mess/drivers/atom.c
r6966r6967
251251static const centronics_interface atom_centronics_config =
252252{
253253   FALSE,
254   DEVCB_DEVICE_HANDLER("via6522_0", via_ca1_w),
254   DEVCB_DEVICE_LINE("via6522_0", via_ca1_w),
255255   DEVCB_NULL,
256256   DEVCB_NULL
257257};
src/mess/drivers/bbc.c
r6966r6967
711711static INTERRUPT_GEN( bbcb_vsync )
712712{
713713   const device_config *via_0 = devtag_get_device(device->machine, "via6522_0");
714   via_ca1_w(via_0, 0,1);
715   via_ca1_w(via_0, 0,0);
714   via_ca1_w(via_0, 1);
715   via_ca1_w(via_0, 0);
716716   bbc_frameclock();
717717}
718718
r6966r6967
735735
736736static WRITE_LINE_DEVICE_HANDLER(bbcb_ack_w)
737737{
738   via_ca1_w(device, 0, !state); /* ack seems to be inverted? */
738   via_ca1_w(device, !state); /* ack seems to be inverted? */
739739}
740740
741741static const centronics_interface bbcb_centronics_config =

Previous 15994 Revisions Next


© 1998-2018 The MESS Team