Rev 353 | Go to most recent revision | Details | Compare with Previous | 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 | |||
485 | heavyiron | 19 | include '..\..\..\..\macros.inc' |
31 | halyavin | 20 | |
21 | |||
22 | |||
23 | START: ; start of execution |
||
24 | |||
25 | call shape_window ; function for shaping |
||
353 | heavyiron | 26 | red: |
31 | halyavin | 27 | call draw_window ; at first, draw the window |
28 | |||
29 | still: |
||
30 | |||
31 | mov eax,10 ; wait here for event |
||
485 | heavyiron | 32 | mcall |
31 | halyavin | 33 | |
353 | heavyiron | 34 | dec eax ; redraw request ? |
35 | jz red |
||
36 | dec eax ; key in buffer ? |
||
37 | jz key |
||
31 | halyavin | 38 | |
353 | heavyiron | 39 | button: |
40 | mov al,17 ; get id |
||
485 | heavyiron | 41 | mcall |
31 | halyavin | 42 | |
353 | heavyiron | 43 | cmp ah,1 ; button id=1 ? |
44 | jne noclose |
||
45 | or eax,-1 ; close this program |
||
485 | heavyiron | 46 | mcall |
31 | halyavin | 47 | |
48 | key: ; key |
||
353 | heavyiron | 49 | mov al,2 ; just read it and ignore |
485 | heavyiron | 50 | mcall |
31 | halyavin | 51 | jmp still |
52 | noclose: |
||
53 | |||
54 | jmp still |
||
55 | |||
56 | |||
57 | shape_window: |
||
58 | |||
59 | pusha |
||
60 | |||
61 | mov eax,50 ; give the shape reference area |
||
62 | mov ebx,0 |
||
63 | mov ecx,shape_reference |
||
485 | heavyiron | 64 | mcall |
31 | halyavin | 65 | |
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 |
||
68 | mov ecx,2 |
||
485 | heavyiron | 69 | mcall |
31 | halyavin | 70 | |
71 | popa |
||
72 | |||
73 | ret |
||
74 | |||
75 | |||
76 | shape_reference: ; 32 x 32 ( window_size_X + 1 ) * ( window_size_Y + 1 ) |
||
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 |
||
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,0,0,0,0,0,0,0 |
||
80 | 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 |
||
81 | 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 |
||
82 | 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 |
||
83 | 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 |
||
84 | 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 |
||
85 | 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 |
||
86 | 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 |
||
87 | 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 |
||
88 | 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 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||
103 | 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 |
||
104 | 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 |
||
105 | 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 |
||
106 | 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 |
||
107 | 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 |
||
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 |
||
110 | |||
111 | |||
112 | ; ********************************************* |
||
113 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
114 | ; ********************************************* |
||
115 | |||
116 | |||
117 | draw_window: |
||
118 | |||
119 | mov eax,12 ; function 12:tell os about windowdraw |
||
120 | mov ebx,1 ; 1, start of draw |
||
485 | heavyiron | 121 | mcall |
31 | halyavin | 122 | |
123 | ; DRAW WINDOW |
||
353 | heavyiron | 124 | xor eax,eax ; function 0 : define and draw window |
31 | halyavin | 125 | mov ebx,100*65536 ; [x start] *65536 + [x size] |
126 | mov ecx,100*65536 ; [y start] *65536 + [y size] |
||
127 | mov bx,word [x_size] |
||
128 | mov cx,word [y_size] |
||
129 | mov edx,0x00cccc00 ; color of work area RRGGBB,8->color glide |
||
130 | mov esi,0x00cccc00 ; color of grab bar RRGGBB,8->color glide |
||
131 | mov edi,0x00cccc00 ; color of frames RRGGBB |
||
485 | heavyiron | 132 | mcall |
31 | halyavin | 133 | |
134 | |||
135 | ; CLOSE BUTTON |
||
136 | mov eax,8 ; function 8 : define and draw button |
||
137 | mov ebx,78*65536+12 ; [x start] *65536 + [x size] |
||
138 | mov ecx,20*65536+12 ; [y start] *65536 + [y size] |
||
139 | mov edx,1 ; button id |
||
140 | mov esi,0x5599cc ; button color RRGGBB |
||
485 | heavyiron | 141 | mcall |
31 | halyavin | 142 | |
143 | |||
144 | mov eax,12 ; function 12:tell os about windowdraw |
||
145 | mov ebx,2 ; 2, end of draw |
||
485 | heavyiron | 146 | mcall |
31 | halyavin | 147 | |
148 | ret |
||
149 | |||
150 | |||
151 | ; DATA AREA |
||
152 | |||
153 | |||
154 | x_size dd 127 |
||
155 | y_size dd 127 |
||
156 | |||
157 | |||
158 | I_END: |