src/mess/drivers/cdi.c
| r6066 | r6067 | |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | cdic_regs.time += 0x100; |
| 951 | | if((cdic_regs.time & 0x00000f00) == 0xa00) |
| 951 | if((cdic_regs.time & 0x00000f00) == 0x00000a00) |
| 952 | 952 | { |
| 953 | 953 | cdic_regs.time &= 0xfffff0ff; |
| 954 | 954 | cdic_regs.time += 0x00001000; |
| 955 | 955 | } |
| 956 | | if((cdic_regs.time & 0x0000ff00) == 0x7500) |
| 956 | if((cdic_regs.time & 0x0000ff00) == 0x00007500) |
| 957 | 957 | { |
| 958 | 958 | cdic_regs.time &= 0xffff00ff; |
| 959 | 959 | cdic_regs.time += 0x00010000; |
| 960 | | if((cdic_regs.time & 0xf0000) == 0xa0000) |
| 960 | if((cdic_regs.time & 0x000f0000) == 0x000a0000) |
| 961 | 961 | { |
| 962 | 962 | cdic_regs.time &= 0xfff0ffff; |
| 963 | | cdic_regs.time += 0x100000; |
| 964 | | if((cdic_regs.time & 0xf00000) == 0xf00000) |
| 963 | cdic_regs.time += 0x00100000; |
| 964 | if((cdic_regs.time & 0x00f00000) == 0x00a00000) |
| 965 | 965 | { |
| 966 | 966 | cdic_regs.time &= 0xff0fffff; |
| 967 | 967 | cdic_regs.time += 0x01000000; |
| 968 | if((cdic_regs.time & 0x0f000000) == 0x0a000000) |
| 969 | { |
| 970 | cdic_regs.time &= 0xf0ffffff; |
| 971 | cdic_regs.time += 0x10000000; |
| 972 | } |
| 968 | 973 | } |
| 969 | 974 | } |
| 970 | 975 | } |
| r6066 | r6067 | |
| 983 | 988 | cdic_regs.data_buffer |= 0x4000; |
| 984 | 989 | cdic_regs.data_buffer &= 0x7fff; |
| 985 | 990 | |
| 986 | | verboselog(machine, 0, "EOF, access should stop here\n" ); |
| 987 | 991 | //printf( "Setting CDIC interrupt line\n" ); |
| 988 | 992 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); |
| 989 | 993 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| r6066 | r6067 | |
| 992 | 996 | } |
| 993 | 997 | else if((buffer[22] & 0x0e) == 0x00) |
| 994 | 998 | { |
| 995 | | // Empty message sector, ignore it |
| 999 | // Ignore the audio sector for now. |
| 1000 | if(!(buffer[22] & 0x10)) |
| 1001 | { |
| 1002 | verboselog(machine, 0, "Message sector, ignored\n" ); |
| 1003 | } |
| 1004 | else |
| 1005 | { |
| 1006 | cdic_regs.x_buffer |= 0x8000; |
| 1007 | |
| 1008 | cdic_regs.data_buffer |= 0x4000; |
| 1009 | cdic_regs.data_buffer &= 0x7fff; |
| 1010 | |
| 1011 | //printf( "Setting CDIC interrupt line\n" ); |
| 1012 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); |
| 1013 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 1014 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 1015 | } |
| 996 | 1016 | } |
| 997 | 1017 | else //if((buffer[22] & 0x04) == 0x04) |
| 998 | 1018 | { |
| r6066 | r6067 | |
| 1001 | 1021 | cdic_regs.data_buffer |= 0x4000; |
| 1002 | 1022 | cdic_regs.data_buffer &= 0x7fff; |
| 1003 | 1023 | |
| 1004 | | verboselog(machine, 0, "EOF, access should stop here\n" ); |
| 1005 | 1024 | //printf( "Setting CDIC interrupt line\n" ); |
| 1006 | 1025 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); |
| 1007 | 1026 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| r6066 | r6067 | |
| 1127 | 1146 | for(index = start / 2; index < (start / 2 + count); index++) |
| 1128 | 1147 | { |
| 1129 | 1148 | memory[index] = cdram[src_index++]; |
| 1130 | | if(cdic_regs.time == 0x00332400 || cdic_regs.time == 0x00332500) |
| 1131 | | { |
| 1132 | | //printf( "%04x ", cdram[src_index - 1] ); |
| 1133 | | } |
| 1134 | 1149 | } |
| 1135 | | //printf( "\n" ); |
| 1136 | 1150 | scc68070_regs.dma.channel[0].memory_address_counter += scc68070_regs.dma.channel[0].transfer_counter * 2; |
| 1137 | 1151 | break; |
| 1138 | 1152 | } |
| r6066 | r6067 | |
| 1163 | 1177 | case 0x2a: // Read Mode 2 |
| 1164 | 1178 | timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed |
| 1165 | 1179 | break; |
| 1180 | default: |
| 1181 | fatalerror( "Unknown CDIC command: %02x\n", cdic_regs.command ); |
| 1182 | break; |
| 1166 | 1183 | } |
| 1167 | 1184 | } |
| 1168 | 1185 | break; |
| r6066 | r6067 | |
| 1235 | 1252 | UINT16 old_mouse_x = slave_regs.real_mouse_x; |
| 1236 | 1253 | UINT16 old_mouse_y = slave_regs.real_mouse_y; |
| 1237 | 1254 | |
| 1255 | if(slave_regs.real_mouse_x == 0xffff) |
| 1256 | { |
| 1257 | old_mouse_x = x & 0x3ff; |
| 1258 | old_mouse_y = y & 0x3ff; |
| 1259 | } |
| 1260 | |
| 1238 | 1261 | slave_regs.real_mouse_x = x & 0x3ff; |
| 1239 | 1262 | slave_regs.real_mouse_y = y & 0x3ff; |
| 1240 | 1263 | |
| 1241 | | if(slave_regs.real_mouse_x == 0xffff) |
| 1264 | slave_regs.fake_mouse_x += (slave_regs.real_mouse_x - old_mouse_x); |
| 1265 | slave_regs.fake_mouse_y += (slave_regs.real_mouse_y - old_mouse_y); |
| 1266 | |
| 1267 | while(slave_regs.fake_mouse_x > 0x3ff) |
| 1242 | 1268 | { |
| 1243 | | slave_regs.fake_mouse_x = slave_regs.real_mouse_x; |
| 1244 | | slave_regs.fake_mouse_y = slave_regs.real_mouse_y; |
| 1269 | slave_regs.fake_mouse_x += 0x400; |
| 1245 | 1270 | } |
| 1246 | | else |
| 1271 | |
| 1272 | while(slave_regs.fake_mouse_y > 0x3ff) |
| 1247 | 1273 | { |
| 1248 | | old_mouse_x = 0xffff; |
| 1249 | | old_mouse_y = 0xffff; |
| 1250 | | slave_regs.fake_mouse_x = x & 0x3ff; |
| 1251 | | slave_regs.fake_mouse_y = y & 0x3ff; |
| 1274 | slave_regs.fake_mouse_y += 0x400; |
| 1252 | 1275 | } |
| 1253 | 1276 | |
| 1254 | | slave_regs.fake_mouse_x += (slave_regs.real_mouse_x - old_mouse_x); |
| 1255 | | slave_regs.fake_mouse_y += (slave_regs.real_mouse_y - old_mouse_y); |
| 1256 | | |
| 1257 | 1277 | x = slave_regs.fake_mouse_x; |
| 1258 | 1278 | y = slave_regs.fake_mouse_y; |
| 1259 | 1279 | |
| r6066 | r6067 | |
| 1306 | 1326 | { |
| 1307 | 1327 | UINT16 x, y; |
| 1308 | 1328 | |
| 1309 | | printf( "old fake mouse x: %04x\n", slave_regs.fake_mouse_x ); |
| 1310 | | printf( "old fake mouse y: %04x\n", slave_regs.fake_mouse_y ); |
| 1329 | printf( "Set mouse position: %02x %02x %02x\n", slave_regs.in_buf[0], slave_regs.in_buf[1], slave_regs.in_buf[2] ); |
| 1311 | 1330 | |
| 1312 | | slave_regs.fake_mouse_y = (slave_regs.fake_mouse_y & 0xff80) | (slave_regs.in_buf[1] & 0x7f); |
| 1313 | | slave_regs.fake_mouse_x = (slave_regs.fake_mouse_x & 0xff80) | (slave_regs.in_buf[2] & 0x7f); |
| 1331 | slave_regs.fake_mouse_y = ((slave_regs.in_buf[1] & 0x0f) << 6) | (slave_regs.in_buf[0] & 0x3f); |
| 1332 | slave_regs.fake_mouse_x = ((slave_regs.in_buf[1] & 0x70) << 3) | slave_regs.in_buf[2]; |
| 1314 | 1333 | |
| 1315 | 1334 | x = slave_regs.fake_mouse_x; |
| 1316 | 1335 | y = slave_regs.fake_mouse_y; |
| 1317 | 1336 | |
| 1318 | | printf( "new fake mouse x: %04x\n", slave_regs.fake_mouse_x ); |
| 1319 | | printf( "new fake mouse y: %04x\n", slave_regs.fake_mouse_y ); |
| 1320 | | |
| 1321 | 1337 | if(slave_regs.polling_active) |
| 1322 | 1338 | { |
| 1323 | 1339 | slave_prepare_readback(machine, ATTOTIME_IN_HZ(10000), 0, 4, (x & 0x380) >> 7, x & 0x7f, (y & 0x380) >> 7, y & 0x7f, 0xf7); |
| r6066 | r6067 | |
| 2367 | 2383 | mcd212.region_flag[flag] = 1; |
| 2368 | 2384 | break; |
| 2369 | 2385 | } |
| 2370 | | break; |
| 2371 | 2386 | } |
| 2372 | 2387 | } |
| 2373 | 2388 | } |
| r6066 | r6067 | |
| 2430 | 2445 | mcd212.region_flag[flag] = 1; |
| 2431 | 2446 | break; |
| 2432 | 2447 | } |
| 2433 | | break; |
| 2434 | 2448 | } |
| 2435 | 2449 | } |
| 2436 | 2450 | } |
| r6066 | r6067 | |
| 2566 | 2580 | { |
| 2567 | 2581 | for(; x < 768; x++) |
| 2568 | 2582 | { |
| 2569 | | pixels[x++] = 0; |
| 2570 | | pixels[x] = 0; |
| 2583 | pixels[x++] = 0x00101010; |
| 2584 | pixels[x] = 0x00101010; |
| 2571 | 2585 | } |
| 2572 | 2586 | } |
| 2573 | 2587 | } |
| r6066 | r6067 | |
| 2637 | 2651 | |
| 2638 | 2652 | static const UINT32 mcd212_4bpp_color[16] = |
| 2639 | 2653 | { |
| 2640 | | 0x00000000, 0x0000007f, 0x00007f00, 0x00007f7f, 0x007f0000, 0x007f007f, 0x007f7f00, 0x007f7f7f, |
| 2641 | | 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff |
| 2654 | 0x00101010, 0x0010107a, 0x00107a10, 0x00107a7a, 0x007a1010, 0x007a107a, 0x007a7a10, 0x007a7a7a, |
| 2655 | 0x00101010, 0x001010e6, 0x0010e610, 0x0010e6e6, 0x00e61010, 0x00e610e6, 0x00e6e610, 0x00e6e6e6 |
| 2642 | 2656 | }; |
| 2643 | 2657 | |
| 2644 | 2658 | INLINE void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y) |
| 2645 | 2659 | { |
| 2646 | 2660 | if(mcd212.channel[0].cursor_control & MCD212_CURCNT_EN) |
| 2647 | 2661 | { |
| 2648 | | UINT16 curx = mcd212.channel[0].cursor_position & 0x3ff; |
| 2649 | | UINT16 cury = (mcd212.channel[0].cursor_position >> 12) & 0x3ff; |
| 2662 | UINT16 curx = mcd212.channel[0].cursor_position & 0x3ff; |
| 2663 | UINT16 cury = ((mcd212.channel[0].cursor_position >> 12) & 0x3ff) + 22; |
| 2650 | 2664 | UINT32 x = 0; |
| 2651 | | cury += 22; |
| 2652 | 2665 | if(y >= cury && y < (cury + 16)) |
| 2653 | 2666 | { |
| 2654 | 2667 | UINT32 color = mcd212_4bpp_color[mcd212.channel[0].cursor_control & MCD212_CURCNT_COLOR]; |
| r6066 | r6067 | |
| 2961 | 2974 | |
| 2962 | 2975 | static INPUT_PORTS_START( cdi ) |
| 2963 | 2976 | PORT_START("MOUSEX") |
| 2964 | | PORT_BIT(0x3ff, 0x000, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_CHANGED(mouse_update, 0) |
| 2977 | PORT_BIT(0x3ff, 0x000, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_MINMAX(0x000, 0x3ff) PORT_KEYDELTA(0) PORT_CHANGED(mouse_update, 0) |
| 2965 | 2978 | |
| 2966 | 2979 | PORT_START("MOUSEY") |
| 2967 | | PORT_BIT(0x1ff, 0x000, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_CHANGED(mouse_update, 0) |
| 2980 | PORT_BIT(0x3ff, 0x000, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_MINMAX(0x000, 0x3ff) PORT_KEYDELTA(0) PORT_CHANGED(mouse_update, 0) |
| 2968 | 2981 | |
| 2969 | 2982 | PORT_START("MOUSEBTN") |
| 2970 | 2983 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("Mouse Button 1") PORT_CHANGED(mouse_update, 0) |