I have written a new plasma demo for TMS9918. I thought that Plascii Petsma by Cruzer/Camelot had one of the nicest looking plasma effects I've seen, and he included source, so I've ported it from C64 to the Z80/TMS9918. Here is a video of it running on my RC2014 homebrew computer with the TMS9918A video card I designed. I'm getting solid 60 fps on 10 MHz Z80, and 30fps when the clock is slowed down to MSX speeds. I followed the high-level structure of the original C64 code where it made sense, but obviously the low-level code is completely rewritten since it's on a Z80 instead of 6502. Also, rather than PETSCII characters, I've used the gradient tiles from the plasma effect in Produkthandler Kom Her. On top of this, I have added the following interactive features:
- change the palette independent of the effect
- hold a particular effect on screen indefinitely
- switch immediately to a new effect
- runtime generation of random effects
- adjust parameters to customize an effect
Translating 6502 to Z80 as efficiently as possible was an interesting exercise. The lack of indexed indirect mode made it pretty tricky sometimes. I tried to play to the Z80's strengths when I could. I keep almost everything in registers and use the alternate register set extensively. The speed code is composed entirely of one byte instructions and the only things held in memory are the input and output arrays.
A lot of the complexity in Plascii Petsma's code was because he didn't want to use a custom character set. Since I didn't have this self-imposed restriction, I was able to remove that code and just calculate the tile names directly from the sine table.
I'm using the TMS9918A's Graphics I mode, which is similar to the VIC-II's extended color mode used by the original demo, except there's no separate foreground color, so I only have to do one write per tile instead of two. Since the TMS9918 has separate video ram, the name table is written to a back buffer in main ram and copied to the screen during vsync.
I confirmed that the basic demo runs on OpenMSX (I don't have a real MSX to test on) and cycles through the preconfigured effects. The interactive features don't work yet. I'm using the CP/M BDOS 06H function for keyboard polling. My understanding is this should be compatible with MSX-DOS but it's not working. I will have to research why. Also seeing a bit of tearing. On the RC2014 I was polling the interrupt flag and intentionally insert delays between VDP writes. Maybe on a real MSX this is too slow and I need to use interrupts and a faster VRAM copy function.
Any ideas about about why keyboard input is not working on MSX?