kestas.kuliukas.com

BrainFuck interpreter for the Casio Color Power Graphic Calculator

This program is a simple brainfuck interpreter for Casio Graphic calculators.

Usage

When you execute the program it will ask you to input the algorithm.

Button Command stored
1 +
2 -
3 >
4 <
5 [
6 ]

Once you've entered the algorithm press 'EXE' to begin. The screen layout is something like this:

_______________________________
|BF CONSOLE-KJK               |
|-----------------------------|
| . .. . .                    | #The height above a 0-dot
|  .  . . ................... | #here represents a command.
|-----------------------------|
|  .  .                       | #The height above a 0-dot
| . .. ...................... | #here represents memory.
|-----------------------------|
|EXECUTING BF SCRIPT          |
_______________________________

There will be pointers represented by dots below the 0-dot pointed to, there is one for the position in the algorithm and another for the position in memory.

Code

The -> represents the arrow under the red 'L' on your calculator, the one that assigns values to variables. The represents the operator which executes the instruction to its right only if the instruction to its left equates to 1. (PRGM>JUMP>=>)
The whole program takes up 718 bytes, and could be cut down by cutting out the text and optimizing the code. The NOT= (used only once) represents the 'not equal' sign (the equal sign with a cross through it). (PRGM>REL>)

ViewWindow 1,128,1,1,64,1:Cls:Horizontal 54
Text 2,1,"BF CONSOLE":Text 57,1,"ENTER ALGORITHM:"
0 -> A:0 -> B:0 -> C:0 -> D:0 -> E
5 -> F:5 -> H:27 -> I:50 -> G
F-Line F,64-G,F+115,64-G:F-Line H,65-I,H+115,65-I
PxlOn I+2,F:PxlOn G+2,F
While Z -> 31
Getkey -> Z
Z=00 -> Y
Z=721 -> Y
Z=622 -> Y
Z=523 -> Y
Z=734 -> Y
Z=635 -> Y
Z=536 -> Y
If Y NOT= 0:Then PxlOn I-Y,H+E:PxlOff I,H+E:E+1 -> E:0 -> Y:IfEnd
WhileEnd
0 -> Z:Text 57,1,"EXECUTING BF SCRIPT":0 -> E
While 1
0 -> C:0 -> J
For 0 -> Z To 6:PxlTest I-Z,H+E:AnsZ -> C:Next
PxlTest G,F+D:Ans -> Y
C=5 And A -> 0A+1 -> A
C=5 And A=0Y -> A
C=6A-1 -> A
A=0 And (C=5 Or C=6)1 -> J
A>01 -> J
A<02 -> J
If C=1 Or C=2:Then For 0 -> Z To 9:PxlTest G-Z,F+D:AnsZ -> B:Next:IfEnd
If C=1:Then PxlOff G-B,F+D:PxlOn G-B-1,F+D;1 -> J:IfEnd
If C=2:Then PxlOff G-B,F+D:PxlOn G-B+1,F+D;1 -> J:IfEnd
If C=3:Then D+1 -> D:1 -> J:PxlOn G+2,F+D:PxlOff G+2,F+D-1:IfEnd
If C=4:Then D-1 -> D:1 -> J:PxlOn G+2,F+D:PxlOff G+2,F+D+1:IfEnd
PxlOff I+2,F+E
J=1E+1 -> E
J=2E-1 -> E
PxlOn I+2,F+E
WhileEnd

Notes

This interpreter has room for 115 instructions and has 115 memory locations. It uses the screen to store and retrieve instructions and memory, and the pointer location. This decreases the speed, but it lets you see exactly what's going on with your program.

Apart from the memory and algorithm size limitations there are a couple of other limitations to bear in mind: