Rev 7315 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7315 | Rev 7316 | ||
---|---|---|---|
1 | Comment *---------------------------+ |
1 | Comment *---------------------------+ |
2 | | | |
2 | | | |
3 | | Plasma Effect | |
3 | | Plasma Effect | |
4 | | | |
4 | | | |
5 | +-----------------------------------* |
5 | +-----------------------------------* |
6 | .686 |
6 | .686 |
7 | .Model Flat, StdCall |
7 | .Model Flat, StdCall |
8 | Option CaseMap: None |
8 | Option CaseMap: None |
9 | 9 | ||
10 | RepArg Macro Arg |
10 | RepArg Macro Arg |
11 | Local NewStr |
11 | Local NewStr |
12 | Quot SubStr |
12 | Quot SubStr |
13 | IfIdn Quot, <"> |
13 | IfIdn Quot, <"> |
14 | .Data |
14 | .Data |
15 | NewStr db Arg,0 |
15 | NewStr db Arg,0 |
16 | .Code |
16 | .Code |
17 | ExitM |
17 | ExitM |
18 | Else |
18 | Else |
19 | ExitM |
19 | ExitM |
20 | EndIf |
20 | EndIf |
21 | EndM |
21 | EndM |
22 | 22 | ||
23 | @ Macro Function:Req, Args:VarArg |
23 | @ Macro Function:Req, Args:VarArg |
24 | Arg equ |
24 | Arg equ |
25 | For Var, |
25 | For Var, |
26 | Arg CatStr Arg, <, RepArg(Var)> |
26 | Arg CatStr Arg, <, RepArg(Var)> |
27 | EndM |
27 | EndM |
28 | Arg |
28 | Arg |
29 | ExitM |
29 | ExitM |
30 | EndM |
30 | EndM |
31 | 31 | ||
32 | Public @Main |
32 | Public @Main |
33 | 33 | ||
34 | ; Event Constants |
34 | ; Event Constants |
35 | REDRAW_EVENT = 1 |
35 | REDRAW_EVENT = 1 |
36 | KEY_EVENT = 2 |
36 | KEY_EVENT = 2 |
37 | 37 | ||
38 | ; Event Mask Constants |
38 | ; Event Mask Constants |
39 | EM_REDRAW = 1 |
39 | EM_REDRAW = 1 |
40 | EM_KEY = 2 |
40 | EM_KEY = 2 |
41 | 41 | ||
42 | ; Window styles |
42 | ; Window styles |
43 | WS_FILL_TRANSPARENT = 40000000H |
43 | WS_FILL_TRANSPARENT = 40000000H |
44 | 44 | ||
45 | TSize Struct |
45 | TSize Struct |
46 | SizeY Word ? |
46 | SizeY Word ? |
47 | SizeX Word ? |
47 | SizeX Word ? |
48 | TSize EndS |
48 | TSize EndS |
49 | 49 | ||
50 | TRGBQuad Struct |
50 | TRGBQuad Struct |
51 | Blue Byte ? |
51 | Blue Byte ? |
52 | Green Byte ? |
52 | Green Byte ? |
53 | Red Byte ? |
53 | Red Byte ? |
54 | reserved Byte ? |
54 | reserved Byte ? |
55 | TRGBQuad EndS |
55 | TRGBQuad EndS |
56 | 56 | ||
57 | SetEventMask Proto EventMask:Dword |
57 | SetEventMask Proto EventMask:Dword |
58 | CheckEvent Proto |
58 | CheckEvent Proto |
59 | BeginDraw Proto |
59 | BeginDraw Proto |
60 | EndDraw Proto |
60 | EndDraw Proto |
61 | GetScreenSize Proto |
61 | GetScreenSize Proto |
62 | DrawWindow Proto Left:SDword, Top:SDword, Right:SDword, Bottom:SDword, Caption:Ptr, BackColor:Dword, Style:Dword, CapStyle:Dword |
62 | DrawWindow Proto Left:SDword, Top:SDword, Right:SDword, Bottom:SDword, Caption:Ptr, BackColor:Dword, Style:Dword, CapStyle:Dword |
63 | DrawImageEx Proto Image:Ptr, X:SDword, Y:SDword, XSize:Dword, YSize:Dword, BPP:Dword, Palette:Ptr, Padding:Dword |
63 | DrawImageEx Proto Image:Ptr, X:SDword, Y:SDword, XSize:Dword, YSize:Dword, BPP:Dword, Palette:Ptr, Padding:Dword |
64 | HeapCreate Proto |
64 | HeapCreate Proto |
65 | HeapAllocate Proto Bytes:Dword |
65 | HeapAllocate Proto Bytes:Dword |
66 | GetTickCount Proto |
66 | GetTickCount Proto |
67 | Sleep Proto Time:Dword |
67 | Sleep Proto Time:Dword |
68 | ThreadTerminate Proto |
68 | ThreadTerminate Proto |
69 | 69 | ||
70 | .Const |
70 | .Const |
71 | Float_50 Real4 50.0 ; to keep the FrameRate |
71 | Float_50 Real4 50.0 ; to keep the FrameRate |
72 | Float_40 Real4 40.0 ; around 40-50 FPS |
72 | Float_40 Real4 40.0 ; around 40-50 FPS |
73 | ; The table below can be calculated approximately as: SinTab[i] = Sin(2 * PI * i / 255) * 128 + 128 |
73 | ; The table below can be calculated approximately as: SinTab[i] = Sin(2 * PI * i / 255) * 128 + 128 |
74 | SinTab Label Byte |
74 | SinTab Label Byte |
75 | Byte 128, 131, 134, 137, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174 |
75 | Byte 128, 131, 134, 137, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174 |
76 | Byte 177, 180, 183, 186, 189, 191, 194, 197, 199, 202, 205, 207, 209, 212, 214, 217 |
76 | Byte 177, 180, 183, 186, 189, 191, 194, 197, 199, 202, 205, 207, 209, 212, 214, 217 |
77 | Byte 219, 221, 223, 225, 227, 229, 231, 233, 235, 236, 238, 240, 241, 243, 244, 245 |
77 | Byte 219, 221, 223, 225, 227, 229, 231, 233, 235, 236, 238, 240, 241, 243, 244, 245 |
78 | Byte 246, 248, 249, 250, 251, 252, 252, 253, 254, 254, 255, 255, 255, 255, 255, 255 |
78 | Byte 246, 248, 249, 250, 251, 252, 252, 253, 254, 254, 255, 255, 255, 255, 255, 255 |
79 | Byte 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 251, 250, 249, 248, 247 |
79 | Byte 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 251, 250, 249, 248, 247 |
80 | Byte 246, 245, 243, 242, 240, 239, 237, 236, 234, 232, 230, 228, 226, 224, 222, 220 |
80 | Byte 246, 245, 243, 242, 240, 239, 237, 236, 234, 232, 230, 228, 226, 224, 222, 220 |
81 | Byte 218, 215, 213, 211, 208, 206, 203, 201, 198, 195, 193, 190, 187, 184, 181, 179 |
81 | Byte 218, 215, 213, 211, 208, 206, 203, 201, 198, 195, 193, 190, 187, 184, 181, 179 |
82 | Byte 176, 173, 170, 167, 164, 161, 158, 155, 152, 148, 145, 142, 139, 136, 133, 130 |
82 | Byte 176, 173, 170, 167, 164, 161, 158, 155, 152, 148, 145, 142, 139, 136, 133, 130 |
83 | Byte 126, 123, 120, 117, 114, 111, 108, 104, 101, 98, 95, 92, 89, 86, 83, 80 |
83 | Byte 126, 123, 120, 117, 114, 111, 108, 104, 101, 98, 95, 92, 89, 86, 83, 80 |
84 | Byte 77, 75, 72, 69, 66, 63, 61, 58, 55, 53, 50, 48, 45, 43, 41, 38 |
84 | Byte 77, 75, 72, 69, 66, 63, 61, 58, 55, 53, 50, 48, 45, 43, 41, 38 |
85 | Byte 36, 34, 32, 30, 28, 26, 24, 22, 20, 19, 17, 16, 14, 13, 11, 10 |
85 | Byte 36, 34, 32, 30, 28, 26, 24, 22, 20, 19, 17, 16, 14, 13, 11, 10 |
86 | Byte 9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0 |
86 | Byte 9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0 |
87 | Byte 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 10 |
87 | Byte 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 10 |
88 | Byte 11, 12, 13, 15, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37 |
88 | Byte 11, 12, 13, 15, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37 |
89 | Byte 39, 42, 44, 47, 49, 51, 54, 57, 59, 62, 65, 67, 70, 73, 76, 79 |
89 | Byte 39, 42, 44, 47, 49, 51, 54, 57, 59, 62, 65, 67, 70, 73, 76, 79 |
90 | Byte 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 115, 119, 122, 125, 128 |
90 | Byte 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 115, 119, 122, 125, 128 |
91 | 91 | ||
92 | .Data |
92 | .Data |
93 | i1 Dword 50 |
93 | i1 Dword 50 |
94 | j1 Dword 90 |
94 | j1 Dword 90 |
95 | Freq Dword 100 ; // GetTickCount return count of 1/100s of second |
95 | Freq Dword 100 ; // GetTickCount return count of 1/100s of second |
96 | Instant Real4 0.0 |
96 | Instant Real4 0.0 |
97 | SleepTime Dword 0 |
97 | SleepTime Dword 0 |
98 | 98 | ||
99 | .Data? |
99 | .Data? |
100 | Screen TSize <> |
100 | Screen TSize <> |
101 | i2 Dword ? |
101 | i2 Dword ? |
102 | j2 Dword ? |
102 | j2 Dword ? |
103 | Palette TRGBQuad 256 Dup (<>) |
103 | Palette TRGBQuad 256 Dup (<>) |
104 | Image Dword ? |
104 | Image Dword ? |
105 | ImageWidth Dword ? |
105 | ImageWidth Dword ? |
106 | ImageHeight Dword ? |
106 | ImageHeight Dword ? |
107 | FrameStart Dword ? |
107 | FrameStart Dword ? |
108 | 108 | ||
109 | .Code |
109 | .Code |
110 | CreatePalette Proc Uses ebx |
110 | CreatePalette Proc Uses ebx |
111 | Local i:Dword |
111 | Local i:Dword |
112 | Local Red:Dword, Green:Dword, Blue:Dword |
112 | Local Red:Dword, Green:Dword, Blue:Dword |
113 | mov i, 0 |
113 | mov i, 0 |
114 | .Repeat |
114 | .Repeat |
115 | mov eax, i |
115 | mov eax, i |
116 | .If eax <= 63 |
116 | .If eax <= 63 |
117 | ; do nothing |
117 | ; do nothing |
118 | .ElseIf eax <= 127 |
118 | .ElseIf eax <= 127 |
119 | neg eax |
119 | neg eax |
120 | add eax, 127 |
120 | add eax, 127 |
121 | .ElseIf eax <= 189 |
121 | .ElseIf eax <= 189 |
122 | sub eax, 128 |
122 | sub eax, 128 |
123 | .ElseIf eax <= 255 |
123 | .ElseIf eax <= 255 |
124 | neg eax |
124 | neg eax |
125 | add eax, 255 |
125 | add eax, 255 |
126 | .EndIf |
126 | .EndIf |
127 | 127 | ||
128 | mov Red, eax |
128 | mov Red, eax |
129 | mov Green, eax |
129 | mov Green, eax |
130 | mov Blue, eax |
130 | mov Blue, eax |
131 | 131 | ||
132 | .If i <= 127 |
132 | .If i <= 127 |
133 | shl Green, 1 |
133 | shl Green, 1 |
134 | shl Blue, 2 |
134 | shl Blue, 2 |
135 | .ElseIf i <= 255 |
135 | .ElseIf i <= 255 |
136 | shl Red, 2 |
136 | shl Red, 2 |
137 | shl Blue, 1 |
137 | shl Blue, 1 |
138 | .EndIf |
138 | .EndIf |
139 | 139 | ||
140 | mov eax, Red ; |
140 | mov eax, Red ; |
141 | cmp eax, 255 ; |
141 | cmp eax, 255 ; |
142 | setna bl ; IF Red > 255 THEN bl = 255 |
142 | setna bl ; IF Red > 255 THEN bl = 255 |
143 | dec bl ; ELSE bl = Red |
143 | dec bl ; ELSE bl = Red |
144 | or bl, al ; |
144 | or bl, al ; |
145 | 145 | ||
146 | mov eax, Green ; |
146 | mov eax, Green ; |
147 | cmp eax, 255 ; |
147 | cmp eax, 255 ; |
148 | setna cl ; IF Green > 255 THEN cl = 255 |
148 | setna cl ; IF Green > 255 THEN cl = 255 |
149 | dec cl ; ELSE cl = Green |
149 | dec cl ; ELSE cl = Green |
150 | or cl, al ; |
150 | or cl, al ; |
151 | 151 | ||
152 | mov eax, Blue ; |
152 | mov eax, Blue ; |
153 | cmp eax, 255 ; |
153 | cmp eax, 255 ; |
154 | setna dl ; IF Blue > 255 THEN dl = 255 |
154 | setna dl ; IF Blue > 255 THEN dl = 255 |
155 | dec dl ; ELSE dl = Blue |
155 | dec dl ; ELSE dl = Blue |
156 | or dl, al ; |
156 | or dl, al ; |
157 | 157 | ||
158 | mov eax, i |
158 | mov eax, i |
159 | mov Palette.Red[eax * SizeOf(Type(Palette))], bl |
159 | mov Palette.Red[eax * SizeOf(Type(Palette))], bl |
160 | mov Palette.Green[eax * SizeOf(Type(Palette))], cl |
160 | mov Palette.Green[eax * SizeOf(Type(Palette))], cl |
161 | mov Palette.Blue[eax * SizeOf(Type(Palette))], dl |
161 | mov Palette.Blue[eax * SizeOf(Type(Palette))], dl |
162 | 162 | ||
163 | inc i |
163 | inc i |
164 | .Until i > 255 |
164 | .Until i > 255 |
165 | ret |
165 | ret |
166 | CreatePalette EndP |
166 | CreatePalette EndP |
167 | ;******************************************************************************* |
167 | ;******************************************************************************* |
168 | Render Proc |
168 | Render Proc |
169 | Local X:Dword, Y:Dword |
169 | Local X:Dword, Y:Dword |
170 | Local Row:Ptr |
170 | Local Row:Ptr |
171 | dec i1 |
171 | dec i1 |
172 | add j1, 2 |
172 | add j1, 2 |
173 | 173 | ||
174 | mov Y, 0 |
174 | mov Y, 0 |
175 | Align 4 |
175 | Align 4 |
176 | .Repeat |
176 | .Repeat |
177 | mov eax, Y |
177 | mov eax, Y |
178 | add eax, i1 |
178 | add eax, i1 |
179 | and eax, 255 |
179 | and eax, 255 |
180 | movzx eax, SinTab[eax] |
180 | movzx eax, SinTab[eax] |
181 | mov i2, eax |
181 | mov i2, eax |
182 | 182 | ||
183 | mov eax, j1 |
183 | mov eax, j1 |
184 | and eax, 255 |
184 | and eax, 255 |
185 | movzx eax, SinTab[eax] |
185 | movzx eax, SinTab[eax] |
186 | mov j2, eax |
186 | mov j2, eax |
187 | 187 | ||
188 | mov eax, Y |
188 | mov eax, Y |
189 | mul ImageWidth |
189 | mul ImageWidth |
190 | add eax, Image |
190 | add eax, Image |
191 | mov Row, eax |
191 | mov Row, eax |
192 | 192 | ||
193 | mov X, 0 |
193 | mov X, 0 |
194 | Align 4 |
194 | Align 4 |
195 | .Repeat |
195 | .Repeat |
196 | mov eax, X |
196 | mov eax, X |
197 | add eax, i2 |
197 | add eax, i2 |
198 | and eax, 255 |
198 | and eax, 255 |
199 | movzx ecx, SinTab[eax] |
199 | movzx ecx, SinTab[eax] |
200 | 200 | ||
201 | mov eax, Y |
201 | mov eax, Y |
202 | add eax, j2 |
202 | add eax, j2 |
203 | and eax, 255 |
203 | and eax, 255 |
204 | movzx eax, SinTab[eax] |
204 | movzx eax, SinTab[eax] |
205 | add ecx, eax |
205 | add ecx, eax |
206 | 206 | ||
207 | mov eax, Row |
207 | mov eax, Row |
208 | add eax, X |
208 | add eax, X |
209 | mov [eax], cl |
209 | mov [eax], cl |
210 | 210 | ||
211 | inc X |
211 | inc X |
212 | mov eax, ImageWidth |
212 | mov eax, ImageWidth |
213 | .Until eax == X |
213 | .Until eax == X |
214 | inc Y |
214 | inc Y |
215 | mov eax, ImageHeight |
215 | mov eax, ImageHeight |
216 | .Until eax == Y |
216 | .Until eax == Y |
217 | ret |
217 | ret |
218 | Render EndP |
218 | Render EndP |
219 | ;******************************************************************************* |
219 | ;******************************************************************************* |
220 | QueryPerf Proc |
220 | QueryPerf Proc |
221 | Local Diff:Dword |
221 | Local Diff:Dword |
222 | Invoke GetTickCount |
222 | Invoke GetTickCount |
223 | sub eax, FrameStart |
223 | sub eax, FrameStart |
224 | mov Diff, eax |
224 | mov Diff, eax |
225 | fild Diff |
225 | fild Diff |
226 | fild Freq |
226 | fild Freq |
227 | fdivrp |
227 | fdivrp |
228 | fstp Instant |
228 | fstp Instant |
229 | mov FrameStart, @(GetTickCount) |
229 | mov FrameStart, @(GetTickCount) |
230 | ret |
230 | ret |
231 | QueryPerf EndP |
231 | QueryPerf EndP |
232 | ;******************************************************************************* |
232 | ;******************************************************************************* |
233 | Waiting Proc |
233 | Waiting Proc |
234 | ; Keep the FrameRate around 40-50 FPS |
234 | ; Keep the FrameRate around 40-50 FPS |
235 | fld Float_50 |
235 | fld Float_50 |
236 | fld Instant |
236 | fld Instant |
237 | fcomip st(0), st(1) |
237 | fcomip st(0), st(1) |
238 | fstp st(0) |
238 | fstp st(0) |
239 | .If ABOVE? |
239 | .If !CARRY? && !ZERO? |
240 | inc SleepTime |
240 | inc SleepTime |
241 | .Else |
241 | .Else |
242 | fld Float_40 |
242 | fld Float_40 |
243 | fld Instant |
243 | fld Instant |
244 | fcomip st(0), st(1) |
244 | fcomip st(0), st(1) |
245 | fstp st(0) |
245 | fstp st(0) |
246 | .If BELOW? && (SleepTime != 0) |
246 | .If CARRY? && (SleepTime != 0) |
247 | dec SleepTime |
247 | dec SleepTime |
248 | .EndIf |
248 | .EndIf |
249 | .EndIf |
249 | .EndIf |
250 | Invoke Sleep, SleepTime |
250 | Invoke Sleep, SleepTime |
251 | ret |
251 | ret |
252 | Waiting EndP |
252 | Waiting EndP |
253 | ;******************************************************************************* |
253 | ;******************************************************************************* |
254 | @Main: |
254 | @Main: |
255 | Invoke HeapCreate |
255 | Invoke HeapCreate |
256 | mov Screen, @(GetScreenSize) |
256 | mov Screen, @(GetScreenSize) |
257 | Invoke CreatePalette |
257 | Invoke CreatePalette |
258 | movzx eax, Screen.SizeX |
258 | movzx eax, Screen.SizeX |
259 | movzx ecx, Screen.SizeY |
259 | movzx ecx, Screen.SizeY |
260 | mov ImageWidth, eax |
260 | mov ImageWidth, eax |
261 | mov ImageHeight, ecx |
261 | mov ImageHeight, ecx |
262 | mul ecx |
262 | mul ecx |
263 | mov Image, @(HeapAllocate, eax) |
263 | mov Image, @(HeapAllocate, eax) |
264 | mov FrameStart, @(GetTickCount) |
264 | mov FrameStart, @(GetTickCount) |
265 | Invoke SetEventMask, EM_REDRAW + EM_KEY |
265 | Invoke SetEventMask, EM_REDRAW + EM_KEY |
266 | .Repeat |
266 | .Repeat |
267 | Invoke CheckEvent |
267 | Invoke CheckEvent |
268 | .If eax == REDRAW_EVENT |
268 | .If eax == REDRAW_EVENT |
269 | Invoke BeginDraw |
269 | Invoke BeginDraw |
270 | Invoke DrawWindow, 0, 0, ImageWidth, ImageHeight, 0, 0, WS_FILL_TRANSPARENT, 0 |
270 | Invoke DrawWindow, 0, 0, ImageWidth, ImageHeight, 0, 0, WS_FILL_TRANSPARENT, 0 |
271 | Invoke EndDraw |
271 | Invoke EndDraw |
272 | .ElseIf eax == KEY_EVENT |
272 | .ElseIf eax == KEY_EVENT |
273 | Invoke ThreadTerminate |
273 | Invoke ThreadTerminate |
274 | .Else |
274 | .Else |
275 | Invoke Render |
275 | Invoke Render |
276 | Invoke QueryPerf |
276 | Invoke QueryPerf |
277 | Invoke DrawImageEx, Image, 0, 0, ImageWidth, ImageHeight, 8, Offset Palette, 0 |
277 | Invoke DrawImageEx, Image, 0, 0, ImageWidth, ImageHeight, 8, Offset Palette, 0 |
278 | Invoke Waiting |
278 | Invoke Waiting |
279 | .EndIf |
279 | .EndIf |
280 | .Until 0 |
280 | .Until 0 |
281 | END=>=>=>=>=>=>>>,>"> |
281 | END=>=>=>=>=>=>>>,>"> |