Super VDP

Ask anything your want about the 32X Mushroom programming.

Moderator: BigEvilCorporation

Post Reply
ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Sun Apr 26, 2009 9:02 pm

It IS actually very clever !
1 byte per line, containing 8 bits, 1 bit per pixel, 0 = transparent, 1 = not transparent.
Then a Lookup Table.
(Note for myself : beware, the mask may be interlaced or unpacked. The jump table has to be set this way).

I have more than 128kB for tiles, so, room for more than 3000 tiles ! Shoudl be enough ;)

Thank you !

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Apr 26, 2009 9:58 pm

Glad I could be of help. If you need any more help or just someone to try things, I'm usually pretty good at assembly and do have a flash cart so I can try stuff on my 32X.

TotOOntHeMooN
Interested
Posts: 38
Joined: Sun Jun 01, 2008 1:12 pm
Location: Lyon, France
Contact:

Post by TotOOntHeMooN » Thu May 07, 2009 3:00 pm

Pleased to see the project move forward ! :)

ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Mon May 11, 2009 7:14 am

Wisely and slow ;)

TotOOntHeMooN
Interested
Posts: 38
Joined: Sun Jun 01, 2008 1:12 pm
Location: Lyon, France
Contact:

Post by TotOOntHeMooN » Mon May 11, 2009 10:29 am

slowly but surely ...

Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake » Mon May 11, 2009 8:27 pm

ob1 wrote:I call unpacking the operation getting from
40516273
to
#0#1#2#3
and
#4#5#6#7
It is achieved in 5 cycles, which is quite fast.
I must have missed this. Can you post the code?

ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Tue May 12, 2009 6:54 am

Sure.
Let r1 = 40516273

Code: Select all

mov.l UNPACK_MASK,r0
mov r1,r2     ; r2 = 40516273
and r0,r1 r   ; r1 = -0-1-2-3
shlr2 r2
shlr2 r2      ; r2 = -4051627
and r0,r2     ; r2 = -4-5-6-7


UNPACK_MASK: dc.l $0F0F0F0F

Well, I lied. 6 cycles.

Toto©

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue May 12, 2009 9:13 am

Loading the mask can be neglected as you'll do it once at the start of the loop. That spreads 1 clock cycle over enough loops that it's essentially zero. So it really is just five cycles. :D

TotOOntHeMooN
Interested
Posts: 38
Joined: Sun Jun 01, 2008 1:12 pm
Location: Lyon, France
Contact:

Post by TotOOntHeMooN » Tue May 12, 2009 2:57 pm

And, you just have to load it for B-Plane. :)
Also, it allow a perfect collision detection.

EDIT:

Else, you can use 48bit :

8 : Transparency Mask
8 : Collision Mask
32 : Tile / Sprite

Very usefull too !

TotOOntHeMooN
Interested
Posts: 38
Joined: Sun Jun 01, 2008 1:12 pm
Location: Lyon, France
Contact:

Post by TotOOntHeMooN » Wed May 13, 2009 8:32 pm

ob1 wrote:It IS actually very clever !
1 byte per line, containing 8 bits, 1 bit per pixel, 0 = transparent, 1 = not transparent. Then a Lookup Table.
Have you read again our previous emails about scrolling, dma, ...
If fact, I'm not sure using O/W was the best way to speed up the display.
ob1 wrote:I have more than 128kB for tiles, so, room for more than 3000 tiles ! Shoudl be enough ;)
In fact, no worry about that, because you can reload tiles memory for what you need...
So you may use :
PPPPXYBBTTTTTTTT

P : palettes (16)
X : real time x flipping
Y : precalculated y flipping
B : banks (4)
T : tiles (256)

2048 tiles used (Y*B*T)
32bit : 64KB
40bit : 80KB
48bit : 96KB
Banks may allow to use 1 Byte for tile indexing and an efficient reloading management.
(1 bank for background, 2 banks for foreground, ...)
Last edited by TotOOntHeMooN on Thu May 14, 2009 12:12 pm, edited 4 times in total.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed May 13, 2009 9:11 pm

