Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1065 Lrz 1
; Copyright (c) 2009, 
2
; All rights reserved.
3
;
4
; Redistribution and use in source and binary forms, with or without
5
; modification, are permitted provided that the following conditions are met:
6
;       * Redistributions of source code must retain the above copyright
7
;       notice, this list of conditions and the following disclaimer.
8
;       * Redistributions in binary form must reproduce the above copyright
9
;       notice, this list of conditions and the following disclaimer in the
10
;       documentation and/or other materials provided with the distribution.
11
;       * Neither the name of the  nor the
12
;       names of its contributors may be used to endorse or promote products
13
;       derived from this software without specific prior written permission.
14
;
15
; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka  ''AS IS'' AND ANY
16
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
19
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
;*****************************************************************************
26
 
27
; тут описываются процедуры которые используются в secondary loader
2434 Serge 28
color_sym_black equ     0
29
color_sym_blue  equ     1
30
color_sym_green equ     2
1065 Lrz 31
color_sym_turquoise equ 3
2434 Serge 32
color_sym_red   equ     4
1065 Lrz 33
 
34
color_sym_lightgray equ 7
35
 
2434 Serge 36
color_sym_lightblue equ 9
1065 Lrz 37
color_sym_lettuce   equ 10
2434 Serge 38
color_sym_pink  equ     12
39
color_sym_yellow equ    14
40
color_sym_white equ     15
1065 Lrz 41
if DEBUG
42
decode:
43
;input eax - число, es:di куда писать, cx=10
2434 Serge 44
        cmp     eax, ecx
1065 Lrz 45
        jb      @f
2434 Serge 46
        xor     edx, edx
1065 Lrz 47
        div     ecx
48
        push    edx
49
        call    decode
50
        pop     eax
2434 Serge 51
    @@:
52
        or      al, 0x30
53
        mov     [ds:di], al
1065 Lrz 54
        inc     di
55
        ret
56
 
57
end if
58
 
59
 
60
putchar:
61
; in: al=character
62
        mov     ah, 0Eh
63
        mov     bh, 0
64
        int     10h
65
        ret
66
 
67
printplain:
68
; in: si->string
1231 Lrz 69
        pushad
1065 Lrz 70
        lodsb
71
@@:
72
        call    putchar
73
        lodsb
2434 Serge 74
        test    al, al
1065 Lrz 75
        jnz     @b
2434 Serge 76
        mov     al, 13
1065 Lrz 77
        call    putchar
78
 
2434 Serge 79
        mov     al, 10
1065 Lrz 80
        call    putchar
1231 Lrz 81
        popad
1065 Lrz 82
        ret
83
getkey:
84
; get number in range [bl,bh] (bl,bh in ['0'..'9'])
85
; in: bx=range
86
; out: ax=digit (1..9, 10 for 0)
87
        mov     ah, 0
88
        int     16h
89
        cmp     al, bl
90
        jb      getkey
91
        cmp     al, bh
92
        ja      getkey
93
        push    ax
94
        call    putchar
95
        pop     ax
96
        and     ax, 0Fh
97
        jnz     @f
98
        mov     al, 10
99
@@:
100
        ret
101
 
102
;setcursor:
103
; in: dl=column, dh=row
104
;        mov     ah, 2
105
;        mov     bh, 0
106
;        int     10h
107
;        ret
108
 
109
;macro _setcursor row,column
110
;{
111
;        mov     dx, row*256 + column
112
;        call    setcursor
113
;}
114
 
115
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
116
;
117
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
118
get_firs_sym:
119
.start:
2434 Serge 120
        mov     al, byte [es:di]
121
        inc     di
122
        dec     cx
123
        jcxz    .exit
1065 Lrz 124
 
2434 Serge 125
        cmp     al, 0xa         ;cmp al,0xa
126
        jz      ._entry
1065 Lrz 127
 
2434 Serge 128
        cmp     al, ';'
129
        jnz     .start
1065 Lrz 130
 
131
.first_com:
132
 
2434 Serge 133
        mov     al, 0xa
134
        repnz scasb
1065 Lrz 135
        jcxz    .exit
136
._entry:
2434 Serge 137
        mov     al, byte [es:di]
1065 Lrz 138
.first_sp:
2434 Serge 139
        cmp     al, ' '
140
        jnz     .not_space
1065 Lrz 141
 
2434 Serge 142
;       mov     al,' '          ;cut ' '
143
        repe scasb
144
        dec     di
145
        inc     cx
146
        mov     al, byte [es:di]
1065 Lrz 147
.not_space:
2434 Serge 148
        cmp     al, ';'
149
        jz      .first_com
150
.exit:
151
        ret
1065 Lrz 152
;;;;;;;;;;;;;;;;;;;;;;;;;;;
153
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
154
show_name_section:
2434 Serge 155
        push    si
