Previous 199869 Revisions Next

r26107 Monday 11th November, 2013 at 19:51:19 UTC by Michael Zapf
(MESS) ti99: Made READY handling safer; more cleanups. (nw)
[src/mess/drivers]ti99_4x.c
[src/mess/machine/ti99]videowrp.c

trunk/src/mess/machine/ti99/videowrp.c
r26106r26107
226226
227227WRITE_LINE_MEMBER( ti_sound_system_device::sound_ready )
228228{
229   // Need to disable this until READY handling is properly implemented in the sound chip
230   // and in the console (otherwise external speech like in Parsec will be interrupted)
231   //m_console_ready(state);
229   m_console_ready(state);
232230}
233231
234232MACHINE_CONFIG_FRAGMENT( sn94624 )
trunk/src/mess/drivers/ti99_4x.c
r26106r26107
5454#include "machine/ti99/joyport.h"
5555#include "machine/ti99/peribox.h"
5656
57// Debugging
58#define TRACE_READY 0
59#define TRACE_INTERRUPTS 0
60#define TRACE_CRU 0
5761#define LOG logerror
58#define VERBOSE 1
5962
6063/*
6164    The console.
r26106r26107
9295   DECLARE_WRITE_LINE_MEMBER( dbin_line );
9396
9497   // Connections from outside towards the CPU (callbacks)
95   DECLARE_WRITE_LINE_MEMBER( console_ready );
9698   DECLARE_WRITE_LINE_MEMBER( console_ready_dmux );
99   DECLARE_WRITE_LINE_MEMBER( console_ready_sound );
100   DECLARE_WRITE_LINE_MEMBER( console_ready_pbox );
101   DECLARE_WRITE_LINE_MEMBER( console_ready_cart );
102   DECLARE_WRITE_LINE_MEMBER( console_ready_grom );
97103   DECLARE_WRITE_LINE_MEMBER( console_reset );
104   DECLARE_WRITE_LINE_MEMBER( extint );
105   DECLARE_WRITE_LINE_MEMBER( notconnected );
98106
99107   // Connections with the system interface chip 9901
100108   DECLARE_WRITE_LINE_MEMBER( set_tms9901_INT2 );
101109   DECLARE_WRITE_LINE_MEMBER( set_tms9901_INT12 );
102110   DECLARE_WRITE_LINE_MEMBER( set_tms9901_INT2_from_v9938);
103   DECLARE_WRITE_LINE_MEMBER( extint );
104   DECLARE_WRITE_LINE_MEMBER( notconnected );
105111
106112   // Connections with the system interface TMS9901
107113   DECLARE_READ8_MEMBER(read_by_9901);
r26106r26107
125131   int     m_keyboard_column;
126132   int     m_check_alphalock;
127133
128   int     m_ready_prev;       // for debugging purposes only
134   // READY handling
135   int     m_nready_combined;
136   int     m_nready_prev;
137   void    console_ready_join(int id, int state);
129138
130   // Latches the ready line from different sources
131   int     m_ready_line, m_ready_line_dmux;
132
133139   // Console type
134140   int    m_console;
135141
r26106r26107
156162};
157163
158164/*
165    READY bits.
166*/
167enum
168{
169   READY_GROM = 1,
170   READY_DMUX = 2,
171   READY_PBOX = 4,
172   READY_SOUND = 8,
173   READY_CART = 16
174};
175
176/*
159177    Memory map.
160178    Most of the work is done in the datamux (see datamux.c). We only keep ROM
161179    and the small 256 byte PAD RAM here because they are directly connected
r26106r26107
340358
341359static GROM_CONFIG(grom0_config)
342360{
343   false, 0, region_grom, 0x0000, 0x1800, DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready), GROMFREQ
361   false, 0, region_grom, 0x0000, 0x1800, DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready_grom), GROMFREQ
344362};
345363
346364static GROM_CONFIG(grom1_config)
347365{
348   false, 1, region_grom, 0x2000, 0x1800,  DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready), GROMFREQ
366   false, 1, region_grom, 0x2000, 0x1800,  DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready_grom), GROMFREQ
349367};
350368
351369static GROM_CONFIG(grom2_config)
352370{
353   false, 2, region_grom, 0x4000, 0x1800, DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready), GROMFREQ
371   false, 2, region_grom, 0x4000, 0x1800, DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready_grom), GROMFREQ
354372};
355373
356374static GROMPORT_CONFIG(console_cartslot)
357375{
358   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready),
376   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready_cart),
359377   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_reset)
360378};
361379
r26106r26107
363381{
364382   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, extint),            // INTA
365383   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, notconnected),  // INTB
366   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready), // READY
384   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready_pbox), // READY
367385   0x70000                                             // Address bus prefix (AMA/AMB/AMC)
368386};
369387
370388static TI_SOUND_CONFIG( sound_conf )
371389{
372   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready)  // READY
390   DEVCB_DRIVER_LINE_MEMBER(ti99_4x_state, console_ready_sound)  // READY
373391};
374392
375393READ8_MEMBER( ti99_4x_state::cruread )
376394{
377//  if (VERBOSE>6) LOG("read access to CRU address %04x\n", offset << 4);
395//  if (TRACE_CRU) LOG("read access to CRU address %04x\n", offset << 4);
378396   UINT8 value = 0;
379397
380398   // Similar to the bus8z_devices, just let the gromport and the p-box
r26106r26107
390408
391409WRITE8_MEMBER( ti99_4x_state::cruwrite )
392410{
393   if (VERBOSE>6) LOG("ti99_4x: write access to CRU address %04x\n", offset << 1);
411   if (TRACE_CRU) LOG("ti99_4x: write access to CRU address %04x\n", offset << 1);
394412   // The QI version does not propagate the CRU signals to the cartridge slot
395413   if (m_console != MODEL_4QI) m_gromport->cruwrite(space, offset<<1, data);
396414   m_peribox->cruwrite(space, offset<<1, data);
r26106r26107
403421   if (offset == IDLE_OP) return;
404422   else
405423   {
406      if (VERBOSE>1) LOG("ti99_4x: External operation %s not implemented on TI-99 board\n", extop[offset]);
424      LOG("ti99_4x: External operation %s not implemented on TI-99 board\n", extop[offset]);
407425   }
408426}
409427
r26106r26107
637655*/
638656WRITE_LINE_MEMBER( ti99_4x_state::set_tms9901_INT2 )
639657{
640   if (VERBOSE>6) LOG("ti99_4x: VDP int 2 on tms9901, level=%d\n", state);
658   if (TRACE_INTERRUPTS) LOG("ti99_4x: VDP int 2 on tms9901, level=%d\n", state);
641659   m_tms9901->set_single_int(2, state);
642660}
643661
644662WRITE_LINE_MEMBER(ti99_4x_state::set_tms9901_INT2_from_v9938)
645663{
664   if (TRACE_INTERRUPTS) LOG("ti99_4x: VDP int 2 on tms9901, level=%d\n", state);
646665   m_tms9901->set_single_int(2, state);
647666}
648667
r26106r26107
651670*/
652671WRITE_LINE_MEMBER( ti99_4x_state::set_tms9901_INT12)
653672{
673   if (TRACE_INTERRUPTS) LOG("ti99_4x: joyport INT 12 on tms9901, level=%d\n", state);
654674   m_tms9901->set_single_int(12, state);
655675}
656676
r26106r26107
660680*/
661681INPUT_CHANGED_MEMBER( ti99_4x_state::load_interrupt )
662682{
683   LOG("ti99_4x: LOAD interrupt, level=%d\n", newval);
663684   m_cpu->set_input_line(INT_9900_LOAD, (newval==0)? ASSERT_LINE : CLEAR_LINE);
664685}
665686
r26106r26107
667688    Links to external devices
668689***********************************************************/
669690
670// FIXME: The sound chip is one of the devices that may operate the ready line
671// at some later time and thus mess up the READY handling (raises the READY
672// line without bothering about the rest). We need to do a proper AND here.
673
674691/*
675    We may have lots of devices pulling down this line; so we should use a AND
676    gate to do it right. On the other hand, when READY is down, there is just
677    no chance to make another device pull down the same line; the CPU just
678    won't access any other device in this time.
692    We combine the incoming READY signals and propagate them to the CPU.
693    An alternative would be to let the CPU get the READY state, but this would
694    be a much higher overhead, as this happens in each clock tick.
679695*/
680WRITE_LINE_MEMBER( ti99_4x_state::console_ready )
696void ti99_4x_state::console_ready_join(int id, int state)
681697{
682   m_ready_line = state;
683   int combined = (m_ready_line == ASSERT_LINE && m_ready_line_dmux == ASSERT_LINE)? ASSERT_LINE : CLEAR_LINE;
698   if (state==CLEAR_LINE)
699      m_nready_combined |= id;
700   else
701      m_nready_combined &= ~id;
684702
685   if (VERBOSE>6)
703   if (TRACE_READY)
686704   {
687      if (m_ready_prev != combined) LOG("ti99_4x: READY level = %d\n", combined);
705      if (m_nready_prev != m_nready_combined) LOG("ti99_4x: READY bits = %04x\n", ~m_nready_combined);
688706   }
689   m_ready_prev = combined;
690   m_cpu->set_ready(combined);
707
708   m_nready_prev = m_nready_combined;
709   m_cpu->set_ready(m_nready_combined==0);
691710}
692711
693712/*
694    The RESET line leading to a reset of the CPU.
713    Connections to the READY line. This might look a bit ugly; we need an
714    implementation of a "Wired AND" device.
695715*/
696WRITE_LINE_MEMBER( ti99_4x_state::console_reset )
716WRITE_LINE_MEMBER( ti99_4x_state::console_ready_grom )
697717{
698   if (machine().phase() != MACHINE_PHASE_INIT)
699   {
700      m_cpu->set_input_line(INT_9900_RESET, state);
701      m_video->reset_vdp(state);
702   }
718   console_ready_join(READY_GROM, state);
703719}
704720
721WRITE_LINE_MEMBER( ti99_4x_state::console_ready_dmux )
722{
723   console_ready_join(READY_DMUX, state);
724}
725
726WRITE_LINE_MEMBER( ti99_4x_state::console_ready_pbox )
727{
728   console_ready_join(READY_PBOX, state);
729}
730
731WRITE_LINE_MEMBER( ti99_4x_state::console_ready_sound )
732{
733   console_ready_join(READY_SOUND, state);
734}
735
736WRITE_LINE_MEMBER( ti99_4x_state::console_ready_cart )
737{
738   console_ready_join(READY_CART, state);
739}
740
705741/*
706    The exception of the above rule. Memory access over the datamux also operates
707    the READY line, and the datamux raises READY depending on the clock pulse.
708    So we must make sure this does not interfere.
742    The RESET line leading to a reset of the CPU. This is asserted when a
743    cartridge is plugged in.
709744*/
710WRITE_LINE_MEMBER( ti99_4x_state::console_ready_dmux )
745WRITE_LINE_MEMBER( ti99_4x_state::console_reset )
711746{
712   m_ready_line_dmux = state;
713   int combined = (m_ready_line == ASSERT_LINE && m_ready_line_dmux == ASSERT_LINE)? ASSERT_LINE : CLEAR_LINE;
714
715   if (VERBOSE>7)
747   if (machine().phase() != MACHINE_PHASE_INIT)
716748   {
717      if (m_ready_prev != combined) LOG("ti99_4x: READY dmux level = %d\n", state);
749      m_cpu->set_input_line(INT_9900_RESET, state);
750      m_video->reset_vdp(state);
718751   }
719   m_ready_prev = combined;
720   m_cpu->set_ready(combined);
721752}
722753
723754WRITE_LINE_MEMBER( ti99_4x_state::extint )
724755{
725   if (VERBOSE>6) LOG("ti99_4x: EXTINT level = %02x\n", state);
756   if (TRACE_INTERRUPTS) LOG("ti99_4x: EXTINT level = %02x\n", state);
726757   if (m_tms9901 != NULL)
727758      m_tms9901->set_single_int(1, state);
728759}
729760
730761WRITE_LINE_MEMBER( ti99_4x_state::notconnected )
731762{
732   if (VERBOSE>6) LOG("ti99_4x: Setting a not connected line ... ignored\n");
763   if (TRACE_INTERRUPTS) LOG("ti99_4x: Setting a not connected line ... ignored\n");
733764}
734765
735766/*****************************************************************************/
r26106r26107
892923{
893924   m_peribox->senila(CLEAR_LINE);
894925   m_peribox->senilb(CLEAR_LINE);
895   m_ready_line = m_ready_line_dmux = ASSERT_LINE;
896
926   m_nready_combined = 0;
897927   m_console = MODEL_4;
898928}
899929
r26106r26107
9971027{
9981028   m_peribox->senila(CLEAR_LINE);
9991029   m_peribox->senilb(CLEAR_LINE);
1000   m_ready_line = m_ready_line_dmux = ASSERT_LINE;
1030   m_nready_combined = 0;
10011031   m_console = MODEL_4A;
10021032}
10031033
r26106r26107
11041134{
11051135   m_peribox->senila(CLEAR_LINE);
11061136   m_peribox->senilb(CLEAR_LINE);
1107   m_ready_line = m_ready_line_dmux = ASSERT_LINE;
11081137   m_console = MODEL_4QI;
1138   m_nready_combined = 0;
11091139}
11101140
11111141static MACHINE_CONFIG_START( ti99_4qi_60hz, ti99_4x_state )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team