| |
Krill
Registered: Apr 2002 Posts: 2854 |
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.... |
| |
HCL
Registered: Feb 2003 Posts: 717 |
Are you guys trying to do what Graham did in Dawnfall (1995).. ;) |
| |
Oswald
Registered: Apr 2002 Posts: 5026 |
that just shows how brilliant graham was 1995 goddamn |
| |
Krill
Registered: Apr 2002 Posts: 2854 |
Quoting HCLAre you guys trying to do what Graham did in Dawnfall (1995).. ;) No.
Afaict, Dawnfall had 2 layers, either with one of them having 2 colours (with what appears to be some temporal blur from the previous frame), or both of them blended together.
Unless i missed something, there aren't 3 independent solid stacked layers. |
| |
Krill
Registered: Apr 2002 Posts: 2854 |
Quoting chatGPZQuote: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
Brilliant! \=D/
Wonder if there are more suitable combinations than these bitpairs... |
| |
Martin Piper
Registered: Nov 2007 Posts: 645 |
Applying a bit twiddle before the logical operations is rather similar to how hardware design makes some logical operations simpler, use fewer gates or use gates of a particular type, by introducing not gates before or after.
Interesting.
If the layer values were coming from three routines that calculate bytes at a time for each layer, this would be quite quick for a nice effect. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11145 |
Quote:Wonder if there are more suitable combinations than these bitpairs...
The most obvious thing would be to invert all values, and swap AND with OR (that always works) :)
lda layer1 ; 01/00 (becomes 11/10)
ora layer2 ; 10/01 (becomes 11/01)
and layer3 ; 11/00 (becomes 11/00)
(this opens the door for storing with fixed layer3 in X and SAX) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11145 |
and noobtracker was busy, so for the records:
; bg l1 l2 l3
; 00 < 01 < 10 < 11
;bg/fg
lda layer1 ;10/11
and layer2 ;01/10
ora layer3 ;00/11
; bg l1 l2 l3
; 00 < 10 < 01 < 11
;bg/fg
lda layer1 ;01/11
and layer2 ;10/01
ora layer3 ;00/11
; bg l1 l2 l3
; 01 < 00 < 10 < 11
;bg/fg
lda layer1 ;11/10
and layer2 ;01/10
ora layer3 ;00/11
; bg l1 l2 l3
; 10 < 00 < 01 < 11
;bg/fg
lda layer1 ;11/01
and layer2 ;10/01
ora layer3 ;00/11
; bg l1 l2 l3
; 01 < 10 < 00 < 11
;bg/fg
lda layer1 ;01/10
and layer2 ;11/00
ora layer3 ;00/11
; bg l1 l2 l3
; 10 < 01 < 00 < 11
;bg/fg
lda layer1 ;10/01
and layer2 ;11/00
ora layer3 ;00/11
(plus all the inverted versions, as said above) |
| |
Krill
Registered: Apr 2002 Posts: 2854 |
Would be cool if the bottom layers 1 and 2 could be EORed.. =) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11145 |
Are you crowdsourcing your coding now? :D |
| |
Krill
Registered: Apr 2002 Posts: 2854 |
Quoting chatGPZAre you crowdsourcing your coding now? :D Still beats AI when it comes to coding! :)
But seriously, was more like "bummer that it won't work with EOR".
(No formal proof but strong guts feeling.) |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 - Next |