/gones

Gones - An NES emulator written in Go

Primary LanguageGo

GoNES - An attempt to program a NES emulator

The following resources were used for the project:

This project the following awesome libraries

  • Ebiten for 2D display, audio and input

Status

  • CPU Working "We've built a working 6502 emulator. Kinda cool"
  • Nes Illegal Opcodes "Look at the debug tool, it's amazing"
  • PPU Debug Working
  • DMA Working
  • PPU Background Rendering Clock Accurate
  • PPU Sprite Rendering Working Clock Accurate
  • Input Working
  • APU Working
  • Implemented iNES Mappers: Mapper000, Mapper002

Usage

Start the emulator with nes romfile.rom The rom file should be valid rom file including iNES header. You can build your own rom file with the description below.

Controls

  • Space - Start or Stop auto mode
  • Enter - Execute one CPU instruction
  • Arrow Up - Execute one CPU Clock
  • Arror Left - Execute one Master/PPU Clock
  • R Reset
  • F1 Hide/Display CPU Debug display
  • F2 Hide/Display Pattern Tables
  • F3 Hide/Display Nametable Information
  • F4 Hide/Display Palette Information
  • L Enable Logging
  • Keypad Enter requested instruction that should be executed when pressing enter. 0 = Disabled,
  • Esc Reset requested instructions

Building

For Windows

  1. No CGO required. Just run go buid github.com/exp625/gones

For Linux

TODO

Compiling C programs to 6502 using cc65

  1. Install the cc65 compiler
  2. Write your C program inside the test folder test.c
  3. Assemble you C program to 6502 assembler cc65 -Os -T -t nes test.c
  4. Create object files for
    1. Your assembled program ca65 -t nes test.s
    2. The startup code ca65 -t nes crt0.s
    3. The default nes characters ca65 -t nes chars.s
  5. Create your rom file ld65 -C memory.cfg test.o crt0.o chars.o nes.lib -o $FILE.nes

For a one liner (Set FILE accordingly): FILE="test" && cc65 -Os -T -t nes $FILE.c && ca65 -t nes $FILE.s && ca65 -t nes crt0.s && ca65 -t nes chars.s && ld65 -C memory.cfg $FILE.o crt0.o chars.o nes.lib -o $FILE.nes

Testing

CPU Testing

  1. Download the awesome nestest.rom
  2. Download the known good cpu log
  3. Start the emulator with the nestest.rom file nes nestest.rom
  4. Force the emulator to start execution on 0xC000 and set P flag to 0x24 using the Q Key ( See Note for why)
  5. Enable logging to file using L Key
  6. Run the emulator step by step or in auto mode
  7. Compare generated log file to the know good log file