Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | 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
;
9
include "lang.inc"
10
include "macros.inc"
11
 
12
  use32
13
  org    0x0
14
  db     'MENUET01'              ; 8 byte id
15
  dd     0x01                    ; header version
16
  dd     START                   ; start of code
17
  dd     I_END                   ; size of image
18
  dd     0x8000                 ; memory for app
19
  dd     0x8000                 ; esp
20
  dd     0x0 , 0x0               ; I_Param , I_Icon
21
 
22
;include "DEBUG.INC"
23
 
24
START:                           ; start of execution
25
 
26
   mov  eax, 5
27
   mov  ebx, 10
28
   int  0x40
29
 
30
   mov  eax, 58               ; load AUTORUN.DAT
31
   mov  ebx, autorun_dat_info
32
   int  0x40
33
 
34
   call get_number
35
   mov  [number_of_files], eax
36
;dps "NUMBER OF FILES: "
37
;dpd eax
38
;dps <13,10>
39
   call next_line
40
 
41
 start_program:
42
;dps <"STARTING A PROGRAM",13,10>
43
   call clear_strings
44
   mov  edi, program
45
   call get_string
46
   mov  edi, parameters
47
   call get_string
48
   call get_number
49
   call run_program
50
   call next_line
51
   dec  [number_of_files]
52
   jnz  start_program
53
 
54
 exit:
55
   or   eax, -1
56
   int  0x40
57
 
58
 
59
 run_program:     ; time to delay in eax
60
   push eax
61
   mcall 58, start_info
62
   pop  ebx
63
 
64
   mov  eax, 5
65
   int  0x40
66
 ret
67
 
68
 
69
 clear_strings:   ; clears buffers
70
   pushad
71
 
72
   mov  ecx, 60
73
   mov  edi, program
74
   xor  al, al ;mov  al, ' '
75
   rep  stosb
76
 
77
   mov  ecx, 60
78
   mov  edi, parameters
79
   xor  al, al
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
114
   cmp  al, '0'
115
   jb   .finish
116
   cmp  al, '9'
117
   ja   .finish
118
   sub  al, '0'
119
   imul ebx, 10
120
   add  ebx, eax
121
   inc  [position]
122
   jmp  .start
123
  .finish:
124
   mov  eax, ebx
125
   pop  esi ebx
126
 ret
127
 
128
 
129
 skip_spaces:
130
   pushad
131
   xor  eax, eax
132
   mov  esi, [position]
133
   add  esi, file_data
134
  .start:
135
   lodsb
136
   cmp  al, ' '
137
   jne  .finish
138
   inc  [position]
139
   jmp  .start
140
  .finish:
141
;dps "NOW AL = "
142
;mov [tmp],al
143
;mov edx, tmp
144
;call debug_outstr
145
;dps <13,10>
146
   popad
147
 ret
148
 
149
 
150
 next_line:
151
   pushad
152
   mov  esi, [position]
153
   add  esi, file_data
154
  .start:
155
   lodsb
156
   cmp  al, 13
157
   je   .finish
158
   inc  [position]
159
   jmp  .start
160
  .finish:
161
   add  [position], 2
162
   inc  esi
163
   lodsb
164
   cmp  al, '#'
165
   je   .skipline
166
   cmp  al, 13
167
   jne  .donotskip
168
  .skipline:
169
   call next_line
170
  .donotskip:
171
   popad
172
 ret
173
 
174
 
175
 
176
; DATA:
177
 position          dd 0            ; position in file
178
 
179
 autorun_dat_info:                 ; AUTORUN.DAT
180
   .mode           dd 0            ; read file
181
   .start_block    dd 0            ; block to read
182
   .blocks         dd 0x10         ; 16*512 bytes max
183
   .address        dd file_data
184
   .workarea       dd work_area
185
   db "/RD/1/AUTORUN.DAT",0
186
 
187
 start_info:
188
   .mode           dd 16
189
                   dd 0
190
   .params         dd parameters
191
                   dd 0
192
   .workarea       dd work_area
193
   .path: ;      
194
 
195
I_END:
196
 
197
 program           rb 61 ; 60 + [0] char
198
 parameters        rb 61
199
 
200
 number_of_files   dd ?
201
 
202
 work_area         rb 0x4000
203
 file_data         rb 16*512