Rev 8089 | Rev 10016 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
6462 | pathoswith | 3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License. ;; |
||
2288 | clevermous | 5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 8091 $ |
||
9 | |||
10 | iglobal |
||
6502 | pathoswith | 11 | full_file_name_table dd sysdir_name |
12 | .size dd 1 |
||
2288 | clevermous | 13 | endg |
14 | |||
15 | uglobal |
||
6502 | pathoswith | 16 | sysdir_name rb 64 ; 'sys',0 |
17 | sysdir_path rb 64 |
||
18 | sysdir_name1 rb 64 |
||
19 | sysdir_path1 rb 64 |
||
3663 | mario79 | 20 | endg |
6502 | pathoswith | 21 | ; Example: |
22 | ; align 64 |
||
23 | ; sysdir_name1 db 'KolibriOS',0 |
||
24 | ; align 64 |
||
25 | ; sysdir_path1 db 'HD0/1',0 |
||
3663 | mario79 | 26 | |
2288 | clevermous | 27 | proc Parser_params |
6502 | pathoswith | 28 | locals |
29 | buff rb 4 ; for test cd |
||
30 | endl |
||
8091 | dunkaist | 31 | if defined extended_primary_loader |
32 | mov ecx, sysdir_path |
||
33 | mov [ecx-64], dword 'sys' |
||
34 | mov [ecx-2], byte 3 |
||
35 | mov esi, BOOT.syspath |
||
36 | mov edi, sysdir_path-1 |
||
37 | mov ecx, 20 |
||
38 | rep movsb |
||
39 | ret |
||
40 | else |
||
8089 | dunkaist | 41 | mov ax, [BOOT.sys_disk] |
2288 | clevermous | 42 | mov ecx, sysdir_path |
43 | mov [ecx-64], dword 'sys' |
||
6502 | pathoswith | 44 | mov [ecx-2], byte 3 |
45 | mov [ecx-1], byte '/' |
||
46 | cmp al, 'r' ; ram disk |
||
2288 | clevermous | 47 | jnz @f |
48 | mov [ecx], dword 'RD/?' |
||
49 | mov [ecx+3], byte ah |
||
50 | mov [ecx+4], byte 0 |
||
51 | ret |
||
6502 | pathoswith | 52 | |
2288 | clevermous | 53 | @@: |
6502 | pathoswith | 54 | cmp al, 'm' |
55 | jnz .hard_disk |
||
56 | mov [ecx], dword 'CD?/' |
||
2288 | clevermous | 57 | mov [ecx+4], byte '1' |
58 | mov [ecx+5], dword '/KOL' |
||
59 | mov [ecx+9], dword 'IBRI' |
||
60 | mov [ecx+13], byte 0 |
||
61 | .next_cd: |
||
62 | mov [ecx+2], byte ah |
||
63 | inc ah |
||
64 | cmp ah, '5' |
||
6502 | pathoswith | 65 | je @f |
2288 | clevermous | 66 | lea edx, [buff] |
67 | pushad |
||
68 | stdcall read_file, read_firstapp, edx, 0, 4 |
||
69 | popad |
||
70 | cmp [edx], dword 'MENU' |
||
71 | jne .next_cd |
||
6502 | pathoswith | 72 | @@: |
73 | ret |
||
8091 | dunkaist | 74 | end if |
3780 | Serge | 75 | |
6502 | pathoswith | 76 | .hard_disk: |
77 | sub al, '1' |
||
78 | mov [ecx], dword 'HD?/' |
||
2288 | clevermous | 79 | mov [ecx+2], byte al |
80 | mov [ecx+4], byte ah |
||
81 | mov [ecx+5], dword '/KOL' |
||
82 | mov [ecx+9], dword 'IBRI' |
||
83 | mov [ecx+13], byte 0 |
||
84 | ret |
||
85 | endp |
||
86 | |||
6471 | pathoswith | 87 | cp866toUpper: |
88 | ; convert cp866 character in al to uppercase |
||
89 | cmp al, 'a' |
||
6262 | pathoswith | 90 | jb .ret |
6471 | pathoswith | 91 | cmp al, 'z' |
92 | jbe @f |
||
93 | cmp al, 0xA0 |
||
6262 | pathoswith | 94 | jb .ret |
6471 | pathoswith | 95 | cmp al, 0xB0 |
96 | jb @f |
||
97 | cmp al, 0xE0 |
||
98 | jb .ret |
||
99 | cmp al, 0xF0 |
||
6262 | pathoswith | 100 | jb .rus |
6471 | pathoswith | 101 | cmp al, 0xF7 |
6262 | pathoswith | 102 | ja .ret |
6471 | pathoswith | 103 | and eax, -2 |
6262 | pathoswith | 104 | .ret: |
105 | ret |
||
106 | |||
6471 | pathoswith | 107 | @@: |
108 | sub eax, 32 |
||
6262 | pathoswith | 109 | ret |
110 | |||
6471 | pathoswith | 111 | .rus: |
112 | sub eax, 0xE0-0x90 |
||
6262 | pathoswith | 113 | ret |
114 | |||
6471 | pathoswith | 115 | utf16toUpper: |
116 | ; convert UTF-16 character in ax to uppercase |
||
117 | cmp ax, 'a' |
||
6262 | pathoswith | 118 | jb .ret |
6471 | pathoswith | 119 | cmp ax, 'z' |
120 | jbe @f |
||
121 | cmp ax, 430h |
||
6262 | pathoswith | 122 | jb .ret |
6471 | pathoswith | 123 | cmp ax, 450h |
124 | jb @f |
||
125 | cmp ax, 460h |
||
126 | jnc .ret |
||
127 | sub eax, 80 |
||
6262 | pathoswith | 128 | .ret: |
129 | ret |
||
130 | |||
6471 | pathoswith | 131 | @@: |
132 | sub eax, 32 |
||
6262 | pathoswith | 133 | ret |
134 | |||
135 | uni2ansi_char: |
||
136 | ; convert UNICODE character in ax to ANSI character in al using cp866 encoding |
||
137 | cmp ax, 0x80 |
||
138 | jb .ret |
||
139 | cmp ax, 0xB6 |
||
140 | jz .B6 |
||
141 | cmp ax, 0x400 |
||
142 | jb .unk |
||
143 | cmp ax, 0x410 |
||
144 | jb @f |
||
145 | cmp ax, 0x440 |
||
146 | jb .rus1 |
||
147 | cmp ax, 0x450 |
||
148 | jb .rus2 |
||
149 | cmp ax, 0x460 |
||
150 | jb @f |
||
151 | .unk: |
||
152 | mov al, '_' |
||
153 | .ret: |
||
154 | ret |
||
155 | |||
156 | .B6: |
||
157 | mov al, 20 |
||
158 | ret |
||
159 | |||
160 | .rus1: ; 0x410-0x43F -> 0x80-0xAF |
||
161 | add al, 0x70 |
||
162 | ret |
||
163 | |||
164 | .rus2: ; 0x440-0x44F -> 0xE0-0xEF |
||
165 | add al, 0xA0 |
||
166 | ret |
||
167 | |||
168 | @@: |
||
169 | push ecx edi |
||
170 | mov ecx, 8 |
||
171 | mov edi, .table |
||
172 | repnz scasb |
||
173 | mov ah, cl |
||
174 | pop edi ecx |
||
175 | jnz .unk |
||
176 | mov al, 0xF7 |
||
177 | sub al, ah |
||
178 | ret |
||
179 | |||
180 | .table db 1, 51h, 4, 54h, 7, 57h, 0Eh, 5Eh |
||
181 | |||
182 | ansi2uni_char: |
||
183 | ; convert ANSI character in al to UNICODE character in ax, using cp866 encoding |
||
184 | movzx eax, al |
||
185 | cmp al, 0x80 |
||
186 | jb @f ; 0x00-0x7F - trivial map |
||
187 | cmp al, 0xB0 |
||
188 | jb .rus ; 0x80-0xAF -> 0x410-0x43F |
||
189 | cmp al, 0xE0 |
||
190 | jb .unk |
||
191 | cmp al, 0xF0 |
||
192 | jb .rus2 ; 0xE0-0xEF -> 0x440-0x44F |
||
193 | cmp al, 0xF8 |
||
194 | jnc .unk |
||
195 | mov al, [eax+uni2ansi_char.table-0xF0] |
||
196 | add ax, 400h |
||
197 | ret |
||
198 | |||
199 | @@: |
||
200 | cmp al, 20 |
||
201 | jnz .ret |
||
202 | mov al, 0xB6 |
||
203 | .ret: |
||
204 | ret |
||
205 | |||
206 | .rus: |
||
207 | add ax, 0x410-0x80 |
||
208 | ret |
||
209 | |||
210 | .rus2: |
||
211 | add ax, 0x440-0xE0 |
||
212 | ret |
||
213 | |||
214 | .unk: |
||
215 | mov al, '_' |
||
216 | ret |
||
6462 | pathoswith | 217 | |
6471 | pathoswith | 218 | cp866toUTF8_string: |
219 | ; in: |
||
220 | ; esi -> cp866 string (could be zero terminated) |
||
221 | ; edi -> buffer for UTF-8 string |
||
222 | ; ecx = buffer size (signed) |
||
223 | lodsb |
||
224 | call ansi2uni_char |
||
225 | push eax |
||
226 | call UTF16to8 |
||
227 | pop eax |
||
228 | js @f |
||
229 | test eax, eax |
||
230 | jnz cp866toUTF8_string |
||
231 | @@: |
||
232 | ret |
||
6462 | pathoswith | 233 | |
6471 | pathoswith | 234 | ; SF=1 -> counter |
235 | ; ZF=1 -> zero char |
||
236 | |||
237 | UTF16to8_string: |
||
6462 | pathoswith | 238 | ; in: |
6471 | pathoswith | 239 | ; esi -> UTF-16 string (could be zero terminated) |
240 | ; edi -> buffer for UTF-8 string |
||
241 | ; ecx = buffer size (signed) |
||
242 | xor eax, eax |
||
243 | @@: |
||
244 | lodsw |
||
245 | push eax |
||
246 | call UTF16to8 |
||
247 | pop eax |
||
248 | js @f |
||
249 | test eax, eax |
||
250 | jnz @b |
||
251 | @@: |
||
252 | ret |
||
253 | |||
254 | UTF16to8: |
||
255 | ; in: |
||
256 | ; eax = UTF-16 char |
||
257 | ; edi -> buffer for UTF-8 char (increasing) |
||
258 | ; ecx = byte counter (decreasing) |
||
6462 | pathoswith | 259 | dec ecx |
260 | js .ret |
||
6471 | pathoswith | 261 | cmp eax, 80h |
262 | jnc @f |
||
263 | stosb |
||
264 | test eax, eax ; SF=0 |
||
265 | .ret: |
||
266 | ret |
||
267 | |||
268 | @@: |
||
269 | dec ecx |
||
270 | js .ret |
||
271 | cmp eax, 800h |
||
272 | jnc @f |
||
273 | shl eax, 2 |
||
274 | shr al, 2 |
||
275 | or eax, 1100000010000000b |
||
276 | xchg al, ah |
||
277 | stosw |
||
278 | ret |
||
279 | |||
280 | @@: |
||
281 | dec ecx |
||
282 | js .ret |
||
283 | shl eax, 4 |
||
284 | shr ax, 2 |
||
285 | shr al, 2 |
||
286 | or eax, 111000001000000010000000b |
||
287 | bswap eax |
||
288 | shr eax, 8 |
||
289 | stosb |
||
290 | shr eax, 8 |
||
291 | stosw |
||
292 | ret |
||
293 | |||
294 | utf8to16: |
||
295 | ; in: esi -> UTF-8 char (increasing) |
||
296 | ; out: ax = UTF-16 char |
||
6462 | pathoswith | 297 | lodsb |
298 | test al, al |
||
299 | jns .got |
||
300 | shl al, 2 |
||
301 | jnc utf8to16 |
||
302 | @@: |
||
303 | shl ax, 8 |
||
304 | lodsb |
||
305 | test al, al |
||
306 | jns .got |
||
307 | shl al, 2 |
||
308 | jc @b |
||
309 | shr ah, 2 |
||
310 | shl ax, 3 |
||
311 | jnc @f |
||
312 | shl eax, 3 |
||
313 | lodsb |
||
314 | test al, al |
||
315 | jns .got |
||
316 | shl al, 2 |
||
317 | jc @b |
||
318 | shr eax, 2 |
||
319 | ret |
||
320 | |||
321 | @@: |
||
322 | shr ax, 5 |
||
323 | ret |
||
324 | |||
325 | .got: |
||
326 | xor ah, ah |
||
327 | ret |
||
328 | |||
329 | strlen: |
||
330 | ; in: esi -> source |
||
331 | ; out: ecx = length |
||
332 | push edi eax |
||
333 | or ecx, -1 |
||
334 | mov edi, esi |
||
335 | xor eax, eax |
||
336 | repnz scasb |
||
337 | inc ecx |
||
338 | not ecx |
||
339 | pop eax edi |
||
340 | ret |