comparison vdp.c @ 1322:b1423d432c0e

Initial stab at implementing the output disable/layer selection bits of the VDP test register
author Michael Pavone <pavone@retrodev.com>
date Tue, 18 Apr 2017 19:27:10 -0700
parents 0849e9356bfe
children 58bfbed6cdb5
comparison
equal deleted inserted replaced
1321:0849e9356bfe 1322:b1423d432c0e
1252 plane_a_off = context->buf_a_off - (context->hscroll_a & 0xF); 1252 plane_a_off = context->buf_a_off - (context->hscroll_a & 0xF);
1253 a_src = DBG_SRC_A; 1253 a_src = DBG_SRC_A;
1254 } 1254 }
1255 plane_b_off = context->buf_b_off - (context->hscroll_b & 0xF); 1255 plane_b_off = context->buf_b_off - (context->hscroll_b & 0xF);
1256 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7)); 1256 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7));
1257 uint8_t output_disabled = (context->test_port & TEST_BIT_DISABLE) != 0;
1258 uint8_t test_layer = context->test_port >> 7 & 3;
1257 1259
1258 if (context->regs[REG_MODE_4] & BIT_HILIGHT) { 1260 if (context->regs[REG_MODE_4] & BIT_HILIGHT) {
1259 for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) { 1261 for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) {
1260 plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK); 1262 plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK);
1261 plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK); 1263 plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK);
1285 } else { 1287 } else {
1286 intensity |= pixel & BUF_BIT_PRIORITY; 1288 intensity |= pixel & BUF_BIT_PRIORITY;
1287 } 1289 }
1288 } 1290 }
1289 } 1291 }
1292 if (output_disabled) {
1293 pixel = 0x3F;
1294 }
1290 if (!intensity) { 1295 if (!intensity) {
1291 src |= DBG_SHADOW; 1296 src |= DBG_SHADOW;
1292 colors += CRAM_SIZE; 1297 colors += CRAM_SIZE;
1293 } else if (intensity == BUF_BIT_PRIORITY*2) { 1298 } else if (intensity == BUF_BIT_PRIORITY*2) {
1294 src |= DBG_HILIGHT; 1299 src |= DBG_HILIGHT;
1295 colors += CRAM_SIZE*2; 1300 colors += CRAM_SIZE*2;
1296 } 1301 }
1302 //TODO: Verify how test register stuff interacts with shadow/highlight
1303 //TODO: Simulate CRAM corruption from bus fight
1304 switch (test_layer)
1305 {
1306 case 1:
1307 pixel &= *sprite_buf;
1308 break;
1309 case 2:
1310 pixel &= *plane_a;
1311 break;
1312 case 3:
1313 pixel &= *plane_b;
1314 break;
1315 }
1297 1316
1298 uint32_t outpixel; 1317 uint32_t outpixel;
1299 if (context->debug) { 1318 if (context->debug) {
1300 outpixel = context->debugcolors[src]; 1319 outpixel = context->debugcolors[src];
1301 } else { 1320 } else {
1307 for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) { 1326 for (int i = 0; i < 16; ++plane_a_off, ++plane_b_off, ++sprite_buf, ++i) {
1308 plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK); 1327 plane_a = context->tmp_buf_a + (plane_a_off & SCROLL_BUFFER_MASK);
1309 plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK); 1328 plane_b = context->tmp_buf_b + (plane_b_off & SCROLL_BUFFER_MASK);
1310 uint8_t pixel = context->regs[REG_BG_COLOR]; 1329 uint8_t pixel = context->regs[REG_BG_COLOR];
1311 src = DBG_SRC_BG; 1330 src = DBG_SRC_BG;
1312 if (*plane_b & 0xF) { 1331 if (output_disabled) {
1313 pixel = *plane_b; 1332 pixel = 0x3F;
1314 src = DBG_SRC_B; 1333 } else {
1334 if (*plane_b & 0xF) {
1335 pixel = *plane_b;
1336 src = DBG_SRC_B;
1337 }
1338 if (*plane_a & 0xF && (*plane_a & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
1339 pixel = *plane_a;
1340 src = a_src;
1341 }
1342 if (*sprite_buf & 0xF && (*sprite_buf & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) {
1343 pixel = *sprite_buf;
1344 src = DBG_SRC_S;
1345 }
1315 } 1346 }
1316 if (*plane_a & 0xF && (*plane_a & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) { 1347 //TODO: Simulate CRAM corruption from bus fight
1317 pixel = *plane_a; 1348 switch (test_layer)
1318 src = a_src; 1349 {
1319 } 1350 case 1:
1320 if (*sprite_buf & 0xF && (*sprite_buf & BUF_BIT_PRIORITY) >= (pixel & BUF_BIT_PRIORITY)) { 1351 pixel &= *sprite_buf;
1321 pixel = *sprite_buf; 1352 break;
1322 src = DBG_SRC_S; 1353 case 2:
1354 pixel &= *plane_a;
1355 break;
1356 case 3:
1357 pixel &= *plane_b;
1358 break;
1323 } 1359 }
1324 uint32_t outpixel; 1360 uint32_t outpixel;
1325 if (context->debug) { 1361 if (context->debug) {
1326 outpixel = context->debugcolors[src]; 1362 outpixel = context->debugcolors[src];
1327 } else { 1363 } else {