; NES I/O locations and masks

; Clocks per second
.ifndef CLOCK_RATE
	CLOCK_RATE = 1789773 ; NTSC
;       CLOCK_RATE = 1662607 ; PAL
.endif

.ifndef BUILD_NSF

; PPU
PPUCTRL   = $2000
PPUMASK   = $2001
PPUSTATUS = $2002
SPRADDR   = $2003
SPRDATA   = $2004
PPUSCROLL = $2005
PPUADDR   = $2006
PPUDATA   = $2007
SPRDMA    = $4014

PPUCTRL_NMI     = $80
PPUMASK_BG0     = $0A
PPUCTRL_8X8     = $00
PPUCTRL_8X16    = $20
PPUMASK_SPR     = $14
PPUMASK_BG0CLIP = $08

.endif

; APU
SNDCHN  = $4015
JOY1    = $4016
JOY2    = $4017
SNDMODE = $4017

PULSE_CH1_DLCV = $4000
PULSE_CH1_SWEEP = $4001
PULSE_CH1_TLOW = $4002
PULSE_CH1_LCTH = $4003
PULSE_CH2_DLCV = $4004
PULSE_CH2_SWEEP = $4005
PULSE_CH2_TLOW = $4006
PULSE_CH2_LCTH = $4007
TRIANGLE_LINEAR_C = $4008
TRIANGLE_TIMER_LOW = $400A
TRIANGLE_LEN_T_HIGH = $400B

SNDMODE_NOIRQ   = $40

.if CLOCK_RATE = 1789773
	PPU_FRAMELEN = 29781
.elseif CLOCK_RATE = 1662607
	PPU_FRAMELEN = 33248
.endif
