src/mess/video/vic6567.c
| r3231 | r3232 | |
| 455 | 455 | case 0x11: |
| 456 | 456 | if (vic2.reg[offset] != data) |
| 457 | 457 | { |
| 458 | // vic2.reg_buffer[offset] = data; |
| 459 | |
| 458 | 460 | vic2.reg[offset] = data; |
| 459 | 461 | if (LINES25) |
| 460 | 462 | { |
| r3231 | r3232 | |
| 466 | 468 | vic2.y_begin = 4; |
| 467 | 469 | vic2.y_end = vic2.y_begin + 192; |
| 468 | 470 | } |
| 471 | |
| 469 | 472 | } |
| 470 | 473 | break; |
| 471 | 474 | case 0x12: |
| r3231 | r3232 | |
| 477 | 480 | case 0x16: |
| 478 | 481 | if (vic2.reg[offset] != data) |
| 479 | 482 | { |
| 483 | // vic2.reg_buffer[offset] = data; |
| 484 | |
| 480 | 485 | vic2.reg[offset] = data; |
| 481 | 486 | if (COLUMNS40) |
| 482 | 487 | { |
| r3231 | r3232 | |
| 488 | 493 | vic2.x_begin = HORIZONTALPOS; |
| 489 | 494 | vic2.x_end = vic2.x_begin + 320; |
| 490 | 495 | } |
| 496 | |
| 491 | 497 | } |
| 492 | 498 | break; |
| 493 | 499 | case 0x18: |
| r3231 | r3232 | |
| 1170 | 1176 | int attr, ch, ecm; |
| 1171 | 1177 | int syend; |
| 1172 | 1178 | int offs, yoff, xoff, ybegin, yend, xbegin, xend; |
| 1173 | | int i, j; |
| 1179 | int i; |
| 1174 | 1180 | |
| 1175 | 1181 | if (vic2.vic3 && VIC3_BITPLANES) return ; |
| 1182 | |
| 1176 | 1183 | /* temporary allowing vic3 displaying 80 columns */ |
| 1177 | | if (vic2.vic3&&(vic2.reg[0x31]&0x80)) { |
| 1178 | | vic3_drawlines(first , last, start_x, end_x); |
| 1184 | if (vic2.vic3 && (vic2.reg[0x31] & 0x80)) |
| 1185 | { |
| 1186 | vic3_drawlines(first, first + 1, start_x, end_x); |
| 1179 | 1187 | return; |
| 1180 | 1188 | } |
| 1181 | 1189 | |
| 1182 | | if (first == last) |
| 1183 | | return; |
| 1184 | | vic2.lastline = last; |
| 1185 | 1190 | if (video_skip_this_frame ()) |
| 1186 | 1191 | return; |
| 1187 | 1192 | |
| 1188 | 1193 | /* top part of display not rastered */ |
| 1189 | 1194 | first -= VIC2_YPOS - YPOS; |
| 1190 | | last -= VIC2_YPOS - YPOS; |
| 1191 | 1195 | |
| 1192 | | /* |
| 1193 | | if ((first >= last) || (last <= 0)) |
| 1194 | | { |
| 1195 | | for (i = 0; i < 8; i++) |
| 1196 | | vic2.sprites[i].repeat = vic2.sprites[i].line = 0; |
| 1197 | | return; |
| 1198 | | } |
| 1199 | | if (first < 0) |
| 1200 | | first = 0; |
| 1201 | | */ |
| 1202 | 1196 | if (!SCREENON) |
| 1203 | 1197 | { |
| 1204 | | for (line = first; (line < last) && (line < vic2.bitmap->height); line++) |
| 1205 | | memset16 (BITMAP_ADDR16(vic2.bitmap, line + FIRSTLINE, 0), FRAMECOLOR, vic2.bitmap->width); |
| 1198 | // if (first < vic2.bitmap->height) |
| 1199 | memset16 (BITMAP_ADDR16(vic2.bitmap, first + FIRSTLINE, 0), FRAMECOLOR, vic2.bitmap->width); |
| 1206 | 1200 | return; |
| 1207 | 1201 | } |
| 1208 | 1202 | |
| r3231 | r3232 | |
| 1211 | 1205 | else |
| 1212 | 1206 | xbegin = XPOS + 7, xend = xbegin + 304; |
| 1213 | 1207 | |
| 1214 | | if (last < vic2.y_begin) |
| 1215 | | end = last; |
| 1208 | if (first + 1 < vic2.y_begin) |
| 1209 | end = first + 1; |
| 1216 | 1210 | else |
| 1217 | 1211 | end = vic2.y_begin + YPOS; |
| 1218 | 1212 | |
| 1219 | 1213 | line = first; |
| 1220 | | if (line < end) { |
| 1214 | if (line < end) |
| 1215 | { |
| 1221 | 1216 | plot_box(vic2.bitmap, start_x, line + FIRSTLINE, end_x - start_x, 1, FRAMECOLOR); |
| 1222 | | line=end; |
| 1217 | line = end; |
| 1223 | 1218 | } |
| 1224 | 1219 | |
| 1225 | 1220 | if (LINES25) |
| r3231 | r3232 | |
| 1230 | 1225 | { |
| 1231 | 1226 | vline = line - vic2.y_begin - YPOS + 8 - VERTICALPOS; |
| 1232 | 1227 | } |
| 1233 | | if (last < vic2.y_end + YPOS) |
| 1234 | | end = last; |
| 1228 | if (first + 1 < vic2.y_end + YPOS) |
| 1229 | end = first + 1; |
| 1235 | 1230 | else |
| 1236 | 1231 | end = vic2.y_end + YPOS; |
| 1237 | 1232 | |
| 1238 | | for (; line < end; vline = (vline + 8) & ~7, line = line + 1 + yend - ybegin) |
| 1233 | if (line < end) |
| 1239 | 1234 | { |
| 1240 | 1235 | offs = (vline >> 3) * 40; |
| 1241 | 1236 | ybegin = vline & 7; |
| 1242 | 1237 | yoff = line - ybegin; |
| 1243 | 1238 | yend = (yoff + 7 < end) ? 7 : (end - yoff - 1); |
| 1239 | |
| 1244 | 1240 | /* rendering 39 characters */ |
| 1245 | 1241 | /* left and right borders are overwritten later */ |
| 1242 | |
| 1246 | 1243 | vic2.shift[line] = HORIZONTALPOS; |
| 1247 | 1244 | for (xoff = vic2.x_begin + XPOS; xoff < vic2.x_end + XPOS; xoff += 8, offs++) |
| 1248 | 1245 | { |
| r3231 | r3232 | |
| 1285 | 1282 | vic2_draw_character (ybegin, yend, ch, yoff, xoff, vic2.mono, start_x, end_x); |
| 1286 | 1283 | } |
| 1287 | 1284 | } |
| 1288 | | } |
| 1289 | 1285 | |
| 1290 | | line = first; |
| 1291 | | if (LINES25) |
| 1292 | | { |
| 1293 | | vline = line - vic2.y_begin - YPOS; |
| 1294 | | } |
| 1295 | | else |
| 1296 | | { |
| 1297 | | vline = line - vic2.y_begin - YPOS + 8 - VERTICALPOS; |
| 1298 | | } |
| 1299 | | if (last < vic2.y_end + YPOS) |
| 1300 | | end = last; |
| 1301 | | else |
| 1302 | | end = vic2.y_end + YPOS; |
| 1303 | | |
| 1304 | | for (; line < end; vline = (vline + 8) & ~7, line = line + 1 + yend - ybegin) |
| 1305 | | { |
| 1306 | | offs = (vline >> 3) * 40; |
| 1307 | | ybegin = vline & 7; |
| 1308 | | yoff = line - ybegin; |
| 1309 | | yend = (yoff + 7 < end) ? 7 : (end - yoff - 1); |
| 1310 | 1286 | /* sprite priority, sprite overwrites lowerprior pixels */ |
| 1311 | 1287 | for (i = 7; i >= 0; i--) |
| 1312 | 1288 | { |
| 1313 | | if (vic2.sprites[i].line || vic2.sprites[i].repeat) // FIX ME: sprite warp is wrong |
| 1314 | | { |
| 1315 | | syend = yend; |
| 1316 | | if (SPRITE_Y_EXPAND (i)) |
| 1317 | | { |
| 1318 | | if ((21 - vic2.sprites[i].line) * 2 - vic2.sprites[i].repeat < yend - ybegin + 1) |
| 1319 | | syend = ybegin + (21 - vic2.sprites[i].line) * 2 - vic2.sprites[i].repeat - 1; |
| 1320 | | } |
| 1321 | | else |
| 1322 | | { |
| 1323 | | if (vic2.sprites[i].line + yend - ybegin + 1 > 20) |
| 1324 | | syend = ybegin + 20 - vic2.sprites[i].line; |
| 1325 | | } |
| 1326 | | if (yoff + syend > YPOS + 200) |
| 1327 | | syend = YPOS + 200 - yoff - 1; |
| 1328 | | if (yoff + ybegin < 0) |
| 1329 | | { |
| 1330 | | ybegin = -yoff; |
| 1331 | | yend = - yoff; |
| 1332 | | } |
| 1333 | | |
| 1334 | | if (SPRITE_MULTICOLOR (i)) |
| 1335 | | vic2_draw_sprite_multi (i, yoff, ybegin, syend, start_x, end_x); |
| 1336 | | else |
| 1337 | | vic2_draw_sprite (i, yoff, ybegin, syend, start_x, end_x); |
| 1338 | | if ((syend != yend) || (vic2.sprites[i].line > 20)) |
| 1339 | | { |
| 1340 | | vic2.sprites[i].line = vic2.sprites[i].repeat = 0; |
| 1341 | | for (j = syend; j <= yend; j++) |
| 1342 | | vic2.sprites[i].paintedline[j] = 0; |
| 1343 | | } |
| 1344 | | } |
| 1345 | | else if (SPRITEON (i) && |
| 1289 | if (SPRITEON (i) && |
| 1346 | 1290 | (yoff + ybegin >= SPRITE_Y_POS (i)) && |
| 1347 | 1291 | (yoff + ybegin - SPRITE_Y_POS (i) < (SPRITE_Y_EXPAND (i)? 21 * 2 : 21 )) && |
| 1348 | 1292 | (SPRITE_Y_POS (i) < 0)) |
| r3231 | r3232 | |
| 1370 | 1314 | vic2_draw_sprite_multi (i, 0, 0 , syend, start_x, end_x); |
| 1371 | 1315 | else |
| 1372 | 1316 | vic2_draw_sprite (i, 0, 0 , syend, start_x, end_x); |
| 1373 | | |
| 1374 | | if ((syend != yend) || (vic2.sprites[i].line > 20)) |
| 1375 | | { |
| 1376 | | for (j = syend; j <= yend; j++) |
| 1377 | | vic2.sprites[i].paintedline[j] = 0; |
| 1378 | | vic2.sprites[i].line = vic2.sprites[i].repeat = 0; |
| 1379 | | } |
| 1380 | 1317 | } |
| 1381 | 1318 | else if (SPRITEON (i) && |
| 1382 | 1319 | (yoff + ybegin >= SPRITE_Y_POS (i)) && |
| r3231 | r3232 | |
| 1402 | 1339 | |
| 1403 | 1340 | vic2.sprites[i].line = wrapped; |
| 1404 | 1341 | |
| 1405 | | for (j = 0; j < SPRITE_Y_POS (i) - yoff; j++) |
| 1406 | | vic2.sprites[i].paintedline[j] = 0; |
| 1407 | | |
| 1408 | 1342 | if (SPRITE_MULTICOLOR (i)) |
| 1409 | 1343 | vic2_draw_sprite_multi (i, yoff + ybegin, 0, 0, start_x, end_x); |
| 1410 | 1344 | else |
| 1411 | 1345 | vic2_draw_sprite (i, yoff + ybegin, 0, 0, start_x, end_x); |
| 1412 | | |
| 1413 | | if ((syend != yend) || (vic2.sprites[i].line > 20)) |
| 1414 | | { |
| 1415 | | for (j = syend; j <= yend; j++) |
| 1416 | | vic2.sprites[i].paintedline[j] = 0; |
| 1417 | | vic2.sprites[i].line = vic2.sprites[i].repeat = 0; |
| 1418 | | } |
| 1419 | 1346 | } |
| 1420 | 1347 | else |
| 1421 | 1348 | { |
| 1422 | 1349 | memset (vic2.sprites[i].paintedline, 0, sizeof (vic2.sprites[i].paintedline)); |
| 1423 | 1350 | } |
| 1424 | 1351 | } |
| 1352 | line += 1 + yend - ybegin; |
| 1425 | 1353 | } |
| 1426 | 1354 | // TO DO: to implement start_x and end_x |
| 1427 | 1355 | plot_box(vic2.bitmap, 0, first + FIRSTLINE, xbegin, 1, FRAMECOLOR); |
| 1428 | 1356 | plot_box(vic2.bitmap, xend, first + FIRSTLINE, vic2.bitmap->width - xend, 1, FRAMECOLOR); |
| 1429 | 1357 | |
| 1430 | | if (last < vic2.bitmap->height) |
| 1431 | | end = last; |
| 1358 | if (first + 1 < vic2.bitmap->height) |
| 1359 | end = first + 1; |
| 1432 | 1360 | else |
| 1433 | 1361 | end = vic2.bitmap->height; |
| 1434 | 1362 | |
| r3231 | r3232 | |
| 1443 | 1371 | // TIMER_CALLBACK( vic2_scanline_interrupt ) |
| 1444 | 1372 | INTERRUPT_GEN( vic2_raster_irq ) |
| 1445 | 1373 | { |
| 1446 | | int i; |
| 1374 | int i,j; |
| 1447 | 1375 | // int scanline = param; |
| 1448 | 1376 | |
| 1449 | 1377 | vic2.rasterline++; |
| r3231 | r3232 | |
| 1463 | 1391 | } |
| 1464 | 1392 | for (i=0; i < 5; i++) |
| 1465 | 1393 | vic2.spritemulti[i] = vic2.spritemulti_buffer[i]; |
| 1466 | | // if (input_code_pressed(KEYCODE_Q)) { cpunum_set_clock(machine, 0, 0x93203); } |
| 1467 | | // if (input_code_pressed(KEYCODE_W)) { cpunum_set_clock(machine, 0, 0xf08a0); } |
| 1468 | | // if (input_code_pressed(KEYCODE_E)) printf("%04x ",cpunum_get_clock(0)); |
| 1469 | | // if (input_code_pressed(KEYCODE_R)) printf("%04x ", (int)(cpunum_get_clock(0)*63/103)); |
| 1394 | /* |
| 1395 | i=0; |
| 1396 | if (input_code_pressed(KEYCODE_Q)) i = 1; |
| 1397 | if (input_code_pressed(KEYCODE_W)) i = 2; |
| 1398 | if (input_code_pressed(KEYCODE_E)) i = 3; |
| 1399 | if (input_code_pressed(KEYCODE_R)) i = 4; |
| 1400 | if (input_code_pressed(KEYCODE_T)) i = 5; |
| 1401 | if (input_code_pressed(KEYCODE_Y)) i = 6; |
| 1402 | if (input_code_pressed(KEYCODE_U)) i = 7; |
| 1403 | |
| 1404 | if ((vic2.rasterline % 8) == 0x02) |
| 1405 | { |
| 1406 | vic2.reg[0x11] = vic2.reg_buffer[0x11]; |
| 1407 | if (LINES25) |
| 1408 | { |
| 1409 | vic2.y_begin = 0; |
| 1410 | vic2.y_end = vic2.y_begin + 200; |
| 1411 | } |
| 1412 | else |
| 1413 | { |
| 1414 | vic2.y_begin = 4; |
| 1415 | vic2.y_end = vic2.y_begin + 192; |
| 1416 | } |
| 1417 | |
| 1418 | vic2.reg[0x16] = vic2.reg_buffer[0x16]; |
| 1419 | if (COLUMNS40) |
| 1420 | { |
| 1421 | vic2.x_begin = 0; |
| 1422 | vic2.x_end = vic2.x_begin + 320; |
| 1423 | } |
| 1424 | else |
| 1425 | { |
| 1426 | vic2.x_begin = HORIZONTALPOS; |
| 1427 | vic2.x_end = vic2.x_begin + 320; |
| 1428 | } |
| 1429 | } |
| 1430 | */ |
| 1431 | /* |
| 1432 | if (input_code_pressed(KEYCODE_Q)) { cpunum_set_clock(machine, 0, 0x93203); } |
| 1433 | if (input_code_pressed(KEYCODE_W)) { cpunum_set_clock(machine, 0, 0xf08a0); } |
| 1434 | if (input_code_pressed(KEYCODE_E)) printf("%04x ",cpunum_get_clock(0)); |
| 1435 | if (input_code_pressed(KEYCODE_R)) printf("%04x ", (int)(cpunum_get_clock(0)*63/103)); |
| 1470 | 1436 | vic2.raster_mod += 63 - (activecpu_gettotalcycles() - vic2.rasterline_start_cpu_cycles); |
| 1471 | | // if (input_code_pressed(KEYCODE_Q)) printf("%04x-%04x ",vic2.raster_mod, (int)(activecpu_gettotalcycles() - vic2.rasterline_start_cpu_cycles)); |
| 1437 | if (input_code_pressed(KEYCODE_Q)) printf("%04x-%04x ",vic2.raster_mod, (int)(activecpu_gettotalcycles() - vic2.rasterline_start_cpu_cycles)); |
| 1472 | 1438 | vic2.rasterline_start_cpu_cycles = activecpu_gettotalcycles(); |
| 1473 | 1439 | if (vic2.raster_mod > 63) |
| 1474 | 1440 | { |
| r3231 | r3232 | |
| 1480 | 1446 | vic2.raster_mod += 63; |
| 1481 | 1447 | vic2.rasterline++; |
| 1482 | 1448 | } |
| 1483 | | |
| 1449 | */ |
| 1484 | 1450 | if (vic2.rasterline == vic2.lines) |
| 1485 | 1451 | { |
| 1486 | 1452 | vic2.rasterline = 0; |
| 1487 | 1453 | |
| 1454 | |
| 1455 | |
| 1488 | 1456 | for (i = 0; i < 8; i++) |
| 1457 | { |
| 1489 | 1458 | vic2.sprites[i].repeat = vic2.sprites[i].line = 0; |
| 1490 | | vic2.lastline = 0; |
| 1459 | for (j = 0; j < 256; j++) |
| 1460 | vic2.sprites[i].paintedline[j] = 0; |
| 1461 | } |
| 1462 | |
| 1491 | 1463 | if (LIGHTPEN_BUTTON) |
| 1492 | 1464 | { |
| 1493 | 1465 | /* lightpen timer starten */ |
| 1494 | 1466 | timer_set (attotime_make(0, 0), NULL, 1, vic2_timer_timeout); |
| 1495 | 1467 | } |
| 1496 | 1468 | } |
| 1497 | | // activecpu_eat_cycles(1000); |
| 1498 | 1469 | |
| 1499 | 1470 | if (vic2.rasterline == C64_2_RASTERLINE(RASTERLINE)) |
| 1500 | 1471 | { |