June 18, 2013

zxsp 0.8.0pre17: multiple instances


faster than anybody thought, especially myself, the next version of zxsp is released. This version fixes some bugs discovered in the SPECTRA emulation and re-enables the possibility to run more than one machine instance at the same time.

The SPECTRA emulation had some bugs in border colours and in .z80 file reading. Also it triggered a sleeping error in the Z80 emulation, where under certain circumstances, e.g. when the SPECTRA interface was attached B-), wait cycles were inserted anytime the CPU was reading from contended memory. According to the location of this bug this should also have occurred when the memory access inspector was open.

Multiple instances: You now can open as many machine instances as you like ... and your Mac can execute. There are probably still some bugs left in here, but i have discovered nothing severe.

Have fun!

    ... Kio !

p.s.: summer has arrived here. B-)

p.p.s.: i have included a test rom which demonstrates the colour capabilities of the SPECTRA interface. On Paul Farrow's site there is probably a newer version. Just in case.

June 15, 2013

zxsp 0.8.0pre16: SPECTRA Interface


the next version of zxsp is out right now. The major new thing is support for Paul Farrow's SPECTRA video interface. But let's start with the small modifications.

Rob Probin has pointed me to an improvement for the undocumented bits in the F register in the Z80 emulation which i now implemented. Hopefully programmes crash more accurate now. B-)

I replaced the default external AY extension, which was an AY-Magic, with the Didaktik Melodik, because i didn't get answer to my request for admittance to use the AY-Magic image.

Now to the big add-on:

Paul Farrow's SPECTRA video interface

Paul Farrow's SPECTRA video interface
This is a RGB-Scart interface to connect your ZX Spectrum to a TV set with much better image quality than with the standard HF lead.

It also incorporates new colour modes, a rom slot with Interface1-compatible paging, a Kempston joystick interface and an Interface1-compatible RS232 port.

Of course the "better image" is not emulated in zxsp, because you already get the best quality here :-) but colour modes, rom and joystick interface are emulated. The RS232 port is postponed for a while.

The new colour modes

Screenshot made with zxsp
There are 32 combinations for new modes combined from
  • extra colours: provides 64 colours
  • half cell mode: set colours for left and right 4 pixels in character cell separately
  • 2-byte attributes: doubles the available information which can be stored for attributes
  • 8, 4, 2 and 1-line mode: increase vertical colour resolution
Some combinations are a little bit pointless, but most provide certain trade-offs between memory consumption and added colour capabilities.

In addition the interface contains 2 x 16 kByte of ram which allows double buffering of video drawing.

All colour modes are supported by zxsp, you can also make GIF images and movies in these modes.

ROM support

The interface has a Sinclair Interface 2-like rom slot or, optionally, a DIL socket, but zxsp basically emulates the IF2 slot. There is the option to enable rom switching on the 3 positions where the Sinclair Interface 1 pages in and out. So you can "insert" an Interface 1 rom or a rom which is somehow based on this rom. You can test that it works if you enter the Basic command

    OPEN #4;"m";1;"foo"

which doesn't pass the parser of the plain Basic rom but works when an Interface 1 rom is inserted and the rom hooks are enabled, though it will only tell you that the microdrive 1 is not present.

Joystick support

The interface contains a Kempston-style joystick port and is emulated by zxsp.


The interface contains a RS232 port which works identical to the Interface 1 port, except that it only supports the RS232 mode of this port. This is not yet emulated in zxsp.

.Z80 file support

I have extended the .Z80 file standard to contain the SPECTRA interface. I just dump the information here, so that everybody who is interested can add support to his own emulator:

I have used 1 formerly unused bit to indicate presence of the SPECTRA interface:
  • Bit 3 in Byte "rldiremu'".

If this bit is set, then two bytes are added to the up-to-now defined header after byte "port_1ffd" introduced by xzx/warajewo:
  • Byte "spectra_bits" and
  • Byte "spectra_port_7fdf".

The first one contains some state information while the latter one the state of the port 0x7FDF colour mode register. 

