1
0
Fork 0

textmode address handling updated (hal)

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3443
This commit is contained in:
Sebastian Strohhäcker 2009-07-11 10:25:25 +00:00
parent a55cf50692
commit 655b7caa71
5 changed files with 45 additions and 21 deletions

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: vga_draw.cpp,v 1.109 2009-06-29 18:43:33 c2woody Exp $ */
/* $Id: vga_draw.cpp,v 1.110 2009-07-11 10:25:24 c2woody Exp $ */
#include <string.h>
#include <math.h>
@ -344,11 +344,24 @@ static Bit8u * VGA_Draw_LIN32_Line_HWMouse(Bitu vidstart, Bitu /*line*/) {
}
}
static const Bit8u* VGA_Text_Memwrap(Bitu vidstart) {
vidstart &= vga.draw.linear_mask;
Bitu line_end = 2 * vga.draw.blocks;
if (GCC_UNLIKELY((vidstart + line_end) > vga.draw.linear_mask)) {
// wrapping in this line
Bitu break_pos = (vga.draw.linear_mask - vidstart) + 1;
// need a temporary storage - TempLine/2 is ok for a bit more than 132 columns
memcpy(&TempLine[sizeof(TempLine)/2], &vga.tandy.draw_base[vidstart], break_pos);
memcpy(&TempLine[sizeof(TempLine)/2 + break_pos],&vga.tandy.draw_base[0], line_end - break_pos);
return &TempLine[sizeof(TempLine)/2];
} else return &vga.tandy.draw_base[vidstart];
}
static Bit32u FontMask[2]={0xffffffff,0x0};
static Bit8u * VGA_TEXT_Draw_Line(Bitu vidstart, Bitu line) {
Bits font_addr;
Bit32u * draw=(Bit32u *)TempLine;
const Bit8u *vidmem = &vga.tandy.draw_base[vidstart];
const Bit8u* vidmem = VGA_Text_Memwrap(vidstart);
for (Bitu cx=0;cx<vga.draw.blocks;cx++) {
Bitu chr=vidmem[cx*2];
Bitu col=vidmem[cx*2+1];
@ -376,7 +389,7 @@ skip_cursor:
static Bit8u * VGA_TEXT_Herc_Draw_Line(Bitu vidstart, Bitu line) {
Bits font_addr;
Bit32u * draw=(Bit32u *)TempLine;
const Bit8u *vidmem = &vga.tandy.draw_base[vidstart];
const Bit8u* vidmem = VGA_Text_Memwrap(vidstart);
for (Bitu cx=0;cx<vga.draw.blocks;cx++) {
Bitu chr=vidmem[cx*2];
@ -425,7 +438,7 @@ skip_cursor:
static Bit8u * VGA_TEXT_Xlat16_Draw_Line(Bitu vidstart, Bitu line) {
Bits font_addr;
Bit16u * draw=(Bit16u *)TempLine;
const Bit8u *vidmem = &vga.tandy.draw_base[vidstart];
const Bit8u* vidmem = VGA_Text_Memwrap(vidstart);
for (Bitu cx=0;cx<vga.draw.blocks;cx++) {
Bitu chr=vidmem[cx*2];
Bitu col=vidmem[cx*2+1];
@ -467,7 +480,7 @@ static Bit8u * VGA_TEXT_Draw_Line_9(Bitu vidstart, Bitu line) {
bool underline=(Bitu)(vga.crtc.underline_location&0x1f)==line;
Bit8u pel_pan=(Bit8u)vga.draw.panning;
if ((vga.attr.mode_control&0x20) && (vga.draw.lines_done>=vga.draw.split_line)) pel_pan=0;
const Bit8u *vidmem = &vga.tandy.draw_base[vidstart];
const Bit8u* vidmem = VGA_Text_Memwrap(vidstart);
Bit8u chr=vidmem[0];
Bit8u col=vidmem[1];
Bit8u font=(vga.draw.font_tables[(col >> 3)&1][chr*32+line])<<pel_pan;
@ -526,7 +539,7 @@ static Bit8u * VGA_TEXT_Xlat16_Draw_Line_9(Bitu vidstart, Bitu line) {
bool underline=(Bitu)(vga.crtc.underline_location&0x1f)==line;
Bit8u pel_pan=(Bit8u)vga.draw.panning;
if ((vga.attr.mode_control&0x20) && (vga.draw.lines_done>=vga.draw.split_line)) pel_pan=0;
const Bit8u *vidmem = &vga.tandy.draw_base[vidstart];
const Bit8u* vidmem = VGA_Text_Memwrap(vidstart);
Bit8u chr=vidmem[0];
Bit8u col=vidmem[1];
Bit8u font=(vga.draw.font_tables[(col >> 3)&1][chr*32+line])<<pel_pan;
@ -809,14 +822,16 @@ static void VGA_VerticalTimer(Bitu /*val*/) {
#endif
break;
case M_TEXT:
if ((IS_VGA_ARCH) && (svgaCard==SVGA_None)) vga.draw.byte_panning_shift = 2;
else vga.draw.byte_panning_shift = 0;
if ((IS_VGA_ARCH) && (svgaCard==SVGA_None)) vga.draw.address = vga.config.real_start * 2;
else vga.draw.address = vga.config.display_start * 2;
vga.draw.address += vga.draw.bytes_skip*vga.draw.byte_panning_shift;
vga.draw.byte_panning_shift = 2;
vga.draw.address += vga.draw.bytes_skip;
// fall-through
case M_TANDY_TEXT:
case M_HERC_TEXT:
if (machine==MCH_HERC) vga.draw.linear_mask = 0xfff; // 1 page
else if (IS_EGAVGA_ARCH) vga.draw.linear_mask = 0x7fff; // 8 pages
else vga.draw.linear_mask = 0x3fff; // CGA, Tandy 4 pages
vga.draw.cursor.address=vga.config.cursor_start*2;
vga.draw.address *= 2;
vga.draw.cursor.count++;
/* check for blinking and blinking change delay */
FontMask[1]=(vga.draw.blinking & (vga.draw.cursor.count >> 4)) ?

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: vga_other.cpp,v 1.27 2009-06-29 18:43:33 c2woody Exp $ */
/* $Id: vga_other.cpp,v 1.28 2009-07-11 10:25:24 c2woody Exp $ */
#include <string.h>
#include <math.h>
@ -68,7 +68,8 @@ static void write_crtc_data_other(Bitu /*port*/,Bitu val,Bitu /*iolen*/) {
vga.other.vsyncp=(Bit8u)val;
break;
case 0x09: //Max scanline
if (vga.other.max_scanline ^ val) VGA_StartResize();
val &= 0x1f; // VGADOC says bit 0-3 but the MC6845 datasheet says bit 0-4
if (vga.other.max_scanline ^ val) VGA_StartResize();
vga.other.max_scanline=(Bit8u)val;
break;
case 0x0A: /* Cursor Start Register */
@ -522,6 +523,7 @@ void VGA_SetupOther(void) {
Bitu i;
memset( &vga.tandy, 0, sizeof( vga.tandy ));
vga.attr.enabled = true;
vga.config.bytes_skip=0;
//Initialize values common for most machines, can be overwritten
vga.tandy.draw_base = vga.mem.linear;

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: int10.h,v 1.39 2009-05-27 09:15:42 qbix79 Exp $ */
/* $Id: int10.h,v 1.40 2009-07-11 10:25:25 c2woody Exp $ */
#include "vga.h"
@ -95,7 +95,7 @@
#define VGAMEM_MTEXT 0xB000
#define BIOS_NCOLS Bit16u ncols=real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
#define BIOS_NROWS Bit16u nrows=real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS)+1;
#define BIOS_NROWS Bit16u nrows=(Bit16u)real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS)+1;
extern Bit8u int10_font_08[256 * 8];
extern Bit8u int10_font_14[256 * 14];

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: int10_char.cpp,v 1.58 2009-05-27 09:15:42 qbix79 Exp $ */
/* $Id: int10_char.cpp,v 1.59 2009-07-11 10:25:25 c2woody Exp $ */
/* Character displaying moving functions */
@ -272,12 +272,19 @@ filling:
void INT10_SetActivePage(Bit8u page) {
Bit16u mem_address;
if (page>7) LOG(LOG_INT10,LOG_ERROR)("INT10_SetActivePage page %d",page);
if (IS_EGAVGA_ARCH && (svgaCard==SVGA_S3Trio)) page &= 7;
mem_address=page*real_readw(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE);
/* Write the new page start */
real_writew(BIOSMEM_SEG,BIOSMEM_CURRENT_START,mem_address);
if (IS_EGAVGA_ARCH && CurMode->mode<0x8) mem_address>>=1;
if (IS_EGAVGA_ARCH) {
if (CurMode->mode<8) mem_address>>=1;
// rare alternative: if (CurMode->type==M_TEXT) mem_address>>=1;
} else {
mem_address>>=1;
}
/* Write the new start address in vgahardware */
Bit16u base=real_readw(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS);
IO_Write(base,0x0c);
@ -587,7 +594,7 @@ static void INT10_TeletypeOutputAttr(Bit8u chr,Bit8u attr,bool useattr,Bit8u pag
if(cur_row==nrows) {
//Fill with black on non-text modes and with 0x7 on textmode
Bit8u fill = (CurMode->type == M_TEXT)?0x7:0;
INT10_ScrollWindow(0,0,nrows-1,ncols-1,-1,fill,page);
INT10_ScrollWindow(0,0,(Bit8u)(nrows-1),ncols-1,-1,fill,page);
cur_row--;
}
// Set the cursor for the page

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: int10_modes.cpp,v 1.86 2009-06-28 14:56:14 c2woody Exp $ */
/* $Id: int10_modes.cpp,v 1.87 2009-07-11 10:25:25 c2woody Exp $ */
#include <string.h>
@ -232,7 +232,7 @@ VideoModeBlock ModeList_OTHER[]={
};
VideoModeBlock Hercules_Mode=
{ 0x007 ,M_TEXT ,640 ,400 ,80 ,25 ,8 ,14 ,4 ,0xB0000 ,0x1000 ,97 ,25 ,80 ,25 ,0 };
{ 0x007 ,M_TEXT ,640 ,400 ,80 ,25 ,8 ,14 ,1 ,0xB0000 ,0x1000 ,97 ,25 ,80 ,25 ,0 };
static Bit8u text_palette[64][3]=
{