rawToAmigaInt {adfExplorer}R Documentation

Convert raw values into Amiga integers

Description

Convert raw data into 8, 16, or 32-bit signed or unsigned integer values, conform Amiga specifications.

Usage

rawToAmigaInt(x, bits = 8, signed = F)

Arguments

x

A vector of class raw to be converted into a character.

bits

Number of bits that represents the integer value. Should be 8 or a positive multitude of 8.

signed

A logical value indicating whether the integer should be signed (TRUE, default) or not (FALSE).

Details

The Commodore Amiga has specified the following data formats to represent integer data: BYTE (signed 8-bit integer), UBYTE (unsigned 8-bit integer), WORD (signed 16-bit integer), UWORD (unsigned 16-bit integer), LONG (signed 32-bit integer), ULONG, (unsigned 32-bit integer). This function converts raw data into such integers. Note that WORD and UWORD are also referred to as SHORT and USHORT respectively.

Value

A numeric value (or a vector of values), representing the integer data represented by the provided raw data. Note that R defines integer as 32-bit signed integers and cannot store the 32-bit signed values. Therefore a numeric value is returned rather than an explicit integer.

Author(s)

Pepijn de Vries

See Also

Other raw.operations: amigaDateToRaw(), amigaIntToRaw(), displayRawData(), rawToAmigaDate(), rawToBitmap()

Examples

## Let's start by obtaining unsigned 8-bit integers:
rawToAmigaInt(as.raw(0:255))

## note that this is the same as:
as.numeric(as.raw(0:255))

## but with this function we can also get signed values:
rawToAmigaInt(as.raw(0:255), signed = TRUE)

## Furthermore 32 or 16-bit integers can also be obtained.
## Let's look at 16-bit integers:
rawToAmigaInt(as.raw(0:255), 16)

## Note that 16-bit integers require twice as many bytes
## as 8 bit integers:
length(rawToAmigaInt(as.raw(0:255), 16))
length(rawToAmigaInt(as.raw(0:255), 8))

[Package adfExplorer version 0.1.8 Index]