>>++++[->++++[->+>++++++<<]<]>>->[-<[-<<<<++++[->++++++++<]]>>>[<<<<<++++++++[->>++<<<+>]>>-<<<++>>]<<[>>>>>>[>>>]>+<<<<<[<<<]<<-]>>>>>>[>>>]++++[-<++++++++>]>[-<+>]<<[<<<]>>]<[-]<<,[[->+>+<<],[-]++++[->>--------<<]>>[>>>>[>>>]+[<<<]<-]>>>>[>>>]<<[-]<[<<<]<<[>>>>>[>>>]<<+<[<<<]<<-]>>>>>[>>>]<<<[[-]<<<]>[.>.>>]++++++++++[->+>++<<]>>[-<.>]<[-]<<<<[<<<]<,]
BrainFuck's options are pretty limited, so output is in the terminal and the screen is "cleared" with 20 newlines. Input should be the ASCII characters, separated by newlines.
Try it online!
Formatted and Documented
These are the debug notes I used to write the program. I used my interpreter which can optionally print the state of the tape at every '~' character for debugging.
[
run.bf
codegolf.stackexchange.com/questions/124306/map-inputted-ascii-characters
]
[
Calculate 16 * 6
Resulting tape state:
[0 0 0 0 0 0 16 96 0 0 0 0 ...]
^
Note that, to obtain a 16-by-6 grid, the 16
immediately to the right is decreased to 15
(since we will decrease it by 1 each loop
until we reach 0 and immediately reset)
]
>>>>++++[->++++[->+>++++++<<]<]>~
[
Our next goal is to make 96 sets of 3 cells each in the pattern [C D 0]
The first cell will represent an entered character--when the corresponding
input on the keyboard is pressed, it will change to the entered key.
The first cell is initialized to 32 (' ').
The second cell will represent the delimiter after that character.
Every 16 cells, this should be 10 for '\n'. Otherwise, it should be 32 for ' '.
The third cell is a buffer cell, used for traversal of the grid. In general,
it should be only temporarily modified and then reset to 0.
]
>->[-<
[
-<<<<++++[->++++++++<]
[
The second cell of our 3-set should be 32, so the above line
writes 32 to the 3rd cell from the beginning of the tape (0-indexed)
]
]
>>>
[
<<<[ The second cell of our 3-set should be 10, and we must reset the line counter ]
<<++++++++[->>++<<<+>]>>-<<<++>>
]
[ At this point, the delimiting cell we need is two cells to the left. ]
<<[>>>>>>[>>>]>+<<<<<[<<<]<<-]
>>>>>>[>>>]++++[-<++++++++>]
[ Debug Mode: In the previous loop, add a + in the string of 8 +'s to get visible spaces in the grid ($-signs) ]
>[-<+>]<<[<<<]>>
]
[ Go back to the beginning of the tape and clear up the residual '15' ]
<[-]~
<<,
[
[->+>+<<],[-]++++[->>--------<<]
[
Take input such that the state of the tape now looks like this:
[0 0 0 0 0 c c-32 0 32 32 0 32 32 0 32 32 0 ...]
^
Where 'c' was the entered character.
We now set up 1's in the buffer zones of the first c-32
3-sets and clear the character that is currently there.
All that is left, then, is to copy c to that location.
]
[ Set up the row of 1's. ]
>>[>>>>[>>>]+[<<<]<-]
[ Clear the current character. ]
>>>>[>>>]<<[-]~<[<<<]
[ Copy the new character. ]
<<[>>>>>[>>>]<<+<[<<<]<<-]
[ Clean up the 1's. ]
>>>>>[>>>]~<<<[[-]<<<]
[ Print the grid. ]
>[.>.>>]~
[ Print a bunch of newlines ]
++++++++++[->+>++<<]>>[-<.>]<[-]
[ Take a new input. ]
<<<<[<<<]<,
]