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