1; Builds program as iNES ROM
2
3; Default is 32K 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.ifndef LARGER_ROM_HACK
65.segment "CODE"
66	.res $4000
67.endif
68
69.include "shell.s"
70
71std_reset:
72	lda #0
73	sta PPUCTRL
74	sta PPUMASK
75	jmp run_shell
76
77init_runtime:
78	.ifdef CHR_RAM
79		load_chr_ram
80	.endif
81	rts
82
83post_exit:
84	jsr set_final_result
85	jsr play_hex
86	jmp forever
87
88; Standard NES bootloader to help with devcart.
89; It is never executed by test ROM.
90.segment "LOADER"
91	.incbin "bootloader.bin"
92
93.code
94.align 256
95