From http://www.jwz.org/xscreensaver/xscreensaver-5.36.tar.gz
[xscreensaver] / hacks / images / m6502 / greynetic.asm
1 ;Port of Greynetic
2 ;Jeremy English 2013
3
4 lda #$0
5 sta $0
6 lda #$2
7 sta $1
8
9 start:
10 lda $1
11 cmp #$6
12 bne randOffset
13 lda #$2
14 sta $1
15
16 randOffset:
17 ;move position by some random offset
18 clc
19 lda $fe
20 adc $0
21 sta $0
22 lda $1
23 adc #$0
24 sta $1
25 cmp #$06 ;Did we go out of range
26 bne setRect ;Nope
27 lda #$02 ;Start back at the top
28 sta $1
29
30 setRect:
31 lda $fe
32 and #$f
33 tax
34 inx ;at least 1
35 stx $2 ;width
36 stx $3 ;working copy
37 lda $fe
38 and #$f
39 tax
40 inx ;at least 1
41 stx $4 ;height
42
43 lda $fe
44 sta $5 ;color
45
46 ldy #0
47 draw:
48 lda $5
49 sta ($0), y
50 dec $3
51 beq down
52
53 lda $0
54 clc
55 adc #$1
56 sta $0
57 lda $1
58 adc #$0
59 sta $1
60 cmp #$06 ;Did we go out of range
61 beq done ;yes
62 jmp draw
63
64 down:
65
66 ;;Move back to the start of this row
67 ldx $2 ;The width of the rectangle
68 dex
69 lda $0
70 stx $0
71 sec
72 sbc $0
73 sta $0
74 lda $1
75 sbc #$0
76 sta $1
77
78 ;;Move down one row
79 dec $4
80 beq done ;;Are we done drawing?
81
82 lda $2
83 sta $3 ;reset the width counter
84
85 lda $0
86 clc
87 adc #$20
88 sta $0
89 lda $1
90 adc #$0
91 sta $1
92 cmp #$06 ;Did we go out of range
93 beq done ;yes
94 jmp draw
95 done:
96 jmp start