2 Screen.CPP version 1.0
\r
3 by Robert Schmidt of Ztiff Zox Softwear 1993
\r
5 Defines some primitives for handling the screen, some screen
\r
6 buffer pointers, and the functions that handle the single
\r
7 temporary screen used in TWEAK.
\r
14 #include <iostream.h>
\r
16 #include "Screen.HPP"
\r
19 char palette256[768];
\r
21 // editHeight and editWidth hold the dimensions of the editing screen.
\r
22 // Not everything is formatted according to those horizontally, but
\r
23 // vertically it should work fine.
\r
25 unsigned editMode, editHeight, editWidth, editSize;
\r
27 // Now for the screens used in TWEAK.
\r
29 // This one points to the standard VGA text screen buffer. textscr[80]
\r
30 // addresses the first character/attribute pair on the second line
\r
31 // if the current mode is an 80-column one, for example.
\r
33 unsigned *textScr = (unsigned far *)MK_FP(0xb800,0);
\r
35 // graphScr points to the standard VGA graphics buffer, being 64Kb.
\r
37 char *graphScr = (char far *)MK_FP(0xa000,0);
\r
39 // setBiosMode() sets the given standard BIOS mode.
\r
41 void setBiosMode(int modeno)
\r
47 // getBiosMode() returns the current BIOS mode.
\r
49 int getBiosMode(void)
\r
56 // The following two functions saves and restores the temporary screen.
\r
57 // The tempScr buffer is allocated and destroyed each time.
\r
59 void tempBuffer::save(void)
\r
63 if (!(temp = new unsigned[editSize]))
\r
65 cout << "Out of memory for swap screen!" << endl;
\r
68 memcpy(temp, link, sizeof(unsigned)*editSize);
\r
71 void tempBuffer::restore(void)
\r
77 memcpy(link, temp, sizeof(unsigned)*editSize);
\r
85 for (int c=0; c<16; c++)
\r
87 outp(0x3c0, 0x20 | c);
\r
88 palette16[c] = inp(0x3c0);
\r
92 void setEgaPalette(char *p)
\r
95 for (int c=0; c<16; c++)
\r
103 void setPalette16()
\r
105 char egaPal[] = {0,1,2,3,4,5,0x14,7,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f};
\r
106 setEgaPalette(egaPal);
\r
107 for (int c=0; c<16; c++)
\r
109 outp(0x3c0, 0x20 | c);
\r
110 outp(0x3c0, palette16[c]);
\r
114 void getPalette256()
\r
117 for (int c=0; c<768; c++)
\r
118 palette256[c] = inp(0x3c9);
\r
121 void setPalette256()
\r
123 char egaPal[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
\r
124 setEgaPalette(egaPal);
\r
126 for (int c=0; c<768; c++)
\r
127 outp(0x3c9, palette256[c]);
\r
130 void preparePalettes()
\r
132 int m=getBiosMode();
\r