📄 video.cpp
字号:
#include "video.h"
/***********************************
** 显卡输出的高层库,被连入应用程序,
** 但内部调用系统调用进行实现
** 谢煜波
** xieyubo@126.com
************************************/
/* 初始化视屏 */
void class_pyos_Video::Init()
{
/* 清屏 */
Clear() ;
}
/* 打印函数 */
void class_pyos_Video::PrintNumber( unsigned int num , enum_pyos_Color FrontColor , bool flash , enum_pyos_Color BackColor , bool add_light )
{
char tmp[ 10 ] ; /* unsigned int 最大可技持 10 位 */
int i = -1 ;
while( num != 0 ){
++i ;
tmp[ i ] = num % 10 + '0';
num /= 10 ;
}
if( i == -1 ){
class_pyos_Video::Print( '0' , FrontColor , flash , BackColor , add_light ) ;
}
while( i != -1 ){
class_pyos_Video::Print( tmp[ i-- ] , FrontColor , flash , BackColor , add_light ) ;
}
}
/* 打印字符信息,此函数封装系统调用,被链入每个进程 */
void class_pyos_Video::Print( char msg , enum_pyos_Color front_color , bool flash , enum_pyos_Color back_color , bool add_light )
{
/* 组合生成系统调用的参数 */
struct_pyos_VideoItem v ;
v.Char = msg ;
v.FrontColor = front_color ;
v.Flash = flash ;
v.BackColor = back_color ;
v.AddLight = add_light ;
/* 产生系统调用,调用调用门 */
// 参数压栈,按从右到左( <-- )的顺序
char ch_tmp = v.Style ;
__asm__( "mov %0,%%eax" : "=m"(ch_tmp) ) ; // 压入风格参数
__asm__( "push %eax" ) ;
ch_tmp = v.Char ;
__asm__( "mov %0,%%eax" : "=m"(ch_tmp) ) ; // 压入字符参数
__asm__( "push %eax" ) ;
int int_tmp = -1 ;
__asm__( "mov %0,%%eax" : "=m"(int_tmp) ) ; // 压入 y 坐标值,为负表是在当前位置打印
__asm__( "push %eax" ) ;
__asm__( "push %eax" ) ; // 压入 x 坐标值
// 调用调用门
__asm__( "lcall $0x18,$0" ) ;
// 恢复栈
__asm__( "add $16,%esp" ) ; // 4 * 4 = 16
}
/* 打印字符信息 */
void class_pyos_Video::Print( char* msg , enum_pyos_Color front_color , bool flash , enum_pyos_Color back_color , bool add_light )
{
while( *msg ){
Print( *msg , front_color , flash , back_color , add_light ) ;
msg++ ;
}
}
/* 清屏 */
void class_pyos_Video::Clear()
{
/* 产生一个系统调用 */
__asm__( "lcall $0x20,$0" ) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -