src/mess/drivers/glasgow.c
| r4651 | r4652 | |
| 56 | 56 | |
| 57 | 57 | static BOARD_FIELD m_board[8][8]; |
| 58 | 58 | |
| 59 | | static int irq_edge=0x00; |
| 59 | static 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"} }, |
| 60 | 63 | |
| 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"} }, |
| 61 | 68 | |
| 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 | |
| 73 | static 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 | |
| 88 | static int irq_edge = 0x00; |
| 89 | |
| 90 | |
| 62 | 91 | // Used by Glasgow and Dallas |
| 63 | 92 | static WRITE16_HANDLER( write_lcd_gg ) |
| 64 | 93 | { |
| 65 | | UINT8 lcd_data; |
| 66 | | lcd_data = data>>8; |
| 94 | UINT8 lcd_data = data >> 8; |
| 95 | |
| 67 | 96 | if (led7 == 0) |
| 68 | 97 | output_set_digit_value(lcd_shift_counter, lcd_data); |
| 98 | |
| 69 | 99 | lcd_shift_counter--; |
| 70 | 100 | lcd_shift_counter &= 3; |
| 71 | 101 | // logerror("LCD Offset = %d Data low = %x \n", offset, lcd_data); |
| r4651 | r4652 | |
| 74 | 104 | static WRITE16_HANDLER( write_beeper ) |
| 75 | 105 | { |
| 76 | 106 | UINT8 beep_flag; |
| 107 | |
| 77 | 108 | lcd_invert = 1; |
| 78 | 109 | 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; |
| 80 | 111 | logerror("Write Beeper = %x \n", data); |
| 81 | 112 | beeper = data; |
| 82 | 113 | } |
| 83 | 114 | |
| 84 | 115 | static WRITE16_HANDLER( write_lcd ) |
| 85 | 116 | { |
| 86 | | UINT8 lcd_data; |
| 87 | | lcd_data = data >> 8; |
| 117 | UINT8 lcd_data = data >> 8; |
| 118 | |
| 88 | 119 | output_set_digit_value(lcd_shift_counter, lcd_invert & 1 ? lcd_data^0xff : lcd_data); |
| 89 | 120 | lcd_shift_counter--; |
| 90 | 121 | lcd_shift_counter &= 3; |
| r4651 | r4652 | |
| 96 | 127 | UINT8 lcd_flag; |
| 97 | 128 | lcd_invert = 0; |
| 98 | 129 | lcd_flag=data >> 8; |
| 99 | | //beep_set_state(0,lcd_flag&1?1:0); |
| 130 | //beep_set_state(0, lcd_flag & 1 ? 1 : 0); |
| 100 | 131 | if (lcd_flag == 0) |
| 101 | 132 | key_selector = 1; |
| 102 | 133 | |
| r4651 | r4652 | |
| 113 | 144 | static WRITE16_HANDLER( write_lcd_flag_gg ) |
| 114 | 145 | { |
| 115 | 146 | 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 | |
| 118 | 149 | beep_set_state(speaker, lcd_flag & 1 ? 1 : 0); |
| 150 | |
| 119 | 151 | if (lcd_flag == 0) |
| 120 | 152 | key_selector = 1; |
| 121 | 153 | |
| r4651 | r4652 | |
| 140 | 172 | |
| 141 | 173 | static WRITE16_HANDLER( write_board ) |
| 142 | 174 | { |
| 143 | | UINT8 board; |
| 144 | | board = data >> 8; |
| 175 | UINT8 board = data >> 8; |
| 176 | |
| 145 | 177 | board_value = board; |
| 178 | |
| 146 | 179 | if (board == 0xff) |
| 147 | 180 | key_selector = 0; |
| 148 | 181 | // The key function in the rom expects after writing to |
| r4651 | r4652 | |
| 157 | 190 | Line18_REED = data >> 8; |
| 158 | 191 | |
| 159 | 192 | // LED's or REED's ? |
| 160 | | |
| 161 | 193 | if (read_board_flag) |
| 162 | 194 | { |
| 163 | 195 | Line18_LED = 0; |
| r4651 | r4652 | |
| 173 | 205 | |
| 174 | 206 | lcd_invert = 1; |
| 175 | 207 | 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; |
| 177 | 209 | //logerror("Write Beeper = %x \n ",data); |
| 178 | 210 | beeper = data; |
| 179 | 211 | } |
| r4651 | r4652 | |
| 181 | 213 | static WRITE16_HANDLER( write_irq_flag ) |
| 182 | 214 | { |
| 183 | 215 | const device_config *speaker = devtag_get_device(space->machine, "beep"); |
| 216 | |
| 184 | 217 | beep_set_state(speaker, data & 0x100); |
| 185 | 218 | logerror("Write 0x800004 = %x \n", data); |
| 186 | 219 | irq_flag = 1; |
| r4651 | r4652 | |
| 189 | 222 | |
| 190 | 223 | static READ16_HANDLER( read_keys ) // Glasgow, Dallas |
| 191 | 224 | { |
| 192 | | UINT16 data; |
| 193 | | data = 0x0300; |
| 225 | UINT16 data = 0x0300; |
| 226 | |
| 194 | 227 | key_low = input_port_read(space->machine, "LINE0"); |
| 195 | 228 | key_hi = input_port_read(space->machine, "LINE1"); |
| 196 | | //logerror("Keyboard Offset = %x Data = %x\n ",offset,data); |
| 229 | |
| 197 | 230 | if (key_select == key_low) |
| 198 | 231 | data = data & 0x100; |
| 232 | |
| 199 | 233 | if (key_select == key_hi) |
| 200 | 234 | data = data & 0x200; |
| 201 | 235 | |
| 236 | //logerror("Keyboard Offset = %x Data = %x\n ", offset, data); |
| 202 | 237 | return data; |
| 203 | 238 | } |
| 204 | 239 | |
| r4651 | r4652 | |
| 219 | 254 | static READ16_HANDLER( read_board_gg ) |
| 220 | 255 | { |
| 221 | 256 | UINT8 i_18, i_AH; |
| 222 | | UINT16 data; |
| 257 | UINT16 data = 0xff; |
| 223 | 258 | |
| 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++) |
| 227 | 260 | { |
| 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))) |
| 232 | 263 | { |
| 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++) |
| 237 | 266 | { |
| 238 | 267 | if (strcmp ((char *)m_board[i_18][i_AH].piece, EMP)) |
| 239 | 268 | data &= ~(1 << i_AH); // clear bit |
| r4651 | r4652 | |
| 266 | 295 | // logerror("Line18_LED = %x \n ",Line18_LED); |
| 267 | 296 | // logerror("LineAH = %x \n ",LineAH); |
| 268 | 297 | |
| 269 | | for (i_AH = 0; i_AH < 8; i_AH = i_AH + 1) |
| 298 | for (i_AH = 0; i_AH < 8; i_AH++) |
| 270 | 299 | { |
| 271 | | if ( LineAH & (1<<i_AH) ) |
| 300 | if (LineAH & (1 << i_AH)) |
| 272 | 301 | { |
| 273 | | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1) |
| 302 | for (i_18 = 0; i_18 < 8; i_18++) |
| 274 | 303 | { |
| 275 | | if ( !(Line18_LED & (1<<i_18)) ) |
| 304 | if (!(Line18_LED & (1 << i_18))) |
| 276 | 305 | { |
| 277 | 306 | // logerror("i_18 = %d \n ",i_18); |
| 278 | 307 | // logerror("i_AH = %d \n ",i_AH); |
| 279 | 308 | // logerror("LED an: = %d \n ",m_board[i_18][i_AH]); |
| 280 | 309 | |
| 281 | 310 | 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 |
| 285 | 313 | } |
| 286 | 314 | else |
| 287 | 315 | { |
| 288 | | // LED off |
| 316 | // LED off |
| 289 | 317 | |
| 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 | } |
| 295 | 323 | else |
| 296 | 324 | { |
| 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++) |
| 299 | 327 | { |
| 300 | | for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1) |
| 328 | for (i_18 = 0; i_18 < 8; i_18++) |
| 301 | 329 | { |
| 302 | | // LED off |
| 330 | // LED off |
| 303 | 331 | 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 | } |
| 308 | 336 | } |
| 309 | 337 | |
| 310 | 338 | /* |
| r4651 | r4652 | |
| 324 | 352 | |
| 325 | 353 | static WRITE32_HANDLER( write_lcd32 ) |
| 326 | 354 | { |
| 327 | | UINT8 lcd_data; |
| 328 | | lcd_data = data >> 8; |
| 355 | UINT8 lcd_data = data >> 8; |
| 356 | |
| 329 | 357 | output_set_digit_value(lcd_shift_counter, lcd_invert & 1 ? lcd_data^0xff : lcd_data); |
| 330 | 358 | lcd_shift_counter--; |
| 331 | 359 | 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); |
| 333 | 361 | } |
| 334 | 362 | |
| 335 | 363 | static WRITE32_HANDLER( write_lcd_flag32 ) |
| 336 | 364 | { |
| 337 | | UINT8 lcd_flag; |
| 365 | UINT8 lcd_flag = data >> 24; |
| 366 | |
| 338 | 367 | lcd_invert = 0; |
| 339 | | lcd_flag = data >> 24; |
| 368 | |
| 340 | 369 | if (lcd_flag == 0) |
| 341 | 370 | key_selector = 1; |
| 371 | |
| 342 | 372 | 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); |
| 344 | 374 | |
| 345 | 375 | if (lcd_flag != 0) |
| 346 | 376 | led7 = 255; |
| r4651 | r4652 | |
| 359 | 389 | static READ32_HANDLER( read_newkeys32 ) // Dallas 32, Roma 32 |
| 360 | 390 | { |
| 361 | 391 | UINT32 data; |
| 392 | |
| 362 | 393 | if (key_selector == 0) |
| 363 | 394 | data = input_port_read(space->machine, "LINE0"); |
| 364 | 395 | else |
| 365 | 396 | 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; |
| 367 | 398 | logerror("read Keyboard Offset = %x Data = %x\n", offset, data); |
| 368 | 399 | data = data << 24; |
| 369 | 400 | return data ; |
| r4651 | r4652 | |
| 378 | 409 | /* |
| 379 | 410 | static READ16_HANDLER(read_board_amsterd) |
| 380 | 411 | { |
| 381 | | logerror("read board amsterdam Offset = %x \n ",offset); |
| 412 | logerror("read board amsterdam Offset = %x \n ", offset); |
| 382 | 413 | return 0xffff; |
| 383 | 414 | } |
| 384 | 415 | */ |
| r4651 | r4652 | |
| 404 | 435 | |
| 405 | 436 | static TIMER_CALLBACK( update_nmi ) |
| 406 | 437 | { |
| 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; |
| 411 | 442 | } |
| 412 | 443 | |
| 413 | 444 | static TIMER_CALLBACK( update_nmi32 ) |
| 414 | 445 | { |
| 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; |
| 419 | 450 | } |
| 420 | 451 | |
| 421 | 452 | static MACHINE_START( glasgow ) |
| 422 | 453 | { |
| 423 | 454 | const device_config *speaker = devtag_get_device(machine, "beep"); |
| 455 | |
| 424 | 456 | key_selector = 0; |
| 425 | 457 | irq_flag = 0; |
| 426 | 458 | lcd_shift_counter = 3; |
| r4651 | r4652 | |
| 432 | 464 | static MACHINE_START( dallas32 ) |
| 433 | 465 | { |
| 434 | 466 | const device_config *speaker = devtag_get_device(machine, "beep"); |
| 467 | |
| 435 | 468 | lcd_shift_counter = 3; |
| 436 | 469 | timer_pulse(machine, ATTOTIME_IN_HZ(50), NULL, 0, update_nmi32); |
| 437 | 470 | beep_set_frequency(speaker, 44); |
| r4651 | r4652 | |
| 441 | 474 | static MACHINE_RESET( glasgow ) |
| 442 | 475 | { |
| 443 | 476 | lcd_shift_counter = 3; |
| 477 | set_board(); |
| 444 | 478 | } |
| 445 | 479 | |
| 446 | 480 | |