-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdisplay_mc_sprites.asm
172 lines (153 loc) · 2.46 KB
/
display_mc_sprites.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
.const fade_speed = 4
.const screenram = $0400
.const sprites = $2000
.const spr_xpos_start = $40
.const spr_ypos_start = $32
.const zp_start = $10
.const zp_spr_xy_lo = zp_start + 0
.const zp_spr_xy_hi = zp_start + 1
.const zp_spr_xpos = zp_start + 2
.const zp_spr_ypos = zp_start + 3
.import source "lib.asm"
.pc = $0801 "basic upstart"
.byte <basicend, >basicend, <year(), >year(), $9e
.text toIntString(start)
.text " PNG2PRG " + versionString()
basicend:
.byte 0, 0, 0
.pc = basicsys() "start"
start:
sei
lda #$37
sta $01
jsr vblank
ldx #0
stx $d011
stx $d020
stx $d021
lda #1
sta $0286
jsr $e536
lda #$ff
!loop:
smc_src:
ldx spr_bitmap+$1fff
smc_dest:
stx sprites+$1fff
dcp smc_src+1
bne !+
dec smc_src+2
!:
dcp smc_dest+1
bne !+
dec smc_dest+2
!:
ldx smc_dest+2
cpx #>(sprites-1)
bne !loop-
init_sprites:
anc #0
sta $d010
sta $d015
sta $d017
sta $d01b
sta $d01d
lda #$ff
sta $d01c // single/multicol
ldx #7
lda spr_spritecol
!: sta $d027,x
dex
bpl !-
lda spr_d025col
sta $d025
lda spr_d026col
sta $d026
ldx #$f
lda #0
!: sta $d000,x
dex
bpl !-
ldx #toSpritePtr(sprites)
.for (var i=0; i<7; i++) {
stx screenram+$3f8+i
inx
}
stx screenram+$3f8+7
lda #<$d000
sta zp_spr_xy_lo
lda #>$d000
sta zp_spr_xy_hi
lda #$40
sta zp_spr_xpos
lda #$32
sta zp_spr_ypos
ldy #0
!loop: ldx spr_columns
!: lda zp_spr_xpos
sta (zp_spr_xy_lo),y
clc
adc #$18
sta zp_spr_xpos
iny
lda zp_spr_ypos
sta (zp_spr_xy_lo),y
iny
cpy #$10
beq !done+
dex
bne !-
lda zp_spr_ypos
clc
adc #21
sta zp_spr_ypos
lda #spr_xpos_start
sta zp_spr_xpos
dec spr_rows
beq !done+
cpy #$10
bne !loop-
!done:
jsr vblank
:setBank(screenram)
lda #toD018(screenram, $1000)
sta $d018
lda #$c8
sta $d016
lda #$1b
sta $d011
lda spr_bgcol
sta $d021
lda #$ff
sta $d015
lda #$ef
!: cmp $dc01
bne !-
jsr vblank
lda #0
sta $d011
jsr $e544
jmp $fce2
vblank:
:vblank()
rts
// -------------------------------------------
/*
.C:0910 02 JAM
.C:0911 50 0F BVC $0922
.C:0913 00 BRK
.C:0914 01 00 ORA ($00,X)
.C:0916 00 BRK
.C:0917 00 BRK
.C:0918 00 BRK
.C:0919 00 BRK
*/
.pc = * "sprites_source" virtual
sprites_source:
spr_columns: .byte 0
spr_rows: .byte 0
spr_bgcol: .byte 0
spr_d025col: .byte 0
spr_spritecol: .byte 0
spr_d026col: .byte 0
spr_bitmap: