Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7649 | leency | 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 | ; language for programs |
||
77 | lang fix ru ; ru en fr ge fi |
||
78 | |||
79 | |||
80 | ; code profiling |
||
81 | macro STARTTIMER |
||
82 | { |
||
83 | push ecx |
||
84 | push ebx |
||
85 | rdtsc |
||
86 | push edx |
||
87 | push eax |
||
88 | } |
||
89 | |||
90 | macro STOPTIMER ;edx:eax = cpu cycles ellapsed |
||
91 | { |
||
92 | rdtsc |
||
93 | pop ebx |
||
94 | pop ecx |
||
95 | clc |
||
96 | sbb eax,ebx |
||
97 | sbb edx,ecx |
||
98 | pop ebx |
||
99 | pop ecx |
||
100 | } |
||
101 | |||
102 | |||
103 | ; optimize the code for size |
||
104 | macro add arg1,arg2 |
||
105 | { |
||
106 | if arg1 in |
||
107 | if arg2 eqtype 0 |
||
108 | if (arg2) = 1 |
||
109 | inc arg1 |
||
110 | else |
||
111 | add arg1,arg2 |
||
112 | end if |
||
113 | else |
||
114 | add arg1,arg2 |
||
115 | end if |
||
116 | else |
||
117 | add arg1,arg2 |
||
118 | end if |
||
119 | } |
||
120 | |||
121 | macro sub arg1,arg2 |
||
122 | { |
||
123 | if arg2 eqtype 0 |
||
124 | if (arg2) = 1 |
||
125 | dec arg1 |
||
126 | else |
||
127 | sub arg1,arg2 |
||
128 | end if |
||
129 | else |
||
130 | sub arg1,arg2 |
||
131 | end if |
||
132 | } |
||
133 | |||
134 | macro mov arg1,arg2 |
||
135 | { |
||
136 | if arg1 in |
||
137 | if arg2 eqtype 0 |
||
138 | if (arg2) = 0 |
||
139 | xor arg1,arg1 |
||
140 | else if (arg2) = 1 |
||
141 | xor arg1,arg1 |
||
142 | inc arg1 |
||
143 | else if (arg2) = -1 |
||
144 | or arg1,-1 |
||
145 | else if (arg2) > -128 & (arg2) < 128 |
||
146 | push arg2 |
||
147 | pop arg1 |
||
148 | else |
||
149 | mov arg1,arg2 |
||
150 | end if |
||
151 | else |
||
152 | mov arg1,arg2 |
||
153 | end if |
||
154 | else |
||
155 | mov arg1,arg2 |
||
156 | end if |
||
157 | } |
||
158 | |||
159 | |||
160 | macro struct name |
||
161 | { |
||
162 | virtual at 0 |
||
163 | name name |
||
164 | sizeof.#name = $ - name |
||
165 | end virtual |
||
166 | } |
||
167 | |||
168 | |||
169 | ; structures used in MeOS |
||
170 | struc process_information |
||
171 | { |
||
172 | .cpu_usage dd ? ; +0 |
||
173 | .window_stack_position dw ? ; +4 |
||
174 | .window_stack_value dw ? ; +6 |
||
175 | .not_used1 dw ? ; +8 |
||
176 | .process_name rb 12 ; +10 |
||
177 | .memory_start dd ? ; +22 |
||
178 | .used_memory dd ? ; +26 |
||
179 | .PID dd ? ; +30 |
||
180 | .x_start dd ? ; +34 |
||
181 | .y_start dd ? ; +38 |
||
182 | .x_size dd ? ; +42 |
||
183 | .y_size dd ? ; +46 |
||
184 | .slot_state dw ? ; +50 |
||
185 | rb (1024-52) |
||
186 | } |
||
187 | struct process_information |
||
188 | |||
189 | struc system_colors |
||
190 | { |
||
191 | .frame dd ? |
||
192 | .grab dd ? |
||
193 | .grab_button dd ? |
||
194 | .grab_button_text dd ? |
||
195 | .grab_text dd ? |
||
196 | .work dd ? |
||
197 | .work_button dd ? |
||
198 | .work_button_text dd ? |
||
199 | .work_text dd ? |
||
200 | .work_graph dd ? |
||
201 | } |
||
202 | struct system_colors |
||
203 | |||
204 | |||
205 | ; constants |
||
206 | |||
207 | ; events |
||
208 | EV_IDLE = 0 |
||
209 | EV_TIMER = 0 |
||
210 | EV_REDRAW = 1 |
||
211 | EV_KEY = 2 |
||
212 | EV_BUTTON = 3 |
||
213 | EV_EXIT = 4 |
||
214 | EV_BACKGROUND = 5 |
||
215 | EV_MOUSE = 6 |
||
216 | EV_IPC = 7 |
||
217 | EV_STACK = 8 |
||
218 | |||
219 | ; event mask bits for function 40 |
||
220 | EVM_REDRAW = 1b |
||
221 | EVM_KEY = 10b |
||
222 | EVM_BUTTON = 100b |
||
223 | EVM_EXIT = 1000b |
||
224 | EVM_BACKGROUND = 10000b |
||
225 | EVM_MOUSE = 100000b |
||
226 | EVM_IPC = 1000000b |
||
227 | EVM_STACK = 10000000b> |