Re-organisation of video emulation.

This commit is contained in:
TomW 2013-06-24 20:42:35 +01:00
commit 58085bcc87
86 changed files with 8087 additions and 7229 deletions

View file

@ -1,13 +1,45 @@
#include <stdio.h>
#include <math.h>
#include "ibm.h"
#include "device.h"
#include "video.h"
#include "vid_svga.h"
#include "io.h"
#include "cpu.h"
#include "timer.h"
int video_timer;
#include "vid_ati18800.h"
#include "vid_ati28800.h"
#include "vid_ati_mach64.h"
#include "vid_cga.h"
#include "vid_cl5429.h"
#include "vid_ega.h"
#include "vid_et4000.h"
#include "vid_et4000w32.h"
#include "vid_hercules.h"
#include "vid_mda.h"
#include "vid_olivetti_m24.h"
#include "vid_oti067.h"
#include "vid_paradise.h"
#include "vid_pc1512.h"
#include "vid_pc1640.h"
#include "vid_pc200.h"
#include "vid_s3.h"
#include "vid_s3_virge.h"
#include "vid_tandy.h"
#include "vid_tvga.h"
#include "vid_vga.h"
int egareads=0,egawrites=0;
int changeframecount=2;
uint8_t rotatevga[8][256];
int frames = 0;
int fullchange;
uint8_t edatlookup[4][4];
/*Video timing settings -
@ -84,70 +116,6 @@ int video_res_x, video_res_y, video_bpp;
void (*video_blit_memtoscreen)(int x, int y, int y1, int y2, int w, int h);
void (*video_blit_memtoscreen_8)(int x, int y, int w, int h);
void (*video_out) (uint16_t addr, uint8_t val, void *priv);
void (*video_mono_out)(uint16_t addr, uint8_t val, void *priv);
uint8_t (*video_in) (uint16_t addr, void *priv);
uint8_t (*video_mono_in)(uint16_t addr, void *priv);
void (*video_write_a000)(uint32_t addr, uint8_t val, void *priv);
void (*video_write_b000)(uint32_t addr, uint8_t val, void *priv);
void (*video_write_b800)(uint32_t addr, uint8_t val, void *priv);
void (*video_write_a000_w)(uint32_t addr, uint16_t val, void *priv);
void (*video_write_a000_l)(uint32_t addr, uint32_t val, void *priv);
uint8_t (*video_read_a000)(uint32_t addr, void *priv);
uint8_t (*video_read_b000)(uint32_t addr, void *priv);
uint8_t (*video_read_b800)(uint32_t addr, void *priv);
void (*video_recalctimings)();
void video_out_null(uint16_t addr, uint8_t val, void *priv)
{
}
uint8_t video_in_null(uint16_t addr, void *priv)
{
return 0xFF;
}
void video_write_null(uint32_t addr, uint8_t val, void *priv)
{
}
uint8_t video_read_null(uint32_t addr, void *priv)
{
return 0xff;
}
void video_load(GFXCARD g)
{
io_sethandler(0x03a0, 0x0020, g.mono_in, NULL, NULL, g.mono_out, NULL, NULL, NULL);
io_sethandler(0x03c0, 0x0020, g.in, NULL, NULL, g.out, NULL, NULL, NULL);
video_out = g.out;
video_in = g.in;
video_mono_out = g.mono_out;
video_mono_in = g.mono_in;
pollvideo = g.poll;
video_recalctimings = g.recalctimings;
video_write_a000 = g.write_a000;
video_write_b000 = g.write_b000;
video_write_b800 = g.write_b800;
video_read_a000 = g.read_a000;
video_read_b000 = g.read_b000;
video_read_b800 = g.read_b800;
video_write_a000_w = video_write_a000_l = NULL;
g.init();
video_timer = timer_add(pollvideo, &vidtime, TIMER_ALWAYS_ENABLED, NULL);
}
void video_init()
{
pclog("Video_init %i %i\n",romset,gfxcard);
@ -155,107 +123,108 @@ void video_init()
switch (romset)
{
case ROM_TANDY:
video_load(vid_tandy);
device_add(&tandy_device);
return;
case ROM_PC1512:
video_load(vid_pc1512);
device_add(&pc1512_device);
return;
case ROM_PC1640:
video_load(vid_pc1640);
device_add(&pc1640_device);
return;
case ROM_PC200:
video_load(vid_pc200);
device_add(&pc200_device);
return;
case ROM_OLIM24:
video_load(vid_m24);
device_add(&m24_device);
return;
case ROM_PC2086:
case ROM_PC3086:
device_add(&paradise_pvga1a_device);
return;
case ROM_MEGAPC:
video_load(vid_paradise);
device_add(&paradise_wd90c11_device);
return;
case ROM_ACER386:
video_load(vid_oti067);
device_add(&oti067_device);
return;
}
switch (gfxcard)
{
case GFX_MDA:
video_load(vid_mda);
device_add(&mda_device);
break;
case GFX_HERCULES:
video_load(vid_hercules);
device_add(&hercules_device);
break;
case GFX_CGA:
video_load(vid_cga);
device_add(&cga_device);
break;
case GFX_EGA:
video_load(vid_ega);
device_add(&ega_device);
break;
case GFX_TVGA:
video_load(vid_tvga);
device_add(&tvga8900d_device);
break;
case GFX_ET4000:
video_load(vid_et4000);
device_add(&et4000_device);
break;
case GFX_ET4000W32:
video_load(vid_et4000w32p);
device_add(&et4000w32p_device);
break;
case GFX_BAHAMAS64:
video_load(vid_s3);
device_add(&s3_bahamas64_device);
break;
case GFX_N9_9FX:
video_load(vid_s3);
device_add(&s3_9fx_device);
break;
case GFX_STEALTH64:
video_load(vid_s3);
break;
case GFX_VIRGE:
video_load(vid_s3_virge);
device_add(&s3_virge_device);
break;
case GFX_TGUI9440:
video_load(vid_tgui9440);
device_add(&tgui9440_device);
break;
case GFX_VGA:
video_load(vid_vga);
device_add(&vga_device);
break;
case GFX_VGAEDGE16:
video_load(vid_ati18800);
device_add(&ati18800_device);
break;
case GFX_VGACHARGER:
video_load(vid_ati28800);
device_add(&ati18800_device);
break;
case GFX_OTI067:
video_load(vid_oti067);
device_add(&oti067_device);
return;
case GFX_MACH64GX:
video_load(vid_mach64);
device_add(&mach64gx_device);
return;
case GFX_CL_GD5429:
video_load(vid_gd5429);
device_add(&gd5429_device);
return;
default:
@ -263,78 +232,26 @@ void video_init()
}
}
uint32_t cga32[256];
BITMAP *buffer,*vbuf;//,*vbuf2;
BITMAP *buffer32;
int speshul=0;
BITMAP *buffer, *buffer32;
uint8_t fontdat[256][8];
uint8_t fontdatm[256][16];
int dispontime,dispofftime;
double disptime;
int svgaon;
uint8_t cgamode=1,cgastat,cgacol=7,ocgamode;
int linepos=0;
int output;
uint8_t *vram,*ram;
int cgadispon=0;
int cgablink;
uint8_t port3de,port3dd,port3df;
uint8_t crtc[128],crtcreg;
uint8_t crtcmask[128]={0xFF,0xFF,0xFF,0xFF,0x7F,0x1F,0x7F,0x7F,0xF3,0x1F,0x7F,0x1F,0x3F,0xFF,0x3F,0xFF,0xFF,0xFF};
uint8_t charbuffer[256];
int crtcams[64]={0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1};
int nmi=0;
int xsize=1,ysize=1;
int firstline=1000,lastline=0;
int ntsc_col[8][8]=
PALETTE cgapal;/* =
{
{0,0,0,0,0,0,0,0}, /*Black*/
{0,0,1,1,1,1,0,0}, /*Blue*/
{1,0,0,0,0,1,1,1}, /*Green*/
{0,0,0,0,1,1,1,1}, /*Cyan*/
{1,1,1,1,0,0,0,0}, /*Red*/
{0,1,1,1,1,0,0,0}, /*Magenta*/
{1,1,0,0,0,0,1,1}, /*Yellow*/
{1,1,1,1,1,1,1,1} /*White*/
};
{ 0, 0, 0},{0,42,0},{42,0,0},{42,21,0},
{ 0, 0, 0},{0,42,42},{42,0,42},{42,42,42},
{ 0, 0, 0},{21,63,21},{63,21,21},{63,63,21},
{ 0, 0, 0},{21,63,63},{63,21,63},{63,63,63},
extern int fullchange;
extern uint32_t vrammask;
int mdacols[256][2][2];
uint8_t gdcreg[16];
int cga4pal[8][4]=
{
{0,2,4,6},{0,3,5,7},{0,3,4,7},{0,3,4,7},
{0,10,12,14},{0,11,13,15},{0,11,12,15},{0,11,12,15}
};
PALETTE cgapal=
{
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
{0,0,0},{21,63,21},{63,21,21},{63,63,21},
{0,0,0},{21,63,63},{63,21,63},{63,63,63},
{0,0,0},{0,0,42},{0,42,0},{0,42,42},
{42,0,0},{42,0,42},{42,21,00},{42,42,42},
{21,21,21},{21,21,63},{21,63,21},{21,63,63},
{63,21,21},{63,21,63},{63,63,21},{63,63,63},
{0, 0, 0}, { 0, 0, 42}, { 0, 42, 0}, { 0, 42, 42},
{42, 0, 0}, {42, 0, 42}, {42, 21, 00}, {42, 42, 42},
{21, 21, 21}, {21, 21, 63}, {21, 63, 21}, {21, 63, 63},
{63, 21, 21}, {63, 21, 63}, {63, 63, 21}, {63, 63, 63},
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
@ -345,7 +262,7 @@ PALETTE cgapal=
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
};
};*/
void loadfont(char *s, int format)
{
@ -419,102 +336,53 @@ void loadfont(char *s, int format)
}
void drawscreen()
{
// printf("Drawscreen %i %i %i %i\n",gfxcard,MDA,EGA,TANDY);
// if (EGA) drawscreenega(buffer,vbuf);
/* else if (MDA) {}//drawscreenmda();
else if (TANDY)
{
if ((cgamode&3)==3 || array[3]&0x10) drawscreentandy(tandyvram);
else drawscreencga(tandyvram);
}*/
// else drawscreencga(&vram[0x8000]);
}
PALETTE comppal=
{
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
{21,21,21},{21,63,21},{42,21,42},{21,63,31},
{63,0,0},{42,42,0},{63,21,42},{41,41,41}
};
void initvideo()
{
int c;
// set_color_depth(desktop_color_depth());
// if (set_gfx_mode(GFX_AUTODETECT_WINDOWED,2048,2048,0,0))
// set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0);
// vbuf=create_video_bitmap(1280+32,1024+32);
// set_color_depth(32);
buffer32=create_bitmap(2048,2048);
// set_color_depth(8);
buffer=create_bitmap(2048,2048);
// set_color_depth(32);
for (c=0;c<64;c++)
{
cgapal[c+64].r=(((c&4)?2:0)|((c&0x10)?1:0))*21;
cgapal[c+64].g=(((c&2)?2:0)|((c&0x10)?1:0))*21;
cgapal[c+64].b=(((c&1)?2:0)|((c&0x10)?1:0))*21;
if ((c&0x17)==6) cgapal[c+64].g>>=1;
}
for (c=0;c<64;c++)
{
cgapal[c+128].r=(((c&4)?2:0)|((c&0x20)?1:0))*21;
cgapal[c+128].g=(((c&2)?2:0)|((c&0x10)?1:0))*21;
cgapal[c+128].b=(((c&1)?2:0)|((c&0x08)?1:0))*21;
}
for (c=0;c<256;c++) cga32[c]=makecol(cgapal[c].r<<2,cgapal[c].g<<2,cgapal[c].b<<2);
// for (c=0;c<16;c++) cgapal[c+192]=comppal[c];
// set_palette(cgapal);
if (MDA && !TANDY && !AMSTRAD && romset!=ROM_PC200) updatewindowsize(720,350);
else updatewindowsize(656,416);
for (c=17;c<64;c++) crtcmask[c]=0xFF;
}
int c, d, e;
void resetvideo()
{
int c;
if (MDA && !TANDY && !AMSTRAD && romset!=ROM_PC200) updatewindowsize(720,350);
else updatewindowsize(656,416);
cgastat=0;
set_palette(cgapal);
buffer32 = create_bitmap(2048, 2048);
for (c=18;c<64;c++) crtcmask[c]=0xFF;
crtc[0]=0x38;
crtc[1]=0x28;
// crtc[3]=0xFA;
crtc[4]=0x7F;
crtc[5]=0x06;
crtc[6]=0x64;
crtc[7]=0x70;
crtc[8]=0x02;
crtc[9]=1;
buffer = create_bitmap(2048, 2048);
cgacol=7;
for (c=0;c<256;c++)
for (c = 0; c < 64; c++)
{
mdacols[c][0][0]=mdacols[c][1][0]=mdacols[c][1][1]=16;
if (c&8) mdacols[c][0][1]=15+16;
else mdacols[c][0][1]=7+16;
cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21;
cgapal[c + 64].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21;
cgapal[c + 64].b = (((c & 1) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21;
if ((c & 0x17) == 6)
cgapal[c + 64].g >>= 1;
}
for (c = 0; c < 64; c++)
{
cgapal[c + 128].r = (((c & 4) ? 2 : 0) | ((c & 0x20) ? 1 : 0)) * 21;
cgapal[c + 128].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21;
cgapal[c + 128].b = (((c & 1) ? 2 : 0) | ((c & 0x08) ? 1 : 0)) * 21;
}
for (c = 0; c < 256; c++)
{
e = c;
for (d = 0; d < 8; d++)
{
rotatevga[d][c] = e;
e = (e >> 1) | ((e & 1) ? 0x80 : 0);
}
}
for (c = 0; c < 4; c++)
{
for (d = 0; d < 4; d++)
{
edatlookup[c][d] = 0;
if (c & 1) edatlookup[c][d] |= 1;
if (d & 1) edatlookup[c][d] |= 2;
if (c & 2) edatlookup[c][d] |= 0x10;
if (d & 2) edatlookup[c][d] |= 0x20;
// printf("Edat %i,%i now %02X\n",c,d,edatlookup[c][d]);
}
}
mdacols[0x70][0][1]=16;
mdacols[0x70][0][0]=mdacols[0x70][1][0]=mdacols[0x70][1][1]=16+15;
mdacols[0xF0][0][1]=16;
mdacols[0xF0][0][0]=mdacols[0xF0][1][0]=mdacols[0xF0][1][1]=16+15;
mdacols[0x78][0][1]=16+7;
mdacols[0x78][0][0]=mdacols[0x78][1][0]=mdacols[0x78][1][1]=16+15;
mdacols[0xF8][0][1]=16+7;
mdacols[0xF8][0][0]=mdacols[0xF8][1][0]=mdacols[0xF8][1][1]=16+15;
mdacols[0x00][0][1] = mdacols[0x00][1][1] = 16;
mdacols[0x08][0][1] = mdacols[0x08][1][1] = 16;
mdacols[0x80][0][1] = mdacols[0x80][1][1] = 16;
mdacols[0x88][0][1] = mdacols[0x88][1][1] = 16;
}
void closevideo()
{
destroy_bitmap(buffer);
destroy_bitmap(vbuf);
}