www.pudn.com > MessageQueue.zip > TextOut.c
/*
Copyright (C) 2004 Liu Ge
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "TextOut.h"
typedef struct
{
unsigned char bChar;
unsigned char bAttr;
}St_VideoBuffChar;
#define WHITE_COLOR 15
#define SCR_WIDTH 80
#define SCR_HEIGHT 25
#define VIDEO_BUFF_LIMIT (80*25)
#define VIDEO_BUFF_BASE (St_VideoBuffChar _far *)0xB8000000
#define xy2off(x, y) ( (y)*SCR_WIDTH + (x) )
// This pointer points to the video buffer, starting at address B800:0000
static St_VideoBuffChar _far * s_aryVideoBuffer = VIDEO_BUFF_BASE;
void TextDev_ClearScreen(void)
{
int y;
for( y = 0; y < SCR_HEIGHT; y ++ )
{
int x;
for( x = 0; x < SCR_WIDTH; x ++ )
{
int iOffset = xy2off(x, y);
s_aryVideoBuffer[iOffset].bChar = 0;
s_aryVideoBuffer[iOffset].bAttr = 0;
}
}
}
void TextDev_Out( int x, int y, const char * szText, int n )
{
unsigned int i;
const char * p;
int iOffset = xy2off(x, y);
for( i = 0, p = szText;
i < n && iOffset < VIDEO_BUFF_LIMIT;
i++,iOffset++, p++)
{
s_aryVideoBuffer[iOffset].bChar = *p;
s_aryVideoBuffer[iOffset].bAttr = WHITE_COLOR;
}
}