Subversion Repositories Kolibri OS

Rev

Rev 766 | Rev 803 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. SYSTEM FUNCTIONS of OS Kolibri 0.7.1.0
  2.  
  3. Number of the function is located in the register eax.
  4. The call of the system function is executed by "int 0x40" command.
  5. All registers except explicitly declared in the returned value,
  6.     including eflags, are preserved.
  7.  
  8.  
  9. ======================================================================
  10. ============== Function 0 - define and draw the window. ==============
  11. ======================================================================
  12. Defines an application window. Draws a frame of the window, header and
  13. working area. For skinned windows defines standard close and minimize
  14. buttons.
  15. Parameters:
  16.   * eax = 0 - function number
  17.   * ebx = [coordinate on axis x]*65536 + [size on axis x]
  18.   * ecx = [coordinate on axis y]*65536 + [size on axis y]
  19.   * edx = 0xXYRRGGBB, where:
  20.     * Y = style of the window:
  21.       * Y=0 - type I - fixed-size window
  22.       * Y=1 - only define window area, draw nothing
  23.       * Y=2 - type II - variable-size window
  24.       * Y=3 - skinned window
  25.       * Y=4 - skinned fixed-size window
  26.       * other possible values (from 5 up to 15) are reserved,
  27.         function call with such Y is ignored
  28.     * RR, GG, BB = accordingly red, green, blue components of a color
  29.       of the working area of the window (are ignored for style Y=2)
  30.     * X = DCBA (bits)
  31.       * A = 1 - window has caption; for styles Y=3,4 caption string
  32.                   must be passed in edi, for other styles use
  33.                   subfunction 1 of function 71
  34.       * B = 1 - coordinates of all graphics primitives are relative to
  35.                   window client area
  36.       * C = 1 - don't fill working area on window draw
  37.       * D = 0 - normal filling of the working area, 1 - gradient
  38.     The following parameters are intended for windows
  39.     of a type I and II, and ignored for styles Y=1,3:
  40.   * esi = 0xXYRRGGBB - color of the header
  41.     * RR, GG, BB define color
  42.     * Y=0 - usual window, Y=1 - unmovable window
  43.     * X defines a gradient of header: X=0 - no gradient,
  44.       X=8 - usual gradient,
  45.       for windows of a type II X=4 - negative gradient
  46.     * other values of X and Y are reserved
  47.   * edi = 0x00RRGGBB - color of the frame
  48. Returned value:
  49.   * function does not return value
  50. Remarks:
  51.   * Position and sizes of the window are installed by the first
  52.     call of this function and are ignored at subsequent; to change
  53.     position and/or sizes of already created window use function 67.
  54.   * For windows with styles Y=3,4 and caption (A=1) caption string
  55.     is set by the first call of this function and is ignored
  56.     at subsequent (strictly speaking, is ignored after a call to
  57.     subfunction 2 of function 12 - end redraw); to change caption of
  58.     already created window use subfunction 1 of function 71.
  59.   * If the window has appropriate styles, position and/or sizes can be
  60.     changed by user. Current position and sizes can be obtained
  61.     by function 9.
  62.   * The window must fit on the screen. If the transferred
  63.     coordinates and sizes do not satisfy to this condition,
  64.     appropriate coordinate (or, probably, both) is considered as zero,
  65.     and if it does not help too, the appropriate size
  66.     (or, probably, both) is installed in a size of the screen.
  67.    
  68.     Further let us designate xpos,ypos,xsize,ysize - values passed
  69.     in ebx,ecx. The coordinates are resulted concerning
  70.     the left upper corner of the window, which, thus, is set as (0,0),
  71.     coordinates of the right lower corner essence (xsize,ysize).
  72.   * The sizes of the window are understood in sence of coordinates
  73.     of the right lower corner. This concerns all other functions too.
  74.     It means, that the real sizes are on 1 pixel more.
  75.   * The window of type I looks as follows:
  76.     * draw external frame of color indicated in edi, 1 pixel in width
  77.     * draw header - rectangle with the left upper corner (1,1) and
  78.       right lower (xsize-1,min(25,ysize)) color indicated in esi
  79.       (taking a gradient into account)
  80.     * if ysize>=26, fill the working area of the window -
  81.       rectangle with the left upper corner (1,21) and right lower
  82.       (xsize-1,ysize-1) (sizes (xsize-1)*(ysize-21)) with color
  83.       indicated in edx (taking a gradient into account)
  84.     * if A=1 and caption has been already set by subfunction 1
  85.       of function 71, it is drawn in the corresponding place of header
  86.   * The window of style Y=1 looks as follows:
  87.     * completely defined by the application
  88.   * The window of type II looks as follows:
  89.     * draw external frame of width 1 pixel with the "shaded" color
  90.       edi (all components of the color decrease twice)
  91.     * draw intermediate frame of width 3 pixels with color edi
  92.     * draw internal frame of width 1 pixel with the "shaded" color edi
  93.     * draw header - rectangle with the left upper corner (4,4)
  94.       and right lower (xsize-4,min(20,ysize)) color, indicated in esi
  95.       (taking a gradient into account)
  96.     * if ysize>=26, fill the working area of the window -
  97.       rectangle with the left upper corner (5,20) and right lower
  98.       (xsize-5,ysize-5) with color indicated in edx
  99.       (taking a gradient into account)
  100.     * if A=1 and caption has been already set by subfunction 1
  101.       of function 71, it is drawn in the corresponding place of header
  102.   * The skinned window looks as follows:
  103.     * draw external frame of width 1 pixel
  104.       with color 'outer' from the skin
  105.     * draw intermediate frame of width 3 pixel
  106.       with color 'frame' from the skin
  107.     * draw internal frame of width 1 pixel
  108.       with color 'inner' from the skin
  109.     * draw header (on bitmaps from the skin) in a rectangle
  110.       (0,0) - (xsize,_skinh-1)
  111.     * if ysize>=26, fill the working area of the window -
  112.       rectangle with the left upper corner (5,_skinh) and right lower
  113.       (xsize-5,ysize-5) with color indicated in edx
  114.       (taking a gradient into account)
  115.     * define two standard buttons: close and minimize
  116.       (see function 8)
  117.     * if A=1 and edi contains (nonzero) pointer to caption string,
  118.       it is drawn in place in header defined in the skin
  119.     * value _skinh is accessible as the result of call
  120.       subfunction 4 of function 48
  121.  
  122. ======================================================================
  123. ================ Function 1 - put pixel in the window. ===============
  124. ======================================================================
  125. Parameters:
  126.   * eax = 1 - function number
  127.   * ebx = x-coordinate (relative to the window)
  128.   * ecx = y-coordinate (relative to the window)
  129.   * edx = 0x00RRGGBB - color of a pixel
  130.     edx = 0x01xxxxxx - invert color of a pixel
  131.           (low 24 bits are ignored)
  132. Returned value:
  133.   * function does not return value
  134.  
  135. ======================================================================
  136. ============ Function 2 - get the code of the pressed key. ===========
  137. ======================================================================
  138. Takes away the code of the pressed key from the buffer.
  139. Parameters:
  140.   * eax = 2 - function number
  141. Returned value:
  142.   * if the buffer is empty, function returns eax=1
  143.   * if the buffer is not empty, function returns al=0,
  144.     ah=code of the pressed key, high word of eax is zero
  145.   * if there is "hotkey", function returns al=2,
  146.     ah=scancode of the pressed key (0 for control keys),
  147.     high word of eax contains a status of control keys at the moment
  148.     of pressing a hotkey
  149. Remarks:
  150.   * There is a common system buffer of the pressed keys
  151.     by a size of 120 bytes, organized as queue.
  152.   * There is one more common system buffer on 120 "hotkeys".
  153.   * If the application with the inactive window calls this function,
  154.     the buffer of the pressed keys is considered to be empty.
  155.   * By default this function returns ASCII-codes; to switch
  156.     to the scancodes mode (and back) use function 66.
  157.     However, hotkeys are always notificated as scancodes.
  158.   * To find out, what keys correspond to what codes, start
  159.     the application keyascii and scancode.
  160.   * Scancodes come directly from keyboard and are fixed;
  161.     ASCII-codes turn out with usage of the conversion tables,
  162.     which can be set by subfunction 2 of function 21
  163.     and get by subfunction 2 of function 26.
  164.   * As a consequence, ASCII-codes take into account current
  165.     keyboard layout (rus/en) as opposed to scancodes.
  166.   * This function notifies only about those hotkeys, which were
  167.     defined by this thread by subfunction 4 of function 66.
  168.  
  169. ======================================================================
  170. ==================== Function 3 - get system time. ===================
  171. ======================================================================
  172. Parameters:
  173.   * eax = 3 - function number
  174. Returned value:
  175.   * eax = 0x00SSMMHH, where HH:MM:SS = Hours:Minutes:Seconds
  176.   * each item is BCD-number, for example,
  177.     for time 23:59:59 function returns 0x00595923
  178. Remarks:
  179.   * See also subfunction 9 of function 26 - get time from
  180.     the moment of start of the system; it is more convenient, because
  181.     returns simply DWORD-value of the time counter.
  182.   * System time can be set by function 22.
  183.  
  184. ======================================================================
  185. ============ Function 4 - draw text string in the window. ============
  186. ======================================================================
  187. Parameters:
  188.   * eax = 4 - function number
  189.   * ebx = [coordinate on axis x]*65536 + [coordinate on axis y]
  190.   * ecx = 0xX0RRGGBB, where
  191.     * RR, GG, BB specify text color
  192.     * X=ABnn (bits):
  193.     * nn specifies the used font: 0=system monospaced,
  194.       1=system font of variable width
  195.     * A=0 - output esi characters, A=1 - output ASCIIZ-string
  196.     * B=1 - fill background with the color edi
  197.   * edx = pointer to the beginning of the string
  198.   * esi = for A=0 length of the string, must not exceed 255;
  199.           for A=1 is ignored
  200. Returned value:
  201.   * function does not return value
  202. Remarks:
  203.   * First system font is read out at loading from the file char.mt,
  204.     second - from char2.mt.
  205.   * Both fonts have height 9 pixels, width of the monospaced font
  206.     is equal to 6 pixels.
  207.  
  208. ======================================================================
  209. ========================= Function 5 - delay. ========================
  210. ======================================================================
  211. Delays execution of the program on the given time.
  212. Parameters:
  213.   * eax = 5 - function number
  214.   * ebx = time in the 1/100 of second
  215. Returned value:
  216.   * function does not return value
  217. Remarks:
  218.   * Passing ebx=0 does not transfer control to the next process
  219.     and does not make any operations at all. If it is really required
  220.     to transfer control to the next process (to complete a current
  221.     time slice), use subfunction 1 of function 68.
  222.   * At current implementation there will be an immediate return from
  223.     the function, if the addition of ebx with current value of
  224.     time counter will call 32-bit overflow.
  225.  
  226. ======================================================================
  227. ============== Function 6 - read the file from ramdisk. ==============
  228. ======================================================================
  229. Parameters:
  230.   * eax = 6 - function number
  231.   * ebx = pointer to the filename
  232.   * ecx = number of start block, beginning from 1;
  233.     ecx=0 - read from the beginning of the file (same as ecx=1)
  234.   * edx = number of blocks to read;
  235.     edx=0 - read one block (same as edx=1)
  236.   * esi = pointer to memory area for the data
  237. Returned value:
  238.   * eax = file size in bytes, if the file was successfully read
  239.   * eax = -1, if the file was not found
  240. Remarks:
  241.   * This function is out-of-date; function 70 allows
  242.     to fulfil the same operations with the extended possibilities.
  243.   * Block = 512 bytes.
  244.   * For reading all file you can specify the certainly large value
  245.     in edx, for example, edx = -1; but in this case be ready that
  246.     the program will "fall", if the file will appear too large and can
  247.     not be placed in the program memory.
  248.   * The filename must be either in the format 8+3 characters
  249.     (first 8 characters - name itself, last 3 - extension,
  250.     the short names and extensions are supplemented with spaces),
  251.     or in the format 8.3 characters "FILE.EXT"/"FILE.EX "
  252.     (name no more than 8 characters, dot, extension 3 characters
  253.     supplemented if necessary by spaces).
  254.     The filename must be written with capital letters. The terminating
  255.     character with code 0 is not necessary (not ASCIIZ-string).
  256.   * This function does not support folders on the ramdisk.
  257.  
  258. ======================================================================
  259. =============== Function 7 - draw image in the window. ===============
  260. ======================================================================
  261. Paramters:
  262.   * eax = 7 - function number
  263.   * ebx = pointer to the image in the format BBGGRRBBGGRR...
  264.   * ecx = [size on axis x]*65536 + [size on axis y]
  265.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  266. Returned value:
  267.   * function does not return value
  268. Remarks:
  269.   * Coordinates of the image are coordinates of the upper left corner
  270.     of the image relative to the window.
  271.   * Size of the image in bytes is 3*xsize*ysize.
  272.  
  273. ======================================================================
  274. =============== Function 8 - define/delete the button. ===============
  275. ======================================================================
  276. Parameters for button definition:
  277.   * eax = 8 - function number
  278.   * ebx = [coordinate on axis x]*65536 + [size on axis x]
  279.   * ecx = [coordinate on axis y]*65536 + [size on axis y]
  280.   * edx = 0xXYnnnnnn, where:
  281.     * nnnnnn = identifier of the button
  282.     * high (31st) bit of edx is cleared
  283.     * if 30th bit of edx is set - do not draw the button
  284.     * if 29th bit of edx is set - do not draw a frame
  285.       at pressing the button
  286.   * esi = 0x00RRGGBB - color of the button
  287. Parameters for button deleting:
  288.   * eax = 8 - function number
  289.   * edx = 0x80nnnnnn, where nnnnnn - identifier of the button
  290. Returned value:
  291.   * function does not return value
  292. Remarks:
  293.   * Sizes of the button must be more than 0 and less than 0x8000.
  294.   * For skinned windows definition of the window
  295.     (call of 0th function) creates two standard buttons -
  296.     for close of the window with identifier 1 and
  297.     for minimize of the window with identifier 0xffff.
  298.   * The creation of two buttons with same identifiers is admitted.
  299.   * The button with the identifier 0xffff at pressing is interpreted
  300.     by the system as the button of minimization, the system handles
  301.     such pressing independently, not accessing to the application.
  302.     In rest it is usual button.
  303.   * Total number of buttons for all applications is limited to 4095.
  304.  
  305. ======================================================================
  306. ============ Function 9 - information on execution thread. ===========
  307. ======================================================================
  308. Parameters:
  309.   * eax = 9 - function number
  310.   * ebx = pointer to 1-Kb buffer
  311.   * ecx = number of the slot of the thread
  312.     ecx = -1 - get information on the current thread
  313. Returned value:
  314.   * eax = maximum number of the slot of a thread
  315.   * buffer pointed to by ebx contains the following information:
  316.     * +0: dword: usage of the processor (how many time units
  317.       per second leaves on execution of this thread)
  318.     * +4: word: position of the window of thread in the window stack
  319.     * +6: word: (has no relation to the specified thread)
  320.       number of the thread slot, which window has in the window stack
  321.       position ecx
  322.     * +8: word: reserved
  323.     * +10 = +0xA: 11 bytes: name of the process
  324.       (name of corresponding executable file in the format 8+3)
  325.     * +21 = +0x15: byte: reserved, this byte is not changed
  326.     * +22 = +0x16: dword: address of the process in memory
  327.     * +26 = +0x1A: dword: size of used memory - 1
  328.     * +30 = +0x1E: dword: identifier (PID/TID)
  329.     * +34 = +0x22: dword: coordinate of the thread window on axis x
  330.     * +38 = +0x26: dword: coordinate of the thread window on axis y
  331.     * +42 = +0x2A: dword: size of the thread window on axis x
  332.     * +46 = +0x2E: dword: size of the thread window on axis y
  333.     * +50 = +0x32: word: status of the thread slot:
  334.       * 0 = thread is running
  335.       * 1 = thread is suspended
  336.       * 2 = thread is suspended while waiting for event
  337.       * 3 = thread is terminating as a result of call to function -1
  338.         or under duress as a result of call to subfunction 2
  339.         of function 18 or termination of the system
  340.       * 4 = thread is terminating as a result of exception
  341.       * 5 = thread waits for event
  342.       * 9 = requested slot is free, all other information on the slot
  343.         is not meaningful
  344.     * +52 = +0x34: word: reserved, this word is not changed
  345.     * +54 = +0x36: dword: coordinate of the client area on axis x
  346.     * +58 = +0x3A: dword: coordinate of the client area on axis y
  347.     * +62 = +0x3E: dword: width of the client area
  348.     * +66 = +0x42: dword: height of the client area
  349.     * +70 = +0x46: byte: state of the window - bitfield
  350.       * bit 0 (mask 1): window is maximized
  351.       * bit 1 (mask 2): window is minimized to panel
  352.       * bit 2 (mask 4): window is rolled up
  353. Remarks:
  354.   * Slots are numbered starting from 1.
  355.   * Returned value is not a total number of threads, because there
  356.     can be free slots.
  357.   * When process is starting, system automatically creates
  358.     execution thread.
  359.   * Function gives information on the thread. Each process has
  360.     at least one thread. One process can create many threads,
  361.     in this case each thread has its own slot and the fields
  362.     +10, +22, +26 in these slots coincide.
  363.     Applications have no common way to define whether two threads
  364.     belong to one process.
  365.   * The active window - window on top of the window stack -
  366.     receives the messages on a keyboard input. For such window
  367.     the position in the window stack coincides with returned value.
  368.   * Slot 1 corresponds to special system thread, for which:
  369.     * the window is in the bottom of the window stack, the fields
  370.       +4 and +6 contain value 1
  371.     * name of the process - "OS/IDLE" (supplemented by spaces)
  372.     * address of the process in memory is 0, size of used memory is
  373.       16 Mb (0x1000000)
  374.     * PID=1
  375.     * coordinates and sizes of the window and the client area are by
  376.       convention set to 0
  377.     * status of the slot is always 0 (running)
  378.     * the execution time adds of time leaving on operations itself
  379.       and idle time in waiting for interrupt (which can be got by call
  380.       to subfunction 4 of function 18).
  381.   * Beginning from slot 2, the normal applications are placed.
  382.   * The normal applications are placed in memory at the address
  383.     0x60400000 (kernel constant 'std_application_base_address').
  384.     There is no intersection, as each process has its own page table.
  385.   * At creation of the thread it is assigned the slot
  386.     in the system table and identifier (Process/Thread IDentifier =
  387.     PID/TID), which do not vary with time for given thread.
  388.     After completion of the thread its slot can be anew used
  389.     for another thread. The thread identifier can not be assigned
  390.     to other thread even after completion of this thread.
  391.     Identifiers, assigned to new threads, grow monotonously.
  392.   * If the thread has not yet defined the window by call to
  393.     function 0, the position and the sizes
  394.     of its window are considered to be zero.
  395.   * Coordinates of the client area are relative to the window.
  396.   * At the moment only the part of the buffer by a size
  397.     71 = 0x37 bytes is used. Nevertheless it is recommended to use
  398.     1-Kb buffer for the future compatibility, in the future
  399.     some fields can be added.
  400.  
  401. ======================================================================
  402. ==================== Function 10 - wait for event. ===================
  403. ======================================================================
  404. If the message queue is empty, waits for appearance of the message
  405. in queue. In this state thread does not consume CPU time.
  406. Then reads out the message from queue.
  407.  
  408. Parameters:
  409.   * eax = 10 - function number
  410. Returned value:
  411.   * eax = event (see the list of events)
  412. Remarks:
  413.   * Those events are taken into account only which enter into
  414.     a mask set by function 40. By default it is
  415.     redraw, key and button events.
  416.   * To check, whether there is a message in queue, use function 11.
  417.     To wait for no more than given time, use function 23.
  418.  
  419. ======================================================================
  420. =============== Function 11 - check for event, no wait. ==============
  421. ======================================================================
  422. If the message queue contains event, function reads out
  423. and return it. If the queue is empty, function returns 0.
  424. Parameters:
  425.   * eax = 11 - function number
  426. Returned value:
  427.   * eax = 0 - message queue is empty
  428.   * else eax = event (see the list of events)
  429. Remarks:
  430.   * Those events are taken into account only, which enter into
  431.     a mask set by function 40. By default it is
  432.     redraw, key and button events.
  433.   * To wait for event, use function 10.
  434.     To wait for no more than given time, use function 23.
  435.  
  436. ======================================================================
  437. =============== Function 12 - begin/end window redraw. ===============
  438. ======================================================================
  439.  
  440. ---------------- Subfunction 1 - begin window redraw. ----------------
  441. Parameters:
  442.   * eax = 12 - function number
  443.   * ebx = 1 - subfunction number
  444. Returned value:
  445.   * function does not return value
  446.  
  447. ----------------- Subfunction 2 - end window redraw. -----------------
  448. Parameters:
  449.   * eax = 12 - function number
  450.   * ebx = 2 - subfunction number
  451. Returned value:
  452.   * function does not return value
  453. Remarks:
  454.   * Subfunction 1 deletes all buttons defined with
  455.     function 8, they must be defined again.
  456.  
  457. ======================================================================
  458. ============ Function 13 - draw a rectangle in the window. ===========
  459. ======================================================================
  460. Parameters:
  461.   * eax = 13 - function number
  462.   * ebx = [coordinate on axis x]*65536 + [size on axis x]
  463.   * ecx = [coordinate on axis y]*65536 + [size on axis y]
  464.   * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill
  465. Returned value:
  466.   * function does not return value
  467. Remarks:
  468.   * Coordinates are understood as coordinates of the left upper corner
  469.     of a rectangle relative to the window.
  470.  
  471. ======================================================================
  472. =================== Function 14 - get screen size. ===================
  473. ======================================================================
  474. Parameters:
  475.   * eax = 14 - function number
  476. Returned value:
  477.   * eax = [xsize]*65536 + [ysize], where
  478.   * xsize = x-coordinate of the right lower corner of the screen =
  479.             horizontal size - 1
  480.   * ysize = y-coordinate of the right lower corner of the screen =
  481.             vertical size - 1
  482. Remarks:
  483.   * See also subfunction 5 of function 48 - get sizes of
  484.     working area of the screen.
  485.  
  486. ======================================================================
  487. == Function 15, subfunction 1 - set a size of the background image. ==
  488. ======================================================================
  489. Parameters:
  490.   * eax = 15 - function number
  491.   * ebx = 1 - subfunction number
  492.   * ecx = width of the image
  493.   * edx = height of the image
  494. Returned value:
  495.   * function does not return value
  496. Remarks:
  497.   * Before calling subfunctions 2 and 5 you should call this function
  498.     to set image size!
  499.   * For update of the screen (after completion of a series of commands
  500.     working with a background) call subfunction 3.
  501.   * There is a pair function for get size of the background image -
  502.     subfunction 1 of function 39.
  503.  
  504. ======================================================================
  505. === Function 15, subfunction 2 - put pixel on the background image. ==
  506. ======================================================================
  507. Parameters:
  508.   * eax = 15 - function number
  509.   * ebx = 2 - subfunction number
  510.   * ecx = offset
  511.   * edx = color of a pixel 0xRRGGBB
  512. Returned value:
  513.   * function does not return value
  514. Remarks:
  515.   * Offset for a pixel with coordinates (x,y) is calculated as
  516.     (x+y*xsize)*3.
  517.   * If the given offset exceeds size set by subfunction 1,
  518.     the call is ignored.
  519.   * For update of the screen (after completion of a series of commands
  520.     working with a background) call subfunction 3.
  521.   * There is a pair function for get pixel on the background image -
  522.     subfunction 2 of function 39.
  523.  
  524. ======================================================================
  525. =========== Function 15, subfunction 3 - redraw background. ==========
  526. ======================================================================
  527. Parameters:
  528.   * eax = 15 - function number
  529.   * ebx = 3 - subfunction number
  530. Returned value:
  531.   * function does not return value
  532.  
  533. ======================================================================
  534. == Function 15, subfunction 4 - set drawing mode for the background. =
  535. ======================================================================
  536. Parameters:
  537.   * eax = 15 - function number
  538.   * ebx = 4 - subfunction number
  539.   * ecx = drawing mode:
  540.     * 1 = tile
  541.     * 2 = stretch
  542. Returned value:
  543.   * function does not return value
  544. Remarks:
  545.   * For update of the screen (after completion of a series of commands
  546.     working with a background) call subfunction 3.
  547.   * There is a pair function for get drawing mode of the background -
  548.     subfunction 4 of function 39.
  549.  
  550. ======================================================================
  551. ===================== Function 15, subfunction 5 =====================
  552. ============ Put block of pixels on the background image. ============
  553. ======================================================================
  554. Parameters:
  555.   * eax = 15 - function number
  556.   * ebx = 5 - subfunction number
  557.   * ecx = pointer to the data in the format BBGGRRBBGGRR...
  558.   * edx = offset in data of the background image
  559.   * esi = size of data in bytes = 3 * number of pixels
  560. Returned value:
  561.   * function does not return value
  562. Remarks:
  563.   * Offset and size are not checked for correctness.
  564.   * Color of each pixel is stored as 3-bytes value BBGGRR.
  565.   * Pixels of the background image are written sequentially
  566.     from left to right, from up to down.
  567.   * Offset of pixel with coordinates (x,y) is (x+y*xsize)*3.
  568.   * For update of the screen (after completion of a series of commands
  569.     working with a background) call subfunction 3.
  570.  
  571. ======================================================================
  572. ===================== Function 15, subfunction 6 =====================
  573. ======== Map background data to the address space of process. ========
  574. ======================================================================
  575. Parameters:
  576.   * eax = 15 - function number
  577.   * ebx = 6 - subfunction number
  578. Returned value:
  579.   * eax = pointer to background data, 0 if error
  580. Remarks:
  581.   * Mapped data are available for read and write.
  582.   * Size of background data is 3*xsize*ysize. The system blocks
  583.     changes of background sizes while process works with mapped data.
  584.   * Color of each pixel is stored as 3-bytes value BBGGRR.
  585.   * Pixels of the background image are written sequentially
  586.     from left to right, from up to down.
  587.  
  588. ======================================================================
  589. ===== Function 15, subfunction 7 - close mapped background data. =====
  590. ======================================================================
  591. Parameters:
  592.   * eax = 15 - function number
  593.   * ebx = 7 - subfunction number
  594.   * ecx = pointer to mapped data
  595. Returned value:
  596.   * eax = 1 - success, 0 - error
  597.  
  598. ======================================================================
  599. =============== Function 16 - save ramdisk on a floppy. ==============
  600. ======================================================================
  601. Parameters:
  602.   * eax = 16 - function number
  603.   * ebx = 1 or ebx = 2 - on which floppy save
  604. Returned value:
  605.   * eax = 0 - success
  606.   * eax = 1 - error
  607.  
  608. ======================================================================
  609. ======= Function 17 - get the identifier of the pressed button. ======
  610. ======================================================================
  611. Takes away the code of the pressed button from the buffer.
  612. Parameters:
  613.   * eax = 17 - function number
  614. Returned value:
  615.   * if the buffer is empty, function returns eax=1
  616.   * if the buffer is not empty, function returns al=0,
  617.     high 24 bits of eax contain button identifier (in particular, ah
  618.     contains low byte of the identifier; if all buttons have
  619.     the identifier less than 256, ah is enough to distinguish).
  620. Remarks:
  621.   * "Buffer" keeps only one button, at pressing the new button the
  622.     information about old is lost.
  623.   * The call of this function by an application with inactive window
  624.     will return answer "buffer is empty".
  625.  
  626. ======================================================================
  627. = Function 18, subfunction 2 - terminate process/thread by the slot. =
  628. ======================================================================
  629. Parameters:
  630.   * eax = 18 - function number
  631.   * ebx = 2 - subfunction number
  632.   * ecx = number of the slot of process/thread
  633. Returned value:
  634.   * function does not return value
  635. Remarks:
  636.   * It is impossible to terminate system thread OS/IDLE (with
  637.     number of the slot 1),
  638.     it is possible to terminate any normal process/thread.
  639.   * See also subfunction 18 - terminate
  640.     process/thread by the identifier.
  641.  
  642. ======================================================================
  643. ===================== Function 18, subfunction 3 =====================
  644. ============= Make active the window of the given thread. ============
  645. ======================================================================
  646. Parameters:
  647.   * eax = 18 - function number
  648.   * ebx = 3 - subfunction number
  649.   * ecx = number of the thread slot
  650. Returned value:
  651.   * function does not return value
  652. Remarks:
  653.   * If correct, but nonexistent slot is given,
  654.     some window is made active.
  655.   * To find out, which window is active, use subfunction 7.
  656.  
  657. ======================================================================
  658. ===================== Function 18, subfunction 4 =====================
  659. =========== Get counter of idle time units per one second. ===========
  660. ======================================================================
  661. Idle time units are units, in which the processor stands idle
  662. in waiting for interrupt (in the command 'hlt').
  663.  
  664. Parameters:
  665.   * eax = 18 - function number
  666.   * ebx = 4 - subfunction number
  667. Returned value:
  668.   * eax = value of the counter of idle time units per one second
  669.  
  670. ======================================================================
  671. ========== Function 18, subfunction 5 - get CPU clock rate. ==========
  672. ======================================================================
  673. Parameters:
  674.   * eax = 18 - function number
  675.   * ebx = 5 - subfunction number
  676. Returned value:
  677.   * eax = clock rate (modulo 2^32 clock ticks = 4GHz)
  678.  
  679. ======================================================================
  680.  Function 18, subfunction 6 - save ramdisk to the file on hard drive.
  681. ======================================================================
  682. Parameters:
  683.   * eax = 18 - function number
  684.   * ebx = 6 - subfunction number
  685.   * ecx = pointer to the full path to file
  686.     (for example, "/hd0/1/kolibri/kolibri.img")
  687. Returned value:
  688.   * eax = 0 - success
  689.   * else eax = error code of the file system
  690. Remarks:
  691.   * All folders in the given path must exist, otherwise function
  692.     returns value 5, "file not found".
  693.  
  694. ======================================================================
  695. =========== Function 18, subfunction 7 - get active window. ==========
  696. ======================================================================
  697. Parameters:
  698.   * eax = 18 - function number
  699.   * ebx = 7 - subfunction number
  700. Returned value:
  701.   * eax = number of the active window
  702.     (number of the slot of the thread with active window)
  703. Remarks:
  704.   * Active window is at the top of the window stack and receives
  705.     messages on all keyboard input.
  706.   * To make a window active, use subfunction 3.
  707.  
  708. ======================================================================
  709. == Function 18, subfunction 8 - disable/enable the internal speaker. =
  710. ======================================================================
  711. If speaker sound is disabled, all calls to subfunction 55 of
  712. function 55 are ignored. If speaker sound is enabled,
  713. they are routed on builtin speaker.
  714.  
  715. ------------------- Subsubfunction 1 - get status. -------------------
  716. Parameters:
  717.   * eax = 18 - function number
  718.   * ebx = 8 - subfunction number
  719.   * ecx = 1 - number of the subsubfunction
  720. Returned value:
  721.   * eax = 0 - speaker sound is enabled; 1 - disabled
  722.  
  723. ----------------- Subsubfunction 2 - toggle status. ------------------
  724. Toggles states of disable/enable.
  725. Parameters:
  726.   * eax = 18 - function number
  727.   * ebx = 8 - subfunction number
  728.   * ecx = 2 - number of the subsubfunction
  729. Returned value:
  730.   * function does not return value
  731.  
  732. ======================================================================
  733. ============ Function 18, subfunction 9 - system shutdown. ===========
  734. ======================================================================
  735. Parameters:
  736.   * eax = 18 - function number
  737.   * ebx = 9 - subfunction number
  738.   * ecx = parameter:
  739.     * 2 = turn off computer
  740.     * 3 = reboot computer
  741.     * 4 = restart the kernel from the file 'kernel.mnt' on ramdisk
  742. Returned value:
  743.   * at incorrect ecx the registers do not change (i.e. eax=18)
  744.   * by correct call function always returns eax=0
  745.     as the tag of success
  746. Remarks:
  747.   * Do not rely on returned value by incorrect call, it can be
  748.     changed in future versions of the kernel.
  749.   * It is possible to use subfunction 1, that on the last step
  750.     the user makes choice himself.
  751. ======================================================================
  752. ===== Function 18, subfunction 10 - minimize application window. =====
  753. ======================================================================
  754. Minimizes the own window.
  755. Parameters:
  756.   * eax = 18 - function number
  757.   * ebx = 10 - subfunction number
  758. Returned value:
  759.   * function does not return value
  760. Remarks:
  761.   * The minimized window from the point of view of function 9
  762.     keeps position and sizes.
  763.   * Restoring of an application window occurs at its activation by
  764.     subfunction 3.
  765.   * Usually there is no necessity to minimize/restire a window
  766.     obviously: minimization of a window is carried out by the system
  767.     at pressing the minimization button (for skinned windows
  768.     it is defined automatically by function 0,
  769.     for other windows it can be defined manually by function 8),
  770.     restore of a window is done by the application '@panel'.
  771.  
  772. ======================================================================
  773.  Function 18, subfunction 11 - get information on the disk subsystem.
  774. ======================================================================
  775. Parameters:
  776.   * eax = 18 - function number
  777.   * ebx = 11 - subfunction number
  778.   * ecx = type of the table:
  779.     * 1 = short version, 10 bytes
  780.     * 2 = full version, 65536 bytes
  781.   * edx = pointer to the buffer (in the application) for the table
  782. Returned value:
  783.   * function does not return value
  784. Format of the table: short version:
  785.   * +0: byte: information about FDD's (drives for floppies),
  786.     AAAABBBB, where AAAA gives type of the first drive, BBBB -
  787.     of the second regarding to the following list:
  788.     * 0 = there is no drive
  789.     * 1 = 360Kb, 5.25''
  790.     * 2 = 1.2Mb, 5.25''
  791.     * 3 = 720Kb, 3.5''
  792.     * 4 = 1.44Mb, 3.5''
  793.     * 5 = 2.88Mb, 3.5'' (such drives are not used anymore)
  794.     For example, for the standard configuration from one 1.44-drive
  795.     here will be 40h, and for the case 1.2Mb on A: and 1.44Mb on B:
  796.     the value is 24h.
  797.   * +1: byte: information about hard disks and CD-drives, AABBCCDD,
  798.     where AA corresponds to the controller IDE0, ..., DD - IDE3:
  799.     * 0 = device is absent
  800.     * 1 = hard drive
  801.     * 2 = CD-drive
  802.     For example, in the case HD on IDE0 and CD on IDE2
  803.     this field contains 48h.
  804.   * +2: 4 db: number of the retrieved partitions on hard disks
  805.     at accordingly IDE0,...,IDE3.
  806.     If the hard disk on IDEx is absent, appropriate byte is zero,
  807.     otherwise it shows number of the recognized partitions, which
  808.     can be not presented (if the drive is not formatted or if
  809.     the file system is not supported). Current version of the kernel
  810.     supports only FAT16, FAT32 and NTFS for hard disks.
  811.   * +6: 4 db: reserved
  812. Format of the table: full version:
  813.   * +0: 10 db: same as for the short version
  814.   * +10: 100 db: data for the first partition
  815.   * +110: 100 db: data for the second partition
  816.   * ...
  817.   * +10+100*(n-1): 100 db: data for the last partition
  818. The partitions are located as follows: at first sequentially all
  819. recoginzed partitions on HD on IDE0 (if present),
  820. then on HD on IDE1 (if present) and so on up to IDE3.
  821. Format of the information about partition
  822. (at moment only FAT is supported):
  823.   * +0: dword: first physical sector of the partition
  824.   * +4: dword: last physical sector of the partition
  825.     (belongs to the partition)
  826.   * +8: byte: file system type:
  827.     16=FAT16, 32=FAT32, 1=NTFS
  828.   * other data are dependent on file system, are modified with
  829.     kernel modifications and therefore are not described
  830. Remarks:
  831.   * The short table can be used for obtaining the information about
  832.     available devices.
  833.  
  834. ======================================================================
  835. ========== Function 18, subfunction 13 - get kernel version. =========
  836. ======================================================================
  837. Parameters:
  838.   * eax = 18 - function number
  839.   * ebx = 13 - subfunction number
  840.   * ecx = pointer to the buffer (not less than 16 bytes), where
  841.     the information will be placed
  842. Returned value:
  843.   * function does not return value
  844. Structure of the buffer:
  845. db a,b,c,d for version a.b.c.d
  846. db UID_xxx: one of UID_NONE=0, UID_MENUET=1, UID_KOLIBRI=2
  847. dd REV - kernel SVN revision number
  848. For Kolibri 0.7.1.0 kernel:
  849. db 0,7,0,0
  850. db 2
  851. dd 638
  852.  
  853. ======================================================================
  854. ======= Function 18, subfunction 14 - wait for screen retrace. =======
  855. ======================================================================
  856. Waits for the beginning of retrace of the scanning ray of the screen
  857. monitor.
  858. Parameters:
  859.   * eax = 18 - function number
  860.   * ebx = 14 - subfunction number
  861. Returned value:
  862.   * eax = 0 as the tag of success
  863. Remarks:
  864.   * Function is intended only for active high-efficiency graphics
  865.     applications; is used for smooth output of a graphics.
  866.  
  867. ======================================================================
  868. == Function 18, subfunction 15 - center mouse cursor on the screen. ==
  869. ======================================================================
  870. Parameters:
  871.   * eax = 18 - function number
  872.   * ebx = 15 - subfunction number
  873. Returned value:
  874.   * eax = 0 as the tag of success
  875.  
  876. ======================================================================
  877. ========= Function 18, subfunction 16 - get size of free RAM. ========
  878. ======================================================================
  879. Parameters:
  880.   * eax = 18 - function number
  881.   * ebx = 16 - subfunction number
  882. Returned value:
  883.   * eax = size of free memory in kilobytes
  884.  
  885. ======================================================================
  886. ======== Function 18, subfunction 17 - get full amount of RAM. =======
  887. ======================================================================
  888. Parameters:
  889.   * eax = 18 - function number
  890.   * ebx = 17 - subfunction number
  891. Returned value:
  892.   * eax = total size of existing memory in kilobytes
  893.  
  894. ======================================================================
  895. ===================== Function 18, subfunction 18 ====================
  896. ============= Terminate process/thread by the identifier. ============
  897. ======================================================================
  898. Parameters:
  899.   * eax = 18 - function number
  900.   * ebx = 18 - subfunction number
  901.   * ecx = identifer of process/thread (PID/TID)
  902. Returned value:
  903.   * eax = 0 - success
  904.   * eax = -1 - error (process is not found or is system)
  905. Remarks:
  906.   * It is impossible to terminate system thread OS/IDLE (identifier
  907.     1), it is possible to terminate any normal process/thread.
  908.   * See also subfunction 2 - terminate
  909.     process/thread by given slot.
  910.  
  911. ======================================================================
  912. ======== Function 18, subfunction 19 - get/set mouse features. =======
  913. ======================================================================
  914.  
  915. ---------------- Subsubfunction 0 - get mouse speed. -----------------
  916. Parameters:
  917.   * eax = 18 - function number
  918.   * ebx = 19 - subfunction number
  919.   * ecx = 0 - subsubfunction number
  920. Returned value:
  921.   * eax = current mouse speed
  922.  
  923. ---------------- Subsubfunction 1 - set mouse speed. -----------------
  924. Parameters:
  925.   * eax = 18 - function number
  926.   * ebx = 19 - subfunction number
  927.   * ecx = 1 - subsubfunction number
  928.   * edx = new value for speed
  929. Returned value:
  930.   * function does not return value
  931.  
  932. ---------------- Subsubfunction 2 - get mouse delay. -----------------
  933. Parameters:
  934.   * eax = 18 - function number
  935.   * ebx = 19 - subfunction number
  936.   * ecx = 2 - subsubfunction number
  937. Returned value:
  938.   * eax = current mouse delay
  939.  
  940. ---------------- Subsubfunction 3 - set mouse delay. -----------------
  941. Parameters:
  942.   * eax = 18 - function number
  943.   * ebx = 19 - subfunction number
  944.   * ecx = 3 - subsubfunction number
  945.   * edx = new value for mouse delay
  946. Returned value:
  947.   * function does not return value
  948.  
  949. ----------- Subsubfunction 4 - set mouse pointer position. -----------
  950. Parameters:
  951.   * eax = 18 - function number
  952.   * ebx = 19 - subfunction number
  953.   * ecx = 4 - subsubfunction number
  954.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  955. Returned value:
  956.   * function does not return value
  957.  
  958. -------- Subsubfunction 5 - simulate state of mouse buttons. ---------
  959. Parameters:
  960.   * eax = 18 - function number
  961.   * ebx = 19 - subfunction number
  962.   * ecx = 5 - subsubfunction number
  963.   * edx = information about emulated state of mouse buttons:
  964.     (same as return value in subfunction 2 of function 37)
  965.     * bit 0 is set = left button is pressed
  966.     * bit 1 is set = right button is pressed
  967.     * bit 2 is set = middle button is pressed
  968.     * bit 3 is set = 4th button is pressed
  969.     * bit 4 is set = 5th button is pressed
  970. Returned value:
  971.   * function does not return value
  972. Remarks:
  973.   * It is recommended to set speed of the mouse (in subsubfunction 1)
  974.     from 1 up to 9. The installed value is not inspected by the kernel
  975.     code, so set it carefully, at incorrect value the cursor
  976.     can "freeze". Speed of the mouse can be regulated through the
  977.     application SETUP.
  978.   * Recommended delay of the mouse (in subsubfunction 3) = 10. Lower
  979.     value is not handled by COM mice. At the very large values the
  980.     movement of the mouse on 1 pixel is impossible and the cursor will
  981.     jump on the value of installed speed (subsubfunction 1). The
  982.     installed value is not inspected by the kernel code.
  983.     Mouse delay can be regulated through the application SETUP.
  984.   * The subsubfunction 4 does not check the passed value. Before
  985.     its call find out current screen resolution (with function 14)
  986.     and check that the value of position is inside the limits of the
  987.     screen.
  988.  
  989. ======================================================================
  990. ======== Function 18, subfunction 20 - get information on RAM. =======
  991. ======================================================================
  992. Parameters:
  993.   * eax = 18 - function number
  994.   * ebx = 20 - subfunction number
  995.   * ecx = pointer to the buffer for information (36 bytes)
  996. Returned value:
  997.   * eax = total size of existing RAM in pages
  998.     or -1 if error has occured
  999.   * buffer pointed to by ecx contains the following information:
  1000.     * +0:  dword: total size of existing RAM in pages
  1001.     * +4:  dword: size of free RAM in pages
  1002.     * +8:  dword: number of page faults (exceptions #PF)
  1003.                  in applications
  1004.     * +12: dword: size of kernel heap in bytes
  1005.     * +16: dword: free in kernel heap in bytes
  1006.     * +20: dword: total number of memory blocks in kernel heap
  1007.     * +24: dword: number of free memory blocks in kernel heap
  1008.     * +28: dword: size of maximum free block in kernel heap
  1009.                  (reserved)
  1010.     * +32: dword: size of maximum allocated block in kernel heap
  1011.                  (reserved)
  1012.  
  1013. ======================================================================
  1014. ===================== Function 18, subfunction 21 ====================
  1015. ======== Get slot number of process/thread by the identifier. ========
  1016. ======================================================================
  1017. Parameters:
  1018.   * eax = 18 - function number
  1019.   * ebx = 21 - subfunction number
  1020.   * ecx = identifer of process/thread (PID/TID)
  1021. Returned value:
  1022.   * eax = 0 - error (invalid identifier)
  1023.   * otherwise eax = slot number
  1024.  
  1025. ======================================================================
  1026. ===================== Function 18, subfunction 22 ====================
  1027. ============== Operations with window of another thread. =============
  1028. ======================================================================
  1029. Parameters:
  1030.   * eax = 18 - function number
  1031.   * ebx = 22 - subfunction number
  1032.   * ecx = operation type:
  1033.     * 0 = minimize window of the thread with given slot number
  1034.     * 1 = minimize window of the thread with given identifier
  1035.     * 2 = restore window of the thread with given slot number
  1036.     * 3 = restore window of the thread with given identifier
  1037.   * edx = parameter (slot number or PID/TID)
  1038. Returned value:
  1039.   * eax = 0 - success
  1040.   * eax = -1 - error (invalid identifier)
  1041. Remarks:
  1042.   * The thread can minimize its window with subfunction 10.
  1043.   * One can restore and activate window simultaneously with
  1044.     subfunction 3 (which requires slot number).
  1045.  
  1046. ======================================================================
  1047. ==================== Function 20 - MIDI interface. ===================
  1048. ======================================================================
  1049.  
  1050. ----------------------- Subfunction 1 - reset ------------------------
  1051. Parameters:
  1052.   * eax = 20 - function number
  1053.   * ebx = 1 - subfunction number
  1054.  
  1055. -------------------- Subfunction 2 - output byte ---------------------
  1056. Parameters:
  1057.   * eax = 20 - function number
  1058.   * ebx = 2 - subfunction number
  1059.   * cl = byte for output
  1060. Returned value (is the same for both subfunctions):
  1061.   * eax = 0 - success
  1062.   * eax = 1 - base port is not defined
  1063. Remarks:
  1064.   * Previously the base port must be defined by
  1065.     subfunction 1 of function 21.
  1066.  
  1067. ======================================================================
  1068. ======== Function 21, subfunction 1 - set MPU MIDI base port. ========
  1069. ======================================================================
  1070. Parameters:
  1071.   * eax = 21 - function number
  1072.   * ebx = 1 - subfunction number
  1073.   * ecx = number of base port
  1074. Returned value
  1075.   * eax = 0 - success
  1076.   * eax = -1 - erratic number of a port
  1077. Remarks:
  1078.   * Number of a port must satisfy to conditions 0x100<=ecx<=0xFFFF.
  1079.   * The installation of base is necessary for function 20.
  1080.   * To get base port use subfunction 1 of function 26.
  1081.  
  1082. ======================================================================
  1083. ========== Function 21, subfunction 2 - set keyboard layout. =========
  1084. ======================================================================
  1085. Keyboard layout is used to convert keyboard scancodes to ASCII-codes,
  1086. which will be read by function 2.
  1087. Parameters:
  1088.   * eax = 21 - function number
  1089.   * ebx = 2 - subfunction number
  1090.   * ecx = which layout to set:
  1091.     * 1 = normal layout
  1092.     * 2 = layout at pressed Shift
  1093.     * 3 = layout at pressed Alt
  1094.   * edx = pointer to layout - table of length 128 bytes
  1095. Or:
  1096.   * ecx = 9
  1097.   * dx = country identifier (1=eng, 2=fi, 3=ger, 4=rus)
  1098. Returned value:
  1099.   * eax = 0 - success
  1100.   * eax = 1 - incorrect parameter
  1101. Remarks:
  1102.   * If Alt is pressed, the layout with Alt is used;
  1103.     if Alt is not pressed, but Shift is pressed,
  1104.     the layout with Shift is used;
  1105.     if Alt and Shift are not pressed, but Ctrl is pressed, the normal
  1106.     layout is used and then from the code is subtracted 0x60;
  1107.     if no control key is pressed, the normal layout is used.
  1108.   * To get layout and country identifier use
  1109.     subfunction 2 of function 26.
  1110.   * Country identifier is global system variable, which is not used
  1111.     by the kernel itself; however the application '@panel' displays
  1112.     the corresponding icon.
  1113.   * The application @panel switches layouts on user request.
  1114.  
  1115. ======================================================================
  1116. ============== Function 21, subfunction 3 - set CD base. =============
  1117. ======================================================================
  1118. Parameters:
  1119.   * eax = 21 - function number
  1120.   * ebx = 3 - subfunction number
  1121.   * ecx = CD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
  1122. Returned value:
  1123.   * eax = 0
  1124. Remarks:
  1125.   * CD base is used by function 24.
  1126.   * To get CD base use subfunction 3 of function 26.
  1127.  
  1128. ======================================================================
  1129. ====== Function 21, subfunction 4 - set Sound Blaster base port. =====
  1130. ======================================================================
  1131. Removed
  1132.  
  1133. ======================================================================
  1134. ========== Function 21, subfunction 5 - set system language. =========
  1135. ======================================================================
  1136. Parameters:
  1137.   * eax = 21 - function number
  1138.   * ebx = 5 - subfunction number
  1139.   * ecx = system language (1=eng, 2=fi, 3=ger, 4=rus)
  1140. Returned value:
  1141.   * eax = 0
  1142. Remarks:
  1143.   * System language is global system variable and is not used
  1144.     by the kernel itself, however application @panel draws the
  1145.     appropriate icon.
  1146.   * Function does not check for correctness, as the kernel does not
  1147.     use this variable.
  1148.   * To get system language use subfunction 5 of function 26.
  1149.  
  1150. ======================================================================
  1151. ============== Function 21, subfunction 7 - set HD base. =============
  1152. ======================================================================
  1153. The HD base defines hard disk to write with usage of obsolete
  1154. syntax /HD in obsolete function 58; at usage of modern syntax
  1155. /HD0,/HD1,/HD2,/HD3 base is set automatically.
  1156. Parameters:
  1157.   * eax = 21 - function number
  1158.   * ebx = 7 - subfunction number
  1159.   * ecx = HD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
  1160. Returned value:
  1161.   * eax = 0
  1162. Remarks:
  1163.   * Any application at any time can change the base.
  1164.   * Do not change base, when any application works with hard disk.
  1165.     If you do not want system bugs.
  1166.   * To get HD base use subfunction 7 of function 26.
  1167.   * It is also necessary to define used partition of hard disk by
  1168.     subfunction 8.
  1169.  
  1170. ======================================================================
  1171. ========= Function 21, subfunction 8 - set used HD partition. ========
  1172. ======================================================================
  1173. The HD partition defines partition of the hard disk to write with
  1174. usage of obsolete syntax /HD and obsolete function 58;
  1175. at usage of functions 58 and 70 and modern syntax /HD0,/HD1,/HD2,/HD3
  1176. base and partition are set automatically.
  1177. Parameters:
  1178.   * eax = 21 - function number
  1179.   * ebx = 8 - subfunction number
  1180.   * ecx = HD partition (beginning from 1)
  1181. Return value:
  1182.   * eax = 0
  1183. Remarks:
  1184.   * Any application at any time can change partition.
  1185.   * Do not change partition when any application works with hard disk.
  1186.     If you do not want system bugs.
  1187.   * To get used partition use subfunction 8 of function 26.
  1188.   * There is no correctness checks.
  1189.   * To get the number of partitions of a hard disk use
  1190.     subfunction 11 of function 18.
  1191.   * It is also necessary to define used HD base by subfunction 7.
  1192.  
  1193. ======================================================================
  1194. ======== Function 21, subfunction 10 - set sound DMA channel. ========
  1195. ======================================================================
  1196. Removed
  1197.  
  1198. ======================================================================
  1199.  Function 21, subfunction 11 - enable/disable low-level access to HD.
  1200. ======================================================================
  1201. Parameters:
  1202.   * eax = 21 - function number
  1203.   * ebx = 11 - subfunction number
  1204.   * ecx = 0/1 - disable/enable
  1205. Returned value:
  1206.   * eax = 0
  1207. Remarks:
  1208.   * Is used in LBA-read (subfunction 8 of function 58).
  1209.   * The current implementation uses only low bit of ecx.
  1210.   * To get current status use subfunction 11 of function 26.
  1211.  
  1212. ======================================================================
  1213.  Function 21, subfunction 12 - enable/disable low-level access to PCI.
  1214. ======================================================================
  1215. Parameters:
  1216.   * eax = 21 - function number
  1217.   * ebx = 12 - subfunction number
  1218.   * ecx = 0/1 - disable/enable
  1219. Returned value:
  1220.   * eax = 0
  1221. Remarks:
  1222.   * Is used in operations with PCI bus (function 62).
  1223.   * The current implementation uses only low bit of ecx.
  1224.   * To get current status use subfunction 12 of function 26.
  1225.  
  1226. ======================================================================
  1227. ============ Function 21, subfunction 13, subsubfunction 1 ===========
  1228. ======== Initialize + get information on the driver vmode.mdr. =======
  1229. ======================================================================
  1230. Parameters:
  1231.   * eax = 21 - function number
  1232.   * ebx = 13 - subfunction number
  1233.   * ecx = 1 - number of the driver function
  1234.   * edx = pointer to 512-bytes buffer
  1235. Returned value:
  1236.   * if driver is not loaded
  1237.     (never happens in the current implementation):
  1238.     * eax = -1
  1239.     * ebx, ecx destroyed
  1240.   * if driver is loaded:
  1241.     * eax = 'MDAZ' (in fasm style, that is 'M' - low byte, 'Z' - high)
  1242.       - signature
  1243.     * ebx = current frequency of the scanning (in Hz)
  1244.     * ecx destroyed
  1245.     * buffer pointed to by edx is filled
  1246. Format of the buffer:
  1247.   * +0: 32*byte: driver name, "Trans VideoDriver"
  1248.     (without quotes, supplemented by spaces)
  1249.   * +32 = +0x20: dword: driver version (version x.y is encoded as
  1250.     y*65536+x), for the current implementation is 1 (1.0)
  1251.   * +36 = +0x24: 7*dword: reserved (0 in the current implementation)
  1252.   * +64 = +0x40: 32*word: list of supported videomodes (each word
  1253.     is number of a videomode, after list itself there are zeroes)
  1254.   * +128 = +0x80: 32*(5*word): list of supported frequences of the
  1255.     scannings for videomodes: for each videomode listed in the
  1256.     previous field up to 5 supported frequences are given
  1257.     (unused positions contain zeroes)
  1258. Remarks:
  1259.   * Function initializes the driver (if it is not initialized yet)
  1260.     and must be called first, before others (otherwise they will do
  1261.     nothing and return -1).
  1262.   * The current implementation supports only one frequency
  1263.     of the scanning on videomode.
  1264.  
  1265. ======================================================================
  1266. ============ Function 21, subfunction 13, subsubfunction 2 ===========
  1267. ================ Get information on current videomode. ===============
  1268. ======================================================================
  1269. Parameters:
  1270.   * eax = 21 - function number
  1271.   * ebx = 13 - subfunction number
  1272.   * ecx = 2 - number of the driver function
  1273. Returned value:
  1274.   * eax = -1 - driver is not loaded or not initialized;
  1275.     ebx,ecx are destroyed
  1276.   * eax = [width]*65536 + [height]
  1277.   * ebx = frequency of the vertical scanning (in Hz)
  1278.   * ecx = number of current videomode
  1279. Remarks:
  1280.   * Driver must be initialized by call to
  1281.     driver function 1.
  1282.   * If only screen sizes are required, it is more expedient to use
  1283.     function 14 taking into account that it
  1284.     returns sizes on 1 less.
  1285.  
  1286. ======================================================================
  1287. === Function 21, subfunction 13, subsubfunction 3 - set videomode. ===
  1288. ======================================================================
  1289. Parameters:
  1290.   * eax = 21 - function number
  1291.   * ebx = 13 - subfunction number
  1292.   * ecx = 3 - number of the driver function
  1293.   * edx = [scanning frequency]*65536 + [videomode number]
  1294. Returned value:
  1295.   * eax = -1 - driver is not loaded, not initialized or
  1296.     an error has occured
  1297.   * eax = 0 - success
  1298.   * ebx, ecx destroyed
  1299. Remarks:
  1300.   * Driver must be initialized by driver function 1.
  1301.   * The videomode number and frequency must be in the table
  1302.     returned by driver function 1.
  1303.  
  1304. ======================================================================
  1305. ============ Function 21, subfunction 13, subsubfunction 4 ===========
  1306. ================== Return to the initial videomode. ==================
  1307. ======================================================================
  1308. Returns the screen to the videomode set at system boot.
  1309. Parameters:
  1310.   * eax = 21 - function number
  1311.   * ebx = 13 - subfunction number
  1312.   * ecx = 4 - number of the driver function
  1313. Returned value:
  1314.   * eax = -1 - driver is not loaded or not initialized
  1315.   * eax = 0 - success
  1316.   * ebx, ecx destroyed
  1317. Remarks:
  1318.   * Driver must be initialized by call to driver function 1.
  1319.  
  1320. ======================================================================
  1321. ============ Function 21, subfunction 13, subsubfunction 5 ===========
  1322. ===== Increase/decrease the size of the visible area of monitor. =====
  1323. ======================================================================
  1324. Parameters:
  1325.   * eax = 21 - function number
  1326.   * ebx = 13 - subfunction number
  1327.   * ecx = 5 - number of the driver function
  1328.   * edx = 0/1 - decrease/increase horizontal size on 1 position
  1329.   * edx = 2/3 - is not supported in the current implementation;
  1330.     is planned as decrease/increase vertical size on 1 position
  1331. Returned value:
  1332.   * eax = -1 - driver is not loaded or not initialized
  1333.   * eax = 0 - success
  1334.   * ebx, ecx destroyed
  1335. Remarks:
  1336.   * Driver must be initialized by call to driver function 1.
  1337.   * Function influences only the physical size of the screen image;
  1338.     the logical size (number of pixels) does not change.
  1339.  
  1340. ======================================================================
  1341. ================= Function 22 - set system date/time. ================
  1342. ======================================================================
  1343. Parameters:
  1344.   * eax = 22 - function number
  1345.   * ebx = 0 - set time
  1346.     * ecx = 0x00SSMMHH - time in the binary-decimal code (BCD):
  1347.     * HH=hour 00..23
  1348.     * MM=minute 00..59
  1349.     * SS=second 00..59
  1350.   * ebx = 1 - set date
  1351.     * ecx = 0x00DDMMYY - date in the binary-decimal code (BCD):
  1352.     * DD=day 01..31
  1353.     * MM=month 01..12
  1354.     * YY=year 00..99
  1355.   * ebx = 2 - set day of week
  1356.     * ecx = 1 for Sunday, ..., 7 for Saturday
  1357.   * ebx = 3 - set alarm clock
  1358.     * ecx = 0x00SSMMHH
  1359. Returned value:
  1360.   * eax = 0 - success
  1361.   * eax = 1 - incorrect parameter
  1362.   * eax = 2 - CMOS-battery was unloaded
  1363. Remarks:
  1364.   * Value of installation of day of week seems to be doubtful,
  1365.     as it a little where is used
  1366.     (day of week can be calculated by date).
  1367.   * Alarm clock can be set on operation in the given time every day.
  1368.     But there is no existing system function to disable it.
  1369.   * Operation of alarm clock consists in generation IRQ8.
  1370.   * Generally CMOS supports for alarm clock set of value 0xFF
  1371.     as one of parameters and it means that the appropriate parameter
  1372.     is ignored. But current implementation does not allow this
  1373.     (will return 1).
  1374.   * Alarm clock is a global system resource; the set of
  1375.     an alarm clock cancels automatically the previous set.
  1376.     However, at moment no program uses it.
  1377.  
  1378. ======================================================================
  1379. ============= Function 23 - wait for event with timeout. =============
  1380. ======================================================================
  1381. If the message queue is empty, waits for new message in the queue,
  1382. but no more than given time. Then reads out a message from the queue.
  1383.  
  1384. Parameters:
  1385.   * eax = 23 - function number
  1386.   * ebx = timeout (in 1/100 of second)
  1387. Returned value:
  1388.   * eax = 0 - the message queue is empty
  1389.   * otherwise eax = event (see the list of events)
  1390. Remarks:
  1391.   * Only those events are taken into account, which enter into
  1392.     the mask set by function 40. By default it is
  1393.     redraw, key and button events.
  1394.   * To check for presence of a message in the queue use function 11.
  1395.     To wait without timeout use function 10.
  1396.   * Transmission ebx=0 results in immediate returning eax=0.
  1397.   * Current implementation returns immediately with eax=0,
  1398.     if the addition of ebx with the current value of time counter
  1399.     makes 32-bit overflow.
  1400.  
  1401. ======================================================================
  1402. ======== Function 24, subfunction 1 - begin to play CD-audio. ========
  1403. ======================================================================
  1404. Parameters:
  1405.   * eax = 24 - function number
  1406.   * ebx = 1 - subfunction number
  1407.   * ecx = 0x00FRSSMM, where
  1408.     * MM = starting minute
  1409.     * SS = starting second
  1410.     * FR = starting frame
  1411. Returned value:
  1412.   * eax = 0 - success
  1413.   * eax = 1 - CD base is not defined
  1414. Remarks:
  1415.   * Previously CD base must be defined by the call to
  1416.     subfunction 3 of function 21.
  1417.   * One second includes 75 frames, one minute includes 60 seconds.
  1418.   * The function is asynchronous (returns control, when play begins).
  1419.  
  1420. ======================================================================
  1421. ======= Function 24, subfunction 2 - get information on tracks. ======
  1422. ======================================================================
  1423. Parameters:
  1424.   * eax = 24 - function number
  1425.   * ebx = 2 - subfunction number
  1426.   * ecx = pointer to the buffer for the table
  1427.     (maximum 8*64h+4 bytes=100 tracks)
  1428. Returned value:
  1429.   * eax = 0 - success
  1430.   * eax = 1 - CD base is not defined
  1431. Remarks:
  1432.   * The format of the table with tracks information is the same as
  1433.     for ATAPI-CD command 43h (READ TOC), usual table (subcommand 00h).
  1434.     Function returns addresses in MSF.
  1435.   * Previously CD base port must be set by call to
  1436.     subfunction 3 of function 21.
  1437.   * Function returns information only about no more than 100
  1438.     first tracks. In most cases it is enough.
  1439.  
  1440. ======================================================================
  1441. ========== Function 24, subfunction 3 - stop play CD-audio. ==========
  1442. ======================================================================
  1443. Parameters:
  1444.   * eax = 24 - function number
  1445.   * ebx = 1 - subfunction number
  1446. Returned value:
  1447.   * eax = 0 - success
  1448.   * eax = 1 - CD base is not defined
  1449. Remarks:
  1450.   * Previously CD base port must be defined by call to
  1451.     subfunction 3 of function 21.
  1452.  
  1453. ======================================================================
  1454. ======= Function 24, subfunction 4 - eject tray of disk drive. =======
  1455. ======================================================================
  1456. Parameters:
  1457.   * eax = 24 - function number
  1458.   * ebx = 4 - subfunction number
  1459.   * ecx = position of CD/DVD-drive
  1460.       (from 0=Primary Master to 3=Secondary Slave)
  1461. Returned value:
  1462.   * function does not return value
  1463. Remarks:
  1464.   * The function is supported only for ATAPI devices (CD and DVD).
  1465.   * When the tray is being ejected,
  1466.     manual control of tray is unlocked.
  1467.   * When the tray is being ejected, the code clears the cache for
  1468.     corresponding device.
  1469.   * An example of usage of the function is the application CD_tray.
  1470.  
  1471. ======================================================================
  1472. ======== Function 24, subfunction 5 - load tray of disk drive. =======
  1473. ======================================================================
  1474. Parameters:
  1475.   * eax = 24 - function number
  1476.   * ebx = 5 - subfunction number
  1477.   * ecx = position of CD/DVD-drive
  1478.       (from 0=Primary Master to 3=Secondary Slave)
  1479. Returned value:
  1480.   * function does not return value
  1481. Remarks:
  1482.   * The function is supported only for ATAPI devices (CD and DVD).
  1483.   * An example of usage of the function is the application CD_tray.
  1484.  
  1485. ======================================================================
  1486. =================== Function 25 - set SBPro volume. ==================
  1487. ======================================================================
  1488. Removed
  1489.  
  1490. ======================================================================
  1491. ======== Function 26, subfunction 1 - get MPU MIDI base port. ========
  1492. ======================================================================
  1493. Parameters:
  1494.   * eax = 26 - function number
  1495.   * ebx = 1 - subfunction number
  1496. Returned value:
  1497.   * eax = port number
  1498. Parameters:
  1499.   * To set base port use subfunction 1 of function 21.
  1500.  
  1501. ======================================================================
  1502. ========== Function 26, subfunction 2 - get keyboard layout. =========
  1503. ======================================================================
  1504. The keyboard layout is used to convert keyboard scancodes to
  1505. ASCII-codes for function 2.
  1506. Parameters:
  1507.   * eax = 26 - function number
  1508.   * ebx = 2 - subfunction number
  1509.   * ecx = what layout to get:
  1510.     * 1 = normal layout
  1511.     * 2 = layout with pressed Shift
  1512.     * 3 = layout with pressed Alt
  1513.   * edx = pointer to the 128-bytes buffer, where the layout will be
  1514.     copied
  1515. Returned value:
  1516.   * function does not return value
  1517. Or:
  1518.   * eax = 26 - function number
  1519.   * ebx = 2 - subfunction number
  1520.   * ecx = 9
  1521. Returned value:
  1522.   * eax = country identifier (1=eng, 2=fi, 3=ger, 4=rus)
  1523. Remarks:
  1524.   * If Alt is pressed, the layout with Alt is used;
  1525.     if Alt is not pressed, but Shift is pressed,
  1526.     the layout with Shift is used;
  1527.     if Alt and Shift are not pressed, but Ctrl is pressed, the normal
  1528.     layout is used and then from the code is subtracted 0x60;
  1529.     if no control key is pressed, the normal layout is used.
  1530.   * To set layout and country identifier use
  1531.     subfunction 2 of function 21.
  1532.   * Country identifier is global system variable, which is not used
  1533.     by the kernel itself; however the application '@panel' displays
  1534.     the corresponding icon (using this function).
  1535.   * The application @panel switches layouts on user request.
  1536.  
  1537. ======================================================================
  1538. ============== Function 26, subfunction 3 - get CD base. =============
  1539. ======================================================================
  1540. Parameters:
  1541.   * eax = 26 - function number
  1542.   * ebx = 3 - subfunction number
  1543. Returned value:
  1544.   * eax = CD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
  1545. Remarks:
  1546.   * CD base is used by function 24.
  1547.   * To set CD base use subfunction 3 of function 21.
  1548.  
  1549. ======================================================================
  1550. ====== Function 26, subfunction 4 - get Sound Blaster base port. =====
  1551. ======================================================================
  1552. Removed
  1553.  
  1554. ======================================================================
  1555. ========== Function 26, subfunction 5 - get system language. =========
  1556. ======================================================================
  1557. Parameters:
  1558.   * eax = 26 - function number
  1559.   * ebx = 5 - subfunction number
  1560. Returned value:
  1561.   * eax = system language (1=eng, 2=fi, 3=ger, 4=rus)
  1562. Remarks:
  1563.   * System language is global system variable and is not used
  1564.     by the kernel itself, however application @panel draws the
  1565.     appropriate icon (using this function).
  1566.   * To set system language use subfunction 5 of function 21.
  1567.  
  1568. ======================================================================
  1569. ============== Function 26, subfunction 7 - get HD base. =============
  1570. ======================================================================
  1571. The HD base defines hard disk to write with usage of obsolete
  1572. syntax /HD in obsolete function 58; at usage of modern syntax
  1573. /HD0,/HD1,/HD2,/HD3 base is set automatically.
  1574. Parameters:
  1575.   * eax = 26 - function number
  1576.   * ebx = 7 - subfunction number
  1577. Returned value:
  1578.   * eax = HD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
  1579. Remarks:
  1580.   * Any application in any time can change HD base.
  1581.   * To set base use subfunction 7 of function 21.
  1582.   * To get used partition of hard disk use subfunction 8.
  1583.  
  1584. ======================================================================
  1585. ========= Function 26, subfunction 8 - get used HD partition. ========
  1586. ======================================================================
  1587. The HD partition defines partition of the hard disk to write with
  1588. usage of obsolete syntax /HD in obsolete function 58;
  1589. at usage of functions 58 and 70 and modern syntax /HD0,/HD1,/HD2,/HD3
  1590. base and partition are set automatically.
  1591. Parameters:
  1592.   * eax = 26 - function number
  1593.   * ebx = 8 - subfunction number
  1594. Returned value:
  1595.   * eax = HD partition (beginning from 1)
  1596. Remarks:
  1597.   * Any application in any time can change partition.
  1598.   * To set partition use subfunction 8 of function 21.
  1599.   * To get number of partitions on a hard disk use
  1600.     subfunction 11 of function 18.
  1601.   * To get base of used hard disk, use subfunction 7.
  1602.  
  1603. ======================================================================
  1604. === Function 26, subfunction 9 - get the value of the time counter. ==
  1605. ======================================================================
  1606. Parameters:
  1607.   * eax = 26 - function number
  1608.   * ebx = 9 - subfunction number
  1609. Returned value:
  1610.   * eax = number of 1/100s of second, past from the system boot time
  1611. Remarks:
  1612.   * Counter takes modulo 2^32, that correspond to a little more
  1613.     than 497 days.
  1614.   * To get system time use function 3.
  1615.  
  1616. ======================================================================
  1617. ======== Function 26, subfunction 10 - get sound DMA channel. ========
  1618. ======================================================================
  1619. Removed
  1620.  
  1621. ======================================================================
  1622. ===================== Function 26, subfunction 11 ====================
  1623. ========== Find out whether low-level HD access is enabled. ==========
  1624. ======================================================================
  1625. Parameters:
  1626.   * eax = 26 - function number
  1627.   * ebx = 11 - subfunction number
  1628. Returned value:
  1629.   * eax = 0/1 - disabled/enabled
  1630. Remarks:
  1631.   * Is used in LBA read (subfunction 8 of function 58).
  1632.   * To set current state use subfunction 11 of function 21.
  1633.  
  1634. ======================================================================
  1635. ===================== Function 26, subfunction 12 ====================
  1636. ========== Find out whether low-level PCI access is enabled. =========
  1637. ======================================================================
  1638. Parameters:
  1639.   * eax = 26 - function number
  1640.   * ebx = 12 - subfunction number
  1641. Returned value:
  1642.   * eax = 0/1 - disabled/enabled
  1643. Remarks:
  1644.   * Is used by operations with PCI bus (function 62).
  1645.   * The current implementation uses only low bit of ecx.
  1646.   * To set the current state use subfunction 12 of function 21.
  1647.  
  1648. ======================================================================
  1649. =================== Function 28 - set SB16 volume. ===================
  1650. ======================================================================
  1651. Removed
  1652.  
  1653. ======================================================================
  1654. =================== Function 29 - get system date. ===================
  1655. ======================================================================
  1656. Parameters:
  1657.   * eax = 29 - function number
  1658. Returned value:
  1659.   * eax = 0x00DDMMYY, where
  1660.     (binary-decimal coding, BCD, is used)
  1661.   * YY = two low digits of year (00..99)
  1662.   * MM = month (01..12)
  1663.   * DD = day (01..31)
  1664. Remarks:
  1665.   * To set system date use function 22.
  1666.  
  1667. ======================================================================
  1668. ============= Function 30 - work with the current folder. ============
  1669. ======================================================================
  1670.  
  1671. --------- Subfunction 1 - set current folder for the thread. ---------
  1672. Parameters:
  1673.   * eax = 30 - function number
  1674.   * ebx = 1 - subfunction number
  1675.   * ecx = pointer to ASCIIZ-string with the path to new current folder
  1676. Returned value:
  1677.   * function does not return value
  1678.  
  1679. --------- Subfunction 2 - get current folder for the thread. ---------
  1680. Parameters:
  1681.   * eax = 30 - function number
  1682.   * ebx = 2 - subfunction number
  1683.   * ecx = pointer to buffer
  1684.   * edx = size of buffer
  1685. Returned value:
  1686.   * eax = size of the current folder's name (including terminating 0)
  1687. Remarks:
  1688.   * If the buffer is too small to hold all data, only first (edx-1)
  1689.     bytes are copied and than terminating 0 is inserted.
  1690.  
  1691. ======================================================================
  1692. ======= Function 35 - read the color of a pixel on the screen. =======
  1693. ======================================================================
  1694. Parameters:
  1695.   * eax = 35
  1696.   * ebx = y*xsize+x, where
  1697.   * (x,y) = coordinates of a pixel (beginning from 0)
  1698.   * xsize = horizontal screen size
  1699. Returned value:
  1700.   * eax = color 0x00RRGGBB
  1701. Remarks:
  1702.   * To get screen sizes use function 14. Pay attention,
  1703.     that it subtracts 1 from both sizes.
  1704.   * There is also direct access (without any system calls)
  1705.     to videomemory through the selector gs. To get parameters of
  1706.     the current videomode, use function 61.
  1707.  
  1708. ======================================================================
  1709. =================== Function 37 - work with mouse. ===================
  1710. ======================================================================
  1711.  
  1712. ---------- Subfunction 0 - screen coordinates of the mouse -----------
  1713. Parameters:
  1714.   * eax = 37 - function number
  1715.   * ebx = 0 - subfunction number
  1716. Returned value:
  1717.   * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer
  1718.     (beginning from 0)
  1719.  
  1720. -- Subfunction 1 - coordinates of the mouse relative to the window ---
  1721. Parameters:
  1722.   * eax = 37 - function number
  1723.   * ebx = 1 - subfunction number
  1724. Returned value:
  1725.   * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer
  1726.     relative to the application window (beginning from 0)
  1727. Remarks:
  1728.   * The value is calculated by formula (x-xwnd)*65536 + (y-ywnd).
  1729.     If y>=ywnd, the low word is non-negative and contains
  1730.     relative y-coordinate, and the high word - relative x-coordinate
  1731.     (with correct sign). Otherwise the low word is negative and still
  1732.     contains relative y-coordinate, and to the high word
  1733.     1 should be added.
  1734.  
  1735. ------------ Subfunction 2 - pressed buttons of the mouse ------------
  1736. Parameters:
  1737.   * eax = 37 - function number
  1738.   * ebx = 2 - subfunction number
  1739. Returned value:
  1740.   * eax contains information on the pressed mouse buttons:
  1741.   * bit 0 is set = left button is pressed
  1742.   * bit 1 is set = right button is pressed
  1743.   * bit 2 is set = middle button is pressed
  1744.   * bit 3 is set = 4th button is pressed
  1745.   * bit 4 is set = 5th button is pressed
  1746.   * other bits are cleared
  1747.  
  1748. -------------------- Subfunction 4 - load cursor ---------------------
  1749. Parameters:
  1750.   * eax = 37 - function number
  1751.   * ebx = 4 - subfunction number
  1752.   * dx = data source:
  1753.   * dx = LOAD_FROM_FILE = 0 - data in a file
  1754.     * ecx = pointer to full path to the cursor file
  1755.     * the file must be in the format .cur, which is standard for
  1756.       MS Windows, at that of the size 32*32 pixels
  1757.   * dx = LOAD_FROM_MEM = 1 - data of file are already loaded in memory
  1758.     * ecx = pointer to data of the cursor file
  1759.     * the data format is the same as in the previous case
  1760.   * dx = LOAD_INDIRECT = 2 - data in memory
  1761.     * ecx = pointer to cursor image in the format ARGB 32*32 pixels
  1762.     * edx = 0xXXYY0002, where
  1763.       * XX = x-coordinate of cursor hotspot
  1764.       * YY = y-coordinate
  1765.       * 0 <= XX, YY <= 31
  1766. Returned value:
  1767.   * eax = 0 - failed
  1768.   * otherwise eax = cursor handle
  1769.  
  1770. --------------------- Subfunction 5 - set cursor ---------------------
  1771. Sets new cursor for the window of the current thread.
  1772. Parameters:
  1773.   * eax = 37 - function number
  1774.   * ebx = 5 - subfunction number
  1775.   * ecx = cursor handle
  1776. Returned value:
  1777.   * eax = handle of previous cursor
  1778. Remarks:
  1779.   * If the handle is incorrect, the function restores the default
  1780.     cursor (standard arrow). In particular, ecx=0 restores it.
  1781.  
  1782. ------------------- Subfunction 6 - delete cursor --------------------
  1783. Parameters:
  1784.   * eax = 37 - function number
  1785.   * ebx = 6 - subfunction number
  1786.   * ecx = cursor handle
  1787. Returned value:
  1788.   * eax destroyed
  1789. Remarks:
  1790.   * The cursor must be loaded previously by the current thread
  1791.     (with the call to subfunction 4). The function does not delete
  1792.     system cursors and cursors, loaded by another applications.
  1793.   * If the active cursor (set by subfunction 5) is deleted,
  1794.     the system restores the default cursor (standard arrow).
  1795.  
  1796. ------------------ Subfunction 7 - get scroll data -------------------
  1797. Parameters:
  1798.   * eax = 37 - function number
  1799.   * ebx = 7 - subfunction number
  1800. Returned value:
  1801.   * eax = [horizontal offset]*65536 + [vertical offset]
  1802. Remarks:
  1803.   * Scroll data is available for active window only.
  1804.   * Values are zeroed after reading.
  1805.   * Values are signed.
  1806.  
  1807. ======================================================================
  1808. ====================== Function 38 - draw line. ======================
  1809. ======================================================================
  1810. Parameters:
  1811.   * eax = 38 - function number
  1812.   * ebx = [start coordinate on axis x]*65536 +
  1813.               [end coordinate on axis x]
  1814.   * ecx = [start coordinate on axis y]*65536 +
  1815.               [end coordinate on axis y]
  1816.   * edx = 0x00RRGGBB - color
  1817.     edx = 0x01xxxxxx - draw inversed line
  1818.           (low 24 bits are ignored)
  1819. Returned value:
  1820.   * function does not return value
  1821. Remarks:
  1822.   * Coordinates are relative to the window.
  1823.   * End point is also drawn.
  1824.  
  1825. ======================================================================
  1826. == Function 39, subfunction 1 - get a size of the background image. ==
  1827. ======================================================================
  1828. Parameters:
  1829.   * eax = 39 - function number
  1830.   * ebx = 1 - subfunction number
  1831. Returned value:
  1832.   * eax = [width]*65536 + [height]
  1833. Remarks:
  1834.   * There is a pair function to set sizes of background image -
  1835.     subfunction 1 of function 15. After which it is necessary,
  1836.     of course, anew to define image.
  1837.  
  1838. ======================================================================
  1839. == Function 39, subfunction 2 - get pixel from the background image. =
  1840. ======================================================================
  1841. Parameters:
  1842.   * eax = 39 - function number
  1843.   * ebx = 2 - subfunction number
  1844.   * ecx = offset
  1845. Returned value:
  1846.   * eax = 0x00RRGGBB - pixel color, if offset is valid
  1847.     (less than 0x160000-16)
  1848.   * eax = 2 otherwise
  1849. Remarks:
  1850.   * Do not rely on returned value for invalid offsets, it may be
  1851.     changed in future kernel versions.
  1852.   * Offset for pixel with coordinates (x,y)
  1853.     is calculated as (x+y*xsize)*3.
  1854.   * There is a pair function to set pixel on the background image -
  1855.     subfunction 2 of function 15.
  1856.  
  1857. ======================================================================
  1858. == Function 39, subfunction 4 - get drawing mode for the background. =
  1859. ======================================================================
  1860. Parameters:
  1861.   * eax = 39 - function number
  1862.   * ebx = 4 - subfunction number
  1863. Returned value:
  1864.   * eax = 1 - tile
  1865.   * eax = 2 - stretch
  1866. Remarks:
  1867.   * There is a pair function to set drawing mode -
  1868.     subfunction 4 of function 15.
  1869.  
  1870. ======================================================================
  1871. =========== Function 40 - set the mask for expected events. ==========
  1872. ======================================================================
  1873. The mask for expected events affects function working with events
  1874. 10, 11, 23 - they notify only about events allowed by this mask.
  1875. Parameters:
  1876.   * eax = 40 - function number
  1877.   * ebx = mask: bit i corresponds to event i+1 (see list of events)
  1878.     (set bit permits notice on event)
  1879. Returned value:
  1880.   * function does not return value
  1881. Remarks:
  1882.   * Default mask (7=111b) enables nofices about redraw,
  1883.     keys and buttons. This is enough for many applications.
  1884.   * Events prohibited in the mask are saved anyway, when come;
  1885.     they are simply not informed with event functions.
  1886.   * Event functions take into account the mask on moment of
  1887.     function call, not on moment of event arrival.
  1888.  
  1889. ======================================================================
  1890. ==================== Function 41 - get IRQ owner. ====================
  1891. ======================================================================
  1892. Parameters:
  1893.   * eax = 41 - function number
  1894.   * ebx = IRQ number, 0..15
  1895. Returned value:
  1896.   * eax = owner PID
  1897.   * eax = 0, if there is no owner
  1898.   * eax = -1 for incorrect ebx
  1899.  
  1900. ======================================================================
  1901. ==================== Function 42 - work with IRQ data. ===============
  1902. ======================================================================
  1903.  
  1904. ------------------------ Reading data --------------------------------
  1905.  
  1906. When an IRQ occurs, the system reads data from ports indicated
  1907. earlier by function 44 and writes this data to
  1908. internal buffer. This function reads out data from that buffer
  1909. to the buffer specified as parameter.
  1910. Parameters:
  1911.   * eax = 42 - function number
  1912.   * bl = IRQ number, 0..15
  1913.   * bh = subfunction number, 0
  1914. Other part of register ebx, must be zero.
  1915.   * ecx = pointer to the receive buffer
  1916. Returned value: (use value of eax to distinguish)
  1917.   * if the thread is not IRQ owner (or IRQ number is incorrect):
  1918.     * eax = -1
  1919.   * if there is no data:
  1920.     * eax = 0
  1921.   * if all is ok:
  1922.     * eax = byte size of data, read from buffer
  1923.  
  1924. See remarks below.
  1925.  
  1926. ------------------------ Get data size -------------------------------
  1927.  
  1928. Parameters:
  1929.   * eax = 42 - function number
  1930.   * bl = IRQ number, 0..15
  1931.   * bh = subfunction number, 0
  1932. Other part of register ebx, must be zero.
  1933.   * ecx = pointer to receive buffer
  1934. Returned value: (use value of eax to distinguish)
  1935.   * if the thread is not IRQ owner (or IRQ number is incorrect):
  1936.     * eax = -1
  1937.   * if all is ok:
  1938.     * eax = byte size of data in buffer
  1939.  
  1940. Remarks:
  1941.   * Previously the thread must reserve indicated IRQ for itself
  1942.     by function 45.
  1943.   * The size of data buffer is 4000 bytes, on overflow
  1944.     "fresh" data cease to be written in the buffer.
  1945.  
  1946. ======================================================================
  1947. ================ Function 43 - input/output to a port. ===============
  1948. ======================================================================
  1949.  
  1950. ------------------------ Output data to port -------------------------
  1951. Parameters:
  1952.   * eax = 43 - function number
  1953.   * bl = byte for output
  1954.   * ecx = port number 0xnnnn (from 0 to 0xFFFF)
  1955. Returned value:
  1956.   * eax = 0 - success
  1957.   * eax = 1 - the thread has not reserved the selected port
  1958.  
  1959. ------------------------ Input data from port ------------------------
  1960. Parameters:
  1961.   * eax = 43 - function number
  1962.   * ebx is ignored
  1963.   * ecx = 0x8000nnnn, where nnnn = port number (from 0 to 0xFFFF)
  1964. Returned value:
  1965.   * eax = 0 - success, thus ebx = entered byte
  1966.   * eax = 1 - the thread has not reserved the selected port
  1967. Remarks:
  1968.   * Previously the thread must reserve the selected port
  1969.     for itself by function 46.
  1970.   * Instead of call to this function it is better to use
  1971.     processor instructions in/out - this is much
  1972.     faster and a bit shorter and easier.
  1973.  
  1974. ======================================================================
  1975. =========== Function 44 - define operations at IRQ arrival. ==========
  1976. ======================================================================
  1977. At IRQ arrival the system can read the data from ports defined
  1978. by this function and write these data to internal buffer, whence
  1979. they can be read by ôóíêöèåé 42.
  1980. Parameters:
  1981.   * eax = 44 - function number
  1982.   * ebx = pointer to the array of structures each describing one port:
  1983.     * +0: word: 0 means end of array, otherwise port number
  1984.     * +2: byte: reserved (ignored)
  1985.     * +3: byte: 1=read byte from this port, 2=read word
  1986.   * ecx = IRQ number, 0..15
  1987. Returned value:
  1988.   * eax = 0 - success
  1989.   * eax = 1 - the thread is not owner of selected IRQ
  1990. Remarks:
  1991.   * Previously the thread must reserve for itself selected IRQ
  1992.     by function 45.
  1993.   * First 16 ports are considered only.
  1994.   * The current implementation considers incorrect value of field +3
  1995.     as a signal to terminate IRQ processing.
  1996.  
  1997. ======================================================================
  1998. =================== Function 45 - reserve/free IRQ. ==================
  1999. ======================================================================
  2000. Parameters:
  2001.   * eax = 45 - function number
  2002.   * ebx = 0 - reserve, 1 = free
  2003.   * ecx = IRQ number, 0..15
  2004. Returned value:
  2005.   * eax = 0 - success
  2006.   * eax = 1 - error (invalid IRQ number
  2007.     or attempt to reserve not free IRQ
  2008.     or to free IRQ, not reserved by this thread)
  2009. Remarks:
  2010.   * IRQ reservation is required for functions 42 and 44.
  2011.   * Only one thread can reserve the specific IRQ.
  2012.   * IRQs, handled by the system itself, are reserved by the system
  2013.     (thread 1) at booting.
  2014.   * When a thread terminates, all reserved by it IRQs
  2015.     are freed automatically.
  2016.  
  2017. ======================================================================
  2018. ====== Function 46 - reserve/free a group of input/output ports. =====
  2019. ======================================================================
  2020. To work with reserved ports an application can access directly by
  2021. commands in/out (recommended way) and can use function 43
  2022. (not recommended way).
  2023. Parameters:
  2024.   * eax = 46 - function number
  2025.   * ebx = 0 - reserve, 1 - free
  2026.   * ecx = start port number
  2027.   * edx = end port number (inclusive)
  2028. Returned value:
  2029.   * eax = 0 - success
  2030.   * eax = 1 - error
  2031. Remarks:
  2032.   * For ports reservation: an error occurs if and only if
  2033.     one from the following condition satisfies:
  2034.     * start port is more than end port;
  2035.     * the selected range contains incorrect port number
  2036.       (correct are from 0 to 0xFFFF);
  2037.     * limit for the total number of reserved areas is exceeded
  2038.       (maximum 255 are allowed);
  2039.     * the selected range intersects with any of earlier reserved
  2040.   * For ports free: an error is an attempt to free range,
  2041.     that was not earlier reserved by this function
  2042.     (with same ecx,edx).
  2043.   * If an error occurs (for both cases) function performs no action.
  2044.   * At booting the system reserves for itself ports
  2045.     0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (inclusively).
  2046.   * When a thread terminates, all reserved by it ports
  2047.     are freed automatically.
  2048.  
  2049. ======================================================================
  2050. ============= Function 47 - draw a number in the window. =============
  2051. ======================================================================
  2052. Parameters:
  2053.   * eax = 47 - function number
  2054.   * ebx = parameters of conversion number to text:
  2055.     * bl = 0 - ecx contains number
  2056.     * bl = 1 - ecx contains pointer to dword/qword-number
  2057.     * bh = 0 - display in decimal number system
  2058.     * bh = 1 - display in hexadecimal system
  2059.     * bh = 2 - display in binary system
  2060.     * bits 16-21 = how many digits to display
  2061.     * bits 22-29 reserved and must be set to 0
  2062.     * bit 30 set = display qword (64-bit) number (must be bl=1)
  2063.     * bit 31 set = do not display leading zeroes of the number
  2064.   * ecx = number (if bl=0) or pointer (if bl=1)
  2065.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  2066.   * esi = 0xX0RRGGBB:
  2067.     * RR, GG, BB specify the color
  2068.     * X = ABnn (bits)
  2069.     * nn = font (0/1)
  2070.     * A is ignored
  2071.     * B=1 - fill background with the color edi
  2072. Returned value:
  2073.   * function does not return value
  2074. Remarks:
  2075.   * The given length must not exceed 60.
  2076.   * The exactly given amount of digits is output. If number is small
  2077.     and can be written by smaller amount of digits, it is supplemented
  2078.     by leading zeroes; if the number is big and can not be written by
  2079.     given amount of digits, extra digits are not drawn.
  2080.   * Parameters of fonts are shown in the description of function 4
  2081.     (text output).
  2082.  
  2083. ======================================================================
  2084. ========= Function 48, subfunction 0 - apply screen settings. ========
  2085. ======================================================================
  2086. Parameters:
  2087.   * eax = 48 - function number
  2088.   * ebx = 0 - subfunction number
  2089.   * ecx = 0 - reserved
  2090. Returned value:
  2091.   * function does not return value
  2092. Remarks:
  2093.   * Function redraws the screen after parameters change by
  2094.     subfunctions 1 and 2.
  2095.   * Function call without prior call to one of indicated subfunctions
  2096.     is ignored.
  2097.   * Function call with nonzero ecx is ignored.
  2098.  
  2099. ======================================================================
  2100. =========== Function 48, subfunction 1 - set button style. ===========
  2101. ======================================================================
  2102. Parameters:
  2103.   * eax = 48 - function number
  2104.   * ebx = 1 - subfunction number
  2105.   * ecx = button style:
  2106.     * 0 = flat
  2107.     * 1 = 3d
  2108. Returned value:
  2109.   * function does not return value
  2110. Remarks:
  2111.   * After call to this function one should redraw the screen by
  2112.     subfunction 0.
  2113.   * Button style influences only to their draw of function 8.
  2114.  
  2115. ======================================================================
  2116. ====== Function 48, subfunction 2 - set standard window colors. ======
  2117. ======================================================================
  2118. Parameters:
  2119.   * eax = 48 - function number
  2120.   * ebx = 2 - subfunction number
  2121.   * ecx = pointer to the color table
  2122.   * edx = size of the color table
  2123.     (must be 40 bytes for future compatibility)
  2124. Format of the color table is shown in description of subfunction 3.
  2125. Returned value:
  2126.   * function does not return value
  2127. Remarks:
  2128.   * After call to this function one should redraw the screen by
  2129.     subfunction 0.
  2130.   * Table of standard colors influences only to applications,
  2131.     which receive this table obviously (by subfunction 3)
  2132.     and use it (specifying colors from it to drawing functions).
  2133.   * Table of standard colors is included in skin and is installed
  2134.     anew with skin installation (by subfunction 8).
  2135.   * Color table can be viewed/changed interactively with
  2136.     the application 'desktop'.
  2137.  
  2138. ======================================================================
  2139. ====== Function 48, subfunction 3 - get standard window colors. ======
  2140. ======================================================================
  2141. Parameters:
  2142.   * eax = 48 - function number
  2143.   * ebx = 3 - subfunction number
  2144.   * ecx = pointer to the buffer with size edx bytes,
  2145.     where table will be written
  2146.   * edx = size of color table
  2147.     (must be 40 bytes for future compatibility)
  2148. Returned value:
  2149.   * function does not return value
  2150. Format of the color table:
  2151. each item is dword-value for color 0x00RRGGBB
  2152.   * +0: dword: frames - color of frame
  2153.   * +4: dword: grab - color of header
  2154.   * +8: dword: grab_button - color of button on header bar
  2155.   * +12 = +0xC: dword: grab_button_text - color of text on button
  2156.     on header bar
  2157.   * +16 = +0x10: dword: grab_text - color of text on header
  2158.   * +20 = +0x14: dword: work - color of working area
  2159.   * +24 = +0x18: dword: work_button - color of button in working area
  2160.   * +28 = +0x1C: dword: work_button_text - color of text on button
  2161.     in working area
  2162.   * +32 = +0x20: dword: work_text - color of text in working area
  2163.   * +36 = +0x24: dword: work_graph - color of graphics in working area
  2164. Remarks:
  2165.   * Structure of the color table is described in the standard
  2166.     include file 'macros.inc' as 'system_colors'; for example,
  2167.     it is possible to write:
  2168.         sc      system_colors           ; variable declaration
  2169.         ...                             ; somewhere one must call
  2170.                                         ; this function with ecx=sc
  2171.         mov     ecx, [sc.work_button_text]      ; read text color on
  2172.                                         ; buttin in working area
  2173.   * A program itself desides to use or not to use color table.
  2174.     For usage program must simply at calls to drawing functions select
  2175.     color taken from the table.
  2176.   * At change of the table of standard colors (by subfunction 2 with
  2177.     the subsequent application of changes by subfunction 0 or
  2178.     at skin set by subfunction 8) the system sends to all windows
  2179.     redraw message (the event with code 1).
  2180.   * Color table can be viewed/changed interactively with
  2181.     the application 'desktop'.
  2182.  
  2183. ======================================================================
  2184. ============ Function 48, subfunction 4 - get skin height. ===========
  2185. ======================================================================
  2186. Parameters:
  2187.   * eax = 48 - function number
  2188.   * ebx = 4 - subfunction number
  2189. Returned value:
  2190.   * eax = skin height
  2191. Remarks:
  2192.   * Skin height is defined as the height of a header
  2193.     of skinned windows.
  2194.   * See also general structure of window in the description
  2195.     of function 0.
  2196.  
  2197. ======================================================================
  2198. ======== Function 48, subfunction 5 - get screen working area. =======
  2199. ======================================================================
  2200. Parameters:
  2201.   * eax = 48 - function number
  2202.   * ebx = 5 - subfunction number
  2203. Returned value:
  2204.   * eax = [left]*65536 + [right]
  2205.   * ebx = [top]*65536 + [bottom]
  2206. Remarks:
  2207.   * The screen working area defines position and coordinates of
  2208.     a maximized window.
  2209.   * The screen working area in view of normal work is all screen
  2210.     without system panel (the application '@panel').
  2211.   * (left,top) are coordinates of the left upper corner,
  2212.     (right,bottom) are coordinates of the right lower one.
  2213.     Thus the size of working area on x axis can be calculated by
  2214.     formula right-left+1, on y axis - by formula bottom-right+1.
  2215.   * See also function 14,
  2216.     to get sizes of all screen.
  2217.   * There is a pair function to set working area - subfunction 6.
  2218.  
  2219. ======================================================================
  2220. ======== Function 48, subfunction 6 - set screen working area. =======
  2221. ======================================================================
  2222. Parameters:
  2223.   * eax = 48 - function number
  2224.   * ebx = 6 - subfunction number
  2225.   * ecx = [left]*65536 + [right]
  2226.   * edx = [top]*65536 + [bottom]
  2227. Returned value:
  2228.   * function does not return value
  2229. Remarks:
  2230.   * The screen working area defines position and coordinates of
  2231.     a maximized window.
  2232.   * This function is used only by the application '@panel',
  2233.     which set working area to all screen without system panel.
  2234.   * (left,top) are coordinates of the left upper corner,
  2235.     (right,bottom) are coordinates of the right lower one.
  2236.     Thus the size of working area on x axis can be calculated by
  2237.     formula right-left+1, on y axis - by formula bottom-right+1.
  2238.   * If 'left'>='right', x-coordinate of working area is not changed.
  2239.     If 'left'<0, 'left' will not be set. If 'right' is greater than or
  2240.     equal to screen width, 'right' will not be set.
  2241.     Similarly on y axis.
  2242.   * See also function 14,
  2243.     to get sizes of all screen.
  2244.   * There is a pair function to get working area - subfunction 5.
  2245.   * This function redraws the screen automatically,
  2246.     updating coordinates and sizes of maximized windows.
  2247.     The system sends to all windows redraw message (the event 1).
  2248.  
  2249. ======================================================================
  2250. =========== Function 48, subfunction 7 - get skin margins. ===========
  2251. ======================================================================
  2252. Returns the area of a header of a skinned window, intended for
  2253. a text of a header.
  2254. Parameters:
  2255.   * eax = 48 - function number
  2256.   * ebx = 7 - subfunction number
  2257. Returned value:
  2258.   * eax = [left]*65536 + [right]
  2259.   * ebx = [top]*65536 + [bottom]
  2260. Remarks:
  2261.   * An application decides itself to use or not to use this function.
  2262.   * It is recommended to take into account returned value
  2263.     of this function for choice of a place for drawing header text
  2264.     (by function 4) or a substitute of header text
  2265.     (at the discretion of an application).
  2266.  
  2267. ======================================================================
  2268. ============= Function 48, subfunction 8 - set used skin. ============
  2269. ======================================================================
  2270. Parameters:
  2271.   * eax = 48 - function number
  2272.   * ebx = 8 - subfunction number
  2273.   * ecx = pointer to a block for function 58, in
  2274.     which the fields of intermediate buffer and file name are filled
  2275. Returned value:
  2276.   * eax = 0 - success
  2277.   * otherwise eax = file system error code; if file does not
  2278.     contain valid skin, function returns error 3
  2279.     (unknown file system).
  2280. Remarks:
  2281.   * After successful skin loading the system sends to all windows
  2282.     redraw message (the event 1).
  2283.   * At booting the system reads skin from file 'default.skn'
  2284.     on ramdisk.
  2285.   * User can change the skin statically by creating hisself
  2286.     'default.skn' or dynamically with the application 'desktop'.
  2287.  
  2288. ======================================================================
  2289. =========== Function 49 - Advanced Power Management (APM). ===========
  2290. ======================================================================
  2291. Parameters:
  2292.   * eax = 49 - function number
  2293.   * dx = number of the APM function
  2294.     (analogue of ax in APM specification)
  2295.   * bx, cx = parameters of the APM function
  2296. Returned value:
  2297.   * 16-bit registers ax, bx, cx, dx, si, di and carry flag CF
  2298.     are set according to the APM specification
  2299.   * high halves of 32-bit registers eax, ebx, ecx,
  2300.     edx, esi, edi are destroyed
  2301. Remarks:
  2302.   * APM 1.2 specification is described in the document
  2303.     "Advanced Power Management (APM) BIOS Specification"
  2304.     (Revision 1.2), available at
  2305.     http://www.microsoft.com/whdc/archive/amp_12.mspx;
  2306.     besides it is included in famous Interrupt List by Ralf Brown
  2307.     (http://www.pobox.com/~ralf/files.html,
  2308.     ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/).
  2309.  
  2310. ======================================================================
  2311. =================== Function 50 - set window shape. ==================
  2312. ======================================================================
  2313. Normal windows have rectangular shape. This function can give to
  2314. a window any shape. The shape is given by a set of points inside
  2315. the base rectangle belonging to a window. Position and coordinates
  2316. of the base rectangle are set by function 0
  2317. and changed by function 67.
  2318.  
  2319. --------------------------- Set shape data ---------------------------
  2320. Parameters:
  2321.   * eax = 50 - function number
  2322.   * ebx = 0 - subfunction number
  2323.   * ecx = pointer to shape data (array of bytes 0/1)
  2324. Returned value:
  2325.   * function does not return value
  2326.  
  2327. -------------------------- Set shape scale ---------------------------
  2328. Parameters:
  2329.   * eax = 50 - function number
  2330.   * ebx = 1 - subfunction number
  2331.   * ecx sets a scale: each byte of data defines
  2332.     (2^scale)*(2^scale) pixels
  2333. Returned value:
  2334.   * function does not return value
  2335. Remarks:
  2336.   * Default scale is 0 (scale factor is 1). If in the shape data
  2337.     one byte corresponds to one pixel, there is no necessity
  2338.     to set scale.
  2339.   * Let's designate xsize = window width (in pixels), ysize = height;
  2340.     pay attention, that they are one pixel more than defined by
  2341.     functions 0, 67.
  2342.   * On definition of scale xsize and ysize must be divisible
  2343.     on 2^scale.
  2344.   * Byte of data on offset 'a' must be 0/1 and defines belonging
  2345.     to a window of square with the side 2^scale (if scale=0,
  2346.     this is one pixel) and coordinates of the left upper corner
  2347.     (a mod (xsize shr scale), a div (xsize shr scale))
  2348.   * Data size: (xsize shr scale)*(ysize shr scale).
  2349.   * Data must be presented in the memory and not change
  2350.     after set of shape.
  2351.   * The system views the shape data at every window redraw by
  2352.     function 0.
  2353.   * The call of subfunction 0 with NULL pointer results in return
  2354.     to the rectangular shape.
  2355.  
  2356. ======================================================================
  2357. ==================== Function 51 - create thread. ====================
  2358. ======================================================================
  2359. Parameters:
  2360.   * eax = 51 - function number
  2361.   * ebx = 1 - unique subfunction
  2362.   * ecx = address of thread entry point (starting eip)
  2363.   * edx = pointer to thread stack (starting esp)
  2364. Returned value:
  2365.   * eax = -1 - error (there is too many threads)
  2366.   * otherwise eax = TID - thread identifier
  2367.     </UL>    
  2368.  
  2369. ======================================================================
  2370. === Function 52, subfunction 0 - get network driver configuration. ===
  2371. ======================================================================
  2372. Parameters:
  2373.   * eax = 52 - function number
  2374.   * ebx = 0 - subfunction number
  2375. Returned value:
  2376.   * eax = configuration dword
  2377. Remarks:
  2378.   * Configuration dword can be set by subfunction 2.
  2379.   * The kernel does not use this variable. The value of this
  2380.     variable and working with it subfunctions 0 and 2 is represented
  2381.     doubtful.
  2382.  
  2383. ======================================================================
  2384. ========= Function 52, subfunction 1 - get local IP-address. =========
  2385. ======================================================================
  2386. Parameters:
  2387.   * eax = 52 - function number
  2388.   * ebx = 1 - subfunction number
  2389. Returned value:
  2390.   * eax = IP-address (4 bytes)
  2391. Remarks:
  2392.   * Local IP-address is set by subfunction 3.
  2393.  
  2394. ======================================================================
  2395. === Function 52, subfunction 2 - set network driver configuration. ===
  2396. ======================================================================
  2397. Parameters:
  2398.   * eax = 52 - function number
  2399.   * ebx = 2 - subfunction number
  2400.   * ecx = configuration dword; if low 7 bits derivate the number 3,
  2401.     function [re-]initializes Ethernet-card, otherwise
  2402.     Ethernet turns off
  2403. Returned value:
  2404.   * if Ethernet-interface is not requested, function returns eax=2,
  2405.     but this can be changed in future kernel versions
  2406.   * if Ethernet-interface is requested, eax=0 means error
  2407.     (absence of Ethernet-card), and nonzero value - success
  2408. Remarks:
  2409.   * Configuration dword can be read by subfunction 0.
  2410.   * The kernel does not use this variable. The value of this
  2411.     variable, subfunction 0 and part of subfunction 2, which set it,
  2412.     is represented doubtful.
  2413.  
  2414. ======================================================================
  2415. ========= Function 52, subfunction 3 - set local IP-address. =========
  2416. ======================================================================
  2417. Parameters:
  2418.   * eax = 52 - function number
  2419.   * ebx = 3 - subfunction number
  2420.   * ecx = IP-address (4 bytes)
  2421. Returned value:
  2422.   * the current implementation returns eax=3, but this can be changed
  2423.     in future versions
  2424. Remarks:
  2425.   * Local IP-address can be get by subfunction 1.
  2426.  
  2427. ======================================================================
  2428. = Function 52, subfunction 6 - add data to the stack of input queue. =
  2429. ======================================================================
  2430. Parameters:
  2431.   * eax = 52 - function number
  2432.   * ebx = 6 - subfunction number
  2433.   * edx = data size
  2434.   * esi = data pointer
  2435. Returned value:
  2436.   * eax = -1 - error
  2437.   * eax = 0 - success
  2438. Remarks:
  2439.   * This function is intended only for slow network drivers
  2440.     (PPP, SLIP).
  2441.   * Data size must not exceed 1500 bytes, though function
  2442.     performs no checks on correctness.
  2443.  
  2444. ======================================================================
  2445.  Function 52, subfunction 8 - read data from the network output queue.
  2446. ======================================================================
  2447. Parameters:
  2448.   * eax = 52 - function number
  2449.   * ebx = 8 - subfunction number
  2450.   * esi = pointer to 1500-byte buffer
  2451. Returned value:
  2452.   * eax = number of read bytes (in the current implementation
  2453.     either 0 = no data or 1500)
  2454.   * data was copied in buffer
  2455. Remarks:
  2456.   * This function is intended only for slow network drivers
  2457.     (PPP, SLIP).
  2458.  
  2459. ======================================================================
  2460. ============ Function 52, subfunction 9 - get gateway IP. ============
  2461. ======================================================================
  2462. Parameters:
  2463.   * eax = 52 - function number
  2464.   * ebx = 9 - subfunction number
  2465. Returned value:
  2466.   * eax = gateway IP (4 bytes)
  2467.  
  2468. ======================================================================
  2469. =========== Function 52, subfunction 10 - get subnet mask. ===========
  2470. ======================================================================
  2471. Parameters:
  2472.   * eax = 52 - function number
  2473.   * ebx = 10 - subfunction number
  2474. Returned value:
  2475.   * eax = subnet mask
  2476.  
  2477. ======================================================================
  2478. ============ Function 52, subfunction 11 - set gateway IP. ===========
  2479. ======================================================================
  2480. Parameters:
  2481.   * eax = 52 - function number
  2482.   * ebx = 11 - subfunction number
  2483.   * ecx = gateway IP (4 bytes)
  2484. Returned value:
  2485.   * the current implementation returns eax=11, but this can be changed
  2486.     in future versions
  2487.  
  2488. ======================================================================
  2489. =========== Function 52, subfunction 12 - set subnet mask. ===========
  2490. ======================================================================
  2491. Parameters:
  2492.   * eax = 52 - function number
  2493.   * ebx = 12 - subfunction number
  2494.   * ecx = subnet mask
  2495. Returned value:
  2496.   * the current implementation returns eax=12, but this can be changed
  2497.     in future versions
  2498.  
  2499. ======================================================================
  2500. ============== Function 52, subfunction 13 - get DNS IP. =============
  2501. ======================================================================
  2502. Parameters:
  2503.   * eax = 52 - function number
  2504.   * ebx = 13 - subfunction number
  2505. Returned value:
  2506.   * eax = DNS IP (4 bytes)
  2507.  
  2508. ======================================================================
  2509. ============== Function 52, subfunction 14 - set DNS IP. =============
  2510. ======================================================================
  2511. Parameters:
  2512.   * eax = 52 - function number
  2513.   * ebx = 14 - subfunction number
  2514.   * ecx = DNS IP (4 bytes)
  2515. Returned value:
  2516.   * the current implementation returns eax=14, but this can be changed
  2517.     in future versions
  2518.  
  2519. ======================================================================
  2520. ======== Function 52, subfunction 15 - get local MAC address. ========
  2521. ======================================================================
  2522. Parameters:
  2523.   * eax = 52 - function number
  2524.   * ebx = 15 - subfunction number
  2525.   * ecx = 0 - read first 4 bytes,
  2526.     ecx = 4 - read last 2 bytes
  2527. Returned value:
  2528.   * for ecx=0: eax = first 4 bytes of MAC address
  2529.   * for ecx=4: ax = last 2 bytes of MAC address,
  2530.                high half of eax is destroyed
  2531.   * for other ecx: eax = -1 indicates an error
  2532.  
  2533. ======================================================================
  2534. ============ Function 53, subfunction 0 - open UDP-socket. ===========
  2535. ======================================================================
  2536. Parameters:
  2537.   * eax = 53 - function number
  2538.   * ebx = 0 - subfunction number
  2539.   * ecx = local port (only low word is taken into account)
  2540.   * edx = remote port (only low word is taken into account)
  2541.   * esi = remote IP
  2542. Returned value:
  2543.   * eax = -1 = 0xFFFFFFFF - error; ebx destroyed
  2544.   * eax = socket handle (some number which unambiguously identifies
  2545.     socket and have sense only for the system) - success;
  2546.     ebx destroyed
  2547.  
  2548. ======================================================================
  2549. =========== Function 53, subfunction 1 - close UDP-socket. ===========
  2550. ======================================================================
  2551. Parameters:
  2552.   * eax = 53 - function number
  2553.   * ebx = 1 - subfunction number
  2554.   * ecx = socket handle
  2555. Returned value:
  2556.   * eax = -1 - incorrect handle
  2557.   * eax = 0 - success
  2558.   * ebx destroyed
  2559. Remarks:
  2560.   * The current implementation does not close automatically all
  2561.     sockets of a thread at termination. In particular, one should not
  2562.     kill a thread with many opened sockets - there will be an outflow
  2563.     of resources.
  2564.   * The current implementation does no checks on correctness
  2565.     (function returns error only if thread tries to close not opened
  2566.     socket with correct handle).
  2567.  
  2568. ======================================================================
  2569. ============== Function 53, subfunction 2 - poll socket. =============
  2570. ======================================================================
  2571. Parameters:
  2572.   * eax = 53 - function number
  2573.   * ebx = 2 - subfunction number
  2574.   * ecx = socket handle
  2575. Returned value:
  2576.   * eax = number of read bytes
  2577.   * ebx destroyed
  2578. Remarks:
  2579.   * There is no checks for correctness.
  2580.  
  2581. ======================================================================
  2582. ========= Function 53, subfunction 3 - read byte from socket. ========
  2583. ======================================================================
  2584. Parameters:
  2585.   * eax = 53 - function number
  2586.   * ebx = 3 - subfunction number
  2587.   * ecx = socket handle
  2588. Returned value:
  2589.   * if there is no read data: eax=0, bl=0,
  2590.     other bytes of ebx are destroyed
  2591.   * if there are read data: eax=number of rest bytes
  2592.     (possibly 0), bl=read byte, other bytes of ebx are destroyed
  2593. Remarks:
  2594.   * There is no checks for correctness.
  2595.  
  2596. ======================================================================
  2597. ========== Function 53, subfunction 4 - write to UDP-socket. =========
  2598. ======================================================================
  2599. Parameters:
  2600.   * eax = 53 - function number
  2601.   * ebx = 4 - subfunction number
  2602.   * ecx = socket handle
  2603.   * edx = number of bytes to write
  2604.   * esi = pointer to data to write
  2605. Returned value:
  2606.   * eax = 0xffffffff - invalid handle
  2607.   * eax = 0xffff - not enough memory
  2608.   * eax = 0 - success
  2609.   * ebx destroyed
  2610. Remarks:
  2611.   * Check on validity of handle is minimal - only not very incorrect
  2612.     not opened handles are eliminated.
  2613.   * Number of bytes to write must not exceed 1500-28, though
  2614.     the appropriate check is not made.
  2615.  
  2616. ======================================================================
  2617. ============ Function 53, subfunction 5 - open TCP-socket. ===========
  2618. ======================================================================
  2619. Parameters:
  2620.   * eax = 53 - function number
  2621.   * ebx = 5 - subfunction number
  2622.   * ecx = local port (only low word is taken into account)
  2623.   * edx = remote port (only low word is taken into account)
  2624.   * esi = remote IP
  2625.   * edi = open mode: SOCKET_PASSIVE=0 or SOCKET_ACTIVE=1
  2626. Returned value:
  2627.   * eax = -1 = 0xFFFFFFFF - error; ebx destroys
  2628.   * eax = socket handle (some number which unambiguously identifies
  2629.     socket and have sense only for the system) - success;
  2630.     ebx destroyed
  2631.  
  2632. ======================================================================
  2633. ========= Function 53, subfunction 6 - get TCP-socket status. ========
  2634. ======================================================================
  2635. Parameters:
  2636.   * eax = 53 - function number
  2637.   * ebx = 6 - subfunction number
  2638.   * ecx = socket handle
  2639. Returned value:
  2640.   * eax = socket status: one of
  2641.   * TCB_LISTEN = 1
  2642.   * TCB_SYN_SENT = 2
  2643.   * TCB_SYN_RECEIVED = 3
  2644.   * TCB_ESTABLISHED = 4
  2645.   * TCB_FIN_WAIT_1 = 5
  2646.   * TCB_FIN_WAIT_2 = 6
  2647.   * TCB_CLOSE_WAIT = 7
  2648.   * TCB_CLOSING = 8
  2649.   * TCB_LAST_ASK = 9
  2650.   * TCB_TIME_WAIT = 10
  2651.   * TCB_CLOSED = 11
  2652.   * ebx destroys
  2653. Remarks:
  2654.   * There is no checks for correctness.
  2655.  
  2656. ======================================================================
  2657. ========== Function 53, subfunction 7 - write to TCP-socket. =========
  2658. ======================================================================
  2659. Parameters:
  2660.   * eax = 53 - function number
  2661.   * ebx = 7 - subfunction number
  2662.   * ecx = socket handle
  2663.   * edx = number of bytes to write
  2664.   * esi = pointer to data to write
  2665. Returned value:
  2666.   * eax = 0xffffffff - error
  2667.   * eax = 0xffff - not enough memory
  2668.   * eax = 0 - success
  2669.   * ebx destroyed
  2670. Remarks:
  2671.   * Check on validity of handle is minimal - only not very incorrect
  2672.     not opened handles are eliminated.
  2673.   * Number of bytes to write must not exceed 1500-40, though
  2674.     the appropriate check is not made.
  2675.  
  2676. ======================================================================
  2677. =========== Function 53, subfunction 8 - close TCP-socket. ===========
  2678. ======================================================================
  2679. Parameters:
  2680.   * eax = 53 - function number
  2681.   * ebx = 8 - subfunction number
  2682.   * ecx = socket handle
  2683. Returned value:
  2684.   * eax = -1 - invalid handle
  2685.   * eax = 0xffff - not enough memory for socket close packet
  2686.   * eax = 0 - success
  2687.   * in many cases eax is destroyed (the result of function 'queue'
  2688.     is returned) - probably this is bug, which will be corrected
  2689.   * ebx destroyed
  2690. Remarks:
  2691.   * The current implementation does not close automatically all
  2692.     sockets of a thread at termination. In particular, one should not
  2693.     kill a thread with many opened sockets - there will be an outflow
  2694.     of resources.
  2695.   * The current implementation does no checks on correctness
  2696.     (function returns error only if thread tries to close not opened
  2697.     socket with correct handle).
  2698.  
  2699. ======================================================================
  2700. === Function 53, subfunction 9 - check whether local port is free. ===
  2701. ======================================================================
  2702. Parameters:
  2703.   * eax = 53 - function number
  2704.   * ebx = 9 - subfunction number
  2705.   * ecx = local port number (low 16 bits are used only)
  2706. Returned value:
  2707.   * eax = 0 - port is used
  2708.   * eax = 1 - port is free
  2709.   * ebx destroyed
  2710.  
  2711. ======================================================================
  2712. ===== Function 53, subfunction 10 - query Ethernet cable status. =====
  2713. ======================================================================
  2714. Parameters:
  2715.   * eax = 53 - function number
  2716.   * ebx = 10 - subfunction number
  2717. Returned value:
  2718.   * al = -1 - a network driver is not loaded or
  2719.               does not support this function
  2720.   * al = 0 - Ethernet cable is unplugged
  2721.   * al = 1 - Ethernet cable is plugged
  2722.   * ebx destroyed
  2723. Remarks:
  2724.   * The current kernel implementation supports this function
  2725.     only for RTL8139 network cards.
  2726.  
  2727. ======================================================================
  2728. ======= Function 53, subfunction 11 - read network stack data. =======
  2729. ======================================================================
  2730. Paramters:
  2731.   * eax = 53 - function number
  2732.   * ebx = 11 - subfunction number
  2733.   * ecx = socket handle
  2734.   * edx = pointer to buffer
  2735.   * esi = number of bytes to read;
  2736.   * esi = 0 - read all data (maximum 4096 bytes)
  2737. Returned value:
  2738.   * eax = number of bytes read
  2739.   * ebx destroyed
  2740. Remakrs:
  2741.   * There is no check on handle correctness.
  2742.  
  2743. ======================================================================
  2744. = Function 53, subfunction 255 - debug information of network driver.
  2745. ======================================================================
  2746. Parameters:
  2747.   * eax = 53 - function number
  2748.   * ebx = 255 - subfunction number
  2749.   * ecx = type of requested information (see below)
  2750. Returned value:
  2751.   * eax = requested information
  2752.   * ebx destroyed
  2753. Possible values for ecx:
  2754.   * 100: length of queue 0 (empty queue)
  2755.   * 101: length of queue 1 (ip-out queue)
  2756.   * 102: length of queue 2 (ip-in queue)
  2757.   * 103: length of queue 3 (net1out queue)
  2758.   * 200: number of items in the ARP table
  2759.   * 201: size of the ARP table (in items) (20 for current version)
  2760.   * 202: read item at edx of the ARP table to the temporary buffer,
  2761.     whence 5 following types take information;
  2762.     in this case eax is not defined
  2763.   * 203: IP-address saved by type 202
  2764.   * 204: high dword of MAC-address saved by type 202
  2765.   * 205: low word of MAC-address saved by type 202
  2766.   * 206: status word saved by type 202
  2767.   * 207: ttl word saved by type 202
  2768.   * 2: total number of received IP-packets
  2769.   * 3: total number of transferred IP-packets
  2770.   * 4: total number of dumped received packets
  2771.   * 5: total number of received ARP-packets
  2772.   * 6: status of packet driver, 0=inactive, nonzero=active
  2773.  
  2774. ======================================================================
  2775. ========== Function 55, subfunction 0 - load data for SB16. ==========
  2776. ======================================================================
  2777. Parameters:
  2778.   * eax = 55 - function number
  2779.   * ebx = 0 - subfunction number
  2780.   * ecx = pointer to data (is copied 64 kilobytes, is used as much as
  2781.     set by subfunction 2)
  2782. Returned value:
  2783.   * function does not return value
  2784. Remarks:
  2785.   * Format and size of data are set by subfunction 2.
  2786.  
  2787. ======================================================================
  2788. ======== Function 55, subfunction 1 - begin play data on SB16. =======
  2789. ======================================================================
  2790. Parameters:
  2791.   * eax = 55 - function number
  2792.   * ebx = 1 - subfunction number
  2793. Returned value:
  2794.   * function does not return value
  2795. Remarks:
  2796.   * Previously data must be loaded by subfunction 0 and
  2797.     their format must be defined by subfunction 2.
  2798.   * Function returns control, when playing of data began; after that
  2799.     play goes independently from application (and does not use
  2800.     processor time at all).
  2801.   * Previously must be defined SB16 base port
  2802.     (by subfunction 4 of function 21) and DMA channel
  2803.     (by subfunction 10 of function 21).
  2804.  
  2805. ======================================================================
  2806. ======== Function 55, subfunction 2 - set format of SB16 data. =======
  2807. ======================================================================
  2808. Parameters:
  2809.   * eax = 55 - function number
  2810.   * ebx = 2 - subfunction number
  2811.   * ecx = 0 - set digit capacity
  2812.     * edx = 1 - 8bit mono
  2813.     * edx = 2 - 8bit stereo
  2814.   * ecx = 1 - set data size
  2815.     * edx = size in bytes
  2816.   * ecx = 2 - set play frequency
  2817.     * edx = frequency
  2818. Returned value:
  2819.   * function does not return value
  2820. Remarks:
  2821.   * When the system boots, it sets following default parameters:
  2822.     digit capacity - 8bit mono, size - 64 Kb, frequency - 44100 Hz.
  2823.     Nevertheless it is recommended to set necessary values obviously
  2824.     as they could be reset by some application.
  2825.  
  2826. ======================================================================
  2827.  Function 55, subfunction 55 - begin to play data on built-in speaker.
  2828. ======================================================================
  2829. Parameters:
  2830.   * eax = 55 - function number
  2831.   * ebx = 55 - subfunction number
  2832.   * esi = pointer to data
  2833. Returned value:
  2834.   * eax = 0 - success
  2835.   * eax = 55 - error (speaker is off or busy)
  2836. Data is an array of items with variable length.
  2837. Format of each item is defined by first byte:
  2838.   * 0 = end of data
  2839.   * 1..0x80 = sets sound duration on 1/100 of second; sound note
  2840.     is defined by immediate value of frequency
  2841.     * following word (2 bytes) contains frequency divider;
  2842.       frequency is defined as 1193180/divider
  2843.   * 0x81 = invalid
  2844.   * 0x82..0xFF = note is defined by octave and number:
  2845.     * duration in 1/100 of second = (first byte)-0x81
  2846.     * there is one more byte;
  2847.     * (second byte)=0xFF - delay
  2848.     * otherwise it looks like a*0x10+b, where b=number of the note in
  2849.       an octave from 1 to 12, a=number of octave (beginning from 0)
  2850. Remarks:
  2851.   * Speaker play can be disabled/enabled by
  2852.     subfunction 8 of function 18.
  2853.   * Function returns control, having informed the system
  2854.     an information on request. Play itself goes independently from
  2855.     the program.
  2856.   * The data must be kept in the memory at least up to the end
  2857.     of play.
  2858.  
  2859. ======================================================================
  2860. ======================= Function 57 - PCI BIOS. ======================
  2861. ======================================================================
  2862. Parameters:
  2863.   * eax = 57 - function number
  2864.   * ebp corresponds to al in PCI BIOS specification
  2865.   * other registers are set according to PCI BIOS specification
  2866. Returned value:
  2867.   * CF is undefined
  2868.   * other registers are set according to PCI BIOS specification
  2869. Remarks:
  2870.   * Many effects of this function can be also achieved with
  2871.     corresponding subfunctions of function 62.
  2872.   * The function calls PCI32 BIOS extension, documented e.g. in
  2873.     http://alpha1.dyns.net/files/PCI/bios21.pdf.
  2874.   * If BIOS does not support this extension, its behavior is emulated
  2875.     (through kernel-mode analogues of subfunctions of function 62).
  2876.  
  2877. ======================================================================
  2878. ================ Function 58 - work with file system. ================
  2879. ======================================================================
  2880. Parameters:
  2881.   * eax = 58
  2882.   * ebx = pointer to the information structure
  2883. Returned value:
  2884.   * eax = 0 - success; otherwise file system error code
  2885.   * some subfunctions return value in other registers too
  2886. General format of the information structure:
  2887.   * +0: dword: subfunction number
  2888.   * +4: dword: number of block
  2889.   * +8: dword: size
  2890.   * +12 = +0xC: dword: pointer to data
  2891.   * +16 = +0x10: dword: pointer to a memory for system operations
  2892.     (4096 bytes)
  2893.   * +20 = +0x14: n db: ASCIIZ-string with the file name
  2894. Specifications - in documentation on the appropriate subfunction.
  2895. Filename is case-insensitive for latin letters, russian letters
  2896. must be capital.
  2897. Format of filename:
  2898. /base/number/dir1/dir2/.../dirn/file,
  2899. where /base/number identifies device, on which file is located:
  2900. one of
  2901.   * /RD/1 = /RAMDISK/1 to access ramdisk
  2902.   * /FD/1 = /FLOPPYDISK/1 to access first floppy drive,
  2903.     /FD/2 = /FLOPPYDISK/2 to access second one
  2904.   * /HD/x = /HARDDISK/x - obsolete variant of access to hard disk
  2905.     (in this case base is defined by subfunction 7 of function 21),
  2906.     x - partition number (beginning from 1)
  2907.   * /HD0/x, /HD1/x, /HD2/x, /HD3/x to access accordingly to devices
  2908.     IDE0 (Primary Master), IDE1 (Primary Slave),
  2909.     IDE2 (Secondary Master), IDE3 (Secondary Slave);
  2910.     x - partition number on the selected hard drive, varies from 1
  2911.     to 255 (on each hard drive the indexing starts from 1)
  2912. Remarks:
  2913.   * In the first two cases it is also possible to use FIRST
  2914.     instead of 1, SECOND instead of 2, but it is not recommended
  2915.     for convenience of transition to the future extensions.
  2916.   * Limitation n<=39 is imposed.
  2917.   * Names of folders and file dir1,...,dirn,file must have the
  2918.     format 8.3: name no more than 8 characters, dot, extension no
  2919.     more than 3 characters. Trailing spaces are ignored, no other
  2920.     spaces is allowed. If name occupies equally 8 characters,
  2921.     dot may be omitted (though it is not recommended to use this
  2922.     feature for convenience of transition to the future extensions).
  2923.   * This function does not support folders on ramdisk.
  2924. Examples:
  2925.   * '/RAMDISK/FIRST/KERNEL.ASM',0
  2926.     '/rd/1/kernel.asm',0
  2927.   * '/HD0/1/kernel.asm',0
  2928.   * '/hd0/1/menuet/pics/tanzania.bmp',0
  2929. Existing subfunctions:
  2930.   * subfunction 0 - read file/folder
  2931.   * subfunction 8 - LBA-read from device
  2932.   * subfunction 15 - get file system information
  2933.  
  2934. ======================================================================
  2935. =========== Function 58, subfunction 0 - read file/folder. ===========
  2936. ======================================================================
  2937. Parameters:
  2938.   * eax = 58
  2939.   * ebx = pointer to the information structure
  2940. Format of the information structure:
  2941.   * +0: dword: 0 = subfunction number
  2942.   * +4: dword: first block to read (beginning from 0)
  2943.   * +8: dword: amount of blocks to read
  2944.   * +12 = +0xC: dword: pointer to buffer for data
  2945.   * +16 = +0x10: dword: pointer to buffer for system operations
  2946.     (4096 bytes)
  2947.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  2948.     given in the general description
  2949. Returned value:
  2950.   * eax = 0 - success, otherwise file system error code
  2951.   * ebx = file size (in bytes) or -1=0xffffffff, if file was not found
  2952. Remarks:
  2953.   * Block size is 512 bytes.
  2954.   * This function is obsolete, for reading files use subfunction 0
  2955.     of function 70, for reading folders - subfunction 1 of
  2956.     function 70.
  2957.   * Function can read contents of a folder. Only FAT file system is
  2958.     supported. The format of FAT-folder is described
  2959.     in any FAT documentation.
  2960.   * Size of a folder is determined by size of FAT clusters chain.
  2961.   * If file was ended before last requested block was read,
  2962.     the function will read as many as it can, and after that return
  2963.     eax=6 (EOF).
  2964.   * Function can read root folders /rd/1,/fd/x,/hd[n]/x, but
  2965.     in the first two cases the current implementation does not follow
  2966.     to the declared rules:
  2967.     for /rd/1:
  2968.     * if one want to read 0 blocks, function considers,
  2969.       that he requested 1;
  2970.     * if one requests more than 14 blocks or starting block is
  2971.       not less than 14, function returns eax=5 (not found) è ebx=-1;
  2972.     * size of ramdisk root folder is 14 blocks,
  2973.       0x1C00=7168 áàéò; but function returns ebx=0
  2974.       (except of the case of previous item);
  2975.     * strangely enough, it is possible to read 14th block (which
  2976.       generally contains a garbage - I remind, the indexing begins
  2977.       from 0);
  2978.     * if some block with the number not less than 14 was requested,
  2979.       function returns eax=6(EOF); otherwise eax=0.
  2980.     For /fd/x:
  2981.     * if the start block is not less than 14, function returns
  2982.       eax=5 (not found) and ebx=0;
  2983.     * note that format of FAT12 allows floppies with the root size
  2984.       more or less than 14 blocks;
  2985.     * check for length is not performed;
  2986.     * if data was successful read, function returns
  2987.       eax=0,ebx=0; otherwise eax=10 (access denied), ebx=-1.
  2988.   * The function handles reading of special folders /,/rd,/fd,/hd[n];
  2989.     but the result does not correspond to expected (on operations with
  2990.     normal files/folders), does not follow the declared rules,
  2991.     may be changed in future versions of the kernel and consequently
  2992.     is not described. To obtain the information about the equipment
  2993.     use subfunction 11 of function 18 or
  2994.     read corresponding folder with subfunction 1 of function 70.
  2995.  
  2996. ======================================================================
  2997. ========= Function 58, subfunction 8 - LBA-read from device. =========
  2998. ======================================================================
  2999. Parameters:
  3000.   * eax = 58 - function number
  3001.   * ebx = pointer to the information structure
  3002. Format of the information structure:
  3003.   * +0: dword: 8 = subfunction number
  3004.   * +4: dword: number of block to read (beginning from 0)
  3005.   * +8: dword: ignored (set to 1)
  3006.   * +12 = +0xC: dword: pointer to buffer for data (512 bytes)
  3007.   * +16 = +0x10: dword: pointer to buffer for system operations
  3008.     (4096 bytes)
  3009.   * +20 = +0x14: ASCIIZ-name of device: case-insensitive, one of
  3010.     /rd/1 = /RamDisk/1, /hd/n = /HardDisk/n,
  3011.     1<=n<=4 - number of device: 1=IDE0, ..., 4=IDE3.
  3012.     Instead of digits it is allowed, though not recommended for
  3013.     convenience of transition to future extensions, to use
  3014.     'first','second','third','fourth'.
  3015. Returned value:
  3016.   * for device name /hd/xxx, where xxx is not in the list above:
  3017.     * eax = ebx = 1
  3018.   * for invalid device name (except for the previous case):
  3019.     * eax = 5
  3020.     * ebx does not change
  3021.   * if LBA-access is disabled by subfunction 11 of function 21:
  3022.     * eax = 2
  3023.     * ebx destroyed
  3024.   * for ramdisk: attempt to read block outside ramdisk
  3025.     (18*2*80 blocks) results in
  3026.     * eax = 3
  3027.     * ebx = 0
  3028.   * for successful read:
  3029.     * eax = ebx = 0
  3030. Remarks:
  3031.   * Block size is 512 bytes; function reads one block.
  3032.   * Do not depend on returned value, it can be changed
  3033.     in future versions.
  3034.   * Function requires that LBA-access to devices is enabled by
  3035.     subfunction 11 of function 21. To check this one can use
  3036.     subfunction 11 of function 26.
  3037.   * LBA-read of floppy is not supported.
  3038.   * Function reads data on physical hard drive; if for any reason
  3039.     data of the concrete partition are required, application must
  3040.     define starting sector of this partition (either directly
  3041.     through MBR, or from the full structure returned by
  3042.     ïîäôóíêöèåé 11 ôóíêöèè 18).
  3043.   * Function does not check error code of hard disk, so request of
  3044.     nonexisting sector reads something (most probably it will be
  3045.     zeroes, but this is defined by device) and this is considered
  3046.     as success (eax=0).
  3047.  
  3048. ======================================================================
  3049. ==== Function 58, subfunction 15 - get information on file system. ===
  3050. ======================================================================
  3051. Parameters:
  3052.   * eax = 58 - function number
  3053.   * ebx = pointer to the information structure
  3054. Format of the information structure:
  3055.   * +0: dword: 15 = subfunction number
  3056.   * +4: dword: ignored
  3057.   * +8: dword: ignored
  3058.   * +12 = +0xC: dword: ignored
  3059.   * +16 = +0x10: dword: ignored
  3060.   * +20 = +0x14: (only second character is checked)
  3061.     /rd=/RAMDISK or /hd=/HARDDISK
  3062. Returned value:
  3063.   * if the second character does not belong to set {'r','R','h','H'}:
  3064.     * eax = 3
  3065.     * ebx = ecx = dword [fileinfo] = 0
  3066.   * for ramdisk:
  3067.     * eax = 0 (success)
  3068.     * ebx = total number of clusters = 2847
  3069.     * ecx = number of free clusters
  3070.     * dword [fileinfo] = cluster size = 512
  3071.   * for hard disk: base and partition are defined by subfunctions
  3072.     7 and 8 of function 21:
  3073.     * eax = 0 (success)
  3074.     * ebx = total number of clusters
  3075.     * ecx = number of free clusters
  3076.     * dword [fileinfo] = cluster size (in bytes)
  3077. Remarks:
  3078.   * Be not surprised to strange layout of 4th returned parameter
  3079.     - when this code was writing, at system calls application got
  3080.     only registers eax,ebx,ecx (from pushad-structure transmitted
  3081.     as argument to the system function). Now it is corrected, so,
  3082.     probably, it is meaningful to return cluster size in edx, while
  3083.     this function is not used yet.
  3084.   * There exists also subfunction 11 of function 18,
  3085.     which returns information on file system. From the full table
  3086.     of disk subsystem it is possible to deduce cluster size (there
  3087.     it is stored in sectors) and total number of clusters
  3088.     for hard disks.
  3089.  
  3090. ======================================================================
  3091. ========== Function 60 - Inter Process Communication (IPC). ==========
  3092. ======================================================================
  3093. IPC is used for message dispatching from one process/thread to
  3094. another. Previously it is necessary to agree how to interpret
  3095. the concrete message.
  3096.  
  3097. ----------- Subfunction 1 - set the area for IPC receiving -----------
  3098. Is called by process-receiver.
  3099. Parameters:
  3100.   * eax = 60 - function number
  3101.   * ebx = 1 - subfunction number
  3102.   * ecx = pointer to the buffer
  3103.   * edx = size of the buffer
  3104. Returned value:
  3105.   * eax = 0 - always success
  3106. Format of IPC-buffer:
  3107.   * +0: dword: if nonzero, buffer is considered locked;
  3108.     lock/unlock the buffer, when you work with it and need that
  3109.     buffer data are not changed from outside (no new messages)
  3110.   * +4: dword: occupied place in the buffer (in bytes)
  3111.   * +8: first message
  3112.   * +8+n: second message
  3113.   * ...
  3114. Format of a message:
  3115.   * +0: dword: PID of sender
  3116.   * +4: dword: message length (not including this header)
  3117.   * +8: n*byte: message data
  3118.  
  3119. ------------------ Subfunction 2 - send IPC message ------------------
  3120. Is called by process-sender.
  3121. Parameters:
  3122.   * eax = 60 - function number
  3123.   * ebx = 2 - subfunction number
  3124.   * ecx = PID of receiver
  3125.   * edx = pointer to the message data
  3126.   * esi = message length (in bytes)
  3127. Returned value:
  3128.   * eax = 0 - success
  3129.   * eax = 1 - the receiver has not defined buffer for IPC messages
  3130.     (can be, still have no time,
  3131.     and can be, this is not right process)
  3132.   * eax = 2 - the receiver has blocked IPC-buffer; try to wait a bit
  3133.   * eax = 3 - overflow of IPC-buffer of the receiver
  3134.   * eax = 4 - process/thread with such PID does not exist
  3135. Remarks:
  3136.   * Immediately after writing of IPC-message to the buffer the system
  3137.     sends to the receiver the event with code 7 (see event codes).
  3138.  
  3139. ======================================================================
  3140. ==== Function 61 - get parameters for the direct graphics access. ====
  3141. ======================================================================
  3142. The data of the graphics screen (the memory area which displays
  3143. screen contents) are accessible to a program directly, without
  3144. any system calls, through the selector gs:
  3145.         mov     eax, [gs:0]
  3146. places in eax the first dword of the buffer, which contains
  3147. information on color of the left upper point (and, possibly, colors
  3148. of several following).
  3149.         mov     [gs:0], eax
  3150. by work in VESA modes with LFB sets color of the left upper point
  3151. (and, possibly, colors of several following).
  3152. To interpret the data of graphics screen program needs to know
  3153. some parameters, returning by this function.
  3154. Remarks:
  3155.   * Graphics parameters changes very seldom at work,
  3156.     namely, only in cases, when user works with the application VRR.
  3157.   * At videomode change the system redraws all windows (event
  3158.     with code 1) and redraws the background (event 5).
  3159.     Same events occur in other cases too, which meet much more often,
  3160.     than videomode change.
  3161.   * By operation in videomodes with LFB the selector gs points to
  3162.     LFB itself, so reading/writing on gs result directly in
  3163.     change of screen contents. By operation in videomodes without
  3164.     LFB gs points to some data area in the kernel, and all functions
  3165.     of screen output fulfil honesty double operation on writing
  3166.     directly to the screen and writing to this buffer. In result
  3167.     at reading contents of this buffer the results correspond to
  3168.     screen contents (with, generally speaking, large color
  3169.     resolution), and writing is ignored.
  3170.     One exception is the mode 320*200, for which main loop of the
  3171.     system thread updates the screen according to mouse movements.
  3172.  
  3173. ------------------------- Screen resolution --------------------------
  3174. Parameters:
  3175.   * eax = 61 - function number
  3176.   * ebx = 1 - subfunction number
  3177. Returned value:
  3178.   * eax = [resolution on x axis]*65536 + [resolution on y axis]
  3179. Remarks:
  3180.   * One can use function 14 paying attention that
  3181.     it returns sizes on 1 pixel less. It is fully equivalent way.
  3182.  
  3183. ---------------------- Number of bits per pixel ----------------------
  3184. Parameters:
  3185.   * eax = 61 - function number
  3186.   * ebx = 2 - subfunction number
  3187. Returned value:
  3188.   * eax = number of bits per pixel (24 or 32)
  3189.  
  3190. -------------------- Number of bytes per scanline --------------------
  3191. Parameters:
  3192.   * eax = 61 - function number
  3193.   * ebx = 3 - subfunction number
  3194. Returned value:
  3195.   * eax = number of bytes occupied by one scanline
  3196.     (horizontal line on the screen)
  3197.  
  3198. ======================================================================
  3199. ===== Function 62, subfunction 0 - get version of PCI-interface. =====
  3200. ======================================================================
  3201. Parameters:
  3202.   * eax = 62 - function number
  3203.   * bl = 0 - subfunction number
  3204. Returned value:
  3205.   * eax = -1 - PCI access is disabled; otherwise
  3206.   * ah.al = version of PCI-interface (ah=version, al=subversion)
  3207.   * high word of eax is zeroed
  3208. Remarks:
  3209.   * Previously low-level access to PCI for applications must be
  3210.     enabled by subfunction 12 of function 21.
  3211.   * If PCI BIOS is not supported, the value of ax is undefined.
  3212.  
  3213. ======================================================================
  3214. ==== Function 62, subfunction 1 - get number of the last PCI-bus. ====
  3215. ======================================================================
  3216. Parameters:
  3217.   * eax = 62 - function number
  3218.   * bl = 1 - subfunction number
  3219. Returned value:
  3220.   * eax = -1 - access to PCI is disabled; otherwise
  3221.   * al = number of the last PCI-bus; other bytes of eax are destroyed
  3222. Remarks:
  3223.   * Previously low-level access to PCI for applications must be
  3224.     enabled by subfunction 12 of function 21.
  3225.   * If PCI BIOS is not supported, the value of ax is undefined.
  3226.  
  3227. ======================================================================
  3228. ===================== Function 62, subfunction 2 =====================
  3229. ===== Get mechanism of addressing to the PCI configuration space. ====
  3230. ======================================================================
  3231. Parameters:
  3232.   * eax = 62 - function number
  3233.   * bl = 2 - subfunction number
  3234. Returned value:
  3235.   * eax = -1 - access to PCI is disabled; otherwise
  3236.   * al = mechanism (1 or 2); other bytes of eax are destroyed
  3237. Remarks:
  3238.   * Previously low-level access to PCI for applications must be
  3239.     enabled by subfunction 12 of function 21.
  3240.   * Addressing mechanism is selected depending on
  3241.     equipment characteristics.
  3242.   * Subfunctions of read and write work automatically
  3243.     with the selected mechanism.
  3244.  
  3245. ======================================================================
  3246. ======== Function 62, subfunctions 4,5,6 - read PCI-register. ========
  3247. ======================================================================
  3248. Parameters:
  3249.   * eax = 62 - function number
  3250.   * bl = 4 - read byte
  3251.   * bl = 5 - read word
  3252.   * bl = 6 - read dword
  3253.   * bh = number of PCI-bus
  3254.   * ch = dddddfff, where ddddd = number of the device on the bus,
  3255.     fff = function number of device
  3256.   * cl = number of register (must be even for bl=5,
  3257.     divisible by 4 for bl=6)
  3258. Returned value:
  3259.   * eax = -1 - error (access to PCI is disabled or parameters
  3260.     are not supported); otherwise
  3261.   * al/ax/eax (depending on requested size) contains the data;
  3262.     the other part of register eax is destroyed
  3263. Remarks:
  3264.   * Previously low-level access to PCI for applications must be
  3265.     enabled by subfunction 12 of function 21.
  3266.   * Access mechanism 2 supports only 16 devices on a bus and ignores
  3267.     function number. To get access mechanism use subfunction 2.
  3268.   * Some registers are standard and exist for all devices, some are
  3269.     defined by the concrete device. The list of registers of the
  3270.     first type can be found e.g. in famous
  3271.     Interrupt List by Ralf Brown
  3272.     (http://www.pobox.com/~ralf/files.html,
  3273.     ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/);
  3274.     registers of the second type must be listed
  3275.     in the device documentation.
  3276.  
  3277. ======================================================================
  3278. ====== Function 62, subfunctions 8,9,10 - write to PCI-register. =====
  3279. ======================================================================
  3280. Parameters:
  3281.   * eax = 62 - function number
  3282.   * bl = 8 - write byte
  3283.   * bl = 9 - write word
  3284.   * bl = 10 - write dword
  3285.   * bh = number of PCI-bus
  3286.   * ch = dddddfff, where ddddd = number of the device on the bus,
  3287.     fff = function number of device
  3288.   * cl = number of register (must be even for bl=9,
  3289.     divisible by 4 for bl=10)
  3290.   * dl/dx/edx (depending on requested size) contatins
  3291.     the data to write
  3292. Returned value:
  3293.   * eax = -1 - error (access to PCI is disabled or parameters
  3294.     are not supported)
  3295.   * eax = 0 - success
  3296. Remarks:
  3297.   * Previously low-level access to PCI for applications must be
  3298.     enabled by subfunction 12 of function 21.
  3299.   * Access mechanism 2 supports only 16 devices on a bus and ignores
  3300.     function number. To get access mechanism use subfunction 2.
  3301.   * Some registers are standard and exist for all devices, some are
  3302.     defined by the concrete device. The list of registers of the
  3303.     first type can be found e.g. in famous Interrupt List by
  3304.     Ralf Brown; registers of the second type must be listed
  3305.     in the device documentation.
  3306.  
  3307. ======================================================================
  3308. ============== Function 63 - work with the debug board. ==============
  3309. ======================================================================
  3310. The debug board is the global system buffer (with the size
  3311. 1024 bytes), to which any program can write (generally speaking,
  3312. arbitrary) data and from which other program can read these data.
  3313. By the agreement written data are text strings interpreted as
  3314. debug messages on a course of program execution. The kernel in
  3315. some situations also writes to the debug board information on
  3316. execution of some functions; by the agreement kernel messages
  3317. begins from the prefix "K : ".
  3318. For view of the debug board the application 'board' was created,
  3319. which reads data from the buffer and displays them in its window.
  3320. 'board' interpretes the sequence of codes 13,10 as newline.
  3321. A character with null code in an end of line is not necessary,
  3322. but also does not prevent.
  3323. Because debugger has been written, the value of the debug board
  3324. has decreased, as debugger allows to inspect completely a course of
  3325. program execution without any efforts from the direction of program
  3326. itself. Nevertheless in some cases the debug board is still useful.
  3327.  
  3328. ----------------------------- Write byte -----------------------------
  3329. Parameters:
  3330.   * eax = 63 - function number
  3331.   * ebx = 1 - subfunction number
  3332.   * cl = data byte
  3333. Returned value:
  3334.   * function does not return value
  3335. Remarks:
  3336.   * Byte is written to the buffer. Buffer size is 512 bytes.
  3337.     At buffer overflow all obtained data are lost.
  3338.   * For output to the debug board of more complicated objects
  3339.     (strings, numbers) it is enough to call this function in cycle.
  3340.     It is possible not to write the appropriate code manually and use
  3341.     file 'debug.inc', which is included into the distributive.
  3342.  
  3343. ----------------------------- Read byte ------------------------------
  3344. Takes away byte from the buffer.
  3345. Parameters:
  3346.   * eax = 63 - function number
  3347.   * ebx = 2 - subfunction number
  3348. Returned value:
  3349.   * eax = ebx = 0 - the buffer is empty
  3350.   * eax = byte, ebx = 1 - byte was successfully read
  3351.  
  3352. ======================================================================
  3353. ============== Function 64 - resize application memory. ==============
  3354. ======================================================================
  3355. Parameters:
  3356.   * eax = 64 - function number
  3357.   * ebx = 1 - unique subfunction
  3358.   * ecx = new memory size
  3359. Returned value:
  3360.   * eax = 0 - success
  3361.   * eax = 1 - not enough memory
  3362. Remarks:
  3363.   * There is another way to dynamically allocate/free memory -
  3364.     subfunctions 11, 12, 13 of function 68.
  3365.   * The function cannot be used together with 68.11, 68.12, 68.13.
  3366.     The function call will be ignored after creation of process heap
  3367.     with function 68.11.
  3368.  
  3369. ======================================================================
  3370. ======== Function 65 - draw image with palette in the window. ========
  3371. ======================================================================
  3372. Parameters:
  3373.   * eax = 65 - function number
  3374.   * ebx = pointer to the image
  3375.   * ecx = [size on axis x]*65536 + [size on axis y]
  3376.   * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
  3377.   * esi = number of bits per pixel, must be 8, 24 or 32
  3378.   * edi = pointer to palette (256 colors 0x00RRGGBB);
  3379.           ignored when esi = 24 and 32
  3380.   * ebp = offset of next row data relative to previous row data
  3381. Returned value:
  3382.   * function does not return value
  3383. Remarks:
  3384.   * Coordinates of the image are coordinates of the upper left corner
  3385.     of the image relative to the window.
  3386.   * Size of the image in bytes is xsize*ysize.
  3387.   * Each byte of image is index in the palette.
  3388.   * If the image uses less than 256 colors, palette size may be
  3389.     less than 256 too.
  3390.   * The call to function 7 is equivalent to call to this function
  3391.     with esi=24, ebp=0.
  3392.  
  3393. ======================================================================
  3394. ================== Function 66 - work with keyboard. =================
  3395. ======================================================================
  3396. The input mode influences results of reading keys by function 2.
  3397. When a program loads, ASCII input mode is set for it.
  3398.  
  3399. -------------- Subfunction 1 - set keyboard input mode. --------------
  3400. Parameters:
  3401.   * eax = 66 - function number
  3402.   * ebx = 1 - subfunction number
  3403.   * ecx = mode:
  3404.     * 0 = normal (ASCII-characters)
  3405.     * 1 = scancodes
  3406. Returned value:
  3407.   * function does not return value
  3408.  
  3409. -------------- Subfunction 2 - get keyboard input mode. --------------
  3410. Parameters:
  3411.   * eax = 66 - function number
  3412.   * ebx = 2 - subfunction number
  3413. Returned value:
  3414.   * eax = current mode
  3415.  
  3416. ------------ Subfunction 3 - get status of control keys. -------------
  3417. Parameters:
  3418.   * eax = 66 - function number
  3419.   * ebx = 3 - subfunction number
  3420. Returned value:
  3421.   * eax = bit mask:
  3422.   * bit 0 (mask 1): left Shift is pressed
  3423.   * bit 1 (mask 2): right Shift is pressed
  3424.   * bit 2 (mask 4): left Ctrl is pressed
  3425.   * bit 3 (mask 8): right Ctrl is pressed
  3426.   * bit 4 (mask 0x10): left Alt is pressed
  3427.   * bit 5 (mask 0x20): right Alt is pressed
  3428.   * bit 6 (mask 0x40): CapsLock is on
  3429.   * bit 7 (mask 0x80): NumLock is on
  3430.   * bit 8 (mask 0x100): ScrollLock is on
  3431.   * other bits are cleared
  3432.  
  3433. -------------- Subfunction 4 - set system-wide hotkey. ---------------
  3434. When hotkey is pressed, the system notifies only those applications,
  3435. which have installed it; the active application (which receives
  3436. all normal input) does not receive such keys.
  3437. The notification consists in sending event with the code 2.
  3438. Reading hotkey is the same as reading normal key - by function 2.
  3439. Parameters:
  3440.   * eax = 66 - function number
  3441.   * ebx = 4 - subfunction number
  3442.   * cl determines key scancode;
  3443.     use cl=0 to give combinations such as Ctrl+Shift
  3444.   * edx = 0xXYZ determines possible states of control keys:
  3445.     * Z (low 4 bits) determines state of LShift and RShift:
  3446.       * 0 = no key must be pressed;
  3447.       * 1 = exactly one key must be pressed;
  3448.       * 2 = both keys must be pressed;
  3449.       * 3 = must be pressed LShift, but not RShift;
  3450.       * 4 = must be pressed RShift, but not LShift
  3451.     * Y - similar for LCtrl and RCtrl;
  3452.     * X - similar for LAlt and RAlt
  3453. Returned value:
  3454.   * eax=0 - success
  3455.   * eax=1 - too mant hotkeys (maximum 256 are allowed)
  3456. Remarks:
  3457.   * Hotkey can work either at pressing or at release. Release
  3458.     scancode of a key is more on 128 than pressing scancode
  3459.     (i.e. high bit is set).
  3460.   * Several applications can set the same combination;
  3461.     all such applications will be informed on pressing
  3462.     such combination.
  3463.  
  3464. -------------- Subfunction 5 - delete installed hotkey. --------------
  3465. Parameters:
  3466.   * eax = 66 - function number
  3467.   * ebx = 5 - subfunction number
  3468.   * cl = scancode of key and edx = 0xXYZ the same as in subfunction 4
  3469. Returned value:
  3470.   * eax = 0 - success
  3471.   * eax = 1 - there is no such hotkey
  3472. Remarks:
  3473.   * When a process/thread terminates, all hotkey installed by it are
  3474.     deleted.
  3475.   * The call to this subfunction does not affect other applications.
  3476.     If other application has defined the same combination, it will
  3477.     still receive notices.
  3478.  
  3479. ======================================================================
  3480. ========= Function 67 - change position/sizes of the window. =========
  3481. ======================================================================
  3482. Parameters:
  3483.   * eax = 67 - function number
  3484.   * ebx = new x-coordinate of the window
  3485.   * ecx = new y-coordinate of the window
  3486.   * edx = new x-size of the window
  3487.   * esi = new y-size of the window
  3488. Returned value:
  3489.   * function does not return value
  3490. Remarks:
  3491.   * The value -1 for a parameter means "do not change"; e.g. to move
  3492.     the window without resizing it is possible to specify edx=esi=-1.
  3493.   * Previously the window must be defined by function 0.
  3494.     It sets initial coordinates and sizes of the window.
  3495.   * Sizes of the window are understood in sense of function 0,
  3496.     that is one pixel less than real sizes.
  3497.   * The function call for maximized windows is simply ignored.
  3498.   * For windows of appropriate styles position and/or sizes can be
  3499.     changed by user; current position and sizes can be obtained by
  3500.     call to function 9.
  3501.   * The function sends to the window redraw event (with the code 1).
  3502.  
  3503. ======================================================================
  3504. ====== Function 68, subfunction 0 - get the task switch counter. =====
  3505. ======================================================================
  3506. Parameters:
  3507.   * eax = 68 - function number
  3508.   * ebx = 0 - subfunction number
  3509. Returned value:
  3510.   * eax = number of task switches from the system booting
  3511.     (modulo 2^32)
  3512.  
  3513. ======================================================================
  3514. ======= Function 68, subfunction 1 - switch to the next thread. ======
  3515. ======================================================================
  3516. The function completes the current time slice allocated to the
  3517. thread and switches to the next. (Which thread in which process
  3518. will be next, is unpredictable). Later, when execution queue
  3519. will reach the current thread, execution will be continued.
  3520. Parameters:
  3521.   * eax = 68 - function number
  3522.   * ebx = 1 - subfunction number
  3523. Returned value:
  3524.   * function does not return value
  3525.  
  3526. ======================================================================
  3527. ============= Function 68, subfunction 2 - cache + rdpmc. ============
  3528. ======================================================================
  3529. Parameters:
  3530.   * eax = 68 - function number
  3531.   * ebx = 2 - subfunction number
  3532.   * ecx = required action:
  3533.     * ecx = 0 - enable instruction 'rdpmc'
  3534.       (ReaD Performance-Monitoring Counters) for applications
  3535.     * ecx = 1 - find out whether cache is disabled/enabled
  3536.     * ecx = 2 - enable cache
  3537.     * ecx = 3 - disable cache
  3538. Returned value:
  3539.   * for ecx=0:
  3540.     * eax = the value of cr4
  3541.   * for ecx=1:
  3542.     * eax = (cr0 and 0x60000000):
  3543.     * eax = 0 - cache is on
  3544.     * eax <> 0 - cache is off
  3545.   * for ecx=2 and ecx=3:
  3546.     * function does not return value
  3547.  
  3548. ======================================================================
  3549. =========== Function 68, subfunction 3 - read MSR-register. ==========
  3550. ======================================================================
  3551. MSR = Model Specific Register; the complete list of MSR-registers
  3552. of a processor is included to the documentation on it (for example,
  3553. IA-32 Intel Architecture Software Developer's Manual,
  3554. Volume 3, Appendix B); each processor family has its own subset
  3555. of the MSR-registers.
  3556. Parameters:
  3557.   * eax = 68 - function number
  3558.   * ebx = 3 - subfunction number
  3559.   * ecx is ignored
  3560.   * edx = MSR address
  3561. Returned value:
  3562.   * ebx:eax = high:low dword of the result
  3563. Remarks:
  3564.   * If ecx contains nonexistent or not implemented for this processor
  3565.     MSR, processor will generate an exception in the kernel, which
  3566.     will kill the thread.
  3567.   * Previously it is necessary to check, whether MSRs are supported
  3568.     as a whole, with the instruction 'cpuid'. Otherwise processor
  3569.     will generate other exception in the kernel, which will anyway
  3570.     kill the thread.
  3571.  
  3572. ======================================================================
  3573. ========= Function 68, subfunction 4 - write to MSR-register. ========
  3574. ======================================================================
  3575. MSR = Model Specific Register; the complete list of MSR-registers
  3576. of a processor is included to the documentation on it (for example,
  3577. IA-32 Intel Architecture Software Developer's Manual,
  3578. Volume 3, Appendix B); each processor family has its own subset
  3579. of the MSR-registers.
  3580. Parameters:
  3581.   * eax = 68 - function number
  3582.   * ebx = 4 - subfunction number
  3583.   * ecx is ignored
  3584.   * edx = MSR address
  3585.   * esi:edi = high:low dword
  3586. Returned value:
  3587.   * function does not return value
  3588. Remarks:
  3589.   * If ecx contains nonexistent or not implemented for this processor
  3590.     MSR, processor will generate an exception in the kernel, which
  3591.     will kill the thread.
  3592.   * Previously it is necessary to check, whether MSRs are supported
  3593.     as a whole, with the instruction 'cpuid'. Otherwise processor
  3594.     will generate other exception in the kernel, which will anyway
  3595.     kill the thread.
  3596.  
  3597. ======================================================================
  3598. ======= Function 68, subfunction 11 - initialize process heap. =======
  3599. ======================================================================
  3600. Parameters:
  3601.   * eax = 68 - function number
  3602.   * ebx = 11 - subfunction number
  3603. Returned value:
  3604.   * eax = 0 - failed
  3605.   * otherwise size of created heap
  3606. Remarks:
  3607.   * The function call initializes heap, from which one can in future
  3608.     allocate and free memory blocks with subfunctions 12 and 13.
  3609.     Heap size is equal to total amount of free application memory.
  3610.   * The second function call from the same process results in
  3611.     returning the size of the existing heap.
  3612.   * After creation of the heap calls to function 64 will be ignored.
  3613.  
  3614. ======================================================================
  3615. ======== Function 68, subfunction 12 - allocate memory block. ========
  3616. ======================================================================
  3617. Parameters:
  3618.   * eax = 68 - function number
  3619.   * ebx = 12 - subfunction number
  3620.   * ecx = required size in bytes
  3621. Returned value:
  3622.   * eax = pointer to the allocated block
  3623. Remarks:
  3624.   * Before this call one must initialize process heap by call to
  3625.     subfunction 11.
  3626.   * The function allocates an integer number of pages (4 Kb) in such
  3627.     way that the real size of allocated block is more than or equal to
  3628.     requested size.
  3629.  
  3630. ======================================================================
  3631. ========== Function 68, subfunction 13 - free memory block. ==========
  3632. ======================================================================
  3633. Parameters:
  3634.   * eax = 68 - function number
  3635.   * ebx = 13 - subfunction number
  3636.   * ecx = pointer to the memory block
  3637. Returned value:
  3638.   * eax = 1 - success
  3639.   * eax = 0 - failed
  3640. Remarks:
  3641.   * The memory block must have been allocated by subfunction 12
  3642.     or subfunction 20.
  3643.  
  3644. ======================================================================
  3645. ======== Function 68, subfunction 14 - wait for driver notify. =======
  3646. ======================================================================
  3647. Parameters:
  3648.   * eax = 68 - function number
  3649.   * ebx = 14 - subfunction number
  3650.   * ecx = pointer to the buffer for information (8 bytes)
  3651. Returned value:
  3652.   * buffer pointed to by ecx contains the following information:
  3653.     * +0: dword: constant EV_INTR = 1
  3654.     * +4: dword: driver data
  3655. Remarks:
  3656.   * The current implementation at wait time uses "heavy" operations
  3657.     of task switch.
  3658.  
  3659. ======================================================================
  3660. ====== Function 68, subfunction 15 - set FPU exception handler. ======
  3661. ======================================================================
  3662. Parameters:
  3663.   * eax = 68 - function number
  3664.   * ebx = 15 - subfunction number
  3665.   * ecx = address of the new exception handler
  3666. Returned value:
  3667.   * eax = address of the old exception handler (0, if it was not set)
  3668.  
  3669. ======================================================================
  3670. ============= Function 68, subfunction 16 - load driver. =============
  3671. ======================================================================
  3672. Parameters:
  3673.   * eax = 68 - function number
  3674.   * ebx = 16 - subfunction number
  3675.   * ecx = pointer to ASCIIZ-string with driver name
  3676. Returned value:
  3677.   * eax = 0 - failed
  3678.   * otherwise eax = driver handle
  3679. Remarks:
  3680.   * If the driver was not loaded yet, it is loaded;
  3681.     if the driver was loaded yet, nothing happens.
  3682.   * Driver name is case-sensitive.
  3683.     Maximum length of the name is 16 characters, including
  3684.     terminating null character, the rest is ignored.
  3685.   * Driver ABC is loaded from file /rd/1/drivers/ABC.obj.
  3686.  
  3687. ======================================================================
  3688. ============ Function 68, subfunction 17 - driver control. ===========
  3689. ======================================================================
  3690. Parameters:
  3691.   * eax = 68 - function number
  3692.   * ebx = 17 - subfunction number
  3693.   * ecx = pointer to the control structure:
  3694.     * +0: dword: handle of driver
  3695.     * +4: dword: code of driver function
  3696.     * +8: dword: pointer to input data
  3697.     * +12 = +0xC: dword: size of input data
  3698.     * +16 = +0x10: dword: pointer to output data
  3699.     * +20 = +0x14: dword: size of output data
  3700. Returned value:
  3701.   * eax = determined by driver
  3702. Remarks:
  3703.   * Function codes and the structure of input/output data
  3704.     are defined by driver.
  3705.   * Previously one must obtain driver handle by subfunction 16.
  3706.  
  3707. ======================================================================
  3708. ====== Function 68, subfunction 18 - set SSE exception handler. ======
  3709. ======================================================================
  3710. Parameters:
  3711.   * eax = 68 - function number
  3712.   * ebx = 15 - subfunction number
  3713.   * ecx = address of the new exception handler
  3714. Returned value:
  3715.   * eax = address of the old exception handler (0, if it was not set)
  3716.  
  3717. ======================================================================
  3718. =============== Function 68, subfunction 19 - load DLL. ==============
  3719. ======================================================================
  3720. Parameters:
  3721.   * eax = 68 - function number
  3722.   * ebx = 19 - subfunction number
  3723.   * ecx = pointer to ASCIIZ-string with the full path to DLL
  3724. Returned value:
  3725.   * eax = 0 - failed
  3726.   * otherwise eax = pointer to DLL export table
  3727. Remarks:
  3728.   * Export table is an array of structures of 2 dword's, terminated
  3729.     by zero. The first dword in structure points to function name,
  3730.     the second dword contains address of function.
  3731.  
  3732. ======================================================================
  3733. ======= Function 68, subfunction 20 - reallocate memory block. =======
  3734. ======================================================================
  3735. Parameters:
  3736.   * eax = 68 - function number
  3737.   * ebx = 20 - subfunction number
  3738.   * ecx = new size in bytes
  3739.   * edx = pointer to already allocated block
  3740. Returned value:
  3741.   * eax = pointer to the reallocated block, 0 = error
  3742. Remarks:
  3743.   * Before this call one must initialize process heap by call to
  3744.     subfunction 11.
  3745.   * The function allocates an integer number of pages (4 Kb) in such
  3746.     way that the real size of allocated block is more than or equal to
  3747.     requested size.
  3748.   * If edx=0, the function call is equivalent to memory allocation
  3749.     with subfunction 12. Otherwise the block at edx
  3750.     must be allocated earlier with subfunction 12 or this subfunction.
  3751.   * If ecx=0, the function frees memory block at edx and returns 0.
  3752.   * The contents of the block are unchanged up to the shorter of
  3753.     the new and old sizes.
  3754.  
  3755. ======================================================================
  3756. ====================== Fucntion 69 - debugging. ======================
  3757. ======================================================================
  3758. A process can load other process as debugged by set of corresponding
  3759. bit by call to subfunction 7 of function 70.
  3760. A process can have only one debugger; one process can debug some
  3761. others. The system notifies debugger on events occuring with
  3762. debugged process. Messages are written to the buffer defined by
  3763. subfunction 0.
  3764. Format of a message:
  3765.   * +0: dword: message code
  3766.   * +4: dword: PID of debugged process
  3767.   * +8: there can be additional data depending on message code
  3768. Message codes:
  3769.   * 1 = exception
  3770.     * in addition dword-number of the exception is given
  3771.     * process is suspended
  3772.   * 2 = process has terminated
  3773.     * comes at any termination: both through the system function -1,
  3774.       and at "murder" by any other process (including debugger itself)
  3775.   * 3 = debug exception int 1 = #DB
  3776.     * in addition dword-image of the register DR6 is given:
  3777.       * bits 0-3: condition of the corresponding breakpoint (set by
  3778.         subfunction 9) is satisfied
  3779.       * áèò 14: exception has occured because of the trace mode
  3780.         (flag TF is set TF)
  3781.     * process is suspended
  3782. When debugger terminates, all debugged processes are killed.
  3783. If debugger does not want this, it must previously detach by
  3784. subfunction 3.
  3785.  
  3786. All subfunctions except 4 and 5 are applicable only to
  3787. processes/threads started from the current by function 70
  3788. with set debugging flag.
  3789. Debugging of multithreaded programs is not supported yet.
  3790. The full list of subfunctions:
  3791.   * subfunction 0 - define data area for debug messages
  3792.   * subfunction 1 - get contents of registers of debugged thread
  3793.   * subfunction 2 - set contents of registers of debugged thread
  3794.   * subfunction 3 - detach from debugged process
  3795.   * subfunction 4 - suspend debugged thread
  3796.   * subfunction 5 - resume debugged thread
  3797.   * subfunction 6 - read from the memory of debugged process
  3798.   * subfunction 7 - write to the memory of debugged process
  3799.   * subfunction 8 - terminate debugged thread
  3800.   * subfunction 9 - set/clear hardware breakpoint
  3801.  
  3802. ======================================================================
  3803. = Function 69, subfunction 0 - define data area fror debug messages. =
  3804. ======================================================================
  3805. Parameters:
  3806.   * eax = 69 - function number
  3807.   * ebx = 0 - subfunction number
  3808.   * ecx = pointer
  3809. Format of data area:
  3810.   * +0: dword: N = buffer size (not including this header)
  3811.   * +4: dword: occupied place
  3812.   * +8: N*byte: buffer
  3813. Returned value:
  3814.   * function does not return value
  3815. Remarks:
  3816.   * If the size field is negative, the buffer is considered locked
  3817.     and at arrival of new message the system will wait.
  3818.     For synchronization frame all work with the buffer by operations
  3819.     lock/unlock
  3820.         neg     [bufsize]
  3821.   * Data in the buffer are considered as array of items with variable
  3822.     length - messages. Format of a message is explained in
  3823.     general description.
  3824.  
  3825. ======================================================================
  3826. ===================== Function 69, subfunction 1 =====================
  3827. ============ Get contents of registers of debugged thread. ===========
  3828. ======================================================================
  3829. Parameters:
  3830.   * eax = 69 - function number
  3831.   * ebx = 1 - subfunction number
  3832.   * ecx = thread identifier
  3833.   * edx = size of context structure, must be 0x28=40 bytes
  3834.   * esi = pointer to context structure
  3835. Returned value:
  3836.   * function does not return value
  3837. Format of context structure: (FPU is not supported yet)
  3838.   * +0: dword: eip
  3839.   * +4: dword: eflags
  3840.   * +8: dword: eax
  3841.   * +12 = +0xC: dword: ecx
  3842.   * +16 = +0x10: dword: edx
  3843.   * +20 = +0x14: dword: ebx
  3844.   * +24 = +0x18: dword: esp
  3845.   * +28 = +0x1C: dword: ebp
  3846.   * +32 = +0x20: dword: esi
  3847.   * +36 = +0x24: dword: edi
  3848. Remarks:
  3849.   * If the thread executes code of ring-0, the function returns
  3850.     contents of registers of ring-3.
  3851.   * Process must be loaded for debugging (as is shown in
  3852.     general description).
  3853.  
  3854. ======================================================================
  3855. ===================== Function 69, subfunction 2 =====================
  3856. ============ Set contents of registers of debugged thread. ===========
  3857. ======================================================================
  3858. Parameters:
  3859.   * eax = 69 - function number
  3860.   * ebx = 2 - subfunction number
  3861.   * ecx = thread identifier
  3862.   * edx = size of context structure, must be 0x28=40 bytes
  3863. Returned value:
  3864.   * function does not return value
  3865. Format of context structure is shown in the description of
  3866. subfunction 1.
  3867. Remarks:
  3868.   * If the thread executes code of ring-0, the function returns
  3869.     contents of registers of ring-3.
  3870.   * Process must be loaded for debugging (as is shown in
  3871.     general description).
  3872.  
  3873. ======================================================================
  3874. ===== Function 69, subfunction 3 - detach from debugged process. =====
  3875. ======================================================================
  3876. Parameters:
  3877.   * eax = 69 - function number
  3878.   * ebx = 3 - subfunction number
  3879.   * ecx = identifier
  3880. Returned value:
  3881.   * function does not return value
  3882. Remarks:
  3883.   * If the process was suspended, it resumes execution.
  3884.  
  3885. ======================================================================
  3886. ============= Function 69, subfunction 4 - suspend thread. ===========
  3887. ======================================================================
  3888. Parameters:
  3889.   * eax = 69 - function number
  3890.   * ebx = 4 - subfunction number
  3891.   * ecx = thread identifier
  3892. Returned value:
  3893.   * function does not return value
  3894.  
  3895. ======================================================================
  3896. ============= Function 69, subfunction 5 - resume thread. ============
  3897. ======================================================================
  3898. Parameters:
  3899.   * eax = 69 - function number
  3900.   * ebx = 5 - subfunction number
  3901.   * ecx = thread identifier
  3902. Returned value:
  3903.   * function does not return value
  3904.  
  3905. ======================================================================
  3906. = Fucntion 69, subfunction 6 - read from memory of debugged process. =
  3907. ======================================================================
  3908. Parameters:
  3909.   * eax = 69 - function number
  3910.   * ebx = 6 - subfunction number
  3911.   * ecx = identifier
  3912.   * edx = number of bytes to read
  3913.   * esi = address in the memory of debugged process
  3914.   * edi = pointer to buffer for data
  3915. Returned value:
  3916.   * eax = -1 at an error (invalid PID or buffer)
  3917.   * otherwise eax = number of read bytes (possibly, 0,
  3918.     if esi is too large)
  3919. Remarks:
  3920.   * Process must be loaded for debugging (as is shown in
  3921.     general description).
  3922.  
  3923. ======================================================================
  3924. == Function 69, subfunction 7 - write to memory of debugged process. =
  3925. ======================================================================
  3926. Parameters:
  3927.   * eax = 69 - function number
  3928.   * ebx = 7 - subfunction number
  3929.   * ecx = identifier
  3930.   * edx = number of bytes to write
  3931.   * esi = address of memory in debugged process
  3932.   * edi = pointer to data
  3933. Returned value:
  3934.   * eax = -1 at an error (invalid PID or buffer)
  3935.   * otherwise eax = number of written bytes (possibly, 0,
  3936.     if esi is too large)
  3937. Remarks:
  3938.   * Process must be loaded for debugging (as is shown in
  3939.     general description).
  3940.  
  3941. ======================================================================
  3942. ======= Function 69, subfunction 8 - terminate debugged thread. ======
  3943. ======================================================================
  3944. Parameters:
  3945.   * eax = 69 - function number
  3946.   * ebx = 8 - subfunction number
  3947.   * ecx = identifier
  3948. Returned value:
  3949.   * function does not return value
  3950. Remarks:
  3951.   * Process must be loaded for debugging (as is shown in
  3952.     general description).
  3953.   * The function is similar to subfunction 2 of function 18
  3954.     with two differences: it requires first remark and
  3955.     accepts PID rather than slot number.
  3956.  
  3957. ======================================================================
  3958. ===== Function 69, subfunction 9 - set/clear hardware breakpoint. ====
  3959. ======================================================================
  3960. Parameters:
  3961.   * eax = 69 - function number
  3962.   * ebx = 9 - subfunction number
  3963.   * ecx = thread identifier
  3964.   * dl = index of breakpoint, from 0 to 3 inclusively
  3965.   * dh = flags:
  3966.     * if high bit is cleared - set breakpoint:
  3967.       * bits 0-1 - condition:
  3968.         * 00 = breakpoint on execution
  3969.         * 01 = breakpoint on read
  3970.         * 11 = breakpoint on read/write
  3971.       * bits 2-3 - length; for breakpoints on exception it must be
  3972.         00, otherwise one of
  3973.         * 00 = byte
  3974.         * 01 = word
  3975.         * 11 = dword
  3976.       * esi = breakpoint address; must be aligned according to
  3977.         the length (i.e. must be even for word breakpoints,
  3978.         divisible by 4 for dword)
  3979.     * if high bit is set - clear breakpoint
  3980. Returned value:
  3981.   * eax = 0 - success
  3982.   * eax = 1 - error in the input data
  3983.   * eax = 2 - (reserved, is never returned in the current
  3984.     implementation) a global breakpoint with that index is already set
  3985. Remarks:
  3986.   * Process must be loaded for debugging (as is shown in
  3987.     general description).
  3988.   * Hardware breakpoints are implemented through DRx-registers of
  3989.     the processor, all limitations results from this.
  3990.   * The function can reinstall the breakpoint, previously set
  3991.     by it (and it does not inform on this).
  3992.     Carry on the list of set breakpoints in the debugger.
  3993.   * Breakpoints generate debug exception #DB, on which the system
  3994.     notifies debugger.
  3995.   * Breakpoints on write and read/write act after
  3996.     execution of the caused it instruction.
  3997.  
  3998. ======================================================================
  3999. ==== Function 70 - work with file system with long names support. ====
  4000. ======================================================================
  4001. Parameters:
  4002.   * eax = 70
  4003.   * ebx = pointer to the information structure
  4004. Returned value:
  4005.   * eax = 0 - success; otherwise file system error code
  4006.   * some subfunctions return value in other registers too
  4007. General format of the information structure:
  4008.   * +0: dword: subfunction number
  4009.   * +4: dword: file offset
  4010.   * +8: dword: high dword of offset (must be 0) or flags field
  4011.   * +12 = +0xC: dword: size
  4012.   * +16 = +0x10: dword: pointer to data
  4013.   * +20 = +0x14: n db: ASCIIZ-string with the filename
  4014.     or
  4015.   * +20 = +0x14: db 0
  4016.   * +21 = +0x15: dd pointer to ASCIIZ-string with the filename
  4017. Specifications - in documentation on the appropriate subfunction.
  4018. Filename is case-insensitive. Russian letters must be written in
  4019. the encoding cp866 (DOS).
  4020. Format of filename:
  4021. /base/number/dir1/dir2/.../dirn/file,
  4022. where /base/number identifies device, on which file is located:
  4023. one of
  4024.   * /RD/1 = /RAMDISK/1 to access ramdisk
  4025.   * /FD/1 = /FLOPPYDISK/1 to access first floppy drive,
  4026.     /FD/2 = /FLOPPYDISK/2 to access second one
  4027.   * /HD0/x, /HD1/x, /HD2/x, /HD3/x to access accordingly to devices
  4028.     IDE0 (Primary Master), IDE1 (Primary Slave),
  4029.     IDE2 (Secondary Master), IDE3 (Secondary Slave);
  4030.     x - partition number on the selected hard drive, varies from 1
  4031.     to 255 (on each hard drive the indexing starts from 1)
  4032.   * /CD0/1, /CD1/1, /CD2/1, /CD3/1 to access accordingly to
  4033.     CD on IDE0 (Primary Master), IDE1 (Primary Slave),
  4034.     IDE2 (Secondary Master), IDE3 (Secondary Slave)
  4035.   * /SYS means system folder; with the usual boot (from floppy)
  4036.     is equivalent to /RD/1
  4037. Examples:
  4038.   * '/rd/1/kernel.asm',0
  4039.   * '/HD0/1/kernel.asm',0
  4040.   * '/hd0/2/menuet/pics/tanzania.bmp',0
  4041.   * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0
  4042.   * '/sys/MySuperApp.ini',0
  4043. Available subfunctions:
  4044.   * subfunction 0 - read file
  4045.   * subfunction 1 - read folder
  4046.   * subfunction 2 - create/rewrite file
  4047.   * subfunction 3 - write to existing file
  4048.   * subfunction 4 - set file size
  4049.   * subfunction 5 - get attributes of file/folder
  4050.   * subfunction 6 - set attributes of file/folder
  4051.   * subfunction 7 - start application
  4052.   * subfunction 8 - delete file/folder
  4053.   * subfunction 9 - create folder
  4054. For CD-drives due to hardware limitations only subfunctions
  4055. 0,1,5 and 7 are available, other subfunctions return error
  4056. with code 2.
  4057. At the first call of subfunctions 0,1,5,7 to ATAPI devices
  4058. (CD and DVD) the manual control of tray is locked due to caching
  4059. drive data. Unlocking is made when subfunction 4 of function 24
  4060. is called for corresponding device.
  4061.  
  4062. ======================================================================
  4063. === Function 70, subfunction 0 - read file with long names support. ==
  4064. ======================================================================
  4065. Parameters:
  4066.   * eax = 70 - function number
  4067.   * ebx = pointer to the information structure
  4068. Format of the information structure:
  4069.   * +0: dword: 0 = subfunction number
  4070.   * +4: dword: file offset (in bytes)
  4071.   * +8: dword: 0 (reserved for high dword of offset)
  4072.   * +12 = +0xC: dword: number of bytes to read
  4073.   * +16 = +0x10: dword: pointer to buffer for data
  4074.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4075.     given in the general description
  4076.     or
  4077.   * +20 = +0x14: db 0
  4078.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4079. Returned value:
  4080.   * eax = 0 - success, otherwise file system error code
  4081.   * ebx = number of read bytes or -1=0xffffffff if file was not found
  4082. Remarks:
  4083.   * If file was ended before last requested block was read,
  4084.     the function will read as many as it can, and after that return
  4085.     eax=6 (EOF).
  4086.   * The function does not allow to read folder (returns eax=10,
  4087.     access denied).
  4088.  
  4089. ======================================================================
  4090. == Function 70, subfunction 1 - read folder with long names support. =
  4091. ======================================================================
  4092. Parameters:
  4093.   * eax = 70 - function number
  4094.   * ebx = pointer to the information structure
  4095. Format of the information structure:
  4096.   * +0: dword: 1 = subfunction number
  4097.   * +4: dword: index of starting block (beginning from 0)
  4098.   * +8: dword: flags field:
  4099.     * bit 0 (mask 1): in what format to return names,
  4100.       0=ANSI, 1=UNICODE
  4101.     * other bits are reserved and must be set to 0 for the future
  4102.       compatibility
  4103.   * +12 = +0xC: dword: number of blocks to read
  4104.   * +16 = +0x10: dword: pointer to buffer for data, buffer size
  4105.     must be not less than 32 + [+12]*560 bytes
  4106.   * +20 = +0x14: ASCIIZ-name of folder, the rules of names forming are
  4107.     given in the general description
  4108.     or
  4109.   * +20 = +0x14: db 0
  4110.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4111. Returned value:
  4112.   * eax = 0 - success, otherwise file system error code
  4113.   * ebx = number of files, information on which was written to
  4114.     the buffer, or -1=0xffffffff, if folder was not found
  4115. Structure of the buffer:
  4116.   * +0: 32*byte: header
  4117.   * +32 = +0x20: n1*byte: block with information on file 1
  4118.   * +32+n1: n2*byte: block with information on file 2
  4119.   * ...
  4120. Structure of header:
  4121.   * +0: dword: version of structure (current is 1)
  4122.   * +4: dword: number of placed blocks; is not greater than requested
  4123.     in the field +12 of information structure; can be less, if
  4124.     there are no more files in folder (the same as in ebx)
  4125.   * +8: dword: total number of files in folder
  4126.   * +12 = +0xC: 20*byte: reserved (zeroed)
  4127. Structure of block of data for folder entry (BDFE):
  4128.   * +0: dword: attributes of file:
  4129.     * bit 0 (mask 1): file is read-only
  4130.     * bit 1 (mask 2): file is hidden
  4131.     * bit 2 (mask 4): file is system
  4132.     * bit 3 (mask 8): this is not a file but volume label
  4133.       (for one partition meets no more than once and
  4134.       only in root folder)
  4135.     * bit 4 (mask 0x10): this is a folder
  4136.     * bit 5 (mask 0x20): file was not archived - many archivation
  4137.       programs have an option to archive only files with this bit set,
  4138.       and after archiving this bit is cleared - it can be useful
  4139.       for automatically creating of backup-archives as at writing
  4140.       this bit is usually set
  4141.   * +4: byte: type of name data:
  4142.     (coincides with bit 0 of flags in the information structure)
  4143.     * 0 = ASCII = 1-byte representation of each character
  4144.     * 1 = UNICODE = 2-byte representation of each character
  4145.   * +5: 3*byte: reserved (zero)
  4146.   * +8: 4*byte: time of file creation
  4147.   * +12 = +0xC: 4*byte: date of file creation
  4148.   * +16 = +0x10: 4*byte: time of last access (read or write)
  4149.   * +20 = +0x14: 4*byte: date of last access
  4150.   * +24 = +0x18: 4*byte: time of last modification
  4151.   * +28 = +0x1C: 4*byte: date of last modification
  4152.   * +32 = +0x20: qword: file size in bytes (up to 16777216 Tb)
  4153.   * +40 = +0x28: name
  4154.     * for ASCII format: maximum length is 263 characters
  4155.       (263 bytes), byte after the name has value 0
  4156.     * for UNICODE format: maximum length is 259 characters
  4157.       (518 bytes), 2 bytes after the name have value 0
  4158. Time format:
  4159.   * +0: byte: seconds
  4160.   * +1: byte: minutes
  4161.   * +2: byte: hours
  4162.   * +3: byte: reserved (0)
  4163.   * for example, 23.59.59 is written as (in hex) 3B 3B 17 00
  4164. Date format:
  4165.   * +0: byte: day
  4166.   * +1: byte: month
  4167.   * +2: word: year
  4168.   * for example, 25.11.1979 is written as (in hex) 19 0B BB 07
  4169. Remarks:
  4170.   * If BDFE contains ASCII name, the length of BDFE is 304 bytes,
  4171.     if UNICODE name - 560 bytes. Value of length is aligned
  4172.     on 16-byte bound (to accelerate processing in CPU cache).
  4173.   * First character after a name is zero (ASCIIZ-string). The further
  4174.     data contain garbage.
  4175.   * If files in folder were ended before requested number was read,
  4176.     the function will read as many as it can, and after that return
  4177.     eax=6 (EOF).
  4178.   * Any folder on the disk, except for root, contains two special
  4179.     entries "." and "..", identifying accordingly the folder itself
  4180.     and the parent folder.
  4181.   * The function allows also to read virtual folders "/", "/rd",
  4182.     "/fd", "/hd[n]", thus attributes of subfolders are set to 0x10,
  4183.     and times and dates are zeroed. An alternative way to get the
  4184.     equipment information - subfunction 11 of function 18.
  4185.  
  4186. ======================================================================
  4187. ===================== Function 70, subfunction 2 =====================
  4188. ============ Create/rewrite file with long names support. ============
  4189. ======================================================================
  4190. Parameters:
  4191.   * eax = 70 - function number
  4192.   * ebx = pointer to the information structure
  4193. Format of the information structure:
  4194.   * +0: dword: 2 = subfunction number
  4195.   * +4: dword: 0 (reserved)
  4196.   * +8: dword: 0 (reserved)
  4197.   * +12 = +0xC: dword: number of bytes to read
  4198.   * +16 = +0x10: dword: pointer to data
  4199.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4200.     given in the general description
  4201.     or
  4202.   * +20 = +0x14: db 0
  4203.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4204. Returned value:
  4205.   * eax = 0 - success, otherwise file system error code
  4206.   * ebx = number of written bytes (possibly 0)
  4207. Remarks:
  4208.   * If a file with given name did not exist, it is created;
  4209.     if it existed, it is rewritten.
  4210.   * If there is not enough free space on disk, the function will
  4211.     write as many as can and then return error code 8.
  4212.   * The function is not supported for CD (returns error code 2).
  4213.  
  4214. ======================================================================
  4215. ===================== Function 70, subfunction 3 =====================
  4216. =========== Write to existing file with long names support. ==========
  4217. ======================================================================
  4218. Parameters:
  4219.   * eax = 70 - function number
  4220.   * ebx = pointer to the information structure
  4221. Format of the information structure:
  4222.   * +0: dword: 3 = subfunction number
  4223.   * +4: dword: file offset (in bytes)
  4224.   * +8: dword: high dword of offset (must be 0 for FAT)
  4225.   * +12 = +0xC: dword: number of bytes to write
  4226.   * +16 = +0x10: dword: pointer to data
  4227.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4228.     given in the general description
  4229.     or
  4230.   * +20 = +0x14: db 0
  4231.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4232. Returned value:
  4233.   * eax = 0 - success, otherwise file system error code
  4234.   * ebx = number of written bytes (possibly 0)
  4235. Remarks:
  4236.   * The file must already exist, otherwise function returns eax=5.
  4237.   * The only result of write 0 bytes is update in the file attributes
  4238.     date/time of modification and access to the current date/time.
  4239.   * If beginning and/or ending position is greater than file size
  4240.     (except for the previous case), the file is expanded to needed
  4241.     size with zero characters.
  4242.   * The function is not supported for CD (returns error code 2).
  4243.  
  4244. ======================================================================
  4245. ============ Function 70, subfunction 4 - set end of file. ===========
  4246. ======================================================================
  4247. Parameters:
  4248.   * eax = 70 - function number
  4249.   * ebx = pointer to the information structure
  4250. Format of the information structure:
  4251.   * +0: dword: 4 = subfunction number
  4252.   * +4: dword: low dword of new file size
  4253.   * +8: dword: high dword of new file size (must be 0 for FAT)
  4254.   * +12 = +0xC: dword: 0 (reserved)
  4255.   * +16 = +0x10: dword: 0 (reserved)
  4256.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4257.     given in the general description
  4258.     or
  4259.   * +20 = +0x14: db 0
  4260.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4261. Returned value:
  4262.   * eax = 0 - success, otherwise file system error code
  4263.   * ebx destroyed
  4264. Remarks:
  4265.   * If the new file size is less than old one, file is truncated.
  4266.     If the new size is greater than old one, file is expanded with
  4267.     characters with code 0. If the new size is equal to old one,
  4268.     the only result of call is set date/time of modification and
  4269.     access to the current date/time.
  4270.   * If there is not enough free space on disk for expansion, the
  4271.     function will expand to maximum possible size and then return
  4272.     error code 8.
  4273.   * The function is not supported for CD (returns error code 2).
  4274.  
  4275. ======================================================================
  4276. ==== Function 70, subfunction 5 - get information on file/folder. ====
  4277. ======================================================================
  4278. Parameters:
  4279.   * eax = 70 - function number
  4280.   * ebx = pointer to the information structure
  4281. Format of the information structure:
  4282.   * +0: dword: 5 = subfunction number
  4283.   * +4: dword: 0 (reserved)
  4284.   * +8: dword: 0 (reserved)
  4285.   * +12 = +0xC: dword: 0 (reserved)
  4286.   * +16 = +0x10: dword: pointer to buffer for data (40 bytes)
  4287.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4288.     given in the general description
  4289.     or
  4290.   * +20 = +0x14: db 0
  4291.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4292. Returned value:
  4293.   * eax = 0 - success, otherwise file system error code
  4294.   * ebx destroyed
  4295. Information on file is returned in the BDFE format (block of data
  4296. for folder entry), explained in the description of
  4297. subfunction 1, but without filename
  4298. (i.e. only first 40 = 0x28 bytes).
  4299. Remarks:
  4300.   * The function does not support virtual folders such as /, /rd and
  4301.     root folders like /rd/1.
  4302.  
  4303. ======================================================================
  4304. ===== Function 70, subfunction 6 - set attributes of file/folder. ====
  4305. ======================================================================
  4306. Parameters:
  4307.   * eax = 70 - function number
  4308.   * ebx = pointer to the information structure
  4309. Format of the information structure:
  4310.   * +0: dword: 6 = subfunction number
  4311.   * +4: dword: 0 (reserved)
  4312.   * +8: dword: 0 (reserved)
  4313.   * +12 = +0xC: dword: 0 (reserved)
  4314.   * +16 = +0x10: dword: pointer to buffer with attributes (32 bytes)
  4315.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4316.     given in the general description
  4317.     or
  4318.   * +20 = +0x14: db 0
  4319.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4320. Returned value:
  4321.   * eax = 0 - success, otherwise file system error code
  4322.   * ebx destroyed
  4323. File attributes are first 32 bytes in BDFE (block of data
  4324. for folder entry), explained in the description of subfunction 1
  4325. (that is, without name and size of file). Attribute
  4326. file/folder/volume label (bits 3,4 in dword +0) is not changed.
  4327. Byte +4 (name format) is ignored.
  4328. Remarks:
  4329.   * The function does not support virtual folders such as /, /rd and
  4330.     root folders like /rd/1.
  4331.   * The function is not supported for CD (returns error code 2).
  4332.  
  4333. ======================================================================
  4334. =========== Function 70, subfunction 7 - start application. ==========
  4335. ======================================================================
  4336. Parameters:
  4337.   * eax = 70 - function number
  4338.   * ebx = pointer to the information structure
  4339. Format of the information structure:
  4340.   * +0: dword: 7 = subfunction number
  4341.   * +4: dword: flags field:
  4342.     * áèò 0: start process as debugged
  4343.     * other bits are reserved and must be set to 0
  4344.   * +8: dword: 0 or pointer to ASCIIZ-string with parameters
  4345.   * +12 = +0xC: dword: 0 (reserved)
  4346.   * +16 = +0x10: dword: 0 (reserved)
  4347.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4348.     given in the general description
  4349.     or
  4350.   * +20 = +0x14: db 0
  4351.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4352. Returned value:
  4353.   * eax > 0 - program is loaded, eax contains PID
  4354.   * eax < 0 - an error has occured, -eax contains
  4355.     file system error code
  4356.   * ebx destroyed
  4357. Remarks:
  4358.   * Command line must be terminated by the character with the code 0
  4359.     (ASCIIZ-string); function takes into account either all characters
  4360.     up to terminating zero inclusively or first 256 character
  4361.     regarding what is less.
  4362.   * If the process is started as debugged, it is created in
  4363.     the suspended state; to run use subfunction 5 of function 69.
  4364.  
  4365. ======================================================================
  4366. ========== Function 70, subfunction 8 - delete file/folder. ==========
  4367. ======================================================================
  4368. Parameters:
  4369.   * eax = 70 - function number
  4370.   * ebx = pointer to the information structure
  4371. Format of the information structure:
  4372.   * +0: dword: 8 = subfunction number
  4373.   * +4: dword: 0 (reserved)
  4374.   * +8: dword: 0 (reserved)
  4375.   * +12 = +0xC: dword: 0 (reserved)
  4376.   * +16 = +0x10: dword: 0 (reserved)
  4377.   * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
  4378.     given in the general description
  4379.     or
  4380.   * +20 = +0x14: db 0
  4381.   * +21 = +0x15: dd pointer to ASCIIZ-string with file name
  4382. Returned value:
  4383.   * eax = 0 - success, otherwise file system error code
  4384.   * ebx destroyed
  4385. Remarks:
  4386.   * The function is not supported for CD (returns error code 2).
  4387.   * The function can delete only empty folders (attempt to delete
  4388.     nonempty folder results in error with code 10, "access denied").
  4389.  
  4390. ======================================================================
  4391. ============= Function 70, subfunction 9 - create folder. ============
  4392. ======================================================================
  4393. Parameters:
  4394.   * eax = 70 - function number
  4395.   * ebx = pointer to the information structure
  4396. Format of the information structure:
  4397.   * +0: dword: 9 = subfunction number
  4398.   * +4: dword: 0 (reserved)
  4399.   * +8: dword: 0 (reserved)
  4400.   * +12 = +0xC: dword: 0 (reserved)
  4401.   * +16 = +0x10: dword: 0 (reserved)
  4402.   * +20 = +0x14: ASCIIZ-name of folder, the rules of names forming are
  4403.     given in the general description
  4404.     or
  4405.   * +20 = +0x14: db 0
  4406.   * +21 = +0x15: dd pointer to ASCIIZ-string with folder name
  4407. Returned value:
  4408.   * eax = 0 - success, otherwise file system error code
  4409.   * ebx destroyed
  4410. Remarks:
  4411.   * The function is not supported for CD (returns error code 2).
  4412.   * The parent folder must already exist.
  4413.   * If target folder already exists, function returns success (eax=0).
  4414.  
  4415. ======================================================================
  4416. ========== Function 71, subfunction 1 - set window caption. ==========
  4417. ======================================================================
  4418. Parameters:
  4419.   * eax = 71 - function number
  4420.   * ebx = 1 - subfunction number
  4421.   * ecx = pointer to caption string
  4422. Returned value:
  4423.   * function does not return value
  4424. Remarks:
  4425.   * String must be in the ASCIIZ-format. Disregarding real string
  4426.     length, no more than 255 characters are drawn.
  4427.   * Pass NULL in ecx to remove caption.
  4428.  
  4429. ======================================================================
  4430. =============== Function 72 - send message to a window. ==============
  4431. ======================================================================
  4432.  
  4433. - Subfunction 1 - send message with parameter to the active window. --
  4434. Parameters:
  4435.   * eax = 72 - function number
  4436.   * ebx = 1 - subfunction number
  4437.   * ecx = event code: 2 or 3
  4438.   * edx = parameter: key code for ecx=2, button identifier for ecx=3
  4439. Returned value:
  4440.   * eax = 0 - success
  4441.   * eax = 1 - buffer is full
  4442.  
  4443. ======================================================================
  4444. =============== Function -1 - terminate thread/process ===============
  4445. ======================================================================
  4446. Parameters:
  4447.   * eax = -1 - function number
  4448. Returned value:
  4449.   * function does not return neither value nor control
  4450. Remarks:
  4451.   * If the process did not create threads obviously, it has only
  4452.     one thread, which termination results in process termination.
  4453.   * If the current thread is last in the process, its termination
  4454.     also results in process terminates.
  4455.   * This function terminates the current thread. Other thread can be
  4456.     killed by call to subfunction 2 of function 18.
  4457.  
  4458. ======================================================================
  4459. =========================== List of events ===========================
  4460. ======================================================================
  4461. Next event can be retrieved by the call of one from functions 10
  4462. (to wait for event), 11 (to check without waiting), 23
  4463. (to wait during the given time).
  4464. These functions return only those events, which enter into a mask set
  4465. by function 40. By default it is first three,
  4466. there is enough for most applications.
  4467. Codes of events:
  4468.   * 1 = redraw event (is reset by call to function 0)
  4469.   * 2 = key on keyboard is pressed (acts, only when the window is
  4470.     active) or hotkey is pressed; is reset, when all keys from
  4471.     the buffer are read out by function 2
  4472.   * 3 = button is pressed, defined earlier by function 8
  4473.     (or close button, created implicitly by function 0;
  4474.     minimize button is handled by the system and sends no message;
  4475.     acts, only when the window is active;
  4476.     is reset when all buttons from the buffer
  4477.     are read out by function 17)
  4478.   * 4 = reserved (in current implementation never comes even after
  4479.     unmasking by function 40)
  4480.   * 5 = the desktop background is redrawed (is reset automatically
  4481.     after redraw, so if in redraw time program does not wait and
  4482.     does not check events, it will not remark this event)
  4483.   * 6 = mouse event (something happened - button pressing or moving;
  4484.     is reset at reading)
  4485.   * 7 = IPC event (see function 60 -
  4486.     Inter Process Communication; is reset at reading)
  4487.   * 8 = network event (is reset at reading)
  4488.   * 9 = debug event (is reset at reading; see
  4489.     debug subsystem)
  4490.   * 16..31 = event with appropriate IRQ
  4491.     (16=IRQ0, 31=IRQ15) (is reset after reading all IRQ data)
  4492.  
  4493. ======================================================================
  4494. =================== Error codes of the file system ===================
  4495. ======================================================================
  4496.   * 0 = success
  4497.   * 1 = base and/or partition of a hard disk is not defined
  4498.     (by subfunctions 7, 8 of function 21)
  4499.   * 2 = function is not supported for the given file system
  4500.   * 3 = unknown file system
  4501.   * 4 = reserved, is never returned in the current implementation
  4502.   * 5 = file not found
  4503.   * 6 = end of file, EOF
  4504.   * 7 = pointer lies outside of application memory
  4505.   * 8 = disk is full
  4506.   * 9 = FAT table is destroyed
  4507.   * 10 = access denied
  4508.   * 11 = device error
  4509. Application start functions can return also following errors:
  4510.   * 30 = 0x1E = not enough memory
  4511.   * 31 = 0x1F = file is not executable
  4512.   * 32 = 0x20 = too many processes
  4513.