Subversion Repositories Kolibri OS

Rev

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

  1.  
  2.   use32
  3.   org    0x0
  4.  
  5.   db     'MENUET01'
  6.   dd     0x01
  7.   dd     START
  8.   dd     I_END
  9.   dd     0x1000
  10.   dd     0x1000
  11.   dd     0x0
  12.   dd     0x0
  13.  
  14. FALSE = 0
  15. TRUE  = 1
  16.  
  17. include '../../../../../proc32.inc'
  18. include '../../../../../macros.inc'
  19. include '../../libio/libio.inc'
  20. include '../dll.inc'
  21.  
  22. yy dd 20
  23.  
  24. proc draw xx,color,key,val
  25.         pushad
  26.  
  27.         mov     esi,[key]
  28.         mov     edi,buf
  29.         cld
  30.         mov     al,"'"
  31.         stosb
  32.     @@: lodsb
  33.         stosb
  34.         or      al,al
  35.         jnz     @b
  36.         mov     word[edi-1],"'"
  37.  
  38.         mov     esi,[val]
  39.         or      esi,esi
  40.         je      .noval
  41.         mov     eax," = '"
  42.         stosd
  43.     @@: lodsb
  44.         stosb
  45.         or      al,al
  46.         jnz     @b
  47.         mov     word[edi-1],"'"
  48.   .noval:
  49.  
  50.         or      [color],0x80000000
  51.         mcall   4,<[xx],[yy]>,[color],buf
  52.         add     [yy],10
  53.         popad
  54.         ret
  55. endp
  56.  
  57. proc callb_k f_name,sec_name,key_name,key_val
  58.         stdcall draw,224,0x0000FF,[key_name],[key_val]
  59.         mov     eax,TRUE
  60.         ret
  61. endp
  62.  
  63. proc callb f_name,sec_name
  64.         stdcall draw,200,0xFF0000,[sec_name],0
  65.         invoke  ini.enum_keys,[f_name],[sec_name],callb_k
  66.         mov     eax,TRUE
  67.         ret
  68. endp
  69.  
  70. ;---------------------------------------------------------------------
  71. ;---  ÍÀ×ÀËÎ ÏÐÎÃÐÀÌÌÛ  ----------------------------------------------
  72. ;---------------------------------------------------------------------
  73.  
  74. s_key1 db "LeftViewMode",0
  75. s_key2 db "RightViewMode",0
  76.  
  77. s_null db "",0
  78.  
  79. macro wildcard_test_data label1, label2, label3, [str1, str2, res]
  80. {
  81.   common
  82.     label label1
  83.   forward
  84.     local ..lbl
  85.     dd ..lbl - $
  86.     db str1,0
  87.     ..lbl:
  88.   common
  89.     dd 0
  90.     label label2
  91.   forward
  92.     local ..lbl
  93.     dd ..lbl - $
  94.     db str2,0
  95.     ..lbl:
  96.   common
  97.     label label3
  98.   forward
  99.     if res = "t"
  100.       dd 1
  101.     else
  102.       dd 0
  103.     end if
  104. }
  105.  
  106. wildcard_test_data _str1, _str2, _str3, \
  107.   ""           ,""       ,"t",    ""            ,"a"        ,"f", \
  108.   "a"          ,"a"      ,"t",    "a"           ,"b"        ,"f", \
  109.   "?"          ,"b"      ,"t",    "??"          ,"bc"       ,"t", \
  110.   "?c"         ,"bc"     ,"t",    "b?"          ,"bc"       ,"t", \
  111.   "[a-z]"      ,"b"      ,"t",    "[A-Z]"       ,"b"        ,"f", \
  112.   "*"          ,"a"      ,"t",    "**"          ,"a"        ,"t", \
  113.   "*"          ,""       ,"t",    "*bc*hij"     ,"abcdfghij","t", \
  114.   "*b*a*"      ,"b"      ,"f",    "*bc*hik"     ,"abcdfghij","f", \
  115.   "abc*"       ,"abc"    ,"t",    "abc**"       ,"abc"      ,"t", \
  116.   "[^]]"       ,"^"      ,"t",    "[^]]"        ,"]"        ,"f", \
  117.   "[^abc]"     ,"d"      ,"t",    "[^abc]"      ,"b"        ,"f", \
  118.   "*???"       ,"abc"    ,"t",    "*???"        ,"ab"       ,"f", \
  119.   "*???"       ,"abcd"   ,"t",    "*?*"         ,"abcd"     ,"t", \
  120.   "*bc"        ,"abc"    ,"t",    "*cc"         ,"abc"      ,"f", \
  121.   "[a-c]*"     ,"d"      ,"f",    "*[a-e]"      ,"d"        ,"t", \
  122.   "*a*"        ,"de"     ,"f",    "*[a-c]"      ,"d"        ,"f", \
  123.   "[a-c]"      ,"d"      ,"f",    "[b-d]"       ,"a"        ,"f", \
  124.   "[]abc]"     ,"b"      ,"t",    "[]abc]"      ,"d"        ,"f", \
  125.   "[z-a]"      ,"-"      ,"t",    "[z-a]"       ,"b"        ,"f", \
  126.   "[A-]"       ,"-"      ,"t",    "[A-]"        ,"]"        ,"f", \
  127.   "[-a]"       ,"-"      ,"t",    "[-[]"        ,"-"        ,"t", \
  128.   "[-]"        ,"-"      ,"t",    "[^-b]"       ,"a"        ,"t", \
  129.   "[^-b]"      ,"-"      ,"f",    "[-b]"        ,"a"        ,"f", \
  130.   "[a-g]lorian","florian","t",    "[a-g]*rorian","f"        ,"f", \
  131.   "*???*"      ,"123"    ,"t"
  132.  
  133. START:
  134.         mcall   68,11
  135.  
  136.         stdcall dll.Load,@IMPORT
  137.         or      eax,eax
  138.         jnz     exit
  139.  
  140. @^ ; commenting out, file.aux.match_wildcard is no longer exported
  141.         mov     esi,_str1 + 4
  142.         mov     edi,_str2 + 4
  143.         mov     ecx,_str3
  144.         xor     ebx,ebx
  145.         inc     ebx
  146.     @@: invoke  file.aux.match_wildcard,edi,esi,0
  147.         cmp     eax,[ecx]
  148.         je      .ok
  149.         mcall   -1
  150.   .ok:  inc     ebx
  151.         add     esi,[esi-4]
  152.         add     edi,[edi-4]
  153.         add     ecx,4
  154.         cmp     dword[esi-4],0
  155.         jnz     @b
  156. ^@
  157.  
  158.         invoke  ini.set_int,s_ini,s_sec,s_key1,100
  159.         invoke  ini.set_int,s_ini,s_sec,s_key2,101
  160.  
  161.         invoke  ini.get_int,s_ini,s_sec,s_key1,-1
  162.         cmp     eax,100
  163.         jne     exit
  164.         invoke  ini.get_int,s_ini,s_sec,s_key2,-1
  165.         cmp     eax,101
  166.         jne     exit
  167.  
  168.         mov     dword[buf],'102'
  169.         invoke  ini.set_str,s_ini,s_sec,s_key1,buf,3
  170.         mov     dword[buf],'103'
  171.         invoke  ini.set_str,s_ini,s_sec,s_key2,buf,3
  172.  
  173.         invoke  ini.get_str,s_ini,s_sec,s_key1,buf,1024,s_null
  174.         cmp     dword[buf],'102'
  175.         jne     exit
  176.         invoke  ini.get_str,s_ini,s_sec,s_key2,buf,1024,s_null
  177.         cmp     dword[buf],'103'
  178.         jne     exit
  179.  
  180.         invoke  ini.enum_sections,s_ini,callb
  181.  
  182. ;       invoke  file.open,s_ininame,O_WRITE+O_CREATE
  183. ;       or      eax,eax
  184. ;       jnz     @f
  185. ;       int3
  186. ;   @@: mov     [fh],eax
  187. ;       invoke  file.seek,[fh],SEEK_SET,8192
  188. ;       invoke  file.write,[fh],s_ininame,16
  189. ;       invoke  file.seteof,[fh]
  190. ;       invoke  file.close,[fh]
  191.  
  192. red:
  193.  
  194.         call    draw_window
  195.  
  196. ;---------------------------------------------------------------------
  197. ;---  ÖÈÊË ÎÁÐÀÁÎÒÊÈ ÑÎÁÛÒÈÉ  ----------------------------------------
  198. ;---------------------------------------------------------------------
  199.  
  200. still:
  201.         mcall   10
  202.  
  203.         cmp     eax,1
  204.         je      red
  205.         cmp     eax,2
  206.         je      key
  207.         cmp     eax,3
  208.         je      button
  209.  
  210.         jmp     still
  211.  
  212. ;---------------------------------------------------------------------
  213.  
  214.   key:
  215.         mcall   2
  216.         jmp     still
  217.  
  218. ;---------------------------------------------------------------------
  219.  
  220.   button:
  221.         mcall   17
  222.  
  223.         cmp     ah,1
  224.         jne     still
  225.  
  226.   exit:
  227.         mcall   -1
  228.  
  229. ;---------------------------------------------------------------------
  230. ;---  ÎÏÐÅÄÅËÅÍÈÅ È ÎÒÐÈÑÎÂÊÀ ÎÊÍÀ  ----------------------------------
  231. ;---------------------------------------------------------------------
  232.  
  233. ctx dd ?
  234.  
  235. draw_window:
  236.         invoke  gfx.open,TRUE
  237.         mov     [ctx],eax
  238.         mcall   0,<200,700>,<200,200>,0x33FFFFFF,,s_header
  239.         invoke  gfx.pen.color,[ctx],0x00FF0000
  240.         invoke  gfx.line,[ctx],0,0,50,50
  241.         invoke  gfx.framerect,[ctx],10,10,100,70
  242.         invoke  gfx.brush.color,[ctx],0x000000FF
  243.         invoke  gfx.fillrect,[ctx],15,15,95,65
  244.         invoke  gfx.pen.color,[ctx],0x00008800
  245.         invoke  gfx.brush.color,[ctx],0x00CCCCFF
  246.         invoke  gfx.rectangle,[ctx],20,20,90,60
  247.         invoke  gfx.move.to,[ctx],13,5
  248.         invoke  gfx.line.to,[ctx],105,5
  249.         invoke  gfx.line.to,[ctx],105,75
  250.         invoke  gfx.line.to,[ctx],5,75
  251.         invoke  gfx.line.to,[ctx],5,13
  252.         invoke  gfx.line.to,[ctx],13,5
  253.         invoke  gfx.pen.color,[ctx],0x00888888
  254.         invoke  gfx.polyline,[ctx],poly_points,11
  255.         invoke  gfx.close,[ctx]
  256.  
  257.         mov     [yy],10
  258.         invoke  ini.enum_sections,s_ini,callb
  259.  
  260.         invoke  file.find_first,_f_path,_f_mask,FA_ANY-FA_FOLDER
  261.         cmp     eax,0
  262.         jle     .finished
  263.         mov     ebp,eax
  264.         mov     [yy],10
  265.     @@: lea     edx,[ebp+FileInfo.FileName]
  266.         mcall   4,<450,[yy]>,0x80000000
  267.         add     [yy],10
  268.         invoke  file.find_next,ebp
  269.         cmp     eax,0
  270.         jg      @b
  271.         invoke  file.find_close,ebp
  272.  
  273.   .finished:
  274.  
  275.         ret
  276.  
  277. _f_path db '/rd/1/lib',0
  278. _f_mask db '*ini*',0
  279.  
  280. ;-----------------------------------------------------------------------------
  281. proc mem.Alloc size ;/////////////////////////////////////////////////////////
  282. ;-----------------------------------------------------------------------------
  283.         push    ebx ecx
  284.         mov     eax,[size]
  285.         lea     ecx,[eax+4+4095]
  286.         and     ecx,not 4095
  287.         mcall   68,12
  288.         add     ecx,-4
  289.         mov     [eax],ecx
  290.         add     eax,4
  291.         pop     ecx ebx
  292.         ret
  293. endp
  294.  
  295. ;-----------------------------------------------------------------------------
  296. proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
  297. ;-----------------------------------------------------------------------------
  298.         push    ebx ecx esi edi eax
  299.         mov     eax,[mptr]
  300.         mov     ebx,[size]
  301.         or      eax,eax
  302.         jz      @f
  303.         lea     ecx,[ebx+4+4095]
  304.         and     ecx,not 4095
  305.         add     ecx,-4
  306.         cmp     ecx,[eax-4]
  307.         je      .exit
  308.     @@: mov     eax,ebx
  309.         call    mem.Alloc
  310.         xchg    eax,[esp]
  311.         or      eax,eax
  312.         jz      .exit
  313.         mov     esi,eax
  314.         xchg    eax,[esp]
  315.         mov     edi,eax
  316.         mov     ecx,[esi-4]
  317.         cmp     ecx,[edi-4]
  318.         jbe     @f
  319.         mov     ecx,[edi-4]
  320.     @@: add     ecx,3
  321.         shr     ecx,2
  322.         cld
  323.         rep     movsd
  324.         xchg    eax,[esp]
  325.         call    mem.Free
  326.   .exit:
  327.         pop     eax edi esi ecx ebx
  328.         ret
  329. endp
  330.  
  331. ;-----------------------------------------------------------------------------
  332. proc mem.Free mptr ;//////////////////////////////////////////////////////////
  333. ;-----------------------------------------------------------------------------
  334.         mov     eax,[mptr]
  335.         or      eax,eax
  336.         jz      @f
  337.         push    ebx ecx
  338.         lea     ecx,[eax-4]
  339.         mcall   68,13
  340.         pop     ecx ebx
  341.     @@: ret
  342. endp
  343.  
  344. ;---------------------------------------------------------------------
  345. ;---  ÄÀÍÍÛÅ ÏÐÎÃÐÀÌÌÛ  ----------------------------------------------
  346. ;---------------------------------------------------------------------
  347.  
  348. s_header db 'EXAMPLE APPLICATION',0
  349.  
  350. s_ini db '/rd/1/test001.ini',0
  351. s_sec db 'Panels',0
  352. s_key db 'param1',0
  353.  
  354. align 4
  355. poly_points dd \
  356.   140, 10, \
  357.   150, 10, \
  358.   150, 20, \
  359.   160, 20, \
  360.   160, 30, \
  361.   170, 30, \
  362.   170, 40, \
  363.   180, 40, \
  364.   180, 50, \
  365.   140, 50, \
  366.   140, 10
  367.  
  368. ;---------------------------------------------------------------------
  369.  
  370. align 16
  371. @IMPORT:
  372.  
  373. library \
  374.         libini,'libini.obj',\
  375.         libio ,'libio.obj',\
  376.         libgfx,'libgfx.obj'
  377.  
  378. import  libini, \
  379.         ini.get_str,'ini.get_str',\
  380.         ini.set_str,'ini.set_str',\
  381.         ini.get_int,'ini.get_int',\
  382.         ini.set_int,'ini.set_int',\
  383.         ini.enum_sections,'ini.enum_sections',\
  384.         ini.enum_keys,'ini.enum_keys'
  385.  
  386. import  libio, \
  387. \;      file.aux.match_wildcard,'file.aux.match_wildcard',\
  388.         file.find_first,'file.find_first',\
  389.         file.find_next,'file.find_next',\
  390.         file.find_close,'file.find_close',\
  391.         file.open,'file.open',\
  392.         file.seek,'file.seek',\
  393.         file.write,'file.write',\
  394.         file.truncate,'file.truncate',\
  395.         file.close,'file.close'
  396.  
  397. import  libgfx, \
  398.         gfx.open        ,'gfx.open',\
  399.         gfx.close       ,'gfx.close',\
  400.         gfx.pen.color   ,'gfx.pen.color',\
  401.         gfx.brush.color ,'gfx.brush.color',\
  402.         gfx.pixel       ,'gfx.pixel',\
  403.         gfx.move.to     ,'gfx.move.to',\
  404.         gfx.line.to     ,'gfx.line.to',\
  405.         gfx.line        ,'gfx.line',\
  406.         gfx.polyline    ,'gfx.polyline',\
  407.         gfx.polyline.to ,'gfx.polyline.to',\
  408.         gfx.fillrect    ,'gfx.fillrect',\
  409.         gfx.fillrect.ex ,'gfx.fillrect.ex',\
  410.         gfx.framerect   ,'gfx.framerect',\
  411.         gfx.framerect.ex,'gfx.framerect.ex',\
  412.         gfx.rectangle   ,'gfx.rectangle',\
  413.         gfx.rectangle.ex,'gfx.rectangle.ex'
  414.  
  415. I_END:
  416.  
  417. fh dd ?
  418.  
  419. buf rb 1024
  420.