Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
849 serge 1
 
2
3
 
1 ha 4
;;
5
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved.
709 diamond 6
;; PROGRAMMING:
431 serge 7
;; Ivan Poddubny
8
;; Marat Zakiyanov (Mario79)
9
;; VaStaNi
10
;; Trans
11
;; Mihail Semenyako (mike.dld)
12
;; Sergey Kuzmin (Wildwest)
13
;; Andrey Halyavin (halyavin)
14
;; Mihail Lisovin (Mihasik)
15
;; Andrey Ignatiev (andrew_programmer)
16
;; NoName
17
;; Evgeny Grechnikov (Diamond)
18
;; Iliya Mihailov (Ghost)
19
;; Sergey Semyonov (Serge)
20
;; Johnny_B
21
;; SPraid (simba)
543 spraid 22
;;
1 ha 23
;; Data in this file was originally part of MenuetOS project which is
431 serge 24
;; distributed under the terms of GNU GPL. It is modified and redistributed as
25
;; part of KolibriOS project under the terms of GNU GPL.
26
;;
1 ha 27
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa
431 serge 28
;; PROGRAMMING:
29
;;
1 ha 30
;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi
431 serge 31
;; - main os coding/design
32
;; Jan-Michael Brummer, BUZZ2@gmx.de
33
;; Felix Kaiser, info@felix-kaiser.de
34
;; Paolo Minazzi, paolo.minazzi@inwind.it
35
;; quickcode@mail.ru
36
;; Alexey, kgaz@crosswinds.net
37
;; Juan M. Caravaca, bitrider@wanadoo.es
38
;; kristol@nic.fi
39
;; Mike Hibbett, mikeh@oceanfree.net
40
;; Lasse Kuusijarvi, kuusijar@lut.fi
41
;; Jarek Pelczar, jarekp3@wp.pl
42
;;
1 ha 43
;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY
431 serge 44
;; WARRANTY. No author or distributor accepts responsibility to anyone for the
45
;; consequences of using it or for whether it serves any particular purpose or
46
;; works at all, unless he says so in writing. Refer to the GNU General Public
47
;; License (the "GPL") for full details.
48
;
49
;; Everyone is granted permission to copy, modify and redistribute KolibriOS,
50
;; but only under the conditions described in the GPL. A copy of this license
51
;; is supposed to have been given to you along with KolibriOS so you can know
52
;; your rights and responsibilities. It should be in a file named COPYING.
53
;; Among other things, the copyright notice and this notice must be preserved
54
;; on all copies.
55
;;
56
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1 ha 57
426 mikedld 58
 
59
60
 
425 victor 61
426 mikedld 62
 
593 mikedld 63
 
841 serge 64
65
 
769 Rus 66
566 serge 67
 
164 serge 68
include "kglobals.inc"
7 me_root 69
include "lang.inc"
1 ha 70
71
 
164 serge 72
max_processes	 equ   255
742 Rus 73
tss_step	 equ   (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
74
1 ha 75
 
928 serge 76
164 serge 77
 
928 serge 78
sel_os_stack    equ  (os_stacK_l - _gdts)      ;0x18
79
1 ha 80
 
928 serge 81
sel_app_data    equ  (app_data_l - _gdts +3)   ;0x2B
82
1 ha 83
 
928 serge 84
sel_srv_stack   equ  (srv_stack_l- _gdts +1)   ;0x39
85
86
 
87
sel_pci_data    equ  (pci_data_32-_gdts)       ;0x48
88
89
 
90
91
 
92
93
 
1 ha 94
;;
95
;;   Included files:
96
;;
97
;;   Kernel16.inc
98
;;    - Booteng.inc   English text for bootup
99
;;    - Bootcode.inc  Hardware setup
100
;;    - Pci16.inc     PCI functions
101
;;
102
;;   Kernel32.inc
103
;;    - Sys32.inc     Process management
104
;;    - Shutdown.inc  Shutdown and restart
105
;;    - Fat32.inc     Read / write hd
106
;;    - Vesa12.inc    Vesa 1.2 driver
107
;;    - Vesa20.inc    Vesa 2.0 driver
108
;;    - Vga.inc       VGA driver
109
;;    - Stack.inc     Network interface
110
;;    - Mouse.inc     Mouse pointer
111
;;    - Scincode.inc  Window skinning
112
;;    - Pci32.inc     PCI functions
113
;;
114
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
115
116
 
117
 
851 serge 118
public _sys_pdbr
119
public _gdts
120
849 serge 121
 
854 serge 122
public _panic_printf
123
public _printf
124
public _pg_balloc
125
public _mem_amount
126
public @balloc@4
127
128
 
928 serge 129
849 serge 130
 
859 serge 131
public _rd_fat
132
public _rd_fat_end
133
public _rd_root
134
public _rd_root_end
135
136
 
996 serge 137
public _current_slot
908 serge 138
public _current_thread
928 serge 139
public _k_reenter
140
908 serge 141
 
889 serge 142
863 serge 143
 
897 serge 144
145
 
908 serge 146
public pe_app_param
897 serge 147
public _init_user_heap
908 serge 148
897 serge 149
 
908 serge 150
public user_free
151
928 serge 152
 
889 serge 153
154
 
890 serge 155
156
 
157
public _DestroyObject       ;         export
158
159
 
160
public _CommitPages         ;         export
161
public _GetPgAddr           ;         export
162
public _MapIoMem            ; stdcall export
163
public _UnmapPages          ;         export
164
165
 
166
public _Kfree               ;         export
167
public _UserAlloc           ; stdcall export
168
public _UserFree            ; stdcall export
169
170
 
171
public _SysMsgBoardStr      ;         export
172
public _SetScreen           ;         export    FIXME  make fastcall
173
174
 
175
public _PciRead8            ; stdcall export
176
public _PciRead16           ; stdcall export
177
public _PciRead32           ; stdcall export
178
public _PciWrite8           ; stdcall export
179
public _PciWrite16          ; stdcall export
180
public _PciWrite32          ; stdcall export
181
182
 
183
public _SetHwCursor         ; stdcall export
184
public _HwCursorRestore     ;         export
185
public _HwCursorCreate      ;         export
186
187
 
928 serge 188
public init_fpu
189
public init_malloc
190
public init_mtrr
191
890 serge 192
 
928 serge 193
public syscall_entry
194
195
 
196
public LFBAddress
197
public LFBSize
198
199
 
996 serge 200
public _screen_height
201
928 serge 202
 
996 serge 203
204
 
205
 
863 serge 206
207
 
928 serge 208
209
 
210
211
 
855 serge 212
extrn _16bit_end
213
214
 
928 serge 215
 
863 serge 216
1 ha 217
 
864 serge 218
extrn @core_free@4
887 serge 219
864 serge 220
 
859 serge 221
886 serge 222
 
890 serge 223
extrn _MemFree
224
854 serge 225
 
890 serge 226
@mem_free@4         equ  _MemFree
227
228
 
928 serge 229
extrn  _sys_exec
897 serge 230
231
 
232
extrn @load_pe_driver@4
889 serge 233
234
 
854 serge 235
236
 
859 serge 237
238
 
851 serge 239
849 serge 240
 
897 serge 241
864 serge 242
 
928 serge 243
244
 
245
246
 
247
extrn cpu_sign
248
extrn cpu_info
249
extrn cpu_caps:dword
250
251
 
252
 
253
 
854 serge 254
1 ha 255
 
851 serge 256
1 ha 257
 
848 serge 258
847 serge 259
 
848 serge 260
261
 
847 serge 262
        ;   bts [cpu_caps-OS_BASE], CAPS_TSC     ;force use rdtsc
854 serge 263
424 spraid 264
 
847 serge 265
837 serge 266
 
848 serge 267
1 ha 268
 
513 serge 269
;bios32_entry    dd ?
854 serge 270
;tmp_page_tabs   dd ?
271
586 serge 272
 
498 diamond 273
 
465 serge 274
__DEBUG_LEVEL__ fix 1
275
380 serge 276
 
848 serge 277
 
839 serge 278
MEM_WC     equ 1               ;write combined memory
279
MEM_UC     equ 0               ;uncached memory
280
281
 
282
 
854 serge 283
           cli
284
@@:
285
           hlt
286
           jmp @B
287
839 serge 288
 
854 serge 289
_panic_printf:
290
839 serge 291
 
854 serge 292
           jmp _printf
293
294
 
839 serge 295
include 'printf.inc'
854 serge 296
297
 
928 serge 298
847 serge 299
 
300
init_apm:
928 serge 301
; init selectors
465 serge 302
    mov ebx,    [OS_BASE +0x9040]    ; offset of APM entry point
996 serge 303
    movzx eax, word [OS_BASE+0x9050] ; real-mode segment base address of
304
				      ; protected-mode 32-bit code segment
742 Rus 305
    movzx ecx, word [OS_BASE+0x9052] ; real-mode segment base address of
996 serge 306
				      ; protected-mode 16-bit code segment
742 Rus 307
    movzx edx, word [OS_BASE+0x9054] ; real-mode segment base address of
996 serge 308
				      ; protected-mode 16-bit data segment
742 Rus 309
465 serge 310
 
311
    mov    [dword apm_code_32 + 2], ax
312
    shr    eax, 16
313
    mov    [dword apm_code_32 + 4], al
314
315
 
316
    mov    [dword apm_code_16 + 2], cx
317
    shr    ecx, 16
318
    mov    [dword apm_code_16 + 4], cl
319
320
 
321
    mov    [dword apm_data_16 + 2], dx
322
    shr    edx, 16
323
    mov    [dword apm_data_16 + 4], dl
324
325
 
326
    mov    word [apm_entry + 4], apm_code_32 - _gdts
851 serge 327
76 mario79 328
 
996 serge 329
    mov    [apm_vf], eax
76 mario79 330
    ret
928 serge 331
753 serge 332
 
928 serge 333
system_init:
334
848 serge 335
 
928 serge 336
337
 
338
339
 
340
        mov   ax, [OS_BASE + 0x9031]
996 serge 341
        mov   [IDEContrRegsBaseAddr], ax
928 serge 342
343
 
996 serge 344
        mov   [allow_dma_access], al
928 serge 345
346
 
996 serge 347
        mov   [ScreenBPP], eax
928 serge 348
349
 
996 serge 350
        movzx ebx,word [OS_BASE+0x900C]  ; Y max
351
        mov   [_screen_width],  eax
352
        mov   [_screen_height], ebx
353
        dec   eax
928 serge 354
        dec   ebx
996 serge 355
        mov   [Screen_Max_X],eax
928 serge 356
        mov   [screen_workarea.right],eax
357
        mov   [Screen_Max_Y],ebx
996 serge 358
        mov   [screen_workarea.bottom],ebx
359
        mov   [BytesPerScanLine], 640*4
928 serge 360
        cmp   [scr_mode], 0x13      ; 320x200
361
        je    @f
362
        cmp   [scr_mode], 0x12      ; VGA 640x480
363
        je    @f
364
365
 
996 serge 366
        mov   [BytesPerScanLine], eax
928 serge 367
@@:
465 serge 368
        mov esi, OS_BASE+0x9080
996 serge 369
        movzx   ecx, byte [esi-1]
928 serge 370
        mov [NumBiosDisks], ecx
371
        mov edi, BiosDisksData
372
        rep movsd
373
1 ha 374
 
375
376
 
996 serge 377
1 ha 378
 
928 serge 379
        jge setvesa20
380
        cmp [scr_mode], 0x13
381
        je  v20ga32
382
        mov [put_pixel], Vesa12_putpixel24  ; Vesa 1.2
383
        mov [get_pixel],dword Vesa12_getpixel24
384
        cmp byte [ScreenBPP], 24
385
        jz  ga24
386
        mov [put_pixel], Vesa12_putpixel32
387
        mov [get_pixel],dword Vesa12_getpixel32
388
ga24:
389
        jmp v20ga24
390
setvesa20:
391
        mov [put_pixel], Vesa20_putpixel24  ; Vesa 2.0
392
        mov [get_pixel],dword Vesa20_getpixel24
393
        cmp byte [ScreenBPP], 24
394
        jz  v20ga24
395
v20ga32:
396
        mov [put_pixel], Vesa20_putpixel32
397
        mov [get_pixel],dword Vesa20_getpixel32
398
v20ga24:
399
        cmp [scr_mode], 0x12            ; 16 C VGA 640x480
400
        jne no_mode_0x12
401
        mov [put_pixel], VGA_putpixel
402
        mov [get_pixel],dword Vesa20_getpixel32
403
no_mode_0x12:
404
1 ha 405
 
928 serge 406
           mov edx, PG_SW
407
           call @mem_alloc@8
408
           mov [_display_data], eax
409
164 serge 410
 
928 serge 411
                    (unpack.lc+unpack.lp)))*4
412
           mov edx, PG_SW
413
           call @mem_alloc@8
414
           mov [unpack.p], eax
415
375 Ghost 416
 
928 serge 417
375 Ghost 418
 
928 serge 419
           mov [graph_data_l+2],ax
420
           shr eax,16
421
           mov [graph_data_l+4],al
422
           mov [graph_data_l+7],ah
423
378 serge 424
 
864 serge 425
           xor edx, edx
426
           call @mem_alloc@8
427
           mov [default_io_map], eax
928 serge 428
465 serge 429
 
928 serge 430
           mov [ipc_tmp], eax
431
           mov ebx, 0x1000
432
164 serge 433
 
928 serge 434
           mov [proc_mem_map], eax
435
164 serge 436
 
928 serge 437
           mov [proc_mem_pdir], eax
438
164 serge 439
 
928 serge 440
           mov [proc_mem_tab], eax
441
164 serge 442
 
928 serge 443
           mov [tmp_task_pdir], eax
444
164 serge 445
 
928 serge 446
           mov [tmp_task_ptab], eax
447
164 serge 448
 
928 serge 449
           mov [ipc_pdir], eax
450
164 serge 451
 
928 serge 452
           mov [ipc_ptab], eax
453
164 serge 454
 
928 serge 455
           mov eax, srv.fd-SRV_FD_OFFSET
456
           mov [srv.fd], eax
457
           mov [srv.bk], eax
458
278 serge 459
 
928 serge 460
           xor eax, eax
461
           mov ecx, 16
462
           rep stosd
463
164 serge 464
 
928 serge 465
           mov [TASK_COUNT],dword 1
466
           mov [TASK_BASE],dword TASK_DATA
467
           mov [current_slot], SLOT_BASE+256
468
1 ha 469
 
469 serge 470
           xor  eax,eax
928 serge 471
           inc  eax
472
           mov   [BgrDrawMode],eax
473
           mov   [BgrDataWidth],eax
474
           mov   [BgrDataHeight],eax
475
           mov ecx, 4095
476
           mov edx, PG_SW
477
           mov    [mem_BACKGROUND],4095
478
           call @mem_alloc@8
479
           mov [img_background], eax
480
469 serge 481
 
928 serge 482
469 serge 483
 
709 diamond 484
485
 
928 serge 486
709 diamond 487
 
488
           call    init_sys_v86
928 serge 489
709 diamond 490
 
725 diamond 491
492
 
742 Rus 493
	out   0x43,al
494
	mov   al,0x9b		   ; lsb    1193180 / 1193
495
	out   0x40,al
496
	mov   al,0x2e		   ; msb
497
	out   0x40,al
498
725 diamond 499
 
500
; they are used: when partitions are scanned, hd_read relies on timer
501
	mov	al, 0xFE
742 Rus 502
	out	0x21, al
503
	mov	al, 0x3F
504
	out	0xA1, al
505
725 diamond 506
 
256 diamond 507
include 'detect/disks.inc'
508
;!!!!!!!!!!!!!!!!!!!!!!!!!!
509
510
 
521 diamond 511
512
 
1 ha 513
514
 
515
;include 'boot/rdload.inc'
846 serge 516
;!!!!!!!!!!!!!!!!!!!!!!!
1 ha 517
;    mov    [dma_hdd],1
518
; CALCULATE FAT CHAIN FOR RAMDISK
519
520
 
742 Rus 521
1 ha 522
 
523
 
847 serge 524
 ; cmp ax,'r1'           ; if using not ram disk, then load librares and parameters {SPraid.simba}
525
 ; je  no_lib_load
526
; LOADING LIBRARES
488 spraid 527
;   stdcall dll.Load,@IMPORT                 ; loading librares for kernel (.obj files)
847 serge 528
;   call load_file_parse_table               ; prepare file parse table
529
;   call set_kernel_conf                     ; configure devices and gui
530
;no_lib_load:
531
488 spraid 532
 
1 ha 533
534
 
742 Rus 535
        stdcall read_file, char2, FONT_II, 0, 2560
848 serge 536
490 serge 537
 
742 Rus 538
	call  boot_log
539
1 ha 540
 
541
	mov	esi, boot_memdetect
742 Rus 542
	call	boot_log
543
1 ha 544
 
742 Rus 545
	or	ecx, (10+29*6) shl 16 ; "Determining amount of memory"
546
	sub	ecx, 10
547
	mov	edx, 0xFFFFFF
548
        mov     ebx, [_mem_amount]
846 serge 549
	shr	ebx, 20
742 Rus 550
	mov	edi, 1
551
	mov	eax, 0x00040000
552
	call	display_number_force
553
41 mikedld 554
 
465 serge 555
556
 
742 Rus 557
465 serge 558
 
742 Rus 559
	call   boot_log
560
567 serge 561
 
742 Rus 562
567 serge 563
 
1 ha 564
 
565
566
 
742 Rus 567
	call  boot_log
568
	call  setwindowdefaults
569
1 ha 570
 
571
572
 
742 Rus 573
	call  boot_log
574
	call  init_background
575
	call  calculatebackground
576
1 ha 577
 
578
579
 
742 Rus 580
	call  boot_log
581
	call  reserve_irqs_ports
582
1 ha 583
 
584
585
 
742 Rus 586
	call boot_log
587
	;call setirqreadports
769 Rus 588
1 ha 589
 
590
591
 
742 Rus 592
	call boot_log
593
214 serge 594
 
742 Rus 595
	mov  dword [SLOT_BASE+APPDATA.fpu_state], fpu_data
596
	mov  dword [SLOT_BASE+APPDATA.fpu_handler], eax
597
	mov  dword [SLOT_BASE+APPDATA.sse_handler], eax
598
164 serge 599
 
742 Rus 600
281 serge 601
 
742 Rus 602
	mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE '
603
        mov edi,  __os_stack-8192+512
847 serge 604
	mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi
742 Rus 605
	add edi, 0x2000-512
606
	mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi
607
	mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case
608
	mov dword [SLOT_BASE+256+APPDATA.io_map],\
609
		  (tss._io_map_0-OS_BASE+PG_MAP)
610
	mov dword [SLOT_BASE+256+APPDATA.io_map+4],\
611
		  (tss._io_map_1-OS_BASE+PG_MAP)
612
357 serge 613
 
742 Rus 614
	mov ecx, 512/4
615
	cld
616
	rep movsd
617
357 serge 618
 
843 serge 619
	mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax
742 Rus 620
214 serge 621
 
742 Rus 622
	mov  dword [SLOT_BASE+256+APPDATA.fd_obj], ebx
623
	mov  dword [SLOT_BASE+256+APPDATA.bk_obj], ebx
624
281 serge 625
 
742 Rus 626
521 diamond 627
 
742 Rus 628
	mov  [CURRENT_TASK],dword 1
629
	mov  [TASK_COUNT],dword 1
630
	mov  [current_slot], SLOT_BASE+256
631
	mov  [TASK_BASE],dword TASK_DATA
