/HiFive1-2600

An embedded Atari 2600 game console emulator for SiFive's RISC-V FE310 chip, as used on the HiFive1 dev board.

Primary LanguageC

HiFive1-2600

This project is an embedded cycle-accurate simulation of a MOS 6502 (technically, 6507) processor. Also included is an abstraction of the Atari's RIOT (RAM I/O-Timer) chip and Jay Miner's Television Interface Adapter (TIA) IC. The end goal is to create an emulator capable of executing Atari 2600 games on a modern micro-controller level device.

Hold onto your butts ...

Preview

HiFive1-2600

HiFive1-2600

HiFive1-2600

Why?

Just for fun.

No, really. Why?

Because I'm personally interested in learning about how the Atari 2600 worked, understanding the 6502 processor and wanted to build a project which would make extensive use of a RISC-V micro-controller. Writing an emulator is a great way to practice programming and doing so in a resource constrained environment presents interesting problems.

Hardware

This project targets the SiFive HiFive1 development board paired with a 2.8" TFT touchscreen from Adafruit.

Usage

Checkout the freedom-e-sdk and clone this repository directly into the software directory. Proceed to compile and upload as with any other freedom-e-sdk program:

 $ make software PROGRAM=HiFive1-2600 BOARD=freedom-e300-hifive1
 $ make upload PROGRAM=HiFive1-2600 BOARD=freedom-e300-hifive1

Compilation flags

Optionally, uncommment in the Makefile:

  • -DEXEC_TESTS run the unit test suites which will load test programs into the emulator and verify the correct functioning of the simulation.

  • -DMANUAL_STEP disables automatic clocking and executes a clock cycle with each press of the spacebar. Useful for step-by-step debugging.

  • -DCOLOUR_TEST Executes a simple test where the TIA colour map is displayed on screen.

ROM usage

At the moment ROMs are handled as inline uint8_t arrays. These can be generated from binary ROM images using xxd, e.g.,:

 $ xxd -i some_file.bin

will generate a .c file with an array containing each byte value and a variable denoting the array length, e.g.,:

char some_file_bin[] = {
  0xa9, 0x00, 0x85, 0x01, 0xa9, 0x02, 0x85, 0x00, 0x85, 0x02, 0x85, 0x02,
  0x85, 0x02, 0xa9, 0x00, 0x85, 0x00, 0x85, 0x02, 0x85, 0x02, 0x85, 0x02,
  0x85, 0x02, 0x85, 0x02, 0x85, 0x02, 0x85, 0x02, 0x85, 0x02, 0x85, 0x02,
  etc ...

[...]
};
int some_file_bin_len = 4096;