Subversion Repositories Kolibri OS

Rev

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

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