src/mess/machine/rmnimbus.c
| r7665 | r7666 | |
| 39 | 39 | #define LATCH_INTS 1 |
| 40 | 40 | #define LOG_PORTS 0 |
| 41 | 41 | #define LOG_INTERRUPTS 0 |
| 42 | | #define LOG_INTERRUPTS_EXT |
| 42 | #define LOG_INTERRUPTS_EXT 1 |
| 43 | 43 | #define LOG_TIMER 0 |
| 44 | 44 | #define LOG_OPTIMIZATION 0 |
| 45 | 45 | #define LOG_DMA 0 |
| 46 | 46 | #define CPU_RESUME_TRIGGER 7123 |
| 47 | 47 | #define LOG_KEYBOARD 0 |
| 48 | 48 | #define LOG_SIO 0 |
| 49 | | #define LOG_DISK_FDD |
| 49 | #define LOG_DISK_FDD 1 |
| 50 | 50 | #define LOG_DISK_HDD 0 |
| 51 | | #define LOG_DISK |
| 51 | #define LOG_DISK 1 |
| 52 | 52 | #define LOG_PC8031 0 |
| 53 | 53 | #define LOG_PC8031_186 0 |
| 54 | 54 | #define LOG_PC8031_PORT 0 |
| r7665 | r7666 | |
| 58 | 58 | |
| 59 | 59 | /* Debugging */ |
| 60 | 60 | |
| 61 | | UINT32 debug_flags; |
| 61 | static UINT32 debug_flags; |
| 62 | 62 | |
| 63 | 63 | #define DMA_BREAK 0x0000001 |
| 64 | #define DECODE_BIOS 0x0000002 |
| 64 | 65 | |
| 65 | 66 | /* 80186 internal stuff */ |
| 66 | 67 | struct mem_state |
| r7665 | r7666 | |
| 139 | 140 | UINT8 tail; |
| 140 | 141 | } keyboard; |
| 141 | 142 | |
| 142 | | |
| 143 | | |
| 144 | 143 | /* Floppy drives WD2793 */ |
| 145 | 144 | |
| 146 | 145 | static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w ); |
| r7665 | r7666 | |
| 158 | 157 | // Static data related to Floppy and SCSI hard disks |
| 159 | 158 | static struct _nimbus_drives |
| 160 | 159 | { |
| 161 | | UINT8 reg400; |
| 162 | | UINT8 reg410_in; |
| 163 | | UINT8 reg410_out; |
| 164 | | UINT8 reg418; |
| 160 | UINT8 reg400; |
| 161 | UINT8 reg410_in; |
| 162 | UINT8 reg410_out; |
| 163 | UINT8 reg418; |
| 165 | 164 | |
| 166 | | UINT8 drq_ff; |
| 165 | UINT8 drq_ff; |
| 166 | UINT8 int_ff; |
| 167 | 167 | } nimbus_drives; |
| 168 | 168 | |
| 169 | 169 | |
| 170 | | static const SCSIConfigTable SCSI_dev_table = |
| 171 | | { |
| 172 | | 1, /* 1 SCSI device */ |
| 173 | | { |
| 174 | | { SCSI_ID_0, HARDDISK0_TAG, SCSI_DEVICE_HARDDISK }, |
| 175 | | } |
| 176 | | }; |
| 177 | | |
| 178 | 170 | /* 8031 Peripheral controler */ |
| 179 | 171 | static struct _ipc_interface |
| 180 | 172 | { |
| r7665 | r7666 | |
| 204 | 196 | /* Sound */ |
| 205 | 197 | UINT8 last_playmode; |
| 206 | 198 | |
| 199 | /* Mouse/Joystick */ |
| 200 | |
| 201 | typedef struct |
| 202 | { |
| 203 | UINT8 mouse_px; |
| 204 | UINT8 mouse_py; |
| 205 | |
| 206 | UINT8 mouse_x; |
| 207 | UINT8 mouse_y; |
| 208 | UINT8 mouse_pc; |
| 209 | UINT8 mouse_pcx; |
| 210 | UINT8 mouse_pcy; |
| 211 | |
| 212 | UINT8 intstate_x; |
| 213 | UINT8 intstate_y; |
| 214 | |
| 215 | UINT8 reg0a4; |
| 216 | |
| 217 | emu_timer *mouse_timer; |
| 218 | } _mouse_joy_state; |
| 219 | |
| 220 | static _mouse_joy_state nimbus_mouse; |
| 221 | UINT8 ay8910_a; |
| 222 | |
| 207 | 223 | static void drq_callback(running_machine *machine, int which); |
| 224 | static void nimbus_recalculate_ints(running_machine *machine); |
| 208 | 225 | |
| 209 | 226 | static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[]); |
| 210 | 227 | static void execute_debug_intmasks(running_machine *machine, int ref, int params, const char *param[]); |
| r7665 | r7666 | |
| 221 | 238 | static void nimbus_bank_memory(running_machine *machine); |
| 222 | 239 | static void memory_reset(running_machine *machine); |
| 223 | 240 | static void fdc_reset(void); |
| 224 | | static void generate_disk_int(running_machine *machine); |
| 241 | static void set_disk_int(running_machine *machine, int state); |
| 225 | 242 | static void hdc_reset(running_machine *machine); |
| 226 | 243 | static void hdc_ctrl_write(running_machine *machine, UINT8 data); |
| 227 | 244 | static void hdc_post_rw(running_machine *machine); |
| r7665 | r7666 | |
| 234 | 251 | static void iou_reset(void); |
| 235 | 252 | static void sound_reset(running_machine *machine); |
| 236 | 253 | |
| 254 | static void mouse_js_reset(running_machine *machine); |
| 255 | static TIMER_CALLBACK(mouse_callback); |
| 256 | |
| 237 | 257 | #define num_ioports 0x80 |
| 238 | 258 | static UINT16 IOPorts[num_ioports]; |
| 239 | 259 | |
| r7665 | r7666 | |
| 324 | 344 | for (Priority = 0; Priority <= i186.intr.priority_mask; Priority++) |
| 325 | 345 | { |
| 326 | 346 | /* note: by checking 4 bits, we also verify that the mask is off */ |
| 327 | | if ((i186.intr.timer & 15) == Priority) |
| 347 | if ((i186.intr.timer & 0x0F) == Priority) |
| 328 | 348 | { |
| 329 | 349 | /* if we're already servicing something at this level, don't generate anything new */ |
| 330 | 350 | if (i186.intr.in_service & 0x01) |
| r7665 | r7666 | |
| 408 | 428 | { |
| 409 | 429 | int Priority; |
| 410 | 430 | int IntNo; |
| 431 | int handled=0; |
| 411 | 432 | |
| 412 | 433 | /* specific case */ |
| 413 | 434 | if (!(data & 0x8000)) |
| r7665 | r7666 | |
| 433 | 454 | else |
| 434 | 455 | { |
| 435 | 456 | /* loop over priorities */ |
| 436 | | for (Priority = 0; Priority <= 7; Priority++) |
| 457 | for (Priority = 0; ((Priority <= 7) && !handled); Priority++) |
| 437 | 458 | { |
| 438 | 459 | /* check for in-service timers */ |
| 439 | 460 | if ((i186.intr.timer & 0x07) == Priority && (i186.intr.in_service & 0x01)) |
| 440 | 461 | { |
| 441 | 462 | i186.intr.in_service &= ~0x01; |
| 442 | 463 | if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", attotime_to_double(timer_get_time(machine))); |
| 443 | | return; |
| 464 | handled=1; |
| 444 | 465 | } |
| 445 | 466 | |
| 446 | 467 | /* check for in-service DMA interrupts */ |
| 447 | | for (IntNo = 0; IntNo < 2; IntNo++) |
| 468 | for (IntNo = 0; ((IntNo < 2) && !handled) ; IntNo++) |
| 448 | 469 | if ((i186.intr.dma[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x04 << IntNo))) |
| 449 | 470 | { |
| 450 | 471 | i186.intr.in_service &= ~(0x04 << IntNo); |
| 451 | 472 | if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", attotime_to_double(timer_get_time(machine)), IntNo); |
| 452 | | return; |
| 473 | handled=1; |
| 453 | 474 | } |
| 454 | 475 | |
| 455 | 476 | /* check external interrupts */ |
| 456 | | for (IntNo = 0; IntNo < 4; IntNo++) |
| 477 | for (IntNo = 0; ((IntNo < 4) && !handled) ; IntNo++) |
| 457 | 478 | if ((i186.intr.ext[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x10 << IntNo))) |
| 458 | 479 | { |
| 459 | 480 | i186.intr.in_service &= ~(0x10 << IntNo); |
| 460 | 481 | if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", attotime_to_double(timer_get_time(machine)), IntNo); |
| 461 | | return; |
| 482 | handled=1; |
| 462 | 483 | } |
| 463 | 484 | } |
| 464 | 485 | } |
| 486 | nimbus_recalculate_ints(machine); |
| 465 | 487 | } |
| 466 | 488 | |
| 467 | 489 | /* Trigger an external interupt, optionally supplying the vector to take */ |
| r7665 | r7666 | |
| 469 | 491 | { |
| 470 | 492 | if (LOG_INTERRUPTS_EXT) logerror("generating external int %02X, vector %02X\n",intno,vector); |
| 471 | 493 | |
| 472 | | // Only 4 external ints |
| 494 | // Only 4 external ints |
| 473 | 495 | if(intno>3) |
| 474 | 496 | { |
| 475 | 497 | logerror("external_int() invalid external interupt no : 0x%02X (can only be 0..3)\n",intno); |
| r7665 | r7666 | |
| 483 | 505 | if(i186.intr.ext[intno] & EXTINT_CTRL_CASCADE) |
| 484 | 506 | i186.intr.ext_vector[intno]=vector; |
| 485 | 507 | } |
| 486 | | |
| 508 | |
| 487 | 509 | // Turn on the requested request bit and handle interrupt |
| 488 | 510 | i186.intr.request |= (0x010 << intno); |
| 489 | 511 | update_interrupt_state(machine); |
| 490 | 512 | } |
| 491 | 513 | |
| 514 | static void nimbus_recalculate_ints(running_machine *machine) |
| 515 | { |
| 516 | if((iou_reg092 & DISK_INT_ENABLE) && nimbus_drives.int_ff) |
| 517 | { |
| 518 | nimbus_drives.int_ff=0; |
| 519 | external_int(machine,0,EXTERNAL_INT_DISK); |
| 520 | } |
| 521 | } |
| 492 | 522 | |
| 493 | 523 | /************************************* |
| 494 | 524 | * |
| r7665 | r7666 | |
| 750 | 780 | } |
| 751 | 781 | |
| 752 | 782 | if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest); |
| 753 | | if (debug_flags & DMA_BREAK) |
| 783 | if (DEBUG_SET(DMA_BREAK)) |
| 754 | 784 | debugger_break(machine); |
| 755 | 785 | |
| 756 | 786 | /* set the new control register */ |
| r7665 | r7666 | |
| 1290 | 1320 | pc8031_reset(machine); |
| 1291 | 1321 | sound_reset(machine); |
| 1292 | 1322 | memory_reset(machine); |
| 1323 | mouse_js_reset(machine); |
| 1293 | 1324 | } |
| 1294 | 1325 | |
| 1295 | 1326 | DRIVER_INIT(nimbus) |
| r7665 | r7666 | |
| 1302 | 1333 | nimbus_cpu_init(machine); |
| 1303 | 1334 | |
| 1304 | 1335 | keyboard.keyscan_timer=timer_alloc(machine, keyscan_callback, NULL); |
| 1305 | | |
| 1336 | nimbus_mouse.mouse_timer=timer_alloc(machine, mouse_callback, NULL); |
| 1337 | |
| 1306 | 1338 | /* setup debug commands */ |
| 1307 | 1339 | if (machine->debug_flags & DEBUG_FLAG_ENABLED) |
| 1308 | 1340 | { |
| r7665 | r7666 | |
| 1315 | 1347 | |
| 1316 | 1348 | } |
| 1317 | 1349 | |
| 1318 | | debug_flags=0; |
| 1350 | debug_flags=DECODE_BIOS; |
| 1319 | 1351 | } |
| 1320 | 1352 | |
| 1321 | 1353 | static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[]) |
| r7665 | r7666 | |
| 1344 | 1376 | { |
| 1345 | 1377 | int IntNo; |
| 1346 | 1378 | |
| 1347 | | |
| 1348 | 1379 | debug_console_printf(machine,"i186.intr.priority_mask=%4X\n",i186.intr.priority_mask); |
| 1349 | 1380 | for(IntNo=0; IntNo<4; IntNo++) |
| 1350 | 1381 | { |
| r7665 | r7666 | |
| 1380 | 1411 | |
| 1381 | 1412 | addr_ptr = (UINT8*)memory_get_read_ptr(space,curpc); |
| 1382 | 1413 | |
| 1383 | | if ((addr_ptr !=NULL) && (addr_ptr[0]==0xCD) && (addr_ptr[1]==0xF0)) |
| 1384 | | decode_subbios(device,curpc); |
| 1414 | if(DEBUG_SET(DECODE_BIOS)) |
| 1415 | if ((addr_ptr !=NULL) && (addr_ptr[0]==0xCD) && (addr_ptr[1]==0xF0)) |
| 1416 | decode_subbios(device,curpc); |
| 1385 | 1417 | |
| 1386 | 1418 | return 0; |
| 1387 | 1419 | } |
| r7665 | r7666 | |
| 2034 | 2066 | |
| 2035 | 2067 | // Setup timer to scan keyboard. |
| 2036 | 2068 | timer_adjust_periodic(keyboard.keyscan_timer, attotime_zero, 0, ATTOTIME_IN_HZ(50)); |
| 2037 | | |
| 2038 | 2069 | } |
| 2039 | 2070 | |
| 2040 | 2071 | static void queue_scancode(UINT8 scancode) |
| r7665 | r7666 | |
| 2060 | 2091 | return data; |
| 2061 | 2092 | } |
| 2062 | 2093 | |
| 2063 | | static TIMER_CALLBACK(keyscan_callback) |
| 2094 | static void scan_keyboard(running_machine *machine) |
| 2095 | |
| 2064 | 2096 | { |
| 2065 | 2097 | UINT8 keyrow; |
| 2066 | 2098 | UINT8 row; |
| r7665 | r7666 | |
| 2095 | 2127 | } |
| 2096 | 2128 | } |
| 2097 | 2129 | |
| 2130 | static TIMER_CALLBACK(keyscan_callback) |
| 2131 | { |
| 2132 | scan_keyboard(machine); |
| 2133 | } |
| 2098 | 2134 | |
| 2099 | 2135 | /* |
| 2100 | 2136 | |
| r7665 | r7666 | |
| 2147 | 2183 | nimbus_drives.reg400=0; |
| 2148 | 2184 | nimbus_drives.reg410_in=0; |
| 2149 | 2185 | nimbus_drives.reg410_out=0; |
| 2186 | nimbus_drives.int_ff=0; |
| 2150 | 2187 | } |
| 2151 | 2188 | |
| 2152 | | static void generate_disk_int(running_machine *machine) |
| 2189 | static void set_disk_int(running_machine *machine, int state) |
| 2153 | 2190 | { |
| 2154 | 2191 | if(LOG_DISK) |
| 2155 | | logerror("nimbus_drives_intrq\n"); |
| 2192 | logerror("nimbus_drives_intrq = %d\n",state); |
| 2156 | 2193 | |
| 2157 | 2194 | if(iou_reg092 & DISK_INT_ENABLE) |
| 2158 | 2195 | { |
| 2159 | | external_int(machine,0,EXTERNAL_INT_DISK); |
| 2196 | nimbus_drives.int_ff=state; |
| 2197 | |
| 2198 | if(state) |
| 2199 | external_int(machine,0,EXTERNAL_INT_DISK); |
| 2160 | 2200 | } |
| 2161 | 2201 | } |
| 2162 | 2202 | |
| 2163 | 2203 | static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w ) |
| 2164 | 2204 | { |
| 2165 | | if (state) |
| 2166 | | generate_disk_int(device->machine); |
| 2205 | set_disk_int(device->machine,state); |
| 2167 | 2206 | } |
| 2168 | 2207 | |
| 2169 | 2208 | static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_drq_w ) |
| r7665 | r7666 | |
| 2333 | 2372 | // If we enable the HDC interupt, and an interrupt is pending, go deal with it. |
| 2334 | 2373 | if(((data & HDC_IRQ_MASK) && (~nimbus_drives.reg410_out & HDC_IRQ_MASK)) && |
| 2335 | 2374 | ((~nimbus_drives.reg410_in & HDC_INT_TRIGGER)==HDC_INT_TRIGGER)) |
| 2336 | | generate_disk_int(machine); |
| 2375 | set_disk_int(machine,1); |
| 2337 | 2376 | |
| 2338 | 2377 | nimbus_drives.reg410_out=data; |
| 2339 | 2378 | |
| r7665 | r7666 | |
| 2381 | 2420 | nimbus_drives.reg410_in&=~mask; |
| 2382 | 2421 | |
| 2383 | 2422 | |
| 2423 | if(HDC_IRQ_ENABLED() && ((~nimbus_drives.reg410_in & HDC_INT_TRIGGER)==HDC_INT_TRIGGER)) |
| 2424 | set_disk_int(device->machine,1); |
| 2425 | else |
| 2426 | set_disk_int(device->machine,0); |
| 2427 | |
| 2384 | 2428 | if(line==SCSI_LINE_REQ) |
| 2385 | 2429 | { |
| 2386 | 2430 | if (state==0) |
| 2387 | 2431 | { |
| 2388 | | if(HDC_IRQ_ENABLED() && ((~nimbus_drives.reg410_in & HDC_INT_TRIGGER)==HDC_INT_TRIGGER)) |
| 2389 | | generate_disk_int(device->machine); |
| 2390 | | |
| 2391 | 2432 | if(((nimbus_drives.reg410_in & HDC_CD_MASK)==HDC_CD_MASK) && (last!=0)) |
| 2392 | 2433 | { |
| 2393 | 2434 | nimbus_drives.drq_ff=1; |
| r7665 | r7666 | |
| 2632 | 2673 | |
| 2633 | 2674 | last_playmode=MSM5205_S48_4B; |
| 2634 | 2675 | msm5205_playmode_w(msm5205,last_playmode); |
| 2676 | |
| 2677 | ay8910_a=0; |
| 2635 | 2678 | } |
| 2636 | 2679 | |
| 2637 | 2680 | READ8_HANDLER( sound_ay8910_r ) |
| r7665 | r7666 | |
| 2666 | 2709 | running_device *msm5205 = devtag_get_device(space->machine, MSM5205_TAG); |
| 2667 | 2710 | |
| 2668 | 2711 | msm5205_data_w(msm5205, data); |
| 2712 | |
| 2713 | // Mouse code needs a copy of this. |
| 2714 | ay8910_a=data; |
| 2669 | 2715 | } |
| 2670 | 2716 | |
| 2671 | 2717 | WRITE8_HANDLER( sound_ay8910_portb_w ) |
| r7665 | r7666 | |
| 2685 | 2731 | external_int(device->machine,0,EXTERNAL_INT_MSM5205); |
| 2686 | 2732 | } |
| 2687 | 2733 | |
| 2734 | static const int MOUSE_XYA[3][4] = { { 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 } }; |
| 2735 | static const int MOUSE_XYB[3][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0, 0 } }; |
| 2736 | //static const int MOUSE_XYA[4] = { 1, 1, 0, 0 }; |
| 2737 | //static const int MOUSE_XYB[4] = { 0, 1, 1, 0 }; |
| 2688 | 2738 | |
| 2739 | static void mouse_js_reset(running_machine *machine) |
| 2740 | { |
| 2741 | _mouse_joy_state *state = &nimbus_mouse; |
| 2742 | |
| 2743 | state->mouse_px=0; |
| 2744 | state->mouse_py=0; |
| 2745 | state->mouse_x=128; |
| 2746 | state->mouse_y=128; |
| 2747 | state->mouse_pc=0; |
| 2748 | state->mouse_pcx=0; |
| 2749 | state->mouse_pcy=0; |
| 2750 | state->intstate_x=0; |
| 2751 | state->intstate_y=0; |
| 2752 | state->reg0a4=0xC0; |
| 2753 | |
| 2754 | // Setup timer to poll the mouse |
| 2755 | timer_adjust_periodic(nimbus_mouse.mouse_timer, attotime_zero, 0, ATTOTIME_IN_HZ(1000)); |
| 2756 | } |
| 2757 | |
| 2758 | static TIMER_CALLBACK(mouse_callback) |
| 2759 | { |
| 2760 | UINT8 x = 0; |
| 2761 | UINT8 y = 0; |
| 2762 | // int pc=cpu_get_pc(devtag_get_device(machine,MAINCPU_TAG)); |
| 2763 | |
| 2764 | UINT8 intstate_x; |
| 2765 | UINT8 intstate_y; |
| 2766 | int xint; |
| 2767 | int yint; |
| 2768 | |
| 2769 | _mouse_joy_state *state = &nimbus_mouse; |
| 2770 | |
| 2771 | |
| 2772 | state->reg0a4 = input_port_read(machine, MOUSE_BUTTON_TAG) | 0xC0; |
| 2773 | x = input_port_read(machine, MOUSEX_TAG); |
| 2774 | y = input_port_read(machine, MOUSEY_TAG); |
| 2775 | |
| 2776 | UINT8 mxa; |
| 2777 | UINT8 mxb; |
| 2778 | UINT8 mya; |
| 2779 | UINT8 myb; |
| 2780 | |
| 2781 | //logerror("poll_mouse()\n"); |
| 2782 | |
| 2783 | if (x == state->mouse_x) |
| 2784 | { |
| 2785 | state->mouse_px = MOUSE_PHASE_STATIC; |
| 2786 | } |
| 2787 | else if (x > state->mouse_x) |
| 2788 | { |
| 2789 | state->mouse_px = MOUSE_PHASE_POSITIVE; |
| 2790 | } |
| 2791 | else if (x < state->mouse_x) |
| 2792 | { |
| 2793 | state->mouse_px = MOUSE_PHASE_NEGATIVE; |
| 2794 | } |
| 2795 | |
| 2796 | if (y == state->mouse_y) |
| 2797 | { |
| 2798 | state->mouse_py = MOUSE_PHASE_STATIC; |
| 2799 | } |
| 2800 | else if (y > state->mouse_y) |
| 2801 | { |
| 2802 | state->mouse_py = MOUSE_PHASE_POSITIVE; |
| 2803 | } |
| 2804 | else if (y < state->mouse_y) |
| 2805 | { |
| 2806 | state->mouse_py = MOUSE_PHASE_NEGATIVE; |
| 2807 | } |
| 2808 | |
| 2809 | switch (state->mouse_px) |
| 2810 | { |
| 2811 | case MOUSE_PHASE_STATIC : break; |
| 2812 | case MOUSE_PHASE_POSITIVE : state->mouse_pcx++; break; |
| 2813 | case MOUSE_PHASE_NEGATIVE : state->mouse_pcx--; break; |
| 2814 | } |
| 2815 | state->mouse_pcx &= 0x03; |
| 2816 | |
| 2817 | switch (state->mouse_py) |
| 2818 | { |
| 2819 | case MOUSE_PHASE_STATIC : break; |
| 2820 | case MOUSE_PHASE_POSITIVE : state->mouse_pcy++; break; |
| 2821 | case MOUSE_PHASE_NEGATIVE : state->mouse_pcy--; break; |
| 2822 | } |
| 2823 | state->mouse_pcy &= 0x03; |
| 2824 | |
| 2825 | // mxb = MOUSE_XYB[state->mouse_px][state->mouse_pcx]; // XB |
| 2826 | // mxa = MOUSE_XYA[state->mouse_px][state->mouse_pcx]; // XA |
| 2827 | // mya = MOUSE_XYA[state->mouse_py][state->mouse_pcy]; // YA |
| 2828 | // myb = MOUSE_XYB[state->mouse_py][state->mouse_pcy]; // YB |
| 2829 | |
| 2830 | mxb = MOUSE_XYB[1][state->mouse_pcx]; // XB |
| 2831 | mxa = MOUSE_XYA[1][state->mouse_pcx]; // XA |
| 2832 | mya = MOUSE_XYA[1][state->mouse_pcy]; // YA |
| 2833 | myb = MOUSE_XYB[1][state->mouse_pcy]; // YB |
| 2834 | |
| 2835 | if ((state->mouse_py!=MOUSE_PHASE_STATIC) || (state->mouse_px!=MOUSE_PHASE_STATIC)) |
| 2836 | { |
| 2837 | // logerror("state->mouse_px=%02X, state->mouse_py=%02X, state->mouse_pcx=%02X, state->mouse_pcy=%02X\n", |
| 2838 | // state->mouse_px,state->mouse_py,state->mouse_pcx,state->mouse_pcy); |
| 2839 | |
| 2840 | // logerror("mxb=%02x, mxa=%02X (mxb ^ mxa)=%02X, (ay8910_a & 0xC0)=%02X, (mxb ^ mxa) ^ ((ay8910_a & 0x80) >> 7)=%02X\n", |
| 2841 | // mxb,mxa, (mxb ^ mxa) , (ay8910_a & 0xC0), (mxb ^ mxa) ^ ((ay8910_a & 0x40) >> 6)); |
| 2842 | } |
| 2843 | |
| 2844 | intstate_x = (mxb ^ mxa) ^ ((ay8910_a & 0x40) >> 6); |
| 2845 | intstate_y = (myb ^ mya) ^ ((ay8910_a & 0x80) >> 7); |
| 2846 | |
| 2847 | if (MOUSE_INT_ENABLED()) |
| 2848 | { |
| 2849 | if ((intstate_x==1) && (state->intstate_x==0)) |
| 2850 | // if (intstate_x!=state->intstate_x) |
| 2851 | { |
| 2852 | |
| 2853 | xint=mxa ? EXTERNAL_INT_MOUSE_XR : EXTERNAL_INT_MOUSE_XL; |
| 2854 | |
| 2855 | external_int(machine,0,xint); |
| 2856 | |
| 2857 | // logerror("Xint:%02X, mxb=%02X\n",xint,mxb); |
| 2858 | } |
| 2859 | |
| 2860 | if ((intstate_y==1) && (state->intstate_y==0)) |
| 2861 | // if (intstate_y!=state->intstate_y) |
| 2862 | { |
| 2863 | yint=myb ? EXTERNAL_INT_MOUSE_YU : EXTERNAL_INT_MOUSE_YD; |
| 2864 | |
| 2865 | external_int(machine,0,yint); |
| 2866 | // logerror("Yint:%02X, myb=%02X\n",yint,myb); |
| 2867 | } |
| 2868 | } |
| 2869 | else |
| 2870 | { |
| 2871 | state->reg0a4 &= 0xF0; |
| 2872 | state->reg0a4 |= ( mxb & 0x01) << 3; // XB |
| 2873 | state->reg0a4 |= (!mxb & 0x01) << 2; // XA |
| 2874 | state->reg0a4 |= (!myb & 0x01) << 1; // YA |
| 2875 | state->reg0a4 |= ( myb & 0x01) << 0; // YB |
| 2876 | } |
| 2877 | |
| 2878 | state->mouse_x = x; |
| 2879 | state->mouse_y = y; |
| 2880 | |
| 2881 | if ((state->mouse_py!=MOUSE_PHASE_STATIC) || (state->mouse_px!=MOUSE_PHASE_STATIC)) |
| 2882 | { |
| 2883 | // logerror("pc=%05X, reg0a4=%02X, reg092=%02X, ay_a=%02X, x=%02X, y=%02X, px=%02X, py=%02X, intstate_x=%02X, intstate_y=%02X\n", |
| 2884 | // pc,state->reg0a4,iou_reg092,ay8910_a,state->mouse_x,state->mouse_y,state->mouse_px,state->mouse_py,intstate_x,intstate_y); |
| 2885 | } |
| 2886 | |
| 2887 | state->intstate_x=intstate_x; |
| 2888 | state->intstate_y=intstate_y; |
| 2889 | } |
| 2890 | |
| 2891 | READ8_HANDLER( mouse_js_r ) |
| 2892 | { |
| 2893 | /* |
| 2894 | |
| 2895 | bit description |
| 2896 | |
| 2897 | 0 JOY 0-Up or mouse XB |
| 2898 | 1 JOY 0-Down or mouse XA |
| 2899 | 2 JOY 0-Left or mouse YA |
| 2900 | 3 JOY 0-Right or mouse YB |
| 2901 | 4 JOY 0-b0 or mouse rbutton |
| 2902 | 5 JOY 0-b1 or mouse lbutton |
| 2903 | 6 ?? always reads 1 |
| 2904 | 7 ?? always reads 1 |
| 2905 | |
| 2906 | */ |
| 2907 | UINT8 result; |
| 2908 | // int pc=cpu_get_pc(devtag_get_device(space->machine,MAINCPU_TAG)); |
| 2909 | |
| 2910 | _mouse_joy_state *state = &nimbus_mouse; |
| 2911 | |
| 2912 | if (input_port_read(space->machine, "config") & 0x01) |
| 2913 | { |
| 2914 | result=state->reg0a4; |
| 2915 | //logerror("mouse_js_r: pc=%05X, result=%02X\n",pc,result); |
| 2916 | } |
| 2917 | else |
| 2918 | { |
| 2919 | result=input_port_read_safe(space->machine, JOYSTICK0_TAG, 0xff); |
| 2920 | } |
| 2921 | |
| 2922 | return result; |
| 2923 | } |
| 2924 | |
| 2925 | WRITE8_HANDLER( mouse_js_w ) |
| 2926 | { |
| 2927 | } |
| 2928 | |
src/mess/drivers/rmnimbus.c
| r7665 | r7666 | |
| 109 | 109 | ADDRESS_MAP_END |
| 110 | 110 | |
| 111 | 111 | static ADDRESS_MAP_START(nimbus_io, ADDRESS_SPACE_IO, 16) |
| 112 | | AM_RANGE( 0x0000, 0x002f) AM_READWRITE( nimbus_video_io_r, nimbus_video_io_w) |
| 113 | | AM_RANGE( 0x0030, 0x007f) AM_READWRITE( nimbus_io_r, nimbus_io_w) |
| 112 | AM_RANGE( 0x0000, 0x0031) AM_READWRITE( nimbus_video_io_r, nimbus_video_io_w) |
| 113 | AM_RANGE( 0x0032, 0x007f) AM_READWRITE( nimbus_io_r, nimbus_io_w) |
| 114 | 114 | AM_RANGE( 0x0080, 0x0081) AM_READWRITE8( mcu_r, mcu_w, 0x00FF) |
| 115 | 115 | AM_RANGE( 0x0092, 0x0093) AM_READWRITE8( iou_r, iou_w, 0x00FF) |
| 116 | AM_RANGE( 0x00A4, 0x00A5) AM_READWRITE8( mouse_js_r, mouse_js_w, 0x00FF) |
| 116 | 117 | AM_RANGE( 0X00c0, 0X00cf) AM_READWRITE8( pc8031_r, pc8031_w, 0x00FF) |
| 117 | 118 | AM_RANGE( 0X00e0, 0X00ef) AM_READWRITE8( sound_ay8910_r, sound_ay8910_w, 0x00FF) |
| 118 | 119 | AM_RANGE( 0x00f0, 0x00f7) AM_DEVREADWRITE8(Z80SIO_TAG, z80sio_cd_ba_r, z80sio_cd_ba_w, 0x00ff) |
| r7665 | r7666 | |
| 121 | 122 | ADDRESS_MAP_END |
| 122 | 123 | |
| 123 | 124 | static INPUT_PORTS_START( nimbus ) |
| 125 | PORT_START("config") |
| 126 | PORT_CONFNAME( 0x01, 0x00, "Input Port 0 Device") |
| 127 | PORT_CONFSETTING( 0x00, "Mouse" ) |
| 128 | PORT_CONFSETTING( 0x01, DEF_STR( Joystick ) ) |
| 129 | |
| 124 | 130 | PORT_START("KEY0") /* Key row 0 scancodes 00..07 */ |
| 125 | 131 | //PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 126 | 132 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED) |
| r7665 | r7666 | |
| 237 | 243 | //PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP6") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR('6') |
| 238 | 244 | //PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP+") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR('+') |
| 239 | 245 | //PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR('1') |
| 246 | |
| 247 | PORT_START(JOYSTICK0_TAG) |
| 248 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_8WAY // XB |
| 249 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_8WAY // XA |
| 250 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_8WAY // YA |
| 251 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_8WAY // YB |
| 252 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) |
| 253 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 254 | |
| 255 | PORT_START(MOUSE_BUTTON_TAG) /* Mouse buttons */ |
| 256 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Button 2") PORT_CODE(MOUSECODE_BUTTON2) |
| 257 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Button 1") PORT_CODE(MOUSECODE_BUTTON1) |
| 258 | |
| 259 | PORT_START(MOUSEX_TAG) /* Mouse - X AXIS */ |
| 260 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 261 | |
| 262 | PORT_START(MOUSEY_TAG) /* Mouse - Y AXIS */ |
| 263 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 264 | |
| 240 | 265 | INPUT_PORTS_END |
| 241 | 266 | |
| 242 | 267 | static ADDRESS_MAP_START(nimbus_iocpu_mem, ADDRESS_SPACE_PROGRAM, 8) |
| r7665 | r7666 | |
| 325 | 350 | MDRV_SOUND_CONFIG(msm5205_config) |
| 326 | 351 | |
| 327 | 352 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, MONO_TAG, 0.75) |
| 353 | |
| 354 | |
| 328 | 355 | MACHINE_DRIVER_END |
| 329 | 356 | |
| 330 | 357 | |