The Humble “Glass Teletype” and the Lazy Programmer…

Way back we had mechanical output devices for our computers. These were big, slow, noisy and really a spill-over from the days of the telegraph, but they fulfilled their purpose and much code, including early Unix was written using them. Teletype Corporation are possibly the most well known ones of the time, although there were many other manufacturers, but when you see a picture of a mechanical printer it’s almost always a “Teletype” (And even when not, it’s almost become a generic word anyway).

Teletype ASR-33

Fast forward to today and we have big, fast screens and editors that do much much more than the old line-oriented editors of yester-year.

But what happens when you build a retro-style computer, running at retro speeds and you want a screen orientated editor?

Well, in the first instance, you write it, test it, use it and it’s great. In my case it’s talking to my desktop PC at 115200 baud (that’s just over 10,000 characters a second, so to fill a typical 80×25 character display takes about a fifth of a second. Acceptable. I’m also using a custom terminal program of my own making and while it’s a relatively “dumb” terminal its clever enough to only update the screen when needed, and as that update is not constrained by the speed of a serial connection it appears to be really smooth and fast, but naturally, I wanted to see what it would be like on a real (or emulated) terminal…

The 1970’s

But lets wind back some years to the mid 1970’s. Computers were still relatively slow but advances were being made in the terminal department. Mechanical printers were now up to about 30 characters per second (from the original 10) and were quieter, but were slowly being deprecated in favour of the new “Glass Teletypes”.

Glass Teletypes?

These fully electronic devices were initially limited in what they could do. Print from top to bottom, scroll upwards and… Well, that’s about it. The limitation was mostly due to the electronics at the time – Memory was still expensive, logic circuits (rather than a microprocessor) were still in-use, so it was not uncommon to see a rather large board stuffed full of TTL ICs driving the CRT (Cathode Ray Tube, often just called a “Tube” in some cultures) typically green phosphors on a black background. If you were very lucky you might have one with Orange phosphors.

Time marches on…

But nothing stays still for very long and terminals (as they were now being called) were becoming more sophisticated – under program control, the location of the cursor could be changed – some could scroll down as well as up. Partial screen clears (say from the current line to the bottom of the screen, or cursor position to the end of the current line). The net result was that “Screen Editors” could now be a thing and while programmers (initially) still used older line-orientated editors for code, ordinary users now had things like “word processors” which used the whole screen and allowed for easier editing of text for documents, letters and so on. WordStar one of those and that was first published in 1978 and relied on these new smart terminals to work.

1978 also saw the introduction of “personal computing” as we might know it today. Relatively affordable computers with screen, keyboard and storage – aimed at small businesses and serious (as they were expensive!) home users and education. The Apple II, Commodore PET and the Tandy/Radio Shack TRS-80 were the three main contenders then.

But what about the old “Glass Teletype”? They were still in-use for a long time – they were an economical device to connect to larger multi-user time sharing systems and so they lived on for quite a few years. Today they may be considered a bit of a relic. An anachronism or just something for the new kids to laugh at… (imagine a screen and keyboard with no computer!)

Retro (and vintage) Computers…

In the world of vintage or retro computers the Glass TTY is still very much a thing, so for my Ruby project I decided to see how it would work with one – although I do have a real terminal, I chose to use an emulator on my Linux desktop using the PuTTY software.

Lazy programmer…

And what I found was that over the years I’d obviously become quite lazy when it comes to screen handling. Ruby was intended to be vaguely Acorn/BBC Micro compatible when it came to screen handling – and it is, but the Acorn MOS screen handling is very much lacking in facilities required to drive a serial terminal, so while it has cursor move screen clear  and scroll facilities, that’s just about it. And although there are text window facilities (to define an area not a modern “window” in a big graphical user interface) you still need to do a lot to e.g. insert a line or character or clear to the end of the line or page.. The net result was that my editor while ran quite well with my own terminal program ran rather poorly when used on a real (or emulated) ANSI terminal.

So back to the drawing board and the old days of working out screen codes, ESC [ then the magic codes. fortunately a standard had emerged which most people just refer to as ANSI. The hardest part? Making the arrow keys and command keys (Home, End, etc.) and even worse the Function keys work. It may be a standard, but there are many interpretations of that standard…

However some work on the VDU handling code in my RubyOS and in my own SDL based RubyTerm and of-course in my editor and other home grown utilities that run on the Ruby board and it’s now running as well as it might have done back in the early 80’s on a real terminal.

 

Ruby816 – Solving the bootstrap paradox

Previously I wrote about the issues bootstrapping BCPL on my Ruby board and I was moaning about needing a C front-end or “shim” to get BCPL going.

So I engaged the little grey cells and worked out a strategy…

What I’ve done is to write sufficient ‘816 assembler code to initialise the BCPL global vector and create a stack, then to point the cintcode program counter to some embedded cintcode (embedded into the ASM program as a binary blob), and call the cintcode interpreter.

At this point the bootstrap program can call local functions but not global ones. The “blob” is actually the bare minimum in terms of library calls to get BCPL fully going. I created it by simply concatenating the files (sections) and turning them into a form I can include in-line with the assembler source for the cintcode interpreter.

The BCPL bootstrap fixes-up the global vector by scanning the concatenated section images and working out the correct offsets to populate the global vector with. The first call I then make is the getvec setup call to initialise the memory for subsequent allocations, then I call the loadseg() function to load the rest of the library files into RAM as before with the C front-end. It’s already running BCPL at that point, so the last file it loads is the command line interpreter which is loaded and called and the system is ready. This is slightly quicker than the C front-end too as some of the library routines are loaded with the interpreter and remain there for the rest of time.

And so the paradox is no more!

Ruby BCPL Bootstrap

Ruby BCPL Bootstrap

A Day at the Races

We have a nice point to point racetrack in (near) Buckfastleigh, so today we went over for the first race of the season.

One of the horses that is stabled/trains at the yard where I ride out from was racing today, so it was really nice to see her in action. She didn’t win but was the best turned out for he race thanks to the hard work of Trudi in the stables.

I made a very little video from the clips and pictures I took. Enjoy!

Home Artisan Microbakery – 3/3

Stage 3, but if you missed it, then back to the mix and knead step… or  back to the preparation step

The Big Bake

The next morning comes – round about 5:45am and the dough has risen!

Dough has risenHooray and up she rises… early in the morning!

The task now is to do the usual clean and sanitise, get the ovens on and get the dough scaled (measured) out and into proving baskets, tins and so on. Additionally, on this particular day I have the added pressure of sticky buns… These are made in the morning from scratch using a fairly standard enriched dough recipe (with eggs, sugar and milk), filled, baked, glazed and sold… Todays were cardamom and cinnamon.

Starting with the sourdough:

scalingThe dough is tipped onto the counter and weighed out into the size I’m after. These are medium (600g) loaves so the dough is a rather generous 740g. After scaling, the lumps are shaped into boulles before final shaping.

pre shaped boullesThese are just rough rounds. I then get the proofing baskets and couch ready

baskets and coucheand do the final shaping and leave them covered to rest and rise a little more. This is being done against the clock, so that’s 24 (actually 25 as there was a bit of spare multiseed dough) loaves and I aim to have this all done inside half an hour.

Rye into the ovenMeanwhile the Lincat oven is up to 200°C and the rye loaves which I’d gotten out of the fridge earlier can go in with a big blast of steam…Not forgetting to set a timer!

more scalingThese are the wholemeal and cheese breads scaled and pre-shaped… There will be 2 cheese loaves, a batch of cheese sticks and 2 cheese rolls for the lovely staff in the cheese shop in Totnes…

wholemealsThe wholemeals are in tins.

cheese loavesThe cheese loaves are roughly shaped, filled with cheese cubes and rolled into a log.

cheese loaves proofingThese are left to rise in these baskets along with the cheese rolls which I’ve also stuffed with cheese…

sticky bun doughMeanwhile, I’ve made up the sticky bun dough – threw it all in the mixer, let it knead and transfer it to a bowl to rise.

cheese sticksThis is the start of the cheese sticks. Pull the dough out into a rough rectangle, 2/3 cover in grated cheese then fold, roll, turn and repeat another3-4 times…

more cheese doughGetting there..

cheese stick doughDone – for now. It’s covered with the (recycled) cling film and put in the fridge for an hour or so to relax.

Baked ryeThe rye breads are usually done by now, so they come out and are left covered in their tins for another 10 minutes or so.

ready for ovenAnd now it’s about 7:45 or so – I’ve had to do a round of washing up/cleaning and lifted the risen dough to the silicone sheets that go into the Rofco oven and attacked them with a razor…

dough close upThis is a closer view of one of them – I’m using a large plywood sheet that has been cut to the exact width of the Rofco to load them into the oven.

loading 2After loading the Rofco, I’ve more to go into the Lincat. These are transferred directly onto the board with a bit of flour then into the Lincat.

Lincat loadedThis is the Lincat loaded with the dough – there’s that extra loaf at the bottom (the bakers own!)

sticky bun dough risenMeanwhile the bun dough has risen and we need to tip it out, roll it into a rectangle, cover it with the filling mix (butter, sugar, cardamom), fold and cut, twist and knot…

yum...cutThey’re all the same size… honest!

buns to riseLeft to rise…

What next – it never stops here… I think the wholemeals might be ready to go into the oven.

wholemeals bakingOr maybe this was when they were done…

Inside the rofcoThis is the breads inside the Rofco oven. After 12-15 minutes, I open the door and whip out the silicone sheets to let them bake the rest of the time directly on the stones.

bakedAnd here they are…

cheese loavesThe cheese loaves and rolls are ready to go into the Lincat oven…

buns risenAs are the buns…

baking bunsmorebakingTiming is key here…

baked wholemealsThe wholemeals are out …

chese sticksAnd don’t forget the cheese sticks – this is the cheesy dough out of the fridge…

sticksRolled and cut …

baking sticksand in the oven.

baked cheeseThe cheese loaves and rolls are baked…

baked bunsAs are the buns (covered in honey sticky glaze now)

cheese sticks bakedThe cheese sticks are baked too.

PackingAnd finally it all needs to be packed up into boxes and taken to the shops and it’s in the shops by 10am while it’s still warm…

Home Artisan Microbakery – 2/3

Stage 2, but if you missed it, then back to the preparation step

The Big Mix

Preparation takes place usually at about 3-4pm. A few hours later round about 7:30 to 8pm, it’s time to mix and knead up the doughs which are then left to ferment overnight.

Bubbly sourdoughThese are the sourdoughs after 4 to 5 hours. They’re nice and bubbly and ready to use.

Now, it’s mostly a matter of weighing up the water and sourdough, tipping that into the mixer, then the flour – giving it a good mix, finally adding in the salt for a few minutes more, lifting it out the mixer and repeat the process…

MixingThis is the spiral mixer. It’s single speed with a fixed head, so getting the dough out requires a certain knack, as does cleaning it. Spiral mixers are very common – this is an Italian make and you’ll find these used in pizza parlours the world over.

Rye mixingThe rye is mixed by hand – only a few loaves usually and it’s a very wet and sticky dough. Gluten doesn’t develop in rye the same way as wheat, so there’s no point trying to knead it really. Keep it wet with a sourdough starter and it’ll be just fine. I add caraway seeds, malt and molasses to mine.

Small mixerThe overnight white dough that I use for the cheese breads is an olive oil based dough with just a fraction of the normal yeast added (it’s not a sourdough). This is mixed in a small stand mixer that I was able to get a nice dough spiral hook for. These are much better than the usual hook you get with them.

After that, it’s just a matter of getting the liquid ready for the next mix/knead in the spiral, emptying it, dividing the dough into lumps that will fit the containers, splitting up the rye into tins and trying to keep sane…

Lump of doughThis is a lump of dough taken out of the spiral mixer and left to rest on the bench while I load it up with the next batch. I try to keep the mixer going all the time so I make sure I have everything ready to load it with as soon as I take one batch out. I also try to plan the loads to avoid too much of one type of dough getting into the next batch, so the seedy ones are often last with the plain white (when I do them) first. This day I had 3 lots through the spiral mixer – my usual sourdough which is a mix of white, wholemeal and rye, then a seeded mix, then the 100% wholemeal. I’m not overly concerned if a few seeds get into the wholemeal – I stopped using the main allergen one a long time ago (sesame seeds)

Split doughThis is a load from the mixer that I’ve weighed and divided into two – the smaller on the left will make exactly 5 loaves and the larger on the right will make 7. My largest tub will only take dough for 10 loaves, so the split is needed.

MultiseedHere is some multiseed in the mixer. I get the dough formed first, then add in the seed mix – I make it up myself and is a mix of poppy, linseed (brown and golden), pumpkin and sunflower seeds. I used to buy a commercial mix that included sesame but even though my labels were clear on what was in them, I decided to drop sesame a while back due to some very public issues involving a fatality due to a mis-labeled product. (Pret a Manger)

Wholemeal in the mixerLast through the mixer is the wholemeal. Here it’s had the initial mix and I’ve just thrown the salt into it. (It’s a bit of a wet mix, but not as wet as the rye!)

Rye in tinsWhile all the machine mixing is going in, I find a few moments to scale out the rye into tins. These stay in the fridge overnight and rise slowly there and are first in the oven in the morning.

dough in tubsThe dough is moved into the tubs as it’s mixed and kneaded and gets left there overnight. Now it’s clean and tidy the place up, have some supper and off to bed!

Dough has risenThis picture really belongs in the next post as it’s tomorrow morning, but I’ve put it here to compare with the one above. You can see how much it’s all risen. The left 2 tubs are the white olive oil dough and the wholemeal dough – these are both made with dried yeast, although only a fraction of what you’d typically use for a standard 1-2 hour process.

On to page 3, the bake!

Home Artisan Microbakery – 1/3

A few of you may know that I do the home artisan microbakery thing. My pages for that are over here: http://moorbakes.co.uk/ but in these posts I thought I’d show you a day in the life …

I make mostly sourdough breads for sale directly and in a few local community shops. It all started as a hobby, then developed a bit more as a sort of therapy to help with some health issues, then it got out of hand and I was doing afternoon teas for weddings, office party buffets, local farmers markets and I ventured into the lovely world of patisserie, however that all got too much and today I’ve scaled it back down a little so I can concentrate on other things – notably some IT projects, weight loss consultancy (to help others undo all those years of eating too much bakery goodness!) and give a little time to an older passion; horse riding (and perhaps more on that later)

All in a days work

A bake is split into three parts over two days – preparation of the sourdough starters, mixing the dough, then (the next day) the final shape/proof/bake.

Preparation

This starts mid-afternoon the day before the breads are baked. Clean and sanitise the work area and fetch the starters from the fridge.

Sourdough?

Sourdough is just a fancy name for a natural yeast culture. Some may suggest the name refers to the old “Sourdough Joes” who roamed the wild west, some may suggest it’s due to the presence of lactic and acetic (and maybe other) bacterias that come along for the ride giving it a midly sour taste and some may think it refers to a particular style of bread – whatever – to me, it’s just a natural, slow acting yeast.

I keep 2 different types in my fridge: A white wheat based one and a wholemeal rye based one. They don’t have names – they’re just my starters.

I measure them out into big bowls and add flour and water to make enough starter for that evenings dough mix. The jars are then topped up and left out with the big bowls until later that evening. This gives the left-over starter in the jars a chance to start again and get active and bubbly before being consigned to the dark recesses of the fridge until they’re needed again.

As I type this my starters are about 8 years old. Maybe older. I got the rye starter from someone who’d had it for 5 years and they got it from someone who’d had it for 20 years. What does that mean? Nothing really, only that we’ve been able to keep something going for all that time. I know that some people are proud of how long their starters have been living, but the reality is that it’s really “triggers broom” syndrome. All the living stuff reproduces and dies off in a matter of weeks, so it’s really unlikely that what’s in the jar today contains not a single molecule of what was in the jar when I started them. (And every now and then, I transfer some to a new, clean jar and the old ones go into the dishwasher)

Sourdough StartersThat’s the rye on the left and wheat on the right. The bowls are covered and left for a few hours and I get on with more preparation which involves weighing out the flour mixes for the mixing that evening.

All weighed outThat’s most of what I need for that particular evening. A batch of multiseed loaves, some white dough,wholemeals wheat  and my Moorbakes Sourdough. The rye flour, etc. is on-top of the rye starter bowl and I use shower caps for the other starter.

Milling RyeSpeaking of rye… I mill my own, and wheat sometimes too. I get organic rye (and some wheat) directly from local farms wherever possible. I use organic ingredients wherever possible, although thanks to a cartel of half a dozen or so “certifying agencies” in the UK I am unable to call my breads organic unless I pay them a lot more money than I’ll ever make from selling my breads, sadly.

So that’s about it, however on that particular day (it was a Wednesday) I also chop and grate some extra strong cheddar cheese for the cheese breads I make on Thursdays. Total time is about an hour, so now I clean any mess and get on with other stuff until later in the day.

On to page 2, the evenings mix and knead

Video Demos..

I’ve just watched Dave Murrays demo of his “Vera” video card moving some balls round the screen. Initially confused by how it was working, but now understand that it’s to do with the way the colour works in text-mode, so there is a separate “shadow” block of memory that controls the foreground and background colour for each character position.

So in an otherwise idle 10 minutes, for a bit of fun, I paused his video, looked at his code and re-write it to work in BBC Basic and ran it on my Ruby board:

I did it more out of curiosity and a bit of fun than anything else – I’m also experimenting with screen capture software, rather than point a camera at the screen.

the graphics are still generated here by sending commands from the Ruby board via the serial interface to the graphical terminal on my desktop (The ‘terminal’ is a C program using the SDL librarys running under Linux – it listens to the serial port and interprets the usual BBC Micro/Acorn MOS VDU commands)

You can see my source here: https://unicorn.drogon.net/balls.txt it should run on any BBC Micro. (and it’s not the best, but was done quickly – remember the fun part!)

Ps. If anyone knows anything better than “RecordMyDesktop” that runs under Devuan Linux then do let me know, thanks!

Pps. Yes, this is on my new 65816 board – more on that in a later post!

 

Ruby 6502 becomes Ruby 65816

Ultimately I wanted a 65C816 system but initially settled on the 65C02 for many reasons. One was that round about the same time another ‘816 project was announced (and subsequently a 2nd, and as of today a 3rd!) so I felt that getting back into the 6502 via my own board then buy into one of the ‘816 projects would be the way to go…

But things change. The first ‘816 system (Stefany’s Foenix) wasn’t to my liking, then the next one – Dave Murray’s Commander X16 has been changed to a 65C02 system. The last ‘816 system – Neon816 is somewhat curios, so I’ve decided to go with my own board for now, so to kick that off, I replaced the 65C02 with a 65C816 on my Ruby board. At the same time, I took the opportunity to make a few optimisations (ie. I removed some resistors that I don’t need because the ATmega host processor has internal pull-ups and with a few software tweaks there can eliminate some unneeded components.

Here’s a photo:

Rubt-816The Yellow LED is the E output from the 65C816 – On is Native mode, off is “Emulation” mode – which is how the ‘816 comes up at power on, so it can run all 6502 code at power up. (This is the default for all 65C816 systems)

Other than a few resistors I’ve removed – I had to add one resistor which goes on pin 3 which is the phase 1 clock output on the 6502 (which is never used in new designs), but is the /ABORT input on the 65C816 which needs to be pulled high. (That resistor is under the board, along with the LED current limiting resistor)

The flying wire is taking the 16Mhz clock from the 65C816 side into the ATmega side and one day I’ll buy more 16Mhz crystals!

(And yes, I’m running the 65C816 at 16Mhz)

So I’m now in the process of laying out my 65C816 board – it’ll be essentially the same as this, but with 512KB of RAM rather than 64K. It will take a 65C02, but that will only be able to see the first 64K of RAM. The ‘816 will be able to see the full 512KB. I have a new bus/IO system planned which I’m testing on the current Ruby board – watch this space, as they say…

 

Back to the main Ruby 6502 Index page

Microsoft BASIC (aka Commodore BASIC 2.0)

This is just a short follow-up to the last post; Comparing BASICs… There, I talked about the differences between BBC Basic and what was effectively a Microsoft BASIC (EhBASIC), however I decided to take a few moments and have a proper look at the published MSBASIC sources to see if I could make it work on Ruby.

And an hour or 4 later – yes. Success with the Commodore version 2.0 – obviously without the “KERNAL” part which is the Commodore equivalent of the Apple II Monitor or the Acorn MOS – what we might call a BIOS today.

The main thing that KERNAL gives a Commodore system (PET, Vic20, C64) is the screen handling – this lets you cursor up to a line, edit the line on-screen and simply hit the return key to (re) enter it into your program.

The MS sources have a simple line entry system with conditional assembly for the many different systems MS sold their BASIC to – some vendors changed it, some were supported directly. I changed it to use the RubyOS standard “getline” code which gives me line editing, history and easy access to the RubyOS star commands.

Character output was similarly changed to point to the RubyOS routines, however there appears to be some issues regarding CR+LF handling that I couldn’t quite get right, so I just edited the code to make it work.

This is MSBASIC level 2, assembled for a Commodore system running on Ruby displaying the MS “Easter Egg”:

Ruby running Commodore BASICI loaded and ran the same mandelbrot program as before – it took a few seconds longer than EhBASIC – I suspect due to it using a 5-byte floating point format, however it did work well.

Easter egg?

Microsoft added a little “Easter egg” into the BASIC 2.0 for Commodore – if you enter

wait 6502,1

then it would print MICROSOFT! on the screen. This didn’t work initially, then after wondering why it was crashing and after looking at the code I found that it poked the characters directly into screen memory – which is at $8000 in a PET, etc. … This is where I assembled the BASIC to load and run, so I decided to change the easter egg code to simply print it to the screen. A small complication is that it uses “PETSCI” codes which are obscured in the code to make it not obvious that it was there – I ‘fixed’ that for Ruby too. the ‘a’ at the end would be an exclamation mark on a real PET/C64.

Microsoft Source code

The sources for the 6502 version of Microsoft BASIC have been published for a number of years now and it seems that Microsoft aren’t doing anything about it, however that doesn’t mean it’s in the public domain, free to use and sell. Microsoft still holds the copyright to it so while I feel it’s fine for me to use it, adapt it for my own personal use, I’m fairly sure that if I tried to sell it I’d be in a somewhat sticky position, however if anyone else wants to have a look at the sources, then I suggest starting here:

Create your own Version of Microsoft BASIC for 6502

I created a new target for it, but used the CBM2 target as a template for everything to try to keep all the Commodore changes and features. (Such as the Easter egg) The one thing I’ve not looked at is the file handling and while I’m sure I could make it work with the Ruby Filing System, I’m not sure it’s really worth it for now. (And also, perhaps selfishly I am wondering why I want to use such a relatively primitive BASIC compared to BBC Basic)

 

Back to the main Ruby 6502 Index page