Blending update for Hecules cards, from 86Box (modified.)

This commit is contained in:
waltje
2018-10-28 17:51:26 -04:00
parent c2c3711afa
commit 5a05143a31
4 changed files with 145 additions and 13 deletions

View File

@@ -8,7 +8,7 @@
*
* Hercules emulation.
*
* Version: @(#)vid_hercules.c 1.0.8 2018/10/16
* Version: @(#)vid_hercules.c 1.0.9 2018/10/28
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -79,8 +79,9 @@ typedef struct {
cursoron;
int dispon,
blink;
int64_t vsynctime;
int vadj;
int blend;
int64_t vsynctime;
int cols[256][2][2];
@@ -240,8 +241,15 @@ hercules_poll(void *priv)
for (x = 0; x < dev->crtc[1]; x++) {
dat = (dev->vram[((dev->ma << 1) & 0x1fff) + ca] << 8) | dev->vram[((dev->ma << 1) & 0x1fff) + ca + 1];
dev->ma++;
for (c = 0; c < 16; c++)
for (c = 0; c < 16; c++) {
buffer->line[dev->displine][(x << 4) + c] = (dat & (32768 >> c)) ? 7 : 0;
}
if (dev->blend) {
for (c = 0; c < 16; c += 8)
video_blend((x << 4) + c, dev->displine);
}
}
} else {
for (x = 0; x < dev->crtc[1]; x++) {
@@ -390,6 +398,8 @@ hercules_init(const device_t *info)
dev = (hercules_t *)mem_alloc(sizeof(hercules_t));
memset(dev, 0x00, sizeof(hercules_t));
dev->blend = device_get_config_int("blend");
dev->vram = (uint8_t *)mem_alloc(0x10000);
timer_add(hercules_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev);
@@ -488,6 +498,9 @@ static const device_config_t hercules_config[] = {
}
}
},
{
"blend", "Blend", CONFIG_BINARY, "", 1
},
{
"", "", -1
}

View File

@@ -8,7 +8,7 @@
*
* Hercules InColor emulation.
*
* Version: @(#)vid_hercules_plus.c 1.0.10 2018/10/16
* Version: @(#)vid_hercules_plus.c 1.0.11 2018/10/28
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -100,8 +100,9 @@ typedef struct {
uint16_t ma, maback;
int con, coff, cursoron;
int dispon, blink;
int64_t vsynctime;
int vadj;
int blend;
int64_t vsynctime;
int cols[256][2][2];
@@ -457,7 +458,7 @@ text_line(herculesplus_t *dev, uint16_t ca)
col = dev->cols[attr][0][1];
for (c = 0; c < cw; c++)
((uint32_t *)buffer32->line[dev->displine])[x * cw + c] = col;
buffer->line[dev->displine][x * cw + c] = col;
}
}
}
@@ -483,7 +484,12 @@ graphics_line(herculesplus_t *dev)
for (c = 0; c < 16; c++) {
val >>= 1;
((uint32_t *)buffer32->line[dev->displine])[(x << 4) + c] = (val & 1) ? 7 : 0;
buffer->line[dev->displine][(x << 4) + c] = (val & 1) ? 7 : 0;
}
if (dev->blend) {
for (c = 0; c < 16; c += 8)
video_blend((x << 4) + c, dev->displine);
}
}
}
@@ -556,8 +562,10 @@ herculesplus_poll(void *priv)
if (oldvc == dev->crtc[4]) {
dev->vc = 0;
dev->vadj = dev->crtc[5];
if (!dev->vadj) dev->dispon=1;
if (!dev->vadj) dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff;
if (! dev->vadj)
dev->dispon = 1;
if (! dev->vadj)
dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff;
if ((dev->crtc[10] & 0x60) == 0x20)
dev->cursoron = 0;
else
@@ -583,7 +591,7 @@ herculesplus_poll(void *priv)
if (video_force_resize_get())
video_force_resize_set(0);
}
video_blit_memtoscreen(0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline);
video_blit_memtoscreen_8(0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline);
frames++;
if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) {
video_res_x = dev->crtc[1] * 16;
@@ -620,6 +628,13 @@ herculesplus_init(const device_t *info)
dev = (herculesplus_t *)mem_alloc(sizeof(herculesplus_t));
memset(dev, 0, sizeof(herculesplus_t));
dev->blend = device_get_config_int("blend");
cga_palette = device_get_config_int("rgb_type") << 1;
if (cga_palette > 6)
cga_palette = 0;
cgapal_rebuild();
dev->vram = (uint8_t *)mem_alloc(0x10000); /* 64k VRAM */
timer_add(herculesplus_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev);
@@ -690,6 +705,37 @@ speed_changed(void *priv)
}
static const device_config_t herculesplus_config[] = {
{
"rgb_type", "Display type", CONFIG_SELECTION, "", 0,
{
{
"Default", 0
},
{
"Green", 1
},
{
"Amber", 2
},
{
"Gray", 3
},
{
""
}
}
},
{
"blend", "Blend", CONFIG_BINARY, "", 1
},
{
"", "", -1
}
};
static const video_timings_t herculesplus_timings = { VID_ISA,8,16,32,8,16,32 };
const device_t herculesplus_device = {
@@ -701,5 +747,5 @@ const device_t herculesplus_device = {
speed_changed,
NULL,
&herculesplus_timings,
NULL
herculesplus_config
};

View File

@@ -40,7 +40,7 @@
* W = 3 bus clocks
* L = 4 bus clocks
*
* Version: @(#)video.c 1.0.21 2018/10/24
* Version: @(#)video.c 1.0.22 2018/10/28
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -402,6 +402,7 @@ static const uint32_t shade[5][256] = {
0xfcf9e9, 0xfdfaea, 0xfefbeb, 0xfffcec
}
};
static uint32_t cga_2_table[16];
static struct {
@@ -491,6 +492,69 @@ video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
}
static uint8_t
pixels8(uint8_t *pixels)
{
uint8_t temp = 0;
int i;
for (i = 0; i < 8; i++)
temp |= (!!*(pixels + i) << (i ^ 7));
return temp;
}
static uint32_t
pixel_to_color(uint8_t *pixels32, uint8_t pos)
{
uint32_t temp;
temp = *(pixels32 + pos) & 0x03;
switch (temp) {
case 0:
return 0;
case 1:
return 0x07;
case 2:
return 0x0f;
default:
break;
}
return 0;
}
void
video_blend(int x, int y)
{
static unsigned int carry = 0;
uint32_t pixels32_1, pixels32_2;
unsigned int val1, val2;
int xx;
if (x == 0)
carry = 0;
val1 = pixels8(&(buffer->line[y][x]));
val2 = (val1 >> 1) + carry;
carry = (val1 & 1) << 7;
pixels32_1 = cga_2_table[val1 >> 4] + cga_2_table[val2 >> 4];
pixels32_2 = cga_2_table[val1 & 0xf] + cga_2_table[val2 & 0xf];
for (xx = 0; xx < 4; xx++) {
buffer->line[y][x + xx] = pixel_to_color((uint8_t *)&pixels32_1, xx);
buffer->line[y][x + (xx | 4)] = pixel_to_color((uint8_t *)&pixels32_2, xx);
}
}
void
video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h)
{
@@ -665,8 +729,16 @@ video_log(int level, const char *fmt, ...)
void
video_init(void)
{
uint8_t total[2] = { 0, 1 };
int c, d, e;
for (c = 0; c < 16; c++) {
cga_2_table[c] = (total[(c >> 3) & 1] << 0 ) |
(total[(c >> 2) & 1] << 8 ) |
(total[(c >> 1) & 1] << 16) |
(total[(c >> 0) & 1] << 24);
}
/* Initialize video type and timing. */
video_inform(VID_TYPE_DFLT, NULL);

View File

@@ -8,7 +8,7 @@
*
* Definitions for the video controller module.
*
* Version: @(#)video.h 1.0.21 2018/10/24
* Version: @(#)video.h 1.0.22 2018/10/28
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -314,6 +314,7 @@ extern const device_t *video_card_getdevice(int card);
#endif
extern void video_setblit(void(*blit)(int,int,int,int,int,int));
extern void video_blend(int x, int y);
extern void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
extern void video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h);
extern void video_blit_complete(void);