1
0
Fork 0

Added some kind of aspect correction calcuation, still not perfect

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1414
This commit is contained in:
Sjoerd van der Berg 2003-11-08 10:11:25 +00:00
parent 433ec14aca
commit 895995c073

View file

@ -30,11 +30,8 @@
static void VGA_HERC_Draw(Bit8u * bitdata,Bitu pitch) {
Bit8u * reader=&vga.mem.linear[(vga.herc.mode_control & 0x80) ? 8*1024 : 0];
for (Bitu y=0;y<vga.draw.height;y++) {
// Bit8u * tempread=reader+((y & 3) * 8 * 1024);
Bit8u * tempread=reader+((y & 3) * 8 * 1024);
// Bit8u * tempread=reader;
Bit8u * draw=bitdata;
//TODO Look up table like in 4color mode
for (Bitu x=vga.draw.width>>3;x>0;x--) {
Bit8u val=*(tempread++);
*(Bit32u *)(draw+0)=CGA_2_Table[val >> 4];
@ -259,8 +256,7 @@ void VGA_DrawHandler(RENDER_Part_Handler part_handler) {
/* Draw the current frame */
if (!vga.draw.resizing) {
if (vga.config.line_compare<vga.draw.lines) {
Bitu stop=vga.config.line_compare;
if (vga.draw.double_height) stop/=2;
Bitu stop=vga.config.line_compare/vga.draw.scaleh;
if (stop>=vga.draw.height){
LOG(LOG_VGAGFX,LOG_NORMAL)("Split at %d",stop);
goto drawnormal;
@ -348,9 +344,13 @@ norender:;
void VGA_SetupDrawing(void) {
/* Calculate the FPS for this screen */
double fps;
Bitu vtotal=2 + (vga.crtc.vertical_total | ((vga.crtc.overflow & 1) << 8) | ((vga.crtc.overflow & 0x20) << 4) );
Bitu vtotal=2 + vga.crtc.vertical_total |
((vga.crtc.overflow & 1) << 8) | ((vga.crtc.overflow & 0x20) << 4)
;
Bitu htotal=5 + vga.crtc.horizontal_total;
Bitu vdispend = 1 + (vga.crtc.vertical_display_end | ((vga.crtc.overflow & 2)<<7) | ((vga.crtc.overflow & 0x40) << 3) );
Bitu vdispend = 1 + (vga.crtc.vertical_display_end |
((vga.crtc.overflow & 2)<<7) | ((vga.crtc.overflow & 0x40) << 3) |
((vga.s3.ex_ver_overflow & 0x2) << 9));
Bitu hdispend = 1 + (vga.crtc.horizontal_display_end);
Bitu hbstart = vga.crtc.start_horizontal_blanking;
@ -365,19 +365,25 @@ void VGA_SetupDrawing(void) {
/* Check for 8 for 9 character clock mode */
if (vga.seq.clocking_mode & 1 ) clock/=8; else clock/=9;
/* Check for pixel doubling, master clock/2 */
if (vga.seq.clocking_mode & 0x8) clock/=2;
if (vga.seq.clocking_mode & 0x8) {
clock/=2;
htotal*=2;
}
/* Check for dual transfer whatever thing,master clock/2 */
if (vga.s3.pll.cmd & 0x10) clock/=2;
LOG(LOG_VGA,LOG_NORMAL)("H total %d, V Total %d",htotal,vtotal);
LOG(LOG_VGA,LOG_NORMAL)("H D End %d, V D End %d",hdispend,vdispend);
fps=clock/(vtotal*htotal);
double correct_ratio=(100.0/525.0);
double aspect_ratio=((double)htotal/((double)vtotal)/correct_ratio);
vga.draw.resizing=false;
Bitu width,height,pitch,flags;
Bitu width,height,pitch;
Bitu scalew=1;
Bitu scaleh=1;
flags=0;
vga.draw.lines=height=vdispend;
width=hdispend;
vga.draw.double_height=vga.config.vline_double;
@ -387,29 +393,19 @@ void VGA_SetupDrawing(void) {
case M_VGA:
vga.draw.double_width=true; //Hack since 256 color modes use 2 clocks for a pixel
/* Don't know might do this different sometime, will have to do for now */
if (!vga.draw.double_height) {
if (vga.config.vline_height&1) {
vga.draw.double_height=true;
vga.draw.font_height/=2;
}
}
scaleh*=vga.draw.font_height;
width<<=2;
pitch=vga.config.scan_len*8;
break;
case M_LIN8:
width<<=3;
if (vga.draw.double_width) width>>=1;
if (!vga.draw.double_height) {
if (vga.config.vline_height&1) {
vga.draw.double_height=true;
vga.draw.font_height/=2;
}
}
scaleh*=vga.draw.font_height;
pitch=vga.config.scan_len*8;
break;
case M_EGA16:
width<<=3;
pitch=vga.config.scan_len*16;
scaleh*=vga.draw.font_height;
break;
case M_CGA4:
case M_CGA16: //Let is use 320x200 res and double pixels myself
@ -435,6 +431,7 @@ void VGA_SetupDrawing(void) {
break;
case M_TEXT2:
case M_TEXT16:
aspect_ratio=1.0;
vga.draw.font_height=vga.config.vline_height+1;
if (vga.draw.font_height<4 && (machine<MCH_VGA || machine==MCH_AUTO)) {
vga.draw.font_height=4;
@ -451,22 +448,23 @@ void VGA_SetupDrawing(void) {
LOG(LOG_VGA,LOG_ERROR)("Unhandled VGA type %d while checking for resolution");
};
if (vga.draw.double_height) {
flags|=DoubleHeight;
height/=2;
scaleh*=2;
}
height/=scaleh;
if (vga.draw.double_width) {
flags|=DoubleWidth;
/* Double width is dividing main clock, the width should be correct already for this */
scalew*=2;
}
if (( width != vga.draw.width) || (height != vga.draw.height) || (pitch != vga.draw.pitch)) {
PIC_RemoveEvents(VGA_BlankTimer);
vga.draw.width=width;
vga.draw.height=height;
vga.draw.pitch=pitch;
vga.draw.scaleh=scaleh;
LOG(LOG_VGA,LOG_NORMAL)("Width %d, Height %d, Pitch %d",width,height,pitch);
LOG(LOG_VGA,LOG_NORMAL)("Flags %X, fps %f",flags,fps);
RENDER_SetSize(width,height,8,pitch,((float)width/(float)height),flags,&VGA_DrawHandler);
LOG(LOG_VGA,LOG_NORMAL)("Width %d, Height %d, Pitch %d fps %f",width,height,pitch,fps);
LOG(LOG_VGA,LOG_NORMAL)("Scalew %d, Scaleh %d aspect %f",scalew,scaleh,aspect_ratio);
RENDER_SetSize(width,height,8,pitch,aspect_ratio,scalew,scaleh,&VGA_DrawHandler);
vga.draw.blank=(Bitu)(1000000/fps);
PIC_AddEvent(VGA_BlankTimer,vga.draw.blank);
}