BrainFox GB

From GameBrew
BrainFox
Brainfoxgb.png
General
AuthorYprit
TypeOther Apps
Version1.3
LicenseMixed
SystemDMG
Last Updated2021/09/30
Links
Download on itch.io
Website

BrainFox (BF) is a "dialect" of BrainFuck language that is designed to be run on Game Boy and a native translator of it.

Unlike the original BrainFuck that doesn't have any program length limitation and had 30,000 one-byte memory cells, this version allows to input and run program that consists of no more than 7200 operators and operates with up to 5000 one-byte memory cells.

The BF program is cycled; it automatically returns to the start from the end. You can only stop it manually.

BrainFox is an entry for Game Boy Competition 2021.

User guide

Here are all available commands:

Character Meaning
> Increment the data pointer (to point to the next cell to the right).
< Decrement the data pointer (to point to the next cell to the left).
+ Increment the byte at the data pointer.
- Decrement the byte at the data pointer.
. Output the byte at the data pointer.
, Accept one byte of input, storing its value in the byte at the data pointer.
] If the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
[ If the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.
(Space) Does nothing, can be used to make program more readable, but still takes place in program memory

Working with interpreter

The BF interpreter consists of 3 parts and allows 3 modes: Start Screen, Code Editor and Interpreter. Below you can read a review of every of them.

Start Screen displays the main information about interpreter (title, version and it's qualities, who is author etc.) and is displayed on screen when Game Boy with BF cartridge is switched on.

Code Editor is designed for input, viewing and editing the BF code. It consists of 3 parts:

  • The 18x10 input window with cursor.
  • The D-Pad help.
  • Cursor counter (helps to control the position of it).

The program saves and loads automatically.

Interpreter works as it is written in "Syntax". To go to editor press Start.

Application

1. Symbol table:

BF uses standard ASCII table, but 7F is delta (triangle). It is not recommended to use hex80 and next symbols.

2. Joypad table:

Any key responds for one bit. There is 8 keys, so the state of joypad can be written in 1 byte.

  • 0 right
  • 1 left
  • 2 up
  • 3 down
  • 4 a
  • 5 b
  • 6 select
  • 7 start*

(*) As the Start key is reserved for interpreter stop, you can't use it to input.

3. Samples and useful codes pattern:

To make it easier to read programs, numbers in round brackets are used to indicate how many times you must enter the operator, written in front of them (e.g. ++++++++++ is the same as +(10) ).

Patterns:

[-] or [+] zeroing the current cell.

Programs:

a) Displays all valid characters in ascending order of their ASCII codes .[+.]

b) Joypad test ,+(32).

c) Hello World (complex variant) +(10)[>+(7)>+(10)>+++>+<<<<-] >++.>+.+(7)..+++.>++. <<+(15).>.+++.-(6).-(8).>+.>.

Important: After printing Hello World the program will work incorrectly because there is no zeroing of memory cells and "cursor" position.

Controls

D-Pad - Enter < > + - commands

D-Pad+A - Enter [ ] . , commands

D-Pad+Select - Move cursor

B - Delete previous symbol (like Backspace)

Start - Run/Stop the program

Start+Select - Clean program memory (do it when you run BrainFox the first time)

Screenshots

brainfoxgb2.pngbrainfoxgb3.png

Changelog

1.3

  • Release version (looks better than previous).

1.2

  • Beta with code saving; 32K ROM + 8K RAM cartridge; code length = 7200 KB, 5000 memory cells.

1.1

  • Alpha with saving; 32K ROM + 8K RAM cartridge; code length = 5 KB, 500 memory cells.

1.0

  • Alpha. 32K cartridge, no saving; code length = 5 KB, 500 memory cells.

External links

Advertising: