Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;    EXAMPLE APPLICATION
  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      0x5000                  ; required amount of memory
  16.                 dd      0x5000                  ; esp = 0x7FFF0
  17.                 dd      0x00000000              ; reserved=no extended header
  18.  
  19. include 'lang.inc'
  20. include 'macros.inc'
  21.  
  22. START:                          ; start of execution
  23.  
  24.     call open_file
  25.  
  26.     call draw_window            ; at first, draw the window
  27.  
  28. still:
  29.  
  30.     mov  eax,10                 ; wait here for event
  31.     int  0x40
  32.  
  33.     cmp  eax,1                  ; redraw request ?
  34.     je   red
  35.     cmp  eax,2                  ; key in buffer ?
  36.     je   key
  37.     cmp  eax,3                  ; button in buffer ?
  38.     je   button
  39.  
  40.     jmp  still
  41.  
  42.   red:                          ; redraw
  43.     call draw_window
  44.     jmp  still
  45.  
  46.   key:                          ; key
  47.     mov  eax,2                  ; just read it and ignore
  48.     int  0x40
  49.     jmp  still
  50.  
  51.   button:                       ; button
  52.     mov  eax,17                 ; get id
  53.     int  0x40
  54.  
  55.     cmp  ah,1                   ; button id=1 ?
  56.     jne  noclose
  57.     mov  eax,-1                 ; close this program
  58.     int  0x40
  59.   noclose:
  60.  
  61.     cmp  ah,2
  62.     jne  noexam
  63.     jmp  still
  64.   noexam:
  65.  
  66.     cmp  ah,3
  67.     jne  noback
  68.     mov  edi,block
  69.     cmp  dword [edi],0
  70.     je   nonext
  71.     dec  dword [edi]
  72.     call open_file
  73.     call draw_window
  74.   noback:
  75.  
  76.     cmp  ah,4
  77.     jne  nonext
  78.     mov  edi,block
  79.     inc  dword [edi]
  80.     call open_file
  81.     call draw_window
  82.   nonext:
  83.  
  84.     jmp  still
  85.  
  86.  
  87. ;   *********************************************
  88. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  89. ;   *********************************************
  90.  
  91.  
  92. draw_window:
  93.  
  94.     mov  eax,12                    ; function 12:tell os about windowdraw
  95.     mov  ebx,1                     ; 1, start of draw
  96.     int  0x40
  97.  
  98.                                    ; DRAW WINDOW
  99.     mov  eax,0                     ; function 0 : define and draw window
  100.     mov  ebx,0*65536+400         ; [x start] *65536 + [x size]
  101.     mov  ecx,0*65536+270+200       ; [y start] *65536 + [y size]
  102.     mov  edx,0x038899aa;1111cc     ; color of work area RRGGBB,8->c
  103.     int  0x40
  104.  
  105.     mov  eax,4                     ; function 4 : write text to window
  106.     mov  ebx,144*65536+8             ; [x start] *65536 + [y start]
  107.     mov  ecx,0x00ffffff            ; color of text RRGGBB
  108.     mov  edx,labelt                ; pointer to text beginning
  109.     mov  esi,labellen-labelt       ; text length
  110.     int  0x40
  111.  
  112.     mov  eax,47          ;decimal
  113.     mov  ecx,[block]
  114.     mov  edx,64*65536+34
  115.     mov  ebx,10
  116.     shl  ebx,16
  117.     mov  esi,0x00ffffff
  118.     int  0x40
  119.  
  120.     add  edx,128*65536    ;hex
  121.     mov  bh,1
  122.     int  0x40
  123.  
  124.     mov  eax,8
  125.     mov  ebx,280*65536+16*6
  126.     mov  ecx,30*65536+14
  127.  
  128.     mov  edx,2
  129.     mov  esi,0x3f49df;5599cc
  130.     int  0x40
  131.  
  132.     mov  ebx,15*65536+32
  133.     add  edx,1
  134.     mov  eax,8
  135.     int  0x40
  136.  
  137.     add  ebx,127*65536
  138.     add  edx,1
  139.     mov  eax,8
  140.     int  0x40
  141.  
  142.  
  143.     mov  eax,4
  144.     mov  ebx,14*65536+33
  145.     mov  ecx,0xffffff
  146.     mov  edx,buttons
  147.     mov  esi,blen-buttons
  148.     int  0x40
  149.  
  150.  
  151.     mov  ebx,280*65536+65           ; draw info text with function 4
  152.     mov  ecx,0xffffff
  153.     mov  edx,text
  154.     mov  esi,16
  155.     mov  edi,16*2
  156.   newline:
  157.  
  158.     pusha                          ; hext
  159.  
  160.     mov  edi,16
  161.  
  162.     mov  ecx,edx
  163.  
  164.     mov  edx,ebx
  165.     sub  edx,265*65536
  166.  
  167.    newhex:
  168.  
  169.     mov  eax,47
  170.     mov  ebx,0x00020101
  171.     xor  esi,0xffff00
  172.     int  0x40
  173.  
  174.     add  edx,16*65536
  175.     add  ecx,1
  176.  
  177.     dec  edi
  178.     jne  newhex
  179.  
  180.     popa
  181.  
  182.     mov  eax,4                     ; text
  183.     int  0x40
  184.     add  ebx,12
  185.     add  edx,16
  186.     dec  edi
  187.     jnz  newline
  188.  
  189.  
  190.     mov  eax,12                    ; function 12:tell os about windowdraw
  191.     mov  ebx,2                     ; 2, end of draw
  192.     int  0x40
  193.  
  194.     ret
  195.  
  196.  
  197.  
  198. open_file:
  199.  
  200.     pusha
  201.  
  202.     mov  eax,58
  203.     mov  ebx,fileinfo
  204.     int  0x40
  205.  
  206.     popa
  207.  
  208.     ret
  209.  
  210.  
  211.  
  212.  
  213. ; DATA AREA
  214.  
  215. fileinfo:
  216.       dd 8
  217. block dd 0
  218.       dd 1
  219.       dd text
  220.       dd os
  221.       db '/HARDDISK/FIRST',0
  222.  
  223.  
  224. labelt:
  225.       db   'EDITOR HEXADECIMAL'
  226. labellen:
  227.  
  228. buttons db '  <<                   >>                    <<  OPTIONS  >> '
  229. blen:
  230.  
  231. os:
  232. times 16384 db ?
  233. text:
  234.  
  235. I_END:
  236.