2 Example2.C version 1.0
\r
3 by Robert Schmidt of Ztiff Zox Softwear 1993
\r
5 Example of making use of a TWEAK file by linking its contents in
\r
6 with the program. This program doesn't need any external files at
\r
14 #include "TwkUser.h"
\r
16 /* The following included file defines the Mode320x240 table of Registers.
\r
17 The file should be created by running
\r
18 TWEAK2C 320x240.256 320x240.c Mode320x240 */
\r
20 #include "320x240.c"
\r
26 cprintf("This example program was compiled with the C version of a TWEAK\n\r");
\r
27 cprintf("register file, and so will not need the external file.\n\r");
\r
28 cprintf("The C array is now used to set Mode X (320x240x256).\n\rPress any key.");
\r
31 /* Save the number of the current BIOS mode, so we can restore it
\r
38 /* Set mode 13h, to make sure the EGA palette set is correct for a 256
\r
44 /* Note that no initialization is neccessary now. The Register array
\r
45 is linked in as global data, and is directly accessible. Take
\r
46 note of the way the number of Register elements in the array is
\r
49 outRegArray(Mode320x240, sizeof(Mode320x240)/sizeof(Register));
\r
51 outpw(0x3c4, 0x0f02); /* Enable all 4 planes */
\r
53 /* Fill the screen with a blend of red and blue lines, defining the
\r
54 palette on the fly. */
\r
56 outp(0x3c8, 0); /* start with color 0 */
\r
57 for (y = 0; y<240; y++)
\r
59 outp(0x3c9, y>>2); /* red component */
\r
60 outp(0x3c9, 0); /* green component */
\r
61 outp(0x3c9, (256-y) >> 2); /* blue component */
\r
62 memset((char*)MK_FP(0xa000,0) + y*80, y, 80);
\r
65 /* The picture is drawn, so wait for user to get tired of it. */
\r
69 /* Restore the saved mode number. Borland's textmode() won't work, as the
\r
70 C library still thinks we're in the mode it detected at startup.
\r
71 The palette will be set to the BIOS mode's default. */
\r
77 /* Also note that since the array is static, global data, there is
\r
78 no pointer to free(), as was done in Example1.C */
\r