Nibbles and Logo

Published February 19, 2009
Advertisement
Work on BBC BASIC has slowed down quite a bit, with only minor features being added. A *FONT command lets you output large or font sized text to the graphics cursor position regardless of the current MODE:


10 MODE 320 VDU 530 MOVE 0,255 : PRINT "Small"40 *FONT LARGE50 MOVE 0,227 : PRINT "Large"60 VDU 470 PRINT TAB(0,3) "Small (VDU 4)"

Another new command is the dangerous *GBUF that can - when used correctly - let you switch the location of the graphics buffer. You can simulate greyscale by quickly flickering between two different images on the LCD, which is where this command may come in use.


Snake/Nibbles is a fun game and an easy one to write, so here's a simple implementation that features variable speeds and mazes. The game runs quickly on a 6MHz TI-83+, which I'm happy with. And yes, I know I'm terrible at it. [wink]

One thing I've always been pretty bad at is writing language parsers resulting in poor performance and bugs. I've started writing a primitive Logo interpreter in C# to try and improve my skills in this area. So far it supports a handful of the basic language features and statements:
Quote:
- print [Hello World]Hello World- make "animals [cat dog sheep] show :animals[cat dog sheep]- make "animals lput "goat :animals show :animals[cat dog sheep goat]- print last :animalsgoat- repeat 2 [ print "A repeat 2 [ print "B ] ]ABBABB- show fput [1 2 3] [4 5 6][[1 2 3] 4 5 6]- [10 9 8]Not sure what to do with [10 9 8]
(No, no turtle graphics yet [wink]). There's no support for infix operators yet. The BBC BASIC ROM manual describes the top-down parsing method it uses to evaluate expressions so I'm going to attempt to reimplement that.

One issue I've already run into are the parenthesis rules: for example the sum function outside parentheses only allows two arguments, but inside parentheses works until the closing parenthesis:
Quote:
- print (sum 4 5)9- print (sum 4 5 6)15- print sum 4 59- print sum 4 5 69Not sure what to do with 6
I'm not sure whether a "this statement was preceded by an opening parenthesis" flag would be sufficient.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement