The BASIC Issue with Retro Computers
hackaday.com
hackaday.com
https://sourceforge.net/projects/brandy/
(Also in Debian.)
BBC Basic is one of the best BASICs ever, featuring things like named procedures with local variables, structured programming, etc. Basic V, which Brandy simulates, is effectively Comal.
But you don't have to use any of that stuff if you don't want to, and all the old favourites like GOTO, GOSUB, ON GOSUB etc still exist. (Along with a handy RENUMBER command for when you run out of space between lines 140 and 150.)
I recently found an ancient program I wrote as a teenager in BBC Basic II --- I'd submitted it to a computer magazine to be printed in an issue (and then they rejected it). If you want to know what BBC Basic II looks like, here's an example.
http://cowlark.com/2015-02-03-bbc-micro
Edit: cut-n-paste tyop.
Found this in the article comments. What happened to the BBC BASIC language? Is it still available, in source?
It was created by Sophie Wilson FRS FREng, while at Cambridge as a student over a summer break on a 6502 micro processor. Wilson also designed the Acorn System 1. [0],[1] Also a portable C version of BBC BASIC is available. [2]
[0] https://en.wikipedia.org/wiki/Sophie_Wilson
[1] https://en.wikipedia.org/wiki/Acorn_System_1
[2] https://en.wikipedia.org/wiki/BBC_BASIC#cite_note-11 and
https://www.raspberrypi.org/blog/risc-os-for-raspberry-pi/
I think you hit F12 and then type 'basic' (no quotes) at the prompt to get to it.
Basic V was a complete rewrite for the ARM. In hand-tooled ARM machine code, also by Sophie Wilson. The source for this is available from the CVS archive here: https://www.riscosopen.org/content/downloads/cvs-access But trust me, it won't help. I've debugged my way through it. It's very... hand written.
Oh, yes: there are also ports of BBC Basic IVish to the 8086 and the Z80 by R.T. Russell: http://www.bbcbasic.co.uk/bbcbasic/bbcbasic.html He wasn't associated with Acorn, as far as I know. The 8086 version (for Windows and DOS) is commercial, but the Z80 version (for a variety of CP/M machines) is a free download. Not open source, unfortunately. His version even includes 80186 or Z80 inline assemblers, depending on the version. His Z80 port was licensed for a variety of machines --- Amstrad made a range of Z80 notebooks with his Basic in ROM. I've used all his versions, and they're superb.
First computer ZX80, so I missed the BBCM.
Thx @David, the reason I asked was I was interested to see ^how^ it was written, but probably more to the point, what made it good? Sounds like speed was a loved feature. Was there ever a API or documentation made public?
Reason: want to hack a language together a BASIC-like language (are of use) for graphics.
One of the coolest ones was AMOS for the Amiga.
http://acorn.huininga.nl/pub/docs/sourcecode/Acorn/BASIC%202...
AFAIK there wasn't anything particular magical about it --- it was just written well, with great care. Programs were stored in tokenised form, where each keyword was reduced to a byte, and line numbers in things like GOTO statements were stored preparsed, but execution happened directly from the tokenised form. Named procedures were faster than GOTOs because the interpreter would cache the address of the line where they were defined, while GOTOs would have to search for the line; variables were stored in a hash table; there were two stacks, one for GOSUBs and one for PROCs (the GOSUB stack was much smaller!); there was a superb 5-byte floating point library...
It's also worth mentioning that Acorn's MOS was in a different ROM, so it didn't have to share space with Basic. The two communicated via a system call interface. I've seen people run BBC Basic on entirely different 6502 machines by reimplementing the system call interface.
I would not recommend writing this style of Basic if you want a simple language these days. Basics are a nightmare of ad-hoc parsing with too many edge cases. Better to write a modern byte-compiled language with a byte interpreter --- you'll end up with something much cleaner and easier to understand. We're not all Sophie Wilson.
thankyou for these suggestions.
"We're not all Sophie Wilson."
agree, very talented individual.
The other variation of BASIC I used a lot in the 80s was Microsoft BASIC on the Commodore 64.
dim personalopinion$ = "Frankly I think the C64 was over hyped. Sure it had the popular MOS 6510 rather than the Z80 as used by the BBC Micro and Amstrad CPC range, but the Amstrad CPC had a more vibrant display, built in cassette player and, most importantly to me as a programming kid in the 80s, a far superior port of BASIC than Microsoft BASIC was."
Coolest thing about those books is they're up on archive.org just like the article's BASIC books.
Now... one thing to realize is bits cost money back then so self modifying code was "clever" not insane. And an old timer having maybe two whole years of experience meant that the code probably looks extremely amateurish today. But, it worked, and back then the only way you got to patch bugs was to sign a contract for new masked roms and then physically install them, in other words it didn't happen, so its a good thing we only had 4K eproms and so on because that's only 4K possible things to be a bug, um, sorta. Kids these days don't realize in the old days software was like un-upgradable firmware today. Some dude screws up the key debounce routine in the rom of your TRS-80 model I, well you better like it that way, or like patching manually after very reboot...
Something I was just thinking about today is noobs today must have it extremely rough being dumped into advanced data structures and RTOS and interrupts and multithreaded programming and GUI interfaces right at the start. In the old days life was easy because stuff you wouldn't understand as a noob didn't exist, or at least you could mostly ignore it. Nobody got confused about MALLOC memory on a TRS80 until they knew what it meant and why they wanted it because it was a model 3000 running linux 1.0, but in 1981 the whole topic couldn't confuse noobs because it wasn't there.
And I should know, because I was one (although I learned python, and never got into the graphics stuff).
but maybe you were thinking of Xenix on the Model 6000? The 6000 had a System3 variety of Xenix with the Z80 as an I/O controller and a Motorola 68K as the CPU.
https://www.theguardian.com/technology/2016/feb/10/programmi...
In addition, I wrote an article for Commodore Disk User on interrupt requests some 25 years ago and was pleasantly surprised to see that the magazines are available on the Internet Archive:
http://alblue.bandlem.com/2012/04/first-published-article.ht...
I loved to get Usborne books as presents or go to the library every week to see if they had any new ones. Still have a few, including one which I couldn't see on the website. Maybe I'll check and email them about it.
I was at the computer museum in Swindon (UK) last week. It's a small museum but they have among other things a couple of Sinclair machines and a C64 set up for people to play with (type in BASIC or load games from tape/disk/cartridge). I attempted to type in a simple program to draw a coloured pattern onscreen from one of the books provided, but I'd forgotten how to type some of the Spectrum's more obscure shift-keyword combinations and after 30 years of progressively nicer IDEs the 48k BASIC editing interface was quite frustrating. Still, good for nostalgia.
Would recommend to micro nostalgists if you're in the area, although it's possible to look at everything they've got within an hour so probably not worth driving much more than that for.
(I suppose I could donate my Usborne books and magazines - if I could bear to part with them...)
Just the eagerness to get your hands on a computer is hard to describe today. Studying the ads in magazines. Hanging around electronic stores. Riding bikes miles to friends who were more fortunate. Even today looking through an old Byte magazines at obsolete hardware almost has me salivating.
I know that today there has never been more capable hardware, more available, more affordable and with the level of help and documentation that we have on the Internet. But it is still hard to let go of the 80s. It was a time when kids with no Internet or peers to help would spontaneously disassemble ROMS and hand code asm. I had two television channels which played no more than an hour of content a day of any interest and the only console game we had was a Pong made from a kit. Although the primitive nature of old computers helped their learnability the lack of distractions was also helpful.
Hope that helps.
If you don't know, 0x10c is a (semi-famously) aborted game project by Notch, which was was known for its 8-bit DCPU computer, which would control your spaceship. Techcompliant seems to be one of several continuations of the concept.
I'm pretty sure Project Trillek is the most active continuation project, but this also seems worth looking at.
Until they're done, though, you can pay TIS-100, or backdate your mincraft to 1.2.5 and install RedPower2. Or you can wait for RedPower3, the game of that mod, which goes in a similar direction.
My family bought a 48k ZX Spectrum for Christmas one year, and the tape-deck didn't work. So no games for my sisters and I. Instead I started programming via the orange programming guide/documentation. My sisters lost interest until we could get a working cassette player a few days later.
From BASIC to z80 machine code - again via the documentation - was a great start.
...Which is why I'm building a Z80 machine. It won't be complicated (no monitor, just a DB9 cable connected to a Z19 (and yes, I have a Z19: my father's actually)), but it will be programmable from the ground up. It will be something that I can learn from.
But no way am I implementing BASIC. Sorry, it's complicated and not actually all that good a language. So I'm implementing FORTH. Simpler, and the stack might be a pain, but I'll learn something from that, too.
Forth's a good choice, and will teach you lots of assembly, but it's not really a compiler, and Z80 Forth's been done to death.
But... and I should point out that where I am it's half past midnight and I'm going weird and random... if you want an off-the-wall but useful language to do an actual compiler for, you might want to check out B. It's like a typeless simplified C (although it's really the other way round), and is eminently suited to tiny architectures.
Tiny example:
http://www.99-bottles-of-beer.net/language-b-1247.html
x86 B compiler written in C, containing links to the language reference:
The Z80 itself's been done to death. If I wanted to go super far off the beaten path, I'd build a 6809 computer (something I actually do want to do, but it's hard to get 6809s). But this is good, because I can base it largely on other's designs, which helps me get to the software bit faster (which is the part that actually excites me), although I will have to make some modifications. This is also good because I suck at electronics. Hopefully, I may suck a bit less by the time this project is done, but that's not the point, really.
But yes, a B compiler might be fun. I'm sure I can at least take it as far as assembler. Mind, it will probably suck, but I'm fairly confident I can make it work.
Provided, of course, that I put in the effort, which isn't a given: a lot of what I set out to do doesn't happen, because I got distracted by something else. The comparison to Leonard of Quirm is obvious, but unfair: he's a genius, and fictional: I'm real, and no genius, just easily distractable.
Re Forth, you might be interested in this:
http://fruttenboel.verhoeven272.nl/Langs/ace.html
It's an annotated disassembly of the Jupiter Ace ROM; the Ace was a ZX80-like Z80 machine which was unique among the 8-bit computers in that it had Forth in ROM rather than Basic. It's a beautiful implementation, and includes everything from keyboard mapping to the character generator to an interactive Forth sort-of-IDE.
Also, there's no modern 6809 variant? There ain't no justice.
As for the 6809, it was out of production for a while. But allegedly, Rochester Electronics is making new ones now. They even seem to have them, if you look on their site. However, they won't sell them to you.
AFTER you finish your z80 thing, of course.
But neither of them really scratch the 6809 itch: They're closer to the 6800 and the 6502, whereas the 6809 was closer to m68k.
(define (square n)
(repeat 4 (fd n) (rt 90))
)
(square 50)Do you want to implement GC in 64k?
Also, I don't know compilers super well. And you have to know compilers to actually write an efficient lisp. I plan on learning that, at some point, but while I'm also writing an OS (or at least a monitor) for a Z80? Nope, forth it is.
How about that IBM 704 from which we have the terms CAR and CDR?
"The 737 Magnetic Core Storage Unit had 4,096 36-bit words, the equivalent of 18,432 bytes and served as RAM."
[Wikipedia]
Besides, the 704 had some helpful features the micros didn't. Also, it was a 36-bit machine. That's a massive advantage.
The heap consisted of fixed 4-byte cons cells (2 byte car, 2 byte cdr). The cdr value was assumed to always be a pointer, which meant that since the cells were aligned at a 4-byte boundary, I had a few spare bits to implement mark-and-sweep GC and track which data type the car value was (number, atom, list or function).
Edit: I got curious and dug up the code. The entire GC code is less than 100 lines of Z80 assembler (admittedly some of the hairiest code in the interpreter, though)
The other problem becomes space efficiency, but that's not unsolvable.
Why not? The IBM 704 had around 18k and yet it was good enough for a full Lisp system.
Sometimes I think that people don't really grasp how constrained the computers using Lisp, Smalltalk and memory safe systems programming languages were and yet those systems were already there running, being used to doing actual work.
Somehow C's adoption has created a strange distortion of what those computers were actually capable of, in spite of their resource constraints.
Still, I might give it a shot. Once I get the damn thing working, that is.
(I started on ZX Spectrum in late 80s. If it had Forth, it could fit twice as much stuff into its ROM than it actually did.)
But, we live in a world where Javascript is having Haskell for a dinner. So I am not really sure why I am surprised.
(On the other hand, at least Python is a decent language, even though Lisp should have won in that particular space.)
Funnily enough the most I've ever played with FORTH was inside of Minecraft on an in-world computer:
I also played with FORTH mostly in Minecraft Redpower 2 (but before that I also read Jones Forth, which is excellent), unfortunately, to prove my original point, people didn't like it and longed for BASIC.
Sadly, RP2 is dead, and with it the RP2 computer model, the likes of which will likely never be seen again (for those not in the know: most mincraft mods adding computers of some sort essentially allow scripting in some HLL, and maybe a primitive DOS-style prompt, akin to ComputerCraft. Not so in RP2. RP2 computers were actually full emulated 6502s, with a FORTH monitor built in (although you could, of course, write your own). This should give you an idea of what made RP2 so special). Except not quite, because Eloraam is now working on RP3, which will actually be its own game, because she got sick of putting up with MC's limitations. Knowing Eloraam, it will be done by 2030.
* https://github.com/freebsd/freebsd/tree/release/11.0.1/sys/b...
Some people want to replace this with Lua.
I started on the VIC-20 (for which I traded in my old, but working Fairchild Channel F, Doh!) and then moved up to a C-64. One of the first games I had came on cassette tape, was written in basic and at a certain point... you'd hit a syntax error... fixing that bug was my introduction into programming in early Junior High School. And to the point of those opening paragraphs, I remember the Programmer's Reference Guide for the C64 included schematics for the computer.
The limited nature of the BASICs that came in ROM also very much forced me to learn fundamentals of computing that I appreciate to this day. If you wanted to draw circle on the screen you had to perform bitwise operations with the screen memory using "PEEK" and "POKE"; there were no fancy "CIRCLE" or "DRAW" commands. At the time, my friends had computers that could do those things, but the extra effort with my computer had pedagogical value that continues to pay dividends today.
In a similar vein, the first games for my Apple II were in Basic on tape, and I figured out how to cheat at them by changing parameters in the code.
There's even a new version of the ZX Spectrum on it's way. http://www.specnext.com/
I guess things really don't change.
Except now you have to buy it piecemeal.
It wasn't much code but you had to write a one-liner at least:
LOAD ""
Then you figure, "What other stuff is there?". Oh you could modify memory to get infinite lives in games and such so you find out about PEEK and POKE. You could go as advanced as you wanted. Wrote my own assembly interpreter. There was a C compiler, a Pascal one. If it crashed, had load everything from tape again.I remember writing and selling my first program when I was 13. My friend's dad ran an semi-legal broadcasting company showing dubbed American movies to a few apartment blocks in the area, so I wrote a program to display the schedule and movie summaries before movies started. As payment I took a cassette tape with music on it, probably something like 2Unlimited or similar ridiculous thing. No regrets though...
I got my start on the ZX Spectrum, as you say hacking games for infinite lives. First of all cracking the tape-based protection system (bleeplock, speedlock, softlock, movieload etc), then the games themselves. I guess I was lucky in that a lot of these protection systems were evolving as I was working on them. Jumping in to the more advanced system without having experience of naive protections that were available even six months beforehand would have been impossible for me.
RANDOMIZE USR 0
Also come to think of it, my ZX Spectrum (a Soviet clone of it really) was probably the reason I learned English. All the games and programs were in English, wanted to devour all that info so I learned a new language as a side-effect.Outside of high-speed games, the principal complaints that people had back in the day with running BASIC programs had very little to do with the execution speed and more to do with the memory, tooling and display limitations of the platforms they were working with.
It's a great miracle that now, in the modern age, we've managed to build up such intense piles of abstraction that it's not unusual to see a machine capable of billions of operations a second perform as fast as a machine capable of millions of operations a second that was also running BASIC code.
1) Program in BASIC--realize that you can't do everything that other programs can do
2) Program in BASIC with Peek/Poke and USR()--realize that you still can't do everything that other programs can do
3) Program in Assembly--realize that you can now do everything other programs can do--and programming is painful.
I was lucky to be on a TRS-80 Color Computer and had William Barden producing excellent books and articles for it.
https://archive.org/details/Color_Computer_Assembly_Language...
I also remember "leveling up" going from edtasm cartridge pack to Microware OS-9 and being pretty well blown away, like today going from edlin or GNU-nano to suddenly emacs. Whoa...
So far, I haven't done any Z80 or 6502 programming.
And as much as I love the 6809, I'm super happy to ARM machines to play with now.
I never managed to get money for an Assembler for the Timex 2068 I had.
By the time I could afford them, I was already using a PC.
... years later I figured out they were coding internally every basic keyword into a lookup table, thus saving your precious 64kb of RAM. The Spectrum did the same, but they didn't have to parse the strings: you had to type the correct key combination to actually write the sentence (does anyone remember spectrum k,l,c, and e cursor modes?)
I miss my Amstrad.
This is so, so true. I cannot even imagine such a book for kids or even teenagers now. Something was lost when computers became powerful and boring.
I don't know if I'll ever manage it, but that's not because it's too hard, it's because I famously never finish projects.
I mean, seriously Intel. Memory Segmentation? Yuck. And that's just the tip of the iceberg.
-Simplicity: The Z80's instruction set is dead simple, and thus easy to wrap your head around.
-Availability: Z80 chips are dirt cheap (and if you want to build a computer around it, designs are readily available).
-Ease: As a new assembler programmer, Z80 assembler is considerably more high level than, say, 6502 assembler.
-Other Factors: GBZ80 is hugely useful, especially to me, because I've got a Gameboy.
Some of those other architectures are on my list as well. Like m68k (and its cousin, the 6809): if only I could still buy the chips. 6502 isn't on your list, but it's on mine.
Also, ARMv4T, for the ARM7TDMI: GBA hacking could be fun.
Example code : https://github.com/Zardoz89/trillek-firmware/blob/develop/bo...
CPU : https://github.com/Zardoz89/trillek-computer/blob/master/cpu...
oh my god, they're still working on it!
Well, this is very exciting.
But yeah, GBA coding is also cool.
Not like the great idea from Google to do AOT on the device itself, which was so good that had to create an hybrid solution on Android N.
I would gladly switch to a platform other than android for my smartphone, but as bad as Android is, everything else seems to suck more.
I got some knowledge from one of the Norton's book.
Segmentation still sucks, though.
And remember this, always: old computers never die. Their users do!
Ironically, this is what hackers from the world of Big Iron (MIT LCS, MIT AI, and MIT MDL (much of which would later become Infocom's Imps and hackers), most famously) said to micro users at the time.
What an irony, that HN is full of kids who grew up on Micros, and yet the culture is a direct descendant of the LISP and UNIX lab cultures of old, whose hatred of micros was legendary.
I really don't know what else to say.
https://www.youtube.com/watch?v=H1p1im_2uf4
https://www.youtube.com/watch?v=MWdG413nNkI
Piece de resistance: https://www.youtube.com/watch?v=gdb3AQ14iVc (live cheering FTW) / https://www.youtube.com/watch?v=hNRO7lno_DM (capture card copy)
The credits in the 3rd video are an excellent example of using modern tooling. (How this was done has been documented online and is easy to find; it did take some cheating to do it but it's still awesome.)
Hrm, the SID music in https://www.youtube.com/watch?v=-mgtY2326Y0 is also amazing (this demo was on two floppies, I particularly like the music in the 2nd part which uses a distinctly different theme) and very obviously produced by modern tools too. (Note, that video is a 50fps capture and uses a real SID.)
My favourite aspect of the modern 8-bit movement is watching the development of this Blakes 7 game for the Oric-1/Atmos games .. we Oric nerds are getting some real treats these days, which seem to really push the machine beyond what we expected in the 80's, and that is surely nice. Just check out the smooth animation and clever use of colours in this demo, for example:
https://www.youtube.com/watch?v=OskowiQuDzQ&t=39s
Interesting note: OASIS is the game/script/content engine created for the purpose of making games like this on the Oric systems. How amazing we have such tools for such an obscure device, even today!
That demo looks pretty cool and rather refined, yeah - the colors are indeed well-balanced. The galaxy sidescrolling does appear to be pushing the machine's limits; with that in mind the mouth animation is very smooth. I'd admittedly add at least one extra mouth-movement frame and randomly switch between them for more realistic lo-fi animation, I'd make the text sequences advance about 25% faster, and I'm not sure if the text was traditionally at the top but I kept looking for it at the bottom (where subtitles/closed captions usually live).
OASIS sounds interesting, but I'm unsure where to find more info on it. Very amusingly, when I googled "oric-1 oasis", your comment on here was among the search results! http://i.imgur.com/4HUICdo.png
Also, for other interesting things that fit in 1MHz: https://www.youtube.com/watch?v=QUN5CSWiLaw
OASIS Info here:
I then started looking at what i386/AMD64 assembly looked like to teach myself that, and quickly decided to back away :)
LET PLANET1$ = "Earth"
LET PLANET2$ = "Mars"
LET PLANET3$ = "Venus"
...
LET PLANET45$ = "Sirius"
And rendered its amazing 16-color EGA screens like this: PSET 0, 0, 7
PSET 1, 0, 5
PSET 2, 0, 6
...
PSET 200, 150, 5
Drawing those pics required some patience for sure. After all that effort, I had no idea how to make them move.The days when it was possible to learn and memorise the entire built-in library of a programming language. I never did work out how to implement a linked list in Amstrad BASIC though.
As for the modem slot, it was quite common to have dial-up BBSes at the time. You can probably imagine.
Wait, what computer were you even using?
Also, the movie "23" has some very accurate depictions.
ps: oh you meant http://www.imdb.com/title/tt0126765/ not "number 23" .. interesting.
Early on, connection speed was 300/300 or 1200/75. Later I ended up writing my own terminal program, because I picked up a 2400 baud +compression modem from somewhere, and none of the existing software was fast enough to do the resulting speed of 4800 baud without dropping characters. To get the speed it had to talk directly to the UART in the serial interface, and then write the bitmaps directly to screen: no firmware calls anywhere, they were too slow. Heady days.
FWIW I don't think any of the 8-bit Amstrads came with a built-in serial port. But they were certainly available as add-ons for both the CPC and PCW.
Got me to do a little youtube digging : https://www.youtube.com/watch?v=3WPMq80wYFY
(See also TESsa COhen.)
If I got access to something like Stack Overflow back then I think I would have fainted.
Guilty!