TotOOntHeMooN wrote:
ob1 wrote:It IS actually very clever !
1 byte per line, containing 8 bits, 1 bit per pixel, 0 = transparent, 1 = not transparent. Then a Lookup Table.
Have you read again our previous emails about scrolling, dma, ...
If fact, I'm not sure using O/W was the best way to speed up the display.
Which is precisely why the bit mask is a good idea. If you either don't use OW, or if the OW won't work (as mention with the palette banks and color 0), you need a mask for transparency. That means you have two choices: make a mask at run-time; or provide a mask as part of the sprite data. As the previous posts showed, deriving the mask from existing data takes a LOT of cycles. Using a bit mask means you only need one look up to change from bits to the mask itself, which is fast.

TotOOntHeMooN
Interested
Posts: 38
Joined: Sun Jun 01, 2008 1:12 pm
Location: Lyon, France
Contact:

Post by TotOOntHeMooN » Thu May 14, 2009 6:32 am

Chilly Willy wrote: Which is precisely why the bit mask is a good idea [...] Using a bit mask means you only need one look up to change from bits to the mask itself, which is fast.
I'm sure that bitmask was a nice solution. I just doubt about the O/W.
And I think it was more efficient to writting a part of both planes at the same time (because if you see B you can't see A) in a memory buffer an then blit it to the frame buffer.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu May 14, 2009 7:21 am

TotOOntHeMooN wrote:
Chilly Willy wrote: Which is precisely why the bit mask is a good idea [...] Using a bit mask means you only need one look up to change from bits to the mask itself, which is fast.
I'm sure that bitmask was a nice solution. I just doubt about the O/W.
And I think it was more efficient to writting a part of both planes at the same time (because if you see B you can't see A) in a memory buffer an then blit it to the frame buffer.
Overwrite is good if your transparency is all or nothing. Alpha effects are what really slow things down if they aren't in hardware.

TotOOntHeMooN
Interested
Posts: 38
Joined: Sun Jun 01, 2008 1:12 pm
Location: Lyon, France
Contact:

Post by TotOOntHeMooN » Thu May 14, 2009 7:49 am

Chilly Willy wrote:Overwrite is good if your transparency is all or nothing. Alpha effects are what really slow things down if they aren't in hardware.
Yes. Fortunately, no alpha here. :)

With bitmask, you may use some "entries" for doing the good task without any test. This stuf can be used for the "screen" too ...
0 : screen 320x224
1 : clipping border (8x8)

Code: Select all

write_pixel[Clip][Smask][Bmask][Amask](...);

write_pixel[0][0][0][0] -> skip
write_pixel[0][0][0][1] -> write A plane
write_pixel[0][0][1][X] -> write B plane
write_pixel[0][1][X][X] -> write Sprites
write_pixel[1][X][X][X] -> clipping (skip)
No write is performed in the border.
For scrolling, you don't have to compute the starting line and column for tiles before writing part of them near the screen border area. Clipping is performed ! :D
111111111111111111111111111111111111111111
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
100000000000000000000000000000000000000001
111111111111111111111111111111111111111111
Toke less than 10KB, and can be changed, if you need to refrest only parts of it.
Last edited by TotOOntHeMooN on Fri May 15, 2009 1:47 pm, edited 3 times in total.

TotOOntHeMooN
Interested
Posts: 38
Joined: Sun Jun 01, 2008 1:12 pm
Location: Lyon, France
Contact:

Post by TotOOntHeMooN » Thu May 14, 2009 8:02 pm

I need to cold my brain.
Another way for drawing all using bit-mask... Front to back !

Steps :
1- init the screen mask.
2- sprite mask AND screen mask, then draw sprite to the FB [...]
3- tile mask AND screen mask, then draw B-plane tile to the FB [...]
4- draw A-plane tile to the FB [...]

Only unclipped pixels will be written, by watching the screen mask.
In all cases, 70KB will be written to the frame buffer.
Last edited by TotOOntHeMooN on Sat May 16, 2009 9:47 pm, edited 16 times in total.

Post Reply