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