Welcome to mirror list, hosted at ThFree Co, Russian Federation.

main.asm « nrom_group_scroll « Samples - github.com/ClusterM/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 392f008a8d1b2315995104045073a22c9d411084 (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
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
; INES header stuff
  .inesprg 1   ; 1 bank of PRG
  .ineschr 1   ; 1 bank of CHR data
  .inesmir 1   ; mirroring
  .inesmap 0   ; we use mapper 0

DELAY .equ 2

  .rsset $0000 ; variables
COPY_SOURCE_ADDR    .rs 2
COPY_DEST_ADDR      .rs 2
SCROLL_X            .rs 1
PAUSE               .rs 1
DIR                 .rs 1
  
  .bank 1
  .org $FFFA   ; reset vectors
  .dw NMI
  .dw Start
  .dw IRQ

  .bank 0
  .org $C000 ; code starts here
Start:
  ; disable interrupts
  sei
  ; reset stack
  ldx #$ff
  txs

  ; disable PPU
  lda #%00000000
  sta PPUCTRL
  lda #%00000000
  sta PPUMASK

  jsr waitblank

  ; reset sound
  lda #0
  sta $4000
  sta $4001
  sta $4002
  sta $4003
  sta $4004
  sta $4005
  sta $4006
  sta $4007
  sta $4009
  sta $400A
  sta $400C
  sta $400D
  sta $400E
  sta $400F
  sta $4010
  sta $4011
  sta $4012
  sta $4013
  lda #$0F
  sta $4015
  lda #$40
  sta $4017
  lda #0

load_palette:
  lda #LOW(palette)
  sta <COPY_SOURCE_ADDR
  lda #HIGH(palette)
  sta <COPY_SOURCE_ADDR+1
  lda #$3F
  sta PPUADDR
  lda #$00
  sta PPUADDR
  ldy #$00
  ldx #16
.loop:
  lda [COPY_SOURCE_ADDR], y
  sta PPUDATA
  iny
  dex
  bne .loop

load_nametable:
  lda #LOW(nametable_0)
  sta <COPY_SOURCE_ADDR
  lda #HIGH(nametable_0)
  sta <COPY_SOURCE_ADDR+1
  lda #$20
  sta PPUADDR
  lda #$00
  sta PPUADDR
  ldy #$00
  ldx #$00
.loop:
  lda [COPY_SOURCE_ADDR], y
  sta PPUDATA
  iny
  bne .loop
  inc COPY_SOURCE_ADDR+1
  inx
  cpx #8
  bne .loop

  ; enable PPU
  jsr waitblank
  lda #%00001010
  sta PPUMASK
  lda #%00000000
  sta PPUCTRL

  ; reset variables
  lda #0
  sta SCROLL_X
  sta DIR

main_loop:
  jsr waitblank
  jmp main_loop

  ; VBlank wait subroutine
waitblank:
  bit PPUSTATUS

  ldx SCROLL_X
  stx PPUSCROLL

  inc PAUSE
  lda PAUSE
  cmp #DELAY
  bne .scroll
  lda #0
  sta PAUSE

  lda DIR
  bne .left
  inx
  bne .scroll
  lda #1
  sta DIR
  dex
  jmp .scroll
.no_turn_left:
  jmp .scroll
.left:
  dex
  bne .scroll
  lda #0
  sta DIR
  
.scroll:
  stx SCROLL_X
  lda #0
  sta PPUSCROLL
.loop:
  lda PPUSTATUS ; load A with value at location PPUSTATUS
  bpl .loop ; if bit 7 is not set (not VBlank) keep checking
  rts

NMI:
  rti

IRQ:
  rti

nametable_0:
  .incbin "name_table_0.bin"
attr_table_0:
  .incbin "attr_table_0.bin"
nametable_1:
  .incbin "name_table_1.bin"
attr_table_1:
  .incbin "attr_table_1.bin"

palette:
  .incbin "palette_0.bin"
  .incbin "palette_1.bin"
  .incbin "palette_2.bin"
  .incbin "palette_3.bin"

  .bank 2
  .org $0000
  .incbin "pattern_0.bin"