Sunday 17 February 2019

Linux, Rasm, Arkos Tracker 2, ZX Spectrum

Looking at a promising recent z80 cross-assembler and Arkos Tracker 2. Both work on Linux and there are now easy-to-use music player routines for ZX Spectrum included.

The assembler compiles the player routines without any modifications so it made sense to me to lump my notes together here.

It couldn't get much easier for the Linux user I think!


Rasm

Rasm is the z80 cross-compiler. (The R stands for Roudoudou I suppose). Download the Rasm archive, extract it to a folder.

Look for the compilation instructions inside the c file, something like

cc rasm_v0108.c -O2 -lm -lrt -march=native -o rasm

(Edit 30.8.2022: These days make seems to work as it should. If compilation stops at stdio.h or string.h, may need sudo apt install build-essential before attempting.)

After copying the output rasm to say /usr/local/bin, you can then use rasm inputfile.asm to produce an instant binary from out of the source.

The inputfile.asm contents might be something trivial like this:

org $8000

ld hl,#4000

loop:
inc a
 inc l
ld (hl),a
jr loop

This should fill the top third of the screen with garbage.

The black screen comes from the bin2tap BASIC header
When the binary rasmoutput.bin (the default name) has been created, it still needs to be converted to a TAP file that a Spectrum could load.

Using the bin2tap (need to compile that too) you can create a runnable tape with a BASIC header. By default it works with the $8000 (32768) address so no need to worry about that either. Again, it ought to be copied to /usr/local/bin (for example).

Then, working with the default output binary name:

bin2tap -b -o mycode.tap rasmoutput.bin

After this, Fuse will happily load the produced mycode.tap and use the BASIC loader to load the binary and execute it at 32768 ($8000).


Rasm is a clever modern macro-assembler with all the repeat functions you'd expect nowadays. With a good editor like sublime-text (with added z80 highlighting) it's a breeze.

For example, the following will generate a table of 192 start addresses for each vertical pixel row, often needed in ZX Spectrum graphics routines:

screenbase=$4000

ytable:
repeat 3,yblock
repeat 8,ychar
repeat 8,ypixel
dw screenbase+(ychar-1)*32+(ypixel-1)*256+(yblock-1)*2048
rend
rend
rend

Using variables, evaluations and local labels inside repeat blocks even quite complex repetitive code can be generated.



Arkos Tracker 2

More information about Arkos Tracker from here. Extract the archive and simply run.

I'm not going too deeply into song creation here, suffice to say this is the easiest cross platform 8-bit tracker I've seen, with an audible default instrument and preset instrument categories for bass, snare etc.

After the pattern has been filled with bleeps and bloops, you can export the creation from the menu option file/export as generic (AKG), choosing source as the export mode.



Pick the PlayerAkg_SPECTRUM.asm from the players/playerAKG/sources folder, and copypaste the contents to the end of your source.  (Of course it would be a better practice to include the player routine and the song.)

For example, this is a minimal main loop that will HALT the Spectrum until the next frame, and call the 'play frame' portion of the player routines.


org $8000

ld hl,Songname_Start
xor a
call PLY_AKG_Init

loop:
halt
call PLY_AKG_Play
jp loop

; paste the PlayerAkg_SPECTRUM.asm contents here

; paste the Songname_AKG.asm contents here


The exported song source can be copypasted after the player source. The Songname obviously refers to the filename it was exported with.

The start address is not needed so the org line may need to be removed from the song source. As can be seen the player nicely accepts a flexible start address - no need to copy the song data to some specific address either.

My example is simple, it's not especially useful to simply HALT and call the player routine, it might be better to use an interrupt to play the song.

But this is it for now, I'm super-impressed how easy this was to set up and get running.

Monday 4 February 2019

Zak McKracken and the Alien Mindbenders

Games that begin from your apartment are of a special category.
I have a vague recollection of 1988 or 1989, when I was torn between whether to have Zak McKracken or Neuromancer for the Commodore 64. I was greatly attracted to Zak, but bought Neuromancer instead.

In hindsight, perhaps this was a good choice. I shudder to think how Zak might have worked on a C64 and the 1541. Not to say Neuromancer fit into 8-bit so well, and I never finished that either. These two games have some similarities too: both allow travelling between distant locations through different transports, and money is an important element of the game play.

To get both to the airport, just enter at the same time! There's another way, too...
Although I've played through a handful of Sierra adventure games, this is the first Lucasfilm game I have ever completed. This was recently, with the ScummVM engine on my Linux. I doubt if I would ever had the patience to do this without the flexible saving/loading options.

I tried to avoid using online help and maps. Yet on two points, outside clues were needed:

1. It never occurred to me that when Zak says he needs to draw the map he saw in the dream, it doesn't mean I should draw it but that Zak should draw it. Turns out this is quite crucial for the game!

2. Never figured out what to do on the ocean. I did think an animal might be helpful but no idea how to reach one. I supposed it would be under the water, and I spent futile energy in trying to equip Zak with the diving gear.

If you don't get it right, this sequence will annoy you every time you fly.
The game is excellent when it presents complete complex milieus, such as the beginning location, San Francisco and the Mars areas. I just love that spaceship buggy and manipulating the dashboard.

Some individual sections, such as causing havoc in the airplane, also deserve praise.

It gets more frustrating when navigating dark mazes and look-a-like rooms designed to add some sense of space and playtime to a game that is not much larger than Maniac Mansion. Yet I also appreciate the game is not pure storyboard but also involves mazes, time, co-ordination and checking money and oxygen limits. The Mars and Earth are two different adventures that run parallel, feeding clues into each other.

You can leave with the ship but it's bit of a red herring.
This approach also means that despite the mazes, walking distances have been kept fairly short, as the world is a sprawling network of point-to-point connections between distant locations. It's already a bit of a chore to move Melissa and Leslie in and around the Mars landing site at a time when you don't exactly know what needs to be done, so I'm actually glad there's not more of that.

I even prefer this game over The Secret of the Monkey Island. This is mostly because I am not a big fan of dialogue trees and Monkey had them in spades. Although the jokes and writing quality is better in Monkey, there's no end to the constant blabbering and in some ways the selection-tree reverts to a more primitive form of gaming.


Traveling salesman, anyone?

In Zak and Maniac, we are closer to the earlier idea of a 'text adventure' transplanted into a graphic environment. Even after playing it through, Zak still feels more like a game than a spoon-fed interactive story.

One thing graphic adventures could do well was the use of multiple player characters. Zak gives almost a bit more than can be handled, but the clever split between Earth-Mars activities helps keep it manageable.

A vital clue has been delivered.
Travelling around Zak's world, I have to note that the environments might be seen as somewhat culturally insensitive! Africa is two locations, the pyramids at Cairo and a primitive hut village at Zaire. There we meet a doctor with pedigrees of Master of Cranial Diminishment from the Watsamatta University and Witch Doctor First Class from Kinshasa University.

I also could have hoped for more countries and locations. Visiting the Tunguska site might have been fitting and hilarious and surely something could have been made out of Australia, China or Japan.

Not sexist? Who gets to do all the cleaning in this game?
The plot and comedic style reminds me of The Adventures of Buckaroo Banzai Across the 8th Dimension, a film I am not a huge fan of, but it has its moments. Also, add some nods to Douglas Adams' works and a heavy dose of Erich Von Däniken's ancient astronaut theories and we pretty much have the feel of Zak McKracken.

The notion of lowly alien race invading earth, and earth receiving protection from an esoteric "higher" race, was at the heart of the Buckaroo Banzai story too. The aliens' disguises and inability to fit in were similarly laughable.

Of course the idea of invading species and high protector alien race goes way back, and I recently encountered it in Have Spacesuit - Will Travel by Robert A. Heinlein. Come to think of it, the detail given to building the space suit and the constant monitoring of oxygen levels also reminds me of this Heinlein story.


Notes on the graphics

I did a Commodore 64 PETSCII 'text art' version of the iconic street vista, beginning from the observation that the SFO 42 bus is quite PETSCII-like in appearance.

Click to see it biggenated
While doing this, I didn't look at the C64 version, but used the Amiga/DOS graphics as the reference for for redrawing the graphics.

I made many compromises with Zak himself, to keep him in the correct height, so forgive me if he doesn't look quite himself.

Fits the grid alright.
Indeed I tried to follow the Amiga/DOS capture exactly. I noted that the graphics at this location are especially well fitted for a character grid, with 8x8 pixel elements.


I'd even argue character graphics may have been a starting point for designing this location, or there's some kind of tile compression scheme that benefits from the 8x8 approach.

I mispositioned the mirror!
With PETSCII, the 120x16 character area, together with symbols and colors, takes 3840 bytes, less than 4K!

Funnily enough, the outcome is in some ways richer than the C64 location, although I'm quite sure the game players would not have accepted the PETSCII look back then.