aboutsummaryrefslogtreecommitdiff
path: root/src/example/nes.asm
blob: 476df60686237b7adb8520a051802639fc38fad3 (plain)
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
	processor 6502

	option  output-file,"nes.nes"
	option  output-format,nes

	option  nes-vector,reset,start
	option  nes-vector,nmi,nmi
	option  nes-vector,brk,nmi
	option	nes-mirror,horizontal

vsync:	macro
.wait
	lda	$2002
	bpl	wait
	endm

start:	org	$c000

	; Clear decimal and setup stack
	;
	cld
	ldx	#$ff
	txs

	; Wait for the PPU.  Recommended practice is clear the flag, and
	; wait for 2 VBL signals
	;
	bit	$2002
	vsync
	vsync

	; Setup PPU
	;
	lda	#%00001000     
	sta	$2000          
	lda	#%00011110 
	sta	$2001

	; Setup the palette
	;
loadpalette:
	lda	#$3f
	sta	$2006
	lda	#$00
	sta	$2006

	ldx	#0
.loop	lda	palette,x
	sta	$2007
	inx
	cpx	#$20
	bne	loop

	; Wait for a vysnc before loading the name table
	;
	vsync

	; Load the name map
	;
load_namemap:
	lda	#$20
	sta	$2006
	lda	#$40
	sta	$2006

	ldx	#0
.loop	lda	map,x
	cmp	#$ff
	beq	done
	sta	$2007
	inx
	jmp	loop
.done


forever:
	jmp	forever

nmi:
	rti

palette:
	incbin	"nes.pal"

map:
	db	'H'-'@'
	db	'E'-'@'
	db	'L'-'@'
	db	'L'-'@'
	db	'O'-'@'
	db	0
	db	'W'-'@'
	db	'O'-'@'
	db	'R'-'@'
	db	'L'-'@'
	db	'D'-'@'
	db	255


;
; VROM
;
	org 0
	bank 1

	incbin	"tiles.chr"