| |
Krill
Registered: Apr 2002 Posts: 2855 |
Stacking multicolour layers in assembly
Consider 3 single-coloured multicolour layers, such that, e.g.,
00 or 01 - layer 1
00 or 10 - layer 2
00 or 11 - layer 3 (with 00 being background or transparent).
Now, how to merge them, rendering one over/on top of the other (no "glenz"-like colour blending, particular layer ordering isn't important as long as any kind of priority regime is preserved, and background/transparent may not be 00) using only binary arithmetic or other primitives, but no lookup tables?
With the above example, it's some kind of max operation on bitpairs, with something like
|00 01 10 11
--------------
00|00 01 10 11
01|01 01 10 11
10|10 10 10 11
11|11 11 11 11 but this doesn't seem to map very well to the 6502's operations. =) |
|
... 81 posts hidden. Click here to view all posts.... |
| |
Krill
Registered: Apr 2002 Posts: 2855 |
Quoting chatGPZQuote:I can imagine 3 layers additive like in many miggy vector fx, can be static scrolling texture, or even scroller.. and as Gunnar wants registers free maybe 3 zoomscrollers ? :P :)
Layered chessboard zoomers - but with Z rotator!
GOGOGO! :D That was EXACTLY what i had in mind before i stumbled over this problem. :)
(But it was a sidetrack so i just asked the experts rather than spending too much time on this one.) |
| |
The Syndrom
Registered: Aug 2005 Posts: 56 |
Quote: CyberBrain...
lda layer1
adc layer2 ; Assume C = 0
and layer2
If:
layer1 = 01
layer2 = 00 (transparent)
layer3 = 00 transparent
Doesn't that produce 0, which forgets that layer 1 already has a colour?
@martin piper
you probably overlooked the twisted input bits of layer 1&2:
>If we use these bitpattern replacements for layer 1 and layer 2:
>layer1_00 = %01 // <- in layer 1: instead of %00 we use %01
>layer2_00 = %01 // <- in layer 2: --||--
>layer1_01 = %00 // <- in layer 1: instead of %01 we use %00
>layer2_10 = %10 // <- in layer 2: we still use %10 as %10 :'( |
| |
chatGPZ
Registered: Dec 2001 Posts: 11150 |
Quote:Can it get any more concise and elegant? :)
Noobtracker to the rescue :)
lda layer1 ; 10/11 (becomes 00/01)
and layer2 ; 01/10 (becomes 00/10)
ora layer3 ; 00/11
|
| |
ChristopherJam
Registered: Aug 2004 Posts: 1382 |
Gorgeous! |
| |
CyberBrain Administrator
Posts: 392 |
Damn, that's cool! And elegant! This is one of those things, that makes you go "why th did i not see that?!" after you see it :) Well done, the quest has been solved! |
| |
Oswald
Registered: Apr 2002 Posts: 5031 |
lda layer1 ; 10/11 (becomes 00/01)
and layer2 ; 01/10 (becomes 00/10)
ora layer3 ; 00/11
I dont see it layer1 and layer2 will make everything 0 where there is a 0, while what is needed a kind of max function per bitpair. and how can an lda perform an operation ?
edit: unless it is using the bitpair scramble offered |
| |
chatGPZ
Registered: Dec 2001 Posts: 11150 |
Now that Y is solved, i want to see X. AT X :D |
| |
JackAsser
Registered: Jun 2002 Posts: 1995 |
Quote: lda layer1 ; 10/11 (becomes 00/01)
and layer2 ; 01/10 (becomes 00/10)
ora layer3 ; 00/11
I dont see it layer1 and layer2 will make everything 0 where there is a 0, while what is needed a kind of max function per bitpair. and how can an lda perform an operation ?
edit: unless it is using the bitpair scramble offered
This works fine Oswald, very neat solution which I definitely will use at some point.
L3 L2 L1 (L1&L2|L3)
00 01 10 00
00 01 11 01
00 10 10 10
00 10 11 10
11 01 10 11
11 01 11 11
11 10 10 11
11 10 11 11
@Oswald: In layer 1 on=10, off=11, in layer 2 on=01, off=10, in layer 3 on=11, off=00 |
| |
Copyfault
Registered: Dec 2001 Posts: 467 |
First of all: nice question raised by Krill, and what a brilliant solution found by Noobtracker. I'd opt for granting him access to csdb, did never really understand why he got banned...
In order to unconfuse Oswald, the meaning of the bitpairs should be put right in your explanation, JA.
In Layer 1, a set (or foreground) pixel is encoded by %11, while a transparent one is encoded by %10.
For Layer 2, it will be %10 for a set pixel, while %01 does the job for a transparent one here.
Finally, Layer 3 is just like described: %11 is the bitpair for a set pixel, %00 for a transparent pixel.
The table given by JA is correct. It shows that Noobtracker's golden opcode trio always gives bitpairs that can be used to set the pixels in the standard encoding.
Now let's try to shorten it even more *evilgrinplusshallowlaughter*
CF |
| |
JackAsser
Registered: Jun 2002 Posts: 1995 |
Quote: First of all: nice question raised by Krill, and what a brilliant solution found by Noobtracker. I'd opt for granting him access to csdb, did never really understand why he got banned...
In order to unconfuse Oswald, the meaning of the bitpairs should be put right in your explanation, JA.
In Layer 1, a set (or foreground) pixel is encoded by %11, while a transparent one is encoded by %10.
For Layer 2, it will be %10 for a set pixel, while %01 does the job for a transparent one here.
Finally, Layer 3 is just like described: %11 is the bitpair for a set pixel, %00 for a transparent pixel.
The table given by JA is correct. It shows that Noobtracker's golden opcode trio always gives bitpairs that can be used to set the pixels in the standard encoding.
Now let's try to shorten it even more *evilgrinplusshallowlaughter*
CF
Oops! Sorry for the typo! |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 - Next |