Subversion Repositories Kolibri OS

Rev

Rev 551 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 551 Rev 8253
Line 43... Line 43...
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
;
Line 53... Line 53...
53
 
53
 
54
PIXWIDTH    equ 511
54
PIXWIDTH    equ 512
Line 55... Line 55...
55
PIXHEIGHT   equ 255
55
PIXHEIGHT   equ 256
Line 56... Line 56...
56
 
56
 
Line 57... Line 57...
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
 
-
 
61
DELTA       equ 200       ; the unit of pan movement in pixels
-
 
Line -... Line 60...
-
 
60
 
Line 62... Line 61...
62
THRESHOLD   equ  7        ; must be in the range of (0,255)
61
DELTA       equ 200       ; the unit of pan movement in pixels
63
STARTSCALE  equ  5        ; a number from 0 to ZOOMLIMIT, inclusive
62
THRESHOLD   equ  7        ; must be in the range of (0,255)
64
CHAR_COLOR  equ 0fh       ; white on black background (for PRINTZOOM feature)
63
STARTSCALE  equ  5        ; a number from 0 to ZOOMLIMIT, inclusive
65
 
64
 
-
 
65
IMGBUF      equ 0x1000
Line 66... Line 66...
66
 
66
 
67
 
-
 
68
; ************************************************************
67
; ************************************************************
Line 69... Line 68...
69
;
68
;
70
;   Menuet header
69
;   KolibriOS header
71
 
70
;
72
 
71
; ************************************************************
73
use32
72
 
74
 
73
use32
75
                  org     0x0
74
        org     0x0
Line 76... Line 75...
76
 
75
 
77
                  db      'MENUET01'
76
        db      'MENUET01'
Line 78... Line -...
78
                  dd      0x01
-
 
79
                  dd      START
-
 
80
                  dd      I_END
-
 
81
                  dd      0x62000
-
 
82
                  dd      0x1000
-
 
83
                  dd      0,0
-
 
84
 
77
        dd      0x01
85
include 'lang.inc'
-
 
86
include '..\..\..\macros.inc'
-
 
87
 
-
 
88
STARTX  dd  200
78
        dd      START
89
STARTY  dd  120
79
        dd      I_END
-
 
80
        dd      PIXWIDTH*PIXHEIGHT*3+IMGBUF+I_END
90
 
81
        dd      0x1000
91
scaleaddy dd 120
-
 
92
scaleaddx dd 200
-
 
93
 
82
        dd      0,0
Line 94... Line 83...
94
START:
83
 
95
 
84
include 'lang.inc'
96
red:
85
include '..\..\..\macros.inc'
97
        call    draw_window
86
 
Line 98... Line 87...
98
        call    draw_fractal
87
START:
99
 
-
 
100
still:
88
        call draw_fractal
101
 
-
 
102
        mov  eax,10
89
redraw:
103
        mcall
-
 
104
 
-
 
105
        dec  eax
-
 
106
        jz   red
-
 
107
        dec  eax
-
 
108
        jz   key
-
 
109
 
90
        call draw_window
110
      button:
-
 
111
        mov  al,17
-
 
112
        mcall
-
 
113
 
-
 
114
        cmp  ah,1
-
 
115
        jne  no_close
-
 
116
        or   eax,-1
-
 
117
        mcall
-
 
118
      no_close:
-
 
119
 
-
 
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
91
still:
128
        mcall
-
 
129
 
-
 
130
        mov  eax,15
-
 
131
        mov  ebx,5
-
 
132
        mov  ecx,0x1000
-
 
133
        mov  edx,0
-
 
134
        mov  esi,512*3*256
-
 
135
        mcall
-
 
136
 
-
 
137
        mov  eax,15
-
 
138
        mov  ebx,3
-
 
139
        mcall
-
 
140
 
-
 
141
        jmp  still
-
 
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
-
 
Line 151... Line 92...
151
        imul eax,8
92
        mcall 10
152
        add  eax,8
93
 
153
        not  eax
94
        dec  eax
Line 154... Line 95...
154
        and  eax,11000b
95
        jz   redraw
155
        mov  [shlc],al
96
        dec  eax
156
        call draw_fractal
97
        jz   key
157
        jmp  still
98
 
158
 
99
      button:
159
      no_color:
100
        mcall 17
