Video 7 rendering fixes

This commit is contained in:
David Kuder 2023-05-02 19:27:43 -04:00
parent d915710a2a
commit f67a365804
4 changed files with 63 additions and 65 deletions

View File

@ -157,7 +157,7 @@ void __time_critical_func(vga_businterface)(uint32_t address, uint32_t value) {
break;
case 0x5f:
// Video 7 shift register
if(!soft_switches & SOFTSW_DGR) {
if(soft_switches & SOFTSW_DGR) {
internal_flags = (internal_flags & 0xfffffffc) | ((internal_flags & 0x1) << 1) | ((soft_switches & SOFTSW_80COL) ? 1 : 0);
}

View File

@ -6,7 +6,7 @@
#include "vga/render.h"
#include "vga/vgaout.h"
static void render_dhgr_line(bool p2, uint line);
static void render_dhgr_line(bool p2, uint line, bool mono);
uint16_t DELAYED_COPY_DATA(dhgr_palette)[16] = {
RGB_BLACK, RGB_DBLUE, RGB_DGREEN, RGB_HBLUE,
@ -25,26 +25,28 @@ static inline uint dhgr_line_to_mem_offset(uint line) {
void DELAYED_COPY_CODE(render_dhgr)() {
if((internal_flags & IFLAGS_VIDEO7) && (internal_flags & IFLAGS_V7_MODE3 == IFLAGS_V7_MODE0)) {
mono_rendering = true;
bool mono = mono_rendering;
if((internal_flags & IFLAGS_VIDEO7) && ((internal_flags & IFLAGS_V7_MODE3) == IFLAGS_V7_MODE0)) {
mono = true;
}
for(uint line=0; line < 192; line++) {
render_dhgr_line(PAGE2SEL, line);
render_dhgr_line(PAGE2SEL, line, mono);
}
}
void DELAYED_COPY_CODE(render_mixed_dhgr)() {
if((internal_flags & IFLAGS_VIDEO7) && (internal_flags & IFLAGS_V7_MODE3 == IFLAGS_V7_MODE0)) {
mono_rendering = true;
bool mono = mono_rendering;
if((internal_flags & IFLAGS_VIDEO7) && ((internal_flags & IFLAGS_V7_MODE3) == IFLAGS_V7_MODE0)) {
mono = true;
}
for(uint line=0; line < 160; line++) {
render_dhgr_line(PAGE2SEL, line);
render_dhgr_line(PAGE2SEL, line, mono);
}
render_mixed_text();
}
static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line) {
static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line, bool mono) {
struct vga_scanline *sl = vga_prepare_scanline();
uint sl_pos = 0;
uint i;
@ -52,11 +54,8 @@ static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line) {
const uint8_t *line_mema = (const uint8_t *)((p2 ? hgr_p2 : hgr_p1) + dhgr_line_to_mem_offset(line));
const uint8_t *line_memb = (const uint8_t *)((p2 ? hgr_p4 : hgr_p3) + dhgr_line_to_mem_offset(line));
if((internal_flags & IFLAGS_VIDEO7) && ((internal_flags & IFLAGS_V7_MODE3) == IFLAGS_V7_MODE1)) {
// Pad 30 pixels on the left to center horizontally
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
sl->data[sl_pos++] = (text_border|THEN_EXTEND_3) | ((text_border|THEN_EXTEND_7) << 16); // 12 pixels per word
sl->data[sl_pos++] = (text_border) | ((text_border) << 16); // 2 pixels per word
if((internal_flags & IFLAGS_VIDEO7) && ((internal_flags & IFLAGS_V7_MODE3) == IFLAGS_V7_MODE2)) {
// Pad 0 pixels on the left to center horizontally
} else {
// Pad 40 pixels on the left to center horizontally
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
@ -70,7 +69,7 @@ static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line) {
uint32_t pixeldata;
i = 0;
if(mono_rendering) {
if(mono) {
while(i < 40) {
// Load in as many subpixels as possible
while((dotc < 28) && (i < 40)) {
@ -91,7 +90,46 @@ static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line) {
dotc -= 2;
}
}
} else if((internal_flags & IFLAGS_VIDEO7) && ((soft_switches & (SOFTSW_80STORE | SOFTSW_80COL)) == (SOFTSW_80STORE))) {
uint32_t color1, color2, color3, color4;
int j;
// Video 7 F/B HiRes
while(i < 40) {
dots = (line_mema[i] & 0x7f);
color1 = lores_palette[(line_memb[i] >> 4) & 0xF];
color2 = lores_palette[(line_memb[i] >> 0) & 0xF];
i++;
dots |= (line_mema[i] & 0x7f) << 7;
color3 = lores_palette[(line_memb[i] >> 4) & 0xF];
color4 = lores_palette[(line_memb[i] >> 0) & 0xF];
i++;
for(j = 0; j < 3; j++) {
pixeldata = ((dots & 1) ? (color1) : (color2)) | THEN_EXTEND_1;
dots >>= 1;
pixeldata |= (((dots & 1) ? (color1) : (color2)) | THEN_EXTEND_1) << 16;
dots >>= 1;
sl->data[sl_pos++] = pixeldata;
}
pixeldata = ((dots & 1) ? (color1) : (color2)) | THEN_EXTEND_1;
dots >>= 1;
pixeldata |= (((dots & 1) ? (color3) : (color4)) | THEN_EXTEND_1) << 16;
dots >>= 1;
sl->data[sl_pos++] = pixeldata;
for(j = 0; j < 3; j++) {
pixeldata = ((dots & 1) ? (color3) : (color4)) | THEN_EXTEND_1;
dots >>= 1;
pixeldata |= (((dots & 1) ? (color3) : (color4)) | THEN_EXTEND_1) << 16;
dots >>= 1;
sl->data[sl_pos++] = pixeldata;
}
}
} else if((internal_flags & IFLAGS_VIDEO7) && ((internal_flags & IFLAGS_V7_MODE3) == IFLAGS_V7_MODE2)) {
// 160x192 Video-7
while(i < 40) {
// Load in as many subpixels as possible
while((dotc <= 18) && (i < 40)) {
@ -104,9 +142,9 @@ static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line) {
// Consume pixels
while(dotc >= 8) {
pixeldata = (dhgr_palette[dots & 0xf] | THEN_EXTEND_3);
pixeldata = (lores_palette[dots & 0xf] | THEN_EXTEND_3);
dots >>= 4;
pixeldata |= (dhgr_palette[dots & 0xf] | THEN_EXTEND_3) << 16;
pixeldata |= (lores_palette[dots & 0xf] | THEN_EXTEND_3) << 16;
dots >>= 4;
sl->data[sl_pos++] = pixeldata;
dotc -= 8;
@ -175,11 +213,8 @@ static void DELAYED_COPY_CODE(render_dhgr_line)(bool p2, uint line) {
sl->data[sl_pos++] = pixeldata;
}
if((internal_flags & IFLAGS_VIDEO7) && ((internal_flags & IFLAGS_V7_MODE3) == IFLAGS_V7_MODE1)) {
// Pad 30 pixels on the right to center horizontally
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word
sl->data[sl_pos++] = (text_border|THEN_EXTEND_3) | ((text_border|THEN_EXTEND_7) << 16); // 12 pixels per word
sl->data[sl_pos++] = (text_border) | ((text_border) << 16); // 2 pixels per word
if((internal_flags & IFLAGS_VIDEO7) && ((internal_flags & IFLAGS_V7_MODE3) == IFLAGS_V7_MODE2)) {
// Pad 0 pixels on the right to center horizontally
} else {
// Pad 40 pixels on the right to center horizontally
sl->data[sl_pos++] = (text_border|THEN_EXTEND_7) | ((text_border|THEN_EXTEND_7) << 16); // 16 pixels per word

View File

@ -10,7 +10,6 @@
#define PAGE2SEL ((soft_switches & (SOFTSW_80STORE | SOFTSW_PAGE_2)) == SOFTSW_PAGE_2)
static void render_hires_line(bool p2, uint line);
extern uint16_t dhgr_palette[16];
static inline uint hires_line_to_mem_offset(uint line) {
return ((line & 0x07) << 10) | ((line & 0x38) << 4) | (((line & 0xc0) >> 6) * 40);
@ -52,12 +51,10 @@ static void DELAYED_COPY_CODE(render_hires_line)(bool p2, uint line) {
if(mono_rendering) {
while(i < 40) {
// Load in as many subpixels as possible
while((dotc < 18) && (i < 40)) {
dots |= (hires_dot_patterns2[lastmsb | line_mem[i]]) << dotc;
lastmsb = (dotc>0) ? ((line_mem[i] & 0x40)<<2) : 0;
i++;
dotc += 14;
}
dots |= (hires_dot_patterns2[lastmsb | line_mem[i]]) << dotc;
lastmsb = (dotc>0) ? ((line_mem[i] & 0x40)<<2) : 0;
i++;
dotc += 14;
// Consume pixels
while(dotc) {
@ -69,38 +66,6 @@ static void DELAYED_COPY_CODE(render_hires_line)(bool p2, uint line) {
dotc -= 2;
}
}
} else if((internal_flags & IFLAGS_VIDEO7) && (soft_switches & SOFTSW_80STORE)) {
const uint8_t *color_mem = (const uint8_t *)(hgr_p3) + hires_line_to_mem_offset(line);
uint16_t color_on, color_off;
// Video 7 F/B HiRes
while(i < 40) {
if(dotc == 0) {
dots |= (line_mem[i] & 0x7f) << dotc;
color_on = lores_palette[(color_mem[i] >> 4) & 0xF];
color_off = lores_palette[(color_mem[i] >> 0) & 0xF];
i++;
dotc += 7;
}
pixeldata = ((dots & 1) ? (color_on) : (color_off));
dots >>= 1;
dotc--;
if(dotc == 0) {
dots |= (line_mem[i] & 0x7f) << dotc;
color_on = lores_palette[(color_mem[i] >> 4) & 0xF];
color_off = lores_palette[(color_mem[i] >> 0) & 0xF];
i++;
dotc += 7;
}
pixeldata |= ((dots & 1) ? (color_on) : (color_off)) << 16;
dots >>= 1;
dotc--;
sl->data[sl_pos++] = pixeldata;
}
} else if(internal_flags & IFLAGS_OLDCOLOR) {
// Each hires byte contains 7 pixels which may be shifted right 1/2 a pixel. That is
// represented here by 14 'dots' to precisely describe the half-pixel positioning.

View File

@ -4,8 +4,6 @@
#include "vga/render.h"
#include "vga/vgaout.h"
extern uint16_t lores_palette[16];
//#define PAGE2SEL (!(soft_switches & SOFTSW_80STORE) && (soft_switches & SOFTSW_PAGE_2))
#define PAGE2SEL ((soft_switches & (SOFTSW_80STORE | SOFTSW_PAGE_2)) == SOFTSW_PAGE_2)
@ -52,7 +50,7 @@ static inline uint_fast8_t char_text_bits(uint_fast8_t ch, uint_fast8_t glyph_li
void DELAYED_COPY_CODE(render_text)() {
uint line;
if((internal_flags & IFLAGS_VIDEO7) && ((soft_switches & (SOFTSW_80STORE | SOFTSW_80COL | SOFTSW_DGR)) == SOFTSW_80STORE)) {
if((internal_flags & IFLAGS_VIDEO7) && ((soft_switches & (SOFTSW_80STORE | SOFTSW_80COL | SOFTSW_DGR)) == (SOFTSW_80STORE | SOFTSW_DGR))) {
for(line=0; line < 24; line++) {
render_color_text40_line(line);
}
@ -72,7 +70,7 @@ void DELAYED_COPY_CODE(render_text)() {
void DELAYED_COPY_CODE(render_mixed_text)() {
uint line;
if((internal_flags & IFLAGS_VIDEO7) && ((soft_switches & (SOFTSW_80STORE | SOFTSW_80COL | SOFTSW_DGR)) == SOFTSW_80STORE)) {
if((internal_flags & IFLAGS_VIDEO7) && ((soft_switches & (SOFTSW_80STORE | SOFTSW_80COL | SOFTSW_DGR)) == (SOFTSW_80STORE | SOFTSW_DGR))) {
for(line=20; line < 24; line++) {
render_color_text40_line(line);
}