; NES.h
; 2003 Cye Freeman

;-----------------------------------------------------------------------------

; R E G I S T E R S

; P P U
; Picture Processing Unit

PPUCtrl0 = $2000 ; PPU Control Register #0
PPUCtrl1 = $2001 ; PPU Control Register #1
PPUStat = $2002 ; PPU Status Register
OAMAddr = $2003 ; SPR-RAM Address Register
OAMIO = $2004 ; SPR-RAM I/O Register
PPUScroll = $2005 ; VRAM Address Register #0
PPUAddr = $2006 ; VRAM Address Register #1
PPUIO = $2007 ; VRAM I/O Register

;-----------------------------------------------------------------------------

; p A P U
; pseuedo-Audio Processing Unit

;P U L S E 0
Pulse0Ctrl = $4000 ; Control Register
Pulse0Sweep = $4001 ; Ramp Control Register
Pulse0FreqLo = $4002 ; Fine Tune Register
Pulse0FreqHi = $4003 ; Coarse Tune Register
; P U L S E 1
Pulse1Ctrl = $4004 ; Control Register
Pulse1Sweep = $4005 ; Ramp Control Register
Pulse1FreqLo = $4006 ; Fine Tune Register
Pulse1FreqHi = $4007 ; Coarse Tune Register
; T R I A N G L E
TriangleTimer = $4008 ; Triangle Control Register #0
TriangleCtrl = $4009 ; Triangle Control Register #1
TriangleFreqLo = $400A ; Triangle Frequency Register #0
TriangleFreqHi = $400B ; Triangle Frequency Register #1
; N O I S E
NoiseCtrl = $400C ; Noise Control Register #0
;UNUSED = $400D
NoiseFreq = $400E ; Noise Frequency Register #0
NoiseTimer = $400F ; Noise Frequency Register #1

; D E L T A M O D U L A T I O N
; The channel of the APU which handles digital data.
; Commonly referred to as the PCM (Pulse Code Modulation) channel.

DeltaCtrl = $4010 ; Delta Modulation Control Register (W)
DC_Offset = $4011 ; Delta Modulation D/A Register (W)
DeltaAddr = $4012 ; Delta Modulation Address Register (W)
DeltaLength = $4013 ; Delta Modulation Data Length Register (W)
SPRDMA = $4014 ; Sprite DMA Register
SoundCtrl = $4015 ; Channel Control (w) Sound/Vertical Clock Signal Register (R)


; J O Y P A D S
PAD0 = $4016
PAD1 = $4017
;-----------------------------------------------------------------------------



; V R A M A D D R E S S E S

PTable0 = $0000 ; Pattern Table 0 (256x2x8, may be VROM)
PTable1 = $1000 ; Pattern Table 1 (256x2x8, may be VROM)
NameTable0 = $2000 ; Name Table 0 (32x25 tiles)
AttribTable0 = $23C0 ; Attribute Table 0
NameTable1 = $2400 ; Name Table 1 (32x25 tiles)
AttribTable1 = $27C0 ; Attribute Table 1
NameTable2 = $2800 ; Name Table 2 (32x25 tiles)
AttribTable2 = $2BC0 ; Attribute Table 2
NameTable3 = $2C00 ; Name Table 3 (32x25 tiles)
AttribTable4 = $2FC0 ; Attribute Table 3
IPalette = $3F00 ; Image Palette
SPalette = $3F10 ; Sprite Palette
Mirror2 = $4000 ; Mirror of $0000-3FFF
;-----------------------------------------------------------------------------


;Macros
; useage : SetPPUAddr $3F12
; note if the high & low byte are the same you can save one byte by ommiting the 2nd ldx

MAC SetPPUAddr
ldx #>{1} ;High byte of address
stx PPUAddr
ldx #<{1} ;Low byte of address
stx PPUAddr
ENDM


MAC SetPPUCtrl
ldx #>{1} ;High byte of address
stx PPUCtrl0
ldx #<{1} ;Low byte of address
stx PPUCtrl1
ENDM
;-----------------------------------------------------------------------------