-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprlib.asm
144 lines (133 loc) · 1.85 KB
/
sprlib.asm
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
.segment Code
.const spren = $d015
.const sprmc = $d01c
.const sprcolor = $d027
.const sprmc1 = $d025
.const sprmc2 = $d026
.const sprxhi = $d010
.const sprxpos = $d000
.const sprypos = $d001
.var sprbase = $4000
.macro setSpriteMC(mc1, mc2) {
lda #mc1
sta sprmc1
lda #mc2
sta sprmc2
}
.macro loadSprite(location, num) {
lda #location
ldy #num
sta sprp1, y
sta sprp2, y
.eval location = (((location + 1) * 64) - 1) + sprbase
lda location
sta tmp0
and #$80 // multicolor
beq !+
lda #(1 << num)
ora sprmc
sta sprmc
jmp !++
!: lda #(1 << num) ^ $ff
and sprmc
sta sprmc
!: lda tmp0
and #$0F // color
sta sprcolor + num
enableSprite(num)
}
.macro enableSprite(num){
lda #(1 << num)
ora spren
sta spren
}
.macro disableSprite(num) {
lda #((1 << num) ^ $ff)
and spren
sta spren
}
.macro enableSprites() {
lda #$ff
sta spren
}
.macro disableSprites() {
lda #$00
sta spren
}
.macro moveSprite(num, x, y) {
.if (x > 255) {
// load the hi bit
lda #(1 << num)
ora sprxhi
sta sprxhi
} else {
lda #((1 << num) ^ $ff)
and sprxhi
sta sprxhi
}
lda #<x
sta sprxpos + (num * 2)
lda #y
sta sprypos + (num * 2)
}
.macro pushFrogRight(amt) {
lda scrollamt
beq addamt
lda $d000
bne !+
lda #$fa
and $d010
sta $d010
!: dec $d000
lda $d002
bne !+
lda #$f5
and $d010
sta $d010
!: dec $d002
dec scrollamt
addamt:
lda $d000
clc
adc amt
foundhi: sta $d000
sta $d004
bcc pfr1
lda #((1 << 0) | (1 << 2))
ora sprxhi
sta sprxhi
pfr1: lda $d002
clc
adc amt
foundhi1: sta $d002
sta $d006
bcc pfr2
lda #((1 << 1) | (1 << 3))
ora sprxhi
sta sprxhi
pfr2:
}
.macro pushFrogUp(amt) {
lda $d001
sec
sbc #amt
sta $d001
sta $d003
lda $d005
sec
sbc #amt
sta $d005
sta $d007
}
.macro pushFrogDown(amt) {
lda $d001
clc
adc #amt
sta $d001
sta $d003
lda $d005
clc
adc #amt
sta $d005
sta $d007
}