Skip to content

Brainfuck interpreter and debugger (almost an IDE) for Sharp *Brain* series electronic dictionaries.

License

Notifications You must be signed in to change notification settings

watamario15/brainfuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brainfuck for SHARP Brain

Brainfuck interpreter and debugger for SHARP Brain. This interpreter is "nice" in terms of this specification.

The Brainfuck program executed in this demo image is taken from ahnmika-white, which is licensed under the MIT License by @yude.

Specs

Default options are shown in bold typeface.

Item Spec
Memory type 8-bit two's-complement integer (-128 to 127), 8-bit integer (0 to 255)
Memory length 65,536 bytes
I/O charset UTF-8, Shift_JIS
Input error input 0, input FF, error
Integer overflow wrap around, error
Debugging Break on @ (disabled by default)

"error" options are useful for debugging and portability check.

Features

  • Behavior Adjustment
    • Run any Brainfuck programs. You can tune all behaviors listed above.
  • Real Time Debugging
    • Your program doesn't work as expected? It's tough to see how the program runs? This interpreter shows the next instruction to execute and memory internals. Also, it can highlight where the memory pointer is. You can also do a step execution or enable breakpoint instruction (@) to further inspect what's going on.
  • Speed Adjustment
    • You can select either 100 ms, 10 ms, 1 ms, or fastest speed to run a program. You can also disable the Real Time Debugging to further speedup the execution.
  • Screen Keyboard
    • Your device doesn't have a good keyboard for Brainfuck programming? This interpreter offers you buttons to type Brainfuck instructions with no hassle.
  • Light/Dark Theme
    • Tired to code in a bright screen? The dark theme isn't for you? This interpreter supports both the light and dark themes.
  • Per Monitor High DPI Aware V2
    • Your display is a high DPI one? You have muitiple display devices that have different DPIs each other? This interpreter smartly adjusts its size according to the DPI setting for the display device where the interpreter is on and perfectly works on these environment with no blur.
  • Switch Layout
    • Your device is wide? Or rather portrait? This interpreter offers you two layouts to support both screens.
  • Lightweight and Runs on Old Devices
    • For Windows CE, it's only about 50 KB and requires only about 1 MB of RAM. The Windows PC version is also tiny and runs perfectly even on Windows 2000.
  • Targets Broad CPU Architectures
    • For Windows CE, you can get Arm, MIPS, SH3, SH4, and x86 versions including variations. Even for Windows PC, you can get ARM32, ARM64, x86, and AMD64 versions.
  • ...and more!

System Requirements

  • Windows 2000 or later
    • Tested on Windows 2000 SP4, XP SP3, and 11.
    • Might also work on older OS versions, but who knows.
  • Windows CE .NET 4.0 or later
  • Wine
    • Tested the AMD64 version on Wine 7 and 8 on M2 MacBook Air (Rosetta 2).
    • I'm not aware of the exact version required, but newer is better.

How To Use

Download appropriate one from Releases and run it on your device. No installation needed. For SHARP Brain, use an Armv4I version and follow the usual procedure, which is explained here (Japanese) and here (English).

You can also remove this app by just deleting it. It doesn't save anything outside.

You write a program on the program editor, fill the input area if necesary, and press "Run" or "Next" to execute your program. You can also use buttons to type Brainfuck instructions in. To edit the program or input after starting an execution, press "End" to end the execution first. Note that black (dark theme)/glayed (light theme) areas are locked and not editable, and gray (dark theme)/white (light theme) areas are editable.

You can tune the behavior and reach more features from the menu bar. They represents

  • File: File features. New file, open file, save file...
  • Edit: Editing features. Undo, redo, copy, paste, ...
  • Brainfuck: Brainfuck language customization. Refer to the "Spec" section.
  • Options: Customizations and features. Speed, memory view address, real time debugging, highlight next instruction and memory pointer, dark/light switch, layout, font, and wordwrap.
  • About: About this program.

How To Build

You can build this app in various ways.

Build for Windows PC

  • win.sh: Builds binaries using MinGW_w64. Requires MinGW_w64 to be accessible from PATH.
    • Requires POSIX compliant environment.
    • Use win.bat for Windows build of MinGW_w64.
  • vs2022proj-pc/: Visual Studio 2022 (not VSCode) solution and project. The free Community edition is enough. Just open the .sln file and build, with the C++ Desktop Development installed.
    • Requires Windows machine.

Build for Windows CE (including SHARP Brain)

You probably want to read either here (Japanese) or here (English) to set up your development environment first.

  • brain.sh: Builds binaries using CeGCC. Requires CeGCC to be accessible from PATH.
    • Requires POSIX compliant environment.
    • Use brain.bat for Windows build of CeGCC.
  • evc4proj/: eMbedded Visual C++ 4.0 project. Just open the .vcw file and build, with a SDK installed.
    • Requires Windows machine.
    • I use the Standard SDK for Windows CE 4.0.
  • vs2005proj/ and vs2008proj/: Visual Studio 2005 and 2008 solution and project. Just open the .sln file and build, with the Smart Device Programmability installed.
    • Requires Windows machine.

Source Hierarchy

├─ main.cpp / main.hpp : Entry point and global definitions
│  ├─ msg.cpp / msg.hpp : Message handlers
│  ├─ runner.cpp / runner.hpp : Brainfuck execution managers
│  ├─ ui.cpp / ui.hpp : UI functions
│  └─ wproc.cpp / wproc.hpp : Window procedures
│
├─ bf.cpp / bf.hpp : Brainfuck interpreter
│
├─ history.cpp / history.hpp : Undo/redo manager
│
├─ tokenizer.cpp / tokenizer.hpp : UTF-8/Shift_JIS tokenizers
│
├─ util.cpp / util.hpp : Utility functions
│
└─ resource.rc / resource.h : Resource
    ├─ app.ico : Application icon
    └─ app.manifest : Application manifest