📄 video.c
字号:
/****************************************************************************** Product: VGA screen output* Last Updated for Version: 3.3.00* Date of the Last Update: Jan 22, 2007** Q u a n t u m L e a P s* ---------------------------* innovating embedded systems** Copyright (c) 2002-2007 Quantum Leaps, LLC. All rights reserved.** Internet: www.quantum-leaps.com Licensing: sales@quantum-leaps.com** This Software is protected by the United States copyright laws and* international treaties. Distribution of products containing this Software* or based upon this Software (Derivative Works) requires a valid Quantum* Leaps Distribution License. Any other distribution, in source or binary* format is illegal.*****************************************************************************/#include "qf_port.h"#include <conio.h>#include <dos.h>#include "video.h"/*..........................................................................*/void Video_clearScreen(uint8_t bgColor) { clrscr(); Video_clearRect(0, 0, 80, 25, bgColor);}/*..........................................................................*/void Video_clearRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t bgColor){ for ( ; y1 < y2; ++y1) { uint8_t x; uint8_t far *pscr = (uint8_t far *)MK_FP(0xB800, (uint16_t)(((y1 * 80) + x1) * 2)); for (x = x1; x < x2; ++x) { pscr[0] = ' '; /* Put space in video RAM */ pscr[1] = bgColor; /* Put video attribute in video RAM */ pscr += 2; } }}/*..........................................................................*/void Video_printStrAt(uint8_t x, uint8_t y, uint8_t color, char const *str){ /* calculate position on the video RAM (VGA) */ uint8_t far *pscr = (uint8_t far *)MK_FP(0xB800, (uint16_t)(((y * 80) + x) * 2)); while (*str != (uint8_t)0) { pscr[0] = *str++; /* Put character in video RAM */ pscr[1] |= color; /* Put video attribute in video RAM */ pscr += 2; }}/*..........................................................................*/void Video_printNumAt(uint8_t x, uint8_t y, uint8_t color, uint32_t num) { char buf[4]; buf[3] = (char)0; buf[2] = (char)('0' + num % 10); num /= 10; buf[1] = (char)('0' + num % 10); num /= 10; buf[0] = (char)('0' + num % 10); if (buf[0] == '0') { buf[0] = ' '; } Video_printStrAt(x, y, color, buf);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -