Subversion Repositories Kolibri OS

Rev

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

  1. get_titlebar_height: ; edi = window draw_data pointer
  2.         mov     al,[edi+WDATA.fl_wstyle]
  3.         and     al,0x0F
  4.         cmp     al,0x03
  5.         jne     @f
  6.         mov     eax,[_skinh]
  7.         ret
  8.     @@: mov     eax,21
  9.         ret
  10.  
  11. get_rolledup_height: ; edi = window draw_data pointer
  12.         mov     al,[edi+WDATA.fl_wstyle]
  13.         and     al,0x0F
  14.         cmp     al,0x03
  15.         jne     @f
  16.         mov     eax,[_skinh]
  17.         add     eax,3
  18.         ret
  19.     @@: or      al,al
  20.         jnz     @f
  21.         mov     eax,21
  22.         ret
  23.     @@: mov     eax,21+2
  24.         ret
  25.  
  26.  
  27. setwindowdefaults:
  28.         pushad
  29.  
  30.         xor   eax,eax
  31.         mov   ecx,0xc000
  32.        @@:
  33.         inc   eax
  34.         add   ecx,2
  35.         mov   [ecx+0x000],ax          ; process no
  36.         mov   [ecx+0x400],ax          ; positions in stack
  37.         cmp   ecx,0xc400-2            ; the more high, the more surface
  38.         jnz   @b
  39.  
  40.         popad
  41.         ret
  42.  
  43.  
  44.  
  45. ; eax = cx
  46. ; ebx = cy
  47. ; ecx = ex
  48. ; edx = ey
  49. ; èäåÿ: ïåðåáðàòü âñå îêíà, íà÷èíàÿ ñ ñàìîãî íèæíåãî,
  50. ;       è äëÿ êàæäîãî âûçâàòü setscreen
  51. align 4
  52. calculatescreen:
  53.         pushad
  54.         cli
  55.  
  56.         mov   esi, 1
  57.         xor   eax, eax
  58.         xor   ebx, ebx
  59.         mov   ecx, [0xFE00]
  60.         mov   edx, [0xFE04]
  61.         call  setscreen
  62.  
  63.         mov   ebp, [0x3004]        ; number of processes
  64.         cmp   ebp, 1
  65.         jbe   .finish
  66.         align 4
  67.       .new_wnd:
  68.         movzx edi, word [0xC400 + esi * 2]
  69.         shl   edi, 5
  70.         add   edi, window_data
  71.         test    [edi+WDATA.fl_wstate],WSTATE_MINIMIZED
  72.         jnz     .not_wnd
  73.         mov     eax,[edi+WDATA.left]
  74.         mov     ebx,[edi+WDATA.top]
  75.         mov     ecx,[edi+WDATA.width]
  76.         add     ecx,eax
  77.         mov     edx,[edi+WDATA.height]
  78.         add     edx,ebx
  79.         push  esi
  80.         movzx esi, word [0xC400 + esi * 2]
  81.         call  setscreen
  82.         pop   esi
  83.       .not_wnd:
  84.         inc   esi
  85.         dec   ebp
  86.         jnz   .new_wnd
  87.       .finish:
  88.         sti
  89.         popad
  90. ret
  91.  
  92.  
  93.  
  94. virtual at esp
  95.   ff_xsz   dd ?
  96.   ff_ysz   dd ?
  97.   ff_scale dd ?
  98. end virtual
  99.  
  100. align 4
  101. ; ðåçåðâèðóåò ìåñòî ïîä îêíî çàäàííîãî ïðîöåññà
  102. setscreen:
  103. ;  eax  x start
  104. ;  ebx  y start
  105. ;  ecx  x end
  106. ;  edx  y end
  107. ;  esi  process number
  108. pushad
  109.         mov edi, esi ;;;word [esi*2+0xc400]
  110.         shl   edi, 8
  111.         add   edi, 0x80000+0x80  ; address of random shaped window area
  112.         cmp   [edi], dword 0
  113.         jne   .free_form
  114.  
  115.         ; get x&y size
  116.         sub   ecx, eax
  117.         sub   edx, ebx
  118.         inc   ecx
  119.         inc   edx
  120.  
  121.         ; get WinMap start
  122.         mov   edi, [0xFE00] ; screen_sx
  123.         inc   edi
  124.         imul  edi, ebx
  125.         add   edi, eax
  126.         add   edi, WinMapAddress
  127.  
  128.   .new_y:
  129.         push  ecx ; sx
  130.         push  edx
  131.  
  132.         mov   edx, esi
  133.         align 4
  134.   .new_x:
  135.         mov   byte [edi], dl
  136.         inc   edi
  137.         dec   ecx
  138.         jnz   .new_x
  139.  
  140.         pop   edx
  141.         pop   ecx
  142.         add   edi, [0xFE00]
  143.         inc   edi
  144.         sub   edi, ecx
  145.         dec   edx
  146.         jnz   .new_y
  147.  popad
  148.  ret
  149.   .read_byte:
  150.    ;eax - address
  151.    ;esi - slot
  152.         push  eax
  153.         push  ebx
  154.         push  ecx
  155.         push  edx
  156.         mov   edx,eax
  157.         mov   eax,esi
  158.         lea   ebx,[esp+12]
  159.         mov   ecx,1
  160.         call  read_process_memory
  161.         pop   edx
  162.         pop   ecx
  163.         pop   ebx
  164.         pop   eax
  165.         ret  
  166.   .free_form:
  167.  
  168.         ;  for (y=0; y <= x_size; y++)
  169.         ;      for (x=0; x <= x_size; x++)
  170.         ;          if (shape[coord(x,y,scale)]==1)
  171.         ;             set_pixel(x, y, process_number);
  172.  
  173.         sub  ecx, eax
  174.         sub  edx, ebx
  175.         inc  ecx
  176.         inc  edx
  177.  
  178.         push  dword [edi+4]  ; push scale first -> for loop
  179.  
  180.         ; get WinMap start  -> ebp
  181.         push  eax
  182.         mov   eax, [0xFE00] ; screen_sx
  183.         inc   eax
  184.         imul  eax, ebx   ;ebx
  185.         add   eax, [esp] ;eax
  186.         add   eax, WinMapAddress
  187.         mov   ebp, eax
  188.  
  189.         mov   edi, [edi]
  190. ;        mov   eax, esi
  191. ;        shl   eax, 5
  192. ;        add   edi, [eax+0x3000+0x10]
  193.         pop   eax
  194.  
  195.         ; eax = x_start
  196.         ; ebx = y_start
  197.         ; ecx = x_size
  198.         ; edx = y_size
  199.         ; esi = process_number
  200.         ; edi = &shape
  201.         ;       [scale]
  202.         push edx ecx ;ebx eax
  203.         xor  ebx, ebx
  204.         align 4
  205.       .ff_new_y:
  206.         xor  edx, edx
  207.         align 4
  208.       .ff_new_x:
  209.         ; -- body --
  210.         mov  ecx, [ff_scale]
  211.         mov  eax, [ff_xsz]
  212.         shr  eax, cl
  213.         push ebx edx
  214.         shr  ebx, cl
  215.         shr  edx, cl
  216.         imul eax, ebx
  217.         add  eax, edx
  218.         pop  edx ebx
  219.         add  eax, edi ;[ff_shape]
  220.         call .read_byte
  221. ;        cmp  byte [eax], 1
  222. ;        jne  @f
  223.         test al,al
  224.         jz   @f
  225.         mov  eax, esi  ; [ff_proc]
  226.         mov  [ebp], al
  227.        @@:
  228.         ; -- end body --
  229.         inc  ebp
  230.         inc  edx
  231.         cmp  edx, [ff_xsz]
  232.         jb   .ff_new_x
  233.         sub  ebp, [ff_xsz]
  234.         add  ebp, [0xFE00]  ; screen.x
  235.         inc  ebp
  236.         inc  ebx
  237.         cmp  ebx, [ff_ysz]
  238.         jb   .ff_new_y
  239.  
  240.         pop  ecx edx   ; eax ebx first
  241.         add  esp, 4
  242. popad
  243. ret
  244.  
  245.  
  246. display_settings:
  247.  
  248. ;    eax = 0         ; DISPLAY redraw
  249. ;          ebx = 0   ; all
  250. ;
  251. ;    eax = 1         ; BUTTON type
  252. ;          ebx = 0   ; flat
  253. ;          ebx = 1   ; 3D
  254. ;    eax = 2         ; set WINDOW colours
  255. ;          ebx = pointer to table
  256. ;          ecx = number of bytes define
  257. ;    eax = 3         ; get WINDOW colours
  258. ;          ebx = pointer to table
  259. ;          ecx = number of bytes wanted
  260. ;    eax = 4         ; get skin height
  261. ;          input  : nothing
  262. ;          output : eax = skin height in pixel
  263. ;    eax = 5         ; get screen workarea
  264. ;          input  : nothing
  265. ;          output : eax = [left]*65536+[right]
  266. ;                   ebx = [top]*65536+[bottom]
  267. ;    eax = 6         ; set screen workarea
  268. ;          input  : ecx = [left]*65536+[right]
  269. ;                   edx = [top]*65536+[bottom]
  270. ;          output : nothing
  271.  
  272.  
  273.      pushad
  274.  
  275.      test eax, eax      ; redraw display
  276.      jnz  dspl0
  277.      test ebx, ebx
  278.      jnz  dspl0
  279.      cmp  [windowtypechanged],dword 1
  280.      jne  dspl00
  281.      mov  [windowtypechanged],dword 0
  282.   redraw_screen_direct:
  283.      mov  [dlx],dword 0
  284.      mov  [dly],dword 0
  285.      mov  eax,[0xfe00]
  286.      mov  [dlxe],eax
  287.      mov  eax,[0xfe04]
  288.      mov  [dlye],eax
  289.      mov  eax,window_data
  290.      call redrawscreen
  291.    dspl00:
  292.      popad
  293.      ret
  294.    dspl0:
  295.  
  296.      cmp  eax,1       ; button type
  297.      jne  dspl1
  298.      and  ebx,1
  299.      cmp  ebx,[buttontype]
  300.      je   dspl9
  301.      mov  [buttontype],ebx
  302.      mov  [windowtypechanged],dword 1
  303.     dspl9:
  304.      popad
  305.      ret
  306.    dspl1:
  307.  
  308.      cmp  eax,2       ; set common window colours
  309.      jne  no_com_colours
  310.      mov  [windowtypechanged],dword 1
  311.      mov  esi,[0x3010]
  312.      add  esi,0x10
  313.      add  ebx,[esi]
  314.      mov  esi,ebx
  315.      mov  edi,common_colours
  316.      and  ecx,127
  317.      cld
  318.      rep  movsb
  319.      popad
  320.      ret
  321.    no_com_colours:
  322.  
  323.      cmp  eax,3       ; get common window colours
  324.      jne  no_get_com
  325.      mov  esi,[0x3010]
  326.      add  esi,0x10
  327.      add  ebx,[esi]
  328.      mov  edi,ebx
  329.      mov  esi,common_colours
  330.      and  ecx,127
  331.      cld
  332.      rep  movsb
  333.      popad
  334.      ret
  335.    no_get_com:
  336.  
  337.      cmp  eax,4       ; get skin height
  338.      jne  no_skin_height
  339.      popad
  340.      mov  eax,[_skinh]
  341.      mov  [esp+36],eax
  342.      ret
  343.    no_skin_height:
  344.  
  345.         cmp     eax,5       ; get screen workarea
  346.         jne     no_get_workarea
  347.         popad
  348.         mov     eax,[screen_workarea.left-2]
  349.         mov     ax,word[screen_workarea.right]
  350.         mov     [esp+36],eax
  351.         mov     eax,[screen_workarea.top-2]
  352.         mov     ax,word[screen_workarea.bottom]
  353.         mov     [esp+24],eax
  354.         ret
  355.    no_get_workarea:
  356.  
  357.         cmp     eax,6       ; set screen workarea
  358.         jne     no_set_workarea
  359.         movsx   eax,word[esp+16+2]
  360.         movsx   ebx,word[esp+16]
  361.         cmp     eax,ebx
  362.         jge     .lp1
  363.         or      eax,eax;[0xFE00]
  364.         jl      @f
  365.         mov     [screen_workarea.left],eax
  366.     @@: cmp     ebx,[0xFE00]
  367.         jg      .lp1
  368.         mov     [screen_workarea.right],ebx
  369.   .lp1: movsx   eax,word[esp+24+2]
  370.         movsx   ebx,word[esp+24]
  371.         cmp     eax,ebx
  372.         jge     .lp2
  373.         or      eax,eax;[0xFE04]
  374.         jl      @f
  375.         mov     [screen_workarea.top],eax
  376.     @@: cmp     ebx,[0xFE04]
  377.         jg      .lp2
  378.         mov     [screen_workarea.bottom],ebx
  379.   .lp2: call    repos_windows
  380.         call    calculatescreen
  381. ;       jmp     redraw_screen_direct
  382.     .exit:
  383.         popad
  384.         ret
  385.    no_set_workarea:
  386.  
  387.      popad
  388.      ret
  389.  
  390.  
  391. repos_windows:
  392.         mov     ecx,[0x3004]
  393.         mov     esi,0x20*2
  394.         mov     byte[0x0000fff0],1
  395.         dec     ecx
  396.         jge     @f
  397.         ret
  398.     @@: mov     [esi+WDATA.fl_redraw],1
  399.         test    [esi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  400.         jz      .lp2
  401.         mov     eax,[screen_workarea.left]
  402.         mov     [esi+WDATA.left],eax
  403.         sub     eax,[screen_workarea.right]
  404.         neg     eax
  405.         mov     [esi+WDATA.width],eax
  406.         mov     eax,[screen_workarea.top]
  407.         mov     [esi+WDATA.top],eax
  408.         test    [esi+WDATA.fl_wstate],WSTATE_ROLLEDUP
  409.         jnz     .lp1
  410.         sub     eax,[screen_workarea.bottom]
  411.         neg     eax
  412.         mov     [esi+WDATA.height],eax
  413.   .lp1: add     esi,0x20
  414.         loop    @b
  415.         ret
  416.   .lp2: mov     eax,[esi+WDATA.left]
  417.         add     eax,[esi+WDATA.width]
  418.         mov     ebx,[0x0000fe00]
  419. ;       inc     ebx
  420.         cmp     eax,ebx
  421.         jle     .lp4
  422.         mov     eax,[esi+WDATA.width]
  423.         sub     eax,ebx
  424.         jle     .lp3
  425.         mov     [esi+WDATA.width],ebx
  426.   .lp3: sub     ebx,[esi+WDATA.width]
  427.         mov     [esi+WDATA.left],ebx
  428.   .lp4: mov     eax,[esi+WDATA.top]
  429.         add     eax,[esi+WDATA.height]
  430.         mov     ebx,[0x0000fe04]
  431. ;       inc     ebx
  432.         cmp     eax,ebx
  433.         jle     .lp6
  434.         mov     eax,[esi+WDATA.height]
  435.         sub     eax,ebx
  436.         jle     .lp5
  437.         mov     [esi+WDATA.height],ebx
  438.   .lp5: sub     ebx,[esi+WDATA.height]
  439.         mov     [esi+WDATA.top],ebx
  440.   .lp6: add     esi,0x20
  441.         loop    @b
  442.         ret
  443.  
  444. uglobal
  445.   common_colours:
  446.      times 128 db 0x0
  447. endg
  448.  
  449.  
  450.  
  451.  
  452. check_window_position:
  453.  
  454.     pushad                           ; window inside screen ?
  455.  
  456.     movzx eax,word [edi+0]
  457.     movzx ebx,word [edi+4]
  458.     movzx ecx,word [edi+8]
  459.     movzx edx,word [edi+12]
  460.  
  461.     mov   esi,ecx             ; check x pos
  462.     add   esi,eax
  463.     cmp   esi,[0xfe00]
  464.     jbe   x_pos_ok
  465.     mov   [edi+0],dword 0
  466.     xor   eax, eax
  467.   x_pos_ok:
  468.  
  469.     mov   esi,edx             ; check y pos
  470.     add   esi,ebx
  471.     cmp   esi,[0xfe04]
  472.     jbe   y_pos_ok
  473.     mov   [edi+4],dword 0
  474.     mov   ebx,0
  475.   y_pos_ok:
  476.  
  477.     mov   esi,ecx             ; check x size
  478.     add   esi,eax
  479.     cmp   esi,[0xfe00]
  480.     jbe   x_size_ok
  481.     mov   ecx,[0xfe00]
  482.     mov   [edi+8],ecx
  483.   x_size_ok:
  484.  
  485.     mov   esi,edx             ; check y size
  486.     add   esi,ebx
  487.     cmp   esi,[0xfe04]
  488.     jbe   y_size_ok
  489.     mov   edx,[0xfe04]
  490.     mov   [edi+12],edx
  491.   y_size_ok:
  492.  
  493.     popad
  494.  
  495.     ret
  496.  
  497.  
  498. uglobal
  499.   new_window_starting dd 0
  500. endg
  501.  
  502.  
  503. sys_window_mouse:
  504.  
  505.     push  eax
  506.  
  507.     mov   eax,[timer_ticks] ;[0xfdf0]
  508.     cmp   [new_window_starting],eax
  509.     jb    swml1
  510.  
  511.     mov   [0xfff4],byte 0  ; no mouse background
  512.     mov   [0xfff5],byte 0  ; draw mouse
  513.  
  514.     mov   [new_window_starting],eax
  515.  
  516.   swml1:
  517.  
  518.     pop   eax
  519.  
  520.     ret
  521.  
  522. drawwindow_I:
  523.  
  524.         pushad
  525.  
  526.         mov   esi,[edx+24]   ; rectangle
  527.         mov   eax,[edx+0]
  528.         shl   eax,16
  529.         add   eax,[edx+0]
  530.         add   eax,[edx+8]
  531.         mov   ebx,[edx+04]
  532.         shl   ebx,16
  533.         add   ebx,[edx+4]
  534.         add   ebx,[edx+12]
  535.         call  draw_rectangle
  536.  
  537.         mov   ecx,[edx+20]   ; grab bar
  538.         push  ecx
  539.         mov   esi,edx
  540.         mov   edx,[esi+04]
  541.         add   edx,1
  542.         mov   ebx,[esi+04]
  543.         add   ebx,25
  544.         mov   eax,[esi+04]
  545.         add   eax,[esi+12]
  546.         cmp   ebx,eax
  547.         jb    wdsizeok
  548.         mov   ebx,eax
  549.       wdsizeok:
  550.         push  ebx
  551.       drwi:
  552.         mov   ebx,edx
  553.         shl   ebx,16
  554.         add   ebx,edx
  555.         mov   eax,[esi+00]
  556.         inc   eax
  557.         shl   eax,16
  558.         add   eax,[esi+00]
  559.         add   eax,[esi+8]
  560.         sub   eax,1
  561.         push  edx
  562.         mov   edx,0x80000000
  563.         mov   ecx,[esi+20]
  564.         and   ecx,edx
  565.         cmp   ecx,edx
  566.         jnz   nofa
  567.         mov   ecx,[esi+20]
  568.         sub   ecx,0x00040404
  569.         mov   [esi+20],ecx
  570.         and   ecx,0x00ffffff
  571.         jmp   faj
  572.       nofa:
  573.         mov   ecx,[esi+20]
  574.         and   ecx,0x00ffffff
  575.       faj:
  576.         pop   edx
  577.         mov   edi,0
  578.         call  [draw_line]
  579.         inc   edx
  580.         cmp   edx,[esp]
  581.         jb    drwi
  582.         add   esp,4
  583.         pop   ecx
  584.         mov   [esi+20],ecx
  585.  
  586.         mov   edx,[esi+04]      ; inside work area
  587.         add   edx,21+5
  588.         mov   ebx,[esi+04]
  589.         add   ebx,[esi+12]
  590.         cmp   edx,ebx
  591.         jg    noinside
  592.         mov   eax,1
  593.         mov   ebx,21
  594.         mov   ecx,[esi+8]
  595.         mov   edx,[esi+12]
  596.         mov   edi,[esi+16]
  597.         call  [drawbar]
  598.       noinside:
  599.  
  600.         popad
  601.  
  602.         ret
  603.  
  604.  
  605. draw_rectangle:
  606.  
  607. r_eax equ [esp+28]   ; x start
  608. r_ax  equ [esp+30]   ; x end
  609. r_ebx equ [esp+16]   ; y start
  610. r_bx  equ [esp+18]   ; y end
  611. ;esi                 ; color
  612.  
  613.         pushad
  614.  
  615.         mov   ecx,esi          ; yb,xb -> yb,xe
  616.      ;<<< 14.11.2004 Ivan Poddubny  <faster and smaller>
  617. ;        mov   eax,r_eax
  618. ;        shl   eax,16
  619. ;        mov   ax,r_ax
  620.         mov   eax, r_eax
  621.         rol   eax, 16
  622.      ;>>> 14.11.2004 Ivan Poddubny  <faster and smaller>
  623.         mov   ebx,r_ebx
  624.         shl   ebx,16
  625.         mov   bx,r_ebx
  626.         xor   edi, edi
  627.         call  [draw_line]
  628.  
  629.         mov   ebx,r_bx         ; ye,xb -> ye,xe
  630.         shl   ebx,16
  631.         mov   bx,r_bx
  632.         call  [draw_line]
  633.  
  634.         mov   ecx,esi          ; ya,xa -> ye,xa
  635.         mov   eax,r_eax
  636.         shl   eax,16
  637.         mov   ax,r_eax
  638.         mov   ebx,r_ebx
  639.         shl   ebx,16
  640.         mov   bx,r_bx
  641.         mov   edi,0
  642.         call  [draw_line]
  643.  
  644.         mov   eax,r_ax       ; ya,xe -> ye,xe
  645.         shl   eax,16
  646.         mov   ax,r_ax
  647.         call  [draw_line]
  648.  
  649.         popad
  650.         ret
  651.  
  652.  
  653. drawwindow_III:
  654.  
  655.         pushad
  656.  
  657.         mov   edi,edx                              ; RECTANGLE
  658.         mov   eax,[edi+0]
  659.         shl   eax,16
  660.         mov   ax,[edi+0]
  661.         add   ax,[edi+8]
  662.         mov   ebx,[edi+4]
  663.         shl   ebx,16
  664.         mov   bx,[edi+4]
  665.         add   bx,[edi+12]
  666.         mov   esi,[edi+24]
  667.         shr   esi,1
  668.         and   esi,0x007f7f7f
  669.         push  esi
  670.         call  draw_rectangle
  671.         mov   ecx,3
  672.       dw3l:
  673.         add   eax,1*65536-1
  674.         add   ebx,1*65536-1
  675.         mov   esi,[edi+24]
  676.         call  draw_rectangle
  677.         dec   ecx
  678.         jnz   dw3l
  679.         pop   esi
  680.         add   eax,1*65536-1
  681.         add   ebx,1*65536-1
  682.         call  draw_rectangle
  683.  
  684.         mov   ecx,[edx+20]                       ; GRAB BAR
  685.         push  ecx
  686.         mov   esi,edx
  687.         mov   edx,[esi+04]
  688.         add   edx,4
  689.         mov   ebx,[esi+04]
  690.         add   ebx,20
  691.         mov   eax,[esi+04]
  692.         add   eax,[esi+12]
  693.         cmp   ebx,eax
  694.         jb    wdsizeok2
  695.         mov   ebx,eax
  696.       wdsizeok2:
  697.         push  ebx
  698.       drwi2:
  699.         mov   ebx,edx
  700.         shl   ebx,16
  701.         add   ebx,edx
  702.         mov   eax,[esi+00]
  703.         shl   eax,16
  704.         add   eax,[esi+00]
  705.         add   eax,[esi+8]
  706.         add   eax,4*65536-4
  707.         mov   ecx,[esi+20]
  708.         test  ecx,0x40000000
  709.         jz    nofa3
  710.         add   ecx,0x040404
  711.       nofa3:
  712.         test  ecx,0x80000000
  713.         jz    nofa2
  714.         sub   ecx,0x040404
  715.       nofa2:
  716.         mov   [esi+20],ecx
  717.         and   ecx,0xffffff
  718.         xor   edi, edi
  719.         call  [draw_line]
  720.         inc   edx
  721.         cmp   edx,[esp]
  722.         jb    drwi2
  723.         add   esp,4
  724.         pop   ecx
  725.         mov   [esi+20],ecx
  726.  
  727.         mov   edx,[esi+04]                       ; WORK AREA
  728.         add   edx,21+5
  729.         mov   ebx,[esi+04]
  730.         add   ebx,[esi+12]
  731.         cmp   edx,ebx
  732.         jg    noinside2
  733.         mov   eax,5
  734.         mov   ebx,20
  735.         mov   ecx,[esi+8]
  736.         mov   edx,[esi+12]
  737.         sub   ecx,4
  738.         sub   edx,4
  739.         mov   edi,[esi+16]
  740.         call  [drawbar]
  741.       noinside2:
  742.  
  743.         popad
  744.  
  745.         ret
  746.  
  747.  
  748.  
  749. ; activate window
  750. align 4
  751. windowactivate:
  752.  
  753.         ; esi = abs mem position in stack 0xC400+
  754.  
  755.         pushad
  756.         push   esi
  757.       movzx   eax, word [esi] ; ax <- process no
  758.       movzx   eax, word [0xC000+eax*2] ; ax <- position in window stack
  759.  
  760.         xor   esi, esi        ; drop others
  761.       waloop:
  762.         cmp   esi, dword [0x3004]
  763.         jae   wacont
  764.         inc   esi
  765.         lea   edi, [0xC000 + esi*2]
  766.         mov   bx, [edi] ; position of the current process
  767.         cmp   bx, ax
  768.         jbe   @f
  769.         dec   bx       ; upper? => drop!
  770.         mov   [edi], bx
  771.       @@:
  772.         jmp   waloop
  773.       wacont:
  774.                             ; set to no 1
  775.         pop   esi           ;   esi = pointer at 0xC400
  776.  
  777.       movzx   eax, word [esi]
  778.         mov   bx, [0x3004]  ; number of processes
  779.         mov   [0xC000+eax*2], bx     ; this is the last (and the upper)
  780.  
  781. ;* start code - get active process (4) - Mario79
  782.         cli
  783.         cmp  [active_process_flag],1
  784.         jne  @f
  785.         mov   [active_process_flag],0
  786.         jmp   end_save_active_process
  787.     @@:
  788.         call save_active_process_stack
  789.     end_save_active_process:
  790.         mov  [active_process],eax
  791.         push  eax
  792.         mov   eax,[active_process]
  793.         shl   eax,5
  794.         add   eax,0x3000
  795.         mov   [eax-twdw+31],byte 1
  796.         pop   eax
  797.         sti
  798. ;* end code - get active process (4) - Mario79
  799.  
  800.         ; update on screen -window stack
  801.         xor   esi, esi
  802.       waloop2:
  803.         mov   edi, [0x3004]
  804.         cmp   esi, edi
  805.         jae   wacont2
  806.         inc   esi
  807.         movzx ebx, word [esi*2 + 0xC000]
  808.         mov   [ebx*2 + 0xC400], si
  809.         jmp   waloop2
  810.       wacont2:
  811.         mov   [0xf400], byte 0           ; empty keyboard buffer
  812.         mov   [0xf500], byte 0           ; empty button buffer
  813.         popad
  814.         ret
  815.  
  816.  
  817. ; check if window is necessary to draw
  818.  
  819. checkwindowdraw:
  820.  
  821.         ; edi = position in window_data+
  822.  
  823.         mov   esi, edi
  824.         sub   esi, window_data
  825.         shr   esi, 5
  826.  
  827.         ; esi = process number
  828.  
  829. ; <IP 15.08.2004>
  830.         movzx eax, word [0xC000 + esi * 2] ; get value of the curr process
  831.         lea   esi, [0xC400 + eax * 2]      ; get address of this process at 0xC400
  832. ; </IP 15.08.2004>
  833.  
  834.         push  esi
  835.  
  836.       .new_check:
  837.  
  838.         pop   esi
  839.         add   esi, 2
  840.         push  esi
  841.  
  842.         mov   eax, [0x3004]
  843.         lea   eax, word [0xC400 + eax * 2] ; number of the upper window
  844.  
  845.         cmp   esi, eax
  846.         ja    .all_wnds_to_top
  847.  
  848.         movzx eax, word [esi]
  849.         shl   eax, 5
  850.         add   eax, window_data
  851.         mov   esi, eax
  852.  
  853.         mov   ebx, [edi+4]
  854.         mov   edx, [edi+12]
  855.         add   edx, ebx
  856.  
  857.         mov   ecx, [esi+4]    ; y check
  858.         cmp   ecx, edx
  859.         jae   .new_check
  860.         mov   eax, [esi+12]
  861.         add   ecx, eax
  862.         cmp   ebx, ecx
  863.         ja    .new_check
  864.  
  865.         mov   eax, [edi+0]
  866.         mov   ecx, [edi+8]
  867.         add   ecx, eax
  868.  
  869.         mov   edx, [esi+0]    ; x check
  870.         cmp   edx, ecx
  871.         jae   .new_check
  872.         mov   ecx, [esi+8]
  873.         add   edx, ecx
  874.         cmp   eax, edx
  875.         ja    .new_check
  876.  
  877.         pop   esi
  878.         mov   ecx,1   ; overlap some window
  879.         ret
  880.  
  881.   .all_wnds_to_top:
  882.  
  883.         pop   esi
  884.  
  885.         xor   ecx, ecx       ; passed all windows to top
  886.         ret
  887.  
  888.  
  889.  
  890.  
  891. waredraw:     ; if redraw necessary at activate
  892.  
  893.         pushad
  894.  
  895.         call  checkwindowdraw      ; draw window on activation ?
  896.         test  ecx, ecx
  897.         jz    .do_not_draw
  898.  
  899.         popad
  900.         mov   [0xfb44], byte 1     ; do draw mouse
  901.         call  windowactivate
  902.  
  903.         ; update screen info
  904.         pushad
  905.         mov   edi, [0x3004] ; the last process (number)
  906.         movzx esi, word [0xC400 + edi * 2]
  907.         shl   esi, 5
  908.         add   esi, window_data
  909.  
  910.         ; coordinates of the upper window
  911.         mov   eax, [esi+00] ; cx
  912.         mov   ebx, [esi+04] ; cy
  913.         mov   ecx, [esi+08] ; sx
  914.         mov   edx, [esi+12] ; sy
  915.  
  916.         add   ecx, eax       ; ecx = x_end
  917.         add   edx, ebx       ; edx = y_end
  918.  
  919.         mov   edi, [0x3004]
  920.         movzx esi, word [0xC400 + edi * 2]
  921.         shl   esi, 5
  922.         movzx esi, byte [esi + 0x3000 + 0xE]
  923.         call  setscreen ;;;calculatescreen ; setscreen
  924.         popad
  925.  
  926.         cmp   [0xff01], dword 1 ; if > 1 then activate process
  927.         jbe   .not_activate
  928.  
  929. ;;;        mov   eax, 10            ; wait for putimages to finish
  930. ;;;        call  delay_hs
  931.  
  932.         mov   [edi+31],byte 1  ; redraw flag for app
  933.         mov   [0xfb44],byte 0  ; mouse down checks
  934.  
  935.         ret
  936.  
  937.      .not_activate:
  938.  
  939. ;        mov   eax,5            ; wait for putimages to finish
  940. ;        call  delay_hs
  941.  
  942.         mov   [edi+31],byte 1  ; redraw flag for app
  943.  
  944.         mov   ecx, 25 ;100
  945.      .waitflagdown:
  946.         dec   ecx
  947.         jz    .nowait
  948. ;        mov   eax, 2
  949. ;        call  delay_hs
  950.         cmp   [edi+31], byte 0 ; wait flag to drop
  951.         jnz   .waitflagdown
  952.       .nowait:
  953.  
  954. ;        mov   ecx,10
  955. ;      .wait:
  956. ;        mov   eax,1           ; wait for draw to finish
  957. ;        call  delay_hs
  958. ;        loop  .wait
  959.  
  960.         mov   [0xfb44],byte 0
  961.  
  962.         ret
  963.  
  964.      .do_not_draw:
  965.  
  966.         popad
  967.  
  968.         call  windowactivate
  969.         mov   [0xfb44],byte 0  ; mouse down checks
  970.         mov   [0xfff4],byte 0  ; no mouse background
  971.         mov   [0xfff5],byte 0  ; draw mouse
  972.         ret
  973.  
  974.  
  975. iglobal
  976.   window_moving   db 'K : Window - move/resize',13,10,0
  977.   window_moved    db 'K : Window - done',13,10,0
  978. endg
  979.  
  980. ; check window touch
  981. align 4
  982. checkwindows:
  983.         pushad
  984.  
  985.         cmp  [0xff01],dword 1  ; activate request from app ?
  986.         jbe  .no_activate_request
  987.         mov  edi,[0xff01]     ; process number
  988.         shl  edi,5
  989.         add  edi,window_data
  990.         mov  ebx,[0xff01]
  991.         movzx esi, word [0xC000 + ebx * 2]
  992.         lea  esi, [0xC400 + esi * 2]
  993.         call waredraw
  994.  
  995. ;* start code - get active process (2) - Mario79
  996. ;        mov  eax,[0xff01]
  997. ;        mov  [active_process],eax
  998. ;* end code - get active process  (2) - Mario79
  999.  
  1000.         mov  [0xff01],dword 0  ; activated
  1001.  
  1002.         popad
  1003.         ret
  1004.  
  1005.     .no_activate_request:
  1006.    
  1007.         cmp   [0xfb40],byte 0    ; mouse buttons pressed ?
  1008.         jne   .mouse_buttons_pressed
  1009. ;        cmp   [window_minimize],2
  1010. ;        jne   .no_activate_request_1
  1011.         cmp   [window_minimize],0
  1012.         je   .no_activate_request_2
  1013.         cmp   [window_minimize],1
  1014.         je    .mouse_buttons_pressed
  1015.         mov   esi,[0x3004]
  1016.         movzx edi, word [0xC400 + esi * 2]
  1017.         shl   edi, 5
  1018.         add   edi, window_data
  1019.         test    [edi+WDATA.fl_wstate],WSTATE_MINIMIZED
  1020.         jnz     .mouse_buttons_pressed
  1021. ;        jne   .no_activate_request_2
  1022. ;    .no_activate_request_1:
  1023. ;        cmp   [window_minimize],1
  1024. ;        jge   .mouse_buttons_pressed
  1025. ;        jmp   .mouse_buttons_pressed
  1026.     .no_activate_request_2:
  1027.         mov   [window_minimize],0
  1028.         popad
  1029.         ret
  1030.  
  1031.     .mouse_buttons_pressed:
  1032.  
  1033.         mov   esi,[0x3004]
  1034.         inc   esi
  1035.  
  1036.       cwloop:
  1037.         cmp   esi,2
  1038.         jb   .exit
  1039.         .temp_window_minimize_1:
  1040.         dec   esi
  1041.         movzx edi, word [0xC400 + esi * 2] ; ebx
  1042.         shl   edi, 5
  1043.         add   edi, window_data
  1044. ;        mov   edi, ebx
  1045.         mov   ecx, [edi+0]
  1046.         mov   edx, [edi+4]
  1047.  
  1048.         mov   eax,ecx
  1049.         mov   ebx,edx
  1050.        cmp   [window_minimize],1
  1051.        jge   .window_minimize_no_check_mouse
  1052.         test    [edi+WDATA.fl_wstate],WSTATE_MINIMIZED
  1053.         jnz     cwloop
  1054.  
  1055.        movzx  eax, word [0xfb0a]
  1056.        movzx  ebx, word [0xfb0c]
  1057.        
  1058.         cmp   ecx, eax
  1059.         jae   cwloop
  1060.         cmp   edx, ebx
  1061.         jae   cwloop
  1062.         add   ecx, [edi+8]
  1063.         add   edx, [edi+12]
  1064.         cmp   eax, ecx
  1065.         jae   cwloop
  1066.         cmp   ebx, edx
  1067.         jae   cwloop
  1068.  
  1069.       .window_minimize_no_check_mouse:
  1070.  
  1071.         pushad
  1072.         mov   eax, esi
  1073.         mov   ebx, [0x3004]
  1074.         cmp   eax, ebx      ; is this window active?
  1075.         jz    .move_resize_window
  1076.  
  1077.         ; eax = position in windowing stack
  1078.         ; redraw must ?
  1079.         lea   esi, [0xC400 + esi * 2]
  1080.         call  waredraw
  1081.         add   esp, 32
  1082.  
  1083.       .exit:
  1084.         popad
  1085.         ret
  1086.  
  1087.    .move_resize_window:    ; MOVE OR RESIZE WINDOW
  1088.  
  1089.         popad
  1090.  
  1091.         ; Check for user enabled fixed window
  1092.         mov   edx, [edi+0x14]
  1093.         and   edx, 0x0f000000
  1094.         cmp   edx, 0x01000000
  1095.         jne   .window_move_enabled_for_user
  1096.         popad
  1097.         ret
  1098.       .window_move_enabled_for_user:
  1099.  
  1100.         test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
  1101.         jnz     .no_resize_2
  1102.  
  1103.         mov   [do_resize_from_corner],byte 0   ; resize for skinned window
  1104.         mov   edx, [edi+0x10]
  1105.         and   edx, 0x0f000000
  1106.         cmp   edx, 0x02000000
  1107.         jb    .no_resize_2 ; not type 2 wnd
  1108.  
  1109.         mov   edx, [edi+4]
  1110.         add   edx, [edi+12]
  1111.         sub   edx, 6       ; edx = y_end - 6
  1112.         cmp   ebx, edx     ; ebx = mouse_y
  1113.         jb    .no_resize_2
  1114.         mov   [do_resize_from_corner],byte 1
  1115.         jmp   .continue
  1116.       .no_resize_2:
  1117.  
  1118.         push    eax
  1119.         call    get_titlebar_height
  1120.         add     eax,[edi+4]
  1121.         cmp     ebx,eax
  1122.         pop     eax
  1123.         jae     .exit
  1124.  
  1125.      .continue:
  1126.  
  1127.         push  esi
  1128.         mov   esi, window_moving
  1129.         call  sys_msg_board_str
  1130.         pop   esi
  1131.  
  1132.         mov   ecx, [timer_ticks] ;[0xfdf0]    ; double-click ?
  1133.         mov   edx, ecx
  1134.         sub   edx, [latest_window_touch]
  1135.         mov   [latest_window_touch], ecx
  1136.         mov   [latest_window_touch_delta], edx
  1137.  
  1138.         mov   cl, [0xfb40]     ; save for shade check
  1139.         mov   [do_resize], cl
  1140.      no_emulation_righ_button:
  1141.         mov   ecx, [edi+0]
  1142.         mov   edx, [edi+4]
  1143.  
  1144.         push  eax ecx edx
  1145.         mov   [dlx], ecx      ; save for drawlimits
  1146.         mov   [dly], edx
  1147.         mov   eax, [edi+8]
  1148.         add   ecx, eax
  1149.         mov   eax, [edi+12]
  1150.         add   edx, eax
  1151.         mov   [dlxe], ecx
  1152.         mov   [dlye], edx
  1153.         pop   edx ecx eax
  1154.  
  1155.         sub   eax, ecx
  1156.         sub   ebx, edx
  1157.  
  1158.         mov   esi, [0xfb0a]
  1159.         mov   [0xf300], esi
  1160.  
  1161.         pushad           ; wait for putimages to finish
  1162. ;        mov   eax,5
  1163. ;        call  delay_hs
  1164.         mov   eax,[edi+0]
  1165.         mov   [npx],eax
  1166.         mov   eax,[edi+4]
  1167.         mov   [npy],eax
  1168.         popad
  1169.  
  1170.         push eax                  ; save old coordinates
  1171.         mov   ax,[edi+00]
  1172.         mov   word [oldc+00],ax
  1173.         mov   ax,[edi+04]
  1174.         mov   word [oldc+04],ax
  1175.         mov   ax,[edi+8]
  1176.         mov   word [oldc+8],ax
  1177.         mov   word [npxe],ax
  1178.         mov   ax,[edi+12]
  1179.         mov   word [oldc+12],ax
  1180.         mov   word [npye],ax
  1181.         pop eax
  1182.  
  1183.         test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  1184.         jnz     @f
  1185.         call  drawwindowframes
  1186.     @@:
  1187.  
  1188.         mov   [reposition],0
  1189.         mov   [0xfb44],byte 1   ; no reaction to mouse up/down
  1190.  
  1191.         ; move window
  1192.  
  1193.       newchm:
  1194.  
  1195.         mov   [0xfff5],byte 1
  1196.  
  1197.         call  checkidle
  1198.  
  1199.         call  checkEgaCga
  1200.  
  1201.         mov   [0xfff4],byte 0
  1202.  
  1203.         call  [draw_pointer]
  1204.  
  1205.         pushad
  1206.         call   stack_handler
  1207.         popad
  1208.  
  1209.         mov   esi,[0xf300]
  1210.         cmp   esi,[0xfb0a]
  1211.         je    cwb
  1212.  
  1213.         mov   cx,[0xfb0a]
  1214.         mov   dx,[0xfb0c]
  1215.         sub   cx,ax
  1216.         sub   dx,bx
  1217.  
  1218.         push  ax
  1219.         push  bx
  1220.  
  1221.         test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  1222.         jnz     @f
  1223.         call  drawwindowframes
  1224.     @@:
  1225.  
  1226.         mov   ax,[0xfe00]
  1227.         mov   bx,[0xfe04]
  1228.  
  1229.         cmp   [do_resize_from_corner],1
  1230.         je    no_new_position
  1231.  
  1232.         mov   word [npx],word 0     ; x repos ?
  1233.         cmp   ax,cx
  1234.         jb    noreposx
  1235.         mov   [reposition],1
  1236.         sub   ax,word [npxe]
  1237.         mov   word [npx],ax
  1238.         cmp   ax,cx
  1239.         jb    noreposx
  1240.         mov   word [npx],cx
  1241.       noreposx:
  1242.  
  1243.         mov   word [npy],word 0     ; y repos ?
  1244.         cmp   bx,dx
  1245.         jb    noreposy
  1246.         mov   [reposition],1
  1247.         sub   bx,word [npye]
  1248.         mov   word [npy],bx
  1249.         cmp   bx,dx
  1250.         jb    noreposy
  1251.         mov   word [npy],dx
  1252.       noreposy:
  1253.  
  1254.       no_new_position:
  1255.  
  1256.         cmp   [do_resize_from_corner],0    ; resize from right corner
  1257.         je    norepos_size
  1258.         pushad
  1259.  
  1260.         mov   edx,edi
  1261.         sub   edx,window_data
  1262.         shr   edx,5
  1263.         shl   edx,8
  1264.         add   edx,0x80000                 ; process base at 0x80000+
  1265.  
  1266.         movzx eax,word [0xfb0a]
  1267.         cmp   eax,[edi+0]
  1268.         jb    nnepx
  1269.         sub   eax,[edi+0]
  1270.         cmp   eax,[edx+0x90+8]
  1271.         jge   nnepx2
  1272.         mov   eax,[edx+0x90+8]
  1273.       nnepx2:
  1274.         mov   [npxe],eax
  1275.       nnepx:
  1276.  
  1277.         call    get_titlebar_height
  1278.         mov     ebx,eax
  1279.         movzx eax,word [0xfb0c]
  1280.         cmp   eax,[edi+4]
  1281.         jb    nnepy
  1282.         sub   eax,[edi+4]
  1283.         cmp     eax,ebx ; [edx+0x90+12]
  1284.         jge     nnepy2
  1285.         mov     eax,ebx ; [edx+0x90+12]
  1286.       nnepy2:
  1287.         mov   [npye],eax
  1288.       nnepy:
  1289.  
  1290.         mov   [reposition],1
  1291.  
  1292.         popad
  1293.       norepos_size:
  1294.  
  1295.         pop   bx
  1296.         pop   ax
  1297.         test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  1298.         jnz     @f
  1299.         call  drawwindowframes
  1300.     @@:
  1301.  
  1302.         mov   esi,[0xfb0a]
  1303.         mov   [0xf300],esi
  1304.  
  1305.       cwb:
  1306.         cmp   [0xfb40],byte 0
  1307.         jne   newchm
  1308.                                      ; new position done
  1309.         mov     [0xfff5],byte 1
  1310.         mov     cl,0
  1311.         test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  1312.         jnz     @f
  1313.         mov     cl,[reposition]
  1314.         call    drawwindowframes
  1315.  
  1316.         mov   eax,[npx]
  1317.         mov   [edi+0],eax
  1318.         mov   eax,[npy]
  1319.         mov   [edi+4],eax
  1320.         mov   eax,[npxe]
  1321.         mov   [edi+8],eax
  1322.         mov   eax,[npye]
  1323.         mov   [edi+12],eax
  1324.  
  1325.     @@: mov     [reposition],cl
  1326.  
  1327.         cmp   [reposition],1         ; save new X and Y start
  1328.         jne   no_xy_save
  1329.         ; <IP 28.08.2004>
  1330.         push  esi edi ecx
  1331.         mov   esi,edi
  1332.         sub   edi,window_data
  1333.         shr   edi,5
  1334.         shl   edi,8
  1335.         add   edi,0x80000+0x90
  1336.         mov   ecx,2
  1337.         cld
  1338.         rep   movsd
  1339.         pop   ecx edi esi
  1340.         ; </IP 28.08.2004>
  1341.       no_xy_save:
  1342.  
  1343.         pushad                             ; WINDOW SHADE/FULLSCREEN
  1344.  
  1345.         cmp   [reposition],1
  1346.         je    no_window_sizing
  1347.         mov   edx,edi
  1348.         sub   edx,window_data
  1349.         shr   edx,5
  1350.         shl   edx,8
  1351.         add   edx,0x80000                 ; process base at 0x80000+
  1352.  
  1353.         cmp     [window_minimize],0
  1354.         je      no_wnd_minimize_restore
  1355.         mov     [reposition],1
  1356.   wnd_minimize:
  1357.         cmp     [window_minimize],1
  1358.         jne     wnd_restore
  1359.         or      [edi+WDATA.fl_wstate],WSTATE_MINIMIZED
  1360.         jmp     no_wnd_minimize_restore
  1361.   wnd_restore:
  1362.         cmp     [window_minimize],2
  1363.         jne     no_wnd_minimize_restore
  1364.         and     [edi+WDATA.fl_wstate],not WSTATE_MINIMIZED
  1365.   no_wnd_minimize_restore:
  1366.  
  1367.  
  1368.         cmp   [do_resize],2               ; window shade ?
  1369.         jne   no_window_shade
  1370.         mov   [reposition],1
  1371.  
  1372.         test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
  1373.         jnz     wnd_rolldown
  1374.   wnd_rollup:
  1375.         or      [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
  1376.         call    get_rolledup_height
  1377.         jmp     @f
  1378.   wnd_rolldown:
  1379.         and     [edi+WDATA.fl_wstate],not WSTATE_ROLLEDUP
  1380.         mov     eax,[edx+0x90+BOX.height]
  1381.         test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  1382.         jz      @f
  1383.         mov     eax,[screen_workarea.bottom]
  1384.         sub     eax,[screen_workarea.top]
  1385.     @@: mov     [edi+WDATA.height],eax
  1386.  
  1387.       no_window_shade:
  1388.  
  1389.         cmp   [do_resize],1               ; fullscreen/restore ?
  1390.         jne   no_fullscreen_restore
  1391.         cmp   [latest_window_touch_delta],dword 50
  1392.         jg    no_fullscreen_restore
  1393.         mov   [reposition],1
  1394.         test    [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  1395.         jnz     restore_from_fullscreen
  1396.         or      [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
  1397.         mov     eax,[screen_workarea.left]
  1398.         mov     [edi+WDATA.left],eax
  1399.         sub     eax,[screen_workarea.right]
  1400.         neg     eax
  1401.         mov     [edi+WDATA.width],eax
  1402.         mov     eax,[screen_workarea.top]
  1403.         mov     [edi+WDATA.top],eax
  1404.         test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
  1405.         jnz     @f
  1406.         sub     eax,[screen_workarea.bottom]
  1407.         neg     eax
  1408.         mov     [edi+WDATA.height],eax
  1409.     @@:
  1410.         jmp   no_fullscreen_restore
  1411.       restore_from_fullscreen:
  1412.         and     [edi+WDATA.fl_wstate],not WSTATE_MAXIMIZED
  1413.         push    [edi+WDATA.height]
  1414.         push  edi                         ; restore
  1415.         lea   esi, [edx + 0x90]
  1416.         mov   ecx,4
  1417.         cld
  1418.         rep   movsd
  1419.         pop   edi
  1420.         pop     eax
  1421.         test    [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
  1422.         jz      @f
  1423.         mov     [edi+WDATA.height],eax
  1424.     @@:
  1425.  
  1426.       no_fullscreen_restore:
  1427.  
  1428.         mov   eax,[edi+4]                 ; check Y inside screen
  1429.         add   eax,[edi+12]
  1430.         cmp   eax,[0xfe04]
  1431.         jbe   no_window_sizing
  1432.         mov   eax,[edi+0]                 ; check X inside screen
  1433.         add   eax,[edi+8]
  1434.         cmp   eax,[0xfe00]
  1435.         jbe   no_window_sizing
  1436.         mov   eax,[0xfe00]
  1437.         sub   eax,[edi+8]
  1438.         mov   [edi+0],eax
  1439.         mov   eax,[0xfe04]
  1440.         sub   eax,[edi+12]
  1441.         mov   [edi+4],eax
  1442.       no_window_sizing:
  1443.  
  1444.         popad
  1445.  
  1446.         cmp   [reposition],0
  1447.         je    retwm
  1448.  
  1449.         pushad
  1450.         mov   eax,[edi+00]
  1451.         mov   ebx,[edi+04]
  1452.         mov   ecx,[edi+8]
  1453.         mov   edx,[edi+12]
  1454.         add   ecx,eax
  1455.         add   edx,ebx
  1456.         mov   edi,[0x3004]
  1457.         shl   edi,1
  1458.         add   edi,0xc400
  1459.         movzx esi,byte [edi]
  1460.         shl   esi,5
  1461.         add   esi,0x3000+0xe
  1462.         movzx esi,byte [esi]
  1463.  
  1464.         sub   edi,draw_data
  1465.         shr   edi,5
  1466.         shl   edi,8
  1467.         add   edi,0x80000+0x80
  1468.         ;cmp   [edi],dword 0
  1469.         ;jne   no_rect_shaped_move
  1470.         call  setscreen
  1471.         jmp   move_calculated
  1472.       no_rect_shaped_move:
  1473.         call  calculatescreen
  1474.       move_calculated:
  1475.  
  1476.         popad
  1477.  
  1478.         mov     [edi+WDATA.fl_redraw],1
  1479.         mov   [0xfff5],byte 1 ; no mouse
  1480.  
  1481.         push  eax ebx ecx edx
  1482.         mov   eax,[oldc+00]
  1483.         mov   ebx,[oldc+04]
  1484.         mov   ecx,[oldc+8]
  1485.         mov   edx,[oldc+12]
  1486.         add   ecx,eax
  1487.         add   edx,ebx
  1488.         call  calculatescreen
  1489.         pop   edx ecx ebx eax
  1490.  
  1491.         mov   eax,edi
  1492.         call  redrawscreen
  1493.  
  1494.         mov   ecx,100         ; wait to avoid mouse residuals
  1495.       waitre2:
  1496.         mov   [0xfff5],byte 1
  1497.         call  checkidle
  1498.         cmp     [edi+WDATA.fl_redraw],0
  1499.         jz    retwm
  1500.         loop  waitre2
  1501.  
  1502.       retwm:
  1503.  
  1504.         mov   [0xfff5],byte 0 ; mouse pointer
  1505.         mov   [0xfff4],byte 0 ; no mouse under
  1506.         mov   [0xfb44],byte 0 ; react to mouse up/down
  1507.  
  1508.         mov    esi,window_moved
  1509.         call   sys_msg_board_str
  1510.  
  1511.         popad
  1512.  
  1513.        mov   [window_minimize],0
  1514. ;        sti
  1515.         ret
  1516.  
  1517. ;temp_mouse_1 dw 0
  1518. ;temp_mouse_2 dw 0
  1519.  
  1520. uglobal
  1521.   add_window_data            dd  0
  1522.   do_resize_from_corner      db  0x0
  1523.   reposition                 db  0x0
  1524.   latest_window_touch        dd  0x0
  1525.   latest_window_touch_delta  dd  0x0
  1526.  
  1527.   do_resize db 0x0
  1528.  
  1529.   oldc    dd 0x0,0x0,0x0,0x0
  1530.  
  1531.   dlx     dd 0x0
  1532.   dly     dd 0x0
  1533.   dlxe    dd 0x0
  1534.   dlye    dd 0x0
  1535.  
  1536.   npx     dd 0x0
  1537.   npy     dd 0x0
  1538.   npxe    dd 0x0
  1539.   npye    dd 0x0
  1540.  
  1541.   mpx     dd 0x0
  1542.   mpy     dd 0x0
  1543. endg
  1544.  
  1545.  
  1546. ; draw negative window frames
  1547.  
  1548. drawwindowframes:
  1549.  
  1550.         pushad
  1551.  
  1552.         mov   eax,[npx]
  1553.         shl   eax,16
  1554.         add   eax,[npx]
  1555.         add   eax,[npxe]
  1556.         add   eax,65536*1-1
  1557.         mov   ebx,[npy]
  1558.         shl   ebx,16
  1559.         add   ebx,[npy]
  1560.         mov   ecx,0x01000000
  1561.         push  edi
  1562.         mov   edi,1
  1563.         call  [draw_line]
  1564.         pop   edi
  1565.  
  1566.         mov   eax,[npx]
  1567.         shl   eax,16
  1568.         add   eax,[npx]
  1569.         add   eax,[npxe]
  1570.         add   eax,65536*1-1
  1571.         mov   ebx,[npy]
  1572.         add   ebx,[npye]
  1573.         shl   ebx,16
  1574.         add   ebx,[npy]
  1575.         add   ebx,[npye]
  1576.         mov   ecx,0x01000000
  1577.         push  edi
  1578.         mov   edi,1
  1579.         call  [draw_line]
  1580.         pop   edi
  1581.  
  1582.         mov   eax,[npx]
  1583.         shl   eax,16
  1584.         add   eax,[npx]
  1585.         mov   ebx,[npy]
  1586.         shl   ebx,16
  1587.         add   ebx,[npy]
  1588.         add   ebx,[npye]
  1589.         mov   ecx,0x01000000
  1590.         push  edi
  1591.         mov   edi,1
  1592.         call  [draw_line]
  1593.         pop   edi
  1594.  
  1595.         mov   eax,[npx]
  1596.         add   eax,[npxe]
  1597.         shl   eax,16
  1598.         add   eax,[npx]
  1599.         add   eax,[npxe]
  1600.         mov   ebx,[npy]
  1601.         shl   ebx,16
  1602.         add   ebx,[npy]
  1603.         add   ebx,[npye]
  1604.         mov   ecx,0x01000000
  1605.         push  edi
  1606.         mov   edi,1
  1607.         call  [draw_line]
  1608.         mov   edi,[0x3000]
  1609.         shl   edi,5
  1610.         add   edi,window_data
  1611.         mov   [edi+30],byte 1
  1612.         pop   edi
  1613.  
  1614.         popad
  1615.  
  1616.         ret
  1617.  
  1618.  
  1619.  
  1620. random_shaped_window:
  1621.  
  1622. ;
  1623. ;  eax = 0    giving address of data area
  1624. ;      ebx    address
  1625. ;  ebx = 1    shape area scale
  1626. ;      ebx    2^ebx scale
  1627.  
  1628.      test eax, eax
  1629.      jne  rsw_no_address
  1630.      mov  eax,[0x3000]
  1631.      shl  eax,8
  1632.  
  1633.      mov  [eax+0x80000+0x80],ebx
  1634.    rsw_no_address:
  1635.  
  1636.      cmp  eax,1
  1637.      jne  rsw_no_scale
  1638.      mov  eax,[0x3000]
  1639.      shl  eax,8
  1640.      mov  [eax+0x80000+0x84],bl
  1641.    rsw_no_scale:
  1642.  
  1643.      ret
  1644.  
  1645.  
  1646.