632
	mov  [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number
633
	mov  [TASK_DATA+TASKDATA.pid], 1	; process id number
634
	mov  [TASK_DATA+TASKDATA.mem_start], 0	; process base address
635
1 ha 636
 
843 serge 637
        mov eax, [def_cursor]
802 serge 638
	mov [SLOT_BASE+APPDATA.cursor],eax
742 Rus 639
	mov [SLOT_BASE+APPDATA.cursor+256],eax
640
281 serge 641
 
897 serge 642
      ;  call @load_pe_driver@4
643
837 serge 644
 
465 serge 645
281 serge 646
 
742 Rus 647
	call  boot_log
648
848 serge 649
 
742 Rus 650
	mov   ecx,eax
651
	mov   esi,250		    ; wait 1/4 a second
652
	call  delay_ms
653
	call  _rdtsc
654
848 serge 655
 
742 Rus 656
	shl   eax,2
657
	mov   [CPU_FREQ],eax	      ; save tsc / sec
658
	mov ebx, 1000000
659
	div ebx
660
	mov [stall_mcs], eax
661
1 ha 662
 
663
664
 
742 Rus 665
1 ha 666
 
774 Rus 667
668
 
669
       ; stdcall load_driver, szCOM_MDriver
839 serge 670
774 Rus 671
 
1 ha 672
673
 
839 serge 674
	call  fdc_init
742 Rus 675
1 ha 676
 
677
678
 
928 serge 679
	jne   no_pal_vga
742 Rus 680
	mov   esi,boot_pal_vga
681
	call  boot_log
682
	call  paletteVGA
683
      no_pal_vga:
1 ha 684
685
 
928 serge 686
	jne   no_pal_ega
742 Rus 687
	mov   esi,boot_pal_ega
688
	call  boot_log
689
	call  palette320x200
690
      no_pal_ega:
1 ha 691
692
 
693
694
 
742 Rus 695
1 ha 696
 
465 serge 697
698
 
897 serge 699
         ;  stdcall map_page,esi,(tss._io_map_0-OS_BASE), PG_MAP
861 serge 700
         ;  add esi, 0x1000
701
         ;  stdcall map_page,esi,(tss._io_map_1-OS_BASE), PG_MAP
702
465 serge 703
 
859 serge 704
         ;          (tss._io_map_0-OS_BASE), PG_MAP
705
         ;  stdcall map_page,tss._io_map_1,\
706
         ;          (tss._io_map_1-OS_BASE), PG_MAP
707
465 serge 708
 
847 serge 709
;  cmp ax,'r1'           ; if not rused ram disk - load network configuration from files {SPraid.simba}
710
;  je  no_st_network
711
;        call set_network_conf
712
;  no_st_network:
713
512 spraid 714
 
1 ha 715
501 serge 716
 
897 serge 717
        push 0
718
        push read_firstapp
719
        call _sys_exec
720
        add esp, 12
721
488 spraid 722
 
742 Rus 723
	je    first_app_found
724
501 serge 725
 
742 Rus 726
	call	boot_log
727
653 diamond 728
 
742 Rus 729
	hlt
730
501 serge 731
 
237 serge 732
501 serge 733
 
742 Rus 734
1 ha 735
 
742 Rus 736
	mov   [CURRENT_TASK],dword 1	   ; set OS task fisrt
737
1 ha 738
 
21 poddubny 739
	mov   al, 0xf6	       ; reset keyboard, scan enabled
742 Rus 740
	call  kb_write
741
1 ha 742
 
742 Rus 743
	xor ecx,ecx
744
@@:
841 serge 745
	in     al,64h
742 Rus 746
	and    al,00000010b
747
	loopnz @b
748
1 ha 749
 
742 Rus 750
	call  kb_write
751
;        call  kb_read
265 diamond 752
	mov   al, 0 ; 30 250 ;00100010b ; 24 500  ;00100100b  ; 20 500
742 Rus 753
	call  kb_write
754
;        call  kb_read
265 diamond 755
     ;// mike.dld [
1 ha 756
	call  set_lights
742 Rus 757
     ;// mike.dld ]
1 ha 758
759
 
21 poddubny 760
1 ha 761
 
847 serge 762
;        mov     esi, boot_tasking
763
;        call    boot_log
764
;.bll1:  in      al, 0x60        ; wait for ESC key press
765
;        cmp     al, 129
766
;        jne     .bll1
767
;end if
768
767 diamond 769
 
1 ha 770
771
 
742 Rus 772
	call  boot_log
773
41 mikedld 774
 
848 serge 775
	out   0xA1,al
742 Rus 776
	out   0x21,al
777
1 ha 778
 
742 Rus 779
1 ha 780
 
781
782
 
742 Rus 783
	out   0x20,al
784
	out   0xa0,al
785
1 ha 786
 
742 Rus 787
1 ha 788
 
774 Rus 789
164 serge 790
 
1 ha 791
	cmp	[IDEContrRegsBaseAddr], 0
742 Rus 792
	setnz	[dma_hdd]
793
	mov [timer_ticks_enable],1		; for cd driver
794
1 ha 795
 
742 Rus 796
	call change_task
797
465 serge 798
 
742 Rus 799
465 serge 800
 
725 diamond 801
1 ha 802
 
742 Rus 803
1 ha 804
 
465 serge 805
include 'fdo.inc'
806
807
 
808
boot_log:
809
	 pushad
742 Rus 810
465 serge 811
 
742 Rus 812
	 mov   bx,word [boot_y]
813
	 add   [boot_y],dword 10
814
	 mov   ecx,0x80ffffff	; ASCIIZ string with white color
815
	 mov   edx,esi
816
	 mov   edi,1
817
465 serge 818
 
848 serge 819
820
 
742 Rus 821
	 call  checkVga_N13
822
465 serge 823
 
764 Rus 824
465 serge 825
 
742 Rus 826
465 serge 827
 
828
 
1 ha 829
;                                                                    ;
830
;                    MAIN OS LOOP START                              ;
33 mario79 831
;                                                                    ;
1 ha 832
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
833
align 32
834
osloop:
835
	call   [draw_pointer]
742 Rus 836
	call   checkbuttons
837
	call   checkwindows
838
;       call   check_window_move_request
49 mikedld 839
	call   checkmisc
742 Rus 840
	call   checkVga_N13
841
        call   stack_handler
839 serge 842
	call   checkidle
742 Rus 843
	call   check_fdd_motor_status
844
	call   check_ATAPI_device_event
845
	jmp    osloop
846
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 mario79 847
;                                                                    ;
848
;                      MAIN OS LOOP END                              ;
849
;                                                                    ;
850
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
851
1 ha 852
 
853
	pushad
742 Rus 854
1 ha 855
 
742 Rus 856
	jne  no_idle_state
857
1 ha 858
 
742 Rus 859
	mov  eax,[idlemem]
860
	mov  ebx,[timer_ticks] ;[0xfdf0]
861
	cmp  eax,ebx
862
	jnz  idle_exit
863
	call _rdtsc
864
	mov  ecx,eax
865
      idle_loop:
1 ha 866
	hlt
742 Rus 867
	cmp  [check_idle_semaphore],0
868
	jne  idle_loop_exit
869
	mov  eax,[timer_ticks] ;[0xfdf0]
870
	cmp  ebx,eax
871
	jz   idle_loop
872
      idle_loop_exit:
1 ha 873
	mov  [idlemem],eax
742 Rus 874
	call _rdtsc
875
	sub  eax,ecx
876
	mov  ebx,[idleuse]
877
	add  ebx,eax
878
	mov  [idleuse],ebx
879
1 ha 880
 
742 Rus 881
	ret
882
1 ha 883
 
884
885
 
742 Rus 886
	mov  [idlemem],ebx
887
	call change_task
888
1 ha 889
 
742 Rus 890
	ret
891
1 ha 892
 
893
894
 
742 Rus 895
1 ha 896
 
742 Rus 897
	mov  [idlemem],ebx
898
	call change_task
899
1 ha 900
 
742 Rus 901
	ret
902
1 ha 903
 
904
  idlemem		dd   0x0
742 Rus 905
  idleuse		dd   0x0
906
  idleusesec		dd   0x0
907
  check_idle_semaphore	dd   0x0
908
endg
1 ha 909
910
 
911
 
912
 
913
;                                                                      ;
914
;                   INCLUDED SYSTEM FILES                              ;
915
;                                                                      ;
916
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
917
918
 
919
 
7 me_root 920
1 ha 921
 
922
 
923
;                                                                      ;
924
;                       KERNEL FUNCTIONS                               ;
925
;                                                                      ;
926
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
927
928
 
929
930
 
742 Rus 931
1 ha 932
 
742 Rus 933
	;mov  [irq_owner+4*1], 1    ; keyboard
769 Rus 934
	mov  [irq_owner+4*6], 1    ; floppy diskette
742 Rus 935
	mov  [irq_owner+4*13], 1   ; math co-pros
936
	mov  [irq_owner+4*14], 1   ; ide I
937
	mov  [irq_owner+4*15], 1   ; ide II
938
465 serge 939
 
671 Ghost 940
	mov   edi,1		       ; 0x00-0x2d
742 Rus 941
	mov   [RESERVED_PORTS],edi
942
	shl   edi,4
943
	mov   [RESERVED_PORTS+edi+0],dword 1
944
	mov   [RESERVED_PORTS+edi+4],dword 0x0
945
	mov   [RESERVED_PORTS+edi+8],dword 0x2d
946
269 serge 947
 
742 Rus 948
	mov   edi,[RESERVED_PORTS]
949
	shl   edi,4
950
	mov   [RESERVED_PORTS+edi+0],dword 1
951
	mov   [RESERVED_PORTS+edi+4],dword 0x30
952
	mov   [RESERVED_PORTS+edi+8],dword 0x4d
953
269 serge 954
 
742 Rus 955
	mov   edi,[RESERVED_PORTS]
956
	shl   edi,4
957
	mov   [RESERVED_PORTS+edi+0],dword 1
958
	mov   [RESERVED_PORTS+edi+4],dword 0x50
959
	mov   [RESERVED_PORTS+edi+8],dword 0xdf
960
233 serge 961
 
742 Rus 962
	mov   edi,[RESERVED_PORTS]
963
	shl   edi,4
964
	mov   [RESERVED_PORTS+edi+0],dword 1
965
	mov   [RESERVED_PORTS+edi+4],dword 0xe5
966
	mov   [RESERVED_PORTS+edi+8],dword 0xff
967
233 serge 968
 
742 Rus 969
	ret
970
1 ha 971
 
972
973
 
742 Rus 974
	mov   [irq12read+4],dword 0		     ; end of port list
975
	;mov   [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte
769 Rus 976
	;mov   [irq04read+4],dword 0                  ; end of port list
977
	;mov   [irq03read+0],dword 0x2f8 + 0x01000000 ; read port 0x2f8 , byte
978
	;mov   [irq03read+4],dword 0                  ; end of port list
979
1 ha 980
 
742 Rus 981
1 ha 982
 
983
  process_number dd 0x1
984
endg
985
986
 
987
988
 
859 serge 989
.fl60:
928 serge 990
        in    al,0x60
991
        loop  .fl60
992
1 ha 993
 
928 serge 994
        mov   [BTN_COUNT], 0                 ; button buffer
995
41 mikedld 996
 
928 serge 997
        mov   ax,[OS_BASE+0x900c]
996 serge 998
        shr   ax,1
928 serge 999
        shl   eax,16
1000
        mov   ax,[OS_BASE+0x900A]
996 serge 1001
        shr   ax,1
928 serge 1002
        mov   dword [MOUSE_X], eax
1003
        pop   eax
1004
1 ha 1005
 
928 serge 1006
1007
 
1 ha 1008
        mov   [next_usage_update], 100
928 serge 1009
        mov   [dont_switch], 0              ; change task if possible
1010
1 ha 1011
 
742 Rus 1012
1 ha 1013
 
1014
mouse_centered:
1015
	push  eax
742 Rus 1016
	mov   eax,[Screen_Max_X]
759 Rus 1017
	shr   eax,1
742 Rus 1018
	mov   [MOUSE_X],ax
1019
	mov   eax,[Screen_Max_Y]
759 Rus 1020
	shr   eax,1
742 Rus 1021
	mov   [MOUSE_Y],ax
1022
	pop   eax
1023
	ret
1024
;* mouse centered - end code- Mario79
1 ha 1025
1026
 
1027
1028
 
1029
1030
 
742 Rus 1031
    and   ebx,65535
1 ha 1032
1033
 
381 serge 1034
    test  ecx,ecx
1 ha 1035
    jne   sopl8
1036
    mov   [esp+36],dword 1
1037
    ret
1038
1039
 
1040
    mov   edx,[TASK_BASE]
379 serge 1041
    mov   edx,[edx+0x4]
1 ha 1042
    and   ebx,65535
1043
    cld
1044
  sopl1:
1045
1046
 
1047
    shl   esi,4
1048
    add   esi,RESERVED_PORTS
381 serge 1049
    cmp   edx,[esi+0]
1 ha 1050
    jne   sopl2
1051
    cmp   ebx,[esi+4]
1052
    jb	  sopl2
742 Rus 1053
    cmp   ebx,[esi+8]
1 ha 1054
    jg	  sopl2
742 Rus 1055
    jmp   sopl3
1 ha 1056
1057
 
1058
1059
 
1060
    jnz   sopl1
1061
    mov   [esp+36],dword 1
1062
    ret
1063
1064
 
1065
1066
 
1067
    jnz   sopl4
1068
1069
 
742 Rus 1070
    out   dx,al
1 ha 1071
    mov   [esp+36],dword 0
1072
    ret
1073
1074
 
1075
1076
 
742 Rus 1077
    in	  al,dx
1078
    and   eax,0xff
1 ha 1079
    mov   [esp+36],dword 0
1080
    mov   [esp+24],eax
1081
    ret
1082
1083
 
1084
1085
 
1086
;                   al=1 -> ebx is pointer
1087
;                   ah=0 -> display decimal
1088
;                   ah=1 -> display hexadecimal
1089
;                   ah=2 -> display binary
1090
;                   eax bits 16-21 = number of digits to display (0-32)
1091
;                   eax bits 22-31 = reserved
1092
;
1093
; ebx = number or pointer
1094
; ecx = x shl 16 + y
1095
; edx = color
1096
	xor	edi, edi
655 mario79 1097
display_number_force:
211 serge 1098
     push  eax
652 mario79 1099
     and   eax,0x3fffffff
655 mario79 1100
     cmp   eax,0xffff		 ; length > 0 ?
1101
     pop   eax
1102
     jge   cont_displ
1 ha 1103
     ret
1104
   cont_displ:
1105
     push  eax
652 mario79 1106
     and   eax,0x3fffffff
655 mario79 1107
     cmp   eax,61*0x10000	 ; length <= 60 ?
1108
     pop   eax
1109
     jb    cont_displ2
75 diamond 1110
     ret
1 ha 1111
   cont_displ2:
1112
1113
 
1114
1115
 
655 mario79 1116
     jne   displnl1
1 ha 1117
     mov   ebp,ebx
655 mario79 1118
     add   ebp,4
1119
     mov   ebp,[ebp]
840 serge 1120
     mov   ebx,[ebx]
1121
   displnl1:
1 ha 1122
     sub   esp,64
1123
1124
 
655 mario79 1125
     jne   no_display_desnum
1 ha 1126
     shr   eax,16
1127
     and   eax,0xC03f
655 mario79 1128
;     and   eax,0x3f
652 mario79 1129
     push  eax
1130
     and   eax,0x3f
75 diamond 1131
     mov   edi,esp
1 ha 1132
     add   edi,4+64-1
194 diamond 1133
     mov   ecx,eax
1 ha 1134
     mov   eax,ebx
1135
     mov   ebx,10
1136
   d_desnum:
1137
     xor   edx,edx
1138
     call  division_64_bits
655 mario79 1139
     div   ebx
1 ha 1140
     add   dl,48
1141
     mov   [edi],dl
1142
     dec   edi
1143
     loop  d_desnum
1144
     pop   eax
1145
     call  normalize_number
652 mario79 1146
     call  draw_num_text
1 ha 1147
     add   esp,64
1148
     popad
1149
     ret
1150
   no_display_desnum:
1151
1152
 
655 mario79 1153
     jne   no_display_hexnum
1 ha 1154
     shr   eax,16
1155
     and   eax,0xC03f
655 mario79 1156
;     and   eax,0x3f
652 mario79 1157
     push  eax
1158
     and   eax,0x3f
75 diamond 1159
     mov   edi,esp
1 ha 1160
     add   edi,4+64-1
194 diamond 1161
     mov   ecx,eax
1 ha 1162
     mov   eax,ebx
1163
     mov   ebx,16
1164
   d_hexnum:
1165
     xor   edx,edx
1166
     call  division_64_bits
655 mario79 1167
     div   ebx
1 ha 1168
     add   edx,hexletters
1169
     mov   dl,[edx]
1170
     mov   [edi],dl
1171
     dec   edi
1172
     loop  d_hexnum
1173
     pop   eax
1174
     call  normalize_number
652 mario79 1175
     call  draw_num_text
1 ha 1176
     add   esp,64
1177
     popad
1178
     ret
1179
   no_display_hexnum:
1180
1181
 
655 mario79 1182
     jne   no_display_binnum
1 ha 1183
     shr   eax,16
1184
     and   eax,0xC03f
655 mario79 1185
;     and   eax,0x3f
652 mario79 1186
     push  eax
1187
     and   eax,0x3f
75 diamond 1188
     mov   edi,esp
1 ha 1189
     add   edi,4+64-1
194 diamond 1190
     mov   ecx,eax
1 ha 1191
     mov   eax,ebx
1192
     mov   ebx,2
1193
   d_binnum:
1194
     xor   edx,edx
1195
     call  division_64_bits
655 mario79 1196
     div   ebx
1 ha 1197
     add   dl,48
1198
     mov   [edi],dl
1199
     dec   edi
1200
     loop  d_binnum
1201
     pop   eax
1202
     call  normalize_number
652 mario79 1203
     call  draw_num_text
1 ha 1204
     add   esp,64
1205
     popad
1206
     ret
1207
   no_display_binnum:
1208
1209
 
1210
     popad
1211
     ret
1212
1213
 
652 mario79 1214
     test  ah,0x80
1215
     jz   .continue
1216
     mov  ecx,48
1217
     and   eax,0x3f
1218
@@:
1219
     inc   edi
1220
     cmp   [edi],cl
1221
     jne   .continue
1222
     dec   eax
1223
     cmp   eax,1
1224
     ja    @r
665 diamond 1225
     mov   al,1
1226
.continue:
652 mario79 1227
     and   eax,0x3f
1228
     ret
1229
1 ha 1230
 
655 mario79 1231
     test  [esp+1+4],byte 0x40
1232
     jz   .continue
1233
     push  eax
1234
     mov   eax,ebp
1235
     div   ebx
1236
     mov   ebp,eax
1237
     pop   eax
1238
.continue:
1239
     ret
1240
652 mario79 1241
 
1 ha 1242
     mov   esi,eax
684 diamond 1243
     mov   edx,64+4
1244
     sub   edx,eax
1245
     add   edx,esp
1246
     mov   ebx,[esp+64+32-8+4]
1247
; add window start x & y
1248
     mov   ecx,[TASK_BASE]
1249
465 serge 1250
 
1251
     shl   edi,8
1252
1253
 
684 diamond 1254
     add   eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
1255
     shl   eax,16
1256
     add   eax,[ecx-twdw+WDATA.box.top]
1257
     add   eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
1258
     add   ebx,eax
1259
     mov   ecx,[esp+64+32-12+4]
1260
	and	ecx, not 0x80000000	; force counted string
742 Rus 1261
	mov	eax, [esp+64+8] 	; background color (if given)
1262
	mov	edi, [esp+64+4]
1263
     jmp   dtext
139 diamond 1264
1 ha 1265
 
1266
1267
 
1268
1269
 
1270
; 2=keyboard   1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
1271
; 3=cd base    1, pri.master 2, pri slave 3 sec master, 4 sec slave
1272
; 5=system language, 1eng 2fi 3ger 4rus
1273
; 7=hd base    1, pri.master 2, pri slave 3 sec master, 4 sec slave
1274
; 8=fat32 partition in hd
1275
; 9
1276
; 10 = sound dma channel
1277
; 11 = enable lba read
1278
; 12 = enable pci access
1279
1280
 
1281
 
1282
     cmp  eax,1 		     ; MIDI
742 Rus 1283
     jnz  nsyse1
1 ha 1284
     cmp  ebx,0x100
1285
     jb   nsyse1
1286
     mov  edx,65535
1287
     cmp  edx,ebx
1288
     jb   nsyse1
1289
     mov  [midi_base],bx
1290
     mov  word [mididp],bx
1291
     inc  bx
1292
     mov  word [midisp],bx
1293
     ret
1294
1295
 
283 diamond 1296
midi_base dw 0
1 ha 1297
endg
283 diamond 1298
1 ha 1299
 
1300
1301
 
742 Rus 1302
     jnz  nsyse2
1 ha 1303
     cmp  ebx,1
1304
     jnz  kbnobase
1305
     mov  edi,[TASK_BASE]
379 serge 1306
     add  ecx,[edi+TASKDATA.mem_start]
115 poddubny 1307
     mov  eax,ecx
1 ha 1308
     mov  ebx,keymap
1309
     mov  ecx,128
1310
     call memmove
1311
     ret
1312
   kbnobase:
1313
     cmp  ebx,2
1314
     jnz  kbnoshift
1315
     mov  edi,[TASK_BASE]
379 serge 1316
     add  ecx,[edi+TASKDATA.mem_start]
115 poddubny 1317
     mov  eax,ecx
1 ha 1318
     mov  ebx,keymap_shift
1319
     mov  ecx,128
1320
     call memmove
1321
     ret
1322
   kbnoshift:
1323
     cmp  ebx,3
1324
     jne  kbnoalt
1325
     mov  edi,[TASK_BASE]
379 serge 1326
     add  ecx,[edi+TASKDATA.mem_start]
115 poddubny 1327
     mov  eax,ecx
1 ha 1328
     mov  ebx,keymap_alt
1329
     mov  ecx,128
1330
     call memmove
1331
     ret
1332
   kbnoalt:
1333
     cmp  ebx,9
1334
     jnz  kbnocountry
1335
     mov  word [keyboard],cx
1336
     ret
1337
   kbnocountry:
1338
     mov  [esp+36],dword 1
1339
     ret
1340
   nsyse2:
1341
     cmp  eax,3 		     ; CD
742 Rus 1342
     jnz  nsyse4
802 serge 1343
     test ebx,ebx
75 diamond 1344
     jz   nosesl
1345
     cmp  ebx, 4
1346
     ja   nosesl
1347
     mov  [cd_base],bl
1 ha 1348
     cmp  ebx,1
1349
     jnz  noprma
1350
     mov  [cdbase],0x1f0
1351
     mov  [cdid],0xa0
1352
   noprma:
1353
     cmp  ebx,2
1354
     jnz  noprsl
1355
     mov  [cdbase],0x1f0
1356
     mov  [cdid],0xb0
1357
   noprsl:
1358
     cmp  ebx,3
1359
     jnz  nosema
1360
     mov  [cdbase],0x170
1361
     mov  [cdid],0xa0
1362
   nosema:
1363
     cmp  ebx,4
1364
     jnz  nosesl
1365
     mov  [cdbase],0x170
1366
     mov  [cdid],0xb0
1367
   nosesl:
1368
     ret
1369
1370
 
1371
1372
 
1373
1374
 
742 Rus 1375
     jnz  nsyse5
1 ha 1376
     mov  [syslang],ebx
1377
     ret
1378
   nsyse5:
1379
1380
 
742 Rus 1381
     jne  nsyse7
1 ha 1382
     test ebx,ebx
75 diamond 1383
     jz   nosethd
1384
     cmp  ebx,4
1385
     ja   nosethd
1386
     mov  [hd_base],bl
1 ha 1387
     cmp  ebx,1
1388
     jnz  noprmahd
1389
     mov  [hdbase],0x1f0
1390
     mov  [hdid],0x0
1391
     mov  [hdpos],1
1392
;     call set_FAT32_variables
1393
   noprmahd:
1394
     cmp  ebx,2
1395
     jnz  noprslhd
1396
     mov  [hdbase],0x1f0
1397
     mov  [hdid],0x10
1398
     mov  [hdpos],2
1399
;     call set_FAT32_variables
1400
   noprslhd:
1401
     cmp  ebx,3
1402
     jnz  nosemahd
1403
     mov  [hdbase],0x170
1404
     mov  [hdid],0x0
1405
     mov  [hdpos],3
1406
;     call set_FAT32_variables
1407
   nosemahd:
1408
     cmp  ebx,4
1409
     jnz  noseslhd
1410
     mov  [hdbase],0x170
1411
     mov  [hdid],0x10
1412
     mov  [hdpos],4
1413
;     call set_FAT32_variables
1414
   noseslhd:
1415
    call  reserve_hd1
1416
    call  reserve_hd_channel
321 diamond 1417
    call  free_hd_channel
1418
    mov   [hd1_status],0	; free
742 Rus 1419
   nosethd:
75 diamond 1420
     ret
1 ha 1421
1422
 
283 diamond 1423
hd_base db 0
1 ha 1424
endg
283 diamond 1425
1 ha 1426
 
802 serge 1427
1 ha 1428
 
742 Rus 1429
     jne  nsyse8
1 ha 1430
     mov  [fat32part],ebx
1431
;     call set_FAT32_variables
1432
    call  reserve_hd1
1433
    call  reserve_hd_channel
321 diamond 1434
    call  free_hd_channel
1435
     pusha
1 ha 1436
     call  choice_necessity_partition_1
1437
     popa
1438
    mov   [hd1_status],0	; free
742 Rus 1439
     ret
1 ha 1440
1441
 
802 serge 1442
     cmp  eax,11		     ; ENABLE LBA READ
742 Rus 1443
     jne  no_set_lba_read
1 ha 1444
     and  ebx,1
1445
     mov  [lba_read_enabled],ebx
1446
     ret
1447
1448
 
802 serge 1449
     cmp  eax,12                     ; ENABLE PCI ACCESS
1450
     jne  no_set_pci_access
1 ha 1451
     and  ebx,1
1452
     mov  [pci_access_enabled],ebx
1453
     ret
1454
   no_set_pci_access:
1455
1456
 
75 diamond 1457
     mov  [esp+36],dword -1
1 ha 1458
     ret
1459
1460
 
1461
1462
 
1463
1464
 
1465
; 2=keyboard   1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
1466
; 3=cd base    1, pri.master 2, pri slave 3 sec master, 4 sec slave
1467
; 5=system language, 1eng 2fi 3ger 4rus
1468
; 7=hd base    1, pri.master 2, pri slave 3 sec master, 4 sec slave
1469
; 8=fat32 partition in hd
1470
; 9=get hs timer tic
1471
1472
 
1473
     jne  ngsyse1
1474
     movzx eax,[midi_base]
1475
     mov  [esp+36],eax
1476
     ret
1477
ngsyse1:
802 serge 1478
1 ha 1479
 
1480
     jne  ngsyse2
1481
     cmp  ebx,1
1482
     jnz  kbnobaseret
1483
     mov  edi,[TASK_BASE]
379 serge 1484
     add  ecx,[edi+TASKDATA.mem_start]
115 poddubny 1485
     mov  ebx,ecx
1 ha 1486
     mov  eax,keymap
1487
     mov  ecx,128
1488
     call memmove
1489
     ret
1490
kbnobaseret:
802 serge 1491
     cmp  ebx,2
1 ha 1492
     jnz  kbnoshiftret
1493
     mov  edi,[TASK_BASE]
379 serge 1494
     add  ecx,[edi+TASKDATA.mem_start]
115 poddubny 1495
     mov  ebx,ecx
1 ha 1496
     mov  eax,keymap_shift
1497
     mov  ecx,128
1498
     call memmove
1499
     ret
1500
kbnoshiftret:
802 serge 1501
     cmp  ebx,3
1 ha 1502
     jne  kbnoaltret
1503
     mov  edi,[TASK_BASE]
379 serge 1504
     add  ecx,[edi+TASKDATA.mem_start]
115 poddubny 1505
     mov  ebx,ecx
1 ha 1506
     mov  eax,keymap_alt
1507
     mov  ecx,128
1508
     call memmove
1509
     ret
1510
kbnoaltret:
802 serge 1511
     cmp  ebx,9
1 ha 1512
     jnz  ngsyse2
1513
     movzx eax,word [keyboard]
1514
     mov  [esp+36],eax
1515
     ret
1516
ngsyse2:
802 serge 1517
1 ha 1518
 
802 serge 1519
         jnz  ngsyse3
1520
         movzx eax,[cd_base]
1521
         mov  [esp+36],eax
1522
         ret
1523
ngsyse3:
1524
         cmp  eax,5
1525
         jnz  ngsyse5
1526
         mov  eax,[syslang]
1527
         mov  [esp+36],eax
1528
         ret
1529
ngsyse5:
1530
     cmp  eax,7
1 ha 1531
     jnz  ngsyse7
1532
     movzx eax,[hd_base]
1533
     mov  [esp+36],eax
1534
     ret
1535
ngsyse7:
802 serge 1536
     cmp  eax,8
1 ha 1537
     jnz  ngsyse8
1538
     mov eax,[fat32part]
1539
     mov  [esp+36],eax
1540
     ret
1541
ngsyse8:
802 serge 1542
     cmp  eax,9
1 ha 1543
     jne  ngsyse9
1544
     mov  eax,[timer_ticks] ;[0xfdf0]
1545
     mov  [esp+36],eax
1546
     ret
1547
ngsyse9:
802 serge 1548
     cmp  eax,11
1 ha 1549
     jnz  ngsyse11
1550
     mov eax,[lba_read_enabled]
1551
     mov  [esp+36],eax
1552
     ret
1553
ngsyse11:
802 serge 1554
     cmp  eax,12
1 ha 1555
     jnz  ngsyse12
1556
     mov eax,[pci_access_enabled]
1557
     mov  [esp+36],eax
1558
     ret
1559
ngsyse12:
802 serge 1560
     mov  [esp+36],dword 1
1 ha 1561
     ret
1562
1563
 
479 kastigar 1564
    mov eax,[timer_ticks]
1565
    ret
1566
1567
 
283 diamond 1568
align 4
1 ha 1569
mousefn dd msscreen, mswin, msbutton, msset
221 serge 1570
	dd app_load_cursor
742 Rus 1571
	dd app_set_cursor
1572
	dd app_delete_cursor
1573
	dd msz
1574
endg
283 diamond 1575
1 ha 1576
 
1577
1578
 
1579
; eax=1 window relative
1580
; eax=2 buttons pressed
1581
; eax=3 set mouse pos   ; reserved
221 serge 1582
; eax=4 load cursor
1583
; eax=5 set cursor
1584
; eax=6 delete cursor   ; reserved
1585
; eax=7 get mouse_z
479 kastigar 1586
1 ha 1587
 
742 Rus 1588
	   ja msset
1589
	   jmp [mousefn+eax*4]
1590
msscreen:
221 serge 1591
       mov  eax, dword [MOUSE_X]
928 serge 1592
	   shl	eax,16
742 Rus 1593
	   mov	ax,[MOUSE_Y]
1594
	   mov	[esp+36],eax
1595
	   ret
1596
mswin:
221 serge 1597
       mov  eax, dword [MOUSE_X]
928 serge 1598
	   shl	eax,16
742 Rus 1599
	   mov	ax,[MOUSE_Y]
1600
	   mov	esi,[TASK_BASE]
1601
	   mov	bx, word [esi-twdw+WDATA.box.left]
1602
	   shl	ebx,16
1603
	   mov	bx, word [esi-twdw+WDATA.box.top]
1604
	   sub	eax,ebx
1605
1 ha 1606
 
742 Rus 1607
	   shl	edi,8
1608
	   sub	ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
1609
	   rol	eax,16
1610
	   sub	ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
1611
	   rol	eax,16
1612
	   mov	[esp+36],eax
1613
	   ret
1614
msbutton:
221 serge 1615
       movzx eax,byte [btn_down]
928 serge 1616
	   mov	[esp+36],eax
742 Rus 1617
	   ret
1618
msz:
479 kastigar 1619
	   mov	 edi, [TASK_COUNT]
742 Rus 1620
	   movzx edi, word [WIN_POS + edi*2]
1621
	   cmp	 edi, [CURRENT_TASK]
1622
	   jne	 @f
1623
       mov   eax,[mouse_scroll_h]
928 serge 1624
	   shl	 eax,16
742 Rus 1625
       mov   ax, word [mouse_scroll_v]
928 serge 1626
	   mov	 [esp+36],eax
742 Rus 1627
       mov   [mouse_scroll_h], 0
928 serge 1628
       mov   [mouse_scroll_v], 0
1629
	   ret
742 Rus 1630
       @@:
479 kastigar 1631
	   mov	[esp+36],dword 0
742 Rus 1632
	   ret
1633
msset:
221 serge 1634
	   ret
742 Rus 1635
164 serge 1636
 
221 serge 1637
      ;     add ebx, new_app_base
465 serge 1638
	   cmp ebx, OS_BASE
742 Rus 1639
	   jae msset
1640
	   stdcall load_cursor, ebx, ecx
1641
	   mov [esp+36], eax
1642
	   ret
1643
164 serge 1644
 
221 serge 1645
	   stdcall set_cursor, ebx
742 Rus 1646
	   mov [esp+36], eax
1647
	   ret
1648
1 ha 1649
 
233 serge 1650
	   stdcall delete_cursor, ebx
742 Rus 1651
	   mov [esp+36], eax
1652
	   ret
1653
1 ha 1654
 
1655
1656
 
1657
   mov	dx,word [midisp]
742 Rus 1658
   in	al,dx
1659
   and	al,0x80
1660
   pop	edx
1661
   ret
1 ha 1662
1663
 
1664
1665
 
1666
   mov	dx,word [midisp]
742 Rus 1667
   in	al,dx
1668
   and	al,0x40
1669
   pop	edx
1670
   ret
1 ha 1671
1672
 
1673
 
1674
1675
 
1676
   mov	dx,word [mididp]
742 Rus 1677
   in	al,dx
1678
   pop	edx
1679
   ret
1 ha 1680
1681
 
1682
 
1683
1684
 
1685
   mov	dx,word [mididp]
742 Rus 1686
   out	dx,al
1687
   pop	edx
1688
   ret
1 ha 1689
1690
 
1691
 
1692
1693
 
1694
   call is_output
1695
   cmp	al,0
742 Rus 1696
   jnz	su1
1697
   mov	dx,word [midisp]
1698
   mov	al,0xff
1699
   out	dx,al
1700
 su2:
1 ha 1701
   mov	dx,word [midisp]
742 Rus 1702
   mov	al,0xff
1703
   out	dx,al
1704
   call is_input
1 ha 1705
   cmp	al,0
742 Rus 1706
   jnz	su2
1707
   call get_mpu_in
1 ha 1708
   cmp	al,0xfe
742 Rus 1709
   jnz	su2
1710
 su3:
1 ha 1711
   call is_output
1712
   cmp	al,0
742 Rus 1713
   jnz	su3
1714
   mov	dx,word [midisp]
1715
   mov	al,0x3f
1716
   out	dx,al
1717
1 ha 1718
 
1719
1720
 
1721
 
1722
1723
 
1724
1725
 
1726
     jnz  sm0
1727
     mov  [esp+36],dword 1
1728
     ret
1729
   sm0:
1730
1731
 
1732
     mov  [esp+36],dword 0
1733
     jnz  smn1
1734
     call setuart
1735
     ret
1736
   smn1:
1737
1738
 
1739
     jnz  smn2
1740
   sm10:
1741
     call get_mpu_in
1742
     call is_output
1743
     test al,al
1744
     jnz  sm10
1745
     mov  al,bl
1746
     call put_mpu_out
1747
     ret
1748
   smn2:
1749
1750
 
1751
1752
 
1753
1754
 
379 serge 1755
     mov   [eax+TASKDATA.state], 3  ; terminate this program
115 poddubny 1756
41 mikedld 1757
 
742 Rus 1758
     mov   ebx,100
684 diamond 1759
     call  delay_hs
1 ha 1760
     jmp   waitterm
1761
1762
 
75 diamond 1763
align 4
170 serge 1764
sys_system_table:
75 diamond 1765
	dd	exit_for_anyone 	; 1 = obsolete
759 Rus 1766
	dd	sysfn_terminate 	; 2 = terminate thread
742 Rus 1767
	dd	sysfn_activate		; 3 = activate window
1768
	dd	sysfn_getidletime	; 4 = get idle time
1769
	dd	sysfn_getcpuclock	; 5 = get cpu clock
1770
	dd	sysfn_saveramdisk	; 6 = save ramdisk
1771
	dd	sysfn_getactive 	; 7 = get active window
1772
	dd	sysfn_sound_flag	; 8 = get/set sound_flag
1773
	dd	sysfn_shutdown		; 9 = shutdown with parameter
748 heavyiron 1774
	dd	sysfn_minimize		; 10 = minimize window
742 Rus 1775
	dd	sysfn_getdiskinfo	; 11 = get disk subsystem info
1776
	dd	sysfn_lastkey		; 12 = get last pressed key
1777
	dd	sysfn_getversion	; 13 = get kernel version
1778
	dd	sysfn_waitretrace	; 14 = wait retrace
1779
	dd	sysfn_centermouse	; 15 = center mouse cursor
1780
	dd	sysfn_getfreemem	; 16 = get free memory size
1781
	dd	sysfn_getallmem 	; 17 = get total memory size
1782
	dd	sysfn_terminate2	; 18 = terminate thread using PID
1783
					;                 instead of slot
1784
	dd	sysfn_mouse_acceleration; 19 = set/get mouse acceleration
1785
	dd	sysfn_meminfo		; 20 = get extended memory info
1786
	dd	sysfn_pid_to_slot	; 21 = get slot number for pid
1787
	dd	sysfn_min_rest_window	; 22 = minimize and restore any window
1788
sysfn_num = ($ - sys_system_table)/4
75 diamond 1789
endg
1790
1791
 
1 ha 1792
	dec	ebx
742 Rus 1793
	cmp	ebx, sysfn_num
1794
	jae	@f
1795
	jmp	dword [sys_system_table + ebx*4]
1796
@@:
75 diamond 1797
	ret
742 Rus 1798
1 ha 1799
 
214 serge 1800
 
759 Rus 1801
     cmp  ecx,1
748 heavyiron 1802
     jl   exit_for_anyone
1803
     cmp  ecx,4
1804
     jg   exit_for_anyone
1805
     mov  [OS_BASE+0x9030],cl
996 serge 1806
748 heavyiron 1807
 
379 serge 1808
     mov  [sys_shutdown], eax
928 serge 1809
     mov  [shutdown_processes],eax
1 ha 1810
     and  dword [esp+32], 0
684 diamond 1811
 exit_for_anyone:
748 heavyiron 1812
     ret
1 ha 1813
  uglobal
1814
   shutdown_processes: dd 0x0
1815
  endg
1816
1817
 
742 Rus 1818
     cmp  ecx,2
684 diamond 1819
     jb   noprocessterminate
1 ha 1820
     mov  edx,[TASK_COUNT]
379 serge 1821
     cmp  ecx,edx
684 diamond 1822
     ja   noprocessterminate
75 diamond 1823
     mov  eax,[TASK_COUNT]
379 serge 1824
     shl  ecx,5
684 diamond 1825
     mov  edx,[ecx+CURRENT_TASK+TASKDATA.pid]
1826
     add  ecx,CURRENT_TASK+TASKDATA.state
1827
     cmp  byte [ecx], 9
1828
     jz   noprocessterminate
75 diamond 1829
41 mikedld 1830
 
1 ha 1831
     mov  [ecx],byte 3	     ; clear possible i40's
742 Rus 1832
     ;call MEM_Heap_UnLock
1 ha 1833
1834
 
1835
     jne  noatsc
1836
     mov  [application_table_status],0
1837
   noatsc:
1838
   noprocessterminate:
75 diamond 1839
     ret
1 ha 1840
1841
 
85 halyavin 1842
;lock application_table_status mutex
1843
.table_status:
164 serge 1844
    cli
85 halyavin 1845
    cmp    [application_table_status],0
1846
    je	   .stf
742 Rus 1847
    sti
85 halyavin 1848
    call   change_task
1849
    jmp    .table_status
1850
.stf:
1851
    call   set_application_table_status
1852
    mov    eax,ecx
684 diamond 1853
    call   pid_to_slot
85 halyavin 1854
    test   eax,eax
1855
    jz	   .not_found
742 Rus 1856
    mov    ecx,eax
684 diamond 1857
    pushfd
848 serge 1858
    cli
85 halyavin 1859
    call   sysfn_terminate
1860
    mov    [application_table_status],0
1861
    popfd
848 serge 1862
    and    dword [esp+32],0
684 diamond 1863
    ret
85 halyavin 1864
.not_found:
1865
    mov    [application_table_status],0
1866
    or	   dword [esp+32],-1
742 Rus 1867
    ret
85 halyavin 1868
1869
 
742 Rus 1870
     cmp  ecx,2
684 diamond 1871
     jb   .nowindowactivate
105 poddubny 1872
     cmp  ecx,[TASK_COUNT]
684 diamond 1873
     ja   .nowindowactivate
105 poddubny 1874
1875
 
1876
1877
 
684 diamond 1878
     cmp   esi, [TASK_COUNT]
379 serge 1879
     je    .nowindowactivate ; already active
105 poddubny 1880
1881
 
684 diamond 1882
     shl   edi, 5
105 poddubny 1883
     add   edi, window_data
1884
     movzx esi, word [WIN_STACK + ecx * 2]
684 diamond 1885
     lea   esi, [WIN_POS + esi * 2]
380 serge 1886
     call  waredraw
105 poddubny 1887
.nowindowactivate:
1888
     ret
1 ha 1889
41 mikedld 1890
 
742 Rus 1891
     mov  eax,[idleusesec]
1 ha 1892
     mov  [esp+32], eax
684 diamond 1893
     ret
1 ha 1894
1895
 
742 Rus 1896
     mov  eax,[CPU_FREQ]
381 serge 1897
     mov  [esp+32], eax
684 diamond 1898
     ret
1 ha 1899
1900
 
1901
;!!!!!!!!!!!!!!!!!!!!!!!!
1902
   include 'blkdev/rdsave.inc'
1903
;!!!!!!!!!!!!!!!!!!!!!!!!
1904
75 diamond 1905
 
742 Rus 1906
     mov  eax, [TASK_COUNT]
379 serge 1907
   movzx  eax, word [WIN_POS + eax*2]
380 serge 1908
     mov  [esp+32],eax
684 diamond 1909
     ret
1 ha 1910
75 diamond 1911
 
742 Rus 1912
     cmp  ecx,1
684 diamond 1913
     jne  nogetsoundflag
1 ha 1914
     movzx  eax,byte [sound_flag] ; get sound_flag
1915
     mov  [esp+32],eax
684 diamond 1916
     ret
1 ha 1917
 nogetsoundflag:
1918
     cmp  ecx,2
684 diamond 1919
     jnz  nosoundflag
1 ha 1920
     xor  byte [sound_flag], 1
75 diamond 1921
 nosoundflag:
1922
     ret
41 mikedld 1923
75 diamond 1924
 
742 Rus 1925
     mov   [window_minimize],1
1 ha 1926
     ret
1927
75 diamond 1928
 
742 Rus 1929
     cmp  ecx,1
684 diamond 1930
     jnz  full_table
1 ha 1931
small_table:
996 serge 1932
     call for_all_tables
1 ha 1933
     mov ecx,10
75 diamond 1934
     cld
1 ha 1935
     rep movsb
1936
     ret
1937
for_all_tables:
996 serge 1938
     mov edi,edx
684 diamond 1939
     mov esi,DRIVE_DATA
381 serge 1940
     ret
1 ha 1941
full_table:
996 serge 1942
     cmp  ecx,2
684 diamond 1943
     jnz  exit_for_anyone
1 ha 1944
     call for_all_tables
1945
     mov ecx,16384
75 diamond 1946
     cld
1 ha 1947
     rep movsd
1948
     ret
1949
75 diamond 1950
 
742 Rus 1951
	and	dword [esp+32], 0
1952
	ret
1953
75 diamond 1954
 
742 Rus 1955
     mov edi,ebx
684 diamond 1956
     mov esi,version_inf
1 ha 1957
     mov ecx,version_end-version_inf
1958
     rep movsb
1959
     ret
1960
75 diamond 1961
 
1962
     ;wait retrace functions
41 mikedld 1963
 sys_wait_retrace:
1964
     mov edx,0x3da
1965
 WaitRetrace_loop:
1966
     in al,dx
1967
     test al,1000b
1968
     jz WaitRetrace_loop
1969
     and [esp+32],dword 0
684 diamond 1970
     ret
1 ha 1971
75 diamond 1972
 
742 Rus 1973
     call  mouse_centered
1 ha 1974
     and [esp+32],dword 0
684 diamond 1975
     ret
1 ha 1976
75 diamond 1977
 
120 mario79 1978
     cmp  ecx,0  ; get mouse speed factor
684 diamond 1979
     jnz  .set_mouse_acceleration
120 mario79 1980
     xor  eax,eax
164 serge 1981
     mov  ax,[mouse_speed_factor]
120 mario79 1982
     mov  [esp+32],eax
684 diamond 1983
     ret
120 mario79 1984
 .set_mouse_acceleration:
1985
     cmp  ecx,1  ; set mouse speed factor
684 diamond 1986
     jnz  .get_mouse_delay
120 mario79 1987
     mov  [mouse_speed_factor],dx
684 diamond 1988
     ret
120 mario79 1989
 .get_mouse_delay:
1990
     cmp  ecx,2  ; get mouse delay
684 diamond 1991
     jnz  .set_mouse_delay
120 mario79 1992
     mov  eax,[mouse_delay]
1993
     mov  [esp+32],eax
684 diamond 1994
     ret
120 mario79 1995
 .set_mouse_delay:
1996
     cmp  ecx,3  ; set mouse delay
684 diamond 1997
     jnz  .set_pointer_position
120 mario79 1998
     mov  [mouse_delay],edx
684 diamond 1999
     ret
120 mario79 2000
 .set_pointer_position:
2001
     cmp  ecx,4  ; set mouse pointer position
684 diamond 2002
     jnz  .set_mouse_button
621 mario79 2003
     mov   [MOUSE_Y],dx    ;y
684 diamond 2004
     ror   edx,16
2005
     mov   [MOUSE_X],dx    ;x
2006
     rol   edx,16
2007
     ret
621 mario79 2008
 .set_mouse_button:
2009
     cmp   ecx,5  ; set mouse button features
684 diamond 2010
     jnz  .end
621 mario79 2011
     mov  byte [btn_down],dl
928 serge 2012
     mov   [mouse_active],1
621 mario79 2013
 .end:
120 mario79 2014
     ret
2015
2016
 
75 diamond 2017
     call _get_free_mem
859 serge 2018
     shl eax, 2
170 serge 2019
     mov [esp+32],eax
684 diamond 2020
     ret
1 ha 2021
75 diamond 2022
 
2023
     mov  eax,[_mem_amount]
846 serge 2024
     shr eax, 10
170 serge 2025
     mov  [esp+32],eax
684 diamond 2026
     ret
32 halyavin 2027
2028
 
608 alver 2029
sysfn_pid_to_slot:
2030
     mov   eax, ecx
684 diamond 2031
     call  pid_to_slot
608 alver 2032
     mov   [esp+32], eax
684 diamond 2033
     ret
608 alver 2034
2035
 
2036
     pushad
2037
     mov   eax, edx	 ; ebx - operating
742 Rus 2038
     shr   ecx, 1
684 diamond 2039
     jnc    @f
608 alver 2040
     call  pid_to_slot
2041
@@:
2042
     or    eax, eax	 ; eax - number of slot
742 Rus 2043
     jz    .error
608 alver 2044
     cmp   eax, 255	    ; varify maximal slot number
742 Rus 2045
     ja    .error
608 alver 2046
     movzx eax, word [WIN_STACK + eax*2]
684 diamond 2047
     shr   ecx, 1
2048
     jc    .restore
608 alver 2049
 ; .minimize:
2050
     call  minimize_window
2051
     jmp   .exit
2052
.restore:
2053
     call  restore_minimized_window
2054
.exit:
2055
     popad
2056
     xor   eax, eax
2057
     mov   [esp+32], eax
684 diamond 2058
     ret
608 alver 2059
.error:
2060
     popad
2061
     xor   eax, eax
2062
     dec   eax
2063
     mov   [esp+32], eax
684 diamond 2064
     ret
608 alver 2065
; } \\ Alver, 2007-22-08 \\
2066
2067
 
41 mikedld 2068
;// mike.dld, 2006-29-01 [
2069
screen_workarea RECT
2070
;// mike.dld, 2006-29-01 ]
2071
window_minimize db 0
1 ha 2072
sound_flag	db 0
742 Rus 2073
endg
41 mikedld 2074
1 ha 2075
 
41 mikedld 2076
version_inf:
2077
  db 0,7,1,0  ; version 0.7.1.0
641 diamond 2078
  db UID_KOLIBRI
41 mikedld 2079
  dd __REV__
540 victor 2080
version_end:
41 mikedld 2081
endg
2082
1 ha 2083
 
41 mikedld 2084
UID_MENUETOS=1	 ;official
742 Rus 2085
UID_KOLIBRI=2	 ;russian
2086
1 ha 2087
 
2088
	cmp	ebx, 1
671 Ghost 2089
	jne	.no_floppy_a_save
2090
	mov	[flp_number], 1
2091
	jmp	.save_image_on_floppy
2092
.no_floppy_a_save:
2093
	cmp	ebx, 2
2094
	jne	.no_floppy_b_save
2095
	mov	[flp_number], 2
2096
.save_image_on_floppy:
2097
	call	save_image
2098
	mov	[esp + 32], dword 0
2099
	cmp	[FDC_Status], 0
2100
	je	.yes_floppy_save
2101
.no_floppy_b_save:
2102
	mov	[esp + 32], dword 1
2103
.yes_floppy_save:
2104
	ret
2105
1 ha 2106
 
2107
;  bgrchanged  dd  0x0
2108
bgrlock db 0
546 diamond 2109
bgrlockpid dd 0
2110
endg
1 ha 2111
2112
 
2113
2114
 
742 Rus 2115
    jnz   nosb1
1 ha 2116
    cmp   ecx,0
2117
    je	  sbgrr
742 Rus 2118
    cmp   edx,0
684 diamond 2119
    je	  sbgrr
742 Rus 2120
@@:
546 diamond 2121
	mov	al, 1
742 Rus 2122
	xchg	[bgrlock], al
2123
	test	al, al
2124
	jz	@f
2125
	call	change_task
2126
	jmp	@b
2127
@@:
546 diamond 2128
    mov   [BgrDataWidth],ecx
684 diamond 2129
    mov   [BgrDataHeight],edx
2130
;    mov   [bgrchanged],1
1 ha 2131
469 serge 2132
 
2133
; return memory for old background
2134
887 serge 2135
 
2136
    call @mem_free@4
2137
2138
 
469 serge 2139
    xor  eax,eax
2140
    inc  eax
2141
    cmp  [BgrDataWidth],eax
527 diamond 2142
    jae   @f
469 serge 2143
    mov [BgrDataWidth],eax
527 diamond 2144
@@:
469 serge 2145
    cmp  [BgrDataHeight],eax
527 diamond 2146
    jae   @f
469 serge 2147
    mov [BgrDataHeight],eax
527 diamond 2148
@@:
469 serge 2149
    mov  eax,[BgrDataWidth]
527 diamond 2150
    imul eax,[BgrDataHeight]
2151
    lea  ecx,[eax*3]
864 serge 2152
    mov  [mem_BACKGROUND],ecx
2153
; get memory for new background
469 serge 2154
    mov edx, PG_SW
864 serge 2155
    stdcall @mem_alloc@8
2156
    test eax, eax
469 serge 2157
    jz .exit_mem
2158
    mov [img_background], eax
2159
.exit_mem:
2160
    popad
2161
	mov	[bgrlock], 0
742 Rus 2162
469 serge 2163
 
1 ha 2164
    ret
2165
469 serge 2166
 
861 serge 2167
1 ha 2168
 
742 Rus 2169
    jnz   nosb2
1 ha 2170
862 serge 2171
 
861 serge 2172
    add ebx, 4095
2173
    and ebx, -4096
2174
    sub ebx, 4
2175
    cmp   ecx, ebx
2176
    ja   @F
2177
2178
 
469 serge 2179
    mov   ebx,[eax+ecx]
684 diamond 2180
    and   ebx,0xFF000000 ;255*256*256*256
2181
    and   edx,0x00FFFFFF ;255*256*256+255*256+255
2182
    add   edx,ebx
2183
    mov   [eax+ecx],edx
2184
@@:
861 serge 2185
    ret
1 ha 2186
2187
 
861 serge 2188
2189
 
742 Rus 2190
    jnz   nosb3
1 ha 2191
draw_background_temp:
2192
;    cmp   [bgrchanged],1 ;0
2193
;    je    nosb31
2194
;draw_background_temp:
2195
;    mov   [bgrchanged],1 ;0
2196
    mov    [background_defined], 1
76 mario79 2197
    call  force_redraw_background
709 diamond 2198
    mov    [redraw_background], 2
928 serge 2199
   nosb31:
1 ha 2200
    ret
2201
  nosb3:
2202
2203
 
742 Rus 2204
    jnz   nosb4
1 ha 2205
    cmp   ecx,[BgrDrawMode]
684 diamond 2206
    je	  nosb41
742 Rus 2207
    mov   [BgrDrawMode],ecx
684 diamond 2208
;    mov   [bgrchanged],1
1 ha 2209
   nosb41:
2210
    ret
2211
  nosb4:
2212
2213
 
742 Rus 2214
    jnz   nosb5
1 ha 2215
  ; bughere
2216
    mov   eax, ecx
684 diamond 2217
    mov   ebx, edx
2218
    add   ebx, [img_background]   ;IMG_BACKGROUND
469 serge 2219
    mov   ecx, esi
684 diamond 2220
    call  memmove
1 ha 2221
  .fin:
2222
    ret
2223
  nosb5:
2224
479 kastigar 2225
 
742 Rus 2226
	jnz	nosb6
2227
@@:
546 diamond 2228
	mov	al, 1
742 Rus 2229
	xchg	[bgrlock], al
2230
	test	al, al
2231
	jz	@f
2232
	call	change_task
2233
	jmp	@b
2234
@@:
546 diamond 2235
	mov	eax, [CURRENT_TASK]
742 Rus 2236
	mov	[bgrlockpid], eax
2237
	stdcall user_alloc, [mem_BACKGROUND]
2238
	mov	[esp+32], eax
2239
	test	eax, eax
2240
	jz	.nomem
2241
	mov	ebx, eax
2242
	shr	ebx, 12
2243
	or	dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK
2244
	mov	esi, [img_background]
2245
	shr	esi, 12
2246
	mov	ecx, [mem_BACKGROUND]
2247
	add	ecx, 0xFFF
2248
	shr	ecx, 12
2249
.z:
546 diamond 2250
	mov	eax, [page_tabs+esi*4]
742 Rus 2251
	or	al, PG_UW
2252
	mov	[page_tabs+ebx*4], eax
2253
	mov	eax, ebx
2254
	shl	eax, 12
2255
	invlpg	[eax]
2256
	inc	ebx
2257
	inc	esi
2258
	loop	.z
2259
	ret
2260
.nomem:
546 diamond 2261
	and	[bgrlockpid], 0
742 Rus 2262
	mov	[bgrlock], 0
2263
nosb6:
546 diamond 2264
	cmp	ebx, 7
742 Rus 2265
	jnz	nosb7
2266
	cmp	[bgrlock], 0
2267
	jz	.err
2268
	mov	eax, [CURRENT_TASK]
2269
	cmp	[bgrlockpid], eax
2270
	jnz	.err
2271
	mov	eax, ecx
2272
	mov	ebx, ecx
2273
	shr	eax, 12
2274
	mov	ecx, [page_tabs+(eax-1)*4]
2275
	test	cl, USED_BLOCK+DONT_FREE_BLOCK
2276
	jz	.err
2277
	jnp	.err
2278
	push	eax
2279
	shr	ecx, 12
2280
@@:
546 diamond 2281
	and	dword [page_tabs+eax*4], 0
742 Rus 2282
	mov	edx, eax
2283
	shl	edx, 12
2284
        push eax
802 serge 2285
	invlpg	[edx]
742 Rus 2286
        pop eax
802 serge 2287
	inc	eax
742 Rus 2288
	loop	@b
2289
	pop	eax
2290
	and	dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK
2291
	stdcall user_free, ebx
2292
	mov	[esp+32], eax
2293
	and	[bgrlockpid], 0
2294
	mov	[bgrlock], 0
2295
	ret
2296
.err:
546 diamond 2297
	and	dword [esp+32], 0
742 Rus 2298
	ret
2299
546 diamond 2300
 
2301
    ret
1 ha 2302
2303
 
709 diamond 2304
    mov   [draw_data+32 + RECT.left],dword 0
2305
    mov   [draw_data+32 + RECT.top],dword 0
2306
    push  eax ebx
2307
    mov   eax,[Screen_Max_X]
753 serge 2308
    mov   ebx,[Screen_Max_Y]
2309
    mov   [draw_data+32 + RECT.right],eax
709 diamond 2310
    mov   [draw_data+32 + RECT.bottom],ebx
2311
    pop   ebx eax
2312
    mov   [redraw_background], 1
928 serge 2313
    ret
709 diamond 2314
479 kastigar 2315
 
1 ha 2316
2317
 
2318
2319
 
742 Rus 2320
    jnz   nogb1
1 ha 2321
    mov   eax,[BgrDataWidth]
527 diamond 2322
    shl   eax,16
1 ha 2323
    mov   ax, word [BgrDataHeight]
996 serge 2324
    mov   [esp+36],eax
1 ha 2325
    ret
2326
2327
 
861 serge 2328
2329
 
742 Rus 2330
    jnz   nogb2
1 ha 2331
862 serge 2332
 
861 serge 2333
    add ecx, 4095
2334
    and ecx, -4096
2335
    sub ecx, 4
2336
    cmp ebx, ecx
2337
    ja  @F
2338
2339
 
469 serge 2340
    mov   eax,[ebx+eax]
2341
2342
 
1 ha 2343
    mov   [esp+36],eax
2344
@@:
861 serge 2345
    ret
1 ha 2346
862 serge 2347
 
1 ha 2348
2349
 
742 Rus 2350
    jnz   nogb4
1 ha 2351
    mov   eax,[BgrDrawMode]
527 diamond 2352
  nogb4:
1 ha 2353
    mov   [esp+36],eax
2354
    ret
2355
2356
 
2357
 
2358
2359
 
2360
	mov	[esp + 32],dword 1
671 Ghost 2361
	; test main buffer
2362
	mov	ebx, [CURRENT_TASK]			     ; TOP OF WINDOW STACK
742 Rus 2363
	movzx	ecx, word [WIN_STACK + ebx * 2]
671 Ghost 2364
	mov	edx, [TASK_COUNT]
2365
	cmp	ecx, edx
2366
	jne	.finish
2367
    cmp [KEY_COUNT], 0
928 serge 2368
	je	.finish
671 Ghost 2369
	movzx	eax, byte [KEY_BUFF]
2370
	shl	eax, 8
2371
	push	eax
2372
    dec [KEY_COUNT]
928 serge 2373
    and [KEY_COUNT], 127
2374
    mov ecx, [KEY_COUNT]
2375
	add	ecx, 2
671 Ghost 2376
	mov	eax, KEY_BUFF + 1
2377
	mov	ebx, KEY_BUFF
2378
	call	memmove
2379
	pop	eax
2380
.ret_eax:
92 diamond 2381
	mov	[esp + 32], eax
671 Ghost 2382
	ret
2383
.finish:
2384
; test hotkeys buffer
92 diamond 2385
	mov	ecx, hotkey_buffer
671 Ghost 2386
@@:
92 diamond 2387
	cmp	[ecx], ebx
671 Ghost 2388
	jz	.found
2389
	add	ecx, 8
2390
	cmp	ecx, hotkey_buffer + 120 * 8
2391
	jb	@b
2392
	ret
2393
.found:
92 diamond 2394
	mov	ax, [ecx + 6]
671 Ghost 2395
	shl	eax, 16
2396
	mov	ah, [ecx + 4]
2397
	mov	al, 2
2398
	and	dword [ecx + 4], 0
2399
	and	dword [ecx], 0
2400
	jmp	.ret_eax
2401
1 ha 2402
 
2403
2404
 
2405
2406
 
742 Rus 2407
	mov	[esp + 32], dword 1
671 Ghost 2408
	movzx	ecx, word [WIN_STACK + ebx * 2]
2409
	mov	edx, [TASK_COUNT] ; less than 256 processes
2410
	cmp	ecx, edx
2411
	jne	.exit
2412
    mov   eax, [BTN_COUNT]
928 serge 2413
    test  eax, eax
2414
	jz	.exit
671 Ghost 2415
	mov	eax, [BTN_BUFF]
2416
	shl	eax, 8
2417
; // Alver 22.06.2008 // {
803 alver 2418
        mov       al, byte [btn_down_determ]
2419
        and       al,0xFE                          ; delete left button bit
928 serge 2420
; } \\ Alver \\
803 alver 2421
    mov [BTN_COUNT], 0
928 serge 2422
	mov	[esp + 32], eax
671 Ghost 2423
.exit:
2424
	ret
2425
1 ha 2426
 
2427
 
2428
2429
 
2430
2431
 
2432
;
2433
;  +00 dword     process cpu usage
2434
;  +04  word     position in windowing stack
2435
;  +06  word     windowing stack value at current position (cpu nro)
2436
;  +10 12 bytes  name
2437
;  +22 dword     start in mem
2438
;  +26 dword     used mem
2439
;  +30 dword     PID , process idenfification number
2440
;
2441
2442
 
742 Rus 2443
    jne  .no_who_am_i
684 diamond 2444
    mov  ecx,[CURRENT_TASK]
2445
  .no_who_am_i:
2446
	cmp	ecx, max_processes
742 Rus 2447
	ja	.nofillbuf
2448
1 ha 2449
 
684 diamond 2450
	mov	ax, [WIN_STACK + ecx * 2]
742 Rus 2451
	mov	[ebx+4], ax
2452
; +6: word: number of the thread slot, which window has in the window stack
684 diamond 2453
;           position ecx (has no relation to the specific thread)
2454
	mov	ax, [WIN_POS + ecx * 2]
742 Rus 2455
	mov	[ebx+6], ax
2456
1 ha 2457
 
742 Rus 2458
1 ha 2459
 
684 diamond 2460
	mov	eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage]
742 Rus 2461
	mov	[ebx], eax
2462
; +10: 11 bytes: name of the process
684 diamond 2463
	push	ecx
742 Rus 2464
	lea	eax, [ecx*8+SLOT_BASE+APPDATA.app_name]
2465
	add	ebx, 10
2466
	mov	ecx, 11
2467
	call	memmove
2468
	pop	ecx
2469
1 ha 2470
 
684 diamond 2471
; +26: size of used memory - 1
2472
	push	edi
742 Rus 2473
	lea	edi, [ebx+12]
2474
	xor	eax, eax
2475
	mov	edx, 0x100000*16
2476
	cmp	ecx, 1 shl 5
2477
	je	.os_mem
2478
	mov	edx, [SLOT_BASE+ecx*8+APPDATA.mem_size]
2479
        xor eax, eax
840 serge 2480
.os_mem:
684 diamond 2481
	stosd
742 Rus 2482
	lea	eax, [edx-1]
2483
	stosd
2484
1 ha 2485
 
684 diamond 2486
	mov	eax, [ecx+CURRENT_TASK+TASKDATA.pid]
742 Rus 2487
	stosd
2488
1 ha 2489
 
2490
	push	esi
742 Rus 2491
	lea	esi, [ecx + window_data + WDATA.box]
2492
	movsd
2493
	movsd
2494
	movsd
2495
	movsd
2496
1 ha 2497
 
2498
	mov	eax, dword [ecx+CURRENT_TASK+TASKDATA.state]
742 Rus 2499
	stosd
2500
1 ha 2501
 
138 mikedld 2502
	lea	esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox]
742 Rus 2503
	movsd
2504
	movsd
2505
	movsd
2506
	movsd
2507
1 ha 2508
 
164 serge 2509
	mov	al, [ecx+window_data+WDATA.fl_wstate]
742 Rus 2510
	stosb
2511
164 serge 2512
 
742 Rus 2513
	pop	edi
2514
138 mikedld 2515
 
684 diamond 2516
    ; return number of processes
1 ha 2517
2518
 
379 serge 2519
    mov    [esp+32],eax
684 diamond 2520
    ret
1 ha 2521
2522
 
2523
sys_clock:
2524
	cli
742 Rus 2525
  ; Mikhail Lisovin  xx Jan 2005
1 ha 2526
  @@:	mov   al, 10
742 Rus 2527
	out   0x70, al
2528
	in    al, 0x71
2529
	test  al, al
2530
	jns   @f
2531
	mov   esi, 1
2532
	call  delay_ms
2533
	jmp   @b
2534
  @@:
1 ha 2535
  ; end Lisovin's fix
2536
2537
 
742 Rus 2538
	out   0x70,al
2539
	in    al,0x71
2540
	movzx ecx,al
2541
	mov   al,02	      ; minutes
2542
	shl   ecx,16
2543
	out   0x70,al
2544
	in    al,0x71
2545
	movzx edx,al
2546
	mov   al,04	      ; hours
2547
	shl   edx,8
2548
	out   0x70,al
2549
	in    al,0x71
2550
	add   ecx,edx
2551
	movzx edx,al
2552
	add   ecx,edx
2553
	sti
2554
	mov	[esp + 32], ecx
671 Ghost 2555
	ret
742 Rus 2556
1 ha 2557
 
2558
 
2559
2560
 
2561
2562
 
742 Rus 2563
  @@:	mov   al, 10
2564
	out   0x70, al
2565
	in    al, 0x71
2566
	test  al, al
2567
	jns   @f
2568
	mov   esi, 1
2569
	call  delay_ms
2570
	jmp   @b
2571
  @@:
75 diamond 2572
2573
 
742 Rus 2574
	mov	al,7		; date
2575
	out	0x70,al
2576
	in	al,0x71
2577
	mov	cl,al
2578
	mov	al,8		; month
2579
	shl	ecx,16
2580
	out	0x70,al
2581
	in	al,0x71
2582
	mov	ch,al
2583
	mov	al,9		; year
2584
	out	0x70,al
2585
	in	al,0x71
2586
	mov	cl,al
2587
	sti
2588
	mov	[esp+32], ecx
2589
	ret
2590
1 ha 2591
 
2592
 
2593
2594
 
2595
	cmp	ebx, 1
671 Ghost 2596
	jne	no_widgets_away
2597
	; buttons away
2598
	mov	ecx,[CURRENT_TASK]
2599
sys_newba2:
996 serge 2600
    mov edi,[btn_addr]
928 serge 2601
	cmp	[edi], dword 0	; empty button list ?
742 Rus 2602
	je	end_of_buttons_away
671 Ghost 2603
	movzx	ebx, word [edi]
2604
	inc	ebx
2605
	mov	eax,edi
2606
sys_newba:
996 serge 2607
	dec	ebx
671 Ghost 2608
	jz	end_of_buttons_away
2609
1 ha 2610
 
671 Ghost 2611
	cmp	cx, [eax]
2612
	jnz	sys_newba
2613
1 ha 2614
 
671 Ghost 2615
	mov	ecx,ebx
2616
	inc	ecx
2617
	shl	ecx, 4
2618
	mov	ebx, eax
2619
	add	eax, 0x10
2620
	call	memmove
2621
	dec	dword [edi]
2622
	pop	ecx ebx eax
2623
1 ha 2624
 
671 Ghost 2625
1 ha 2626
 
2627
2628
 
671 Ghost 2629
1 ha 2630
 
2631
2632
 
671 Ghost 2633
	jnz	srl1
2634
1 ha 2635
 
671 Ghost 2636
    sub edx, CURRENT_TASK
996 serge 2637
    mov [edx +draw_data + RECT.left], 0
2638
    mov [edx +draw_data+ RECT.top], 0
2639
	mov	eax, [Screen_Max_X]
759 Rus 2640
    mov [edx +draw_data+ RECT.right], eax
996 serge 2641
	mov	eax, [Screen_Max_Y]
759 Rus 2642
    mov [edx +draw_data+ RECT.bottom], eax
996 serge 2643
1 ha 2644
 
671 Ghost 2645
	or	[edi - twdw + WDATA.fl_wdrawn], 1   ; no new position & buttons from app
2646
	ret
2647
1 ha 2648
 
2649
	ret
671 Ghost 2650
1 ha 2651
 
2652
 
2653
2654
 
684 diamond 2655
    shr   eax,16+8
2656
    and   eax,15
2657
1 ha 2658
 
684 diamond 2659
    jne   nosyswI
1 ha 2660
    inc   [mouse_pause]
33 mario79 2661
    call  [disable_mouse]
36 mario79 2662
    call  sys_set_window
1 ha 2663
    call  [disable_mouse]
36 mario79 2664
    call  drawwindow_I
1 ha 2665
    ;dec   [mouse_pause]
114 mikedld 2666
    ;call   [draw_pointer]
2667
    ;ret
2668
    jmp   draw_window_caption.2
2669
nosyswI:
996 serge 2670
1 ha 2671
 
742 Rus 2672
    jne   nosyswII
1 ha 2673
    inc   [mouse_pause]
33 mario79 2674
    call  [disable_mouse]
36 mario79 2675
    call  sys_set_window
1 ha 2676
    call  [disable_mouse]
36 mario79 2677
    dec   [mouse_pause]
33 mario79 2678
    call   [draw_pointer]
36 mario79 2679
    ret
1 ha 2680
  nosyswII:
2681
2682
 
742 Rus 2683
    jne   nosyswIII
1 ha 2684
    inc   [mouse_pause]
33 mario79 2685
    call  [disable_mouse]
36 mario79 2686
    call  sys_set_window
1 ha 2687
    call  [disable_mouse]
36 mario79 2688
    call  drawwindow_III
1 ha 2689
    ;dec   [mouse_pause]
114 mikedld 2690
    ;call   [draw_pointer]
2691
    ;ret
2692
    jmp   draw_window_caption.2
2693
  nosyswIII:
1 ha 2694
2695
 
742 Rus 2696
    je	  draw_skin_window
2697
    cmp   al,4	  ; type V - skinned window not sized! {not_sized_skin_window}
2698
    jne   nosyswV
549 spraid 2699
draw_skin_window:
996 serge 2700
567 serge 2701
 
569 diamond 2702
    call  [disable_mouse]
2703
    call  sys_set_window
2704
    call  [disable_mouse]
2705
    mov   eax, [TASK_COUNT]
684 diamond 2706
    movzx eax, word [WIN_POS + eax*2]
2707
    cmp   eax, [CURRENT_TASK]
2708
    setz  al
2709
    movzx eax, al
2710
    push  eax
2711
    call  drawwindow_IV
36 mario79 2712
    ;dec   [mouse_pause]
114 mikedld 2713
    ;call   [draw_pointer]
2714
    ;ret
2715
    jmp   draw_window_caption.2
2716
  nosyswV:
549 spraid 2717
1 ha 2718
 
2719
2720
 
2721
 
114 mikedld 2722
	inc	[mouse_pause]
742 Rus 2723
	call	[disable_mouse]
2724
114 mikedld 2725
 
742 Rus 2726
	mov	edx,[TASK_COUNT]
2727
	movzx	edx,word[WIN_POS+edx*2]
2728
	cmp	edx,[CURRENT_TASK]
2729
	jne	@f
2730
	inc	eax
2731
    @@: mov	edx,[CURRENT_TASK]
2732
	shl	edx,5
2733
	add	edx,window_data
2734
	movzx	ebx,[edx+WDATA.fl_wstyle]
2735
	and	bl,0x0F
2736
	cmp	bl,3
2737
	je	.draw_caption_style_3		;{for 3 and 4 style write caption}
2738
	cmp	bl,4
2739
	je	.draw_caption_style_3
2740
567 serge 2741
 
742 Rus 2742
  .draw_caption_style_3:
549 spraid 2743
114 mikedld 2744
 
742 Rus 2745
	call	drawwindow_IV_caption
2746
	add	esp,4
2747
	jmp	.2
2748
114 mikedld 2749
 
2750
	cmp	bl,2
742 Rus 2751
	jne	.not_style_2
2752
114 mikedld 2753
 
742 Rus 2754
	jmp	.2
2755
114 mikedld 2756
 
2757
	cmp	bl,0
742 Rus 2758
	jne	.2
2759
114 mikedld 2760
 
742 Rus 2761
114 mikedld 2762
 
2763
  .2:	;jmp     @f
742 Rus 2764
	mov	edi,[CURRENT_TASK]
2765
	shl	edi,5
2766
	test	[edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION
2767
	jz	@f
2768
	mov	edx,[edi*8+SLOT_BASE+APPDATA.wnd_caption]
2769
	or	edx,edx
2770
	jz	@f
2771
114 mikedld 2772
 
742 Rus 2773
	and	al,0x0F
2774
	cmp	al,3
2775
	je	.skinned
2776
	cmp	al,4
2777
	je	.skinned
2778
567 serge 2779
 
742 Rus 2780
  .skinned:
567 serge 2781
	mov	ebp,[edi+window_data+WDATA.box.left-2]
742 Rus 2782
	mov	bp,word[edi+window_data+WDATA.box.top]
2783
	movzx	eax,word[edi+window_data+WDATA.box.width]
2784
	sub	ax,[_skinmargins.left]
2785
	sub	ax,[_skinmargins.right]
2786
	push	edx
2787
	cwde
2788
	cdq
2789
	mov	ebx,6
2790
	idiv	ebx
2791
	pop	edx
2792
	or	eax,eax
2793
	js	@f
2794
	mov	esi,eax
2795
	mov	ebx,dword[_skinmargins.left-2]
2796
	mov	bx,word[_skinh]
2797
	sub	bx,[_skinmargins.bottom]
2798
	sub	bx,[_skinmargins.top]
2799
	sar	bx,1
2800
	adc	bx,0
2801
	add	bx,[_skinmargins.top]
2802
	add	bx,-3
2803
	add	ebx,ebp
2804
	jmp	.dodraw
2805
114 mikedld 2806
 
2807
	cmp	al,1
742 Rus 2808
	je	@f
2809
114 mikedld 2810
 
742 Rus 2811
	mov	bp,word[edi+window_data+WDATA.box.top]
2812
	movzx	eax,word[edi+window_data+WDATA.box.width]
2813
	sub	eax,16
2814
	push	edx
2815
	cwde
2816
	cdq
2817
	mov	ebx,6
2818
	idiv	ebx
2819
	pop	edx
2820
	or	eax,eax
2821
	js	@f
2822
	mov	esi,eax
2823
	mov	ebx,0x00080007
2824
	add	ebx,ebp
2825
.dodraw:
139 diamond 2826
	mov	ecx,[common_colours+16];0x00FFFFFF
742 Rus 2827
	or	ecx, 0x80000000
2828
	xor	edi,edi
2829
; // Alver 22.06.2008 // {
803 alver 2830
;	call	dtext
2831
        call dtext_asciiz_esi
2832
; } \\ Alver \\
2833
114 mikedld 2834
 
2835
;--------------------------------------------------------------
2836
	dec	[mouse_pause]
742 Rus 2837
	call	[draw_pointer]
2838
	ret
2839
114 mikedld 2840
 
2841
align 4
2842
window_topleft dd \
2843
  1, 21,\		;type 0
549 spraid 2844
  0,  0,\	;type 1
742 Rus 2845
  5, 20,\	;type 2
2846
  5,  ?,\	;type 3 {set by skin}
2847
  5,  ? 	;type 4 {set by skin}
2848
endg
114 mikedld 2849
2850
 
2851
	push	eax ecx edi
742 Rus 2852
114 mikedld 2853
 
742 Rus 2854
	mov	[window_topleft+4*7],eax
2855
	mov	[window_topleft+4*9],eax
2856
114 mikedld 2857
 
742 Rus 2858
	sub	edi,window_data
2859
	shl	edi,3
2860
	test	[ecx+WDATA.fl_wstyle],WSTYLE_CLIENTRELATIVE
2861
	jz	@f
2862
114 mikedld 2863
 
742 Rus 2864
	and	eax,0x0F
2865
	mov	eax,[eax*8+window_topleft+0]
2866
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax
2867
	shl	eax,1
2868
	neg	eax
2869
	add	eax,[ecx+WDATA.box.width]
2870
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax
2871
114 mikedld 2872
 
742 Rus 2873
	and	eax,0x0F
2874
	push	[eax*8+window_topleft+0]
2875
	mov	eax,[eax*8+window_topleft+4]
2876
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax
2877
	neg	eax
2878
	sub	eax,[esp]
2879
	add	eax,[ecx+WDATA.box.height]
2880
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax
2881
	add	esp,4
2882
114 mikedld 2883
 
742 Rus 2884
	ret
2885
    @@:
114 mikedld 2886
	xor	eax,eax
742 Rus 2887
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax
2888
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax
2889
	mov	eax,[ecx+WDATA.box.width]
2890
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax
2891
	mov	eax,[ecx+WDATA.box.height]
2892
	mov	[edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax
2893
114 mikedld 2894
 
742 Rus 2895
	ret
2896
114 mikedld 2897
 
1 ha 2898
2899
 
684 diamond 2900
    shl   eax,5
2901
    add   eax,window_data
2902
1 ha 2903
 
2904
    mov   [eax+WDATA.cl_workarea],edx
684 diamond 2905
    mov   [eax+WDATA.cl_titlebar],esi
2906
    mov   [eax+WDATA.cl_frames],edi
2907
1 ha 2908
 
684 diamond 2909
2910
 
1 ha 2911
    test  [edi+WDATA.fl_wdrawn],1
186 diamond 2912
    jnz   newd
2913
1 ha 2914
 
860 serge 2915
    mov   [edi+WDATA.box.width],eax
2916
    movsx eax,cx
2917
    mov   [edi+WDATA.box.height],eax
2918
    sar   ebx,16
114 mikedld 2919
    sar   ecx,16
684 diamond 2920
    mov   [edi+WDATA.box.left],ebx
860 serge 2921
    mov   [edi+WDATA.box.top],ecx
2922
1 ha 2923
 
2924
2925
 
164 serge 2926
1 ha 2927
 
742 Rus 2928
    ;mov   esi,edi
114 mikedld 2929
2930
 
742 Rus 2931
	mov	eax, [edi+WDATA.cl_frames]
2932
114 mikedld 2933
 
1 ha 2934
    shl   edi,3
114 mikedld 2935
    add   edi,SLOT_BASE
380 serge 2936
114 mikedld 2937
 
742 Rus 2938
	mov	[edi+APPDATA.wnd_caption],0
2939
	cmp	cl,3
2940
	je	set_APPDATA_wnd_caption
2941
	cmp	cl,4								; {SPraid.simba}
2942
	je	set_APPDATA_wnd_caption
2943
567 serge 2944
 
742 Rus 2945
set_APPDATA_wnd_caption:
996 serge 2946
	mov	[edi+APPDATA.wnd_caption],eax
742 Rus 2947
    @@: mov	esi,[esp+0]
2948
114 mikedld 2949
 
115 poddubny 2950
	movsd
742 Rus 2951
	movsd
2952
	movsd
2953
	movsd
2954
    pop   edi esi ecx
1 ha 2955
2956
 
742 Rus 2957
	movzx	esi, word [WIN_STACK+esi*2]
2958
	lea	esi, [WIN_POS+esi*2]
2959
	call	waredraw
2960
569 diamond 2961
 
684 diamond 2962
;;;    call  delay_hs
1 ha 2963
    mov   eax, [edi+WDATA.box.left]
115 poddubny 2964
    mov   ebx, [edi+WDATA.box.top]
2965
    mov   ecx, [edi+WDATA.box.width]
2966
    mov   edx, [edi+WDATA.box.height]
2967
    add   ecx, eax
1 ha 2968
    add   edx, ebx
2969
    call  calculatescreen
2970
2971
 
928 serge 2972
    mov   [BTN_COUNT], 0           ; empty button buffer
2973
1 ha 2974
 
996 serge 2975
    mov   [edi+WDATA.fl_redraw],byte 0	 ; no redraw
742 Rus 2976
    mov   edx,edi
1 ha 2977
2978
 
2979
2980
 
114 mikedld 2981
1 ha 2982
 
114 mikedld 2983
	dec	eax	; subfunction #1 - set window caption
742 Rus 2984
	jnz	.get_window_caption
2985
114 mikedld 2986
 
742 Rus 2987
	;       so there's no parameter for PID/TID
2988
114 mikedld 2989
 
742 Rus 2990
	shl	edi,5
2991
114 mikedld 2992
 
742 Rus 2993
	; check is trivial, and if application resizes its memory,
2994
	;   caption still can become over bounds
2995
; diamond, 31.10.2006: check removed because with new memory manager
202 diamond 2996
; there can be valid data after APPDATA.mem_size bound
2997
;        mov     ecx,[edi*8+SLOT_BASE+APPDATA.mem_size]
380 serge 2998
;        add     ecx,255 ; max caption length
202 diamond 2999
;        cmp     ebx,ecx
3000
;        ja      .exit_fail
3001
114 mikedld 3002
 
742 Rus 3003
	or	[edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION
3004
114 mikedld 3005
 
742 Rus 3006
114 mikedld 3007
 
742 Rus 3008
	ret
3009
114 mikedld 3010
 
3011
	dec	eax	; subfunction #2 - get window caption
742 Rus 3012
	jnz	.exit_fail
3013
114 mikedld 3014
 
742 Rus 3015
114 mikedld 3016
 
3017
	xor	eax,eax
742 Rus 3018
	inc	eax	; eax = 1 (fail)
3019
	ret
3020
114 mikedld 3021
 
3022
 
1 ha 3023
3024
 
742 Rus 3025
	shl	edi,5
3026
	add	edi,window_data
3027
1 ha 3028
 
742 Rus 3029
	jnz	.window_move_return
3030
1 ha 3031
 
742 Rus 3032
	push	dword [edi + WDATA.box.top]
3033
	push	dword [edi + WDATA.box.width]
3034
	push	dword [edi + WDATA.box.height]
3035
1 ha 3036
 
742 Rus 3037
	je    .no_x_reposition
3038
	mov	[edi + WDATA.box.left], eax
3039
      .no_x_reposition:
49 mikedld 3040
	cmp   ebx,-1
742 Rus 3041
	je    .no_y_reposition
3042
	mov	[edi + WDATA.box.top], ebx
3043
      .no_y_reposition:
49 mikedld 3044
1 ha 3045
 
742 Rus 3046
	jnz	.no_y_resizing
3047
1 ha 3048
 
742 Rus 3049
	je    .no_x_resizing
3050
	mov	[edi + WDATA.box.width], ecx
3051
      .no_x_resizing:
49 mikedld 3052
	cmp   edx,-1
742 Rus 3053
	je    .no_y_resizing
3054
	mov	[edi + WDATA.box.height], edx
3055
      .no_y_resizing:
49 mikedld 3056
1 ha 3057
 
742 Rus 3058
	call  set_window_clientbox
3059
1 ha 3060
 
742 Rus 3061
	mov   esi,edi
3062
	sub   edi,window_data
3063
	shr   edi,5
3064
	shl   edi,8
3065
	add   edi, SLOT_BASE + APPDATA.saved_box
3066
	mov   ecx,4
3067
	cld
3068
	rep   movsd
3069
	popad
3070
49 mikedld 3071
 
742 Rus 3072
	mov   eax, [edi + WDATA.box.left]
3073
	mov   ebx, [edi + WDATA.box.top]
3074
	mov   ecx, [edi + WDATA.box.width]
3075
	mov   edx, [edi + WDATA.box.height]
3076
	add   ecx,eax
3077
	add   edx,ebx
3078
221 serge 3079
 
742 Rus 3080
	popad
3081
49 mikedld 3082
 
742 Rus 3083
	pop   ecx
3084
	pop   ebx
3085
	pop   eax
3086
	add   ecx,eax
3087
	add   edx,ebx
3088
	mov   [dlx],eax 	    ; save for drawlimits
3089
	mov   [dly],ebx
3090
	mov   [dlxe],ecx
3091
	mov   [dlye],edx
3092
	call  calculatescreen
3093
49 mikedld 3094
 
742 Rus 3095
49 mikedld 3096
 
742 Rus 3097
	xor   esi,esi
3098
	call  redrawscreen
3099
49 mikedld 3100
 
742 Rus 3101
49 mikedld 3102
 
742 Rus 3103
49 mikedld 3104
 
996 serge 3105
49 mikedld 3106
 
742 Rus 3107
1 ha 3108
 
3109
  window_move_pr   dd  0x0
3110
  window_move_eax  dd  0x0
3111
  window_move_ebx  dd  0x0
3112
  window_move_ecx  dd  0x0
3113
  window_move_edx  dd  0x0
3114
endg
3115
3116
 
3117
;nt - not tested
3118
;---------------------------------------------------------------------------------------------
3119
;eax
3120
;0 - task switch counter. Ret switch counter in eax. Block. ok.
3121
;1 - change task. Ret nothing. Block. ok.
3122
;2 - performance control
3123
; ebx
3124
; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode.
3125
; returned new cr4 in eax. Ret cr4 in eax. Block. ok.
3126
; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok.
3127
; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok.
3128
; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok.
3129
;eax
3130
;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok.
3131
;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok.
3132
;---------------------------------------------------------------------------------------------
3133
sys_sheduler: ;noname & halyavin
3134
    cmp eax,0
3135
    je shed_counter
3136
    cmp eax,2
3137
    je perf_control
3138
    cmp eax,3
3139
    je rdmsr_instr
3140
    cmp eax,4
3141
    je wrmsr_instr
3142
    cmp eax,1
3143
    jne not_supported
3144
    call change_task ;delay,0
3145
ret
3146
shed_counter:
3147
    mov eax,[context_counter]
3148
    mov [esp+36],eax
3149
not_supported:
3150
ret
3151
perf_control:
3152
    inc eax ;now eax=3
3153
    cmp ebx,eax
3154
    je cache_disable
3155
    dec eax
3156
    cmp ebx,eax
3157
    je cache_enable
3158
    dec eax
3159
    cmp ebx,eax
3160
    je is_cache_enabled
3161
    dec eax
3162
    cmp ebx,eax
3163
    je modify_pce
3164
ret
3165
3166
 
3167
;now counter in ecx
3168
;(edx:eax) esi:edi => edx:esi
3169
mov eax,esi
3170
rdmsr
3171
mov [esp+36],eax
3172
mov [esp+24],edx ;ret in ebx?
3173
ret
3174
3175
 
3176
;now counter in ecx
3177
;(edx:eax) esi:edi => edx:esi
3178
	; Fast Call MSR can't be destroy
482 Ghost 3179
	; Íî MSR_AMD_EFER ìîæíî èçìåíÿòü, ò.ê. â ýòîì ðåãèñòðå ëèø
3180
	; âêëþ÷àþòñÿ/âûêëþ÷àþòñÿ ðàñøèðåííûå âîçìîæíîñòè
3181
	cmp	ecx, MSR_SYSENTER_CS
3182
	je	@f
3183
	cmp	ecx, MSR_SYSENTER_ESP
3184
	je	@f
3185
	cmp	ecx, MSR_SYSENTER_EIP
3186
	je	@f
3187
	cmp	ecx, MSR_AMD_STAR
3188
	je	@f
3189
3190
 
3191
	wrmsr
3192
	; mov   [esp + 36], eax
742 Rus 3193
	; mov   [esp + 24], edx ;ret in ebx?
3194
@@:
482 Ghost 3195
ret
1 ha 3196
3197
 
3198
       mov eax,cr0
3199
       or  eax,01100000000000000000000000000000b
3200
       mov cr0,eax
3201
       wbinvd ;set MESI
3202
ret
3203
3204
 
3205
       mov eax,cr0
3206
       and eax,10011111111111111111111111111111b
3207
       mov cr0,eax
3208
ret
3209
3210
 
3211
       mov eax,cr0
3212
       mov ebx,eax
3213
       and eax,01100000000000000000000000000000b
3214
       jz cache_disabled
3215
       mov [esp+36],ebx
3216
cache_disabled:
3217
       mov dword [esp+36],eax ;0
3218
ret
3219
3220
 
3221
       mov eax,cr4
3222
;       mov ebx,0
3223
;       or  bx,100000000b ;pce
3224
;       xor eax,ebx ;invert pce
3225
       bts eax,8 ;pce=cr4[8]
17 me_root 3226
       mov cr4,eax
1 ha 3227
       mov [esp+36],eax
3228
ret
3229
;---------------------------------------------------------------------------------------------
3230
3231
 
3232
 
3233
3234
 
3235
	push eax edx
742 Rus 3236
1 ha 3237
 
759 Rus 3238
        mov  ecx, [_display_data]
840 serge 3239
3240
 
3241
	imul edx, ebx
742 Rus 3242
1 ha 3243
 
840 serge 3244
        mov  dl, [eax+edx] ; lea eax, [...]
3245
3246
 
742 Rus 3247
	mov  eax, [CURRENT_TASK]
3248
	cmp  al, dl
3249
	setne cl
3250
1 ha 3251
 
742 Rus 3252
	ret
3253
1 ha 3254
 
3255
  cpustring db '/sys/CPU',0
897 serge 3256
endg
1 ha 3257
3258
 
67 diamond 3259
background_defined    db    0	 ; diamond, 11.04.2006
742 Rus 3260
endg
67 diamond 3261
1 ha 3262
 
3263
; check misc
3264
3265
 
3266
3267
 
928 serge 3268
        jne   nocpustart
3269
501 serge 3270
 
897 serge 3271
        push 0
3272
        push cpustring
3273
        call _sys_exec
3274
        add esp, 12
3275
501 serge 3276
 
928 serge 3277
465 serge 3278
 
3279
    cmp   [mouse_active], 1
1 ha 3280
    jne   mouse_not_active
3281
    mov   [mouse_active], 0
3282
    xor   edi, edi
3283
    mov   ecx,	[TASK_COUNT]
742 Rus 3284
set_mouse_event:
465 serge 3285
    add   edi, 256
1 ha 3286
    or	  [edi+SLOT_BASE+APPDATA.event_mask], dword 100000b
742 Rus 3287
    loop  set_mouse_event
1 ha 3288
3289
 
465 serge 3290
    cmp   [redraw_background], 0           ; background update ?
928 serge 3291
    jz	  nobackgr
742 Rus 3292
    cmp    [background_defined], 0
76 mario79 3293
    jz	  nobackgr
742 Rus 3294
    cmp   [redraw_background], 2
928 serge 3295
    jnz   no_set_bgr_event
709 diamond 3296
    xor   edi, edi
473 diamond 3297
    mov   ecx,	[TASK_COUNT]
742 Rus 3298
set_bgr_event:
473 diamond 3299
    add   edi, 256
3300
    or	  [edi+SLOT_BASE+APPDATA.event_mask], 16
742 Rus 3301
    loop  set_bgr_event
473 diamond 3302
no_set_bgr_event:
709 diamond 3303
;    mov   [draw_data+32 + RECT.left],dword 0
3304
;    mov   [draw_data+32 + RECT.top],dword 0
3305
;    mov   eax,[Screen_Max_X]
753 serge 3306
;    mov   ebx,[Screen_Max_Y]
3307
;    mov   [draw_data+32 + RECT.right],eax
709 diamond 3308
;    mov   [draw_data+32 + RECT.bottom],ebx
3309
    call  drawbackground
1 ha 3310
    mov   [redraw_background], 0
928 serge 3311
    mov   [redraw_background], 0
3312
1 ha 3313
 
465 serge 3314
1 ha 3315
 
3316
3317
 
928 serge 3318
    je	 noshutdown
742 Rus 3319
1 ha 3320
 
3321
3322
 
928 serge 3323
    jne  no_mark_system_shutdown
1 ha 3324
3325
 
709 diamond 3326
    mov   edx,OS_BASE+0x3040
465 serge 3327
    jecxz @f
709 diamond 3328
markz:
465 serge 3329
    mov   [edx+TASKDATA.state],byte 3
115 poddubny 3330
    add   edx,0x20
1 ha 3331
    loop  markz
3332
@@:
709 diamond 3333
1 ha 3334
 
3335
3336
 
3337
3338
 
928 serge 3339
    je	 system_shutdown
742 Rus 3340
1 ha 3341
 
465 serge 3342
1 ha 3343
 
3344
 
742 Rus 3345
    mov   ebx,TASK_DATA+TASKDATA.state
379 serge 3346
    mov   esi,1
1 ha 3347
3348
 
465 serge 3349
    mov   cl,[ebx]
1 ha 3350
    cmp   cl,byte 3
3351
    jz	  terminate
742 Rus 3352
    cmp   cl,byte 4
1 ha 3353
    jz	  terminate
742 Rus 3354
1 ha 3355
 
3356
    inc   esi
3357
    dec   eax
3358
    jnz   newct
3359
    ret
3360
3361
 
3362
3363
 
3364
3365
 
3366
3367
 
742 Rus 3368
	 push  eax
3369
1 ha 3370
 
684 diamond 3371
;;;         call  delay_hs
1 ha 3372
3373
 
742 Rus 3374
	 xor   ecx,ecx
3375
       newdw2:
1 ha 3376
3377
 
742 Rus 3378
	 push  ecx
3379
1 ha 3380
 
742 Rus 3381
	 shl   eax,5
3382
	 add   eax,window_data
3383
1 ha 3384
 
742 Rus 3385
	 je    not_this_task
3386
				   ; check if window in redraw area
3387
	 mov   edi,eax
3388
1 ha 3389
 
742 Rus 3390
	 jz    bgli
3391
1 ha 3392
 
742 Rus 3393
	 mov   ebx, [edi + WDATA.box.top]
3394
	 mov   ecx, [edi + WDATA.box.width]
3395
	 mov   edx, [edi + WDATA.box.height]
3396
	 add   ecx,eax
3397
	 add   edx,ebx
3398
1 ha 3399
 
742 Rus 3400
	 cmp   ecx,ebx
3401
	 jb    ricino
3402
1 ha 3403
 
742 Rus 3404
	 cmp   ecx,eax
3405
	 jb    ricino
3406
1 ha 3407
 
742 Rus 3408
	 mov   ebx, [edi + WDATA.box.top]
3409
	 mov   ecx, [edi + WDATA.box.width]
3410
	 mov   edx, [edi + WDATA.box.height]
3411
	 add   ecx, eax
3412
	 add   edx, ebx
3413
164 serge 3414
 
742 Rus 3415
	 cmp   edx,eax
3416
	 jb    ricino
3417
1 ha 3418
 
742 Rus 3419
	 cmp   ecx,eax
3420
	 jb    ricino
3421
1 ha 3422
 
996 serge 3423
1 ha 3424
 
742 Rus 3425
     jnz   .az
996 serge 3426
     mov   al, byte [redraw_background]
928 serge 3427
	 cmp   al,2
742 Rus 3428
	 jz    newdw8
3429
	 test  al,al
3430
	 jz    .az
3431
     lea   eax,[edi+draw_data+(0x100000000-OS_BASE)]
996 serge 3432
	 mov   ebx,[dlx]
742 Rus 3433
	 cmp   ebx,[eax+RECT.left]
3434
	 jae   @f
3435
	 mov   [eax+RECT.left],ebx
3436
@@:
996 serge 3437
	 mov   ebx,[dly]
742 Rus 3438
	 cmp   ebx,[eax+RECT.top]
3439
	 jae   @f
3440
	 mov   [eax+RECT.top],ebx
3441
@@:
996 serge 3442
	 mov   ebx,[dlxe]
742 Rus 3443
	 cmp   ebx,[eax+RECT.right]
3444
	 jbe   @f
3445
	 mov   [eax+RECT.right],ebx
3446
@@:
996 serge 3447
	 mov   ebx,[dlye]
742 Rus 3448
	 cmp   ebx,[eax+RECT.bottom]
3449
	 jbe   @f
3450
	 mov   [eax+RECT.bottom],ebx
3451
@@:
996 serge 3452
	 jmp   newdw8
742 Rus 3453
.az:
996 serge 3454
1 ha 3455
 
742 Rus 3456
     add   eax, draw_data+(0x100000000-OS_BASE)
996 serge 3457
1 ha 3458
 
742 Rus 3459
	 mov   [eax + RECT.left], ebx
3460
	 mov   ebx,[dly]
3461
	 mov   [eax + RECT.top], ebx
3462
	 mov   ebx,[dlxe]
3463
	 mov   [eax + RECT.right], ebx
3464
	 mov   ebx,[dlye]
3465
	 mov   [eax + RECT.bottom], ebx
3466
1 ha 3467
 
996 serge 3468
1 ha 3469
 
742 Rus 3470
	 jne   nobgrd
3471
     mov   [redraw_background], 1
928 serge 3472
1 ha 3473
 
996 serge 3474
nobgrd:
3475
1 ha 3476
 
742 Rus 3477
1 ha 3478
 
996 serge 3479
1 ha 3480
 
996 serge 3481
1 ha 3482
 
742 Rus 3483
1 ha 3484
 
742 Rus 3485
	 jle   newdw2
3486
1 ha 3487
 
742 Rus 3488
	 popad
3489
1 ha 3490
 
742 Rus 3491
1 ha 3492
 
3493
3494
 
742 Rus 3495
1 ha 3496
 
742 Rus 3497
	xor   eax, eax
3498
	mov   ecx, 1023    ;0x0fff00 / 4
3499
	cld
3500
	rep   stosd
3501
1 ha 3502
 
840 serge 3503
	mov   eax,0x01010101
742 Rus 3504
	mov   ecx,1280*1024 / 4
3505
	rep   stosd
3506
1 ha 3507
 
928 serge 3508
1 ha 3509
 
742 Rus 3510
1 ha 3511
 
3512
  imax	  dd 0x0
742 Rus 3513
endg
1 ha 3514
3515
 
3516
 
3517
 
3518
3519
 
3520
 
742 Rus 3521
	push  ecx
3522
1 ha 3523
 
742 Rus 3524
	; 
3525
	imul  ecx, 33941
3526
	shr   ecx, 9
3527
	; 
3528
1 ha 3529
 
742 Rus 3530
	and   al,0x10
3531
	mov   ah,al
3532
	cld
3533
1 ha 3534
 
742 Rus 3535
	and   al,0x10
3536
	cmp   al,ah
3537
	jz    cnt1
3538
1 ha 3539
 
742 Rus 3540
	loop  cnt1
3541
1 ha 3542
 
742 Rus 3543
	pop   eax
3544
1 ha 3545
 
742 Rus 3546
1 ha 3547
 
3548
 
3549
	mov	edi, [TASK_BASE]
742 Rus 3550
	mov	[edi + TASKDATA.event_mask], ebx
3551
	ret
3552
1 ha 3553
 
3554
 
3555
 
3556
; ebx = delay time
684 diamond 3557
	push  ecx
742 Rus 3558
	push  edx
3559
1 ha 3560
 
742 Rus 3561
1 ha 3562
 
3563
	mov   ecx,[timer_ticks]
742 Rus 3564
	sub   ecx,edx
3565
	cmp   ecx,ebx
3566
	jae   zerodelay
3567
1 ha 3568
 
742 Rus 3569
1 ha 3570
 
742 Rus 3571
1 ha 3572
 
3573
	pop   edx
742 Rus 3574
	pop   ecx
3575
1 ha 3576
 
742 Rus 3577
1 ha 3578
 
3579
 
3580
3581
 
3582
; ebx = to
3583
; ecx = no of bytes
3584
    test ecx, ecx
3585
    jle  .ret
3586
3587
 
3588
 
3589
3590
 
3591
    mov  esi, eax
3592
3593
 
3594
    jz	 @f
742 Rus 3595
1 ha 3596
 
3597
    shr  ecx, 2
3598
    rep  movsd
3599
    pop  ecx
3600
    and  ecx, 11b
3601
    jz	 .finish
742 Rus 3602
  @@:
1 ha 3603
    rep  movsb
3604
3605
 
3606
    pop  ecx edi esi
3607
  .ret:
3608
    ret
3609
3610
 
3611
 
75 diamond 3612
;align 4
3613
;
1 ha 3614
;read_floppy_file:
75 diamond 3615
;
1 ha 3616
;; as input
75 diamond 3617
;;
3618
;; eax pointer to file
3619
;; ebx file lenght
3620
;; ecx start 512 byte block number
3621
;; edx number of blocks to read
3622
;; esi pointer to return/work area (atleast 20 000 bytes)
3623
;;
3624
;;
3625
;; on return
3626
;;
3627
;; eax = 0 command succesful
3628
;;       1 no fd base and/or partition defined
3629
;;       2 yet unsupported FS
3630
;;       3 unknown FS
3631
;;       4 partition not defined at hd
3632
;;       5 file not found
3633
;; ebx = size of file
3634
;
1 ha 3635
;     mov   edi,[TASK_BASE]
379 serge 3636
;     add   edi,0x10
75 diamond 3637
;     add   esi,[edi]
3638
;     add   eax,[edi]
3639
;
1 ha 3640
;     pushad
75 diamond 3641
;     mov  edi,esi
3642
;     add  edi,1024
3643
;     mov  esi,0x100000+19*512
3644
;     sub  ecx,1
3645
;     shl  ecx,9
3646
;     add  esi,ecx
3647
;     shl  edx,9
3648
;     mov  ecx,edx
3649
;     cld
3650
;     rep  movsb
3651
;     popad
3652
;
3653
;     mov   [esp+36],eax
3654
;     mov   [esp+24],ebx
3655
;     ret
3656
1 ha 3657
 
3658
 
3659
 
3660
3661
 
3662
3663
 
765 Rus 3664
    add   ebx, [eax + TASKDATA.mem_start]
3665
1 ha 3666
 
765 Rus 3667
    jae   .not_owner
75 diamond 3668
    mov   edi, [eax + TASKDATA.pid]
765 Rus 3669
    cmp   edi, [irq_owner + 4 * ecx]
3670
    je	  .spril1
3671
.not_owner:
75 diamond 3672
    xor   ecx, ecx
765 Rus 3673
    jmp   .end
3674
  .spril1:
3675
1 ha 3676
 
765 Rus 3677
    mov   esi, ebx
3678
    lea   edi, [irq00read + ecx]
3679
    push  16
3680
    pop   ecx
3681
3682
 
1 ha 3683
    rep   movsd
3684
  .end:
765 Rus 3685
    mov   [esp+32], ecx
3686
    ret
1 ha 3687
3688
 
3689
 
3690
3691
 
3692
     movzx esi, bh			 ; save number of subfunction, if bh = 1, return data size, otherwise, read data
760 Rus 3693
     xor   bh, bh
3694
     cmp   ebx, 16
3695
     jae   .not_owner
75 diamond 3696
     mov   edx, [4 * ebx + irq_owner]	 ; check for irq owner
760 Rus 3697
742 Rus 3698
 
760 Rus 3699
742 Rus 3700
 
760 Rus 3701
     je    gidril1
1 ha 3702
.not_owner:
75 diamond 3703
     xor   edx, edx
760 Rus 3704
     dec   edx
3705
     jmp   gid1
3706
1 ha 3707
 
996 serge 3708
1 ha 3709
 
760 Rus 3710
     lea   eax, [ebx + IRQ_SAVE]	 ; calculate address of the beginning of buffer + 0x0 - data size
3711
     mov   edx, [eax]			 ;                                              + 0x4 - data offset
3712
     dec   esi
3713
     jz    gid1
1 ha 3714
     test  edx, edx			 ; check if buffer is empty
760 Rus 3715
     jz    gid1
3716
1 ha 3717
 
760 Rus 3718
     mov   edi, ecx
3719
742 Rus 3720
 
760 Rus 3721
742 Rus 3722
 
760 Rus 3723
     jb    @f
759 Rus 3724
742 Rus 3725
 
760 Rus 3726
759 Rus 3727
 
3728
3729
 
760 Rus 3730
     cld
3731
     cmp   esi, ecx			 ; if greater than the buffer size, begin cycle again
3732
     jbe   @f
3733
759 Rus 3734
 
760 Rus 3735
     sub   edx, ecx
3736
759 Rus 3737
 
760 Rus 3738
     rep   movsb
3739
3740
 
3741
   @@:
3742
     lea   esi, [eax + ebx + 0x10]
3743
     mov   ecx, edx
3744
     add   ebx, edx
3745
3746
 
3747
     mov   edx, [eax]
3748
     mov   [eax], ecx			 ; set data size to zero
3749
     mov   [eax + 0x4], ebx		 ; set data offset
3750
3751
 
1 ha 3752
     mov   [esp+32], edx		 ; eax
760 Rus 3753
     ret
1 ha 3754
3755
 
3756
 
3757
3758
 
3759
3760
 
465 serge 3761
1 ha 3762
 
465 serge 3763
;     and   ecx,7    ; offset in byte
3764
1 ha 3765
 
465 serge 3766
;     add   edi,eax
3767
1 ha 3768
 
465 serge 3769
;     shl   ebx,cl
3770
1 ha 3771
 
742 Rus 3772
     jne   siar1
1 ha 3773
3774
 
465 serge 3775
;     and   [edi],byte bl
3776
     btr [edi], eax
3777
1 ha 3778
 
3779
3780
 
3781
3782
 
465 serge 3783
1 ha 3784
 
465 serge 3785
  ;  or    [edi],byte bl        ; disable access - ebp = 1
3786
1 ha 3787
 
3788
3789
 
3790
3791
 
3792
3793
 
3794
     jnz   free_port_area
3795
;     je    r_port_area
3796
;     jmp   free_port_area
3797
3798
 
3799
3800
 
3801
3802
 
742 Rus 3803
     ja    rpal1
75 diamond 3804
     cmp   ecx,65536
3805
     jae   rpal1
3806
     mov   esi,[RESERVED_PORTS]
381 serge 3807
     test  esi,esi	      ; no reserved areas ?
742 Rus 3808
     je    rpal2
1 ha 3809
     cmp   esi,255	      ; max reserved
742 Rus 3810
     jae   rpal1
75 diamond 3811
 rpal3:
465 serge 3812
     mov   edi,esi
1 ha 3813
     shl   edi,4
3814
     add   edi,RESERVED_PORTS
381 serge 3815
     cmp   ebx,[edi+8]
1 ha 3816
     ja    rpal4
75 diamond 3817
     cmp   ecx,[edi+4]
1 ha 3818
     jae   rpal1
3819
;     jb    rpal4
3820
;     jmp   rpal1
3821
 rpal4:
465 serge 3822
1 ha 3823
 
3824
     jnz   rpal3
3825
     jmp   rpal2
3826
   rpal1:
3827
     popad
3828
     mov   eax,1
3829
     ret
3830
3831
 
3832
     popad
3833
3834
 
3835
 
3836
     cli
3837
     pushad			   ; start enable io map
742 Rus 3838
1 ha 3839
 
3840
     jae   no_unmask_io ; jge
3841
3842
 
3843
3844
 
3845
3846
 
3847
3848
 
742 Rus 3849
     call  set_io_access_rights
1 ha 3850
3851
 
3852
3853
 
3854
     cmp   eax,ecx
3855
     jbe   new_port_access
3856
3857
 
3858
3859
 
742 Rus 3860
     sti
1 ha 3861
3862
 
381 serge 3863
     add   edi,1
1 ha 3864
     mov   [RESERVED_PORTS],edi
381 serge 3865
     shl   edi,4
1 ha 3866
     add   edi,RESERVED_PORTS
381 serge 3867
     mov   esi,[TASK_BASE]
379 serge 3868
     mov   esi,[esi+TASKDATA.pid]
115 poddubny 3869
     mov   [edi],esi
1 ha 3870
     mov   [edi+4],ebx
3871
     mov   [edi+8],ecx
3872
3873
 
3874
     ret
3875
3876
 
3877
3878
 
3879
3880
 
381 serge 3881
     test  esi,esi
75 diamond 3882
     je    frpal2
1 ha 3883
     mov   edx,[TASK_BASE]
379 serge 3884
     mov   edx,[edx+TASKDATA.pid]
115 poddubny 3885
   frpal3:
1 ha 3886
     mov   edi,esi
3887
     shl   edi,4
3888
     add   edi,RESERVED_PORTS
381 serge 3889
     cmp   edx,[edi]
1 ha 3890
     jne   frpal4
3891
     cmp   ebx,[edi+4]
3892
     jne   frpal4
3893
     cmp   ecx,[edi+8]
3894
     jne   frpal4
3895
     jmp   frpal1
3896
   frpal4:
3897
     dec   esi
3898
     jnz   frpal3
3899
   frpal2:
3900
     popad
3901
     mov   eax,1
3902
     ret
3903
   frpal1:
3904
     mov   ecx,256
3905
     sub   ecx,esi
3906
     shl   ecx,4
3907
     mov   esi,edi
3908
     add   esi,16
3909
     cld
3910
     rep   movsb
3911
3912
 
381 serge 3913
1 ha 3914
 
3915
3916
 
3917
 
3918
3919
 
742 Rus 3920
1 ha 3921
 
3922
     jge   no_mask_io
3923
3924
 
3925
3926
 
3927
3928
 
3929
3930
 
742 Rus 3931
     call  set_io_access_rights
1 ha 3932
3933
 
3934
3935
 
3936
     cmp   eax,ecx
3937
     jbe   new_port_access_disable
3938
3939
 
3940
3941
 
742 Rus 3942
1 ha 3943
 
3944
     ret
3945
3946
 
3947
 
3948
3949
 
765 Rus 3950
     inc   esi
3951
     cmp   ecx, 16
3952
     jae   ril1
3953
1 ha 3954
 
769 Rus 3955
     lea   ecx, [irq_owner + 4 * ecx]
765 Rus 3956
     mov   edx, [ecx]
3957
     mov   eax, [TASK_BASE]
3958
     mov   edi, [eax + TASKDATA.pid]
3959
     pop   eax
769 Rus 3960
     dec   ebx
765 Rus 3961
     jnz   reserve_irq
3962
1 ha 3963
 
765 Rus 3964
     jne   ril1
3965
     dec   esi
3966
     mov   [ecx], esi
3967
3968
 
3969
3970
 
1 ha 3971
3972
 
765 Rus 3973
     jne   ril1
3974
1 ha 3975
 
769 Rus 3976
3977
 
774 Rus 3978
769 Rus 3979
 
765 Rus 3980
769 Rus 3981
 
765 Rus 3982
   ril1:
1 ha 3983
     mov   [esp+32], esi ; return in eax
765 Rus 3984
     ret
1 ha 3985
3986
 
769 Rus 3987
f_irqs:
3988
     dd 0x0
3989
     dd 0x0
3990
     dd p_irq2
3991
     dd p_irq3
3992
     dd p_irq4
3993
     dd p_irq5
3994
     dd p_irq6
3995
     dd p_irq7
3996
     dd p_irq8
3997
     dd p_irq9
3998
     dd p_irq10
3999
     dd p_irq11
4000
     dd 0x0
4001
     dd 0x0
4002
     dd p_irq14
4003
     dd p_irq15
4004
4005
 
4006
4007
 
1 ha 4008
       inc   [mouse_pause]
33 mario79 4009
       cmp   [scr_mode], 0x12
928 serge 4010
       je   dbrv20
117 mario79 4011
     dbrv12:
1 ha 4012
       cmp  [scr_mode], 0100000000000000b
928 serge 4013
       jge  dbrv20
1 ha 4014
       cmp  [scr_mode], 0x13
928 serge 4015
       je   dbrv20
1 ha 4016
       call  vesa12_drawbackground
4017
       dec   [mouse_pause]
33 mario79 4018
       call   [draw_pointer]
36 mario79 4019
       ret
1 ha 4020
     dbrv20:
4021
       cmp   [BgrDrawMode],dword 1
527 diamond 4022
       jne   bgrstr
1 ha 4023
       call  vesa20_drawbackground_tiled
4024
       dec   [mouse_pause]
33 mario79 4025
       call   [draw_pointer]
36 mario79 4026
       ret
1 ha 4027
     bgrstr:
4028
       call  vesa20_drawbackground_stretch
4029
       dec   [mouse_pause]
33 mario79 4030
       call   [draw_pointer]
36 mario79 4031
       ret
1 ha 4032
4033
 
75 diamond 4034
1 ha 4035
 
742 Rus 4036
sys_putimage:
1 ha 4037
     test  ecx,0x80008000
53 mikedld 4038
     jnz   .exit
4039
     test  ecx,0x0000FFFF
4040
     jz    .exit
4041
     test  ecx,0xFFFF0000
4042
     jnz   @f
4043
.exit:
996 serge 4044
     ret
53 mikedld 4045
@@:
996 serge 4046
	mov	edi,[current_slot]
742 Rus 4047
	add	dx,word[edi+APPDATA.wnd_clientbox.top]
4048
	rol	edx,16
4049
	add	dx,word[edi+APPDATA.wnd_clientbox.left]
4050
	rol	edx,16
4051
.forced:
996 serge 4052
	push	ebp esi 0
742 Rus 4053
	mov	ebp, putimage_get24bpp
4054
	mov	esi, putimage_init24bpp
4055
sys_putimage_bpp:
283 diamond 4056
;        call    [disable_mouse] ; this will be done in xxx_putimage
4057
;        mov     eax, vga_putimage
117 mario79 4058
    cmp [scr_mode], 0x12
928 serge 4059
	jz	@f   ;.doit
742 Rus 4060
	mov	eax, vesa12_putimage
4061
    cmp [scr_mode], 0100000000000000b
928 serge 4062
	jae	@f
742 Rus 4063
    cmp [scr_mode], 0x13
928 serge 4064
	jnz	.doit
742 Rus 4065
@@:
75 diamond 4066
	mov	eax, vesa20_putimage
742 Rus 4067
.doit:
75 diamond 4068
	inc	[mouse_pause]
742 Rus 4069
	call	eax
4070
	dec	[mouse_pause]
4071
	pop	ebp esi ebp
4072
	jmp	[draw_pointer]
4073
1 ha 4074
 
283 diamond 4075
	mov	edi, esi
742 Rus 4076
	mov	esi, edx
4077
	mov	edx, ecx
4078
	mov	ecx, ebx
4079
	mov	ebx, eax
4080
sys_putimage_palette:
283 diamond 4081
; ebx = pointer to image
4082
; ecx = [xsize]*65536 + [ysize]
4083
; edx = [xstart]*65536 + [ystart]
4084
; esi = number of bits per pixel, must be 8, 24 or 32
314 diamond 4085
; edi = pointer to palette
283 diamond 4086
; ebp = row delta
314 diamond 4087
	mov	eax, [CURRENT_TASK]
742 Rus 4088
	shl	eax, 8
4089
	add	dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top]
4090
	rol	edx, 16
4091
	add	dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left]
4092
	rol	edx, 16
4093
.forced:
283 diamond 4094
	cmp	esi, 1
914 serge 4095
	jnz	@f
4096
	push	edi
4097
	mov	eax, [edi+4]
4098
	sub	eax, [edi]
4099
	push	eax
4100
	push	dword [edi]
4101
	push	0ffffff80h
4102
	mov	edi, esp
4103
	call	put_mono_image
4104
	add	esp, 12
4105
	pop	edi
4106
	ret
4107
@@:
4108
	cmp	esi, 4
4109
	jnz	@f
4110
	push	edi
4111
	push	0ffffff80h
4112
	mov	edi, esp
4113
	call	put_4bit_image
4114
	pop	eax
4115
	pop	edi
4116
	ret
4117
@@:
4118
	push	ebp esi ebp
742 Rus 4119
	cmp	esi, 8
4120
	jnz	@f
4121
	mov	ebp, putimage_get8bpp
4122
	mov	esi, putimage_init8bpp
4123
	jmp	sys_putimage_bpp
4124
@@:
314 diamond 4125
        cmp     esi, 15
914 serge 4126
        jnz     @f
4127
        mov     ebp, putimage_get15bpp
4128
        mov     esi, putimage_init15bpp
4129
        jmp     sys_putimage_bpp
4130
@@:
4131
        cmp     esi, 16
844 serge 4132
        jnz     @f
4133
        mov     ebp, putimage_get16bpp
4134
        mov     esi, putimage_init16bpp
4135
        jmp     sys_putimage_bpp
4136
@@:
4137
	cmp	esi, 24
742 Rus 4138
	jnz	@f
4139
	mov	ebp, putimage_get24bpp
4140
	mov	esi, putimage_init24bpp
4141
	jmp	sys_putimage_bpp
4142
@@:
314 diamond 4143
	cmp	esi, 32
742 Rus 4144
	jnz	@f
4145
	mov	ebp, putimage_get32bpp
4146
	mov	esi, putimage_init32bpp
4147
	jmp	sys_putimage_bpp
4148
@@:
314 diamond 4149
	pop	ebp esi ebp
844 serge 4150
	ret
742 Rus 4151
283 diamond 4152
 
914 serge 4153
	push	ebp esi ebp
4154
	mov	ebp, putimage_get1bpp
4155
	mov	esi, putimage_init1bpp
4156
	jmp	sys_putimage_bpp
4157
put_4bit_image:
4158
	push	ebp esi ebp
4159
	mov	ebp, putimage_get4bpp
4160
	mov	esi, putimage_init4bpp
4161
	jmp	sys_putimage_bpp
4162
4163
 
283 diamond 4164
	lea	eax, [eax*3]
742 Rus 4165
putimage_init8bpp:
283 diamond 4166
	ret
742 Rus 4167
283 diamond 4168
 
914 serge 4169
putimage_get24bpp:
283 diamond 4170
	mov	eax, [esi]
742 Rus 4171
	add	esi, 3
4172
	ret	4
4173
align 16
914 serge 4174
putimage_get8bpp:
283 diamond 4175
	movzx	eax, byte [esi]
742 Rus 4176
	push	edx
4177
	mov	edx, [esp+8]
4178
	mov	eax, [edx+eax*4]
4179
	pop	edx
4180
	inc	esi
4181
	ret	4
4182
283 diamond 4183
 
914 serge 4184
	add	eax, ecx
4185
	push	ecx
4186
	add	eax, 7
4187
	add	ecx, 7
4188
	shr	eax, 3
4189
	shr	ecx, 3
4190
	sub	eax, ecx
4191
	pop	ecx
4192
	ret
4193
align 16
4194
putimage_get1bpp:
4195
	push	edx
4196
	mov	edx, [esp+8]
4197
	mov	al, [edx]
4198
	add	al, al
4199
	jnz	@f
4200
	lodsb
4201
	adc	al, al
4202
@@:
4203
	mov	[edx], al
4204
	sbb	eax, eax
4205
	and	eax, [edx+8]
4206
	add	eax, [edx+4]
4207
	pop	edx
4208
	ret	4
4209
4210
 
4211
	add	eax, ecx
4212
	push	ecx
4213
	add	ecx, 1
4214
	add	eax, 1
4215
	shr	ecx, 1
4216
	shr	eax, 1
4217
	sub	eax, ecx
4218
	pop	ecx
4219
	ret
4220
align 16
4221
putimage_get4bpp:
4222
	push	edx
4223
	mov	edx, [esp+8]
4224
	add	byte [edx], 80h
4225
	jc	@f
4226
	movzx	eax, byte [edx+1]
4227
	mov	edx, [edx+4]
4228
	and	eax, 0x0F
4229
	mov	eax, [edx+eax*4]
4230
	pop	edx
4231
	ret	4
4232
@@:
4233
	movzx	eax, byte [esi]
4234
	add	esi, 1
4235
	mov	[edx+1], al
4236
	shr	eax, 4
4237
	mov	edx, [edx+4]
4238
	mov	eax, [edx+eax*4]
4239
	pop	edx
4240
	ret	4
4241
4242
 
314 diamond 4243
	shl	eax, 2
742 Rus 4244
	ret
4245
align 16
914 serge 4246
putimage_get32bpp:
314 diamond 4247
	lodsd
742 Rus 4248
	ret	4
4249
314 diamond 4250
 
914 serge 4251
putimage_init16bpp:
844 serge 4252
        add     eax, eax
4253
        ret
4254
align 16
914 serge 4255
putimage_get15bpp:
4256
; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000
844 serge 4257
        push    ecx edx
4258
        movzx   eax, word [esi]
4259
        add     esi, 2
4260
        mov     ecx, eax
4261
        mov     edx, eax
4262
        and     eax, 0x1F
4263
        and     ecx, 0x1F shl 5
4264
        and     edx, 0x1F shl 10
4265
        shl     eax, 3
4266
        shl     ecx, 6
4267
        shl     edx, 9
4268
        or      eax, ecx
4269
        or      eax, edx
4270
        pop     edx ecx
4271
        ret     4
914 serge 4272
844 serge 4273
 
914 serge 4274
putimage_get16bpp:
4275
; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000
4276
        push    ecx edx
4277
        movzx   eax, word [esi]
4278
        add     esi, 2
4279
        mov     ecx, eax
4280
        mov     edx, eax
4281
        and     eax, 0x1F
4282
        and     ecx, 0x3F shl 5
4283
        and     edx, 0x1F shl 11
4284
        shl     eax, 3
4285
        shl     ecx, 5
4286
        shl     edx, 8
4287
        or      eax, ecx
4288
        or      eax, edx
4289
        pop     edx ecx
4290
        ret     4
4291
4292
 
1 ha 4293
; ebx y beginning
4294
; ecx x end
4295
	; edx y end
283 diamond 4296
; edi color
1 ha 4297
4298
 
4299
	mov	esi,[current_slot]
742 Rus 4300
	add	eax,[esi+APPDATA.wnd_clientbox.left]
4301
	add	ecx,[esi+APPDATA.wnd_clientbox.left]
4302
	add	ebx,[esi+APPDATA.wnd_clientbox.top]
4303
	add	edx,[esi+APPDATA.wnd_clientbox.top]
4304
  .forced:
114 mikedld 4305
    inc   [mouse_pause]
33 mario79 4306
;        call    [disable_mouse]
283 diamond 4307
    cmp   [scr_mode], 0x12
928 serge 4308
    je	 dbv20
742 Rus 4309
   sdbv20:
1 ha 4310
    cmp  [scr_mode], 0100000000000000b
928 serge 4311
    jge  dbv20
1 ha 4312
    cmp  [scr_mode], 0x13
928 serge 4313
    je	 dbv20
742 Rus 4314
    call vesa12_drawbar
1 ha 4315
    dec   [mouse_pause]
33 mario79 4316
    call   [draw_pointer]
36 mario79 4317
    ret
1 ha 4318
  dbv20:
4319
    call vesa20_drawbar
4320
    dec   [mouse_pause]
33 mario79 4321
    call   [draw_pointer]
36 mario79 4322
    ret
1 ha 4323
4324
 
4325
 
4326
 
4327
4328
 
742 Rus 4329
1 ha 4330
 
742 Rus 4331
      kr_loop:
1 ha 4332
	in	al,0x64
742 Rus 4333
	test	al,1
4334
	jnz	kr_ready
4335
	loop	kr_loop
4336
	mov	ah,1
4337
	jmp	kr_exit
4338
      kr_ready:
1 ha 4339
	push	ecx
742 Rus 4340
	mov	ecx,32
4341
      kr_delay:
1 ha 4342
	loop	kr_delay
742 Rus 4343
	pop	ecx
4344
	in	al,0x60
4345
	xor	ah,ah
4346
      kr_exit:
1 ha 4347
4348
 
742 Rus 4349
1 ha 4350
 
742 Rus 4351
1 ha 4352
 
4353
 
4354
4355
 
742 Rus 4356
1 ha 4357
 
742 Rus 4358
;        mov     ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
265 diamond 4359
;      kw_loop1:
4360
;        in      al,0x64
4361
;        test    al,0x20
4362
;        jz      kw_ok1
4363
;        loop    kw_loop1
4364
;        mov     ah,1
4365
;        jmp     kw_exit
4366
;      kw_ok1:
4367
	in	al,0x60
742 Rus 4368
	mov	ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
4369
      kw_loop:
1 ha 4370
	in	al,0x64
742 Rus 4371
	test	al,2
4372
	jz	kw_ok
4373
	loop	kw_loop
4374
	mov	ah,1
4375
	jmp	kw_exit
4376
      kw_ok:
1 ha 4377
	mov	al,dl
742 Rus 4378
	out	0x60,al
4379
	mov	ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
4380
      kw_loop3:
1 ha 4381
	in	al,0x64
742 Rus 4382
	test	al,2
4383
	jz	kw_ok3
4384
	loop	kw_loop3
4385
	mov	ah,1
4386
	jmp	kw_exit
4387
      kw_ok3:
1 ha 4388
	mov	ah,8
742 Rus 4389
      kw_loop4:
1 ha 4390
	mov	ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
742 Rus 4391
      kw_loop5:
1 ha 4392
	in	al,0x64
742 Rus 4393
	test	al,1
4394
	jnz	kw_ok4
4395
	loop	kw_loop5
4396
	dec	ah
4397
	jnz	kw_loop4
4398
      kw_ok4:
1 ha 4399
	xor	ah,ah
742 Rus 4400
      kw_exit:
1 ha 4401
4402
 
742 Rus 4403
1 ha 4404
 
742 Rus 4405
1 ha 4406
 
4407
 
4408
4409
 
742 Rus 4410
      c_wait:
1 ha 4411
	in	al,0x64
742 Rus 4412
	test	al,2
4413
	jz	c_send
4414
	loop	c_wait
4415
	jmp	c_error
4416
      c_send:
1 ha 4417
	mov	al,bl
742 Rus 4418
	out	0x64,al
4419
	mov	ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
4420
      c_accept:
1 ha 4421
	in	al,0x64
742 Rus 4422
	test	al,2
4423
	jz	c_ok
4424
	loop	c_accept
4425
      c_error:
1 ha 4426
	mov	ah,1
742 Rus 4427
	jmp	c_exit
4428
      c_ok:
1 ha 4429
	xor	ah,ah
742 Rus 4430
      c_exit:
1 ha 4431
	ret
742 Rus 4432
1 ha 4433
 
4434
 
4435
     bt [cpu_caps], CAPS_TSC
164 serge 4436
     jnc ret_rdtsc
4437
     rdtsc
1 ha 4438
     ret
4439
   ret_rdtsc:
4440
     mov   edx,0xffffffff
4441
     mov   eax,0xffffffff
4442
     ret
4443
4444
 
4445
4446
 
742 Rus 4447
	out	0x20,al
4448
	out	0xA0,al
4449
1 ha 4450
 
742 Rus 4451
	out	0x21,al
4452
	mov	al,0x28 	;  generate 0x28 +
4453
	out	0xA1,al
4454
1 ha 4455
 
742 Rus 4456
	out	0x21,al
4457
	mov	al,0x02 	;  at irq9
4458
	out	0xA1,al
4459
1 ha 4460
 
742 Rus 4461
	out	0x21,al
4462
	out	0xA1,al
4463
1 ha 4464
 
742 Rus 4465
	out	0xA1,al
4466
	out	0x21,al
4467
1 ha 4468
 
742 Rus 4469
	out	0xA1,al
4470
	out	0x21,al
4471
	ret
4472
1 ha 4473
 
890 serge 4474
_SysMsgBoardStr:
4475
sys_msg_board_str:
1 ha 4476
4477
 
4478
   @@:
4479
     cmp    [esi],byte 0
4480
     je     @f
4481
     mov    eax,1
4482
     movzx  ebx,byte [esi]
4483
     call   sys_msg_board
4484
     inc    esi
4485
     jmp    @b
4486
   @@:
4487
     popad
4488
     ret
4489
4490
 
709 diamond 4491
; in: al = byte to display
4492
; out: nothing
4493
; destroys: nothing
4494
	pushad
742 Rus 4495
	mov	ecx, 2
4496
	shl	eax, 24
4497
	jmp	@f
4498
709 diamond 4499
 
4500
; in: ax = word to display
4501
; out: nothing
4502
; destroys: nothing
4503
	pushad
742 Rus 4504
	mov	ecx, 4
4505
	shl	eax, 16
4506
	jmp	@f
4507
709 diamond 4508
 
4509
; in: eax = dword to display
4510
; out: nothing
4511
; destroys: nothing
4512
	pushad
742 Rus 4513
	mov	ecx, 8
4514
@@:
709 diamond 4515
	push	ecx
742 Rus 4516
	rol	eax, 4
4517
	push	eax
4518
	and	al, 0xF
4519
	cmp	al, 10
4520
	sbb	al, 69h
4521
	das
4522
	mov	bl, al
4523
	xor	eax, eax
4524
	inc	eax
4525
	call	sys_msg_board
4526
	pop	eax
4527
	pop	ecx
4528
	loop	@b
4529
	popad
4530
	ret
4531
709 diamond 4532
 
1 ha 4533
  msg_board_data: times 4096 db 0
373 mikedld 4534
  msg_board_count dd 0x0
1 ha 4535
endg
4536
4537
 
4538
4539
 
4540
; eax=2 :  read :  ebx=0 -> no data, ebx=1 -> data in al
4541
4542
 
671 Ghost 4543
	cmp	eax, 1
4544
	jne	.smbl1
4545
1 ha 4546
 
4547
 
671 Ghost 4548
	inc	ecx
4549
	and	ecx, 4095
4550
	mov	[msg_board_count], ecx
4551
	mov	[check_idle_semaphore], 5
4552
	ret
4553
.smbl1:
4554
	cmp	eax, 2
4555
	jne	.smbl2
4556
	test	ecx, ecx
4557
	jz	.smbl21
4558
	mov	eax, msg_board_data+1
4559
	mov	ebx, msg_board_data
4560
	movzx	edx, byte [ebx]
4561
	call	memmove
4562
	dec	[msg_board_count]
4563
	mov	[esp + 36], edx ;eax
4564
	mov	[esp + 24], dword 1
4565
	ret
4566
.smbl21:
4567
	mov	[esp+36], ecx
4568
	mov	[esp+24], ecx
4569
.smbl2:
4570
	ret
4571
1 ha 4572
 
4573
 
4574
 
4575
	mov	edi, [CURRENT_TASK]
742 Rus 4576
1 ha 4577
 
742 Rus 4578
     jne   no_set_keyboard_setup
1 ha 4579
4580
 
4581
     mov   [edi+SLOT_BASE + APPDATA.keyboard_mode],bl
380 serge 4582
1 ha 4583
 
4584
4585
 
4586
4587
 
742 Rus 4588
     jne   no_get_keyboard_setup
1 ha 4589
4590
 
4591
     movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode]
380 serge 4592
1 ha 4593
 
4594
4595
 
4596
4597
 
4598
4599
 
742 Rus 4600
     jne   no_get_keyboard_cas
1 ha 4601
4602
 
4603
;     movzx eax,byte [shift]
4604
;     movzx ebx,byte [ctrl]
4605
;     shl   ebx,2
4606
;     add   eax,ebx
4607
;     movzx ebx,byte [alt]
4608
;     shl   ebx,3
4609
;     add   eax,ebx
4610
4611
 
4612
     mov   eax, [kb_state]
4613
 ;// mike.dld ]
4614
4615
 
4616
4617
 
4618
4619
 
4620
4621
 
742 Rus 4622
	jnz	no_add_keyboard_hotkey
4623
1 ha 4624
 
742 Rus 4625
@@:
92 diamond 4626
	cmp	dword [eax+8], 0
742 Rus 4627
	jz	.found_free
4628
	add	eax, 16
4629
	cmp	eax, hotkey_list+16*256
4630
	jb	@b
4631
	mov	dword [esp+36], 1
4632
	ret
4633
.found_free:
92 diamond 4634
	mov	[eax+8], edi
742 Rus 4635
	mov	[eax+4], ecx
4636
	movzx	ebx, bl
4637
	lea	ebx, [hotkey_scancodes+ebx*4]
4638
	mov	ecx, [ebx]
4639
	mov	[eax], ecx
4640
	mov	[ebx], eax
4641
	mov	[eax+12], ebx
4642
	jecxz	@f
4643
	mov	[ecx+12], eax
4644
@@:
92 diamond 4645
	and	dword [esp+36], 0
742 Rus 4646
	ret
4647
92 diamond 4648
 
4649
4650
 
742 Rus 4651
	jnz	no_del_keyboard_hotkey
4652
92 diamond 4653
 
742 Rus 4654
	lea	ebx, [hotkey_scancodes+ebx*4]
4655
	mov	eax, [ebx]
4656
.scan:
92 diamond 4657
	test	eax, eax
742 Rus 4658
	jz	.notfound
4659
	cmp	[eax+8], edi
4660
	jnz	.next
4661
	cmp	[eax+4], ecx
4662
	jz	.found
4663
.next:
92 diamond 4664
	mov	eax, [eax]
742 Rus 4665
	jmp	.scan
4666
.notfound:
92 diamond 4667
	mov	dword [esp+36], 1
742 Rus 4668
	ret
4669
.found:
92 diamond 4670
	mov	ecx, [eax]
742 Rus 4671
	jecxz	@f
4672
	mov	edx, [eax+12]
4673
	mov	[ecx+12], edx
4674
@@:
92 diamond 4675
	mov	ecx, [eax+12]
742 Rus 4676
	mov	edx, [eax]
4677
	mov	[ecx], edx
4678
	xor	edx, edx
4679
	mov	[eax+4], edx
4680
	mov	[eax+8], edx
4681
	mov	[eax+12], edx
4682
	mov	[eax], edx
4683
	mov	[esp+36], edx
4684
	ret
4685
92 diamond 4686
 
4687
     ret
1 ha 4688
4689
 
4690
 
4691
4692
 
742 Rus 4693
1 ha 4694
 
742 Rus 4695
     jne  no_gs1
1 ha 4696
     mov  eax,[Screen_Max_X]
753 serge 4697
     shl  eax,16
1 ha 4698
     mov  ax, word [Screen_Max_Y]
928 serge 4699
     add  eax,0x00010001
1 ha 4700
     mov  [esp+36],eax
4701
     ret
4702
   no_gs1:
4703
4704
 
742 Rus 4705
     jne   no_gs2
1 ha 4706
     mov   eax, [ScreenBPP]
928 serge 4707
     mov   [esp+36],eax
1 ha 4708
     ret
4709
   no_gs2:
4710
4711
 
742 Rus 4712
     jne   no_gs3
1 ha 4713
     mov   eax,[BytesPerScanLine]
381 serge 4714
     mov   [esp+36],eax
1 ha 4715
     ret
4716
   no_gs3:
4717
4718
 
4719
     ret
4720
4721
 
4722
 
4723
4724
 
4725
4726
 
4727
     mov   [esp+36],eax
4728
     ret
4729
4730
 
4731
 
4732
4733
 
742 Rus 4734
1 ha 4735
 
742 Rus 4736
	mov	ebx, ecx
4737
	mov	ecx, edx
4738
	mov	edx, [TASK_BASE]
4739
	add	eax, [edx-twdw+WDATA.box.left]
4740
	add	ebx, [edx-twdw+WDATA.box.top]
4741
	mov	edi, [current_slot]
4742
	add	eax, [edi+APPDATA.wnd_clientbox.left]
4743
	add	ebx, [edi+APPDATA.wnd_clientbox.top]
4744
	xor	edi, edi ; no force
4745
;       mov     edi, 1
684 diamond 4746
	call	[disable_mouse]
742 Rus 4747
	jmp	[putpixel]
4748
1 ha 4749
 
4750
4751
 
742 Rus 4752
1 ha 4753
 
742 Rus 4754
	mov   ebp,[eax-twdw+WDATA.box.left]
4755
	push  esi
4756
	mov   esi,[current_slot]
4757
	add   ebp,[esi+APPDATA.wnd_clientbox.left]
4758
	shl   ebp,16
4759
	add   ebp,[eax-twdw+WDATA.box.top]
4760
	add   bp,word[esi+APPDATA.wnd_clientbox.top]
4761
	pop   esi
4762
	add   ebx,ebp
4763
	mov   eax,edi
4764
	xor   edi,edi
4765
	jmp   dtext
4766
1 ha 4767
 
4768
4769
 
742 Rus 4770
1 ha 4771
 
742 Rus 4772
	mov	ebx, ecx
4773
	mov	ecx, edx
4774
	mov	edx, esi
4775
	mov	esi, 12
4776
	call	fileread
4777
	mov	[esp+32], eax
4778
	ret
4779
1 ha 4780
 
4781
4782
 
742 Rus 4783
1 ha 4784
 
671 Ghost 4785
	and	edi, 0x80FFFFFF
4786
	test	bx, bx	; x.size
4787
	je	.drectr
4788
	test	cx, cx ; y.size
4789
	je	.drectr
4790
1 ha 4791
 
671 Ghost 4792
	mov	ebx, ecx
4793
1 ha 4794
 
671 Ghost 4795
	shr	eax, 16 ; eax - x.coord
4796
	movzx	edx, bx ; edx - y.size
4797
	shr	ebx, 16 ; ebx - y.coord
4798
	mov	esi, [current_slot]
4799
1 ha 4800
 
671 Ghost 4801
	add	ebx, [esi + APPDATA.wnd_clientbox.top]
4802
	add	ecx, eax
4803
	add	edx, ebx
4804
	jmp	[drawbar]
4805
.drectr:
4806
	ret
4807
1 ha 4808
 
4809
syscall_getscreensize:			; GetScreenSize
742 Rus 4810
    mov eax, [Screen_Max_X]
928 serge 4811
	shl	eax, 16
671 Ghost 4812
    mov ax, word [Screen_Max_Y]
928 serge 4813
	mov	[esp + 32], eax
671 Ghost 4814
	ret
4815
1 ha 4816
 
671 Ghost 4817
4818
 
742 Rus 4819
1 ha 4820
 
742 Rus 4821
	jb	.audio
4822
	jz	.eject
4823
	cmp	eax, 5
4824
	jnz	.ret
4825
.load:
588 diamond 4826
	call	.reserve
742 Rus 4827
	call	LoadMedium
4828
	call	.free
4829
	ret
4830
.eject:
588 diamond 4831
	call	.reserve
742 Rus 4832
	call	clear_CD_cache
4833
	call	allow_medium_removal
4834
	call	EjectMedium
4835
	call	.free
4836
	ret
4837
.audio:
588 diamond 4838
     call  sys_cd_audio
1 ha 4839
     mov   [esp+36],eax
4840
.ret:
588 diamond 4841
     ret
1 ha 4842
4843
 
588 diamond 4844
	call	reserve_cd
742 Rus 4845
	mov	eax, ebx
4846
	shr	eax, 1
4847
	and	eax, 1
4848
	inc	eax
4849
	mov	[ChannelNumber], ax
4850
	mov	eax, ebx
4851
	and	eax, 1
4852
	mov	[DiskNumber], al
4853
	call	reserve_cd_channel
4854
	and	ebx, 3
4855
	inc	ebx
4856
	mov	[cdpos], ebx
4857
	add	ebx, ebx
4858
	mov	cl, 8
4859
	sub	cl, bl
4860
	mov	al, [DRIVE_DATA+1]
4861
	shr	al, cl
4862
	test	al, 2
4863
	jz	.err
4864
	ret
4865
.free:
588 diamond 4866
	call	free_cd_channel
742 Rus 4867
	and	[cd_status], 0
4868
	ret
4869
.err:
590 diamond 4870
	call	.free
742 Rus 4871
	pop	eax
4872
	ret
4873
588 diamond 4874
 
1 ha 4875
4876
 
742 Rus 4877
     mov   ecx, [Screen_Max_X]
753 serge 4878
     inc   ecx
1 ha 4879
     xor   edx, edx
671 Ghost 4880
     mov   eax, ebx
4881
     div   ecx
1 ha 4882
     mov   ebx, edx
671 Ghost 4883
     xchg  eax, ebx
4884
     call  dword [get_pixel] ; eax - x, ebx - y
928 serge 4885
     mov   [esp + 32], ecx
671 Ghost 4886
     ret
1 ha 4887
4888
 
4889
 
4890
4891
 
742 Rus 4892
1 ha 4893
 
671 Ghost 4894
	movzx	eax, word[edi-twdw+WDATA.box.left]
752 Lrz 4895
	mov	ebp, eax
4896
	mov	esi, [current_slot]
671 Ghost 4897
	add	ebp, [esi+APPDATA.wnd_clientbox.left]
4898
	add	ax, word[esi+APPDATA.wnd_clientbox.left]
752 Lrz 4899
	add	ebp,ebx
4900
	shl	eax, 16
4901
	movzx	ebx, word[edi-twdw+WDATA.box.top]
4902
	add	eax, ebp
671 Ghost 4903
	mov	ebp, ebx
752 Lrz 4904
	add	ebp, [esi+APPDATA.wnd_clientbox.top]
671 Ghost 4905
	add	bx, word[esi+APPDATA.wnd_clientbox.top]
752 Lrz 4906
	add	ebp, ecx
759 Rus 4907
	shl	ebx, 16
752 Lrz 4908
	xor	edi, edi
671 Ghost 4909
	add	ebx, ebp
752 Lrz 4910
	mov	ecx, edx
4911
	jmp	[draw_line]
671 Ghost 4912
1 ha 4913
 
4914
4915
 
742 Rus 4916
4917
 
4918
     jae   .err
75 diamond 4919
742 Rus 4920
 
774 Rus 4921
     je    .err
4922
4923
 
742 Rus 4924
     mov   [esp+32],eax
4925
4926
 
1 ha 4927
.err:
75 diamond 4928
     or    dword [esp+32], -1
742 Rus 4929
     ret
75 diamond 4930
1 ha 4931
 
4932
4933
 
742 Rus 4934
1 ha 4935
 
4936
     mov   [esp+36],eax
4937
     ret
4938
4939
 
4940
4941
 
742 Rus 4942
1 ha 4943
 
4944
     mov   [esp+36],eax
4945
     ret
4946
4947
 
4948
4949
 
4950
4951
 
742 Rus 4952
1 ha 4953
 
4954
;     call  change_task                 ; between sent packet
4955
4956
 
4957
     ret
4958
4959
 
4960
4961
 
742 Rus 4962
     call  app_socket_handler
1 ha 4963
4964
 
4965
;     call  change_task                 ; between sent packet
4966
4967
 
4968
     mov   [esp+24],ebx
4969
     ret
4970
4971
 
4972
4973
 
742 Rus 4974
1 ha 4975
 
379 serge 4976
     add   edi,TASKDATA.mem_start
115 poddubny 4977
     add   eax,[edi]
1 ha 4978
     add   ecx,[edi]
4979
     add   edx,[edi]
4980
     call  file_read
4981
4982
 
4983
     mov   [esp+24],ebx
4984
4985
 
4986
4987
 
375 Ghost 4988
	ret
742 Rus 4989
378 serge 4990
 
890 serge 4991
 
757 serge 4992
_SetScreen:
890 serge 4993
set_screen:
757 serge 4994
	cmp eax, [Screen_Max_X]
759 Rus 4995
	jne .set
4996
709 diamond 4997
 
759 Rus 4998
	jne .set
4999
	ret
5000
.set:
757 serge 5001
	pushfd
759 Rus 5002
	cli
5003
757 serge 5004
 
759 Rus 5005
	mov [Screen_Max_Y], edx
5006
757 serge 5007
 
759 Rus 5008
	mov [screen_workarea.bottom], edx
5009
	inc eax
5010
	shl eax, 2			;32 bpp
5011
	mov [BytesPerScanLine], eax
5012
	push ebx
5013
	push esi
5014
	push edi
5015
	call	repos_windows
5016
	mov	eax, 0
5017
	mov	ebx, 0
5018
	mov	ecx, [Screen_Max_X]
5019
	mov	edx, [Screen_Max_Y]
5020
	call	calculatescreen
5021
	pop edi
5022
	pop esi
5023
	pop ebx
5024
757 serge 5025
 
759 Rus 5026
	ret
5027
757 serge 5028
 
76 mario79 5029
apm_entry    dp    0
5030
apm_vf	      dd    0
742 Rus 5031
align 4
1 ha 5032
sys_apm:
76 mario79 5033
    cmp    word [apm_vf], 0    ; Check APM BIOS enable
5034
    jne    @f
5035
    or	  [esp + 56], byte 1	; error
742 Rus 5036
    mov    [esp + 36], dword 8	  ; 32-bit protected-mode interface not supported
5037
    ret
76 mario79 5038
164 serge 5039
 
465 serge 5040
    xchg    eax, ecx
5041
    xchg    ebx, ecx
76 mario79 5042
164 serge 5043
 
76 mario79 5044
    ja	  @f
742 Rus 5045
    and    [esp + 56], byte 0xfe    ; emulate func 0..3 as func 0
78 diamond 5046
    mov    eax, [apm_vf]
76 mario79 5047
    mov    [esp + 36], eax
5048
    shr    eax, 16
5049
    mov    [esp + 32], eax
5050
    ret
5051
78 diamond 5052
 
465 serge 5053
5054
 
5055
    xchg [master_tab], esi
5056
    push esi
5057
    mov edi, cr3
5058
    mov cr3, edi		 ;flush TLB
742 Rus 5059
465 serge 5060
 
742 Rus 5061
465 serge 5062
 
5063
    mov [master_tab], eax
5064
    mov eax, cr3
5065
    mov cr3, eax
5066
    pop eax
5067
5068
 
76 mario79 5069
    mov    [esp + 12], esi
5070
    mov    [esp + 24], ebx
5071
    mov    [esp + 28], edx
5072
    mov    [esp + 32], ecx
5073
    mov    [esp + 36], eax
5074
    setc    al
5075
    and    [esp + 56], byte 0xfe
78 diamond 5076
    or	  [esp + 56], al
742 Rus 5077
465 serge 5078
 
5079
 
76 mario79 5080
; -----------------------------------------
5081
1 ha 5082
 
76 mario79 5083
5084
 
742 Rus 5085
     mov   [esp + 32], dword -1
671 Ghost 5086
     ret
1 ha 5087
5088
 
465 serge 5089
system_shutdown:	  ; shut down the system
742 Rus 5090
1 ha 5091
 
996 serge 5092
	   jne @F
742 Rus 5093
	   ret
5094
@@:
465 serge 5095
	   call stop_all_services
742 Rus 5096
	   push 3		 ; stop playing cd
5097
	   pop	eax
5098
	   call sys_cd_audio
5099
1 ha 5100
 
465 serge 5101
863 serge 5102
 
742 Rus 5103
1 ha 5104
 
996 serge 5105
           je _sys_reboot
863 serge 5106
1 ha 5107
 
996 serge 5108
           je _sys_restart
863 serge 5109
1 ha 5110
 
863 serge 5111
           mov  esi, BOOT_VAR    ; restore 0x0 - 0xffff
855 serge 5112
           mov  edi, OS_BASE
847 serge 5113
           mov  ecx,0x10000/4
5114
           rep movsd
5115
1 ha 5116
 
863 serge 5117
           mov ecx, _16bit_end
5118
           shr ecx, 2
5119
           mov edi, _16BIT_BASE + OS_BASE
5120
           rep movsd
5121
1 ha 5122
 
863 serge 5123
           mov eax, _sys_pdbr + (0x100000000-OS_BASE)
5124
           mov cr3, eax
5125
1 ha 5126
 
928 serge 5127
1 ha 5128
 
928 serge 5129
1 ha 5130
 
863 serge 5131
709 diamond 5132
 
928 serge 5133
           mov dx, sel_app_data
5134
           mov ss, ax
5135
           mov esp, __os_stack
863 serge 5136
1 ha 5137
 
863 serge 5138
           mov es, dx
5139
           mov fs, dx
5140
           mov gs, dx
5141
1 ha 5142
 
863 serge 5143
709 diamond 5144
 
863 serge 5145
709 diamond 5146
 
928 serge 5147
           mov [_pg_balloc], eax
863 serge 5148
709 diamond 5149
 
863 serge 5150
           mov eax, _sys_pdbr + (0x100000000-OS_BASE)
5151
           mov cr3, eax
5152
5153
 
5154
           mov edi, cur_saved_data
5155
           sub edi, OS_BASE
5156
           sub ecx, edi
5157
           shr ecx, 2
5158
           xor eax, eax
5159
           rep stosd
5160
5161
 
5162
5163
 
5164
5165
 
5166
           mov  word [OS_BASE+0x467+0],0xFFF0
5167
           mov  word [OS_BASE+0x467+2],0xF000
5168
5169
 
742 Rus 5170
	   out	0x70,al
5171
	   mov	al,0x05
5172
	   out	0x71,al
5173
709 diamond 5174
 
742 Rus 5175
	   out	0x64,al
5176
709 diamond 5177
 
742 Rus 5178
709 diamond 5179
 
465 serge 5180
1 ha 5181
 
465 serge 5182
1 ha 5183
 
849 serge 5184
;diff16 "end of kernel code",0,$
5185