Clipmask: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
Fixed: sprites and walls were swapped.
Line 3: Line 3:


One can calculate a mask using this formula:<br>
One can calculate a mask using this formula:<br>
  clipmask=(wall_cstat*65536)+sprite_cstat<br>
  clipmask=(sprite_cstat*65536)+wall_cstat<br>
[[cstat(wall)|wall_cstat]] and [[cstat|sprite_cstat]] should have only set the bits which should be clipped.  
[[cstat|sprite_cstat]] and [[cstat(wall)|wall_cstat]] should have only set the bits which should be clipped.  
The most important bits are blockable(flag 1), hitable(flag 64 for walls and 256 for sprites), masking wall(flag 16).
The most important bits are blockable(flag 1), hitable(flag 64 for walls and 256 for sprites), masking wall(flag 16).


The game has two predefined clipmasks: CLIPMASK0 and CLIPMASK1<br>
The game has two predefined clipmasks: CLIPMASK0 and CLIPMASK1<br>
  CLIPMASK0 = (1*65536)+1 = 1 0001h<br>
  CLIPMASK0 = (1*65536)+1 = 1 0001h<br>
This clips to blockable walls(flag 1) and sprites(flag 1).<br>
This clips to blockable sprites(flag 1) and walls(flag 1).<br>


  CLIPMASK1 = (256*65536)+64 = 100 0040h<br>
  CLIPMASK1 = (256*65536)+64 = 100 0040h<br>
This clips to hitable walls(flag 256) and sprites(flag 64).<br>
This clips to hitable sprites(flag 256) and walls(flag 64).<br>


  Recommend clipmask for hitscan 4294901808) = FFFF 0030h<br>
  Recommend clipmask for hitscan 4294901808) = FFFF 0030h<br>
This clips walls which have any flags and sprites which are flat(horizontally or vertically).
This clips sprites which have any flags and walls which are one-sided or masking..

Revision as of 09:57, 18 May 2008

Clipmask is a mask that tells whether the object should be clipped to or not. The lower 16 bits are anded with cstat of wall and the higher 16 bits are anded with cstat of sprite. Clipmask is used by the getzrange and hitscan commands.


One can calculate a mask using this formula:

clipmask=(sprite_cstat*65536)+wall_cstat

sprite_cstat and wall_cstat should have only set the bits which should be clipped. The most important bits are blockable(flag 1), hitable(flag 64 for walls and 256 for sprites), masking wall(flag 16).

The game has two predefined clipmasks: CLIPMASK0 and CLIPMASK1

CLIPMASK0 = (1*65536)+1 = 1 0001h

This clips to blockable sprites(flag 1) and walls(flag 1).

CLIPMASK1 = (256*65536)+64 = 100 0040h

This clips to hitable sprites(flag 256) and walls(flag 64).

Recommend clipmask for hitscan 4294901808) = FFFF 0030h

This clips sprites which have any flags and walls which are one-sided or masking..