Previous 15994 Revisions Next

r3390 Sunday 5th October, 2008 at 10:24:50 UTC by Fabio Priuli
Removed custom clickable artwork code which was crashing MESS. Systems still don't work due to wrong PULSE_LINE use.
[src/mess/drivers]glasgow.c

src/mess/drivers/glasgow.c
r3389r3390
2828#include "glasgow.lh"
2929#include "sound/beep.h"
3030
31#include "render.h"
32#include "rendlay.h"
3331
3432static UINT8 lcd_shift_counter;
3533// static UINT8 led_status;
3634static UINT8 led7;
3735static UINT8 key_low,
38       key_hi,
39       key_select,
40       irq_flag,
41       lcd_invert,
42       key_selector;
36      key_hi,
37      key_select,
38      irq_flag,
39      lcd_invert,
40      key_selector;
4341static UINT8 board_value;
4442static UINT16 beeper;
4543
44static UINT16 Line18_LED;
45static UINT16 Line18_REED;
4646
47  #define MOUSE_X      56
48  #define MOUSE_Y      56
49  #define MAX_X         530
50  #define MAX_Y         660
51  #define MOUSE_SPEED   3
47static UINT8 read_board_flag;
5248
53  #define MIN_BOARD_X   60.0
54  #define MAX_BOARD_X   480.0
49static const char EMP[4] = "EMP";
5550
56  #define MIN_BOARD_Y   60.0
57  #define MAX_BOARD_Y   480.0
51typedef struct {
52   unsigned int field;
53   unsigned int x;
54   unsigned int y;
55   unsigned char piece[4];
56} BOARD_FIELD;
5857
59  #define MIN_CURSOR_X   -10
60  #define MAX_CURSOR_X   496
58static BOARD_FIELD m_board[8][8];
6159
62  #define MIN_CURSOR_Y   0
63  #define MAX_CURSOR_Y   622
6460
65  static INT16 m_x, m_y;
66  static UINT8 m_button1 , m_button2;
67  static UINT8 MOUSE_MOVE = 0;
68  static UINT8 MOUSE_BUTTON1_WAIT = 0;
69  static UINT8 MOUSE_BUTTON2_WAIT = 0;
70
71  static UINT16 Line18_LED;
72  static UINT16 Line18_REED;
73
74  static UINT8 read_board_flag;
75
76  static const char EMP[4] = "EMP";
77  static const char NO_PIECE[4]  = "NOP";
78
79
80  typedef struct {
81       unsigned int field;
82      unsigned int x;
83      unsigned int y;
84       unsigned char piece[4];
85  } BOARD_FIELD;
86
87
88   #define WR   12
89   #define WB   13
90   #define WKN   14
91   #define WQ   15
92   #define WK   16
93
94   #define BP   21
95   #define BR   22
96   #define BB   23
97   #define BKN   24
98   #define BQ   25
99   #define BK   26
100
101
102
103static     BOARD_FIELD m_board[8][8];
104
105static const BOARD_FIELD start_board[8][8] =
106   {
107      { { 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"} },
108      { {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"} },
109
110      { {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"} },
111      { {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"} },
112      { {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"} },
113      { {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"} },
114
115      { {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"} },
116      { {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"} }
117
118   };
119
120
121   static BOARD_FIELD cursor_field;
122
123
124     typedef struct {
125       unsigned char piece[4];
126      unsigned int selected;
127      unsigned int set;
128  } P_STATUS;
129
130
131    static P_STATUS all_pieces[48] =
132    {
133       {"WR1",0,0}, {"WN1",0,0},{"WB1",0,0}, {"WQ1",0,0},  {"WK",0,0},  {"WB2",0,0}, {"WN2",0,0}, {"WR2",0,0},
134       {"WP1",0,0}, {"WP2",0,0},{"WP3",0,0}, {"WP4",0,0}, {"WP5",0,0},  {"WP6",0,0}, {"WP7",0,0}, {"WP8",0,0},
135
136
137      {"BP1",0,0}, {"BP2",0,0},{"BP3",0,0}, {"BP4",0,0}, {"BP5",0,0},  {"BP6",0,0}, {"BP7",0,0}, {"BP8",0,0},
138       {"BR1",0,0}, {"BN1",0,0},{"BB1",0,0}, {"BQ1",0,0},  {"BK",0,0},  {"BB2",0,0}, {"BN2",0,0}, {"BR2",0,0},
139
140
141        {"BQ2",0,0}, {"BQ3",0,0}, {"BQ4",0,0}, {"BQ5",0,0}, {"BQ6",0,0}, {"BQ7",0,0},
142
143
144      {"WQ2",0,0}, {"WQ3",0,0}, {"WQ4",0,0}, {"WQ5",0,0}, {"WQ6",0,0}, {"WQ7",0,0}
145
146    };
147
148     static UINT8 start_i;
149
150
151  struct _render_target
152{
153   render_target *      next;            /* keep a linked list of targets */
154   layout_view *      curview;         /* current view */
155   layout_file *      filelist;         /* list of layout files */
156   UINT32            flags;            /* creation flags */
157   render_primitive_list primlist[2];/* list of primitives */
158   int               listindex;         /* index of next primlist to use */
159   INT32            width;            /* width in pixels */
160   INT32            height;            /* height in pixels */
161   render_bounds      bounds;            /* bounds of the target */
162   float            pixel_aspect;      /* aspect ratio of individual pixels */
163   float            max_refresh;      /* maximum refresh rate, 0 or if none */
164   int               orientation;      /* orientation */
165   int               layerconfig;      /* layer configuration */
166   layout_view *      base_view;         /* the view at the time of first frame */
167   int               base_orientation;   /* the orientation at the time of first frame */
168   int               base_layerconfig;   /* the layer configuration at the time of first frame */
169   int               maxtexwidth;      /* maximum width of a texture */
170   int               maxtexheight;      /* maximum height of a texture */
171};
172
173  static render_target *my_target;
174
175  static view_item *my_cursor;
176
177  static void set_cursor (running_machine *machine, view_item *view_cursor);
178
179  static view_item *get_view_item(render_target *target, const char *v_name);
180
181  static BOARD_FIELD  get_field( float i_x, float i_y, UINT8 mouse_move);
182  static void update_board(render_target *target, BOARD_FIELD board_field, unsigned int update_clear_flag);
183
184  static void calculate_bounds(view_item *view_item, float new_x0, float new_y0, float new_del_x, float new_del_y );
185
186  static void set_render_board(void);
187  static void clear_layout(void);
188  static void set_status_of_pieces(void);
189
190  static const char * get_non_set_pieces(const char *cur_piece);
191
192  static unsigned int out_of_board( float x0, float y0);
193
194
195
19661// Used by Glasgow and Dallas
197static WRITE16_HANDLER ( write_lcd_gg )
62static WRITE16_HANDLER( write_lcd_gg )
19863{
199  UINT8 lcd_data;
200  lcd_data = data>>8;
201  if (led7==0) output_set_digit_value(lcd_shift_counter,lcd_data);
202  lcd_shift_counter--;
203  lcd_shift_counter&=3;
204//  logerror("LCD Offset = %d Data low  = %x \n  ",offset,lcd_data);
64   UINT8 lcd_data;
65   lcd_data = data>>8;
66   if (led7 == 0)
67      output_set_digit_value(lcd_shift_counter, lcd_data);
68   lcd_shift_counter--;
69   lcd_shift_counter &= 3;
70//   logerror("LCD Offset = %d Data low = %x \n", offset, lcd_data);
20571}
20672
207
208
209static WRITE16_HANDLER ( write_beeper )
73static WRITE16_HANDLER( write_beeper )
21074{
211UINT8 beep_flag;
212lcd_invert=1;
213beep_flag=data>>8;
214//if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
215 logerror("Write Beeper   = %x \n  ",data);
216 beeper=data;
75   UINT8 beep_flag;
76   lcd_invert = 1;
77   beep_flag = data >> 8;
78//   if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
79   logerror("Write Beeper = %x \n", data);
80   beeper = data;
21781}
21882
219static WRITE16_HANDLER ( write_lcd )
83static WRITE16_HANDLER( write_lcd )
22084{
221  UINT8 lcd_data;
222  lcd_data = data>>8;
223  output_set_digit_value(lcd_shift_counter,lcd_invert&1?lcd_data^0xff:lcd_data);
224  lcd_shift_counter--;
225  lcd_shift_counter&=3;
226  logerror("LCD Offset = %d Data low  = %x \n  ",offset,lcd_data);
85   UINT8 lcd_data;
86   lcd_data = data >> 8;
87   output_set_digit_value(lcd_shift_counter, lcd_invert & 1 ? lcd_data^0xff : lcd_data);
88   lcd_shift_counter--;
89   lcd_shift_counter &= 3;
90   logerror("LCD Offset = %d Data low = %x \n", offset, lcd_data);
22791}
22892
229static WRITE16_HANDLER ( write_lcd_flag )
93static WRITE16_HANDLER( write_lcd_flag )
23094{
231  UINT8 lcd_flag;
232  lcd_invert=0;
233  lcd_flag=data>>8;
234  //beep_set_state(0,lcd_flag&1?1:0);
235  if (lcd_flag == 0) key_selector=1;
95   UINT8 lcd_flag;
96   lcd_invert = 0;
97   lcd_flag=data >> 8;
98   //beep_set_state(0,lcd_flag&1?1:0);
99   if (lcd_flag == 0)
100      key_selector = 1;
101
236102 // The key function in the rom expects after writing to
237 // the  a value from  the second key row;
238  if (lcd_flag!=0) led7=255;else led7=0;
239  logerror("LCD Flag 16  = %x \n  ",data);
103 // the  a value from the second key row;
104   if (lcd_flag != 0)
105      led7 = 255;
106   else
107      led7 = 0;
108
109   logerror("LCD Flag 16 = %x \n", data);
240110}
241111
242
243
244static WRITE16_HANDLER ( write_lcd_flag_gg )
112static WRITE16_HANDLER( write_lcd_flag_gg )
245113{
246  UINT8 lcd_flag;
247  lcd_flag=data>>8;
248  beep_set_state(0,lcd_flag&1?1:0);
249  if (lcd_flag == 0) key_selector=1;
250  if (lcd_flag!=0) led7=255;else led7=0;
114   UINT8 lcd_flag;
115   lcd_flag = data >> 8;
116   beep_set_state(0, lcd_flag & 1 ? 1 : 0);
117   if (lcd_flag == 0)
118      key_selector = 1;
251119
252//  logerror("LCD Flag gg  = %x \n  ",lcd_flag);
120   if (lcd_flag != 0)
121      led7 = 255;
122   else
123      led7 = 0;
124
125//   logerror("LCD Flag gg = %x \n", lcd_flag);
253126}
254127
255static WRITE16_HANDLER ( write_keys )
128static WRITE16_HANDLER( write_keys )
256129{
257 key_select=data>>8;
258// logerror("Write Key   = %x \n  ",data);
130   key_select = data >> 8;
131//   logerror("Write Key = %x \n", data);
259132}
260133
261
262static READ16_HANDLER(read_board)
134static READ16_HANDLER( read_board )
263135{
264  return 0xff00;   // Mephisto need it for working
136   return 0xff00;   // Mephisto need it for working
265137}
266138
267
268static WRITE16_HANDLER(write_board)
139static WRITE16_HANDLER( write_board )
269140{
270 UINT8 board;
271 board=data>>8;
272 board_value=board;
273 if (board==0xff) key_selector=0;
274 // The key function in the rom expects after writing to
275 // the chess board a value from  the first key row;
276  logerror("Write Board   = %x \n  ",data>>8);
141   UINT8 board;
142   board = data >> 8;
143   board_value = board;
144   if (board == 0xff)
145      key_selector = 0;
146//   The key function in the rom expects after writing to
147//   the chess board a value from  the first key row;
148   logerror("Write Board = %x \n", data >> 8);
277149}
278150
279
280
281static WRITE16_HANDLER ( write_board_gg )
151static WRITE16_HANDLER( write_board_gg )
282152{
283UINT8 beep_flag;
153   UINT8 beep_flag;
284154
285Line18_REED=data>>8;
155   Line18_REED = data >> 8;
286156
287// LED's or REED's ?
288//
289if (read_board_flag)
157   // LED's or REED's ?
158
159   if (read_board_flag)
290160   {
291   Line18_LED=0;
292   read_board_flag=0;
161      Line18_LED = 0;
162      read_board_flag = 0;
293163   }
294else
164   else
295165   {
296   Line18_LED=data>>8;
166      Line18_LED = data >> 8;
297167   }
298168
299//logerror("write_board Line18_LED   = %x \n  ", Line18_LED);
300//logerror("write_board Line18_REED   = %x \n  ",Line18_REED);
169   //logerror("write_board Line18_LED   = %x \n  ", Line18_LED);
170   //logerror("write_board Line18_REED   = %x \n  ",Line18_REED);
301171
302lcd_invert=1;
303beep_flag=data>>8;
304//if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
305//logerror("Write Beeper   = %x \n  ",data);
306 beeper=data;
172   lcd_invert = 1;
173   beep_flag = data >> 8;
174   //if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
175   //logerror("Write Beeper   = %x \n  ",data);
176   beeper = data;
307177}
308178
309static WRITE16_HANDLER ( write_irq_flag )
179static WRITE16_HANDLER( write_irq_flag )
310180{
311 beep_set_state(0,data&0x100);
312 logerror("Write 0x800004   = %x \n  ",data);
313 irq_flag=1;
314 beeper=data;
181   beep_set_state(0, data & 0x100);
182   logerror("Write 0x800004 = %x \n", data);
183   irq_flag = 1;
184   beeper = data;
315185}
316186
317static READ16_HANDLER(read_keys) // Glasgow, Dallas
187static READ16_HANDLER( read_keys ) // Glasgow, Dallas
318188{
319  UINT16 data;
320  data=0x0300;
321  key_low = input_port_read(machine, "LINE0");
322  key_hi =  input_port_read(machine, "LINE1");
323//logerror("Keyboard Offset = %x Data = %x\n  ",offset,data);
324  if (key_select==key_low){data=data&0x100;}
325  if (key_select==key_hi){data=data&0x200;}
326  return data;
189   UINT16 data;
190   data = 0x0300;
191   key_low = input_port_read(machine, "LINE0");
192   key_hi = input_port_read(machine, "LINE1");
193   //logerror("Keyboard Offset = %x Data = %x\n  ",offset,data);
194   if (key_select == key_low)
195      data = data & 0x100;
196   if (key_select == key_hi)
197      data = data & 0x200;
198
199   return data;
327200}
328201
329static READ16_HANDLER(read_newkeys16)  //Amsterdam, Roma
202static READ16_HANDLER( read_newkeys16 )  //Amsterdam, Roma
330203{
331 UINT16 data;
204   UINT16 data;
332205
333 if (key_selector==0) data=input_port_read(machine, "LINE0");else data=input_port_read(machine, "LINE1");
334 logerror("read Keyboard Offset = %x Data = %x   Select = %x \n  ",offset,data,key_selector);
335 data=data<<8;
336 return data ;
206   if (key_selector == 0)
207      data = input_port_read(machine, "LINE0");
208   else
209      data = input_port_read(machine, "LINE1");
210
211   logerror("read Keyboard Offset = %x Data = %x Select = %x \n", offset, data, key_selector);
212   data = data << 8;
213   return data ;
337214}
338215
339static READ16_HANDLER(read_board_gg)
216static READ16_HANDLER( read_board_gg )
340217{
341     UINT8 i_18, i_AH;
342     UINT16 data;
218   UINT8 i_18, i_AH;
219   UINT16 data;
343220
344     data = 0xff;
221   data = 0xff;
345222
346      for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
347         {
223   for (i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
224   {
348225
349// Looking for cleared bit in Line18 -> current line
350//
226   // Looking for cleared bit in Line18 -> current line
227
351228      if ( !(Line18_REED & (1<<i_18)) )
352           {
229      {
353230
354// if there is a piece on the field -> set bit in data
355//
356           for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
357            {
358               if (strcmp ((char *)m_board[i_18][i_AH].piece, EMP))
359               {
360                  data &= ~(1 << i_AH);  // clear bit
361               }
362            }
363         }
364       }
231   // if there is a piece on the field -> set bit in data
365232
366         data = data<<8;
233         for (i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
234         {
235            if (strcmp ((char *)m_board[i_18][i_AH].piece, EMP))
236               data &= ~(1 << i_AH);  // clear bit
237         }
238      }
239   }
367240
368      read_board_flag = TRUE;
241   data = data << 8;
242   read_board_flag = TRUE;
243   logerror("read_board_data = %x \n", data);
369244
370      logerror("read_board_data = %x \n  ", data);
245//   return 0xff00;   // Mephisto need it for working
371246
372
373//    return 0xff00;   // Mephisto need it for working
374
375
376      return data;
377
247   return data;
378248}
379249
380static WRITE16_HANDLER(write_beeper_gg)
250static WRITE16_HANDLER( write_beeper_gg )
381251{
382252//  logerror("Write Board   = %x \n  ",data>>8);
383
384    UINT8 i_AH, i_18;
385    UINT16 LineAH = 0;
386
253   UINT8 i_AH, i_18;
254   UINT16 LineAH = 0;
387255   UINT8 LED;
388256
257//   logerror("Write Board   = %x \n  ",data);
389258
390//    logerror("Write Board   = %x \n  ",data);
259   LineAH = data >> 8;
391260
392    LineAH = data>>8;
393
394261   if (LineAH && Line18_LED)
395262   {
263//   logerror("Line18_LED   = %x \n  ",Line18_LED);
264//   logerror("LineAH   = %x \n  ",LineAH);
396265
397//  logerror("Line18_LED   = %x \n  ",Line18_LED);
398//  logerror("LineAH   = %x \n  ",LineAH);
399
400      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
266      for (i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
401267      {
402
403         if ( LineAH & (1<<i_AH) )
404            {
405            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
268         if ( LineAH & (1<<i_AH) )
269         {
270            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
406271            {
407272               if ( !(Line18_LED & (1<<i_18)) )
408                  {
273               {
274//                  logerror("i_18   = %d \n  ",i_18);
275//                  logerror("i_AH   = %d \n  ",i_AH);
276//                  logerror("LED an:   = %d \n  ",m_board[i_18][i_AH]);
409277
410//                      logerror("i_18   = %d \n  ",i_18);
411//                      logerror("i_AH   = %d \n  ",i_AH);
412//                      logerror("LED an:   = %d \n  ",m_board[i_18][i_AH]);
278                  LED = m_board[i_18][i_AH].field;
279                  output_set_led_value( LED, 1 );
413280
414                        LED = m_board[i_18][i_AH].field;
415
416                        output_set_led_value( LED, 1 );
417
418281//  LED on
419                  }
282               }
420283               else
421                  {
284               {
422285//  LED off
423286
424                     } // End IF 18
287               } // End IF 18
425288            } // End For 18
426           } // End IF AH
427
289         } // End IF AH
428290      } // End For AH
429
430291   } // End IF LineAH
431
432292   else
433293   {
434294//  No LED  -> all LED's off
435295      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
436         {
296      {
437297         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
438            {
298         {
439299// LED off
440                 LED = m_board[i_18][i_AH].field;
441                 output_set_led_value( LED, 0 );
442
443             } //End For 18
444         } // End For AH
445
300            LED = m_board[i_18][i_AH].field;
301            output_set_led_value( LED, 0 );
302         } //End For 18
303      } // End For AH
446304   } //End ELSE LineAH
447
448305}
449306
450307/*
r3389r3390
462319
463320*/
464321
465static WRITE32_HANDLER ( write_lcd32 )
322static WRITE32_HANDLER( write_lcd32 )
466323{
467  UINT8 lcd_data;
468  lcd_data = data>>8;
469  output_set_digit_value(lcd_shift_counter,lcd_invert&1?lcd_data^0xff:lcd_data);
470  lcd_shift_counter--;
471  lcd_shift_counter&=3;
472  //logerror("LCD Offset = %d Data   = %x \n  ",offset,lcd_data);
324   UINT8 lcd_data;
325   lcd_data = data >> 8;
326   output_set_digit_value(lcd_shift_counter, lcd_invert & 1 ? lcd_data^0xff : lcd_data);
327   lcd_shift_counter--;
328   lcd_shift_counter &= 3;
329   //logerror("LCD Offset = %d Data   = %x \n  ",offset,lcd_data);
473330}
474static WRITE32_HANDLER ( write_lcd_flag32 )
331
332static WRITE32_HANDLER( write_lcd_flag32 )
475333{
476  UINT8 lcd_flag;
477  lcd_invert=0;
478  lcd_flag=data>>24;
479  if (lcd_flag == 0) key_selector=1;
480  logerror("LCD Flag 32  = %x \n  ",lcd_flag);
481  //beep_set_state(0,lcd_flag&1?1:0);
482  if (lcd_flag!=0) led7=255;else led7=0;
334   UINT8 lcd_flag;
335   lcd_invert = 0;
336   lcd_flag = data >> 24;
337   if (lcd_flag == 0)
338      key_selector = 1;
339   logerror("LCD Flag 32 = %x \n", lcd_flag);
340   //beep_set_state(0,lcd_flag&1?1:0);
341
342   if (lcd_flag != 0)
343      led7 = 255;
344   else
345      led7 = 0;
483346}
484347
485348
486static WRITE32_HANDLER ( write_keys32 )
349static WRITE32_HANDLER( write_keys32 )
487350{
488 lcd_invert=1;
489 key_select=data;
490 logerror("Write Key = %x \n  ",key_select);
351   lcd_invert = 1;
352   key_select = data;
353   logerror("Write Key = %x \n", key_select);
491354}
492355
493static READ32_HANDLER(read_newkeys32) // Dallas 32, Roma 32
356static READ32_HANDLER( read_newkeys32 ) // Dallas 32, Roma 32
494357{
495 UINT32 data;
496 if (key_selector==0) data=input_port_read(machine, "LINE0");else data=input_port_read(machine, "LINE1");
497 //if (key_selector==1) data=input_port_read(machine, "LINE0");else data=0;
498 logerror("read Keyboard Offset = %x Data = %x\n  ",offset,data);
499 data=data<<24;
500 return data ;
358   UINT32 data;
359   if (key_selector == 0)
360      data = input_port_read(machine, "LINE0");
361   else
362      data = input_port_read(machine, "LINE1");
363   //if (key_selector==1) data=input_port_read(machine, "LINE0");else data=0;
364   logerror("read Keyboard Offset = %x Data = %x\n", offset, data);
365   data = data << 24;
366   return data ;
501367}
502368
503
504
505static READ32_HANDLER(read_board32)
369static READ32_HANDLER( read_board32 )
506370{
507  logerror("read board 32 Offset = %x \n  ",offset);
508  return 0x00000000;
371   logerror("read board 32 Offset = %x \n", offset);
372   return 0x00000000;
509373}
374
510375/*
511376static READ16_HANDLER(read_board_amsterd)
512377{
513378  logerror("read board amsterdam Offset = %x \n  ",offset);
514379  return 0xffff;
515380}
516
517381*/
518static WRITE32_HANDLER(write_board32)
382
383static WRITE32_HANDLER( write_board32 )
519384{
520 UINT8 board;
521 board=data>>24;
522 if (board==0xff) key_selector=0;
523 logerror("Write Board   = %x \n  ",data);
385   UINT8 board;
386   board = data >> 24;
387   if (board == 0xff)
388      key_selector = 0;
389   logerror("Write Board = %x \n", data);
524390}
525391
526392
527393static WRITE32_HANDLER ( write_beeper32 )
528394{
529  beep_set_state(0,data&0x01000000);
530 logerror("Write 0x8000004   = %x \n  ",data);
531 irq_flag=1;
532 beeper=data;
395   beep_set_state(0, data & 0x01000000);
396   logerror("Write 0x8000004 = %x \n", data);
397   irq_flag = 1;
398   beeper = data;
533399}
534400
535401static TIMER_CALLBACK( update_nmi )
536402{
537403   // if (irq_flag==0)cpunum_set_input_line_and_vector(machine, 0,  MC68000_IRQ_7, PULSE_LINE, MC68000_INT_ACK_AUTOVECTOR);
538404   cpunum_set_input_line_and_vector(machine, 0,  MC68000_IRQ_7, PULSE_LINE, MC68000_INT_ACK_AUTOVECTOR);
539
540405}
541406
542407static TIMER_CALLBACK( update_nmi32 )
r3389r3390
546411
547412static MACHINE_START( glasgow )
548413{
549   key_selector=0;
550   irq_flag=0;
551   lcd_shift_counter=3;
414   key_selector = 0;
415   irq_flag = 0;
416   lcd_shift_counter = 3;
552417   timer_pulse(ATTOTIME_IN_HZ(50), NULL, 0, update_nmi);
553418   beep_set_frequency(0, 44);
554419}
r3389r3390
556421
557422static MACHINE_START( dallas32 )
558423{
559   lcd_shift_counter=3;
560
424   lcd_shift_counter = 3;
561425   timer_pulse(ATTOTIME_IN_HZ(50), NULL, 0, update_nmi32);
562426   beep_set_frequency(0, 44);
563427}
r3389r3390
565429
566430static MACHINE_RESET( glasgow )
567431{
568   lcd_shift_counter=3;
569
570    clear_layout();
571    set_render_board();
572    set_status_of_pieces();
432   lcd_shift_counter = 3;
573433}
574434
575435
576
577static VIDEO_START( glasgow )
578{
579}
580
581
582
583
584static VIDEO_UPDATE( glasgow )
585{
586//  INT32 lg_x, lg_y;
587//  UINT8 p_key;
588
589    const char *piece;
590
591   float save_x, save_y;
592
593   my_target = render_get_ui_target();
594
595// Get view item of cursor
596//
597//  my_cursor = my_target->curview->itemlist[3]->next;
598   if (my_cursor == NULL)
599      my_cursor = get_view_item(my_target,"CURSOR_1");
600
601//  my_cursor = my_target->curview->itemlist[2];
602
603// Mouse movement
604//
605   if (my_cursor != NULL)
606      set_cursor (screen->machine, my_cursor);
607
608    m_button1=input_port_read(screen->machine, "BUTTON_L");
609    m_button2=input_port_read(screen->machine, "BUTTON_R");
610
611    if ( m_button1) MOUSE_BUTTON1_WAIT = 0;
612
613    if ( m_button1 != 1 && !MOUSE_BUTTON1_WAIT )
614      {
615
616         MOUSE_BUTTON1_WAIT = 1;
617
618         if (MOUSE_MOVE == 0)
619            {
620
621            cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
622            if ( strcmp((char *)cursor_field.piece, "0") && (strcmp((char *)cursor_field.piece, EMP))  && strcmp(my_cursor->output_name, (char *)cursor_field.piece ) )
623               {
624               update_board(my_target,cursor_field, 0);
625
626               my_cursor->color.a = 0;
627
628               my_cursor = get_view_item(my_target, (char *)cursor_field.piece);
629               my_cursor->color.a = 0.5;
630
631               MOUSE_MOVE = 1;
632
633               }
634            } // ENDIF MOUSE_MOVE
635         else
636            {
637
638            save_x = my_cursor->rawbounds.x0;
639            save_y = my_cursor->rawbounds.y0;
640
641            cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
642            if ( strcmp((char *)cursor_field.piece, "0") && strcmp(my_cursor->output_name, "CURSOR_1") )
643               {
644
645// Put piece back to board
646//
647                 strcpy((char *)cursor_field.piece, (char *)my_cursor->output_name);
648               update_board(my_target,cursor_field, 1);
649               my_cursor->color.a = 1;
650
651// Set piece to field
652//
653               calculate_bounds(my_cursor, (float) cursor_field.x, (float) cursor_field.y, 0 ,0  );
654
655
656// Get old cursor and set new x,y
657//
658               my_cursor = get_view_item(my_target,"CURSOR_1");
659               my_cursor->color.a = 1;
660
661               calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_Y  );
662
663               MOUSE_MOVE = 0;
664
665               }//ENDIF curosr_field
666
667// piece is set out of board -> remove it
668//
669        if  ( out_of_board(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0) )
670         {
671
672         save_x = my_cursor->rawbounds.x0;
673         save_y = my_cursor->rawbounds.y0;
674
675            my_cursor->color.a = 0;
676         my_cursor = get_view_item(my_target,"CURSOR_1");
677         my_cursor->color.a = 1;
678         calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_X  );
679
680         MOUSE_MOVE = 0;
681         }
682
683         }//ELSE MOUSE_MOVE
684
685       } // ENDIF m_button1
686
687
688// right mouse button -> set pieces
689//
690   if ( m_button2) MOUSE_BUTTON2_WAIT = 0;
691    if ( m_button2 != 1 && !MOUSE_BUTTON2_WAIT )
692      {
693
694      MOUSE_BUTTON2_WAIT = 1;
695
696// save cursor position
697//
698      save_x = my_cursor->rawbounds.x0;
699      save_y = my_cursor->rawbounds.y0;
700
701// cursor off
702//
703      my_cursor->color.a = 0;
704
705// change cursor to piece
706//
707        piece = get_non_set_pieces(my_cursor->output_name);
708
709      if (strcmp(piece,NO_PIECE))
710         {
711         my_cursor = get_view_item(my_target,piece);
712         my_cursor->color.a = 0.5;
713
714         calculate_bounds(my_cursor, save_x, save_y, 0 ,0  );
715
716         MOUSE_MOVE = 1;
717         }
718      else
719         {
720           my_cursor = get_view_item(my_target,"CURSOR_1");
721         my_cursor->color.a = 1;
722            calculate_bounds(my_cursor, save_x, save_y, MOUSE_X ,MOUSE_X  );
723         MOUSE_MOVE = 0;
724         }
725
726      }
727
728// Put Item back to render
729//
730    render_set_ui_target (my_target);
731
732      return 0;
733}
734
735
736
737
738
739static VIDEO_UPDATE( dallas32 )
740{
741 return 0;
742}
743
744436static ADDRESS_MAP_START(glasgow_mem, ADDRESS_SPACE_PROGRAM, 16)
745   AM_RANGE( 0x0000, 0xffff ) AM_ROM
746   AM_RANGE( 0x00ff0000, 0x00ff0001)  AM_MIRROR ( 0xfe0000 ) AM_WRITE     ( write_lcd_gg )
747  AM_RANGE( 0x00ff0002, 0x00ff0003)  AM_MIRROR ( 0xfe0002 ) AM_READWRITE ( read_keys,write_keys )
748  AM_RANGE( 0x00ff0004, 0x00ff0005)  AM_MIRROR ( 0xfe0004 ) AM_WRITE     ( write_lcd_flag_gg )
749  AM_RANGE( 0x00ff0006, 0x00ff0007)  AM_MIRROR ( 0xfe0006 ) AM_READWRITE ( read_board_gg, write_beeper_gg )
750  AM_RANGE( 0x00ff0008, 0x00ff0009)  AM_MIRROR ( 0xfe0008 ) AM_WRITE     ( write_board_gg )
751  AM_RANGE( 0x00ffC000, 0x00ffFFFF)  AM_MIRROR ( 0xfeC000 ) AM_RAM      // 16KB
437   AM_RANGE(0x00000000, 0x0000ffff) AM_ROM
438   AM_RANGE(0x00ff0000, 0x00ff0001) AM_MIRROR(0xfe0000) AM_WRITE( write_lcd_gg )
439   AM_RANGE(0x00ff0002, 0x00ff0003) AM_MIRROR(0xfe0002) AM_READWRITE( read_keys,write_keys )
440   AM_RANGE(0x00ff0004, 0x00ff0005) AM_MIRROR(0xfe0004) AM_WRITE( write_lcd_flag_gg )
441   AM_RANGE(0x00ff0006, 0x00ff0007) AM_MIRROR(0xfe0006) AM_READWRITE( read_board_gg, write_beeper_gg )
442   AM_RANGE(0x00ff0008, 0x00ff0009) AM_MIRROR(0xfe0008) AM_WRITE( write_board_gg )
443   AM_RANGE(0x00ffc000, 0x00ffffff) AM_MIRROR(0xfec000) AM_RAM      // 16KB
752444ADDRESS_MAP_END
753445
754446
755447static ADDRESS_MAP_START(amsterd_mem, ADDRESS_SPACE_PROGRAM, 16)
756448   // ADDRESS_MAP_GLOBAL_MASK(0x7FFFF)
757    AM_RANGE( 0x0000, 0xffff )         AM_ROM
758    AM_RANGE( 0x00800002, 0x00800003)  AM_WRITE( write_lcd )
759    AM_RANGE( 0x00800008, 0x00800009)  AM_WRITE( write_lcd_flag )
760    AM_RANGE( 0x00800004, 0x00800005)  AM_WRITE( write_irq_flag )
761    AM_RANGE( 0x00800010, 0x00800011)  AM_WRITE( write_board )
762    AM_RANGE( 0x00800020, 0x00800021)  AM_READ ( read_board )
763    AM_RANGE( 0x00800040, 0x00800041)  AM_READ ( read_newkeys16 )
764    AM_RANGE( 0x00800088, 0x00800089)  AM_WRITE( write_beeper )
765    AM_RANGE( 0x00ffC000, 0x00ffFFFF)  AM_RAM      // 16KB
449   AM_RANGE(0x00000000, 0x0000ffff) AM_ROM
450   AM_RANGE(0x00800002, 0x00800003) AM_WRITE( write_lcd )
451   AM_RANGE(0x00800008, 0x00800009) AM_WRITE( write_lcd_flag )
452   AM_RANGE(0x00800004, 0x00800005) AM_WRITE( write_irq_flag )
453   AM_RANGE(0x00800010, 0x00800011) AM_WRITE( write_board )
454   AM_RANGE(0x00800020, 0x00800021) AM_READ( read_board )
455   AM_RANGE(0x00800040, 0x00800041) AM_READ( read_newkeys16 )
456   AM_RANGE(0x00800088, 0x00800089) AM_WRITE( write_beeper )
457   AM_RANGE(0x00ffc000, 0x00ffffff) AM_RAM      // 16KB
766458ADDRESS_MAP_END
767459
768460
769461static ADDRESS_MAP_START(dallas32_mem, ADDRESS_SPACE_PROGRAM, 32)
770     // ADDRESS_MAP_GLOBAL_MASK(0x1FFFF)
771     AM_RANGE( 0x0000, 0xffff )        AM_ROM
772     AM_RANGE( 0x00800000, 0x00800003) AM_WRITE ( write_lcd32 )
773     AM_RANGE( 0x00800004, 0x00800007) AM_WRITE ( write_beeper32 )
774     AM_RANGE( 0x00800008, 0x0080000B) AM_WRITE ( write_lcd_flag32 )
775     AM_RANGE( 0x00800010, 0x00800013) AM_WRITE ( write_board32 )
776     AM_RANGE( 0x00800020, 0x00800023) AM_READ  ( read_board32 )
777     AM_RANGE( 0x00800040, 0x00800043) AM_READ  ( read_newkeys32 )
778     AM_RANGE( 0x00800088, 0x0080008b) AM_WRITE ( write_keys32 )
779     AM_RANGE( 0x0010000, 0x001FFFF)   AM_RAM      // 64KB
462   // ADDRESS_MAP_GLOBAL_MASK(0x1FFFF)
463   AM_RANGE(0x00000000, 0x0000ffff) AM_ROM
464   AM_RANGE(0x00800000, 0x00800003) AM_WRITE( write_lcd32 )
465   AM_RANGE(0x00800004, 0x00800007) AM_WRITE( write_beeper32 )
466   AM_RANGE(0x00800008, 0x0080000B) AM_WRITE( write_lcd_flag32 )
467   AM_RANGE(0x00800010, 0x00800013) AM_WRITE( write_board32 )
468   AM_RANGE(0x00800020, 0x00800023) AM_READ( read_board32 )
469   AM_RANGE(0x00800040, 0x00800043) AM_READ( read_newkeys32 )
470   AM_RANGE(0x00800088, 0x0080008b) AM_WRITE( write_keys32 )
471   AM_RANGE(0x0010000, 0x001ffff) AM_RAM   // 64KB
780472ADDRESS_MAP_END
781473
782474static INPUT_PORTS_START( new_keyboard ) //Amsterdam, Dallas 32, Roma, Roma 32
783  PORT_START("LINE0")
784  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_A ) PORT_CODE(KEYCODE_1 )
785  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_B ) PORT_CODE(KEYCODE_2 )
786  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_C ) PORT_CODE(KEYCODE_3 )
787  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_D ) PORT_CODE(KEYCODE_4 )
788  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_E ) PORT_CODE(KEYCODE_5 )
789  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_F ) PORT_CODE(KEYCODE_6 )
790  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0")   PORT_CODE(KEYCODE_9 )
791  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9")   PORT_CODE(KEYCODE_0 )
792  PORT_START("LINE1")
793  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1 )
794  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2 )
795  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3 )
796  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4 )
797  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLR") PORT_CODE(KEYCODE_F5 )
798  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER )
799  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_G ) PORT_CODE(KEYCODE_7 )
800  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_H ) PORT_CODE(KEYCODE_8 )
475   PORT_START("LINE0")
476   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A1") PORT_CODE(KEYCODE_A) PORT_CODE(KEYCODE_1)
477   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B2") PORT_CODE(KEYCODE_B) PORT_CODE(KEYCODE_2)
478   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C3") PORT_CODE(KEYCODE_C) PORT_CODE(KEYCODE_3)
479   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D4") PORT_CODE(KEYCODE_D) PORT_CODE(KEYCODE_4)
480   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E5") PORT_CODE(KEYCODE_E) PORT_CODE(KEYCODE_5)
481   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F) PORT_CODE(KEYCODE_6)
482   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_9)
483   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_0)
801484
802  PORT_START("MOUSE_X")
803  PORT_BIT( 0xffff, 0x00, IPT_MOUSE_X)  PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
804
805  PORT_START("MOUSE_Y")
806  PORT_BIT( 0xffff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
807
808  PORT_START("BUTTON_L")
809  PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("left button")
810
811  PORT_START("BUTTON_R")
812  PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("right button")
485   PORT_START("LINE1")
486   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1)
487   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2)
488   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3)
489   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4)
490   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLR") PORT_CODE(KEYCODE_F5)
491   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER)
492   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G7") PORT_CODE(KEYCODE_G) PORT_CODE(KEYCODE_7)
493   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H8") PORT_CODE(KEYCODE_H) PORT_CODE(KEYCODE_8)
813494INPUT_PORTS_END
814495
815
816
817496static INPUT_PORTS_START( old_keyboard )   //Glasgow,Dallas
818  PORT_START("LINE0")
819    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9")   PORT_CODE(KEYCODE_9 )
820    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CL")  PORT_CODE(KEYCODE_F5 )
821    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_C ) PORT_CODE(KEYCODE_3 )
822    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER )
823    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_D ) PORT_CODE(KEYCODE_4 )
824    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_A ) PORT_CODE(KEYCODE_1 )
825    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_F ) PORT_CODE(KEYCODE_6 )
826    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_B ) PORT_CODE(KEYCODE_2 )
827  PORT_START("LINE1")
828    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_E ) PORT_CODE(KEYCODE_5 )
829    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1 )
830    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0")   PORT_CODE(KEYCODE_0 )
831    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2 )
832    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_H ) PORT_CODE(KEYCODE_8 )
833    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3)
834    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_G ) PORT_CODE(KEYCODE_7 )
835    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4)
497   PORT_START("LINE0")
498   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9)
499   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CL") PORT_CODE(KEYCODE_F5)
500   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C3") PORT_CODE(KEYCODE_C) PORT_CODE(KEYCODE_3)
501   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER)
502   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D4") PORT_CODE(KEYCODE_D) PORT_CODE(KEYCODE_4)
503   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A1") PORT_CODE(KEYCODE_A) PORT_CODE(KEYCODE_1)
504   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F) PORT_CODE(KEYCODE_6)
505   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B2") PORT_CODE(KEYCODE_B) PORT_CODE(KEYCODE_2)
836506
837  PORT_START("MOUSE_X")
838    PORT_BIT( 0xffff, 0x00, IPT_MOUSE_X)  PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
839
840  PORT_START("MOUSE_Y")
841    PORT_BIT( 0xffff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
842
843  PORT_START("BUTTON_L")
844    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("left button")
845
846  PORT_START("BUTTON_R")
847    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("right button")
507   PORT_START("LINE1")
508   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E5") PORT_CODE(KEYCODE_E) PORT_CODE(KEYCODE_5)
509   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1)
510   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0)
511   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2)
512   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H8") PORT_CODE(KEYCODE_H) PORT_CODE(KEYCODE_8)
513   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3)
514   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7") PORT_CODE(KEYCODE_G) PORT_CODE(KEYCODE_7)
515   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4)
848516INPUT_PORTS_END
849517
850518
851519
852520static MACHINE_DRIVER_START(glasgow )
853    /* basic machine hardware */
854    MDRV_CPU_ADD("main", M68000, 12000000)
521   /* basic machine hardware */
522   MDRV_CPU_ADD("main", M68000, 12000000)
855523   MDRV_CPU_PROGRAM_MAP(glasgow_mem, 0)
856524   MDRV_MACHINE_START(glasgow)
857525   MDRV_MACHINE_RESET(glasgow)
858526
859     /* video hardware */
860    MDRV_SCREEN_ADD("main", RASTER)
861    MDRV_SCREEN_REFRESH_RATE(60)
862    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
863    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
864    MDRV_SCREEN_SIZE(640, 480)
865    MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
866    MDRV_PALETTE_LENGTH(4)
867
868    MDRV_VIDEO_START(glasgow)
869    MDRV_VIDEO_UPDATE(glasgow)
870    MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
871    MDRV_DEFAULT_LAYOUT(layout_glasgow)
872   
873    MDRV_SPEAKER_STANDARD_MONO("mono")
527   /* video hardware */
528   MDRV_DEFAULT_LAYOUT(layout_glasgow)
529   
530   MDRV_SPEAKER_STANDARD_MONO("mono")
874531   MDRV_SOUND_ADD("beep", BEEP, 0)
875532   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
876533MACHINE_DRIVER_END
r3389r3390
878535
879536static MACHINE_DRIVER_START(amsterd )
880537   MDRV_IMPORT_FROM( glasgow )
538
881539   /* basic machine hardware */
882540   MDRV_CPU_MODIFY("main")
883541   MDRV_CPU_PROGRAM_MAP(amsterd_mem, 0)
884   MDRV_VIDEO_UPDATE(dallas32)
885542MACHINE_DRIVER_END
886543
887544
888545static MACHINE_DRIVER_START(dallas32 )
889546   MDRV_IMPORT_FROM( glasgow )
547
890548   /* basic machine hardware */
891549   MDRV_CPU_REPLACE("main", M68020, 14000000)
892550   MDRV_CPU_PROGRAM_MAP(dallas32_mem, 0)
893551   MDRV_MACHINE_START( dallas32 )
894  MDRV_VIDEO_UPDATE(dallas32)
895552MACHINE_DRIVER_END
896553
897554
r3389r3390
900557***************************************************************************/
901558
902559ROM_START( glasgow )
903    ROM_REGION( 0x10000, "main", 0 )
904    //ROM_LOAD("glasgow.rom", 0x000000, 0x10000, CRC(3e73eff3) )
905    ROM_LOAD16_BYTE("me3_3_1u.410",0x00000, 0x04000,CRC(bc8053ba) SHA1(57ea2d5652bfdd77b17d52ab1914de974bd6be12))
906    ROM_LOAD16_BYTE("me3_1_1l.410",0x00001, 0x04000,CRC(d5263c39) SHA1(1bef1cf3fd96221eb19faecb6ec921e26ac10ac4))
907    ROM_LOAD16_BYTE("me3_4_2u.410",0x08000, 0x04000,CRC(8dba504a) SHA1(6bfab03af835cdb6c98773164d32c76520937efe))
908    ROM_LOAD16_BYTE("me3_2_2l.410",0x08001, 0x04000,CRC(b3f27827) SHA1(864ba897d24024592d08c4ae090aa70a2cc5f213))
560   ROM_REGION( 0x10000, "main", 0 )
561   //ROM_LOAD("glasgow.rom", 0x000000, 0x10000, CRC(3e73eff3) )
562   ROM_LOAD16_BYTE("me3_3_1u.410",0x00000, 0x04000,CRC(bc8053ba) SHA1(57ea2d5652bfdd77b17d52ab1914de974bd6be12))
563   ROM_LOAD16_BYTE("me3_1_1l.410",0x00001, 0x04000,CRC(d5263c39) SHA1(1bef1cf3fd96221eb19faecb6ec921e26ac10ac4))
564   ROM_LOAD16_BYTE("me3_4_2u.410",0x08000, 0x04000,CRC(8dba504a) SHA1(6bfab03af835cdb6c98773164d32c76520937efe))
565   ROM_LOAD16_BYTE("me3_2_2l.410",0x08001, 0x04000,CRC(b3f27827) SHA1(864ba897d24024592d08c4ae090aa70a2cc5f213))
909566ROM_END
910567
911568ROM_START( amsterd )
912    ROM_REGION16_BE( 0x1000000, "main", 0 )
913    //ROM_LOAD16_BYTE("output.bin", 0x000000, 0x10000, CRC(3e73eff3) )
914    ROM_LOAD16_BYTE("amsterda-u.bin",0x00000, 0x05a00,CRC(16cefe29) SHA1(9f8c2896e92fbfd47159a59cb5e87706092c86f4))
915    ROM_LOAD16_BYTE("amsterda-l.bin",0x00001, 0x05a00,CRC(c859dfde) SHA1(b0bca6a8e698c322a8c597608db6735129d6cdf0))
569   ROM_REGION16_BE( 0x1000000, "main", 0 )
570   //ROM_LOAD16_BYTE("output.bin", 0x000000, 0x10000, CRC(3e73eff3) )
571   ROM_LOAD16_BYTE("amsterda-u.bin",0x00000, 0x05a00,CRC(16cefe29) SHA1(9f8c2896e92fbfd47159a59cb5e87706092c86f4))
572   ROM_LOAD16_BYTE("amsterda-l.bin",0x00001, 0x05a00,CRC(c859dfde) SHA1(b0bca6a8e698c322a8c597608db6735129d6cdf0))
916573ROM_END
917574
918575
919576ROM_START( dallas )
920    ROM_REGION16_BE( 0x1000000, "main", 0 )
921    ROM_LOAD16_BYTE("dal_g_pr.dat",0x00000, 0x04000,CRC(66deade9) SHA1(07ec6b923f2f053172737f1fc94aec84f3ea8da1))
922    ROM_LOAD16_BYTE("dal_g_pl.dat",0x00001, 0x04000,CRC(c5b6171c) SHA1(663167a3839ed7508ecb44fd5a1b2d3d8e466763))
923    ROM_LOAD16_BYTE("dal_g_br.dat",0x08000, 0x04000,CRC(e24d7ec7) SHA1(a936f6fcbe9bfa49bf455f2d8a8243d1395768c1))
924    ROM_LOAD16_BYTE("dal_g_bl.dat",0x08001, 0x04000,CRC(144a15e2) SHA1(c4fcc23d55fa5262f5e01dbd000644a7feb78f32))
577   ROM_REGION16_BE( 0x1000000, "main", 0 )
578   ROM_LOAD16_BYTE("dal_g_pr.dat",0x00000, 0x04000,CRC(66deade9) SHA1(07ec6b923f2f053172737f1fc94aec84f3ea8da1))
579   ROM_LOAD16_BYTE("dal_g_pl.dat",0x00001, 0x04000,CRC(c5b6171c) SHA1(663167a3839ed7508ecb44fd5a1b2d3d8e466763))
580   ROM_LOAD16_BYTE("dal_g_br.dat",0x08000, 0x04000,CRC(e24d7ec7) SHA1(a936f6fcbe9bfa49bf455f2d8a8243d1395768c1))
581   ROM_LOAD16_BYTE("dal_g_bl.dat",0x08001, 0x04000,CRC(144a15e2) SHA1(c4fcc23d55fa5262f5e01dbd000644a7feb78f32))
925582ROM_END
926583
927584ROM_START( dallas16 )
928    ROM_REGION16_BE( 0x1000000, "main", 0 )
929    ROM_LOAD16_BYTE("dallas-u.bin",0x00000, 0x06f00,CRC(8c1462b4) SHA1(8b5f5a774a835446d08dceacac42357b9e74cfe8))
930    ROM_LOAD16_BYTE("dallas-l.bin",0x00001, 0x06f00,CRC(f0d5bc03) SHA1(4b1b9a71663d5321820b4cf7da205e5fe5d3d001))
585   ROM_REGION16_BE( 0x1000000, "main", 0 )
586   ROM_LOAD16_BYTE("dallas-u.bin",0x00000, 0x06f00,CRC(8c1462b4) SHA1(8b5f5a774a835446d08dceacac42357b9e74cfe8))
587   ROM_LOAD16_BYTE("dallas-l.bin",0x00001, 0x06f00,CRC(f0d5bc03) SHA1(4b1b9a71663d5321820b4cf7da205e5fe5d3d001))
931588ROM_END
932589
933590ROM_START( roma )
934    ROM_REGION16_BE( 0x1000000, "main", 0 )
935    ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd))
591   ROM_REGION16_BE( 0x1000000, "main", 0 )
592   ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd))
936593ROM_END
937594
938595ROM_START( dallas32 )
939    ROM_REGION( 0x10000, "main", 0 )
940    ROM_LOAD("dallas32.epr", 0x000000, 0x10000, CRC(83b9ff3f) SHA1(97bf4cb3c61f8ec328735b3c98281bba44b30a28) )
596   ROM_REGION( 0x10000, "main", 0 )
597   ROM_LOAD("dallas32.epr", 0x000000, 0x10000, CRC(83b9ff3f) SHA1(97bf4cb3c61f8ec328735b3c98281bba44b30a28) )
941598ROM_END
942599
943600ROM_START( roma32 )
944    ROM_REGION( 0x10000, "main", 0 )
945    ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd) )
601   ROM_REGION( 0x10000, "main", 0 )
602   ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd) )
946603ROM_END
947604
948/***************************************************************************
949  System config
950***************************************************************************/
951605
952
953
954606/***************************************************************************
955607  Game drivers
956608***************************************************************************/
r3389r3390
963615CONS(  1984, dallas32, 0,        0,    dallas32,      new_keyboard,   0,       NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas 32 Bit", 0)
964616CONS(  1984, roma32,   0,        0,    dallas32,      new_keyboard,   0,       NULL,   "Hegener & Glaser Muenchen",  "Mephisto Roma 32 Bit",   0)
965617CONS(  1984, dallas16, 0,        0,    amsterd,       new_keyboard,   0,      NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas 16 Bit", 0)
966
967
968
969static void set_cursor (running_machine *machine, view_item *view_cursor)
970  {
971
972   static INT16 save_x, save_y;
973   static float diff_x, diff_y, del_x, del_y;
974
975    save_x = m_x;
976    save_y = m_y;
977
978    m_x=input_port_read(machine, "MOUSE_X");
979    m_y=input_port_read(machine, "MOUSE_Y");
980
981//    logerror("m_x   = %d \n  ",m_x);
982//    logerror("m_y   = %d \n  ",m_y);
983
984    diff_x = (float) (save_x - m_x) / MOUSE_SPEED;
985    diff_y = (float) (save_y - m_y) / MOUSE_SPEED;
986
987    del_x = view_cursor->rawbounds.x1 - view_cursor->rawbounds.x0;
988    del_y = view_cursor->rawbounds.y1 - view_cursor->rawbounds.y0;
989
990// Set Cursor, depending on limits
991//
992      view_cursor->rawbounds.x0 =   view_cursor->rawbounds.x0 - diff_x;
993
994      if ( view_cursor->rawbounds.x0 > MAX_CURSOR_X )
995           view_cursor->rawbounds.x0 = MAX_CURSOR_X;
996
997     if ( view_cursor->rawbounds.x0 < MIN_CURSOR_X )
998           view_cursor->rawbounds.x0 = MIN_CURSOR_X;
999
1000      view_cursor->rawbounds.y0 =   view_cursor->rawbounds.y0 - diff_y;
1001
1002      if ( view_cursor->rawbounds.y0 > MAX_CURSOR_Y )
1003           view_cursor->rawbounds.y0 = MAX_CURSOR_Y;
1004
1005     if ( view_cursor->rawbounds.y0 < MIN_CURSOR_Y )
1006         view_cursor->rawbounds.y0 = MIN_CURSOR_Y;
1007
1008      view_cursor->rawbounds.x1 = view_cursor->rawbounds.x0 + del_x;
1009      view_cursor->rawbounds.y1 = view_cursor->rawbounds.y0 + del_y;
1010
1011// Calculate bounds
1012//
1013     view_cursor->bounds.x0 = view_cursor->rawbounds.x0 / MAX_X;
1014     view_cursor->bounds.y0 = view_cursor->rawbounds.y0 / MAX_Y;
1015     view_cursor->bounds.x1 = view_cursor->rawbounds.x1 / MAX_X;
1016     view_cursor->bounds.y1 = view_cursor->rawbounds.y1 / MAX_Y;
1017
1018  }
1019
1020//render_target *render_target_get_indexed
1021
1022
1023view_item *get_view_item(render_target *target, const char *v_name)
1024{
1025
1026 view_item *cur_view;
1027 cur_view = target->curview->itemlist[3]->next;
1028
1029 for (; cur_view != NULL; cur_view = cur_view->next)
1030 {
1031   if (!strcmp(cur_view->output_name, v_name))
1032      {
1033      return (cur_view);
1034      }
1035 }
1036
1037return (NULL);
1038}
1039
1040
1041BOARD_FIELD get_field( float i_x, float i_y, UINT8 mouse_move)
1042{
1043UINT8 i_AH, i_18;
1044float corr_x, corr_y;
1045
1046
1047float f_x, f_y;
1048
1049BOARD_FIELD null_board  = { 0,0,0,"0"};
1050
1051
1052// Correction of mouse pointer
1053//
1054     if (!mouse_move)
1055      {
1056      corr_x = i_x+29.0;
1057      corr_y = i_y+22.0;
1058      }else
1059       {
1060      corr_x = i_x+28;
1061      corr_y = i_y+28;
1062      }
1063
1064// Loop ?ber alle Spalten
1065      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1066      {
1067
1068            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1069            {
1070             f_x =   (float) m_board [i_18] [i_AH].x;
1071             f_y =   (float) m_board [i_18] [i_AH].y;
1072
1073                if (   ( corr_x >= f_x  && corr_x <= f_x+56 ) && ( corr_y >= f_y  && corr_y <= f_y+56 ) )
1074             {
1075             return (m_board [i_18] [i_AH]);
1076             }
1077
1078            }
1079      }
1080
1081return (null_board);
1082}
1083
1084
1085static unsigned int out_of_board( float x0, float y0)
1086{
1087
1088   if ( ( x0 >= MIN_BOARD_X  && x0 <= MAX_BOARD_X ) && ( y0 >= MIN_BOARD_Y  && y0 <= MAX_BOARD_Y ) )
1089      {
1090      return (0);
1091      }
1092   else
1093      {
1094      return (1);
1095      }
1096}
1097
1098
1099
1100static void update_board(render_target *target, BOARD_FIELD board_field, unsigned int update_clear_flag)
1101{
1102
1103   UINT8 i_18, i_AH;
1104
1105   view_item *view_item;
1106
1107   div_t div_result;
1108
1109   div_result = div(board_field.field, 8);
1110
1111   i_18 = div_result.quot;
1112   i_AH = 7 - div_result.rem;
1113
1114   if (update_clear_flag)
1115   {
1116// there is already a piece on target field - > set it invisible
1117//
1118      view_item = get_view_item(target, (char *)m_board[i_18][i_AH].piece);
1119      if (view_item != NULL)
1120         {
1121         view_item->color.a = 0;
1122         }
1123      strcpy ((char *)&m_board[i_18][i_AH].piece[0], (char *)&board_field.piece[0]);
1124   }else
1125   {
1126      strcpy ((char *)m_board[i_18][i_AH].piece, EMP);
1127   }
1128
1129   set_status_of_pieces();
1130
1131}
1132
1133 static void calculate_bounds(view_item *view_item, float new_x0, float new_y0, float new_del_x, float new_del_y )
1134  {
1135
1136   static float del_x, del_y;
1137
1138      if (new_del_x)
1139      {
1140      del_x = new_del_x;
1141      }
1142     else
1143      {
1144      del_x = view_item->rawbounds.x1 - view_item->rawbounds.x0;
1145      }
1146
1147      if (new_del_y)
1148      {
1149      del_y = new_del_y;
1150      }
1151     else
1152      {
1153      del_y = view_item->rawbounds.y1 - view_item->rawbounds.y0;
1154      }
1155
1156      view_item->rawbounds.x0 = new_x0;
1157      view_item->rawbounds.y0 = new_y0;
1158      view_item->rawbounds.x1 = view_item->rawbounds.x0 + del_x;
1159      view_item->rawbounds.y1 = view_item->rawbounds.y0 + del_y;
1160
1161// Calculate bounds
1162//
1163     view_item->bounds.x0 = view_item->rawbounds.x0 / MAX_X;
1164     view_item->bounds.y0 = view_item->rawbounds.y0 / MAX_Y;
1165     view_item->bounds.x1 = view_item->rawbounds.x1 / MAX_X;
1166     view_item->bounds.y1 = view_item->rawbounds.y1 / MAX_Y;
1167
1168  }
1169
1170
1171static void set_render_board()
1172   {
1173
1174    view_item *view_item;
1175    UINT8 i_AH, i_18;
1176
1177   my_target = render_get_ui_target();
1178
1179
1180    for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1181      {
1182         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1183         {
1184
1185// copy start postition to m_board
1186//
1187            m_board[i_18][i_AH] = start_board [i_18] [i_AH];
1188
1189// Get view item of this piece
1190//
1191         if (strcmp((char *)m_board[i_18][i_AH].piece, EMP))
1192            {
1193            view_item = get_view_item(my_target, (char *)m_board[i_18][i_AH].piece);
1194
1195// change all pieces
1196//
1197            if (view_item != NULL)
1198               {
1199               calculate_bounds(view_item, m_board[i_18][i_AH].x, m_board[i_18][i_AH].y, 0, 0 );
1200               view_item->color.a = 1.0;
1201               }//ENDIF view_item
1202
1203            } // ENDIF strcmp
1204         }// FOR i_18
1205      }// FOR i_AH
1206
1207    render_set_ui_target (my_target);
1208
1209   }
1210
1211static void clear_layout()
1212   {
1213
1214    view_item *view_item;
1215    UINT8 i;
1216
1217   my_target = render_get_ui_target();
1218
1219   for ( i = 0; i < 44; i = i + 1)
1220      {
1221         view_item = get_view_item(my_target,(char *)all_pieces[i].piece);
1222       if (view_item != NULL)
1223         {
1224         view_item->color.a = 0.0;
1225         }
1226      }
1227
1228    render_set_ui_target (my_target);
1229
1230   }
1231
1232
1233
1234static void set_status_of_pieces()
1235   {
1236
1237    UINT8 i_AH, i_18 , i;
1238    BOARD_FIELD field;
1239
1240
1241   for ( i = 0; i < 47; i = i + 1)
1242      {
1243
1244        all_pieces[i].set = 0;
1245
1246       for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1247         {
1248         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1249            {
1250
1251// set status depending piece is in game or not
1252//
1253            field = m_board[i_18][i_AH];
1254
1255            if (!strcmp((char *)m_board[i_18][i_AH].piece, (char *) all_pieces[i].piece))
1256               {
1257               all_pieces[i].set = 1;
1258               break;
1259               }
1260
1261            } // END for i_18=0
1262
1263         if (all_pieces[i].set) break;
1264
1265         }// END for i_AH=0
1266      } // END for i=0
1267
1268   }
1269
1270
1271static const char *get_non_set_pieces(const char *cur_piece)
1272{
1273   UINT8 i=0;
1274
1275   do
1276      {
1277
1278      start_i = start_i+1;
1279      if ( start_i ==  44) start_i = 0;
1280
1281
1282       if (!all_pieces[start_i].set && ( all_pieces[start_i].piece[0] != cur_piece[0] ||
1283                                        all_pieces[start_i].piece[1] != cur_piece[1]) )
1284           {
1285         return ((const char *)&all_pieces[start_i].piece[0]);
1286         }
1287
1288      i=i+1;
1289}
1290   while (i != 44);
1291
1292   return (NO_PIECE);
1293}
1294
1295

Previous 15994 Revisions Next


© 1998-2018 The MESS Team