ddribin (owner)

Revisions

gist: 213995 Download_button fork
public
Public Clone URL: git://gist.github.com/213995.git
Embed All Files: show embed
background.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
.segment "HEADER"
 
.byte "NES", $1A ; iNES header identifier
.byte 2 ; 2x 16KB PRG code
.byte 1 ; 1x 8KB CHR data
.byte 0, 0 ; mapper 0, vertical mirroring
 
;;;;;;;;;;;;;;;
 
;;; "nes" linker config requires a STARTUP section, even if it's empty
.segment "STARTUP"
 
.segment "CODE"
 
reset:
sei ; disable IRQs
cld ; disable decimal mode
ldx #$40
stx $4017 ; dsiable APU frame IRQ
ldx #$ff ; Set up stack
txs ; +
inx ; now X = 0
stx $2000 ; disable NMI
stx $2001 ; disable rendering
stx $4010 ; disable DMC IRQs
 
@vblankwait1: ; First wait for vlbank to make sure PPU is ready
bit $2002
bpl @vblankwait1
 
@clrmem:
lda #$00
sta $0000, x
sta $0100, x
sta $0200, x
sta $0400, x
sta $0500, x
sta $0600, x
sta $0700, x
lda #$fe
sta $0300, x
inx
bne @clrmem
 
@vblankwait2: ; Second wait for vblank, PPU is ready after this
bit $2002
bpl @vblankwait2
 
 
.if 0 ; Enable this to work on Nestopia
lda #$3f ; Set PPU address to BG palette RAM ($3F00)
sta $2006
lda #$00
sta $2006
 
lda #$00
sta $2007
sta $2007
 
@vblankwait3:
bit $2002
bpl @vblankwait3
.endif
 
lda #%10000000 ; intensify blues
sta $2001
 
@forever:
jmp @forever
 
nmi:
rti
 
;;;;;;;;;;;;;;
  
.segment "VECTORS"
 
.word 0, 0, 0 ; Unused
;; When an NMI happens (once per frame if enabled) the label nmi:
.word nmi
;; When the processor first turns on or is reset, it will jump to the
;; label reset:
.word reset
;; External interrupt IRQ is not used in this tutorial
.word 0
  
;;;;;;;;;;;;;;
  
.segment "CHARS"
 
.incbin "mario.chr" ; includes 8KB graphics from SMB1