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