Rizin
unix-like reverse engineering framework and cli tools
nes_specs.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2015 maijin <maijin21@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 // CPU_memory_map: http://wiki.nesdev.com/w/index.php/CPU_memory_map
5 
6 #ifndef _NES_H
7 #define _NES_H
8 
9 #define INES_MAGIC "\x4E\x45\x53\x1A"
10 
11 #define PRG_PAGE_SIZE 0x4000
12 #define CHR_PAGE_SIZE 0x2000
13 #define INES_HDR_SIZE sizeof(ines_hdr)
14 
15 #define RAM_START_ADDRESS 0x0000
16 #define RAM_SIZE 0x0800
17 
18 #define RAM_MIRROR_1_ADDRESS 0x0800
19 #define RAM_MIRROR_1_SIZE 0x0800
20 
21 #define RAM_MIRROR_2_ADDRESS 0x1000
22 #define RAM_MIRROR_2_SIZE 0x0800
23 
24 #define RAM_MIRROR_3_ADDRESS 0x1800
25 #define RAM_MIRROR_3_SIZE 0x0800
26 
27 #define PPU_REG_ADDRESS 0x2000
28 #define PPU_REG_SIZE 0x0008
29 
30 #define APU_AND_IOREGS_START_ADDRESS 0x4000
31 #define APU_AND_IOREGS_SIZE 0x0020
32 
33 #define SRAM_START_ADDRESS 0x6000
34 #define SRAM_SIZE 0x2000
35 
36 #define ROM_START_ADDRESS 0x8000
37 #define ROM_SIZE 0x8000
38 
39 #define ROM_MIRROR_ADDRESS 0xC000
40 #define ROM_MIRROR_SIZE 0x8000
41 
42 #define NMI_VECTOR_START_ADDRESS 0xFFFA
43 #define RESET_VECTOR_START_ADDRESS 0xFFFC
44 #define IRQ_VECTOR_START_ADDRESS 0xFFFE
45 
46 #define PPU_CTRL_REG1 0x2000
47 #define PPU_CTRL_REG2 0x2001
48 #define PPU_STATUS 0x2002
49 #define PPU_SPR_ADDR 0x2003
50 #define PPU_SPR_DATA 0x2004
51 #define PPU_SCROLL_REG 0x2005
52 #define PPU_ADDRESS 0x2006
53 #define PPU_DATA 0x2007
54 
55 #define SND_REGISTER 0x4000
56 #define SND_SQUARE1_REG 0x4000
57 #define SND_SQUARE2_REG 0x4004
58 #define SND_TRIANGLE_REG 0x4008
59 #define SND_NOISE_REG 0x400c
60 #define SND_DELTA_REG 0x4010
61 #define SND_MASTERCTRL_REG 0x4015
62 
63 #define SPR_DMA 0x4014
64 #define JOYPAD_PORT 0x4016
65 #define JOYPAD_PORT1 0x4016
66 #define JOYPAD_PORT2 0x4017
67 
69  typedef struct {
70  char id[0x4]; // NES\x1A
71  ut8 prg_page_count_16k; // number of PRG-ROM pages
72  ut8 chr_page_count_8k; // number of CHR-ROM pages
73  ut8 rom_control_byte_0; // flags describing ROM image
74  ut8 rom_control_byte_1; // flags describing ROM image
75  ut8 ram_bank_count_8k; // size of PRG RAM
76  ut8 reserved[7]; // zero filled
77  })
78 ines_hdr;
79 
80 #endif // _NES_H
uint8_t ut8
Definition: lh5801.h:11
@ reserved
Definition: lm32_isa.h:94
RZ_PACKED(typedef struct { char id[0x4];ut8 prg_page_count_16k;ut8 chr_page_count_8k;ut8 rom_control_byte_0;ut8 rom_control_byte_1;ut8 ram_bank_count_8k;ut8 reserved[7];}) ines_hdr