Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
866 lines
38 KiB
C
866 lines
38 KiB
C
/*
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
* running old operating systems and software designed for IBM
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
* system designs based on the PCI bus.
|
|
*
|
|
* This file is part of the 86Box distribution.
|
|
*
|
|
* SVGA renderers.
|
|
*
|
|
* Version: @(#)vid_svga_render.c 1.0.13 2019/03/08
|
|
*
|
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
|
* Miran Grca, <mgrca8@gmail.com>
|
|
*
|
|
* Copyright 2008-2019 Sarah Walker.
|
|
* Copyright 2016-2019 Miran Grca.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <wchar.h>
|
|
#include "../86box.h"
|
|
#include "../mem.h"
|
|
#include "../timer.h"
|
|
#include "video.h"
|
|
#include "vid_svga.h"
|
|
#include "vid_svga_render.h"
|
|
|
|
|
|
void svga_render_blank(svga_t *svga)
|
|
{
|
|
int x, xx;
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x < svga->hdisp; x++)
|
|
{
|
|
switch (svga->seqregs[1] & 9)
|
|
{
|
|
case 0:
|
|
for (xx = 0; xx < 9; xx++) buffer32->line[svga->displine + y_add][(x * 9) + xx + 32 + x_add] = 0;
|
|
break;
|
|
case 1:
|
|
for (xx = 0; xx < 8; xx++) buffer32->line[svga->displine + y_add][(x * 8) + xx + 32 + x_add] = 0;
|
|
break;
|
|
case 8:
|
|
for (xx = 0; xx < 18; xx++) buffer32->line[svga->displine + y_add][(x * 18) + xx + 32 + x_add] = 0;
|
|
break;
|
|
case 9:
|
|
for (xx = 0; xx < 16; xx++) buffer32->line[svga->displine + y_add][(x * 16) + xx + 32 + x_add] = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void svga_render_text_40(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
if (svga->fullchange)
|
|
{
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][32 + x_add];
|
|
int x, xx;
|
|
int drawcursor;
|
|
uint8_t chr, attr, dat;
|
|
uint32_t charaddr;
|
|
int fg, bg;
|
|
int xinc = (svga->seqregs[1] & 1) ? 16 : 18;
|
|
|
|
for (x = 0; x < svga->hdisp; x += xinc)
|
|
{
|
|
drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron);
|
|
chr = svga->vram[(svga->ma << 1) & svga->vram_display_mask];
|
|
attr = svga->vram[((svga->ma << 1) + 1) & svga->vram_display_mask];
|
|
if (attr & 8) charaddr = svga->charsetb + (chr * 128);
|
|
else charaddr = svga->charseta + (chr * 128);
|
|
|
|
if (drawcursor)
|
|
{
|
|
bg = svga->pallook[svga->egapal[attr & 15]];
|
|
fg = svga->pallook[svga->egapal[attr >> 4]];
|
|
}
|
|
else
|
|
{
|
|
fg = svga->pallook[svga->egapal[attr & 15]];
|
|
bg = svga->pallook[svga->egapal[attr >> 4]];
|
|
if (attr & 0x80 && svga->attrregs[0x10] & 8)
|
|
{
|
|
bg = svga->pallook[svga->egapal[(attr >> 4) & 7]];
|
|
if (svga->blink & 16)
|
|
fg = bg;
|
|
}
|
|
}
|
|
|
|
dat = svga->vram[charaddr + (svga->sc << 2)];
|
|
if (svga->seqregs[1] & 1)
|
|
{
|
|
for (xx = 0; xx < 16; xx += 2)
|
|
p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg;
|
|
}
|
|
else
|
|
{
|
|
for (xx = 0; xx < 16; xx += 2)
|
|
p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg;
|
|
if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4))
|
|
p[16] = p[17] = bg;
|
|
else
|
|
p[16] = p[17] = (dat & 1) ? fg : bg;
|
|
}
|
|
svga->ma += 4;
|
|
p += xinc;
|
|
}
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_text_80(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
if (svga->fullchange)
|
|
{
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][32 + x_add];
|
|
int x, xx;
|
|
int drawcursor;
|
|
uint8_t chr, attr, dat;
|
|
uint32_t charaddr;
|
|
int fg, bg;
|
|
int xinc = (svga->seqregs[1] & 1) ? 8 : 9;
|
|
|
|
for (x = 0; x < svga->hdisp; x += xinc)
|
|
{
|
|
drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron);
|
|
chr = svga->vram[(svga->ma << 1) & svga->vram_display_mask];
|
|
attr = svga->vram[((svga->ma << 1) + 1) & svga->vram_display_mask];
|
|
|
|
|
|
if (attr & 8) charaddr = svga->charsetb + (chr * 128);
|
|
else charaddr = svga->charseta + (chr * 128);
|
|
|
|
if (drawcursor)
|
|
{
|
|
bg = svga->pallook[svga->egapal[attr & 15]];
|
|
fg = svga->pallook[svga->egapal[attr >> 4]];
|
|
}
|
|
else
|
|
{
|
|
fg = svga->pallook[svga->egapal[attr & 15]];
|
|
bg = svga->pallook[svga->egapal[attr >> 4]];
|
|
if (attr & 0x80 && svga->attrregs[0x10] & 8)
|
|
{
|
|
bg = svga->pallook[svga->egapal[(attr >> 4) & 7]];
|
|
if (svga->blink & 16)
|
|
fg = bg;
|
|
}
|
|
}
|
|
|
|
dat = svga->vram[charaddr + (svga->sc << 2)];
|
|
if (svga->seqregs[1] & 1)
|
|
{
|
|
for (xx = 0; xx < 8; xx++)
|
|
p[xx] = (dat & (0x80 >> xx)) ? fg : bg;
|
|
}
|
|
else
|
|
{
|
|
for (xx = 0; xx < 8; xx++)
|
|
p[xx] = (dat & (0x80 >> xx)) ? fg : bg;
|
|
if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4))
|
|
p[8] = bg;
|
|
else
|
|
p[8] = (dat & 1) ? fg : bg;
|
|
}
|
|
svga->ma += 4;
|
|
p += xinc;
|
|
}
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_text_80_ksc5601(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
if (svga->fullchange)
|
|
{
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][32 + x_add];
|
|
int x, xx;
|
|
int drawcursor;
|
|
uint8_t chr, attr, dat, nextchr;
|
|
uint32_t charaddr;
|
|
int fg, bg;
|
|
int xinc = (svga->seqregs[1] & 1) ? 8 : 9;
|
|
|
|
for (x = 0; x < svga->hdisp; x += xinc)
|
|
{
|
|
drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron);
|
|
chr = svga->vram[(svga->ma << 1) & svga->vram_display_mask];
|
|
nextchr = svga->vram[((svga->ma + 4) << 1) & svga->vram_display_mask];
|
|
attr = svga->vram[((svga->ma << 1) + 1) & svga->vram_display_mask];
|
|
|
|
|
|
if (drawcursor)
|
|
{
|
|
bg = svga->pallook[svga->egapal[attr & 15]];
|
|
fg = svga->pallook[svga->egapal[attr >> 4]];
|
|
}
|
|
else
|
|
{
|
|
fg = svga->pallook[svga->egapal[attr & 15]];
|
|
bg = svga->pallook[svga->egapal[attr >> 4]];
|
|
if (attr & 0x80 && svga->attrregs[0x10] & 8)
|
|
{
|
|
bg = svga->pallook[svga->egapal[(attr >> 4) & 7]];
|
|
if (svga->blink & 16)
|
|
fg = bg;
|
|
}
|
|
}
|
|
|
|
if(x + xinc < svga->hdisp && (chr & (nextchr | svga->ksc5601_sbyte_mask) & 0x80))
|
|
{
|
|
if((chr == 0xc9 || chr == 0xfe) && (nextchr > 0xa0 && nextchr < 0xff))
|
|
dat = fontdatksc5601_user[(chr == 0xfe ? 96 : 0) + (nextchr & 0x7F) - 0x20].chr[svga->sc];
|
|
else if(nextchr & 0x80)
|
|
dat = fontdatksc5601[((chr & 0x7F) << 7) | (nextchr & 0x7F)].chr[svga->sc];
|
|
else
|
|
dat = 0xff;
|
|
}
|
|
else
|
|
{
|
|
if (attr & 8) charaddr = svga->charsetb + (chr * 128);
|
|
else charaddr = svga->charseta + (chr * 128);
|
|
|
|
dat = svga->vram[charaddr + (svga->sc << 2)];
|
|
}
|
|
if (svga->seqregs[1] & 1)
|
|
{
|
|
for (xx = 0; xx < 8; xx++)
|
|
p[xx] = (dat & (0x80 >> xx)) ? fg : bg;
|
|
}
|
|
else
|
|
{
|
|
for (xx = 0; xx < 8; xx++)
|
|
p[xx] = (dat & (0x80 >> xx)) ? fg : bg;
|
|
if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4))
|
|
p[8] = bg;
|
|
else
|
|
p[8] = (dat & 1) ? fg : bg;
|
|
}
|
|
svga->ma += 4;
|
|
p += xinc;
|
|
|
|
if(x + xinc < svga->hdisp && (chr & (nextchr | svga->ksc5601_sbyte_mask) & 0x80))
|
|
{
|
|
attr = svga->vram[((svga->ma << 1) + 1) & svga->vram_display_mask];
|
|
|
|
if (drawcursor)
|
|
{
|
|
bg = svga->pallook[svga->egapal[attr & 15]];
|
|
fg = svga->pallook[svga->egapal[attr >> 4]];
|
|
}
|
|
else
|
|
{
|
|
fg = svga->pallook[svga->egapal[attr & 15]];
|
|
bg = svga->pallook[svga->egapal[attr >> 4]];
|
|
if (attr & 0x80 && svga->attrregs[0x10] & 8)
|
|
{
|
|
bg = svga->pallook[svga->egapal[(attr >> 4) & 7]];
|
|
if (svga->blink & 16)
|
|
fg = bg;
|
|
}
|
|
}
|
|
|
|
if((chr == 0xc9 || chr == 0xfe) && (nextchr > 0xa0 && nextchr < 0xff))
|
|
dat = fontdatksc5601_user[(chr == 0xfe ? 96 : 0) + (nextchr & 0x7F) - 0x20].chr[svga->sc + 16];
|
|
else if(nextchr & 0x80)
|
|
dat = fontdatksc5601[((chr & 0x7F) << 7) | (nextchr & 0x7F)].chr[svga->sc + 16];
|
|
else
|
|
dat = 0xFF;
|
|
if (svga->seqregs[1] & 1)
|
|
{
|
|
for (xx = 0; xx < 8; xx++)
|
|
p[xx] = (dat & (0x80 >> xx)) ? fg : bg;
|
|
}
|
|
else
|
|
{
|
|
for (xx = 0; xx < 8; xx++)
|
|
p[xx] = (dat & (0x80 >> xx)) ? fg : bg;
|
|
if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4))
|
|
p[8] = bg;
|
|
else
|
|
p[8] = (dat & 1) ? fg : bg;
|
|
}
|
|
|
|
svga->ma += 4;
|
|
p += xinc;
|
|
x += xinc;
|
|
}
|
|
}
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_2bpp_lowres(svga_t *svga)
|
|
{
|
|
int changed_offset;
|
|
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
changed_offset = ((svga->ma << 1) + (svga->sc & ~svga->crtc[0x17] & 3) * 0x8000) >> 12;
|
|
|
|
if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = ((8 - svga->scrollcache) << 1) + 16;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 16)
|
|
{
|
|
uint8_t dat[2];
|
|
|
|
dat[0] = svga->vram[(svga->ma << 1) + ((svga->sc & ~svga->crtc[0x17] & 3)) * 0x8000];
|
|
dat[1] = svga->vram[(svga->ma << 1) + ((svga->sc & ~svga->crtc[0x17] & 3)) * 0x8000 + 1];
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
|
|
p[0] = p[1] = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]];
|
|
p[2] = p[3] = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]];
|
|
p[4] = p[5] = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]];
|
|
p[6] = p[7] = svga->pallook[svga->egapal[dat[0] & 3]];
|
|
p[8] = p[9] = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]];
|
|
p[10] = p[11] = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]];
|
|
p[12] = p[13] = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]];
|
|
p[14] = p[15] = svga->pallook[svga->egapal[dat[1] & 3]];
|
|
|
|
p += 16;
|
|
}
|
|
}
|
|
}
|
|
|
|
void svga_render_2bpp_highres(svga_t *svga)
|
|
{
|
|
int changed_offset;
|
|
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
changed_offset = ((svga->ma << 1) + (svga->sc & ~svga->crtc[0x17] & 3) * 0x8000) >> 12;
|
|
|
|
if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - svga->scrollcache) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 8)
|
|
{
|
|
uint8_t dat[2];
|
|
|
|
dat[0] = svga->vram[(svga->ma << 1) + ((svga->sc & ~svga->crtc[0x17] & 3)) * 0x8000];
|
|
dat[1] = svga->vram[(svga->ma << 1) + ((svga->sc & ~svga->crtc[0x17] & 3)) * 0x8000 + 1];
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
|
|
p[0] = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]];
|
|
p[1] = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]];
|
|
p[2] = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]];
|
|
p[3] = svga->pallook[svga->egapal[dat[0] & 3]];
|
|
p[4] = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]];
|
|
p[5] = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]];
|
|
p[6] = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]];
|
|
p[7] = svga->pallook[svga->egapal[dat[1] & 3]];
|
|
|
|
p += 8;
|
|
}
|
|
}
|
|
}
|
|
|
|
void svga_render_4bpp_lowres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = ((8 - svga->scrollcache) << 1) + 16;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 16)
|
|
{
|
|
uint8_t edat[4];
|
|
uint8_t dat;
|
|
|
|
*(uint32_t *)(&edat[0]) = *(uint32_t *)(&svga->vram[svga->ma]);
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
|
|
dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2);
|
|
p[0] = p[1] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[2] = p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2);
|
|
p[4] = p[5] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[6] = p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2);
|
|
p[8] = p[9] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[10] = p[11] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
|
|
p[12] = p[13] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[14] = p[15] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
|
|
p += 16;
|
|
}
|
|
}
|
|
}
|
|
|
|
void svga_render_4bpp_highres(svga_t *svga)
|
|
{
|
|
int changed_offset;
|
|
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
changed_offset = (svga->ma + (svga->sc & ~svga->crtc[0x17] & 3) * 0x8000) >> 12;
|
|
|
|
if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - svga->scrollcache) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 8)
|
|
{
|
|
uint8_t edat[4];
|
|
uint8_t dat;
|
|
|
|
*(uint32_t *)(&edat[0]) = *(uint32_t *)(&svga->vram[svga->ma | ((svga->sc & ~svga->crtc[0x17] & 3)) * 0x8000]);
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
|
|
dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2);
|
|
p[0] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[1] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2);
|
|
p[2] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2);
|
|
p[4] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[5] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
|
|
p[6] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]];
|
|
p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]];
|
|
|
|
p += 8;
|
|
}
|
|
}
|
|
}
|
|
|
|
void svga_render_8bpp_lowres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - (svga->scrollcache & 6)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 8)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
|
|
|
|
p[0] = p[1] = svga->pallook[dat & 0xff];
|
|
p[2] = p[3] = svga->pallook[(dat >> 8) & 0xff];
|
|
p[4] = p[5] = svga->pallook[(dat >> 16) & 0xff];
|
|
p[6] = p[7] = svga->pallook[(dat >> 24) & 0xff];
|
|
|
|
svga->ma += 4;
|
|
p += 8;
|
|
}
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_8bpp_highres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 8)
|
|
{
|
|
uint32_t dat;
|
|
dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
|
|
p[0] = svga->pallook[dat & 0xff];
|
|
p[1] = svga->pallook[(dat >> 8) & 0xff];
|
|
p[2] = svga->pallook[(dat >> 16) & 0xff];
|
|
p[3] = svga->pallook[(dat >> 24) & 0xff];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + 4) & svga->vram_display_mask]);
|
|
p[4] = svga->pallook[dat & 0xff];
|
|
p[5] = svga->pallook[(dat >> 8) & 0xff];
|
|
p[6] = svga->pallook[(dat >> 16) & 0xff];
|
|
p[7] = svga->pallook[(dat >> 24) & 0xff];
|
|
|
|
svga->ma += 8;
|
|
p += 8;
|
|
}
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_15bpp_lowres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - (svga->scrollcache & 6)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 4)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
|
|
|
|
p[x] = video_15to32[dat & 0xffff];
|
|
p[x + 1] = video_15to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
|
|
|
|
p[x + 2] = video_15to32[dat & 0xffff];
|
|
p[x + 3] = video_15to32[dat >> 16];
|
|
}
|
|
svga->ma += x << 1;
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_15bpp_highres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 8)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
|
|
p[x] = video_15to32[dat & 0xffff];
|
|
p[x + 1] = video_15to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
|
|
p[x + 2] = video_15to32[dat & 0xffff];
|
|
p[x + 3] = video_15to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 8) & svga->vram_display_mask]);
|
|
p[x + 4] = video_15to32[dat & 0xffff];
|
|
p[x + 5] = video_15to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 12) & svga->vram_display_mask]);
|
|
p[x + 6] = video_15to32[dat & 0xffff];
|
|
p[x + 7] = video_15to32[dat >> 16];
|
|
}
|
|
svga->ma += x << 1;
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_16bpp_lowres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - (svga->scrollcache & 6)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 4)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
|
|
|
|
p[x] = video_16to32[dat & 0xffff];
|
|
p[x + 1] = video_16to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
|
|
|
|
p[x + 2] = video_16to32[dat & 0xffff];
|
|
p[x + 3] = video_16to32[dat >> 16];
|
|
}
|
|
svga->ma += x << 1;
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_16bpp_highres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 8)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]);
|
|
p[x] = video_16to32[dat & 0xffff];
|
|
p[x + 1] = video_16to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]);
|
|
p[x + 2] = video_16to32[dat & 0xffff];
|
|
p[x + 3] = video_16to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 8) & svga->vram_display_mask]);
|
|
p[x + 4] = video_16to32[dat & 0xffff];
|
|
p[x + 5] = video_16to32[dat >> 16];
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 12) & svga->vram_display_mask]);
|
|
p[x + 6] = video_16to32[dat & 0xffff];
|
|
p[x + 7] = video_16to32[dat >> 16];
|
|
}
|
|
svga->ma += x << 1;
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_24bpp_lowres(svga_t *svga)
|
|
{
|
|
int x, offset;
|
|
uint32_t fg;
|
|
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
offset = (8 - (svga->scrollcache & 6)) + 24;
|
|
|
|
for (x = 0; x <= svga->hdisp; x++)
|
|
{
|
|
fg = svga->vram[svga->ma] | (svga->vram[svga->ma + 1] << 8) | (svga->vram[svga->ma + 2] << 16);
|
|
svga->ma += 3;
|
|
svga->ma &= svga->vram_display_mask;
|
|
buffer32->line[svga->displine + y_add][(x << 1) + offset + x_add] = buffer32->line[svga->displine + y_add][(x << 1) + 1 + offset + x_add] = fg;
|
|
}
|
|
}
|
|
}
|
|
|
|
void svga_render_24bpp_highres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x += 4)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
|
|
p[x] = dat & 0xffffff;
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + 3) & svga->vram_display_mask]);
|
|
p[x + 1] = dat & 0xffffff;
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + 6) & svga->vram_display_mask]);
|
|
p[x + 2] = dat & 0xffffff;
|
|
|
|
dat = *(uint32_t *)(&svga->vram[(svga->ma + 9) & svga->vram_display_mask]);
|
|
p[x + 3] = dat & 0xffffff;
|
|
|
|
svga->ma += 12;
|
|
}
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_32bpp_lowres(svga_t *svga)
|
|
{
|
|
int x, offset;
|
|
uint32_t fg;
|
|
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange)
|
|
{
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
offset = (8 - (svga->scrollcache & 6)) + 24;
|
|
|
|
for (x = 0; x <= svga->hdisp; x++)
|
|
{
|
|
fg = svga->vram[svga->ma] | (svga->vram[svga->ma + 1] << 8) | (svga->vram[svga->ma + 2] << 16);
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
buffer32->line[svga->displine + y_add][(x << 1) + offset + x_add] = buffer32->line[svga->displine + y_add][(x << 1) + 1 + offset + x_add] = fg;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*72%
|
|
91%*/
|
|
void svga_render_32bpp_highres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x++)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]);
|
|
p[x] = dat & 0xffffff;
|
|
}
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_ABGR8888_highres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x++)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]);
|
|
p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16);
|
|
}
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|
|
|
|
void svga_render_RGBA8888_highres(svga_t *svga)
|
|
{
|
|
int y_add = enable_overscan ? (overscan_y >> 1) : 0;
|
|
int x_add = enable_overscan ? 8 : 0;
|
|
|
|
if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange)
|
|
{
|
|
int x;
|
|
int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24;
|
|
uint32_t *p = &buffer32->line[svga->displine + y_add][offset + x_add];
|
|
|
|
if (svga->firstline_draw == 2000)
|
|
svga->firstline_draw = svga->displine;
|
|
svga->lastline_draw = svga->displine;
|
|
|
|
for (x = 0; x <= svga->hdisp; x++)
|
|
{
|
|
uint32_t dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]);
|
|
p[x] = dat >> 8;
|
|
}
|
|
svga->ma += 4;
|
|
svga->ma &= svga->vram_display_mask;
|
|
}
|
|
}
|