- char width switch feature (8 / 9 pixels) prepared for all display libraries

and implemented in SDL
  * sequencer controller register 0x01 bit 0 controls the width of the characters.
    This value is used to calculate the screen width.
  * attribute controller register 0x10 bit 2 controls the appearance of graphics
    characters (ASCII 0xC0 - 0cDF). A change of this value forces a charmap update
    to rebuild the font bitmaps.
  * the SDL display library uses the new feature described above
  * the other display libraries recalculate the screen width, since they are using
    a fixed font width of 8 for now.
- VGA: attribute controller register 0x10 bit 2 (enable_line_graphics) does not
  switch the palatte in CGA mode
This commit is contained in:
Volker Ruppert 2003-05-11 15:07:54 +00:00
parent 846ffa3dba
commit 3a788ddcf4
14 changed files with 94 additions and 49 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: amigaos.cc,v 1.17 2003-05-07 19:15:45 vruppert Exp $
// $Id: amigaos.cc,v 1.18 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000 MandrakeSoft S.A.
@ -664,12 +664,15 @@ bx_amigaos_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
void
bx_amigaos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
bx_amigaos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
int xdiff = w - x;
if (fheight > 0) {
if (fwidth != 8) {
x = x * 8 / fwidth;
}
if (fheight != 16) {
y = y * 16 / fheight;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: beos.cc,v 1.23 2003-05-07 19:15:45 vruppert Exp $
// $Id: beos.cc,v 1.24 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -435,9 +435,12 @@ bx_beos_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsi
void
bx_beos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
bx_beos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
if (fheight > 0) {
if (fwidth != 8) {
x = x * 8 / fwidth;
}
if (fheight != 16) {
y = y * 16 / fheight;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: carbon.cc,v 1.18 2003-05-07 19:15:45 vruppert Exp $
// $Id: carbon.cc,v 1.19 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1285,9 +1285,12 @@ void bx_carbon_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0
// x: new VGA x size
// y: new VGA y size (add headerbar_y parameter from ::specific_init().
void bx_carbon_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
void bx_carbon_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
if (fheight > 0) {
if (fwidth != 8) {
x = x * 8 / fwidth;
}
if (fheight != 16) {
y = y * 16 / fheight;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.h,v 1.37 2003-05-07 19:15:46 vruppert Exp $
// $Id: gui.h,v 1.38 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -31,6 +31,7 @@ typedef struct bx_vga_tminfo_t {
Bit16u line_compare;
Bit8u h_panning;
Bit8u v_panning;
bx_bool line_graphics;
};
@ -55,7 +56,7 @@ public:
virtual void flush(void) = 0;
virtual void clear_screen(void) = 0;
virtual bx_bool palette_change(unsigned index, unsigned red, unsigned green, unsigned blue) = 0;
virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0) = 0;
virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0, unsigned fwidth=0) = 0;
virtual unsigned create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim) = 0;
virtual unsigned headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void)) = 0;
virtual void replace_bitmap(unsigned hbar_id, unsigned bmap_id) = 0;
@ -156,7 +157,8 @@ protected:
virtual void clear_screen(void); \
virtual bx_bool palette_change(unsigned index, \
unsigned red, unsigned green, unsigned blue); \
virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0); \
virtual void dimension_update(unsigned x, unsigned y, unsigned fheight=0, \
unsigned fwidth=0); \
virtual unsigned create_bitmap(const unsigned char *bmap, \
unsigned xdim, unsigned ydim); \
virtual unsigned headerbar_bitmap(unsigned bmap_id, unsigned alignment, \

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: macintosh.cc,v 1.19 2003-05-07 19:15:46 vruppert Exp $
// $Id: macintosh.cc,v 1.20 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -989,9 +989,12 @@ void bx_macintosh_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned
// x: new VGA x size
// y: new VGA y size (add headerbar_y parameter from ::specific_init().
void bx_macintosh_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
void bx_macintosh_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
if (fheight > 0) {
if (fwidth != 8) {
x = x * 8 / fwidth;
}
if (fheight != 16) {
y = y * 16 / fheight;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: nogui.cc,v 1.19 2003-05-07 19:15:46 vruppert Exp $
// $Id: nogui.cc,v 1.20 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -229,11 +229,12 @@ bx_nogui_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
// y: new VGA y size (add headerbar_y parameter from ::specific_init().
void
bx_nogui_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
bx_nogui_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
UNUSED(x);
UNUSED(y);
UNUSED(fheight);
UNUSED(fwidth);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: rfb.cc,v 1.21 2003-05-07 19:15:46 vruppert Exp $
// $Id: rfb.cc,v 1.22 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000 Psyon.Org!
@ -640,11 +640,12 @@ void bx_rfb_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
// y: new VGA y size (add headerbar_y parameter from ::specific_init().
void
bx_rfb_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
bx_rfb_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
UNUSED(x);
UNUSED(y);
UNUSED(fheight);
UNUSED(fwidth);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: sdl.cc,v 1.35 2003-05-10 17:03:36 vruppert Exp $
// $Id: sdl.cc,v 1.36 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -273,7 +273,7 @@ void bx_sdl_gui_c::text_update(
bx_vga_tminfo_t tm_info,
unsigned rows)
{
unsigned char font_row, *pfont_row, *old_line, *new_line;
unsigned char *pfont_row, *old_line, *new_line;
unsigned long x,y;
int hchars,fontrows,fontpixels;
int fgcolor_ndx;
@ -282,8 +282,9 @@ void bx_sdl_gui_c::text_update(
Uint32 bgcolor;
Uint32 *buf, *buf_row, *buf_char;
Uint32 disp;
Bit8u cs_line, mask, cfwidth, cfheight;
bx_bool invert, forceUpdate;
Bit16u font_row, mask;
Bit8u cs_line, cfwidth, cfheight;
bx_bool gfxcharw9, invert, forceUpdate;
forceUpdate = 0;
if(charmap_updated)
@ -357,7 +358,8 @@ void bx_sdl_gui_c::text_update(
fgcolor = palette[fgcolor_ndx];
bgcolor = palette[bgcolor_ndx];
invert = ( (y == cursor_y) && (x == cursor_x) && (tm_info.cs_start < tm_info.cs_end) );
gfxcharw9 = ( (tm_info.line_graphics) && ((new_text[0] & 0xE0) == 0xC0) );
// Display this one char
fontrows = cfheight;
if (y > 0)
@ -372,6 +374,14 @@ void bx_sdl_gui_c::text_update(
do
{
font_row = *pfont_row++;
if (gfxcharw9)
{
font_row = (font_row << 1) | (font_row & 0x01);
}
else
{
font_row <<= 1;
}
if (hchars > textres_x)
{
font_row <<= h_panning;
@ -379,12 +389,12 @@ void bx_sdl_gui_c::text_update(
fontpixels = cfwidth;
cs_line = (fontheight - fontrows);
if( (invert) && (cs_line >= tm_info.cs_start) && (cs_line <= tm_info.cs_end) )
mask = 0x80;
mask = 0x100;
else
mask = 0x00;
do
{
if( (font_row & 0x80) == mask )
if( (font_row & 0x100) == mask )
*buf = bgcolor;
else
*buf = fgcolor;
@ -864,12 +874,13 @@ bx_bool bx_sdl_gui_c::palette_change(
void bx_sdl_gui_c::dimension_update(
unsigned x,
unsigned y,
unsigned fheight)
unsigned fheight,
unsigned fwidth)
{
if( fheight > 0 )
{
fontheight = fheight;
fontwidth = 8;
fontwidth = fwidth;
textres_x = x / fontwidth;
textres_y = y / fontheight;
}

View File

@ -393,7 +393,8 @@ bx_bool bx_svga_gui_c::palette_change(
void bx_svga_gui_c::dimension_update(
unsigned x,
unsigned y,
unsigned fheight)
unsigned fheight,
unsigned fwidth)
{
int newmode;
@ -403,6 +404,9 @@ void bx_svga_gui_c::dimension_update(
if( fheight > 0 )
{
fontheight = fheight;
if (fwidth != 8) {
x = x * 8 / fwidth;
}
fontwidth = 8;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: term.cc,v 1.26 2003-05-07 19:15:46 vruppert Exp $
// $Id: term.cc,v 1.27 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000 MandrakeSoft S.A.
@ -621,11 +621,12 @@ bx_term_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
// y: new VGA y size (add headerbar_y parameter from ::specific_init().
void
bx_term_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
bx_term_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
UNUSED(x);
UNUSED(y);
UNUSED(fheight);
UNUSED(fwidth);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32.cc,v 1.53 2003-05-07 19:15:46 vruppert Exp $
// $Id: win32.cc,v 1.54 2003-05-11 15:07:53 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -1140,9 +1140,12 @@ void bx_win32_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
// x: new VGA x size
// y: new VGA y size (add headerbar_y parameter from ::specific_init().
void bx_win32_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
void bx_win32_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
if (fheight > 0) {
if (fwidth != 8) {
x = x * 8 / fwidth;
}
if (fheight >= 14) {
FontId = 2;
yChar = fheight;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wx.cc,v 1.56 2003-05-11 08:29:23 vruppert Exp $
// $Id: wx.cc,v 1.57 2003-05-11 15:07:54 vruppert Exp $
/////////////////////////////////////////////////////////////////
//
// wxWindows VGA display for Bochs. wx.cc implements a custom
@ -1083,14 +1083,17 @@ void bx_wx_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
// x: new VGA x size
// y: new VGA y size (add headerbar_y parameter from ::specific_init().
void bx_wx_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
void bx_wx_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
IFDBG_VGA(wxLogDebug (wxT ("MyPanel::dimension_update trying to get lock. wxScreen=%p", wxScreen)));
wxScreen_lock.Enter ();
IFDBG_VGA(wxLogDebug (wxT ("MyPanel::dimension_update got lock. wxScreen=%p", wxScreen)));
BX_INFO (("dimension update x=%d y=%d fontheight=%d", x, y, fheight));
if (fheight > 0) {
wxFontY = fheight;
if (fwidth != 8) {
x = x * 8 / fwidth;
}
wxFontY = fheight;
}
wxScreenX = x;
wxScreenY = y;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: x.cc,v 1.64 2003-05-11 08:29:23 vruppert Exp $
// $Id: x.cc,v 1.65 2003-05-11 15:07:54 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -1299,9 +1299,12 @@ bx_x_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigne
void
bx_x_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
bx_x_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth)
{
if (fheight > 0) {
if (fwidth != 8) {
x = x * 8 / fwidth;
}
font_height = fheight;
font_width = 8;
columns = x / font_width;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vga.cc,v 1.75 2003-05-10 12:00:58 vruppert Exp $
// $Id: vga.cc,v 1.76 2003-05-11 15:07:54 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -725,8 +725,8 @@ bx_vga_c::write_handler_no_log(void *this_ptr, Bit32u address, Bit32u value, uns
bx_vga_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_log)
{
unsigned i;
bx_bool prev_video_enabled;
Bit8u charmap1, charmap2, prev_memory_mapping;
bx_bool prev_video_enabled, prev_line_graphics;
bx_bool prev_graphics_alpha, prev_chain_odd_even;
bx_bool needs_update = 0;
@ -845,6 +845,7 @@ bx_vga_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_log)
}
break;
case 0x10: // mode control register
prev_line_graphics = BX_VGA_THIS s.attribute_ctrl.mode_ctrl.enable_line_graphics;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.graphics_alpha =
(value >> 0) & 0x01;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.display_type =
@ -859,6 +860,10 @@ bx_vga_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_log)
(value >> 6) & 0x01;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.internal_palette_size =
(value >> 7) & 0x01;
if (((value >> 2) & 0x01) != prev_line_graphics) {
bx_gui->set_text_charmap(
& BX_VGA_THIS s.vga_memory[0x20000 + BX_VGA_THIS s.charmap_address]);
}
#if !defined(VGA_TRACE_FEATURE)
BX_DEBUG(("io write 3c0: mode control: %02x h",
(unsigned) value);
@ -1503,8 +1508,6 @@ bx_vga_c::update(void)
attribute = 6 - 2*(x % 4);
palette_reg_val = (BX_VGA_THIS s.vga_memory[byte_offset]) >> attribute;
palette_reg_val &= 3;
palette_reg_val |= BX_VGA_THIS s.attribute_ctrl.mode_ctrl.enable_line_graphics << 2;
// palette_reg_val |= BX_VGA_THIS s.attribute_ctrl.mode_ctrl.blink_intensity << 3;
DAC_regno = BX_VGA_THIS s.attribute_ctrl.palette_reg[palette_reg_val];
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = DAC_regno;
}
@ -1620,14 +1623,13 @@ bx_vga_c::update(void)
tm_info.line_compare = BX_VGA_THIS s.line_compare;
tm_info.h_panning = BX_VGA_THIS s.attribute_ctrl.horiz_pel_panning & 0x0f;
tm_info.v_panning = BX_VGA_THIS s.CRTC.reg[0x08] & 0x1f;
if (BX_VGA_THIS s.attribute_ctrl.mode_ctrl.enable_line_graphics) {
tm_info.line_graphics = BX_VGA_THIS s.attribute_ctrl.mode_ctrl.enable_line_graphics;
if ((BX_VGA_THIS s.sequencer.reg1 & 0x01) == 0) {
if (tm_info.h_panning == 8)
tm_info.h_panning = 0;
else
tm_info.h_panning++;
}
// FIXME: this can be removed when we implement the char width switch
if (tm_info.h_panning == 8) tm_info.h_panning = 7;
switch (BX_VGA_THIS s.graphics_ctrl.memory_mapping) {
case 0: // 128K @ A0000
@ -1636,7 +1638,7 @@ bx_vga_c::update(void)
iHeight = 16*25;
if( (iWidth != old_iWidth) || (iHeight != old_iHeight) )
{
bx_gui->dimension_update(iWidth, iHeight, 16);
bx_gui->dimension_update(iWidth, iHeight, 16, 8);
old_iWidth = iWidth;
old_iHeight = iHeight;
}
@ -1668,7 +1670,7 @@ bx_vga_c::update(void)
iHeight = 16*25;
if( (iWidth != old_iWidth) || (iHeight != old_iHeight) )
{
bx_gui->dimension_update(iWidth, iHeight, 16);
bx_gui->dimension_update(iWidth, iHeight, 16, 8);
old_iWidth = iWidth;
old_iHeight = iHeight;
}
@ -1696,7 +1698,7 @@ bx_vga_c::update(void)
break;
case 3: // B8000 .. BFFFF
unsigned VDE, MSL, rows;
unsigned VDE, MSL, rows, cWidth;
// Verticle Display End: find out how many lines are displayed
VDE = BX_VGA_THIS s.vertical_display_end;
@ -1710,18 +1712,20 @@ bx_vga_c::update(void)
// emulated CGA graphics mode 160x100x16 colors
MSL = 3;
rows = 100;
iWidth = 8 * BX_VGA_THIS s.CRTC.reg[1];
cWidth = 8;
iWidth = cWidth * BX_VGA_THIS s.CRTC.reg[1];
iHeight = 400;
} else {
rows = (VDE+1)/(MSL+1);
if (rows > BX_MAX_TEXT_LINES)
BX_PANIC(("text rows>%d: %d",BX_MAX_TEXT_LINES,rows));
iWidth = 8 * (BX_VGA_THIS s.CRTC.reg[1] + 1);
cWidth = ((BX_VGA_THIS s.sequencer.reg1 & 0x01) == 1) ? 8 : 9;
iWidth = cWidth * (BX_VGA_THIS s.CRTC.reg[1] + 1);
iHeight = VDE+1;
}
if( (iWidth != old_iWidth) || (iHeight != old_iHeight) || (MSL != old_MSL) )
{
bx_gui->dimension_update(iWidth, iHeight, MSL+1);
bx_gui->dimension_update(iWidth, iHeight, MSL+1, cWidth);
old_iWidth = iWidth;
old_iHeight = iHeight;
old_MSL = MSL;
@ -1735,8 +1739,8 @@ bx_vga_c::update(void)
cursor_y = 0xffff;
}
else {
cursor_x = ((cursor_address - start_address)/2) % (iWidth/8);
cursor_y = ((cursor_address - start_address)/2) / (iWidth/8);
cursor_x = ((cursor_address - start_address)/2) % (iWidth/cWidth);
cursor_y = ((cursor_address - start_address)/2) / (iWidth/cWidth);
}
bx_gui->text_update(BX_VGA_THIS s.text_snapshot,
&BX_VGA_THIS s.vga_memory[start_address],