summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--render_sdl.c16
-rw-r--r--vdp.c110
-rw-r--r--vdp.h2
3 files changed, 101 insertions, 27 deletions
diff --git a/render_sdl.c b/render_sdl.c
index da6fc02..8c75b46 100644
--- a/render_sdl.c
+++ b/render_sdl.c
@@ -34,9 +34,19 @@ void render_init(int width, int height)
}
uint8_t b,g,r;
for (uint16_t color = 0; color < (1 << 12); color++) {
- b = levels[(color >> 8) & 0xE];
- g = levels[(color >> 4) & 0xE];
- r = levels[color & 0xE];
+ if (color & FBUF_SHADOW) {
+ b = levels[(color >> 9) & 0x7];
+ g = levels[(color >> 5) & 0x7];
+ r = levels[(color >> 1) & 0x7];
+ } else if(color & FBUF_HILIGHT) {
+ b = levels[((color >> 9) & 0x7) + 7];
+ g = levels[((color >> 5) & 0x7) + 7];
+ r = levels[((color >> 1) & 0x7) + 7];
+ } else {
+ b = levels[(color >> 8) & 0xE];
+ g = levels[(color >> 4) & 0xE];
+ r = levels[color & 0xE];
+ }
color_map[color] = SDL_MapRGB(screen->format, r, g, b);
}
min_delay = 0;
diff --git a/vdp.c b/vdp.c
index 75edbd3..4387f48 100644
--- a/vdp.c
+++ b/vdp.c
@@ -14,6 +14,8 @@
#define BIT_DMA_ENABLE 0x4
#define BIT_H40 0x1
+#define BIT_HILIGHT 0x8
+
#define SCROLL_BUFFER_SIZE 32
#define SCROLL_BUFFER_DRAW 16
@@ -516,31 +518,91 @@ void render_map_output(uint32_t line, int32_t col, vdp_context * context)
end = dst + 16;
uint16_t src;
//printf("A | tmp_buf offset: %d\n", 8 - (context->hscroll_a & 0x7));
- for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) {
- uint8_t pixel;
- if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) {
- pixel = *sprite_buf;
- src = FBUF_SRC_S;
- } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) {
- pixel = *plane_a;
- src = a_src;
- } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) {
- pixel = *plane_b;
- src = FBUF_SRC_B;
- } else if (*sprite_buf & 0xF) {
- pixel = *sprite_buf;
- src = FBUF_SRC_S;
- } else if (*plane_a & 0xF) {
- pixel = *plane_a;
- src = a_src;
- } else if (*plane_b & 0xF){
- pixel = *plane_b;
- src = FBUF_SRC_B;
- } else {
- pixel = context->regs[REG_BG_COLOR] & 0x3F;
- src = FBUF_SRC_BG;
+
+ if (context->regs[REG_MODE_4] & BIT_HILIGHT) {
+ for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) {
+ uint8_t pixel;
+
+ src = 0;
+ uint8_t sprite_color = *sprite_buf & 0x3F;
+ if (sprite_color == 0x3E || sprite_color == 0x3F) {
+ if (sprite_color == 0x3E) {
+ src |= FBUF_SHADOW;
+ } else {
+ src |= FBUF_HILIGHT;
+ }
+ if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) {
+ pixel = *plane_a;
+ src |= a_src;
+ } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) {
+ pixel = *plane_b;
+ src |= FBUF_SRC_B;
+ } else if (*plane_a & 0xF) {
+ pixel = *plane_a;
+ src |= a_src;
+ } else if (*plane_b & 0xF){
+ pixel = *plane_b;
+ src |= FBUF_SRC_B;
+ } else {
+ pixel = context->regs[REG_BG_COLOR] & 0x3F;
+ src |= FBUF_SRC_BG;
+ }
+ } else {
+ if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) {
+ pixel = *sprite_buf;
+ src = FBUF_SRC_S;
+ } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) {
+ pixel = *plane_a;
+ src = a_src;
+ } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) {
+ pixel = *plane_b;
+ src = FBUF_SRC_B;
+ } else if (*sprite_buf & 0xF) {
+ pixel = *sprite_buf;
+ src = FBUF_SRC_S;
+ if (*sprite_buf & 0xF != 0xE) {
+ src |= FBUF_SHADOW;
+ }
+ } else if (*plane_a & 0xF) {
+ pixel = *plane_a;
+ src = a_src | FBUF_SHADOW;
+ } else if (*plane_b & 0xF){
+ pixel = *plane_b;
+ src = FBUF_SRC_B | FBUF_SHADOW;
+ } else {
+ pixel = context->regs[REG_BG_COLOR] & 0x3F;
+ src = FBUF_SRC_BG | FBUF_SHADOW;
+ }
+ }
+ *dst = (context->cram[pixel & 0x3F] & 0xEEE) | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src;
+ }
+ } else {
+ for (; dst < end; ++plane_a, ++plane_b, ++sprite_buf, ++dst) {
+ uint8_t pixel;
+ if (*sprite_buf & BUF_BIT_PRIORITY && *sprite_buf & 0xF) {
+ pixel = *sprite_buf;
+ src = FBUF_SRC_S;
+ } else if (*plane_a & BUF_BIT_PRIORITY && *plane_a & 0xF) {
+ pixel = *plane_a;
+ src = a_src;
+ } else if (*plane_b & BUF_BIT_PRIORITY && *plane_b & 0xF) {
+ pixel = *plane_b;
+ src = FBUF_SRC_B;
+ } else if (*sprite_buf & 0xF) {
+ pixel = *sprite_buf;
+ src = FBUF_SRC_S;
+ } else if (*plane_a & 0xF) {
+ pixel = *plane_a;
+ src = a_src;
+ } else if (*plane_b & 0xF){
+ pixel = *plane_b;
+ src = FBUF_SRC_B;
+ } else {
+ pixel = context->regs[REG_BG_COLOR] & 0x3F;
+ src = FBUF_SRC_BG;
+ }
+ *dst = context->cram[pixel & 0x3F] | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src;
}
- *dst = context->cram[pixel & 0x3F] | ((pixel & BUF_BIT_PRIORITY) ? FBUF_BIT_PRIORITY : 0) | src;
}
} else {
//dst = context->framebuf + line * 320;
diff --git a/vdp.h b/vdp.h
index fe5e559..650c372 100644
--- a/vdp.h
+++ b/vdp.h
@@ -18,6 +18,8 @@
#define MAX_SPRITES_FRAME 80
#define MAX_SPRITES_FRAME_H32 64
+#define FBUF_SHADOW 0x0001
+#define FBUF_HILIGHT 0x0010
#define FBUF_BIT_PRIORITY 0x1000
#define FBUF_SRC_MASK 0xE000
#define FBUF_SRC_A 0x0000