SCREEN.CPP
资源名称:commutil.zip [点击查看]
上传用户:xr_qian
上传日期:2007-01-05
资源大小:443k
文件大小:4k
源码类别:
通讯/手机编程
开发平台:
DOS
- // ******************************************************************** //
- // //
- // SCREEN.CPP //
- // Copyright (c) 1993, Michael Holmes and Bob Flanders //
- // C++ Communication Utilities //
- // //
- // This file contains the routines for moving to and from //
- // the window buffers for saving and restoring the screen. //
- // //
- // ******************************************************************** //
- char huge *vid_seg = // video adapter address
- (char huge *) MK_FP(0xb800, 0);
- /* ******************************************************************** *
- *
- * screen_move() -- move between the video adapter and work buffer
- *
- * ******************************************************************** */
- void screen_move(int left, int top, // left and top corner
- int right, int bottom, // right and bottom corner
- char *buffer, // work buffer
- int dir) // direction (0=to screen)
- {
- char huge *p1, huge *p2; // work pointers
- int y, // loop variable
- p1size, p2size, size; // bytes per line
- size = (right - left + 1) * 2; // length of window line
- y = ((top - 1) * 160) + ((left - 1) * 2); // offset into video buffer
- if (dir) // q. moving to buffer?
- {
- p1 = buffer; // a. yes .. dest is buffer
- p1size = size; // ..and line length
- p2 = &vid_seg[y]; // source is video ram
- p2size = 160; // ..and length is 80 * 2
- }
- else
- {
- p1 = &vid_seg[y]; // else .. source is video ram
- p1size = 160; // ..and length is 80 * 2
- p2 = buffer; // destination is buffer
- p2size = size; // ..and line length
- }
- for (y = bottom - top + 1; y--; // loop thru for whole
- p1 += p1size, p2 += p2size) // ..screen window moving
- memcpy((void *) p1, (void *) p2, size); // ..from one to the other
- }
- /* ******************************************************************** *
- *
- * gettext() -- get text data from the video memory
- *
- * ******************************************************************** */
- void gettext(int left, int top, // left and top corner
- int right, int bottom, // right and bottom corner
- char *buffer) // work buffer
- {
- screen_move(left, top, right, bottom, // set up common call
- buffer, 1); // ..to screen move routine
- }
- /* ******************************************************************** *
- *
- * puttext() -- put text data from a work buffer into the video memory
- *
- * ******************************************************************** */
- void puttext(int left, int top, // left and top corner
- int right, int bottom, // right and bottom corner
- char *buffer) // work buffer
- {
- screen_move(left, top, right, bottom, // set up common call
- buffer, 0); // ..to screen move routine
- }