http://www.tienza.es/crux/src/www.jwz.org/xscreensaver/xscreensaver-5.05.tar.gz
[xscreensaver] / hacks / images / m6502 / keftal.asm
1 ; awfully slow.. be patient
2
3 init:
4   ldx #0
5   stx $0
6   inx
7   stx $2
8   stx $3
9   inx
10   stx $1
11
12 loop:
13   lda $2
14   cmp #$20
15   bne notIncF2
16   inc $3
17   lda #0
18   sta $2
19 notIncF2:
20   inc $2
21
22 ; CALCULATE START
23
24   lda $2
25   sta $f1
26   lda $2
27   sta $f2
28   jsr multiply
29
30   lda $f4
31   sta $f8
32
33   lda $3
34   sta $f1
35   lda $3
36   sta $f2
37   jsr multiply
38
39 ; CALCULATE STOP
40
41   lda $f4
42   clc
43   adc $f8
44
45   lsr
46   lsr
47   lsr
48   lsr
49   lsr
50   ldx #0
51   sta ($0,x)
52   inc $0
53   lda $0
54   cmp #$00
55   bne notNextY
56   inc $1
57   lda $1
58   cmp #6
59   beq exit
60 notNextY:
61   jmp loop
62 exit:
63   rts
64
65 multiply:
66   lda #0
67   sta $f4
68   sta $f5
69   ldx #8
70 a:asl $f4
71   rol $f5
72   asl $f2
73   bcc b
74   clc
75   lda $f4
76   adc $f1
77   sta $f4
78   bcc b
79   inc $f5
80 b:dex
81   bne a
82   rts