-
Notifications
You must be signed in to change notification settings - Fork 0
/
rainbow.asm
64 lines (47 loc) · 1.54 KB
/
rainbow.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
;;;;;;;;;;;;;;;;; Initialization ;;;;;;;;;;;;;;;;;;;
PROCESSOR 6502 ; MOS 6502/6507
INCLUDE "vcs.h"
INCLUDE "macro.h"
SEG CODE
ORG $F000
Start:
CLEAN_START ; macro to clean regs & memory
LDA #2 ; A = 2 => Start bit
LDY #0 ; Y = 0 => Stop bit
;;;;;;;;;;;; Start new frame, turn oon VBLANK and VSYNC ;;;;;;;;;;;;;;
NextFrame:
STA VBLANK ; start VBLANK
;;;;;;;;;; Generate WSYNC lines (3 scanlines) ;;;;;;;;;;;;;
STA VSYNC
STA WSYNC ; 1st line
STA WSYNC ; 2nd line
STA WSYNC ; 3rd line
STY VSYNC ; stop VSYNC
;;;;;;;;;; Generate VBLANK lines (37 scanlines) ;;;;;;;;;;
LDX #37 ; X = 37
LoopVBlank:
STA WSYNC ; hit wsync & wait for TIA to return
DEX
BNE LoopVBlank ; while X != 0
STY VBLANK ; stop VBLANK
;;;;;;;;;;; Draw visible scanlines (192) ;;;;;;;;;;;;;
LDX #192
LoopVisible:
STX COLUBK ; set bg color
STA WSYNC ; wait for next line
DEX
BNE LoopVisible
;;;;;;;;; Generate VBLANK lines (overscan, 30 lines) ;;;;;;;;;;
STA VBLANK ; restart vblank
LDX #30 ; X = 30
LoopOverscan:
STA WSYNC ; draw line
DEX ; X--
BNE LoopOverscan ; While X != 0
JMP NextFrame ; Goto next frame
;;;; Define end of cartridge ;;;;;;;
End:
ORG $FFFC ; goto cartridge end - 4 bytes
; Setup interrupt vectors
.word Start ; add 2 bytes and Start address (FFFC-FFFD)
.word Start ; another 2 bytes and Start address (FFFE-FFFF)