Subversion Repositories Kolibri OS

Rev

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

  1. ;   Author: M. Lisovin
  2. ;   Compile with FASM for Menuet
  3. ;
  4.  
  5. use32
  6.  
  7.                org    0x0
  8.  
  9.                db     'MENUET01'              ; 8 byte id
  10.                dd     0x01                    ; header version
  11.                dd     START                   ; start of code
  12.                dd     I_END                   ; size of image
  13.                dd     0x1000                  ; memory for app
  14.                dd     0x1000                  ; esp
  15.                dd     0x0 , 0x0               ; I_Param , I_Icon
  16.  
  17. include 'lang.inc'
  18. include '..\..\..\macros.inc'
  19.  
  20. START:                          ; start of execution
  21.   red:
  22.      call draw_window
  23.  
  24. still:
  25.  
  26.     mov  eax,10                 ; wait here for event
  27.     mcall
  28.  
  29.     cmp  eax,1                  ; redraw request ?
  30.     je   red
  31.     cmp  eax,2                  ; key in buffer ?
  32.     je   key
  33.     cmp  eax,3                  ; button in buffer ?
  34.     je   button
  35.  
  36.     jmp  still
  37.  
  38.   key:                          ; key
  39.     mov  eax,2                  ; just read it and ignore
  40.     mcall
  41.     mov  [keyid],ah
  42.     shr  eax,16
  43.     mov  [scan_keyid],al
  44.     call draw_window
  45.     jmp  still
  46.  
  47.   button:                       ; button
  48.     mov  eax,17                 ; get id
  49.     mcall
  50.  
  51.     cmp  ah,1                   ; button id=1 ?
  52.     jne  noclose
  53.  
  54.     or   eax,-1                 ; close this program
  55.     mcall
  56.   noclose:
  57.  
  58.     jmp  still
  59.  
  60. ;   *********************************************
  61. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  62. ;   *********************************************
  63.  
  64. draw_window:
  65. ; function 12:tell os about windowdraw ; 1, start of draw
  66.         mcall   12,1
  67.  
  68.                                    ; DRAW WINDOW
  69.         mov     eax,0                     ; function 0 : define and draw window
  70.         mov     ebx,100*65536+270         ; [x start] *65536 + [x size]
  71.         mov     ecx,100*65536+100          ; [y start] *65536 + [y size]
  72.         mov     edx,0x34ffffff            ; color of work area RRGGBB,8->color gl
  73.         mov     edi,title
  74.         mcall
  75.  
  76. ; function 4 : write text to window
  77.         xor     ecx,ecx
  78.         mcall   4,<33,8>,,text1,6
  79.         mcall   ,<85,8>,,text2,9
  80.         mcall   ,<8,28>,,tdec,4
  81.         add     ebx,23
  82.         mcall   ,,,thex
  83.  
  84.         movzx  ecx,byte [keyid]
  85.         mcall   47,0x30000,,<40,28>,0x224466
  86.         add     edx,23
  87.         mov     bh,1
  88.         mcall
  89.  
  90.         mov     bh,0
  91.         movzx   ecx,byte [scan_keyid]
  92.         mcall   ,,,<100,28>
  93.         add     edx,23
  94.         mov     bh,1
  95.         mcall
  96.  
  97. ; function 12:tell os about windowdraw ; 2, end of draw
  98.         mcall   12,2
  99.         ret
  100.  
  101.  
  102. ; DATA AREA
  103.  text1: db 'ASCII:'
  104.  text2: db 'SCANCODE:'
  105.  tdec: db 'DEC:'
  106.  thex: db 'HEX:'
  107.  title: db 'KEYBOARD ASCIICODES-PRESS ANY KEY',0
  108. I_END:
  109.  keyid: rb 1
  110.  scan_keyid: rb 1
  111.  
  112.  
  113.