Direct write screen display text

zhaozj2021-02-17  51

Seeing something before (money) published DOS, I also made together and put it out of a small thing used in graduation design. It is not mildew!

This is a DOS direct written display showing 16-point array Chinese characters. The function output () is complete, which is based on the features of most such functions. Support view area cutout output. Support screen arbitrary location output (no Confirm in the general direct write screen method 640x480 resolution must be an integer multiple of 8, 8x16 output. 8x16 ovary output of English letters and numbers. Support direct write-down color Chinese characters output

Seeing that the word library is read in XMS memory and the word mode is read from the XMS memory, the hard disk can be read in pure DOS. To get a direct write function supported by XMS, you can view the EGL program source code. (2001.10.13 Note: This EGL is a DOS, which is doing this. Easy Graphics Library. Very complete, menu, dialog, mouse, keyboard, graphic flashing cursor, movable window , XMS, animation, bitmap, editing control, check box, single button, push button, etc., are supported, now look at it is really fanatics, there is no example in the book of the disk, just use hands hard. Just I have seen it again, it is really TMD to break up. I'm going to have a lot of things.) I have said a lot, I have sent a little emotion, let's talk about the topic, the following is the code, the format is to be aligned, put TAB All replaced with spaces, more forgivement, need HZK16 and ASC16 two fonts (UCDOS comes with ASC16) and Egavga.bgi, if you have anything on your hard disk, then please http: / /www.9cbs.net/filebbs/read_topic.asp?id=677 Download the packaged document

Add a sentence, 9CBS is on the tiger Hidden Dragon, the small person is a small code of the cow, if it doesn't have it, if I don't have a quick, I will see me on the street, I will thank you first.

MSVCER (home treasure)

/*OutText.C,Turbo C 2.0WangJiaBao CreateShenYang Electric Power Institute, 1997.09.19 * // * WangJiaBao Modify for friendShenYang Thermo Power Plant, 2001.04.20 * // * WangJiaBao Modify for 9CBSShenYang Thermo Power Plant, 2001.10.13 * /

#include "dos.h" #include "stdio.h" #include "stdlib.h" #include "graphics.h"

FILE * fp_hzk, * fp_asc; / * OutText () Each parameter meaning: x-string X-axis coordinate Y string Y axis coordinate Color string color HZ string address * / void OutText (int X, int y, unsigned char color , unsigned char * hz);

Main () {int GD = VGA, GM = Vgahi; Int x, y, len, color, y8x8 = 2, y8x16 = 16, bottom = 447; int WL = 120, wt = 100, WR = 520, WB = 315 ; / * Regional coordinate * / unsigned long Times = 1, TIME1 = 0, TIME2 = 0; Unsigned Char Tmpstr [100], / * ErrorHzk = "/ NERROR OPEN HZK16 / A", / * Errorasc = "/ NERROR OPEN ASC16 / A ", / * GOON =" Arbitrary button Continue Demo ", / * Viewport =" Demo the view fault ", / * demoviewStr =" of the OutText () function ", / * demoviewStr =" in the view Zone (% D,% D,% D) The Chinese characters are displayed in% d), the starting point coordinates are X =% D y =% D ", / * fonts =" Compare 8x8 and 8x16 output effect ", / * Hello =" small man 9CBS friends say "", / * report = "% lu second output sentence% Lu times.", / * Enddemo = "Demo the high-speed write-screen capability of the OutText () function, any key end demonstration"; if ((fp_hzk = FOPEN ("HZK16", "RB"))) == null) {/ * Open 16 * 16 o'clock Chinese word library file * / printf (errorhzk); exit (1);} if ((fp_asc = fopen ("ASC16" "RB")) == NULL) {/ * Open the ASCII code 8 * 16 o'clock file * / printf (errooranc); fclose (fp_hzk); exit (1);} initgraph (& gd, & gm, "); / * 1. Demonstration OutText () function full-screen output and viewability * / setfillstyle (wide_dot_fill, blue); bar (0,0,639,479); setFillStyle (Solid_Fill, White); bar (WL, WT, W R, wb); setViewPort (WL, WT, WR, WB, 1); / * Define the view * / for (x = y = 0; x <= 15; x , y = 16) {Sprintf (Tmpstr, DemoviewStr , WL, WT, WR, WB, X, Y); OutText (x, y, blue, tmpstr);} setViewPort (0, 0, 639, 479, 1); / * Reset Aspect * / OutText (320-Strlen (Viewport * 4, 60, Yellow, viewport); OutText (320-Strlen (GOON) * 4, 80, Lightcyan, Goon; getch (); / * 2. Demo the ASCII code character in graphics mode, with 8x8 dot Comparison between 8x16 dot matrix output * / setFillStyle (Solid_Fill, Black); BAR (0, 0, 639, 479); x = 0; TmpStr [0] = TmpStr [1] = '

/ 0 '; TextColor (White); do {if (x> 630) {y8x8 = 48; y8x16 = 48; x = 0;} OutTextxy (x, y8x8, tmpstr); OutText (x, y8x16, lightcyan, tmpstr) ; X = 10;} while ( TmpStr [0] <255); OutText (320-Strlen (Fonts) * 4,200, Yellow, Fonts; OutText (320-Strlen (GOON) * 4, 220, Lightcyan, Goon; Getch (); / * 3. Demonstrate the high-speed output capability of the OutText () function * / bar (0,0,639,479); OutText (639-Strlen (endDemo) * 8, 463, Lightcy, EndDemo; y = bottom; randomize (); Len = strlen (Hello) * 8; Time1 = Time (); / * Start time * / while (! kbhit ()) {/ * Perform * / if (y> = bottom) {y = 0 when no button X = random (639-le); color = random (15) 1; bottom = bottom <= 0? 447: bottom-16;} bar (x-1, y-1, x len, y 16) OutText (x, y , color, hello; sprintf (Tmpstr, "% Lu", Times ); BAR (0,463, strlen (tmpstr) * 8, 479); OutText (0,463, white, tmpstr); / * Count * / } TIME2 = Time (); / * End time * / getch (); bar (0,463,639,479); sprintf (Tmpstr, Report, Time2-Time1, Times); O Uttext (0,463, lightgreen, tmpstr); getCh (); fclose (fp_hzk); fclose (fp_asc); closegraph ();}

Void OutText (int X, int y, unsigned char color, unsigned char * hz) {long i; char far * ptr; int movebit, ybit; struct viewporttype v; unsigned char by2, by2, by2, byte1, byte2 , TMP, * BYPTR; GetViewSettings (& V); x = v.Left; Y = v.top; / * Display * / if (x <0 || y <0 || x> = 639 || Y> = 479 || x> = v.right || y> = v.bottom) Return; ybit = y 15> = v.bottom? v.bottom-y: 16; / * Y direction does not exceed the view area The lower boundary * / ybit = ybit <= 0? 0: ybit; / * Using write mode 2 * / OUTPORTB (0x3CE, 5); OUTPORTB (0x3cf, 2); / * Write 4 bit flat * / OUTPORTB 0x3C4, 2); OUTPORTB (0x3c5, 255); OUTPORTB (0x3CE, 8); While (* Hz) {BYTE1 = (unsigned char) * hz; Byte2 = (unsigned char) * (Hz 1); IF Byte1> = 0xa1 && Byte1 <= 0xfe) && (byte2> = 0xA1 && Byte2 <= 0xfe)) {/ * Chinese characters * / byptr = by; if (x 15> v.right) Break; / * Beyond the Vision Zone Do not display * / i = (byte1-0xa1) * 94 byte2-0xa1; i << = 5; fseek (fp_hzk, i, seek_set); FREAD (by, 32, 1, fp_hzk); / * Read Chinese characters * / * Because one byte contains 8 pixel points, it must be considered when the starting position is not in X% 8 == 0 * / / * To this turn, a offset movit * / movebit = x% 8 written only from a valid X position; / * The starting position is relatively offset in the buffer in the buffer * / for (i = 0; I > Movebit); TMP = * ptr; * PTR = color; / * Write color value to buffer * / / * to write 8 image points, second byte * / OUTPORTB (0x3cf, (by1 <<

转载请注明原文地址:https://www.9cbs.com/read-30252.html

New Post(0)