Feb 102014
 

A couple of years ago I became interested in methods of automatically “up-scaling” retro video game art for the high resolution screens that are everywhere these days, without generating a blurry mess. I came across the “HQX” algorithm, which is a pixel art scaling algorithm developed by Martin Stepin, and which is used in various places, including several emulators (such as NestopiaFCEUX and more). There are three hqx algorithms, corresponding to 2x, 3x and 4x scaling respectively. Code for the algorithm can be found here.

This weekend I was playing around with art from my ZX Spectrum game Crosswize, and I thought I’d share some of the results obtained by applying hq4x. The original art for the game was in typical ZX Spectrum “2 color with 8×8 pixel attributes” mode (though nicely done by Colin Grunes). What I’ve done here is first added some color shading into the low resolution art by hand and then applied the hq4x algorithm (the final result is unretouched, bar some cropping for inclusion here).

First example:

Original ZX Speccy image

Color shading added

HQ4X 4x scaled result

And another example:

Screen Shot 2014-02-09 at 8.57.36 PM

Original ZX Speccy image

Screen Shot 2014-02-09 at 8.57.43 PM

Color shading applied

Screen Shot 2014-02-09 at 9.16.52 PM

Resultant HQ4X image

I think the results are pretty remarkable! The resultant images remove any pixel stepping contained in the original low resolution image, and I think have a “retro” charm of their own. What may not be obvious here is that the original art is really tiny compared to the result – the original art is shown magnified using pixel quadrupling so you can compare the images. Also note that the “original” images are not quite the same as the colored and scaled ones due to simple laziness on my part – I just grabbed a similar part of the image because it was more convenient to do so.

Here’s an image at the original scale:

old_house

Image from ZX Speccy @ original scale

 Posted by at 1:17 am
Feb 092014
 

Here’s a presentation given by “Bernie Dugggs” (Doug Burns) to a group @ an Oracle Users Group (I think ) a couple of years ago. Doug touches on some of the lessons learned early in his career while programming the ZX Speccy, and how those lessons are still useful today.

 

 Posted by at 11:31 pm
Feb 092014
 

The other day, I came across source code for Crosswize, a ZX Spectrum game I wrote back in the 80’s. Crosswize was written in Z80 assembly (of course), and featured a smooth-scrolling background, accomplished through a goodly amount of self-modifying code, along with the discovery that the fastest way to read and write to memory on the Z80 is to use the stack (if you can free up enough register pairs that is). The reason the stack is so fast is because the “push” instruction is encoded in only a single byte which specifies the 16 bit register pair to push (the source), and which naturally decrements the stack pointer before writing to memory when executed. Similarly, loading register pairs (using “pop”) from the stack is also fast, and that approach is also used here.

In the following code snippet (which is responsible for drawing 8 pixel rows of the smooth scrolling background), by the time the code gets to the label “push_00”, the register pairs AF, BC, DE, IY and IY have been loaded with pre-shifted bitmap data, and the register pair HL cleared. In a previous setup routine, the block of .db 0 starting @ label push_00 has been pre-populated with (using self-modifying code) a series of “push” instructions. The stack pointer (sp) is set to the byte just after the right edge of a screen pixel row. When the Z80 CPU executes the code following push_00, 16 bit values (corresponding to 16 pixels on the ZX Spectrum) are written to the screen from right to left (a push instruction first decrements the stack pointer and then writes the 16 bit value to the new location).

I had a struggle to find enough registers (as may be evident from the code), so ended up using push ix and push iy opcodes (which have an extra 0xdd or 0xfd byte prefix), so the “jp 0” at the label skip_00 is self-modified to jump into the correct spot in the buffer to allow for all combinations of 1 and 2 byte opcodes.

This code is rife with self-modifying code, a technique that is mostly obsolete today, but which was a handy tool for many Z80 coders back in the day.

 Posted by at 12:50 am
Feb 012014
 

UPDATE Sunday February 2nd, 2014: I’ve edited the excerpted Jan 30 statement from Steve Wilcox out of the paragraph below – Google the Elite website if you want to read the statement. Elite does seem to have removed essentially all of their emulated Spectrum apps from the iOS App Store (at least), for the moment. I don’t anticipate making further public statements on the issue here until it is resolved.

Further to my post two days ago regarding Elite’s (funded) Kickstarter for a Bluetooth keyboard for their Spectrum emulator apps, Elite has pulled their “ZX Spectrum: Elite Collection” iOS apps from the iTunes App Store.

At this time, Elite still has Odin games on the iOS App Store, including Robin of the Wood, Nodes of Yesod, Heartland and Arc of Yesod (in various forms).

 Posted by at 6:47 pm