Plascii Petsma ported to Z80/TMS9918A
category: general [glöplog]
Sacrilege! OK, with that out of the way, I thought that Plascii Petsma by Cruzer/Camelot had one of the nicest looking plasma effects I've seen, so I've ported it from C64 to my RC2014 homebrew computer with the TMS9918A video card I designed. I'm getting 60 fps on 10 MHz Z80. I followed Cruzer's high-level code structure where it made sense, but obviously the 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 Cruzer's plasma effect in Produkthandler Kom Her. I will probably add runtime random generation of parameters and keys to control that and palette swapping. Maybe some music too on the YM2149 or SN76489 for which I have plugin cards on the RC2014.
No glops so no direct links... :(
youtube: /watch?v=s-DdxUdJskI
github: /jblang/TMS9918A/blob/master/examples/plasma.asm
No glops so no direct links... :(
youtube: /watch?v=s-DdxUdJskI
github: /jblang/TMS9918A/blob/master/examples/plasma.asm
awesome plasma! thanks for sharing
Thanks!
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, 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.
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, 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 have updated the code with interactive features:
- change the palette independent of the effect
- hold a particular effect indefinitely
- runtime generation of random parameters
- adjust parameters for an effect
Source code link remains the same as before.
I also have made a longer video on youtube: /watch?v=aIT_a1AZj5A
Finally, I confirmed that the basic demo runs on OpenMSX (I don't have a real MSX to test on). The interactive features don't work yet. I'm using the CP/M BDOS 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.
- change the palette independent of the effect
- hold a particular effect indefinitely
- runtime generation of random parameters
- adjust parameters for an effect
Source code link remains the same as before.
I also have made a longer video on youtube: /watch?v=aIT_a1AZj5A
Finally, I confirmed that the basic demo runs on OpenMSX (I don't have a real MSX to test on). The interactive features don't work yet. I'm using the CP/M BDOS 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.