Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;    MAGNIFY SCREEN
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6.  
  7. use32
  8.  
  9.                 org     0x0
  10.  
  11.                 db      'MENUET00'              ; 8 byte id
  12.                 dd      38                      ; required os
  13.                 dd      START                   ; program start
  14.                 dd      I_END                   ; program image size
  15.                 dd      0x10000                ; required amount of memory
  16.                 dd      0x10000
  17.                 dd      0x00000000              ; reserved=no extended header
  18.  
  19. include 'lang.inc'
  20. include 'macros.inc'
  21. scr     equ     0x1000
  22.  
  23.  
  24. START:                          ; start of execution
  25.  
  26.     mov  esp,0xfff0
  27.  
  28.     mov  eax,14                 ; get screen size
  29.     int  0x40
  30.     push eax
  31.     and  eax,0x0000ffff
  32.     add  eax,1
  33.     mov  [size_y],eax
  34.     pop  eax
  35.     shr  eax,16
  36.     add  eax,1
  37.     mov  [size_x],eax
  38.  
  39.     mov  eax,[size_x]
  40.     shr  eax,2
  41.     mov  [cmp_ecx],eax
  42.  
  43.     mov  eax,[size_x]
  44.     xor  edx,edx
  45.     mov  ebx,3
  46.     mul  ebx
  47.     mov  [add_esi],eax
  48.  
  49.     mov  eax,[size_y]
  50.     shr  eax,2
  51.     mov  [cmp_edx],eax
  52.  
  53.  
  54.  
  55.     call draw_window            ; at first, draw the window
  56.  
  57. still:
  58.  
  59.     call draw_screen
  60.  
  61.     mov  eax,23                 ; wait here for event with timeout
  62.     mov  ebx,[delay]
  63.     int  0x40
  64.  
  65.     cmp  eax,1                  ; redraw request ?
  66.     jz   red
  67.     cmp  eax,2                  ; key in buffer ?
  68.     jz   key
  69.     cmp  eax,3                  ; button in buffer ?
  70.     jz   button
  71.  
  72.     jmp  still
  73.  
  74.   red:                          ; redraw
  75.     call draw_window
  76.     jmp  still
  77.  
  78.   key:                          ; key
  79.     mov  eax,2                  ; just read it and ignore
  80.     int  0x40
  81.     jmp  still
  82.  
  83.   button:                       ; button
  84.     mov  eax,17                 ; get id
  85.     int  0x40
  86.  
  87.     cmp  ah,1                   ; button id=1 ?
  88.     jnz  noclose
  89.     mov  eax,0xffffffff         ; close this program
  90.     int  0x40
  91.   noclose:
  92.  
  93.     cmp  ah,2
  94.     jnz  nosave
  95.     call save_screen
  96.   nosave:
  97.  
  98.     jmp  still
  99.  
  100.  
  101.  
  102. save_screen:
  103.  
  104.      pusha
  105.  
  106.      mov  ebx,0
  107.      mov  edi,0x10000
  108.  
  109.    ss1:
  110.  
  111.      mov  eax,35
  112.      int  0x40
  113.  
  114.      add  ebx,1
  115.  
  116.      mov  [edi],eax
  117.      add  edi,3
  118.  
  119.      cmp  edi,0xFFFF0
  120.      jb   ss1
  121.  
  122.      mov  eax,33
  123.      mov  ebx,filename
  124.      mov  ecx,0x10000
  125.      mov  edx,0xEFFF0
  126.      mov  esi,0
  127.      int  0x40
  128.  
  129.      popa
  130.  
  131.      ret
  132.  
  133.  
  134. filename  db  'SCREEN  RAW'
  135.  
  136. ;   *********************************************
  137. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  138. ;   *********************************************
  139.  
  140.  
  141. draw_window:
  142.  
  143.     mov  eax,12                    ; function 12:tell os about windowdraw
  144.     mov  ebx,1                     ; 1, start of draw
  145.     int  0x40
  146.  
  147.                                    ; DRAW WINDOW
  148.     mov  eax,0                     ; function 0 : define and draw window
  149.     mov  ebx,100*65536             ; [x start] *65536 + [x size]
  150.     mov  ebx,100*65536+322
  151.     mov  ecx,100*65536+262         ; [y start] *65536 + [y size]
  152.     mov  edx,0x0;01111cc            ; color of work area RRGGBB
  153.     mov  esi,0x809977ff            ; color of grab bar  RRGGBB,8->color glide
  154.     mov  edi,0x00ffff00            ; color of frames    RRGGBB
  155.     int  0x40
  156.  
  157.                                    ; WINDOW LABEL
  158.     mov  eax,4                     ; function 4 : write text to window
  159.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  160.     mov  ecx,0x00ffffff            ; color of text RRGGBB
  161.     mov  edx,labelt                ; pointer to text beginning
  162.     mov  esi,labellen-labelt       ; text length
  163.     int  0x40
  164.  
  165.                                    ; CLOSE BUTTON
  166.     mov  eax,8                     ; function 8 : define and draw button
  167.     mov  bx,12                     ; [x start] *65536 + [x size]
  168.     mov  ebx,(322-19)*65536+12
  169.     mov  ecx,5*65536+12            ; [y start] *65536 + [y size]
  170.     mov  edx,1                     ; button id
  171.     mov  esi,0x22aacc              ; button color RRGGBB
  172.     int  0x40
  173.  
  174.     call draw_screen
  175.  
  176.     mov  eax,12                    ; function 12:tell os about windowdraw
  177.     mov  ebx,2                     ; 2, end of draw
  178.     int  0x40
  179.  
  180.     ret
  181.  
  182.  
  183. draw_screen:
  184.  
  185.     call draw_magnify
  186.  
  187.     ret
  188.  
  189.     pusha
  190.  
  191.     mov  edi,scr
  192.  
  193.     mov  ecx,0
  194.     mov  edx,0
  195.  
  196.     mov  esi,0
  197.  
  198.   ds1:
  199.  
  200.     mov  eax,35
  201.     mov  ebx,esi
  202.     int  0x40
  203.     stosd
  204.     sub  edi,1
  205.  
  206.     add  esi,4
  207.     add  ecx,1
  208.     cmp  ecx,[cmp_ecx] ; 800/4
  209.     jb   ds1
  210.  
  211.     add  esi,[add_esi] ; 800*3
  212.     mov  ecx,0
  213.     add  edx,1
  214.     cmp  edx,[cmp_edx] ; 600/4
  215.     jb   ds1
  216.  
  217.     mov  eax,7
  218.     mov  ebx,scr
  219.     mov  ecx,200*65536+160
  220.     mov  ecx,[size_x]
  221.     shr  ecx,2
  222.     shl  ecx,16
  223.     mov  cx,word [size_y]
  224.     shr  cx,2
  225.     mov  edx,20*65536+35
  226.     int  0x40
  227.  
  228.     popa
  229.  
  230.     call draw_magnify
  231.  
  232.     ret
  233.  
  234.  
  235. draw_magnify:
  236.  
  237.     pusha
  238.  
  239.     mov  eax,37
  240.     mov  ebx,0
  241.     int  0x40
  242.  
  243.     mov  ecx,eax
  244.     mov  edx,eax
  245.     shr  ecx,16
  246.     and  edx,65535
  247.  
  248.     sub  ecx,39
  249.     sub  edx,29
  250.  
  251.     cmp  ecx,3000
  252.     jb   co1
  253.     popa
  254.     ret
  255.   co1:
  256.     cmp  edx,3000
  257.     jb   co2
  258.     popa
  259.     ret
  260.  
  261.   co2:
  262.  
  263.     and  ecx,2047
  264.     and  edx,2047
  265.  
  266.     mov  [m_x],ecx
  267.     mov  [m_y],edx
  268.  
  269.     add  ecx,40
  270.     add  edx,30
  271.  
  272.     mov  [m_xe],ecx
  273.     mov  [m_ye],edx
  274.  
  275.     mov  ecx,[m_x]
  276.     mov  edx,[m_y]
  277.  
  278.   dm1:
  279.  
  280.     push edx
  281.     mov  eax,edx
  282.     mul  [size_x]
  283.     pop  edx
  284.     add  eax,ecx
  285.  
  286.     mov  ebx,eax
  287.     mov  eax,35
  288.     int  0x40
  289.  
  290.     pusha
  291.     mov  ebx,ecx
  292.     sub  ebx,[m_x]
  293.     mov  ecx,edx
  294.     sub  ecx,[m_y]
  295.     shl  ebx,3
  296.     add  ebx,2
  297.     shl  ebx,16
  298.     mov  bx,7
  299.     shl  ecx,3
  300.     add  ecx,22
  301.     shl  ecx,16
  302.     mov  cx,7
  303.  
  304.     mov  edx,eax
  305.     mov  eax,13
  306.     int  0x40
  307.     popa
  308.  
  309.     add  ecx,1
  310.     cmp  ecx,[m_xe]
  311.     jnz  dm1
  312.     mov  ecx,[m_x]
  313.     add  edx,1
  314.     cmp  edx,[m_ye]
  315.     jnz  dm1
  316.  
  317.     popa
  318.  
  319.     ret
  320.  
  321.  
  322.  
  323. ; DATA AREA
  324.  
  325. m_x      dd  100
  326. m_y      dd  100
  327.  
  328. m_xe     dd  110
  329. m_ye     dd  110
  330.  
  331. size_x   dd  0
  332. size_y   dd  0
  333.  
  334. cmp_ecx  dd  0
  335. add_esi  dd  0
  336. cmp_edx  dd  0
  337.  
  338. delay    dd  20
  339.  
  340. labelt:
  341.     db   'MAGNIFIER - MOVE MOUSE POINTER'
  342. labellen:
  343.  
  344.  
  345. I_END:
  346.  
  347.  
  348.  
  349.