summaryrefslogtreecommitdiffstats
path: root/hacks/images/m6502/greynetic.asm
blob: 1218d87fd7c0daf20fd8a286ee8b45ed4445b8a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
;Port of Greynetic
;Jeremy English 2013

lda #$0
sta $0
lda #$2
sta $1

start:
lda $1
cmp #$6
bne randOffset
lda #$2
sta $1

randOffset:
;move position by some random offset
clc
lda $fe
adc $0
sta $0
lda $1
adc #$0
sta $1
cmp #$06 ;Did we go out of range
bne setRect ;Nope
lda #$02 ;Start back at the top
sta $1

setRect:
lda $fe
and #$f
tax
inx ;at least 1
stx $2 ;width
stx $3 ;working copy
lda $fe
and #$f
tax
inx ;at least 1
stx $4 ;height

lda $fe
sta $5 ;color

ldy #0
draw:
lda $5
sta ($0), y
dec $3
beq down

lda $0
clc
adc #$1
sta $0
lda $1
adc #$0
sta $1
cmp #$06 ;Did we go out of range
beq done ;yes
jmp draw

down:

;;Move back to the start of this row
ldx $2 ;The width of the rectangle
dex
lda $0
stx $0
sec
sbc $0
sta $0
lda $1
sbc #$0
sta $1

;;Move down one row
dec $4
beq done ;;Are we done drawing?

lda $2
sta $3 ;reset the width counter

lda $0
clc
adc #$20
sta $0
lda $1
adc #$0
sta $1
cmp #$06 ;Did we go out of range
beq done ;yes
jmp draw
done:
jmp start