Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ; new application structure
  2. macro meos_app_start
  3.  {
  4.   use32
  5.   org 0x0
  6.  
  7.   db 'MENUET01'
  8.   dd 0x01
  9.   dd __start
  10.   dd __end
  11.   dd __memory
  12.   dd __stack
  13.  
  14.   if used __params & ~defined __params
  15.     dd __params
  16.   else
  17.     dd 0x0
  18.   end if
  19.  
  20.   dd 0x0
  21.  }
  22. MEOS_APP_START fix meos_app_start
  23.  
  24. macro code
  25.  {
  26.   __start:
  27.  }
  28. CODE fix code
  29.  
  30. macro data
  31.  {
  32.   __data:
  33.  }
  34. DATA fix data
  35.  
  36. macro udata
  37.  {
  38.   if used __params & ~defined __params
  39.     __params:
  40.       db 0
  41.     __end:
  42.       rb 255
  43.   else
  44.     __end:
  45.   end if
  46.   __udata:
  47.  }
  48. UDATA fix udata
  49.  
  50. macro meos_app_end
  51.  {
  52.   align 32
  53.   rb 2048
  54.   __stack:
  55.   __memory:
  56.  }
  57. MEOS_APP_END fix meos_app_end
  58.  
  59.  
  60. ; macro for defining multiline text data
  61. struc mstr [sstring]
  62.  {
  63.   forward
  64.     local ssize
  65.     virtual at 0
  66.       db sstring
  67.       ssize = $
  68.     end virtual
  69.     dd ssize
  70.     db sstring
  71.   common
  72.     dd -1
  73.  }
  74.  
  75.  
  76.  
  77.  
  78.  
  79. ; code profiling
  80. macro STARTTIMER
  81.  {
  82.   push ecx
  83.   push ebx
  84.   rdtsc
  85.   push edx
  86.   push eax
  87.  }
  88.  
  89. macro STOPTIMER ;edx:eax = cpu cycles ellapsed
  90.  {
  91.   rdtsc
  92.   pop ebx
  93.   pop ecx
  94.   clc
  95.   sbb eax,ebx
  96.   sbb edx,ecx
  97.   pop ebx
  98.   pop ecx
  99.  }
  100.  
  101.  
  102. ; optimize the code for size
  103. macro add arg1,arg2
  104.  {
  105.    if arg1 in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
  106.       if arg2 eqtype 0
  107.          if (arg2) = 1
  108.             inc arg1
  109.          else
  110.             add arg1,arg2
  111.          end if
  112.       else
  113.          add arg1,arg2
  114.       end if
  115.    else
  116.       add arg1,arg2
  117.    end if
  118.  }
  119.  
  120. macro sub arg1,arg2
  121.  {
  122.    if arg2 eqtype 0
  123.       if (arg2) = 1
  124.          dec arg1
  125.       else
  126.          sub arg1,arg2
  127.       end if
  128.    else
  129.       sub arg1,arg2
  130.    end if
  131.  }
  132.  
  133. macro mov arg1,arg2
  134.  {
  135.    if arg1 in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
  136.       if arg2 eqtype 0
  137.          if (arg2) = 0
  138.             xor arg1,arg1
  139.          else if (arg2) = 1
  140.             xor arg1,arg1
  141.             inc arg1
  142.          else if (arg2) = -1
  143.             or  arg1,-1
  144.          else if (arg2) > -128 & (arg2) < 128
  145.             push arg2
  146.             pop  arg1
  147.          else
  148.             mov arg1,arg2
  149.          end if
  150.       else
  151.          mov arg1,arg2
  152.       end if
  153.    else
  154.       mov arg1,arg2
  155.    end if
  156.  }
  157.  
  158.  
  159. macro struct name
  160.  {
  161.   virtual at 0
  162.    name name
  163.    sizeof.#name = $ - name
  164.   end virtual
  165.  }
  166.  
  167.  
  168. ; structures used in MeOS
  169. struc process_information
  170.  {
  171.   .cpu_usage               dd ?  ; +0
  172.   .window_stack_position   dw ?  ; +4
  173.   .window_stack_value      dw ?  ; +6
  174.   .not_used1               dw ?  ; +8
  175.   .process_name            rb 12 ; +10
  176.   .memory_start            dd ?  ; +22
  177.   .used_memory             dd ?  ; +26
  178.   .PID                     dd ?  ; +30
  179.   .x_start                 dd ?  ; +34
  180.   .y_start                 dd ?  ; +38
  181.   .x_size                  dd ?  ; +42
  182.   .y_size                  dd ?  ; +46
  183.   .slot_state              dw ?  ; +50
  184.   rb (1024-52)
  185.  }
  186. struct process_information
  187.  
  188. struc system_colors
  189.  {
  190.   .frame            dd ?
  191.   .grab             dd ?
  192.   .grab_button      dd ?
  193.   .grab_button_text dd ?
  194.   .grab_text        dd ?
  195.   .work             dd ?
  196.   .work_button      dd ?
  197.   .work_button_text dd ?
  198.   .work_text        dd ?
  199.   .work_graph       dd ?
  200.  }
  201. struct system_colors
  202.  
  203.  
  204. ; constants
  205.  
  206. ; events
  207. EV_IDLE        = 0
  208. EV_TIMER       = 0
  209. EV_REDRAW      = 1
  210. EV_KEY         = 2
  211. EV_BUTTON      = 3
  212. EV_EXIT        = 4
  213. EV_BACKGROUND  = 5
  214. EV_MOUSE       = 6
  215. EV_IPC         = 7
  216. EV_STACK       = 8
  217.  
  218. ; event mask bits for function 40
  219. EVM_REDRAW     =        1b
  220. EVM_KEY        =       10b
  221. EVM_BUTTON     =      100b
  222. EVM_EXIT       =     1000b
  223. EVM_BACKGROUND =    10000b
  224. EVM_MOUSE      =   100000b
  225. EVM_IPC        =  1000000b
  226. EVM_STACK      = 10000000b