Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;    FILE COPIER
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6.  
  7.    use32
  8.    org     0x0
  9.  
  10.    db      'MENUET00'   ; 8 byte id
  11.    dd      38           ; required os
  12.    dd      START        ; program start
  13.    dd      I_END        ; program image size
  14.    dd      0x1000       ; required amount of memory
  15.    dd      0x1000
  16.    dd      0            ; reserved=no extended header
  17.  
  18. include "lang.inc"
  19. include "macros.inc"
  20.  
  21. START:                          ; start of execution
  22.  
  23.     call draw_window            ; at first, draw the window
  24.  
  25. still:
  26.  
  27.     mov  eax,10                 ; wait here for event
  28.     int  0x40
  29.  
  30.     cmp  eax,1                  ; redraw request ?
  31.     jz   red
  32.     cmp  eax,2                  ; key in buffer ?
  33.     jz   key
  34.     cmp  eax,3                  ; button in buffer ?
  35.     jz   button
  36.  
  37.     jmp  still
  38.  
  39.   red:                          ; redraw
  40.     call draw_window
  41.     jmp  still
  42.  
  43.   key:                          ; key
  44.     mov  eax,2                  ; just read it and ignore
  45.     int  0x40
  46.     jmp  still
  47.  
  48.   button:                       ; button
  49.     mov  eax,17                 ; get id
  50.     int  0x40
  51.  
  52.     cmp  ah,1                   ; button id=1 ?
  53.     jnz  noclose
  54.     mov  eax,0xffffffff         ; close this program
  55.     int  0x40
  56.   noclose:
  57.  
  58.  
  59.     cmp  ah,3    ; delete ?
  60.     jnz  nodelete
  61.     mov  eax,32
  62.     mov  ebx,destination
  63.     int  0x40
  64.     jmp  still
  65.   nodelete:
  66.  
  67.  
  68.     cmp  ah,4
  69.     jz   f2
  70.     jmp  nof12
  71.  
  72.   f2:
  73.     mov  [addr],dword destination
  74.     mov  [ya],dword 35
  75.     jmp  rk
  76.  
  77.   rk:
  78.     mov  edi,[addr]
  79.     mov  al,' '
  80.     mov  ecx,11
  81.     rep  stosb
  82.  
  83.     call print_text
  84.  
  85.     mov  edi,[addr]
  86.  
  87.   f11:
  88.     mov  eax,10
  89.     int  0x40
  90.     cmp  eax,2
  91.     jz   fbu
  92.     jmp  still
  93.   fbu:
  94.     mov  eax,2
  95.     int  0x40
  96.     shr  eax,8
  97.     cmp  eax,8
  98.     jnz  nobs
  99.     cmp  edi,[addr]
  100.     jz   f11
  101.     sub  edi,1
  102.     mov  [edi],byte 0
  103.     call print_text
  104.     jmp  f11
  105.   nobs:
  106.     cmp  eax,dword 31
  107.     jbe  f11
  108.     cmp  eax,dword 95
  109.     jb   keyok
  110.     sub  eax,32
  111.   keyok:
  112.     mov  [edi],al
  113.  
  114.     call print_text
  115.  
  116.     add  edi,1
  117.     mov  esi,[addr]
  118.     add  esi,11
  119.     cmp  esi,edi
  120.     jnz  f11
  121.  
  122.     jmp  still
  123.  
  124. print_text:
  125.  
  126.     mov  eax,13
  127.     mov  ebx,109*65536+11*6
  128.     mov  ecx,[ya]
  129.     shl  ecx,16
  130.     mov  cx,8
  131.     mov  edx,0xffffff
  132.     int  0x40
  133.  
  134.     mov  eax,4
  135.     mov  ebx,109*65536
  136.     add  ebx,[ya]
  137.     mov  ecx,0x000000
  138.     mov  edx,[addr]
  139.     mov  esi,11
  140.     int  0x40
  141.  
  142.     ret
  143.  
  144.   nof12:
  145.     jmp  still
  146.  
  147.  
  148. ;   *********************************************
  149. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  150. ;   *********************************************
  151.  
  152.  
  153. draw_window:
  154.  
  155.     mov  eax,12                    ; function 12:tell os about windowdraw
  156.     mov  ebx,1                     ; 1, start of draw
  157.     int  0x40
  158.  
  159.                                    ; DRAW WINDOW
  160.     mov  eax,0                     ; function 0 : define and draw window
  161.     mov  ebx,100*65536+230         ; [x start] *65536 + [x size]
  162.     mov  ecx,100*65536+105         ; [y start] *65536 + [y size]
  163.     mov  edx,0x03ffffff            ; color of work area RRGGBB
  164.     int  0x40
  165.  
  166.                                    ; WINDOW LABEL
  167.     mov  eax,4                     ; function 4 : write text to window
  168.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  169.     mov  ecx,0x10ffffff            ; color of text RRGGBB
  170.     mov  edx,header                ; pointer to text beginning
  171.     mov  esi,header.len            ; text length
  172.     int  0x40
  173.  
  174.     mov  esi,0xbbbbbb
  175.  
  176.     mov  eax,8              ; DELETE BUTTON
  177.     mov  ebx,20*65536+190
  178.     mov  ecx,63*65536+15
  179.     mov  edx,3
  180.     int  0x40
  181.  
  182.     mov  eax,8
  183.     mov  ebx,200*65536+10
  184.     mov  ecx,33*65536+10
  185.     mov  edx,4
  186.     int  0x40
  187.  
  188.     mov  esi,destination
  189.     mov  edi,text+14
  190.     mov  ecx,11
  191.     cld
  192.     rep  movsb
  193.  
  194.     mov  ebx,25*65536+35           ; draw info text with function 4
  195.     mov  ecx,0x0
  196.     mov  edx,text
  197.     mov  esi,40
  198.   newline:
  199.     mov  eax,4
  200.     int  0x40
  201.     add  ebx,16*2
  202.     add  edx,40
  203.     cmp  [edx],byte 'x'
  204.     jnz  newline
  205.  
  206.  
  207.     mov  eax,12                    ; function 12:tell os about windowdraw
  208.     mov  ebx,2                     ; 2, end of draw
  209.     int  0x40
  210.  
  211.     ret
  212.  
  213.  
  214. ; DATA AREA
  215.  
  216. destination  db  'EXAMPLE.ASM'
  217.  
  218. addr  dd  0x0
  219. ya    dd  0x0
  220.  
  221. text:
  222.     db 'FILENAME   :  yyyyyyyyyyy               '
  223.     db '     DELETE FROM RAMDISK                '
  224.  
  225.     db 'x' ; <- END MARKER, DONT DELETE
  226.  
  227.  
  228. header:
  229.     db   'RAMDISK FILE DELETE'
  230.  .len = $ - header
  231.  
  232. I_END:
  233.