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: 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....
 
2024-02-16 23:21
HCL

Registered: Feb 2003
Posts: 717
Are you guys trying to do what Graham did in Dawnfall (1995).. ;)
2024-02-16 23:28
Oswald

Registered: Apr 2002
Posts: 5026
that just shows how brilliant graham was 1995 goddamn
2024-02-16 23:43
Krill

Registered: Apr 2002
Posts: 2854
Quoting HCL
Are 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.
2024-02-16 23:57
Krill

Registered: Apr 2002
Posts: 2854
Quoting chatGPZ
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
Brilliant! \=D/

Wonder if there are more suitable combinations than these bitpairs...
2024-02-17 04:57
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.
2024-02-17 19:58
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)
2024-02-17 20:44
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)
2024-02-18 12:25
Krill

Registered: Apr 2002
Posts: 2854
Would be cool if the bottom layers 1 and 2 could be EORed.. =)
2024-02-18 16:23
chatGPZ

Registered: Dec 2001
Posts: 11145
Are you crowdsourcing your coding now? :D
2024-02-18 23:42
Krill

Registered: Apr 2002
Posts: 2854
Quoting chatGPZ
Are 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
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
Luca/FIRE
Acidchild/Padua
FunFun/Triangle
MMS_Z
pcollins/Quantum
Guests online: 109
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 Layers  (9.7)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Booze Design  (9.3)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 Performers  (9.3)
Top Original Suppliers
1 Black Beard  (9.7)
2 Derbyshire Ram  (9.5)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Jazzcat  (8.6)

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