It is currently Wed May 22, 2019 4:37 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Feb 12, 2019 12:07 pm 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 143
Location: Edmonton, Canada
Image

Why? Why not. Use this awesome language to write your subroutines, when you feel that assembler is too difficult to master.

* uses 8 bit memory cells
* input is supported but limited

Source is here: https://github.com/veremenko-y/nes-brainfuck

Code:
; Hello World
BF_run:
BF_compile "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."
jsr BF_run


Result:

Image

Code:
; Factorial
BF_run:
BF_compile "+++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++>++++++>>+<<[>++++++++++++++++++++++++++++++++++++++++++++++++.------------------------------------------------<<<<.-.>.<.+>>>>>>>++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>[<+>-]>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]<[++++++++++++++++++++++++++++++++++++++++++++++++.[-]]<<<++++++++++++++++++++++++++++++++++++++++++++++++.[-]<<<<<<.>>+>[>>+<<-]>>[<<<[>+>+<<-]>>[<<+>>-]>-]<<<<-]"
jsr BF_run


Result:

Image

Edit: Updated version with fixed screen glitch


Attachments:
game.nes [40.02 KiB]
Downloaded 71 times


Last edited by yaros on Fri Feb 15, 2019 9:25 pm, edited 4 times in total.
Top
 Profile  
 
PostPosted: Tue Feb 12, 2019 3:54 pm 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 143
Location: Edmonton, Canada
Now with bottles of beer =) "Compiled version" is 6647 bytes...


Attachments:
bottles of beer.png
bottles of beer.png [ 5.69 KiB | Viewed 2409 times ]
Top
 Profile  
 
PostPosted: Fri Feb 15, 2019 7:28 pm 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 143
Location: Edmonton, Canada
Too bad, ca65 macroses are too slow to be useful (I should say abused). As soon as I started doing small optimizations, execution time decreased dramatically, so I rewrote compiler to C#.

I also changed compilation from jsr opcode to opcodes with jumptable to save space. It runs slower, but now it can actually run "Adv" - text adventure by Jon Ripley (http://jonripley.com/brainfuck/games/adv.html).

Controls:
left, right, up, down = west, east, north, south
select = down
start = up
a = look
b = inventory


Attachments:
game.nes [40.02 KiB]
Downloaded 70 times
adv.png
adv.png [ 4.98 KiB | Viewed 2296 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group