amigaIntToRaw: Convert Amiga integers into raw values

View source: R/01genericSupport.r

amigaIntToRawR Documentation

Convert Amiga integers into raw values

Description

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

Usage

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

Arguments

x

A vector of class numeric which needs to be converted into raw values.

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 numeric values is 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 such integers into raw data.

Value

Returns (a vector of) raw data, representing the integer value(s) conform Amiga specifications.

Author(s)

Pepijn de Vries

See Also

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

Examples

## some unsigned 8-bit integers:
ubyte <- sample.int(255, 100, TRUE)

## The same values as raw data:
amigaIntToRaw(ubyte)

## some signed 8-bit integers:
byte <- sample.int(255, 100, TRUE) - 128

## The same values as raw data:
amigaIntToRaw(byte, signed = TRUE)

## some signed 16-bit integers:
word <- sample.int(2^16, 100, TRUE) - 2^15

## The same values as raw data:
amigaIntToRaw(word, 16, TRUE)

## note that 16-bit integers require
## twice as many raw values:
length(amigaIntToRaw(word, 16, TRUE))
length(amigaIntToRaw(byte, 8, TRUE))

adfExplorer documentation built on May 29, 2024, 11:23 a.m.