Showing posts with label BBC Micro. Show all posts
Showing posts with label BBC Micro. Show all posts

Moon Phase Program

Need to know when the next few phases of the moon will be?

Time and Date dot com will give you an accurate and reliable moon phase data, should you, for example, be a werewolf. In this case, knowing the exact minute of your upcoming transformation, I imagine, would be incredibly useful information.

I am not a werewolf (to my knowledge), but I am interested in astronomy, ancient computers and a bit of paganism. Therefore, this post is about a different Moon Phase application I often run on my BBC microcomputer and Raspberry Pi running RISC OS.

I hope this post will be of use to amateur astronomers, pagans and lycanthropes everywhere. Following the phases of the moon not only provides great evidence that the world is not a flat plane but studying our celestial neighbour is very relaxing. The moon is more than just a heavenly calendar. Really.

I originally found this program on a disk of public domain software, and it was originally adapted by D. Ambrose from that given in Microsoft QuickBasic 4.5 in Chapter 1 of Numerical Recipes in Basic by J. C. Sprott, CUP 1991. I have adapted the code slightly so that it picks up the time from the BBC micro's inbuilt battery-backed clock, and I also included some nifty 8-bit graphics for the moon phases. I have also changed the date format so it uses the (more correct) IEEE standard (follow that link for an in-depth rant about the subject).

Moon Phases running on the Beebem BBC micro emulator (Note, that this BBC has not been adjusted for the millennium bug as to my knowledge it is NOT 1999 all over).

Moon Phases running on my desktop PC in BBC BASIC for Windows.

I am assuming that this program remains in the public domain, and so I present it here. You can download the code from my OneDrive, and the directory includes:

  • A BBC microcomputer disk image; 
  • BBC BASIC for Windows source code; 
  • a Windows executable file (totally not a virus!); 
  • RISC OS application for Raspberry Pi, 
  • and the source code in plain text for you to do whatever you want with. 


Have fun now.


Could win an award for the best comment ever?

+1 Geek experience points awarded to J. C. Sprott and D Ambrose.

This is all for today, but if you like this sort of thing, then you might like other posts about the BBC microcomputer, or Raspberry Pi. Maybe you just want something completely different, or you are feeling brave enough to click this link.

Lunar Eclipse Jan 2019

This morning, I woke up at 4am, dragged my geeky body out of bed, grabbed a coffee and braved the freezing Yorkshire air to observe the eclipse.

Our ancient ancestors had various explanations for the eclipse or blood moon. The Chinese thought that an eclipse was caused by a giant cosmic toad-like dragon; the ancient Mesopotamians though that it was an attack by demons; the ancient Mayan civilisation thought that the moon was eaten by a jaguar; while the Egyptians assumed it was a beastly cow that was to blame.

Although we now know that a lunar eclipse is caused by the full moon crossing the plane of the ecliptic, the explanations of demonic animal attack described above are still more accurate than the best explanations of the most gifted flat-earth astronomers, who, to date, have failed repeatedly to provide a model for their flat earth belief. Although it is lamentable, that 2% of the population claim to believe that the earth is flat, this is not a post about how wrong flat earth supporters are. If you want to read about flat earth, I suggest this post.

I wanted to create this post to show the two apps I use for predicting eclipses, one old, one new, or in other words, how did I know that I needed to wake up at 4am this morning (and not as my colleague put it, 'I was coming to work this morning and I noticed that the moon looked a bit funny')?

My trusty go-to eclipse app on the BBC Microcomputer
The first app is 'eclipse' for the BBC Microcomputer. It reliably predicts lunar eclipses, even showing start times and end times with a graphic. The image shows the path of the moon (small circle) through the Earth's shadow (big circle). I still run this on my trusty BBC Micro. I think that it came on a Beebug magazine once. I am always impressed with its accuracy (EDIT image shown is NOT from this morning).

The second is Eclipse Guide developed by Vito Technology, Inc. who also developed the wonderful Sky Walk 2 app. This app is ostensibly a new and improved version of the app above, with better graphics, maps and a bit more information, oh and you can carry it around in your pocket.

Eclipse guide, showing handy information, such as when you need to go outside to freeze and when you need to get excited and tell people who are currently inside to come outside, and when to tell people that it is too late, they have missed it.

Skipping ahead to the near future, this is the app with details about a future solar eclipse, unless you are reading this in the future and the eclipse has already happened.
Well, that's it for today, suffice to say that the eclipse was a beautiful sight to see and I am looking forward to the next one, albeit partial on the 16th July.

If you are sticking around and have nothing better to do, then you might like to look at some similar posts from the history of this blog.

BBC Micro versus PC at chess

If a BBC microcomputer met a Windows 10 PC for a game of chess, which machine would win?

Let's find out.

The contestants:

WHITE
BBC microcomputer 32KB RAM, 2MHz 8 bit 6502 processor
Chess engine - Acornsoft Chess

BLACK
Windows 10 PC 24GB RAM, 2.9GHz i7 64 bit Quad-core processor
Chess engine - Chess level 100

Chess Level 100 for Windows 10 (on the left playing black) V. Acornsoft Chess for the Beeb (on the right playing white)

I decided to start with both machines running on their lowest setting. Acornsoft Chess has ten levels of difficulty whereas Chess Level 100 has, erm... one hundred levels of play. The BBC machine was emulated using BeebEm on the Windows PC. I initially set the BBC difficulty to the highest possible, however, after waiting over ten minutes for it to make its opening move, I decided to drop the difficulty level for the sake of sanity. Both machines came to a gentleman's agreement that the Beeb would play white.

You can follow the game below, or download the PGN file to study on your own system or board.

1. Nf3 h6

Against United Nations security resolutions, the Beeb starts with the Zukertort Opening, keeping its options flexible. The PC responds with a dubious pawn defence. Maybe it doesn't know that there is a war on?

2. d3 d5
3. g3 Nc6
4. Nbd2 Bg4

Already the PC is on the offensive with bishop g4. The Beeb responds with an excellent defence from his own bishop.

5. Bg2 Qd6
6. O-O f5
7. Bh1 b5
8. Nh4 Nf6
9. Rb1 Qe6

PC has an active Queen and is attacking with its pawns. The Beeb is focussed on defence.

10. f3 b4

A superb attacking move from the Beeb threatens the black bishop, however, the PC makes the dubious pawn advance to b4. It was at this point that I realised that the PC was clearly outmatched by the Beeb. First blood went to the Beeb by capturing the neglected black bishop.

11. fxg4 Nxg4
12. Bf3 Nd4
13. Bxg4 Nxe2+

The PC ignores the bishop capture on g4 and sacrifices its knight for a pawn on e2.

14. Bxe2 Qe3+
15. Rf2 e5
16. Nxf5 Qc5
17. Bh5+ Kd8
18. Bf7 Qc6
19. h3 g5
20. b3 Rc8
21. Qf3 g4

The Beeb's white pieces are beginning to dominate the board as black makes another blunder with the g4 move.

22. hxg4 Be7
23. Qxd5+ Qxd5

The Beeb captures the pawn on d5 and forces a swap of queens. It is pretty much all over for the PC now but neither machines offered a ceasation to hostilities.

24. Bxd5 c5
25. Kf1 Rg8

A blunder from the PC puts the black rook in the firing line of the white bishop. Maybe fog of war or otherwise poor intel did not reveal the white bishop lying in wait like a sniper.

26. Bxg8 h5
27. gxh5 c4
28. dxc4 Kd7
29. Nh6 a5
30. Ke1 Rc5
31. Ke2 Rc8
32. Ke3 Bc5+
33. Ke4 Bxf2

The PC makes some good play and steals a rook at f2 with probably the only good move it made all game.

34. g4 Be1
35. Bd5 Rh8
36. Nf3 Rxh6

Another blunder from black coming up. The white knight on h6 is too much of a temptation and does not seem to realise it is covered by the white bishop on c1. The Beeb does not let it get away with this mistake.

37. Bxh6 Bf2
38. Kxe5 Kc7
39. Nd4 Bg3+
40. Ke6 Bf2
41. Bf4+ Kc8
42. Nf3 a4
43. bxa4 Bc5
44. Ng5 Bb6
45. Rxb4 Bc7

The breakthrough is complete. Black's king hides in his underground bunker and denies the reports of his generals that the enemy is massing at the gates.

46. Bb7+ Kd8
47. Nf7+ Ke8
48. Bxc7 Kf8
49. Bc6 Kg8
50. Bd5 Kf8
51. Nd6 Kg7
52. Ke5 Kh7
53. Nf5 Kh8

Moments before the end black's king has shuffled off into the corner to die.

54. Rb8+ Kh7
55. Rb5 Kh8
56. Rc5 Kh7
57. Ke4 Kh8
58. Rc6 Kh7
59. Rh6#
White wins.

Conclusion

So the winner of this battle was the BBC microcomputer running on the emulator. This did come as something of a surprise, but it teaches us very little. The Beeb played reasonable chess, it did not make any blunders and was both defensive and exploitative of black's errors. The PC running Chess Level 100, on the other hand, played very poor chess and was punished for it by the Beeb. It is important to note that both chess engines were playing at their very lowest settings. I am an average ability chess player and I can beat both of these programs with ease on their lowest settings. Clearly, the lowest level of Chess Level 100 is designed to be a pretty weak player.

If there is any interest in this post then I will maybe follow up with a game where both machines are playing at their very best. Important to note that the Beeb made all its moves in just over 5 minutes at this setting, yet it took over ten minutes to make a single move at the highest setting so it won't be a very quick game.

If you enjoyed watching this game, then you might want to let me know by writing something on the noticeboard or maybe you just want to read some more posts about chess

Castle Defender is a brilliant new game for the BBC micro

Every now and then a new game is developed for vintage computers. Built by computing enthusiasts these games are often better than the original offerings from the time that the machines were first popular, or include titles and ideas that come from the modern age.

Castle Defender is the BBC micro's first ever tower defence game, and it is really very good. Programmed by Chris Bradburne with graphics by John Blythe, this game is superbly well written and designed. The graphics are stunning and the game play is addictive. I have been playing all morning, with admittedly, a pathetic high score of only 40% to show for my efforts.

A hoard of orcs and goblins storm my castle defences on the BeebEm emulator.
The aim of Castle Defender is to protect your castle from the waves of computer controlled 'nasties'. You build towers at strategic points along the way to shoot your enemies to death. There are three different types of weapons which can be upgraded as you earn more gold. Indeed, upgrading your weapons is the only way you will succeed at this game.

There is an initial steep learning curve in Castle Defender. At first the cursor key controls seem a little counter-intuitive, and you will possibly long for a touch screen. The best approach is to only use the left and right cursor keys to navigate the battle field. The second lesson you will need to learn is how to read the display at the bottom of the screen. Some enemies have shields which make them almost impossible to kill unless you have weapons that can deal with shields. Choosing the appropriate mix of weapons is essential to surviving each wave of nasties in Castle Defender.

Snakes! I hate snakes, Jock! I hate 'em! Come on! Show a little backbone, will ya!
There are four levels of superb high-resolution MODE 1 graphics, with each level getting progressively more 'evil'. You can skip levels by pressing the corresponding key 2,3 or 4 at the start of the game, although if you do the game wont track your high score. The animation is very smooth and the enemies make a satisfying 'pop' when they die.

It really is a joy to see developers creating new games for vintage machines, particularly when the results are such superb quality releases. One geek experience point is awarded each to Chris Bradburne and John Blythe.

You can download a copy of this game for your BBC micro or BBC master computer, or run it on your PC in an emulator such as BeebEm.

Zap that nasty! The loading screen of Castle Defender.
More modern games for vintage computers are available on the Homebrew Heroes Facebook page.

Well that's all from me today. I'm off to squish some 8-bit orcs...


BBC BASIC on Raspberry Pi

Recently I wrote about setting up RISC OS Pi for Raspberry Pi. One of the good things about RISCO OS is that it has a built in BASIC interpreter which is backwards compatible (mostly) with your BBC micro computer BASIC.

One way of running BBC software on your Raspberry Pi is to use an emulator, however it is also possible to run 'beeb' BASIC programs from your pinboard or command line, as this blog post will attempt to show.

RISC OS pinboard showing native BASIC apps and a stormy day in Scarborough.

Whether you choose to run the emulator, or run BASIC as native programs, your first port of call will be some BBC disc images. You might choose to download your BASIC disc images from the internet, or you may already have them on your vintage beeb machine. This post will cover both situations.

  • First load your disc image into your BBC emulator on your PC. I will be using the excellent BeebEm emulator for Windows.  To do this select: File > Load Disc 0 and find the disc image in your file explorer. The disc image will now be loaded into a virtual drive in your emulator. To see the files, type *cat in the BASIC command line.
Load your disc image into your emulator.
  • Export the BASIC programs that you want from the disc image. BeebEm provides you with the option of exporting a file from your disc image onto you PC. Save this onto a USB flash drive.  To do this select: Edit > Export Files from Disc > Disc 0

