Previous 15994 Revisions Next

r4652 Friday 8th May, 2009 at 16:47:54 UTC by Fabio Priuli
[GLASGOW] Fixed (hopefully) LEDs
[src/mess/drivers]glasgow.c

src/mess/drivers/glasgow.c
r4651r4652
5656
5757static BOARD_FIELD m_board[8][8];
5858
59static int irq_edge=0x00;
59static const BOARD_FIELD start_board[8][8] =
60{
61   { { 7,44,434,"WR1"}, { 6,100,434,"WN1"}, { 5,156,434,"WB1"}, { 4,212,434,"WQ1"}, { 3,268,434,"WK"}, { 2,324,434,"WB2"}, { 1,380,434,"WN2"}, { 0,436,434,"WR2"} },
62   { {15,44,378,"WP1"}, {14,100,378,"WP2"}, {13,156,378,"WP3"}, {12,212,378,"WP4"}, {11,268,378,"WP5"}, {10,324,378,"WP6"}, { 9,380,378,"WP7"}, { 8,436,378,"WP8"} },
6063
64   { {23,44,322, "EMP"}, {22,100,322, "EMP"}, {21,156,322, "EMP"}, {20,212,322, "EMP"}, {19,268,322, "EMP"}, {18,324,322, "EMP"}, {17,380,322, "EMP"}, {16,436,322, "EMP"} },
65   { {31,44,266, "EMP"}, {30,100,266, "EMP"}, {29,156,266, "EMP"}, {28,212,266, "EMP"}, {27,268,266, "EMP"}, {26,324,266, "EMP"}, {25,380,266, "EMP"}, {24,436,266, "EMP"} },
66   { {39,44,210, "EMP"}, {38,100,210, "EMP"}, {37,156,210, "EMP"}, {36,212,210, "EMP"}, {35,268,210, "EMP"}, {34,324,210, "EMP"}, {33,380,210, "EMP"}, {32,436,210, "EMP"} },
67   { {47,44,154, "EMP"}, {46,100,154, "EMP"}, {45,156,154, "EMP"}, {44,212,154, "EMP"}, {43,268,154, "EMP"}, {42,324,154, "EMP"}, {41,380,154, "EMP"}, {40,436,154, "EMP"} },
6168
69   { {55,44,100,"BP1"}, {54,100,100,"BP2"}, {53,156,100,"BP3"}, {52,212,100,"BP4"}, {51,268,100,"BP5"}, {50,324,100,"BP6"}, {49,380,100,"BP7"}, {48,436,100,"BP8"} },
70   { {63,44,44 ,"BR1"}, {62,100,44 ,"BN1"}, {61,156,44 ,"BB1"}, {60,212,44 ,"BQ1"}, {59,268,44 ,"BK"}, {58,324,44 ,"BB2"}, {57,380,44 ,"BN2"}, {56,436,44 ,"BR2"} }
71};
72
73static void set_board( void )
74{
75   UINT8 i_AH, i_18;
76
77   for (i_AH = 0; i_AH < 8; i_AH++)
78   {
79      for (i_18 = 0; i_18 < 8; i_18++)
80      {
81         // copy start postition to m_board
82         m_board[i_18][i_AH] = start_board[i_18][i_AH];
83      }
84   }
85}
86
87
88static int irq_edge = 0x00;
89
90
6291// Used by Glasgow and Dallas
6392static WRITE16_HANDLER( write_lcd_gg )
6493{
65   UINT8 lcd_data;
66   lcd_data = data>>8;
94   UINT8 lcd_data = data >> 8;
95
6796   if (led7 == 0)
6897      output_set_digit_value(lcd_shift_counter, lcd_data);
98
6999   lcd_shift_counter--;
70100   lcd_shift_counter &= 3;
71101//   logerror("LCD Offset = %d Data low = %x \n", offset, lcd_data);
r4651r4652
74104static WRITE16_HANDLER( write_beeper )
75105{
76106   UINT8 beep_flag;
107
77108   lcd_invert = 1;
78109   beep_flag = data >> 8;
79//   if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
110//   if ((beep_flag & 02) == 0) key_selector = 0; else key_selector = 1;
80111   logerror("Write Beeper = %x \n", data);
81112   beeper = data;
82113}
83114
84115static WRITE16_HANDLER( write_lcd )
85116{
86   UINT8 lcd_data;
87   lcd_data = data >> 8;
117   UINT8 lcd_data = data >> 8;
118
88119   output_set_digit_value(lcd_shift_counter, lcd_invert & 1 ? lcd_data^0xff : lcd_data);
89120   lcd_shift_counter--;
90121   lcd_shift_counter &= 3;
r4651r4652
96127   UINT8 lcd_flag;
97128   lcd_invert = 0;
98129   lcd_flag=data >> 8;
99   //beep_set_state(0,lcd_flag&1?1:0);
130   //beep_set_state(0, lcd_flag & 1 ? 1 : 0);
100131   if (lcd_flag == 0)
101132      key_selector = 1;
102133
r4651r4652
113144static WRITE16_HANDLER( write_lcd_flag_gg )
114145{
115146   const device_config *speaker = devtag_get_device(space->machine, "beep");
116   UINT8 lcd_flag;
117   lcd_flag = data >> 8;
147   UINT8 lcd_flag = data >> 8;
148
118149   beep_set_state(speaker, lcd_flag & 1 ? 1 : 0);
150
119151   if (lcd_flag == 0)
120152      key_selector = 1;
121153
r4651r4652
140172
141173static WRITE16_HANDLER( write_board )
142174{
143   UINT8 board;
144   board = data >> 8;
175   UINT8 board = data >> 8;
176
145177   board_value = board;
178
146179   if (board == 0xff)
147180      key_selector = 0;
148181//   The key function in the rom expects after writing to
r4651r4652
157190   Line18_REED = data >> 8;
158191
159192   // LED's or REED's ?
160
161193   if (read_board_flag)
162194   {
163195      Line18_LED = 0;
r4651r4652
173205
174206   lcd_invert = 1;
175207   beep_flag = data >> 8;
176   //if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
208   //if ((beep_flag & 02) == 0) key_selector = 0; else key_selector = 1;
177209   //logerror("Write Beeper   = %x \n  ",data);
178210   beeper = data;
179211}
r4651r4652
181213static WRITE16_HANDLER( write_irq_flag )
182214{
183215   const device_config *speaker = devtag_get_device(space->machine, "beep");
216
184217   beep_set_state(speaker, data & 0x100);
185218   logerror("Write 0x800004 = %x \n", data);
186219   irq_flag = 1;
r4651r4652
189222
190223static READ16_HANDLER( read_keys ) // Glasgow, Dallas
191224{
192   UINT16 data;
193   data = 0x0300;
225   UINT16 data = 0x0300;
226
194227   key_low = input_port_read(space->machine, "LINE0");
195228   key_hi = input_port_read(space->machine, "LINE1");
196   //logerror("Keyboard Offset = %x Data = %x\n  ",offset,data);
229
197230   if (key_select == key_low)
198231      data = data & 0x100;
232
199233   if (key_select == key_hi)
200234      data = data & 0x200;
201235
236   //logerror("Keyboard Offset = %x Data = %x\n  ", offset, data);
202237   return data;
203238}
204239
r4651r4652
219254static READ16_HANDLER( read_board_gg )
220255{
221256   UINT8 i_18, i_AH;
222   UINT16 data;
257   UINT16 data = 0xff;
223258
224   data = 0xff;
225
226   for (i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
259   for (i_18 = 0; i_18 < 8; i_18++)
227260   {
228
229   // Looking for cleared bit in Line18 -> current line
230
231      if ( !(Line18_REED & (1<<i_18)) )
261      // Looking for cleared bit in Line18 -> current line
262      if (!(Line18_REED & (1 << i_18)))
232263      {
233
234   // if there is a piece on the field -> set bit in data
235
236         for (i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
264         // if there is a piece on the field -> set bit in data
265         for (i_AH = 0; i_AH < 8; i_AH++)
237266         {
238267            if (strcmp ((char *)m_board[i_18][i_AH].piece, EMP))
239268               data &= ~(1 << i_AH);  // clear bit
r4651r4652
266295//   logerror("Line18_LED   = %x \n  ",Line18_LED);
267296//   logerror("LineAH   = %x \n  ",LineAH);
268297
269      for (i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
298      for (i_AH = 0; i_AH < 8; i_AH++)
270299      {
271         if ( LineAH & (1<<i_AH) )
300         if (LineAH & (1 << i_AH))
272301         {
273            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
302            for (i_18 = 0; i_18 < 8; i_18++)
274303            {
275               if ( !(Line18_LED & (1<<i_18)) )
304               if (!(Line18_LED & (1 << i_18)))
276305               {
277306//                  logerror("i_18   = %d \n  ",i_18);
278307//                  logerror("i_AH   = %d \n  ",i_AH);
279308//                  logerror("LED an:   = %d \n  ",m_board[i_18][i_AH]);
280309
281310                  LED = m_board[i_18][i_AH].field;
282                  output_set_led_value( LED, 1 );
283
284//  LED on
311                  output_set_led_value(LED, 1);
312                  //  LED on
285313               }
286314               else
287315               {
288//  LED off
316               //  LED off
289317
290               } // End IF 18
291            } // End For 18
292         } // End IF AH
293      } // End For AH
294   } // End IF LineAH
318               }
319            }
320         }
321      }
322   }
295323   else
296324   {
297//  No LED  -> all LED's off
298      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
325      //  No LED  -> all LED's off
326      for (i_AH = 0; i_AH < 8; i_AH++)
299327      {
300         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
328         for (i_18 = 0; i_18 < 8; i_18++)
301329         {
302// LED off
330            // LED off
303331            LED = m_board[i_18][i_AH].field;
304            output_set_led_value( LED, 0 );
305         } //End For 18
306      } // End For AH
307   } //End ELSE LineAH
332            output_set_led_value(LED, 0);
333         }
334      }
335   }
308336}
309337
310338/*
r4651r4652
324352
325353static WRITE32_HANDLER( write_lcd32 )
326354{
327   UINT8 lcd_data;
328   lcd_data = data >> 8;
355   UINT8 lcd_data = data >> 8;
356
329357   output_set_digit_value(lcd_shift_counter, lcd_invert & 1 ? lcd_data^0xff : lcd_data);
330358   lcd_shift_counter--;
331359   lcd_shift_counter &= 3;
332   //logerror("LCD Offset = %d Data   = %x \n  ",offset,lcd_data);
360   //logerror("LCD Offset = %d Data   = %x \n  ", offset, lcd_data);
333361}
334362
335363static WRITE32_HANDLER( write_lcd_flag32 )
336364{
337   UINT8 lcd_flag;
365   UINT8 lcd_flag = data >> 24;
366
338367   lcd_invert = 0;
339   lcd_flag = data >> 24;
368
340369   if (lcd_flag == 0)
341370      key_selector = 1;
371
342372   logerror("LCD Flag 32 = %x \n", lcd_flag);
343   //beep_set_state(0,lcd_flag&1?1:0);
373   //beep_set_state(0, lcd_flag & 1 ? 1 : 0);
344374
345375   if (lcd_flag != 0)
346376      led7 = 255;
r4651r4652
359389static READ32_HANDLER( read_newkeys32 ) // Dallas 32, Roma 32
360390{
361391   UINT32 data;
392
362393   if (key_selector == 0)
363394      data = input_port_read(space->machine, "LINE0");
364395   else
365396      data = input_port_read(space->machine, "LINE1");
366   //if (key_selector==1) data=input_port_read(machine, "LINE0");else data=0;
397   //if (key_selector == 1) data = input_port_read(machine, "LINE0"); else data = 0;
367398   logerror("read Keyboard Offset = %x Data = %x\n", offset, data);
368399   data = data << 24;
369400   return data ;
r4651r4652
378409/*
379410static READ16_HANDLER(read_board_amsterd)
380411{
381  logerror("read board amsterdam Offset = %x \n  ",offset);
412  logerror("read board amsterdam Offset = %x \n  ", offset);
382413  return 0xffff;
383414}
384415*/
r4651r4652
404435
405436static TIMER_CALLBACK( update_nmi )
406437{
407   //cputag_set_input_line_and_vector(machine, "maincpu",  M68K_IRQ_7,irq_edge&0xff ? CLEAR_LINE:ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
408      cputag_set_input_line_and_vector(machine, "maincpu",  M68K_IRQ_7,ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
409      cputag_set_input_line_and_vector(machine, "maincpu",  M68K_IRQ_7,CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
410      irq_edge=~irq_edge;
438   //cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, irq_edge & 0xff ? CLEAR_LINE : ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
439      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
440      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
441      irq_edge = ~irq_edge;
411442}
412443
413444static TIMER_CALLBACK( update_nmi32 )
414445{
415   // cputag_set_input_line_and_vector(machine, "maincpu",  M68K_IRQ_7, irq_edge&0xff ? CLEAR_LINE:ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
416      cputag_set_input_line_and_vector(machine, "maincpu",  M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
417      cputag_set_input_line_and_vector(machine, "maincpu",  M68K_IRQ_7, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
418    irq_edge=~irq_edge;
446   // cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, irq_edge & 0xff ? CLEAR_LINE : ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
447      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
448      cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
449    irq_edge = ~irq_edge;
419450}
420451
421452static MACHINE_START( glasgow )
422453{
423454   const device_config *speaker = devtag_get_device(machine, "beep");
455
424456   key_selector = 0;
425457   irq_flag = 0;
426458   lcd_shift_counter = 3;
r4651r4652
432464static MACHINE_START( dallas32 )
433465{
434466   const device_config *speaker = devtag_get_device(machine, "beep");
467
435468   lcd_shift_counter = 3;
436469   timer_pulse(machine, ATTOTIME_IN_HZ(50), NULL, 0, update_nmi32);
437470   beep_set_frequency(speaker, 44);
r4651r4652
441474static MACHINE_RESET( glasgow )
442475{
443476   lcd_shift_counter = 3;
477   set_board();
444478}
445479
446480

Previous 15994 Revisions Next


© 1998-2018 The MESS Team