160
 
101
        cmp  ah,1
161
        jmp  still
102
        jne  still
162
 
103
        mcall -1
Line 163... Line 104...
163
 
104
 
164
      key:
105
      key:
165
        mov  al,2
106
        mcall 2
166
        mcall
107
        shr eax,16
167
 
108
 
168
        cmp  ah,'e'
109
        cmp  al,24 ;'o'
169
        je   cycle
110
		je cycle
170
        cmp  ah,'r'
111
        cmp  al,23 ;'i'
171
        je   cycle
112
        je   cycle
172
        jmp  no_cycle
113
        jmp  no_cycle
173
      cycle:
114
      cycle:
-
 
115
        call color_cycle
-
 
116
        jmp  still
174
        call color_cycle
117
      no_cycle:
Line 175... Line 118...
175
        jmp  still
118
 
176
      no_cycle:
119
        cmp  al,13 ;'+'
177
 
120
        jne  no_in
178
        cmp  ah,'q'
121
        inc  byte [scale]
179
        jne  no_in
122
        mov  ebx,[STARTX]
180
        inc  byte [scale]
123
        imul ebx,2
181
        mov  ebx,[STARTX]
124
        sub  ebx,[scaleaddx]
182
        imul ebx,2
125
        mov  [STARTX],ebx
183
        sub  ebx,[scaleaddx]
126
        mov  ebx,[STARTY]
184
        mov  [STARTX],ebx
127
        imul ebx,2
185
        mov  ebx,[STARTY]
128
        sub  ebx,[scaleaddy]
-
 
129
        mov  [STARTY],ebx
-
 
130
        call draw_fractal
186
        imul ebx,2
131
        jmp  still
Line 187... Line 132...
187
        sub  ebx,[scaleaddy]
132
      no_in:
188
        mov  [STARTY],ebx
133
 
189
      no_in:
134
        cmp  al,12 ;'-'
-
 
135
        jne  no_out
-
 
136
        dec  byte [scale]
190
 
137
        mov  ebx,[STARTX]
Line 191... Line 138...
191
        cmp  ah,'w'
138
        add  ebx,[scaleaddx]
192
        jne  no_out
139
        shr  ebx,1
193
        dec  byte [scale]
140
        mov  [STARTX],ebx
-
 
141
        mov  ebx,[STARTY]
-
 
142
        add  ebx,[scaleaddy]
194
        mov  ebx,[STARTX]
143
        shr  ebx,1
Line 195... Line 144...
195
        add  ebx,[scaleaddx]
144
        mov  [STARTY],ebx
196
        shr  ebx,1
145
        call draw_fractal
197
        mov  [STARTX],ebx
146
        jmp  still
-
 
147
      no_out:
-
 
148
 
198
        mov  ebx,[STARTY]
149
        cmp  al,72
Line 199... Line 150...
199
        add  ebx,[scaleaddy]
150
        jne  no_up
200
        shr  ebx,1
151
        sub  [STARTY],100
201
        mov  [STARTY],ebx
152
        call draw_fractal
-
 
153
        jmp  still
-
 
154
      no_up:
202
      no_out:
155
 
Line -... Line 156...
-
 
156
        cmp  al,80
-
 
157
        jne  no_down
-
 
158
        add  [STARTY],100
203
 
159
        call draw_fractal
204
        cmp  ah,130+48
160
        jmp  still
-
 
161
      no_down:
-
 
162
 
-
 
163
        cmp  al,75
-
 
164
        jne  no_left
-
 
165
        sub  [STARTX],100
-
 
166
        call draw_fractal
-
 
167
        jmp  still
-
 
168
      no_left:
-
 
169
 
-
 
170
        cmp  al,77
-
 
171
        jne  no_right
-
 
172
        add  [STARTX],100
-
 
173
        call draw_fractal
-
 
174
        jmp  still
-
 
175
      no_right:
-
 
176
      
-
 
177
        cmp  al,19 ;'r'
-
 
178
        jne  no_red
-
 
179
        mov  ah,3
-
 
180
        call colorize
-
 
181
        jmp  still
-
 
182
      no_red:
-
 
183
      
-
 
184
        cmp  al,34 ;'g'
-
 
185
        jne  no_green
-
 
186
        mov  ah,4
-
 
187
        call colorize
-
 
