Rev 109 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 109 | Rev 485 | ||
---|---|---|---|
1 | ; |
1 | ; |
2 | ; EXAMPLE APPLICATION |
2 | ; EXAMPLE APPLICATION |
3 | ; |
3 | ; |
4 | ; Compile with FASM for Menuet |
4 | ; Compile with FASM for Menuet |
5 | ; |
5 | ; |
6 | 6 | ||
7 | use32 |
7 | use32 |
8 | 8 | ||
9 | org 0x0 |
9 | org 0x0 |
10 | 10 | ||
11 | db 'MENUET00' ; 8 byte id |
11 | db 'MENUET00' ; 8 byte id |
12 | dd 38 ; required os |
12 | dd 38 ; required os |
13 | dd START ; program start |
13 | dd START ; program start |
14 | dd I_END ; program image size |
14 | dd I_END ; program image size |
15 | dd 0x8000 ; required amount of memory |
15 | dd 0x8000 ; required amount of memory |
16 | dd 0x8000 ; esp = 0x7FFF0 |
16 | dd 0x8000 ; esp = 0x7FFF0 |
17 | dd 0x00000000 ; reserved=no extended header |
17 | dd 0x00000000 ; reserved=no extended header |
18 | 18 | ||
19 | include 'lang.inc' |
19 | include 'lang.inc' |
20 | include 'macros.inc' |
20 | include '..\..\..\macros.inc' |
21 | 21 | ||
22 | begin dd 0 |
22 | begin dd 0 |
23 | 23 | ||
24 | START: ; start of execution |
24 | START: ; start of execution |
25 | 25 | ||
26 | call open_file |
26 | call open_file |
27 | 27 | ||
28 | red: |
28 | red: |
29 | call draw_window ; at first, draw the window |
29 | call draw_window ; at first, draw the window |
30 | 30 | ||
31 | still: |
31 | still: |
32 | 32 | ||
33 | mov eax,10 ; wait here for event |
33 | mov eax,10 ; wait here for event |
34 | int 0x40 |
34 | mcall |
35 | 35 | ||
36 | dec eax ; redraw request ? |
36 | dec eax ; redraw request ? |
37 | je red |
37 | je red |
38 | dec eax ; key in buffer ? |
38 | dec eax ; key in buffer ? |
39 | je key |
39 | je key |
40 | dec eax ; button in buffer ? |
40 | dec eax ; button in buffer ? |
41 | je button |
41 | je button |
42 | 42 | ||
43 | jmp still |
43 | jmp still |
44 | 44 | ||
45 | ; red: ; redraw |
45 | ; red: ; redraw |
46 | ; call draw_window |
46 | ; call draw_window |
47 | ; jmp still |
47 | ; jmp still |
48 | 48 | ||
49 | key: ; key |
49 | key: ; key |
50 | mov eax,2 ; just read it and ignore |
50 | mov eax,2 ; just read it and ignore |
51 | int 0x40 |
51 | mcall |
52 | jmp still |
52 | jmp still |
53 | 53 | ||
54 | button: ; button |
54 | button: ; button |
55 | mov eax,17 ; get id |
55 | mov eax,17 ; get id |
56 | int 0x40 |
56 | mcall |
57 | 57 | ||
58 | cmp ah,3 |
58 | cmp ah,3 |
59 | jne no_up |
59 | jne no_up |
60 | cmp [begin],16 |
60 | cmp [begin],16 |
61 | jb no_up |
61 | jb no_up |
62 | 62 | ||
63 | add [begin],-16 |
63 | add [begin],-16 |
64 | jmp red |
64 | jmp red |
65 | no_up: |
65 | no_up: |
66 | 66 | ||
67 | cmp ah,4 |
67 | cmp ah,4 |
68 | jne no_down |
68 | jne no_down |
69 | add [begin],16 |
69 | add [begin],16 |
70 | jmp red |
70 | jmp red |
71 | no_down: |
71 | no_down: |
72 | 72 | ||
73 | dec ah ; button id=1 ? |
73 | dec ah ; button id=1 ? |
74 | jne still |
74 | jne still |
75 | xor eax,eax ; close this program |
75 | or eax,-1 ; close this program |
76 | dec eax |
76 | mcall |
77 | int 0x40 |
- | |
78 | 77 | ||
79 | 78 | ||
80 | ; ********************************************* |
79 | ; ********************************************* |
81 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
80 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
82 | ; ********************************************* |
81 | ; ********************************************* |
83 | 82 | ||
84 | 83 | ||
85 | draw_window: |
84 | draw_window: |
86 | 85 | ||
87 | mov eax,12 ; function 12:tell os about windowdraw |
86 | mov eax,12 ; function 12:tell os about windowdraw |
88 | mov ebx,1 ; 1, start of draw |
87 | mov ebx,1 ; 1, start of draw |
89 | int 0x40 |
88 | mcall |
90 | 89 | ||
91 | ; DRAW WINDOW |
90 | ; DRAW WINDOW |
92 | xor eax,eax ; function 0 : define and draw window |
91 | xor eax,eax ; function 0 : define and draw window |
93 | mov ebx,100*65536+400 ; [x start] *65536 + [x size] |
92 | mov ebx,100*65536+400 ; [x start] *65536 + [x size] |
94 | mov ecx,100*65536+270 ; [y start] *65536 + [y size] |
93 | mov ecx,100*65536+270 ; [y start] *65536 + [y size] |
95 | mov edx,0x03224466 ; color of work area RRGGBB,8->c |
94 | mov edx,0x13224466 ; color of work area RRGGBB,8->c |
96 | mov esi,0x006688aa ; color of grab bar RRGGBB,8->color gl |
- | |
97 | mov edi,0x00ffffff ; color of frames RRGGBB |
95 | mov edi,title ; WINDOW LABEL |
98 | int 0x40 |
96 | mcall |
99 | 97 | ||
100 | ; WINDOW LABEL |
- | |
101 | mov eax,4 ; function 4 : write text to window |
- | |
102 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
- | |
103 | mov ecx,0x00ffffff ; color of text RRGGBB |
- | |
104 | mov edx,labelt ; pointer to text beginning |
- | |
105 | mov esi,labellen-labelt ; text length |
- | |
106 | int 0x40 |
- | |
107 | 98 | ||
108 | mov eax,8 |
99 | mov eax,8 |
109 | mov ebx,280*65536+16*6 |
100 | mov ebx,280*65536+16*6 |
110 | mov ecx,240*65536+14 |
101 | mov ecx,240*65536+14 |
111 | mov edx,2 |
102 | mov edx,2 |
112 | mov esi,0x5599cc |
103 | mov esi,0x5599cc |
113 | int 0x40 |
104 | mcall |
114 | 105 | ||
115 | mov ebx,15*65536+125 |
106 | mov ebx,15*65536+125 |
116 | inc edx |
107 | inc edx |
117 | int 0x40 |
108 | mcall |
118 | 109 | ||
119 | 110 | ||
120 | add ebx,127*65536 |
111 | add ebx,127*65536 |
121 | inc edx |
112 | inc edx |
122 | int 0x40 |
113 | mcall |
123 | 114 | ||
124 | 115 | ||
125 | mov eax,4 |
116 | mov eax,4 |
126 | mov ebx,15*65536+243 |
117 | mov ebx,15*65536+243 |
127 | mov ecx,0xffffff |
118 | mov ecx,0xffffff |
128 | mov edx,buttons |
119 | mov edx,buttons |
129 | mov esi,blen-buttons |
120 | mov esi,blen-buttons |
130 | int 0x40 |
121 | mcall |
131 | 122 | ||
132 | 123 | ||
133 | mov ebx,280*65536+35 ; draw info text with function 4 |
124 | mov ebx,280*65536+35 ; draw info text with function 4 |
134 | mov ecx,0xffffff |
125 | mov ecx,0xffffff |
135 | mov edx,text |
126 | mov edx,text |
136 | add edx,[begin] |
127 | add edx,[begin] |
137 | 128 | ||
138 | mov esi,16 |
129 | mov esi,16 |
139 | mov edi,esi |
130 | mov edi,esi |
140 | newline: |
131 | newline: |
141 | 132 | ||
142 | push ebx ; hext |
133 | push ebx ; hext |
143 | push edx |
134 | push edx |
144 | push edi |
135 | push edi |
145 | 136 | ||
146 | mov edi,16 |
137 | mov edi,16 |
147 | mov ecx,edx |
138 | mov ecx,edx |
148 | mov edx,ebx |
139 | mov edx,ebx |
149 | add edx,-265*65536 |
140 | add edx,-265*65536 |
150 | 141 | ||
151 | mov eax,47 |
142 | mov eax,47 |
152 | mov ebx,0x00020101 |
143 | mov ebx,0x00020101 |
153 | mov esi,0xffff00 |
144 | mov esi,0xffff00 |
154 | 145 | ||
155 | newhex: |
146 | newhex: |
156 | 147 | ||
157 | ; mov ebx,0x00020101 |
148 | ; mov ebx,0x00020101 |
158 | ; mov esi,0xffff00 |
149 | ; mov esi,0xffff00 |
159 | int 0x40 |
150 | mcall |
160 | 151 | ||
161 | add edx,16*65536 |
152 | add edx,16*65536 |
162 | inc ecx |
153 | inc ecx |
163 | dec edi |
154 | dec edi |
164 | jne newhex |
155 | jne newhex |
165 | 156 | ||
166 | ; popa |
157 | ; popa |
167 | pop edi |
158 | pop edi |
168 | pop edx |
159 | pop edx |
169 | pop ebx |
160 | pop ebx |
170 | 161 | ||
171 | mov eax,4 ; text |
162 | mov eax,4 ; text |
172 | mov esi,16 |
163 | mov esi,16 |
173 | mov ecx,0xffffff |
164 | mov ecx,0xffffff |
174 | int 0x40 |
165 | mcall |
175 | add ebx,12 |
166 | add ebx,12 |
176 | add edx,16 |
167 | add edx,16 |
177 | dec edi |
168 | dec edi |
178 | jnz newline |
169 | jnz newline |
179 | 170 | ||
180 | mov eax,12 ; function 12:tell os about windowdraw |
171 | mov eax,12 ; function 12:tell os about windowdraw |
181 | mov ebx,2 ; 2, end of draw |
172 | mov ebx,2 ; 2, end of draw |
182 | int 0x40 |
173 | mcall |
183 | 174 | ||
184 | ret |
175 | ret |
185 | 176 | ||
186 | 177 | ||
187 | 178 | ||
188 | file_name db 'EXAMPLE.ASM ' |
179 | file_name db 'EXAMPLE.ASM ' |
189 | ; db 'EXAMPLE ' |
180 | ; db 'EXAMPLE ' |
190 | 181 | ||
191 | open_file: |
182 | open_file: |
192 | 183 | ||
193 | pusha |
184 | pusha |
194 | 185 | ||
195 | mov eax,6 |
186 | mov eax,6 |
196 | mov ebx,file_name |
187 | mov ebx,file_name |
197 | xor ecx,ecx |
188 | xor ecx,ecx |
198 | mov edx,-1 |
189 | mov edx,-1 |
199 | mov esi,text |
190 | mov esi,text |
200 | int 0x40 |
191 | mcall |
201 | 192 | ||
202 | popa |
193 | popa |
203 | 194 | ||
204 | ret |
195 | ret |
205 | 196 | ||
206 | 197 | ||
207 | 198 | ||
208 | ; DATA AREA |
199 | ; DATA AREA |
209 | 200 | ||
210 | labelt: db 'HEXVIEW' |
- | |
211 | labellen: |
201 | title db 'HEXVIEW',0 |
212 | 202 | ||
213 | buttons db ' UP DOWN' |
203 | buttons db ' UP DOWN' |
214 | db ' EXAMPLE ' |
204 | db ' EXAMPLE ' |
215 | blen: |
205 | blen: |
216 | 206 | ||
217 | text: |
207 | text: |
218 | 208 | ||
219 | I_END: |
209 | I_END: |