Added the monochrome monitor constrast change option, patch from basic2004.
This commit is contained in:
@@ -77,10 +77,6 @@ void cga_out(uint16_t addr, uint8_t val, void *p)
|
||||
if ((cga->cgamode ^ val) & 1)
|
||||
{
|
||||
cga_palette = (cga->rgb_type << 1);
|
||||
if (!(val & 1) && (cga_palette > 0) && (cga_palette < 8))
|
||||
{
|
||||
cga_palette--;
|
||||
}
|
||||
cgapal_rebuild();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Emulation of the EGA, Chips & Technologies SuperEGA, and
|
||||
* AX JEGA graphics cards.
|
||||
*
|
||||
* Version: @(#)vid_ega.c 1.0.0 2017/05/30
|
||||
* Version: @(#)vid_ega.c 1.0.1 2017/06/01
|
||||
*
|
||||
* Author: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "../device.h"
|
||||
#include "video.h"
|
||||
#include "vid_ega.h"
|
||||
#include "vid_ega_render.h"
|
||||
|
||||
|
||||
extern uint8_t edatlookup[4][4];
|
||||
@@ -495,28 +496,10 @@ void ega_recalctimings(ega_t *ega)
|
||||
ega->dispofftime = (int)(_dispofftime * (1 << TIMER_SHIFT));
|
||||
}
|
||||
|
||||
int ega_display_line(ega_t *ega)
|
||||
{
|
||||
int y_add = (enable_overscan) ? (overscan_y >> 1) : 0;
|
||||
unsigned int dl = ega->displine;
|
||||
if (ega->crtc[9] & 0x1f)
|
||||
{
|
||||
dl -= (ega->crtc[8] & 0x1f);
|
||||
}
|
||||
dl += y_add;
|
||||
dl &= 0x7ff;
|
||||
return dl;
|
||||
}
|
||||
|
||||
void ega_poll(void *p)
|
||||
{
|
||||
ega_t *ega = (ega_t *)p;
|
||||
uint8_t chr, dat, attr;
|
||||
uint32_t charaddr;
|
||||
int x, xx;
|
||||
uint32_t fg, bg;
|
||||
int offset;
|
||||
uint8_t edat[4];
|
||||
int x;
|
||||
int drawcursor = 0;
|
||||
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
||||
int x_add = enable_overscan ? 8 : 0;
|
||||
@@ -524,7 +507,6 @@ void ega_poll(void *p)
|
||||
int x_add_ex = enable_overscan ? 16 : 0;
|
||||
uint32_t *q, i, j;
|
||||
int wx = 640, wy = 350;
|
||||
int dl = ega_display_line(ega);
|
||||
|
||||
if (!ega->linepos)
|
||||
{
|
||||
@@ -543,204 +525,36 @@ void ega_poll(void *p)
|
||||
|
||||
if (ega->scrblank)
|
||||
{
|
||||
for (x = 0; x < ega->hdisp; x++)
|
||||
{
|
||||
switch (ega->seqregs[1] & 9)
|
||||
{
|
||||
case 0:
|
||||
for (xx = 0; xx < 9; xx++) ((uint32_t *)buffer32->line[dl])[(x * 9) + xx + 32 + x_add] = 0;
|
||||
break;
|
||||
case 1:
|
||||
for (xx = 0; xx < 8; xx++) ((uint32_t *)buffer32->line[dl])[(x * 8) + xx + 32 + x_add] = 0;
|
||||
break;
|
||||
case 8:
|
||||
for (xx = 0; xx < 18; xx++) ((uint32_t *)buffer32->line[dl])[(x * 18) + xx + 32 + x_add] = 0;
|
||||
break;
|
||||
case 9:
|
||||
for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[dl])[(x * 16) + xx + 32 + x_add] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ega_render_blank(ega);
|
||||
}
|
||||
else if (!(ega->gdcreg[6] & 1))
|
||||
{
|
||||
if (fullchange)
|
||||
{
|
||||
for (x = 0; x < ega->hdisp; x++)
|
||||
{
|
||||
drawcursor = ((ega->ma == ega->ca) && ega->con && ega->cursoron);
|
||||
chr = ega->vram[(ega->ma << 1) & ega->vrammask];
|
||||
attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask];
|
||||
|
||||
if (attr & 8) charaddr = ega->charsetb + (chr * 128);
|
||||
else charaddr = ega->charseta + (chr * 128);
|
||||
|
||||
if (drawcursor)
|
||||
{
|
||||
bg = ega->pallook[ega->egapal[attr & 15]];
|
||||
fg = ega->pallook[ega->egapal[attr >> 4]];
|
||||
}
|
||||
else
|
||||
{
|
||||
fg = ega->pallook[ega->egapal[attr & 15]];
|
||||
bg = ega->pallook[ega->egapal[attr >> 4]];
|
||||
if (attr & 0x80 && ega->attrregs[0x10] & 8)
|
||||
{
|
||||
bg = ega->pallook[ega->egapal[(attr >> 4) & 7]];
|
||||
if (ega->blink & 16)
|
||||
fg = bg;
|
||||
}
|
||||
}
|
||||
|
||||
dat = ega->vram[charaddr + (ega->sc << 2)];
|
||||
if (ega->seqregs[1] & 8)
|
||||
{
|
||||
if (ega->seqregs[1] & 1)
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x << 4) + 32 + (xx << 1)) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x << 4) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + (xx << 1)) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4))
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 16) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 17) & 2047) + x_add] = bg;
|
||||
else
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 16) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 17) & 2047) + x_add] = (dat & 1) ? fg : bg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ega->seqregs[1] & 1)
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x << 3) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4))
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + 8) & 2047) + x_add] = bg;
|
||||
else
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + 8) & 2047) + x_add] = (dat & 1) ? fg : bg;
|
||||
}
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
}
|
||||
}
|
||||
ega_render_text_standard(ega, drawcursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ega->gdcreg[5] & 0x20)
|
||||
{
|
||||
case 0x00:
|
||||
if (ega->seqregs[1] & 8)
|
||||
{
|
||||
offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
if (ega->sc & 1 && !(ega->crtc[0x17] & 1))
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma | 0x8000];
|
||||
edat[1] = ega->vram[ega->ma | 0x8001];
|
||||
edat[2] = ega->vram[ega->ma | 0x8002];
|
||||
edat[3] = ega->vram[ega->ma | 0x8003];
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma];
|
||||
edat[1] = ega->vram[ega->ma | 0x1];
|
||||
edat[2] = ega->vram[ega->ma | 0x2];
|
||||
edat[3] = ega->vram[ega->ma | 0x3];
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
|
||||
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 14 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 15 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 12 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 13 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 10 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 11 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 8 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 9 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 6 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 7 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 4 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 5 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 2 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 3 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 1 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = (8 - ega->scrollcache) + 24;
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
if (ega->sc & 1 && !(ega->crtc[0x17] & 1))
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma | 0x8000];
|
||||
edat[1] = ega->vram[ega->ma | 0x8001];
|
||||
edat[2] = ega->vram[ega->ma | 0x8002];
|
||||
edat[3] = ega->vram[ega->ma | 0x8003];
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma];
|
||||
edat[1] = ega->vram[ega->ma | 0x1];
|
||||
edat[2] = ega->vram[ega->ma | 0x2];
|
||||
edat[3] = ega->vram[ega->ma | 0x3];
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
|
||||
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 7 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 6 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 5 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 4 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 3 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 2 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 1 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (ega->seqregs[1] & 8)
|
||||
{
|
||||
ega_render_4bpp_lowres(ega);
|
||||
}
|
||||
else
|
||||
{
|
||||
ega_render_4bpp_highres(ega);
|
||||
}
|
||||
break;
|
||||
case 0x20:
|
||||
offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
if (ega->sc & 1 && !(ega->crtc[0x17] & 1))
|
||||
{
|
||||
edat[0] = ega->vram[(ega->ma << 1) + 0x8000];
|
||||
edat[1] = ega->vram[(ega->ma << 1) + 0x8001];
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[(ega->ma << 1)];
|
||||
edat[1] = ega->vram[(ega->ma << 1) + 1];
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 14 + offset + x_add]= ((uint32_t *)buffer32->line[dl])[(x << 4) + 15 + offset + x_add] = ega->pallook[ega->egapal[edat[1] & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 12 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 13 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 2) & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 10 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 11 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 4) & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 8 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 9 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 6) & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 6 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 7 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 0) & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 4 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 5 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 2) & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 2 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 3 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 4) & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 1 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 6) & 3]];
|
||||
}
|
||||
break;
|
||||
if (ega->seqregs[1] & 8)
|
||||
{
|
||||
ega_render_2bpp_lowres(ega);
|
||||
}
|
||||
else
|
||||
{
|
||||
ega_render_2bpp_highres(ega);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ega->lastline < ega->displine)
|
||||
@@ -903,7 +717,8 @@ void ega_poll(void *p)
|
||||
else
|
||||
{
|
||||
if (ega->crtc[9] & 0x80)
|
||||
ega->video_res_y /= 2; if (!(ega->crtc[0x17] & 1))
|
||||
ega->video_res_y /= 2;
|
||||
if (!(ega->crtc[0x17] & 1))
|
||||
ega->video_res_y *= 2;
|
||||
ega->video_res_y /= (ega->crtc[9] & 31) + 1;
|
||||
if (ega->seqregs[1] & 8)
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "vid_wy700.h"
|
||||
|
||||
|
||||
int vid_cga_contrast = 0;
|
||||
int cga_palette = 0;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -111,6 +111,7 @@ void ddraw_fs_take_screenshot(wchar_t *fn);
|
||||
#endif
|
||||
|
||||
extern int cga_palette;
|
||||
extern int vid_cga_contrast;
|
||||
|
||||
void loadfont(wchar_t *s, int format);
|
||||
void initvideo();
|
||||
|
||||
Reference in New Issue
Block a user