Subversion Repositories Kolibri OS

Rev

Rev 142 | Rev 529 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;   LAUNCHER - АВТОЗАПУСК ПРОГРАММ
3
;     Код программы совсем не оптимизирован, но очень прост для понимания.
4
;     Этот лаунчер грузит информацию о программах для запуска из файла
5
;     AUTORUN.DAT. Формат очень прост и в комментариях не нуждается.
6
;
7
;   Компилируйте с помощью FASM 1.52 и выше
8
;
485 heavyiron 9
include "..\..\..\MACROS.INC"
31 halyavin 10
 
11
  use32
12
  org    0x0
13
  db     'MENUET01'              ; 8 byte id
14
  dd     0x01                    ; header version
15
  dd     START                   ; start of code
16
  dd     I_END                   ; size of image
17
  dd     0x8000                 ; memory for app
18
  dd     0x8000                 ; esp
19
  dd     0x0 , 0x0               ; I_Param , I_Icon
20
 
21
;include "DEBUG.INC"
22
 
23
START:                           ; start of execution
24
 
132 diamond 25
;   mov  eax, 5
26
;   mov  ebx, 10
485 heavyiron 27
;   mcall
31 halyavin 28
 
132 diamond 29
   mcall 18,15
30
 
142 diamond 31
   mov  eax, 70               ; load AUTORUN.DAT
31 halyavin 32
   mov  ebx, autorun_dat_info
485 heavyiron 33
   mcall
31 halyavin 34
 
35
   call get_number
36
   mov  [number_of_files], eax
37
;dps "NUMBER OF FILES: "
38
;dpd eax
39
;dps <13,10>
40
   call next_line
41
 
42
 start_program:
43
;dps <"STARTING A PROGRAM",13,10>
44
   call clear_strings
45
   mov  edi, program
46
   call get_string
47
   mov  edi, parameters
48
   call get_string
49
   call get_number
50
   call run_program
51
   call next_line
52
   dec  [number_of_files]
53
   jnz  start_program
54
 
55
 exit:
56
   or   eax, -1
485 heavyiron 57
   mcall
31 halyavin 58
 
59
 
60
 run_program:     ; time to delay in eax
61
   push eax
142 diamond 62
   mcall 70, start_info
31 halyavin 63
   pop  ebx
64
 
65
   mov  eax, 5
485 heavyiron 66
   mcall
31 halyavin 67
 ret
68
 
69
 
70
 clear_strings:   ; clears buffers
71
   pushad
72
 
73
   mov  ecx, 60
74
   mov  edi, program
75
   xor  al, al ;mov  al, ' '
76
   rep  stosb
77
 
78
   mov  ecx, 60
79
   mov  edi, parameters
80
   rep  stosb
81
 
82
   popad
83
 ret
84
 
85
 
86
 get_string: ; pointer to destination buffer in edi
87
   pushad
88
   call skip_spaces
89
   mov  esi, [position]
90
;dpd esi
91
;dps <13,10>
92
   add  esi, file_data
93
  .start:
94
   lodsb
95
   cmp  al, ' '
96
   je   .finish
97
   stosb
98
   inc  [position]
99
   jmp  .start
100
  .finish:
101
   popad
102
 ret
103
 
104
 
105
 get_number:
106
   push ebx esi
107
   call skip_spaces
108
   mov  esi, [position]
109
   add  esi, file_data
110
   xor  eax, eax
111
   xor  ebx, ebx
112
  .start:
113
   lodsb
142 diamond 114
   sub  al, '0'
115
   cmp  al, 9
31 halyavin 116
   ja   .finish
142 diamond 117
   lea  ebx,[ebx*4+ebx]
118
   lea  ebx,[ebx*2+eax]
31 halyavin 119
   inc  [position]
120
   jmp  .start
121
  .finish:
122
   mov  eax, ebx
123
   pop  esi ebx
124
 ret
125
 
126
 
127
 skip_spaces:
128
   pushad
129
   xor  eax, eax
130
   mov  esi, [position]
131
   add  esi, file_data
132
  .start:
133
   lodsb
134
   cmp  al, ' '
135
   jne  .finish
136
   inc  [position]
137
   jmp  .start
138
  .finish:
139
;dps "NOW AL = "
140
;mov [tmp],al
141
;mov edx, tmp
142
;call debug_outstr
143
;dps <13,10>
144
   popad
145
 ret
146
 
147
 
148
 next_line:
149
   pushad
150
   mov  esi, [position]
151
   add  esi, file_data
152
  .start:
153
   lodsb
154
   cmp  al, 13
155
   je   .finish
156
   inc  [position]
157
   jmp  .start
158
  .finish:
159
   add  [position], 2
160
   inc  esi
161
   lodsb
162
   cmp  al, '#'
163
   je   .skipline
164
   cmp  al, 13
165
   jne  .donotskip
166
  .skipline:
167
   call next_line
168
  .donotskip:
169
   popad
170
 ret
171
 
172
 
173
 
174
; DATA:
175
 position          dd 0            ; position in file
176
 
177
 autorun_dat_info:                 ; AUTORUN.DAT
178
   .mode           dd 0            ; read file
179
   .start_block    dd 0            ; block to read
142 diamond 180
                   dd 0
181
   .blocks         dd 16*512       ; 16*512 bytes max
31 halyavin 182
   .address        dd file_data
183
   db "/RD/1/AUTORUN.DAT",0
184
 
185
 start_info:
142 diamond 186
   .mode           dd 7
31 halyavin 187
                   dd 0
188
   .params         dd parameters
189
                   dd 0
142 diamond 190
                   dd 0
31 halyavin 191
   .path: ;      
192
 
193
I_END:
194
 
195
 program           rb 61 ; 60 + [0] char
196
 parameters        rb 61
197
 
198
 number_of_files   dd ?
199
 
200
 file_data         rb 16*512