"; */ ?>

ruby


19
Nov 08

ZX-Spectrum Child

zx speccy logoMy first computer book was “Basic for Children with Arturo”. It was 1989, the book was in Russian, and I was 10…

Back then, in USSR, to own a 8086 compatible PC was somewhat mystical, and therefore people, who knew a thing or two about microelectronics, were putting together Speccy(s) (ZX Spectrums), which were based on Zilog Z80 8-bit microprocessor and ran at 3.5 MHz.

The official ZX-Spectrum that was sold by “Sinclair Research Ltd” at that time was a bit pricey for middle class families, and therefore many cities across Europe and USSR started to come up with their own “clones“. There were over 50(!) semi-official clones that came out by the end of 1980s, beginning of 1990s. But to cut cost even further, people who knew “how to solder” created hybrids of the clones at home, which came out to be very cheap.

The process to build ZX-Spectrum’s clone’s hybrid was “a bit” involved, and included many days/weeks of hacking poor, incomplete electrical circuit documentation and sleepless nights of manual calibration of the hardware. The one had to “get” a ZX-Spectrum full circuit schema:

zx spectrum electrical circuit

Study it, change it to fit the budget. Go to several flea markets to first find a CPU, which was a quite rare find:

zilog z80 cpu

plus many more components: an empty electrical board, all other chip, transistors, capacitors, resistors, etc…

After some time and a combination of new ideas, documentation, hardware and labour, the one ended up with something like this:

zx-spectrum circut board

ZX-Spectrum keyboard had an interesting feature – pretty much every key, depending on the combination of special keys used, could represent 3-4, sometimes even 5 different things (commands/letters/symbols/special characters/etc). This made it much smaller (“compacter”) than for example PC keyboards:

zx-spectrum keyboard

And due to its small size, it most of the time served as a ZX-Spectrum case, and fit it the Speccy’s “motherboard”:

zx-spectrum under the keyboard

There were also some alternatives, and some people used “an extended” keyboards, but “a single key multi-purpose” pattern was still there. Here is a snippet of the Russian ZX-Spectrum keyboard, for example:

zx-spectrum russian keyboard

which is “a bit extended” – has a separate cursor, and some other keys. But take a look at the individual keys – due to the additional Cyrillic letters, “an average key” is now used to represent even more (+1) values.

At this point, when most of the work with oscillograph was behind, the only true way to see if the creation works was to see it with your own eyes. The word “monitor” in a sense of a “computer monitor” was not a widely used due to its price mostly, therefore most of ZX-Spectrum people used old black and white (at first) TVs. Speccy (well it’s clone’s hybrid at least) was designed in a way that it could be pugged into a regular TV Antena’s jack:

zx-spectrum hookup to TV

And due to the fact that family is usually more than one person, the main TV often was not used, and people used old TVs as a Speccy “monitor” instead:

zx-spectrum TV monitor

The whole process above was about 50% of the job – yea, just 50%. The other half was split on two. First quarter was spent in calibrating hundreds of little circuits, in order to get a sacred “© 1982 Sinclair Research Ltd” message at the bottom of TV (monitor):

1982 Sinclair Research Ltd

This message brought lots and lots of joy into families once it appeared on the screen. It meant a lot – CPU was working (so that guy on the flea market who sold it to you was ok.. sigh…). ROM was working (so that guy on the flea mark…). CPU and ROM were calibrated to work together, along with RAM and some other parts.

Usually the one plugged in Speccy to TV with no RAM/ROM/CPU at first, and calibrated all the circuits to reach a documented pattern on TV (for example small squares). After that was achieved, RAM/ROM and CPU were inserted one after the other by the same technique – each had to produce a certain visual pattern. So if all the parts were inserted and the message “© 1982 Sinclair Research Ltd” appeared, job was 75% done.

The last quarter was usually spent to tune all the parts to work as designed. Most of the time Speccy would restart in 3-4 minutes of use, just because something was “out of it”. To find that “something” was an art on its own. There was no Internet, no books or literature on this – it was pure work of art!

Fortunately my father is such an artist, and by the time I was 10, I got one of those Speccy beasts that my dad and I put together. The only problem though was that although it was designed to have 64Kb of RAM, it only had 16Kb. Well, 7 months later we solder more capacitors around 4Kb RAM memory chips, and that fixed it, but for 7 months I could not really play any games, because most of them required 64Kb to be there. Hence, the “Basic for Children with Arturo” book did not get a chance to get too dusty…

Where ZX-Spectrum shined the most is of course boot time – there was none :) Well, everything was in a ROM chip, including Sinclair Basic.

So having spent about 4-5 months to build Speccy, I was out of luck, and could not use it. Well, that is how I saw it for the first one or two weeks. But then…. I pressed a “p” key, which by default was a Basic “print” command, and then…. I typed what was on my mind: “I want to play!”, and to my astonishment Speccy “said“: “I want to play!”.

It is probably hard to surprise anybody right now by the fact that computer prints something on the screen, when you ask him/her to, but for me, being 10, and haven’t seen anything cooler than that, it was the biggest technical discovery of all times. I picked up my Basic book, and started to type, and type, and type, and then…. type a little more. That is how I started. That, in programming sense, makes me a “Speccy Child”.

A program in Basic in Speccy looked something like this:

zx-spectrum Sinclair Basic

where every line had to have a number, and the usual increment was 10. Quickly my favourite commands became “peek”, “poke” and “randomize” which worked directly with the memory (absolute addresses). And although I felt like a memory King, something was missing. I figured out what it was after I bought a system program that exposed me to something much more powerful than Basic – it was 8-bit Assembly language, the language that Zilog Z80 talked natively. Therefore me together with Z80, could control pretty much everything in the Speccy kingdom. That was awesome!

Here is an example on how you’d print a line of text to the screen in Speccy’s native language:

zx-spectrum z80 assembly

Cool – huh!? Another thing that was very useful at the beginning of my Assembly journey, was a documented character table ( like an “ASCII” ):

zx-spectrum ascii table

The only problem was that in order to work in Assembly, or in any other language, or with any other system program – it needed to be loaded since it was not in RAM/ROM – and that took time. No, really took time. It needed to be loaded from a tape – a regular cassette that is used in a tape recorder. In fact these very tape recorders were used to load all these neat programs in:

zx-spectrum tape

But not only it did take time to load, it was a constant pain to tune the head of the tape recorder for each tape bought on the flea market, since nobody followed the recording standards. A lot of times, you would have to sit and hold a screwdriver against the recorder’s head for 3-5, even 10 minutes, depending on how big the program was.

Here is what the screen looked like when the program was loading from tape into RAM. You can see the zebra looking lines, they were the moving loading indicator:

zx-spectrum loading screen

But time went, flea markets grew along with demand, and we upgraded to the real “RGB deal”. It was done by soldering an external controller (kind of like modern video cards, but not really) that had an RGB jack:

zx-spectrum rgb jack

Although it had 9 pins, only 5 were used: Red / Green / Blue / Sync / Ground. But we did not stop on this. Soldered another external controller, but this time for a disk drive! Oh yea – that was a huuuge deal. Looking at programs to load for seconds (well in rear occasions minutes) from these beautiful 5 inch disks!

Since we had a disk drive, Speccy needed to catch up with us, and the disk controller brought another cool thing, which was TR-DOS, where, of course, DOS stands for Disk Operating System. That is how pretty it looked:

zx-spectrum tr-dos os

Did you notice some colour? Good catch :) So now it was possible to actually browse the disk, and start programs with a button click. There were tons of system utilities with different browsers that you could start at the start up time (sort of like in MBS, but not).

Right after TR-DOS, I felt like I need more. I need more.. I need more.. RAM! And we soldered another level of RAM on top of 64Kb chips. So now my Speccy was equipped with 128Kb of RAM, which could free up some ROM real estate, which enabled ROM to fit a little menu on startup:

zx-spectrum 128 menu

At this point not only I could swim in the Assembly language ocean, but also play games, and use various utilities!

First let’s look at Photoshop:

zx-spectrum artstudio

well, maybe not the Photoshop you’re used to see right now, but Art Studio rocked! I was drawing away for hours!

Now, how about CuBase/ProTools:

zx-spectrum wham the music box

well, maybe not exactly the latest CuBase, but I wrote lots of tunes in Wham. Some tunes I actually recorded along with playing a real guitar – it was cool!

As to games, my favourite control was my keyboard, but for many friends that came to play, I bought a joystick:

zx-spectrum joystick

Now we could play multiplayer games like:

zx-spectrum match point game

Match Point (Tennis) or:

zx-spectrum fist game

Fist (Karate) game. Or even:

zx-spectrum tetris2 game

Tetris2 – which was a bit different from the regular Tetris in a way it gave different patterns and challenges on different levels, and was also a multiplayer game, which was of course cool.

There were tons of other games, but two I still remember are Robocop:

zx-spectrum robocop game

and Bomb Jack:

zx-spectrum bomb jack game

I could play long long time in Bomb Jack, not longer than I spent writing my own little games in Assembly language of course, but still – it was good amount of Bomb Jack time.

All the above was of course some time ago… 25, or even soon 30 years. Everything is a bit different now. Speccy lives somewhere in museum behind the glass:

zx-spectrum in museum behind the glass

But I remember him/her – those were times of big discoveries for me!

Like probably right now for some other 10 year old kid who just accidentally pressed a “p” button, and discovered….. time traveling…

Good luck to you kid!


2
Aug 08

Make rails.vim Work: Compile VIM From Sources

rails.vimEver heard about rails.vim project? “Accept no imitations: rails.vim is the one true Vim plugin for syntax highlighing, easy navigation, and script invocation for all your Ruby on Rails applications, transparently and unobtrusively” says creator Tim Pope.

The very good “rails.vim” guide can be found here or just by reading project’s vimdoc here.

PROBLEM:

There is however one gotcha for Ubuntu Hardy Heron lovers (or other modern Linux distros). Using rails.vim would result in VIM “segmentation fault”crashes similar to:

Vim: Caught deadly signal ABRT
Vim: Finished.
Aborted

REASON:

This is due to the fact that a packaged VIM that comes from some Linux distros repositories has old patches.

SOLUTION:

One of possible solutions would be to download most current VIM sources from http://www.vim.org/sources.php and compile/install it manually. Below is how it is done on Ubuntu (but should be pretty similar on any Linux distro):

1. Get vim sources:

wget ftp://ftp.vim.org/pub/vim/unix/vim-7.1.tar.bz2

(where ‘7.1’ is the current VIM version at the moment of writing)

2. Unpack it

tar -xvjf vim-7.1.tar.bz2

3. Install terminal libraries (vim needs them to compile correctly)

sudo apt-get install libncurses5-dev

4. Configure / Compile / Install

./configure --with-features=huge
make
sudo make install

5. Point your system to newly compiled VIM:

sudo rm /etc/alternatives/vi
sudo rm /etc/alternatives/vim
sudo rm /etc/alternatives/vimdiff
 
sudo ln -s /usr/local/bin/vim /etc/alternatives/vi
sudo ln -s /usr/local/bin/vim /etc/alternatives/vim
sudo ln -s /usr/local/bin/vimdiff /etc/alternatives/vimdiff

DONE


30
Oct 07

How to Build DIGG in Ruby On Rails (Free Book)

    I’ve been playing a lot lately with RoR (Ruby on Rails) and of course I love DIGG, hence I was very pleased to stumble upon a very interesting work by Patrick Lenz, which is a definitely cool and enjoyable free book (pdf) on how to build a full blown DIGG in Ruby on Rails from scratch!

    I spent a couple of hours reading and trying, and I am already (!) building the app (or should I say building the DIGG) at this point of writing this post. The book uses Web 2.0 approach which covers a lot of Web 2.0 along the way – very cool! I highly recommend it to anybody who has the same passion, since it really is an awesome read!

    Please hurry, as this book is only free (since the moment of me writing this) for "32 days, 14 hours, 21 minutes, 49 seconds" more, and I guess will blend in with many other books that we have to pay for once the time is up (currently it is $26.37 at Amazon).

    For something "not very free", but "the best" on Ruby on Rails, there is another great book "Agile Web Development with Rails, 2nd Edition" that can be obtained, well, same place all other "not very free" books are obtained :) here.

    It is not in any way an intentional advertisement for any of the links above, I am just so exited reading it, that I could not stop my self from sharing with the rest of the universe! ;)