1; Builds program as iNES ROM
2
3; Default is 16K PRG and 8K CHR ROM, NROM (0)
4
5.if 0 ; Options to set before .include "shell.inc":
6CHR_RAM=1       ; Use CHR-RAM instead of CHR-ROM
7CART_WRAM=1     ; Use mapper that supports 8K WRAM in cart
8CUSTOM_MAPPER=n ; Specify mapper number
9.endif
10
11.ifndef CUSTOM_MAPPER
12	.ifdef CART_WRAM
13		CUSTOM_MAPPER = 2 ; UNROM
14	.else
15		CUSTOM_MAPPER = 0 ; NROM
16	.endif
17.endif
18
19;;;; iNES header
20.ifndef CUSTOM_HEADER
21	.segment "HEADER"
22		.byte $4E,$45,$53,26 ; "NES" EOF
23
24		.ifdef CHR_RAM
25			.byte 2,0 ; 32K PRG, CHR RAM
26		.else
27			.byte 2,1 ; 32K PRG, 8K CHR
28		.endif
29
30		.byte CUSTOM_MAPPER*$10+$01 ; vertical mirroring
31.endif
32
33.ifndef CUSTOM_VECTORS
34	.segment "VECTORS"
35		.word -1,-1,-1, nmi, reset, irq
36.endif
37
38;;;; CHR-RAM/ROM
39.ifdef CHR_RAM
40	.define CHARS "CHARS_PRG"
41	.segment CHARS
42		ascii_chr:
43
44	.segment "CHARS_PRG_ASCII"
45		.align $200
46			.incbin "ascii.chr"
47		ascii_chr_end:
48.else
49	.define CHARS "CHARS"
50	.segment "CHARS_ASCII"
51		.align $200
52		.incbin "ascii.chr"
53		.res $1800
54.endif
55
56.segment CHARS
57	.res $10,0
58
59;;;; Shell
60.ifndef NEED_CONSOLE
61	NEED_CONSOLE=1
62.endif
63
64; Move code to $C000
65.segment "DMC"
66	.res $4000
67
68.include "shell.s"
69
70std_reset:
71	lda #0
72	sta PPUCTRL
73	sta PPUMASK
74	jmp run_shell
75
76init_runtime:
77	.ifdef CHR_RAM
78		load_ascii_chr
79	.endif
80	rts
81
82post_exit:
83	jsr set_final_result
84	jmp forever
85
86; This helps devcart recover after running test.
87; It is never executed by test ROM.
88.segment "LOADER"
89	.incbin "devcart.bin"
90
91.code
92.align 256
93