1717#include " machine/nscsi_bus.h"
1818#include " machine/nvram.h"
1919#include " video/ramdac.h"
20+ #include " machine/rescap.h"
2021#include " machine/scc66470.h"
22+ #include " machine/watchdog.h"
2123#include " sound/ymz280b.h"
2224#include " screen.h"
2325#include " speaker.h"
@@ -37,15 +39,17 @@ class bfm_cobra3_state : public driver_device
3739 m_palette(*this , " palette" ),
3840 m_ramdac(*this , " ramdac" ),
3941 m_scc66470(*this , " scc66470" ),
40- // m_strobein(*this, "STROBE%u", 0),
42+ m_strobein(*this , " STROBE%u" , 0 ),
4143 m_meters(*this , " meters" ),
4244 m_lamps(*this , " lamp%u" , 0U ),
4345 m_scsibus(*this , " scsi" ),
44- m_scsic(*this , " scsi:6:ncr5380" )
46+ m_scsic(*this , " scsi:6:ncr5380" ),
47+ m_watchdog(*this , " watchdog" )
4548 { }
4649
4750 std::unique_ptr<uint16_t []> m_mainram;
4851
52+ void volume_control (uint8_t direction, uint8_t clock);
4953 uint16_t bfm_cobra3_mem_r (offs_t offset, uint16_t mem_mask = ~0 );
5054 void bfm_cobra3_mem_w (offs_t offset, uint16_t data, uint16_t mem_mask = ~0 );
5155
@@ -64,12 +68,17 @@ class bfm_cobra3_state : public driver_device
6468 required_device<palette_device> m_palette;
6569 required_device<ramdac_device> m_ramdac;
6670 required_device<scc66470_device> m_scc66470;
67- // required_ioport_array<4 > m_strobein;
71+ required_ioport_array<5 > m_strobein;
6872 optional_device<meters_device> m_meters;
6973 output_finder<256 > m_lamps;
7074 required_device<nscsi_bus_device> m_scsibus;
7175 required_device<ncr5380_device> m_scsic;
76+ required_device<watchdog_timer_device> m_watchdog;
7277
78+ uint8_t m_active_strobe;
79+ uint8_t m_triac_latch;
80+ uint8_t m_vol_clock;
81+ uint8_t m_volume;
7382
7483 virtual void machine_start () override ATTR_COLD;
7584 static void scsi_devices (device_slot_interface &device);
@@ -79,6 +88,32 @@ class bfm_cobra3_state : public driver_device
7988
8089};
8190
91+ void bfm_cobra3_state::volume_control (uint8_t direction, uint8_t clock)
92+ {
93+ int clock_changed = m_vol_clock^clock;
94+
95+ m_vol_clock = clock;
96+ if ( clock_changed )
97+ { // digital volume clock line changed
98+ if ( !(clock) )
99+ { // changed from high to low,
100+ if ( !(direction) )
101+ {
102+ if ( m_volume < 31 ) m_volume++; // 0-31 expressed as 1-32
103+ }
104+ else
105+ {
106+ if ( m_volume > 0 ) m_volume--;
107+ }
108+
109+ float percent = (64 - m_volume) / 64 .0f ;
110+
111+ m_ymz->set_output_gain (0 , percent);
112+ m_ymz->set_output_gain (1 , percent);
113+ }
114+ }
115+ }
116+
82117uint16_t bfm_cobra3_state::bfm_cobra3_mem_r (offs_t offset, uint16_t mem_mask)
83118{
84119 int cs = m_maincpu->get_cs (offset * 2 );
@@ -105,10 +140,10 @@ uint16_t bfm_cobra3_state::bfm_cobra3_mem_r(offs_t offset, uint16_t mem_mask)
105140 break ;
106141
107142 case 0x400 :
108- // input reads, haven't got far enough to trigger any
109- logerror ( " %s maincpu read access offset %08x mem_mask %08x cs %d \n " , machine (). describe_context (), offset* 4 , mem_mask, cs);
110- break ;
111-
143+ {
144+ // input reads, haven't got far enough to trigger any
145+ return m_strobein[m_active_strobe]-> read () ;
146+ }
112147 case 0x500 : // SCSI DMA
113148 if (ACCESSING_BITS_8_15)
114149 {
@@ -168,21 +203,41 @@ void bfm_cobra3_state::bfm_cobra3_mem_w(offs_t offset, uint16_t data, uint16_t m
168203 switch (cs_addr_8_11)
169204 {
170205 case 0x000 :
171- logerror (" %s maincpu write access lamp drive io latch offset %08x mem_mask %08x cs %d\n " , machine ().describe_context (), offset*4 , mem_mask, cs);
206+ logerror (" %s maincpu write access lamp drive io latch offset %08x data %08x mem_mask %08x cs %d\n " , machine ().describe_context (), offset*4 , data , mem_mask, cs);
172207 // lamps;
173208 break ;
174209
175210 case 0x100 :
176- logerror (" %s maincpu write access lockout latch offset %08x mem_mask %08x cs %d\n " , machine ().describe_context (), offset*4 , mem_mask, cs);
177- if (ACCESSING_BITS_8_15)
178- {
179- // coin lockout and optional vfd (debug only?)
180- }
211+ logerror (" %s maincpu write access lockout latch offset %08x data %08x mem_mask %08x cs %d\n " , machine ().describe_context (), offset*4 , data, mem_mask, cs);
212+ // TODO, does this need the ACCESSING_BITS_8_15?
213+ // coin lockout and optional vfd (debug only?)
181214 break ;
182215
183216 case 0x200 :
184- logerror (" %s maincpu write access io latch offset %08x mem_mask %08x cs %d\n " , machine ().describe_context (), offset*4 , mem_mask, cs);
185- // volume, watchdog and other stuff ? That's where it would be elsewhere
217+ if (data > 0x100 )
218+ {
219+ logerror (" %s maincpu write access io latch offset %08x data %08x mem_mask %08x cs %d\n " , machine ().describe_context (), offset*4 , data, mem_mask, cs);
220+ }
221+ for (int i=0 ; i<4 ; i++)
222+ {
223+ m_meters->update (i, BIT (data, i));
224+
225+ }
226+ for (int i=4 ; i<6 ; i++)
227+ {
228+ // triacs
229+ }
230+ m_triac_latch = BIT (data, 9 );
231+ volume_control (BIT (data,7 ), BIT (data,15 ));
232+ m_watchdog->reset_line_w (BIT (data , 8 ));
233+
234+ for (int i=10 ; i<15 ; i++)
235+ {
236+ if (BIT (data, i))
237+ {
238+ m_active_strobe = i - 10 ;
239+ }
240+ }
186241 break ;
187242
188243 case 0x300 :
@@ -302,11 +357,23 @@ static INPUT_PORTS_START( bfm_cobra3 )
302357 PORT_BIT( 0x40 , IP_ACTIVE_HIGH, IPT_BUTTON14 )
303358 PORT_BIT( 0x80 , IP_ACTIVE_HIGH, IPT_BUTTON15 )
304359
360+ PORT_START(" STROBE4" )
361+ PORT_DIPUNKNOWN_DIPLOC( 0x01 , 0x00 , " DIL:!01" )
362+ PORT_DIPUNKNOWN_DIPLOC( 0x02 , 0x00 , " DIL:!02" )
363+ PORT_DIPUNKNOWN_DIPLOC( 0x04 , 0x00 , " DIL:!03" )
364+ PORT_DIPUNKNOWN_DIPLOC( 0x08 , 0x00 , " DIL:!04" )
365+ PORT_DIPUNKNOWN_DIPLOC( 0x10 , 0x00 , " DIL:!05" )
366+ PORT_DIPUNKNOWN_DIPLOC( 0x20 , 0x00 , " DIL:!06" )
367+ PORT_DIPUNKNOWN_DIPLOC( 0x40 , 0x00 , " DIL:!07" )
368+ PORT_DIPUNKNOWN_DIPLOC( 0x80 , 0x00 , " DIL:!08" )
369+
305370INPUT_PORTS_END
306371
307372
308373void bfm_cobra3_state::machine_start()
309374{
375+ m_active_strobe = 0 ;
376+ m_lamps.resolve ();
310377 m_mainram = make_unique_clear<uint16_t []>((1024 * 16 ) / 2 );
311378 m_nvram->set_base (m_mainram.get (), 1024 * 16 );
312379}
@@ -320,7 +387,7 @@ static void cobra_scsi_devices(device_slot_interface &device)
320387
321388void bfm_cobra3_state::dma1_drq (int state)
322389{
323- // Triggers, but seems not to do anything, may be CPU bug related.
390+ // m_maincpu->dma_dreq1_w(state);
324391}
325392
326393void bfm_cobra3_state::scc66470_irq (int state)
@@ -431,6 +498,9 @@ void bfm_cobra3_state::bfm_cobra3(machine_config &config)
431498 ncr53c80_device &adapter = downcast<ncr53c80_device &>(*device);
432499 adapter.drq_handler ().set (*this , FUNC (bfm_cobra3_state::dma1_drq));
433500 });
501+
502+ WATCHDOG_TIMER (config, " watchdog" ).set_time (PERIOD_OF_555_MONOSTABLE (120000 ,100e-9 )); // TODO: Check timings
503+ METERS (config, m_meters, 0 ).set_number (4 );
434504}
435505
436506ROM_START ( c3_rtime )
0 commit comments