Skip to content
kb1p edited this page Mar 28, 2021 · 11 revisions

Welcome to the db1mu wiki!

Contents:

Introduction

The goal of this project is to create a NES emulator from scratch for deployment on the smart TV platforms. The emulator must be portable and third-party dependencies must be minimal. Currently the emulator requires Qt 5 to interact with the platform GUI system but further plan is to move to SDL2.

Design

We decided to design the emulator components in the way resembling its hardware counterpart (see the references section for further information about design of the hardware console).

The main components are:

For more details about the corresponding hardware components refer to NES reference guide.

Bus

This is a central component that coordinates operation of all the other components (this means that all memory read and write requests go through the bus, which decides how to fulfill them). All components keep track of the Bus and Bus keeps track of all the components thus forming a star-like dependency structure as shown on the diagram below:

The two functions of the Bus are as follows:

  • provide for interaction of system components with each other;
  • propagate system-wide events such as timer clock ticks.

CPU

Emulates MOS 6502 CPU operation. Uses jump table to emulate opcode operation. Every operation implementing routine is a template parametrized with operand fetching routine; operand fetching routines defined for every supported addressing mode. All combinations of operation / addressing mode routines are listed in a jump table. A NES opcode fetched from the ROM is an index to the jump table. This approach reduces the amount of boilerplate code and increases its stability.

PPU

Uses line-by-line rendering. Each line rendering is accompanied with CPU execution which provides for better emulation of the real hardware. PPU "renders" to a 256x240 pixels color buffer which is passed to a rendering backend for the actual drawing on the screen.

Rendering backend

A delegate responsible for rendering of color buffer containing NES color data onto the screen (or elsewhere). Currently there is an Open GL ES 2.0 rendering backend implementation which decodes the color buffer using default palette and copies it to a texture and paints it onto the default framebuffer.

APU

Not implemented yet. Will be using front/back end approach the same way PPU does.

Input module

Very simple component; currently supports gamepad with turbo buttons and light gun. The actual input signal dispatch is delegated to the user code which has to call the corresponding API functions. In current GUI implementation gamepad buttons are associated with the keyboard and light gun is not used.

Cartridge

Loads the ROM, instantiates proper mapper, dispatches CPU memory reads from the ROM memory area. Currently only the NROM mapper (1-2 of 16K PRG ROM banks + 8K VROM bank) is supported.

Validity checks

Refer to this page about how to check the validity of implemented components.

References

Clone this wiki locally