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 > setting nibbles for chunky FLI
2016-10-07 17:53
Digger

Registered: Mar 2005
Posts: 421
setting nibbles for chunky FLI

A classic one but couldn't find any relevant threads in this forum –
what's the fastest way for merging color nibbles for the screen RAM (chunky FLI, plasmas, whatever) that you've came across?

The non-optimised being:
lda #colorL
ldx #colorH
ora nibbleLUT,x
sta $0400

* = $80

nibbleLUT: .byte $00, $10, $20, $30
           .byte $40, $50, $60, $70
           .byte $80, $90, $a0, $b0
           .byte $c0, $d0, $e0, $f0
 
... 2 posts hidden. Click here to view all posts....
 
2016-10-07 19:31
Oswald

Registered: Apr 2002
Posts: 5017
maybe you will find this helpful:


lda 0x0y,x
sta screen

where 0x and 0y are two lo nibbles to be merged.

,x helps to push the look up tables away from $0000-$0001.

$10 byte table needed troughout 4k pages.
2016-10-07 20:47
Digger

Registered: Mar 2005
Posts: 421
Quote: That would require two STAs. One can do:

lda #colorL
ldx #colorH_eor_FF
sax $0400


Very neat! So, since SAX stores the bitwise AND of A and X, it needs the opposite nibbles filled with ones.

lda #$f(colorL)
ldx #$(colorH)f
sax $0400
2016-10-08 03:20
ChristopherJam

Registered: Aug 2004
Posts: 1378
…or
lda $8x8y
sta $0400
if you plot with colours $80 to $8f instead of $00 to $0f…
2016-10-08 06:07
ChristopherJam

Registered: Aug 2004
Posts: 1378
That said, plotting into a routine with a stride of six bytes is not ideal.

Perhaps
lda(buf+n*2),y
sta$400+n
where each entry of buf contains $8x? It's two cycles slower than my previous submission, but you save two cycles on writing the buffer, the memory arrangement is saner, and the buffer filling code would be shorter too.
2016-10-08 10:46
Copyfault

Registered: Dec 2001
Posts: 466
Quoting Digger
Very neat! So, since SAX stores the bitwise AND of A and X, it needs the opposite nibbles filled with ones.

lda #$f(colorL)
ldx #$(colorH)f
sax $0400


But this requires that you know beforehand which colour belongs to the low-/hi-nibble resp. Plus your algorithm has to also render those %1111-nibles accordingly.

Then again, it would be the same doing
lda #$0(colorL)
ora #$(colorH)0
sta $0400,

where the algo has to take care for the %0000 nibbles instead of the %1111.

If you only have the colour information as low-nibble-bytes ($00,..., $0f), maybe one could do
lda #0(colorL)
ora $0(colorH) -> bytes in zp with swapped nibbles, i.e. $0f -> $f0 etc.
sta $0400

But I guess the zp-adresses $00 and $01 will cause trouble here, so we again have to tweak the byte with the Hi-Colour-information (smth. like "ora $1(colourH)").

Maybe I missed the central advantage of that SAX-approach...
2016-10-08 14:33
Rastah Bar

Registered: Oct 2012
Posts: 336
If you have the colours as $fx, x=0..$f, then maybe you could do
lda #f(colorL) -> for example $f6 for blue.
and $f(colorH) -> zp-addresses $f0 .. $ff contain $0f, $1f, ..., $ff
sta $0400
2016-10-08 17:09
ChristopherJam

Registered: Aug 2004
Posts: 1378
Quote: If you have the colours as $fx, x=0..$f, then maybe you could do
lda #f(colorL) -> for example $f6 for blue.
and $f(colorH) -> zp-addresses $f0 .. $ff contain $0f, $1f, ..., $ff
sta $0400


Ooh, I like that one!
2016-10-09 05:13
Oswald

Registered: Apr 2002
Posts: 5017
Quote: That said, plotting into a routine with a stride of six bytes is not ideal.

Perhaps
lda(buf+n*2),y
sta$400+n
where each entry of buf contains $8x? It's two cycles slower than my previous submission, but you save two cycles on writing the buffer, the memory arrangement is saner, and the buffer filling code would be shorter too.


I dont get this one where are the lo/hi pixels merged?
2016-10-09 06:33
ChristopherJam

Registered: Aug 2004
Posts: 1378
Oswald, it accesses your sparse table, just relocated to $8L8H

The y register is zero, and a row of pixels are stored in a buffer in zero page. Each pair of pixels is treated as a pointer.
2016-10-09 07:40
Oswald

Registered: Apr 2002
Posts: 5017
ah I get it.

actually its on par with the ABS method hence the writes to zp are faster by 1-1 cycle.

in some cases it might be the better choice over the abs one. usually sta's are fixed in 4x4 per pixel style effects, imho the benefit would come from that the writes happen to the same zp buffer and they get translated to fullscreen.
Previous - 1 | 2 - 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
CA$H/TRiAD
CreaMD/React
Flex/Artline Designs
K-reator/CMS/F4CG
TPM/Silicon Ltd
Didi/Laxity
Guests online: 151
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

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