Subversion Repositories Kolibri OS

Rev

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