Rev 109 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; |
2 | ; SHAPED WINDOW - BASIC EXAMPLE |
||
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 0x1000 ; required amount of memory |
||
16 | dd 0x1000 ; esp |
||
17 | dd 0x00000000 ; reserved=no extended header |
||
18 | |||
19 | include 'lang.inc' |
||
20 | include 'macros.inc' |
||
21 | |||
22 | |||
23 | |||
24 | START: ; start of execution |
||
25 | |||
26 | call shape_window ; function for shaping |
||
27 | |||
28 | call draw_window ; at first, draw the window |
||
29 | |||
30 | still: |
||
31 | |||
32 | mov eax,10 ; wait here for event |
||
33 | int 0x40 |
||
34 | |||
35 | cmp eax,1 ; redraw request ? |
||
36 | je red |
||
37 | cmp eax,2 ; key in buffer ? |
||
38 | je key |
||
39 | cmp eax,3 ; button in buffer ? |
||
40 | je button |
||
41 | |||
42 | jmp still |
||
43 | |||
44 | red: ; redraw |
||
45 | call draw_window |
||
46 | jmp still |
||
47 | |||
48 | key: ; key |
||
49 | mov eax,2 ; just read it and ignore |
||
50 | int 0x40 |
||
51 | jmp still |
||
52 | |||
53 | button: ; button |
||
54 | mov eax,17 ; get id |
||
55 | int 0x40 |
||
56 | |||
57 | cmp ah,1 ; button id=1 ? |
||
58 | jne noclose |
||
59 | mov eax,-1 ; close this program |
||
60 | int 0x40 |
||
61 | noclose: |
||
62 | |||
63 | jmp still |
||
64 | |||
65 | |||
66 | shape_window: |
||
67 | |||
68 | pusha |
||
69 | |||
70 | mov eax,50 ; give the shape reference area |
||
71 | mov ebx,0 |
||
72 | mov ecx,shape_reference |
||
73 | int 0x40 |
||
74 | |||
75 | mov eax,50 ; give the shape scale 32 x 32 -> 128 x 128 |
||
76 | mov ebx,1 ; you dont have to give this, scale is 1:1 by default |
||
77 | mov ecx,2 |
||
78 | int 0x40 |
||
79 | |||
80 | popa |
||
81 | |||
82 | ret |
||
83 | |||
84 | |||
85 | shape_reference: ; 32 x 32 ( window_size_X + 1 ) * ( window_size_Y + 1 ) |
||
86 | |||
87 | db 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0 |
||
88 | db 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0 |
||
89 | db 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0 |
||
90 | db 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0 |
||
91 | db 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0 |
||
92 | db 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0 |
||
93 | db 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0 |
||
94 | db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 |
||
95 | db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 |
||
96 | db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 |
||
97 | db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0 |
||
98 | db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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1,1,1,1,1,1,1,1,1,1,0,0,0 |
||
113 | db 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0 |
||
114 | db 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0 |
||
115 | db 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0 |
||
116 | db 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0 |
||
117 | db 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0 |
||
118 | db 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0 |
||
119 | |||
120 | |||
121 | ; ********************************************* |
||
122 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
123 | ; ********************************************* |
||
124 | |||
125 | |||
126 | draw_window: |
||
127 | |||
128 | mov eax,12 ; function 12:tell os about windowdraw |
||
129 | mov ebx,1 ; 1, start of draw |
||
130 | int 0x40 |
||
131 | |||
132 | ; DRAW WINDOW |
||
133 | mov eax,0 ; function 0 : define and draw window |
||
134 | mov ebx,100*65536 ; [x start] *65536 + [x size] |
||
135 | mov ecx,100*65536 ; [y start] *65536 + [y size] |
||
136 | mov bx,word [x_size] |
||
137 | mov cx,word [y_size] |
||
138 | mov edx,0x00cccc00 ; color of work area RRGGBB,8->color glide |
||
139 | mov esi,0x00cccc00 ; color of grab bar RRGGBB,8->color glide |
||
140 | mov edi,0x00cccc00 ; color of frames RRGGBB |
||
141 | int 0x40 |
||
142 | |||
143 | |||
144 | ; CLOSE BUTTON |
||
145 | mov eax,8 ; function 8 : define and draw button |
||
146 | mov ebx,78*65536+12 ; [x start] *65536 + [x size] |
||
147 | mov ecx,20*65536+12 ; [y start] *65536 + [y size] |
||
148 | mov edx,1 ; button id |
||
149 | mov esi,0x5599cc ; button color RRGGBB |
||
150 | int 0x40 |
||
151 | |||
152 | |||
153 | mov eax,12 ; function 12:tell os about windowdraw |
||
154 | mov ebx,2 ; 2, end of draw |
||
155 | int 0x40 |
||
156 | |||
157 | ret |
||
158 | |||
159 | |||
160 | ; DATA AREA |
||
161 | |||
162 | |||
163 | x_size dd 127 |
||
164 | y_size dd 127 |
||
165 | |||
166 | |||
167 | I_END: |