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