156
        push    ini_data_
157
        pop     es
1065 Lrz 158
 
159
 
2434 Serge 160
        mov     al, ']'
161
        repnz scasb
162
        test    cx, cx
163
        jz      error.incorect_section_def
1065 Lrz 164
.find_val_name_fb1:
2434 Serge 165
        mov     al, 'n'
1065 Lrz 166
.find_val_name_fb:
2434 Serge 167
        repnz scasb
168
        jcxz    .not_name_sec_fb
1065 Lrz 169
 
2434 Serge 170
        mov     si, parse_name
1065 Lrz 171
 
2434 Serge 172
        push    cx
173
        push    di
1065 Lrz 174
 
2434 Serge 175
        mov     cx, parse_name_e -parse_name
176
        repe cmpsb
177
        pop     di
178
        pop     cx
179
        jz      .yaaa_find_value
1065 Lrz 180
 
181
 
2434 Serge 182
        jmp     .find_val_name_fb
1065 Lrz 183
 
184
.yaaa_find_value:
2434 Serge 185
        sub     cx, parse_name_e -parse_name
186
        add     di, parse_name_e -parse_name
1065 Lrz 187
 
2434 Serge 188
        mov     ax, 0x3d20         ; ah='='
189
        repe scasb
190
        test    cx, cx
191
        jz      .not_name_sec_fb
1065 Lrz 192
 
2434 Serge 193
        cmp     ah, byte [es:di-1]   ;find '='
194
        jnz     .find_val_name_fb1
195
 
196
        repe scasb                 ;cut ' '
197
        inc     cx
198
        dec     di
1065 Lrz 199
 
200
 
201
;все вырезали и все готово для вывода имени секции ))
2434 Serge 202
        push    es
203
        pop     ds
1065 Lrz 204
 
205
.def_sect_name:
2434 Serge 206
        push    0xb800
207
        pop     es
1065 Lrz 208
;clear array for message
2434 Serge 209
        xor     ax, ax
1065 Lrz 210
if DEBUG
2434 Serge 211
        mov     ax, 0x0720
1065 Lrz 212
end if
213
 
2434 Serge 214
        mov     cx, 39
215
        mov     si, di
216
        mov     di, dx
217
        sub     di, 2
218
        rep stosw
1065 Lrz 219
;//////////////////////
220
 
221
 
2434 Serge 222
        mov     di, dx
223
        mov     ah, color_sym_white;color_sym_lightblue
224
        mov     cx, 36
225
        lodsb
226
        sub     di, 2
227
        cmp     al, '"'
228
        jz      @f
229
        cmp     al, "'"
230
        jnz     .end_sh_name_sec
1065 Lrz 231
@@:
2434 Serge 232
        lodsb
233
@@:
234
        stosw
235
        lodsb
236
        cmp     al, '"'
237
        jz      .end_sh_name_sec
238
        cmp     al, "'"
239
        jz      .end_sh_name_sec
240
        loop    @b
241
 
242
        mov     al, '}'
243
        mov     ah, color_sym_yellow
244
        stosw
1065 Lrz 245
.end_sh_name_sec:
2434 Serge 246
        push    cs
247
        pop     ds
1065 Lrz 248
 
2434 Serge 249
        pop     si
250
        ret
1065 Lrz 251
 
252
.not_name_sec_fb:    ;нет имени в названии секции - значит так и скажем об этом
2434 Serge 253
        push    cs
254
        pop     ds
255
        mov     di, default_section_name
256
        jmp     .def_sect_name
1065 Lrz 257
 
258
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
259
;процедура поиска вверх следующей секции
260
;в point_default содержиться указатель на дефаулт секцию, и в пределах врейма мы бегаем по заранее пропарсеными значениям указателей
261
;для того что бы отобразить и пропарсить следующий фрейм, нам нужно получить за пердыдущий или следующий указатель
262
find_before_sect:
2434 Serge 263
        mov     di, point_default
1065 Lrz 264
.e:
2434 Serge 265
        push    ini_data_
266
        pop     es
267
        mov     cx, di  ;предположим будем просматривать к началу, текущая позиция di = сколько символов от начала документа имеется
268
        mov     bx, cx  ;копия
1065 Lrz 269
 
270
;настроили указатель на дефаулт секцию
271
;будем искать вверх
272
.find_start_section:
2434 Serge 273
        std     ;установка флага направления - будем просматирвать к началу нашего ини файла
1065 Lrz 274
;будем искать начало секции т.е. '[' этот символ
2434 Serge 275
        mov     al, 0xa
276
        repnz scasb     ;просканируем на наличее символа начала секции
