mybits

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2025 License: MIT Imports: 2 Imported by: 0

README

mybits

This is a collection of functions for bit-manipulative stuff.

The most important thing in here is the encoder and decoder for our event tile bitmaps. This is documented at the top of onoff.c

In addition, we compile the onoff decoder into a WASM module.

Test/debug the native C code

See debug/test-bits.c and debug/test-onoff.c

Test the Go interface

go test .

Build and test the WASM code

./build-wasm && node test-wasm.mjs

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutOfSpace = errors.New("out of buffer space")

Functions

func AndBitmapsCount

func AndBitmapsCount(a, b []byte) int

Compute the binary AND of the bitmaps 'a' and 'b', and return the number of 'on' bits.

func AndBitmapsNonZero

func AndBitmapsNonZero(a, b []byte) bool

Compute the binary AND of the bitmaps 'a' and 'b', and return true if any bits are set

func BitmapFillRect

func BitmapFillRect(bits []byte, width, x, y, w, h int)

Fill a bitmap with a rectangle of 'on' bits. The bitmap's width must be a multiple of 8

func DecodeOnoff

func DecodeOnoff(enc []byte, out []byte) (int, error)

Returns the number of BITS decoded. Returns ErrOutOfSpace if the decoded bit stream is larger than 'out'

func DecodeOnoff3

func DecodeOnoff3(enc []byte, out []byte) (int, error)

Returns the number of BITS decoded. Returns ErrOutOfSpace if the decoded bit stream is larger than 'out'. Note that DecodeOnoff is a wrapper around this function.

func EncodeOnoff

func EncodeOnoff(bits []byte, out []byte) (int, error)

Encode the given bit stream using our on/off encoding. Returns the number of bytes written into 'out'. If the resulting bit stream ends up being larger than 'out', then abort and return ErrOutOfSpace.

func EncodeOnoff3

func EncodeOnoff3(bits []byte, out []byte) (int, error)

Final version Note that EncodeOnoff is a wrapper around this function.

func MaxEncodedBytes

func MaxEncodedBytes(inputBitCount int) int

Return the maximum number of bytes required to encode an input of the given bit length

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL