Subversion Repositories Kolibri OS

Rev

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