src/mess/includes/coco.h
| r4152 | r4153 | |
| 1 | 1 | /***************************************************************************** |
| 2 | | * |
| 3 | | * includes/coco.h |
| 4 | | * |
| 5 | | * CoCo/Dragon |
| 6 | | * |
| 7 | | ****************************************************************************/ |
| 8 | 2 | |
| 9 | | #ifndef COCO_H_ |
| 10 | | #define COCO_H_ |
| 3 | includes/coco.h |
| 11 | 4 | |
| 5 | CoCo/Dragon |
| 6 | |
| 7 | ****************************************************************************/ |
| 8 | |
| 9 | #ifndef __COCO_H__ |
| 10 | #define __COCO_H__ |
| 11 | |
| 12 | 12 | #include "devices/snapquik.h" |
| 13 | 13 | #include "machine/wd17xx.h" |
| 14 | 14 | #include "machine/6883sam.h" |
| 15 | 15 | |
| 16 | |
| 17 | /*************************************************************************** |
| 18 | CONSTANTS |
| 19 | ***************************************************************************/ |
| 20 | |
| 16 | 21 | #define COCO_CPU_SPEED_HZ 894886 /* 0.894886 MHz */ |
| 17 | 22 | #define COCO_FRAMES_PER_SECOND (COCO_CPU_SPEED_HZ / 57.0 / 263) |
| 18 | 23 | #define COCO_CPU_SPEED (ATTOTIME_IN_HZ(COCO_CPU_SPEED_HZ)) |
| 19 | 24 | #define COCO_TIMER_CMPCARRIER (COCO_CPU_SPEED * 0.25) |
| 20 | 25 | |
| 21 | 26 | |
| 27 | /*************************************************************************** |
| 28 | TYPE DEFINITIONS |
| 29 | ***************************************************************************/ |
| 30 | |
| 31 | typedef struct _coco_state coco_state; |
| 32 | struct _coco_state |
| 33 | { |
| 34 | const device_config *cartslot_device; |
| 35 | const device_config *cassette_device; |
| 36 | const device_config *bitbanger_device; |
| 37 | const device_config *printer_device; |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | /*************************************************************************** |
| 42 | PROTOTYPES |
| 43 | ***************************************************************************/ |
| 44 | |
| 22 | 45 | /*----------- defined in video/coco.c -----------*/ |
| 23 | 46 | |
| 24 | 47 | ATTR_CONST UINT8 coco_get_attributes(UINT8 c); |
| r4152 | r4153 | |
| 118 | 141 | extern const struct coco3_video_vars coco3_vidvars; |
| 119 | 142 | |
| 120 | 143 | |
| 121 | | #endif /* COCO_H_ */ |
| 144 | #endif /* __COCO_H__ */ |
src/mess/machine/coco.c
| r4152 | r4153 | |
| 455 | 455 | |
| 456 | 456 | static void pak_load_trailer(running_machine *machine, const pak_decodedtrailer *trailer) |
| 457 | 457 | { |
| 458 | | device_config *sam = (device_config*)devtag_get_device(machine, SAM6883, "sam"); |
| 458 | const device_config *sam = devtag_get_device(machine, SAM6883, "sam"); |
| 459 | 459 | cpu_set_reg(machine->cpu[0], M6809_PC, trailer->reg_pc); |
| 460 | 460 | cpu_set_reg(machine->cpu[0], M6809_X, trailer->reg_x); |
| 461 | 461 | cpu_set_reg(machine->cpu[0], M6809_Y, trailer->reg_y); |
| r4152 | r4153 | |
| 1120 | 1120 | |
| 1121 | 1121 | static const device_config *cartslot_image(running_machine *machine) |
| 1122 | 1122 | { |
| 1123 | | return devtag_get_device(machine, CARTSLOT, "cart"); |
| 1123 | coco_state *state = machine->driver_data; |
| 1124 | return state->cartslot_device; |
| 1124 | 1125 | } |
| 1125 | 1126 | |
| 1126 | 1127 | static const device_config *cassette_device_image(running_machine *machine) |
| 1127 | 1128 | { |
| 1128 | | return devtag_get_device(machine, CASSETTE, "cassette"); |
| 1129 | coco_state *state = machine->driver_data; |
| 1130 | return state->cassette_device; |
| 1129 | 1131 | } |
| 1130 | 1132 | |
| 1131 | 1133 | static const device_config *bitbanger_image(running_machine *machine) |
| 1132 | 1134 | { |
| 1133 | | return devtag_get_device(machine, BITBANGER, "bitbanger"); |
| 1135 | coco_state *state = machine->driver_data; |
| 1136 | return state->bitbanger_device; |
| 1134 | 1137 | } |
| 1135 | 1138 | |
| 1136 | 1139 | static const device_config *printer_image(running_machine *machine) |
| 1137 | 1140 | { |
| 1138 | | return devtag_get_device(machine, PRINTER, "printer"); |
| 1141 | coco_state *state = machine->driver_data; |
| 1142 | return state->printer_device; |
| 1139 | 1143 | } |
| 1140 | 1144 | |
| 1141 | 1145 | static int get_soundmux_status(void) |
| r4152 | r4153 | |
| 1215 | 1219 | |
| 1216 | 1220 | WRITE8_HANDLER ( dgnalpha_psg_porta_write ) |
| 1217 | 1221 | { |
| 1218 | | device_config *fdc = (device_config*)devtag_get_device(space->machine, WD179X, "wd179x"); |
| 1222 | const device_config *fdc = devtag_get_device(space->machine, WD179X, "wd179x"); |
| 1219 | 1223 | /* Bits 0..3 are the drive select lines for the internal floppy interface */ |
| 1220 | 1224 | /* Bit 4 is the motor on, in the real hardware these are inverted on their way to the drive */ |
| 1221 | 1225 | /* Bits 5,6,7 are connected to /DDEN, ENP and 5/8 on the WD2797 */ |
| r4152 | r4153 | |
| 1671 | 1675 | /* The Dragon Alpha hardware reverses the order of the WD2797 registers */ |
| 1672 | 1676 | READ8_HANDLER(wd2797_r) |
| 1673 | 1677 | { |
| 1674 | | device_config *fdc = (device_config*)devtag_get_device(space->machine, WD179X, "wd179x"); |
| 1678 | const device_config *fdc = devtag_get_device(space->machine, WD179X, "wd179x"); |
| 1675 | 1679 | int result = 0; |
| 1676 | 1680 | |
| 1677 | 1681 | switch(offset & 0x03) |
| r4152 | r4153 | |
| 1697 | 1701 | |
| 1698 | 1702 | WRITE8_HANDLER(wd2797_w) |
| 1699 | 1703 | { |
| 1700 | | device_config *fdc = (device_config*)devtag_get_device(space->machine, WD179X, "wd179x"); |
| 1704 | const device_config *fdc = devtag_get_device(space->machine, WD179X, "wd179x"); |
| 1701 | 1705 | switch(offset & 0x3) |
| 1702 | 1706 | { |
| 1703 | 1707 | case 0: |
| r4152 | r4153 | |
| 1937 | 1941 | |
| 1938 | 1942 | /* We need to init these vars from the sam, as this may be called from outside the sam callbacks */ |
| 1939 | 1943 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 1940 | | device_config *sam = (device_config*)devtag_get_device(space->machine, SAM6883, "sam"); |
| 1944 | const device_config *sam = devtag_get_device(space->machine, SAM6883, "sam"); |
| 1941 | 1945 | UINT8 memsize = get_sam_memorysize(sam); |
| 1942 | 1946 | UINT8 maptype = get_sam_maptype(sam); |
| 1943 | 1947 | // UINT8 pagemode = get_sam_pagemode(machine); |
| r4152 | r4153 | |
| 1990 | 1994 | if(!maptype) |
| 1991 | 1995 | { |
| 1992 | 1996 | UINT8 *cart_rom = memory_region(machine, "cart"); |
| 1997 | UINT32 cart_length = memory_region_length(machine, "cart"); |
| 1993 | 1998 | |
| 1994 | 1999 | for(block_index=0;block_index<=7;block_index++) |
| 1995 | 2000 | { |
| r4152 | r4153 | |
| 1999 | 2004 | if (block_index < 4) |
| 2000 | 2005 | offset = &bas_rom_bank[0x1000*block_index]; |
| 2001 | 2006 | else |
| 2002 | | offset = &cart_rom[(0x1000*(block_index-4))]; |
| 2007 | offset = &cart_rom[(0x1000*(block_index-4)) % cart_length]; |
| 2003 | 2008 | |
| 2004 | 2009 | memory_set_bankptr(machine, block_index + 9,offset); |
| 2005 | 2010 | memory_install_write_handler(space, memmap[block_index+8].start, memmap[block_index+8].end, 0, 0, STATIC_NOP); |
| r4152 | r4153 | |
| 2811 | 2816 | /* for everything except the coco3, so it made sense not to pass it as a parameter */ |
| 2812 | 2817 | static void generic_init_machine(running_machine *machine, const machine_init_interface *init) |
| 2813 | 2818 | { |
| 2819 | coco_state *state = (coco_state *) machine->driver_data; |
| 2814 | 2820 | coco_cartridge_config cart_config; |
| 2815 | 2821 | const device_config *cart_image; |
| 2816 | 2822 | const char *extrainfo; |
| 2817 | 2823 | const char *cart_hardware; |
| 2818 | 2824 | int i; |
| 2819 | 2825 | |
| 2826 | /* locate devices */ |
| 2827 | state->cartslot_device = devtag_get_device(machine, CARTSLOT, "cart"); |
| 2828 | state->cassette_device = devtag_get_device(machine, CASSETTE, "cassette"); |
| 2829 | state->bitbanger_device = devtag_get_device(machine, BITBANGER, "bitbanger"); |
| 2830 | state->printer_device = devtag_get_device(machine, PRINTER, "printer"); |
| 2831 | |
| 2820 | 2832 | /* clear static variables */ |
| 2821 | 2833 | coco_hiresjoy_ca = 1; |
| 2822 | 2834 | coco_hiresjoy_xtransitiontime = attotime_zero; |
src/mess/drivers/coco.c
| r4152 | r4153 | |
| 659 | 659 | MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND) |
| 660 | 660 | |
| 661 | 661 | MDRV_MACHINE_START( dragon32 ) |
| 662 | MDRV_DRIVER_DATA( coco_state ) |
| 662 | 663 | |
| 663 | 664 | /* video hardware */ |
| 664 | 665 | MDRV_VIDEO_START(dragon) |
| r4152 | r4153 | |
| 691 | 692 | MDRV_CPU_PROGRAM_MAP(d64_map, 0) |
| 692 | 693 | |
| 693 | 694 | MDRV_MACHINE_START( dragon64 ) |
| 695 | MDRV_DRIVER_DATA( coco_state ) |
| 694 | 696 | |
| 695 | 697 | /* video hardware */ |
| 696 | 698 | MDRV_VIDEO_START(dragon) |
| r4152 | r4153 | |
| 729 | 731 | MDRV_CPU_PROGRAM_MAP(d64_plus_map, 0) |
| 730 | 732 | |
| 731 | 733 | MDRV_MACHINE_START( dragon64 ) |
| 734 | MDRV_DRIVER_DATA( coco_state ) |
| 732 | 735 | |
| 733 | 736 | /* video hardware */ |
| 734 | 737 | MDRV_VIDEO_START(dragon) |
| r4152 | r4153 | |
| 767 | 770 | MDRV_CPU_PROGRAM_MAP(dgnalpha_map, 0) |
| 768 | 771 | |
| 769 | 772 | MDRV_MACHINE_START( dgnalpha ) |
| 773 | MDRV_DRIVER_DATA( coco_state ) |
| 770 | 774 | |
| 771 | 775 | /* video hardware */ |
| 772 | 776 | MDRV_VIDEO_START(dragon) |
| r4152 | r4153 | |
| 808 | 812 | MDRV_CPU_PROGRAM_MAP(d64_map, 0) |
| 809 | 813 | |
| 810 | 814 | MDRV_MACHINE_START( tanodr64 ) |
| 815 | MDRV_DRIVER_DATA( coco_state ) |
| 811 | 816 | |
| 812 | 817 | /* video hardware */ |
| 813 | 818 | MDRV_VIDEO_START(dragon) |
| r4152 | r4153 | |
| 846 | 851 | MDRV_CPU_PROGRAM_MAP(coco_map, 0) |
| 847 | 852 | |
| 848 | 853 | MDRV_MACHINE_START( coco ) |
| 854 | MDRV_DRIVER_DATA( coco_state ) |
| 849 | 855 | |
| 850 | 856 | /* video hardware */ |
| 851 | 857 | MDRV_SCREEN_ADD("main", RASTER) |
| r4152 | r4153 | |
| 886 | 892 | MDRV_CPU_PROGRAM_MAP(coco_map, 0) |
| 887 | 893 | |
| 888 | 894 | MDRV_MACHINE_START( coco2 ) |
| 895 | MDRV_DRIVER_DATA( coco_state ) |
| 889 | 896 | |
| 890 | 897 | /* video hardware */ |
| 891 | 898 | MDRV_SCREEN_ADD("main", RASTER) |
| r4152 | r4153 | |
| 926 | 933 | MDRV_CPU_PROGRAM_MAP(coco_map, 0) |
| 927 | 934 | |
| 928 | 935 | MDRV_MACHINE_START( coco2 ) |
| 936 | MDRV_DRIVER_DATA( coco_state ) |
| 929 | 937 | |
| 930 | 938 | /* video hardware */ |
| 931 | 939 | MDRV_SCREEN_ADD("main", RASTER) |
| r4152 | r4153 | |
| 967 | 975 | |
| 968 | 976 | MDRV_MACHINE_START( coco3 ) |
| 969 | 977 | MDRV_MACHINE_RESET( coco3 ) |
| 978 | MDRV_DRIVER_DATA( coco_state ) |
| 970 | 979 | |
| 971 | 980 | /* video hardware */ |
| 972 | 981 | MDRV_VIDEO_START(coco3) |