The nes_hardware
module is imported automatically on NES targets.
It contains defintions for the NES's memory-mapped registers, as well
as some joypad and PPU management routines.
Named memory locations for interfacing with the PPU's memory-mapped registers.
Available variables:
byte ppu_ctrl @$2000
byte ppu_mask @$2001
byte ppu_status @$2002
byte oam_addr @$2003
byte oam_data @$2004
byte ppu_scroll @$2005
byte ppu_addr @$2006
byte ppu_data @$2007
byte oam_dma @$4014
Strobes joypads in preparation for reading new joypad states.
Get joypad1's state as a byte.
Get joypad2's state as a byte.
Simulates a hardware reset by jumping to the reset vector, which then calls main().
Sets the PPU to point at the VRAM address at ax, usually in preparation for a write via ppu_write_data().
Gets the PPU status byte.
Sets the PPU scroll register. Parameter a defines the horizontal (X-axis) scroll value, and parameter x defines the vertical (Y-axis) scroll value.
Writes a byte to the PPU's VRAM at the address the PPU is currently pointing to. Usually used after a call to ppu_set_addr().
Initiates a DMA transfer of 256 bytes from CPU memory address $xx00-$xxFF to PPU OAM memory, where xx is the hexadecimal representation of parameter a.
The nes_mmc4
module is imported automatically on the NES MMC4 target
and contains routines related to MMC4 bankswitching.
Changes the $8000-$BFFF PRG bank.
Changes the CHR bank 0 ($0000-$0fff in the PPU memory space).
The high nibble (0 or 1) selects between chrrom0
and chrrom1
segments.
The low nibble L (0-$F) selects a 4K-aligned address in the segment ($L000).
Changes the CHR bank 1 ($1000-$1fff in the PPU memory space).
The high nibble (0 or 1) selects between chrrom0
and chrrom1
segments.
The low nibble L (0-$F) selects a 4K-aligned address in the segment ($L000).
Switches nametable mirroring to vertical.
Switches nametable mirroring to horizontal.
Provides an interface for reading joypads that is compatible with the joy
module.
1 if A button pressed, 0 if not pressed.
1 if B button pressed, 0 if not pressed.
1 if Select button pressed, 0 if not pressed.
1 if Start button pressed, 0 if not pressed.
Reads the joypad from the port 1.
Reads the joypad from the port 2.
Reads the joypad from the port 1 and adds its readouts to the current readouts.
Reads the joypad from the port 2 and adds its readouts to the current readouts.
Resets the state variables.
Defines the joystick in port 1 as the default joystick.