src/mess/machine/tms9901.c
| r3831 | r3832 | |
| 9 | 9 | |
| 10 | 10 | #include "tms9901.h" |
| 11 | 11 | |
| 12 | | #define MAX_9901 2 |
| 13 | | |
| 14 | 12 | /* |
| 15 | 13 | TMS9901 emulation. |
| 16 | 14 | |
| r3831 | r3832 | |
| 86 | 84 | tms9901 state structure |
| 87 | 85 | */ |
| 88 | 86 | |
| 89 | | typedef struct tms9901_t |
| 87 | |
| 88 | /*************************************************************************** |
| 89 | TYPE DEFINITIONS |
| 90 | ***************************************************************************/ |
| 91 | |
| 92 | typedef struct _tms9901_t tms9901_t; |
| 93 | struct _tms9901_t |
| 90 | 94 | { |
| 91 | 95 | /* interrupt registers */ |
| 92 | 96 | int supported_int_mask; /* mask: bit #n is set if pin #n is supported as an interrupt pin, |
| r3831 | r3832 | |
| 118 | 122 | state, write interrupt enable mask) |
| 119 | 123 | 1 = clock mode (read/write clock interval) */ |
| 120 | 124 | |
| 121 | | /* driver-dependent read and write handlers */ |
| 122 | | int (*read_handlers[4])(int offset); |
| 123 | | void (*write_handlers[16])(int offset, int data); |
| 124 | | |
| 125 | | /* interrupt callback to notify driver of changes in intreq and ic0-3 pins */ |
| 126 | | void (*interrupt_callback)(int intreq, int ic); |
| 127 | | |
| 128 | 125 | /* tms9901 clock rate (PHI* pin, normally connected to TMS9900 Phi3*) */ |
| 129 | 126 | /* decrementer rate equates PHI* rate/64 (e.g. 46875Hz for a 3MHz clock) |
| 130 | 127 | (warning: 3MHz on a tms9900 is equivalent to 12MHz on a tms9995 or tms99000) */ |
| 131 | 128 | double clock_rate; |
| 132 | | } tms9901_t; |
| 133 | 129 | |
| 134 | | static tms9901_t tms9901[MAX_9901]; |
| 130 | /* Pointer to interface */ |
| 131 | const tms9901_interface *intf; |
| 132 | }; |
| 135 | 133 | |
| 136 | 134 | |
| 137 | | /* |
| 138 | | prototypes |
| 139 | | */ |
| 135 | /*************************************************************************** |
| 136 | INLINE FUNCTIONS |
| 137 | ***************************************************************************/ |
| 140 | 138 | |
| 141 | | static void tms9901_field_interrupts(int which); |
| 142 | | static TIMER_CALLBACK(decrementer_callback); |
| 143 | | static void tms9901_timer_reload(int which); |
| 139 | INLINE tms9901_t *get_token(const device_config *device) |
| 140 | { |
| 141 | assert(device != NULL); |
| 142 | assert(device->type == TMS9901); |
| 143 | return (tms9901_t *) device->token; |
| 144 | } |
| 144 | 145 | |
| 145 | 146 | |
| 146 | | |
| 147 | 147 | /* |
| 148 | 148 | utilities |
| 149 | 149 | */ |
| r3831 | r3832 | |
| 189 | 189 | return bit; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | | |
| 193 | 192 | /* |
| 194 | | initialize the tms9901 core |
| 195 | | */ |
| 196 | | void tms9901_init(running_machine *machine,int which, const tms9901reset_param *param) |
| 197 | | { |
| 198 | | int i; |
| 199 | | |
| 200 | | tms9901[which].timer = timer_alloc(machine, decrementer_callback, NULL); |
| 201 | | |
| 202 | | tms9901[which].supported_int_mask = param->supported_int_mask; |
| 203 | | |
| 204 | | for (i=0; i<4; i++) |
| 205 | | tms9901[which].read_handlers[i] = param->read_handlers[i]; |
| 206 | | |
| 207 | | for (i=0; i<16; i++) |
| 208 | | tms9901[which].write_handlers[i] = param->write_handlers[i]; |
| 209 | | |
| 210 | | tms9901[which].interrupt_callback = param->interrupt_callback; |
| 211 | | |
| 212 | | tms9901[which].clock_rate = param->clock_rate; |
| 213 | | |
| 214 | | |
| 215 | | tms9901[which].int_state = 0; |
| 216 | | |
| 217 | | |
| 218 | | tms9901_reset(which); |
| 219 | | } |
| 220 | | |
| 221 | | |
| 222 | | void tms9901_cleanup(int which) |
| 223 | | { |
| 224 | | if (tms9901[which].timer) |
| 225 | | { |
| 226 | | timer_reset(tms9901[which].timer, attotime_never); /* FIXME - timers should only be allocated once */ |
| 227 | | tms9901[which].timer = NULL; |
| 228 | | } |
| 229 | | } |
| 230 | | |
| 231 | | void tms9901_reset(int which) |
| 232 | | { |
| 233 | | tms9901[which].timer_int_pending = 0; |
| 234 | | tms9901[which].enabled_ints = 0; |
| 235 | | |
| 236 | | tms9901[which].pio_direction = 0; |
| 237 | | tms9901[which].pio_direction_mirror = 0; |
| 238 | | tms9901[which].pio_output = tms9901[which].pio_output_mirror = 0; |
| 239 | | |
| 240 | | tms9901_field_interrupts(which); |
| 241 | | |
| 242 | | tms9901[which].mode9901 = 0; |
| 243 | | |
| 244 | | tms9901[which].clockinvl = 0; |
| 245 | | tms9901_timer_reload(which); |
| 246 | | } |
| 247 | | |
| 248 | | /* |
| 249 | 193 | should be called after any change to int_state or enabled_ints. |
| 250 | 194 | */ |
| 251 | | static void tms9901_field_interrupts(int which) |
| 195 | static void tms9901_field_interrupts(const device_config *device) |
| 252 | 196 | { |
| 253 | 197 | int current_ints; |
| 198 | tms9901_t *tms = get_token(device); |
| 254 | 199 | |
| 255 | 200 | /* int_state: state of lines int1-int15 */ |
| 256 | | current_ints = tms9901[which].int_state; |
| 257 | | if (tms9901[which].clockinvl != 0) |
| 201 | current_ints = tms->int_state; |
| 202 | if (tms->clockinvl != 0) |
| 258 | 203 | { /* if timer is enabled, INT3 pin is overriden by timer */ |
| 259 | | if (tms9901[which].timer_int_pending) |
| 204 | if (tms->timer_int_pending) |
| 260 | 205 | current_ints |= TMS9901_INT3; |
| 261 | 206 | else |
| 262 | 207 | current_ints &= ~ TMS9901_INT3; |
| r3831 | r3832 | |
| 264 | 209 | |
| 265 | 210 | /* enabled_ints: enabled interrupts */ |
| 266 | 211 | /* mask out all int pins currently set as output */ |
| 267 | | current_ints &= tms9901[which].enabled_ints & (~ tms9901[which].pio_direction_mirror); |
| 212 | current_ints &= tms->enabled_ints & (~ tms->pio_direction_mirror); |
| 268 | 213 | |
| 269 | 214 | if (current_ints) |
| 270 | 215 | { |
| r3831 | r3832 | |
| 272 | 217 | we simply look for the first bit set to 1 in current_ints... */ |
| 273 | 218 | int level = find_first_bit(current_ints); |
| 274 | 219 | |
| 275 | | tms9901[which].int_pending = TRUE; |
| 220 | tms->int_pending = TRUE; |
| 276 | 221 | |
| 277 | | if (tms9901[which].interrupt_callback) |
| 278 | | (*tms9901[which].interrupt_callback)(1, level); |
| 222 | if (tms->intf->interrupt_callback) |
| 223 | (*tms->intf->interrupt_callback)(device, 1, level); |
| 279 | 224 | } |
| 280 | 225 | else |
| 281 | 226 | { |
| 282 | | tms9901[which].int_pending = FALSE; |
| 227 | tms->int_pending = FALSE; |
| 283 | 228 | |
| 284 | | if (tms9901[which].interrupt_callback) |
| 285 | | (*tms9901[which].interrupt_callback)(0, 0xf); |
| 229 | if (tms->intf->interrupt_callback) |
| 230 | (*tms->intf->interrupt_callback)(device, 0, 0xf); |
| 286 | 231 | } |
| 287 | 232 | } |
| 288 | 233 | |
| r3831 | r3832 | |
| 296 | 241 | |
| 297 | 242 | 0<=pin_number<=15 |
| 298 | 243 | */ |
| 299 | | void tms9901_set_single_int(int which, int pin_number, int state) |
| 244 | void tms9901_set_single_int(const device_config *device, int pin_number, int state) |
| 300 | 245 | { |
| 246 | tms9901_t *tms = get_token(device); |
| 301 | 247 | /* remember new state of INTn* pin state */ |
| 302 | 248 | if (state) |
| 303 | | tms9901[which].int_state |= 1 << pin_number; |
| 249 | tms->int_state |= 1 << pin_number; |
| 304 | 250 | else |
| 305 | | tms9901[which].int_state &= ~ (1 << pin_number); |
| 251 | tms->int_state &= ~ (1 << pin_number); |
| 306 | 252 | |
| 307 | 253 | /* we do not need to always call this function - time for an optimization */ |
| 308 | | tms9901_field_interrupts(which); |
| 254 | tms9901_field_interrupts(device); |
| 309 | 255 | } |
| 310 | 256 | |
| 311 | 257 | |
| r3831 | r3832 | |
| 315 | 261 | */ |
| 316 | 262 | static TIMER_CALLBACK(decrementer_callback) |
| 317 | 263 | { |
| 318 | | int which = param; |
| 319 | | tms9901[which].timer_int_pending = TRUE; /* decrementer interrupt requested */ |
| 264 | const device_config *device = (const device_config *) ptr; |
| 265 | tms9901_t *tms = get_token(device); |
| 266 | |
| 267 | tms->timer_int_pending = TRUE; /* decrementer interrupt requested */ |
| 320 | 268 | |
| 321 | | tms9901_field_interrupts(which); |
| 269 | tms9901_field_interrupts(device); |
| 322 | 270 | } |
| 323 | 271 | |
| 324 | 272 | /* |
| 325 | 273 | load the content of clockinvl into the decrementer |
| 326 | 274 | */ |
| 327 | | static void tms9901_timer_reload(int which) |
| 275 | static void tms9901_timer_reload(const device_config *device) |
| 328 | 276 | { |
| 329 | | if (tms9901[which].clockinvl) |
| 277 | tms9901_t *tms = get_token(device); |
| 278 | if (tms->clockinvl) |
| 330 | 279 | { /* reset clock interval */ |
| 331 | | timer_adjust_periodic(tms9901[which].timer, double_to_attotime((double) tms9901[which].clockinvl / (tms9901[which].clock_rate / 64.)), which, double_to_attotime((double) tms9901[which].clockinvl / (tms9901[which].clock_rate / 64.))); |
| 280 | timer_adjust_periodic(tms->timer, double_to_attotime((double) tms->clockinvl / (tms->clock_rate / 64.)), 0, double_to_attotime((double) tms->clockinvl / (tms->clock_rate / 64.))); |
| 332 | 281 | } |
| 333 | 282 | else |
| 334 | 283 | { /* clock interval == 0 -> no timer */ |
| 335 | | timer_enable(tms9901[which].timer, 0); |
| 284 | timer_enable(tms->timer, 0); |
| 336 | 285 | } |
| 337 | 286 | } |
| 338 | 287 | |
| r3831 | r3832 | |
| 355 | 304 | |
| 356 | 305 | bit 16-31: current status of the P0-P15 pins (quits timer mode, too...) |
| 357 | 306 | */ |
| 358 | | int tms9901_cru_r(int which, int offset) |
| 307 | READ8_DEVICE_HANDLER ( tms9901_cru_r ) |
| 359 | 308 | { |
| 360 | 309 | int answer; |
| 310 | tms9901_t *tms = get_token(device); |
| 361 | 311 | |
| 362 | 312 | offset &= 0x003; |
| 363 | 313 | |
| 364 | 314 | switch (offset) |
| 365 | 315 | { |
| 366 | 316 | case 0: |
| 367 | | if (tms9901[which].mode9901) |
| 317 | if (tms->mode9901) |
| 368 | 318 | { /* clock mode */ |
| 369 | | answer = ((tms9901[which].latchedtimer & 0x7F) << 1) | 0x01; |
| 319 | answer = ((tms->latchedtimer & 0x7F) << 1) | 0x01; |
| 370 | 320 | } |
| 371 | 321 | else |
| 372 | 322 | { /* interrupt mode */ |
| 373 | | answer = ((~ tms9901[which].int_state) & tms9901[which].supported_int_mask) & 0xFF; |
| 323 | answer = ((~ tms->int_state) & tms->supported_int_mask) & 0xFF; |
| 374 | 324 | |
| 375 | | if (tms9901[which].read_handlers[0]) |
| 376 | | answer |= (* tms9901[which].read_handlers[0])(0); |
| 325 | if (tms->intf->read_handlers[0]) |
| 326 | answer |= (* tms->intf->read_handlers[0])(0); |
| 377 | 327 | |
| 378 | | answer &= ~ tms9901[which].pio_direction_mirror; |
| 379 | | answer |= (tms9901[which].pio_output_mirror & tms9901[which].pio_direction_mirror) & 0xFF; |
| 328 | answer &= ~ tms->pio_direction_mirror; |
| 329 | answer |= (tms->pio_output_mirror & tms->pio_direction_mirror) & 0xFF; |
| 380 | 330 | } |
| 381 | 331 | break; |
| 382 | 332 | case 1: |
| 383 | | if (tms9901[which].mode9901) |
| 333 | if (tms->mode9901) |
| 384 | 334 | { /* clock mode */ |
| 385 | | answer = (tms9901[which].latchedtimer & 0x3F80) >> 7; |
| 386 | | if (! tms9901[which].int_pending) |
| 335 | answer = (tms->latchedtimer & 0x3F80) >> 7; |
| 336 | if (! tms->int_pending) |
| 387 | 337 | answer |= 0x80; |
| 388 | 338 | } |
| 389 | 339 | else |
| 390 | 340 | { /* interrupt mode */ |
| 391 | | answer = ((~ tms9901[which].int_state) & tms9901[which].supported_int_mask) >> 8; |
| 341 | answer = ((~ tms->int_state) & tms->supported_int_mask) >> 8; |
| 392 | 342 | |
| 393 | | if (tms9901[which].read_handlers[1]) |
| 394 | | answer |= (* tms9901[which].read_handlers[1])(1); |
| 343 | if (tms->intf->read_handlers[1]) |
| 344 | answer |= (* tms->intf->read_handlers[1])(1); |
| 395 | 345 | |
| 396 | | answer &= ~ (tms9901[which].pio_direction_mirror >> 8); |
| 397 | | answer |= (tms9901[which].pio_output_mirror & tms9901[which].pio_direction_mirror) >> 8; |
| 346 | answer &= ~ (tms->pio_direction_mirror >> 8); |
| 347 | answer |= (tms->pio_output_mirror & tms->pio_direction_mirror) >> 8; |
| 398 | 348 | } |
| 399 | 349 | break; |
| 400 | 350 | case 2: |
| 401 | 351 | /* exit timer mode */ |
| 402 | | tms9901[which].mode9901 = 0; |
| 352 | tms->mode9901 = 0; |
| 403 | 353 | |
| 404 | | answer = (tms9901[which].read_handlers[2]) ? (* tms9901[which].read_handlers[2])(2) : 0; |
| 354 | answer = (tms->intf->read_handlers[2]) ? (* tms->intf->read_handlers[2])(2) : 0; |
| 405 | 355 | |
| 406 | | answer &= ~ tms9901[which].pio_direction; |
| 407 | | answer |= (tms9901[which].pio_output & tms9901[which].pio_direction) & 0xFF; |
| 356 | answer &= ~ tms->pio_direction; |
| 357 | answer |= (tms->pio_output & tms->pio_direction) & 0xFF; |
| 408 | 358 | |
| 409 | 359 | break; |
| 410 | 360 | default: |
| 411 | 361 | /* exit timer mode */ |
| 412 | | tms9901[which].mode9901 = 0; |
| 362 | tms->mode9901 = 0; |
| 413 | 363 | |
| 414 | | answer = (tms9901[which].read_handlers[3]) ? (* tms9901[which].read_handlers[3])(3) : 0; |
| 364 | answer = (tms->intf->read_handlers[3]) ? (* tms->intf->read_handlers[3])(3) : 0; |
| 415 | 365 | |
| 416 | | answer &= ~ (tms9901[which].pio_direction >> 8); |
| 417 | | answer |= (tms9901[which].pio_output & tms9901[which].pio_direction) >> 8; |
| 366 | answer &= ~ (tms->pio_direction >> 8); |
| 367 | answer |= (tms->pio_output & tms->pio_direction) >> 8; |
| 418 | 368 | |
| 419 | 369 | break; |
| 420 | 370 | } |
| r3831 | r3832 | |
| 435 | 385 | |
| 436 | 386 | bit 16-31: set output state of P0-P15 (and set them as output pin) (quit timer mode, too...) |
| 437 | 387 | */ |
| 438 | | void tms9901_cru_w(int which, int offset, int data) |
| 388 | WRITE8_DEVICE_HANDLER ( tms9901_cru_w ) |
| 439 | 389 | { |
| 390 | tms9901_t *tms = get_token(device); |
| 391 | |
| 440 | 392 | data &= 1; /* clear extra bits */ |
| 441 | 393 | offset &= 0x01F; |
| 442 | 394 | |
| 443 | 395 | switch (offset) |
| 444 | 396 | { |
| 445 | 397 | case 0x00: /* write to mode bit */ |
| 446 | | if (tms9901[which].mode9901 != data) |
| 398 | if (tms->mode9901 != data) |
| 447 | 399 | { |
| 448 | | tms9901[which].mode9901 = data; |
| 400 | tms->mode9901 = data; |
| 449 | 401 | |
| 450 | | if (tms9901[which].mode9901) |
| 402 | if (tms->mode9901) |
| 451 | 403 | { |
| 452 | 404 | /* we are switching to clock mode: latch the current value of |
| 453 | 405 | the decrementer register */ |
| 454 | | if (tms9901[which].clockinvl) |
| 455 | | tms9901[which].latchedtimer = ceil(attotime_to_double(timer_timeleft(tms9901[which].timer)) * (tms9901[which].clock_rate / 64.)); |
| 406 | if (tms->clockinvl) |
| 407 | tms->latchedtimer = ceil(attotime_to_double(timer_timeleft(tms->timer)) * (tms->clock_rate / 64.)); |
| 456 | 408 | else |
| 457 | | tms9901[which].latchedtimer = 0; /* timer inactive... */ |
| 409 | tms->latchedtimer = 0; /* timer inactive... */ |
| 458 | 410 | } |
| 459 | 411 | else |
| 460 | 412 | { |
| r3831 | r3832 | |
| 483 | 435 | : Bit in clock interval |
| 484 | 436 | */ |
| 485 | 437 | /* offset is the index of the modified bit of register (-> interrupt number -1) */ |
| 486 | | if (tms9901[which].mode9901) |
| 438 | if (tms->mode9901) |
| 487 | 439 | { /* modify clock interval */ |
| 488 | 440 | int mask = 1 << ((offset & 0x0F) - 1); /* corresponding mask */ |
| 489 | 441 | |
| 490 | 442 | if (data) |
| 491 | | tms9901[which].clockinvl |= mask; /* set bit */ |
| 443 | tms->clockinvl |= mask; /* set bit */ |
| 492 | 444 | else |
| 493 | | tms9901[which].clockinvl &= ~ mask; /* clear bit */ |
| 445 | tms->clockinvl &= ~ mask; /* clear bit */ |
| 494 | 446 | |
| 495 | 447 | /* reset clock timer */ |
| 496 | | tms9901_timer_reload(which); |
| 448 | tms9901_timer_reload(device); |
| 497 | 449 | } |
| 498 | 450 | else |
| 499 | 451 | { /* modify interrupt enable mask */ |
| 500 | 452 | int mask = 1 << (offset & 0x0F); /* corresponding mask */ |
| 501 | 453 | |
| 502 | 454 | if (data) |
| 503 | | tms9901[which].enabled_ints |= mask; /* set bit */ |
| 455 | tms->enabled_ints |= mask; /* set bit */ |
| 504 | 456 | else |
| 505 | | tms9901[which].enabled_ints &= ~ mask; /* unset bit */ |
| 457 | tms->enabled_ints &= ~ mask; /* unset bit */ |
| 506 | 458 | |
| 507 | 459 | if (offset == 3) |
| 508 | | tms9901[which].timer_int_pending = FALSE; /* SBO 3 clears pending timer interrupt (??) */ |
| 460 | tms->timer_int_pending = FALSE; /* SBO 3 clears pending timer interrupt (??) */ |
| 509 | 461 | |
| 510 | | tms9901_field_interrupts(which); /* changed interrupt state */ |
| 462 | tms9901_field_interrupts(device); /* changed interrupt state */ |
| 511 | 463 | } |
| 512 | 464 | break; |
| 513 | 465 | case 0x0F: |
| 514 | | if (tms9901[which].mode9901) |
| 466 | if (tms->mode9901) |
| 515 | 467 | { /* in clock mode, this is the soft reset bit */ |
| 516 | 468 | if (! data) |
| 517 | 469 | { /* TMS9901 soft reset */ |
| 518 | 470 | /* all output pins are input pins again */ |
| 519 | | tms9901[which].pio_direction = 0; |
| 520 | | tms9901[which].pio_direction_mirror = 0; |
| 471 | tms->pio_direction = 0; |
| 472 | tms->pio_direction_mirror = 0; |
| 521 | 473 | |
| 522 | | tms9901[which].enabled_ints = 0; /* right??? */ |
| 474 | tms->enabled_ints = 0; /* right??? */ |
| 523 | 475 | } |
| 524 | 476 | } |
| 525 | 477 | else |
| 526 | 478 | { /* modify interrupt enable mask */ |
| 527 | 479 | if (data) |
| 528 | | tms9901[which].enabled_ints |= 0x4000; /* set bit */ |
| 480 | tms->enabled_ints |= 0x4000; /* set bit */ |
| 529 | 481 | else |
| 530 | | tms9901[which].enabled_ints &= ~0x4000; /* unset bit */ |
| 482 | tms->enabled_ints &= ~0x4000; /* unset bit */ |
| 531 | 483 | |
| 532 | | tms9901_field_interrupts(which); /* changed interrupt state */ |
| 484 | tms9901_field_interrupts(device); /* changed interrupt state */ |
| 533 | 485 | } |
| 534 | 486 | break; |
| 535 | 487 | case 0x10: |
| r3831 | r3832 | |
| 553 | 505 | int mask = (1 << pin); |
| 554 | 506 | |
| 555 | 507 | /* exit timer mode */ |
| 556 | | tms9901[which].mode9901 = 0; |
| 508 | tms->mode9901 = 0; |
| 557 | 509 | |
| 558 | | tms9901[which].pio_direction |= mask; /* set up as output pin */ |
| 510 | tms->pio_direction |= mask; /* set up as output pin */ |
| 559 | 511 | |
| 560 | 512 | if (data) |
| 561 | | tms9901[which].pio_output |= mask; |
| 513 | tms->pio_output |= mask; |
| 562 | 514 | else |
| 563 | | tms9901[which].pio_output &= ~ mask; |
| 515 | tms->pio_output &= ~ mask; |
| 564 | 516 | |
| 565 | 517 | if (pin >= 7) |
| 566 | 518 | { /* pins P7-P15 are mirrored as INT15*-INT7* */ |
| 567 | 519 | int pin2 = 22 - pin; |
| 568 | 520 | int mask2 = (1 << pin2); |
| 569 | 521 | |
| 570 | | tms9901[which].pio_direction_mirror |= mask2; /* set up as output pin */ |
| 522 | tms->pio_direction_mirror |= mask2; /* set up as output pin */ |
| 571 | 523 | |
| 572 | 524 | if (data) |
| 573 | | tms9901[which].pio_output_mirror |= mask2; |
| 525 | tms->pio_output_mirror |= mask2; |
| 574 | 526 | else |
| 575 | | tms9901[which].pio_output_mirror &= ~ mask2; |
| 527 | tms->pio_output_mirror &= ~ mask2; |
| 576 | 528 | } |
| 577 | 529 | |
| 578 | | if (tms9901[which].write_handlers[pin] != NULL) |
| 579 | | (* tms9901[which].write_handlers[pin])(pin, data); |
| 530 | if (tms->intf->write_handlers[pin] != NULL) |
| 531 | (* tms->intf->write_handlers[pin])(pin, data); |
| 580 | 532 | } |
| 581 | 533 | |
| 582 | 534 | break; |
| 583 | 535 | } |
| 584 | 536 | } |
| 585 | 537 | |
| 586 | | READ8_HANDLER ( tms9901_0_cru_r ) |
| 538 | /*------------------------------------------------- |
| 539 | DEVICE_STOP( tms9901 ) |
| 540 | -------------------------------------------------*/ |
| 541 | |
| 542 | static DEVICE_STOP( tms9901 ) |
| 587 | 543 | { |
| 588 | | return tms9901_cru_r(0, offset); |
| 544 | tms9901_t *tms = get_token(device); |
| 545 | |
| 546 | if (tms->timer) |
| 547 | { |
| 548 | timer_reset(tms->timer, attotime_never); /* FIXME - timers should only be allocated once */ |
| 549 | tms->timer = NULL; |
| 550 | } |
| 589 | 551 | } |
| 590 | 552 | |
| 591 | | WRITE8_HANDLER ( tms9901_0_cru_w ) |
| 553 | /*------------------------------------------------- |
| 554 | DEVICE_RESET( tms9901 ) |
| 555 | -------------------------------------------------*/ |
| 556 | |
| 557 | static DEVICE_RESET( tms9901 ) |
| 592 | 558 | { |
| 593 | | tms9901_cru_w(0, offset, data); |
| 559 | tms9901_t *tms = get_token(device); |
| 560 | |
| 561 | tms->timer_int_pending = 0; |
| 562 | tms->enabled_ints = 0; |
| 563 | |
| 564 | tms->pio_direction = 0; |
| 565 | tms->pio_direction_mirror = 0; |
| 566 | tms->pio_output = tms->pio_output_mirror = 0; |
| 567 | |
| 568 | tms9901_field_interrupts(device); |
| 569 | |
| 570 | tms->mode9901 = 0; |
| 571 | |
| 572 | tms->clockinvl = 0; |
| 573 | tms9901_timer_reload(device); |
| 574 | |
| 594 | 575 | } |
| 595 | 576 | |
| 596 | | READ8_HANDLER ( tms9901_1_cru_r ) |
| 577 | |
| 578 | /*------------------------------------------------- |
| 579 | DEVICE_START( tms9901 ) |
| 580 | -------------------------------------------------*/ |
| 581 | |
| 582 | static DEVICE_START( tms9901 ) |
| 597 | 583 | { |
| 598 | | return tms9901_cru_r(1, offset); |
| 584 | tms9901_t *tms = get_token(device); |
| 585 | |
| 586 | assert(device != NULL); |
| 587 | assert(device->tag != NULL); |
| 588 | assert(strlen(device->tag) < 20); |
| 589 | assert(device->static_config != NULL); |
| 590 | |
| 591 | tms->intf = device->static_config; |
| 592 | |
| 593 | tms->timer = timer_alloc(device->machine, decrementer_callback, (void *) device); |
| 594 | |
| 595 | tms->supported_int_mask = tms->intf->supported_int_mask; |
| 596 | |
| 597 | tms->clock_rate = tms->intf->clock_rate; |
| 598 | |
| 599 | tms->int_state = 0; |
| 600 | return DEVICE_START_OK; |
| 599 | 601 | } |
| 600 | 602 | |
| 601 | | WRITE8_HANDLER ( tms9901_1_cru_w ) |
| 603 | |
| 604 | |
| 605 | /*------------------------------------------------- |
| 606 | DEVICE_SET_INFO( tms9901 ) |
| 607 | -------------------------------------------------*/ |
| 608 | |
| 609 | static DEVICE_SET_INFO( tms9901 ) |
| 602 | 610 | { |
| 603 | | tms9901_cru_w(1, offset, data); |
| 611 | switch (state) |
| 612 | { |
| 613 | /* no parameters to set */ |
| 614 | } |
| 604 | 615 | } |
| 616 | |
| 617 | |
| 618 | |
| 619 | /*------------------------------------------------- |
| 620 | DEVICE_GET_INFO( tms9901 ) |
| 621 | -------------------------------------------------*/ |
| 622 | |
| 623 | DEVICE_GET_INFO( tms9901 ) |
| 624 | { |
| 625 | switch (state) |
| 626 | { |
| 627 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 628 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tms9901_t); break; |
| 629 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 630 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 631 | |
| 632 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 633 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(tms9901); break; |
| 634 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tms9901); break; |
| 635 | case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME (tms9901); break; |
| 636 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(tms9901); break; |
| 637 | |
| 638 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 639 | case DEVINFO_STR_NAME: info->s = "TMS9901"; break; |
| 640 | case DEVINFO_STR_FAMILY: info->s = "TMS9901"; break; |
| 641 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 642 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 643 | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 644 | } |
| 645 | } |
src/mess/machine/geneve.c
| r3831 | r3832 | |
| 27 | 27 | static void inta_callback(running_machine *machine, int state); |
| 28 | 28 | static void intb_callback(running_machine *machine, int state); |
| 29 | 29 | |
| 30 | | static void read_key_if_possible(void); |
| 30 | static void read_key_if_possible(running_machine *machine); |
| 31 | 31 | static void poll_keyboard(running_machine *machine); |
| 32 | 32 | static void poll_mouse(running_machine *machine); |
| 33 | 33 | |
| 34 | | static void tms9901_interrupt_callback(int intreq, int ic); |
| 34 | static void tms9901_interrupt_callback(const device_config *device,int intreq, int ic); |
| 35 | 35 | static int R9901_0(int offset); |
| 36 | 36 | static int R9901_1(int offset); |
| 37 | 37 | static int R9901_2(int offset); |
| r3831 | r3832 | |
| 76 | 76 | static char has_alt_boot; |
| 77 | 77 | |
| 78 | 78 | /* tms9901 setup */ |
| 79 | | static const tms9901reset_param tms9901reset_param_ti99 = |
| 79 | const tms9901_interface tms9901reset_param_ti99 = |
| 80 | 80 | { |
| 81 | 81 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT8 | TMS9901_INTB | TMS9901_INTC, /* only input pins whose state is always known */ |
| 82 | 82 | |
| r3831 | r3832 | |
| 207 | 207 | |
| 208 | 208 | MACHINE_START( geneve ) |
| 209 | 209 | { |
| 210 | | tms9901_init(machine, 0, & tms9901reset_param_ti99); |
| 211 | | |
| 212 | 210 | /* Initialize all. Actually, at this point, we don't know |
| 213 | 211 | how the switches are set. Later we use the configuration switches to |
| 214 | 212 | determine which one to use. */ |
| r3831 | r3832 | |
| 238 | 236 | /* reset cartridge mapper */ |
| 239 | 237 | cartridge_page = 0; |
| 240 | 238 | |
| 241 | | /* init tms9901 */ |
| 242 | | tms9901_reset(0); |
| 243 | | |
| 244 | 239 | v9938_reset(0); |
| 245 | 240 | |
| 246 | 241 | /* clear keyboard interface state (probably overkill, but can't harm) */ |
| r3831 | r3832 | |
| 315 | 310 | { |
| 316 | 311 | if (has_ide) |
| 317 | 312 | ti99_ide_save_memcard(); |
| 318 | | |
| 319 | | tms9901_cleanup(0); |
| 320 | 313 | } |
| 321 | 314 | |
| 322 | 315 | |
| r3831 | r3832 | |
| 349 | 342 | */ |
| 350 | 343 | static void inta_callback(running_machine *machine, int state) |
| 351 | 344 | { |
| 352 | | tms9901_set_single_int(0, 1, state); |
| 345 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 1, state); |
| 353 | 346 | cpu_set_input_line(machine->cpu[0], 1, state ? ASSERT_LINE : CLEAR_LINE); |
| 354 | 347 | } |
| 355 | 348 | |
| r3831 | r3832 | |
| 358 | 351 | */ |
| 359 | 352 | static void intb_callback(running_machine *machine, int state) |
| 360 | 353 | { |
| 361 | | tms9901_set_single_int(0, 12, state); |
| 354 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 12, state); |
| 362 | 355 | } |
| 363 | 356 | |
| 364 | 357 | |
| r3831 | r3832 | |
| 988 | 981 | if ((offset == 0x778) && data && (! (old_flags & mf_keyclock))) |
| 989 | 982 | { |
| 990 | 983 | /* set mf_keyclock */ |
| 991 | | read_key_if_possible(); |
| 984 | read_key_if_possible(space->machine); |
| 992 | 985 | } |
| 993 | 986 | if (offset == 0x779) |
| 994 | 987 | { |
| r3831 | r3832 | |
| 996 | 989 | { |
| 997 | 990 | /* set mf_keyclear: enable key input */ |
| 998 | 991 | /* shift in new key immediately if possible */ |
| 999 | | read_key_if_possible(); |
| 992 | read_key_if_possible(space->machine); |
| 1000 | 993 | } |
| 1001 | 994 | else if ((! data) && (old_flags & mf_keyclear)) |
| 1002 | 995 | { |
| r3831 | r3832 | |
| 1007 | 1000 | KeyQueueLen--; |
| 1008 | 1001 | } |
| 1009 | 1002 | /* clear keyboard interrupt */ |
| 1010 | | tms9901_set_single_int(0, 8, 0); |
| 1003 | tms9901_set_single_int(device_list_find_by_tag(space->machine->config->devicelist, TMS9901, "tms9901"), 8, 0); |
| 1011 | 1004 | KeyInBuf = 0; |
| 1012 | 1005 | } |
| 1013 | 1006 | } |
| r3831 | r3832 | |
| 1022 | 1015 | #pragma mark KEYBOARD INTERFACE |
| 1023 | 1016 | #endif |
| 1024 | 1017 | |
| 1025 | | static void read_key_if_possible(void) |
| 1018 | static void read_key_if_possible(running_machine *machine) |
| 1026 | 1019 | { |
| 1027 | 1020 | /* if keyboard reset is not asserted, and key clock is enabled, and key |
| 1028 | 1021 | buffer clear is disabled, and key queue is not empty. */ |
| 1029 | 1022 | if ((! KeyReset) && (mode_flags & mf_keyclock) && (mode_flags & mf_keyclear) && KeyQueueLen) |
| 1030 | 1023 | { |
| 1031 | | tms9901_set_single_int(0, 8, 1); |
| 1024 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 8, 1); |
| 1032 | 1025 | KeyInBuf = 1; |
| 1033 | 1026 | } |
| 1034 | 1027 | } |
| r3831 | r3832 | |
| 1240 | 1233 | keycode |= 0x80; |
| 1241 | 1234 | post_in_KeyQueue(keycode); |
| 1242 | 1235 | } |
| 1243 | | read_key_if_possible(); |
| 1236 | read_key_if_possible(machine); |
| 1244 | 1237 | } |
| 1245 | 1238 | } |
| 1246 | 1239 | } |
| r3831 | r3832 | |
| 1270 | 1263 | { |
| 1271 | 1264 | post_in_KeyQueue(KeyAutoRepeatKey); |
| 1272 | 1265 | } |
| 1273 | | read_key_if_possible(); |
| 1266 | read_key_if_possible(machine); |
| 1274 | 1267 | KeyAutoRepeatTimer = KeyAutoRepeatRate; |
| 1275 | 1268 | } |
| 1276 | 1269 | } |
| r3831 | r3832 | |
| 1340 | 1333 | */ |
| 1341 | 1334 | /*void tms9901_set_int2(int state) |
| 1342 | 1335 | { |
| 1343 | | tms9901_set_single_int(0, 2, state); |
| 1336 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 2, state); |
| 1344 | 1337 | }*/ |
| 1345 | 1338 | |
| 1346 | 1339 | /* |
| 1347 | 1340 | Called by the 9901 core whenever the state of INTREQ and IC0-3 changes |
| 1348 | 1341 | */ |
| 1349 | | static void tms9901_interrupt_callback(int intreq, int ic) |
| 1342 | static void tms9901_interrupt_callback(const device_config *device, int intreq, int ic) |
| 1350 | 1343 | { |
| 1351 | 1344 | /* INTREQ is connected to INT1 (IC0-3 are not connected) */ |
| 1352 | | cpu_set_input_line(Machine->cpu[0], 0, intreq ? ASSERT_LINE : CLEAR_LINE); |
| 1345 | cpu_set_input_line(device->machine->cpu[0], 0, intreq ? ASSERT_LINE : CLEAR_LINE); |
| 1353 | 1346 | } |
| 1354 | 1347 | |
| 1355 | 1348 | /* |
src/mess/machine/ti99_4x.c
| r3831 | r3832 | |
| 77 | 77 | static WRITE16_HANDLER ( ti99_wspeech_w ); |
| 78 | 78 | |
| 79 | 79 | static void tms9901_set_int1(running_machine *machine, int state); |
| 80 | | static void tms9901_interrupt_callback(int intreq, int ic); |
| 80 | static void tms9901_interrupt_callback(const device_config *device, int intreq, int ic); |
| 81 | 81 | static int ti99_R9901_0(int offset); |
| 82 | 82 | static int ti99_R9901_1(int offset); |
| 83 | 83 | static int ti99_R9901_2(int offset); |
| r3831 | r3832 | |
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | /* tms9901 setup */ |
| 150 | | static const tms9901reset_param tms9901reset_param_ti99_4x = |
| 150 | const tms9901_interface tms9901reset_param_ti99_4x = |
| 151 | 151 | { |
| 152 | 152 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 153 | 153 | |
| r3831 | r3832 | |
| 184 | 184 | 3000000. |
| 185 | 185 | }; |
| 186 | 186 | |
| 187 | | static const tms9901reset_param tms9901reset_param_ti99_8 = |
| 187 | const tms9901_interface tms9901reset_param_ti99_8 = |
| 188 | 188 | { |
| 189 | 189 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 190 | 190 | |
| r3831 | r3832 | |
| 750 | 750 | |
| 751 | 751 | void ti99_common_init(running_machine *machine, const TMS9928a_interface *gfxparm) |
| 752 | 752 | { |
| 753 | | if (ti99_model==model_99_8) { |
| 754 | | tms9901_init(machine, 0, &tms9901reset_param_ti99_8); |
| 755 | | } |
| 756 | | else { |
| 757 | | tms9901_init(machine, 0, &tms9901reset_param_ti99_4x); |
| 758 | | } |
| 759 | 753 | if (gfxparm!=0) TMS9928A_configure(gfxparm); |
| 760 | 754 | |
| 761 | 755 | /* Initialize all. Actually, at this point, we don't know |
| r3831 | r3832 | |
| 807 | 801 | current_page_ptr = cartridge_pages[0]; |
| 808 | 802 | } |
| 809 | 803 | |
| 810 | | /* init tms9901 */ |
| 811 | | tms9901_reset(0); |
| 812 | | |
| 813 | 804 | if (!has_evpc) TMS9928A_reset(); |
| 814 | 805 | else v9938_reset(0); |
| 815 | 806 | |
| r3831 | r3832 | |
| 822 | 813 | handset_buflen = 0; |
| 823 | 814 | handset_clock = 0; |
| 824 | 815 | handset_ack = 0; |
| 825 | | tms9901_set_single_int(0, 12, 0); |
| 816 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 12, 0); |
| 826 | 817 | |
| 827 | 818 | /* read config */ |
| 828 | 819 | if (ti99_model == model_99_8) |
| r3831 | r3832 | |
| 1790 | 1781 | handset_clock = ! handset_clock; |
| 1791 | 1782 | handset_buf >>= 4; |
| 1792 | 1783 | handset_buflen--; |
| 1793 | | tms9901_set_single_int(0, 12, 0); |
| 1784 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 12, 0); |
| 1794 | 1785 | |
| 1795 | 1786 | if (handset_buflen == 1) |
| 1796 | 1787 | { |
| r3831 | r3832 | |
| 1832 | 1823 | |
| 1833 | 1824 | message: 12-bit message to post (only the 12 LSBits are meaningful) |
| 1834 | 1825 | */ |
| 1835 | | static void ti99_handset_post_message(int message) |
| 1826 | static void ti99_handset_post_message(running_machine *machine, int message) |
| 1836 | 1827 | { |
| 1837 | 1828 | /* post message and assert interrupt */ |
| 1838 | 1829 | handset_clock = 1; |
| 1839 | 1830 | handset_buf = ~ message; |
| 1840 | 1831 | handset_buflen = 3; |
| 1841 | | tms9901_set_single_int(0, 12, 1); |
| 1832 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 12, 1); |
| 1842 | 1833 | } |
| 1843 | 1834 | |
| 1844 | 1835 | /* |
| r3831 | r3832 | |
| 1884 | 1875 | previous_key[num] = current_key = previous_key[num] & ~0x20; |
| 1885 | 1876 | } |
| 1886 | 1877 | /* post message */ |
| 1887 | | ti99_handset_post_message((((unsigned) current_key) << 4) | (num << 1)); |
| 1878 | ti99_handset_post_message(machine, (((unsigned) current_key) << 4) | (num << 1)); |
| 1888 | 1879 | |
| 1889 | 1880 | return TRUE; |
| 1890 | 1881 | } |
| r3831 | r3832 | |
| 1913 | 1904 | previous_key[num] = current_key; |
| 1914 | 1905 | |
| 1915 | 1906 | /* post message */ |
| 1916 | | ti99_handset_post_message((((unsigned) current_key) << 4) | (num << 1)); |
| 1907 | ti99_handset_post_message(machine, (((unsigned) current_key) << 4) | (num << 1)); |
| 1917 | 1908 | |
| 1918 | 1909 | return TRUE; |
| 1919 | 1910 | } |
| r3831 | r3832 | |
| 1990 | 1981 | message |= (num << 1) | 0x1; |
| 1991 | 1982 | |
| 1992 | 1983 | /* post message */ |
| 1993 | | ti99_handset_post_message(message); |
| 1984 | ti99_handset_post_message(machine, message); |
| 1994 | 1985 | |
| 1995 | 1986 | return TRUE; |
| 1996 | 1987 | } |
| r3831 | r3832 | |
| 2221 | 2212 | */ |
| 2222 | 2213 | static void tms9901_set_int1(running_machine *machine, int state) |
| 2223 | 2214 | { |
| 2224 | | tms9901_set_single_int(0, 1, state); |
| 2215 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 1, state); |
| 2225 | 2216 | } |
| 2226 | 2217 | |
| 2227 | 2218 | /* |
| r3831 | r3832 | |
| 2229 | 2220 | */ |
| 2230 | 2221 | void tms9901_set_int2(running_machine *machine, int state) |
| 2231 | 2222 | { |
| 2232 | | tms9901_set_single_int(0, 2, state); |
| 2223 | tms9901_set_single_int(device_list_find_by_tag(machine->config->devicelist, TMS9901, "tms9901"), 2, state); |
| 2233 | 2224 | } |
| 2234 | 2225 | |
| 2235 | 2226 | /* |
| 2236 | 2227 | Called by the 9901 core whenever the state of INTREQ and IC0-3 changes |
| 2237 | 2228 | */ |
| 2238 | | static void tms9901_interrupt_callback(int intreq, int ic) |
| 2229 | static void tms9901_interrupt_callback(const device_config *device, int intreq, int ic) |
| 2239 | 2230 | { |
| 2240 | 2231 | if (intreq) |
| 2241 | 2232 | { |
| 2242 | 2233 | /* On TI99, TMS9900 IC0-3 lines are not connected to TMS9901, |
| 2243 | 2234 | * but hard-wired to force level 1 interrupts */ |
| 2244 | | cpu_set_input_line_and_vector(Machine->cpu[0], 0, ASSERT_LINE, 1); /* interrupt it, baby */ |
| 2235 | cpu_set_input_line_and_vector(device->machine->cpu[0], 0, ASSERT_LINE, 1); /* interrupt it, baby */ |
| 2245 | 2236 | } |
| 2246 | 2237 | else |
| 2247 | 2238 | { |
| 2248 | | cpu_set_input_line(Machine->cpu[0], 0, CLEAR_LINE); |
| 2239 | cpu_set_input_line(device->machine->cpu[0], 0, CLEAR_LINE); |
| 2249 | 2240 | } |
| 2250 | 2241 | } |
| 2251 | 2242 | |
src/mess/drivers/tm990189.c
| r3831 | r3832 | |
| 81 | 81 | |
| 82 | 82 | static void hold_load(running_machine *machine); |
| 83 | 83 | |
| 84 | | static void usr9901_interrupt_callback(int intreq, int ic); |
| 85 | | static void sys9901_interrupt_callback(int intreq, int ic); |
| 84 | static void usr9901_interrupt_callback(const device_config *device, int intreq, int ic); |
| 85 | static void sys9901_interrupt_callback(const device_config *device, int intreq, int ic); |
| 86 | 86 | |
| 87 | 87 | static void usr9901_led_w(int offset, int data); |
| 88 | 88 | |
| r3831 | r3832 | |
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | /* user tms9901 setup */ |
| 99 | | static const tms9901reset_param usr9901reset_param = |
| 99 | static const tms9901_interface usr9901reset_param = |
| 100 | 100 | { |
| 101 | 101 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT3 | TMS9901_INT4 | TMS9901_INT5 | TMS9901_INT6, /* only input pins whose state is always known */ |
| 102 | 102 | |
| r3831 | r3832 | |
| 135 | 135 | }; |
| 136 | 136 | |
| 137 | 137 | /* system tms9901 setup */ |
| 138 | | static const tms9901reset_param sys9901reset_param = |
| 138 | static const tms9901_interface sys9901reset_param = |
| 139 | 139 | { |
| 140 | 140 | 0, /* only input pins whose state is always known */ |
| 141 | 141 | |
| r3831 | r3832 | |
| 194 | 194 | |
| 195 | 195 | hold_load(machine); |
| 196 | 196 | |
| 197 | | tms9901_init(machine, 0, &usr9901reset_param); |
| 198 | | tms9901_init(machine, 1, &sys9901reset_param); |
| 199 | | tms9901_reset(0); |
| 200 | | tms9901_reset(1); |
| 201 | | |
| 202 | 197 | tms9902_init(machine, 0, &tms9902_params); |
| 203 | 198 | } |
| 204 | 199 | |
| r3831 | r3832 | |
| 226 | 221 | |
| 227 | 222 | hold_load(machine); |
| 228 | 223 | |
| 229 | | tms9901_init(machine, 0, &usr9901reset_param); |
| 230 | | tms9901_init(machine, 1, &sys9901reset_param); |
| 231 | | tms9901_reset(0); |
| 232 | | tms9901_reset(1); |
| 233 | | |
| 234 | 224 | tms9902_init(machine, 0, &tms9902_params); |
| 235 | 225 | |
| 236 | 226 | TMS9928A_reset(); |
| r3831 | r3832 | |
| 380 | 370 | tms9901 code |
| 381 | 371 | */ |
| 382 | 372 | |
| 383 | | static void usr9901_interrupt_callback(int intreq, int ic) |
| 373 | static void usr9901_interrupt_callback(const device_config *device, int intreq, int ic) |
| 384 | 374 | { |
| 385 | 375 | ic_state = ic & 7; |
| 386 | 376 | |
| r3831 | r3832 | |
| 396 | 386 | LED_state &= ~(1 << offset); |
| 397 | 387 | } |
| 398 | 388 | |
| 399 | | static void sys9901_interrupt_callback(int intreq, int ic) |
| 389 | static void sys9901_interrupt_callback(const device_config *device,int intreq, int ic) |
| 400 | 390 | { |
| 401 | 391 | (void)ic; |
| 402 | 392 | |
| 403 | | tms9901_set_single_int(0, 5, intreq); |
| 393 | tms9901_set_single_int(device_list_find_by_tag(device->machine->config->devicelist, TMS9901, "tms9901_0"), 5, intreq); |
| 404 | 394 | } |
| 405 | 395 | |
| 406 | 396 | static int sys9901_r0(int offset) |
| r3831 | r3832 | |
| 761 | 751 | */ |
| 762 | 752 | |
| 763 | 753 | static ADDRESS_MAP_START(tm990_189_writecru, ADDRESS_SPACE_IO, 8) |
| 764 | | |
| 765 | | |
| 766 | | AM_RANGE(0x000, 0x1ff) AM_WRITE(tms9901_0_cru_w) /* user I/O tms9901 */ |
| 767 | | AM_RANGE(0x200, 0x3ff) AM_WRITE(tms9901_1_cru_w) /* system I/O tms9901 */ |
| 754 | AM_RANGE(0x000, 0x1ff) AM_DEVWRITE(TMS9901, "tms9901_0", tms9901_cru_w) /* user I/O tms9901 */ |
| 755 | AM_RANGE(0x200, 0x3ff) AM_DEVWRITE(TMS9901, "tms9901_1", tms9901_cru_w) /* system I/O tms9901 */ |
| 768 | 756 | AM_RANGE(0x400, 0x5ff) AM_WRITE(tms9902_0_cru_w) /* optional tms9902 */ |
| 769 | 757 | |
| 770 | 758 | AM_RANGE(0x0800,0x1fff)AM_WRITE(ext_instr_decode) /* external instruction decoding (IDLE, RSET, CKON, CKOF, LREX) */ |
| 771 | | |
| 772 | 759 | ADDRESS_MAP_END |
| 773 | 760 | |
| 774 | 761 | static ADDRESS_MAP_START(tm990_189_readcru, ADDRESS_SPACE_IO, 8) |
| 775 | | |
| 776 | | AM_RANGE(0x00, 0x3f) AM_READ(tms9901_0_cru_r) /* user I/O tms9901 */ |
| 777 | | AM_RANGE(0x40, 0x6f) AM_READ(tms9901_1_cru_r) /* system I/O tms9901 */ |
| 762 | AM_RANGE(0x00, 0x3f) AM_DEVREAD(TMS9901, "tms9901_0", tms9901_cru_r) /* user I/O tms9901 */ |
| 763 | AM_RANGE(0x40, 0x6f) AM_DEVREAD(TMS9901, "tms9901_1", tms9901_cru_r) /* system I/O tms9901 */ |
| 778 | 764 | AM_RANGE(0x80, 0xcf) AM_READ(tms9902_0_cru_r) /* optional tms9902 */ |
| 779 | 765 | |
| 780 | 766 | ADDRESS_MAP_END |
| r3831 | r3832 | |
| 821 | 807 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 822 | 808 | |
| 823 | 809 | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |
| 810 | |
| 811 | MDRV_TMS9901_ADD("tms9901_0", usr9901reset_param) |
| 812 | MDRV_TMS9901_ADD("tms9901_1", sys9901reset_param) |
| 824 | 813 | MACHINE_DRIVER_END |
| 825 | 814 | |
| 826 | 815 | #define LEFT_BORDER 15 |
| r3831 | r3832 | |
| 859 | 848 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 860 | 849 | |
| 861 | 850 | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |
| 851 | |
| 852 | MDRV_TMS9901_ADD("tms9901_0", usr9901reset_param) |
| 853 | MDRV_TMS9901_ADD("tms9901_1", sys9901reset_param) |
| 862 | 854 | MACHINE_DRIVER_END |
| 863 | 855 | |
| 864 | 856 | |