-
Notifications
You must be signed in to change notification settings - Fork 0
/
i_dtv.asm
214 lines (176 loc) · 4.13 KB
/
i_dtv.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
enable_dtvextensions .macro
lda #$01
sta $D03F ;Enable extended features
.endm
;--------------------------------------------------------------------------------
enable_burstmode_skipcycles .macro
sei
sac #$99 ;enable burstmode and skipcycles
lda #%00000011
sac #$00 ;
cli
.endm
;--------------------------------------------------------------------------------
disable_burstmode_skipcycles .macro
sei
sac #$99 ;disable burstmode and skipcycles
lda #%00000000
sac #$00 ;
cli
.endm
;--------------------------------------------------------------------------------
enable_burstmode .macro
sei
sac #$99 ;enable burstmode
lda #%00000010
sac #$00 ;
cli
.endm
;--------------------------------------------------------------------------------
set_videomode8pp .macro
lda #$55
sta $D03C ;Enable Linear Mode
lda #$5B
sta $D011
lda #$18
sta $D016
lda #$08
sta $D04C ;Stepping=8
.endm
;--------------------------------------------------------------------------------
set_pal16gray .macro
LDY #$00 ;Define first 16 palette colors
- TYA
sta $D200,Y
INY
CPY #$10
BNE -
.endm
;--------------------------------------------------------------------------------
set_pal16black .macro
LDY #$00 ;Define first 16 palette colors
tya
-
sta $D200,Y
INY
CPY #$10
BNE -
.endm
;--------------------------------------------------------------------------------
set_pal16white .macro
LDY #$00 ;Define first 16 palette colors
lda #$0f
-
sta $D200,Y
INY
CPY #$10
BNE -
.endm
;--------------------------------------------------------------------------------
show_bank .macro
lda #$00
sta $D049 ;Screen location LOW
lda #$00
sta $D04A ;Screen location MID
lda \1
sta $D04B ;Screen location HIGH
.endm
;--------------------------------------------------------------------------------
wait_dma .macro
- lda $D31F ;Wait for DMA to finish
AND #$01
CMP #$00
BNE -
.endm
;--------------------------------------------------------------------------------
dma_memcopy .macro
lda #$00
sta $D300 ;Set source low
lda #$00
sta $D301 ;Set source Mid
lda \1
sta $D302 ;Set source high
lda #$00
sta $D303 ;Set Dest low
lda #$00
sta $D304 ;Set Dest Mid
lda \2
sta $D305 ;Set Dest High
lda #$01
sta $D306 ;Set Source Step Low
lda #$00
sta $D307 ;Set Source Step High
lda #$01
sta $D308 ;Set Dest Step Low
lda #$00
sta $D309 ;Set Dest Step High
lda #<64000
sta $D30A ;Set Length Low
lda #>64000
sta $D30B ;Set Length High
lda #$0D
sta $D31F ;start transfer
- lda $D31F ;Wait for DMA to finish
AND #$01
CMP #$00
BNE -
.endm
;--------------------------------------------------------------------------------
clearbitmap .macro
lda #<PC
sta $D300 ;Set source low
lda #>PC
sta $D301 ;Set source Mid
lda #$40
sta $D302 ;Set source high
lda #$00
sta $D303 ;Set Dest low
lda #$00
sta $D304 ;Set Dest Mid
lda \1
sta $D305 ;Set Dest High
lda #$00
sta $D306 ;Set Source Step Low
lda #$00
sta $D307 ;Set Source Step High
lda #$01
sta $D308 ;Set Dest Step Low
lda #$00
sta $D309 ;Set Dest Step High
lda #<$ffff
sta $D30A ;Set Length Low
lda #>$ffff
sta $D30B ;Set Length High
lda #$0D
sta $D31F ;start transfer
- lda $D31F ;Wait for DMA to finish
AND #$01
CMP #$00
BNE -
.endm
;--------------------------------------------------------------------------------
wait_vbl .macro
-
lda $d011
bpl -
-
lda $d011
bmi -
.endm
;--------------------------------------------------------------------------------
push_regs .macro
pha
txa
pha
tya
pha
.endm
;--------------------------------------------------------------------------------
pull_regs .macro
pla
tay
pla
tax
pla
.endm
;--------------------------------------------------------------------------------