/nes-bf

Brainfuck interpreter (NES)

Primary LanguageAssemblyGNU General Public License v3.0GPL-3.0

Qalle's Brainfuck

A Brainfuck interpreter for the NES.

Table of contents:

List of files

  • *.bf: long Brainfuck programs
  • assemble.sh: a Linux script that assembles the program (warning: deletes files)
  • bf.asm: source code (assembles with ASM6)
  • bf.nes.gz: the assembled program (iNES format, gzip compressed)
  • chr.bin.gz: CHR ROM data (gzip compressed)
  • chr.png: CHR ROM data as an image (can be encoded with nes_chr_encode.py in my NES utilities)
  • examples.txt: short Brainfuck programs
  • movies.tar.gz: FCEUX movie files that enter a Brainfuck program into the NES program
  • snap*.png: screenshots
  • txt2fm2.py: a Python script that converts a Brainfuck program into an FCEUX movie file that enters the Brainfuck program into the NES program

Features

  • maximum program size: 239 (8×30−1) instructions
  • maximum output size: 240 (8×30) bytes
  • Brainfuck RAM size: 1,024 bytes
  • output speed: 1 character/frame

Technical info

  • mapper: NROM
  • PRG ROM: 16 KiB
  • CHR ROM: 8 KiB
  • name table mirroring: vertical
  • compatibility: NTSC & PAL

How to use

There are two modes.

Edit mode

edit mode

  • the program starts in this mode
  • the cursor (blinking square) is always on the program input area
  • note: the Brainfuck program won't run if brackets don't match

Run mode

run mode

  • there are three submodes:
    • if the cursor is on the output area: the Brainfuck program is running
    • if the cursor is on the virtual keyboard: the user is expected to enter a character
    • if the cursor is next to the B=exit text: the Brainfuck program has finished or the maximum output size has been reached
  • press B at any time to return to edit mode

Character set

  • output behavior:
    • byte 0x0a moves the cursor to the start of the next line
    • other bytes advance the cursor by one
  • output appearance:
    • bytes 0x20 to 0x7e: as in ASCII
    • some bytes from 0x7f on contain special characters
    • other bytes are blank
  • input (virtual keyboard):
    • newline symbol (↵ at bottom right) inserts byte 0x0a
    • other symbols insert bytes 0x20 to 0x7e

References