| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
how do i get the right combinations
hi,
i have 4 different bit paterns..
00
11
01
10
we can pack them in one byte.. #%00110110
how to code a neat routine that calculates al the different combinations and store them into a table...
bye
Testa
|
|
| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
Well
ldx #0
loop lda #0
eor #%10101010
sta tab,x
inc loop+1
inx
bne loop
and they are conjuctive stored...
i have 256 combinations now but some how i,ve got the
feeling something is wrong..
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
you're not specific enough with your question. all the possible combinations means in decimal the numbers from 0-255: all the possible numbers in one byte.
for plotting pixels a general approach is to make 4 tables.
one for #%000000xx combos
one for #%0000xx00 combos
one for #%00xx0000 combos
one for #%xx000000 combos
then you do:
ldx pixelcombo1
lda table1,x
ldx pixelcombo2
ora table2,x
ldx pixelcombo3
ora table3,x
ldx pixelcombo4
ora table4,xű
sta screen |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
:D
ldx #$00
:
txa
sta table,x
inx
bne :-
|
| |
Mace
Registered: May 2002 Posts: 1799 |
Testa,
JackAsser presents you the shortest possible answer with the broadest possible scope.
But I think you'll find it useless :-)
It's pretty damn obvious there are 256 combinations in total, but do you also need all those combinations?
And why would you want to store all combinations?
On top of that, in what order would you want them?
As often the case, there's probably a question behind the question.
You shouldn't ask how to make a solution work, you should tell us your problem. |
| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
well i need this for a 4x4 routine, you know graphics spinning,rotating around in circels..
but no fli or normal graphics, the whole 4x4 effect is in sprites.. so it can be displayed over graphics or in the sideborder...
each combination represents a sprite pointer, the sprite itself is filled with a multycolour pitpatern to represent
the 4x4 dots.. so you have 4 colors.. mc1 mc2 mc3 and background... one spritepointer points to 4 4x4 dots next to each other.
and ofcourse i switch spritepointers each 4th rasterline
no i can divide the screen in colums and i have 4x4 xy position in sprites...
ofcourse after the spinning/rotation calculation you have to calculate al the right combinations but this can be precalculated.. and becoz each byte of this precalculated table represents 4 4x4 dots it is compact and fast..
one thing i didn't get right last night was that i forgot
about the double combinations..
to make things more clear:
lets say:
00 = 1
01 = 2
00 = 3
11 = 4
the first combinations..
1234
1432
1243
1342
1324
1423
now same tabel but swap 1 and 2
2134
2431
2143
2341
2314
2413
now same tabel but swap 2 and 3
and the last is the same but now swap 3 and 4
this way you get al the right combinations but no combinations like 2214 or 1344, no double ones...
i am working on it...
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
all the possible combinations are all the possible combinations of 8 1's and 0's. all numbers from 0-255 in binary form. you dont need a table, simply make the sprite's shape equal to the sprite's pointer. tho this doesnt make much sense, 256 sprites will not leave room for even the sprite pointers alone. you could instead transform your precalculated 4 pixels stored in bytes into a bitmap or character based 4x4 screen. |
| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
i think 255 different sprites is not a problem at all,
256 sprites takes one complete bank, the only problem now is that i need some memory for the sprites parameters
($07F8-$07FF) i think i go for 254 sprites ...
for example. i dont use sprite pointer $ef ($7bc0) and $ff ($7fc0) so i can use $7bf8-$7bff and $7ff8-$7fff as sprite parameters... and switch $d018 right before the 4th rasterline...
this way i can not use any other graphics like a bitmap picture or something else.. so i think i go for a screen without badlines and use sprites only.. and swing
the 4x4 effect in all directions and all borders..
thanks for the help,
Testa
than |
| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
well after some coding and thinking it over, precalculating takes very much memory..
i think this is only usable if you need a small and fast 4x4 sprite routine.. he he...
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
in general: sprite 4x4 is no advantage over other (4col) 4x4, except that you can put it on the border, or use the sprites as a 2nd layer over other gfx. |
| |
Mace
Registered: May 2002 Posts: 1799 |
Quote:or use the sprites as a 2nd layer over other gfx But with 255 sprites in one bank, there's no room for other graphics...
You need to transfer data or reduce the amount of sprites, I'd say. |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: i think 255 different sprites is not a problem at all,
256 sprites takes one complete bank, the only problem now is that i need some memory for the sprites parameters
($07F8-$07FF) i think i go for 254 sprites ...
for example. i dont use sprite pointer $ef ($7bc0) and $ff ($7fc0) so i can use $7bf8-$7bff and $7ff8-$7fff as sprite parameters... and switch $d018 right before the 4th rasterline...
this way i can not use any other graphics like a bitmap picture or something else.. so i think i go for a screen without badlines and use sprites only.. and swing
the 4x4 effect in all directions and all borders..
thanks for the help,
Testa
than
Hmms, it's an alternative of course. I don't know if it's any help but you might wanna check out my S:T Lars Meeting III - Invite. Source included. It's also a 4x4 effect done using sprites and runs in all borders. I had a completly different implementation though. I simply stretched the sprites every 2nd line to get 4x4 resolution and in between I mixed in the 4x4-math code with the raster code. |
| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
yeah... nice atuff jack.. this is what i,ve got in mind,
i think 4x4 in the border is a nice effect...
thanks for the info...
|