not finished.

		KON      ----- Kanji ON Linux console -----

Being something which internal constitution of the KON the to document is converted, it does this file. Still, it is incomplete, but the case of the bug taking and remodelling please refer. 

1. Flow of letter output 

With the KON picture output is done through the hypothetical text VRAM. Output from the PTY the to fragment being converted at the BUFSIZ unit, is delivered to VT emulator. Analyzing 1 letter each, it outputs VT emulator to the hypothetical text. If the console is active at the point in time when one fragment was processed contents of the hypothetical text are written to the VGA picture that way. 

1.1. False terminal 

1.2. VT emulator 

Structure con 

The text state information in VT emulator is remembered in the con structure. With VT emulator as for text system of coordinates it calculates the left edge starting point [ as 0, 0 ]. 

Variable scrollLine 

Con.y region (the range of the con.ymin to con.ymax) it is outside, it is necessary the scroll to do. But, with the FEP of the uum and the like the occasion where letter it outputs in the system line by all means it is outside region. 
Then, the scroll it does not do vis-a-vis the cursor movement with the \Ey:xH the sea urchin it did. When the con.y goes outside region with method the other than this, the number of suitable scroll lines is added to the variable scrollLine. 
When it is smaller than the con.ymin, when it is larger than negative number and the con.ymax, positive number is respectively added. The control code (indicatory impossible letter) the variable scrollLine is reflected on the actual scroll at the point in time when it is inputted. 

1.3. Hypothetical text 

The hypothetical text consists of three buffers. 

Text buffer 

The character cord/code of the text is housed. Half angle letter is housed that ASCII cord/code that way. In case of Chinese character both the EUC/SJIS being converted by the JIS cord/code, it is housed. 
In addition, if with the BIG5 " the ESC (0 " of Mule expansion comes, being converted by the 16bit cord/code of the BIG5, it is housed. In addition, in case of the EUC Chinese character the 8bit being dropped in the same way with any language, because it is housed, when with the BIG5 it makes the EUC, information falls. 

Color * attribute buffer 

Information of color and attribute is housed. However, in case of full size letter it is housed in only young address. Meaning of each bit like below has become the thing. 

	MSB                   LSB
	|b7|b6|b5|b4|b3|b2|b1|b0|

	b2b0:	Four gland color 
	b3:	Unused
	b6b4:	Back gland color 
	b7:	Underline attribute 

Flag buffer 

The flag buffer has the information and language information of modification of the corresponding text. When the MSB when with information of modification, entry to the text happens, becomes 0, that is reflected to the actual picture, it becomes with 1. 
The following 2bit has meant the Double Byte cord/code, if it is the 1st byte, if the b5, the 2nd byte the b6 becomes with 1. Language information enters into the b3-b0 of the 1st byte. 
If in the future, corresponding language increases, the b4 or it is the schedule which allots the being less crowded bit of 2nd byte to language information. As for language information, 

	enum {
	    DF_GB2312,
	    DF_JISX0208,
	    DF_KSC5601,
	    DF_JISX0212,
	    DF_BIG5_0,
	    DF_BIG5_1
	    };


with it is defined. 

	MSB                                   LSB
	|     b7|     b6|     b5|b4||b3|b2|b1|b0|
	|CLEAN_S|LATCH_2|LATCH_1|  ||<--------->|
	|0=latch|  byte2|  byte1|  ||       LANG|

In the standard VGA picture of the 80x30 text coordinate [ 5, 3 ] (as for the left corner when [ 0, 0 ])" 1 ? " is indicated there is no white background color with, 

	Relative address: 80 X 3 + 5 = 245 
	ASCII code of "1" : 0x31
	JIS code of "" : 0x2422
	There is no white background color: 00000111(B) = 0x07


	textBuff[245] = 0x31
	attrBuff[245] = 0x07
	flagBuff[245] = 0x00

	textBuff[246] = 0xA2
	textBuff[247] = 0x24
	attrBuff[246] = 0x07
	attrBuff[247] = 0x07
	flagBuff[246] = 0x22
	flagBuff[247] = 0x40

With it becomes. 	
	
2. VGA

2.1. Register

2.2. Basic operation 

Structure dInfo

The information which shows indicatory ability is retained. Each it is worthy of being something which was calculated those which are read from the kon.cfg, or with those. 

Structure cInfo

It is the information regarding cursor. If as for frequency of blinking even number we mean while indicating, are used even in the counter of the screen saber. The addr is calculated by the VgaSetCursorAddress. 
If as for the kanji cursor position full size it reaches fault 0 value. The indicatory switch is operated by the ESC sequence. 

2.3. WideText

With the KON in order to move to high resolution mode try the VGA to be able to appoint the CRT control register and the MISC register of the VGA with the kon.cfg file. 
If it does from VGA original standard, if it is resolution to the 800x600, in order to be able to modify the resolution of the VGA with only the CRT control register and the MISC register, being to be able to think, it does, but the majority of the plural modes which the SVGA card has seems that depends on the other register. 

Structure regText, regGraph

It is register information of the VGA. In case of the regGraph the CRT control register and the misc register are read from the kon.cfg. The CRT control register is administered furthermore calculation. The dInfo.gydim when being read from the kon.cfg, is converted to indicatory effective value. It is necessary to modify the number of indicatory of VGA side lines the on the basis of this value. As for the number of indicatory lines there is a CRT control register, 
	All bit of 0x12 : Subordinate 16 bits 
	2nd bit of 0x07 : 9th
	7th bit of 0x07 : 10th
