src/mess/machine/ncr5380.c
| r3906 | r3907 | |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | #include "driver.h" |
| 24 | | #include "deprecat.h" |
| 25 | 24 | #include "ncr5380.h" |
| 26 | 25 | |
| 27 | 26 | #define VERBOSE (0) |
| r3906 | r3907 | |
| 360 | 359 | return rv; |
| 361 | 360 | } |
| 362 | 361 | |
| 363 | | void ncr5380_init( const struct NCR5380interface *interface ) |
| 362 | void ncr5380_init( running_machine *machine, const struct NCR5380interface *interface ) |
| 364 | 363 | { |
| 365 | 364 | int i; |
| 366 | 365 | |
| r3906 | r3907 | |
| 376 | 375 | SCSIAllocInstance( interface->scsidevs->devices[i].scsiClass, &devices[interface->scsidevs->devices[i].scsiID], interface->scsidevs->devices[i].diskregion ); |
| 377 | 376 | } |
| 378 | 377 | |
| 379 | | state_save_register_item_array(Machine, "ncr5380", NULL, 0, n5380_Registers); |
| 380 | | state_save_register_item_array(Machine, "ncr5380", NULL, 0, n5380_Command); |
| 381 | | state_save_register_item_array(Machine, "ncr5380", NULL, 0, n5380_Data); |
| 382 | | state_save_register_item(Machine, "ncr5380", NULL, 0, last_id); |
| 383 | | state_save_register_item(Machine, "ncr5380", NULL, 0, cmd_ptr); |
| 384 | | state_save_register_item(Machine, "ncr5380", NULL, 0, d_ptr); |
| 385 | | state_save_register_item(Machine, "ncr5380", NULL, 0, d_limit); |
| 378 | state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Registers); |
| 379 | state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Command); |
| 380 | state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Data); |
| 381 | state_save_register_item(machine, "ncr5380", NULL, 0, last_id); |
| 382 | state_save_register_item(machine, "ncr5380", NULL, 0, cmd_ptr); |
| 383 | state_save_register_item(machine, "ncr5380", NULL, 0, d_ptr); |
| 384 | state_save_register_item(machine, "ncr5380", NULL, 0, d_limit); |
| 386 | 385 | } |
| 387 | 386 | |
| 388 | 387 | void ncr5380_exit( const struct NCR5380interface *interface ) |
src/mess/machine/coco.c
| r3906 | r3907 | |
| 82 | 82 | #include <assert.h> |
| 83 | 83 | |
| 84 | 84 | #include "driver.h" |
| 85 | | #include "deprecat.h" |
| 86 | 85 | #include "cpu/m6809/m6809.h" |
| 87 | 86 | #include "machine/6821pia.h" |
| 88 | 87 | #include "includes/coco.h" |
| r3906 | r3907 | |
| 136 | 135 | static void d_pia0_irq_b(running_machine *machine, int state); |
| 137 | 136 | static void d_pia1_firq_a(running_machine *machine, int state); |
| 138 | 137 | static void d_pia1_firq_b(running_machine *machine, int state); |
| 139 | | static void d_sam_set_pageonemode(int val); |
| 140 | | static void d_sam_set_mpurate(int val); |
| 141 | | static void d_sam_set_memorysize(int val); |
| 142 | | static void d_sam_set_maptype(int val); |
| 138 | static void d_sam_set_pageonemode(running_machine *machine,int val); |
| 139 | static void d_sam_set_mpurate(running_machine *machine,int val); |
| 140 | static void d_sam_set_memorysize(running_machine *machine,int val); |
| 141 | static void d_sam_set_maptype(running_machine *machine,int val); |
| 143 | 142 | static void coco_setcartline(running_machine *machine, coco_cartridge *cartridge, cococart_line line, cococart_line_value value); |
| 144 | 143 | static void twiddle_cart_line_if_q(running_machine *machine); |
| 145 | 144 | |
| r3906 | r3907 | |
| 160 | 159 | static void coco3_pia0_irq_b(running_machine *machine, int state); |
| 161 | 160 | static void coco3_pia1_firq_a(running_machine *machine, int state); |
| 162 | 161 | static void coco3_pia1_firq_b(running_machine *machine, int state); |
| 163 | | static void coco3_sam_set_maptype(int val); |
| 164 | | static const UINT8 *coco3_sam_get_rambase(void); |
| 162 | static void coco3_sam_set_maptype(running_machine *machine, int val); |
| 163 | static const UINT8 *coco3_sam_get_rambase(running_machine *machine); |
| 165 | 164 | |
| 166 | 165 | /* Dragon 32 specific */ |
| 167 | 166 | static READ8_HANDLER ( d_pia1_pb_r_dragon32 ); |
| r3906 | r3907 | |
| 497 | 496 | * access that bit or or whether it is something else. So that is why |
| 498 | 497 | * I am specifying 0x7fff instead of 0xffff here |
| 499 | 498 | */ |
| 500 | | sam_set_state(trailer->sam, 0x7fff); |
| 499 | sam_set_state(machine, trailer->sam, 0x7fff); |
| 501 | 500 | } |
| 502 | 501 | |
| 503 | 502 | static int generic_pak_load(const device_config *image, int rambase_index, int rombase_index, int pakbase_index) |
| r3906 | r3907 | |
| 1458 | 1457 | } |
| 1459 | 1458 | |
| 1460 | 1459 | /* Printer output functions used by d_pia1_pa_w */ |
| 1461 | | static void (*printer_out)(int data); |
| 1460 | static void (*printer_out)(running_machine *machine, int data); |
| 1462 | 1461 | |
| 1463 | 1462 | /* Printer output for the CoCo, output to bitbanger port */ |
| 1464 | | static void printer_out_coco(int data) |
| 1463 | static void printer_out_coco(running_machine *machine, int data) |
| 1465 | 1464 | { |
| 1466 | | bitbanger_output(bitbanger_image(Machine), (data & 2) >> 1); |
| 1465 | bitbanger_output(bitbanger_image(machine), (data & 2) >> 1); |
| 1467 | 1466 | } |
| 1468 | 1467 | |
| 1469 | 1468 | /* Printer output for the Dragon, output to Paralel port */ |
| 1470 | | static void printer_out_dragon(int data) |
| 1469 | static void printer_out_dragon(running_machine *machine, int data) |
| 1471 | 1470 | { |
| 1472 | 1471 | /* If strobe bit is high send data from pia0 port b to dragon parallel printer */ |
| 1473 | 1472 | if (data & 0x02) |
| 1474 | 1473 | { |
| 1475 | | printer_output(printer_image(Machine), pia_get_output_b(0)); |
| 1474 | printer_output(printer_image(machine), pia_get_output_b(0)); |
| 1476 | 1475 | } |
| 1477 | 1476 | } |
| 1478 | 1477 | |
| r3906 | r3907 | |
| 1543 | 1542 | |
| 1544 | 1543 | /* Handle printer output, serial for CoCos, Paralell for Dragons */ |
| 1545 | 1544 | |
| 1546 | | printer_out(data); |
| 1545 | printer_out(space->machine, data); |
| 1547 | 1546 | } |
| 1548 | 1547 | |
| 1549 | 1548 | /* |
| r3906 | r3907 | |
| 1868 | 1867 | Misc |
| 1869 | 1868 | ***************************************************************************/ |
| 1870 | 1869 | |
| 1871 | | static void d_sam_set_mpurate(int val) |
| 1870 | static void d_sam_set_mpurate(running_machine *machine, int val) |
| 1872 | 1871 | { |
| 1873 | 1872 | /* The infamous speed up poke. |
| 1874 | 1873 | * |
| r3906 | r3907 | |
| 1892 | 1891 | * TODO: Make the overclock more accurate. In dual speed, ROM was a fast |
| 1893 | 1892 | * access but RAM was not. I don't know how to simulate this. |
| 1894 | 1893 | */ |
| 1895 | | cpu_set_clockscale(Machine->cpu[0], val ? 2 : 1); |
| 1894 | cpu_set_clockscale(machine->cpu[0], val ? 2 : 1); |
| 1896 | 1895 | } |
| 1897 | 1896 | |
| 1898 | 1897 | READ8_HANDLER(dragon_alpha_mapped_irq_r) |
| r3906 | r3907 | |
| 1953 | 1952 | |
| 1954 | 1953 | /* We need to init these vars from the sam, as this may be called from outside the sam callbacks */ |
| 1955 | 1954 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 1956 | | UINT8 memsize = get_sam_memorysize(); |
| 1957 | | UINT8 maptype = get_sam_maptype(); |
| 1958 | | // UINT8 pagemode = get_sam_pagemode(); |
| 1955 | UINT8 memsize = get_sam_memorysize(machine); |
| 1956 | UINT8 maptype = get_sam_maptype(machine); |
| 1957 | // UINT8 pagemode = get_sam_pagemode(machine); |
| 1959 | 1958 | int last_ram_block; /* Last block that will be RAM, dependent on maptype */ |
| 1960 | 1959 | int block_index; /* Index of block being processed */ |
| 1961 | 1960 | int wbank; /* bank no to go in this block */ |
| r3906 | r3907 | |
| 2021 | 2020 | } |
| 2022 | 2021 | |
| 2023 | 2022 | |
| 2024 | | static void d_sam_set_pageonemode(int val) |
| 2023 | static void d_sam_set_pageonemode(running_machine *machine, int val) |
| 2025 | 2024 | { |
| 2026 | 2025 | /* Page mode - allowed switching between the low 32k and the high 32k, |
| 2027 | 2026 | * assuming that 64k wasn't enabled |
| r3906 | r3907 | |
| 2030 | 2029 | * this (it probably ignored it) |
| 2031 | 2030 | */ |
| 2032 | 2031 | |
| 2033 | | if (!get_sam_maptype()) // Ignored in maptype 1 |
| 2032 | if (!get_sam_maptype(machine)) // Ignored in maptype 1 |
| 2034 | 2033 | { |
| 2035 | 2034 | if((mess_ram_size>0x8000) && val) |
| 2036 | 2035 | bottom_32k=&mess_ram[0x8000]; |
| 2037 | 2036 | else |
| 2038 | 2037 | bottom_32k=mess_ram; |
| 2039 | 2038 | |
| 2040 | | setup_memory_map(Machine); |
| 2039 | setup_memory_map(machine); |
| 2041 | 2040 | } |
| 2042 | 2041 | } |
| 2043 | 2042 | |
| 2044 | | static void d_sam_set_memorysize(int val) |
| 2043 | static void d_sam_set_memorysize(running_machine *machine, int val) |
| 2045 | 2044 | { |
| 2046 | 2045 | /* Memory size - allowed restricting memory accesses to something less than |
| 2047 | 2046 | * 32k |
| r3906 | r3907 | |
| 2067 | 2066 | * TODO: Verify that the CoCo 3 ignored this |
| 2068 | 2067 | */ |
| 2069 | 2068 | |
| 2070 | | setup_memory_map(Machine); |
| 2069 | setup_memory_map(machine); |
| 2071 | 2070 | } |
| 2072 | 2071 | |
| 2073 | 2072 | |
| r3906 | r3907 | |
| 2163 | 2162 | /* way as the CoCo 1/2 and Dragon 32, this now has been reduced to a call to */ |
| 2164 | 2163 | /* setup_memory_map() - 2007-01-02 phs. */ |
| 2165 | 2164 | |
| 2166 | | static void d_sam_set_maptype(int val) |
| 2165 | static void d_sam_set_maptype(running_machine *machine,int val) |
| 2167 | 2166 | { |
| 2168 | 2167 | if(val) |
| 2169 | 2168 | bottom_32k=mess_ram; // Always reset, when in maptype 1 |
| 2170 | 2169 | |
| 2171 | | setup_memory_map(Machine); |
| 2170 | setup_memory_map(machine); |
| 2172 | 2171 | } |
| 2173 | 2172 | |
| 2174 | 2173 | /************************************* |
| r3906 | r3907 | |
| 2570 | 2569 | |
| 2571 | 2570 | |
| 2572 | 2571 | |
| 2573 | | static const UINT8 *coco3_sam_get_rambase(void) |
| 2572 | static const UINT8 *coco3_sam_get_rambase(running_machine *machine) |
| 2574 | 2573 | { |
| 2575 | 2574 | UINT32 video_base; |
| 2576 | 2575 | video_base = coco3_get_video_base(0xE0, 0x3F); |
| r3906 | r3907 | |
| 2580 | 2579 | |
| 2581 | 2580 | |
| 2582 | 2581 | |
| 2583 | | static void coco3_sam_set_maptype(int val) |
| 2582 | static void coco3_sam_set_maptype(running_machine *machine,int val) |
| 2584 | 2583 | { |
| 2585 | 2584 | coco3_enable_64k = val; |
| 2586 | | coco3_mmu_update(Machine, 4, 8); |
| 2585 | coco3_mmu_update(machine, 4, 8); |
| 2587 | 2586 | } |
| 2588 | 2587 | |
| 2589 | 2588 | |
| r3906 | r3907 | |
| 2826 | 2825 | const pia6821_interface *piaintf; /* PIA initializer */ |
| 2827 | 2826 | int piaintf_count; /* PIA count */ |
| 2828 | 2827 | timer_fired_func recalc_interrupts_; /* recalculate inturrupts callback */ |
| 2829 | | void (*printer_out_)(int data); /* printer output callback */ |
| 2828 | void (*printer_out_)(running_machine *machine, int data); /* printer output callback */ |
| 2830 | 2829 | timer_fired_func cart_timer_proc; /* cartridge timer proc */ |
| 2831 | 2830 | const char *fdc_cart_hardware; /* normal cartridge hardware */ |
| 2832 | 2831 | void (*map_memory)(running_machine *machine, coco_cartridge *cartridge, UINT32 offset, UINT32 mask); |
src/mess/machine/6883sam.c
| r3906 | r3907 | |
| 93 | 93 | |
| 94 | 94 | static void sam_reset(running_machine *machine); |
| 95 | 95 | |
| 96 | | static void update_sam(void) |
| 96 | static void update_sam(running_machine *machine) |
| 97 | 97 | { |
| 98 | 98 | UINT16 xorval; |
| 99 | 99 | |
| r3906 | r3907 | |
| 102 | 102 | |
| 103 | 103 | /* Check changes in Page #1 */ |
| 104 | 104 | if ((xorval & 0x0400) && sam.intf->set_pageonemode) |
| 105 | | sam.intf->set_pageonemode((sam.state & 0x0400) / 0x0400); |
| 105 | sam.intf->set_pageonemode(machine,(sam.state & 0x0400) / 0x0400); |
| 106 | 106 | |
| 107 | 107 | /* Check changes in MPU Rate */ |
| 108 | 108 | if ((xorval & 0x1800) && sam.intf->set_mpurate) |
| 109 | | sam.intf->set_mpurate((sam.state & 0x1800) / 0x0800); |
| 109 | sam.intf->set_mpurate(machine,(sam.state & 0x1800) / 0x0800); |
| 110 | 110 | |
| 111 | 111 | /* Check changes in Memory Size */ |
| 112 | 112 | if ((xorval & 0x6000) && sam.intf->set_memorysize) |
| 113 | | sam.intf->set_memorysize((sam.state & 0x6000) / 0x2000); |
| 113 | sam.intf->set_memorysize(machine,(sam.state & 0x6000) / 0x2000); |
| 114 | 114 | |
| 115 | 115 | /* Check changes in Map Type */ |
| 116 | 116 | if ((xorval & 0x8000) && sam.intf->set_maptype) |
| 117 | | sam.intf->set_maptype((sam.state & 0x8000) / 0x8000); |
| 117 | sam.intf->set_maptype(machine,(sam.state & 0x8000) / 0x8000); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | static STATE_POSTLOAD( update_sam_postload ) |
| 123 | 123 | { |
| 124 | | update_sam(); |
| 124 | update_sam(machine); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
| r3906 | r3907 | |
| 146 | 146 | { |
| 147 | 147 | sam.state = 0; |
| 148 | 148 | sam.old_state = ~0; |
| 149 | | update_sam(); |
| 149 | update_sam(machine); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | |
| 154 | | void sam_set_state(UINT16 state, UINT16 mask) |
| 154 | void sam_set_state(running_machine *machine, UINT16 state, UINT16 mask) |
| 155 | 155 | { |
| 156 | 156 | sam.state &= ~mask; |
| 157 | 157 | sam.state |= (state & mask); |
| 158 | | update_sam(); |
| 158 | update_sam(machine); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
| r3906 | r3907 | |
| 171 | 171 | sam.state |= mask; |
| 172 | 172 | else |
| 173 | 173 | sam.state &= ~mask; |
| 174 | | update_sam(); |
| 174 | update_sam(space->machine); |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | |
| 180 | | const UINT8 *sam_m6847_get_video_ram(int scanline) |
| 180 | const UINT8 *sam_m6847_get_video_ram(running_machine *machine,int scanline) |
| 181 | 181 | { |
| 182 | 182 | const UINT8 *ram_base; |
| 183 | 183 | UINT16 video_position; |
| r3906 | r3907 | |
| 216 | 216 | logerror("sam_m6847_get_video_ram(): scanline=%d video_position=0x%04X\n", scanline, video_position); |
| 217 | 217 | |
| 218 | 218 | /* return actual position */ |
| 219 | | ram_base = sam.intf->get_rambase ? sam.intf->get_rambase() : mess_ram; |
| 219 | ram_base = sam.intf->get_rambase ? sam.intf->get_rambase(machine) : mess_ram; |
| 220 | 220 | return &ram_base[video_position]; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | | UINT8 get_sam_memorysize(void) |
| 223 | UINT8 get_sam_memorysize(running_machine *machine) |
| 224 | 224 | { |
| 225 | 225 | return (sam.state & 0x6000) / 0x2000; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | | UINT8 get_sam_pagemode(void) |
| 228 | UINT8 get_sam_pagemode(running_machine *machine) |
| 229 | 229 | { |
| 230 | 230 | return (sam.state & 0x0400) / 0x0400; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | | UINT8 get_sam_maptype(void) |
| 233 | UINT8 get_sam_maptype(running_machine *machine) |
| 234 | 234 | { |
| 235 | 235 | return (sam.state & 0x8000) / 0x8000; |
| 236 | 236 | } |
src/mess/devices/coco_pak.c
| r3906 | r3907 | |
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | | #include "deprecat.h" |
| 11 | 10 | #include "device.h" |
| 12 | 11 | #include "cococart.h" |
| 13 | 12 | |
| r3906 | r3907 | |
| 16 | 15 | pak_init - initializer for the PAKs |
| 17 | 16 | -------------------------------------------------*/ |
| 18 | 17 | |
| 19 | | static void pak_init(coco_cartridge *cartridge) |
| 18 | static void pak_init(running_machine *machine, coco_cartridge *cartridge) |
| 20 | 19 | { |
| 21 | | cococart_set_line(Machine, cartridge, COCOCART_LINE_CART, COCOCART_LINE_VALUE_Q); |
| 20 | cococart_set_line(machine, cartridge, COCOCART_LINE_CART, COCOCART_LINE_VALUE_Q); |
| 22 | 21 | } |
| 23 | 22 | |
| 24 | 23 | |
| r3906 | r3907 | |
| 50 | 49 | banked_pak_set_bank - function to set the bank |
| 51 | 50 | -------------------------------------------------*/ |
| 52 | 51 | |
| 53 | | static void banked_pak_set_bank(coco_cartridge *cartridge, UINT32 bank) |
| 52 | static void banked_pak_set_bank(running_machine *machine, coco_cartridge *cartridge, UINT32 bank) |
| 54 | 53 | { |
| 55 | | cococart_map_memory(Machine, cartridge, bank * 0x4000, 0x3FFF); |
| 54 | cococart_map_memory(machine, cartridge, bank * 0x4000, 0x3FFF); |
| 56 | 55 | } |
| 57 | 56 | |
| 58 | 57 | |
| r3906 | r3907 | |
| 61 | 60 | banked_pak_init |
| 62 | 61 | -------------------------------------------------*/ |
| 63 | 62 | |
| 64 | | static void banked_pak_init(coco_cartridge *cartridge) |
| 63 | static void banked_pak_init(running_machine *machine, coco_cartridge *cartridge) |
| 65 | 64 | { |
| 66 | | pak_init(cartridge); |
| 67 | | banked_pak_set_bank(cartridge, 0); |
| 65 | pak_init(machine,cartridge); |
| 66 | banked_pak_set_bank(machine,cartridge, 0); |
| 68 | 67 | } |
| 69 | 68 | |
| 70 | 69 | |
| r3906 | r3907 | |
| 73 | 72 | banked_pak_w - function to write to $FF40 |
| 74 | 73 | -------------------------------------------------*/ |
| 75 | 74 | |
| 76 | | static void banked_pak_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 75 | static void banked_pak_w(running_machine *machine, coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 77 | 76 | { |
| 78 | 77 | switch(addr) |
| 79 | 78 | { |
| 80 | 79 | case 0: |
| 81 | 80 | /* set the bank */ |
| 82 | | banked_pak_set_bank(cartridge, data); |
| 81 | banked_pak_set_bank(machine, cartridge, data); |
| 83 | 82 | break; |
| 84 | 83 | } |
| 85 | 84 | } |
src/mess/devices/coco_fdc.c
| r3906 | r3907 | |
| 67 | 67 | *********************************************************************/ |
| 68 | 68 | |
| 69 | 69 | #include "driver.h" |
| 70 | | #include "deprecat.h" |
| 71 | 70 | #include "cococart.h" |
| 72 | 71 | #include "coco_vhd.h" |
| 73 | 72 | #include "includes/coco.h" |
| r3906 | r3907 | |
| 85 | 84 | unsigned drq : 1; |
| 86 | 85 | unsigned intrq : 1; |
| 87 | 86 | |
| 88 | | void (*update_lines)(coco_cartridge *cartridge); |
| 87 | void (*update_lines)(running_machine *machine, coco_cartridge *cartridge); |
| 89 | 88 | }; |
| 90 | 89 | |
| 91 | 90 | |
| r3906 | r3907 | |
| 133 | 132 | break; |
| 134 | 133 | } |
| 135 | 134 | |
| 136 | | (*info->update_lines)(cartridge); |
| 135 | (*info->update_lines)(device->machine,cartridge); |
| 137 | 136 | } |
| 138 | 137 | |
| 139 | 138 | extern coco_cartridge *coco_cart; |
| r3906 | r3907 | |
| 157 | 156 | fdc_init - general function to initialize FDC |
| 158 | 157 | -------------------------------------------------*/ |
| 159 | 158 | |
| 160 | | static void fdc_init(running_machine *machine, |
| 161 | | coco_cartridge *cartridge, |
| 162 | | void (*update_lines)(coco_cartridge *cartridge), |
| 159 | static void fdc_init(coco_cartridge *cartridge, |
| 160 | void (*update_lines)(running_machine *machine,coco_cartridge *cartridge), |
| 163 | 161 | int initial_drq) |
| 164 | 162 | { |
| 165 | 163 | fdc_info *info = fdc_get_info(cartridge); |
| r3906 | r3907 | |
| 168 | 166 | memset(info, 0, sizeof(*info)); |
| 169 | 167 | info->update_lines = update_lines; |
| 170 | 168 | info->drq = initial_drq ? 1 : 0; |
| 171 | | |
| 172 | | /* initialize FDC */ |
| 173 | | // wd17xx_init(machine, type, fdc_callback, (void *) cartridge); |
| 174 | 169 | } |
| 175 | 170 | |
| 176 | 171 | |
| r3906 | r3907 | |
| 199 | 194 | controller lines |
| 200 | 195 | -------------------------------------------------*/ |
| 201 | 196 | |
| 202 | | static void fdc_coco_update_lines(coco_cartridge *cartridge) |
| 197 | static void fdc_coco_update_lines(running_machine *machine, coco_cartridge *cartridge) |
| 203 | 198 | { |
| 204 | 199 | fdc_info *info = fdc_get_info(cartridge); |
| 205 | 200 | |
| r3906 | r3907 | |
| 209 | 204 | |
| 210 | 205 | /* set the NMI line */ |
| 211 | 206 | cococart_set_line( |
| 212 | | Machine, |
| 207 | machine, |
| 213 | 208 | cartridge, |
| 214 | 209 | COCOCART_LINE_NMI, |
| 215 | 210 | ((info->intrq != 0) && (info->dskreg & 0x20)) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR); |
| 216 | 211 | |
| 217 | 212 | /* set the HALT line */ |
| 218 | 213 | cococart_set_line( |
| 219 | | Machine, |
| 214 | machine, |
| 220 | 215 | cartridge, |
| 221 | 216 | COCOCART_LINE_HALT, |
| 222 | 217 | ((info->drq == 0) && (info->dskreg & 0x80)) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR); |
| r3906 | r3907 | |
| 228 | 223 | fdc_coco_init - function to initialize CoCo FDC |
| 229 | 224 | -------------------------------------------------*/ |
| 230 | 225 | |
| 231 | | static void fdc_coco_init(coco_cartridge *cartridge) |
| 226 | static void fdc_coco_init(running_machine *machine, coco_cartridge *cartridge) |
| 232 | 227 | { |
| 233 | | fdc_init(Machine, cartridge, fdc_coco_update_lines, 1); |
| 228 | fdc_init(cartridge, fdc_coco_update_lines, 1); |
| 234 | 229 | } |
| 235 | 230 | |
| 236 | 231 | |
| r3906 | r3907 | |
| 240 | 235 | dskreg |
| 241 | 236 | -------------------------------------------------*/ |
| 242 | 237 | |
| 243 | | static void fdc_coco_dskreg_w(coco_cartridge *cartridge, UINT8 data) |
| 238 | static void fdc_coco_dskreg_w(running_machine *machine, coco_cartridge *cartridge, UINT8 data) |
| 244 | 239 | { |
| 245 | | running_machine *machine = Machine; |
| 246 | 240 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1773, "wd1773"); |
| 247 | 241 | fdc_info *info = fdc_get_info(cartridge); |
| 248 | 242 | UINT8 drive = 0; |
| r3906 | r3907 | |
| 286 | 280 | |
| 287 | 281 | info->dskreg = data; |
| 288 | 282 | |
| 289 | | (*info->update_lines)(cartridge); |
| 283 | (*info->update_lines)(machine, cartridge); |
| 290 | 284 | |
| 291 | 285 | wd17xx_set_drive(fdc,drive); |
| 292 | 286 | wd17xx_set_side(fdc,head); |
| r3906 | r3907 | |
| 299 | 293 | fdc_coco_r - function to read from CoCo FDC |
| 300 | 294 | -------------------------------------------------*/ |
| 301 | 295 | |
| 302 | | static UINT8 fdc_coco_r(coco_cartridge *cartridge, UINT16 addr) |
| 296 | static UINT8 fdc_coco_r(running_machine *machine, coco_cartridge *cartridge, UINT16 addr) |
| 303 | 297 | { |
| 304 | | running_machine *machine = Machine; |
| 305 | 298 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1773, "wd1773"); |
| 306 | 299 | UINT8 result = 0; |
| 307 | 300 | switch(addr & 0xEF) |
| r3906 | r3907 | |
| 328 | 321 | fdc_coco_w - function to write to CoCo FDC |
| 329 | 322 | -------------------------------------------------*/ |
| 330 | 323 | |
| 331 | | static void fdc_coco_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 324 | static void fdc_coco_w(running_machine *machine, coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 332 | 325 | { |
| 333 | | running_machine *machine = Machine; |
| 334 | 326 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD1773, "wd1773"); |
| 335 | 327 | switch(addr & 0xEF) |
| 336 | 328 | { |
| 337 | 329 | case 0: case 1: case 2: case 3: |
| 338 | 330 | case 4: case 5: case 6: case 7: |
| 339 | | fdc_coco_dskreg_w(cartridge, data); |
| 331 | fdc_coco_dskreg_w(machine, cartridge, data); |
| 340 | 332 | break; |
| 341 | 333 | case 8: |
| 342 | 334 | wd17xx_command_w(fdc, 0, data); |
| r3906 | r3907 | |
| 397 | 389 | real_time_clock |
| 398 | 390 | -------------------------------------------------*/ |
| 399 | 391 | |
| 400 | | static rtc_type_t real_time_clock(void) |
| 392 | static rtc_type_t real_time_clock(running_machine *machine) |
| 401 | 393 | { |
| 402 | | return (rtc_type_t) (int) input_port_read_safe(Machine, "real_time_clock", 0x00); |
| 394 | return (rtc_type_t) (int) input_port_read_safe(machine, "real_time_clock", 0x00); |
| 403 | 395 | } |
| 404 | 396 | |
| 405 | 397 | |
| r3906 | r3907 | |
| 408 | 400 | fdc_coco3plus_r |
| 409 | 401 | -------------------------------------------------*/ |
| 410 | 402 | |
| 411 | | static UINT8 fdc_coco3plus_r(coco_cartridge *cartridge, UINT16 addr) |
| 403 | static UINT8 fdc_coco3plus_r(running_machine *machine, coco_cartridge *cartridge, UINT16 addr) |
| 412 | 404 | { |
| 413 | 405 | const device_config *dev; |
| 414 | | running_machine *machine = Machine; |
| 415 | 406 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 416 | | UINT8 result = fdc_coco_r(cartridge, addr); |
| 407 | UINT8 result = fdc_coco_r(machine, cartridge, addr); |
| 417 | 408 | |
| 418 | 409 | switch(addr) |
| 419 | 410 | { |
| 420 | 411 | case 0x10: /* FF50 */ |
| 421 | | if (real_time_clock() == RTC_DISTO) |
| 412 | if (real_time_clock(machine) == RTC_DISTO) |
| 422 | 413 | { |
| 423 | 414 | dev = device_list_find_by_tag(machine->config->devicelist, MSM6242, "disto"); |
| 424 | 415 | result = msm6242_r(dev, msm6242_rtc_address); |
| r3906 | r3907 | |
| 426 | 417 | break; |
| 427 | 418 | |
| 428 | 419 | case 0x38: /* FF78 */ |
| 429 | | if (real_time_clock() == RTC_CLOUD9) |
| 420 | if (real_time_clock(machine) == RTC_CLOUD9) |
| 430 | 421 | ds1315_r_0(space, addr); |
| 431 | 422 | break; |
| 432 | 423 | |
| 433 | 424 | case 0x39: /* FF79 */ |
| 434 | | if (real_time_clock() == RTC_CLOUD9) |
| 425 | if (real_time_clock(machine) == RTC_CLOUD9) |
| 435 | 426 | ds1315_r_1(space, addr); |
| 436 | 427 | break; |
| 437 | 428 | |
| 438 | 429 | case 0x3C: /* FF7C */ |
| 439 | | if (real_time_clock() == RTC_CLOUD9) |
| 430 | if (real_time_clock(machine) == RTC_CLOUD9) |
| 440 | 431 | result = ds1315_r_data(space, addr); |
| 441 | 432 | break; |
| 442 | 433 | |
| r3906 | r3907 | |
| 460 | 451 | fdc_coco3plus_w |
| 461 | 452 | -------------------------------------------------*/ |
| 462 | 453 | |
| 463 | | static void fdc_coco3plus_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 454 | static void fdc_coco3plus_w(running_machine *machine, coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 464 | 455 | { |
| 465 | 456 | const device_config *dev; |
| 466 | | running_machine *machine = Machine; |
| 467 | 457 | |
| 468 | | fdc_coco_w(cartridge, addr, data); |
| 458 | fdc_coco_w(machine, cartridge, addr, data); |
| 469 | 459 | |
| 470 | 460 | switch(addr) |
| 471 | 461 | { |
| 472 | 462 | case 0x10: /* FF50 */ |
| 473 | | if (real_time_clock() == RTC_DISTO) |
| 463 | if (real_time_clock(machine) == RTC_DISTO) |
| 474 | 464 | { |
| 475 | 465 | dev = device_list_find_by_tag(machine->config->devicelist, MSM6242, "disto"); |
| 476 | 466 | msm6242_w(dev, msm6242_rtc_address, data); |
| r3906 | r3907 | |
| 478 | 468 | break; |
| 479 | 469 | |
| 480 | 470 | case 0x11: /* FF51 */ |
| 481 | | if (real_time_clock() == RTC_DISTO) |
| 471 | if (real_time_clock(machine) == RTC_DISTO) |
| 482 | 472 | msm6242_rtc_address = data & 0x0f; |
| 483 | 473 | break; |
| 484 | 474 | |
| r3906 | r3907 | |
| 528 | 518 | controller lines |
| 529 | 519 | -------------------------------------------------*/ |
| 530 | 520 | |
| 531 | | static void fdc_dragon_update_lines(coco_cartridge *cartridge) |
| 521 | static void fdc_dragon_update_lines(running_machine *machine, coco_cartridge *cartridge) |
| 532 | 522 | { |
| 533 | 523 | fdc_info *info = fdc_get_info(cartridge); |
| 534 | 524 | |
| 535 | 525 | /* set the NMI line */ |
| 536 | 526 | cococart_set_line( |
| 537 | | Machine, |
| 527 | machine, |
| 538 | 528 | cartridge, |
| 539 | 529 | COCOCART_LINE_NMI, |
| 540 | 530 | ((info->intrq != 0) && (info->dskreg & 0x20)) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR); |
| 541 | 531 | |
| 542 | 532 | /* set the CART line */ |
| 543 | 533 | cococart_set_line( |
| 544 | | Machine, |
| 534 | machine, |
| 545 | 535 | cartridge, |
| 546 | 536 | COCOCART_LINE_CART, |
| 547 | 537 | (info->drq != 0) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR); |
| r3906 | r3907 | |
| 554 | 544 | FDC |
| 555 | 545 | -------------------------------------------------*/ |
| 556 | 546 | |
| 557 | | static void fdc_dragon_init(coco_cartridge *cartridge) |
| 547 | static void fdc_dragon_init(running_machine *machine, coco_cartridge *cartridge) |
| 558 | 548 | { |
| 559 | | fdc_init(Machine, cartridge, fdc_dragon_update_lines, 0); |
| 549 | fdc_init( cartridge, fdc_dragon_update_lines, 0); |
| 560 | 550 | } |
| 561 | 551 | |
| 562 | 552 | |
| r3906 | r3907 | |
| 566 | 556 | Dragon dskreg |
| 567 | 557 | -------------------------------------------------*/ |
| 568 | 558 | |
| 569 | | static void fdc_dragon_dskreg_w(coco_cartridge *cartridge, UINT8 data) |
| 559 | static void fdc_dragon_dskreg_w(running_machine *machine,coco_cartridge *cartridge, UINT8 data) |
| 570 | 560 | { |
| 571 | | running_machine *machine = Machine; |
| 572 | 561 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); |
| 573 | 562 | fdc_info *info = fdc_get_info(cartridge); |
| 574 | 563 | |
| r3906 | r3907 | |
| 599 | 588 | fdc_dragon_r - function to read from Dragon FDC |
| 600 | 589 | -------------------------------------------------*/ |
| 601 | 590 | |
| 602 | | static UINT8 fdc_dragon_r(coco_cartridge *cartridge, UINT16 addr) |
| 591 | static UINT8 fdc_dragon_r(running_machine *machine, coco_cartridge *cartridge, UINT16 addr) |
| 603 | 592 | { |
| 604 | | running_machine *machine = Machine; |
| 605 | 593 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); |
| 606 | 594 | UINT8 result = 0; |
| 607 | 595 | switch(addr & 0xEF) |
| r3906 | r3907 | |
| 628 | 616 | fdc_dragon_w - function to write to Dragon FDC |
| 629 | 617 | -------------------------------------------------*/ |
| 630 | 618 | |
| 631 | | static void fdc_dragon_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 619 | static void fdc_dragon_w(running_machine *machine, coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 632 | 620 | { |
| 633 | | running_machine *machine = Machine; |
| 634 | 621 | device_config *fdc = (device_config*)device_list_find_by_tag( machine->config->devicelist, WD179X, "wd179x"); |
| 635 | 622 | switch(addr & 0xEF) |
| 636 | 623 | { |
| r3906 | r3907 | |
| 653 | 640 | break; |
| 654 | 641 | case 8: case 9: case 10: case 11: |
| 655 | 642 | case 12: case 13: case 14: case 15: |
| 656 | | fdc_dragon_dskreg_w(cartridge, data); |
| 643 | fdc_dragon_dskreg_w(machine, cartridge, data); |
| 657 | 644 | break; |
| 658 | 645 | }; |
| 659 | 646 | } |
src/mess/devices/cococart.c
| r3906 | r3907 | |
| 12 | 12 | |
| 13 | 13 | struct _coco_cartridge |
| 14 | 14 | { |
| 15 | | UINT8 (*rh)(coco_cartridge *cartridge, UINT16 addr); |
| 16 | | void (*wh)(coco_cartridge *cartridge, UINT16 addr, UINT8 data); |
| 15 | UINT8 (*rh)(running_machine *machine, coco_cartridge *cartridge, UINT16 addr); |
| 16 | void (*wh)(running_machine *machine, coco_cartridge *cartridge, UINT16 addr, UINT8 data); |
| 17 | 17 | void (*set_line)(running_machine *machine, coco_cartridge *cartridge, cococart_line line, cococart_line_value value); |
| 18 | 18 | void (*map_memory)(running_machine *machine, coco_cartridge *cartridge, UINT32 offset, UINT32 mask); |
| 19 | 19 | void *extra_data; |
| r3906 | r3907 | |
| 62 | 62 | coco_cartridge *cartridge; |
| 63 | 63 | cococart_getinfo cart_proc; |
| 64 | 64 | size_t extra_data_size; |
| 65 | | void (*init)(coco_cartridge *cartridge); |
| 65 | void (*init)(running_machine *machine,coco_cartridge *cartridge); |
| 66 | 66 | |
| 67 | 67 | /* sanity check */ |
| 68 | 68 | assert_always(mame_get_phase(machine) == MAME_PHASE_INIT, "Can only call cococart_init at init time!"); |
| r3906 | r3907 | |
| 77 | 77 | memset(cartridge, '\0', sizeof(*cartridge) + extra_data_size - 1); |
| 78 | 78 | |
| 79 | 79 | /* populate the cartridge structure */ |
| 80 | | cartridge->rh = (UINT8 (*)(coco_cartridge *, UINT16)) cococart_get_info_fct(cart_proc, COCOCARTINFO_PTR_FF40_R); |
| 81 | | cartridge->wh = (void (*)(coco_cartridge *, UINT16, UINT8)) cococart_get_info_fct(cart_proc, COCOCARTINFO_PTR_FF40_W); |
| 80 | cartridge->rh = (UINT8 (*)(running_machine *machine,coco_cartridge *, UINT16)) cococart_get_info_fct(cart_proc, COCOCARTINFO_PTR_FF40_R); |
| 81 | cartridge->wh = (void (*)(running_machine *machine,coco_cartridge *, UINT16, UINT8)) cococart_get_info_fct(cart_proc, COCOCARTINFO_PTR_FF40_W); |
| 82 | 82 | cartridge->extra_data = (extra_data_size > 0) ? cartridge->dummy : NULL; |
| 83 | 83 | |
| 84 | 84 | /* copy callbacks */ |
| r3906 | r3907 | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /* invoke init function */ |
| 92 | | init = (void (*)(coco_cartridge *cartridge)) cococart_get_info_fct(cart_proc, COCOCARTINFO_PTR_INIT); |
| 92 | init = (void (*)(running_machine *machine, coco_cartridge *cartridge)) cococart_get_info_fct(cart_proc, COCOCARTINFO_PTR_INIT); |
| 93 | 93 | if (init != NULL) |
| 94 | | init(cartridge); |
| 94 | init(machine, cartridge); |
| 95 | 95 | |
| 96 | 96 | /* finish up */ |
| 97 | 97 | return cartridge; |
| r3906 | r3907 | |
| 105 | 105 | |
| 106 | 106 | UINT8 cococart_read(running_machine *machine, coco_cartridge *cartridge, UINT16 address) |
| 107 | 107 | { |
| 108 | | return cartridge->rh ? cartridge->rh(cartridge, address) : 0xFF; |
| 108 | return cartridge->rh ? cartridge->rh(machine, cartridge, address) : 0xFF; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| r3906 | r3907 | |
| 117 | 117 | void cococart_write(running_machine *machine, coco_cartridge *cartridge, UINT16 address, UINT8 data) |
| 118 | 118 | { |
| 119 | 119 | if (cartridge->wh) |
| 120 | | cartridge->wh(cartridge, address, data); |
| 120 | cartridge->wh(machine, cartridge, address, data); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | |