PancakeNESEmu
A homebrewed NES Emulator written in C
Loading...
Searching...
No Matches
macros.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXIT_SUCCESS   0
 
#define EXIT_FAILURE   1
 
#define NES_SIGNATURE   0x4e45531a
 
#define TOTAL_MEM_SIZE   65536
 
#define ERR_ABN_OPCODE   0xff
 
#define BIT_7_MASK   0b10000000
 
#define BIT_6_MASK   0b01000000
 
#define BIT_5_MASK   0b00100000
 
#define BIT_4_MASK   0b00010000
 
#define BIT_3_MASK   0b00001000
 
#define BIT_2_MASK   0b00000100
 
#define BIT_1_MASK   0b00000010
 
#define BIT_0_MASK   0b00000001
 
#define NBIT_7_MASK   0b01111111
 
#define NBIT_6_MASK   0b10111111
 
#define NBIT_5_MASK   0b11011111
 
#define NBIT_4_MASK   0b11101111
 
#define NBIT_3_MASK   0b11110111
 
#define NBIT_2_MASK   0b11111011
 
#define NBIT_1_MASK   0b11111101
 
#define NBIT_0_MASK   0b11111110
 
#define GET_LOWER(x)
 
#define GET_HIGHER(x)
 
#define STACK_START   0x11FF
 
#define STACK_END   0x1100
 
#define RAM_START   0x0000
 
#define RAM_END   0x07FF
 
#define RAM_MIRROR_1_START   0x0800
 
#define RAM_MIRROR_1_END   0x0FFF
 
#define RAM_MIRROR_2_START   0x1000
 
#define RAM_MIRROR_2_END   0x17FF
 
#define RAM_MIRROR_3_START   0x1800
 
#define RAM_MIRROR_3_END   0x1FFF
 
#define IO_START   0x2000
 
#define PPU_REG_ZERO   0x2000
 
#define PPU_REG_ONE   0x2001
 
#define PPU_REG_TWO   0x2002
 
#define PPU_REG_THREE   0x2003
 
#define PPU_REG_FOUR   0x2004
 
#define PPU_REG_FIVE   0x2005
 
#define PPU_REG_SIX   0x2006
 
#define PPU_REG_SEVEN   0x2007
 
#define PPU_REG_START   PPU_REG_ZERO
 
#define PPU_REG_END   PPU_REG_SEVEN
 
#define PPU_MIRRORS_START_ZERO   0x2008
 
#define PPU_MIRRORS_START_ONE   0x2009
 
#define PPU_MIRRORS_START_TWO   0x200a
 
#define PPU_MIRRORS_START_THREE   0x200b
 
#define PPU_MIRRORS_START_FOUR   0x200c
 
#define PPU_MIRRORS_START_FIVE   0x200d
 
#define PPU_MIRRORS_START_SIX   0x200e
 
#define PPU_MIRRORS_START_SEVEN   0x200f
 
#define PPU_MIRRORS_END   0x3FFF
 
#define APU_REG_START   0x4000
 
#define APU_SQUARE_ONE_START   APU_REG_START
 
#define APU_SQUARE_ONE_CONF   APU_SQUARE_ONE_START
 
#define APU_SQUARE_ONE_FREQ_SWEEP   0x4001
 
#define APU_SQUARE_ONE_FREQ_LOW   0x4002
 
#define APU_SQUARE_ONE_FREQ_HIGH   0x4003
 
#define APU_SQUARE_TWO_START   0x4004
 
#define APU_SQUARE_TWO_CONF   APU_SQUARE_TWO_START
 
#define APU_SQUARE_TWO_FREQ_SWEEP   0x4005
 
#define APU_SQUARE_TWO_FREQ_LOW   0x4006
 
#define APU_SQUARE_TWO_FREQ_HIGH   0x4007
 
#define APU_TRIANGLE_START   0x4008
 
#define APU_TRIANGLE_CONF   APU_TRIANGLE_START
 
#define APU_TRIANGLE_UNUSED   0x4009
 
#define APU_TRIANGLE_FREQ_LOW   0x400a
 
#define APU_TRIANGLE_FREQ_HIGH   0x400b
 
#define APU_NOISE_START   0x400c
 
#define APU_NOISE_CONF   APU_NOISE_START
 
#define APU_NOISE_UNUSED   0x400d
 
#define APU_NOISE_FREQUENCY   0x400e
 
#define APU_NOISE_LENGTH   0x400f
 
#define APU_DMC_START   0x4010
 
#define APU_DMC_CONF   APU_DMC_START
 
#define APU_DMC_VOLUME   0x4011
 
#define APU_DMC_SAMPLE_ADDR   0x4012
 
#define APU_DMC_LENGTH   0x4013
 
#define APU_DMC_UNUSED   0x4014
 
#define APU_CONTROL_WRITE   0x4015
 
#define APU_CONTROL_READ   APU_CONTROL_WRITE
 
#define APU_UNSUSED   0x4016
 
#define APU_FRAME_COUNTER   0x4017
 
#define APU_REG_END   APU_FRAME_COUNTER
 
#define TEST_MODE_IO_REG_START   0x4018
 
#define TEST_MODE_IO_REG_END   0x401F
 
#define IO_END   0x401F
 
#define CARTRIDGE_START   0x4020
 
#define CARTRIDGE_RAM_START   0x6000
 
#define CARTRIDGE_RAM_END   0x7FFF
 
#define GAME_ROM_START   0x8000
 
#define APU_DCM_START   0xC000
 
#define APU_DCM_END   0xFFF1
 
#define GAME_ROM_END   0xFFFF
 
#define CARTRIDGE_END   0xFFFF
 
#define NMI_HIGH   0xFFFA
 
#define NMI_LOW   0xFFFB
 
#define RESET_HIGH   0xFFFC
 
#define RESET_LOW   0xFFFD
 
#define IRQ_BRK_HIGH   0xFFFE
 
#define IRQ_BRK_LOW   0xFFFF
 

Macro Definition Documentation

◆ APU_CONTROL_READ

#define APU_CONTROL_READ   APU_CONTROL_WRITE

Definition at line 172 of file macros.h.

◆ APU_CONTROL_WRITE

#define APU_CONTROL_WRITE   0x4015

Definition at line 168 of file macros.h.

◆ APU_DCM_END

#define APU_DCM_END   0xFFF1

Definition at line 197 of file macros.h.

◆ APU_DCM_START

#define APU_DCM_START   0xC000

Definition at line 196 of file macros.h.

◆ APU_DMC_CONF

#define APU_DMC_CONF   APU_DMC_START

Definition at line 151 of file macros.h.

◆ APU_DMC_LENGTH

#define APU_DMC_LENGTH   0x4013

Definition at line 162 of file macros.h.

◆ APU_DMC_SAMPLE_ADDR

#define APU_DMC_SAMPLE_ADDR   0x4012

Definition at line 159 of file macros.h.

◆ APU_DMC_START

#define APU_DMC_START   0x4010

Definition at line 148 of file macros.h.

◆ APU_DMC_UNUSED

#define APU_DMC_UNUSED   0x4014

Definition at line 164 of file macros.h.

◆ APU_DMC_VOLUME

#define APU_DMC_VOLUME   0x4011

Definition at line 154 of file macros.h.

◆ APU_FRAME_COUNTER

#define APU_FRAME_COUNTER   0x4017

Definition at line 181 of file macros.h.

◆ APU_NOISE_CONF

#define APU_NOISE_CONF   APU_NOISE_START

Definition at line 137 of file macros.h.

◆ APU_NOISE_FREQUENCY

#define APU_NOISE_FREQUENCY   0x400e

Definition at line 143 of file macros.h.

◆ APU_NOISE_LENGTH

#define APU_NOISE_LENGTH   0x400f

Definition at line 146 of file macros.h.

◆ APU_NOISE_START

#define APU_NOISE_START   0x400c

Definition at line 134 of file macros.h.

◆ APU_NOISE_UNUSED

#define APU_NOISE_UNUSED   0x400d

Definition at line 139 of file macros.h.

◆ APU_REG_END

#define APU_REG_END   APU_FRAME_COUNTER

Definition at line 182 of file macros.h.

◆ APU_REG_START

#define APU_REG_START   0x4000

Definition at line 86 of file macros.h.

◆ APU_SQUARE_ONE_CONF

#define APU_SQUARE_ONE_CONF   APU_SQUARE_ONE_START

Definition at line 96 of file macros.h.

◆ APU_SQUARE_ONE_FREQ_HIGH

#define APU_SQUARE_ONE_FREQ_HIGH   0x4003

Definition at line 108 of file macros.h.

◆ APU_SQUARE_ONE_FREQ_LOW

#define APU_SQUARE_ONE_FREQ_LOW   0x4002

Definition at line 103 of file macros.h.

◆ APU_SQUARE_ONE_FREQ_SWEEP

#define APU_SQUARE_ONE_FREQ_SWEEP   0x4001

Definition at line 100 of file macros.h.

◆ APU_SQUARE_ONE_START

#define APU_SQUARE_ONE_START   APU_REG_START

Definition at line 87 of file macros.h.

◆ APU_SQUARE_TWO_CONF

#define APU_SQUARE_TWO_CONF   APU_SQUARE_TWO_START

Definition at line 112 of file macros.h.

◆ APU_SQUARE_TWO_FREQ_HIGH

#define APU_SQUARE_TWO_FREQ_HIGH   0x4007

Definition at line 115 of file macros.h.

◆ APU_SQUARE_TWO_FREQ_LOW

#define APU_SQUARE_TWO_FREQ_LOW   0x4006

Definition at line 114 of file macros.h.

◆ APU_SQUARE_TWO_FREQ_SWEEP

#define APU_SQUARE_TWO_FREQ_SWEEP   0x4005

Definition at line 113 of file macros.h.

◆ APU_SQUARE_TWO_START

#define APU_SQUARE_TWO_START   0x4004

Definition at line 111 of file macros.h.

◆ APU_TRIANGLE_CONF

#define APU_TRIANGLE_CONF   APU_TRIANGLE_START

Definition at line 123 of file macros.h.

◆ APU_TRIANGLE_FREQ_HIGH

#define APU_TRIANGLE_FREQ_HIGH   0x400b

Definition at line 132 of file macros.h.

◆ APU_TRIANGLE_FREQ_LOW

#define APU_TRIANGLE_FREQ_LOW   0x400a

Definition at line 128 of file macros.h.

◆ APU_TRIANGLE_START

#define APU_TRIANGLE_START   0x4008

Definition at line 117 of file macros.h.

◆ APU_TRIANGLE_UNUSED

#define APU_TRIANGLE_UNUSED   0x4009

Definition at line 125 of file macros.h.

◆ APU_UNSUSED

#define APU_UNSUSED   0x4016

Definition at line 174 of file macros.h.

◆ BIT_0_MASK

#define BIT_0_MASK   0b00000001

Definition at line 27 of file macros.h.

Referenced by print_cpu_expected().

◆ BIT_1_MASK

#define BIT_1_MASK   0b00000010

Definition at line 26 of file macros.h.

Referenced by main(), and print_cpu_expected().

◆ BIT_2_MASK

#define BIT_2_MASK   0b00000100

Definition at line 25 of file macros.h.

Referenced by print_cpu_expected().

◆ BIT_3_MASK

#define BIT_3_MASK   0b00001000

Definition at line 24 of file macros.h.

Referenced by print_cpu_expected().

◆ BIT_4_MASK

#define BIT_4_MASK   0b00010000

Definition at line 23 of file macros.h.

Referenced by print_cpu_expected().

◆ BIT_5_MASK

#define BIT_5_MASK   0b00100000

Definition at line 22 of file macros.h.

Referenced by print_cpu_expected().

◆ BIT_6_MASK

