original:
Http://purec.binghua.com/Article/class6/class7/200410/281.html
PDF format:
http://purec.binghua.com/soft/class9/class16/200410/67.html
Source code:
Http://purec.binghua.com/soft/class9/class16/200410/66.html
Reprint, please specify the original author and the source
Let your own operating system support mouse
- Do a support system that supports graphical interfaces (below)
Version 0.01
(Corresponding PYOS version 2004_10_06_15_00)
Harbin Institute of Technology Xie Yubo
(email: xieyubo@126.com URL: http://purec.binghua.com)
(QQ: 13916830 Harbin Institute of Technology BBS ID: IAMXIAOHAN)
Foreword
In the last sheet, we have already understood how to display a graphical interface, including how to operate the graphics, how to display pictures, how to display Chinese Chinese characters and English characters. However, as a complete graphical interface, it is not preferentially displayed, and it is necessary to accept user input, and in the graphical interface, the most important input means is input through the mouse. In this article, we will describe how to let you Your own operating system supports the mouse.
Since there are many interface protocols in the mouse, we only describe the most commonly used PS / 2 protocol. This article is to guide the friends who are interested, and I don't know how to get started, I personally do my own experiment, so I will not describe the full content of the agreement. If you need to understand the content of the entire protocol, you should look for the relevant literature for reading, You can refer to a reference for this article.
The content described in this article is based on my own understanding of this problem. There is a certain deviation and improper, so don't use the content described in this article as a "standard", if you find the problems existing in it, I am very welcome to contact me in time, I will also feedback on the problems that appear in the pure C toum (http://purec.binghua.com).
This time I also experiment with PYOS, let's take a look at the ultimate results of this experiment:
This is the interface waiting for the user to log in after PYOS startup.
This is the interface behind the user, which is equivalent to the desktop of Windows.
Use the right click of the mouse to drag the application icon
Click the icon to open the application, this app is a push box game
Use I, J, K, L four keys to play games, ESC keys, or use the mouse click the window title bar to close it.
Use the mouse right to drag the title bar to drag the entire window, just like Windows
Click the "Shutdown" button in the lower left corner to exit PYOS
This is the interface after the shutdown, the interface after PYOS exits
The above is the final experimental result of this experiment. I hope that by reading this experiment report, you can complete a better experiment than this :).
This experiment is also a synthesis of the previous experiment, which uses "operating system guidance", "protection mode
8259A
Chip Programming and Interrupt Processing (Up) "," Writing the implementation of the keyboard interaction of the operating system "," to make an operating system (on) that support graphical interfaces (on) "The content described in these experimental reports. Therefore, if you want to better understand the content of this experiment, you can find the above experimental report on the pure C forum for reference, this experiment report will not discuss the contents already mentioned in previous experiment reports.
This experiment has got a lot of friends, in which the Harbin Institute of Technology, the Landscam, Swordlea, recommended to support the Windows standard BMP image format, PineApple help me find the icon under Windows, Hotice guide to use Photoshop, and So ON ~~ :) The words are correct, and we start our experiment below.
First, by programming the mouse by the I8042 keyboard controller
Now we use the mouse that supports the mouse that supports the PS / 2 protocol. This mouse is also known as the PS / 2 mouse. The PS / 2 protocol actually supports two devices, one is a keyboard, one is a mouse, it is The IBM is developed, the protocol itself defines the rules of the keyboard and the mouse with the host, including a large number of physical and electrical information, such as the pin (needle) of the plug of the mouse connection, each The use of the pin (needle), how is the level, but fortunately, we don't need to know more about such hardware details, you can complete our operating system, what we need to know how to initialize the mouse, And how to get information from the mouse.
Here, let's take a look at how to initialize the mouse. According to the PS / 2 protocol, the mouse is controlled by the controller (I8042) of the keyboard, the keyboard controller (I8042) has two channels, and one channel is used by the keyboard, and the other channel is used by the mouse, and we operate on the mouse It is also done by the I8042 chip, so the current focus is to understand and become familiar with how to program I8042 to complete control of the mouse.
I8042 supports two working modes --at mode and PS / 2 mode, which are some specification defined by IBM, and I8042 automatically detects the keyboard and mouse that the user supports the PS / 2 protocol when the user is started. Decide whether to work in PS / 2 mode, now we assume that we are using the PS / 2 keyboard and mouse, so I8042 is now working in PS / 2 mode (please remember this, that is, I8042 can work in AT mode Or in the PS / 2 mode, and now assume that it works in PS / 2 mode, this will be used later).
There are two I / O ports related to I8042, one is a 0x60 port, one is a 0x64 port, if we want to get the status of the I8042, we need to read 0x64 port, which will return the content of the status register in I8042. If we want to send a command to the I8042, we need to send the command to the 0x64 port, then send the parameters of this command to the 0x60 port, then we can get the data returned by the i8042 by reading the 0x60 port.
Let's take a look, what kind of command should be sent to control the mouse, which involves the following several commands that need to be sent to I8042:
0xA8 Command: The mouse channel of I8042 is allowed to allow mouse operations.
0xD4 Command: Send the parameter data sent to 0x60 port to the mouse.
0x60 Command: Write the parameter data sent to the 0x60 port to the control register of the I8042.
From above, we can basically see how to operate the mouse. First, we should send 0xA8 commands to the 0x64 port of I8042 to license the I8042 mouse channel to complete the operation of the mouse. Second, we should send 0xD4 commands to the i8042 0x64 port to inform I8042 We need to control the mouse and send the command to the I8042 to the 0x60 port, and then retrieve the data from the I8042's 0x60 port to our data, this The process is undoubtedly relatively simple, let's take a look, we should send what kind of control commands to the mouse, and then look at the actual code. Controlling the command of the mouse is very much, such as the 0xFF command to make the mouse reset; 0xfe command allows the mouse to resend the last packet; 0xF3 command can set the sampling rate of the mouse, that is, the sensitivity of the mouse slide; 0xF4 command can be allowed The mouse sends a packet to the host. The most important thing here is the 0xF4 command, and other settings of the mouse can be temporarily indiscriminate, because the default value is already good to complete the experiment. To understand what the 0xF4 command is there, we need to learn about the four working modes of the mouse: Reset mode, Stream mode, Remote mode, and WRAP mode.
The first is RESET mode. After the mouse is initially powered or received, the mouse is in this mode, then the mouse will make a series of initialization and detection work, including setting the default sampling rate, etc., after the initialization pole detection, The mouse will enter the Stream mode.
In Stream mode, if the mouse is moved, or the key is pressed, then the mouse will send a packet to the host, and draw an interrupt request, the host needs to respond to this interrupt, and obtain the data package sent by the mouse in the interrupt handler . If in Stream mode, we send a 0xF0 command to the mouse, which will enter the REMOTE mode.
The Remote mode is similar to the stream mode. The main job is to detect whether the mouse is moved and whether it is pressed, but it is different from the Stream mode. It does not actively draw the interrupt request, that is, it will not active Send a packet to the host, but the passive wait host uses the 0xeb (read data command), then populates the interrupt request to the host, send a packet. In other words, if you want to read data each time you want to read data, you need to send a 0xeB command to the mouse, and if you are in Stream mode, the mouse will automatically send you data.
WRAP mode is mainly used to detect whether the cable between the mouse and the host is normal. The host sends a command to it. It usually does not execute this command, but simply puts this command differently to the host, the host can compare it Commands and whether the received commands is consistent and determined whether the cable between the mouse and the host is normal.
From the above description, we can see that there is only RESET mode and Stream mode concerned, but for operating system writers instead of BIOS writing personnel, there is only STREAM mode, because when the computer is started At the time, the BIOS will automatically detect the mouse, communicate with the mouse. At this time it sends 0xFF command to the mouse, then the mouse will be self-test, and notify the host self-test is normal, and then the mouse will be in Stream mode, at this time The mouse has begun to detect if the mouse is moved and whether the key is pressed, but it will not immediately send data to the host, because it is possible that the host has not entered the real operating system, the host is still started, so the mouse will wait The notification of the host until the host sends the 0xF4 command, it starts to send data to the host. Therefore, the action of initializing the mouse in the operating system is very simple, please see the relevant code of the initialization mouse in Pyos below:
// Limited mouse
Void mouse_enable_mouse ()
{
/ / Program the 8042 keyboard control chip
/ / Allow mouse interface
IO_WRITE_TO_IO_PORT (0x64, 0xA8);
/ / Notify 8042 Data of the Directive 0x60 of the next byte will be sent to the mouse
IO_WRITE_TO_IO_PORT (0x64, 0xD4);
// Allow mouse to send data
IO_WRITE_TO_IO_PORT (0x60, 0xf4);
/ / Notify 8042, the data of the severity 0x60 of the next byte should be depressed to the 8042 command register
IO_WRITE_TO_IO_PORT (0x64, 0x60);
/ / License keyboard and mouse interface and interrupt
IO_WRITE_TO_IO_PORT (0x60, 0x47);
}
With the above description, this code is quite simple, first it sends a 0xA8 command to the I8042 0x64 port, notifying I8042, allowing the mouse channel. Then, it sends a 0x6 command to the 0x64 port of the I8042. This command indicates that the command to 0x60 will be sent to the mouse, so it followed, it also transmits the 0x60 port of I8042, that is, to the mouse, 0xF4 command This command will allow the BIOS to initialize the mouse to the host to send a packet to the host. Subsequently, it transmits a 0x60 command to the 0x64 port of the I8042, indicating that the data below the 0x60 port needs to be written to the control register of the I8042, and finally it transmits data of the value of 0x47 to the 0x60 port of I8042, which is written. The I8042 control register. Below, let's take a look at this control register to understand why you need to send data to be 0x47 to it.
Below is the format of the I8042 control register, this control register has a total of 8 digits, namely one byte.
Bit 0: Keyboard interrupt flag bit, if 1, then if there is a keyboard action, i8042 will disclose the IRQ1 interrupt.
Bit 1: The mouse interrupt flag, if 1, then if there is a mouse action, I8042 will disclose the IRQ12 interrupt (this is not used in the AT mode, only in the PS / 2 mode. Here you can recall our mention The I8042 can be operated in two modes of AT or PS / 2).
Bit 2: The system flag is 0, it is 0, and it is 1 after the self-test is successful.
Bit 3: Keyboard lock flag, if it is 1, will ignore the keyboard lock, which is mainly to be compatible with some old-fashioned keyboards, and this only in the AT mode, this bit will not be used in PS / 2 mode . Bit 4: Keyboard interface flag, if 1, will be banned from using the keyboard interface.
Bit 5: In AT mode, this is the AT keyboard protocol. When 0, I8042 will use the AT protocol, if set, will use the XT protocol. In PS / 2 mode, this is a mouse interface (channel) flag, and if set 1 will disable the mouse interface (channel).
Bit 6: Keyboard Scan code conversion flag. If set 1 will convert the real keyboard scan code to the first set of keyboard scanning code (for this content, see "Writing the keyboard interaction of the operating system").
Bit 7: Reserved, should be 0.
Second, the mouse data package brief analysis
In the previous section, we know how to program the I8042 to complete the initialization operation of the mouse, then when the mouse is initialized, if there is a mouse action, such as the user moves the mouse, or presses the mouse button. Then the mouse will send the data package to the host. Now let's take a look at the structure of the data package that the mouse returns to the host. Before you understand this structure, we must know that there are two types of mice in existing, one is called 2D (two-dimensional) mouse, it is the kind of mouse that we usually use, because this mouse is only in the two directions, so it is called 2D (two-dimensional) mouse; there is also a class It is now relatively common 3D (3D) mouse, there is a roller in the middle, and this roller produces an additional z-bit shift, so it has X, Y, Z three directions on the displacement, so For 3D (3D) mouse. Below, let's take a look at what the data packets of these two categories are sent to the host. Let's take a look at the two-dimensional mouse.
Bit 0: Left button Press the flag, 1 means that the left button is pressed.
Bit 1: Right click to press the flag, 1 means that the right button is pressed.
Bit 2: Middle key Press the flag, 1 means the middle button is pressed.
Bit 3: Reserved bit, always 1.
Bit 4: X symbol flag, 1 means X-bit shift amount is negative.
Bit 5: Y symbol flag, 1 means that Y displacement is negative.
Bit 6: X overflow flag, 1 means that the X-bit shift overflows.
Bit 7: Y overflow is the next, 1 means that the Y displacement is overflow.
Below, let's take a look at the data packet structure of a three-dimensional mouse.
The first data packet in the 3D mouse packet is identical to each of the first packets in the first packet in the 2D mouse package, and the only difference is that it will send a packet each time, 4 packets, this packet contains Z's displacement, the same X, Y bit shift is the same, which is represented by complement. However, the X and Y displacement is different, the Z displacement amount is 4 bits, where the highest bit (fourth bit) is a symbolic bit, so the effective range of z-shift is: -8 ~ 7. The displacement amount of X and Y is 9 bits, the highest bit (9th bit) is a symbol bit, which is represented in the first packet, so the effective range of the displacement amount of X and Y is: 256 ~ 255.
Seeing this, you may have questions, how can the system know that I should receive 3 packets or receive 4 packets? The standard of the three-dimensional mouse is made by Microsoft. Initially, this three-dimensional mouse only works in the standard PS / 2 mode. If you want it to work in three-dimensional mode, you need to use 0xF3 to set the mouse sampling rate command , Operate in order as follows: 1. Set the mouse sampling rate 200
2. Set the mouse sampling rate of 100
3. Set the mouse sampling rate of 80
After this, if your mouse is a three-dimensional mouse, it will go to 3D mode for work, this time, the host sends 0xF2 (get the mouse type id) command, your mouse in 3D mode will be The host returns its type ID, but if your mouse does not support three-dimensional mode, if your mouse is just a two-dimensional mouse, it returns to the host's type ID will be 0, so that the host can know now you use the mouse What type of mouse and thus knows that 3 or 4 packets should be accepted. This experiment will only operate the standard two-dimensional mouse if you are interested, you can change the program to allow it to support 3D mouse.
Now let's take a look, how this packet is obtained by the host. In "protection mode
8259A
The chip programming and interrupt processing exploration (up and down) "In this experiment report, we know that the mouse interrupt is proposed by IRQ12, so in the operating system, we need to write an interrupt handler for IRQ12, then in this Read the data packet sent by the mouse in the interrupt handler, let's take a look at this real code that exists in PYOS:
// Mouse interrupt processing function
Void mouse_handle_for_mouse_interrupt ()
{
Static int x_position = 444; // Defines the initial X coordinate of the mouse
Static int y_position = 300; // Defines the initial Y coordinate of the mouse
Static int count = 0; // This variable is used to record this is the first few packets.
// Because each packet sent by the mouse
// will cause an interrupt
Static int x_sign = 0; // Used to represent the symbol of the X-bit shift
Static int y_sign = 0; // Used to represent a symbol of the Y-shift
Static struct message_message_struct message; // Define a message
// This message is used to notify the operating system core with mouse action
CHAR CH = IO_READ_FROM_IO_PORT (0x60); // Get the data package sent by the 0x60 port
Switch ( count) {// detection is the first few packets
Case 1:
// Received the first byte
// Detect button information
Message.dose_left_button_down = ch & 0x1;
Message.dose_right_button_down = ch & 0x2;
// Get the symbol of X and Y displacement
X_SIGN = CH & 0x10? 0xfffffffff00: 0;
Y_SIGN = CH & 0x20? 0xfffffffff00: 0; Break;
Case 2:
// Received a second byte, that is, X's displacement
X_Position = (x_sign | ch); // Calculate new X coordinates
Break;
Case 3:
// Received the third byte, that is, the bit shift amount of Y
Y_Position = - (Y_SIGN | CH); // Calculate the new Y coordinate
// Send the message to the kernel
Message.Mestage_Type = message_mouse_message; // Set the type of message
Message.x_position = x_position; // Setting the parameters of the message (the coordinates of X)
Message.y_position = y_position; // Setting the parameters of the message (Y coordinate)
Message_put_message (& kernel_message_queue, message); // put the message into the kernel's message queue
count = 0; // The three packets have been received, so the zero counter
Break;
}
}
The above code comments have been very detailed, and the "message" is "message", if you have seen the experimental report of the "keyboard interaction of the operating system", it should be very familiar with it. If you haven't seen it, So don't worry, it will be described when analyzing the entire PYOS experimental program structure.
This PYOS experiment, supports the Windows standard BMP image format, let's describe the problem of this standard BMP image format to facilitate better understanding of this experiment.
Third, the Windows standard BMP image format supported by PYOS
BMP image format is not only a single format, but a class of formats, including 24-bit true color format, 16-bit true color format, 555 format in the 16-bit true color format, 565 format, etc. There are 4, 8-bit tuning format, compressed storage format, etc., very complicated, this PYOS only supports one of them, ie non-compressed, 16-bit color 555 format, this is also 32-bit Windows default 16-bit BMP format. Since the BMP format has been complicated, I want to be more authoritative in this regard. This experiment report will only describe this experiment. This experiment report will only describe this experiment. Some of the details used in order to read the code of this experiment very convenient.
Let's take a brief understanding of the BMP format. The BMP format is also called a bitmap format. It is a complete record of the color information of a picture. Every point is used in a color, so when it is displayed, just read this file, and then get The color data of each point, then displays this point in this color to the screen, because each picture is composed of one point, so after the point is displayed, it will complete the whole Display of the picture.
However, a file light records the color information of each point, but also requires the size of this picture, and this picture each point with several data bits to record colors, this information is called BMP The header information of the file is recorded in the beginning of the file. Let's take a look at this file header: struct bmp_bmp_head_struct {
Short type; // Type
INT size_file; // size
Short reserved_0;
Short reserved_1;
INT OFFSET; // bitmap array start position
Struct BMP_BMP_INFO_HEAD_STRUCT INFO_HEAD;
}
This structure is relatively simple, first is a 2-byte type data, used to determine this is a BMP file, followed by a 4-byte data, used to indicate the size of this file, followed by 4 bytes to the future Using, the subsequent 4-byte is an offset, which points out where the color data of each point is in this BMP file, which is very important for us. Subsequently, it is a so-called BMP information structure. Let's take a look at what data in this so-called BMP information structure is worthy of our concern.
Struct BMP_BMP_INFO_HEAD_STRUCT {
INT the_struct_size;
Int width;
INT height;
// There is also data below, but the current PYOS only processes 16-bit true color frame, so the following data is not
}
This structure also compares the shortage, first is 4-byte data, used to represent the size of this structure, and then 4-byte data gives the width of the picture described in this file, the four bytes of the following are given. The height of this picture, then there are some data, which give this picture to use the compressed format to store data, each point is used by how many bits, and whether it is used, if used Color version, there is also a color palette data. Since this article only handles 16 digits, the following data is not considered, but if you want to be a better and more complete system, then you need to study the full format of BMP. Then, according to the different information recorded, different processing in the program, PYOS is only a principle of experimental system, so it is not intended to have more effort in this regard, very hoped to see the improved version later: p.
With the above description, we can show the picture with a relatively good understanding, let's take a look at the actual processing code in PYOS:
// Show images in PBMP format
Void VESA_SHOW_BMP_PICTURE (unsigned int x, unsigned int y, void * bmp_addr, unsigned short mask_color, int dose_use_mask_color)
{
/ / This only supports Windows standard 16-bit BMP format pictures, (1: 5: 5: 5)
Struct BMP_BMP_HEAD_STRUCT * BMP_HEAD = (Struct Bmp_BMP_HEAD_STRUCT *) BMP_ADDR;
INT width = bmp_head-> info_head.width; // Get the width of the picture
INT Height = BMP_HEAD-> Info_Head.height; // Get the height of the picture
// The location of the information of each point is stored below.
Unsigned short * color = (unsigned in *) ((unsigned int) bmp_addr bmp_head-> offset); // Since the number of bytes must be a multiple of 4, here, here, the number of pads required for each line first, Except for 2 bytes of each pixel
INT FILL_LENGTH = Width * 2% 4/2;
/ / BMP's storage order is from bottom to right
For (int i = height - 1; i> = 0; --I) {
For (int J = 0; j / / Get color information for each point // Since Windows default is 555 format, and Pyos uses 565 format, so let's take a conversion first. Unsigned short temp_color = vesa_change_color_form_555_to_565 (* color); IF (! DOSE_USE_MASK_COLOR || TEMP_COLOR! = Mask_color) { // Draw each point VESA_DRAW_POINT (X J, Y I, TEMP_COLOR); } Color; } // Fill Color = Fill_Length; } } The above code is also relatively simple, and there is a more detailed note, here is not described, only two points to be reminded: First, the default order of the BMP file is stored in the lowermost left corner of one picture, From left to right, from bottom to top, rather than according to normal from top to bottom. Moreover, each departure data must be detected whether it is a multiple of 4, if not, fill 0 so that it is always 4 bytes of multiple, which is also called 4-byte alignment. The second thing to note is that the 16-bit true color bitmap used by Windows is 555 format, that is, red (R), Green (G), Lan (B) is represented by 5 digits, while Pyos Now use 565 format (i.e., red (R) to use 5 bits, green (g) uses 6 bits, the blue (B) is represented by 5 bits), so before the display, it is necessary to convert it, specifically Content, you can see source code. Fourth, PYOS system architecture The basic knowledge required for this experiment has been described in front. Here we will take a look at the main architecture of PYOS. The first thing to say is that since PYOS has not completed disk-driven and file systems, all resources used in PYOS, including pictures, fonts, etc., are initially generated in the startup image (pyos.img) of PYOS. When it is written directly to the fixed address called "make_together.exe" directly to the fixed address on disk, then, when SETUP.ASM is guided in the system, the fixed position in the memory is read, and the operating system core is used. When they are used through the fixed address of this memory. Learn this, it is very helpful to see the source code. When SETUP.ASM reads the picture used, the system will jump to the kernel.c, this is the system's kernel, let's take a look at some programs in this file: // kernel main function Void kernel_main () { // Operating system initialization SYSTEM_INIT (); Old_picture = (unsigned short *) 0x100000; // Crossing the read-only memory area / / Painting the landing interface KERNEL_DRAW_LOGIN_FORM (); // 0x903B3 / / Clear the keyboard buffer IO_READ_FROM_IO_PORT (0x60); // Initialization Message Queue Message_init_Message_Queue (& Kernel_Message_Queue); // open interrupt Interrupt_open_interrupt (); Struct message_message_struct message; KERNEL_KERNEL_STATE = Kernel_Wait_User_login // Enter the message loop For (;;) { IF (! message_get_message (& kernel_message_queue, & message) { CONTINUE; } IF (Message.Message_Type == Message_Shutdown_Computer) { Break; } Switch (Message.Message_Type) { Case message_keyboard_message: // Process the keyboard message ...... Case message_mouse_message: // Handling mouse message ...... } } // stop For (;;) { __ASM __ ("HLT"); } } This program is also very simple, first call SYSTEM_INIT () to make some initialization operations, such as initializing the interrupt vector table, initializing the keyboard, initializing the mouse, etc., then call the kernel_draw_login_form () This function to display the interface waiting for the user to log in, and finally It initializes a message queue and then enters a message loop, and the message is constantly removed from this message queue and performs different processing according to the type of message. Whenever a keyboard actions or mouse action, the keyboard and the mouse interrupt handler construct a message, then put this message in the kernel's message queue, which can know what the user has operation, then according to the user The operation is processed. For example, if the user indicates the left mouse button in the mouse message, the kernel will detect if the user's mouse is within the range where the application icon is located. If so, start the application (this is the push box in the experiment. game). If you have experience in writing a Windows application under Windows, it should be better understood. The specific details can be seen from the source program. In addition, there is a very detailed description of the message queue, interrupt processing, this content is a detailed description of the "implementation of the keyboard interaction of the operating system", which is not available here. /* system initialization */ void system_init () { // Since the project may be added to the GDT table later, you should reinitialize the GDT table to save the GDT table location. System_init_gdt (); // Initialization interrupt Interrupt_init (); // Initialize the keyboard Keyboard_init (); // Initialize the mouse mouse_init (); } The above code is the system initialized program, which is called in the kernel.c's main () function to complete some of the initialization operations of the system, the specific code, and you can see the source program. Note: In the PYOS source code, the first word of each function or variable indicates which file exists in, for example: system_init (), the first word System in system_init () indicates that this function exists in system.c. In the file, I hope this naming way will help you read the source program. V. Suggestions for further experiments Because PYOS may be more focused on principality or basic, it has made some assumptions and ignore in many ways. For example, in this experiment, it did not detect whether the user used a three-dimensional mouse. Therefore, there was no support for the three-dimensional mouse. It did not detect the real color BMP image file used by the user, and the user is used. This picture does not have any error inspection and correction for this image file. In addition, it adopts a way of the most snail, each of its pictures, every line, is a point, a point, a graphic copy is also a point of assignment, so PYOS is running very slow, The actual system is never like this. You can perform a series of optimizations for it. For example, in copying pictures, use Memcpy a copy of memory or build a buffer in memory, and draw the map in the buffer, and then use Memcpy to copy to the memory card in memory. Display. I know the basic principles, how to optimize should not be a high incomplete thing. Also, if you want to have a deeper understanding of the details of the stuff described in this article, you can read this article, most of them can be found on the pure C forum. postscript This article is "Being an Operating System for the Graphical Interface". The last article has been posted on the pure C forum, received a feedback from a friend, everyone should complete a graphical operating system, or Whether PyOS should take a graphical road, put forward a very valuable opinion, here is a sincere gratitude to all friends, and I want to talk about this opportunity to talk about this problem. First, from Pyos's perspective, PYOS is just an experimental operating system, the purpose is to verify the learned, and therefore, PYOS pursue is started from one unsuccessful raw state, and strives to learn more detail by such a process. Implementation details, so PYOS is simple, slow, but stronger is complete. It is not intended to be a virtual useful OS, in Pyos, just verification can be done, but not in the actual OS, must do it. Pyos is a start without the final result. In this experiment, PYOS deliberately simulates the Windows graphical interface, which is only that you want to uncover the mysterious veil on Windows or other operating systems through such analog, so that you don't understand this. People can realize that as long as I do one step, I don't have Microsoft, and we may also do it. Thus, let more people have confidence and this interest to write their own operating system. I always force a complete OS, cut into a number of details, and each experiment, use Pyos to implement a detail, and ignore other details, so, each experiment is different, very Big, sometimes there is not much to work, however, I always think that you can understand each detail, we can achieve it yourself, then, I hope that one day, we can combine this detail. This graphical interface like this is actually a comprehensive result of the expropriation of the experiment. Second, from the general sense, if you plan to develop an OS, do I develop a graphical interface, my point is: If you are developing a specific goal, then you need to choose from your goals, you have to develop A efficient system or an interface-friendly system. If the demand is different, I think this conclusion should also be different. Like Pyos, it is defined as a Chinese operating system. To support Chinese, graphics mode is necessary. If you are learning a skill or knowledge, then I suggest you can try the development of the graphical interface, what you want to consider is more complicated than the character interface, and it is more difficult to handle, this kind of challenge is clearly beneficial . In fact, whether you decide whether you choose a graphical interface, the most important thing is that you are interested in doing this. In order to complete this experiment, I only slept for less than 15 hours in three days, I didn't eat, and I didn't eat, escaped for three days. fortunately The teacher didn't point me, thank the good, it is not the case, but generally, it is very difficult to stop, this is also a support, it is interested. . So if you want to decide to use the graphical interface, or don't use the graphical interface, please confirm that you have enough interest to it, That's your os, just ask as you like! PYOS is an open system where you can find it from the pure C forum, including all the experimental reports and all source code, all relevant resources. PYOS is not based on any existing operating system. It is just some principle implementation. Therefore, PYOS does not comply with the GPL Convention, and it is also required to comply with the GPL Convention on Pyos, but I am very hopeful. If you are also doing Development or experiment, you can also publicize your experience, your experience, let more friends know your work, and let more friends can benefit from it. Academic needs are exchanges, hundreds of Chinese in the ancient Spring and Autumn Warring States period constant, leading to the emergence of many ancient outstanding thinkers, you have an apple, I have an apple, after we exchange, there is only one apple, but if you have a thought I have a kind of thought, after we exchange, each person has two ideas. PYOS was originally a guide to a foreign friend who wrote a foreign friend. I found online. Many friends have a lot of friends in my own system, and have a very good results. The most important thing is that these results are It is open, you can get at will, and there is a lot of tutorials, tell you how to do, all kinds of information, relatively rich, there are still many news groups, forums, there are many The enthusiastic person discussed above, I think this is also the foundation of Linux. Scientific research requires an atmosphere. The system development also needs a atmosphere. However, in the past, the atmosphere of this free communication is light, at least from my feelings, I am in front of a national Nine universities, however, the academic atmosphere that can feel is not as strong as imagined, especially in the undergraduate phase, basically generally in What is the teacher who tells what students learns, the teacher is not too guided to how to dig more deeper excavation, how to go independently, and students also seem to be unilateral acceptance, and focus on the exam. Time, I prefer to pursue emerging technologies, and is not interested in relative underlying support technology. Teacher who had a virtue also said to me: Do some Dongdong, what does it mean? What is the value? However, I always think that others have already, it is someone else, not our own, although someone else has already done, we may not need to do it again, but we should know how others do it, don't go It is two concepts that can be done. Therefore, the birth of the Harbin Institute of Technology, which pursues a pure computer science technology, specially focused on some relative bottom-up support technology, now we plan to publish the 28th of the month "Harbin Institute of Technology, Pure C Forum · Electronic magazine, very happy, found a lot of likely to complete this job, hoping to create a long-awaited atmosphere. references 1. "PS / 2 Technical Reference" (ADAM Chapske, Roy Show Translation) (Net Wen, Pure C Forum) 2. "I8042 - Control command, register, port, keyboard and mouse command" (like the netizen HYL of China Linux Forum (http://www.linuxforum.net/) (Net, Pure C Forum is reproduced ) 3. "BMP File Format Analysis" (Net, Author Yz, Pure C Forum has reproduced) Appendix: "Harbin Institute of Technology, Pure C Forum · Electronic Journal" "Harbin Institute of Technology, Pure C Forum · Electronic Magazine" officially established the public announcement! I am very happy and grand announced that under all support and enthusiasm support, the Editorial Department of Harbin Institute of Technology is officially established today! This issue is positioned as a relatively underlying and pure computer science and technology research, focusing on the basic theory, basic principles research, attachment to the foundation, and intensive application technology to form a unique technical style of this journal. This journal will be issued through the network every month, anyone can download this journal from the Internet this day, and will send it to the registered user of the Pure C Forum to the Pure C Forum. Based on the Harbin Institute of Technology, the Harbin Institute of Technology, the Harbin Institute of Technology, and invited major aware version of the master, the heroes to join the editorial department. At present, there are ten backbone technical section: Column Technical Consultant Contributation Letter Computer Composition Principle and Architecture Kylix Purec_Coa@126.com Compilation Principle Worldguy Purec_COMPILE@126.com Algorithm Theory and Data Structure Xiong Purec_Algorithm@126.com C and C Language Sun Purec_cpp@126.com assembly language Oggg Purec_asm@126.com database principle Pineapple purec_db@126.com computer network True purec_network@126.com computer virus swordlea purec_virus@126.com artificial intelligence and information processing car purec_ai@126.com operating system IAMXIAOHAN PUREC_OS@126.com From now on, this magazine is open to the whole school, nationwide, all networks to collect all kinds of manuscripts, your contribution will be reviewed by the technical consultants of this journal, we will handle carefully for each manuscript, and inform you to choose whether you choose Or make a review of the manuscript by the technical consultants. All manusions selected by this magazine, or not suitable for the document published by e-magazines, will be published on the Pure C Forum website. All documents are copyrighted by each authors. You are very welcome to make your work. Let your work know, let yourself exchange, explore, learn, and progress! In order to ensure the quality of this magazine, ensure the technical content of this article, this journal has some basic requirements for the manuscript: 1. Mainly based on original (including translating foreign literature), you can do not need to have strong innovation, but require a certain technical content, the problem described can be small but meticulous, and it can be more comprehensive. Configuring papers, the contribution is sent to the submission mailbox to each column in Word format, or contact each column technical consultant. This issue does not have special requirements for the style or format of the manuscript, pay attention to quality rather than form, copyright belongs to all authors, unlimited manuscript to limit repetitive submission (if the manuscript is not published, it is not repeatable submission ). 2. If there is a code implementation part in the manuscript, it is best to come with the source code and executable, and each issue is released. In addition to the magazine of a PDF format, there will be a compressed file, which will include this All source code and corresponding resources. Of course, the source code is not provided, and the author will be self-satisfied. 3. If the manuscript is the translation manuscript, please attach the original text in English to school. In addition, this magazine will be published as much as possible, and therefore, please confirm the copyright issue before the submission. 4. Please clearly indicate the name and email, so as to edit the timely communication, send change opinions, select notices and send samples, etc. If you are willing to express your manuscript, provide a small authors, we Very welcome. 5. All copyrights are all owned by the authors, and the authors are responsible, do not copy, if there is a place directly to the viewpoint conclusions and results in the text, please be explained in the reference. Each manuscript is best to provide a profile and several keywords to facilitate readers to read and query. Since this journal is likely to be read by some overseas friends, you recommend you to provide English abstracts. 6. All posts, the editorial department is handled, and each manuscript will be repeated. If you have not received the message from the editorial department for a long time, please contact the editorial department. 7. Because this is a pure public welfare, there is no foreign economic support, all editing is unpaid labor. Therefore, this journal has not been able to pay a manuscript to you, but when appropriate, this journal will give you excellent authors. "Pure C Forum Information (Disc Version)", thank you by your author's support! Let's invite you to join this journal again. This magazine will be issued on 10.28, I hope to see your figure above! Finally, I wish you all a happy Mid-Autumn Festival! Editorial Department of "Harbin Institute of Technology, Pure C Forum · Electronic Journal" http://purec.binghua.com Purec@126.com 2004.09.28