Welcome to the website of the Sydney Amiga Users Group!

Next Meeting:Sunday 14th November 2021

Due to the Sydney lock-down, the meeting was reverted to a virtual one.

The agenda was:
3pm – Greetings and catch-up
3.15pm – John Kenyon talk and QA
3.30pm – Steve Smit – Intro to Forth on C64 for robotics
4.00pm – Open floor for general discussions
6.00pm – Official close

John Kenyon discussed how he had many treasured home videos stored on DVD-R media that over time (and a spell in the ceiling over an Australian summer) had started to become unplayable. He looked at various solutions for recovering the data and got good success using ddrescue.

The slides for John’s presentation are viewable at Rescuing optical media

Steve Smit then covered an intro to DurexForth, a version of Forth programming language on the Commodore 64. Forth was developed by Charles Moore in 1968. He was working at a radio telescope facility and wanted a way to program the moving of the dishes. He went on to become cofounder of Forth Inc. in 1971. Postscript is a derivative of Forth. Forth is a stack based language and uses reverse polish notation (as found in many HP calculators). It’s very close to the ‘tin’ but much easier to read than assembly language.

Since there are versions of Forth for the Commodore 64, Amiga, PC, Rasberry Pi and Arduino, Steve is keen to explore using Forth for many upcoming robotic projects he has in mind. He demonstrated how Forth is both a programming language and an operating system, since new ‘Words’ can be added to the dictionary of the system in real-time and used immediately, including being called from within other pre-written ‘Words’, a bit like calling sub-routines. While there are quite a few Forth versions available for the Commodore 64, Steve chose DurexForth as it’s open source and still being improved.

In Forth everything is just separated by either space or a new line. Numbers are automatically added to the Stack as LIFO (Last In, First Out). And anything that isn’t a number is assumed to be a ‘Word’. If that Word has not been defined before you get an error. Let’s take the example of (2 + 3) * 4 = 20. In Forth this would be entered as so: 2 3 + 4 * . The +, * and . are not numbers so are Words. + simply takes the top two numbers on the Stack, adds them together, and puts the result onto the Stack. Then * multiples the top two numbers putting the result onto the stack. The Dot at the end simply ‘prints’ the number on the top of the stack.

To define a new Word it just needs to be between a : and a ;

For example : ADD10 10 + . ; cr

The Word ADD10 can then be used to add 10 to any number. At the Forth prompt simply type:

20 ADD10 cr and the result will be 30 shown on the screen.

To mess with someone any Word can also be re-defined simply by a new colin semicolon code. For instance one could reprogram the + to actually do a multiply like this:

: + * ; cr

Now, if we use our previously defined ADD10 again with

20 ADD10 cr

The result would be 200. That’s because we redefined a + to be a *.

DurexForth also works with standard text files that can be pasted into the vi style editor that’s built into DurexForth.

Steve then showed how he added Words to send bytes over RS232 from the Commodore 64 to a Arduino UNO (fitted with an RS232 shield). He wrote a routine that would read the Commodore 64 joystick 1 fire button. If the button was pressed a letter T was sent to the Arduino which Turned on an LED (shown with a * on the screen). When the fire button was released a Letter O was sent to turn Off the LED (shown as ‘n’ on the screen). The Word ‘readf1’ remains in a begin again loop while the joystick is not pushed in the up direction (which takes bit one low in the CIA register at $DC01).

Lastly, another Word was created such that the direction of the joystick (Left or Right) would result in either a “1” being sent to the Arduino to command a servo motor to turn Left, or a “2” for it to turn Right, only ending if the fire button was pressed.

Report written by Steve Smit

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *