Previous 15994 Revisions Next

r10409 Sunday 13th February, 2011 at 12:46:34 UTC by Miodrag Milanović
Fixed dallas32 and roma32 (timer issue) and cleanup of supercon driver [Ralf Schafer]
[src/mess/drivers]glasgow.c supercon.c

src/mess/drivers/glasgow.c
r10408r10409
260260   // irq_edge = ~irq_edge;
261261}
262262
263static TIMER_DEVICE_CALLBACK( update_nmi32 )
263static TIMER_CALLBACK( update_nmi32 )
264264{
265265   // cputag_set_input_line_and_vector(timer.machine, "maincpu", M68K_IRQ_7, irq_edge & 0xff ? CLEAR_LINE : ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
266      cputag_set_input_line_and_vector(timer.machine, "maincpu", M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
267      cputag_set_input_line_and_vector(timer.machine, "maincpu", M68K_IRQ_7, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
266      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
267      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
268268   // irq_edge = ~irq_edge;
269269}
270270
r10408r10409
290290   state->lcd_shift_counter = 3;
291291   beep_set_frequency(speaker, 44);
292292
293   machine->scheduler().timer_pulse(attotime::from_hz(50),FUNC(update_nmi32),NULL);
294
293295   mboard_savestate_register(machine);
294296}
295297
r10408r10409
523525    MCFG_MACHINE_START( dallas32 )
524526
525527   MCFG_DEVICE_REMOVE("nmi_timer")
526   MCFG_TIMER_ADD_PERIODIC("nmi_timer", update_nmi32, attotime::from_hz(50))
528
527529MACHINE_CONFIG_END
528530
529531/***************************************************************************
src/mess/drivers/supercon.c
r10408r10409
3232
3333   UINT8 *ram;
3434   emu_timer* timer_update_irq;
35   emu_timer* timer_mouse_click;
3536   int emu_started;
3637   int moving_piece;
3738   UINT8 data_1E00;
r10408r10409
4445   int led_update;
4546   int remove_led_flag;
4647   int selecting;
48   int save_key_data;
49   attotime wait_time;
50   int *current_field;
4751   int confirm_board_click;
48   int *current_field;
4952   int m_board[64];
5053   int save_board[64];
5154};
r10408r10409
8891#define   TAKE      1
8992#define SET         2
9093
91
92
93
94
95
96
97
98
9994/* artwork board */
10095static const int start_board[64] =
10196{
r10408r10409
193188static void mouse_update(running_machine *machine)
194189{
195190   supercon_state *state = machine->driver_data<supercon_state>();
196   UINT8 port_input, m_left;
191   UINT8 port_input; // m_left;
197192   int i;
198193
199/* Set-remove piece after mouse release and confirmation of a board click = beep */
200
201    m_left=input_port_read(machine, "BUTTON_L");
202    if (!m_left && state->selecting)
203    {
204       if (state->confirm_board_click)
205       {
206         if (state->selecting==SET)
207         {
208            *state->current_field=state->moving_piece;
209            state->moving_piece=EM;
210         }else
211         {
212            state->moving_piece=*state->current_field;
213            *state->current_field=EM;
214         }
215         set_pieces(state);
216         output_set_value("MOVING",state->moving_piece);
217       }
218
219       state->selecting=NO_ACTION;
220       state->confirm_board_click=FALSE;
221    }
222
223194/* Boarder pieces and moving pice */
224195
225196   port_input=input_port_read(machine, "B_WHITE");
r10408r10409
263234   state->LED_AH=0;
264235   state->LED_ST=0;
265236
237   state->wait_time =  attotime::from_hz(4);
238   state->save_key_data = 0xff;
239
266240   state->moving_piece=0;
267241}
268242
r10408r10409
391365   if (i_18==NOT_VALID)
392366      return 0xff;
393367
368/* if a button was pressed wait til timer -timer_mouse_click- is fired */
369
370   if (state->selecting)
371      return state->save_key_data;
372   else
373   {
374      set_pieces(state);
375      output_set_value("MOVING",state->moving_piece);
376   }
377
394378   key_data=input_port_read(space->machine, board_lines[i_18]);
395379
396380   if (key_data != 0xff)
397381   {
398382      LOG(("%s key_data: %02x \n",board_lines[i_18],key_data));
399383
400      if (key_data)
384/* Only if valid data and mouse button is pressed */
385
386      if (key_data && input_port_read(space->machine, "BUTTON_L"))
401387      {
402388
403389/* Set or remove pieces */
r10408r10409
405391         i_AH=7-get_first_cleared_bit(key_data);
406392         LOG(("Press -> AH: %d 18: %d Piece: %d\n",i_AH,i_18,state->m_board[i_18*8 + i_AH]););
407393
408         if (state->selecting==NO_ACTION)
394         state->current_field=&state->m_board[i_18*8 + i_AH];
395
396         if (state->moving_piece)
409397         {
410            state->current_field=&state->m_board[i_18*8 + i_AH];
398            *state->current_field = state->moving_piece;
399            state->moving_piece = EM;
400         }
401         else
402         {
403            state->moving_piece = *state->current_field;
404            *state->current_field = EM;
405         }
406         state->selecting=TRUE;            /* Flag is removed in timer -timer_mouse_click- */
407         state->save_key_data=key_data;      /* return same key_data til flag selecting is removed */
411408
412            if (state->moving_piece)
413               state->selecting=SET;
414            else
415               state->selecting=TAKE;
416         }
409         state->timer_mouse_click->adjust(state->wait_time, 0);
410
417411         return key_data;
418412      }
419413   }
r10408r10409
504498   {
505499      beep_set_state(speaker,1);
506500      state->emu_started=TRUE;
507
508      if (state->selecting)               /* fast mouse clicks are recognized by the artwork but not by the emulation  */
509         state->confirm_board_click=TRUE;   /* therefore a beep must confirm each click on the board */
510501   }
511502   else
512503      beep_set_state(speaker,0);
513504
514505}
515506
507static TIMER_CALLBACK( mouse_click )
508{
509   supercon_state *state = machine->driver_data<supercon_state>();
510
511   if (input_port_read_safe(machine, "BUTTON_L",0) )            /* wait for mouse release */
512      state->timer_mouse_click->adjust(state->wait_time, 0);
513   else
514      state->selecting=FALSE;
515}
516
516517static TIMER_DEVICE_CALLBACK( update_artwork )
517518{
518519   mouse_update(timer.machine);
r10408r10409
528529
529530static STATE_PRESAVE( m_board_presave )
530531{
531   supercon_state *state = machine->driver_data<supercon_state>();
532   int i;
533   for (i=0;i<64;i++)
534      state->save_board[i]=state->m_board[i];
532    supercon_state *state = machine->driver_data<supercon_state>();
533    int i;
534    for (i=0;i<64;i++)
535        state->save_board[i]=state->m_board[i];
535536}
536537
537538static STATE_POSTLOAD( m_board_postload )
538539{
539   supercon_state *state = machine->driver_data<supercon_state>();
540   int i;
541   for (i=0;i<64;i++)
542      state->m_board[i]=state->save_board[i];
540    supercon_state *state = machine->driver_data<supercon_state>();
541    int i;
542    for (i=0;i<64;i++)
543        state->m_board[i]=state->save_board[i];
543544
544   set_pieces(state);
545    set_pieces(state);
545546}
546547
547548static MACHINE_START( supercon )
548549{
549550   supercon_state *state = machine->driver_data<supercon_state>();
550   state->led_update=TRUE;
551   state->remove_led_flag=TRUE;
552551
553552   state->timer_update_irq = machine->scheduler().timer_alloc(FUNC(update_irq));
554553   state->timer_update_irq->adjust( attotime::zero, 0, attotime::from_hz(1000) );
555554
556   state->save_item(NAME(state->save_board));
557   machine->state().register_postload(m_board_postload,NULL);
558   machine->state().register_presave(m_board_presave,NULL);
555   state->timer_mouse_click =  machine->scheduler().timer_alloc(FUNC(mouse_click),NULL);
556
557
558    state->save_item(NAME(state->save_board));
559    machine->state().register_postload(m_board_postload,NULL);
560    machine->state().register_presave(m_board_presave,NULL);
561
559562}
560563
561564static MACHINE_RESET( supercon )
r10408r10409
764767   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
765768
766769   MCFG_TIMER_ADD_PERIODIC("artwork_timer", update_artwork, attotime::from_hz(20))
770
767771MACHINE_CONFIG_END
768772
769773/* ROM definition */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team