Added a nice blinking cursor again
Added support for cga register to toggle textmode blinking Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1625
This commit is contained in:
parent
7146fd91ad
commit
d1f0154107
4 changed files with 54 additions and 66 deletions
|
@ -124,6 +124,7 @@ typedef struct {
|
|||
Bit8u font[64*1024];
|
||||
Bitu font1_start;
|
||||
Bitu font2_start;
|
||||
Bitu blinking;
|
||||
struct {
|
||||
Bit8u sline,eline;
|
||||
Bit8u count,delay;
|
||||
|
@ -161,6 +162,7 @@ typedef struct {
|
|||
} VGA_HERC;
|
||||
|
||||
typedef struct {
|
||||
Bit8u mode_control;
|
||||
Bit8u color_select;
|
||||
} VGA_CGA;
|
||||
|
||||
|
@ -311,6 +313,7 @@ void VGA_SetClock(Bitu which,Bitu target);
|
|||
void VGA_DACSetEntirePalette(void);
|
||||
void VGA_StartRetrace(void);
|
||||
void VGA_StartUpdateLFB(void);
|
||||
void VGA_SetBlinking(Bitu enabled);
|
||||
|
||||
extern VGA_Type vga;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#define attr(blah) vga.attr.blah
|
||||
|
||||
|
||||
void VGA_ATTR_SetPalette(Bit8u index,Bit8u val) {
|
||||
vga.attr.palette[index]=val;
|
||||
if (vga.attr.mode_control & 0x80) val=(val&0xf) | (vga.attr.color_select << 4);
|
||||
|
@ -63,9 +62,7 @@ void write_p3c0(Bit32u port,Bit8u val) {
|
|||
}
|
||||
}
|
||||
if ((attr(mode_control) ^ val) & 0x08) {
|
||||
/* Fill up background text mode color lookup table */
|
||||
Bit32u b=(val & 8) ^ 0x8;
|
||||
for (Bitu i=0;i<8;i++) TXT_BG_Table[i+8]=(b+i) | ((b+i) << 8)| ((b+i) <<16) | ((b+i) << 24);
|
||||
VGA_SetBlinking(val & 0x8);
|
||||
}
|
||||
/*
|
||||
Special hacks for games programming registers themselves,
|
||||
|
|
|
@ -101,7 +101,7 @@ static Bit8u * VGA_VGA_Draw_Line(Bitu vidstart,Bitu panning,Bitu line) {
|
|||
|
||||
static Bit32u FontMask[2]={0xffffffff,0x0};
|
||||
static Bit8u * VGA_TEXT_Draw_Line(Bitu vidstart,Bitu panning,Bitu line) {
|
||||
Bit8u * draw=VGA_DrawBuffer;
|
||||
Bit32u * draw=(Bit32u *)&VGA_DrawBuffer[0];
|
||||
Bit8u * vidmem=&vga.mem.linear[vidstart];
|
||||
for (Bitu cx=0;cx<vga.draw.blocks;cx++) {
|
||||
Bitu chr=vidmem[cx*2];
|
||||
|
@ -112,62 +112,22 @@ static Bit8u * VGA_TEXT_Draw_Line(Bitu vidstart,Bitu panning,Bitu line) {
|
|||
Bit32u fg=TXT_FG_Table[col&0xf];
|
||||
Bit32u bg=TXT_BG_Table[col>>4];
|
||||
mask1&=FontMask[col >> 7];mask2&=FontMask[col >> 7];
|
||||
*(Bit32u*)draw=fg&mask1 | bg&~mask1;
|
||||
draw+=4;
|
||||
*(Bit32u*)draw=fg&mask2 | bg&~mask2;
|
||||
draw+=4;
|
||||
*draw++=fg&mask1 | bg&~mask1;
|
||||
*draw++=fg&mask2 | bg&~mask2;
|
||||
}
|
||||
if (!vga.draw.cursor.enabled || !(vga.draw.cursor.count&0x8)) goto skip_cursor;
|
||||
Bits font_addr=(vga.config.cursor_start*2-vidstart)/2;
|
||||
if (font_addr>=0 && font_addr<vga.draw.blocks) {
|
||||
if (line<vga.draw.cursor.sline) goto skip_cursor;
|
||||
if (line>vga.draw.cursor.eline) goto skip_cursor;
|
||||
draw=(Bit32u *)&VGA_DrawBuffer[font_addr*8];
|
||||
Bit32u att=TXT_FG_Table[vga.mem.linear[vga.config.cursor_start*2+1]&0xf];
|
||||
*draw++=att;*draw++=att;
|
||||
}
|
||||
skip_cursor:
|
||||
return VGA_DrawBuffer;
|
||||
}
|
||||
|
||||
void VGA_TEXT_Draw(Bit8u * bitdata,Bitu start,Bitu panning,Bitu lines) {
|
||||
#if 0
|
||||
Bit8u * reader=&vga.mem.linear[start*2];Bitu rows=lines/vga.draw.font_height;
|
||||
for (Bitu cy=rows;cy>0;cy--) {
|
||||
for (Bitu y=0;y<vga.draw.font_height;y++) {
|
||||
Bit8u * draw=bitdata;
|
||||
bitdata+=vga.draw.width;
|
||||
for (Bitu cx=0;cx<vga.draw.cols;cx++) {
|
||||
Bit8u chr=reader[cx*2];
|
||||
Bit8u font=vga.draw.font[chr*32+y];
|
||||
Bit32u mask1=TXT_Font_Table[font>>4];
|
||||
Bit32u mask2=TXT_Font_Table[font&0xf];
|
||||
Bit8u col=reader[cx*2+1];
|
||||
Bit32u fg=TXT_FG_Table[col&0xf];
|
||||
Bit32u bg=TXT_BG_Table[col>>4];
|
||||
*(Bit32u*)draw=fg&mask1 | bg&~mask1;
|
||||
draw+=4;
|
||||
*(Bit32u*)draw=fg&mask2 | bg&~mask2;
|
||||
draw+=4;
|
||||
}
|
||||
}
|
||||
reader+=(vga.config.scan_len*4);
|
||||
}
|
||||
/* Cursor handling */
|
||||
if(vga.draw.cursor.enabled && (vga.draw.cursor.count>8)) { /* Draw a cursor if enabled */
|
||||
Bits cur_start=vga.config.cursor_start-start;
|
||||
if (cur_start<0) return;
|
||||
|
||||
Bitu row=cur_start / (vga.config.scan_len*2);
|
||||
Bitu col=cur_start % (vga.config.scan_len*2);
|
||||
Bit32u att=vga.mem.linear[vga.config.cursor_start*2+1]&0xf;
|
||||
att=TXT_BG_Table[att];
|
||||
|
||||
if ((col*8)>=vga.draw.width) return;
|
||||
if ((row*vga.draw.font_height)>=vga.draw.height) return;
|
||||
if (vga.draw.cursor.sline>=vga.draw.font_height) return;
|
||||
if (vga.draw.cursor.sline>vga.draw.cursor.eline) return;
|
||||
Bit8u * cursor_draw=bitdata+(row*vga.draw.font_height+vga.draw.cursor.sline)*vga.draw.width+col*8;
|
||||
|
||||
for (Bits loop=vga.draw.cursor.eline-vga.draw.cursor.sline;loop>=0;loop--) {
|
||||
*((Bit32u *)cursor_draw)=att;
|
||||
*((Bit32u *)(cursor_draw+4))=att;
|
||||
cursor_draw+=vga.draw.width;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void VGA_VerticalDisplayEnd(void) {
|
||||
vga.config.retrace=true;
|
||||
vga.config.real_start=vga.config.display_start;
|
||||
|
@ -199,6 +159,21 @@ static void VGA_DrawPart(void) {
|
|||
// if (vga.draw.parts_left) PIC_AddEvent(VGA_DrawPart,vga.draw.micro.parts);
|
||||
}
|
||||
|
||||
void VGA_SetBlinking(Bitu enabled) {
|
||||
Bitu b;
|
||||
LOG_MSG("Blinking %d",enabled);
|
||||
if (enabled) {
|
||||
b=0;vga.draw.blinking=-1;
|
||||
vga.attr.mode_control|=0x08;
|
||||
vga.cga.mode_control&=~0x20;
|
||||
} else {
|
||||
b=8;vga.draw.blinking=0;
|
||||
vga.attr.mode_control&=~0x08;
|
||||
vga.cga.mode_control|=0x20;
|
||||
}
|
||||
for (Bitu i=0;i<8;i++) TXT_BG_Table[i+8]=(b+i) | ((b+i) << 8)| ((b+i) <<16) | ((b+i) << 24);
|
||||
}
|
||||
|
||||
static void VGA_VerticalTimer(void) {
|
||||
vga.config.retrace=false;
|
||||
PIC_AddEvent(VGA_VerticalTimer,vga.draw.micro.vtotal);
|
||||
|
@ -364,10 +339,10 @@ void VGA_SetupDrawing(void) {
|
|||
case M_TEXT2:
|
||||
case M_TEXT16:
|
||||
aspect_ratio=1.0;
|
||||
vga.draw.address_line_total=vga.draw.font_height;
|
||||
if (vga.draw.font_height<4 && (machine<MCH_VGA || machine==MCH_AUTO)) {
|
||||
vga.draw.font_height=4;
|
||||
};
|
||||
vga.draw.address_line_total=vga.draw.font_height;
|
||||
vga.draw.blocks=width;
|
||||
vga.draw.address_add=vga.config.scan_len*4;
|
||||
if (vga.seq.clocking_mode & 0x8) scalew*=2;
|
||||
|
|
|
@ -57,15 +57,22 @@ static Bit8u read_p3da(Bit32u port) {
|
|||
|
||||
|
||||
static void write_p3d8(Bit32u port,Bit8u val) {
|
||||
/* Check if someone changes the blinking/hi intensity bit */
|
||||
switch (machine) {
|
||||
case MCH_AUTO:
|
||||
VGA_SetBlinking((val & 0x20));
|
||||
switch (vga.mode) {
|
||||
case M_CGA2:
|
||||
case M_CGA4:
|
||||
case M_CGA16:
|
||||
case M_TANDY16:
|
||||
goto m_cga;
|
||||
}
|
||||
break;
|
||||
case MCH_CGA:
|
||||
goto cga_3d8;
|
||||
};
|
||||
switch (vga.mode) {
|
||||
case M_CGA16:
|
||||
case M_CGA4:
|
||||
case M_CGA2:
|
||||
cga_3d8:
|
||||
case MCH_TANDY:
|
||||
VGA_SetBlinking((val & 0x20));
|
||||
m_cga:
|
||||
if (val & 0x2) {
|
||||
if (val & 0x10) {
|
||||
if (val & 0x8) {
|
||||
|
@ -78,10 +85,10 @@ cga_3d8:
|
|||
} else {
|
||||
VGA_SetMode(M_TEXT16);
|
||||
}
|
||||
vga.cga.mode_control=val;
|
||||
break;
|
||||
default:
|
||||
LOG(LOG_VGAMISC,LOG_NORMAL)("Write %2X to 3d8 in mode %d",val,vga.mode);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
3 Vertical Sync Select. If set Vertical Sync to the monitor is the
|
||||
|
@ -117,6 +124,10 @@ static void write_p3d9(Bit32u port,Bit8u val) {
|
|||
case M_CGA16:
|
||||
for(i=0;i<0x10;i++) VGA_ATTR_SetPalette(i,i);
|
||||
break;
|
||||
case M_TEXT16:
|
||||
/* Assume a normal text palette has been set */
|
||||
// VGA_ATTR_SetPalette(0,(val & 0x8) ? ((val & 7)+32) : (val &7));
|
||||
break;
|
||||
default:
|
||||
LOG(LOG_VGAMISC,LOG_NORMAL)("Unhandled Write %2X to %X in mode %d",val,port,vga.mode);
|
||||
}
|
||||
|
@ -213,7 +224,9 @@ static void write_hercules(Bit32u port,Bit8u val) {
|
|||
if ((vga.herc.enable_bits & 1) && ((vga.herc.mode_control ^ val)&0x2)) {
|
||||
vga.herc.mode_control^=0x2;
|
||||
if (vga.mode != M_HERC || vga.mode != M_TEXT2) {
|
||||
VGA_ATTR_SetPalette(0,0x00);
|
||||
VGA_ATTR_SetPalette(1,0x07);
|
||||
|
||||
/* Force 0x3b4/5 registers */
|
||||
if (vga.misc_output & 1) write_p3c2(0,vga.misc_output & ~1);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue