src/mess/video/vic6567.c
| r8745 | r8746 | |
| 74 | 74 | #include "emu.h" |
| 75 | 75 | #include "video/vic6567.h" |
| 76 | 76 | |
| 77 | static UINT8 rdy_cycles = 0; |
| 78 | |
| 77 | 79 | typedef struct _vic2_state vic2_state; |
| 78 | 80 | struct _vic2_state |
| 79 | 81 | { |
| r8745 | r8746 | |
| 375 | 377 | { |
| 376 | 378 | vic2->first_ba_cycle = vic2->cycles_counter; |
| 377 | 379 | if ((vic2->rdy_workaround_cb != NULL) && (vic2->rdy_workaround_cb(machine) != 7 )) |
| 378 | | cpu_suspend(machine->firstcpu, SUSPEND_REASON_SPIN, 0); |
| 380 | { |
| 381 | // cpu_suspend(machine->firstcpu, SUSPEND_REASON_SPIN, 0); |
| 382 | } |
| 379 | 383 | vic2->cpu_suspended = 1; |
| 380 | 384 | } |
| 381 | 385 | } |
| r8745 | r8746 | |
| 386 | 390 | if (vic2->cpu_suspended == 1) |
| 387 | 391 | { |
| 388 | 392 | if ((vic2->rdy_workaround_cb != NULL)) |
| 389 | | cpu_resume(machine->firstcpu, SUSPEND_REASON_SPIN); |
| 393 | { |
| 394 | // cpu_resume(machine->firstcpu, SUSPEND_REASON_SPIN); |
| 395 | } |
| 390 | 396 | vic2->cpu_suspended = 0; |
| 391 | 397 | } |
| 392 | 398 | } |
| r8745 | r8746 | |
| 993 | 999 | vic2_state *vic2 = (vic2_state *)ptr; |
| 994 | 1000 | int i; |
| 995 | 1001 | UINT8 mask; |
| 1002 | static int adjust[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 1003 | |
| 1004 | UINT8 cpu_cycles = machine->device<cpu_device>("maincpu")->total_cycles() & 0xff; |
| 1005 | UINT8 vic_cycles = (vic2->cycles_counter + 1) & 0xff; |
| 996 | 1006 | vic2->cycles_counter++; |
| 997 | 1007 | |
| 1008 | // printf("%02x %02x %02x\n",cpu_cycles,vic_cycles,rdy_cycles); |
| 1009 | /* |
| 1010 | if (input_code_pressed(machine, KEYCODE_X)) |
| 1011 | { |
| 1012 | if (input_code_pressed_once(machine, KEYCODE_Q)) adjust[1]++; |
| 1013 | if (input_code_pressed_once(machine, KEYCODE_W)) adjust[2]++; |
| 1014 | if (input_code_pressed_once(machine, KEYCODE_E)) adjust[3]++; |
| 1015 | if (input_code_pressed_once(machine, KEYCODE_R)) adjust[4]++; |
| 1016 | if (input_code_pressed_once(machine, KEYCODE_T)) adjust[5]++; |
| 1017 | if (input_code_pressed_once(machine, KEYCODE_Y)) adjust[6]++; |
| 1018 | if (input_code_pressed_once(machine, KEYCODE_U)) adjust[7]++; |
| 1019 | if (input_code_pressed_once(machine, KEYCODE_I)) adjust[8]++; |
| 1020 | if (input_code_pressed_once(machine, KEYCODE_A)) adjust[1]--; |
| 1021 | if (input_code_pressed_once(machine, KEYCODE_S)) adjust[2]--; |
| 1022 | if (input_code_pressed_once(machine, KEYCODE_D)) adjust[3]--; |
| 1023 | if (input_code_pressed_once(machine, KEYCODE_F)) adjust[4]--; |
| 1024 | if (input_code_pressed_once(machine, KEYCODE_G)) adjust[5]--; |
| 1025 | if (input_code_pressed_once(machine, KEYCODE_H)) adjust[6]--; |
| 1026 | if (input_code_pressed_once(machine, KEYCODE_J)) adjust[7]--; |
| 1027 | if (input_code_pressed_once(machine, KEYCODE_K)) adjust[8]--; |
| 1028 | if (input_code_pressed_once(machine, KEYCODE_C)) adjust[0]++; |
| 1029 | if (input_code_pressed_once(machine, KEYCODE_V)) adjust[0]--; |
| 1030 | if (input_code_pressed_once(machine, KEYCODE_Z)) printf("b:%02x 1:%02x 2:%02x 3:%02x 4:%02x 5:%02x 6:%02x 7:%02x 8:%02x\n", |
| 1031 | adjust[0],adjust[1],adjust[2],adjust[3],adjust[4],adjust[5],adjust[6],adjust[7],adjust[8]); |
| 1032 | } |
| 1033 | */ |
| 1034 | |
| 998 | 1035 | switch(vic2->cycle) |
| 999 | 1036 | { |
| 1000 | 1037 | |
| r8745 | r8746 | |
| 1034 | 1071 | else |
| 1035 | 1072 | vic2_resume_cpu(machine, vic2); |
| 1036 | 1073 | |
| 1074 | if (vic2->spr_dma_on & 0x08) rdy_cycles += (2 + adjust[1]); |
| 1075 | |
| 1037 | 1076 | vic2->cycle++; |
| 1038 | 1077 | break; |
| 1039 | 1078 | |
| r8745 | r8746 | |
| 1078 | 1117 | else |
| 1079 | 1118 | vic2_resume_cpu(machine, vic2); |
| 1080 | 1119 | |
| 1120 | if (vic2->spr_dma_on & 0x10) rdy_cycles += (2 + adjust[2]); |
| 1121 | |
| 1081 | 1122 | vic2->cycle++; |
| 1082 | 1123 | break; |
| 1083 | 1124 | |
| r8745 | r8746 | |
| 1101 | 1142 | else |
| 1102 | 1143 | vic2_resume_cpu(machine, vic2); |
| 1103 | 1144 | |
| 1145 | if (vic2->spr_dma_on & 0x20) rdy_cycles += (2 + adjust[3]); |
| 1146 | |
| 1104 | 1147 | vic2->cycle++; |
| 1105 | 1148 | break; |
| 1106 | 1149 | |
| r8745 | r8746 | |
| 1124 | 1167 | else |
| 1125 | 1168 | vic2_resume_cpu(machine, vic2); |
| 1126 | 1169 | |
| 1170 | if (vic2->spr_dma_on & 0x40) rdy_cycles += (2 + adjust[4]); |
| 1171 | |
| 1127 | 1172 | vic2->cycle++; |
| 1128 | 1173 | break; |
| 1129 | 1174 | |
| r8745 | r8746 | |
| 1147 | 1192 | else |
| 1148 | 1193 | vic2_resume_cpu(machine, vic2); |
| 1149 | 1194 | |
| 1195 | if (vic2->spr_dma_on & 0x80) rdy_cycles += (2 + adjust[5]); |
| 1196 | |
| 1150 | 1197 | vic2->cycle++; |
| 1151 | 1198 | break; |
| 1152 | 1199 | |
| r8745 | r8746 | |
| 1187 | 1234 | vic2->raster_x = 0xfffc; |
| 1188 | 1235 | |
| 1189 | 1236 | if ((vic2->rdy_workaround_cb(machine) == 0 ) && (vic2->is_bad_line)) |
| 1190 | | vic2_suspend_cpu(machine, vic2); |
| 1237 | rdy_cycles += (43+adjust[0]); |
| 1191 | 1238 | |
| 1192 | 1239 | vic2->cycle++; |
| 1193 | 1240 | break; |
| r8745 | r8746 | |
| 1202 | 1249 | vic2->vc = vic2->vc_base; |
| 1203 | 1250 | |
| 1204 | 1251 | if ((vic2->rdy_workaround_cb(machine) == 1 ) && (vic2->is_bad_line)) |
| 1205 | | vic2_suspend_cpu(machine, vic2); |
| 1252 | rdy_cycles += (42+adjust[0]); |
| 1206 | 1253 | |
| 1207 | 1254 | vic2->cycle++; |
| 1208 | 1255 | break; |
| r8745 | r8746 | |
| 1222 | 1269 | vic2_matrix_access(machine, vic2); |
| 1223 | 1270 | |
| 1224 | 1271 | if ((vic2->rdy_workaround_cb(machine) == 2 ) && (vic2->is_bad_line)) |
| 1225 | | vic2_suspend_cpu(machine, vic2); |
| 1272 | rdy_cycles += (41+adjust[0]); |
| 1226 | 1273 | |
| 1227 | 1274 | vic2->cycle++; |
| 1228 | 1275 | break; |
| r8745 | r8746 | |
| 1246 | 1293 | vic2_matrix_access(machine, vic2); |
| 1247 | 1294 | |
| 1248 | 1295 | if ((vic2->rdy_workaround_cb(machine) == 3 ) && (vic2->is_bad_line)) |
| 1249 | | vic2_suspend_cpu(machine, vic2); |
| 1296 | rdy_cycles += (40+adjust[0]); |
| 1250 | 1297 | |
| 1251 | 1298 | vic2->cycle++; |
| 1252 | 1299 | break; |
| r8745 | r8746 | |
| 1283 | 1330 | vic2_matrix_access(machine, vic2); |
| 1284 | 1331 | |
| 1285 | 1332 | if ((vic2->rdy_workaround_cb(machine) == 4 ) && (vic2->is_bad_line)) |
| 1286 | | vic2_suspend_cpu(machine, vic2); |
| 1333 | rdy_cycles += (40+adjust[0]); |
| 1287 | 1334 | |
| 1288 | 1335 | vic2->cycle++; |
| 1289 | 1336 | break; |
| r8745 | r8746 | |
| 1456 | 1503 | else |
| 1457 | 1504 | vic2_resume_cpu(machine, vic2); |
| 1458 | 1505 | |
| 1506 | if (vic2->spr_dma_on & 0x01) rdy_cycles += (2 + adjust[6]); |
| 1507 | |
| 1459 | 1508 | vic2->cycle++; |
| 1460 | 1509 | break; |
| 1461 | 1510 | |
| r8745 | r8746 | |
| 1511 | 1560 | else |
| 1512 | 1561 | vic2_resume_cpu(machine, vic2); |
| 1513 | 1562 | |
| 1563 | if (vic2->spr_dma_on & 0x02) rdy_cycles += (2 + adjust[7]); |
| 1564 | |
| 1514 | 1565 | vic2->cycle++; |
| 1515 | 1566 | break; |
| 1516 | 1567 | |
| r8745 | r8746 | |
| 1534 | 1585 | else |
| 1535 | 1586 | vic2_resume_cpu(machine, vic2); |
| 1536 | 1587 | |
| 1588 | if (vic2->spr_dma_on & 0x04) rdy_cycles += (2 + adjust[8]); |
| 1589 | |
| 1537 | 1590 | vic2->cycle++; |
| 1538 | 1591 | break; |
| 1539 | 1592 | |
| r8745 | r8746 | |
| 1553 | 1606 | vic2->cycle = 1; |
| 1554 | 1607 | } |
| 1555 | 1608 | |
| 1609 | if ((cpu_cycles == vic_cycles) && (rdy_cycles > 0)) |
| 1610 | { |
| 1611 | device_spin_until_time (machine->firstcpu, machine->device<cpu_device>("maincpu")->cycles_to_attotime(rdy_cycles)); |
| 1612 | rdy_cycles = 0; |
| 1613 | } |
| 1614 | |
| 1556 | 1615 | vic2->raster_x += 8; |
| 1557 | 1616 | timer_set(machine, machine->device<cpu_device>("maincpu")->cycles_to_attotime(1), vic2, 0, pal_timer_callback); |
| 1558 | 1617 | } |
| r8745 | r8746 | |
| 2685 | 2744 | // from 0 to 311 (0 first, PAL) or from 0 to 261 (? first, NTSC 6567R56A) or from 0 to 262 (? first, NTSC 6567R8) |
| 2686 | 2745 | vic2->rasterline = 0; // VIC2_LINES - 1; |
| 2687 | 2746 | |
| 2688 | | vic2->cycles_counter = 0; |
| 2747 | vic2->cycles_counter = -1; |
| 2689 | 2748 | vic2->cycle = 63; |
| 2690 | 2749 | |
| 2691 | 2750 | vic2->on = 1; |