188
        jmp  still
-
 
189
      no_green:
-
 
190
      
-
 
191
        cmp  al,48 ;'b'
-
 
192
        jne  no_blue
-
 
193
        mov  ah,5
-
 
194
        call colorize
-
 
195
        jmp  still
-
 
196
      no_blue:
Line 205... Line 197...
205
        jne  no_up
197
      
Line 206... Line 198...
206
        sub  [STARTY],100
198
        cmp  al,17 ;'w'
207
      no_up:
199
        jne  no_set_as_wallpaper
208
 
200
        mcall 15, 1, PIXWIDTH, PIXHEIGHT
209
        cmp  ah,129+48
201
		mcall 15, 4, 1 ;mode 1-tiled, 0-stretch
210
        jne  no_down
202
        mcall 15, 5, IMGBUF, 0, PIXWIDTH*3*PIXHEIGHT
211
        add  [STARTY],100
203
        mcall 15, 3 
212
      no_down:
204
      no_set_as_wallpaper:
213
 
205
 
Line 214... Line 206...
214
        cmp  ah,128+48
206
        jmp  still
215
        jne  no_left
207
 
216
        sub  [STARTX],100
208
colorize:       
217
      no_left:
209
        shr  eax,8
218
 
210
        sub  eax,3
219
        cmp  ah,131+48
211
        imul eax,8
220
        jne  no_right
212
        add  eax,8
221
        add  [STARTX],100
213
        not  eax
222
      no_right:
214
        and  eax,11000b
223
 
215
        mov  [shlc],al
224
        call draw_fractal
216
        call draw_fractal
225
        jmp  still
217
        ret
226
 
218
 
227
color_cycle:
219
color_cycle:
228
 
220
 
Line 229... Line 221...
229
     pusha
221
     pusha
230
     mov  ecx,0x08080808
222
     mov  ecx,0x08080808
231
     mov  esi,(256/8)*5
223
     mov  esi,(PIXHEIGHT/8)*5
232
     cmp  ah,'e'
224
     cmp  al,24
233
     je   f_out
225
     je   f_out
Line 234... Line 226...
234
     mov  ecx,-0x08080808
226
     mov  ecx,-0x08080808
Line 235... Line 227...
235
     mov  esi,(256/8)*5-1
227
     mov  esi,(PIXHEIGHT/8)*5-1
Line 236... Line 228...
236
   f_out:
228
   f_out:
Line 237... Line -...
237
 
-
 
238
   newcycle:
-
 
239
     mov  edi,0x1000
-
 
240
   newpix:
229
 
241
     mov  eax,[edi]
230
   newcycle:
242
     add  eax,ecx
231
     mov  edi,IMGBUF
243
     mov  [edi],eax
232
   newpix:
244
     add  edi,4
-
 
-
 
233
     mov  eax,[edi]
Line 245... Line 234...
245
     cmp  edi,0x1000+512*256*3
234
     add  eax,ecx
Line 246... Line 235...
246
     jb   newpix
235
     mov  [edi],eax
247
     call put_image
-
 
248
     mov  eax,5
-
 
249
     mov  ebx,1
236
     add  edi,4
250
     mcall
-
 
251
     dec  esi
-
 
252
     jnz  newcycle
237
     cmp  edi,IMGBUF+PIXWIDTH*PIXHEIGHT*3
253
 
238
     jb   newpix
Line 254... Line 239...
254
     mov  eax,0
239
     call put_image
255
     mov  edi,0x1000
240
     mov  eax,5
Line 296... Line 281...
296
        sub     di,cx           ; adjust our Y offset
281
        sub     di,cx           ; adjust our Y offset
297
@@CalcRow:
282
@@CalcRow:
Line 298... Line 283...
298
 
283
 
Line 299... Line 284...
299
        push    cx
284
        push    cx
Line 300... Line 285...
300
 
285
 
301
        mov     cx, PIXWIDTH -1  ; width of screen in pixels
286
        mov     cx, PIXWIDTH ; width of screen in pixels
302
 
287
 
303
        sub     bp,cx           ;
288
        sub     bp,cx           ;
Line 343... Line 328...
343
 
328
 
Line 344... Line 329...
344
        popa
329
        popa
Line 345... Line -...
345
 
-
 
346
        ret
-
 
347
 
-
 
348
 
