Subversion Repositories Kolibri OS

Rev

Rev 7938 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  use32          
  2.         org     0x0          
  3.          
  4.         db      'MENUET01'      ; 8 byte id          
  5.         dd      38              ; required os          
  6.         dd      STARTAPP        ; program start          
  7.         dd      I_END           ; program image size          
  8.         dd      0x1000000       ; required amount of memory          
  9.         dd      0x1000000       ; stack heap          
  10.         dd      0x0
  11.         dd      0x0          
  12.                    
  13. include '../../../proc32.inc'          
  14. include '../../../macros.inc'          
  15. include '../../../dll.inc'          
  16.  
  17.          
  18. PATH_MAX equ 255          
  19.  
  20. STARTAPP:          
  21.     ; Initialize heap
  22.     mcall   68, 11        
  23.     ; Import libraries          
  24.     stdcall dll.Load,importTable
  25.    
  26.         ; Set button style: flat or gradient (3D)
  27.     invoke  ini_get_int, aIni, aSection, aButtonStyle, 0
  28.     mov ecx, eax
  29.     mcall 48, 1
  30.  
  31.         ; Set desktop background
  32.     invoke  ini_get_str, aIni, aSection, aBgProgram, sz_app, PATH_MAX, 0
  33.     invoke  ini_get_str, aIni, aSection, aBgParam, sz_param, PATH_MAX, 0
  34.        
  35.         cmp     byte[sz_param], '\' ;detecting KIV param like '\S__/path/to/img'
  36.         jne     @f
  37.  
  38.         m2m     dword [ReadFile.path], sz_param+4
  39.         call    check_file_exists
  40.  
  41. @@:
  42.     mcall   70, RunApp
  43.            
  44.         ; Set system skin
  45.     invoke  ini_get_str, aIni, aSection, aSkinPath, sz_param, PATH_MAX, 0
  46.         cmp     byte [sz_param], 0 ;no need to set skin if it was not specified
  47.         je      @f
  48.        
  49.         m2m     dword [ReadFile.path], sz_param
  50.         call    check_file_exists
  51.        
  52.     mcall   48, 8, sz_param          
  53. @@:
  54.         ; Exit app
  55.     mcall   -1
  56.  
  57. ;----------------------------------------------------------------
  58. ; This is fix for files located at /kolibrios and /usbhd drives
  59. ; It checks is the file exists for 5 times with perioud 1 second
  60. check_file_exists:
  61.         mov     edi, 0
  62. @@:
  63.         mcall   70, ReadFile
  64.         cmp     eax,0
  65.         je      .exit
  66.         mcall   5, 100
  67.         inc     edi
  68.         cmp     edi, 5
  69.         jle     @b
  70. .exit:
  71.         ret
  72. ;----------------------------------------------------------------
  73.        
  74. importTable:          
  75. library                                                 \          
  76.         libini, 'libini.obj'          
  77.          
  78. import  libini, \          
  79.         ini_get_str  ,'ini_get_str', \          
  80.         ini_get_int  ,'ini_get_int'      
  81.          
  82. RunApp:
  83.         dd      7     ; subfunction number          
  84.         dd      0     ; position in the file in bytes          
  85.         dd      sz_param  ; upper part of the position address          
  86.         dd      0     ; number of bytes to read          
  87.         dd      0     ; pointer to the buffer to write data          
  88.         db      0          
  89.         dd      sz_app ; pointer to the filename
  90.  
  91. ReadFile:
  92.         dd      0     ; subfunction number          
  93.         dd      0     ; position in the file in bytes          
  94.         dd      0     ; upper part of the position address          
  95.         dd      4     ; number of bytes to read          
  96.         dd      buf   ; pointer to the buffer to write data  
  97.                 db      0                      
  98. .path   dd      ?     ; pointer to the filename
  99. buf rb 4
  100.          
  101. aIni          db  '/sys/settings/system.ini',0          
  102. aSection      db  'style',0
  103.  
  104. aBgProgram    db  'bg_program',0
  105. aBgParam      db  'bg_param',0          
  106. aButtonStyle  db  'buttons_gradient',0
  107. aSkinPath     db  'skin',0
  108.  
  109. sz_app:
  110.     rb        PATH_MAX
  111. sz_param:          
  112.     rb        PATH_MAX
  113.          
  114. I_END:                ; End of application code and data marker          
  115.        
  116.