The bits are:
  • Bit 0: new colour modes enabled
  • Bit 1: RS232 enabled            
  • Bit 2: Joystick enabled  
  • Bit 3: IF1 rom hooks enabled
  • Bit 4: rom paged in      
  • Bit 5: port 239: Comms out bit
  • Bit 6: port 239: CTS out bit 
  • Bit 7: port 247: Data out bit

After the header, pages with ID 12, 13 and 14 may be present.
  • Page 12: rom data of inserted rom
  • Page 13: ram data of ram bank 0
  • Page 14: ram data of ram bank 1

If page 12 is not present, then no rom is inserted.
If page 13 is not present, then it shall be copied from the contended ram page.
Same for page 14.

The zip archive of this release comes with some examples and links to my and Paul's website where you can get some more. Let's see how many people find it fancy to write a game or demo which uses this interface. You now have an emulator for convenient development. :-)

    ... Kio !

p.s.: Someone promised a download link here, so here's a link to the official download page: http://k1.spdns.de/Develop/projects/zxsp-osx/distributions/. The downloads are at the end of the page.

June 6, 2013

zxsp 0.8.0pre15: Screenshots for TC2048 and b&w machines


i was busy working on GIF file export in zxsp, which i had temporarily disabled in 0.8.0pre14. GIF file export is now working for all models, that is, in addition to the ZX Spectrum compatible models you now can make screen shots from the TC2048 and ZX80, ZX81 and Jupiter ACE screens.

For the TC2048 i decided on a compromise, after i ran into a widely unsupported feature of gif files, the pixel aspect ratio. Screenshots of the TC2048 are made in the same 1x size as those of a ZX Spectrum. In most cases you will probably use the standard 32 column mode anyway and then this is what you want. If you make a screenshot when (parts of) the display is in 64 column mode, the image will be smoothly scaled down to 256 pixels width.

Weird Science Overscan Demo
Also new is that you can include full border animation in the gif file movies. There is an option right under the "Record gif movie" item to include or exclude border animation. In most cases this makes no difference, but when you make a movie from the loading process of a programme, then it's surely preferable not to include the border animation, because this will explode file size. On the other hand you may want to make a movie from a demo which performs some tricks with the border; then you want to record border changes.

While i was over the b&w gif movie support i also fixed some errors in the display of the ZX80 and ZX81 compatible machines, especially in 60 Hz mode.

TC2048 64 Column Mode ZX81 Silly Basic Demo

    ... Kio !

June 4, 2013

My Annual Rant

Ok here it is.

I have debugged yesterday a piece of code which i had an older version of, which worked, and a new one which didn't. It took me some time to find out what made the difference:

-2 != -2

There are some crap design jokes in C / C++, but this is really special.
If you apply the unary negation operator on an unsigned int, the result is still an unsigned int. Really, approximately in nearly 100% of all cases not what you want.

The other "highlight" in C / C++, which actually made it verbatim into quite a lot of other languages, e.g. Java, is the totally broken operator precedence hierarchy.

A sane precedence order must account of three distinct groups of operators:
  1. ops which take 2 numbers and yield a numeric result,
  2. ops which take two numbers and yield a boolean result, and 
  3. ops which take 2 boolean values and yield a boolean result.
All operators of group 1 must have higher precedence than those of group 2 and those must have higher precedence than those of group 3. Now take a look at the C / C++ / Java / etc. operator precedence hierarchy and see how broken it is by design.

But that was not the only thing that made me feel bad yesterday. I again ran into the especially good support for gif files in all today's real-world apps.

After i got lately response from some Mozilla cleaning officer, who complained, that the example gifs i made for a 6 year old bug report were no longer available, i now found a well documented, basic and easy feature in gif files which no app i tested did support: pixel size aspect ratio, the ratio of width to height of pixels. I wanted to use pixels with an aspect ratio of 1:2 for screenshots of the TC2048 in 64 column mode. When i displayed them in the OSX image viewer, Xee, Firefox, Chrome or Gimp these looked like double-width scarfs. Only Gimp at least showed a warning. All other ignored the aspect ratio all together. So i had to rewrite my code to produce easier-to-decode images. :-/

sometime these things suck.