Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;   BCD CLOCK
  3. ;
  4. ;   Compile with FASM for Menuet
  5. ;
  6. ;
  7.  
  8. use32
  9.  
  10.  org 0x0
  11.  
  12.  db 'MENUET01'
  13.  dd 0x01
  14.  dd START
  15.  dd I_END
  16.  dd 0x1000
  17.  dd 0x1000
  18.  dd 0x0 , 0x0
  19.  
  20. include 'lang.inc'
  21. include '../../../macros.inc'
  22.  
  23.  
  24. START:
  25. red:
  26.      call drawwindow
  27.  
  28. still:
  29.  
  30.  
  31.     mov  eax,23   ; wait for timeout
  32.     mov  ebx,50
  33.     mcall
  34.  
  35.     cmp  eax,1 ; redraw ?
  36.     je red
  37.  
  38.     cmp  eax,3 ; button in buffer ?
  39.     je button
  40.  
  41.     call  drawclock
  42.  
  43.     jmp still
  44.  
  45. button:
  46.     mov  al,17   ; get id
  47.     mcall
  48.  
  49.     cmp  ah,1 ; button id=1 ?
  50.     jne  noclose
  51.     or   eax,-1   ; close this program
  52.     mcall
  53.   noclose:
  54.  
  55.     jmp  still
  56.  
  57. drawclock:
  58.  
  59.     mov eax,3 ; get time
  60.     mcall
  61.     bswap eax
  62.     shr  eax,8
  63.     mov  edi,dg1
  64.     mov  ecx,6
  65. dgtomem:
  66.     push eax
  67.     and  al,15
  68.     mov  [edi],al
  69.     inc  edi
  70.     pop  eax
  71.     shr  eax,4
  72.     loop dgtomem
  73.     mov  ebx,74*65536+10
  74.     mov  edi,dg1
  75. digitlp:
  76.     mov  ecx,10*65536+10
  77.     xor  esi,esi
  78. plotlp:
  79.     xor  edx,edx
  80.     test byte[edi],8
  81.     je   nobit
  82.     mov  edx,0x00ff0000
  83. nobit:
  84.     mov  eax,13  ; plot 8,4,2,1
  85.     mcall
  86.     add  ecx,12*65536
  87.     shl  byte[edi],1
  88.     inc  esi
  89.     cmp  esi,4
  90.     jne  plotlp
  91.     shr  byte[edi],4
  92.     mov  edx,0x00880040
  93.     mov  eax,13 ; draw digit box
  94.     mcall
  95.     pusha
  96.     mov  edx,ebx
  97.     and  edx,0xffff0000
  98.     shr  ecx,16
  99.     or   edx,ecx
  100.     add  edx,3*65536+2
  101.     mov  ebx,0x00010100
  102.     mov  ecx,[edi]
  103.     mov  esi,0x00ffffff
  104.     mov  eax,47  ; display decimal
  105.     mcall
  106.     popa
  107.     sub  ebx,12*65536
  108.     inc  edi
  109.     cmp  edi,dg1+6
  110.     jne  digitlp
  111.     ret
  112.  
  113.  
  114. drawwindow:
  115.  
  116.  
  117.     mov  eax,12
  118.     mov  ebx,1 ; start redraw
  119.     mcall
  120.  
  121.     xor  eax,eax ; window
  122.     mov  ebx,100*65536+107
  123.     mov  ecx,100*65536+105
  124.     mov  edx,0x34400088
  125.     mov  edi,title
  126.     mcall
  127.  
  128. call drawclock
  129.  
  130.     mov  eax,12
  131.     mov  ebx,2 ; end redraw
  132.     mcall
  133.  
  134.     ret
  135.  
  136. title   db   'BCD Clock',0
  137. I_END:
  138. dg1:   db  ?