Previous 199869 Revisions Next

r19986 Tuesday 1st January, 2013 at 14:15:28 UTC by Wilbert Pol
(MESS) Started hooking up the paddle to the i8021. (nw)
[src/mess/drivers]microvsn.c

trunk/src/mess/drivers/microvsn.c
r19985r19986
2121#include "rendlay.h"
2222
2323
24#define LOG   0
25
2426enum cpu_type
2527{
2628   CPU_TYPE_I8021,
r19985r19986
4951   // i8021 interface
5052   DECLARE_WRITE8_MEMBER(i8021_p0_write);
5153   DECLARE_WRITE8_MEMBER(i8021_p1_write);
54   DECLARE_WRITE8_MEMBER(i8021_p2_write);
55   DECLARE_READ8_MEMBER(i8021_t1_read);
5256   DECLARE_READ8_MEMBER(i8021_bus_read);
5357
5458   // TMS1100 interface
r19985r19986
6367   required_device<cpu_device> m_i8021;
6468   required_device<cpu_device> m_tms1100;
6569
70   // Timers
71   static const device_timer_id TIMER_PADDLE = 0;
72   emu_timer *m_paddle_timer;
73   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
74
6675   // i8021 variables
6776   UINT8   m_p0;
77   UINT8   m_p2;
78   UINT8   m_t1;
6879
6980   // tms1100 variables
7081   UINT16   m_r;
r19985r19986
104115
105116MACHINE_START_MEMBER(microvision_state, microvision)
106117{
118   m_paddle_timer = timer_alloc(TIMER_PADDLE);
119
107120   save_item(NAME(m_p0));
121   save_item(NAME(m_p2));
122   save_item(NAME(m_t1));
108123   save_item(NAME(m_r));
109124   save_item(NAME(m_o));
110125   save_item(NAME(m_lcd_latch));
r19985r19986
131146
132147   m_o = 0;
133148   m_r = 0;
149   m_p0 = 0;
150   m_p2 = 0;
151   m_t1 = 0;
134152
153   m_paddle_timer->adjust( attotime::never );
154
135155   switch ( m_cpu_type )
136156   {
137157      case CPU_TYPE_I8021:
r19985r19986
198218      UINT16 row = ( m_lcd_latch[0] << 12 ) | ( m_lcd_latch[1] << 8 ) | ( m_lcd_latch[2] << 4 ) | m_lcd_latch[3];
199219      UINT16 col = ( m_lcd_latch[4] << 12 ) | ( m_lcd_latch[5] << 8 ) | ( m_lcd_latch[6] << 4 ) | m_lcd_latch[7];
200220
201      //logerror("row = %04x, col = %04x\n", row, col );
221      if (LOG) logerror("row = %04x, col = %04x\n", row, col );
202222      for ( int i = 0; i < 16; i++ )
203223      {
204224         UINT16 temp = row;
r19985r19986
229249}
230250
231251
252void microvision_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
253{
254   switch ( id )
255   {
256      case TIMER_PADDLE:
257         m_t1 = 0;
258         break;
259   }
260}
261
262
232263/*
233264 x--- ---- KEY3
234265 -x-- ---- KEY4
r19985r19986
241272*/
242273WRITE8_MEMBER( microvision_state::i8021_p0_write )
243274{
244   logerror( "p0_write: %02x\n", data );
275   if (LOG) logerror( "p0_write: %02x\n", data );
245276
246277   m_p0 = data;
247278}
r19985r19986
257288*/
258289WRITE8_MEMBER( microvision_state::i8021_p1_write )
259290{
260   logerror( "p1_write: %02x\n", data );
291   if (LOG) logerror( "p1_write: %02x\n", data );
261292
262293   lcd_write( data & 0x03, data >> 4 );
263294}
264295
265296
297/*
298---- xx-- CAP2 (paddle)
299---- --x- SPKR1
300---- ---x SPKR0
301*/
302WRITE8_MEMBER( microvision_state::i8021_p2_write )
303{
304   if (LOG) logerror( "p2_write: %02x\n", data );
305
306   m_p2 = data;
307
308   speaker_write( m_p2 & 0x03 );
309
310   if ( m_p2 & 0x0c )
311   {
312      m_t1 = 1;
313      // Stop paddle timer
314      m_paddle_timer->adjust( attotime::never );
315   }
316   else
317   {
318      // Start paddle timer (min is 160uS, max is 678uS)
319      UINT8 paddle = 255 - ioport("PADDLE")->read();
320      m_paddle_timer->adjust( attotime::from_usec(160 + ( 518 * paddle ) / 255 ) );
321   }
322}
323
324
325READ8_MEMBER( microvision_state::i8021_t1_read )
326{
327   return m_t1;
328}
329
330
266331READ8_MEMBER( microvision_state::i8021_bus_read )
267332{
268333   UINT8 data = m_p0;
r19985r19986
304369{
305370   UINT8 data = 0;
306371
307   //logerror("read_k\n");
372   if (LOG) logerror("read_k\n");
308373
309374   if ( m_r & 0x100 )
310375   {
r19985r19986
324389
325390WRITE16_MEMBER( microvision_state::tms1100_write_o )
326391{
327   logerror("write_o: %04x\n", data);
392   if (LOG) logerror("write_o: %04x\n", data);
328393
329394   m_o = data;
330395
r19985r19986
343408*/
344409WRITE16_MEMBER( microvision_state::tms1100_write_r )
345410{
346   logerror("write_r: %04x\n", data);
411   if (LOG) logerror("write_r: %04x\n", data);
347412
348413   m_r = data;
349414
r19985r19986
425490   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON6)  PORT_CODE(KEYCODE_T) PORT_NAME("B06")
426491   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON9)  PORT_CODE(KEYCODE_G) PORT_NAME("B09")
427492   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON12) PORT_CODE(KEYCODE_B) PORT_NAME("B12")
493
494   PORT_START("PADDLE")
495   PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_PLAYER(1) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0, 255)
428496INPUT_PORTS_END
429497
430498
r19985r19986
432500   AM_RANGE( 0x00, 0xFF ) AM_WRITE( i8021_p0_write )
433501   AM_RANGE( MCS48_PORT_P0, MCS48_PORT_P0 ) AM_WRITE( i8021_p0_write )
434502   AM_RANGE( MCS48_PORT_P1, MCS48_PORT_P1 ) AM_WRITE( i8021_p1_write )
503   AM_RANGE( MCS48_PORT_P2, MCS48_PORT_P2 ) AM_WRITE( i8021_p2_write )
504   AM_RANGE( MCS48_PORT_T1, MCS48_PORT_T1 ) AM_READ( i8021_t1_read )
435505   AM_RANGE( MCS48_PORT_BUS, MCS48_PORT_BUS ) AM_READ( i8021_bus_read )
436506ADDRESS_MAP_END
437507

Previous 199869 Revisions Next


© 1997-2024 The MAME Team