With being to have become, 
        regGraph.crt[0x12] = (dInfo.gydim - 1) & 0xFF;
        regGraph.crt[7] &= 0xBD;
        regGraph.crt[7] |= ((dInfo.gydim - 1) & 0x100) >> 7;
        regGraph.crt[7] |= ((dInfo.gydim - 1) & 0x200) >> 3;
With the operation of saying is administered. 

Variable LineComp8, LineComp9

As for the line relative register there is a 0x18, but the 9th bit and as for the 10th bit are the respective 0x07 and the 0x09. Value other than these bits and those which collected register number are the LineComp8 and the LineComp9. 

3. The communication by the socket 

Thinking of various expandability, being to prepare the socket, it does, but it is used yet in only the font load. It meaning that also the knowledge which it draws up & mounts honest protocol the time is prompt, it has become something whose communication method is random. 

3.1. Socket name

The socket of the KON is drawn up to the /tmp. The name has accompanied several letter 1 letters after the.kon. This number several letters of end of the false terminal name which the KON has utilized becomes equal. 
In addition, if SocketClientOpen function of the GON library is utilized, because suitable socket name is used automatically, there are no times when you are conscious of name and they are possible to open the socket. 

3.2. Basic communication method 

Communication is done making use of the messageHeader structure. 

	struct  messageHeader   {
		u_char  cno,	Client number (unused) 
			cmd;	Functional code 
	};

ommunication is started due to the fact that the client appoints the functional cord/code. The functional cord/code is half angle letter 1 letter. 

	S: Half angle character font load 
	W: Full size character font load 

The functional cord/code forcing the ACK, it returns the KON which recognizes the functional cord/code. When you cannot recognize, the NAK is returned. Whenever from now on, the data is received, the KON transmits the ACK or the NAK. If the NAK is received, at once transmission the discontinuance there must be a client side. 

3.3. System of font load 

The case where the font loader transmits the font data to the KON it explains concerning procedure. 

	Font loader (fld.*) <-- /usr/tmp/.kon? --> KON

	Function: S|W          -------------------->
		S = Half angle font 
		W = Chinese character font 
				<-------------------- Acknowledgment (ACK) 
	FontInfo structure 	-------------------->
				<-------------------- Acknowledgment (ACK)
	The to fragment converting the font data with the BUFSIZ, it repeats below: 
	Datagram 		-------------------->
				<-------------------- Acknowledgment (ACK)

4. Mouse driver 

The mouse driver wrote the selection-1.4 on reference. Therefore but it has become 5 type correspondences, the fact that it has tested with this way is only the MircoSoft and the Mouse Systems. 

Structure mInfo

The information regarding the mouse is managed. Coordinate information is expressed with all text systems of coordinates. Whenever cursor indicatory life cursor blinks, decrement it is done, mouse cursor stops being indicated at the point in time when it has become 0. When state of the mouse changes, always this value the MOUSE_LIFETIME (default 22) with it has reached the point where it initializes. 

Variable dx, dy

The static variable DX which is used with the functional MouseAnalyzePacket, the dy is mouse portable value of graphic system of coordinates. You prepared in order properly to try to be reflected even with when the mouse was moved slowly. 

Variable oldstat

The static variable oldstat which is used with the functional MouseAnalyzePacket is previous state of the mInfo.stat. 

File /tmp/.kontmp

It is the file which houses the buffer which is cut with the mouse. 

5. The treatment regarding multi languages 

Those which are registered to the lib/coding.c can utilize the font. As for register of new font in case of Single Byte in coding.c:fSRegs and coding.c:fldSRegs, in case of Double Byte DF_ of coding.c:fDRegs, coding.c:fldDRegs, and please describe to the DF_?????? of the vt.h. Because the respective information 1 has become to 1, please protect order. 

6. GON library 

It is the library which is prepared in order to communicate with the KON easily. 
6.1. Memory operation function 

void PortOutw(u_short value, u_short port)

It outputs 2 byte unit to the I/O port. 

void PortOutb(char value, u_short port)

It outputs 1 byte unit to the I/O port.

u_char PortInb(unsigned short port)

It inputs 1 byte unit from the I/O port. 

void bzero2(void *buff, int n)

The high speed which used the stosb they are zero burying functions. The result is the same as the bzero. 

void wzero(void *buff, int n)

The high speed which used the stosw they are zero burying functions. Please pay attention to zero burying the N byte. 

void lzero(void *buff, int n)

The high speed which used the stosl they are zero burying functions. Please pay attention to zero burying the N byte. 

void bmove(void *dst, void *src, int n)

The high speed which used the movsb it is buffer transfer function. 

void brmove(void *dst, void *src, int n)

The high speed which used the movsb it is opposite direction buffer transfer function. From the src and the dst it transfers the N byte in opposite direction. 

void wmove(void *dst, void *src, int n)

The high speed which used the movsw it is buffer transfer function. The N byte please pay attention to transferring. 

void lmove(void *dst, void *src, int n)

The high speed which used the movsl it is buffer transfer function. The N byte please pay attention to transferring. 

6.2. Socket operation function 

void SocketKill(int fd)

The socket which is appointed with the ??????????? is closed, the socket of the KON is deleted. 

int SocketRecCommand(int fd, struct messageHeader *mh)

From the socket, the messageHeader structure is read 

int SocketSendCommand(int fd, char *cmd)

From the client, the functional code is sent to the KON. 

char socketName[MAX_SOCKET_NAME+1]

It is the buffer where the socket name which was drawn up with the functional SocketClientOpen is remembered. 

FILE *CapSearchLabel(char *label)

The function which searches the label which is appointed from the kon.cfg. You inspect also the alias of the label. When the label which agrees is found, the pointer to the FILE structure is returned. 

