/[projet1]/public/oric/demos/buggy_boy/LcpIntro/mandel.s
Defence Force logotype

Contents of /public/oric/demos/buggy_boy/LcpIntro/mandel.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 903 - (show annotations)
Sun Jan 13 15:30:30 2013 UTC (6 years, 10 months ago) by dbug
File size: 19085 byte(s)
Added the Buggy Boy demo.
Please note that the building of the DSK file requires working versions of Tap2Dsk and Old2Mfm, they may not work on recent windows versions.
1
2
3 #define MANDEL_ITER_BIS 19
4 #define MAX_MANDEL_ITER 512
5
6 //#define MANDEL_X_POS 64
7 //#define MANDEL_Y_POS 64
8
9 #define MANDEL_X_POS 32
10 #define MANDEL_Y_POS 92
11
12 #define MANDEL_WINDOWS_Y 30
13
14 .zero
15
16 //*= 128
17
18 screen_1 .dsb 2
19 screen_2 .dsb 2
20 screen_3 .dsb 2
21 screen_4 .dsb 2
22
23 big_buff .dsb 2
24 x_buff .dsb 1
25
26 accu_1 .dsb 1
27 accu_2 .dsb 1
28
29 _c .dsb 2
30 _d .dsb 2
31 _b .dsb 2
32
33 _x1 .dsb 2
34 _y1 .dsb 2
35 _xn .dsb 2
36 _yn .dsb 2
37
38 _x .dsb 1
39 _y .dsb 1
40 _w .dsb 1
41 _h .dsb 1
42
43 _n .dsb 1
44
45 _ref_pixel .dsb 1
46
47 _axn .dsb 2
48 _ayn .dsb 2
49
50 _tempfastdiv .dsb 1
51
52 greetings_pointer .dsb 2
53
54 .text
55
56
57 #define MANDEL_TEXT_OFFSET(size) 19-((size)*3-1)/2
58
59
60 _Mandel_GreetingList
61 .byt MANDEL_TEXT_OFFSET(6) ,0,"ACTIVE",0
62 .byt MANDEL_TEXT_OFFSET(5) ,0,"ANTIC",0
63 .byt MANDEL_TEXT_OFFSET(7) ,0,"BLOCKOS",0
64 .byt MANDEL_TEXT_OFFSET(12)+1,0,"BOOZE DESIGN",0
65 .byt MANDEL_TEXT_OFFSET(7) ,0,"CAMELOT",0
66 .byt MANDEL_TEXT_OFFSET(6) ,0,"COSINE",0
67 .byt MANDEL_TEXT_OFFSET(4) ,0,"CNCD",0
68 .byt MANDEL_TEXT_OFFSET(8) ,0,"CREATORS",0
69 .byt MANDEL_TEXT_OFFSET(5) ,0,"CREST",0
70 .byt MANDEL_TEXT_OFFSET(7) ,0,"DEFIERS",0
71 .byt MANDEL_TEXT_OFFSET(9) ,0,"DEKADENCE",0
72 .byt MANDEL_TEXT_OFFSET(5) ,0,"DEPTH",0
73 .byt MANDEL_TEXT_OFFSET(3) ,0,"DHS",0
74 .byt MANDEL_TEXT_OFFSET(9) ,0,"DUAL CREW",0
75 .byt MANDEL_TEXT_OFFSET(9) ,0,"EPHIDRENA",0
76 .byt MANDEL_TEXT_OFFSET(7) ,0,"EQUINOX",0
77 .byt MANDEL_TEXT_OFFSET(6) ,0,"EXTEND",0
78 .byt MANDEL_TEXT_OFFSET(9) ,0,"FAIRLIGHT",0
79 .byt MANDEL_TEXT_OFFSET(10),0,"FARBRAUSCH",0
80 .byt MANDEL_TEXT_OFFSET(9) ,0,"FLASH INC",0
81 .byt MANDEL_TEXT_OFFSET(5) ,0,"FOCUS",0
82 .byt MANDEL_TEXT_OFFSET(3) ,0,"G.P",0
83 .byt MANDEL_TEXT_OFFSET(7) ,0,"HAUJOBB",0
84 .byt MANDEL_TEXT_OFFSET(6) ,0,"HITMEN",0
85 .byt MANDEL_TEXT_OFFSET(8) ,0,"INSTINCT",0
86 .byt MANDEL_TEXT_OFFSET(3) ,0,"ISO",0
87 .byt MANDEL_TEXT_OFFSET(7) ,0,"KEWLERS",0
88 .byt MANDEL_TEXT_OFFSET(6) ,0,"LAXITY",0
89 .byt MANDEL_TEXT_OFFSET(7) ,0,"M AND M",0
90 .byt MANDEL_TEXT_OFFSET(3) ,0,"MFX",0
91 .byt MANDEL_TEXT_OFFSET(9) ,0,"NECTARINE",0
92 .byt MANDEL_TEXT_OFFSET(5) ,0,"NOICE",0
93 .byt MANDEL_TEXT_OFFSET(6) ,0,"NONAME",0
94 .byt MANDEL_TEXT_OFFSET(6) ,0,"ONEWAY",0
95 .byt MANDEL_TEXT_OFFSET(9) ,0,"ONSLAUGHT",0
96 .byt MANDEL_TEXT_OFFSET(6) ,0,"OXYRON",0
97 .byt MANDEL_TEXT_OFFSET(5) ,0,"PADUA",0
98 .byt MANDEL_TEXT_OFFSET(9) ,0,"PANORAMIC",0
99 .byt MANDEL_TEXT_OFFSET(8) ,0,"PHANTASY",0
100 .byt MANDEL_TEXT_OFFSET(5) ,0,"PLUSH",0
101 .byt MANDEL_TEXT_OFFSET(10),0,"POPSY TEAM",0
102 .byt MANDEL_TEXT_OFFSET(3) ,0,"PWP",0
103 .byt MANDEL_TEXT_OFFSET(10),0,"SECTOR ONE",0
104 .byt MANDEL_TEXT_OFFSET(7) ,0,"SCOOPEX",0
105 .byt MANDEL_TEXT_OFFSET(5) ,0,"SHAPE",0
106 .byt MANDEL_TEXT_OFFSET(10),0,"SPACEBALLS",0
107 .byt MANDEL_TEXT_OFFSET(10),0,"RAZOR 1911",0
108 .byt MANDEL_TEXT_OFFSET(11),0,"RETROCODERS",0
109 .byt MANDEL_TEXT_OFFSET(10),0,"THE DREAMS",0
110 .byt MANDEL_TEXT_OFFSET(5) ,0,"TRIAD",0
111 .byt 2 ,0,"WRATHDESIGNS",0
112 .byt MANDEL_TEXT_OFFSET(11),0,"WWW.C64.ORG",0
113 .byt MANDEL_TEXT_OFFSET(12),0,"WWW.ORIC.ORG",0
114
115 .byt 0
116
117 _Mandel_GreetingsRasters_Offset
118 .byt 0
119
120 _Mandel_GreetingsRasters
121
122 _Mandel_GreetingsRasters_Blue
123 .byt 0 // not visible
124 .byt 4
125 .byt 4
126 .byt 4
127 .byt 4
128 .byt 6
129 .byt 4
130 .byt 4
131 .byt 4
132 .byt 6
133 .byt 6
134 .byt 4
135 .byt 4
136 .byt 6
137 .byt 6
138 .byt 6
139 .byt 4
140 .byt 6
141 .byt 6
142 .byt 6
143 .byt 6
144 .byt 7
145 .byt 6
146 .byt 6
147 .byt 7
148 .byt 6
149 .byt 7
150 .byt 7
151
152 _Mandel_GreetingsRasters_Red
153 .byt 0 // not visible
154 .byt 1
155 .byt 1
156 .byt 1
157 .byt 1
158 .byt 3
159 .byt 1
160 .byt 1
161 .byt 1
162 .byt 3
163 .byt 3
164 .byt 1
165 .byt 1
166 .byt 3
167 .byt 3
168 .byt 3
169 .byt 1
170 .byt 3
171 .byt 3
172 .byt 3
173 .byt 3
174 .byt 7
175 .byt 3
176 .byt 3
177 .byt 7
178 .byt 3
179 .byt 7
180 .byt 7
181
182 _Mandel_GreetingsRasters_Green
183 .byt 0 // not visible
184 .byt 2
185 .byt 2
186 .byt 2
187 .byt 2
188 .byt 3
189 .byt 2
190 .byt 2
191 .byt 2
192 .byt 3
193 .byt 3
194 .byt 2
195 .byt 2
196 .byt 3
197 .byt 3
198 .byt 3
199 .byt 2
200 .byt 3
201 .byt 3
202 .byt 3
203 .byt 3
204 .byt 7
205 .byt 3
206 .byt 3
207 .byt 7
208 .byt 3
209 .byt 7
210 .byt 7
211
212 _Mandel_GreetingsRasters_Buarkish
213 .byt 0 // not visible
214 .byt 1
215 .byt 2
216 .byt 5
217 .byt 3
218 .byt 7
219 .byt 2
220 .byt 4
221 .byt 2
222 .byt 1
223 .byt 3
224 .byt 2
225 .byt 2
226 .byt 7
227 .byt 3
228 .byt 3
229 .byt 2
230 .byt 3
231 .byt 6
232 .byt 6
233 .byt 3
234 .byt 5
235 .byt 3
236 .byt 4
237 .byt 2
238 .byt 3
239 .byt 5
240 .byt 7
241
242 #define MANDEL_NAME_AREA $a000+40*170
243
244 // .byt "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?. ",0
245 // Each char is 3*28
246 // Maximum of 13 characters per line (13*3)=39
247 _Mandel_DisplayGreetings
248 // sei
249 // jmp _Mandel_DisplayGreetings
250 .(
251 //
252 // Read start offset, 0 means => End of things
253 //
254 ldy #0
255 lda (greetings_pointer),y
256 .(
257 bne skip
258 // End of greeting list
259 rts
260 skip
261 .)
262 clc
263 adc #<MANDEL_NAME_AREA
264 sta tmp1+0
265 lda #0
266 adc #>MANDEL_NAME_AREA
267 sta tmp1+1
268
269 .(
270 inc greetings_pointer+0
271 bne skip
272 inc greetings_pointer+1
273 skip
274 .)
275
276
277 //
278 // Read raster color
279 //
280 ldy #0
281 lda (greetings_pointer),y
282 sta _Mandel_GreetingsRasters_Offset
283
284 .(
285 inc greetings_pointer+0
286 bne skip
287 inc greetings_pointer+1
288 skip
289 .)
290
291
292 .(
293 //
294 // Cleanup the name area
295 //
296 lda #<MANDEL_NAME_AREA
297 sta tmp0+0
298 lda #>MANDEL_NAME_AREA
299 sta tmp0+1
300
301 ldx #28
302 loop_y
303 ldy #2
304 lda #64
305 loop_x
306 sta (tmp0),y
307 iny
308 cpy #40
309 bne loop_x
310
311 //
312 // Rasters
313 //
314 txa
315 clc
316 adc _Mandel_GreetingsRasters_Offset
317 tay
318 lda _Mandel_GreetingsRasters-1,y
319 ldy #0
320 sta (tmp0),y
321
322 .(
323 clc
324 lda tmp0+0
325 adc #40
326 sta tmp0+0
327 bcc skip
328 inc tmp0+1
329 skip
330 .)
331
332 dex
333 bne loop_y
334 .)
335
336
337 loop_character
338 ldy #0
339 lda (greetings_pointer),y
340 .(
341 inc greetings_pointer+0
342 bne skip
343 inc greetings_pointer+1
344 skip
345 .)
346
347 .(
348 cmp #0
349 bne skip
350 jmp end
351 skip
352 .)
353 tax
354 lda _ScrollMapping,x
355 tax
356 lda _FontAddrLow,x
357 sta tmp0+0
358 lda _FontAddrHigh,x
359 sta tmp0+1
360
361 ldx #28
362 loop
363 ldy #0
364 lda (tmp0),y
365 sta (tmp1),y
366 iny
367 lda (tmp0),y
368 sta (tmp1),y
369 iny
370 lda (tmp0),y
371 sta (tmp1),y
372
373 .(
374 clc
375 lda tmp0+0
376 adc #3
377 sta tmp0+0
378 bcc skip
379 inc tmp0+1
380 skip
381 .)
382
383 .(
384 clc
385 lda tmp1+0
386 adc #40
387 sta tmp1+0
388 bcc skip
389 inc tmp1+1
390 skip
391 .)
392
393 dex
394 bne loop
395
396 .(
397 sec
398 lda tmp1+0
399 sbc #<40*28-3
400 sta tmp1+0
401 lda tmp1+1
402 sbc #>40*28-3
403 sta tmp1+1
404 .)
405
406 jmp loop_character
407
408 end
409
410 rts
411 .)
412
413
414
415 _Mandle_ColorizeBigBuffer
416 .(
417 lda #<_BigBuffer
418 sta tmp0+0
419 lda #>_BigBuffer
420 sta tmp0+1
421
422 ldx #33
423 stx tmp1
424 loop_outer
425 ldy #0
426 loop_inner
427 lda (tmp0),y
428 tax
429 lda _RasterLine,x
430 sta (tmp0),y
431 dey
432 bne loop_inner
433 inc tmp0+1
434 dec tmp1
435 bne loop_outer
436
437 rts
438 .)
439
440
441
442
443 _Mandle_ClearBigBuffer
444 .(
445 lda #<_BigBuffer
446 sta tmp0+0
447 lda #>_BigBuffer
448 sta tmp0+1
449
450 lda #0
451 ldx #33
452 loop_outer
453 ldy #0
454 loop_inner
455 sta (tmp0),y
456 dey
457 bne loop_inner
458 inc tmp0+1
459 dex
460 bne loop_outer
461
462 rts
463 .)
464
465
466 // _BigBuffer is equivalent to a 128x64 picture, that when zoomed in 2x2
467 // give us a 256x128 resolution, not bad !
468 //
469 _Mandle_BlitBigBuffer
470 //sei
471 .(
472 pha
473 txa
474 pha
475 tya
476 pha
477
478 lda #<$a000+(40*MANDEL_WINDOWS_Y)
479 sta screen_1
480 lda #>$a000+(40*MANDEL_WINDOWS_Y)
481 sta screen_1+1
482
483 lda #<$a000+(40*(MANDEL_WINDOWS_Y+1))
484 sta screen_2
485 lda #>$a000+(40*(MANDEL_WINDOWS_Y+1))
486 sta screen_2+1
487
488
489
490 lda #<_BigBuffer
491 sta tmp0+0
492 lda #>_BigBuffer
493 sta tmp0+1
494
495 lda #64
496 sta tmp1
497 loop_y
498
499 //jmp loop_y
500
501
502 //
503 // First read a bloc of 114 bytes, and push them on stack
504 // (40-1)*3=117
505 //
506 ldy #0
507 loop_fill
508 lda (tmp0),y
509 pha
510 iny
511 cpy #117
512 bne loop_fill
513
514 //
515 // Increment pointer on big buffer
516 //
517 .(
518 clc
519 lda tmp0
520 adc #128
521 sta tmp0
522 bcc skip
523 inc tmp0+1
524 skip
525 .)
526
527 //
528 // Write colors
529 //
530 ldy #0
531 lda #1
532 sta (screen_1),y
533 lda #16+4
534 sta (screen_2),y
535 iny
536
537 //
538 // And then remove pixels from stack
539 //
540 loop_x
541 pla
542 tax
543 asl
544 asl
545 asl
546 asl
547 and #%110000
548 sta accu_1
549
550 txa
551 asl
552 asl
553 and #%110000
554 sta accu_2
555
556
557 pla
558 tax
559 asl
560 asl
561 and #%001100
562 ora accu_1
563 sta accu_1
564
565 txa
566 and #%001100
567 ora accu_2
568 sta accu_2
569
570
571 pla
572 tax
573 and #%000011
574 ora accu_1
575 ora #64
576 sta (screen_1),y
577
578 txa
579 lsr
580 lsr
581 and #%000011
582 ora accu_2
583 ora #64
584 sta (screen_2),y
585
586 iny
587
588 cpy #40
589 bne loop_x
590
591
592 .(
593 clc
594 lda screen_1
595 adc #80
596 sta screen_1
597 bcc skip_1
598 inc screen_1+1
599 clc
600 skip_1
601 .)
602
603 .(
604 clc
605 lda screen_2
606 adc #80
607 sta screen_2
608 bcc skip_2
609 inc screen_2+1
610 skip_2
611 .)
612
613 dec tmp1
614 beq end
615 jmp loop_y
616
617 end
618
619 pla
620 tay
621 pla
622 tax
623 pla
624
625 jsr _Mandel_DisplayGreetings
626 rts
627 .)
628
629
630
631
632 _Mandel_InitDisplay
633 .(
634 //
635 // Prepare the tone mapping
636 //
637 jsr _VScroll_GenerateScrollMapping
638
639 //
640 // Initialise the pointer on greetings
641 //
642 lda #<_Mandel_GreetingList
643 sta greetings_pointer+0
644 lda #>_Mandel_GreetingList
645 sta greetings_pointer+1
646
647 //
648 // Start by clearing the buffer to avoid surprises
649 //
650 jsr _Mandle_ClearBigBuffer
651
652 //
653 // Prepare the table of colors
654 //
655 ldy #0
656 loop_screen_offset
657 src_1
658 lda #<_BigBuffer
659 sta _BufferAddrLow,y
660
661 src_2
662 lda #>_BigBuffer
663 sta _BufferAddrHigh,y
664
665 clc
666 lda src_1+1
667 adc #128
668 sta src_1+1
669 bcc skip
670 inc src_2+1
671 skip
672
673 iny
674 cpy #200
675 bne loop_screen_offset
676
677 //
678 // Draw some rasters, and the blue colors for mandelbrot
679 //
680 lda #16+1
681 sta $a000+40*(MANDEL_WINDOWS_Y-2)
682 sta $a000+40*(MANDEL_WINDOWS_Y+128+1)
683
684 lda #16+3
685 sta $a000+40*(MANDEL_WINDOWS_Y-3)
686 sta $a000+40*(MANDEL_WINDOWS_Y+128+2)
687
688 lda #16+7
689 sta $a000+40*(MANDEL_WINDOWS_Y-4)
690 sta $a000+40*(MANDEL_WINDOWS_Y+128+3)
691
692 lda #16+3
693 sta $a000+40*(MANDEL_WINDOWS_Y-5)
694 sta $a000+40*(MANDEL_WINDOWS_Y+128+4)
695
696 lda #16+1
697 sta $a000+40*(MANDEL_WINDOWS_Y-6)
698 sta $a000+40*(MANDEL_WINDOWS_Y+128+5)
699
700 //
701 // Blit the buffer to get the colors
702 //
703 jsr _Mandle_BlitBigBuffer
704
705 rts
706 .)
707
708
709
710
711
712
713 // y=200
714 // do
715 // {
716 // y-=2
717 //
718 // ptr_buffer=ColorBuffer
719 //
720 // x=230
721 // do
722 // {
723 // compute_outer()
724 //
725 // *ptr_buffer++=n
726 // }
727 // while (x)
728 //
729 // display_buffer()
730 // }
731 // while (y)
732
733 //xpos .byt 0
734
735
736
737
738 _Mandel_ComputeParameters
739 //jmp _Mandel_ComputeParameters
740 .(
741 //
742 // big_buff=_BigBuffer+(_y*128)
743 //
744 /*
745 clc
746 lda _y
747 ror
748 sta big_buff+1
749 lda #0
750 ror
751 sta big_buff+0
752 clc
753 lda big_buff+0
754 adc #<_BigBuffer
755 sta big_buff+0
756 lda big_buff+1
757 adc #>_BigBuffer
758 sta big_buff+1
759 */
760 ldy _y
761 lda _BufferAddrLow,y
762 sta big_buff+0
763 lda _BufferAddrHigh,y
764 sta big_buff+1
765
766
767 // X1=-64+(x*2)
768 clc
769 lda _x
770 rol
771 sta _x1+0
772 lda #0
773 rol
774 sta _x1+1
775
776 sec
777 lda _x1+0
778 sbc #<MANDEL_X_POS
779 sta _x1+0
780 lda _x1+1
781 sbc #>MANDEL_X_POS
782 sta _x1+1
783
784
785 // y1=-64+(y*2)
786 clc
787 lda _y
788 rol
789 sta _y1+0
790 lda #0
791 rol
792 sta _y1+1
793
794 sec
795 lda _y1+0
796 sbc #<MANDEL_Y_POS
797 sta _y1+0
798 lda _y1+1
799 sbc #>MANDEL_Y_POS
800 sta _y1+1
801
802
803 rts
804 .)
805
806
807 //
808 // Call with initialized values for:
809 // _x
810 // _y
811 // _w
812 //
813 // _x1
814 // _y1
815 //
816 _Mandel_HLine
817 .(
818 jsr _Mandel_ComputeParameters
819
820 lda _w
821 pha
822
823 loop_x
824 clc
825 lda _x1+0
826 sta _xn+0
827 adc #2
828 sta _x1+0
829 lda _x1+1
830 sta _xn+1
831 adc #0
832 sta _x1+1
833
834 lda _y1+0
835 sta _yn+0
836 lda _y1+1
837 sta _yn+1
838
839 jsr _compute_outer
840
841 // Store pixel in buffer
842 lda _n
843 ldy _x
844 sta (big_buff),y
845 inc _x
846
847 dec _w
848 bne loop_x
849
850 pla
851 sta _w
852
853 rts
854 .)
855
856
857
858 //
859 // Call with initialized values for:
860 // _x
861 // _y
862 // _h
863 //
864 // _x1
865 // _y1
866 //
867 _Mandel_VLine
868 .(
869 jsr _Mandel_ComputeParameters
870
871 lda _h
872 pha
873
874 loop_y
875 clc
876 lda _y1+0
877 sta _yn+0
878 adc #2
879 sta _y1+0
880 lda _y1+1
881 sta _yn+1
882 adc #0
883 sta _y1+1
884
885 lda _x1+0
886 sta _xn+0
887 lda _x1+1
888 sta _xn+1
889
890 jsr _compute_outer
891
892 // Store pixel in buffer
893 lda _n
894 ldy _x
895 sta (big_buff),y
896
897 clc
898 lda big_buff+0
899 adc #128
900 sta big_buff+0
901 bcc skip
902 inc big_buff+1
903 skip
904
905 dec _h
906 bne loop_y
907
908 pla
909 sta _h
910
911 rts
912 .)
913
914
915
916
917
918 //
919 // Check if the value in the rect is homogeneous
920 //
921 _Mandel_CheckRect
922 .(
923 /*
924 clc
925 lda _y
926 ror
927 sta big_buff+1
928 lda #0
929 ror
930 sta big_buff+0
931 clc
932 lda big_buff+0
933 adc #<_BigBuffer
934 sta big_buff+0
935 sta screen_1+0
936 lda #>_BigBuffer
937 adc big_buff+1
938 sta big_buff+1
939 sta screen_1+1
940 */
941
942 ldy _y
943 lda _BufferAddrLow,y
944 sta big_buff+0
945 sta screen_1+0
946 lda _BufferAddrHigh,y
947 sta big_buff+1
948 sta screen_1+1
949
950
951 // Read the comparison value
952 ldy _x
953 lda (big_buff),y
954 sta _ref_pixel
955
956 // Check the rectangle around
957 clc
958 lda _x
959 adc _w
960 sta x_buff
961
962 .(
963 // Top part
964 ldy _x
965 ldx _w
966 inx
967 loop
968 lda (big_buff),y
969 cmp _ref_pixel
970 bne found_different
971 iny
972 dex
973 bne loop
974 .)
975
976 .(
977 // Left and right part
978 ldx _h
979 inx
980 loop
981 ldy _x
982 lda (big_buff),y
983 cmp _ref_pixel
984 bne found_different
985 ldy x_buff
986 lda (big_buff),y
987 cmp _ref_pixel
988 bne found_different
989
990 clc
991 lda big_buff+0
992 adc #128
993 sta big_buff+0
994 bcc skip
995 inc big_buff+1
996 skip
997
998 iny
999 dex
1000 bne loop
1001 .)
1002
1003 .(
1004 // Bottom part
1005 ldy _x
1006 ldx _w
1007 inx
1008 loop
1009 lda (big_buff),y
1010 cmp _ref_pixel
1011 bne found_different
1012 iny
1013 dex
1014 bne loop
1015 .)
1016
1017 found_similar
1018 //
1019 // Fill the box with solid color
1020 //
1021 .(
1022 lda _h
1023 sta tmp0
1024 loop_y
1025
1026 ldx _w
1027 ldy _x
1028 lda _ref_pixel
1029 loop_x
1030 sta (screen_1),y
1031 iny
1032 dex
1033 bne loop_x
1034
1035 clc
1036 lda screen_1+0
1037 adc #128
1038 sta screen_1+0
1039 bcc skip
1040 inc screen_1+1
1041 skip
1042
1043 dec tmp0
1044 bne loop_y
1045 .)
1046 lda #0
1047 rts
1048
1049 found_different
1050 lda #1
1051 rts
1052 .)
1053
1054
1055
1056 // (0,0)-(127,63)
1057 _Mandel_Divide
1058 //jmp _Mandel_Divide
1059 .(
1060 // VBL Check draw
1061 .(
1062 lda _VblCounter
1063 cmp #60
1064 bcc skip
1065 jsr _Mandle_BlitBigBuffer
1066 lda #0
1067 sta _VblCounter
1068 skip
1069 .)
1070
1071 //lda _w
1072 //beq quit
1073 //cmp #1
1074 //beq quit
1075 lda _h
1076 //beq quit
1077 cmp #1
1078 beq quit
1079
1080 jsr _Mandel_CheckRect
1081 cmp #0
1082 bne recurse
1083 quit
1084 rts
1085
1086 recurse
1087
1088 .(
1089 lda _x
1090 pha
1091 lda _y
1092 pha
1093 lda _w
1094 pha
1095 lda _h
1096 pha
1097
1098
1099 // h_line
1100 lda _h
1101 lsr
1102 clc
1103 adc _y
1104 sta _y
1105
1106 inc _x
1107 dec _w
1108
1109 jsr _Mandel_HLine
1110
1111 pla
1112 sta _h
1113 pla
1114 sta _w
1115 pla
1116 sta _y
1117 pla
1118 sta _x
1119 .)
1120
1121 .(
1122 lda _x
1123 pha
1124 lda _y
1125 pha
1126 lda _w
1127 pha
1128 lda _h
1129 pha
1130
1131 // v_line
1132 lda _w
1133 lsr
1134 clc
1135 adc _x
1136 sta _x
1137
1138 inc _y
1139 dec _h
1140
1141 jsr _Mandel_VLine
1142
1143 pla
1144 sta _h
1145 pla
1146 sta _w
1147 pla
1148 sta _y
1149 pla
1150 sta _x
1151 .)
1152
1153 //jsr _Mandle_BlitBigBuffer
1154
1155 .(
1156 lda _w
1157 pha
1158 lda _h
1159 pha
1160
1161 lsr _w
1162 lsr _h
1163
1164 lda _h
1165 cmp #1
1166 beq skip_recurse
1167
1168
1169 // 0,0
1170 jsr _Mandel_Divide
1171
1172 // 1,0
1173 lda _x
1174 pha
1175 clc
1176 adc _w
1177 sta _x
1178 jsr _Mandel_Divide
1179 pla
1180 sta _x
1181
1182 // 0,1
1183 lda _y
1184 pha
1185 clc
1186 adc _h
1187 sta _y
1188 jsr _Mandel_Divide
1189 pla
1190 sta _y
1191
1192 // 1,1
1193 lda _x
1194 pha
1195 clc
1196 adc _w
1197 sta _x
1198 lda _y
1199 pha
1200 clc
1201 adc _h
1202 sta _y
1203 jsr _Mandel_Divide
1204 pla
1205 sta _y
1206 pla
1207 sta _x
1208
1209 skip_recurse
1210
1211 pla
1212 sta _h
1213 pla
1214 sta _w
1215
1216 .)
1217
1218 rts
1219 .)
1220
1221
1222 //
1223 // Optimised recursive version of fractalus
1224 //
1225 _Mandel_DrawFractal
1226 .(
1227 /*
1228 .(
1229 lda #0
1230 sta _y
1231
1232 loop
1233 lda #0
1234 sta _x
1235
1236 lda #128
1237 sta _w
1238
1239 jsr _Mandel_HLine
1240 jsr _Mandle_BlitBigBuffer
1241
1242 inc _y
1243 ldy _y
1244 cpy #64
1245 bne loop
1246 rts
1247 .)
1248 */
1249
1250 /*
1251 .(
1252 lda #0
1253 sta _x
1254 loop
1255 lda #0
1256 sta _y
1257
1258 lda #64
1259 sta _h
1260
1261 jsr _Mandel_VLine
1262 jsr _Mandle_BlitBigBuffer
1263
1264 inc _x
1265 ldy _x
1266 cpy #128
1267 bne loop
1268 rts
1269 .)
1270 */
1271
1272
1273 // h_line(0,0,largeur,XO,YO,PAS,buf,screen,pitch);
1274 lda #0
1275 sta _x
1276
1277 lda #0
1278 sta _y
1279
1280 lda #128
1281 sta _w
1282
1283 jsr _Mandel_HLine
1284
1285
1286 // h_line(0+1,0+largeur,largeur,XO+PAS,YO+((reel)largeur)*PAS,PAS,buf,screen,pitch);
1287 lda #0
1288 sta _x
1289
1290 lda #64
1291 sta _y
1292
1293 lda #128
1294 sta _w
1295
1296 jsr _Mandel_HLine
1297
1298
1299 // v_line(0,0+1,largeur,XO,YO+PAS,PAS,buf,screen,pitch);
1300 lda #0
1301 sta _x
1302
1303 lda #0
1304 sta _y
1305
1306 lda #64
1307 sta _h
1308
1309 jsr _Mandel_VLine
1310
1311
1312 // v_line(0+largeur,0,largeur,XO+((reel)largeur)*PAS,YO,PAS,buf,screen,pitch);
1313 lda #128
1314 sta _x
1315
1316 lda #0
1317 sta _y
1318
1319 lda #64
1320 sta _h
1321
1322 jsr _Mandel_VLine
1323
1324
1325
1326 jsr _Mandle_BlitBigBuffer
1327
1328
1329 // division(0,0,PAS,XO,YO,largeur,buf,screen,pitch);
1330
1331 lda #0
1332 sta _VblCounter
1333
1334 lda #0
1335 sta _x
1336 lda #0
1337 sta _y
1338 lda #128
1339 sta _w
1340 lda #64
1341 sta _h
1342
1343 jsr _Mandel_Divide
1344
1345 jsr _Mandle_BlitBigBuffer
1346
1347
1348 // Don't forget to restore AddrTables :)
1349 jsr _Tables_InitialiseScreenAddrTable
1350
1351
1352 /*
1353 h_line(0,0,largeur,XO,YO,PAS,buf,screen,pitch);
1354
1355 v_line(0+largeur,0,largeur,XO+((reel)largeur)*PAS,YO,PAS,buf,screen,pitch);
1356
1357 h_line(0+1,0+largeur,largeur,XO+PAS,YO+((reel)largeur)*PAS,PAS,buf,screen,pitch);
1358
1359 v_line(0,0+1,largeur,XO,YO+PAS,PAS,buf,screen,pitch);
1360
1361 division(0,0,PAS,XO,YO,largeur,buf,screen,pitch);
1362 */
1363
1364 rts
1365 .)
1366
1367
1368
1369
1370
1371
1372 // x-=2
1373 // n=pr
1374 // x1=x-80
1375 // y1=y-100
1376 // xn=x1
1377 // yn=y1
1378 //
1379 //
1380 // do
1381 // {
1382 // compute_inner()
1383 // }
1384 // while ( (n!=0) && ((abs(xn)+abs(yn))<=d3) )
1385
1386 _outer_exit
1387 rts
1388
1389 _compute_outer
1390 // n=pr
1391 lda #MANDEL_ITER_BIS
1392 sta _n
1393
1394 compute_outer_loop
1395 jsr _compute_inner
1396
1397 // n--
1398 dec _n
1399 beq _outer_exit
1400
1401 // ABS(xn)
1402 lda _xn+1
1403 bmi xn_neg
1404 sta _axn+1
1405 lda _xn
1406 sta _axn
1407 jmp xn_abs
1408
1409 xn_neg
1410 sec
1411 lda #0
1412 sbc _xn
1413 sta _axn
1414 lda #0
1415 sbc _xn+1
1416 sta _axn+1
1417 xn_abs
1418
1419
1420 // ABS(yn)
1421 lda _yn+1
1422 bmi yn_neg
1423 sta _ayn+1
1424 lda _yn
1425 sta _ayn
1426 jmp yn_abs
1427
1428 yn_neg
1429 sec
1430 lda #0
1431 sbc _yn
1432 sta _ayn
1433 lda #0
1434 sbc _yn+1
1435 sta _ayn+1
1436 yn_abs
1437
1438 // sum axn+ayn => axn
1439 // if axn+ayn<=d3 exit loop
1440 clc
1441 lda _axn
1442 adc _ayn
1443 sta _axn
1444 lda _axn+1
1445 adc _ayn+1
1446 cmp #>MAX_MANDEL_ITER
1447 bcc compute_outer_loop
1448
1449 lda _axn
1450 cmp #<MAX_MANDEL_ITER
1451 bcc compute_outer_loop
1452
1453 end_outer
1454 rts
1455
1456
1457
1458
1459 // d=xn+yn
1460 // b=xn-yn
1461 // c=xn*yn
1462 //
1463 // xn=d*b/d1-x1
1464 // yn=c/d2-y1
1465 //
1466 // n--
1467
1468 _compute_inner
1469 // d=xn+yn
1470 clc
1471 lda _xn
1472 adc _yn
1473 sta _d
1474 lda _xn+1
1475 adc _yn+1
1476 sta _d+1
1477
1478 // b=xn-yn
1479 sec
1480 lda _xn
1481 sbc _yn
1482 sta _b
1483 lda _xn+1
1484 sbc _yn+1
1485 sta _b+1
1486
1487 // c=xn*yn
1488 lda _xn
1489 sta op1
1490 lda _xn+1
1491 sta op1+1
1492 lda _yn
1493 sta op2
1494 lda _yn+1
1495 sta op2+1
1496 jsr mul16i
1497 stx _c
1498 sta _c+1
1499
1500 // yn=c/d2-y1
1501 ldx _c+1
1502 ldy _c
1503
1504 lda _TableDiv32_low,x
1505 and #%11111000
1506 sta _tempfastdiv
1507
1508 lda _TableDiv32_low,y
1509 and #%00000111
1510 ora _tempfastdiv
1511 sec
1512 sta _c
1513 sbc _y1
1514 sta _yn
1515 lda _TableDiv32_high,x
1516 sbc _y1+1
1517 sta _yn+1
1518
1519
1520 // xn=d*b/d1-x1
1521 lda _d
1522 sta op1
1523 lda _d+1
1524 sta op1+1
1525 lda _b
1526 sta op2
1527 lda _b+1
1528 sta op2+1
1529 jsr mul16i
1530 stx op1
1531 sta op1+1
1532
1533 ldx op1+1
1534 ldy op1
1535
1536 lda _TableDiv64_low,x
1537 and #%11111100
1538 sta _tempfastdiv
1539
1540 lda _TableDiv64_low,y
1541 and #%00000011
1542 ora _tempfastdiv
1543 sec
1544 sta op1
1545 sbc _x1
1546 sta _xn
1547 lda _TableDiv64_high,x
1548 sbc _x1+1
1549 sta _xn+1
1550
1551 rts
1552
1553
1554 /*
1555 // unsigned 16bit multply op1 x op2
1556 mandel_mul16u
1557 lda #0
1558 sta tmp
1559 sta tmp+1
1560 ldy #16
1561 mandel_mult1
1562 asl tmp
1563 rol tmp+1
1564 rol op1
1565 rol op1+1
1566 bcc mandel_mult2
1567 clc
1568 lda op2
1569 adc tmp
1570 sta tmp
1571 lda op2+1
1572 adc tmp+1
1573 sta tmp+1
1574 bcc mandel_mult2
1575 inc op1
1576 mandel_mult2
1577 dey
1578 bne mandel_mult1
1579 ldx tmp
1580 lda tmp+1
1581 rts
1582
1583 mandel_mul16i
1584 lda op1+1
1585 bpl mandel_mul16u
1586 sec
1587 lda #0
1588 sbc op1
1589 sta op1
1590 lda #0
1591 sbc op1+1
1592 sta op1+1
1593 jsr mandel_mul16u
1594 sec
1595 lda #0
1596 sbc tmp
1597 tax
1598 lda #0
1599 sbc tmp+1
1600 rts
1601 */

  ViewVC Help
Powered by ViewVC 1.1.26