-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfe1.asm
291 lines (243 loc) · 6.07 KB
/
fe1.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
.include "include/layout.asm"
.include "include/constants/misc.asm"
.macro BASE_BANK args BANKID
.if BANKID < 31
.bank BANKID slot "ROM-LO"
.endif
.if BANKID == 31
.bank BANKID slot "ROM-HI"
.endif
.if BANKID >= 32
.bank BANKID slot "CHR"
.endif
.org 0
.if BANKID < 32
.incbin "fe1-expand.nes" skip 16 + BANKID*$4000 read $4000
.else
.incbin "fe1-expand.nes" skip 16 + (32*$4000) + ((BANKID-32)*$1000) read $1000
.endif
.endm
; WRAM
.include "include/wram.asm"
.include "include/sram.asm"
; Base ROM data
; PRG banks
BASE_BANK 0
BASE_BANK 1
BASE_BANK 2
BASE_BANK 3
BASE_BANK 4
BASE_BANK 5
BASE_BANK 6
BASE_BANK 7
BASE_BANK 8
BASE_BANK 9
BASE_BANK 10
BASE_BANK 11
BASE_BANK 12
BASE_BANK 13
BASE_BANK 14
//BASE_BANK 15;expanded area
//BASE_BANK 16;expanded area
//BASE_BANK 17;expanded area
//BASE_BANK 18;expanded area
//BASE_BANK 19;expanded area
//BASE_BANK 20;expanded area
//BASE_BANK 21;expanded area
//BASE_BANK 22;expanded area
//BASE_BANK 23;expanded area
//BASE_BANK 24;expanded area
//BASE_BANK 25;expanded area
//BASE_BANK 26;expanded area
//BASE_BANK 27;expanded area
//BASE_BANK 28;expanded area
//BASE_BANK 29;expanded area
//BASE_BANK 30;expanded area
BASE_BANK 31
; CHR banks
BASE_BANK 32
BASE_BANK 33
BASE_BANK 34
BASE_BANK 35
BASE_BANK 36
BASE_BANK 37
BASE_BANK 38
BASE_BANK 39
BASE_BANK 40
BASE_BANK 41
BASE_BANK 42
BASE_BANK 43
BASE_BANK 44
BASE_BANK 45
BASE_BANK 46
BASE_BANK 47
BASE_BANK 48
BASE_BANK 49
BASE_BANK 50
BASE_BANK 51
BASE_BANK 52
BASE_BANK 53
BASE_BANK 54
BASE_BANK 55
BASE_BANK 56
BASE_BANK 57
BASE_BANK 58
BASE_BANK 59
BASE_BANK 60
BASE_BANK 61
BASE_BANK 62
BASE_BANK 63
.include "banksel_hijack.asm"
.bank 6 slot "ROM-LO"
.orga $B366
; STA $7FEE,X //cause bug(why this is exist?)
NOP
NOP
NOP
.bank 15 slot "ROM-LO"
.orga $8000
FONT_2BPP:
.incbin "font.bin"
FONT_2BPP_END:
.bank 31 slot "ROM-HI"
.orga $F500
MAPPER165BANK:
PHA
ASL A
PHA
LDA #BANKSEL.PRGLO
STA MMC3BANKSEL
PLA
STA MMC3BANKDATA
PHA
LDA #BANKSEL.PRGHI
STA MMC3BANKSEL
PLA
CLC
ADC #$01
STA MMC3BANKDATA
PLA
RTS
RESET:
LDA #$00
STA MMC3IRQLATCH
STA MMC3IRQDISABLE
LDA #$FF
STA MMC3MIRROR
LDA #$80
STA MMC3PRGRAMPROTECT
JSR INIT_CHR_RAM
LDA #13
JSR MAPPER165BANK
JMP $C075
INIT_CHR_RAM:
LDA #15
JSR MAPPER165BANK
LDA #0
JSR MAPPER165CHRHI1
JSR MAPPER165CHRHI2
//backup $0000
LDA $00
PHA
LDA $01
PHA
//initialize X and Y
LDX #$00
LDY #$00
//Write where font is located on $0000
LDA #<FONT_2BPP
STA $00
LDA #>FONT_2BPP
STA $01
//Do something on $1FD0... I don't know
LDA #$1F
STA PPUADDR
LDA #$D0
STA PPUADDR
LDA PPUDATA
LDA PPUDATA
//Size of copy byte
LDX #>(FONT_2BPP_END-FONT_2BPP)
LDY #<(FONT_2BPP_END-FONT_2BPP)
//SELECT PPU $1000
LDA #$10
STA PPUADDR
LDA #$00
STA PPUADDR
//Load font
LOOP_803A:
LDA ($00), Y
STA PPUDATA
INY
BNE LOOP_803A
INC $01
DEX
BNE LOOP_803A
//Do something on $1FE0... I don't know
LDA #$1F
STA PPUADDR
LDA #$E0
STA PPUADDR
LDA PPUDATA
LDA PPUDATA
//restore backup
PLA
STA $01
PLA
STA $00
RTS
MAPPER165CHRLO1:
PHA
TXA
PHA
TYA
PHA
TSX
LDA #BANKSEL.CHRLO1
JMP MAPPER165CHR_COMMON1
MAPPER165CHRLO2:
PHA
TXA
PHA
TYA
PHA
TSX
LDA #BANKSEL.CHRLO2
JMP MAPPER165CHR_COMMON1
MAPPER165CHRHI1:
PHA
TXA
PHA
TYA
PHA
TSX
LDA #BANKSEL.CHRHI1
JMP MAPPER165CHR_COMMON1
MAPPER165CHRHI2:
PHA
TXA
PHA
TYA
PHA
TSX
LDA #BANKSEL.CHRHI2
JMP MAPPER165CHR_COMMON1
MAPPER165CHR_COMMON1:
PHA
LDA $0103,X
NOP
ASL A
ASL A
TAY
PLA
TAX
STX MMC3BANKSEL
STY MMC3BANKDATA
PLA
TAY
PLA
TAX
PLA
RTS
.orga $FFFC
.dw RESET