277
        jcxz    .go_    ;мы просмотрели до начала файла, но так и ничего не нашли ;(( по тихому выйдем )
1065 Lrz 278
 
2434 Serge 279
        mov     find_sec_di, di ;сохраним данные
280
        mov     cx, di ;
1065 Lrz 281
 
2434 Serge 282
        sub     bx, cx
283
        mov     cx, bx  ;в сx значение - кол-во символов
284
        cld
285
        call    get_firs_sym
1065 Lrz 286
.ret_go:
2434 Serge 287
        jcxz    ._not_section   ; в данном случае имеем конструкцию 0xa ... ; hello [секция] обломс ищем далее
1065 Lrz 288
 
2434 Serge 289
        cmp     di, point_loader; секцию loader мы не заносим иначе крах
290
        jz      ._not_section
1065 Lrz 291
;все удачно мы нашли вхождение секции предыдущей
2434 Serge 292
        cmp     al, '['
293
        jnz     ._not_section
294
        mov     point_default, di
1065 Lrz 295
.exit_scan_sect:
2434 Serge 296
        ret
1065 Lrz 297
;;;;;;;; восстановим значения и продолжим поиски начала секции которая нас устроит ))
298
._not_section:
2434 Serge 299
        mov     di, find_sec_di
300
        mov     cx, di
301
        mov     bx, cx
302
        jmp     .find_start_section
1065 Lrz 303
.go_:
2434 Serge 304
        cld
305
        mov     cx, bx  ;в сx значение - кол-во символов
1065 Lrz 306
 
2434 Serge 307
        mov     al, byte [es:di]
308
        push    word .f_go
309
        cmp     al, ' '
310
        jz      @f
311
        jmp     get_firs_sym.not_space
1065 Lrz 312
@@:
2434 Serge 313
        jmp     get_firs_sym.first_sp
1065 Lrz 314
 
315
.f_go:
2434 Serge 316
        jcxz    .exit_scan_sect ; в данном случае имеем конструкцию 0xa ... ; hello [секция] обломс ищем далее
1065 Lrz 317
 
2434 Serge 318
        cmp     di, point_loader; секцию loader мы не заносим иначе крах
319
        jz      .exit_scan_sect
1065 Lrz 320
;все удачно мы нашли вхождение секции предыдущей
2434 Serge 321
        cmp     al, '['
322
        jnz     .exit_scan_sect
323
        mov     point_default, di
324
        ret
1065 Lrz 325
 
326
 
327
 
328
 
329
 
330
 
331
 
332
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
333
;
334
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
335
find_next_sect:
2434 Serge 336
        mov     di, point_default
337
        push    ini_data_
338
        pop     es
339
        mov     cx, save_cx;di   ;предположим будем просматривать к концу, текущая позиция di = сколько символов от начала документа имеется
340
        sub     cx, di  ;сейчас в cx остаток т.е.  сколько можно крутить до конца и не вылазить на начало
341
        jmp     .let_s_go
1065 Lrz 342
.h:
2434 Serge 343
        push    ini_data_
344
        pop     es
345
        mov     cx, save_cx;di   ;предположим будем просматривать к концу, текущая позиция di = сколько символов от начала документа имеется
346
;       sub     cx,di   ;сейчас в cx остаток т.е.  сколько можно крутить до конца и не вылазить на начало
1065 Lrz 347
 
2434 Serge 348
        mov     al, byte [es:di]
349
        push    word .let_s_go_ret
350
        cmp     al, ' '
351
        jz      @f
352
        jmp     get_firs_sym.not_space
1065 Lrz 353
@@:
2434 Serge 354
        jmp     get_firs_sym.first_sp
1065 Lrz 355
 
356
 
357
 
358
 
359
;настроили указатель на дефаулт секцию
360
;будем искать вниз
361
.let_s_go:
2434 Serge 362
        call    get_firs_sym
1065 Lrz 363
.let_s_go_ret:
2434 Serge 364
        jcxz    .exit_scan_sect ; в данном случае имеем конструкцию 0xa ... ; hello [секция] обломс ищем далее
365
        cmp     al, '['
366
        jnz     .let_s_go
367
        cmp     di, point_loader
368
        jz      .let_s_go
1065 Lrz 369
;все удачно мы нашли вхождение секции предыдущей
2434 Serge 370
        mov     point_default, di
1065 Lrz 371
.exit_scan_sect:
2434 Serge 372
        ret
1065 Lrz 373
 
374
;;;;;;;;;;;;;;;;;;;;;;;;;;
375
;clean old cursor
376
clean_active_cursor:
377
;не изменяет значение ax
378
;отображение курсора по умолчанию
2434 Serge 379
        lea     si, point_to_hframe
380
        mov     di, 962-160
381
        mov     dx, point_default
382
        mov     cx, 18
1065 Lrz 383
.clean_show_cur:
2434 Serge 384
        mov     bx, [si]
385
        add     di, 160
386
        cmp     bx, dx
387
        jz      .clean_cursor_
388
        sub     si, 2