Export the BASIC files from the disk image onto a USB device.
  • Rename the file that has been exported. You don't want the DFS directory information showing. For example, change $.file to file only.
  • Plug the USB device into your Raspberry Pi. RISC OS should see the USB device which will allow you to copy the file and save it wherever it makes sense on your machine.
You should see the USB drive appear on your icon bar.
  • At this point you will probably have to change the file type to 'BASIC' rather than 'Text'. To do this, press the middle 'menu' mouse button and choose the appropriate option from the menu.
  • Your BASIC program will be ready to run directly from your pinboard.
To run from the command line, you will need a couple of extra steps.

  • First select the filing system for your USB drive. This is likely to be the command *fat32fs

  • Then mount the disk with *mount 0 or *mount 1 depending on the number of USB devices you have. To get a directory listing try *dir :0 followed by *cat and hopefully you will see your file. This can be executed with CH."filename" or edited with LOAD"filename" and LIST or RUN.

If in doubt, RISC OS provides documentation with the *help command. To return to the main filing system type *SFDS

Data Centre

If you have BASIC programs on floppy disc on a vintage beeb machine, you can also get your code running on RISC OS using the brilliant Data Centre from RetroClinic.

The documentation that comes with your data center explains fully how to transfer disc images from floppies or Compact Flash cards onto your PC.

In my case, I am transferring files stored on compact flash drive under ADFS to virtual RAM drives under DFS. These can then be exported onto the USB stick.  Once you have the disc images you can follow the instructions on getting them running on your Raspberry Pi from above.

Compatibility

Although you will find that most of your BBC micro, Electron or Master BASIC programs will run on your RISC OS Pi or RISC OS pico machine, there may be some minor compatibility problems.

Most notably is that you are going to find that your programs run fast. Very fast! This might not be a problem, in fact it might be very welcome if your program involves a lot of graphics. It could be a problem if you wish to play a game but don't have the reflexes of a Jedi.

With a program that I wrote myself for the BBC Master I notice that the different keyboard layout of the BBC machine and a modern USB keyboard caused an issue. This was because my program uses the key combination SHIFT + '3' to reset a timer. On the BBC machines this combination of keys produces the octothorpe character '#' whereas on my IEEE keyboard, this combination produces the '£' character. This was a minor problem which was overcome by a quick patch of the code.

Another problem was that some BBC BASIC programs do not have well-defined exit strategies. Oftentimes the way out of the program is to reset the machine with the 'BREAK' key. Under RISC OS this may cause programs to hang forever requiring a full reboot of the machine.  In most cases you either need to put up with this, or write an exit strategy.

One way of doing this would be to program the 'ESC' key to act like the 'BREAK' key. Just add the following BASIC line into the start of your program:

  ON ERROR IF ERR = 17 OSCLI("DESKTOP")

If you have enjoyed this post then you might want to read other posts about the Raspberry Pi, or about the BBC micro systems, or just something at random from this blog.



Can you use a BBC Micro as your main computer?

Well, the short answer is no, (but I have been trying)...

For a computer to be of any use, I figure that it must be able to do the following well:

  • Connect to the Internet and have a fast, secure browser.
  • Provide applications for work flow.
  • Provide applications for playing media files.
We'll look at these in turn, but first some information about the BBC Microcomputer.

A Graphical User Interface for the Beeb

The BBC micro, (or 'Beeb') was an 8-bit microcomputer commissioned by the BBC and built by Acorn in 1981. It was highly popular in education in the UK and survives today in the hands of enthusiasts such as myself. If you need to get your beeb 'fix' then there are a number of emulators available, including browser-based, and desktop (I recommend BeebEm). There is, however, nothing like running a vintage machine for the full experience. I recommend Retroclinic for all your BBC computer needs, including the datacentre (more about that later).

The Internet

While Acorn produced Econet, their own version of LAN connectivity for the BBC microcomputer, in the modern world this is not going to get you very far. It is possible to connect a modem to a BBC micro computer, however you must keep in mind that this machine was build before the World Wide Web was invented. You will be very disappointed if you need to upload your duck faces to Instagram on a beeb. You will find that you must keep your Twitter-rants to yourself and it will be virtually impossible to see what everyone is having for dinner on Facebook.

As a main computer, the BBC micro falls at the first hurdle. This was a pre-Internet machine and sadly, you will need a modern computer to experience the modern Internet.

That should be enough to kill anyone's dreams of using the BBC micro as a main computer, however there are two other critical points of failure:

Work flow

Whatever your job, business or hobby, you will likely need to run some Office software, or other such desktop publishing or productivity tools. If these are mission-critical to you, then switching to a 35-year old computer is not an option. The Beeb doesn't fall flat completely, however. Most BBC computers were packing work-flow software, and although they seem primitive now, you can get stuff done. My BBC Master computer has a word processor, spreadsheet and text editor built into ROM, and thanks to the Retroclinic datacentre it is possible to transfer files from the beeb onto my Windows 10 PC.

That being said, and despite having some, albeit ancient productivity tools, the beeb cannot replace my PC as a productivity machine (however I will talk about what it CAN do later).

Media center

I am currently typing away on a modern laptop, and streaming music on a chromebook which is plugged into my amplifier. I have a library of music, movies and photographs stretching back nearly two decades stored on a network drive, and if any computer is going to be my main computer, then it will need to handle my entertainment needs. For a while, I used a Raspberry Pi as my main music jukebox, although I now use Microsoft's Groove app. Whatever your media needs, your BBC microcomputer is not going to do it. 8 bit machines simply do not have the codecs required to play audio and other media files. Although digital cameras were available for the BBC, they are nothing compared to their modern counterparts.

So, it seems like the BBC computer cannot be used as a main computer. 

If, however, you accept these limitations, then the beeb still has a lot going for it. In the rest of this post I shall talk about some of the cool things my beeb does for me.

My BBC

My computer is a Master series with 128K RAM and a second processor. The caps were replace about a year ago, so there is no danger of the power supply failing anytime soon. The battery for the CMOS RAM is also in good condition having been replace fairly recently. I have a dual-drive disk drive, however the main way of storing files is using the Retroclinic datacentre. This little device provides four virtual RAM disks, a small non-volatile 64K RAM disk and it also has 2GB compact-flash cards which provide four 500MB hard disk drives. There is a USB flash drive sticking out of the front storing literally hundreds of disk images which can be transferred into RAM in just a few seconds.

My microcomputer has 'pride of place' on my desk and supports a 32 inch monitor. When I first got it I promised myself that I would use it as an 'everyday' machine in order to justify its position on the desk.

I often use the BBC as a notebook. The EDIT program built into ROM is always available, and I use this to write notes to myself as well as my diary and other documents. I didn't go as far as writing this blog post on it, however I just realised that I could have done, and now I wish I had. I also use the spreadsheet program to help manage my accounts, as well as other diverse tasks including calculating the most cost effective pizza as well as helping calculate options in online games. The Beeb performs all of these tasks admirably and there really is no need for a modern computer. I am waiting for the time a colleague requests some trivial or not critical information from me, expecting an email, but instead, as I am a mischievous soul I will provide them with a text file on a portable USB disk drive. Mwah ha ha ha HAAAA!

Although the BBC was not well-know for it's games, this computer did have an extensive library of titles available for it, and the beeb was no slouch when it came to graphics and sound, for it's time. Most games are available to download online from such sites as Stairway to Hell. The best experience can be had from games with a focus on gameplay rather than graphics. Classic games such as chess, backgammon, connect-four, patience, solitaire, UNO, Yahtzee, NIM, Mastermind, draughts, reversi and cribbage all work very well on a BBC. There really is no need for a modern PC to play these games as the beeb will be a very challenging opponent.

Being beaten at Minesweeper on the Beeb (again).
Armies of programmers have over the years written countless applications for the beeb. I often trawl through the disk images that came with magazines in the eighties to find apps that are still useful today.

Here is an app for finding the next few phases of the moon.

This app calculates the dates of future eclipses and even shows a graphic of what the Earth's shadow will look like over the moon.
Okay, it's not quite Google Earth...

The beeb has a (very good) version of BASIC held in ROM. For this reason it is very easy to write your applications for the beeb. You can read about my early attempts here. I currently have applications for telling me the time and date, as well as useful stopwatches, countdowns and alarms (yes, I use it to help me cook my dinner). I have a perpetual calendar application and a calculator. All of which get regular use. I am currently working on a dictionary program.

My very useful calendar/clock app.
So, in summary, can you use a BBC microcomputer as your main computer? No, but it does make a very handy, and tremendously fun second computer.

If you are still awake and for some reason you liked this post then you might like to read about my other BBC micro posts, or even my adventures with the Raspberry Pi. Perhaps you just want to know how many floppy disks would be needed to store all of Google Maps?

Either way, I hope you liked this post. Please come back soon for more geeky stuff.

Label

World Karma Game