Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Stacking multicolour layers in assembly
2024-02-15 22:20
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....
 
2024-02-16 15:35
Krill

Registered: Apr 2002
Posts: 2855
Quoting chatGPZ
Quote:
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.)
2024-02-16 15:39
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 :'(
2024-02-16 16:48
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
2024-02-16 17:03
ChristopherJam

Registered: Aug 2004
Posts: 1382
Gorgeous!
2024-02-16 17:21
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!
2024-02-16 17:36
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
2024-02-16 18:22
chatGPZ

Registered: Dec 2001
Posts: 11150
Now that Y is solved, i want to see X. AT X :D
2024-02-16 19:29
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
2024-02-16 20:26
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
2024-02-16 20:30
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
iAN CooG/HVSC
fenz/SCC
Dymo/G★P
syntaxerror
Guests online: 101
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.7)
6 No Bounds  (9.6)
7 Aliens in Wonderland  (9.6)
8 Comaland 100%  (9.6)
9 Uncensored  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 It's More Fun to Com..  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 SHAPE  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.067 sec.