Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1805 | yogev_ezra | 1 | //CODED by Veliant, Leency, Nable. GNU GPL licence. |
2 | |||
3 | #code32 TRUE |
||
4 | |||
5 | char os_name[8] = {'M','E','N','U','E','T','0','1'}; |
||
6 | dword os_version = 0x00000001; |
||
7 | dword start_addr = #main; |
||
8 | dword final_addr = #stop+32; |
||
9 | dword alloc_mem = 0x00100000; |
||
10 | dword x86esp_reg = 0x00100000; |
||
11 | dword I_Param = #param; |
||
12 | dword I_Icon = 0x0; |
||
13 | char param[256]=""; |
||
14 | |||
15 | //Events |
||
16 | #define evMouse 6 |
||
17 | #define evButton 3 |
||
18 | #define evKey 2 |
||
19 | #define evReDraw 1 |
||
20 | |||
21 | //Button options |
||
22 | #define BT_DEL 0x80000000 |
||
23 | #define BT_HIDE 0x40000000 |
||
24 | #define BT_NOFRAME 0x20000000 |
||
25 | |||
26 | #define OLD -1 |
||
27 | #define true 1 |
||
28 | #define false 0 |
||
29 | |||
30 | inline fastcall dword WaitEvent(){ |
||
31 | EAX = 10; |
||
32 | $int 0x40 |
||
33 | } |
||
34 | |||
35 | inline fastcall word GetKey(){ |
||
36 | EAX = 2; // just read this key from buffer |
||
37 | $int 0x40 |
||
38 | EAX = EAX >> 8; |
||
39 | } |
||
40 | |||
41 | inline fastcall word GetButtonID(){ |
||
42 | EAX = 17; |
||
43 | $int 0x40 |
||
44 | EAX = EAX >> 8; |
||
45 | } |
||
46 | |||
47 | inline fastcall dword strlen(dword EDI){ |
||
48 | EAX=0; |
||
49 | ECX=-1; |
||
50 | $REPNE $SCASB |
||
51 | EAX-=2+ECX; |
||
52 | } |
||
53 | |||
54 | byte WindowRePaint=0; |
||
55 | inline fastcall void WindowRedrawStatus(dword EBX) |
||
56 | { |
||
57 | EAX = 12; // function 12:tell os about windowdraw |
||
58 | $int 0x40 |
||
59 | IF (EBX==1) WindowRePaint=1; ELSE WindowRePaint=0; |
||
60 | } |
||
61 | |||
62 | void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI) |
||
63 | { |
||
64 | EBX = x << 16 + sizeX; |
||
65 | ECX = y << 16 + sizeY; |
||
66 | EDX = mainAreaType << 24 | mainAreaColour; |
||
67 | ESI = headerType << 24 | headerColour; |
||
68 | $xor eax,eax |
||
69 | $int 0x40 |
||
70 | } |
||
71 | |||
72 | |||
73 | void WriteText(dword x,y,byte fontType, dword color, EDX, ESI) |
||
74 | { |
||
75 | EAX = 4; |
||
76 | EBX = x<<16+y; |
||
77 | ECX = fontType<<24+color; |
||
78 | $int 0x40; |
||
79 | } |
||
80 | |||
81 | void WriteNumber(dword x,y,byte fontType, ESI, ECX) |
||
82 | { |
||
83 | EAX = 47; |
||
84 | EBX = 2<<16; |
||
85 | EDX = x<<16+y; |
||
86 | ESI = fontType<<24+ESI; |
||
87 | $int 0x40; |
||
88 | } |
||
89 | |||
90 | |||
91 | |||
92 | void DrawBar(dword x,y,w,h,EDX) |
||
93 | { |
||
94 | EAX = 13; |
||
95 | EBX = x<<16+w; |
||
96 | ECX = y<<16+h; |
||
97 | $int 0x40 |
||
98 | } |
||
99 | |||
100 | void DefineButton(dword x,y,w,h,EDX,ESI) |
||
101 | { |
||
102 | EAX = 8; |
||
103 | EBX = x<<16+w; |
||
104 | ECX = y<<16+h; |
||
105 | $int 0x40 |
||
106 | } |
||
107 | |||
108 | inline fastcall void DeleteButton(dword EDX) |
||
109 | { |
||
110 | EAX = 8; |
||
111 | EDX += BT_DEL; |
||
112 | $int 0x40; |
||
113 | } |
||
114 | |||
115 | void DrawFlatButton(dword x,y,width,height,id,color,text) |
||
116 | { |
||
117 | DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE); |
||
118 | DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7); |
||
119 | DrawBar(x+2,y+2,width-3,height-3,color); //§ «ЁўЄ |
||
120 | IF (id<>0) DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //Є®ЇЄ |
||
121 | WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0); |
||
122 | } |
||
123 | |||
124 | |||
125 | dword generator; // random number generator - для генерации случайных чисел |
||
126 | |||
127 | :int random(int max) |
||
128 | // get pseudo-random number - получить псевдослучайное число |
||
129 | { |
||
130 | $rdtsc // eax & edx |
||
131 | $xor eax,edx |
||
132 | $not eax |
||
133 | |||
134 | EBX = generator; |
||
135 | $ror ebx,3 |
||
136 | $xor ebx,0xdeadbeef |
||
137 | EBX += EAX; |
||
138 | generator = EBX; |
||
139 | |||
140 | EAX += EBX; |
||
141 | EAX = EAX % max; |
||
142 | return EAX; |
||
143 | } |
||
144 | |||
145 | :randomize() |
||
146 | // initialize random number generator - инициализировать генератор случайных чисел |
||
147 | { |
||
148 | asm |
||
149 | { |
||
150 | mov eax,3 |
||
151 | int 0x40 |
||
152 | ror eax,16 |
||
153 | } |
||
154 | generator = EAX; |
||
155 | } |
||
156 | |||
157 | inline fastcall ExitProcess(){ |
||
158 | EAX = -1; // close this program |
||
159 | $int 0x40 |
||
160 | } |
||
161 | |||
162 | void DrawRegion_3D(dword x,y,width,height,color1,color2) |
||
163 | { |
||
164 | DrawBar(x,y,width+1,1,color1); |
||
165 | DrawBar(x,y+1,1,height-1,color1); |
||
166 | DrawBar(x+width,y+1,1,height,color2); |
||
167 | DrawBar(x,y+height,width,1,color2); |
||
168 | }>16+h; |