Subversion Repositories Kolibri OS

Rev

Rev 4589 | 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,200*65536+250         ; [x start] *65536 + [x size]
  71.     mov ecx,200*65536+106          ; [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.     mcall   4,<55,8>,0x10000000,text1,5
  78.     mcall   ,<130,8>,,text2,9
  79.     mcall   ,<8,30>,,tdec,4
  80.     add ebx,23
  81.     mcall   ,,,thex
  82.  
  83.     movzx  ecx,byte [keyid]
  84.     mcall   47,0x30000,,<55,30>,0x10224466
  85.     add edx,23
  86.     mov bh,1
  87.     mcall
  88.  
  89.     mov bh,0
  90.     movzx   ecx,byte [scan_keyid]
  91.     mcall   ,,,<130,30>
  92.     add edx,23
  93.     mov bh,1
  94.     mcall
  95.  
  96. ; function 12:tell os about windowdraw ; 2, end of draw
  97.     mcall   12,2
  98.     ret
  99.  
  100.  
  101. ; DATA AREA
  102.  text1: db 'ASCII'
  103.  text2: db 'SCANCODE'
  104.  tdec: db 'DEC:'
  105.  thex: db 'HEX:'
  106.  title: db 'Keyboard ASCII codes',0
  107. I_END:
  108.  keyid: rb 1
  109.  scan_keyid: rb 1
  110.  
  111.  
  112.