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 > Multicolor, multi pattern 4x4 mode, How?
2010-01-25 07:19
PopMilo

Registered: Mar 2004
Posts: 146
Multicolor, multi pattern 4x4 mode, How?

How are those 4x4 pixel, multicolor, multi pattern modes made?

Example, Bumpmania from Arise:
Bumpmania



Is it with char mode and FLI at middle of each char row ?
2010-01-25 07:50
Oswald

Registered: Apr 2002
Posts: 5094
yes, and special charset with 16 individual shades for the left/right part. so fex. lowmost 4 bits of the charnr sets brightness of the right part of the char and highest 4 bits the left part. usually one has twice the texture to lda ora the left/right part, but here's a trick to use only one texture: mix the bit's of the left/right part like this:
76543210
lrlrlrlr

l=left
r=right

then with one bit rotate instruction you can push the bits into their correct position, so lda texture asl (=left side) ora texture.
2010-01-25 12:10
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Oh, that bit-shift trick is nice! *files away for possible later use* Moahaha! :)
2010-01-25 13:00
WVL

Registered: Mar 2002
Posts: 902
Oswald : but that trick is only for generating the charset, right? But that only saves 3 bytes in the generator and only a couple of cycles..

I dont really see the profit?
2010-01-25 13:22
Oswald

Registered: Apr 2002
Posts: 5094
the profit is that you can halve the texture space, and to do that you only have to do one asl instead of four in the lda ora part.
2010-01-25 14:27
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: the profit is that you can halve the texture space, and to do that you only have to do one asl instead of four in the lda ora part.

Normally i'd do:

lda left_texture,x
ora right_texture,y
sta screen


To save twice texture space one would do:

lda texture,x
lsr
lsr
lsr
lsr
ora texture,y
sta screen


Oswald speed this up by:

lda texture,x
lsr
ora texture,y
sta screen

Did I understand you correct Ossie?
2010-01-25 14:36
Oswald

Registered: Apr 2002
Posts: 5094
yep:) credit gos to Bubis for this nice trick. here's a similar one:

in error 23 the 'freedirectional' tunnel is only calculated at 8x8 resolution the rest is interpolation. horizontally the interpolation is built into the character set, you just lda ora the two pixels to be interpolated, and get the answer from the characterset.

so fex. you have already pixels A and C calculated and want to get the inbetween pixel B with interpolation:

A_C_E_G_H

simpy lda A ora C sta , lda C ora E sta, and voila, you get:

ABCDEFGH


this one goes to Bubis aswell.
2010-01-25 14:52
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: yep:) credit gos to Bubis for this nice trick. here's a similar one:

in error 23 the 'freedirectional' tunnel is only calculated at 8x8 resolution the rest is interpolation. horizontally the interpolation is built into the character set, you just lda ora the two pixels to be interpolated, and get the answer from the characterset.

so fex. you have already pixels A and C calculated and want to get the inbetween pixel B with interpolation:

A_C_E_G_H

simpy lda A ora C sta , lda C ora E sta, and voila, you get:

ABCDEFGH


this one goes to Bubis aswell.


And to optimize that using twice texture memory u can do:

lda left_A
ldx right_C
sax
lda left_E
sax
ldx right_G
sax
lda left_H
sax

== automatic 4x4 interpolation in 8x8 mode (at least horizontally)

left_X looks like: XXXX1111
right_X looks like: 1111XXXX
2010-01-25 15:07
Oswald

Registered: Apr 2002
Posts: 5094
nice one :)
2010-01-25 15:20
WVL

Registered: Mar 2002
Posts: 902
Ah OK..

So normally you'd use

lda texture1,x
ora texture2,y
sta screen

and you'd have the texture twice, once with ....XXXX and once with XXXX....

but using

lda texture,x
lsr
ora texture,y
sta screen

you only need a texture with X.X.X.X.

So only half the mem..

got it.
2010-01-25 15:21
Frantic

Registered: Mar 2003
Posts: 1648
I won't point out that the use of SAX is illegal!

...which reminds me of when I ate a hamburger with Jackasser before StLCP 2008 took off. We were sitting next to some policemen, and I asked Jackasser in a loud voice, "So, Andreas, you're using ILLEGAL OPCODES in your stuff?"... :) Unfortunately they did not arrest him though.

Sorry for being 99% off topic.
2010-01-25 16:04
WVL

Registered: Mar 2002
Posts: 902
Quote: And to optimize that using twice texture memory u can do:

lda left_A
ldx right_C
sax
lda left_E
sax
ldx right_G
sax
lda left_H
sax

== automatic 4x4 interpolation in 8x8 mode (at least horizontally)

left_X looks like: XXXX1111
right_X looks like: 1111XXXX


This doesnt work ofcourse..

if your original data is like

A_C_E_G_

you'd want the screen to look like

ABCDEFGH

But with this routine it will end up looking like

ABEDEFIH

because lda left_a + ldx right_c gives AB

so ldx right_c + lda left_e gives ED
2010-01-25 16:07
Ninja

Registered: Jan 2002
Posts:
Oswald: I told you about the SAX method at least twice, but you always replied something like "Naaah, don't want to redo the tables, not worth the effort" ;)

The bit-shifting-thingie is also used in loaders (when accessing the tables for GCR-conversion).
2010-01-25 17:16
Oswald

Registered: Apr 2002
Posts: 5094
Quote: This doesnt work ofcourse..

if your original data is like

A_C_E_G_

you'd want the screen to look like

ABCDEFGH

But with this routine it will end up looking like

ABEDEFIH

because lda left_a + ldx right_c gives AB

so ldx right_c + lda left_e gives ED


ninja, sorries :)

2010-01-25 19:47
WVL

Registered: Mar 2002
Posts: 902
Well, you can still save a cycle by using TXA and TAX
lda zp1
ldx zp2
sax screen
txa
ldx zp3
sax screen
txa
ldx zp4
sax screen

etc
2010-01-25 19:59
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: Well, you can still save a cycle by using TXA and TAX
lda zp1
ldx zp2
sax screen
txa
ldx zp3
sax screen
txa
ldx zp4
sax screen

etc


Indeed. Sax is more useful when doing tunnels f.e. Where f.e. u want to load the left texel and reuse it on as many screen positions as possible but with another right texel.
2010-01-25 21:01
PopMilo

Registered: Mar 2004
Posts: 146
Quote: yes, and special charset with 16 individual shades for the left/right part. so fex. lowmost 4 bits of the charnr sets brightness of the right part of the char and highest 4 bits the left part. usually one has twice the texture to lda ora the left/right part, but here's a trick to use only one texture: mix the bit's of the left/right part like this:
76543210
lrlrlrlr

l=left
r=right

then with one bit rotate instruction you can push the bits into their correct position, so lda texture asl (=left side) ora texture.


Thanks Oswald!

That is one cool trick :)

Reminds me of chunky mode bit shifting tricks on Amiga.
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
zscs
iAN CooG/HVSC
Youth
MCM/ONSLAUGHT
TheRyk/MYD!
Laddh
Holy Moses/Role
Smasher/F4CG
Acidchild/Padua
Mike
rambo/Therapy/ Resou..
LKP/CFN
𝘁𝗡𝗚/FairLight
grasstust/Hoaxers
Guests online: 124
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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