Saturday, July 11, 2015

Arduino Retro Computer: v1.0

I'm calling the current state of the Arduino Retro Computer version 1.0. There are still a ton of improvements on the to-do list, but the computer as it stands is in a usable state.


I've made 2 short programs to show it can do something useful...

Guess the Random Number


10 let guessNum% rnd 100
20 print "Guess the number between 0 and 100"
30 input guessVal%
35 print guessVal%
40 if guessVal% < guessNum%
50 print "Too low."
60 if guessVal% > guessNum%
70 print "Too high."
80 if guessVal% == guessNum%
90 goto 200
100 goto 20
200 print "You got it!"


Simple RPG Battle (Using Joystick)


1 let playerHP! = 40
2 let playerSP! = 5
3 let monsterHP! = 40
4 if playerHP! <= 0
5 goto 39
6 if monsterHP! <= 0
7 goto 41
8 print "You face a troll."
9 print "Your health:"
10 print playerHP!
11 print "Your spell points:"
12 print playerSP!
13 print "Command?"
14 read joystick 1
15 if j1left% = 1
16 goto 25
17 if j1right% = 1
18 goto 30
19 goto 14
20 let mDamage! rnd 20
21 let playerHP! -= mDamage!
22 print "Troll hits you for:"
23 print mDamage!
24 goto 4
25 let pDamage! rnd 20
26 let monsterHP! -= pDamage!
27 print "You hit troll for:"
28 print pDamage!
29 goto 20
30 if playerSP! <= 0
31 goto 20
32 let pSpell! rnd 15
33 let pSpell! += 10
34 let monsterHP! -= pSpell!
35 print "You cast fireball at troll for:"
36 print pSpell!
37 let playerSP! -= 1
38 goto 20
39 print "You have died."
40 end
41 print "You have defeated the troll."


Video of Computer


Here's a video of me making a quick program and demonstrating the multitasking. (Multitasking works great, but you can see it slows things down!)

video

What's Next?


Version 2.0 will probably be refining the BASIC interpreter along with some refactoring of the code.

Some ideas for it:
- Cleanup how I handle assigning variables (quotes and = signs).
- Be able to manage variables without the let statement.
- Make the if statement follow standard behavior. (Support "end if".)
- Support printing text and variables in the same print statement.
- Add a REM statement.
- Support single key input (similar to C's getchar() function).
- Fixing bugs. I currently have a mixture of long & int. Arduino Int's are only 2 bytes. I want to standardize on the 4-byte integer (Arduino Long).


Hopefully some of these posts could be a useful reference for your own project. I've got another project that I'm excited to start, so I figure I'm at a good "pause" point on the computer. Looking back at my intro post, it looks like I reached step #5. The BASIC interpreter could use many more features, but I'm way ahead of schedule to make it an educational first computer for my son (now 9 months old).


No comments:

Post a Comment