Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;    UNIFORM WINDOW COLOURS
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6. ;    < russian edition by Ivan Poddubny >
  7. ;
  8.  
  9. ;******************************************************************************
  10.    use32
  11.    org     0
  12.    db      'MENUET01'  ; identifier
  13.    dd      1           ; header version
  14.    dd      START       ; start address
  15.    dd      I_END       ; file size
  16.    dd      20000h      ; memory
  17.    dd      10000h      ; stack pointer (0x10000+ - work area for os)
  18.    dd      0;,0        ; parameters, reserved
  19.  
  20.   include 'lang.inc'
  21.   include 'macros.inc'
  22. ;******************************************************************************
  23.  
  24.  
  25.  
  26. START:                          ; start of execution
  27.  
  28.     mov  eax,48                 ; get current colors
  29.     mov  ebx,3
  30.     mov  ecx,color_table
  31.     mov  edx,4*10
  32.     int  0x40
  33.  
  34.     cld
  35.     mov  esi, default_file
  36.     mov  edi, fname
  37.     mov  ecx, default_file.size
  38.     rep  movsb
  39.  
  40.     mov  [read_info.address],     color_table
  41.     mov  [read_info.workarea],    0x10000
  42.     mov  [read_info.start_block], 0
  43.  
  44. red:
  45.     call draw_window            ; at first, draw the window
  46.  
  47. still:
  48.  
  49.     mov  eax,23                 ; wait here for event
  50.     mov  ebx,5
  51.     int  0x40
  52.  
  53.     dec  eax                    ; redraw request ?
  54.     jz   red
  55.     dec  eax                    ; key in buffer ?
  56.     jz   key
  57.     dec  eax                    ; button in buffer ?
  58.     jz   button
  59.  
  60.     call draw_cursor
  61.  
  62.     jmp  still
  63.  
  64.  
  65.   key:                          ; key
  66.     mov  eax,2                  ; just read it and ignore
  67.     int  0x40
  68.     jmp  still
  69.  
  70.   button:                       ; button
  71.     mov  eax,17                 ; get id
  72.     int  0x40
  73.  
  74.     cmp  ah,14                  ; set 3d buttons
  75.     jne  no_3d
  76.     mov  eax,48
  77.     mov  ebx,1
  78.     mov  ecx,1
  79.     int  0x40
  80.     mov  eax,48
  81.     mov  ebx,0
  82.     mov  ecx,0
  83.     int  0x40
  84.     jmp  still
  85.    no_3d:
  86.  
  87.     cmp  ah,15                  ; set flat buttons
  88.     jne  no_flat
  89.     mcall 48, 1, 0
  90.     mcall 48, 0, 0
  91.     jmp  still
  92.   no_flat:
  93.  
  94.     cmp  ah,51      ; apply
  95.     jne  no_apply
  96.     mov  eax,48
  97.     mov  ebx,2
  98.     mov  ecx,color_table
  99.     mov  edx,10*4
  100.     int  0x40
  101.     mov  eax,48
  102.     mov  ebx,0
  103.     mov  ecx,0
  104.     int  0x40
  105.   no_apply:
  106.  
  107.     cmp  ah,31
  108.     jb   no_new_colour
  109.     cmp  ah,41
  110.     jg   no_new_colour
  111.     shr  eax,8
  112.     sub  eax,31
  113.     shl  eax,2
  114.     add  eax,color_table
  115.     mov  ebx,[color]
  116.     mov  [eax],ebx
  117.     call draw_colours
  118.     jmp  still
  119.   no_new_colour:
  120.  
  121.      cmp  ah,1                   ; terminate
  122.      jnz  noid1
  123.     mov  eax,-1
  124.     int  0x40
  125.   noid1:
  126.  
  127.     cmp  ah,11                  ; read string
  128.     jne  no_string
  129.     call read_string
  130.     jmp  still
  131.   no_string:
  132.  
  133.     cmp  ah,12                  ; load file
  134.     jne  no_load
  135.     call load_file
  136.     call draw_window
  137.     jmp  still
  138.   no_load:
  139.  
  140.     cmp  ah,13                  ; save file
  141.     jne  no_save
  142.     call save_file
  143.     jmp  still
  144.   no_save:
  145.  
  146.     jmp  still
  147.  
  148.  
  149. draw_cursor:
  150.  
  151.     pusha
  152.     mov  eax,37
  153.     mov  ebx,2
  154.     int  0x40
  155.  
  156.     cmp  eax,0
  157.     jne  dc1
  158.     popa
  159.     ret
  160.  
  161.  dc1:
  162.  
  163.     mov  eax,37
  164.     mov  ebx,1
  165.     int  0x40
  166.  
  167.     mov  ebx,eax
  168.     shr  ebx,16
  169.     mov  ecx,eax
  170.     and  ecx,0xffff
  171.  
  172.     cmp  ecx,32
  173.     jbe  no_color
  174.     cmp  ebx,32
  175.     jbe  no_color
  176.  
  177.     cmp  ebx,280           ; CHANGE COLOR
  178.     jb   no_color
  179.     cmp  ebx,280+20*3
  180.     jg   no_color
  181.  
  182.     cmp  ecx,30+128
  183.     jge  no_color
  184.     cmp  ecx,30
  185.     jb   no_color
  186.  
  187.     sub  ebx,280
  188.     mov  eax,ebx
  189.     cdq
  190.     mov  ebx,20
  191.     div  ebx
  192.     mov  ebx,2
  193.     sub  ebx,eax
  194.  
  195.     add  ecx,-30
  196.     not  ecx
  197.     shl  ecx,1
  198.  
  199.     mov  byte [ebx+color],cl
  200.     call draw_color
  201.  
  202.     popa
  203.     ret
  204.  
  205.   no_color:
  206.  
  207.     popa
  208.     ret
  209.  
  210.  
  211. load_file:
  212.     pushad
  213.  
  214.     mov   [read_info.mode],   0
  215.     mov   [read_info.blocks], 1
  216.     mcall 58, read_info
  217.  
  218.     call  draw_colours
  219.  
  220.     popad
  221. ret
  222.  
  223.  
  224. save_file:
  225.     pushad
  226.  
  227.     mov   [write_info.mode],        1
  228.     mov   [write_info.bytes2write], 10*4
  229.     mcall 58, write_info
  230.  
  231.     popad
  232. ret
  233.  
  234.  
  235. read_string:
  236.  
  237.     pusha
  238.  
  239.     mov  edi,fname
  240.     mov  al,'_'
  241.     mov  ecx,54
  242.     cld
  243.     rep  stosb
  244.  
  245.     call print_text
  246.  
  247.     mov  edi,fname
  248.  
  249.   f11:
  250.     mov  eax,10
  251.     int  0x40
  252.     cmp  eax,2
  253.     jne  read_done
  254.     mov  eax,2
  255.     int  0x40
  256.     shr  eax,8
  257.     cmp  eax,13
  258.     je   read_done
  259.     cmp  eax,8
  260.     jne  nobsl
  261.     cmp  edi,fname
  262.     je   f11
  263.     dec  edi
  264.     mov  [edi],byte '_'
  265.     call print_text
  266.     jmp  f11
  267.    nobsl:
  268.     mov  [edi],al
  269.  
  270.     call print_text
  271.  
  272.     inc  edi
  273.     cmp  edi, fname+54
  274.     jne  f11
  275.  
  276.   read_done:
  277.  
  278.     mov  ecx, fname
  279.     add  ecx, 55
  280.     sub  ecx, edi
  281.     mov  eax, 0
  282.     cld
  283.     rep  stosb
  284.  
  285.     call print_text
  286.  
  287.     popa
  288.  
  289.     ret
  290.  
  291.  
  292. print_text:
  293.     pushad
  294.  
  295.     mpack ebx, 16, 6*54+4
  296.     mpack ecx, 234, 10
  297.     mcall 13, , , [w_work]
  298.  
  299.     mpack ebx, 17, 235
  300.     mcall 4, , [w_work_text], fname, 54
  301.  
  302.     popad
  303. ret
  304.  
  305.  
  306. draw_color:
  307.  
  308.     pusha
  309.  
  310.     mov  eax,13
  311.     mov  ebx,280*65536+60
  312.     mov  ecx,170*65536+30
  313.     mov  edx,[color]
  314.     int  0x40
  315.  
  316. ;   mov  eax,13
  317.     mov  ebx,280*65536+60
  318.     mov  ecx,200*65536+10
  319.     mov  edx,[w_work]
  320.     int  0x40
  321.  
  322.     mov  eax,47
  323.     mov  ebx,0+1*256+8*65536
  324.     mov  ecx,[color]
  325.     mov  edx,280*65536+201
  326.     mov  esi,[w_work_text]
  327.     int  0x40
  328.  
  329.     popa
  330.  
  331.     ret
  332.  
  333.  
  334. draw_colours:
  335.  
  336.     pusha
  337.  
  338.     mov  esi,color_table
  339.  
  340.     mov  ebx,225*65536+32
  341.     mov  ecx,37*65536+12
  342.   newcol:
  343.     mov  eax,13
  344.     mov  edx,[esi]
  345.     int  0x40
  346.     add  ecx,20*65536
  347.     add  esi,4
  348.     cmp  esi,color_table+4*9
  349.     jbe  newcol
  350.  
  351.     popa
  352.  
  353.     ret
  354.  
  355.  
  356.  
  357. ;   *********************************************
  358. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  359. ;   *********************************************
  360.  
  361.  
  362. draw_window:
  363.  
  364.     mov  eax,12                    ; function 12:tell os about windowdraw
  365.     mov  ebx,1                     ; 1, start of draw
  366.     int  0x40
  367.  
  368.     mov  eax,48
  369.     mov  ebx,3
  370.     mov  ecx,app_colours
  371.     mov  edx,10*4
  372.     int  0x40
  373.  
  374.     mov  eax,14
  375.     int  0x40
  376.  
  377.     sub  eax,60*65536
  378.     mov  ebx,eax
  379.     mov  bx,40
  380.  
  381.                                    ; DRAW WINDOW
  382.     mov  eax,0                     ; function 0 : define and draw window
  383.     mov  ebx,110*65536+360         ; [x start] *65536 + [x size]
  384.     mov  ecx,50*65536+300          ; [y start] *65536 + [y size]
  385.     mov  edx,[w_work]              ; color of work area RRGGBB,8->color
  386.     or   edx,0x02000000
  387.     mov  esi,[w_grab]              ; color of grab bar  RRGGBB,8->color gl
  388.     or   esi,0x80000000
  389.     mov  edi,[w_frame]             ; color of frames    RRGGBB
  390.     int  0x40
  391.  
  392.                                    ; WINDOW LABEL
  393.     mov  eax,4                     ; function 4 : write text to window
  394.     mov  ebx,8*65536+7 ;8          ; [x start] *65536 + [y start]
  395.     mov  ecx,[w_grab_text]         ; color of text RRGGBB
  396. if lang eq ru
  397.     or   ecx,0x10000000
  398. end if
  399.     mov  edx,labelt                ; pointer to text beginning
  400.     mov  esi,labelt.size           ; text length
  401.     int  0x40
  402.                                    ; CLOSE BUTTON
  403.     mov  eax,8                     ; function 8 : define and draw button
  404.     mov  ebx,(360-19)*65536+12     ; [x start] *65536 + [x size]
  405.     mov  ecx,4*65536+12            ; [y start] *65536 + [y size]
  406.     mov  edx,1                     ; button id
  407.     mov  esi,[w_grab_button]       ; button color RRGGBB
  408.     int  0x40
  409.  
  410. ;   mov  eax,8                    ; FILENAME BUTTON
  411.     mov  ebx,280*65536+60
  412.     mov  ecx,250*65536+14
  413.     mov  edx,11
  414.     mov  esi,[w_work_button]
  415.     int  0x40
  416.  
  417. ;   mov  eax,8                    ; SAVE BUTTON
  418.     mov  ebx,280*65536+29
  419.     mov  ecx,270*65536+14
  420.     mov  edx,12
  421.     int  0x40
  422.  
  423. ;   mov  eax,8                    ; LOAD BUTTON
  424.     add  ebx,30*65536
  425.     inc  edx
  426.     int  0x40
  427.  
  428. ;   mov  eax,8                    ; 3D
  429.     mov  ebx,15*65536+35
  430.     mov  ecx,275*65536+14
  431.     inc  edx
  432.     int  0x40
  433. ;   mov  eax,8                    ; FLAT
  434. if lang eq ru
  435.     add  ebx,40*65536+7
  436. else
  437.     add  ebx,40*65536
  438. end if
  439.     inc  edx
  440.     int  0x40
  441.  
  442.  
  443.     mov  eax, 4
  444.     mov  ebx, 281*65536+254
  445.     mov  ecx, [w_work_button_text]
  446.     mov  edx, t1
  447.     mov  esi, t1.size
  448.     int  0x40
  449.  
  450. ;   mov  eax, 4
  451.     mov  ebx, 277*65536+274
  452.     mov  edx, t2
  453.     mov  esi, t2.size
  454.     int  0x40
  455.  
  456.     mov  eax,38                    ; R G B COLOR GLIDES
  457.     mov  ebx,280*65536+300 ;295
  458.     mov  ecx,30*65536+30
  459.     mov  edx,0xff0000
  460.   .newl:
  461.     int  0x40
  462.     pusha
  463.     add  ebx,20*65536+20
  464.     shr  edx,8
  465.     int  0x40
  466.     add  ebx,20*65536+20
  467.     shr  edx,8
  468.     int  0x40
  469.     popa
  470.     sub  edx,0x020000
  471.     add  ecx,0x00010001
  472.     cmp  ecx,158*65536+158
  473.     jnz  .newl
  474.  
  475.     call draw_color
  476.  
  477.     mov  edx,31                    ; BUTTON ROW
  478.     mov  ebx,15*65536+200
  479.     mov  ecx,35*65536+14
  480.     mov  esi,[w_work_button]
  481.   newb:
  482.     mov  eax,8
  483.     int  0x40
  484.     add  ecx,20*65536
  485.     inc  edx
  486.     cmp  edx,40
  487.     jbe  newb
  488.  
  489. ;    mov  eax,8                     ; APPLY BUTTON
  490.     add  ecx,20*65536
  491.     mov  edx,51
  492.     int  0x40
  493.  
  494.     mov  ebx,20*65536+39           ; ROW OF TEXTS
  495.     mov  ecx,[w_work_button_text]
  496.     mov  edx,text
  497.     mov  esi,32
  498.   newline:
  499.     mov  eax,4
  500.     int  0x40
  501.     add  ebx,20
  502.     add  edx,32
  503.     cmp  [edx],byte 'x'
  504.     jne  newline
  505.  
  506.     call draw_colours
  507.  
  508.     call print_text
  509.  
  510.     mov  eax,12                    ; function 12:tell os about windowdraw
  511.     mov  ebx,2                     ; 2, end of draw
  512.     int  0x40
  513.  
  514.     ret
  515.  
  516.  
  517. ; DATA AREA
  518.  
  519. lsz text,\
  520.     ru,  ' €ŒŠ€ ŽŠ€                     ',\
  521.     ru,  ' Ž‹Ž‘€ ‡€ƒŽ‹Ž‚Š€               ',\
  522.     ru,  ' ŠŽŠ€ € Ž‹Ž‘… ‡€ƒŽ‹Ž‚Š€     ',\
  523.     ru,  ' ’…Š‘’ € ŠŽŠ… € ‡€ƒŽ‹Ž‚Š…   ',\
  524.     ru,  ' ’…Š‘’ ‡€ƒŽ‹Ž‚ŽŠ€               ',\
  525.     ru,  ' €Ž—€Ÿ Ž‹€‘’œ                ',\
  526.     ru,  ' ŠŽŠ€ ‚ €Ž—…‰ Ž‹€‘’ˆ       ',\
  527.     ru,  ' ’…Š‘’ € ŠŽŠ…                ',\
  528.     ru,  ' ’…Š‘’ ‚ €Ž—…‰ Ž‹€‘’ˆ        ',\
  529.     ru,  ' ƒ€”ˆŠ€ ‚ €Ž—…‰ Ž‹€‘’ˆ      ',\
  530.     ru,  '                                ',\
  531.     ru,  '           ˆŒ…ˆ’œ            ',\
  532.     ru,  ' 3D    ‹Ž‘Š                    ',\
  533.     ru,  'x',\
  534.     en,  ' WINDOW FRAME                   ',\
  535.     en,  ' WINDOW GRAB BAR                ',\
  536.     en,  ' WINDOW GRAB BUTTON             ',\
  537.     en,  ' WINDOW GRAB BUTTON TEXT        ',\
  538.     en,  ' WINDOW GRAB TITLE              ',\
  539.     en,  ' WINDOW WORK AREA               ',\
  540.     en,  ' WINDOW WORK AREA BUTTON        ',\
  541.     en,  ' WINDOW WORK AREA BUTTON TEXT   ',\
  542.     en,  ' WINDOW WORK AREA TEXT          ',\
  543.     en,  ' WINDOW WORK AREA GRAPH         ',\
  544.     en,  '                                ',\
  545.     en,  '        APPLY CHANGES           ',\
  546.     en,  ' 3D    FLAT                     ',\
  547.     en,  'x'
  548.  
  549.  
  550. lsz t2,\
  551.     ru, ' ‡€ƒ ‘Ž• ',\
  552.     en, ' LOAD SAVE '
  553.  
  554. lsz t1,\
  555.     ru, '   ”€‰‹    ',\
  556.     en, ' FILENAME  '
  557.  
  558. lsz labelt,\
  559.     ru, '€‘’Ž‰Š€ –‚…’Ž‚',\
  560.     en, 'DESKTOP COLOURS - DEFINE COLOR AND CLICK ON TARGET'
  561.  
  562.  
  563. sz  default_file, '/RD/1/DEFAULT.DTP'
  564.  
  565. color dd  0
  566.  
  567. I_END:
  568.  
  569. read_info:
  570.   .mode         dd ?            ; read
  571.   .start_block  dd ?            ; first block
  572.   .blocks       dd ?            ; 512 bytes
  573.   .address      dd ?
  574.   .workarea     dd ?
  575. fname rb 256+1            ; filename (+1 - for zero at the end)
  576.  
  577. virtual at read_info
  578.  write_info:
  579.   .mode         dd ?
  580.   rd 1
  581.   .bytes2write  dd ?
  582.   .address      dd ?
  583.   .workarea     dd ?
  584. end virtual
  585.  
  586. app_colours:
  587.  
  588. w_frame              dd ?
  589. w_grab               dd ?
  590. w_grab_button        dd ?
  591. w_grab_button_text   dd ?
  592. w_grab_text          dd ?
  593. w_work               dd ?
  594. w_work_button        dd ?
  595. w_work_button_text   dd ?
  596. w_work_text          dd ?
  597. w_work_graph         dd ?
  598.  
  599. color_table:
  600.   times 10 dd ?
  601.