Rev 1050 | Rev 1293 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1050 | Rev 1236 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
16 | ;; Launch finds program in search dirictories and runs it. ;; |
16 | ;; Launch finds program in search dirictories and runs it. ;; |
17 | ;; For more details see readme.txt ;; |
17 | ;; For more details see readme.txt ;; |
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line -... | Line 19... | ||
- | 19 | ||
- | 20 | format binary |
|
19 | 21 | ||
20 | APP_NAME fix 'Launch' |
22 | APP_NAME fix 'Launch' |
Line 21... | Line 23... | ||
21 | APP_VERSION fix '0.1.4' |
23 | APP_VERSION fix '0.1.5' |
22 | 24 | ||
Line 23... | Line 25... | ||
23 | use32 |
25 | use32 |
Line 30... | Line 32... | ||
30 | dd MEM_END |
32 | dd MEM_END |
31 | dd APP_STACK |
33 | dd APP_STACK |
32 | dd args |
34 | dd args |
33 | dd path |
35 | dd path |
Line -... | Line 36... | ||
- | 36 | ||
- | 37 | define DEBUG_NO 0 |
|
- | 38 | define DEBUG_CONSOLE 1 |
|
- | 39 | define DEBUG_BOARD 2 ;; Not used now |
|
34 | 40 | ||
35 | define PATH_MAX_LEN 1024 |
41 | define PATH_MAX_LEN 1024 |
36 | define DEBUG_MAX_LEN 8 |
42 | define DEBUG_MAX_LEN 8 |
37 | define DEBUG_DEFAULT debug_no_num |
43 | define DEBUG_DEFAULT 0 |
Line 38... | Line 44... | ||
38 | define BUFF_SIZE 1024 |
44 | define BUFF_SIZE 1024 |
39 | 45 | ||
40 | include 'macros.inc' |
46 | include '../../../proc32.inc' |
41 | include 'proc32.inc' |
47 | include '../../../macros.inc' |
42 | include 'libio.inc' |
48 | include 'libio.inc' |
Line -... | Line 49... | ||
- | 49 | include 'mem.inc' |
|
- | 50 | include 'dll.inc' |
|
43 | include 'mem.inc' |
51 | |
44 | include 'dll.inc' |
52 | ;;-------------------------------------------------------------------------------------------------- |
45 | 53 | ;; Basic initialization |
|
46 | START: |
54 | START: |
47 | ;; Initialize process heap |
55 | ;; Initialize process heap |
Line 52... | Line 60... | ||
52 | ;; Import modules |
60 | ;; Import modules |
53 | stdcall dll.Load,importTable |
61 | stdcall dll.Load,importTable |
54 | test eax, eax |
62 | test eax, eax |
55 | jnz exit |
63 | jnz exit |
Line -... | Line 64... | ||
- | 64 | ||
56 | 65 | ;;-------------------------------------------------------------------------------------------------- |
|
- | 66 | ;; Reading config |
|
57 | read_ini: |
67 | read_ini_path: ;; Read search path |
58 | ;; First read config in /sys/etc |
68 | ;; First read config in /sys/etc |
Line 59... | Line 69... | ||
59 | invoke ini.get_str, etc_cfg, cfg_main, cfg_path, search_path, PATH_MAX_LEN, empty_str |
69 | invoke ini.get_str, etc_cfg, cfg_main, cfg_path, search_path, PATH_MAX_LEN, empty_str |
60 | 70 | ||
Line 87... | Line 97... | ||
87 | mov eax, path+PATH_MAX_LEN |
97 | mov eax, path+PATH_MAX_LEN |
88 | sub eax, edi |
98 | sub eax, edi |
89 | ;; Read ini |
99 | ;; Read ini |
90 | invoke ini.get_str, path, cfg_main, cfg_path, edi, PATH_MAX_LEN, empty_str |
100 | invoke ini.get_str, path, cfg_main, cfg_path, edi, PATH_MAX_LEN, empty_str |
Line 91... | Line 101... | ||
91 | 101 | ||
92 | read_ini_debug: |
102 | read_ini_debug: ;; Read debug options |
93 | ;; Read debug options from config files |
103 | ;; Read debug options from config files |
94 | invoke ini.get_str, etc_cfg, cfg_debug, cfg_debug, debug_option, DEBUG_MAX_LEN, DEBUG_DEFAULT |
104 | invoke ini.get_option_str, etc_cfg, cfg_debug, cfg_debug, debug_strings, DEBUG_MAX_LEN, DEBUG_DEFAULT |
95 | invoke ini.get_str, path, cfg_debug, cfg_debug, debug_option, DEBUG_MAX_LEN, debug_option |
- | |
96 | - | ||
97 | ;; Now convert debug_option from string to number of debug mode |
- | |
98 | mov ebx, modes-4 |
- | |
99 | .convert: |
105 | invoke ini.get_option_str, path, cfg_debug, cfg_debug, debug_strings, DEBUG_MAX_LEN, eax |
100 | mov al, byte [debug_option] |
- | |
101 | cmp al, 10 |
- | |
Line 102... | Line -... | ||
102 | jbe .converted |
- | |
103 | - | ||
104 | .convert_nxt: |
- | |
105 | add ebx, 4 |
- | |
106 | mov esi, dword [ebx] |
- | |
107 | test esi, esi |
- | |
108 | je .set_default ;; String is incorrect, so set default |
- | |
109 | mov edi, debug_option |
- | |
110 | .conv_loop: |
- | |
111 | mov al, byte [esi] |
- | |
112 | cmp al, byte [edi] |
- | |
113 | jne .convert_nxt ;; Not equal, so try next |
106 | mov [debug_option], eax |
114 | test al, al |
- | |
115 | je .found ;; Equal, end of loop |
- | |
116 | inc esi |
- | |
117 | inc edi |
- | |
118 | jmp .conv_loop |
- | |
119 | - | ||
120 | .set_default: |
- | |
121 | mov al, byte [DEBUG_DEFAULT] |
- | |
122 | mov byte [debug_option], al |
- | |
123 | jmp .converted |
- | |
124 | - | ||
125 | .found: |
- | |
126 | sub ebx, modes |
- | |
127 | shr ebx, 2 |
- | |
128 | add ebx, modes_nums |
- | |
129 | mov al, byte [ebx] |
- | |
130 | mov byte [debug_option], al |
- | |
131 | - | ||
132 | .converted: |
- | |
133 | dec al |
107 | |
134 | test al, al |
- | |
135 | je .ok |
- | |
136 | dec al |
- | |
Line 137... | Line 108... | ||
137 | test al, al |
108 | test eax, eax ;; No console |
- | 109 | je .ok |
|
138 | je .con_init |
110 | |
139 | 111 | jmp .con_init |
|
140 | .noconsole: |
112 | |
Line 141... | Line 113... | ||
141 | mov al, 1 |
113 | .console_err: |
142 | mov byte [debug_option], al |
114 | mov dword [debug_option], 0 |
143 | jmp .ok |
115 | jmp .ok |
144 | 116 | ||
145 | .con_init: |
117 | .con_init: |
Line 146... | Line 118... | ||
146 | stdcall dll.Load, consoleImport |
118 | stdcall dll.Load, consoleImport |
147 | test eax, eax |
119 | test eax, eax |
148 | jnz .noconsole |
120 | jnz .console_err |
149 | invoke con.init, -1, -1, -1, -1, WinTitle |
121 | invoke con.init, -1, -1, -1, -1, window_title |
150 | 122 | ||
Line -... | Line 123... | ||
- | 123 | .read_level: |
|
- | 124 | invoke ini.get_int, etc_cfg, cfg_debug, cfg_level, 0 |
|
- | 125 | invoke ini.get_int, path, cfg_debug, cfg_level, eax |
|
- | 126 | mov dword [debug_level], eax |
|
- | 127 | .ok: |
|
- | 128 | ||
- | 129 | ; read_ini_kobra: |
|
- | 130 | ; invoke ini.get_str, etc_cfg, cfg_kobra, cfg_use, kobra_use, KOBRA_USE_MAX_LEN, KOBRA_USE_DEFAULT |
|
- | 131 | ; invoke ini.get_str, path, cfg_kobra, cfg_use, kobra_use, KOBRA_USE_MAX_LEN, kobra_use |
|
151 | .read_level: |
132 | ; |
152 | invoke ini.get_int, etc_cfg, cfg_debug, cfg_level, 0 |
133 | ; ;; Now convert string option to acceptable type |
153 | invoke ini.get_int, path, cfg_debug, cfg_level, eax |
134 | |
154 | mov dword [debug_level], eax |
135 | |
Line 155... | Line 136... | ||
155 | .ok: |
136 | ;;-------------------------------------------------------------------------------------------------- |
156 | 137 | ;; Parse command line options |
|
157 | parse_args: |
138 | parse_args: |
158 | ;; Now parse command line arguments |
139 | ;; Now parse command line arguments |
Line 182... | Line 163... | ||
182 | 163 | ||
183 | pop edi |
164 | pop edi |
184 | dec edi |
165 | dec edi |
Line 185... | Line 166... | ||
185 | ;; Now edi = program name |
166 | ;; Now edi = program name |
- | 167 | ||
186 | 168 | ;;-------------------------------------------------------------------------------------------------- |
|
187 | ;; End of preparations! Now we can find file and launch it. |
169 | ;; Finding file |
188 | search_file: |
170 | search_file: |
189 | push edi |
171 | push edi |
190 | mov esi, search_path |
172 | mov esi, search_path |
Line 195... | Line 177... | ||
195 | xor dl, dl |
177 | xor dl, dl |
196 | jmp .prn_end |
178 | jmp .prn_end |
197 | .prn_dbg: |
179 | .prn_dbg: |
198 | push eax |
180 | push eax |
199 | mov al, byte [debug_option] |
181 | mov al, byte [debug_option] |
200 | dec al |
182 | ; dec al |
201 | test al, al |
183 | test al, al |
202 | je .prn_stp |
184 | je .prn_stp |
203 | mov eax, dword [debug_level] |
185 | mov eax, dword [debug_level] |
204 | or eax, eax |
186 | or eax, eax |
205 | je .prn_stp |
187 | je .prn_stp |
Line 251... | Line 233... | ||
251 | mov dword [LaunchStruct.FileNameP], buff |
233 | mov dword [LaunchStruct.FileNameP], buff |
252 | mcall 70, LaunchStruct |
234 | mcall 70, LaunchStruct |
253 | cmp eax, 0 |
235 | cmp eax, 0 |
254 | jl .loop |
236 | jl .loop |
Line -... | Line 237... | ||
- | 237 | ||
- | 238 | ;;-------------------------------------------------------------------------------------------------- |
|
255 | 239 | ;; Exit |
|
256 | exit: |
240 | exit: |
257 | push eax |
241 | push eax |
258 | ;; If console is present we should write some info |
242 | ;; If console is present we should write some info |
259 | mov al, byte [debug_option] |
243 | mov al, byte [debug_option] |
260 | cmp al, 2 |
- | |
261 | je .write_console |
- | |
262 | 244 | cmp al, DEBUG_CONSOLE |
|
263 | .close: |
- | |
Line 264... | Line 245... | ||
264 | mcall -1 |
245 | jne .close |
265 | 246 | ||
266 | .write_console: |
247 | .write_console: |
267 | pop eax |
248 | pop eax |
Line 273... | Line 254... | ||
273 | .write_error: |
254 | .write_error: |
274 | pop edi |
255 | pop edi |
275 | cinvoke con.printf, message_error, edi |
256 | cinvoke con.printf, message_error, edi |
276 | .wr_end: |
257 | .wr_end: |
277 | invoke con.exit, 0 |
258 | invoke con.exit, 0 |
- | 259 | ||
278 | jmp .close |
260 | .close: |
- | 261 | mcall -1 |
|
- | 262 | ||
- | 263 | ;; End of code |
|
- | 264 | ;;-------------------------------------------------------------------------------------------------- |
|
Line 279... | Line 265... | ||
279 | 265 | ||
280 | align 16 |
266 | align 16 |
281 | importTable: |
267 | importTable: |
282 | library \ |
268 | |
283 | libini, 'libini.obj';, \ |
269 | library libini, 'libini.obj' ;, \ |
Line 284... | Line 270... | ||
284 | ; libio, 'libio.obj', \ |
270 | ; libio, 'libio.obj', \ |
285 | 271 | ||
286 | import libini, \ |
272 | import libini, \ |
287 | ini.get_str ,'ini.get_str', \ |
273 | ini.get_str ,'ini_get_str', \ |
288 | \; ini.set_str ,'ini.set_str', \ |
274 | \; ini.set_str ,'ini_set_str', \ |
289 | ini.get_int ,'ini.get_int';, \ |
275 | ini.get_int ,'ini_get_int', \ |
290 | \; ini.set_int ,'ini.set_int', \ |
276 | \; ini.set_int ,'ini_set_int', \ |
- | 277 | \; ini.get_color ,'ini_get_color', \ |
|
Line 291... | Line 278... | ||
291 | ; ini.get_color,'ini.get_color', \ |
278 | \; ini.set_color ,'ini_set_color', \ |
292 | ; ini.set_color,'ini.set_color' |
279 | ini.get_option_str ,'ini_get_option_str';, \ |
293 | 280 | ||
294 | ;import libio, \ |
281 | ;import libio, \ |
295 | ; file.find_first,'file.find_first', \ |
282 | ; file_find_first,'file_find_first', \ |
296 | ; file.find_next ,'file.find_next', \ |
283 | ; file_find_next ,'file_find_next', \ |
297 | ; file.find_close,'file.find_close', \ |
284 | ; file_find_close,'file_find_close', \ |
298 | ; file.size ,'file.size', \ |
285 | ; file_size ,'file_size', \ |
299 | ; file.open ,'file.open', \ |
286 | ; file_open ,'file_open', \ |
300 | ; file.read ,'file.read', \ |
287 | ; file_read ,'file_read', \ |
301 | ; file.write ,'file.write', \ |
288 | ; file_write ,'file_write', \ |
302 | ; file.seek ,'file.seek', \ |
289 | ; file_seek ,'file_seek', \ |
303 | ; file.tell ,'file.tell', \ |
290 | ; file_tell ,'file_tell', \ |
Line 304... | Line 291... | ||
304 | ; file.eof? ,'file.eof?', \ |
291 | ; file_eof? ,'file_eof?', \ |
305 | ; file.truncate ,'file.truncate', \ |
292 | ; file_truncate ,'file_truncate', \ |
306 | ; file.close ,'file.close' |
293 | ; file_close ,'file_close' |
Line 307... | Line 294... | ||
307 | 294 | ||
308 | consoleImport: |
295 | consoleImport: |
309 | library \ |
296 | library \ |
310 | conlib, 'console.obj' |
297 | conlib, 'console.obj' |
311 | 298 | ||
Line 312... | Line 299... | ||
312 | import conlib, \ |
299 | import conlib,\ |
313 | con.init, 'con.init',\ |
300 | con.init, 'con_init',\ |
Line -... | Line 301... | ||
- | 301 | con.exit, 'con_exit',\ |
|
314 | con.exit, 'con.exit',\ |
302 | con.printf, 'con_printf' ;,\ |
315 | con.printf, 'con.printf';,\ |
303 | ; con.write_asciiz, 'con_write_asciiz' |
Line -... | Line 304... | ||
- | 304 | ||
316 | ; con.write_asciiz, 'con.write_asciiz' |
305 | align 16 |
317 | 306 | APP_DATA: |
|
Line 318... | Line 307... | ||
318 | align 16 |
307 | |
319 | APP_DATA: |
308 | ;; Window title |
Line 320... | Line 309... | ||
320 | 309 | window_title: |
|
321 | WinTitle: |
310 | db APP_NAME, ' ', APP_VERSION, 0 |
Line -... | Line 311... | ||
- | 311 | ||
322 | db APP_NAME, ' ', APP_VERSION, 0 |
312 | ;; Messages |
323 | 313 | message_dbg_not_found: |
|
- | 314 | db '%s not found', 10, 0 |
|
- | 315 | ||
324 | message_dbg_not_found: |
316 | message_error: |
325 | db '%s not found', 10, 0 |
317 | db 'File (%s) not found!', 0 |
326 | 318 | ||
327 | message_error: |
319 | message_ok: |
328 | db 'File (%s) not found!', 0 |
320 | db '%s loaded succesfully. PID: %d (0x%X)' |
329 | 321 | ||
Line -... | Line 322... | ||
- | 322 | ;; Empty string |
|
330 | message_ok: |
323 | empty_str: |
331 | db '%s loaded succesfully. PID: %d (0x%X)' |
324 | db 0 |
332 | 325 | ||
333 | empty_str: |
326 | ;; Configuration path |
334 | db 0 |
327 | etc_cfg: |
335 | etc_cfg: |
328 | db '/sys/etc/' |
336 | db '/sys/etc/' |
329 | cfg_name: |
337 | cfg_name: |
330 | db 'launch' |
Line -... | Line 331... | ||
- | 331 | cfg_ext: |
|
338 | db 'launch' |
332 | db '.cfg', 0 |
339 | cfg_ext: |
333 | |
340 | db '.cfg', 0 |
334 | ;; String in config file |
341 | 335 | cfg_main: |
|
Line 342... | Line 336... | ||
342 | cfg_main: |
336 | db 'main', 0 |
343 | db 'main', 0 |
337 | cfg_path: |
344 | cfg_path: |
338 | db 'path', 0 |
345 | db 'path', 0 |
339 | cfg_debug: |
Line 346... | Line 340... | ||
346 | cfg_debug: |
340 | db 'debug', 0 |
347 | db 'debug', 0 |
341 | cfg_level: |
348 | cfg_level: |
342 | db 'level', 0 |
349 | db 'level', 0 |
343 | |
350 | 344 | ;; List of debug modes for parsing debug option |
|
351 | modes: |
345 | debug_strings: |
Line 352... | Line 346... | ||
352 | dd debug_no |
346 | dd debug_no |
353 | dd debug_console |
347 | dd debug_console |
Line -... | Line 348... | ||
- | 348 | dd 0 |
|
- | 349 | ||
- | 350 | debug_no: |
|
354 | dd 0 |
351 | db 'no', 0 |
Line 355... | Line 352... | ||
355 | 352 | debug_console: |
|
356 | debug_no: |
353 | db 'console', 0 |
357 | db 'no', 0 |
354 | |
Line 377... | Line 374... | ||
377 | prog_args: |
374 | prog_args: |
378 | rd 1 |
375 | rd 1 |
379 | path: |
376 | path: |
380 | rb 1024 |
377 | rb 1024 |
Line -... | Line 378... | ||
- | 378 | ||
381 | 379 | ;; Search path will be here |
|
382 | search_path: |
380 | search_path: |
Line -... | Line 381... | ||
- | 381 | rb PATH_MAX_LEN |
|
383 | rb PATH_MAX_LEN |
382 | |
384 | 383 | ;; debug option as number |
|
Line -... | Line 384... | ||
- | 384 | debug_option: |
|
385 | debug_option: |
385 | dd 0 |
386 | rb DEBUG_MAX_LEN |
386 | |
Line 387... | Line 387... | ||
387 | 387 | ;; Buffer |
|
388 | buff: |
388 | buff: |