Rev 109 | Rev 551 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 109 | Rev 485 | ||
---|---|---|---|
1 | ; tinyfrac.asm |
1 | ; tinyfrac.asm |
2 | ; |
2 | ; |
3 | ; teeny program displays the Mandelbrot set. |
3 | ; teeny program displays the Mandelbrot set. |
4 | ; |
4 | ; |
5 | ; written on Sun 03-26-1995 by Ed Beroset (Fidonet 1:3641/1.250) |
5 | ; written on Sun 03-26-1995 by Ed Beroset (Fidonet 1:3641/1.250) |
6 | ; |
6 | ; |
7 | ; This program was based on a program by Frank Hommers, later optimized |
7 | ; This program was based on a program by Frank Hommers, later optimized |
8 | ; for size by Mikko Hyvarinen and posted in Fidonet's 80XXX echo. |
8 | ; for size by Mikko Hyvarinen and posted in Fidonet's 80XXX echo. |
9 | ; |
9 | ; |
10 | ; This new version has many new features and was based on my own |
10 | ; This new version has many new features and was based on my own |
11 | ; optimization of Hyvarinen's version. Some features: |
11 | ; optimization of Hyvarinen's version. Some features: |
12 | ; |
12 | ; |
13 | ; pan using the arrow keys, one can navigate the fractal. |
13 | ; pan using the arrow keys, one can navigate the fractal. |
14 | ; |
14 | ; |
15 | ; Home Up PgUp |
15 | ; Home Up PgUp |
16 | ; Left Right correspond to 8 obvious directions |
16 | ; Left Right correspond to 8 obvious directions |
17 | ; End Dn PgDn |
17 | ; End Dn PgDn |
18 | ; |
18 | ; |
19 | ; zoom there are now ten levels of magnification available. If the |
19 | ; zoom there are now ten levels of magnification available. If the |
20 | ; program is assembled with FEATURES defined, the number |
20 | ; program is assembled with FEATURES defined, the number |
21 | ; corresponding to the zoom level (0-9, zero is most zoomed in) |
21 | ; corresponding to the zoom level (0-9, zero is most zoomed in) |
22 | ; is displayed in the upper left hand corner of the screen just |
22 | ; is displayed in the upper left hand corner of the screen just |
23 | ; before each new fractal is drawn. The gray '+' key zooms out, |
23 | ; before each new fractal is drawn. The gray '+' key zooms out, |
24 | ; the gray '-' key zooms in. |
24 | ; the gray '-' key zooms in. |
25 | ; |
25 | ; |
26 | ; beep the program will beep at the completion of each fractal |
26 | ; beep the program will beep at the completion of each fractal |
27 | ; drawing or if the user attempts to zoom past either limit. |
27 | ; drawing or if the user attempts to zoom past either limit. |
28 | ; |
28 | ; |
29 | ; mode if the program is assembled with MODECHANGE defined, the |
29 | ; mode if the program is assembled with MODECHANGE defined, the |
30 | ; will change to the next video mode if the 'v' key is pressed. |
30 | ; will change to the next video mode if the 'v' key is pressed. |
31 | ; This is handy because drawing fractals at high resolution can |
31 | ; This is handy because drawing fractals at high resolution can |
32 | ; be very timeconsuming. The user can find an interesting spot |
32 | ; be very timeconsuming. The user can find an interesting spot |
33 | ; in a low res mode and then change to a high res mode to see it |
33 | ; in a low res mode and then change to a high res mode to see it |
34 | ; more fully rendered. |
34 | ; more fully rendered. |
35 | ; |
35 | ; |
36 | ; size this whole project was started off as a size optimization |
36 | ; size this whole project was started off as a size optimization |
37 | ; exercise, so there have been some rather ugly tradeoffs to |
37 | ; exercise, so there have been some rather ugly tradeoffs to |
38 | ; sacrifice speed for size. |
38 | ; sacrifice speed for size. |
39 | ; |
39 | ; |
40 | ; 8086 yes, it runs on an 8086 although only if you leave out either |
40 | ; 8086 yes, it runs on an 8086 although only if you leave out either |
41 | ; the FEATURES option or the MODECHANGE option and it would be |
41 | ; the FEATURES option or the MODECHANGE option and it would be |
42 | ; slower and more painful than oral surgery. |
42 | ; slower and more painful than oral surgery. |
43 | ; |
43 | ; |
44 | ; cost there IS such a thing as a free lunch! This code is hereby |
44 | ; cost there IS such a thing as a free lunch! This code is hereby |
45 | ; released to the public domain by the author. |
45 | ; released to the public domain by the author. |
46 | ; |
46 | ; |
47 | ; |
47 | ; |
48 | ; to assemble & link: |
48 | ; to assemble & link: |
49 | ; TASM /m2 tinyfrac (assemble using two pass mode if required) |
49 | ; TASM /m2 tinyfrac (assemble using two pass mode if required) |
50 | ; TLINK /Tdc tinyfrac (link Target platform is DOS, COM file) |
50 | ; TLINK /Tdc tinyfrac (link Target platform is DOS, COM file) |
51 | ; |
51 | ; |
52 | ; |
52 | ; |
53 | 53 | ||
54 | PIXWIDTH equ 511 |
54 | PIXWIDTH equ 511 |
55 | PIXHEIGHT equ 255 |
55 | PIXHEIGHT equ 255 |
56 | 56 | ||
57 | ZOOMLIMIT equ 13 ; can change to up to 13 for extended zoom in |
57 | ZOOMLIMIT equ 13 ; can change to up to 13 for extended zoom in |
58 | 58 | ||
59 | ; feel free to experiment with the following constants: |
59 | ; feel free to experiment with the following constants: |
60 | 60 | ||
61 | DELTA equ 200 ; the unit of pan movement in pixels |
61 | DELTA equ 200 ; the unit of pan movement in pixels |
62 | THRESHOLD equ 7 ; must be in the range of (0,255) |
62 | THRESHOLD equ 7 ; must be in the range of (0,255) |
63 | STARTSCALE equ 5 ; a number from 0 to ZOOMLIMIT, inclusive |
63 | STARTSCALE equ 5 ; a number from 0 to ZOOMLIMIT, inclusive |
64 | CHAR_COLOR equ 0fh ; white on black background (for PRINTZOOM feature) |
64 | CHAR_COLOR equ 0fh ; white on black background (for PRINTZOOM feature) |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | ; ************************************************************ |
68 | ; ************************************************************ |
69 | ; |
69 | ; |
70 | ; Menuet header |
70 | ; Menuet header |
71 | 71 | ||
72 | 72 | ||
73 | use32 |
73 | use32 |
74 | 74 | ||
75 | org 0x0 |
75 | org 0x0 |
76 | 76 | ||
77 | db 'MENUET01' |
77 | db 'MENUET01' |
78 | dd 0x01 |
78 | dd 0x01 |
79 | dd START |
79 | dd START |
80 | dd I_END |
80 | dd I_END |
81 | dd 0x62000 |
81 | dd 0x62000 |
82 | dd 0x1000 |
82 | dd 0x1000 |
83 | dd 0,0 |
83 | dd 0,0 |
84 | 84 | ||
85 | include 'lang.inc' |
85 | include 'lang.inc' |
86 | include 'macros.inc' |
86 | include '..\..\..\macros.inc' |
87 | 87 | ||
88 | STARTX dd 200 |
88 | STARTX dd 200 |
89 | STARTY dd 120 |
89 | STARTY dd 120 |
90 | 90 | ||
91 | scaleaddy dd 120 |
91 | scaleaddy dd 120 |
92 | scaleaddx dd 200 |
92 | scaleaddx dd 200 |
93 | 93 | ||
94 | START: |
94 | START: |
- | 95 | ||
95 | 96 | red: |
|
96 | call draw_window |
- | |
97 | 97 | call draw_window |
|
98 | call draw_fractal |
98 | call draw_fractal |
99 | 99 | ||
100 | still: |
100 | still: |
101 | 101 | ||
102 | mov eax,10 |
102 | mov eax,10 |
- | 103 | mcall |
|
- | 104 | ||
- | 105 | dec eax |
|
- | 106 | jz red |
|
- | 107 | dec eax |
|
- | 108 | jz key |
|
- | 109 | ||
- | 110 | button: |
|
- | 111 | mov al,17 |
|
- | 112 | mcall |
|
- | 113 | ||
103 | int 0x40 |
114 | cmp ah,1 |
- | 115 | jne no_close |
|
- | 116 | or eax,-1 |
|
- | 117 | mcall |
|
- | 118 | no_close: |
|
104 | 119 | ||
105 | cmp eax,1 |
120 | cmp ah,2 |
- | 121 | jne no_bgr |
|
- | 122 | ||
- | 123 | ||
- | 124 | mov eax,15 ; bgr 512 x 256 |
|
- | 125 | mov ebx,1 |
|
- | 126 | mov ecx,512 |
|
- | 127 | mov edx,256 |
|
- | 128 | mcall |
|
106 | je red |
129 | |
107 | cmp eax,2 |
130 | mov eax,15 |
- | 131 | mov ebx,5 |
|
108 | je key |
132 | mov ecx,0x1000 |
- | 133 | mov edx,0 |
|
- | 134 | mov esi,512*3*256 |
|
- | 135 | mcall |
|
109 | cmp eax,3 |
136 | |
- | 137 | mov eax,15 |
|
- | 138 | mov ebx,3 |
|
110 | je button |
139 | mcall |
111 | 140 | ||
112 | jmp still |
141 | jmp still |
113 | 142 | ||
- | 143 | no_bgr: |
|
- | 144 | ||
- | 145 | cmp ah,3 |
|
- | 146 | jb no_color |
|
- | 147 | cmp ah,5 |
|
- | 148 | jg no_color |
|
- | 149 | shr eax,8 |
|
- | 150 | sub eax,3 |
|
- | 151 | imul eax,8 |
|
- | 152 | add eax,8 |
|
- | 153 | not eax |
|
- | 154 | and eax,11000b |
|
114 | red: |
155 | mov [shlc],al |
115 | call draw_window |
156 | call draw_fractal |
- | 157 | jmp still |
|
- | 158 | ||
- | 159 | no_color: |
|
116 | call put_image |
160 | |
- | 161 | jmp still |
|
117 | jmp still |
162 | |
118 | 163 | ||
119 | key: |
164 | key: |
120 | mov eax,2 |
165 | mov al,2 |
121 | int 0x40 |
166 | mcall |
122 | 167 | ||
123 | cmp ah,'e' |
168 | cmp ah,'e' |
124 | je cycle |
169 | je cycle |
125 | cmp ah,'r' |
170 | cmp ah,'r' |
126 | je cycle |
171 | je cycle |
127 | jmp no_cycle |
172 | jmp no_cycle |
128 | cycle: |
173 | cycle: |
129 | call color_cycle |
174 | call color_cycle |
130 | jmp still |
175 | jmp still |
131 | no_cycle: |
176 | no_cycle: |
132 | 177 | ||
133 | cmp ah,'q' |
178 | cmp ah,'q' |
134 | jne no_in |
179 | jne no_in |
135 | inc byte [scale] |
180 | inc byte [scale] |
136 | mov ebx,[STARTX] |
181 | mov ebx,[STARTX] |
137 | imul ebx,2 |
182 | imul ebx,2 |
138 | sub ebx,[scaleaddx] |
183 | sub ebx,[scaleaddx] |
139 | mov [STARTX],ebx |
184 | mov [STARTX],ebx |
140 | mov ebx,[STARTY] |
185 | mov ebx,[STARTY] |
141 | imul ebx,2 |
186 | imul ebx,2 |
142 | sub ebx,[scaleaddy] |
187 | sub ebx,[scaleaddy] |
143 | mov [STARTY],ebx |
188 | mov [STARTY],ebx |
144 | no_in: |
189 | no_in: |
145 | 190 | ||
146 | cmp ah,'w' |
191 | cmp ah,'w' |
147 | jne no_out |
192 | jne no_out |
148 | dec byte [scale] |
193 | dec byte [scale] |
149 | mov ebx,[STARTX] |
194 | mov ebx,[STARTX] |
150 | add ebx,[scaleaddx] |
195 | add ebx,[scaleaddx] |
151 | shr ebx,1 |
196 | shr ebx,1 |
152 | mov [STARTX],ebx |
197 | mov [STARTX],ebx |
153 | mov ebx,[STARTY] |
198 | mov ebx,[STARTY] |
154 | add ebx,[scaleaddy] |
199 | add ebx,[scaleaddy] |
155 | shr ebx,1 |
200 | shr ebx,1 |
156 | mov [STARTY],ebx |
201 | mov [STARTY],ebx |
157 | no_out: |
202 | no_out: |
158 | 203 | ||
159 | cmp ah,130+48 |
204 | cmp ah,130+48 |
160 | jne no_up |
205 | jne no_up |
161 | sub [STARTY],100 |
206 | sub [STARTY],100 |
162 | no_up: |
207 | no_up: |
163 | 208 | ||
164 | cmp ah,129+48 |
209 | cmp ah,129+48 |
165 | jne no_down |
210 | jne no_down |
166 | add [STARTY],100 |
211 | add [STARTY],100 |
167 | no_down: |
212 | no_down: |
168 | 213 | ||
169 | cmp ah,128+48 |
214 | cmp ah,128+48 |
170 | jne no_left |
215 | jne no_left |
171 | sub [STARTX],100 |
216 | sub [STARTX],100 |
172 | no_left: |
217 | no_left: |
173 | 218 | ||
174 | cmp ah,131+48 |
219 | cmp ah,131+48 |
175 | jne no_right |
220 | jne no_right |
176 | add [STARTX],100 |
221 | add [STARTX],100 |
177 | no_right: |
222 | no_right: |
178 | 223 | ||
179 | call draw_fractal |
224 | call draw_fractal |
180 | jmp still |
225 | jmp still |
181 | - | ||
182 | button: |
- | |
183 | mov eax,17 |
- | |
184 | int 0x40 |
- | |
185 | - | ||
186 | cmp ah,1 |
- | |
187 | jne no_close |
- | |
188 | mov eax,-1 |
- | |
189 | int 0x40 |
- | |
190 | no_close: |
- | |
191 | - | ||
192 | cmp ah,2 |
- | |
193 | jne no_bgr |
- | |
194 | - | ||
195 | mov eax,15 ; bgr 512 x 256 |
- | |
196 | mov ebx,1 |
- | |
197 | mov ecx,512 |
- | |
198 | mov edx,256 |
- | |
199 | int 0x40 |
- | |
200 | - | ||
201 | mov eax,15 |
- | |
202 | mov ebx,5 |
- | |
203 | mov ecx,0x1000 |
- | |
204 | mov edx,0 |
- | |
205 | mov esi,512*3*256 |
- | |
206 | int 0x40 |
- | |
207 | - | ||
208 | mov eax,15 |
- | |
209 | mov ebx,3 |
- | |
210 | int 0x40 |
- | |
211 | - | ||
212 | jmp still |
- | |
213 | - | ||
214 | no_bgr: |
- | |
215 | - | ||
216 | cmp ah,3 |
- | |
217 | jb no_color |
- | |
218 | cmp ah,5 |
- | |
219 | jg no_color |
- | |
220 | shr eax,8 |
- | |
221 | sub eax,3 |
- | |
222 | imul eax,8 |
- | |
223 | add eax,8 |
- | |
224 | not eax |
- | |
225 | and eax,11000b |
- | |
226 | ; sub eax,8 |
- | |
227 | mov [shlc],al |
- | |
228 | call draw_fractal |
- | |
229 | jmp still |
- | |
230 | - | ||
231 | no_color: |
- | |
232 | - | ||
233 | - | ||
234 | jmp still |
- | |
235 | - | ||
236 | 226 | ||
237 | color_cycle: |
227 | color_cycle: |
238 | 228 | ||
239 | pusha |
229 | pusha |
240 | mov ecx,0x08080808 |
230 | mov ecx,0x08080808 |
241 | mov esi,(256/8)*5 |
231 | mov esi,(256/8)*5 |
242 | cmp ah,'e' |
232 | cmp ah,'e' |
243 | je f_out |
233 | je f_out |
244 | mov ecx,-0x08080808 |
234 | mov ecx,-0x08080808 |
245 | mov esi,(256/8)*5-1 |
235 | mov esi,(256/8)*5-1 |
246 | f_out: |
236 | f_out: |
247 | 237 | ||
248 | newcycle: |
238 | newcycle: |
249 | mov edi,0x1000 |
239 | mov edi,0x1000 |
250 | newpix: |
240 | newpix: |
251 | mov eax,[edi] |
241 | mov eax,[edi] |
252 | add eax,ecx |
242 | add eax,ecx |
253 | mov [edi],eax |
243 | mov [edi],eax |
254 | add edi,4 |
244 | add edi,4 |
255 | cmp edi,0x1000+512*256*3 |
245 | cmp edi,0x1000+512*256*3 |
256 | jb newpix |
246 | jb newpix |
257 | call put_image |
247 | call put_image |
258 | mov eax,5 |
248 | mov eax,5 |
259 | mov ebx,1 |
249 | mov ebx,1 |
260 | int 0x40 |
250 | mcall |
261 | dec esi |
251 | dec esi |
262 | jnz newcycle |
252 | jnz newcycle |
263 | 253 | ||
264 | mov eax,0 |
254 | mov eax,0 |
265 | mov edi,0x1000 |
255 | mov edi,0x1000 |
266 | mov ecx,512*256*3 / 4 +50 |
256 | mov ecx,512*256*3 / 4 +50 |
267 | cld |
257 | cld |
268 | rep stosd |
258 | rep stosd |
269 | 259 | ||
270 | popa |
260 | popa |
271 | 261 | ||
272 | call draw_fractal |
262 | call draw_fractal |
273 | 263 | ||
274 | ret |
264 | ret |
275 | 265 | ||
276 | 266 | ||
277 | 267 | ||
278 | 268 | ||
279 | 269 | ||
280 | ; ********************************************************************** |
270 | ; ********************************************************************** |
281 | ; |
271 | ; |
282 | ; Tinyfrac |
272 | ; Tinyfrac |
283 | ; |
273 | ; |
284 | 274 | ||
285 | 275 | ||
286 | draw_fractal: |
276 | draw_fractal: |
287 | 277 | ||
288 | pusha |
278 | pusha |
289 | mov eax,4 |
279 | mov eax,4 |
290 | mov ebx,15*65536+35 |
280 | mov ebx,10*65536+30 |
291 | mov ecx,0xffffff |
281 | mov ecx,0x80ffffff |
292 | mov edx,calc |
282 | mov edx,calc |
293 | mov esi,calcl-calc |
- | |
294 | int 0x40 |
283 | mcall |
295 | popa |
284 | popa |
296 | pusha |
285 | pusha |
297 | 286 | ||
298 | movzx ebp,word [STARTX] |
287 | movzx ebp,word [STARTX] |
299 | movzx edi,word [STARTY] |
288 | movzx edi,word [STARTY] |
300 | 289 | ||
301 | 290 | ||
302 | ; This routine is the fractal drawing engine. It has been |
291 | ; This routine is the fractal drawing engine. It has been |
303 | ; optimized for size, sacrificing speed. |
292 | ; optimized for size, sacrificing speed. |
304 | 293 | ||
305 | mov cx, PIXHEIGHT ; height of screen in pixels |
294 | mov cx, PIXHEIGHT ; height of screen in pixels |
306 | 295 | ||
307 | sub di,cx ; adjust our Y offset |
296 | sub di,cx ; adjust our Y offset |
308 | @@CalcRow: |
297 | @@CalcRow: |
309 | 298 | ||
310 | push cx |
299 | push cx |
311 | - | ||
312 | ; and cl,0x7 |
- | |
313 | ; cmp cl,0 |
- | |
314 | ; jne noim |
- | |
315 | ; call put_image |
- | |
316 | ; noim: |
- | |
317 | 300 | ||
318 | mov cx, PIXWIDTH -1 ; width of screen in pixels |
301 | mov cx, PIXWIDTH -1 ; width of screen in pixels |
319 | 302 | ||
320 | sub bp,cx ; |
303 | sub bp,cx ; |
321 | @@CalcPixel: |
304 | @@CalcPixel: |
322 | push cx ; save the column counter on stack |
305 | push cx ; save the column counter on stack |
323 | xor cx, cx ; clear out color loop counter |
306 | xor cx, cx ; clear out color loop counter |
324 | xor bx, bx ; zero i coefficient |
307 | xor bx, bx ; zero i coefficient |
325 | xor dx, dx ; zero j coefficient |
308 | xor dx, dx ; zero j coefficient |
326 | @@CycleColors: |
309 | @@CycleColors: |
327 | push dx ; save j value for later |
310 | push dx ; save j value for later |
328 | mov ax, bx ; ax = i |
311 | mov ax, bx ; ax = i |
329 | sub ax, dx ; ax = i - j |
312 | sub ax, dx ; ax = i - j |
330 | add dx, bx ; dx = i + j |
313 | add dx, bx ; dx = i + j |
331 | stc ; one additional shift, please |
314 | stc ; one additional shift, please |
332 | call Shifty ; ax = ((i+j)*(i-j)) shifted right |
315 | call Shifty ; ax = ((i+j)*(i-j)) shifted right |
333 | pop dx ; retrieve our saved value for j |
316 | pop dx ; retrieve our saved value for j |
334 | add ax,bp ; account for base offset... |
317 | add ax,bp ; account for base offset... |
335 | cmp ah,THRESHOLD ; Q: is i > THRESHOLD * 256? |
318 | cmp ah,THRESHOLD ; Q: is i > THRESHOLD * 256? |
336 | xchg bx,ax ; now swap new i with old i |
319 | xchg bx,ax ; now swap new i with old i |
337 | jg @@draw ; Y: draw this pixel |
320 | jg @@draw ; Y: draw this pixel |
338 | clc ; no additional shifts here, please |
321 | clc ; no additional shifts here, please |
339 | call Shifty ; now dx:ax = old i * j |
322 | call Shifty ; now dx:ax = old i * j |
340 | xchg dx,ax ; |
323 | xchg dx,ax ; |
341 | add dx,di ; account for base offset... |
324 | add dx,di ; account for base offset... |
342 | inc cl ; increment color |
325 | inc cl ; increment color |
343 | jnz @@CycleColors ; keep going until we're done |
326 | jnz @@CycleColors ; keep going until we're done |
344 | @@draw: |
327 | @@draw: |
345 | xchg ax, cx ; mov color into al |
328 | xchg ax, cx ; mov color into al |
346 | pop cx ; retrieve our column counter |
329 | pop cx ; retrieve our column counter |
347 | pop dx ; fetch row (column already in cx) |
330 | pop dx ; fetch row (column already in cx) |
348 | push dx ; must leave a copy on the stack |
331 | push dx ; must leave a copy on the stack |
349 | xor bx,bx ; write to video page zero |
332 | xor bx,bx ; write to video page zero |
350 | 333 | ||
351 | call put_pixel |
334 | call put_pixel |
352 | 335 | ||
353 | inc bp |
336 | inc bp |
354 | loop @@CalcPixel |
337 | loop @@CalcPixel |
355 | inc di |
338 | inc di |
356 | pop cx |
339 | pop cx |
357 | loop @@CalcRow |
340 | loop @@CalcRow |
358 | 341 | ||
359 | call put_image |
342 | call put_image |
360 | 343 | ||
361 | popa |
344 | popa |
362 | 345 | ||
363 | ret |
346 | ret |
364 | 347 | ||
365 | 348 | ||
366 | put_image: |
349 | put_image: |
367 | 350 | ||
368 | pusha |
351 | pusha |
369 | 352 | ||
370 | mov eax,7 |
353 | mov eax,7 |
371 | mov ebx,0x1000 |
354 | mov ebx,0x1000 |
372 | mov ecx,512*65536+255 |
355 | mov ecx,512*65536+256 |
373 | mov edx,10*65536+30 |
356 | mov edx,4*65536+21 |
374 | int 0x40 |
357 | mcall |
375 | 358 | ||
376 | popa |
359 | popa |
377 | 360 | ||
378 | ret |
361 | ret |
379 | 362 | ||
380 | 363 | ||
381 | shlc db 0 |
364 | shlc db 0 |
382 | 365 | ||
383 | put_pixel: |
366 | put_pixel: |
384 | 367 | ||
385 | pusha |
368 | pusha |
386 | sub edi,[STARTY] |
369 | sub edi,[STARTY] |
387 | sub ebp,[STARTX] |
370 | sub ebp,[STARTX] |
388 | and edi,0xff |
371 | and edi,0xff |
389 | and ebp,0x1ff |
372 | and ebp,0x1ff |
390 | shl edi,9 |
373 | shl edi,9 |
391 | mov ebx,edi ; * 3 - Y |
374 | mov ebx,edi ; * 3 - Y |
392 | add edi,ebx |
375 | add edi,ebx |
393 | add edi,ebx |
376 | add edi,ebx |
394 | mov ebx,ebp |
377 | mov ebx,ebp |
395 | add ebp,ebx |
378 | add ebp,ebx |
396 | add ebp,ebx |
379 | add ebp,ebx |
397 | add edi,ebp |
380 | add edi,ebp |
398 | mov cl,[shlc] |
381 | mov cl,[shlc] |
399 | mov ebx,0xff |
382 | mov ebx,0xff |
400 | shl ebx,cl |
383 | shl ebx,cl |
401 | add cl,3 |
384 | add cl,3 |
402 | shl eax,cl |
385 | shl eax,cl |
403 | and eax,ebx |
386 | and eax,ebx |
404 | mov [0x1000+edi],eax |
387 | mov [0x1000+edi],eax |
405 | popa |
388 | popa |
406 | 389 | ||
407 | ret |
390 | ret |
408 | 391 | ||
409 | 392 | ||
410 | ;**************************************************************************** |
393 | ;**************************************************************************** |
411 | ; |
394 | ; |
412 | ; This routine multiplies AX by DX and shifts the result (in |
395 | ; This routine multiplies AX by DX and shifts the result (in |
413 | ; DX:AX) to the right by scale bits (or scale+1 bits if CY is |
396 | ; DX:AX) to the right by scale bits (or scale+1 bits if CY is |
414 | ; set). The resulting value is left in AX. DX is destroyed. |
397 | ; set). The resulting value is left in AX. DX is destroyed. |
415 | ; |
398 | ; |
416 | ;**************************************************************************** |
399 | ;**************************************************************************** |
417 | 400 | ||
418 | Shifty: |
401 | Shifty: |
419 | push cx ; save middle bits (i*i - j*j) |
402 | push cx ; save middle bits (i*i - j*j) |
420 | db 0b1h ; code for mov cl,immed8 |
403 | db 0b1h ; code for mov cl,immed8 |
421 | scale db STARTSCALE |
404 | scale db STARTSCALE |
422 | adc cl,0 ; adjust per CY flag |
405 | adc cl,0 ; adjust per CY flag |
423 | imul dx ; do the multiply |
406 | imul dx ; do the multiply |
424 | 407 | ||
425 | xchg ax,dx ; |
408 | xchg ax,dx ; |
426 | shl eax,16 ; put hi part in hi 16 bits |
409 | shl eax,16 ; put hi part in hi 16 bits |
427 | xchg ax,dx |
410 | xchg ax,dx |
428 | shr eax,cl ; |
411 | shr eax,cl ; |
429 | 412 | ||
430 | pop cx ; |
413 | pop cx ; |
431 | ret ; |
414 | ret ; |
432 | 415 | ||
433 | 416 | ||
434 | 417 | ||
435 | ; ********************************************************************** |
418 | ; ********************************************************************** |
436 | ; |
419 | ; |
437 | ; WINDOW DEFINITIONS AND DRAW |
420 | ; WINDOW DEFINITIONS AND DRAW |
438 | ; |
421 | ; |
439 | ; ********************************************************************** |
422 | ; ********************************************************************** |
440 | 423 | ||
441 | 424 | ||
442 | 425 | ||
443 | draw_window: |
426 | draw_window: |
444 | 427 | ||
445 | pusha |
428 | pusha |
446 | 429 | ||
447 | mov eax,12 |
430 | mov eax,12 |
448 | mov ebx,1 |
431 | mov ebx,1 |
449 | int 0x40 |
432 | mcall |
450 | 433 | ||
451 | mov eax,0 |
434 | xor eax,eax |
452 | mov ebx,50*65536+531 |
435 | mov ebx,50*65536+PIXWIDTH+8 |
453 | mov ecx,100*65536+256+48 |
436 | mov ecx,100*65536+PIXHEIGHT+25 |
454 | mov edx,0x02334455 |
- | |
455 | mov esi,0x80778899 |
437 | mov edx,0x13334455 |
456 | mov edi,0x00778899 |
438 | mov edi,title |
457 | int 0x40 |
439 | mcall |
458 | - | ||
459 | mov eax,8 |
- | |
460 | mov ebx,(531-19)*65536+12 |
- | |
461 | mov ecx,5*65536+12 |
- | |
462 | mov edx,1 |
- | |
463 | mov esi,0x808080 |
- | |
464 | int 0x40 |
- | |
465 | 440 | ||
466 | mov eax,8 |
441 | mov eax,8 |
467 | mov ebx,300*65536+112 |
442 | mov ebx,290*65536+112 |
468 | mov ecx,5*65536+12 |
443 | mov ecx,5*65536+12 |
469 | mov edx,2 |
444 | mov edx,2 |
470 | mov esi,0x808080 |
445 | mov esi,0x808080 |
471 | int 0x40 |
446 | mcall |
472 | 447 | ||
473 | mov ebx,430*65536+12 |
448 | mov ebx,420*65536+12 |
474 | mov ecx,5*65536+12 |
449 | mov ecx,5*65536+12 |
475 | mov edx,3 |
450 | mov edx,3 |
476 | mov esi,0xa00000 |
451 | mov esi,0xa00000 |
477 | mov edi,3 |
452 | mov edi,3 |
- | 453 | ;mov eax,8 |
|
478 | newcolor: |
454 | newcolor: |
479 | mov eax,8 |
455 | mcall |
480 | int 0x40 |
- | |
481 | add ebx,13*65536 |
456 | add ebx,13*65536 |
482 | shr esi,8 |
457 | shr esi,8 |
483 | inc edx |
458 | inc edx |
484 | dec edi |
459 | dec edi |
485 | jnz newcolor |
460 | jnz newcolor |
486 | 461 | ||
487 | mov eax,4 |
462 | mov eax,4 |
488 | mov ebx,8*65536+8 |
463 | mov ebx,300*65536+8 |
489 | mov ecx,0xffffff |
464 | mov ecx,0x80ffffff |
490 | mov edx,l |
465 | mov edx,button_txt |
491 | mov esi,ll-l |
466 | mcall |
492 | int 0x40 |
- | |
493 | 467 | ||
494 | mov eax,12 |
468 | mov eax,12 |
495 | mov ebx,2 |
469 | mov ebx,2 |
496 | int 0x40 |
470 | mcall |
497 | 471 | ||
498 | popa |
472 | popa |
499 | ret |
473 | ret |
500 | 474 | ||
501 | 475 | ||
502 | ; *************************************************************** |
476 | ; *************************************************************** |
503 | ; |
477 | ; |
504 | ; DATA AREA |
478 | ; DATA AREA |
505 | ; |
479 | ; |
506 | 480 | ||
507 | 481 | ||
508 | l: db 'TINYFRAC - MOVE: ARROWS, ZOOM Q/W, CYCLE: E/R ' |
482 | title db 'Tinyfrac - MOVE: ARROWS, ZOOM Q/W, CYCLE: E/R',0 |
509 | db 'SET AS WALLPAPER' |
- | |
510 | ll: |
483 | button_txt db 'Set as wallpaper',0 |
511 | - | ||
512 | calc db 'CALCULATING' |
484 | |
513 | calcl: |
- | |
514 | - | ||
515 | I_END: |
- | |
516 | - | ||
- | 485 | calc db 'CALCULATING',0 |
|
- | 486 | ||
- | 487 | I_END: |