Wednesday 22 June 2016

Horizontal starfield in BASIC

Scrolly stuff is a bit hard in eight-bit BASIC, so of course it had to be tried.

Horizontal scrolling is an interesting case as the environment usually does not have special commands or ROM calls for that. Also, starfields are kind of easy/fake scrolling as there's no real bitmap or background to move.


Commodore 64

In the first version, I was silly enough to use dimensioned arrays and a FOR-NEXT loop for drawing the eight stars. POKE seemed slow in this context and I abandoned it for a while. The C64 BASIC does not have a LOCATE or PRINT AT command, so the horizontal/vertical coordinates had to be handled with the TAB function and/or character control codes. This means that for the speed of the program it is not trivial where the stars are vertically. I settled for 8 stars with one row between, filling about 2/3 of the screen.


I did know from experience that it is not necessary to test each star x coordinate every time the coordinate is reduced. After the eight stars are moved, only one of the star coordinates is checked. With stars it is acceptable if they disappear at a bit randomly near the left side of the screen.

For the second version, I unrolled the code and did away with the DIM at the same time. So each star has their own separate variable. Because of the single-star coordinate testing, the star printing is unrolled eight times, and after each printing only one horizontal coordinate is compared.

40 print chr$(19);tab(xx);"* ";chr$(17):xx=xx-1
41 print tab(xa);"* ";chr$(17):xa=xa-1
42 print tab(xb);"* ";chr$(17):xb=xb-1
43 print tab(xc);"* ";chr$(17):xc=xc-1
44 print tab(xd);"* ";chr$(17):xd=xd-1
45 print tab(xe);"* ";chr$(17):xe=xe-1
46 print tab(xf);"* ";chr$(17):xf=xf-1
47 print tab(xg);"* ";:xg=xg-1
65 if xx<9 then poke 1025+xx,32:xx=35

(repeated eight times, with the last line comparing a different variable)

I also tried to combine the character formatting codes and printed stars into one long line, but this was a bit slower.

By using POKE instead of PRINT "* "; statements, although previously unsuccessful, I could now get an extra bit of speed. The third starfield is faster, but it also flickers a bit. Possibly not so visibly on a tube TV.

20 poke ba,32:ba=ba-1:poke ba,42
21 poke bb,32:bb=bb-1:poke bb,42
22 poke bc,32:bc=bc-1:poke bc,42
23 poke bd,32:bd=bd-1:poke bd,42
24 poke be,32:be=be-1:poke be,42
25 poke bf,32:bf=bf-1:poke bf,42
26 poke bg,32:bg=bg-1:poke bg,42
27 poke bh,32:bh=bh-1:poke bh,42
29 if ba<1032 then poke ba,32:ba=1063

(repeated eight times, with the last line comparing a different variable)

One advantage is that the POKEd stars can be more freely located around the screen, but also their color is not specified and in principle the color memory could be pre-filled with interesting colors.

The alternative would be using a char display that is pre-filled with * and the POKEs would address the color memory.

A larger number of stars, or even a kind of parallax is also possible, but I want to keep the program version speeds easily comparable.

I used petcat (one of VICE package tools) to convert text files into a basic PRG.

All three starfield program versions are downloadable from here:

http://csdb.dk/release/?id=148877


ZX Spectrum

I could transfer the above insights into a finished result almost straightaway. The screen memory is filled with ****oooo---- type pattern and the attribute space is filled with black-on-black.

Then the POKEs adjust the attribute memory just as the Commodore 64 version used the character screen memory. This way it's possible to have some advantages of a character display on the Spectrum bitmap screen, as shown in many machine code demos and games.


I also tried a PRINT AT -based version that does not use POKEs. It might be just a tiny bit faster than the POKE-ing, but not enough to justify it.

Perhaps surprisingly, despite all the talk about Commodore Basic being slow, the ZX Spectrum version is not really faster. It's a bit difficult to compare through eye-ball judgment, but given that the Speccy screen is 32 characters wide and C64 is 40, one might even say the C64 BASIC is more effective here. Obviously this character-based starfield is not an indicative comparison of the two Basics overall, for example bitmap graphics is practically impossible on C64 Basic.

I used zmakebas to convert text files into a TAP.

Download the zip with the TAP and the text file from here.


MSX

I made a short attempt at replicating the approach with MSX basic, where I had to use a LOCATE/PRINT based approach as there's no real way to POKE directly to the screen.

I could not easily find an equivalent of petcat/zmakebas so I simply wrote the listing in an emulator. However I crashed my openmsx trying to save the machine state so the motivation for the project sort of dwindled. But what little I got did seem a little faster than the Spectrum and C64 versions. I could not really go into potential SCREEN 0/SCREEN 1 differences, though.

Saturday 18 June 2016

Round up: Commodore 64 Text editors and word processors

Some time back, I looked at my Commodore Plus/4 computer and the not that great built-in text editor. I began to wonder "what could be", and the result is a quick look at some Commodore 64 text editors. Well, for most part the programs are not that great, but there are a couple of surprisingly good efforts.

I was surprised to see how old most of these programs are, and thus the problem is not so much the C64 but the fact the programmers had not yet learned much. So perhaps it can be forgiven that around 1983-1984, when the Plus/4 features were decided, there were no great examples around.

This is by no means an exhaustive list, but rather an illustrative one. I've deliberately excluded one well known program, GeoWrite, because it is so tied to the GEOS setup. The desktop publishing software (!) Pagefox also includes an editor. There are also "conversions" of Vi and emacs I ignore for now.

I was mostly interested if the central "typing experience" was good quality or not. To use these programs at all in today's environment you'd need to be able to a) type quickly, b) insert effectively and c) scroll rapidly to view the document effectively. I gave these features a poor-ok-good-excellent ratings. I thought about reviewing the functions such as copy/paste, but they are sometimes a bit too difficult to find. And yes, I admit I did not use the real Commodore 64 to check these out.


Vizawrite

Looks more professional than most, with indentation and typewriter-style tabs and formatting characters. The cursor behaves pretty much as it ought to, but I could not find any proper insert mode to see if it delivers. At least there is the insert key and a means to "insert" typed text as a special command. The delete/move/replace/find functions are quite easy to find and operate.


Typing speed: Good
Insert: Ok
Scrolling speed: Ok


Speedscript

Speedscript looks like one of those desirable minimalist editors that might really work very well, but the basic program functionality is a bit erratic for today's typist. It's fast enough, though.


Typing speed: Good
Insert: Good
Scrolling speed: Good


Easy Script

Screen colors change from Control+1,2 and 3. Insert works pretty quickly, after setting the insert mode it works almost as you'd expect a modern text editor to work. It's slow at times, at least a bit when inserting carriage returns inside paragraphs.


Typing speed: Good
Insert: Good
Scrolling speed: Good


Paperclip

Not bad at all, but hampered by slow inserting of whole lines. Otherwise the insert works pretty well. Control+keys bring out features almost from every key, so I guess it's comprehensive. There's find and copy range type functions. F2, F4 and F6 change screen colors, a welcome addition.



Typing speed: Good
Insert: Ok
Scrolling speed: Good


Tekstinkasittely 80-400

An early Finnish effort with 80-column display. Don't be fooled though, the text has to be typed in line-numbered entities and even then it's pretty slow. I'd rather work my text in Basic REM statements.


Typing speed: Poor
Insert: Poor
Scrolling speed: Poor


TasWord

I think this originated from the ZX Spectrum, where a 64-column mode was very welcome compared to the standard 32. Here we have 80-column mode and it's surprisingly smooth. However text insertion does not work as one would nowadays expect, and inserting carriage returns inside paragraphs results in a long pause. There are different versions of this software, so perhaps some of them work better.


Typing speed: Good
Insert: Ok
Scrolling speed: Ok


Paperback Writer

An overall good show, I'm just wondering about that large help/options bar at the top. I suppose there would be an option to reduce it. But hey, the "on-line" help is very comprehensive compared to many others on this list. Inserting works semi-ok.


Typing speed: Good
Insert: Ok/Good
Scrolling speed: Good


Kwik Write

From Fairlight, a standard text editor, but boy is it fast for both typing and inserting text in-between. The basic text typing, removing and cursor motion is what one would expect these days, with no hiccups. The program also keeps track of how many characters of memory are left. I could even consider using it for some real text editing.



Typing speed: Excellent
Insert: Excellent
Scrolling speed: Excellent


Monday 13 June 2016

Apple Museum Prague


Somewhere in the most touristic arteries of Prague, there's the Apple Museum. How could I resist?
They have "all" Apple computers on display (expect that other Lisa).

Is it interesting? In some ways it's nice to see all the products lined up on tables, giving an overview on how the stylings have developed. The original iPhone/iPod, for example, seems quite clunky and not that different to other stuff on the market at that time. Also for a retro-head like me it's sobering to see how few late 1970s and early 1980s models there really were compared to the later flood of products. There's a few NeXT boxes too though they are not Apple products. Goes to show how Steve Jobs-oriented the display really is.

And that's about it. There's not much else to see except the casings of the products, little attention is given to how they work and what could be done with them. Yes there are videos and texts but it gets a little boring very quickly: speeches praising Steve Jobs' genius are blaring out of the speakers constantly. Granted, effort has gone in making the environment stylish. If there had been a museum shop (promised in the future) there at least might have been some books or gadgets.

It does make me think, how and why this place exists. It's a tiny step towards historicising Apple and Steve Jobs and attempting to codify Apple's success as the evolutionary survival of the fittest of home computing. On the other hand it's just another tourist trap "museum" in a city of "museums." (Beer/Torture/Sex Machine/KGB/Communism whatever) I'd give it a miss unless you already have a zillion other reasons to go to the neighbourhood.