src/mess/drivers/glasgow.c
| r1236 | r1237 | |
| 28 | 28 | #include "glasgow.lh"
|
| 29 | 29 | #include "sound/beep.h"
|
| 30 | 30 | |
| 31 | #include "render.h"
|
| 32 | #include "rendlay.h"
|
| 33 | |
| 31 | 34 | static UINT8 lcd_shift_counter;
|
| 32 | 35 | // static UINT8 led_status;
|
| 33 | 36 | static UINT8 led7;
|
| r1236 | r1237 | |
| 41 | 44 | static UINT16 beeper;
|
| 42 | 45 | |
| 43 | 46 | |
| 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
|
| 52 | |
| 53 | #define MIN_BOARD_X 60.0
|
| 54 | #define MAX_BOARD_X 480.0
|
| 55 | |
| 56 | #define MIN_BOARD_Y 60.0
|
| 57 | #define MAX_BOARD_Y 480.0
|
| 58 | |
| 59 | #define MIN_CURSOR_X -10
|
| 60 | #define MAX_CURSOR_X 496
|
| 61 | |
| 62 | #define MIN_CURSOR_Y 0
|
| 63 | #define MAX_CURSOR_Y 622
|
| 64 | |
| 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 char EMP[4] = "EMP";
|
| 77 | static 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 | |
| 103 | BOARD_FIELD m_board[8][8];
|
| 104 | |
| 105 | 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 (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 char * get_non_set_pieces(const char *cur_piece);
|
| 191 | |
| 192 | static unsigned int out_of_board( float x0, float y0);
|
| 193 | |
| 194 | |
| 195 | |
| 44 | 196 | // Used by Glasgow and Dallas
|
| 45 | 197 | static WRITE16_HANDLER ( write_lcd_gg )
|
| 46 | 198 | {
|
| r1236 | r1237 | |
| 49 | 201 | if (led7==0) output_set_digit_value(lcd_shift_counter,lcd_data);
|
| 50 | 202 | lcd_shift_counter--;
|
| 51 | 203 | lcd_shift_counter&=3;
|
| 52 | | logerror("LCD Offset = %d Data low = %x \n ",offset,lcd_data);
|
| 204 | // logerror("LCD Offset = %d Data low = %x \n ",offset,lcd_data);
|
| 53 | 205 | }
|
| 54 | 206 | |
| 55 | 207 | static WRITE16_HANDLER ( write_lcd )
|
| r1236 | r1237 | |
| 59 | 211 | output_set_digit_value(lcd_shift_counter,lcd_invert&1?lcd_data^0xff:lcd_data);
|
| 60 | 212 | lcd_shift_counter--;
|
| 61 | 213 | lcd_shift_counter&=3;
|
| 62 | | logerror("LCD Offset = %d Data low = %x \n ",offset,lcd_data);
|
| 214 | // logerror("LCD Offset = %d Data low = %x \n ",offset,lcd_data);
|
| 63 | 215 | }
|
| 64 | 216 | static WRITE16_HANDLER ( write_lcd_flag )
|
| 65 | 217 | {
|
| r1236 | r1237 | |
| 68 | 220 | lcd_flag=data>>8;
|
| 69 | 221 | //beep_set_state(0,lcd_flag&1?1:0);
|
| 70 | 222 | if (lcd_flag == 0) key_selector=1;
|
| 71 | | // The key function in the rom expects after writing to |
| 72 | | // the a value from the second key row;
|
| 73 | 223 | if (lcd_flag!=0) led7=255;else led7=0;
|
| 74 | | logerror("LCD Flag 16 = %x \n ",data);
|
| 224 | // logerror("LCD Flag 16 = %x \n ",data);
|
| 75 | 225 | }
|
| 76 | 226 | |
| 77 | 227 | |
| r1236 | r1237 | |
| 82 | 232 | beep_set_state(0,lcd_flag&1?1:0);
|
| 83 | 233 | if (lcd_flag == 0) key_selector=1;
|
| 84 | 234 | if (lcd_flag!=0) led7=255;else led7=0;
|
| 85 | | logerror("LCD Flag 16 = %x \n ",data);
|
| 235 | |
| 236 | // logerror("LCD Flag gg = %x \n ",lcd_flag);
|
| 86 | 237 | }
|
| 87 | 238 | |
| 88 | 239 | static WRITE16_HANDLER ( write_keys )
|
| 89 | 240 | {
|
| 90 | 241 | key_select=data>>8;
|
| 91 | | logerror("Write Key = %x \n ",data);
|
| 242 | // logerror("Write Key = %x \n ",data);
|
| 92 | 243 | }
|
| 93 | 244 | |
| 94 | | static WRITE16_HANDLER ( write_beeper )
|
| 245 | static WRITE16_HANDLER ( write_board )
|
| 95 | 246 | {
|
| 96 | 247 | UINT8 beep_flag;
|
| 248 | |
| 249 | Line18_REED=data>>8;
|
| 250 | |
| 251 | // LED's or REED's ?
|
| 252 | //
|
| 253 | if (read_board_flag)
|
| 254 | {
|
| 255 | Line18_LED=0;
|
| 256 | read_board_flag=0;
|
| 257 | }
|
| 258 | else
|
| 259 | {
|
| 260 | Line18_LED=data>>8;
|
| 261 | }
|
| 262 | |
| 263 | //logerror("write_board Line18_LED = %x \n ", Line18_LED);
|
| 264 | //logerror("write_board Line18_REED = %x \n ",Line18_REED);
|
| 265 | |
| 97 | 266 | lcd_invert=1;
|
| 98 | 267 | beep_flag=data>>8;
|
| 99 | 268 | //if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
|
| 100 | | logerror("Write Beeper = %x \n ",data);
|
| 269 | //logerror("Write Beeper = %x \n ",data);
|
| 101 | 270 | beeper=data;
|
| 102 | 271 | }
|
| 103 | 272 | |
| r1236 | r1237 | |
| 116 | 285 | data=0x0300;
|
| 117 | 286 | key_low=readinputport(0x00);
|
| 118 | 287 | key_hi=readinputport(0x01);
|
| 119 | | logerror("Keyboard Offset = %x Data = %x\n ",offset,data);
|
| 288 | //logerror("Keyboard Offset = %x Data = %x\n ",offset,data);
|
| 120 | 289 | if (key_select==key_low){data=data&0x100;}
|
| 121 | 290 | if (key_select==key_hi){data=data&0x200;}
|
| 122 | 291 | return data;
|
| r1236 | r1237 | |
| 134 | 303 | |
| 135 | 304 | static READ16_HANDLER(read_board)
|
| 136 | 305 | {
|
| 137 | | UINT16 data;
|
| 138 | | //data=board_value^0xff;
|
| 139 | | data=0xff;
|
| 140 | | data=data<<8;
|
| 141 | | logerror("read board Offset = %x \n ",offset);
|
| 142 | | return data; // Mephisto need it for working
|
| 306 | UINT8 i_18, i_AH;
|
| 307 | UINT16 data;
|
| 308 | |
| 309 | data = 0xff;
|
| 310 | |
| 311 | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
|
| 312 | {
|
| 313 | |
| 314 | // Looking for cleared bit in Line18 -> current line
|
| 315 | //
|
| 316 | if ( !(Line18_REED & (1<<i_18)) )
|
| 317 | {
|
| 318 | |
| 319 | // if there is a piece on the field -> set bit in data
|
| 320 | //
|
| 321 | for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
|
| 322 | {
|
| 323 | if (strcmp ((char *)m_board[i_18][i_AH].piece, EMP))
|
| 324 | {
|
| 325 | data &= ~(1 << i_AH); // clear bit
|
| 326 | }
|
| 327 | }
|
| 328 | }
|
| 329 | }
|
| 330 | |
| 331 | data = data<<8;
|
| 332 | |
| 333 | read_board_flag = TRUE;
|
| 334 | |
| 335 | logerror("read_board_data = %x \n ", data);
|
| 336 | |
| 337 | |
| 338 | // return 0xff00; // Mephisto need it for working
|
| 339 | |
| 340 | |
| 341 | return data;
|
| 342 | |
| 143 | 343 | }
|
| 144 | 344 | |
| 145 | | static WRITE16_HANDLER(write_board)
|
| 345 | static WRITE16_HANDLER(write_beeper)
|
| 146 | 346 | {
|
| 147 | | UINT8 board;
|
| 148 | | board=data>>8;
|
| 149 | | board_value=board;
|
| 150 | | if (board==0xff) key_selector=0;
|
| 151 | | // The key function in the rom expects after writing to |
| 152 | | // the chess board a value from the first key row;
|
| 153 | | logerror("Write Board = %x \n ",data>>8);
|
| 347 | // logerror("Write Board = %x \n ",data>>8);
|
| 348 | |
| 349 | UINT8 i_AH, i_18;
|
| 350 | UINT16 LineAH = 0;
|
| 351 | |
| 352 | UINT8 LED;
|
| 353 | |
| 354 | |
| 355 | // logerror("Write Board = %x \n ",data);
|
| 356 | |
| 357 | LineAH = data>>8;
|
| 358 | |
| 359 | if (LineAH && Line18_LED)
|
| 360 | {
|
| 361 | |
| 362 | // logerror("Line18_LED = %x \n ",Line18_LED);
|
| 363 | // logerror("LineAH = %x \n ",LineAH);
|
| 364 | |
| 365 | for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
|
| 366 | {
|
| 367 | |
| 368 | if ( LineAH & (1<<i_AH) )
|
| 369 | {
|
| 370 | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
|
| 371 | {
|
| 372 | if ( !(Line18_LED & (1<<i_18)) )
|
| 373 | {
|
| 374 | |
| 375 | // logerror("i_18 = %d \n ",i_18);
|
| 376 | // logerror("i_AH = %d \n ",i_AH);
|
| 377 | // logerror("LED an: = %d \n ",m_board[i_18][i_AH]);
|
| 378 | |
| 379 | LED = m_board[i_18][i_AH].field;
|
| 380 | |
| 381 | output_set_led_value( LED, 1 );
|
| 382 | |
| 383 | // LED on
|
| 384 | }
|
| 385 | else
|
| 386 | {
|
| 387 | // LED off
|
| 388 | |
| 389 | } // End IF 18
|
| 390 | } // End For 18
|
| 391 | } // End IF AH
|
| 392 | |
| 393 | } // End For AH
|
| 394 | |
| 395 | } // End IF LineAH
|
| 396 | |
| 397 | else
|
| 398 | {
|
| 399 | // No LED -> all LED's off
|
| 400 | for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
|
| 401 | {
|
| 402 | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
|
| 403 | {
|
| 404 | // LED off
|
| 405 | LED = m_board[i_18][i_AH].field;
|
| 406 | output_set_led_value( LED, 0 );
|
| 407 | |
| 408 | } //End For 18
|
| 409 | } // End For AH
|
| 410 | |
| 411 | } //End ELSE LineAH
|
| 412 | |
| 154 | 413 | }
|
| 155 | 414 | |
| 156 | 415 | /*
|
| r1236 | r1237 | |
| 267 | 526 | static MACHINE_RESET( glasgow )
|
| 268 | 527 | {
|
| 269 | 528 | lcd_shift_counter=3;
|
| 529 | |
| 530 | clear_layout();
|
| 531 | set_render_board();
|
| 532 | set_status_of_pieces();
|
| 270 | 533 | }
|
| 271 | 534 | |
| 272 | 535 | |
| r1236 | r1237 | |
| 277 | 540 | |
| 278 | 541 | static VIDEO_UPDATE( glasgow )
|
| 279 | 542 | {
|
| 280 | | return 0;
|
| 543 | // INT32 lg_x, lg_y;
|
| 544 | // UINT8 p_key;
|
| 545 | |
| 546 | char *piece;
|
| 547 | |
| 548 | float save_x, save_y;
|
| 549 | |
| 550 | my_target = render_get_ui_target();
|
| 551 | |
| 552 | // Get view item of cursor
|
| 553 | //
|
| 554 | // my_cursor = my_target->curview->itemlist[3]->next;
|
| 555 | if (my_cursor == NULL)
|
| 556 | my_cursor = get_view_item(my_target,"CURSOR_1");
|
| 557 | |
| 558 | // my_cursor = my_target->curview->itemlist[2];
|
| 559 | |
| 560 | // Mouse movement
|
| 561 | //
|
| 562 | if (my_cursor != NULL)
|
| 563 | set_cursor (my_cursor);
|
| 564 | |
| 565 | m_button1=readinputport(0x04);
|
| 566 | m_button2=readinputport(0x05);
|
| 567 | |
| 568 | if ( m_button1) MOUSE_BUTTON1_WAIT = 0;
|
| 569 | |
| 570 | if ( m_button1 != 1 && !MOUSE_BUTTON1_WAIT )
|
| 571 | {
|
| 572 | |
| 573 | MOUSE_BUTTON1_WAIT = 1;
|
| 574 | |
| 575 | if (MOUSE_MOVE == 0)
|
| 576 | {
|
| 577 | |
| 578 | cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
|
| 579 | if ( strcmp((char *)cursor_field.piece, "0") && (strcmp((char *)cursor_field.piece, EMP)) && strcmp(my_cursor->name, (char *)cursor_field.piece ) )
|
| 580 | {
|
| 581 | update_board(my_target,cursor_field, 0);
|
| 582 | |
| 583 | my_cursor->color.a = 0;
|
| 584 | |
| 585 | my_cursor = get_view_item(my_target, (char *)cursor_field.piece);
|
| 586 | my_cursor->color.a = 0.5;
|
| 587 | |
| 588 | MOUSE_MOVE = 1;
|
| 589 | |
| 590 | }
|
| 591 | } // ENDIF MOUSE_MOVE
|
| 592 | else
|
| 593 | {
|
| 594 | |
| 595 | save_x = my_cursor->rawbounds.x0;
|
| 596 | save_y = my_cursor->rawbounds.y0;
|
| 597 | |
| 598 | cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
|
| 599 | if ( strcmp((char *)cursor_field.piece, "0") && strcmp(my_cursor->name, "CURSOR_1") )
|
| 600 | {
|
| 601 | |
| 602 | // Put piece back to board
|
| 603 | //
|
| 604 | strcpy((char *)cursor_field.piece, (char *)my_cursor->name);
|
| 605 | update_board(my_target,cursor_field, 1);
|
| 606 | my_cursor->color.a = 1;
|
| 607 | |
| 608 | // Set piece to field
|
| 609 | //
|
| 610 | calculate_bounds(my_cursor, (float) cursor_field.x, (float) cursor_field.y, 0 ,0 );
|
| 611 | |
| 612 | |
| 613 | // Get old cursor and set new x,y
|
| 614 | //
|
| 615 | my_cursor = get_view_item(my_target,"CURSOR_1");
|
| 616 | my_cursor->color.a = 1;
|
| 617 | |
| 618 | calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_Y );
|
| 619 | |
| 620 | MOUSE_MOVE = 0;
|
| 621 | |
| 622 | }//ENDIF curosr_field
|
| 623 | |
| 624 | // piece is set out of board -> remove it
|
| 625 | //
|
| 626 | if ( out_of_board(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0) )
|
| 627 | {
|
| 628 | |
| 629 | save_x = my_cursor->rawbounds.x0;
|
| 630 | save_y = my_cursor->rawbounds.y0;
|
| 631 | |
| 632 | my_cursor->color.a = 0;
|
| 633 | my_cursor = get_view_item(my_target,"CURSOR_1");
|
| 634 | my_cursor->color.a = 1;
|
| 635 | calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_X );
|
| 636 | |
| 637 | MOUSE_MOVE = 0;
|
| 638 | }
|
| 639 | |
| 640 | }//ELSE MOUSE_MOVE
|
| 641 | |
| 642 | } // ENDIF m_button1
|
| 643 | |
| 644 | |
| 645 | // right mouse button -> set pieces
|
| 646 | //
|
| 647 | if ( m_button2) MOUSE_BUTTON2_WAIT = 0;
|
| 648 | if ( m_button2 != 1 && !MOUSE_BUTTON2_WAIT )
|
| 649 | {
|
| 650 | |
| 651 | MOUSE_BUTTON2_WAIT = 1;
|
| 652 | |
| 653 | // save cursor position
|
| 654 | //
|
| 655 | save_x = my_cursor->rawbounds.x0;
|
| 656 | save_y = my_cursor->rawbounds.y0;
|
| 657 | |
| 658 | // cursor off
|
| 659 | //
|
| 660 | my_cursor->color.a = 0;
|
| 661 | |
| 662 | // change cursor to piece
|
| 663 | //
|
| 664 | piece = get_non_set_pieces(my_cursor->name);
|
| 665 | |
| 666 | if (strcmp(piece,NO_PIECE))
|
| 667 | {
|
| 668 | my_cursor = get_view_item(my_target,piece);
|
| 669 | my_cursor->color.a = 0.5;
|
| 670 | |
| 671 | calculate_bounds(my_cursor, save_x, save_y, 0 ,0 );
|
| 672 | |
| 673 | MOUSE_MOVE = 1;
|
| 674 | }
|
| 675 | else
|
| 676 | {
|
| 677 | my_cursor = get_view_item(my_target,"CURSOR_1");
|
| 678 | my_cursor->color.a = 1;
|
| 679 | calculate_bounds(my_cursor, save_x, save_y, MOUSE_X ,MOUSE_X );
|
| 680 | MOUSE_MOVE = 0;
|
| 681 | }
|
| 682 | |
| 683 | }
|
| 684 | |
| 685 | // Put Item back to render
|
| 686 | //
|
| 687 | render_set_ui_target (my_target);
|
| 688 | |
| 689 | return 0;
|
| 281 | 690 | }
|
| 282 | 691 | |
| 283 | 692 | |
| r1236 | r1237 | |
| 292 | 701 | ADDRESS_MAP_END
|
| 293 | 702 | |
| 294 | 703 | |
| 295 | | |
| 296 | | |
| 297 | | |
| 298 | | |
| 299 | | |
| 300 | | |
| 301 | 704 | static ADDRESS_MAP_START(amsterd_mem, ADDRESS_SPACE_PROGRAM, 16)
|
| 302 | 705 | // ADDRESS_MAP_FLAGS( AMEF_ABITS(19) )
|
| 303 | 706 | AM_RANGE( 0x0000, 0xffff ) AM_ROM
|
| r1236 | r1237 | |
| 383 | 786 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7") PORT_CODE(KEYCODE_G )
|
| 384 | 787 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7") PORT_CODE(KEYCODE_7 )
|
| 385 | 788 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4)
|
| 789 | |
| 790 | PORT_START
|
| 791 | PORT_BIT( 0xffff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535) PORT_PLAYER(1)
|
| 792 | |
| 793 | PORT_START
|
| 794 | PORT_BIT( 0xffff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535) PORT_PLAYER(1)
|
| 795 | |
| 796 | PORT_START
|
| 797 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("left button")
|
| 798 | |
| 799 | PORT_START
|
| 800 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("right button")
|
| 801 | |
| 802 | |
| 386 | 803 | INPUT_PORTS_END
|
| 387 | 804 | |
| 388 | 805 | |
| r1236 | r1237 | |
| 396 | 813 | /* video hardware */
|
| 397 | 814 | MDRV_SCREEN_REFRESH_RATE(60)
|
| 398 | 815 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
|
| 816 | |
| 817 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
|
| 818 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
|
| 819 | MDRV_SCREEN_SIZE(640, 480)
|
| 820 | MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
|
| 821 | MDRV_PALETTE_LENGTH(4)
|
| 822 | |
| 399 | 823 | MDRV_DEFAULT_LAYOUT(layout_glasgow)
|
| 400 | 824 | MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 401 | 825 | MDRV_SOUND_ADD(BEEP, 0)
|
| r1236 | r1237 | |
| 405 | 829 | MACHINE_DRIVER_END
|
| 406 | 830 | |
| 407 | 831 | |
| 408 | | |
| 409 | 832 | static MACHINE_DRIVER_START(amsterd )
|
| 410 | 833 | MDRV_IMPORT_FROM( glasgow )
|
| 411 | 834 | /* basic machine hardware */
|
| r1236 | r1237 | |
| 423 | 846 | MACHINE_DRIVER_END
|
| 424 | 847 | |
| 425 | 848 | |
| 426 | | |
| 427 | 849 | /***************************************************************************
|
| 428 | 850 | ROM definitions
|
| 429 | 851 | ***************************************************************************/
|
| r1236 | r1237 | |
| 479 | 901 | ***************************************************************************/
|
| 480 | 902 | |
| 481 | 903 | |
| 904 | |
| 482 | 905 | /***************************************************************************
|
| 483 | 906 | Game drivers
|
| 484 | 907 | ***************************************************************************/
|
| r1236 | r1237 | |
| 492 | 915 | CONS( 1984, roma32, 0, 0, dallas32, new_keyboard, NULL, NULL, "Hegener & Glaser Muenchen", "Mephisto Roma 32 Bit", 0)
|
| 493 | 916 | CONS( 1984, dallas16, 0, 0, amsterd, new_keyboard, NULL, NULL, "Hegener & Glaser Muenchen", "Mephisto Dallas 16 Bit", 0)
|
| 494 | 917 | |
| 918 | |
| 919 | |
| 920 | static void set_cursor (view_item *view_cursor)
|
| 921 | {
|
| 922 | |
| 923 | static INT16 save_x, save_y;
|
| 924 | static float diff_x, diff_y, del_x, del_y;
|
| 925 | |
| 926 | save_x = m_x;
|
| 927 | save_y = m_y;
|
| 928 | |
| 929 | m_x=readinputport(0x02);
|
| 930 | m_y=readinputport(0x03);
|
| 931 | |
| 932 | // logerror("m_x = %d \n ",m_x);
|
| 933 | // logerror("m_y = %d \n ",m_y);
|
| 934 | |
| 935 | diff_x = (float) (save_x - m_x) / MOUSE_SPEED;
|
| 936 | diff_y = (float) (save_y - m_y) / MOUSE_SPEED;
|
| 937 | |
| 938 | del_x = view_cursor->rawbounds.x1 - view_cursor->rawbounds.x0;
|
| 939 | del_y = view_cursor->rawbounds.y1 - view_cursor->rawbounds.y0;
|
| 940 | |
| 941 | // Set Cursor, depending on limits
|
| 942 | //
|
| 943 | view_cursor->rawbounds.x0 = view_cursor->rawbounds.x0 - diff_x;
|
| 944 | |
| 945 | if ( view_cursor->rawbounds.x0 > MAX_CURSOR_X )
|
| 946 | view_cursor->rawbounds.x0 = MAX_CURSOR_X;
|
| 947 | |
| 948 | if ( view_cursor->rawbounds.x0 < MIN_CURSOR_X )
|
| 949 | view_cursor->rawbounds.x0 = MIN_CURSOR_X;
|
| 950 | |
| 951 | view_cursor->rawbounds.y0 = view_cursor->rawbounds.y0 - diff_y;
|
| 952 | |
| 953 | if ( view_cursor->rawbounds.y0 > MAX_CURSOR_Y )
|
| 954 | view_cursor->rawbounds.y0 = MAX_CURSOR_Y;
|
| 955 | |
| 956 | if ( view_cursor->rawbounds.y0 < MIN_CURSOR_Y )
|
| 957 | view_cursor->rawbounds.y0 = MIN_CURSOR_Y;
|
| 958 | |
| 959 | view_cursor->rawbounds.x1 = view_cursor->rawbounds.x0 + del_x;
|
| 960 | view_cursor->rawbounds.y1 = view_cursor->rawbounds.y0 + del_y;
|
| 961 | |
| 962 | // Calculate bounds
|
| 963 | //
|
| 964 | view_cursor->bounds.x0 = view_cursor->rawbounds.x0 / MAX_X;
|
| 965 | view_cursor->bounds.y0 = view_cursor->rawbounds.y0 / MAX_Y;
|
| 966 | view_cursor->bounds.x1 = view_cursor->rawbounds.x1 / MAX_X;
|
| 967 | view_cursor->bounds.y1 = view_cursor->rawbounds.y1 / MAX_Y;
|
| 968 | |
| 969 | }
|
| 970 | |
| 971 | //render_target *render_target_get_indexed
|
| 972 | |
| 973 | |
| 974 | view_item *get_view_item(render_target *target, const char *v_name)
|
| 975 | {
|
| 976 | |
| 977 | view_item *cur_view;
|
| 978 | cur_view = target->curview->itemlist[3]->next;
|
| 979 | |
| 980 | for (; cur_view != NULL; cur_view = cur_view->next)
|
| 981 | {
|
| 982 | if (!strcmp(cur_view->name, v_name))
|
| 983 | {
|
| 984 | return (cur_view);
|
| 985 | }
|
| 986 | }
|
| 987 | |
| 988 | return (NULL);
|
| 989 | }
|
| 990 | |
| 991 | |
| 992 | BOARD_FIELD get_field( float i_x, float i_y, UINT8 mouse_move)
|
| 993 | {
|
| 994 | UINT8 i_AH, i_18;
|
| 995 | float corr_x, corr_y;
|
| 996 | |
| 997 | |
| 998 | float f_x, f_y;
|
| 999 | |
| 1000 | BOARD_FIELD null_board = { 0,0,0,"0"};
|
| 1001 | |
| 1002 | |
| 1003 | // Correction of mouse pointer
|
| 1004 | //
|
| 1005 | if (!mouse_move)
|
| 1006 | {
|
| 1007 | corr_x = i_x+29.0;
|
| 1008 | corr_y = i_y+22.0;
|
| 1009 | }else
|
| 1010 | {
|
| 1011 | corr_x = i_x+28;
|
| 1012 | corr_y = i_y+28;
|
| 1013 | }
|
| 1014 | |
| 1015 | // Loop über alle Spalten
|
| 1016 | for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
|
| 1017 | {
|
| 1018 | |
| 1019 | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
|
| 1020 | {
|
| 1021 | f_x = (float) m_board [i_18] [i_AH].x;
|
| 1022 | f_y = (float) m_board [i_18] [i_AH].y;
|
| 1023 | |
| 1024 | if ( ( corr_x >= f_x && corr_x <= f_x+56 ) && ( corr_y >= f_y && corr_y <= f_y+56 ) )
|
| 1025 | {
|
| 1026 | return (m_board [i_18] [i_AH]);
|
| 1027 | }
|
| 1028 | |
| 1029 | }
|
| 1030 | }
|
| 1031 | |
| 1032 | return (null_board);
|
| 1033 | }
|
| 1034 | |
| 1035 | |
| 1036 | static unsigned int out_of_board( float x0, float y0)
|
| 1037 | {
|
| 1038 | |
| 1039 | if ( ( x0 >= MIN_BOARD_X && x0 <= MAX_BOARD_X ) && ( y0 >= MIN_BOARD_Y && y0 <= MAX_BOARD_Y ) )
|
| 1040 | {
|
| 1041 | return (0);
|
| 1042 | }
|
| 1043 | else
|
| 1044 | {
|
| 1045 | return (1);
|
| 1046 | }
|
| 1047 | }
|
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | static void update_board(render_target *target, BOARD_FIELD board_field, unsigned int update_clear_flag)
|
| 1052 | {
|
| 1053 | |
| 1054 | UINT8 i_18, i_AH;
|
| 1055 | |
| 1056 | view_item *view_item;
|
| 1057 | |
| 1058 | div_t div_result;
|
| 1059 | |
| 1060 | div_result = div(board_field.field, 8);
|
| 1061 | |
| 1062 | i_18 = div_result.quot;
|
| 1063 | i_AH = 7 - div_result.rem;
|
| 1064 | |
| 1065 | if (update_clear_flag)
|
| 1066 | {
|
| 1067 | // there is already a piece on target field - > set it invisible
|
| 1068 | //
|
| 1069 | view_item = get_view_item(target, (char *)m_board[i_18][i_AH].piece);
|
| 1070 | if (view_item != NULL)
|
| 1071 | {
|
| 1072 | view_item->color.a = 0;
|
| 1073 | }
|
| 1074 | strcpy ((char *)&m_board[i_18][i_AH].piece[0], (char *)&board_field.piece[0]);
|
| 1075 | }else
|
| 1076 | {
|
| 1077 | strcpy ((char *)m_board[i_18][i_AH].piece, EMP);
|
| 1078 | }
|
| 1079 | |
| 1080 | set_status_of_pieces();
|
| 1081 | |
| 1082 | }
|
| 1083 | |
| 1084 | static void calculate_bounds(view_item *view_item, float new_x0, float new_y0, float new_del_x, float new_del_y )
|
| 1085 | {
|
| 1086 | |
| 1087 | static float del_x, del_y;
|
| 1088 | |
| 1089 | if (new_del_x)
|
| 1090 | {
|
| 1091 | del_x = new_del_x;
|
| 1092 | }
|
| 1093 | else
|
| 1094 | {
|
| 1095 | del_x = view_item->rawbounds.x1 - view_item->rawbounds.x0;
|
| 1096 | }
|
| 1097 | |
| 1098 | if (new_del_y)
|
| 1099 | {
|
| 1100 | del_y = new_del_y;
|
| 1101 | }
|
| 1102 | else
|
| 1103 | {
|
| 1104 | del_y = view_item->rawbounds.y1 - view_item->rawbounds.y0;
|
| 1105 | }
|
| 1106 | |
| 1107 | view_item->rawbounds.x0 = new_x0;
|
| 1108 | view_item->rawbounds.y0 = new_y0;
|
| 1109 | view_item->rawbounds.x1 = view_item->rawbounds.x0 + del_x;
|
| 1110 | view_item->rawbounds.y1 = view_item->rawbounds.y0 + del_y;
|
| 1111 | |
| 1112 | // Calculate bounds
|
| 1113 | //
|
| 1114 | view_item->bounds.x0 = view_item->rawbounds.x0 / MAX_X;
|
| 1115 | view_item->bounds.y0 = view_item->rawbounds.y0 / MAX_Y;
|
| 1116 | view_item->bounds.x1 = view_item->rawbounds.x1 / MAX_X;
|
| 1117 | view_item->bounds.y1 = view_item->rawbounds.y1 / MAX_Y;
|
| 1118 | |
| 1119 | }
|
| 1120 | |
| 1121 | |
| 1122 | static void set_render_board()
|
| 1123 | {
|
| 1124 | |
| 1125 | view_item *view_item;
|
| 1126 | UINT8 i_AH, i_18;
|
| 1127 | |
| 1128 | my_target = render_get_ui_target();
|
| 1129 | |
| 1130 | |
| 1131 | for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
|
| 1132 | {
|
| 1133 | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
|
| 1134 | {
|
| 1135 | |
| 1136 | // copy start postition to m_board
|
| 1137 | //
|
| 1138 | m_board[i_18][i_AH] = start_board [i_18] [i_AH];
|
| 1139 | |
| 1140 | // Get view item of this piece
|
| 1141 | //
|
| 1142 | if (strcmp((char *)m_board[i_18][i_AH].piece, EMP))
|
| 1143 | {
|
| 1144 | view_item = get_view_item(my_target, (char *)m_board[i_18][i_AH].piece);
|
| 1145 | |
| 1146 | // change all pieces
|
| 1147 | //
|
| 1148 | if (view_item != NULL)
|
| 1149 | {
|
| 1150 | calculate_bounds(view_item, m_board[i_18][i_AH].x, m_board[i_18][i_AH].y, 0, 0 );
|
| 1151 | view_item->color.a = 1.0;
|
| 1152 | }//ENDIF view_item
|
| 1153 | |
| 1154 | } // ENDIF strcmp
|
| 1155 | }// FOR i_18
|
| 1156 | }// FOR i_AH
|
| 1157 | |
| 1158 | render_set_ui_target (my_target);
|
| 1159 | |
| 1160 | }
|
| 1161 | |
| 1162 | static void clear_layout()
|
| 1163 | {
|
| 1164 | |
| 1165 | view_item *view_item;
|
| 1166 | UINT8 i;
|
| 1167 | |
| 1168 | my_target = render_get_ui_target();
|
| 1169 | |
| 1170 | for ( i = 0; i < 44; i = i + 1)
|
| 1171 | {
|
| 1172 | view_item = get_view_item(my_target,(char *)all_pieces[i].piece);
|
| 1173 | if (view_item != NULL)
|
| 1174 | {
|
| 1175 | view_item->color.a = 0.0;
|
| 1176 | }
|
| 1177 | }
|
| 1178 | |
| 1179 | render_set_ui_target (my_target);
|
| 1180 | |
| 1181 | }
|
| 1182 | |
| 1183 | |
| 1184 | |
| 1185 | static void set_status_of_pieces()
|
| 1186 | {
|
| 1187 | |
| 1188 | UINT8 i_AH, i_18 , i;
|
| 1189 | BOARD_FIELD field;
|
| 1190 | |
| 1191 | |
| 1192 | for ( i = 0; i < 47; i = i + 1)
|
| 1193 | {
|
| 1194 | |
| 1195 | all_pieces[i].set = 0;
|
| 1196 | |
| 1197 | for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
|
| 1198 | {
|
| 1199 | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
|
| 1200 | {
|
| 1201 | |
| 1202 | // set status depending piece is in game or not
|
| 1203 | //
|
| 1204 | field = m_board[i_18][i_AH];
|
| 1205 | |
| 1206 | if (!strcmp((char *)m_board[i_18][i_AH].piece, (char *) all_pieces[i].piece))
|
| 1207 | {
|
| 1208 | all_pieces[i].set = 1;
|
| 1209 | break;
|
| 1210 | }
|
| 1211 | |
| 1212 | } // END for i_18=0
|
| 1213 | |
| 1214 | if (all_pieces[i].set) break;
|
| 1215 | |
| 1216 | }// END for i_AH=0
|
| 1217 | } // END for i=0
|
| 1218 | |
| 1219 | }
|
| 1220 | |
| 1221 | |
| 1222 | static char *get_non_set_pieces(const char *cur_piece)
|
| 1223 | {
|
| 1224 | UINT8 i=0;
|
| 1225 | |
| 1226 | do
|
| 1227 | {
|
| 1228 | |
| 1229 | start_i = start_i+1;
|
| 1230 | if ( start_i == 44) start_i = 0;
|
| 1231 | |
| 1232 | |
| 1233 | if (!all_pieces[start_i].set && ( all_pieces[start_i].piece[0] != cur_piece[0] ||
|
| 1234 | all_pieces[start_i].piece[1] != cur_piece[1]) )
|
| 1235 | {
|
| 1236 | return ((char *)&all_pieces[start_i].piece[0]);
|
| 1237 | }
|
| 1238 | |
| 1239 | i=i+1;
|
| 1240 | }
|
| 1241 | while (i != 44);
|
| 1242 | |
| 1243 | return (NO_PIECE);
|
| 1244 | }
|
| 1245 | |
| 1246 | |