-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter 05.a
56 lines (43 loc) · 1.47 KB
/
Chapter 05.a
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
processor 6502
include "vcs.h"
include "macro.h"
org $f000 ; start code at $f000
BGColor equ $81 ; variable in memory address $81
Start
CLEAN_START ; macro to safely clear memroy and TIA
NextFrame
lda #2 ; same as binary #%00000010
sta VBLANK ; turn on VBLANK
sta VSYNC ; turn on VSYNC
sta WSYNC ; first scanline
sta WSYNC ; second scanline
sta WSYNC ; third scanline
lda #0
sta VSYNC ; turn off VSYNC
ldx #37 ; count 37 scanlines
LVBlank
sta WSYNC ; wait for next scanline
dex ; decrement x
bne LVBlank ; loop while x != 0
lda #0
sta VBLANK ; turn off VBLANK
ldx #192 ; count 192 scanlines
ldy BGColor ; load the background color from RAM
LVScan
sty COLUBK ; set the background color
sta WSYNC ; wait for the next scanline
iny ; increment the background color
dex ; decrement X
bne LVScan ; loop while X != 0
lda #2
sta VBLANK ; turn on VBLANK again
ldx #30 ; count 30 scanlines
LVOver
sta WSYNC ; wait for next scanline
dex ; decrement X
bne LVOver ; loop while X != 0
dec BGColor ; decrement BGColor
jmp NextFrame ; jump to NextFrame label
org $fffc
.word Start ; reset vector at $fffc
.word Start ; interrupt vector at $fffe (unused in VCS)