#define BIT_6_MASK   0b01000000

Definition at line 21 of file macros.h.

Referenced by print_cpu_expected().

◆ BIT_7_MASK

#define BIT_7_MASK   0b10000000

Definition at line 20 of file macros.h.

Referenced by main(), and print_cpu_expected().

◆ CARTRIDGE_END

#define CARTRIDGE_END   0xFFFF

Definition at line 201 of file macros.h.

◆ CARTRIDGE_RAM_END

#define CARTRIDGE_RAM_END   0x7FFF

Definition at line 192 of file macros.h.

◆ CARTRIDGE_RAM_START

#define CARTRIDGE_RAM_START   0x6000

Definition at line 191 of file macros.h.

◆ CARTRIDGE_START

#define CARTRIDGE_START   0x4020

Definition at line 189 of file macros.h.

◆ ERR_ABN_OPCODE

#define ERR_ABN_OPCODE   0xff

Definition at line 17 of file macros.h.

Referenced by execute_instruction(), and step_cpu().

◆ EXIT_FAILURE

#define EXIT_FAILURE   1

Definition at line 6 of file macros.h.

Referenced by init_memory(), and open_rom().

◆ EXIT_SUCCESS

#define EXIT_SUCCESS   0

Definition at line 5 of file macros.h.

Referenced by main().

◆ GAME_ROM_END

#define GAME_ROM_END   0xFFFF

Definition at line 199 of file macros.h.

◆ GAME_ROM_START

#define GAME_ROM_START   0x8000

Definition at line 194 of file macros.h.

◆ GET_HIGHER

#define GET_HIGHER ( x)
Value:
((x >> 8) & 0x00FF)

Definition at line 41 of file macros.h.

◆ GET_LOWER

#define GET_LOWER ( x)
Value:
(x & 0x00FF)

Definition at line 40 of file macros.h.

◆ IO_END

#define IO_END   0x401F

Definition at line 187 of file macros.h.

◆ IO_START

#define IO_START   0x2000

Definition at line 60 of file macros.h.

◆ IRQ_BRK_HIGH

#define IRQ_BRK_HIGH   0xFFFE

Definition at line 211 of file macros.h.

◆ IRQ_BRK_LOW

#define IRQ_BRK_LOW   0xFFFF

Definition at line 212 of file macros.h.

◆ NBIT_0_MASK

#define NBIT_0_MASK   0b11111110

Definition at line 36 of file macros.h.

◆ NBIT_1_MASK

#define NBIT_1_MASK   0b11111101

Definition at line 35 of file macros.h.

◆ NBIT_2_MASK

#define NBIT_2_MASK   0b11111011

Definition at line 34 of file macros.h.

◆ NBIT_3_MASK

#define NBIT_3_MASK   0b11110111

Definition at line 33 of file macros.h.

◆ NBIT_4_MASK

#define NBIT_4_MASK   0b11101111

Definition at line 32 of file macros.h.

◆ NBIT_5_MASK

#define NBIT_5_MASK   0b11011111

Definition at line 31 of file macros.h.

◆ NBIT_6_MASK

#define NBIT_6_MASK   0b10111111

Definition at line 30 of file macros.h.

◆ NBIT_7_MASK

#define NBIT_7_MASK   0b01111111

Definition at line 29 of file macros.h.

◆ NES_SIGNATURE

#define NES_SIGNATURE   0x4e45531a

Definition at line 10 of file macros.h.

Referenced by open_rom().

◆ NMI_HIGH

#define NMI_HIGH   0xFFFA

Definition at line 205 of file macros.h.

◆ NMI_LOW

#define NMI_LOW   0xFFFB

Definition at line 206 of file macros.h.

◆ PPU_MIRRORS_END

#define PPU_MIRRORS_END   0x3FFF

Definition at line 84 of file macros.h.

◆ PPU_MIRRORS_START_FIVE

#define PPU_MIRRORS_START_FIVE   0x200d

Definition at line 80 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_MIRRORS_START_FOUR

#define PPU_MIRRORS_START_FOUR   0x200c

Definition at line 79 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_MIRRORS_START_ONE

#define PPU_MIRRORS_START_ONE   0x2009

Definition at line 76 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_MIRRORS_START_SEVEN

#define PPU_MIRRORS_START_SEVEN   0x200f

Definition at line 82 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_MIRRORS_START_SIX

#define PPU_MIRRORS_START_SIX   0x200e

Definition at line 81 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_MIRRORS_START_THREE

#define PPU_MIRRORS_START_THREE   0x200b

Definition at line 78 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_MIRRORS_START_TWO

#define PPU_MIRRORS_START_TWO   0x200a

Definition at line 77 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_MIRRORS_START_ZERO

#define PPU_MIRRORS_START_ZERO   0x2008

Definition at line 75 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_END

#define PPU_REG_END   PPU_REG_SEVEN

Definition at line 72 of file macros.h.

◆ PPU_REG_FIVE

#define PPU_REG_FIVE   0x2005

Definition at line 67 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_FOUR

#define PPU_REG_FOUR   0x2004

Definition at line 66 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_ONE

#define PPU_REG_ONE   0x2001

Definition at line 63 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_SEVEN

#define PPU_REG_SEVEN   0x2007

Definition at line 69 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_SIX

#define PPU_REG_SIX   0x2006

Definition at line 68 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_START

#define PPU_REG_START   PPU_REG_ZERO

Definition at line 71 of file macros.h.

◆ PPU_REG_THREE

#define PPU_REG_THREE   0x2003

Definition at line 65 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_TWO

#define PPU_REG_TWO   0x2002

Definition at line 64 of file macros.h.

Referenced by memory_mirroring().

◆ PPU_REG_ZERO

#define PPU_REG_ZERO   0x2000

Definition at line 62 of file macros.h.

Referenced by memory_mirroring().

◆ RAM_END

#define RAM_END   0x07FF

Definition at line 49 of file macros.h.

◆ RAM_MIRROR_1_END

#define RAM_MIRROR_1_END   0x0FFF

Definition at line 52 of file macros.h.

◆ RAM_MIRROR_1_START

#define RAM_MIRROR_1_START   0x0800

Definition at line 51 of file macros.h.

Referenced by memory_mirroring().

◆ RAM_MIRROR_2_END

#define RAM_MIRROR_2_END   0x17FF

Definition at line 55 of file macros.h.

◆ RAM_MIRROR_2_START

#define RAM_MIRROR_2_START   0x1000

Definition at line 54 of file macros.h.

Referenced by memory_mirroring().

◆ RAM_MIRROR_3_END

#define RAM_MIRROR_3_END   0x1FFF

Definition at line 58 of file macros.h.

◆ RAM_MIRROR_3_START

#define RAM_MIRROR_3_START   0x1800

Definition at line 57 of file macros.h.

Referenced by memory_mirroring().

◆ RAM_START

#define RAM_START   0x0000

Definition at line 48 of file macros.h.

◆ RESET_HIGH

#define RESET_HIGH   0xFFFC

Definition at line 208 of file macros.h.

◆ RESET_LOW

#define RESET_LOW   0xFFFD

Definition at line 209 of file macros.h.

◆ STACK_END

#define STACK_END   0x1100

Definition at line 46 of file macros.h.

Referenced by main(), and print_stack_state().

◆ STACK_START

#define STACK_START   0x11FF

Definition at line 45 of file macros.h.

Referenced by print_stack_state().

◆ TEST_MODE_IO_REG_END

#define TEST_MODE_IO_REG_END   0x401F

Definition at line 185 of file macros.h.

◆ TEST_MODE_IO_REG_START

#define TEST_MODE_IO_REG_START   0x4018

Definition at line 184 of file macros.h.

◆ TOTAL_MEM_SIZE

#define TOTAL_MEM_SIZE   65536

Definition at line 13 of file macros.h.

Referenced by free_memory(), init_memory(), and reset_memory().