Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 5098 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 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
340 heavyiron 34
	%define DEFAULT_WIDTH	100
35
	%define DEFAULT_HEIGHT	100
31 halyavin 36
 
37
	; minimal size (horizontal and vertical) of work area
340 heavyiron 38
	%define MIN_WIDTH	100
39
	%define MIN_HEIGHT	100
31 halyavin 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
	cmp	eax,MOS_EVT_REDRAW
97
	je	.redraw
98
	cmp	eax,MOS_EVT_KEY
99
	je	.key
100
	cmp	eax,MOS_EVT_BUTTON
101
	je	.button
102
	jmp	.msgpump
103
 
104
.redraw:
105
	call	drawWindow
106
	jmp	.msgpump
107
.key:
108
	mov	eax,MOS_SC_GETKEY
109
	int	0x40
110
	jmp	.msgpump
111
.button:
112
	mov	eax,MOS_SC_EXIT
113
	int	0x40
114
	jmp	.msgpump
115
 
116
 
117
;********************************************************************
118
;	get default window colors
119
;	input		:	nothing
120
;	output		:	wndColors contains default colors
121
;	destroys	:	nothing
122
;********************************************************************
123
getDefaultWindowColors:
124
	pushad
125
	pushfd
126
	mov	eax,MOS_SC_WINDOWPROPERTIES
127
	mov	ebx,3
128
	mov	ecx,wndColors
129
	mov	edx,MOS_WNDCOLORS_size
130
	int	0x40
131
	popfd
132
	popad
133
	ret
134
 
135
 
136
;********************************************************************
137
;	define and draw window
138
;	input		nothing
139
;	output		nothing
140
;	destroys	flags
141
;********************************************************************
142
	align	4
143
drawWindow:
144
	pusha
145
 
146
	; start window redraw
147
	mov	eax,MOS_SC_REDRAWSTATUS
148
	mov	ebx,1
149
	int	0x40
150
 
151
	; create window
152
	mov	eax,MOS_SC_DEFINEWINDOW
153
	mov	ebx,[wndXPos]
154
	shl	ebx,16
155
	or	ebx,[wndWidth]
156
	mov	ecx,[wndYPos]
157
	shl	ecx,16
158
	or	ecx,[wndHeight]
159
	mov	edx,[wndColors+MOS_WNDCOLORS.work]
160
	or	edx,0x03000000
161
	mov	esi,[wndColors+MOS_WNDCOLORS.grab]
162
	mov	edi,[wndColors+MOS_WNDCOLORS.frame]
163
	int	0x40
164
 
165
	; draw window label
166
	mov	eax,MOS_SC_WRITETEXT
167
	mov	ebx,MOS_DWORD(8,8)
168
	mov	ecx,[wndColors+MOS_WNDCOLORS.grabText]
169
	mov	edx,label
170
	mov	esi,LABEL_LEN
171
	int	0x40
172
 
173
	call drawClock
174
 
175
	; end window redraw
176
	mov	eax,MOS_SC_REDRAWSTATUS
177
	mov	ebx,2
178
	int	0x40
179
	popa
180
	ret
181
 
182
 
183
;********************************************************************
184
;	initialized data
185
;********************************************************************
186
 
187
	; window position and dimensions.
188
	; dimensions are for work area only.
189
wndXPos		dd	DEFAULT_XPOS
190
wndYPos		dd	DEFAULT_YPOS
191
wndWidth	dd	DEFAULT_WIDTH
192
wndHeight	dd	DEFAULT_HEIGHT
193
 
194
	; window label
195
label		db	APPNAME,0
196
LABEL_LEN	equ	($-label-1)
197
 
198
	; token delimiter list for command line
199
delimiters	db	9,10,11,12,13,32,0
200
 
201
	; don't insert anything after this label
202
image_end:
203
 
204
 
205
;********************************************************************
206
;	uninitialized data
207
;********************************************************************
208
	section .bss
209
 
210
wndColors	resb	MOS_WNDCOLORS_size
211
procInfo	resb	MOS_PROCESSINFO_size
212
 
213
	; space for command line. at the end we have an additional
214
	; byte for a terminating zero, just to be sure...
215
cmdLine		resb	257
216
 
217
	alignb	4
218
stack		resb	STACKSIZE
219
stacktop:
220
 
221
	; don't insert anything after this label
222
memory_end:
223