src/mess/devices/aescart.c
| r10232 | r10233 | |
| 72 | 72 | }; |
| 73 | 73 | typedef struct _aes_pcb_t aes_pcb_t; |
| 74 | 74 | |
| 75 | INLINE aes_multicart_t *get_safe_token(device_t *device) |
| 76 | { |
| 77 | assert(device != NULL); |
| 78 | assert(device->type() == AES_MULTICART); |
| 79 | |
| 80 | return (aes_multicart_t *)downcast<legacy_device_base *>(device)->token(); |
| 81 | } |
| 82 | |
| 83 | INLINE aes_pcb_t *get_safe_pcb_token(device_t *device) |
| 84 | { |
| 85 | assert(device != NULL); |
| 86 | assert(device->type() == AES_CARTRIDGE_PCB_NONE || device->type() == AES_CARTRIDGE_PCB_STD); |
| 87 | |
| 88 | return (aes_pcb_t *)downcast<legacy_device_base *>(device)->token(); |
| 89 | } |
| 90 | |
| 91 | INLINE cartslot_t *get_safe_cartslot_token(device_t *device) |
| 92 | { |
| 93 | assert(device != NULL); |
| 94 | assert(device->type() == CARTSLOT); |
| 95 | |
| 96 | return (cartslot_t *)downcast<legacy_device_base *>(device)->token(); |
| 97 | } |
| 98 | |
| 75 | 99 | /* |
| 76 | 100 | Find the index of the cartridge name. We assume the format |
| 77 | 101 | <name><number>, i.e. the number is the longest string from the right |
| r10232 | r10233 | |
| 96 | 120 | /* Pointer to the cartridge structure. */ |
| 97 | 121 | aescartridge_t *cartridge; |
| 98 | 122 | device_t *cartsys = cartslot->owner(); |
| 99 | | aes_multicart_t *cartslots = (aes_multicart_t *)downcast<legacy_device_base *>(cartsys)->token(); |
| 123 | aes_multicart_t *cartslots = get_safe_token(cartsys); |
| 100 | 124 | UINT8 *socketcont, *romrgn; |
| 101 | 125 | int reslength, i, blockofs; |
| 102 | 126 | char sprname1[16], sprname2[16]; |
| r10232 | r10233 | |
| 217 | 241 | static void set_pointers(device_t *pcb, int index) |
| 218 | 242 | { |
| 219 | 243 | device_t *cartsys = pcb->owner()->owner(); |
| 220 | | aes_multicart_t *cartslots = (aes_multicart_t *)downcast<legacy_device_base *>(cartsys)->token(); |
| 221 | | aes_pcb_t *pcb_def = (aes_pcb_t *)downcast<legacy_device_base *>(pcb)->token(); |
| 244 | aes_multicart_t *cartslots = get_safe_token(cartsys); |
| 245 | aes_pcb_t *pcb_def = get_safe_pcb_token(pcb); |
| 222 | 246 | |
| 223 | 247 | pcb_def->assemble = (assmfct *)downcast<const legacy_cart_slot_device_config_base *>(&pcb->baseconfig())->get_config_fct(AESCART_FCT_ASSM); |
| 224 | 248 | pcb_def->disassemble = (assmfct *)downcast<const legacy_cart_slot_device_config_base *>(&pcb->baseconfig())->get_config_fct(AESCART_FCT_DISASSM); |
| r10232 | r10233 | |
| 393 | 417 | */ |
| 394 | 418 | static DEVICE_START( aes_cartridge ) |
| 395 | 419 | { |
| 396 | | cartslot_t *cart = (cartslot_t *)downcast<legacy_device_base *>(device)->token(); |
| 420 | cartslot_t *cart = get_safe_cartslot_token(device); |
| 397 | 421 | |
| 398 | 422 | /* find the PCB device */ |
| 399 | 423 | cart->pcb_device = device->subdevice(TAG_PCB); |
| r10232 | r10233 | |
| 586 | 610 | fatalerror("Error loading multicart: no pcb found."); |
| 587 | 611 | |
| 588 | 612 | /* If we are here, we have a multicart. */ |
| 589 | | pcb = (aes_pcb_t *)downcast<legacy_device_base *>(pcbdev)->token(); |
| 590 | | cart = (cartslot_t *)downcast<legacy_device_base *>(&image.device())->token(); |
| 613 | pcb = get_safe_pcb_token(pcbdev); |
| 614 | cart = get_safe_cartslot_token(&image.device()); |
| 591 | 615 | |
| 592 | 616 | /* try opening this as a multicart */ |
| 593 | 617 | /* This line requires that cartslot_t be included in cartslot.h, |
| r10232 | r10233 | |
| 625 | 649 | |
| 626 | 650 | if (pcbdev != NULL) |
| 627 | 651 | { |
| 628 | | aes_pcb_t *pcb = (aes_pcb_t *)downcast<legacy_device_base *>(pcbdev)->token(); |
| 629 | | cartslot_t *cart = (cartslot_t *)downcast<legacy_device_base *>(&image.device())->token(); |
| 652 | aes_pcb_t *pcb = get_safe_pcb_token(pcbdev); |
| 653 | cartslot_t *cart = get_safe_cartslot_token(&image.device()); |
| 630 | 654 | |
| 631 | 655 | // printf("unload\n"); |
| 632 | 656 | if (cart->mc != NULL) |
| r10232 | r10233 | |
| 663 | 687 | { |
| 664 | 688 | int i; |
| 665 | 689 | // printf("DEVICE_START(aes_multicart)\n"); |
| 666 | | aes_multicart_t *cartslots = (aes_multicart_t *)downcast<legacy_device_base *>(device)->token(); |
| 690 | aes_multicart_t *cartslots = get_safe_token(device); |
| 667 | 691 | |
| 668 | 692 | /* Save this in the shortcut; we don't want to look for it each time |
| 669 | 693 | that we have a memory access. And currently we do not plan for |
src/mess/devices/xmodem.c
| r10232 | r10233 | |
| 76 | 76 | |
| 77 | 77 | } xmodem; |
| 78 | 78 | |
| 79 | INLINE xmodem *get_safe_token(device_t *device) |
| 80 | { |
| 81 | assert(device != NULL); |
| 82 | assert(device->type() == XMODEM); |
| 79 | 83 | |
| 84 | return (xmodem*)downcast<legacy_device_base *>(device)->token(); |
| 85 | } |
| 80 | 86 | |
| 81 | 87 | /* compute checksum of the data part of the packet, i.e., sum modulo 256 */ |
| 82 | 88 | static UINT8 xmodem_chksum( xmodem* state ) |
| r10232 | r10233 | |
| 162 | 168 | /* emulated machine has read the last byte we sent */ |
| 163 | 169 | void xmodem_byte_transmitted( device_t *device ) |
| 164 | 170 | { |
| 165 | | xmodem* state = (xmodem*) downcast<legacy_device_base *>(device)->token(); |
| 171 | xmodem* state = get_safe_token(device); |
| 166 | 172 | if ( (state->state == XMODEM_SENDING) && (state->pos < 132) ) |
| 167 | 173 | { |
| 168 | 174 | /* send next byte */ |
| r10232 | r10233 | |
| 173 | 179 | /* emulated machine sends a byte to the outside (us) */ |
| 174 | 180 | void xmodem_receive_byte( device_t *device, UINT8 data ) |
| 175 | 181 | { |
| 176 | | xmodem* state = (xmodem*) downcast<legacy_device_base *>(device)->token(); |
| 182 | xmodem* state = get_safe_token(device); |
| 177 | 183 | switch ( state->state ) |
| 178 | 184 | { |
| 179 | 185 | |
| r10232 | r10233 | |
| 293 | 299 | |
| 294 | 300 | static DEVICE_START( xmodem ) |
| 295 | 301 | { |
| 296 | | xmodem* state = (xmodem*) downcast<legacy_device_base *>(device)->token(); |
| 302 | xmodem* state = get_safe_token(device); |
| 297 | 303 | LOG(( "xmodem: start\n" )); |
| 298 | 304 | state->state = XMODEM_NOIMAGE; |
| 299 | 305 | state->image = NULL; |
| r10232 | r10233 | |
| 304 | 310 | |
| 305 | 311 | static DEVICE_RESET( xmodem ) |
| 306 | 312 | { |
| 307 | | xmodem* state = (xmodem*) downcast<legacy_device_base *>(device)->token(); |
| 313 | xmodem* state = get_safe_token(device); |
| 308 | 314 | LOG(( "xmodem: reset\n" )); |
| 309 | 315 | if ( state->state != XMODEM_NOIMAGE ) xmodem_make_idle( state ); |
| 310 | 316 | } |
| 311 | 317 | |
| 312 | 318 | static DEVICE_IMAGE_LOAD( xmodem ) |
| 313 | 319 | { |
| 314 | | xmodem* state = (xmodem*) downcast<legacy_device_base *>(&image.device())->token(); |
| 320 | xmodem* state = get_safe_token(&image.device()); |
| 315 | 321 | LOG(( "xmodem: image load\n" )); |
| 316 | 322 | state->image = ℑ |
| 317 | 323 | xmodem_make_idle( state ); |
| r10232 | r10233 | |
| 320 | 326 | |
| 321 | 327 | static DEVICE_IMAGE_CREATE( xmodem ) |
| 322 | 328 | { |
| 323 | | xmodem* state = (xmodem*) downcast<legacy_device_base *>(&image.device())->token(); |
| 329 | xmodem* state = get_safe_token(&image.device()); |
| 324 | 330 | LOG(( "xmodem: image create\n" )); |
| 325 | 331 | state->image = ℑ |
| 326 | 332 | xmodem_make_idle( state ); |
| r10232 | r10233 | |
| 329 | 335 | |
| 330 | 336 | static DEVICE_IMAGE_UNLOAD( xmodem ) |
| 331 | 337 | { |
| 332 | | xmodem* state = (xmodem*) downcast<legacy_device_base *>(&image.device())->token(); |
| 338 | xmodem* state = get_safe_token(&image.device()); |
| 333 | 339 | LOG(( "xmodem: image unload\n" )); |
| 334 | 340 | state->state = XMODEM_NOIMAGE; |
| 335 | 341 | state->image = NULL; |
src/mess/devices/kermit.c
| r10232 | r10233 | |
| 110 | 110 | } kermit; |
| 111 | 111 | |
| 112 | 112 | |
| 113 | INLINE kermit *get_safe_token(device_t *device) |
| 114 | { |
| 115 | assert(device != NULL); |
| 116 | assert(device->type() == KERMIT); |
| 117 | |
| 118 | return (kermit*)downcast<legacy_device_base *>(device)->token(); |
| 119 | } |
| 120 | |
| 113 | 121 | static int kermit_is_char( UINT8 data ) |
| 114 | 122 | { |
| 115 | 123 | return data >= 32 && data <= 126; |
| r10232 | r10233 | |
| 401 | 409 | /* emulated machine sends a byte to the outside (us) */ |
| 402 | 410 | void kermit_receive_byte( device_t *device, UINT8 data ) |
| 403 | 411 | { |
| 404 | | kermit* state = (kermit*) downcast<legacy_device_base *>(device)->token(); |
| 412 | kermit* state = get_safe_token(device); |
| 405 | 413 | |
| 406 | 414 | LOG(( "get %i %2x %c (%i)\n", data, data, data, state->posin )); |
| 407 | 415 | |
| r10232 | r10233 | |
| 610 | 618 | |
| 611 | 619 | void kermit_byte_transmitted( device_t *device ) |
| 612 | 620 | { |
| 613 | | kermit* state = (kermit*) downcast<legacy_device_base *>(device)->token(); |
| 621 | kermit* state = get_safe_token(device); |
| 614 | 622 | |
| 615 | 623 | LOG(( "transmitted %i %2x %c, %i / %i\n", state->pout[ state->posout-1 ], state->pout[ state->posout-1 ], state->pout[ state->posout-1 ], state->posout - 1, state->nbout - 1 )); |
| 616 | 624 | |
| r10232 | r10233 | |
| 633 | 641 | |
| 634 | 642 | static DEVICE_START( kermit ) |
| 635 | 643 | { |
| 636 | | kermit* state = (kermit*) downcast<legacy_device_base *>(device)->token(); |
| 644 | kermit* state = get_safe_token(device); |
| 637 | 645 | LOG(( "kermit: start\n" )); |
| 638 | 646 | state->image = NULL; |
| 639 | 647 | state->conf = (kermit_config*) device->baseconfig().static_config(); |
| r10232 | r10233 | |
| 644 | 652 | |
| 645 | 653 | static DEVICE_RESET( kermit ) |
| 646 | 654 | { |
| 647 | | kermit* state = (kermit*) downcast<legacy_device_base *>(device)->token(); |
| 655 | kermit* state = get_safe_token(device); |
| 648 | 656 | LOG(( "kermit: reset\n" )); |
| 649 | 657 | kermit_reset( state ); |
| 650 | 658 | } |
| 651 | 659 | |
| 652 | 660 | static DEVICE_IMAGE_LOAD( kermit ) |
| 653 | 661 | { |
| 654 | | kermit* state = (kermit*) downcast<legacy_device_base *>(&image.device())->token(); |
| 662 | kermit* state = get_safe_token(&image.device()); |
| 655 | 663 | LOG(( "kermit: image load\n" )); |
| 656 | 664 | state->image = ℑ |
| 657 | 665 | kermit_reset( state ); |
| r10232 | r10233 | |
| 660 | 668 | |
| 661 | 669 | static DEVICE_IMAGE_CREATE( kermit ) |
| 662 | 670 | { |
| 663 | | kermit* state = (kermit*) downcast<legacy_device_base *>(&image.device())->token(); |
| 671 | kermit* state = get_safe_token(&image.device()); |
| 664 | 672 | LOG(( "kermit: image create\n" )); |
| 665 | 673 | state->image = ℑ |
| 666 | 674 | kermit_reset( state ); |
| r10232 | r10233 | |
| 669 | 677 | |
| 670 | 678 | static DEVICE_IMAGE_UNLOAD( kermit ) |
| 671 | 679 | { |
| 672 | | kermit* state = (kermit*) downcast<legacy_device_base *>(&image.device())->token(); |
| 680 | kermit* state = get_safe_token(&image.device()); |
| 673 | 681 | LOG(( "kermit: image unload\n" )); |
| 674 | 682 | state->image = NULL; |
| 675 | 683 | kermit_reset( state ); |
src/mess/machine/ti99/gromport.c
| r10232 | r10233 | |
| 165 | 165 | INLINE ti99_multicart_state *get_safe_token(device_t *device) |
| 166 | 166 | { |
| 167 | 167 | assert(device != NULL); |
| 168 | assert(device->type() == TI99_MULTICART); |
| 169 | |
| 168 | 170 | return (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 169 | 171 | } |
| 170 | 172 | |
| r10232 | r10233 | |
| 172 | 174 | { |
| 173 | 175 | assert(device != NULL); |
| 174 | 176 | assert(device->type() == TI99_MULTICART); |
| 177 | |
| 175 | 178 | return (const ti99_multicart_config *) downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config(); |
| 176 | 179 | } |
| 177 | 180 | |
| 178 | 181 | INLINE ti99_pcb_t *get_safe_pcb_token(device_t *device) |
| 179 | 182 | { |
| 180 | 183 | assert(device != NULL); |
| 184 | assert(device->type() == TI99_CARTRIDGE_PCB_NONE || |
| 185 | device->type() == TI99_CARTRIDGE_PCB_STD || |
| 186 | device->type() == TI99_CARTRIDGE_PCB_PAGED || |
| 187 | device->type() == TI99_CARTRIDGE_PCB_MINIMEM || |
| 188 | device->type() == TI99_CARTRIDGE_PCB_SUPER || |
| 189 | device->type() == TI99_CARTRIDGE_PCB_MBX || |
| 190 | device->type() == TI99_CARTRIDGE_PCB_PAGED379I || |
| 191 | device->type() == TI99_CARTRIDGE_PCB_PAGEDCRU || |
| 192 | device->type() == TI99_CARTRIDGE_PCB_GRAMKRACKER); |
| 193 | |
| 181 | 194 | return (ti99_pcb_t *)downcast<legacy_device_base *>(device)->token(); |
| 182 | 195 | } |
| 183 | 196 | |
| 197 | INLINE cartslot_t *get_safe_cartslot_token(device_t *device) |
| 198 | { |
| 199 | assert(device != NULL); |
| 200 | assert(device->type() == CARTSLOT); |
| 201 | |
| 202 | return (cartslot_t *)downcast<legacy_device_base *>(device)->token(); |
| 203 | } |
| 204 | |
| 184 | 205 | static WRITE_LINE_DEVICE_HANDLER( cart_grom_ready ) |
| 185 | 206 | { |
| 186 | 207 | device_t *cartdev = device->owner()->owner(); |
| r10232 | r10233 | |
| 205 | 226 | |
| 206 | 227 | static int in_legacy_mode(device_t *device) |
| 207 | 228 | { |
| 208 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 229 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 209 | 230 | return ((cartslots->legacy_slots>0) && (cartslots->multi_slots==0)); |
| 210 | 231 | } |
| 211 | 232 | |
| r10232 | r10233 | |
| 325 | 346 | } |
| 326 | 347 | |
| 327 | 348 | // Register the GROMs |
| 328 | | pcb_def = (ti99_pcb_t *)downcast<legacy_device_base *>(pcb)->token(); |
| 349 | pcb_def = get_safe_pcb_token(pcb); |
| 329 | 350 | for (int i=0; i < 5; i++) pcb_def->grom[i]= NULL; |
| 330 | 351 | if (cartridge->grom_size > 0) pcb_def->grom[0] = pcb->subdevice("grom_3"); |
| 331 | 352 | if (cartridge->grom_size > 0x2000) pcb_def->grom[1] = pcb->subdevice("grom_4"); |
| r10232 | r10233 | |
| 340 | 361 | { |
| 341 | 362 | device_t *cartsys = pcb->owner()->owner(); |
| 342 | 363 | ti99_multicart_state *cartslots = get_safe_token(cartsys); |
| 343 | | ti99_pcb_t *pcb_def = (ti99_pcb_t *)downcast<legacy_device_base *>(pcb)->token(); |
| 364 | ti99_pcb_t *pcb_def = get_safe_pcb_token(pcb); |
| 344 | 365 | |
| 345 | 366 | pcb_def->read = (read8z_device_func)downcast<const legacy_cart_slot_device_config_base *>(&pcb->baseconfig())->get_config_fct(TI99CARTINFO_FCT_6000_R); |
| 346 | 367 | pcb_def->write = (write8_device_func)downcast<const legacy_cart_slot_device_config_base *>(&pcb->baseconfig())->get_config_fct(TI99CARTINFO_FCT_6000_W); |
| r10232 | r10233 | |
| 1432 | 1453 | */ |
| 1433 | 1454 | static DEVICE_START( ti99_cartridge ) |
| 1434 | 1455 | { |
| 1435 | | cartslot_t *cart = (cartslot_t *)downcast<legacy_device_base *>(device)->token(); |
| 1456 | cartslot_t *cart = get_safe_cartslot_token(device); |
| 1436 | 1457 | |
| 1437 | 1458 | /* find the PCB device */ |
| 1438 | 1459 | cart->pcb_device = device->subdevice(TAG_PCB); |
| r10232 | r10233 | |
| 1454 | 1475 | if (pcbdev != NULL) |
| 1455 | 1476 | { |
| 1456 | 1477 | /* If we are here, we have a multicart. */ |
| 1457 | | ti99_pcb_t *pcb = (ti99_pcb_t *)downcast<legacy_device_base *>(pcbdev)->token(); |
| 1458 | | cartslot_t *cart = (cartslot_t *)downcast<legacy_device_base *>(&image.device())->token(); |
| 1478 | ti99_pcb_t *pcb = get_safe_pcb_token(pcbdev); |
| 1479 | cartslot_t *cart = get_safe_cartslot_token(&image.device()); |
| 1459 | 1480 | |
| 1460 | 1481 | /* try opening this as a multicart */ |
| 1461 | 1482 | // This line requires that cartslot_t be included in cartslot.h, |
| r10232 | r10233 | |
| 1486 | 1507 | static DEVICE_IMAGE_UNLOAD( ti99_cartridge ) |
| 1487 | 1508 | { |
| 1488 | 1509 | device_t *pcbdev; |
| 1489 | | // ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(image.device().owner())->token(); |
| 1510 | //ti99_multicart_state *cartslots = get_safe_token(image.device().owner()); |
| 1490 | 1511 | |
| 1491 | 1512 | if (downcast<legacy_device_base *>(&image.device())->token() == NULL) |
| 1492 | 1513 | { |
| r10232 | r10233 | |
| 1499 | 1520 | |
| 1500 | 1521 | if (pcbdev != NULL) |
| 1501 | 1522 | { |
| 1502 | | ti99_pcb_t *pcb = (ti99_pcb_t *)downcast<legacy_device_base *>(pcbdev)->token(); |
| 1503 | | cartslot_t *cart = (cartslot_t *)downcast<legacy_device_base *>(&image.device())->token(); |
| 1523 | ti99_pcb_t *pcb = get_safe_pcb_token(pcbdev); |
| 1524 | cartslot_t *cart = get_safe_cartslot_token(&image.device()); |
| 1504 | 1525 | |
| 1505 | 1526 | if (cart->mc != NULL) |
| 1506 | 1527 | { |
| r10232 | r10233 | |
| 1542 | 1563 | static DEVICE_START(ti99_multicart) |
| 1543 | 1564 | { |
| 1544 | 1565 | int i; |
| 1545 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 1566 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1546 | 1567 | const ti99_multicart_config* cartconf = (const ti99_multicart_config*)get_config(device); |
| 1547 | 1568 | |
| 1548 | 1569 | cartslots->active_slot = 0; |
| r10232 | r10233 | |
| 1573 | 1594 | // However, schematics do not reveal any pin for resetting a cartridge; |
| 1574 | 1595 | // the reset line is an input used when plugging in a cartridge. |
| 1575 | 1596 | |
| 1576 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 1597 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1577 | 1598 | int slotnumber = input_port_read(device->machine, "CARTSLOT"); |
| 1578 | 1599 | cartslots->fixed_slot = slotnumber-1; /* auto = -1 */ |
| 1579 | 1600 | } |
| r10232 | r10233 | |
| 1583 | 1604 | */ |
| 1584 | 1605 | READ8Z_DEVICE_HANDLER( gromportr_rz ) |
| 1585 | 1606 | { |
| 1586 | | ti99_multicart_state *cartslots = (ti99_multicart_state *) downcast<legacy_device_base *>(device)->token(); |
| 1607 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1587 | 1608 | int slot = cartslots->active_slot; |
| 1588 | 1609 | cartridge_t *cart; |
| 1589 | 1610 | |
| r10232 | r10233 | |
| 1609 | 1630 | if (!slot_is_empty(device, slot)) |
| 1610 | 1631 | { |
| 1611 | 1632 | // printf("try it on slot %d\n", slot); |
| 1612 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(cart->pcb)->token(); |
| 1633 | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 1613 | 1634 | (*pcbdef->read)(cart->pcb, offset, value); |
| 1614 | 1635 | } |
| 1615 | 1636 | } |
| r10232 | r10233 | |
| 1619 | 1640 | */ |
| 1620 | 1641 | WRITE8_DEVICE_HANDLER( gromportr_w ) |
| 1621 | 1642 | { |
| 1622 | | ti99_multicart_state *cartslots = (ti99_multicart_state *) downcast<legacy_device_base *>(device)->token(); |
| 1643 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1623 | 1644 | int slot = cartslots->active_slot; |
| 1624 | 1645 | cartridge_t *cart; |
| 1625 | 1646 | |
| r10232 | r10233 | |
| 1639 | 1660 | |
| 1640 | 1661 | if (!slot_is_empty(device, slot)) |
| 1641 | 1662 | { |
| 1642 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(cart->pcb)->token(); |
| 1663 | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 1643 | 1664 | (*pcbdef->write)(cart->pcb, offset, data); |
| 1644 | 1665 | } |
| 1645 | 1666 | } |
| r10232 | r10233 | |
| 1651 | 1672 | { |
| 1652 | 1673 | int slot; |
| 1653 | 1674 | cartridge_t *cartridge; |
| 1654 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 1675 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1655 | 1676 | |
| 1656 | 1677 | // Set the cart slot. |
| 1657 | 1678 | // 1001 1wbb bbbb bbr0 |
| r10232 | r10233 | |
| 1694 | 1715 | { |
| 1695 | 1716 | for (int i=0; i < 5; i++) |
| 1696 | 1717 | { |
| 1697 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(cartridge->pcb)->token(); |
| 1718 | ti99_pcb_t *pcbdef = get_safe_pcb_token(cartridge->pcb); |
| 1698 | 1719 | if (pcbdef->grom[i]!=NULL) |
| 1699 | 1720 | ti99grom_w(pcbdef->grom[i], offset, data); |
| 1700 | 1721 | } |
| r10232 | r10233 | |
| 1713 | 1734 | { |
| 1714 | 1735 | int slot; |
| 1715 | 1736 | cartridge_t *cartridge; |
| 1716 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 1737 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1717 | 1738 | |
| 1718 | 1739 | // Set the cart slot. Note that the port must be adjusted for 16-bit |
| 1719 | 1740 | // systems, i.e. it should be shifted left by 1. |
| r10232 | r10233 | |
| 1758 | 1779 | { |
| 1759 | 1780 | for (int i=0; i < 5; i++) |
| 1760 | 1781 | { |
| 1761 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(cartridge->pcb)->token(); |
| 1782 | ti99_pcb_t *pcbdef = get_safe_pcb_token(cartridge->pcb); |
| 1762 | 1783 | if (pcbdef->grom[i]!=NULL) |
| 1763 | 1784 | ti99grom_rz(pcbdef->grom[i], offset, value); |
| 1764 | 1785 | } |
| r10232 | r10233 | |
| 1774 | 1795 | */ |
| 1775 | 1796 | READ8Z_DEVICE_HANDLER( gromportc_rz ) |
| 1776 | 1797 | { |
| 1777 | | ti99_multicart_state *cartslots = (ti99_multicart_state *) downcast<legacy_device_base *>(device)->token(); |
| 1798 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1778 | 1799 | cartridge_t *cart; |
| 1779 | 1800 | |
| 1780 | 1801 | int slot = cartslots->active_slot; |
| r10232 | r10233 | |
| 1798 | 1819 | |
| 1799 | 1820 | if (!slot_is_empty(device, slot)) |
| 1800 | 1821 | { |
| 1801 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(cart->pcb)->token();; |
| 1822 | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 1802 | 1823 | if (pcbdef->cruread != NULL) |
| 1803 | 1824 | (*pcbdef->cruread)(cart->pcb, offset, value); |
| 1804 | 1825 | } |
| r10232 | r10233 | |
| 1809 | 1830 | */ |
| 1810 | 1831 | WRITE8_DEVICE_HANDLER( gromportc_w ) |
| 1811 | 1832 | { |
| 1812 | | ti99_multicart_state *cartslots = (ti99_multicart_state *) downcast<legacy_device_base *>(device)->token(); |
| 1833 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1813 | 1834 | cartridge_t *cart; |
| 1814 | 1835 | |
| 1815 | 1836 | int slot = cartslots->active_slot; |
| r10232 | r10233 | |
| 1833 | 1854 | |
| 1834 | 1855 | if (!slot_is_empty(device, slot)) |
| 1835 | 1856 | { |
| 1836 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(cart->pcb)->token();; |
| 1857 | ti99_pcb_t *pcbdef = get_safe_pcb_token(cart->pcb); |
| 1837 | 1858 | if (pcbdef->cruwrite != NULL) |
| 1838 | 1859 | (*pcbdef->cruwrite)(cart->pcb, offset, data); |
| 1839 | 1860 | } |
| r10232 | r10233 | |
| 1913 | 1934 | { |
| 1914 | 1935 | for (int i=0; i < 5; i++) |
| 1915 | 1936 | { |
| 1916 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(gkguestcart->pcb)->token(); |
| 1937 | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 1917 | 1938 | if (pcbdef->grom[i]!=NULL) |
| 1918 | 1939 | { |
| 1919 | 1940 | ti99grom_rz(pcbdef->grom[i], 0x9800, value); |
| r10232 | r10233 | |
| 1993 | 2014 | // gk_slot is the slot where the GK module is plugged in |
| 1994 | 2015 | // gk_guest_slot is the slot where the cartridge is plugged in |
| 1995 | 2016 | cartridge_t *gromkrackerbox, *gkguestcart; |
| 1996 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 2017 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 1997 | 2018 | |
| 1998 | 2019 | gromkrackerbox = &cartslots->cartridge[cartslots->gk_slot]; |
| 1999 | 2020 | |
| r10232 | r10233 | |
| 2006 | 2027 | return; |
| 2007 | 2028 | } |
| 2008 | 2029 | // printf("accessing cartridge in slot %d\n", slot); |
| 2009 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(gkguestcart->pcb)->token(); |
| 2030 | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 2010 | 2031 | // printf("address=%lx, offset=%lx\n", pcbdef, offset); |
| 2011 | 2032 | (*pcbdef->read)(gkguestcart->pcb, offset, value); |
| 2012 | 2033 | return; |
| r10232 | r10233 | |
| 2048 | 2069 | // gk_slot is the slot where the GK module is plugged in |
| 2049 | 2070 | // gk_guest_slot is the slot where the cartridge is plugged in |
| 2050 | 2071 | cartridge_t *gromkrackerbox, *gkguestcart; |
| 2051 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 2072 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2052 | 2073 | |
| 2053 | 2074 | gromkrackerbox = &cartslots->cartridge[cartslots->gk_slot]; |
| 2054 | 2075 | |
| r10232 | r10233 | |
| 2061 | 2082 | return; |
| 2062 | 2083 | } |
| 2063 | 2084 | |
| 2064 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(gkguestcart->pcb)->token(); |
| 2085 | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 2065 | 2086 | (*pcbdef->write)(gkguestcart->pcb, offset, data); |
| 2066 | 2087 | } |
| 2067 | 2088 | else |
| r10232 | r10233 | |
| 2094 | 2115 | */ |
| 2095 | 2116 | static READ8Z_DEVICE_HANDLER( ti99_cart_cru_gk_rz ) |
| 2096 | 2117 | { |
| 2097 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 2118 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2098 | 2119 | cartridge_t *gkguestcart; |
| 2099 | 2120 | |
| 2100 | 2121 | if (cartslots->gk_guest_slot != -1) |
| 2101 | 2122 | { |
| 2102 | 2123 | gkguestcart = &cartslots->cartridge[cartslots->gk_guest_slot]; |
| 2103 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(gkguestcart->pcb)->token(); |
| 2124 | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 2104 | 2125 | if (pcbdef->cruread != NULL) |
| 2105 | 2126 | (*pcbdef->cruread)(gkguestcart->pcb, offset, value); |
| 2106 | 2127 | } |
| r10232 | r10233 | |
| 2111 | 2132 | */ |
| 2112 | 2133 | static WRITE8_DEVICE_HANDLER( ti99_cart_cru_gk_w ) |
| 2113 | 2134 | { |
| 2114 | | ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(device)->token(); |
| 2135 | ti99_multicart_state *cartslots = get_safe_token(device); |
| 2115 | 2136 | cartridge_t *gkguestcart; |
| 2116 | 2137 | |
| 2117 | 2138 | if (cartslots->gk_guest_slot != -1) |
| 2118 | 2139 | { |
| 2119 | 2140 | gkguestcart = &cartslots->cartridge[cartslots->gk_guest_slot]; |
| 2120 | | ti99_pcb_t *pcbdef = (ti99_pcb_t *)downcast<legacy_device_base *>(gkguestcart->pcb)->token(); |
| 2141 | ti99_pcb_t *pcbdef = get_safe_pcb_token(gkguestcart->pcb); |
| 2121 | 2142 | if (pcbdef->cruwrite != NULL) |
| 2122 | 2143 | (*pcbdef->cruwrite)(gkguestcart->pcb, offset, data); |
| 2123 | 2144 | } |
src/mess/machine/ti99/ti99_hd.c
| r10232 | r10233 | |
| 28 | 28 | int id_index; /* position in track for seeking the sector; counts the sector number */ |
| 29 | 29 | } mfmhd_state, idehd_state; |
| 30 | 30 | |
| 31 | INLINE mfmhd_state *get_safe_token(device_t *device) |
| 32 | { |
| 33 | assert(device != NULL); |
| 34 | assert(device->type() == MFMHD || device->type() == IDEHD); |
| 35 | |
| 36 | return (mfmhd_state *)downcast<legacy_device_base *>(device)->token(); |
| 37 | } |
| 38 | |
| 31 | 39 | #if 0 |
| 32 | 40 | static void dump_contents(UINT8 *buffer, int length) |
| 33 | 41 | { |
| r10232 | r10233 | |
| 70 | 78 | void ti99_mfm_harddisk_read_sector(device_t *harddisk, int cylinder, int head, int sector, UINT8 **buf, int *sector_length) |
| 71 | 79 | { |
| 72 | 80 | UINT32 lba; |
| 73 | | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 81 | mfmhd_state *hd = get_safe_token(harddisk); |
| 74 | 82 | device_t *drive = harddisk->subdevice("drive"); |
| 75 | 83 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 76 | 84 | |
| r10232 | r10233 | |
| 106 | 114 | void ti99_mfm_harddisk_write_sector(device_t *harddisk, int cylinder, int head, int sector, UINT8 *buf, int sector_length) |
| 107 | 115 | { |
| 108 | 116 | UINT32 lba; |
| 109 | | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 117 | mfmhd_state *hd = get_safe_token(harddisk); |
| 110 | 118 | device_t *drive = harddisk->subdevice("drive"); |
| 111 | 119 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 112 | 120 | |
| r10232 | r10233 | |
| 171 | 179 | */ |
| 172 | 180 | void ti99_mfm_harddisk_read_track(device_t *harddisk, int head, UINT8 **pbuffer, int *data_count) |
| 173 | 181 | { |
| 174 | | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 182 | mfmhd_state *hd = get_safe_token(harddisk); |
| 175 | 183 | device_t *drive = harddisk->subdevice("drive"); |
| 176 | 184 | |
| 177 | 185 | /* We assume an interleave of 3 for 32 sectors. */ |
| r10232 | r10233 | |
| 306 | 314 | int sync = 13; |
| 307 | 315 | |
| 308 | 316 | UINT32 lba; |
| 309 | | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 317 | mfmhd_state *hd = get_safe_token(harddisk); |
| 310 | 318 | device_t *drive = harddisk->subdevice("drive"); |
| 311 | 319 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 312 | 320 | |
| r10232 | r10233 | |
| 409 | 417 | { |
| 410 | 418 | UINT8 status = 0; |
| 411 | 419 | device_t *drive; |
| 412 | | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 420 | mfmhd_state *hd = get_safe_token(harddisk); |
| 413 | 421 | drive = harddisk->subdevice("drive"); |
| 414 | 422 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 415 | 423 | |
| r10232 | r10233 | |
| 432 | 440 | void ti99_mfm_harddisk_seek(device_t *harddisk, int direction) |
| 433 | 441 | { |
| 434 | 442 | device_t *drive = harddisk->subdevice("drive"); |
| 435 | | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 443 | mfmhd_state *hd = get_safe_token(harddisk); |
| 436 | 444 | const hard_disk_info *info; |
| 437 | 445 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 438 | 446 | |
| r10232 | r10233 | |
| 459 | 467 | void ti99_mfm_harddisk_get_next_id(device_t *harddisk, int head, chrn_id_hd *id) |
| 460 | 468 | { |
| 461 | 469 | device_t *drive = harddisk->subdevice("drive"); |
| 462 | | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 470 | mfmhd_state *hd = get_safe_token(harddisk); |
| 463 | 471 | const hard_disk_info *info; |
| 464 | 472 | hard_disk_file *file; |
| 465 | 473 | int interleave = 3; |
src/mess/machine/rp5c15.c
| r10232 | r10233 | |
| 111 | 111 | void (*timer_fired_func)(int state); |
| 112 | 112 | void (*alarm_callback)(running_machine *machine, int state); |
| 113 | 113 | const rp5c15_intf* intf; |
| 114 | emu_timer* timer; |
| 114 | 115 | }; // Ricoh RP5C15 |
| 115 | 116 | |
| 116 | | static emu_timer* rtc_timer; |
| 117 | | |
| 118 | 117 | static void rtc_add_second(device_t*); |
| 119 | 118 | static void rtc_add_minute(device_t*); |
| 120 | 119 | static void rtc_add_day(device_t*); |
| 121 | 120 | static void rtc_add_month(device_t*); |
| 122 | 121 | |
| 122 | INLINE rp5c15_t *get_safe_token(device_t *device) |
| 123 | { |
| 124 | assert(device != NULL); |
| 125 | assert(device->type() == RP5C15); |
| 126 | |
| 127 | return (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 128 | } |
| 129 | |
| 123 | 130 | static TIMER_CALLBACK(rtc_alarm_pulse) |
| 124 | 131 | { |
| 125 | 132 | device_t* device = (device_t*)ptr; |
| 126 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 133 | rp5c15_t* rtc = get_safe_token(device); |
| 127 | 134 | |
| 128 | 135 | if(rtc->pulse16_state == 0) // low |
| 129 | 136 | { |
| r10232 | r10233 | |
| 149 | 156 | |
| 150 | 157 | static DEVICE_START( rp5c15 ) |
| 151 | 158 | { |
| 152 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 159 | rp5c15_t* rtc = get_safe_token(device); |
| 153 | 160 | system_time systm; |
| 154 | 161 | |
| 155 | 162 | rtc->intf = (const rp5c15_intf*)device->baseconfig().static_config(); |
| r10232 | r10233 | |
| 186 | 193 | rtc->test = 0x00; |
| 187 | 194 | rtc->pulse_count = 0; |
| 188 | 195 | |
| 189 | | rtc_timer = timer_alloc(device->machine, rtc_alarm_pulse, (void*)device); |
| 190 | | timer_adjust_periodic(rtc_timer, attotime_zero, 0, ATTOTIME_IN_HZ(32)); |
| 196 | rtc->timer = timer_alloc(device->machine, rtc_alarm_pulse, (void*)device); |
| 197 | timer_adjust_periodic(rtc->timer, attotime_zero, 0, ATTOTIME_IN_HZ(32)); |
| 191 | 198 | } |
| 192 | 199 | |
| 193 | 200 | static int rp5c15_read(device_t* device, int offset, UINT16 mem_mask) |
| 194 | 201 | { |
| 195 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 202 | rp5c15_t* rtc = get_safe_token(device); |
| 196 | 203 | if((rtc->mode & 0x01) == 0x00) // BANK 0 selected |
| 197 | 204 | { |
| 198 | 205 | switch(offset) |
| r10232 | r10233 | |
| 264 | 271 | |
| 265 | 272 | static void rp5c15_write(device_t* device, int offset, int data, UINT16 mem_mask) |
| 266 | 273 | { |
| 267 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 274 | rp5c15_t* rtc = get_safe_token(device); |
| 268 | 275 | if(offset == 13) |
| 269 | 276 | { |
| 270 | 277 | rtc->mode = data & 0x0f; |
| r10232 | r10233 | |
| 359 | 366 | |
| 360 | 367 | static void rtc_add_second(device_t* device) // add one second to current time |
| 361 | 368 | { |
| 362 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 369 | rp5c15_t* rtc = get_safe_token(device); |
| 363 | 370 | |
| 364 | 371 | if((rtc->mode & 0x08) == 0x00) // if timer is not enabled |
| 365 | 372 | return; |
| r10232 | r10233 | |
| 376 | 383 | |
| 377 | 384 | static void rtc_add_minute(device_t* device) |
| 378 | 385 | { |
| 379 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 386 | rp5c15_t* rtc = get_safe_token(device); |
| 380 | 387 | |
| 381 | 388 | rtc->systime.min_1++; |
| 382 | 389 | if(rtc->systime.min_1 < 10) |
| r10232 | r10233 | |
| 401 | 408 | |
| 402 | 409 | static void rtc_add_day(device_t* device) |
| 403 | 410 | { |
| 404 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 411 | rp5c15_t* rtc = get_safe_token(device); |
| 405 | 412 | int d,m; |
| 406 | 413 | |
| 407 | 414 | rtc->systime.dayofweek++; |
| r10232 | r10233 | |
| 469 | 476 | |
| 470 | 477 | static void rtc_add_month(device_t* device) |
| 471 | 478 | { |
| 472 | | rp5c15_t* rtc = (rp5c15_t*)downcast<legacy_device_base *>(device)->token(); |
| 479 | rp5c15_t* rtc = get_safe_token(device); |
| 473 | 480 | |
| 474 | 481 | rtc->systime.month_1++; |
| 475 | 482 | if(rtc->systime.month_1 < 10 && rtc->systime.month_10 < 1) |
src/mess/machine/hd63450.c
| r10232 | r10233 | |
| 32 | 32 | typedef struct _hd63450_t hd63450_t; |
| 33 | 33 | struct _hd63450_t |
| 34 | 34 | { |
| 35 | | hd63450_regs reg[4]; |
| 35 | hd63450_regs reg[4]; |
| 36 | 36 | emu_timer* timer[4]; // for timing data reading/writing each channel |
| 37 | 37 | attotime clock[4]; |
| 38 | 38 | attotime burst_clock[4]; |
| r10232 | r10233 | |
| 48 | 48 | static void dma_transfer_continue(device_t* device, int channel); |
| 49 | 49 | static void dma_transfer_start(device_t* device, int channel, int dir); |
| 50 | 50 | |
| 51 | INLINE hd63450_t *get_safe_token(device_t *device) |
| 52 | { |
| 53 | assert(device != NULL); |
| 54 | assert(device->type() == HD63450); |
| 55 | |
| 56 | return (hd63450_t *)downcast<legacy_device_base *>(device)->token(); |
| 57 | } |
| 58 | |
| 51 | 59 | static DEVICE_START(hd63450) |
| 52 | 60 | { |
| 53 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 61 | hd63450_t* dmac = get_safe_token(device); |
| 54 | 62 | int x; |
| 55 | 63 | |
| 56 | 64 | dmac->intf = (const hd63450_intf*)device->baseconfig().static_config(); |
| r10232 | r10233 | |
| 69 | 77 | int hd63450_read(device_t* device, int offset, UINT16 mem_mask) |
| 70 | 78 | { |
| 71 | 79 | int channel,reg; |
| 72 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 80 | hd63450_t* dmac = get_safe_token(device); |
| 73 | 81 | |
| 74 | 82 | channel = (offset & 0x60) >> 5; |
| 75 | 83 | reg = offset & 0x1f; |
| r10232 | r10233 | |
| 120 | 128 | { |
| 121 | 129 | int channel,reg; |
| 122 | 130 | |
| 123 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 131 | hd63450_t* dmac = get_safe_token(device); |
| 124 | 132 | |
| 125 | 133 | channel = (offset & 0x60) >> 5; |
| 126 | 134 | reg = offset & 0x1f; |
| r10232 | r10233 | |
| 232 | 240 | static void dma_transfer_start(device_t* device, int channel, int dir) |
| 233 | 241 | { |
| 234 | 242 | address_space *space = cpu_get_address_space(device->machine->firstcpu, ADDRESS_SPACE_PROGRAM); |
| 235 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 243 | hd63450_t* dmac = get_safe_token(device); |
| 236 | 244 | dmac->in_progress[channel] = 1; |
| 237 | 245 | dmac->reg[channel].csr &= ~0xe0; |
| 238 | 246 | dmac->reg[channel].csr |= 0x08; // Channel active |
| r10232 | r10233 | |
| 263 | 271 | |
| 264 | 272 | void hd63450_set_timer(device_t* device, int channel, attotime tm) |
| 265 | 273 | { |
| 266 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 274 | hd63450_t* dmac = get_safe_token(device); |
| 267 | 275 | |
| 268 | 276 | dmac->clock[channel] = tm; |
| 269 | 277 | if(dmac->in_progress[channel] != 0) |
| r10232 | r10233 | |
| 277 | 285 | |
| 278 | 286 | static void dma_transfer_abort(device_t* device, int channel) |
| 279 | 287 | { |
| 280 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 288 | hd63450_t* dmac = get_safe_token(device); |
| 281 | 289 | |
| 282 | 290 | logerror("DMA#%i: Transfer aborted\n",channel); |
| 283 | 291 | timer_adjust_oneshot(dmac->timer[channel], attotime_zero, 0); |
| r10232 | r10233 | |
| 289 | 297 | |
| 290 | 298 | static void dma_transfer_halt(device_t* device, int channel) |
| 291 | 299 | { |
| 292 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 300 | hd63450_t* dmac = get_safe_token(device); |
| 293 | 301 | |
| 294 | 302 | dmac->halted[channel] = 1; |
| 295 | 303 | timer_adjust_oneshot(dmac->timer[channel], attotime_zero, 0); |
| r10232 | r10233 | |
| 297 | 305 | |
| 298 | 306 | static void dma_transfer_continue(device_t* device, int channel) |
| 299 | 307 | { |
| 300 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 308 | hd63450_t* dmac = get_safe_token(device); |
| 301 | 309 | |
| 302 | 310 | if(dmac->halted[channel] != 0) |
| 303 | 311 | { |
| r10232 | r10233 | |
| 311 | 319 | address_space *space = cpu_get_address_space(device->machine->firstcpu, ADDRESS_SPACE_PROGRAM); |
| 312 | 320 | int data; |
| 313 | 321 | int datasize = 1; |
| 314 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 322 | hd63450_t* dmac = get_safe_token(device); |
| 315 | 323 | |
| 316 | 324 | if(dmac->in_progress[x] != 0) // DMA in progress in channel x |
| 317 | 325 | { |
| r10232 | r10233 | |
| 443 | 451 | |
| 444 | 452 | int hd63450_get_vector(device_t* device, int channel) |
| 445 | 453 | { |
| 446 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 454 | hd63450_t* dmac = get_safe_token(device); |
| 447 | 455 | return dmac->reg[channel].niv; |
| 448 | 456 | } |
| 449 | 457 | |
| 450 | 458 | int hd63450_get_error_vector(device_t* device, int channel) |
| 451 | 459 | { |
| 452 | | hd63450_t* dmac = (hd63450_t*)downcast<legacy_device_base *>(device)->token(); |
| 460 | hd63450_t* dmac = get_safe_token(device); |
| 453 | 461 | return dmac->reg[channel].eiv; |
| 454 | 462 | } |
| 455 | 463 | |