-
 
349
put_image:
-
 
350
 
-
 
351
        pusha
-
 
352
 
-
 
353
        mov  eax,7
-
 
354
        mov  ebx,0x1000
-
 
355
        mov  ecx,512*65536+256
-
 
356
        mov  edx,4*65536+21
-
 
357
        mcall
-
 
358
 
-
 
359
        popa
-
 
360
 
-
 
361
        ret
330
 
Line 362... Line 331...
362
 
331
        ret
Line 363... Line 332...
363
 
332
 
Line 382... Line 351...
382
        mov     ebx,0xff
351
        mov     ebx,0xff
383
        shl     ebx,cl
352
        shl     ebx,cl
384
        add     cl,3
353
        add     cl,3
385
        shl     eax,cl
354
        shl     eax,cl
386
        and     eax,ebx
355
        and     eax,ebx
387
        mov     [0x1000+edi],eax
356
        mov     [IMGBUF+edi],eax
388
        popa
357
        popa
Line 389... Line 358...
389
 
358
 
Line 412... Line 381...
412
 
381
 
413
        pop     cx              ;
382
        pop     cx              ;
Line 414... Line -...
414
        ret                     ;
-
 
415
 
383
        ret                     ;
416
 
384
 
417
 
385
 
418
; **********************************************************************
386
; **********************************************************************
419
;
387
;
Line 420... Line -...
420
;                   WINDOW DEFINITIONS AND DRAW
-
 
421
;
-
 
422
; **********************************************************************
388
;     WINDOW DEFINITIONS AND DRAW
423
 
-
 
424
 
389
;
-
 
390
; **********************************************************************
Line 425... Line -...
425
 
-
 
426
draw_window:
-
 
427
 
-
 
428
      pusha
-
 
429
 
-
 
430
      mov  eax,12
391
 
431
      mov  ebx,1
392
draw_window:
432
      mcall
-
 
433
 
-
 
434
      xor  eax,eax
-
 
435
      mov  ebx,50*65536+PIXWIDTH+8
-
 
436
      mov  ecx,100*65536+PIXHEIGHT+25
-
 
437
      mov  edx,0x14334455
-
 
438
      mov  edi,title
-
 
439
      mcall
-
 
440
 
393
      pusha
441
      mov  eax,8
-
 
Line 442... Line -...
442
      mov  ebx,290*65536+112
-
 
443
      mov  ecx,5*65536+12
-
 
444
      mov  edx,2
-
 
445
      mov  esi,0x808080
-
 
446
      mcall
-
 
447
 
-
 
448
      mov  ebx,420*65536+12
-
 
449
      mov  ecx,5*65536+12
-
 
450
      mov  edx,3
394
      mcall 12, 1
451
      mov  esi,0xa00000
-
 
452
      mov  edi,3
-
 
453
      ;mov  eax,8
-
 
454
    newcolor:
-
 
455
      mcall
-
 
456
      add  ebx,13*65536
-
 
457
      shr  esi,8
-
 
458
      inc  edx
-
 
459
      dec  edi
-
 
460
      jnz  newcolor
-
 
Line 461... Line 395...
461
 
395
	  
462
      mov  eax,4
396
      mcall 48, 4                        ;get skin height
463
      mov  ebx,300*65536+8
397
      lea   ecx, [50*65536+PIXHEIGHT+4+eax]
Line -... Line 398...
-
 
398
      mcall 0,<50,PIXWIDTH+9>,,0x74000000,,header_txt ;draw window
-
 
399
	  
-
 
400
      call    put_image
464
      mov  ecx,0x80ffffff
401
	  
465
      mov  edx,button_txt
402
      mcall 12, 2
Line 466... Line 403...
466
      mcall
403
      popa
467
 
404
      ret
468
      mov  eax,12
405
 
469
      mov  ebx,2
406
put_image:
-
 
407
        pusha
Line -... Line 408...
-
 
408
        mcall 7, IMGBUF, PIXWIDTH*65536+PIXHEIGHT, 0*65536+0
-
 
409
        popa
Line 470... Line 410...
470
      mcall
410
        ret
471
 
411
 
Line -... Line 412...
-
 
412
 
472
      popa
413
; **********************************************************************
Line 473... Line 414...
473
      ret
414
;
474
 
415
;     DATA AREA