25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_dreamcast_maple.c,v 1.15 2007/04/28 09:19:51 debug Exp $ |
* $Id: dev_dreamcast_maple.c,v 1.17 2007/06/15 19:11:15 debug Exp $ |
29 |
* |
* |
30 |
* Dreamcast "Maple" bus controller. |
* COMMENT: Dreamcast Maple bus controller |
31 |
* |
* |
32 |
* The Maple bus has 4 ports (A-D), and each port has up to 6 possible "units" |
* The Maple bus has 4 ports (A-D), and each port has up to 6 possible "units" |
33 |
* (where unit 0 is the main unit). Communication is done using DMA; each |
* (where unit 0 is the main unit). Communication is done using DMA; each |
538 |
|
|
539 |
DEVICE_ACCESS(dreamcast_maple) |
DEVICE_ACCESS(dreamcast_maple) |
540 |
{ |
{ |
541 |
struct dreamcast_maple_data *d = (struct dreamcast_maple_data *) extra; |
struct dreamcast_maple_data *d = extra; |
542 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
543 |
|
|
544 |
if (writeflag == MEM_WRITE) |
if (writeflag == MEM_WRITE) |
624 |
|
|
625 |
DEVINIT(dreamcast_maple) |
DEVINIT(dreamcast_maple) |
626 |
{ |
{ |
627 |
struct machine *machine = devinit->machine; |
struct dreamcast_maple_data *d; |
628 |
struct dreamcast_maple_data *d = |
|
629 |
malloc(sizeof(struct dreamcast_maple_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct dreamcast_maple_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
630 |
memset(d, 0, sizeof(struct dreamcast_maple_data)); |
memset(d, 0, sizeof(struct dreamcast_maple_data)); |
631 |
|
|
632 |
memory_device_register(machine->memory, devinit->name, |
memory_device_register(devinit->machine->memory, devinit->name, |
633 |
0x5f6c00, 0x100, dev_dreamcast_maple_access, d, DM_DEFAULT, NULL); |
0x5f6c00, 0x100, dev_dreamcast_maple_access, d, DM_DEFAULT, NULL); |
634 |
|
|
635 |
/* Devices connected to port A..D: */ |
/* Devices connected to port A..D: */ |
638 |
d->device[2] = &maple_device_keyboard; |
d->device[2] = &maple_device_keyboard; |
639 |
d->device[3] = NULL; /* TODO: &maple_device_mouse; */ |
d->device[3] = NULL; /* TODO: &maple_device_mouse; */ |
640 |
|
|
641 |
d->console_handle = console_start_slave_inputonly(machine, "maple", 1); |
d->console_handle = console_start_slave_inputonly( |
642 |
machine->main_console_handle = d->console_handle; |
devinit->machine, "maple", 1); |
643 |
|
devinit->machine->main_console_handle = d->console_handle; |
644 |
|
|
645 |
machine_add_tickfunction(devinit->machine, dev_maple_tick, d, |
machine_add_tickfunction(devinit->machine, dev_maple_tick, d, |
646 |
MAPLE_TICK_SHIFT, 0.0); |
MAPLE_TICK_SHIFT); |
647 |
|
|
648 |
return 1; |
return 1; |
649 |
} |
} |