Emulating the Nintendo Entertainment System
description
Transcript of Emulating the Nintendo Entertainment System
Emulating the Nintendo Entertainment System
By Danny Matthews
Supervised by Dr Des Watson
8 Bit console released in 1983
60 Million Units Sold Over 1000 Released Titles
Major Player in Revitalising the Market After the Crash of 1983
Background
NES
Emulation
“A very precise form of simulation which enables one type of computer to operate as if it were a
different type of computer.” - BCS
NES Software
NESEmulator
Executes on
Executed on
Executed on
Executed on
Executed on
NESFour Main Units
Central Processing Unit (CPU)Picture Processing Unit (PPU)Audio Processing Unit (APU)Input
Development ToolsDebuggerName Table ViewerPattern Table Viewer
Implemented using Java 1.5
Project Overview
Central Processing Unit (CPU)• 2A0X – A Modified 6502 Processor• Minus Binary Coded Decimal (BCD) mode • Plus 22 Memory Mapped Registers
CPU Implementation• Implemented as a large switch/case construct
• Memory divided into several objects to reflect the varied read/write behaviour.
Picture Processing Unit (PPU)
Spr i tes
Images
Pattern Tables
Sprites
Name Tables
Picture Processing Unit (PPU)PPU Implementation
• In contrast to the CPU, Memory stored as primitive integer arrays • Additional structure unnecessary as read/write
behaviour largely identical for all memory.
• Colour Palette handled within its own class.• Provides extremely accurate NES colours through
use of a mathematical algorithm.
• Provides alterable hue and tint to emulate TV colour adjustment
• Algorithm devised by Kevin Horton, implemented by David de Niese
Audio Processing Unit (APU)• Voltages – Two (0 or 1)
• Volume – 16 Levels
• Pitch Bending Capabilities
• Voltages – Sixteen (0-15)
• Volume – Fixed
• Capable of Longer Play Duration
• Voltages – Two (0 or 1)
• Volume – 16 Levels
• Pseudo Random Bit Sequence
• Allows the Playback of samples from memory
Pulse (x2)
Noise
Triangle
DMC
MixerAudio Processing Unit (APU)
Pulse 1Pulse 2
Triangle
Noise
DMC
Mixer Analogue Signal
Sound Implementation• Designed to mirror the NES APU structure.
• Down-sampling required to output sound at 44100 hz as NES outputs samples at ~1789772 hz.
• Volume Control
InputStandard Controller• Movement in Four Directions• Two “Action” buttons• Two “Control” Buttons Movement
“Control”“Action”
Input Implementation• Button states stored within an 8 bit register• Listeners used to detect button presses and releases• Program reads the button states from the pads periodically
• User definable button mapping
DebuggerDevelopment Tools
System State CPU Registers
PPU Registers
PPU State
Breakpoint System Interrupt Points Register Value Points
Step/Resume Functionality
DisassemblerMemory Viewer
CPU Memory
PPU Memory
Development ToolsDebugger Implementation
• System State and Memory Viewer implemented via the manipulation of data obtained using accessor methods in the CPU and PPU.
• Disassembler implemented via use of an opcode information lookup table.
• Index into the table via opcode number• Retrieve pertinent information for opcode.• Advance forward in file by length of opcode in
bytes.
• Breakpoints added to and removed from a handler. Handler checks all breakpoint conditions each instruction.
Name Table ViewerDevelopment Tools
Pattern Table Viewer
Name Tables
Scroll Lines
Attribute Table Information
Display Options
Pattern TablesTile and Palette
Information
Display Options
Palettes
The Software in Action
Graphical Auditory