src/mame/drivers/megadriv.c
| r9355 | r9356 | |
| 4360 | 4360 | segacd_redled = (data >> 8)&1; |
| 4361 | 4361 | segacd_greenled = (data >> 9)&1; |
| 4362 | 4362 | |
| 4363 | | //popmessage("%02x %02x",segacd_greenled,segacd_redled); |
| 4363 | popmessage("%02x %02x",segacd_greenled,segacd_redled); |
| 4364 | 4364 | } |
| 4365 | 4365 | |
| 4366 | 4366 | } |
| r9355 | r9356 | |
| 4435 | 4435 | } |
| 4436 | 4436 | } |
| 4437 | 4437 | |
| 4438 | | static void cdd_hock_irq(running_machine *machine) |
| 4438 | static void cdd_hock_irq(running_machine *machine,UINT8 dir) |
| 4439 | 4439 | { |
| 4440 | 4440 | int i,cdd_crc; |
| 4441 | 4441 | |
| 4442 | | if(segacd_cdd.ctrl & 4 && segacd_irq_mask & 0x10) // export status, check if bit 2 (HOst ClocK) and irq is enabled |
| 4442 | if((segacd_cdd.ctrl & 4 || dir) && segacd_irq_mask & 0x10) // export status, check if bit 2 (HOst ClocK) and irq is enabled |
| 4443 | 4443 | { |
| 4444 | 4444 | // TODO: this shouldn't be instant, CDD should first fill receive data. |
| 4445 | 4445 | segacd_cdd.ctrl &= 0x103; // clear HOCK flag |
| r9355 | r9356 | |
| 4474 | 4474 | { |
| 4475 | 4475 | segacd_irq_mask = data & 0x7e; |
| 4476 | 4476 | |
| 4477 | | cdd_hock_irq(space->machine); |
| 4477 | cdd_hock_irq(space->machine,0); |
| 4478 | 4478 | // check here other pending IRQs |
| 4479 | 4479 | } |
| 4480 | 4480 | |
| r9355 | r9356 | |
| 4487 | 4487 | { |
| 4488 | 4488 | segacd_cdd.ctrl = data; |
| 4489 | 4489 | |
| 4490 | | cdd_hock_irq(space->machine); |
| 4490 | cdd_hock_irq(space->machine,0); |
| 4491 | 4491 | } |
| 4492 | 4492 | |
| 4493 | 4493 | /* 68k <- CDD communication comms are 4-bit wide */ |
| r9355 | r9356 | |
| 4514 | 4514 | "Unknown 0xF" |
| 4515 | 4515 | }; |
| 4516 | 4516 | |
| 4517 | static const char *const segacd_cdd_get_toc_cmd[] = |
| 4518 | { |
| 4519 | "Get Current Position", |
| 4520 | "Get Elapsed Time of Current Track", |
| 4521 | "Get Current Track", |
| 4522 | "Get Total Length", |
| 4523 | "Get First and Last Track Number", |
| 4524 | "Get Track Addresses", |
| 4525 | "Invalid 0x6", |
| 4526 | "Invalid 0x7", |
| 4527 | "Invalid 0x8", |
| 4528 | "Invalid 0x9", |
| 4529 | "Invalid 0xA", |
| 4530 | "Invalid 0xB", |
| 4531 | "Invalid 0xC", |
| 4532 | "Invalid 0xD", |
| 4533 | "Invalid 0xE", |
| 4534 | "Invalid 0xF", |
| 4535 | }; |
| 4536 | |
| 4537 | static void segacd_cdd_get_status(running_machine *machine) |
| 4538 | { |
| 4539 | // ... |
| 4540 | |
| 4541 | cdd_hock_irq(machine,1); |
| 4542 | } |
| 4543 | |
| 4544 | static void segacd_cdd_stop_all(running_machine *machine) |
| 4545 | { |
| 4546 | // ... |
| 4547 | segacd_cdd.ctrl |= 0x100; // set data bit |
| 4548 | |
| 4549 | //cdd_hock_irq(machine,1); // doesn't work? |
| 4550 | } |
| 4551 | |
| 4552 | |
| 4553 | static void segacd_cdd_get_toc_info(running_machine *machine) |
| 4554 | { |
| 4555 | segacd_cdd.status = ((segacd_cdd_tx[3] & 0xf) << 4) | (segacd_cdd.status & 0xf); |
| 4556 | |
| 4557 | switch(segacd_cdd_tx[3] & 0xf) |
| 4558 | { |
| 4559 | default: printf("CDD: unhandled TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]); |
| 4560 | } |
| 4561 | |
| 4562 | cdd_hock_irq(machine,1); |
| 4563 | } |
| 4564 | |
| 4517 | 4565 | static WRITE8_HANDLER( segacd_cdd_tx_w ) |
| 4518 | 4566 | { |
| 4519 | 4567 | //printf("CDD Communication write %02x -> [%02x]\n",data,offset); |
| 4520 | 4568 | segacd_cdd_tx[offset] = data & 0xf; |
| 4521 | 4569 | |
| 4522 | | if(offset == 9) //execute the command when crc is sent (TODO: I wonder if we need to check if crc is valid ...) |
| 4570 | if(offset == 9) //execute the command when crc is sent (TODO: I wonder if we need to check if crc is valid. Plus obviously this shouldn't be instant) |
| 4523 | 4571 | { |
| 4524 | 4572 | switch(segacd_cdd_tx[0] & 0xf) |
| 4525 | 4573 | { |
| 4574 | case 0x0: segacd_cdd_get_status(space->machine); break; |
| 4575 | case 0x1: segacd_cdd_stop_all(space->machine); break; |
| 4576 | case 0x2: segacd_cdd_get_toc_info(space->machine); break; |
| 4526 | 4577 | default: printf("CDD: unhandled command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]); |
| 4527 | 4578 | } |
| 4528 | 4579 | } |
| r9355 | r9356 | |
| 4535 | 4586 | AM_RANGE(0x080000, 0x0bffff) AM_READWRITE(segacd_sub_dataram_part1_r, segacd_sub_dataram_part1_w) AM_BASE(&segacd_dataram) |
| 4536 | 4587 | AM_RANGE(0x0c0000, 0x0dffff) AM_READWRITE(segacd_sub_dataram_part2_r, segacd_sub_dataram_part2_w) AM_BASE(&segacd_dataram2) |
| 4537 | 4588 | |
| 4538 | | // AM_RANGE(0xfe0000, 0xfe3fff) // backup RAM, odd bytes only! |
| 4589 | AM_RANGE(0xfe0000, 0xfe3fff) AM_RAM // backup RAM, odd bytes only! |
| 4539 | 4590 | |
| 4540 | 4591 | AM_RANGE(0xff0000, 0xff7fff) AM_RAM // PCM, RF5C164 |
| 4541 | 4592 | AM_RANGE(0xff8000 ,0xff8001) AM_READWRITE(segacd_sub_led_ready_r, segacd_sub_led_ready_w) |