ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:packing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
new:packing [2018/02/17 21:20] – created korshunnew:packing [2018/02/17 21:24] korshun
Line 3: Line 3:
 All ACS integers are 32-bit. Value packing functions let you store four 8-bit integers or two 16-bit integers in one 32-bit ''int'' variable. This can be useful, for example, to store RGBA colors in a single variable. Or to store big arrays using less memory. All ACS integers are 32-bit. Value packing functions let you store four 8-bit integers or two 16-bit integers in one 32-bit ''int'' variable. This can be useful, for example, to store RGBA colors in a single variable. Or to store big arrays using less memory.
  
-===== Packing 8-bit integers =====+===== Packing 8-bit integers (bytes) =====
  
 ''int PackBytes(int b1, int b2, int b3, int b4)'' returns a 32-bit integer containing 4 bytes. Byte values must be in [0, 255] range. ''int PackBytes(int b1, int b2, int b3, int b4)'' returns a 32-bit integer containing 4 bytes. Byte values must be in [0, 255] range.
Line 23: Line 23:
 </code> </code>
  
 +===== Packing 16-bit integers (shorts) =====
  
 +''int PackShorts(int short1, int short2)'' returns a 32-bit integer containing two 16-bit integers (shorts). Short values must be in [-32678. 32767] range.
 +
 +  * ''int UnpackShort1(int packed)'' -- returns the first packed short.
 +  * ''int UnpackShort2(int packed)'' -- returns the second packed short.
  
new/packing.txt · Last modified: 2018/02/17 21:25 by korshun