comparison vdp.c @ 230:d3266cee02c9

Implemented shadow hilight mode.
author Mike Pavone <pavone@retrodev.com>
date Mon, 22 Apr 2013 19:39:38 -0700
parents 1b4d856b067a
children 54873acb982e
comparison
equal deleted inserted replaced
229:d60837a7d18a 230:d3266cee02c9
11 #define MAP_BIT_V_FLIP 0x1000 11 #define MAP_BIT_V_FLIP 0x1000
12 12
13 #define BIT_PAL 0x8 13 #define BIT_PAL 0x8
14 #define BIT_DMA_ENABLE 0x4 14 #define BIT_DMA_ENABLE 0x4
15 #define BIT_H40 0x1 15 #define BIT_H40 0x1
16
17 #define BIT_HILIGHT 0x8
16 18
17 #define SCROLL_BUFFER_SIZE 32 19 #define SCROLL_BUFFER_SIZE 32
18 #define SCROLL_BUFFER_DRAW 16 20 #define SCROLL_BUFFER_DRAW 16
19 21
20 #define FIFO_SIZE 4 22 #define FIFO_SIZE 4
514 } 516 }
515 plane_b = context->tmp_buf_b + SCROLL_BUFFER_DRAW - (context->hscroll_b & 0xF); 517 plane_b = context->tmp_buf_b + SCROLL_BUFFER_DRAW - (context->hscroll_b & 0xF);
516 end = dst + 16; 518 end = dst + 16;
517 uint16_t src; 519 uint16_t src;
518 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7)); 520 //printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7));
519 for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) { 521
520 uint8_t pixel; 522 if (context->regs[REG_MODE_4] & BIT_HILIGHT) {
521 if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) { 523 for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) {
522 pixel = *sprite_buf; 524 uint8_t pixel;
523 src = FBUF_SRC_S; 525
524 } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) { 526 src = 0;
525 pixel = *plane_a; 527 uint8_t sprite_color = *sprite_buf & 0x3F;
526 src = a_src; 528 if (sprite_color == 0x3E || sprite_color == 0x3F) {
527 } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) { 529 if (sprite_color == 0x3E) {
528 pixel = *plane_b; 530 src |= FBUF_SHADOW;
529 src = FBUF_SRC_B; 531 } else {
530 } else if (*sprite_buf & 0xF) { 532 src |= FBUF_HILIGHT;
531 pixel = *sprite_buf; 533 }
532 src = FBUF_SRC_S; 534 if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) {
533 } else if (*plane_a & 0xF) { 535 pixel = *plane_a;
534 pixel = *plane_a; 536 src |= a_src;
535 src = a_src; 537 } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) {
536 } else if (*plane_b & 0xF){ 538 pixel = *plane_b;
537 pixel = *plane_b; 539 src |= FBUF_SRC_B;
538 src = FBUF_SRC_B; 540 } else if (*plane_a & 0xF) {
539 } else { 541 pixel = *plane_a;
540 pixel = context->regs[REG_BG_COLOR] & 0x3F; 542 src |= a_src;
541 src = FBUF_SRC_BG; 543 } else if (*plane_b & 0xF){
542 } 544 pixel = *plane_b;
543 *dst = context->cram[pixel & 0x3F] | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src; 545 src |= FBUF_SRC_B;
546 } else {
547 pixel = context->regs[REG_BG_COLOR] & 0x3F;
548 src |= FBUF_SRC_BG;
549 }
550 } else {
551 if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) {
552 pixel = *sprite_buf;
553 src = FBUF_SRC_S;
554 } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) {
555 pixel = *plane_a;
556 src = a_src;
557 } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) {
558 pixel = *plane_b;
559 src = FBUF_SRC_B;
560 } else if (*sprite_buf & 0xF) {
561 pixel = *sprite_buf;
562 src = FBUF_SRC_S;
563 if (*sprite_buf & 0xF != 0xE) {
564 src |= FBUF_SHADOW;
565 }
566 } else if (*plane_a & 0xF) {
567 pixel = *plane_a;
568 src = a_src | FBUF_SHADOW;
569 } else if (*plane_b & 0xF){
570 pixel = *plane_b;
571 src = FBUF_SRC_B | FBUF_SHADOW;
572 } else {
573 pixel = context->regs[REG_BG_COLOR] & 0x3F;
574 src = FBUF_SRC_BG | FBUF_SHADOW;
575 }
576 }
577 *dst = (context->cram[pixel & 0x3F] & 0xEEE) | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src;
578 }
579 } else {
580 for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) {
581 uint8_t pixel;
582 if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) {
583 pixel = *sprite_buf;
584 src = FBUF_SRC_S;
585 } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) {
586 pixel = *plane_a;
587 src = a_src;
588 } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) {
589 pixel = *plane_b;
590 src = FBUF_SRC_B;
591 } else if (*sprite_buf & 0xF) {
592 pixel = *sprite_buf;
593 src = FBUF_SRC_S;
594 } else if (*plane_a & 0xF) {
595 pixel = *plane_a;
596 src = a_src;
597 } else if (*plane_b & 0xF){
598 pixel = *plane_b;
599 src = FBUF_SRC_B;
600 } else {
601 pixel = context->regs[REG_BG_COLOR] & 0x3F;
602 src = FBUF_SRC_BG;
603 }
604 *dst = context->cram[pixel & 0x3F] | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src;
605 }
544 } 606 }
545 } else { 607 } else {
546 //dst = context->framebuf + line * 320; 608 //dst = context->framebuf + line * 320;
547 //sprite_buf = context->linebuf + col * 8; 609 //sprite_buf = context->linebuf + col * 8;
548 //plane_a = context->tmp_buf_a + 16 - (context->hscroll_a & 0x7); 610 //plane_a = context->tmp_buf_a + 16 - (context->hscroll_a & 0x7);