📄 video.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Product: Direct Video (VGA) screen output// Last Updated for Version: 3.3.00// Date of the Last Update: Jan 24, 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.//// This software may be distributed and modified under the terms of the GNU// General Public License version 2 (GPL) as published by the Free Software// Foundation and appearing in the file GPL.TXT included in the packaging of// this file. Please note that GPL Section 2[b] requires that all works based// on this software must also be made publicly available under the terms of// the GPL ("Copyleft").//// Alternatively, this software may be distributed and modified under the// terms of Quantum Leaps commercial licenses, which expressly supersede// the GPL and are specifically designed for licensees interested in// retaining the proprietary status of their code.//// Contact information:// Quantum Leaps Web site: http://www.quantum-leaps.com// e-mail: sales@quantum-leaps.com//////////////////////////////////////////////////////////////////////////////#include "qf_port.h"#include <conio.h>#include <dos.h>#include "video.h"//............................................................................void Video::clearScreen(uint8_t bgColor) { clrscr(); 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 != (char)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] = ' '; } printStrAt(x, y, color, buf);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -