How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Requests for features
Post Reply
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

I am looking at:
https://github.com/z88dk/z88dk/blob/mas ... de/games.h
to try to figure out how the "or types" work.

I only see:
spr_or = or
spr_and = and not (it applies and to the inversed sprite)
spr_xor = xor (I guess)

So no simple "spr_copy" to just have the sprite copied on the screen with no transparency (as a tile)?

If such a feature is not present, it would be nice to have as it would be much faster than a very slow spr_and to produce the 0's and spr_or to get the 1's
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

I'm sorry, that option is not available.
You can either create a square Sprite to previously 'cut' a square space (spr_and), or use the text features, e.g. by providing an extra font. This latter option comes in several flavours on some target but it is quite machine specific and less flexible.
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

Yes, I know how to do this with an "and not" + "or" but it would be much slower than one single copy:
2 times applying a mask vs 1 copy.
Sprites are extremely slow on some targets that only have sprite support and no UDG support (e.g., C128).
So, doing twice the same operation is not possible in such cases.

A no-transparency option would be useful.
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

.. the only quick hack coming to my mind would work respecting the byte boundary only, try by forcing 0 (zero) in place of the and/or expression. The trick should work in a good percentage of the putsprite ports.
A cleaner solution would require a brand new function behaving differently. I can do it, just convince me it's useful :)
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

A non-transparent blitter operation with byte boundaries would fit my use-case as I am ab-using sprites as tiles.
This is very egoistic, though. My use-case is not the most common.
My use-case could/should be handled with real tiles whenever possible... I should implement UDG on the VIC-II (I know how to do it) and for the VDC (I need to study this) for the C128. For the other targets I need the non-transparent blitter operation.

Nevertheless having a general non-transparent blitter operation looks to me as a general use-case, where you want to display a rectangular bitmap picture on the screen. If we forget about speed, then the spr_and + spr_or is good enough.
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

ok then, let me know if putting 0 in place of spr_or will work
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

@stefano, I just tried 0 instead of spr_or and it does copy instead of applying an OR mask but the shapes are all totally wrong.
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

does it fail even with 8 or 16 pixel wide sprites placed at 8, 16, 24... x positions ?
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

It does fail with 8x8 sprites placed at byte boundaries:
- it does work as a blitter copy (no transparency)
- the shape is not the one it is supposed to blitter
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

you're right, I'm sorry.
This trick coul still work respecting the word boundary (needed on the x axis only).
If it still fails, try reducing the sprite size to 15 bit.
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

The sprite size is 8 x 8. That is quite small.
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

I understand, I was just supposing that this trick could still work with 15 pixel wide sprites.
I'm not confident that reducing the size to 7 would work.
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

The targets for which such a thing would really help are targets with no UDG support and very slow sprites.

In particular:
C128 that could have UDG support in VDC text mode (I could implement it myself if I figure it out)

The ZX81 has sprite support for WRX and some UDG support but I am not sure it is meant to work on an uncommon hack.
User avatar
dom
Well known member
Posts: 1305
Joined: Sun Jul 15, 2007 10:01 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by dom »

Yes, the C128 is decidedly lacking at the moment - I would have liked to provide full gencon facilities for it but I never managed to get an emulator to startup quickly, as mentioned in other threads I'm not the most patient person it seems!

If z80 cartridges are supported by the machine then that should be quicker way to develop.

For the ZX81 - have you had a look at the pseudo hires mode? https://z88dk.org/forum/viewtopic.php?t=11219
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

@dom, There are several decent C128 emulators, the most VDC-accurate being, Z64K.
pseudo hires mode may not be best fit in my use-case (Cross-Lib) as I have graphics assets for all my targets that are edited only once and used on all 200 supported targets across all dev-kits.
Does the pseudo-hires mode allow me to use freely chosen tiles? Or do I have to adapt them?
My build-chain is supposed to be automatic and use the same tiles.
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

The pseudo hrg stuff is still unstable, I wouldn't suggest to try it now. The UDG on the zx81 requires extra hardware as well as the wrx, they're well known nowadays and available on most of the modern expansions, but they are not standard.
About the cartridges and the c128, I do not remember the exact reason but I think that the z80 can't boot in a cartridge.. in short the z80 cpu is used in the c128 boot process to gracefully make the main CPU to follow the desired path (cartridge, c64 mode, etc..). Probably a loader in native 8502 machine code is mandatory (the cartridge must be recognized as a C128 one, otherwise the system will enter and stay in C64 mode).
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

@stefano @dom, I am lost. Why do you need a cartridge to test Z80 code on the C128? Do you want to test on the real hardware while debugging the code?

A simple sd2iec (few bucks) is enough to load a program. The program should contain a loader to start the Z80 CPU. Z88DK (the C128 crt I guess) is already doing this. So you can already load anything into a real C128 very easily and quickly. In order to speed up the loading, you need Jiffydos or other similar solutions.

For debugging/developping I would rather use Z64K and Vice. I am not so sure Mame/Mess has accurate VDC emulation.
Z64K emulates the VDC accurately. Vice has decent VDC emulation. Both are good enough to run (most of) the Risen to Oblivion demo (VDC demo) which exploits all VDC official and unofficial features.
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

Fabrizio, you probably know something I don't.
My own path to test the programs is via VICE (X128). I'm just running it using A.T64 as a command parameter. Then LOAD once more.. waiting few seconds.. and finally RUN.
I suppose those few seconds are the ones Dominic is willing to save, hence the idea to make the games bootable from a virtual cartridge image on an emulator.
User avatar
dom
Well known member
Posts: 1305
Joined: Sun Jul 15, 2007 10:01 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by dom »

I think the last time I was on the c128 I was doing some cpm testing.

I think it took several minutes from start to actually executing my code. Hence my reluctance to do any more.

I know Robertk requested disc support a while back but the format looked a little too unique with no reuse possibility.
Fabrizio
Member
Posts: 86
Joined: Tue Jul 11, 2017 9:28 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by Fabrizio »

@dom I think SD2IEC should handle any .d71 and .d41 files. You cannot speed-up loading from a floppy or SD2IEC with a C64 mode cartridge in C128 mode. The best solution is JiffyDos128, which is a kernal replacement rom. There is also a software solution that should have a C128 (but not CP/M) version: SJLOAD for C128 mode only.
stefano
Well known member
Posts: 1629
Joined: Mon Jul 16, 2007 7:39 pm

Re: How to display a sprite with no transparency (display both 0's and 1's in one single copy)?

Post by stefano »

https://github.com/DL2DW/ZX1541-Interface

..this is a recent refresh of the old 1541 imterface for the zx81.
Part of the z80code could be reusable, but the serial driver probably needs to be rewritten or adapted from the cpm sources (https://github.com/DL2DW/ZX1541-Interface).
Post Reply