Subversion Repositories Kolibri OS

Rev

Rev 5847 | Rev 5867 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
  4. ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
  5. ;; Distributed under terms of the GNU General Public License    ;;
  6. ;;                                                              ;;
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.  
  9. $Revision: 5865 $
  10.  
  11. ;==============================================================================
  12. ;///// public functions ///////////////////////////////////////////////////////
  13. ;==============================================================================
  14.  
  15. window.BORDER_SIZE = 5
  16.  
  17. macro FuncTable name, table_name, [label]
  18. {
  19.   common
  20.     align 4
  21.     \label name#.#table_name dword
  22.   forward
  23.     dd name#.#label
  24.   common
  25.     name#.sizeof.#table_name = $ - name#.#table_name
  26. }
  27.  
  28. uglobal
  29.   common_colours rd 48
  30.   draw_limits    RECT
  31. endg
  32.  
  33. ;------------------------------------------------------------------------------
  34. syscall_draw_window: ;///// system function 0 /////////////////////////////////
  35. ;------------------------------------------------------------------------------
  36.         mov     eax, edx
  37.         shr     eax, 24
  38.         and     al, 0x0f
  39.         cmp     al, 5
  40.         jae     .exit
  41.  
  42.         push    eax
  43.         call    window._.sys_set_window
  44.         pop     eax
  45.  
  46.         or      al, al
  47.         jnz     @f
  48.  
  49. ; type I - original style
  50.         call    drawwindow_I
  51.         jmp     window._.draw_window_caption.2
  52. ;--------------------------------------
  53. @@:
  54.         dec     al
  55.         jnz     @f
  56.  
  57. ; type II - only reserve area, no draw
  58.         call    __sys_draw_pointer
  59.         jmp     .exit
  60. ;--------------------------------------
  61. @@:
  62.         dec     al
  63.         jnz     @f
  64.  
  65. ; type III  - new style
  66.         call    drawwindow_III
  67.         jmp     window._.draw_window_caption.2
  68. ;--------------------------------------
  69. @@:
  70. ; type IV & V - skinned window (resizable & not)
  71.         mov     eax, [TASK_COUNT]
  72.         movzx   eax, word[WIN_POS + eax * 2]
  73.         cmp     eax, [CURRENT_TASK]
  74.         setz    al
  75.         movzx   eax, al
  76.         push    eax
  77.         call    drawwindow_IV
  78.         jmp     window._.draw_window_caption.2
  79. ;--------------------------------------
  80. .exit:
  81.         ret
  82. ;------------------------------------------------------------------------------
  83. syscall_display_settings: ;///// system function 48 ///////////////////////////
  84. ;------------------------------------------------------------------------------
  85. ;; Redraw screen:
  86. ;< ebx = 0
  87. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  88. ;; Set button style:
  89. ;< ebx = 1
  90. ;< ecx = 0 (flat) or 1 (with gradient)
  91. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  92. ;; Set system color palette:
  93. ;< ebx = 2
  94. ;< ecx = pointer to color table
  95. ;< edx = size of color table
  96. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  97. ;; Get system color palette:
  98. ;< ebx = 3
  99. ;< ecx = pointer to color table buffer
  100. ;< edx = size of color table buffer
  101. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  102. ;; Get skinned caption height:
  103. ;< ebx = 4
  104. ;> eax = height in pixels
  105. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  106. ;; Get screen working area:
  107. ;< ebx = 5
  108. ;> eax = pack[16(left), 16(right)]
  109. ;> ebx = pack[16(top), 16(bottom)]
  110. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  111. ;; Set screen working area:
  112. ;< ebx = 6
  113. ;< ecx = pack[16(left), 16(right)]
  114. ;< edx = pack[16(top), 16(bottom)]
  115. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  116. ;; Get skin margins:
  117. ;< ebx = 7
  118. ;> eax = pack[16(left), 16(right)]
  119. ;> ebx = pack[16(top), 16(bottom)]
  120. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  121. ;; Set skin:
  122. ;< ebx = 8
  123. ;< ecx = pointer to FileInfoBlock struct
  124. ;> eax = FS error code
  125. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  126. ;; Get font smoothing:
  127. ;< ebx = 9
  128. ;> eax = 0 — off, 1 — on, 2 — subpixel
  129. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  130. ;; Set font smoothing:
  131. ;< ebx = 10
  132. ;< ecx = 0 — off, 1 — on, 2 — subpixel
  133. ;------------------------------------------------------------------------------
  134.         cmp     ebx, .sizeof.ftable / 4
  135.         ja      @f
  136.         jmp     [.ftable + ebx * 4]
  137. ;------------------------------------------------------------------------------
  138. syscall_display_settings.00:
  139.         xor     eax, eax
  140.         inc     ebx
  141.         cmp     [windowtypechanged], ebx
  142.         jne     @f
  143.         mov     [windowtypechanged], eax
  144.         jmp     syscall_display_settings._.redraw_whole_screen
  145. ;------------------------------------------------------------------------------
  146. syscall_display_settings.01:
  147.         and     ecx, 1
  148.         cmp     ecx, [buttontype]
  149.         je      @f
  150.         mov     [buttontype], ecx
  151.         mov     [windowtypechanged], ebx
  152. @@:
  153.         ret
  154. ;------------------------------------------------------------------------------
  155. syscall_display_settings.02:
  156.         dec     ebx
  157.         mov     esi, ecx
  158.         cmp     edx, 192
  159.         jnae    @f
  160.         mov     edx, 192 ; max size
  161. @@:
  162.         mov     edi, common_colours
  163.         mov     ecx, edx
  164.         rep movsb
  165.         mov     [windowtypechanged], ebx
  166.         ret
  167. ;------------------------------------------------------------------------------
  168. syscall_display_settings.03:
  169.         mov     edi, ecx
  170.         cmp     edx, 192
  171.         jnae    @f
  172.         mov     edx, 192 ; max size
  173. @@:
  174.         mov     esi, common_colours
  175.         mov     ecx, edx
  176.         rep movsb
  177.         ret
  178. ;------------------------------------------------------------------------------
  179. syscall_display_settings.04:
  180.         mov     eax, [_skinh]
  181.         mov     [esp + 32], eax
  182.         ret
  183. ;------------------------------------------------------------------------------
  184. syscall_display_settings.05:
  185.         mov     eax, [screen_workarea.left - 2]
  186.         mov     ax, word[screen_workarea.right]
  187.         mov     [esp + 32], eax
  188.         mov     eax, [screen_workarea.top - 2]
  189.         mov     ax, word[screen_workarea.bottom]
  190.         mov     [esp + 20], eax
  191.         ret
  192. ;------------------------------------------------------------------------------
  193. syscall_display_settings.06:
  194.         xor     esi, esi
  195.         mov     edi, [_display.width]
  196.         dec     edi
  197.         mov     eax, ecx
  198.         movsx   ebx, ax
  199.         sar     eax, 16
  200.         cmp     eax, ebx
  201.         jge     .check_horizontal
  202.         inc     esi
  203.         or      eax, eax
  204.         jge     @f
  205.         xor     eax, eax
  206. @@:
  207.         mov     [screen_workarea.left], eax
  208.         cmp     ebx, edi
  209.         jle     @f
  210.         mov     ebx, edi
  211. @@:
  212.         mov     [screen_workarea.right], ebx
  213. .check_horizontal:
  214.         mov     edi, [_display.height]
  215.         dec     edi
  216.         mov     eax, edx
  217.         movsx   ebx, ax
  218.         sar     eax, 16
  219.         cmp     eax, ebx
  220.         jge     .check_if_redraw_needed
  221.         inc     esi
  222.         or      eax, eax
  223.         jge     @f
  224.         xor     eax, eax
  225. @@:
  226.         mov     [screen_workarea.top], eax
  227.         cmp     ebx, edi
  228.         jle     @f
  229.         mov     ebx, edi
  230. @@:
  231.         mov     [screen_workarea.bottom], ebx
  232. .check_if_redraw_needed:
  233.         or      esi, esi
  234.         jz      @f
  235.  
  236.         call    repos_windows
  237.         jmp     syscall_display_settings._.calculate_whole_screen
  238. ;------------------------------------------------------------------------------
  239. syscall_display_settings.07:
  240.         mov     eax, [_skinmargins + 0]
  241.         mov     [esp + 32], eax
  242.         mov     eax, [_skinmargins + 4]
  243.         mov     [esp + 20], eax
  244. @@:
  245.         ret
  246. ;------------------------------------------------------------------------------
  247. syscall_display_settings.08:
  248.         mov     ebx, ecx
  249.         call    read_skin_file
  250.         mov     [esp + 32], eax
  251.         test    eax, eax
  252.         jnz     @b
  253.  
  254.         call    syscall_display_settings._.calculate_whole_screen
  255.         jmp     syscall_display_settings._.redraw_whole_screen
  256. ;------------------------------------------------------------------------------
  257. syscall_display_settings.09:
  258.         xor     eax, eax
  259.         mov     al, [fontSmoothing]
  260.         mov     [esp + 32], eax
  261.         ret
  262. ;------------------------------------------------------------------------------
  263. syscall_display_settings.10:
  264.         mov     [fontSmoothing], cl
  265.         ret
  266. ;------------------------------------------------------------------------------
  267. syscall_display_settings._.calculate_whole_screen:
  268.         xor     eax, eax
  269.         xor     ebx, ebx
  270.         mov     ecx, [_display.width]
  271.         mov     edx, [_display.height]
  272.         dec     ecx
  273.         dec     edx
  274.         jmp     calculatescreen
  275. ;------------------------------------------------------------------------------
  276. syscall_display_settings._.redraw_whole_screen:
  277.         xor     eax, eax
  278.         mov     [draw_limits.left], eax
  279.         mov     [draw_limits.top], eax
  280.         mov     eax, [_display.width]
  281.         dec     eax
  282.         mov     [draw_limits.right], eax
  283.         mov     eax, [_display.height]
  284.         dec     eax
  285.         mov     [draw_limits.bottom], eax
  286.         mov     eax, window_data
  287.         jmp     redrawscreen
  288. ;------------------------------------------------------------------------------
  289. syscall_set_window_shape: ;///// system function 50 ///////////////////////////
  290. ;------------------------------------------------------------------------------
  291. ;; Set window shape address:
  292. ;> ebx = 0
  293. ;> ecx = shape data address
  294. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  295. ;; Set window shape scale:
  296. ;> ebx = 1
  297. ;> ecx = scale power (resulting scale is 2^ebx)
  298. ;------------------------------------------------------------------------------
  299.         mov     edi, [current_slot]
  300.  
  301.         test    ebx, ebx
  302.         jne     .shape_scale
  303.         mov     [edi + APPDATA.wnd_shape], ecx
  304. ;--------------------------------------
  305. align 4
  306. .shape_scale:
  307.         dec     ebx
  308.         jnz     .exit
  309.         mov     [edi + APPDATA.wnd_shape_scale], ecx
  310. ;--------------------------------------
  311. align 4
  312. .exit:
  313.         ret
  314. ;------------------------------------------------------------------------------
  315. align 4
  316. ;------------------------------------------------------------------------------
  317. syscall_move_window: ;///// system function 67 ////////////////////////////////
  318. ;------------------------------------------------------------------------------
  319. ;? <description>
  320. ;------------------------------------------------------------------------------
  321.         mov     edi, [CURRENT_TASK]
  322.         shl     edi, 5
  323.         add     edi, window_data
  324.  
  325.         test    [edi + WDATA.fl_wdrawn], 1
  326.         jz      .exit
  327.  
  328.         test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
  329.         jnz     .exit
  330.  
  331.         cmp     ebx, -1
  332.         jne     @f
  333.         mov     ebx, [edi + WDATA.box.left]
  334. ;--------------------------------------
  335. align 4
  336. @@:
  337.         cmp     ecx, -1
  338.         jne     @f
  339.         mov     ecx, [edi + WDATA.box.top]
  340. ;--------------------------------------
  341. align 4
  342. @@:
  343.         cmp     edx, -1
  344.         jne     @f
  345.         mov     edx, [edi + WDATA.box.width]
  346. ;--------------------------------------
  347. align 4
  348. @@:
  349.         cmp     esi, -1
  350.         jne     @f
  351.         mov     esi, [edi + WDATA.box.height]
  352. ;--------------------------------------
  353. align 4
  354. @@:
  355.         push    esi edx ecx ebx
  356.         mov     eax, esp
  357.         mov     bl, [edi + WDATA.fl_wstate]
  358. ;--------------------------------------
  359. align 4
  360. @@:
  361.         cmp     [REDRAW_BACKGROUND], byte 0
  362.         jz      @f
  363.         call    change_task
  364.         jmp     @b
  365. ;--------------------------------------
  366. align 4
  367. @@:
  368.         call    window._.set_window_box
  369.         add     esp, sizeof.BOX
  370.  
  371.         ; NOTE: do we really need this? to be reworked
  372. ;       mov     byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
  373. ;       mov     byte[MOUSE_BACKGROUND], 0 ; no mouse under
  374. ;       mov     byte[MOUSE_DOWN], 0 ; react to mouse up/down
  375.  
  376.         ; NOTE: do we really need this? to be reworked
  377. ;       call    [draw_pointer]
  378. ;--------------------------------------
  379. align 4
  380. .exit:
  381.         ret
  382. ;------------------------------------------------------------------------------
  383. align 4
  384. ;------------------------------------------------------------------------------
  385. syscall_window_settings: ;///// system function 71 /////////////////////////////
  386. ;------------------------------------------------------------------------------
  387. ;? <description>
  388. ;------------------------------------------------------------------------------
  389.         dec     ebx     ; subfunction #1 - set window caption
  390.         jnz     .exit_fail
  391.  
  392.         ; NOTE: only window owner thread can set its caption,
  393.         ;       so there's no parameter for PID/TID
  394.  
  395.         mov     edi, [CURRENT_TASK]
  396.         shl     edi, 5
  397.  
  398.         mov     [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx
  399.         or      [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
  400.  
  401.         call    window._.draw_window_caption
  402.  
  403.         xor     eax, eax ; eax = 0 (success)
  404.         ret
  405.  
  406. ;  .get_window_caption:
  407. ;        dec     eax     ; subfunction #2 - get window caption
  408. ;        jnz     .exit_fail
  409.  
  410.         ; not implemented yet
  411. ;--------------------------------------
  412. align 4
  413. .exit_fail:
  414.         xor     eax, eax
  415.         inc     eax     ; eax = 1 (fail)
  416.         ret
  417. ;------------------------------------------------------------------------------
  418. align 4
  419. ;------------------------------------------------------------------------------
  420. set_window_defaults: ;/////////////////////////////////////////////////////////
  421. ;------------------------------------------------------------------------------
  422. ;? <description>
  423. ;------------------------------------------------------------------------------
  424.         mov     byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
  425.         push    eax ecx
  426.         xor     eax, eax
  427.         mov     ecx, WIN_STACK
  428. ;--------------------------------------
  429. align 4
  430. @@:
  431.         inc     eax
  432.         add     ecx, 2
  433.         ; process no
  434.         mov     [ecx + 0x000], ax
  435.         ; positions in stack
  436.         mov     [ecx + 0x400], ax
  437.         cmp     ecx, WIN_POS - 2
  438.         jne     @b
  439.         pop     ecx eax
  440.         ret
  441. ;------------------------------------------------------------------------------
  442.  
  443. align 4
  444. ;------------------------------------------------------------------------------
  445. calculatescreen: ;/////////////////////////////////////////////////////////////
  446. ;------------------------------------------------------------------------------
  447. ;? Scan all windows from bottom to top, calling `setscreen` for each one
  448. ;? intersecting given screen area
  449. ;------------------------------------------------------------------------------
  450. ;> eax = left
  451. ;> ebx = top
  452. ;> ecx = right
  453. ;> edx = bottom
  454. ;------------------------------------------------------------------------------
  455.         push    esi
  456.         pushfd
  457.         cli
  458.  
  459.         mov     esi, 1
  460.         call    window._.set_screen
  461.  
  462.         push    ebp
  463.  
  464.         mov     ebp, [TASK_COUNT]
  465.         cmp     ebp, 1
  466.         jbe     .exit
  467.  
  468.         push    eax ;for num layout
  469.  
  470.         push    edx ecx ebx eax
  471.  
  472.         mov     dword[esp+10h], ZPOS_DESKTOP
  473. ;--------------------------------------
  474. align 4
  475. .layout:
  476.         mov     esi, 1          ; = num in window stack
  477.         mov     ebp, [TASK_COUNT]
  478. ;--------------------------------------
  479. align 4
  480. .next_window:
  481.         movzx   edi, word[WIN_POS + esi * 2]
  482.         shl     edi, 5                  ;size of TASKDATA and WDATA = 32 bytes
  483.  
  484.         cmp     [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
  485.         je      .skip_window
  486.  
  487.         add     edi, window_data
  488.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  489.         jnz     .skip_window
  490.  
  491.         mov     eax, [esp+10h]
  492.         cmp     [edi + WDATA.z_modif], al
  493.         jne     .skip_window
  494.  
  495.         mov     eax, [edi + WDATA.box.left]
  496.         cmp     eax, [esp + RECT.right]
  497.         jg      .skip_window
  498.         mov     ebx, [edi + WDATA.box.top]
  499.         cmp     ebx, [esp + RECT.bottom]
  500.         jg      .skip_window
  501.         mov     ecx, [edi + WDATA.box.width]
  502.         add     ecx, eax
  503.         cmp     ecx, [esp + RECT.left]
  504.         jl      .skip_window
  505.         mov     edx, [edi + WDATA.box.height]
  506.         add     edx, ebx
  507.         cmp     edx, [esp + RECT.top]
  508.         jl      .skip_window
  509.  
  510.         cmp     eax, [esp + RECT.left]
  511.         jae     @f
  512.         mov     eax, [esp + RECT.left]
  513. ;--------------------------------------
  514. align 4
  515. @@:
  516.         cmp     ebx, [esp + RECT.top]
  517.         jae     @f
  518.         mov     ebx, [esp + RECT.top]
  519. ;--------------------------------------
  520. align 4
  521. @@:
  522.         cmp     ecx, [esp + RECT.right]
  523.         jbe     @f
  524.         mov     ecx, [esp + RECT.right]
  525. ;--------------------------------------
  526. align 4
  527. @@:
  528.         cmp     edx, [esp + RECT.bottom]
  529.         jbe     @f
  530.         mov     edx, [esp + RECT.bottom]
  531. ;--------------------------------------
  532. align 4
  533. @@:
  534.         push    esi
  535.         movzx   esi, word[WIN_POS + esi * 2]
  536.         call    window._.set_screen
  537.         pop     esi
  538. ;--------------------------------------
  539. align 4
  540. .skip_window:
  541.         inc     esi
  542.         dec     ebp
  543.         jnz     .next_window
  544. ;---------------------------------------------
  545.         inc     dword[esp+10h]
  546.         cmp     dword[esp+10h], ZPOS_ALWAYS_TOP
  547.         jle     .layout
  548. ;---------------------------------------------
  549.         mov     esi, [TASK_COUNT]
  550.         movzx   edi, word[WIN_POS + esi * 2]
  551.         shl     edi, 5
  552.         add     edi, window_data
  553.  
  554.         pop     eax ebx ecx edx
  555.         pop     ebp     ;del num layout
  556. ;--------------------------------------
  557. align 4
  558. .exit:
  559.         pop     ebp
  560.         inc     [_display.mask_seqno]
  561.         popfd
  562.         pop     esi
  563.         ret
  564. ;------------------------------------------------------------------------------
  565. align 4
  566. ;------------------------------------------------------------------------------
  567. repos_windows: ;///////////////////////////////////////////////////////////////
  568. ;------------------------------------------------------------------------------
  569. ;? <description>
  570. ;------------------------------------------------------------------------------
  571.         mov     ecx, [TASK_COUNT]
  572.         mov     edi, window_data + sizeof.WDATA * 2
  573.         call    force_redraw_background
  574.         dec     ecx
  575.         jle     .exit
  576. ;--------------------------------------
  577. align 4
  578. .next_window:
  579.         mov     [edi + WDATA.fl_redraw], 1
  580.         test    [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
  581.         jnz     .fix_maximized
  582.  
  583.         mov     eax, [edi + WDATA.box.left]
  584.         add     eax, [edi + WDATA.box.width]
  585.         mov     ebx, [_display.width]
  586.         cmp     eax, ebx
  587.         jl      .fix_vertical
  588.         mov     eax, [edi + WDATA.box.width]
  589.         sub     eax, ebx
  590.         jl      @f
  591.         mov     [edi + WDATA.box.width], ebx
  592. ;--------------------------------------
  593. align 4
  594. @@:
  595.         sub     ebx, [edi + WDATA.box.width]
  596.         mov     [edi + WDATA.box.left], ebx
  597. ;--------------------------------------
  598. align 4
  599. .fix_vertical:
  600.         mov     eax, [edi + WDATA.box.top]
  601.         add     eax, [edi + WDATA.box.height]
  602.         mov     ebx, [_display.height]
  603.         cmp     eax, ebx
  604.         jl      .fix_client_box
  605.         mov     eax, [edi + WDATA.box.height]
  606.         sub     eax, ebx
  607.         jl      @f
  608.         mov     [edi + WDATA.box.height], ebx
  609. ;--------------------------------------
  610. align 4
  611. @@:
  612.         sub     ebx, [edi + WDATA.box.height]
  613.         mov     [edi + WDATA.box.top], ebx
  614. ;--------------------------------------
  615. align 4
  616. .fix_client_box:
  617.         call    window._.set_window_clientbox
  618.         add     edi, sizeof.WDATA
  619.         loop    .next_window
  620. ;--------------------------------------
  621. align 4
  622. .exit:
  623.         ret
  624. ;--------------------------------------
  625. align 4
  626. .fix_maximized:
  627.         mov     eax, [screen_workarea.left]
  628.         mov     [edi + WDATA.box.left], eax
  629.         sub     eax, [screen_workarea.right]
  630.         neg     eax
  631.         mov     [edi + WDATA.box.width], eax
  632.         mov     eax, [screen_workarea.top]
  633.         mov     [edi + WDATA.box.top], eax
  634.         test    [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
  635.         jnz     .fix_client_box
  636.         sub     eax, [screen_workarea.bottom]
  637.         neg     eax
  638.         mov     [edi + WDATA.box.height], eax
  639.         jmp     .fix_client_box
  640. ;------------------------------------------------------------------------------
  641. ;align 4
  642. ;------------------------------------------------------------------------------
  643. ;sys_window_mouse: ;////////////////////////////////////////////////////////////
  644. ;------------------------------------------------------------------------------
  645. ;? <description>
  646. ;------------------------------------------------------------------------------
  647.         ; NOTE: commented out since doesn't provide necessary functionality
  648.         ;       anyway, to be reworked
  649. ;       push    eax
  650. ;
  651. ;       mov     eax, [timer_ticks]
  652. ;       cmp     [new_window_starting], eax
  653. ;       jb      .exit
  654. ;
  655. ;       mov     byte[MOUSE_BACKGROUND], 0
  656. ;       mov     byte[DONT_DRAW_MOUSE], 0
  657. ;
  658. ;       mov     [new_window_starting], eax
  659. ;
  660. ; .exit:
  661. ;       pop     eax
  662. ;        ret
  663. ;------------------------------------------------------------------------------
  664. align 4
  665. ;------------------------------------------------------------------------------
  666. draw_rectangle: ;//////////////////////////////////////////////////////////////
  667. ;------------------------------------------------------------------------------
  668. ;> eax = pack[16(left), 16(right)]
  669. ;> ebx = pack[16(top), 16(bottom)]
  670. ;> esi = color
  671. ;       ?? RR GG BB    ; 0x01000000 negation
  672. ;                      ; 0x02000000 used for draw_rectangle without top line
  673. ;                      ;           for example drawwindow_III and drawwindow_IV
  674. ;------------------------------------------------------------------------------
  675.         push    eax ebx ecx edi
  676.  
  677.         xor     edi, edi
  678. ;--------------------------------------
  679. align 4
  680. .flags_set:
  681.         push    ebx
  682.  
  683.         ; set line color
  684.         mov     ecx, esi
  685.         ; draw top border
  686.         rol     ebx, 16
  687.         push    ebx
  688.         rol     ebx, 16
  689.         pop     bx
  690.         test    ecx, 1 shl 25
  691.         jnz     @f
  692.         sub     ecx, 1 shl 25
  693. ;        call    [draw_line]
  694.         call    __sys_draw_line
  695. ;--------------------------------------
  696. align 4
  697. @@:
  698.         ; draw bottom border
  699.         mov     ebx, [esp - 2]
  700.         pop     bx
  701. ;        call    [draw_line]
  702.         call    __sys_draw_line
  703.  
  704.         pop     ebx
  705.         add     ebx, 1 * 65536 - 1
  706.  
  707.         ; draw left border
  708.         rol     eax, 16
  709.         push    eax
  710.         rol     eax, 16
  711.         pop     ax
  712. ;        call    [draw_line]
  713.         call    __sys_draw_line
  714.  
  715.         ; draw right border
  716.         mov     eax, [esp - 2]
  717.         pop     ax
  718. ;        call    [draw_line]
  719.         call    __sys_draw_line
  720.  
  721.         pop     edi ecx ebx eax
  722.         ret
  723. ;--------------------------------------
  724. align 4
  725. .forced:
  726.         push    eax ebx ecx edi
  727.         xor     edi, edi
  728.         inc     edi
  729.         jmp     .flags_set
  730. ;------------------------------------------------------------------------------
  731. align 4
  732. ;------------------------------------------------------------------------------
  733. drawwindow_I_caption: ;////////////////////////////////////////////////////////
  734. ;------------------------------------------------------------------------------
  735. ;? <description>
  736. ;------------------------------------------------------------------------------
  737.         push    [edx + WDATA.cl_titlebar]
  738.         mov     esi, edx
  739.  
  740.         mov     edx, [esi + WDATA.box.top]
  741.         mov     eax, edx
  742.         lea     ebx, [edx + 21]
  743.         inc     edx
  744.         add     eax, [esi + WDATA.box.height]
  745.  
  746.         cmp     ebx, eax
  747.         jbe     @f
  748.         mov     ebx, eax
  749. ;--------------------------------------
  750. align 4
  751. @@:
  752.         push    ebx
  753.  
  754.         xor     edi, edi
  755. ;--------------------------------------
  756. align 4
  757. .next_line:
  758.         mov     ebx, edx
  759.         shl     ebx, 16
  760.         add     ebx, edx
  761.         mov     eax, [esi + WDATA.box.left]
  762.         inc     eax
  763.         shl     eax, 16
  764.         add     eax, [esi + WDATA.box.left]
  765.         add     eax, [esi + WDATA.box.width]
  766.         dec     eax
  767.         mov     ecx, [esi + WDATA.cl_titlebar]
  768.         test    ecx, 0x80000000
  769.         jz      @f
  770.         sub     ecx, 0x00040404
  771.         mov     [esi + WDATA.cl_titlebar], ecx
  772. ;--------------------------------------
  773. align 4
  774. @@:
  775.         and     ecx, 0x00ffffff
  776. ;        call    [draw_line]
  777.         call    __sys_draw_line
  778.         inc     edx
  779.         cmp     edx, [esp]
  780.         jb      .next_line
  781.  
  782.         add     esp, 4
  783.         pop     [esi + WDATA.cl_titlebar]
  784.         ret
  785. ;------------------------------------------------------------------------------
  786. align 4
  787. ;------------------------------------------------------------------------------
  788. drawwindow_I: ;////////////////////////////////////////////////////////////////
  789. ;------------------------------------------------------------------------------
  790. ;? <description>
  791. ;------------------------------------------------------------------------------
  792.         pushad
  793.  
  794.         ; window border
  795.  
  796.         mov     eax, [edx + WDATA.box.left - 2]
  797.         mov     ax, word[edx + WDATA.box.left]
  798.         add     ax, word[edx + WDATA.box.width]
  799.         mov     ebx, [edx + WDATA.box.top - 2]
  800.         mov     bx, word[edx + WDATA.box.top]
  801.         add     bx, word[edx + WDATA.box.height]
  802.  
  803.         mov     esi, [edx + WDATA.cl_frames]
  804.         call    draw_rectangle
  805.  
  806.         ; window caption
  807.  
  808.         call    drawwindow_I_caption
  809.  
  810.         ; window client area
  811.  
  812.         ; do we need to draw it?
  813.         mov     edi, [esi + WDATA.cl_workarea]
  814.         test    edi, 0x40000000
  815.         jnz     .exit
  816.  
  817.         ; does client area have a positive size on screen?
  818.         cmp     [esi + WDATA.box.height], 21
  819.         jle     .exit
  820.  
  821.         ; okay, let's draw it
  822.         mov     eax, 1
  823.         mov     ebx, 21
  824.         mov     ecx, [esi + WDATA.box.width]
  825.         mov     edx, [esi + WDATA.box.height]
  826. ;        call    [drawbar]
  827.         call    vesa20_drawbar
  828. ;--------------------------------------
  829. align 4
  830. .exit:
  831.         popad
  832.         ret
  833. ;------------------------------------------------------------------------------
  834. align 4
  835. ;------------------------------------------------------------------------------
  836. drawwindow_III_caption: ;/////////////////////////////////////////////////////
  837. ;------------------------------------------------------------------------------
  838. ;? <description>
  839. ;------------------------------------------------------------------------------
  840.         mov     ecx, [edx + WDATA.cl_titlebar]
  841.         push    ecx
  842.         mov     esi, edx
  843.         mov     edx, [esi + WDATA.box.top]
  844.         add     edx, 4
  845.         mov     ebx, [esi + WDATA.box.top]
  846.         add     ebx, 20
  847.         mov     eax, [esi + WDATA.box.top]
  848.         add     eax, [esi + WDATA.box.height]
  849.  
  850.         cmp     ebx, eax
  851.         jb      @f
  852.         mov     ebx, eax
  853. ;--------------------------------------
  854. align 4
  855. @@:
  856.         push    ebx
  857.  
  858.         xor     edi, edi
  859. ;--------------------------------------
  860. align 4
  861. .next_line:
  862.         mov     ebx, edx
  863.         shl     ebx, 16
  864.         add     ebx, edx
  865.         mov     eax, [esi + WDATA.box.left]
  866.         shl     eax, 16
  867.         add     eax, [esi + WDATA.box.left]
  868.         add     eax, [esi + WDATA.box.width]
  869.         add     eax, 4 * 65536 - 4
  870.         mov     ecx, [esi + WDATA.cl_titlebar]
  871.         test    ecx, 0x40000000
  872.         jz      @f
  873.         add     ecx, 0x00040404
  874. ;--------------------------------------
  875. align 4
  876. @@:
  877.         test    ecx, 0x80000000
  878.         jz      @f
  879.         sub     ecx, 0x00040404
  880. ;--------------------------------------
  881. align 4
  882. @@:
  883.         mov     [esi + WDATA.cl_titlebar], ecx
  884.         and     ecx, 0x00ffffff
  885. ;        call    [draw_line]
  886.         call    __sys_draw_line
  887.         inc     edx
  888.         cmp     edx, [esp]
  889.         jb      .next_line
  890.  
  891.         add     esp, 4
  892.         pop     [esi + WDATA.cl_titlebar]
  893.         ret
  894. ;------------------------------------------------------------------------------
  895. align 4
  896. ;------------------------------------------------------------------------------
  897. drawwindow_III: ;//////////////////////////////////////////////////////////////
  898. ;------------------------------------------------------------------------------
  899. ;? <description>
  900. ;------------------------------------------------------------------------------
  901.         pushad
  902.  
  903.         ; window border
  904.  
  905.         mov     eax, [edx + WDATA.box.left - 2]
  906.         mov     ax, word[edx + WDATA.box.left]
  907.         add     ax, word[edx + WDATA.box.width]
  908.         mov     ebx, [edx + WDATA.box.top - 2]
  909.         mov     bx, word[edx + WDATA.box.top]
  910.         add     bx, word[edx + WDATA.box.height]
  911.  
  912.         mov     esi, [edx + WDATA.cl_frames]
  913.         shr     esi, 1
  914.         and     esi, 0x007f7f7f
  915.         call    draw_rectangle
  916.  
  917.         push    esi
  918.         mov     ecx, 3
  919.         mov     esi, [edx + WDATA.cl_frames]
  920. ;--------------------------------------
  921. align 4
  922. .next_frame:
  923.         add     eax, 1 * 65536 - 1
  924.         add     ebx, 1 * 65536 - 1
  925.         call    draw_rectangle
  926.         dec     ecx
  927.         jnz     .next_frame
  928.  
  929.         pop     esi
  930.         add     eax, 1 * 65536 - 1
  931.         add     ebx, 1 * 65536 - 1
  932.         call    draw_rectangle
  933.  
  934.         ; window caption
  935.  
  936.         call    drawwindow_III_caption
  937.  
  938.         ; window client area
  939.  
  940.         ; do we need to draw it?
  941.         mov     edi, [esi + WDATA.cl_workarea]
  942.         test    edi, 0x40000000
  943.         jnz     .exit
  944.  
  945.         ; does client area have a positive size on screen?
  946.         mov     edx, [esi + WDATA.box.top]
  947.         add     edx, 21 + 5
  948.         mov     ebx, [esi + WDATA.box.top]
  949.         add     ebx, [esi + WDATA.box.height]
  950.         cmp     edx, ebx
  951.         jg      .exit
  952.  
  953.         ; okay, let's draw it
  954.         mov     eax, 5
  955.         mov     ebx, 20
  956.         mov     ecx, [esi + WDATA.box.width]
  957.         mov     edx, [esi + WDATA.box.height]
  958.         sub     ecx, 4
  959.         sub     edx, 4
  960. ;        call    [drawbar]
  961.         call    vesa20_drawbar
  962. ;--------------------------------------
  963. align 4
  964. .exit:
  965.         popad
  966.         ret
  967. ;------------------------------------------------------------------------------
  968. align 4
  969. ;------------------------------------------------------------------------------
  970. waredraw: ;////////////////////////////////////////////////////////////////////
  971. ;------------------------------------------------------------------------------
  972. ;? Activate window, redrawing if necessary
  973. ;------------------------------------------------------------------------------
  974.         push    -1
  975.         mov     eax, [TASK_COUNT]
  976.         lea     eax, [WIN_POS + eax * 2]
  977.         cmp     eax, esi
  978.         pop     eax
  979.         je      .exit
  980.  
  981.         ; is it overlapped by another window now?
  982.         push    ecx
  983.         call    window._.check_window_draw
  984.         test    ecx, ecx
  985.         pop     ecx
  986.         jz      .do_not_draw
  987.  
  988.         ; yes it is, activate and update screen buffer
  989.         call    window._.window_activate
  990.  
  991.         pushad
  992.         mov     edi, [TASK_COUNT]
  993.         movzx   esi, word[WIN_POS + edi * 2]
  994.         shl     esi, 5
  995.         add     esi, window_data
  996.  
  997.         mov     eax, [esi + WDATA.box.left]
  998.         mov     ebx, [esi + WDATA.box.top]
  999.         mov     ecx, [esi + WDATA.box.width]
  1000.         mov     edx, [esi + WDATA.box.height]
  1001.  
  1002.         add     ecx, eax
  1003.         add     edx, ebx
  1004.  
  1005.         mov     edi, [TASK_COUNT]
  1006.         movzx   esi, word[WIN_POS + edi * 2]
  1007.         call    window._.set_screen
  1008.  
  1009.         call    window._.set_top_wnd
  1010.  
  1011.         inc     [_display.mask_seqno]
  1012.         popad
  1013.  
  1014.         ; tell application to redraw itself
  1015.         mov     [edi + WDATA.fl_redraw], 1
  1016.         xor     eax, eax
  1017.         jmp     .exit
  1018. ;--------------------------------------
  1019. align 4
  1020. .do_not_draw:
  1021.         ; no it's not, just activate the window
  1022.         call    window._.window_activate
  1023.         xor     eax, eax
  1024.         ret
  1025.  
  1026. ;--------------------------------------
  1027. align 4
  1028. .exit:
  1029.         inc     eax
  1030.         ret
  1031. ;------------------------------------------------------------------------------
  1032. align 4
  1033. ;------------------------------------------------------------------------------
  1034. minimize_all_window:
  1035.         push    ebx ecx edx esi edi
  1036.         pushfd
  1037.         cli
  1038.         xor     edx, edx
  1039.         mov     eax, 2  ; we do not minimize the kernel thread N1
  1040.         mov     ebx, [TASK_COUNT]
  1041. ;--------------------------------------
  1042. align 4
  1043. .loop:
  1044.         movzx   edi, word[WIN_POS + eax * 2]
  1045.         shl     edi, 5
  1046. ; it is a unused slot?
  1047.         cmp     dword [edi+CURRENT_TASK+TASKDATA.state], 9
  1048.         je      @f
  1049. ; it is a hidden thread?
  1050.         lea     esi, [edi*8+SLOT_BASE+APPDATA.app_name]
  1051.         cmp     [esi], byte '@'
  1052.         je      @f
  1053. ; is it already minimized?
  1054.         test    [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
  1055.         jnz     @f
  1056. ; no it's not, let's do that
  1057.         or      [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED
  1058.         inc     edx
  1059. ;--------------------------------------
  1060. align 4
  1061. @@:
  1062.         inc     eax
  1063.         cmp     eax, ebx
  1064.         jbe     .loop
  1065. ; If nothing has changed
  1066.         test    edx, edx
  1067.         jz      @f
  1068.  
  1069.         push    edx
  1070.         call    syscall_display_settings._.calculate_whole_screen
  1071.         call    syscall_display_settings._.redraw_whole_screen
  1072.         pop     edx
  1073. ;--------------------------------------
  1074. align 4
  1075. @@:
  1076.         mov     eax, edx
  1077.         popfd
  1078.         pop     edi esi edx ecx ebx
  1079.         ret
  1080. ;------------------------------------------------------------------------------
  1081. align 4
  1082. ;------------------------------------------------------------------------------
  1083. minimize_window: ;/////////////////////////////////////////////////////////////
  1084. ;------------------------------------------------------------------------------
  1085. ;> eax = window number on screen
  1086. ;------------------------------------------------------------------------------
  1087. ;# corrupts [dl*]
  1088. ;------------------------------------------------------------------------------
  1089.         push    edi
  1090.         pushfd
  1091.         cli
  1092.  
  1093.         ; is it already minimized?
  1094.         movzx   edi, word[WIN_POS + eax * 2]
  1095.         shl     edi, 5
  1096.         add     edi, window_data
  1097.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  1098.         jnz     .exit
  1099.  
  1100.         push    eax ebx ecx edx esi
  1101.  
  1102.         ; no it's not, let's do that
  1103.         or      [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  1104. ; If the window width is 0, then the action is not needed.
  1105.         cmp     [edi + WDATA.box.width], dword 0
  1106.         je      @f
  1107. ; If the window height is 0, then the action is not needed.
  1108.         cmp     [edi + WDATA.box.height], dword 0
  1109.         je      @f
  1110.  
  1111.         mov     eax, [edi + WDATA.box.left]
  1112.         mov     [draw_limits.left], eax
  1113.         mov     ecx, eax
  1114.         add     ecx, [edi + WDATA.box.width]
  1115.         mov     [draw_limits.right], ecx
  1116.         mov     ebx, [edi + WDATA.box.top]
  1117.         mov     [draw_limits.top], ebx
  1118.         mov     edx, ebx
  1119.         add     edx, [edi + WDATA.box.height]
  1120.         mov     [draw_limits.bottom], edx
  1121.  
  1122. ;        DEBUGF  1, "K : minimize_window\n"
  1123. ;        DEBUGF  1, "K : dl_left %x\n",[draw_limits.left]
  1124. ;        DEBUGF  1, "K : dl_right %x\n",[draw_limits.right]
  1125. ;        DEBUGF  1, "K : dl_top %x\n",[draw_limits.top]
  1126. ;        DEBUGF  1, "K : dl_bottom %x\n",[draw_limits.bottom]
  1127.         call    calculatescreen
  1128. ;        xor     esi, esi
  1129. ;        xor     eax, eax
  1130.         mov     eax, edi
  1131.         call    redrawscreen
  1132. ;--------------------------------------
  1133. align 4
  1134. @@:
  1135.         pop     esi edx ecx ebx eax
  1136. ;--------------------------------------
  1137. align 4
  1138. .exit:
  1139.         popfd
  1140.         pop     edi
  1141.         ret
  1142. ;------------------------------------------------------------------------------
  1143. align 4
  1144. ;------------------------------------------------------------------------------
  1145. restore_minimized_window: ;////////////////////////////////////////////////////
  1146. ;------------------------------------------------------------------------------
  1147. ;> eax = window number on screen
  1148. ;------------------------------------------------------------------------------
  1149. ;# corrupts [dl*]
  1150. ;------------------------------------------------------------------------------
  1151.         pushad
  1152.         pushfd
  1153.         cli
  1154.  
  1155.         ; is it already restored?
  1156.         movzx   esi, word[WIN_POS + eax * 2]
  1157.         mov     edi, esi
  1158.         shl     edi, 5
  1159.         add     edi, window_data
  1160.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  1161.         jz      .exit
  1162.  
  1163.         ; no it's not, let's do that
  1164.         mov     [edi + WDATA.fl_redraw], 1
  1165.         and     [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED
  1166.         mov     ebp, window._.set_screen
  1167.         cmp     eax, [TASK_COUNT]
  1168.         jz      @f
  1169.         mov     ebp, calculatescreen
  1170. ;--------------------------------------
  1171. align 4
  1172. @@:
  1173.         mov     eax, [edi + WDATA.box.left]
  1174.         mov     ebx, [edi + WDATA.box.top]
  1175.         mov     ecx, [edi + WDATA.box.width]
  1176.         mov     edx, [edi + WDATA.box.height]
  1177.         add     ecx, eax
  1178.         add     edx, ebx
  1179.         call    ebp
  1180.  
  1181.         cmp     ebp, window._.set_screen
  1182.         jne     @f
  1183.         call    window._.set_top_wnd
  1184.     @@:
  1185.         inc     [_display.mask_seqno]
  1186. ;--------------------------------------
  1187. align 4
  1188. .exit:
  1189.         popfd
  1190.         popad
  1191.         ret
  1192. ;------------------------------------------------------------------------------
  1193. align 4
  1194. ; TODO: remove this proc
  1195. ;------------------------------------------------------------------------------
  1196. window_check_events: ;/////////////////////////////////////////////////////////
  1197. ;------------------------------------------------------------------------------
  1198. ;? <description>
  1199. ;------------------------------------------------------------------------------
  1200.         ; do we have window minimize/restore request?
  1201.         cmp     [window_minimize], 0
  1202.         je      .exit
  1203.  
  1204.         ; okay, minimize or restore top-most window and exit
  1205.         mov     eax, [TASK_COUNT]
  1206.         mov     bl, 0
  1207.         xchg    [window_minimize], bl
  1208.         dec     bl
  1209.         jnz     @f
  1210.         call    minimize_window
  1211.         jmp     .exit
  1212. ;--------------------------------------
  1213. align 4
  1214. @@:
  1215.         call    restore_minimized_window
  1216. ;--------------------------------------
  1217. align 4
  1218. .exit:
  1219.         ret
  1220. ;------------------------------------------------------------------------------
  1221. align 4
  1222. ;------------------------------------------------------------------------------
  1223. sys_window_maximize_handler: ;/////////////////////////////////////////////////
  1224. ;------------------------------------------------------------------------------
  1225. ;? <description>
  1226. ;------------------------------------------------------------------------------
  1227. ;> esi = process slot
  1228. ;------------------------------------------------------------------------------
  1229.         mov     edi, esi
  1230.         shl     edi, 5
  1231.         add     edi, window_data
  1232.  
  1233.         ; can window change its height?
  1234.         ; only types 2 and 3 can be resized
  1235.         mov     dl, [edi + WDATA.fl_wstyle]
  1236.         test    dl, 2
  1237.         jz      .exit
  1238.  
  1239.         ; toggle normal/maximized window state
  1240.         mov     bl, [edi + WDATA.fl_wstate]
  1241.         xor     bl, WSTATE_MAXIMIZED
  1242.  
  1243.         ; calculate and set appropriate window bounds
  1244.         test    bl, WSTATE_MAXIMIZED
  1245.         jz      .restore_size
  1246.  
  1247.         mov     eax, [screen_workarea.left]
  1248.         mov     ecx, [screen_workarea.top]
  1249.         push    [screen_workarea.bottom] \
  1250.                 [screen_workarea.right] \
  1251.                 ecx \
  1252.                 eax
  1253.         sub     [esp + BOX.width], eax
  1254.         sub     [esp + BOX.height], ecx
  1255.         mov     eax, esp
  1256.         jmp     .set_box
  1257. ;--------------------------------------
  1258. align 4
  1259. .restore_size:
  1260.         mov     eax, esi
  1261.         shl     eax, 8
  1262.         add     eax, SLOT_BASE + APPDATA.saved_box
  1263.         push    [eax + BOX.height] \
  1264.                 [eax + BOX.width] \
  1265.                 [eax + BOX.top] \
  1266.                 [eax + BOX.left]
  1267.         mov     eax, esp
  1268. ;--------------------------------------
  1269. align 4
  1270. .set_box:
  1271.         test    bl, WSTATE_ROLLEDUP
  1272.         jz      @f
  1273.  
  1274.         xchg    eax, ecx
  1275.         call    window._.get_rolledup_height
  1276.         mov     [ecx + BOX.height], eax
  1277.         xchg    eax, ecx
  1278. ;--------------------------------------
  1279. align 4
  1280. @@:
  1281.         call    window._.set_window_box
  1282.         add     esp, sizeof.BOX
  1283. ;--------------------------------------
  1284. align 4
  1285. .exit:
  1286.         inc     [_display.mask_seqno]
  1287.         ret
  1288. ;------------------------------------------------------------------------------
  1289. align 4
  1290. ;------------------------------------------------------------------------------
  1291. sys_window_rollup_handler: ;///////////////////////////////////////////////////
  1292. ;------------------------------------------------------------------------------
  1293. ;? <description>
  1294. ;------------------------------------------------------------------------------
  1295. ;> esi = process slot
  1296. ;------------------------------------------------------------------------------
  1297.         mov     edx, esi
  1298.         shl     edx, 8
  1299.         add     edx, SLOT_BASE
  1300.  
  1301.         ; toggle normal/rolled up window state
  1302.         mov     bl, [edi + WDATA.fl_wstate]
  1303.         xor     bl, WSTATE_ROLLEDUP
  1304.  
  1305.         ; calculate and set appropriate window bounds
  1306.         test    bl, WSTATE_ROLLEDUP
  1307.         jz      .restore_size
  1308.  
  1309.         call    window._.get_rolledup_height
  1310.         push    eax \
  1311.                 [edi + WDATA.box.width] \
  1312.                 [edi + WDATA.box.top] \
  1313.                 [edi + WDATA.box.left]
  1314.         mov     eax, esp
  1315.         jmp     .set_box
  1316. ;--------------------------------------
  1317. align 4
  1318. .restore_size:
  1319.         test    bl, WSTATE_MAXIMIZED
  1320.         jnz     @f
  1321.         add     esp, -sizeof.BOX
  1322.         lea     eax, [edx + APPDATA.saved_box]
  1323.         jmp     .set_box
  1324. ;--------------------------------------
  1325. align 4
  1326. @@:
  1327.         mov     eax, [screen_workarea.top]
  1328.         push    [screen_workarea.bottom] \
  1329.                 [edi + WDATA.box.width] \
  1330.                 eax \
  1331.                 [edi + WDATA.box.left]
  1332.         sub     [esp + BOX.height], eax
  1333.         mov     eax, esp
  1334. ;--------------------------------------
  1335. align 4
  1336. .set_box:
  1337.         call    window._.set_window_box
  1338.         add     esp, sizeof.BOX
  1339.         ret
  1340. ;------------------------------------------------------------------------------
  1341. align 4
  1342. ;------------------------------------------------------------------------------
  1343. ;sys_window_start_moving_handler: ;/////////////////////////////////////////////
  1344. ;------------------------------------------------------------------------------
  1345. ;? <description>
  1346. ;------------------------------------------------------------------------------
  1347. ;> eax = old (original) window box
  1348. ;> esi = process slot
  1349. ;------------------------------------------------------------------------------
  1350. ;        mov     edi, eax
  1351. ;        call    window._.draw_negative_box
  1352. ;        ret
  1353. ;------------------------------------------------------------------------------
  1354. align 4
  1355. ;------------------------------------------------------------------------------
  1356. sys_window_end_moving_handler: ;///////////////////////////////////////////////
  1357. ;------------------------------------------------------------------------------
  1358. ;? <description>
  1359. ;------------------------------------------------------------------------------
  1360. ;> eax = old (original) window box
  1361. ;> ebx = new (final) window box
  1362. ;> esi = process slot
  1363. ;------------------------------------------------------------------------------
  1364. ;        mov     edi, ebx
  1365. ;        call    window._.end_moving__box
  1366.  
  1367.         mov     edi, esi
  1368.         shl     edi, 5
  1369.         add     edi, window_data
  1370.  
  1371.         mov     eax, ebx
  1372.         mov     bl, [edi + WDATA.fl_wstate]
  1373.         call    window._.set_window_box
  1374.         ret
  1375. ;------------------------------------------------------------------------------
  1376. align 4
  1377. ;------------------------------------------------------------------------------
  1378. sys_window_moving_handler: ;///////////////////////////////////////////////////
  1379. ;------------------------------------------------------------------------------
  1380. ;? <description>
  1381. ;------------------------------------------------------------------------------
  1382. ;> eax = old (from previous call) window box
  1383. ;> ebx = new (current) window box
  1384. ;> esi = process_slot
  1385. ;------------------------------------------------------------------------------
  1386.         mov     edi, eax
  1387.         call    window._.draw_negative_box
  1388.         mov     edi, ebx
  1389.         call    window._.draw_negative_box
  1390.         ret
  1391. ;==============================================================================
  1392. ;///// private functions //////////////////////////////////////////////////////
  1393. ;==============================================================================
  1394.  
  1395. iglobal
  1396.   FuncTable syscall_display_settings, ftable, \
  1397.     00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10
  1398.  
  1399.   align 4
  1400.   window_topleft dd \
  1401.     1, 21, \ ;type 0
  1402.     0,  0, \ ;type 1
  1403.     5, 20, \ ;type 2
  1404.     5,  ?, \ ;type 3 {set by skin}
  1405.     5,  ?    ;type 4 {set by skin}
  1406. endg
  1407.  
  1408. ;uglobal
  1409.   ; NOTE: commented out since doesn't provide necessary functionality anyway,
  1410.   ;       to be reworked
  1411. ; new_window_starting       dd ?
  1412. ;endg
  1413. ;------------------------------------------------------------------------------
  1414. align 4
  1415. ;------------------------------------------------------------------------------
  1416. window._.invalidate_screen: ;//////////////////////////////////////////////////
  1417. ;------------------------------------------------------------------------------
  1418. ;? <description>
  1419. ;------------------------------------------------------------------------------
  1420. ;> eax = old (original) window box
  1421. ;> ebx = new (final) window box
  1422. ;> edi = pointer to WDATA struct
  1423. ;------------------------------------------------------------------------------
  1424.         push    eax ebx
  1425.  
  1426.         ; TODO: do we really need `draw_limits`?
  1427.         ; Yes, they are used by background drawing code.
  1428.  
  1429. ; we need only to restore the background windows at the old place!
  1430.         mov     ecx, [ebx + BOX.left]
  1431.         mov     [draw_limits.left], ecx
  1432.         add     ecx, [ebx + BOX.width]
  1433.         mov     [draw_limits.right], ecx
  1434.         mov     ecx, [ebx + BOX.top]
  1435.         mov     [draw_limits.top], ecx
  1436.         add     ecx, [ebx + BOX.height]
  1437.         mov     [draw_limits.bottom], ecx
  1438. ; recalculate screen buffer at old position
  1439.         push    ebx
  1440.         mov     edx, [eax + BOX.height]
  1441.         mov     ecx, [eax + BOX.width]
  1442.         mov     ebx, [eax + BOX.top]
  1443.         mov     eax, [eax + BOX.left]
  1444.         add     ecx, eax
  1445.         add     edx, ebx
  1446.         call    calculatescreen
  1447.         pop     eax
  1448. ; recalculate screen buffer at new position
  1449.         mov     edx, [eax + BOX.height]
  1450.         mov     ecx, [eax + BOX.width]
  1451.         mov     ebx, [eax + BOX.top]
  1452.         mov     eax, [eax + BOX.left]
  1453.         add     ecx, eax
  1454.         add     edx, ebx
  1455.         call    calculatescreen
  1456.  
  1457.         mov     eax, edi
  1458.         call    redrawscreen
  1459.  
  1460.         ; tell window to redraw itself
  1461.         mov     [edi + WDATA.fl_redraw], 1
  1462.  
  1463.         pop     ebx eax
  1464.         ret
  1465. ;------------------------------------------------------------------------------
  1466. align 4
  1467. ;------------------------------------------------------------------------------
  1468. window._.set_window_box: ;/////////////////////////////////////////////////////
  1469. ;------------------------------------------------------------------------------
  1470. ;? <description>
  1471. ;------------------------------------------------------------------------------
  1472. ;> eax = pointer to BOX struct
  1473. ;> bl = new window state flags
  1474. ;> edi = pointer to WDATA struct
  1475. ;------------------------------------------------------------------------------
  1476.         push    eax ebx esi
  1477.  
  1478. ; don't do anything if the new box is identical to the old
  1479.         cmp     bl, [edi + WDATA.fl_wstate]
  1480.         jnz     @f
  1481.         mov     esi, eax
  1482.         push    edi
  1483. if WDATA.box
  1484.         add     edi, WDATA.box
  1485. end if
  1486.         mov     ecx, 4
  1487.         repz cmpsd
  1488.         pop     edi
  1489.         jz      .exit
  1490. ;--------------------------------------
  1491. align 4
  1492. @@:
  1493.         add     esp, -sizeof.BOX
  1494.         mov     ebx, esp
  1495. if WDATA.box
  1496.         lea     esi, [edi + WDATA.box]
  1497. else
  1498.         mov     esi, edi ; optimization for WDATA.box = 0
  1499. end if
  1500.         xchg    eax, esi
  1501.         mov     ecx, sizeof.BOX
  1502.         call    memmove
  1503.         xchg    eax, esi
  1504.         xchg    ebx, esi
  1505.         call    memmove
  1506.         mov     eax, ebx
  1507.         mov     ebx, esi
  1508.  
  1509.         push    edi
  1510.         mov     edi, eax
  1511.         call    window._.draw_negative_box
  1512.         pop     edi
  1513.         call    window._.check_window_position
  1514.         call    window._.set_window_clientbox
  1515.         call    window._.invalidate_screen
  1516.  
  1517.         add     esp, sizeof.BOX
  1518.  
  1519.         mov     cl, [esp + 4]
  1520.         mov     ch, cl
  1521.         xchg    cl, [edi + WDATA.fl_wstate]
  1522.  
  1523.         or      cl, ch
  1524.         test    cl, WSTATE_MAXIMIZED
  1525.         jnz     .exit
  1526.  
  1527.         mov     eax, edi
  1528.         sub     eax, window_data
  1529.         shl     eax, 3
  1530.         add     eax, SLOT_BASE
  1531.  
  1532.         lea     ebx, [edi + WDATA.box]
  1533.         xchg    esp, ebx
  1534.  
  1535.         pop     [eax + APPDATA.saved_box.left] \
  1536.                 [eax + APPDATA.saved_box.top] \
  1537.                 [eax + APPDATA.saved_box.width] \
  1538.                 edx
  1539.  
  1540.         xchg    esp, ebx
  1541.  
  1542.         test    ch, WSTATE_ROLLEDUP
  1543.         jnz     .exit
  1544.  
  1545.         mov     [eax + APPDATA.saved_box.height], edx
  1546. ;--------------------------------------
  1547. align 4
  1548. .exit:
  1549.         pop     esi ebx eax
  1550.         ret
  1551. ;------------------------------------------------------------------------------
  1552. align 4
  1553. ;------------------------------------------------------------------------------
  1554. window._.set_window_clientbox: ;///////////////////////////////////////////////
  1555. ;------------------------------------------------------------------------------
  1556. ;? <description>
  1557. ;------------------------------------------------------------------------------
  1558. ;> edi = pointer to WDATA struct
  1559. ;------------------------------------------------------------------------------
  1560.         push    eax ecx edi
  1561.  
  1562.         mov     eax, [_skinh]
  1563.         mov     [window_topleft + 8 * 3 + 4], eax
  1564.         mov     [window_topleft + 8 * 4 + 4], eax
  1565.  
  1566.         mov     ecx, edi
  1567.         sub     edi, window_data
  1568.         shl     edi, 3
  1569.         test    [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
  1570.         jz      .whole_window
  1571.  
  1572.         movzx   eax, [ecx + WDATA.fl_wstyle]
  1573.         and     eax, 0x0F
  1574.         mov     eax, [eax * 8 + window_topleft + 0]
  1575.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
  1576.         shl     eax, 1
  1577.         neg     eax
  1578.         add     eax, [ecx + WDATA.box.width]
  1579.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
  1580.  
  1581.         movzx   eax, [ecx + WDATA.fl_wstyle]
  1582.         and     eax, 0x0F
  1583.         push    [eax * 8 + window_topleft + 0]
  1584.         mov     eax, [eax * 8 + window_topleft + 4]
  1585.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
  1586.         neg     eax
  1587.         sub     eax, [esp]
  1588.         add     eax, [ecx + WDATA.box.height]
  1589.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
  1590.         add     esp, 4
  1591.         jmp     .exit
  1592. ;--------------------------------------
  1593. align 4
  1594. .whole_window:
  1595.         xor     eax, eax
  1596.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
  1597.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
  1598.         mov     eax, [ecx + WDATA.box.width]
  1599.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
  1600.         mov     eax, [ecx + WDATA.box.height]
  1601.         mov     [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
  1602. ;--------------------------------------
  1603. align 4
  1604. .exit:
  1605.         pop     edi ecx eax
  1606.         ret
  1607. ;------------------------------------------------------------------------------
  1608. align 4
  1609. ;------------------------------------------------------------------------------
  1610. window._.sys_set_window: ;/////////////////////////////////////////////////////
  1611. ;------------------------------------------------------------------------------
  1612. ;? <description>
  1613. ;------------------------------------------------------------------------------
  1614. ;< edx = pointer to WDATA struct
  1615. ;------------------------------------------------------------------------------
  1616.         mov     eax, [CURRENT_TASK]
  1617.         shl     eax, 5
  1618.         add     eax, window_data
  1619.  
  1620.         ; save window colors
  1621.         mov     [eax + WDATA.cl_workarea], edx
  1622.         mov     [eax + WDATA.cl_titlebar], esi
  1623.         mov     [eax + WDATA.cl_frames], edi
  1624.  
  1625.         mov     edi, eax
  1626.  
  1627.         ; was it already defined before?
  1628.         test    [edi + WDATA.fl_wdrawn], 1
  1629.         jnz     .set_client_box
  1630.         or      [edi + WDATA.fl_wdrawn], 1
  1631. ; After first draw_window we need redraw mouse necessarily!
  1632. ; Otherwise the user can see cursor specified by f.37.5 from another window.
  1633. ; He will be really unhappy! He is terrible in rage - usually he throws stones!
  1634.         mov     [redrawmouse_unconditional], 1
  1635.         call    wakeup_osloop
  1636.         ; NOTE: commented out since doesn't provide necessary functionality
  1637.         ;       anyway, to be reworked
  1638. ;       mov     eax, [timer_ticks] ; [0xfdf0]
  1639. ;       add     eax, 100
  1640. ;       mov     [new_window_starting], eax
  1641.  
  1642.         ; no it wasn't, performing initial window definition
  1643.         movzx   eax, bx
  1644.         mov     [edi + WDATA.box.width], eax
  1645.         movzx   eax, cx
  1646.         mov     [edi + WDATA.box.height], eax
  1647.         sar     ebx, 16
  1648.         sar     ecx, 16
  1649.         mov     [edi + WDATA.box.left], ebx
  1650.         mov     [edi + WDATA.box.top], ecx
  1651.  
  1652.         call    window._.check_window_position
  1653.  
  1654.         push    ecx edi
  1655.  
  1656.         mov     cl, [edi + WDATA.fl_wstyle]
  1657.         mov     eax, [edi + WDATA.cl_frames]
  1658.  
  1659.         sub     edi, window_data
  1660.         shl     edi, 3
  1661.         add     edi, SLOT_BASE
  1662.  
  1663.         and     cl, 0x0F
  1664.         cmp     cl, 3
  1665.         je      @f
  1666.         cmp     cl, 4
  1667.         je      @f
  1668.  
  1669.         xor     eax, eax
  1670. ;--------------------------------------
  1671. align 4
  1672. @@:
  1673.         mov     [edi + APPDATA.wnd_caption], eax
  1674.  
  1675.         mov     esi, [esp]
  1676.         add     edi, APPDATA.saved_box
  1677.         movsd
  1678.         movsd
  1679.         movsd
  1680.         movsd
  1681.  
  1682.         pop     edi ecx
  1683.  
  1684.         mov     esi, [CURRENT_TASK]
  1685.         movzx   esi, word[WIN_STACK + esi * 2]
  1686.         lea     esi, [WIN_POS + esi * 2]
  1687.         call    waredraw
  1688.  
  1689.         mov     eax, [edi + WDATA.box.left]
  1690.         mov     ebx, [edi + WDATA.box.top]
  1691.         mov     ecx, [edi + WDATA.box.width]
  1692.         mov     edx, [edi + WDATA.box.height]
  1693.         add     ecx, eax
  1694.         add     edx, ebx
  1695.         call    calculatescreen
  1696.  
  1697.         mov     byte[KEY_COUNT], 0           ; empty keyboard buffer
  1698.         mov     byte[BTN_COUNT], 0           ; empty button buffer
  1699. ;--------------------------------------
  1700. align 4
  1701. .set_client_box:
  1702.         ; update window client box coordinates
  1703.         call    window._.set_window_clientbox
  1704.  
  1705.         ; reset window redraw flag and exit
  1706.         mov     [edi + WDATA.fl_redraw], 0
  1707.         mov     edx, edi
  1708.         ret
  1709. ;------------------------------------------------------------------------------
  1710. align 4
  1711. ;------------------------------------------------------------------------------
  1712. window._.check_window_position: ;//////////////////////////////////////////////
  1713. ;------------------------------------------------------------------------------
  1714. ;? Check if window is inside screen area
  1715. ;------------------------------------------------------------------------------
  1716. ;> edi = pointer to WDATA
  1717. ;------------------------------------------------------------------------------
  1718.         push    eax ebx ecx edx esi
  1719.  
  1720.         mov     eax, [edi + WDATA.box.left]
  1721.         mov     ebx, [edi + WDATA.box.top]
  1722.         mov     ecx, [edi + WDATA.box.width]
  1723.         mov     edx, [edi + WDATA.box.height]
  1724.  
  1725.         mov     esi, [_display.width]
  1726.         cmp     ecx, esi
  1727.         jae     .fix_width_high
  1728. ;--------------------------------------
  1729. align 4
  1730. .check_left:
  1731.         or      eax, eax
  1732.         jl      .fix_left_low
  1733.         add     eax, ecx
  1734.         cmp     eax, esi
  1735.         jge     .fix_left_high
  1736. ;--------------------------------------
  1737. align 4
  1738. .check_height:
  1739.         mov     esi, [_display.height]
  1740.         cmp     edx, esi
  1741.         jae     .fix_height_high
  1742. ;--------------------------------------
  1743. align 4
  1744. .check_top:
  1745.         or      ebx, ebx
  1746.         jl      .fix_top_low
  1747.         add     ebx, edx
  1748.         cmp     ebx, esi
  1749.         jge     .fix_top_high
  1750. ;--------------------------------------
  1751. align 4
  1752. .exit:
  1753.         pop     esi edx ecx ebx eax
  1754.         ret
  1755. ;--------------------------------------
  1756. align 4
  1757. .fix_width_high:
  1758.         mov     ecx, esi
  1759.         mov     [edi + WDATA.box.width], esi
  1760.         jmp     .check_left
  1761. ;--------------------------------------
  1762. align 4
  1763. .fix_left_low:
  1764.         xor     eax, eax
  1765.         mov     [edi + WDATA.box.left], eax
  1766.         jmp     .check_height
  1767. ;--------------------------------------
  1768. align 4
  1769. .fix_left_high:
  1770.         mov     eax, esi
  1771.         sub     eax, ecx
  1772.         mov     [edi + WDATA.box.left], eax
  1773.         jmp     .check_height
  1774. ;--------------------------------------
  1775. align 4
  1776. .fix_height_high:
  1777.         mov     edx, esi
  1778.         mov     [edi + WDATA.box.height], esi
  1779.         jmp     .check_top
  1780. ;--------------------------------------
  1781. align 4
  1782. .fix_top_low:
  1783.         xor     ebx, ebx
  1784.         mov     [edi + WDATA.box.top], ebx
  1785.         jmp     .exit
  1786. ;--------------------------------------
  1787. align 4
  1788. .fix_top_high:
  1789.         mov     ebx, esi
  1790.         sub     ebx, edx
  1791.         mov     [edi + WDATA.box.top], ebx
  1792.         jmp     .exit
  1793. ;------------------------------------------------------------------------------
  1794. align 4
  1795. ;------------------------------------------------------------------------------
  1796. window._.get_titlebar_height: ;////////////////////////////////////////////////
  1797. ;------------------------------------------------------------------------------
  1798. ;? <description>
  1799. ;------------------------------------------------------------------------------
  1800. ;> edi = pointer to WDATA
  1801. ;------------------------------------------------------------------------------
  1802.         mov     al, [edi + WDATA.fl_wstyle]
  1803.         and     al, 0x0f
  1804.         cmp     al, 0x03
  1805.         jne     @f
  1806.         mov     eax, [_skinh]
  1807.         ret
  1808. ;--------------------------------------
  1809. align 4
  1810. @@:
  1811.         mov     eax, 21
  1812.         ret
  1813. ;------------------------------------------------------------------------------
  1814. align 4
  1815. ;------------------------------------------------------------------------------
  1816. window._.get_rolledup_height: ;////////////////////////////////////////////////
  1817. ;------------------------------------------------------------------------------
  1818. ;? <description>
  1819. ;------------------------------------------------------------------------------
  1820. ;> edi = pointer to WDATA
  1821. ;------------------------------------------------------------------------------
  1822.         mov     al, [edi + WDATA.fl_wstyle]
  1823.         and     al, 0x0f
  1824.         cmp     al, 0x03
  1825.         jb      @f
  1826.         mov     eax, [_skinh]
  1827.         add     eax, 3
  1828.         ret
  1829. ;--------------------------------------
  1830. align 4
  1831. @@:
  1832.         or      al, al
  1833.         jnz     @f
  1834.         mov     eax, 21
  1835.         ret
  1836. ;--------------------------------------
  1837. align 4
  1838. @@:
  1839.         mov     eax, 21 + 2
  1840.         ret
  1841. ;------------------------------------------------------------------------------
  1842. align 4
  1843. ;------------------------------------------------------------------------------
  1844. window._.set_screen: ;/////////////////////////////////////////////////////////
  1845. ;------------------------------------------------------------------------------
  1846. ;? Reserve window area in screen buffer
  1847. ;------------------------------------------------------------------------------
  1848. ;> eax = left
  1849. ;> ebx = top
  1850. ;> ecx = right
  1851. ;> edx = bottom
  1852. ;> esi = process number
  1853. ;------------------------------------------------------------------------------
  1854. virtual at esp
  1855.   ff_x     dd ?
  1856.   ff_y     dd ?
  1857.   ff_width dd ?
  1858.   ff_xsz   dd ?
  1859.   ff_ysz   dd ?
  1860.   ff_scale dd ?
  1861. end virtual
  1862.  
  1863.         pushad
  1864.  
  1865.         cmp     esi, 1
  1866.         jz      .check_for_shaped_window
  1867.         mov     edi, esi
  1868.         shl     edi, 5
  1869.         cmp     [window_data + edi + WDATA.box.width], 0
  1870.         jnz     .check_for_shaped_window
  1871.         cmp     [window_data + edi + WDATA.box.height], 0
  1872.         jz      .exit
  1873. ;--------------------------------------
  1874. align 4
  1875. .check_for_shaped_window:
  1876.         mov     edi, esi
  1877.         shl     edi, 8
  1878.         add     edi, SLOT_BASE
  1879.         cmp     [edi + APPDATA.wnd_shape], 0
  1880.         jne     .shaped_window
  1881.  
  1882.         ; get x&y size
  1883.         sub     ecx, eax
  1884.         sub     edx, ebx
  1885.         inc     ecx
  1886.         inc     edx
  1887.  
  1888.         ; get WinMap start
  1889.         push    esi
  1890.         mov     esi, [_display.width]
  1891.         mov     edi, [d_width_calc_area + ebx*4]
  1892.  
  1893.         add     edi, eax
  1894.         add     edi, [_display.win_map]
  1895.         pop     eax
  1896.         mov     ah, al
  1897.         push    ax
  1898.         shl     eax, 16
  1899.         pop     ax
  1900. ;--------------------------------------
  1901. align 4
  1902. .next_line:
  1903.         push    ecx
  1904.         shr     ecx, 2
  1905.         rep stosd
  1906.         mov     ecx, [esp]
  1907.         and     ecx, 3
  1908.         rep stosb
  1909.         pop     ecx
  1910.         add     edi, esi
  1911.         sub     edi, ecx
  1912.         dec     edx
  1913.         jnz     .next_line
  1914.  
  1915.         jmp     .exit
  1916. ;--------------------------------------
  1917. align 4
  1918. .shaped_window:
  1919.         ;  for (y=0; y <= x_size; y++)
  1920.         ;      for (x=0; x <= x_size; x++)
  1921.         ;          if (shape[coord(x,y,scale)]==1)
  1922.         ;             set_pixel(x, y, process_number);
  1923.  
  1924.         sub     ecx, eax
  1925.         sub     edx, ebx
  1926.         inc     ecx
  1927.         inc     edx
  1928.  
  1929.         push    [edi + APPDATA.wnd_shape_scale]  ; push scale first -> for loop
  1930.  
  1931.         ; get WinMap start  -> ebp
  1932.         push    eax
  1933.         mov     eax, [d_width_calc_area + ebx*4]
  1934.  
  1935.         add     eax, [esp]
  1936.         add     eax, [_display.win_map]
  1937.         mov     ebp, eax
  1938.  
  1939.         mov     edi, [edi + APPDATA.wnd_shape]
  1940.         pop     eax
  1941.  
  1942.         ; eax = x_start
  1943.         ; ebx = y_start
  1944.         ; ecx = x_size
  1945.         ; edx = y_size
  1946.         ; esi = process_number
  1947.         ; edi = &shape
  1948.         ;       [scale]
  1949.         push    edx ecx ; for loop - x,y size
  1950.  
  1951.         mov     ecx, esi
  1952.         shl     ecx, 5
  1953.         mov     edx, [window_data + ecx + WDATA.box.top]
  1954.         push    [window_data + ecx + WDATA.box.width]           ; for loop - width
  1955.         mov     ecx, [window_data + ecx + WDATA.box.left]
  1956.         sub     ebx, edx
  1957.         sub     eax, ecx
  1958.         push    ebx eax ; for loop - x,y
  1959.  
  1960.         add     [ff_xsz], eax
  1961.         add     [ff_ysz], ebx
  1962.  
  1963.         mov     ebx, [ff_y]
  1964. ;--------------------------------------
  1965. align 4
  1966. .ff_new_y:
  1967.         mov     edx, [ff_x]
  1968. ;--------------------------------------
  1969. align 4
  1970. .ff_new_x:
  1971.         ; -- body --
  1972.         mov     ecx, [ff_scale]
  1973.         mov     eax, [ff_width]
  1974.         inc     eax
  1975.         shr     eax, cl
  1976.         push    ebx edx
  1977.         shr     ebx, cl
  1978.         shr     edx, cl
  1979.         imul    eax, ebx
  1980.         add     eax, edx
  1981.         pop     edx ebx
  1982.         add     eax, edi
  1983.         call    .read_byte
  1984.         test    al, al
  1985.         jz      @f
  1986.         mov     eax, esi
  1987.         mov     [ebp], al
  1988.         ; -- end body --
  1989. ;--------------------------------------
  1990. align 4
  1991. @@:
  1992.         inc     ebp
  1993.         inc     edx
  1994.         cmp     edx, [ff_xsz]
  1995.         jb      .ff_new_x
  1996.  
  1997.         sub     ebp, [ff_xsz]
  1998.         add     ebp, [ff_x]
  1999.         add     ebp, [_display.width]  ; screen.x
  2000.         inc     ebx
  2001.         cmp     ebx, [ff_ysz]
  2002.         jb      .ff_new_y
  2003.  
  2004.         add     esp, 24
  2005. ;--------------------------------------
  2006. align 4
  2007. .exit:
  2008.         popad
  2009.         inc     [_display.mask_seqno]
  2010.         ret
  2011. ;--------------------------------------
  2012. align 4
  2013. .read_byte:
  2014.         ; eax - address
  2015.         ; esi - slot
  2016.         push    eax ecx edx esi
  2017.         xchg    eax, esi
  2018.         lea     ecx, [esp + 12]
  2019.         mov     edx, 1
  2020.         call    read_process_memory
  2021.         pop     esi edx ecx eax
  2022.         ret
  2023. ;------------------------------------------------------------------------------
  2024. align 4
  2025. ;------------------------------------------------------------------------------
  2026. window._.window_activate: ;////////////////////////////////////////////////////
  2027. ;------------------------------------------------------------------------------
  2028. ;? Activate window
  2029. ;------------------------------------------------------------------------------
  2030. ;> esi = pointer to WIN_POS+ window data
  2031. ;------------------------------------------------------------------------------
  2032.         push    eax ebx
  2033.  
  2034.         ; if type of current active window is 3 or 4, it must be redrawn
  2035.         mov     ebx, [TASK_COUNT]
  2036.  
  2037. ;       DEBUGF  1, "K : TASK_COUNT (0x%x)\n", ebx
  2038.  
  2039.         movzx   ebx, word[WIN_POS + ebx * 2]
  2040.         shl     ebx, 5
  2041.         add     eax, window_data
  2042.         mov     al, [window_data + ebx + WDATA.fl_wstyle]
  2043.         and     al, 0x0f
  2044.         cmp     al, 0x03
  2045.         je      .set_window_redraw_flag
  2046.         cmp     al, 0x04
  2047.         jne     .move_others_down
  2048. ;--------------------------------------
  2049. align 4
  2050. .set_window_redraw_flag:
  2051.         mov     [window_data + ebx + WDATA.fl_redraw], 1
  2052. ;--------------------------------------
  2053. align 4
  2054. .move_others_down:
  2055.         ; ax <- process no
  2056.         movzx   ebx, word[esi]
  2057.         ; ax <- position in window stack
  2058.         movzx   ebx, word[WIN_STACK + ebx * 2]
  2059.  
  2060.         ; drop others
  2061.         xor     eax, eax
  2062. ;--------------------------------------
  2063. align 4
  2064. .next_stack_window:
  2065.         cmp     eax, [TASK_COUNT]
  2066.         jae     .move_self_up
  2067.         inc     eax
  2068.  
  2069. ;       push    ebx
  2070. ;       xor     ebx,ebx
  2071. ;       mov     bx,[WIN_STACK + eax * 2]
  2072. ;       DEBUGF  1, "K : DEC WIN_STACK (0x%x)\n",ebx
  2073. ;       pop     ebx
  2074.  
  2075.         cmp     [WIN_STACK + eax * 2], bx
  2076.         jbe     .next_stack_window
  2077.         dec     word[WIN_STACK + eax * 2]
  2078.         jmp     .next_stack_window
  2079. ;--------------------------------------
  2080. align 4
  2081. .move_self_up:
  2082.         movzx   ebx, word[esi]
  2083.         ; number of processes
  2084.         mov     ax, [TASK_COUNT]
  2085.         ; this is the last (and the upper)
  2086.         mov     [WIN_STACK + ebx * 2], ax
  2087.  
  2088.         ; update on screen - window stack
  2089.         xor     eax, eax
  2090. ;--------------------------------------
  2091. align 4
  2092. .next_window_pos:
  2093.         cmp     eax, [TASK_COUNT]
  2094.         jae     .reset_vars
  2095.         inc     eax
  2096.         movzx   ebx, word[WIN_STACK + eax * 2]
  2097.         mov     [WIN_POS + ebx * 2], ax
  2098.         jmp     .next_window_pos
  2099. ;--------------------------------------
  2100. align 4
  2101. .reset_vars:
  2102.         mov     byte[KEY_COUNT], 0
  2103.         mov     byte[BTN_COUNT], 0
  2104.         mov     word[MOUSE_SCROLL_H], 0
  2105.         mov     word[MOUSE_SCROLL_V], 0
  2106.  
  2107.         pop     ebx eax
  2108.         ret
  2109. ;------------------------------------------------------------------------------
  2110. window._.window_deactivate: ;////////////////////////////////////////////////////
  2111. ;------------------------------------------------------------------------------
  2112. ;? Deactivate window
  2113. ;------------------------------------------------------------------------------
  2114. ;> esi = pointer to WIN_POS+ window data
  2115. ;------------------------------------------------------------------------------
  2116.         push    eax ebx
  2117. ;--------------------------------------
  2118. align 4
  2119. .move_others_up:
  2120.         ; ax <- process no
  2121.         movzx   ebx, word[esi]
  2122.         ; ax <- position in window stack
  2123.         movzx   ebx, word[WIN_STACK + ebx * 2]
  2124.         ; up others
  2125.         xor     eax, eax
  2126. ;--------------------------------------
  2127. align 4
  2128. .next_stack_window:
  2129.         cmp     eax, [TASK_COUNT]
  2130.         jae     .move_self_down
  2131.         inc     eax
  2132.         cmp     [WIN_STACK + eax * 2], bx
  2133.         jae     .next_stack_window
  2134.         inc     word[WIN_STACK + eax * 2]
  2135.         jmp     .next_stack_window
  2136. ;--------------------------------------
  2137. align 4
  2138. .move_self_down:
  2139.         movzx   ebx, word[esi]
  2140.         ; this is the last (and the low)
  2141.         mov     [WIN_STACK + ebx * 2], word 1
  2142.         ; update on screen - window stack
  2143.         xor     eax, eax
  2144. ;--------------------------------------
  2145. align 4
  2146. .next_window_pos:
  2147.         cmp     eax, [TASK_COUNT]
  2148.         jae     .reset_vars
  2149.         inc     eax
  2150.         movzx   ebx, word[WIN_STACK + eax * 2]
  2151.         mov     [WIN_POS + ebx * 2], ax
  2152.         jmp     .next_window_pos
  2153. ;--------------------------------------
  2154. align 4
  2155. .reset_vars:
  2156.         mov     byte[KEY_COUNT], 0
  2157.         mov     byte[BTN_COUNT], 0
  2158.         mov     word[MOUSE_SCROLL_H], 0
  2159.         mov     word[MOUSE_SCROLL_V], 0
  2160.         pop     ebx eax
  2161.         ret
  2162. ;------------------------------------------------------------------------------
  2163. align 4
  2164. ;------------------------------------------------------------------------------
  2165. window._.check_window_draw: ;//////////////////////////////////////////////////
  2166. ;------------------------------------------------------------------------------
  2167. ;? Check if window is necessary to draw
  2168. ;------------------------------------------------------------------------------
  2169. ;> edi = pointer to WDATA
  2170. ;------------------------------------------------------------------------------
  2171.         mov     cl, [edi + WDATA.fl_wstyle]
  2172.         and     cl, 0x0f
  2173.         cmp     cl, 3
  2174.         je      .exit.redraw      ; window type 3
  2175.         cmp     cl, 4
  2176.         je      .exit.redraw      ; window type 4
  2177.  
  2178.         push    eax ebx edx esi
  2179.  
  2180.         mov     eax, edi
  2181.         sub     eax, window_data
  2182.         shr     eax, 5
  2183.  
  2184.         movzx   eax, word[WIN_STACK + eax * 2]  ; get value of the curr process
  2185.         lea     esi, [WIN_POS + eax * 2]        ; get address of this process at 0xC400
  2186. ;--------------------------------------
  2187. align 4
  2188. .next_window:
  2189.         add     esi, 2
  2190.  
  2191.         mov     eax, [TASK_COUNT]
  2192.         lea     eax, word[WIN_POS + eax * 2] ; number of the upper window
  2193.  
  2194.         cmp     esi, eax
  2195.         ja      .exit.no_redraw
  2196.  
  2197.         movzx   edx, word[esi]
  2198.         shl     edx, 5
  2199.         cmp     [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE
  2200.         je      .next_window
  2201.  
  2202.         mov     eax, [edi + WDATA.box.top]
  2203.         mov     ebx, [edi + WDATA.box.height]
  2204.         add     ebx, eax
  2205.  
  2206.         mov     ecx, [window_data + edx + WDATA.box.top]
  2207.         cmp     ecx, ebx
  2208.         jge     .next_window
  2209.         add     ecx, [window_data + edx + WDATA.box.height]
  2210.         cmp     eax, ecx
  2211.         jge     .next_window
  2212.  
  2213.         mov     eax, [edi + WDATA.box.left]
  2214.         mov     ebx, [edi + WDATA.box.width]
  2215.         add     ebx, eax
  2216.  
  2217.         mov     ecx, [window_data + edx + WDATA.box.left]
  2218.         cmp     ecx, ebx
  2219.         jge     .next_window
  2220.         add     ecx, [window_data + edx + WDATA.box.width]
  2221.         cmp     eax, ecx
  2222.         jge     .next_window
  2223.  
  2224.         pop     esi edx ebx eax
  2225. ;--------------------------------------
  2226. align 4
  2227. .exit.redraw:
  2228.         xor     ecx, ecx
  2229.         inc     ecx
  2230.         ret
  2231. ;--------------------------------------
  2232. align 4
  2233. .exit.no_redraw:
  2234.         pop     esi edx ebx eax
  2235.         xor     ecx, ecx
  2236.         ret
  2237. ;------------------------------------------------------------------------------
  2238. align 4
  2239. ;------------------------------------------------------------------------------
  2240. window._.draw_window_caption: ;////////////////////////////////////////////////
  2241. ;------------------------------------------------------------------------------
  2242. ;? <description>
  2243. ;------------------------------------------------------------------------------
  2244.         xor     eax, eax
  2245.         mov     edx, [TASK_COUNT]
  2246.         movzx   edx, word[WIN_POS + edx * 2]
  2247.         cmp     edx, [CURRENT_TASK]
  2248.         jne     @f
  2249.         inc     eax
  2250. ;--------------------------------------
  2251. align 4
  2252. @@:
  2253.         mov     edx, [CURRENT_TASK]
  2254.         shl     edx, 5
  2255.         add     edx, window_data
  2256.         movzx   ebx, [edx + WDATA.fl_wstyle]
  2257.         and     bl, 0x0F
  2258.         cmp     bl, 3
  2259.         je      .draw_caption_style_3
  2260.         cmp     bl, 4
  2261.         je      .draw_caption_style_3
  2262.  
  2263.         jmp     .not_style_3
  2264. ;--------------------------------------
  2265. align 4
  2266. .draw_caption_style_3:
  2267.         push    edx
  2268.         call    drawwindow_IV_caption
  2269.         add     esp, 4
  2270.         jmp     .2
  2271. ;--------------------------------------
  2272. align 4
  2273. .not_style_3:
  2274.         cmp     bl, 2
  2275.         jne     .not_style_2
  2276.  
  2277.         call    drawwindow_III_caption
  2278.         jmp     .2
  2279. ;--------------------------------------
  2280. align 4
  2281. .not_style_2:
  2282.         cmp     bl, 0
  2283.         jne     .2
  2284.  
  2285.         call    drawwindow_I_caption
  2286. ;--------------------------------------
  2287. align 4
  2288. .2:
  2289.         mov     edi, [CURRENT_TASK]
  2290.         shl     edi, 5
  2291.         test    [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
  2292.         jz      .exit
  2293.         mov     edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
  2294.         or      edx, edx
  2295.         jz      .exit
  2296.  
  2297.         movzx   eax, [edi + window_data + WDATA.fl_wstyle]
  2298.         and     al, 0x0F
  2299.         cmp     al, 3
  2300.         je      .skinned
  2301.         cmp     al, 4
  2302.         je      .skinned
  2303.  
  2304.         jmp     .not_skinned
  2305. ;--------------------------------------
  2306. align 4
  2307. .skinned:
  2308.         mov     ebp, [edi + window_data + WDATA.box.left - 2]
  2309.         mov     bp, word[edi + window_data + WDATA.box.top]
  2310.         movzx   eax, word[edi + window_data + WDATA.box.width]
  2311.         sub     ax, [_skinmargins.left]
  2312.         sub     ax, [_skinmargins.right]
  2313.         push    edx
  2314.         cwde
  2315.         cdq
  2316.         mov     ebx, 6
  2317.         idiv    ebx
  2318.         pop     edx
  2319.         or      eax, eax
  2320.         js      .exit
  2321.  
  2322.         mov     esi, eax
  2323.         mov     ebx, dword[_skinmargins.left - 2]
  2324.         mov     bx, word[_skinh]
  2325.         sub     bx, [_skinmargins.bottom]
  2326.         sub     bx, [_skinmargins.top]
  2327.         sar     bx, 1
  2328.         adc     bx, 0
  2329.         add     bx, [_skinmargins.top]
  2330.         add     bx, -3
  2331.         add     ebx, ebp
  2332.         jmp     .dodraw
  2333. ;--------------------------------------
  2334. align 4
  2335. .not_skinned:
  2336.         cmp     al, 1
  2337.         je      .exit
  2338.  
  2339.         mov     ebp, [edi + window_data + WDATA.box.left - 2]
  2340.         mov     bp, word[edi + window_data + WDATA.box.top]
  2341.         movzx   eax, word[edi + window_data + WDATA.box.width]
  2342.         sub     eax, 16
  2343.         push    edx
  2344.         cwde
  2345.         cdq
  2346.         mov     ebx, 6
  2347.         idiv    ebx
  2348.         pop     edx
  2349.         or      eax, eax
  2350.         js      .exit
  2351.  
  2352.         mov     esi, eax
  2353.         mov     ebx, 0x00080007
  2354.         add     ebx, ebp
  2355. ;--------------------------------------
  2356. align 4
  2357. .dodraw:
  2358.         mov     ecx, [common_colours + 16]
  2359.         or      ecx, 0x80000000
  2360.         xor     edi, edi
  2361.         call    dtext_asciiz_esi
  2362. ;--------------------------------------
  2363. align 4
  2364. .exit:
  2365. ;        call    [draw_pointer]
  2366.         call    __sys_draw_pointer
  2367.         ret
  2368. ;------------------------------------------------------------------------------
  2369. align 4
  2370. ;------------------------------------------------------------------------------
  2371. window._.draw_negative_box: ;//////////////////////////////////////////////////
  2372. ;------------------------------------------------------------------------------
  2373. ;? Draw negative box
  2374. ;------------------------------------------------------------------------------
  2375. ;> edi = pointer to BOX struct
  2376. ;------------------------------------------------------------------------------
  2377.         push    eax ebx esi
  2378.         mov     esi, 0x01000000
  2379. ;--------------------------------------
  2380. align 4
  2381. .1:
  2382.         mov     eax, [edi + BOX.left - 2]
  2383.         mov     ax, word[edi + BOX.left]
  2384.         add     ax, word[edi + BOX.width]
  2385.         mov     ebx, [edi + BOX.top - 2]
  2386.         mov     bx, word[edi + BOX.top]
  2387.         add     bx, word[edi + BOX.height]
  2388.         call    draw_rectangle.forced
  2389.         pop     esi ebx eax
  2390.         ret
  2391. ;------------------------------------------------------------------------------
  2392. ;align 4
  2393. ;------------------------------------------------------------------------------
  2394. ;window._.end_moving__box: ;//////////////////////////////////////////////////
  2395. ;------------------------------------------------------------------------------
  2396. ;? Draw positive box
  2397. ;------------------------------------------------------------------------------
  2398. ;> edi = pointer to BOX struct
  2399. ;------------------------------------------------------------------------------
  2400. ;        push    eax ebx esi
  2401. ;        xor     esi, esi
  2402. ;        jmp     window._.draw_negative_box.1
  2403. ;------------------------------------------------------------------------------
  2404. align 4
  2405. ;------------------------------------------------------------------------------
  2406. window._.get_rect: ;/////////////////////////////////////////////////////
  2407. ;------------------------------------------------------------------------------
  2408. ;? <description>  void __fastcall get_window_rect(struct RECT* rc);
  2409. ;------------------------------------------------------------------------------
  2410. ;> ecx = pointer to RECT
  2411. ;------------------------------------------------------------------------------
  2412.         mov     eax, [TASK_BASE]
  2413.  
  2414.         mov     edx, [eax-twdw + WDATA.box.left]
  2415.         mov     [ecx+RECT.left], edx
  2416.  
  2417.         add     edx, [eax-twdw + WDATA.box.width]
  2418.         mov     [ecx+RECT.right], edx
  2419.  
  2420.         mov     edx, [eax-twdw + WDATA.box.top]
  2421.         mov     [ecx+RECT.top], edx
  2422.  
  2423.         add     edx, [eax-twdw + WDATA.box.height]
  2424.         mov     [ecx+RECT.bottom], edx
  2425.         ret
  2426. ;------------------------------------------------------------------------------
  2427. align 4
  2428. ;------------------------------------------------------------------------------
  2429. window._.redraw_top_wnd: ;////////////////////////////////////////////////////////
  2430. ;------------------------------------------------------------------------------
  2431. ;? redraw all windows one above the window
  2432. ;------------------------------------------------------------------------------
  2433. ;> eax = left
  2434. ;> ebx = top
  2435. ;> ecx = right
  2436. ;> edx = bottom
  2437. ;> esi = process number
  2438. ;! corrupted edi
  2439. ;------------------------------------------------------------------------------
  2440.         push    0
  2441.         jmp     window._.set_top_wnd.go
  2442.  
  2443. align 4
  2444. ;------------------------------------------------------------------------------
  2445. window._.set_top_wnd: ;////////////////////////////////////////////////////////
  2446. ;------------------------------------------------------------------------------
  2447. ;? call set_screen for all windows one above the window
  2448. ;------------------------------------------------------------------------------
  2449. ;> eax = left
  2450. ;> ebx = top
  2451. ;> ecx = right
  2452. ;> edx = bottom
  2453. ;> esi = process number
  2454. ;! corrupted edi
  2455. ;------------------------------------------------------------------------------
  2456.  
  2457.         push    1
  2458. .go:
  2459.         push    esi
  2460.         pushfd
  2461.         cli
  2462.  
  2463.         push    ebp
  2464.         mov     ebp, [TASK_COUNT]
  2465.         cmp     ebp, 1
  2466.         jbe     .exit
  2467.  
  2468.         shl     esi, 5
  2469.         cmp     [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
  2470.         je      .exit
  2471.  
  2472.         push    eax ;for num layout
  2473.         push    edx ecx ebx eax
  2474.  
  2475.         movsx   eax, byte [esi + window_data + WDATA.z_modif]
  2476.         inc     eax
  2477.         mov     dword[esp+10h], eax
  2478. ;--------------------------------------
  2479. align 4
  2480. .layout:
  2481.         mov     esi, 1        ; = num in window stack
  2482.         mov     ebp, [TASK_COUNT]
  2483. ;--------------------------------------
  2484. align 4
  2485. .next_window:
  2486.         movzx   edi, word[WIN_POS + esi * 2]
  2487.         shl     edi, 5                  ;size of TASKDATA and WDATA = 32 bytes
  2488.  
  2489.         cmp     [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
  2490.         je      .skip_window
  2491.  
  2492.         add     edi, window_data
  2493.         test    [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
  2494.         jnz     .skip_window
  2495.  
  2496.         mov     eax, [esp+10h]
  2497.         cmp     [edi + WDATA.z_modif], al
  2498.         jne     .skip_window
  2499.  
  2500.         mov     eax, [edi + WDATA.box.left]
  2501.         cmp     eax, [esp + RECT.right]
  2502.         jg      .skip_window
  2503.         mov     ebx, [edi + WDATA.box.top]
  2504.         cmp     ebx, [esp + RECT.bottom]
  2505.         jg      .skip_window
  2506.         mov     ecx, [edi + WDATA.box.width]
  2507.         add     ecx, eax
  2508.         cmp     ecx, [esp + RECT.left]
  2509.         jl      .skip_window
  2510.         mov     edx, [edi + WDATA.box.height]
  2511.         add     edx, ebx
  2512.         cmp     edx, [esp + RECT.top]
  2513.         jl      .skip_window
  2514.  
  2515.         cmp     eax, [esp + RECT.left]
  2516.         jae     @f
  2517.         mov     eax, [esp + RECT.left]
  2518. ;--------------------------------------
  2519. align 4
  2520. @@:
  2521.         cmp     ebx, [esp + RECT.top]
  2522.         jae     @f
  2523.         mov     ebx, [esp + RECT.top]
  2524. ;--------------------------------------
  2525. align 4
  2526. @@:
  2527.         cmp     ecx, [esp + RECT.right]
  2528.         jbe     @f
  2529.         mov     ecx, [esp + RECT.right]
  2530. ;--------------------------------------
  2531. align 4
  2532. @@:
  2533.         cmp     edx, [esp + RECT.bottom]
  2534.         jbe     @f
  2535.         mov     edx, [esp + RECT.bottom]
  2536. ;--------------------------------------
  2537. align 4
  2538. @@:
  2539.         cmp     dword[esp+32], 0
  2540.         je      .set_fl_redraw
  2541.  
  2542.         push    esi
  2543.         movzx   esi, word[WIN_POS + esi * 2]
  2544.         call    window._.set_screen
  2545.         pop     esi
  2546.         jmp     @f
  2547. .set_fl_redraw:
  2548.         mov     [edi + WDATA.fl_redraw], 1      ;set redraw flag
  2549.      @@:
  2550. ;--------------------------------------
  2551. align 4
  2552. .skip_window:
  2553.         inc     esi
  2554.         dec     ebp
  2555.         jnz     .next_window
  2556. ;--------------------------------------
  2557.         inc     dword[esp+10h]
  2558.         cmp     byte[esp+10h], ZPOS_ALWAYS_TOP
  2559.         jle     .layout
  2560. ;-------------------------------------
  2561.  
  2562.         pop     eax ebx ecx edx
  2563.         pop     ebp     ;del num layout
  2564. ;-------------------------------------
  2565. align 4
  2566. .exit:
  2567.  
  2568.         pop     ebp
  2569.         popfd
  2570.         pop     esi
  2571.  
  2572.         add     esp, 4   ;dword for 0/1 - set_screen/fl_redraw
  2573.         ret
  2574.  
  2575.  
  2576.  
  2577.