389
        loop    .clean_show_cur
1065 Lrz 390
 
2434 Serge 391
;       jmp $
1065 Lrz 392
 
393
.clean_cursor_:
2434 Serge 394
        push    0xb800
395
        pop     es
396
        push    ax
397
        mov     point_to_point_def, si
398
        xor     ax, ax
1065 Lrz 399
if DEBUG
2434 Serge 400
        mov     ax, 0x0720
1065 Lrz 401
end if
2434 Serge 402
        stosw
403
        add     di, 68
404
        stosw
405
        pop     ax
406
        ret
1065 Lrz 407
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
408
;установка таймера и отображение счетчика времени
409
gettime:
2434 Serge 410
        mov     ah, 0
1065 Lrz 411
        int     1Ah
412
        xchg    ax, cx
413
        shl     eax, 10h
414
        xchg    ax, dx
415
        ret
416
newtimer:
2434 Serge 417
        push    ds
1065 Lrz 418
 
419
        push    cs
420
        pop     ds
421
 
422
        pushf
2434 Serge 423
        call    far dword [old_timer]
1065 Lrz 424
 
425
        pushad
426
        call    gettime
427
 
428
        sub     eax, dword[start_timer]
2434 Serge 429
        mov     bx, word [value_timeout]
430
        imul    bx, 18
1065 Lrz 431
        sub     bx, ax
432
        jbe     .timergo
433
 
2434 Serge 434
        push    es
1065 Lrz 435
 
2434 Serge 436
        push    0xb800
437
        pop     es
438
        mov     ax, bx
1065 Lrz 439
 
440
        mov     bx, 18
441
        xor     dx, dx
442
        div     bx
443
 
2434 Serge 444
        mov     bx, 10
445
        mov     di, 3734
446
        call    .decode
1065 Lrz 447
 
2434 Serge 448
        xor     ax, ax
449
        stosw
1065 Lrz 450
 
451
; wait 5/4/3/2 seconds, 1 second
2434 Serge 452
        pop     es
1065 Lrz 453
        popad
2434 Serge 454
        pop     ds
1065 Lrz 455
 
456
        iret
457
.timergo:
458
        push    0
459
        pop     es
2434 Serge 460
        mov     eax, dword [old_timer]
1065 Lrz 461
        mov     [es:8*4], eax
2434 Serge 462
        mov     dword [timer_], eax
463
        mov     sp, word [start_stack]
464
        mov     bp, word [save_bp_from_timer]
1065 Lrz 465
;;не восстановленый стек :(
2434 Serge 466
        sti
467
        jmp     parse_start.parse_run_only
1065 Lrz 468
 
469
 
470
.decode:
471
;input ax - число, es:di куда писать, bx=10
2434 Serge 472
        cmp     ax, bx
1065 Lrz 473
        jb      @f
2434 Serge 474
        xor     dx, dx
1065 Lrz 475
        div     bx
476
        push    dx
477
        call    .decode
478
        pop     ax
2434 Serge 479
    @@:
480
        or      al, 0x30
481
        push    ax
482
        mov     ah, 9
1065 Lrz 483
        stosw
2434 Serge 484
        pop     ax
1065 Lrz 485
        ret
486
 
487
show_bl_sc_sect:
488
;1) отображение списка секций. Если секция не имет имя - ошибка - вывод Section unname
489
;проверка на наличее имени.
490
;входные данные es:di -указатель на секцию - cx размер секции
2434 Serge 491
;       push    bp
492
        mov     bx, point_to_eframe
493
        lea     si, point_to_hframe
494
        mov     dx, 966
1065 Lrz 495
 
496
.home_show_fb:
2434 Serge 497
        cmp     si, bx
498
        jb      ._show_space_fb
499
        mov     di, [si]
500
        sub     si, 2
501
        mov     cx, [si]
502
        sub     cx, di          ;home first section it's end before section
503
        call    show_name_section
504
        add     dx, 160
505
        jmp     .home_show_fb
1065 Lrz 506
._show_space_fb:
2434 Serge 507
        sub     dx, 4
508
        push    0xb800
509
        pop     es
1065 Lrz 510
@@:
2434 Serge 511
        cmp     dx, 0xE64
512
        ja      .exit_show_fb
513
        mov     di, dx
1065 Lrz 514
;clear array for message
2434 Serge 515
        xor     ax, ax
1065 Lrz 516
if DEBUG
2434 Serge 517
        mov     ax, 0x0720
1065 Lrz 518
end if
2434 Serge 519
        mov     cx, 39
520
        rep stosw
1065 Lrz 521
;//////////////////////
522
 
2434 Serge 523
        add     dx, 160
524
        jmp     @b
1065 Lrz 525
.exit_show_fb:
2434 Serge 526
;        pop    bp
527
        ret
1065 Lrz 528