Subversion Repositories Kolibri OS

Rev

Rev 2741 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; aclock 1.1
  2. ; Copyright (c) 2002 Thomas Mathys
  3. ; killer@vantage.ch
  4. ;
  5. ; This program is free software; you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation; either version 2 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program; if not, write to the Free Software
  17. ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19.         bits 32
  20.         %include 'mos.inc'
  21.         section .text
  22.  
  23.  
  24. ;********************************************************************
  25. ;       configuration stuff
  26. ;********************************************************************
  27.  
  28.         %define APPNAME         "AClock 1.1"
  29.         %define STACKSIZE       1024
  30.  
  31.         ; default window position/dimensions (work area)
  32.         %define DEFAULT_XPOS    -20
  33.         %define DEFAULT_YPOS    20
  34.         %define DEFAULT_WIDTH   100
  35.         %define DEFAULT_HEIGHT  100
  36.  
  37.         ; minimal size (horizontal and vertical) of work area
  38.         %define MIN_WIDTH       100
  39.         %define MIN_HEIGHT      100
  40.  
  41.  
  42. ;********************************************************************
  43. ;       header
  44. ;********************************************************************
  45.        
  46.         MOS_HEADER01 main,image_end,memory_end,stacktop-4,cmdLine,0
  47.  
  48.         ; these includes introduce code and thus mustn't stand
  49.         ; before the menuet header =)
  50.         %include 'dbgboard.inc'
  51.         %include 'strlen.inc'
  52.         %include 'str2dwrd.inc'
  53.         %include 'strtok.inc'
  54.         %include 'cmdline.inc'
  55.         %include 'adjstwnd.inc'
  56.         %include 'draw.inc'
  57.  
  58. ;********************************************************************
  59. ;       main program
  60. ;********************************************************************
  61. main:
  62.         call    getDefaultWindowColors
  63.         call    parseCommandLine
  64.  
  65.         ; check minimal window dimensions
  66.         cmp     dword [wndWidth],MIN_WIDTH
  67.         jae     .widthok
  68.         mov     dword [wndWidth],MIN_WIDTH
  69. .widthok:
  70.         cmp     dword [wndHeight],MIN_HEIGHT
  71.         jae     .heightok
  72.         mov     dword [wndHeight],MIN_HEIGHT
  73. .heightok:
  74.  
  75.         ; adjust window dimensions
  76.         mov     eax,ADJSTWND_TYPE_SKINNED
  77.         mov     ebx,[wndXPos]
  78.         mov     ecx,[wndYPos]
  79.         mov     edx,[wndWidth]
  80.         mov     esi,[wndHeight]
  81.         call    adjustWindowDimensions
  82.         mov     [wndXPos],ebx
  83.         mov     [wndYPos],ecx
  84.         mov     [wndWidth],edx
  85.         mov     [wndHeight],esi
  86.  
  87.         call    drawWindow
  88. .msgpump:
  89. ;       call    drawClock
  90.  
  91.         ; wait up to a second for next event
  92.         mov     eax,MOS_SC_WAITEVENTTIMEOUT
  93.         mov     ebx,100
  94.         int     0x40
  95.  
  96.         test    eax,eax
  97.         jne     .event_occured
  98.         call    drawClock
  99.  
  100.   .event_occured:
  101.         cmp     eax,MOS_EVT_REDRAW
  102.         je      .redraw
  103.         cmp     eax,MOS_EVT_KEY
  104.         je      .key
  105.         cmp     eax,MOS_EVT_BUTTON
  106.         je      .button
  107.         jmp     .msgpump
  108.  
  109. .redraw:
  110.         call    drawWindow
  111.         jmp     .msgpump
  112. .key:
  113.         mov     eax,MOS_SC_GETKEY
  114.         int     0x40
  115.         jmp     .msgpump
  116. .button:
  117.         mov     eax,MOS_SC_EXIT
  118.         int     0x40
  119.         jmp     .msgpump
  120.  
  121.  
  122. ;********************************************************************
  123. ;       get default window colors
  124. ;       input           :       nothing
  125. ;       output          :       wndColors contains default colors
  126. ;       destroys        :       nothing
  127. ;********************************************************************
  128. getDefaultWindowColors:
  129.         pushad
  130.         pushfd
  131.         mov     eax,MOS_SC_WINDOWPROPERTIES
  132.         mov     ebx,3
  133.         mov     ecx,wndColors
  134.         mov     edx,MOS_WNDCOLORS_size
  135.         int     0x40
  136.         popfd
  137.         popad
  138.         ret
  139.  
  140.  
  141. ;********************************************************************
  142. ;       define and draw window
  143. ;       input           nothing
  144. ;       output          nothing
  145. ;       destroys        flags
  146. ;********************************************************************
  147.         align   4
  148. drawWindow:
  149.         pusha
  150.  
  151.         ; start window redraw
  152.         mov     eax,MOS_SC_REDRAWSTATUS
  153.         mov     ebx,1
  154.         int     0x40
  155.  
  156.         ; create window
  157.         mov     eax,MOS_SC_DEFINEWINDOW
  158.         mov     ebx,[wndXPos]
  159.         shl     ebx,16
  160.         or      ebx,[wndWidth]
  161.         mov     ecx,[wndYPos]
  162.         shl     ecx,16
  163.         or      ecx,[wndHeight]
  164.         mov     edx,[wndColors+MOS_WNDCOLORS.work]
  165.         or      edx,0x53000000
  166.         mov     edi,label
  167.         int     0x40
  168.  
  169.         call drawClock
  170.        
  171.         ; end window redraw
  172.         mov     eax,MOS_SC_REDRAWSTATUS
  173.         mov     ebx,2
  174.         int     0x40
  175.         popa
  176.         ret
  177.  
  178.  
  179. ;********************************************************************
  180. ;       initialized data
  181. ;********************************************************************
  182.  
  183.         ; window position and dimensions.
  184.         ; dimensions are for work area only.
  185. wndXPos         dd      DEFAULT_XPOS
  186. wndYPos         dd      DEFAULT_YPOS
  187. wndWidth        dd      DEFAULT_WIDTH
  188. wndHeight       dd      DEFAULT_HEIGHT
  189.  
  190.         ; window label
  191. label           db      APPNAME,0
  192. LABEL_LEN       equ     ($-label-1)
  193.  
  194.         ; token delimiter list for command line
  195. delimiters      db      9,10,11,12,13,32,0
  196.  
  197.         ; don't insert anything after this label
  198. image_end:
  199.  
  200.  
  201. ;********************************************************************
  202. ;       uninitialized data
  203. ;********************************************************************
  204.         section .bss align=4
  205.  
  206. wndColors       resb    MOS_WNDCOLORS_size
  207. procInfo        resb    MOS_PROCESSINFO_size
  208.  
  209.         ; space for command line. at the end we have an additional
  210.         ; byte for a terminating zero, just to be sure...
  211. cmdLine         resb    257
  212.  
  213.         alignb  4
  214. stack           resb    STACKSIZE
  215. stacktop:
  216.  
  217.         ; don't insert anything after this label
  218. memory_end:
  219.  
  220.