Title: | Commodore Amiga File Format Handler |
---|---|
Description: | Modern software often poorly support older file formats. This package intends to handle many file formats that were native to the antiquated Commodore Amiga machine. This package focuses on file types from the older Amiga operating systems (<= 3.0). It will read and write specific file formats and coerces them into more contemporary data. |
Authors: | Pepijn de Vries [aut, cre, dtc] |
Maintainer: | Pepijn de Vries <[email protected]> |
License: | GPL-3 |
Version: | 0.4.5 |
Built: | 2024-10-25 04:01:28 UTC |
Source: | https://github.com/pepijn-devries/AmigaFFH |
Extract or replace lines of Amiga Basic code
## S3 method for class 'AmigaBasic' x[i] ## S3 replacement method for class 'AmigaBasic' x[i] <- value ## S3 method for class 'AmigaBasic' x[[i]] ## S3 replacement method for class 'AmigaBasic' x[[i]] <- value
## S3 method for class 'AmigaBasic' x[i] ## S3 replacement method for class 'AmigaBasic' x[i] <- value ## S3 method for class 'AmigaBasic' x[[i]] ## S3 replacement method for class 'AmigaBasic' x[[i]] <- value
x |
An |
i |
In case of |
value |
A |
Extract or replace specific lines in an AmigaBasic()
-class object.
The extraction method returns an AmigaBasic()
object based in the lines selected with i
.
The replacement method returns an AmigaBasic()
object with the selected lines replaced with value
.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
## Not run: ## First generate a few lines of Basic code: bas <- as.AmigaBasic(c( "LET a = 1", "a = a + 1", "PRINT \"a now equals\";a", "INPUT \"clear screen (y/n)? \", b$", "IF UCASE$(b$) = \"Y\" THEN CLS" )) ## Select only lines 4 and 5: bas[4:5] ## use negative indices to deselect specific lines. ## deselect line 2: bas[-2] ## replace line 2 bas[2] <- "a = a + 2" ## You can also use AmigaBasic class object as replacement bas[2] <- as.AmigaBasic("a = a + 3") ## single lines can also be selected with '[[' bas[[2]] ## End(Not run)
## Not run: ## First generate a few lines of Basic code: bas <- as.AmigaBasic(c( "LET a = 1", "a = a + 1", "PRINT \"a now equals\";a", "INPUT \"clear screen (y/n)? \", b$", "IF UCASE$(b$) = \"Y\" THEN CLS" )) ## Select only lines 4 and 5: bas[4:5] ## use negative indices to deselect specific lines. ## deselect line 2: bas[-2] ## replace line 2 bas[2] <- "a = a + 2" ## You can also use AmigaBasic class object as replacement bas[2] <- as.AmigaBasic("a = a + 3") ## single lines can also be selected with '[[' bas[[2]] ## End(Not run)
A list of special display modes on the Amiga and corresponding raw
keys.
A data.frame
with 2 columns:
The column named 'mode': a factor
reflecting a display mode, monitor or bitwise mask
The column named 'code': vector of 4 raw
values as used by the Amiga to reflect specific display modes
This table show specific special display modes and to which Amiga monitors they
relate. The raw
codes can be used to interpret specific display modes
as listed in amiga_display_modes()
. This information is used to
interpret IFFChunk()
objects of type 'CAMG'. It is also used to
interpret ILBM images and creating IFF files from raster images.
https://wiki.amigaos.net/wiki/Display_Database#ModeID_Identifiers
http://amigadev.elowar.com/read/ADCD_2.1/AmigaMail_Vol2_guide/node00FD.html
data("amiga_display_keys")
data("amiga_display_keys")
raw
codesA table of display modes on the Amiga and corresponding raw
codes
representing these modes.
A data.frame
with 4 columns:
The column named 'DISPLAY_MODE': a factor
reflecting
the display mode
The column named 'DISPLAY_MODE_ID': A list
containing a vector
of 4 raw
values as used by the Amiga to reflect specific display modes.
These raw values are usually also stored with bitmap images in the Interchange
File Format in a IFFChunk()
called 'CAMG'.
The column named 'MONITOR_ID': A character
string identifying
the monitor that could display the specific mode.
The column named 'CHIPSET': a factor
identifying the minimal
chip set that was required to display the specific mode. OCS is the original
chip set; ECS is the Enhanced Chip Set. AGA is the Advanced Graphics Architecture
chip set (in some countries known as just Advanced Architecture). AGA could
also display OCS and ECS modes, ECS could also display OCS modes, OCS could only
display OCS modes.
This table contains most display modes that were available on the Amiga.
It also contains raw
codes that were used to represent these modes.
The table also contains the hardware monitors that could display the specific
modes, and the minimal chip set that was required for the display mode.
This data is used to interpret IFFChunk()
objects of type
'CAMG'. It is also used to interpret ILBM images and creating IFF files from
raster images.
https://wiki.amigaos.net/wiki/Display_Database#ModeID_Identifiers
http://amigadev.elowar.com/read/ADCD_2.1/AmigaMail_Vol2_guide/node00FD.html
data("amiga_display_modes")
data("amiga_display_modes")
This table lists Amiga monitors and corresponding raw
codes that represent
these monitors.
A data.frame
with 2 columns:
The column named 'MONITOR_ID': a factor
representing an Amiga monitor
The column named 'CODE': A list
containing a vector
of 4
raw
values as used by the Amiga to represent a specific monitor.
This table contains monitors that were compatible with the Amiga.
It also contains raw
codes that were used to represent them.
This data is used to interpret IFFChunk()
objects of type
'CAMG'. It is also used to interpret ILBM images and creating IFF files from
raster images.
https://wiki.amigaos.net/wiki/Display_Database#ModeID_Identifiers
data("amiga_monitors")
data("amiga_monitors")
amiga_palettes
is a named list, where each element represents a commonly
used palette on the Commodore Amiga.
A named list with the following elements:
wb.os1
: A vector
of 4 colours that were used as the default
palette of the Workbench on Amiga OS 1.x.
wb.os2
: A vector
of 8 colours. The first 4 colours are the default
colours of a standard Workbench on Amiga OS 2.x. The latter 4 are additional
colours used by the Workbench expansion MagicWB.
spr.os1
: A vector
of 3 colours that were used by default
for a mouse pointer sprite on Amiga OS 1.x.
spr.os2
: A vector
of 3 colours that were used by default
for a mouse pointer sprite on Amiga OS 2.x.
Some files that contain bitmap images with an indexed palette did not store the
palette in the same file. Amiga Workbench icons (AmigaIcon()
) for instance
only store the index values of the palette, but not the palette itself.
amiga_palettes
therefore provides some commonly used palettes on the Amiga,
such that these files can be interpreted.
data("amiga_palettes")
data("amiga_palettes")
A class that represents the content of Amiga Basic files.
Amiga Basic is a BASIC-style programming language that was shipped with early Commodore Amiga machines. It requires an interpreter to run an Amiga Basic script. The AmigaFFH package does not interpret Amiga Basic scripts. It does allow for encoding and decoding scripts in the binary format in which it was originally stored on the Amiga. Amiga Basic scripts were stored as encoded binaries instead of ASCII text files in order to save (at the time precious) memory and disk space.
Amiga Basic binary files start with a file header (as an identifier) and is followed by each line of the script
as binary data. The AmigaBasic
-class object stores each line of the script as a list
item as a vector
of raw
data. Use as.character()
and as.AmigaBasic()
to switch between
character
data and AmigaBasic
-class objects.
Although there is ample reference material on the Amiga BASIC language, there is no documentation available on the script file storage format. The implementation in the AmigaFFH package is all the result of painstaking reverse engineering on my part. Consequently the Amiga Basic file encoders and decoders implemented here may not be infallible.
Pepijn de Vries
https://en.wikipedia.org/wiki/AmigaBASIC
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
## Not run: ## This creates an AmigaBasic-class object: bas <- as.AmigaBasic("PRINT \"hello world!\"") ## This will decode the object as plain text: as.character(bas) ## End(Not run)
## Not run: ## This creates an AmigaBasic-class object: bas <- as.AmigaBasic("PRINT \"hello world!\"") ## This will decode the object as plain text: as.character(bas) ## End(Not run)
'demo.bas', 'r_logo.shp' and 'ball.shp' as example files for AmigaBasic()
and
AmigaBasicShape()
objects
See AmigaBasic()
and AmigaBasicShape()
for more information
about the format.
The 'r_logo.shp' and 'ball.shp' files are formatted such that they can be read with
read.AmigaBasicShape()
. They serve as an example of the AmigaBasicShape()
class, where
the first represents a blitter object, and the latter a sprite.
The 'demo.bas' file is an example of a binary encoded Amiga Basic script. It can be read with
read.AmigaBasic()
. The script demonstrates how the shape files could be used in Amiga Basic.
## Not run: read.AmigaBasic(system.file("demo.bas", package = "AmigaFFH")) read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) read.AmigaBasicShape(system.file("r_logo.shp", package = "AmigaFFH")) ## End(Not run)
## Not run: read.AmigaBasic(system.file("demo.bas", package = "AmigaFFH")) read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) read.AmigaBasicShape(system.file("r_logo.shp", package = "AmigaFFH")) ## End(Not run)
Obtain a list of reserved Amiga Basic words. These words are not allowed as names of variables or labels in Amiga Basic.
AmigaBasic.reserved()
AmigaBasic.reserved()
This function will return a full list of reserved Amiga Basic words. This list does not serve as a manual for basic (for that purpose consult external resources). This list is meant to consult when choosing label names in Amiga Basic code. These reserved words are not allowed as names.
Returns a vecor
of character
strings of
reserved Amiga Basic words.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
AmigaBasic.reserved()
AmigaBasic.reserved()
A class that represents the content of Amiga Basic BMAP files.
The Amiga operating system made use of library files to execute specific (repetitive/routine) tasks. Amiga Basic was also able to call such routines from library files. In order to do so, it required a 'bmap' file for each library. This file contains a map of the library where it specifies: the name of routine; the ‘Library Vector Offset’ (explained below); and used CPU registers (explained below).
The ‘Library Vector Offset’ is an offset to the base address of a library in memory. This offsets indicates where a specific executable routine starts. The CPU registers are used to (temporary) store (pointers to) input data used by the routine. The BMAP file thus lists which CPU registers are used by specified routines.
Pepijn de Vries
https://en.wikipedia.org/wiki/AmigaOS#Libraries_and_devices
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
A class that represents the file format used by Amiga Basic to store bitmap graphics: blitter objects and sprites.
Amiga Basic used a specific format to store bitmap images that could be displayed using Basic code. Both sprites and blitter objects can be stored and used. This class is used to represent such files.
Pepijn de Vries
Other AmigaBasicShape.operations:
rasterToAmigaBasicShape()
,
read.AmigaBasicShape()
,
write.AmigaBasicShape()
## Not run: ball <- read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) r_logo <- read.AmigaBasicShape(system.file("r_logo.shp", package = "AmigaFFH")) plot(ball) plot(r_logo) ## End(Not run)
## Not run: ball <- read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) r_logo <- read.AmigaBasicShape(system.file("r_logo.shp", package = "AmigaFFH")) plot(ball) plot(r_logo) ## End(Not run)
A comprehensive representation of monochromous Amiga bitmap fonts.
Nowadays fonts are represented by vector graphics an computer systems.
On the original Commodore Amiga, the screen resolution, system memory
and cpu speed were limited. On those systems, it was more efficient
to use bitmap images to represent the glyphs in fonts. The
AmigaBitmapFontSet
and AmigaBitmapFont
classes can be used
to represent Amiga bitmap fonts.
The Commodore Amiga had a directory named 'FONTS' located in the root, where (bitmap) fonts were stored. Font sets were stored under the font name with a *.font extension. Files with the *.font extension did not contain the bitmap images of the font. Rather the *.font file contained information on which font heights (in pixels) are available, in addition to some other meta-information.
The bitmap images were stored in separate files for each individual
height. The AmigaBitmapFontSet
is an S3 class that forms
a comprehensive format (named list
) to represent the *.font
files. The AmigaBitmapFont
is an S3 class is a comprehensive
format (named list
) that represent each font bitmap and glyph
information. The AmigaBitmapFontSet
objects will hold one or more
AmigaBitmapFont
objects.
The AmigaBitmapFont
and AmigaBitmapFontSet
objects are
essentially named list
s. Their structure and most important
elements are described below. Although it is possible to replace
elements manually, it is only advisable when you know what you
are doing as it may break the validity of the font.
fch_FileID
: A factor
with levels 'FontContents', 'TFontContents' and
'ScalableOutline'. It specifies the type of font.
Currently only the first level is supported.
fch_NumEntries
: number of font heights available for this font. It should
match with the length of FontContents
. Do not change
this value manually.
FontContents
: This is a list
with bitmap entries for each specific font
height (in pixels). The name of each element in this list is
'pt' followed by the height. Each element in this list holds
the elements:
Miscellaneous: Miscellaneous information from the \*.font file
fc_FileName
: This element represents the filename of the
nested font bitmap images. Note that it should be a valid
Commodore Amiga filename. It is best to modify this name
using fontName()
. Note that this field could cause
problems as Commodore Amiga filenames can contain characters
that most modern platforms would not allow (such as the
question mark).
BitmapFont
: This element is of type AmigaBitmapFont
and is structured
as described in the following section. The information in this
element is no longer part of the *.font file.
Information represented by a AmigaBitmapFont
is not stored
in *.font files. Rather it is stored in sub-directories of the font
in separate files. It has the following structure:
Miscellaneous: Elements with information on the font properties and style, and also relative file pointers.
glyph.info
: A data.frame
containing glyph info with information
for specific glyphs on each row. Each row matches with a specific
ASCII code, ranging from tf_LoChar
up to tf_HiChar
. There is an additional
row that contains information for the default glyph that is
out of the range of the tf_LoChar
and tf_HiChar
. The data.frame
thus has 2 + tf_HiChar - tf_LoChar
rows. This
table is used to extract and plot a glyph from the
bitmap
image correctly.
bitmap
: Is a monochromous bitmap image of all the font's glyphs in a
single line. It is a simple raster
object
(see grDevices::as.raster()
) with an additional
attribute 'palette', which lists the two colours in the image. In
this palette, the first colour is the background colour and the
second colour is interpreted as the foregroundcolour.
For importing and exporting the following functions are useful:
read.AmigaBitmapFont()
, read.AmigaBitmapFontSet()
,
write.AmigaBitmapFont()
and write.AmigaBitmapFontSet()
.
The following generic functions are implemented for these objects:
plot()
, print
,
as.raster()
and as.raw()
.
Use c()
to combine one or more
AmigaBitmapFont
objects into a AmigaBitmapFontSet
.
Pepijn de Vries
http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node03E0.html http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node03DE.html http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node05BA.html
Other AmigaBitmapFont.operations:
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
Other raster.operations:
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: ## 'font_example' is an example of the AmigaBitmapFontSet object: data(font_example) ## An AmigaBitmapFont object can also be extracted from this object: font_example_9 <- getAmigaBitmapFont(font_example, 9) ## the objects can be printed, plotted, converted to raw data or a raster: print(font_example) plot(font_example) font_example_raw <- as.raw(font_example) font_example_raster <- as.raster(font_example) ## You can also format text using the font: formated_raster <- as.raster(font_example, text = "Foo bar", style = "bold") plot(font_example, text = "Foo bar", style = "underlined", interpolate = F) ## End(Not run)
## Not run: ## 'font_example' is an example of the AmigaBitmapFontSet object: data(font_example) ## An AmigaBitmapFont object can also be extracted from this object: font_example_9 <- getAmigaBitmapFont(font_example, 9) ## the objects can be printed, plotted, converted to raw data or a raster: print(font_example) plot(font_example) font_example_raw <- as.raw(font_example) font_example_raster <- as.raster(font_example) ## You can also format text using the font: formated_raster <- as.raster(font_example, text = "Foo bar", style = "bold") plot(font_example, text = "Foo bar", style = "underlined", interpolate = F) ## End(Not run)
A comprehensive representation of an Amiga Workbench icon file.
Files, directories and other similar objects were depicted as icons on the Amiga Workbench (the Amiga's equivalent of what is now mostly known as the computer's desktop). Icons were actually separate files with the exact same name as the file or directory it represents, except for an additional ‘.info’ extension.
In addition of being a graphical representation of files or directories, icon files also contained additional information about the file. It could for instance indicate which tool would be required to open the file.
The classic Amiga Workbench icon file has a rather complex structure as it is basically a dump of how it is stored in memory. As a result it contains many memory pointers that are really not necassary to store in a file.
The S3 AmigaIcon class is used to represent these complex files as a named
list
. The elements in that list
have mostly identical
names as listed in the document at the top referenced below. The names are usually
self-explanatory, but the referred documents can also be
consulted to obtain more detailed information with respect to each of
these elements. As pointed out earlier, not all elements will have a meaningful
use.
It is possible to change the values of the list, but not all values may be valid.
Note that they will not be fully checked for validity. Invalid values may result in errors
when writing to a binary file using write.AmigaIcon()
, or may simply not
work properly on an Amiga or in an emulator.
The original ‘.info’ file could be extended with NewIcon or with an OS3.5
IFFChunk()
data, that allowed for icons with larger colour depths.
These extensions are currently not implemented.
Use simpleAmigaIcon()
for creating a simple AmigaIcon
object which can
be modified. Use read.AmigaIcon()
to read, and write.AmigaIcon()
to write workbench icon files (*.info). With rawToAmigaIcon()
and
as.raw()
AmigaIcon
can be coerced back and forth from
and to its raw (binary) form.
Pepijn de Vries
http://www.evillabs.net/index.php/Amiga_Icon_Formats http://fileformats.archiveteam.org/wiki/Amiga_Workbench_icon http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node0241.html http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_3._guide/node05D6.html
Other AmigaIcon.operations:
rawToAmigaIcon()
,
read.AmigaIcon()
,
simpleAmigaIcon()
,
write.AmigaIcon()
Coerce raw or character data to an AmigaBasic()
S3 class object
as.AmigaBasic(x, ...)
as.AmigaBasic(x, ...)
x |
When |
... |
Currently ignored. |
Convert text to an AmigaBasic()
S3 class object. The text should
consist of valid Amiga BASIC syntaxis. This function does not perform a
full check of the syntaxis, but will break on some fundamental syntaxis malformations
Returns an AmigaBasic()
class object based on x
.
Pepijn de Vries
https://en.wikipedia.org/wiki/AmigaBASIC
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
Other raw.operations:
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: ## An AmigaBasic object can be created from text. ## Note that each line of code is a seperate element ## in the vector: bas <- as.AmigaBasic(c( "CLS ' Clear the screen", "PRINT \"Hello world!\" ' Print a message on the screen" )) ## Let's make it raw data: bas.raw <- as.raw(bas) ## We can also use the raw data to create an Amiga Basic object: ## Note that this effectively the same as calling 'rawToAmigaBasic' bas <- as.AmigaBasic(bas.raw) ## End(Not run)
## Not run: ## An AmigaBasic object can be created from text. ## Note that each line of code is a seperate element ## in the vector: bas <- as.AmigaBasic(c( "CLS ' Clear the screen", "PRINT \"Hello world!\" ' Print a message on the screen" )) ## Let's make it raw data: bas.raw <- as.raw(bas) ## We can also use the raw data to create an Amiga Basic object: ## Note that this effectively the same as calling 'rawToAmigaBasic' bas <- as.AmigaBasic(bas.raw) ## End(Not run)
Coerce raw
or named list
to an AmigaBasicBMAP()
class object
as.AmigaBasicBMAP(x)
as.AmigaBasicBMAP(x)
x |
When |
An Amiga Basic BMAP file maps the offset of routines in Amiga libraries. This
function converts the raw format in which it would be stored as a file into a comprehensive S3 class object. It
can also convert a named list into an S3 class object. See Arguments' and
Examples' sections on how to format
this list.
Returns a AmigaBasicBMAP()
based on x
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
## Not run: ## For the dos.library, the start of the bmap list would look like: dos.list <- list( xOpen = list( libraryVectorOffset = -30, registers = as.raw(2:3) ), xClose = list( libraryVectorOffset = -36, registers = as.raw(2) ), xRead = list( libraryVectorOffset = -42, registers = as.raw(2:4) ) ) ## Note that the list above is incomplete, the dos.library holds more routines than shown here. ## This merely serves as an example. ## This list can be converted to an S3 class as follows: dos.bmap <- as.AmigaBasicBMAP(dos.list) ## End(Not run)
## Not run: ## For the dos.library, the start of the bmap list would look like: dos.list <- list( xOpen = list( libraryVectorOffset = -30, registers = as.raw(2:3) ), xClose = list( libraryVectorOffset = -36, registers = as.raw(2) ), xRead = list( libraryVectorOffset = -42, registers = as.raw(2:4) ) ) ## Note that the list above is incomplete, the dos.library holds more routines than shown here. ## This merely serves as an example. ## This list can be converted to an S3 class as follows: dos.bmap <- as.AmigaBasicBMAP(dos.list) ## End(Not run)
Coerce an AmigaBasic()
-class object to its character representation
## S3 method for class 'AmigaBasic' as.character(x, ...)
## S3 method for class 'AmigaBasic' as.character(x, ...)
x |
An |
... |
Currently ignored. |
Amiga Basic files are encoded in a binary format and are also stored as such
in AmigaBasic()
-class objects. Use this function to convert
these objects into legible character
data.
A vector
of character
strings, where
each element of the vector
is a character
representation
of a line of Amiga Basic code stored in x
.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
## Not run: ## First create an Amiga Basic object: bas <- as.AmigaBasic("PRINT \"Hello world!\"") ## now convert the object back into text: bas.txt <- as.character(bas) ## End(Not run)
## Not run: ## First create an Amiga Basic object: bas <- as.AmigaBasic("PRINT \"Hello world!\"") ## now convert the object back into text: bas.txt <- as.character(bas) ## End(Not run)
Convert AmigaFFH objects that contain bitmap images into grDevices raster images.
## S3 method for class 'AmigaBasicShape' as.raster(x, selected = c("bitmap", "shadow", "collision"), ...) ## S3 method for class 'AmigaBitmapFont' as.raster(x, text, style, palette, ...) ## S3 method for class 'AmigaBitmapFontSet' as.raster(x, text, style, palette, ...) ## S3 method for class 'hardwareSprite' as.raster(x, background = "#AAAAAA", ...) ## S3 method for class 'IFFChunk' as.raster(x, ...) ## S3 method for class 'AmigaIcon' as.raster(x, selected = F, ...)
## S3 method for class 'AmigaBasicShape' as.raster(x, selected = c("bitmap", "shadow", "collision"), ...) ## S3 method for class 'AmigaBitmapFont' as.raster(x, text, style, palette, ...) ## S3 method for class 'AmigaBitmapFontSet' as.raster(x, text, style, palette, ...) ## S3 method for class 'hardwareSprite' as.raster(x, background = "#AAAAAA", ...) ## S3 method for class 'IFFChunk' as.raster(x, ...) ## S3 method for class 'AmigaIcon' as.raster(x, selected = F, ...)
x |
Object that needs to be converted into a |
selected |
When When |
... |
Currently ignored. |
text |
Text (a |
style |
Argument is only valid when |
palette |
Argument is only valid when |
background |
Use the argument |
Images on the Amiga were stored as bitmap images with indexed colour
palettes. This was mainly due to hardware and memory limitations.
Bitmap images could also be embedded in several file types. This method
can be used to convert AmigaFFH objects read from such files into
grDevices raster images (grDevices::as.raster()
).
Returns a grDevices
raster image (grDevices::as.raster()
)
based on x
. If x
is an animation (IFFChunk()
of type ANIM),
a list
of raster objects is returned.
Pepijn de Vries
Other raster.operations:
AmigaBitmapFont
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
Other raster.operations:
AmigaBitmapFont
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
Other iff.operations:
IFFChunk-class
,
WaveToIFF()
,
getIFFChunk()
,
interpretIFFChunk()
,
rasterToIFF()
,
rawToIFFChunk()
,
read.iff()
,
write.iff()
Other raster.operations:
AmigaBitmapFont
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
Other raster.operations:
AmigaBitmapFont
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## The file contains an interleaved bitmap image that can be ## converted into a raster: example.raster <- as.raster(example.iff) ## the raster can be plotted: plot(example.raster) ## note that the IFFChunk can also be plotted directly: plot(example.iff) ## Hardware sprites can also be converted into raster images. ## Let's generate a 16x16 sprite with a random bitmap: spr <- new("hardwareSprite", VStop = 16, bitmap = as.raw(sample.int(255, 64, replace = TRUE))) ## now convert it into a raster image. ## as the background colour is not specified for hardware ## sprite, we can optionally provide it here. spr.raster <- as.raster(spr, background = "green") ## AmigaBasicShape objects can also be converted into rasters: ball <- read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) ball.rst <- as.raster(ball) ## End(Not run)
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## The file contains an interleaved bitmap image that can be ## converted into a raster: example.raster <- as.raster(example.iff) ## the raster can be plotted: plot(example.raster) ## note that the IFFChunk can also be plotted directly: plot(example.iff) ## Hardware sprites can also be converted into raster images. ## Let's generate a 16x16 sprite with a random bitmap: spr <- new("hardwareSprite", VStop = 16, bitmap = as.raw(sample.int(255, 64, replace = TRUE))) ## now convert it into a raster image. ## as the background colour is not specified for hardware ## sprite, we can optionally provide it here. spr.raster <- as.raster(spr, background = "green") ## AmigaBasicShape objects can also be converted into rasters: ball <- read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) ball.rst <- as.raster(ball) ## End(Not run)
Convert AmigaFFH objects into raw data, as they would be stored in the Commodore Amiga's memory or files.
## S3 method for class 'AmigaBasic' as.raw(x, ...) ## S3 method for class 'AmigaBasicShape' as.raw(x, ...) ## S3 method for class 'AmigaBasicBMAP' as.raw(x) ## S3 method for class 'AmigaBitmapFont' as.raw(x, ...) ## S3 method for class 'AmigaBitmapFontSet' as.raw(x, ...) ## S3 method for class 'AmigaTimeVal' as.raw(x, ...) ## S4 method for signature 'hardwareSprite' as.raw(x) ## S4 method for signature 'IFFChunk' as.raw(x) ## S3 method for class 'IFF.ANY' as.raw(x, ...) ## S3 method for class 'SysConfig' as.raw(x, ...) ## S3 method for class 'AmigaIcon' as.raw(x, ...)
## S3 method for class 'AmigaBasic' as.raw(x, ...) ## S3 method for class 'AmigaBasicShape' as.raw(x, ...) ## S3 method for class 'AmigaBasicBMAP' as.raw(x) ## S3 method for class 'AmigaBitmapFont' as.raw(x, ...) ## S3 method for class 'AmigaBitmapFontSet' as.raw(x, ...) ## S3 method for class 'AmigaTimeVal' as.raw(x, ...) ## S4 method for signature 'hardwareSprite' as.raw(x) ## S4 method for signature 'IFFChunk' as.raw(x) ## S3 method for class 'IFF.ANY' as.raw(x, ...) ## S3 method for class 'SysConfig' as.raw(x, ...) ## S3 method for class 'AmigaIcon' as.raw(x, ...)
x |
An AmigaFFH object that needs to be converted into raw data. See usage section for all supported objects. |
... |
Arguments passed on to |
Objects originating from this package can in some cases be converted into raw data, as they would be stored on an original Amiga. See the usage section for the currently supported objects.
Not all information from x
may be included in the raw
data that is returned, so handle with care.
As this package grows additional objects can be converted with this method.
Returns a vector
of raw
data based on x
.
Pepijn de Vries
Other raw.operations:
as.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: ## read an IFF file as an IFFChunk object: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## This will recreate the exact raw data as it was read from the file: example.raw <- as.raw(example.iff) ## End(Not run)
## Not run: ## read an IFF file as an IFFChunk object: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## This will recreate the exact raw data as it was read from the file: example.raw <- as.raw(example.iff) ## End(Not run)
Get available font sizes (height) from an AmigaBitmapFontSet()
in pixels.
availableFontSizes(x)
availableFontSizes(x)
x |
An |
An AmigaBitmapFontSet()
can hold bitmaps of multiple font
sizes. Use this function to obtain the available size from such a set.
Returns a vector
of numeric
values specifying
the available font sizes (height in pixels) for x
.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
## Not run: data(font_example) ## The example font holds two font sizes (8 and 9): availableFontSizes(font_example) ## End(Not run)
## Not run: data(font_example) ## The example font holds two font sizes (8 and 9): availableFontSizes(font_example) ## End(Not run)
Amiga images are usually stored as bitmap images with indexed colours. This
function converts raw Amiga bitmap data into raster data
(grDevices::as.raster()
).
bitmapToRaster( x, w, h, depth, palette = grDevices::gray(seq(0, 1, length.out = 2^depth)), interleaved = T )
bitmapToRaster( x, w, h, depth, palette = grDevices::gray(seq(0, 1, length.out = 2^depth)), interleaved = T )
x |
a |
w |
Width in pixels of the bitmap image. Can be any positive value. However, bitmap data is ‘word’ aligned on the amiga. This means that the width of the stored bitmap data is a multiple of 16 pixels. The image is cropped to the width specified here. |
h |
Height in pixels of the bitmap image. |
depth |
The colour depth of the bitmap image (i.e., the number of bit planes).
The image will be composed of |
palette |
A |
interleaved |
A |
Bitmap images stored as raw data, representing palette index colours, can
be converted into raster data (grDevices::as.raster()
). The latter
data can easily be plotted in R. It is usually not necessary to call this function
directly, as there are several more convenient wrappers for this function. Those
wrappers can convert specific file formats (such as IFF ILBM and Hardware Sprites,
see as.raster()
) into raster objects. This function is
provided for completeness sake (or for when you want to search for images in an
amiga memory dump).
Returns a raster object (as.raster()
) as specified in
the grDevices()
package. Unless, palette
is set to NULL
,
in which case a matrix
with numeric
palette index values is returned.
Pepijn de Vries
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: ## first load an example image: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## get the raw bitmap data, which is nested in the InterLeaved BitMap (ILBM) ## IFF chunk as the BODY: bitmap.data <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "BODY"))) ## In order to translate the bitmap data into a raster object we need ## to know the image dimensions (width, height and colour depth). This ## information can be obtained from the bitmap header (BMHD): bitmap.header <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "BMHD"))) ## First the bitmap data needs to be unpacked as it was stored in a compresssed ## form in the IFF file (see bitmap.header$Compression): bitmap.data <- unPackBitmap(bitmap.data) ## It would also be nice to use the correct colour palette. This can be obtained ## from the CMAP chunk in the IFF file: bitmap.palette <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "CMAP"))) example.raster <- bitmapToRaster(bitmap.data, bitmap.header$w, bitmap.header$h, bitmap.header$nPlanes, bitmap.palette) ## We now have a raster object that can be plotted: plot(example.raster, interpolate = FALSE) ## End(Not run)
## Not run: ## first load an example image: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## get the raw bitmap data, which is nested in the InterLeaved BitMap (ILBM) ## IFF chunk as the BODY: bitmap.data <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "BODY"))) ## In order to translate the bitmap data into a raster object we need ## to know the image dimensions (width, height and colour depth). This ## information can be obtained from the bitmap header (BMHD): bitmap.header <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "BMHD"))) ## First the bitmap data needs to be unpacked as it was stored in a compresssed ## form in the IFF file (see bitmap.header$Compression): bitmap.data <- unPackBitmap(bitmap.data) ## It would also be nice to use the correct colour palette. This can be obtained ## from the CMAP chunk in the IFF file: bitmap.palette <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "CMAP"))) example.raster <- bitmapToRaster(bitmap.data, bitmap.header$w, bitmap.header$h, bitmap.header$nPlanes, bitmap.palette) ## We now have a raster object that can be plotted: plot(example.raster, interpolate = FALSE) ## End(Not run)
Use this function to correctly combine one or more AmigaBitmapFont()
class objects into a single AmigaBitmapFontSet()
class
object, or to combine multiple AmigaBasic()
class objects.
## S3 method for class 'AmigaBasic' c(...) ## S3 method for class 'AmigaBitmapFont' c(..., name = "font")
## S3 method for class 'AmigaBasic' c(...) ## S3 method for class 'AmigaBitmapFont' c(..., name = "font")
... |
Either |
name |
This argument is only valid when A |
In case ...
are one or more AmigaBasic()
class objects:
AmigaBasic()
class objects are combined into a single
AmigaBasic()
class object in the same order as they
are given as argument to this function. for this purpose the lines of
Amiga Basic codes are simply concatenated.
In case ...
are one or more AmigaBitmapFont()
class objects:
AmigaBitmapFontSet()
class objects can hold multiple
AmigaBitmapFont()
class objects. Use this method to
combine font bitmaps into such a font set. Make sure each bitmap
represents a unique font height (in pixels). When heights are duplicated
an error will be thrown.
You can also specify a name
for the font, that will be embeded
in the object. As this name will also be used as a file name when
writing the font to a file, make sure that it is a valid filename.
Returns an AmigaBitmapFontSet()
in which the
AmigaBitmapFont()
objects are combined. Or when AmigaBasic()
objects are combined, an AmigaBasic()
object is returned
in which the lines of Amiga Basic code are combined.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
## Not run: data(font_example) ## first get some AmigaBitmapFont objects: font8 <- getAmigaBitmapFont(font_example, 8) font9 <- getAmigaBitmapFont(font_example, 9) ## now bind these bitmaps again in a single set font.set <- c(font8, font9, name = "my_font_name") ## Amiga Basic codes can also be combined: bas1 <- as.AmigaBasic("LET a = 1") bas2 <- as.AmigaBasic("PRINT a") bas <- c(bas1, bas2) ## End(Not run)
## Not run: data(font_example) ## first get some AmigaBitmapFont objects: font8 <- getAmigaBitmapFont(font_example, 8) font9 <- getAmigaBitmapFont(font_example, 9) ## now bind these bitmaps again in a single set font.set <- c(font8, font9, name = "my_font_name") ## Amiga Basic codes can also be combined: bas1 <- as.AmigaBasic("LET a = 1") bas2 <- as.AmigaBasic("PRINT a") bas <- c(bas1, bas2) ## End(Not run)
Check Amiga Basic label/variable names for validity
check.names.AmigaBasic(x, ...)
check.names.AmigaBasic(x, ...)
x |
A |
... |
Currently ignored. |
Names for variables and labels should adhere to the following rules in Amiga Basic:
Length of the names should be in the range of 1 up to 255 character
Names cannot be AmigaBasic.reserved()
words
Names should only contain alphanumeric characters or periods and should not contain special characters (i.e., reserved for type definition, such as dollar- or percentage sign)
Names should not start with a numeric character
This function tests names against each of these criteria.
A data.frame
with logical
values with the same number of rows as the length of x
.
Columns in the data.frame corresponds with the criteria listed in the details.
FALSE
for invalid names.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
## Not run: ## These are valid names in Amiga Basic: check.names.AmigaBasic(c("Foo", "Bar")) ## Reserved words and repeated names are not allowed: check.names.AmigaBasic(c("Print", "Foo", "Foo")) ## End(Not run)
## Not run: ## These are valid names in Amiga Basic: check.names.AmigaBasic(c("Foo", "Bar")) ## Reserved words and repeated names are not allowed: check.names.AmigaBasic(c("Print", "Foo", "Foo")) ## End(Not run)
Convert colours to Amiga compatible raw data or vice versa, such that it can be used in graphical objects from the Commodore Amiga.
colourToAmigaRaw( x, colour.depth = c("12 bit", "24 bit"), n.bytes = c("2", "3") ) amigaRawToColour( x, colour.depth = c("12 bit", "24 bit"), n.bytes = c("2", "3") )
colourToAmigaRaw( x, colour.depth = c("12 bit", "24 bit"), n.bytes = c("2", "3") ) amigaRawToColour( x, colour.depth = c("12 bit", "24 bit"), n.bytes = c("2", "3") )
x |
In the case |
colour.depth |
A |
n.bytes |
A |
On the original Commodore Amiga chipset, graphics used indexed palettes of 12 bit colours. Colours are specified by their RGB (Red, Green and Blue) values, each component requiring 4 bits (with corresponding values ranging from 0 up to 15). Data structures on the Amiga were WORD (2 bytes) aligned. Colours are therefore typically stored in either 2 bytes (skipping the first four bits) or 3 bytes (one byte for each value).
These functions can be used to convert R colours into the closest matching
Amiga colour in a raw
format, or vice versa. Note that later Amiga
models with the advanced (graphics) architecture (known as AA or AGA) allowed
for 24 bit colours.
In the case amigaRawToColour
is called, a (vector of)
colour character
string(s) is returned. When colourToAmigaRaw
is called, raw
representing the colour(s) specified in x
is
returned.
Pepijn de Vries
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Let's create some Amiga palettes: colourToAmigaRaw(c("red", "navy blue", "brown", "#34AC5A")) ## let's do the reverse. ## this is white: amigaRawToColour(as.raw(c(0x0f, 0xff))) ## this is white specified in 3 bytes: amigaRawToColour(as.raw(c(0xf0, 0xf0, 0xf0)), n.bytes = "3") ## lower nybbles are ignored, you will get a warning when it is not zero: amigaRawToColour(as.raw(c(0xf0, 0xf0, 0x0f)), n.bytes = "3")
## Let's create some Amiga palettes: colourToAmigaRaw(c("red", "navy blue", "brown", "#34AC5A")) ## let's do the reverse. ## this is white: amigaRawToColour(as.raw(c(0x0f, 0xff))) ## this is white specified in 3 bytes: amigaRawToColour(as.raw(c(0xf0, 0xf0, 0xf0)), n.bytes = "3") ## lower nybbles are ignored, you will get a warning when it is not zero: amigaRawToColour(as.raw(c(0xf0, 0xf0, 0x0f)), n.bytes = "3")
Use a lossy delta-Fibonacci (de)compression to continuous 8-bit signals. This algorithm was used to compress 8-bit audio wave data on the Amiga.
deltaFibonacciCompress(x, ...) deltaFibonacciDecompress(x, ...)
deltaFibonacciCompress(x, ...) deltaFibonacciDecompress(x, ...)
x |
A |
... |
Currently ignored. |
This form of compression is lossy, meaning that information and quality will get lost. 8-bit audio is normally stored as an 8-bit signed value representing the amplitude at specific time intervals. The delta-Fibonacci compression instead stores the difference between two time intervals (delta) as a 4-bit index. This index in turn represents a value from the Fibonacci series (hence the algorithm name). The compression stores small delta values accurately, but large delta values less accurately. As each sample is stored as a 4-bit value instead of an 8-bit value, the amount of data is reduced with almost 50\
The algorithm was first described by Steve Hayes and was used in 8SVX audio stored in the Interchange File Format (IFF). The quality loss is considerable (especially when the audio contained many large deltas) and was even in the time it was developed (1985) not used much. The function is provided here for the sake of completeness. The implementation here only compresses 8-bit data, as for 16-bit data the quality loss will be more considerable.
Returns a vector
of the resulting (de)compressed raw
data.
Pepijn de Vries
https://en.wikipedia.org/wiki/Delta_encoding
http://amigadev.elowar.com/read/ADCD_2.1/Devices_Manual_guide/node02D6.html
## Not run: ## Let's get an audio wave from the ProTrackR package, which we ## can use in this example: buzz <- ProTrackR::PTSample(ProTrackR::mod.intro, 1) ## Let's convert it into raw data, such that we can compress it: buzz.raw <- adfExplorer::amigaIntToRaw(ProTrackR::waveform(buzz) - 128, 8, T) ## Let's compress it: buzz.compress <- deltaFibonacciCompress(buzz.raw) ## Look the new data uses less memory: length(buzz.compress)/length(buzz.raw) ## The compression was lossy, which we can examine by decompressing the ## sample again: buzz.decompress <- deltaFibonacciDecompress(buzz.compress) ## And turn the raw data into numeric data: buzz.decompress <- adfExplorer::rawToAmigaInt(buzz.decompress, 8, T) ## Plot the original wave in black, the decompressed wave in blue ## and the error in red (difference between the original and decompressed ## wave). The error is actually very small here. plot(ProTrackR::waveform(buzz) - 128, type = "l") lines(buzz.decompress, col = "blue") buzz.error <- ProTrackR::waveform(buzz) - 128 - buzz.decompress lines(buzz.error, col = "red") ## this can also be visualised by plotting the orignal wave data against ## the decompressed data (and observe a very good correlation): plot(ProTrackR::waveform(buzz) - 128, buzz.decompress) ## Let's do the same with a sample of a snare drum, which has larger ## delta values: snare.drum <- ProTrackR::PTSample(ProTrackR::mod.intro, 2) ## Let's convert it into raw data, such that we can compress it: snare.raw <- adfExplorer::amigaIntToRaw(ProTrackR::waveform(snare.drum) - 128, 8, T) ## Let's compress it: snare.compress <- deltaFibonacciCompress(snare.raw) ## Decompress the sample: snare.decompress <- deltaFibonacciDecompress(snare.compress) ## And turn the raw data into numeric data: snare.decompress <- adfExplorer::rawToAmigaInt(snare.decompress, 8, T) ## Now if we make the same comparison as before, we note that the ## error in the decompressed wave is much larger than in the previous ## case (red line): plot(ProTrackR::waveform(snare.drum) - 128, type = "l") lines(snare.decompress, col = "blue") snare.error <- ProTrackR::waveform(snare.drum) - 128 - snare.decompress lines(snare.error, col = "red") ## this can also be visualised by plotting the orignal wave data against ## the decompressed data (and observe a nice but not perfect correlation): plot(ProTrackR::waveform(snare.drum) - 128, snare.decompress) ## End(Not run)
## Not run: ## Let's get an audio wave from the ProTrackR package, which we ## can use in this example: buzz <- ProTrackR::PTSample(ProTrackR::mod.intro, 1) ## Let's convert it into raw data, such that we can compress it: buzz.raw <- adfExplorer::amigaIntToRaw(ProTrackR::waveform(buzz) - 128, 8, T) ## Let's compress it: buzz.compress <- deltaFibonacciCompress(buzz.raw) ## Look the new data uses less memory: length(buzz.compress)/length(buzz.raw) ## The compression was lossy, which we can examine by decompressing the ## sample again: buzz.decompress <- deltaFibonacciDecompress(buzz.compress) ## And turn the raw data into numeric data: buzz.decompress <- adfExplorer::rawToAmigaInt(buzz.decompress, 8, T) ## Plot the original wave in black, the decompressed wave in blue ## and the error in red (difference between the original and decompressed ## wave). The error is actually very small here. plot(ProTrackR::waveform(buzz) - 128, type = "l") lines(buzz.decompress, col = "blue") buzz.error <- ProTrackR::waveform(buzz) - 128 - buzz.decompress lines(buzz.error, col = "red") ## this can also be visualised by plotting the orignal wave data against ## the decompressed data (and observe a very good correlation): plot(ProTrackR::waveform(buzz) - 128, buzz.decompress) ## Let's do the same with a sample of a snare drum, which has larger ## delta values: snare.drum <- ProTrackR::PTSample(ProTrackR::mod.intro, 2) ## Let's convert it into raw data, such that we can compress it: snare.raw <- adfExplorer::amigaIntToRaw(ProTrackR::waveform(snare.drum) - 128, 8, T) ## Let's compress it: snare.compress <- deltaFibonacciCompress(snare.raw) ## Decompress the sample: snare.decompress <- deltaFibonacciDecompress(snare.compress) ## And turn the raw data into numeric data: snare.decompress <- adfExplorer::rawToAmigaInt(snare.decompress, 8, T) ## Now if we make the same comparison as before, we note that the ## error in the decompressed wave is much larger than in the previous ## case (red line): plot(ProTrackR::waveform(snare.drum) - 128, type = "l") lines(snare.decompress, col = "blue") snare.error <- ProTrackR::waveform(snare.drum) - 128 - snare.decompress lines(snare.error, col = "red") ## this can also be visualised by plotting the orignal wave data against ## the decompressed data (and observe a nice but not perfect correlation): plot(ProTrackR::waveform(snare.drum) - 128, snare.decompress) ## End(Not run)
Dither is an intentional form of noise applied to an image to avoid colour
banding when reducing the amount of colours in that image. This function
applies dithering to a grDevices raster
image.
dither(x, method, ...) ## S3 method for class 'raster' dither( x, method = c("none", "floyd-steinberg", "JJN", "stucki", "atkinson", "burkse", "sierra", "two-row-sierra", "sierra-lite"), palette, mode = c("none", "HAM6", "HAM8"), ... ) ## S3 method for class 'matrix' dither( x, method = c("none", "floyd-steinberg", "JJN", "stucki", "atkinson", "burkse", "sierra", "two-row-sierra", "sierra-lite"), palette, mode = c("none", "HAM6", "HAM8"), ... )
dither(x, method, ...) ## S3 method for class 'raster' dither( x, method = c("none", "floyd-steinberg", "JJN", "stucki", "atkinson", "burkse", "sierra", "two-row-sierra", "sierra-lite"), palette, mode = c("none", "HAM6", "HAM8"), ... ) ## S3 method for class 'matrix' dither( x, method = c("none", "floyd-steinberg", "JJN", "stucki", "atkinson", "burkse", "sierra", "two-row-sierra", "sierra-lite"), palette, mode = c("none", "HAM6", "HAM8"), ... )
x |
Original image data that needs to be dithered. Should be a raster object
( |
method |
A |
... |
Currently ignored. |
palette |
A palette to which the image should be dithered. It should be a
|
mode |
A |
The approaches implemented here all use error diffusion to achieve dithering. Each pixel is scanned (from top to bottom, from left to right), where the actual colour is sampled and compared with the closest matching colour in the palette. The error (the differences between the actual and used colour) is distributed over the surrounding pixels. The only difference between the methods implemented here is the way the error is distributed. The algorithm itself is identical. For more details consult the listed references.
Which method results in the best quality image will depend on the original image and the palette colours used for dithering, but is also a matter of taste. Note that the dithering algorithm is relatively slow and is provided in this package for your convenience. As it is not in the main scope of this package you should use dedicated software for faster/better results.
Returns a matrix
with the same dimensions as x
containing
numeric
index values. The corresponding palette is returned as attribute,
as well as the index value for the fully transparent colour in the palette.
Pepijn de Vries
R.W. Floyd, L. Steinberg, An adaptive algorithm for spatial grey scale. Proceedings of the Society of Information Display 17, 75-77 (1976).
J. F. Jarvis, C. N. Judice, and W. H. Ninke, A survey of techniques for the display of continuous tone pictures on bilevel displays. Computer Graphics and Image Processing, 5:1:13-40 (1976).
https://en.wikipedia.org/wiki/Floyd-Steinberg_dithering
https://tannerhelland.com/4660/dithering-eleven-algorithms-source-code/
Other colour.quantisation.operations:
index.colours()
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## let's dither the image, using a predefined two colour palette: volcano.dither <- dither(volcano.raster, method = "floyd-steinberg", palette = c("yellow", "green")) ## Convert the indices back into a raster object, such that we can plot it: volcano.dither <- as.raster(apply(volcano.dither, 2, function(x) c("yellow", "green")[x])) par(mfcol = c(1, 2)) plot(volcano.raster, interpolate = F) plot(volcano.dither, interpolate = F) ## results will get better when a better matching colour palette is used. ## for that purpose use the function 'index.colours'. ## End(Not run)
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## let's dither the image, using a predefined two colour palette: volcano.dither <- dither(volcano.raster, method = "floyd-steinberg", palette = c("yellow", "green")) ## Convert the indices back into a raster object, such that we can plot it: volcano.dither <- as.raster(apply(volcano.dither, 2, function(x) c("yellow", "green")[x])) par(mfcol = c(1, 2)) plot(volcano.raster, interpolate = F) plot(volcano.dither, interpolate = F) ## results will get better when a better matching colour palette is used. ## for that purpose use the function 'index.colours'. ## End(Not run)
An example object for the AmigaBitmapFontSet()
class used in
examples throughout this package. It also contains a nested
AmigaBitmapFont()
class objects, which can be obtain by
using getAmigaBitmapFont(font_example, 9)
.
font_example
is an AmigaBitmapFontSet()
object. For details see the object class documentation.
The font_example
contains a font that was designed as an example
for this package. It holds bitmap glyphs for 8 and 9 pixels tall
characters.
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
data("font_example")
data("font_example")
Extract or replace a font name from an AmigaBitmapFontSet()
object.
fontName(x) fontName(x) <- value
fontName(x) fontName(x) <- value
x |
An |
value |
A |
The name of a font is embeded at multiple locations of an AmigaBitmapFontSet()
object. This function can be used to extract or replace the font name
correctly. This is also the name that will be used when writing the
font to a file with write.AmigaBitmapFontSet()
.
Returns the font name. In case of the replace function, a copy
of x
is returned with the name replaced by 'value
'.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
## Not run: data(font_example) ## show the name of the example font: fontName(font_example) ## This is how you change the name into "foo" fontName(font_example) <- "foo" ## see it worked: fontName(font_example) ## End(Not run)
## Not run: data(font_example) ## show the name of the example font: fontName(font_example) ## This is how you change the name into "foo" fontName(font_example) <- "foo" ## see it worked: fontName(font_example) ## End(Not run)
Extract a specific AmigaBitmapFont()
from a
AmigaBitmapFontSet()
.
getAmigaBitmapFont(x, size)
getAmigaBitmapFont(x, size)
x |
An |
size |
A single |
An AmigaBitmapFontSet()
object can hold one or more
bitmaps for specific font sizes (heights). Use this function to
obtain such a specific AmigaBitmapFont()
.
Returns an AmigaBitmapFont()
of the requested size.
An error is thrown when the requested size is not available.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
## Not run: data(font_example) ## get the font object for the first available size: font <- getAmigaBitmapFont(font_example, availableFontSizes(font_example)[1]) ## End(Not run)
## Not run: data(font_example) ## get the font object for the first available size: font <- getAmigaBitmapFont(font_example, availableFontSizes(font_example)[1]) ## End(Not run)
IFFChunk()
s can be nested in a tree-like structure. Use this method
to get a specific chunk with a specific label.
## S4 method for signature 'IFFChunk,character,integer' getIFFChunk(x, chunk.path, chunk.number) ## S4 method for signature 'IFFChunk,character,missing' getIFFChunk(x, chunk.path, chunk.number) ## S4 replacement method for signature 'IFFChunk,character,missing,IFFChunk' getIFFChunk(x, chunk.path, chunk.number = NULL) <- value ## S4 replacement method for signature 'IFFChunk,character,integer,IFFChunk' getIFFChunk(x, chunk.path, chunk.number = NULL) <- value
## S4 method for signature 'IFFChunk,character,integer' getIFFChunk(x, chunk.path, chunk.number) ## S4 method for signature 'IFFChunk,character,missing' getIFFChunk(x, chunk.path, chunk.number) ## S4 replacement method for signature 'IFFChunk,character,missing,IFFChunk' getIFFChunk(x, chunk.path, chunk.number = NULL) <- value ## S4 replacement method for signature 'IFFChunk,character,integer,IFFChunk' getIFFChunk(x, chunk.path, chunk.number = NULL) <- value
x |
An |
chunk.path |
A |
chunk.number |
A |
value |
An |
IFFChunk
objects have 4 character
identifiers, indicating what type
of chunk you are dealing with. These chunks can be nested inside of each other.
Use this method to extract specific chunks by referring to there respective
identifiers. The identifiers are shown when calling print
on an
IFFChunk()
. If a specified path doesn't exist, this method throws a
‘subscript out of range’ error.
Returns an IFFChunk()
object nested inside x
at the
specified path. Or in case of the replace method the original chunk x
is
returned with the target chunk replaced by value
.
Pepijn de Vries
Other iff.operations:
IFFChunk-class
,
WaveToIFF()
,
as.raster.AmigaBasicShape()
,
interpretIFFChunk()
,
rasterToIFF()
,
rawToIFFChunk()
,
read.iff()
,
write.iff()
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## Get the BMHD (bitmap header) from the ILBM (interleaved bitmap) chunk: bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD")) ## This is essentially doing the same thing, but we now explicitly ## tell the method to get the first element for each specified label: bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD"), c(1L, 1L)) ## Let's modify the bitmap header and replace it in the parent IFF chunk. bmhd.itpt <- interpretIFFChunk(bmhd) ## Let's disable the masking, the bitmap will no longer be transparent: bmhd.itpt$Masking <- "mskNone" bmhd <- IFFChunk(bmhd.itpt) ## Now replace the header from the original iff with the modified header: getIFFChunk(example.iff, c("ILBM", "BMHD")) <- bmhd ## End(Not run)
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## Get the BMHD (bitmap header) from the ILBM (interleaved bitmap) chunk: bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD")) ## This is essentially doing the same thing, but we now explicitly ## tell the method to get the first element for each specified label: bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD"), c(1L, 1L)) ## Let's modify the bitmap header and replace it in the parent IFF chunk. bmhd.itpt <- interpretIFFChunk(bmhd) ## Let's disable the masking, the bitmap will no longer be transparent: bmhd.itpt$Masking <- "mskNone" bmhd <- IFFChunk(bmhd.itpt) ## Now replace the header from the original iff with the modified header: getIFFChunk(example.iff, c("ILBM", "BMHD")) <- bmhd ## End(Not run)
An S4 class object that represent graphical objects known as hardware sprites on the Commodore Amiga.
Amiga hardware supported sprites, which are graphical objects that could be moved around the display and independently from each other. Basic sprites were 16 pixels wide and any number of pixels high and were composed of four colours, of which one is transparent.
More complex sprites could be formed by linking separate sprites together. That way, sprites could become wider, or be composed of more colours. Such extended sprites are currently not supported by this package.
A well known example of hardware sprite on the Commodore Amiga is the mouse pointer.
This object simply holds the basic information belonging to
hardware sprite. Use as.raster()
to convert it to
a raster which is a more useful graphical element in R.
VStart
The vertical starting position of a sprite.
HStart
The horizontal starting position of a sprite.
VStop
The vertical stopping position of a sprite. The
height of a sprite should be given by VStart
- VStop
.
control.bits
8 logical
values used for extending
sprites. The values are stored in this objects but extending
sprites is not (yet) supported.
bitmap
Interleaved bitmap data containing information on the pixel colour numbers of the sprite.
colours
A vector of the 3 colours used for the sprite.
end.of.data
Sprite data can be followed by another sprite. It is terminated
with two WORDS equalling zero (raw(4)
). Repeated sprite data is currently not
supported.
Pepijn de Vries
http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node00AE.html
## This generates a sprite of a single line (16x1 pixels) with an empty bitmap: new("hardwareSprite") ## This generates a sprite of a single line (16x1 pixels) where ## the bitmap contains some coloured pixels: new("hardwareSprite", bitmap = as.raw(c(0x01,0x02,0x03,0x04))) ## This generates a sprite of 16x16 pixels: new("hardwareSprite", VStop = 16, bitmap = as.raw(sample.int(255, 64, replace = TRUE)))
## This generates a sprite of a single line (16x1 pixels) with an empty bitmap: new("hardwareSprite") ## This generates a sprite of a single line (16x1 pixels) where ## the bitmap contains some coloured pixels: new("hardwareSprite", bitmap = as.raw(c(0x01,0x02,0x03,0x04))) ## This generates a sprite of 16x16 pixels: new("hardwareSprite", VStop = 16, bitmap = as.raw(sample.int(255, 64, replace = TRUE)))
An S4 class structure to represent data stored in the Interchange File Format (IFF).
The Interchange File Format (IFF) was introduced in 1985 by Electronic Arts. This format stores files in standardised modular objects, called ‘chunks’. At the start of each chunk it is specified what type of data can be expected and what the size of this data is. This was a very forward thinking way of storing data, similar structures are still used in modern file formats (such as PNG images and XML files).
Although the IFF format is still in use, and new standardised chunk types can still be registered, this package will focus on the older chunk types that were primarily used on the Commodore Amiga (OS <= 3.0). IFF files could contain any kind of information. It could contain bitmap images, but also audio clips or (formatted) texts.
The IFFChunk
class is designed such that it theoretically can hold
any type of IFF data. This package will mostly focus on the early IFF file types
(i.e., IFF chunks as originally registered by Electronic Arts). IFF files are
read by this package in a none lossy way (read.iff()
), such that all
information is preserved (even if it is of an unknown type, as long as the chunk
identifier is 4 characters long).
This means that the object needs to be interpreted in order to make sense out of
it (interpretIFFChunk()
). This interpretation returns simplified
interpretations of class IFF.ANY
when it is supported (see
IFFChunk-method()
for supported chunk types). Note that in the
interpretation process (meta-)information may get lost. converting
IFF.ANY
objects back into IFFChunk()
objects (if possible)
could therefore result in an object that is different from then one stored in the
original file and could even destroy the correct interpretation of IFF objects.
IFF files should thus be handled with care.
chunk.type
A four character
long code reflecting the type of
information represented by this chunk.
chunk.data
A list
that holds either one or more valid
IFFChunk
s or a single vector
of raw
data. This data
can only be interpreted in context of the specified type or in some cases
information from other IFFChunk
s.
Pepijn de Vries
https://wiki.amigaos.net/wiki/IFF_Standard
https://wiki.amigaos.net/wiki/IFF_FORM_and_Chunk_Registry
https://en.wikipedia.org/wiki/Interchange_File_Format
Other iff.operations:
WaveToIFF()
,
as.raster.AmigaBasicShape()
,
getIFFChunk()
,
interpretIFFChunk()
,
rasterToIFF()
,
rawToIFFChunk()
,
read.iff()
,
write.iff()
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## 'example.iff' is of class IFFChunk: class(example.iff) ## let's plot it: plot(example.iff) ## The default constructor will create an empty FORM: new("IFFChunk") ## The constructor can also be used to create simple chunks: new("IFFChunk", chunk.type = "TEXT", chunk.data = list(charToRaw("A simple chunk"))) ## End(Not run)
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## 'example.iff' is of class IFFChunk: class(example.iff) ## let's plot it: plot(example.iff) ## The default constructor will create an empty FORM: new("IFFChunk") ## The constructor can also be used to create simple chunks: new("IFFChunk", chunk.type = "TEXT", chunk.data = list(charToRaw("A simple chunk"))) ## End(Not run)
Convert IFF.ANY
objects (created with interpretIFFChunk()
) into
IFFChunk()
objects. A basic IFFChunk()
can also be
created with this method by providing the chunk type name.
IFFChunk(x, ...) ## S3 method for class 'character' IFFChunk(x, ...) ## S3 method for class 'IFF.FORM' IFFChunk(x, ...) ## S3 method for class 'IFF.BODY' IFFChunk(x, ...) ## S3 method for class 'IFF.ANNO' IFFChunk(x, ...) ## S3 method for class 'IFF.AUTH' IFFChunk(x, ...) ## S3 method for class 'IFF.CHRS' IFFChunk(x, ...) ## S3 method for class 'IFF.NAME' IFFChunk(x, ...) ## S3 method for class 'IFF.TEXT' IFFChunk(x, ...) ## S3 method for class 'IFF.copyright' IFFChunk(x, ...) ## S3 method for class 'IFF.CHAN' IFFChunk(x, ...) ## S3 method for class 'IFF.VHDR' IFFChunk(x, ...) ## S3 method for class 'IFF.8SVX' IFFChunk(x, ...) ## S3 method for class 'IFF.ILBM' IFFChunk(x, ...) ## S3 method for class 'IFF.CMAP' IFFChunk(x, ...) ## S3 method for class 'IFF.BMHD' IFFChunk(x, ...) ## S3 method for class 'IFF.CAMG' IFFChunk(x, ...) ## S3 method for class 'IFF.CRNG' IFFChunk(x, ...) ## S3 method for class 'IFF.ANIM' IFFChunk(x, ...) ## S3 method for class 'IFF.ANHD' IFFChunk(x, ...) ## S3 method for class 'IFF.DLTA' IFFChunk(x, ...) ## S3 method for class 'IFF.DPAN' IFFChunk(x, ...)
IFFChunk(x, ...) ## S3 method for class 'character' IFFChunk(x, ...) ## S3 method for class 'IFF.FORM' IFFChunk(x, ...) ## S3 method for class 'IFF.BODY' IFFChunk(x, ...) ## S3 method for class 'IFF.ANNO' IFFChunk(x, ...) ## S3 method for class 'IFF.AUTH' IFFChunk(x, ...) ## S3 method for class 'IFF.CHRS' IFFChunk(x, ...) ## S3 method for class 'IFF.NAME' IFFChunk(x, ...) ## S3 method for class 'IFF.TEXT' IFFChunk(x, ...) ## S3 method for class 'IFF.copyright' IFFChunk(x, ...) ## S3 method for class 'IFF.CHAN' IFFChunk(x, ...) ## S3 method for class 'IFF.VHDR' IFFChunk(x, ...) ## S3 method for class 'IFF.8SVX' IFFChunk(x, ...) ## S3 method for class 'IFF.ILBM' IFFChunk(x, ...) ## S3 method for class 'IFF.CMAP' IFFChunk(x, ...) ## S3 method for class 'IFF.BMHD' IFFChunk(x, ...) ## S3 method for class 'IFF.CAMG' IFFChunk(x, ...) ## S3 method for class 'IFF.CRNG' IFFChunk(x, ...) ## S3 method for class 'IFF.ANIM' IFFChunk(x, ...) ## S3 method for class 'IFF.ANHD' IFFChunk(x, ...) ## S3 method for class 'IFF.DLTA' IFFChunk(x, ...) ## S3 method for class 'IFF.DPAN' IFFChunk(x, ...)
x |
An S3 class |
... |
Arguments passed onto methods underlying the interpretation of the
specific IFF chunks. Allowed arguments depend on the specific type of IFF chunk that
|
IFF data is stored in a IFFChunk-class()
object when read from an
IFF file (read.iff()
). These objects reflect the file structure
well, but the data is stored as raw
information. IFF files can contain
a wide variety of information types, ranging from bitmap images to audio
clips. The raw information stored in IFFChunk()
objects can
be interpreted into more meaningful representations that can be handled in
R. This is achieved with the interpretIFFChunk()
method, which
returns IFF.ANY
objects.
These IFF.ANY
objects are a less strict representation of the
IFF Chunk, but are easier to handle in R. The interpretation method is lossy
and may not preserve all information in the IFF.ANY
object.
The IFFChunk-method()
can coerce IFF.ANY
back
to the more strictly defined IFFChunk-class()
objects.
Be careful with conversions between IFFChunk-class()
and
IFF.ANY
objects and vice versa, as information may get lost.
More detailed information about IFF chunks can be found in the IFF chunk registry (see references).
IFF.FORM
represents a FORM chunk, which is a container that can hold any kind of chunk.
When interpreted, it is represented as a list
, where each element is an interpreted chunk
nested inside the FORM.
IFF.BODY
represents the actual data in an IFF file. However, without context
this chunk cannot be interpreted and is therefore interpreted as a vector of raw
data.
IFF.ANIM
represents an animation (ANIM) chunk. When interpreted, it will return a list
where each
element is an animation frame represented as an IFF.ILBM
object. Each animation frame should be
nested inside an ILBM chunk nested inside a FORM chunk, nested inside an ANIM chunk.
IFF.ANHD
represents an ANimation HeaDer (ANHD) chunk. When interpreted,
it returns a named list
containing the
following information:
operation
is a character
string indicating how the bitmap
data for the animation frame is encoded. Can be one of the following:
"standard
", "XOR
", "LongDeltaMode
",
"ShortDeltaMode
", "GeneralDeltamode
",
"ByteVerticalCompression
", "StereoOp5
", or
"ShortLongVerticalDeltaMode
". Currently, only the
ByteVerticalCompression is implemented in this package.
mask
is a vector
of 8 logical
values. It is currently
ignored.
w
and h
are positive numeric
values, specifying
the width and height of the frame (should be identical for all frames).
x
and y
are numeric
values, specifying the plotting
position for the frame.
abstime
is a positive numeric
value - currently unused - used for
timing the frame relative to the time the first frame was displayed. In
jiffies (1/60 sec).
reltime
is a positive numeric
value for timing the frame
relative to time previous frame was displayed. In jiffies (1/60 sec).
interleave
is currently unused. It should be set to 0.
pad0
is a padding byte (raw
) for future use.
flags
is a vector
of 32 logical
values. They contain
information on how the bitmap data is stored.
pad1
are 16 padding bytes (raw
) for future use.
IFF.DPAN
represents an DPaint ANimation (DPAN) chunk. Some software will
require this chunk to correctly derive the total number of frames in the animation.
When interpreted, it will return a named list
with the following elements:
version
a numeric
version number.
nframes
a positive numeric
value, indicating the number
of frames in the animation.
flags
a vector
of 32 logical
values. Ignored in
this package as it was intended for future implementations.
IFF.DLTA
represents a delta mode data chunk (DLTA). The first animation
frame is stored as a normal InterLeaved BitMap (ILBM) image as described below.
The following frames only store differences in bitmap data compared to the
previous frames but is not interleaved. They are thus incorrectly embedded in
an ILBM chunk (but is kept so for backward compatibility). When interpreted,
a grDevices
raster object is returned only showing the differences. It
is not very meaningful to interpret these chunks on their own, but rather the
entire parent ANIM chunk.
IFF.ILBM
represents InterLeaved BitMap (ILBM) chunks. It is interpreted here as a
raster image (see grDevices::as.raster()
). ILBM chunks are usually nested inside
a FORM container.
IFF.BMHD
represents the header chunk of a bitmap (BMHD), and should always be present
(nested inside) an ILBM chunk. It is interpreted as a named list containing the following elements:
w
and h
are positive numeric
values specifying
the bitmap width and height in pixels. Note that the width
can be any positive whole number, whereas the bitmap data always
has a width divisible by 16.
x
and y
are numeric
values specifying the plotting
position relative to the top left position of the screen.
Although required in the bitmap header. It is ignored in the
interpretation of bitmap images.
nPlanes
is a positive value indicating the number of
bitplanes in the image. The number of colours in an image
can be calculated as 2^nPlanes
.
Masking
indicates whether there are bitplanes that should
be masked (i.e. are treated as transparent). It is a character
string equalling any of the following: "mskNone
",
"mskHasMask
", "mskHasTransparentColour
",
"mskLasso
" or "mskUnknown
". Only the first (no transparency)
and third (one of the colours should be treated as transparent)
id is currently interpreted correctly. The others are ignored.
"mskUnknown
" means that an undocumented mask is applied
to the image.
Compression
indicates whether the bitmap data is
compressed. It is a character
string that can equal any
of the following: "cmpNone
", "cmpByteRun1
" or
"cmpUnknown
". The latter means an undocumented form of
compression is applied and is currently ignored. In most cases
bitmap data is compressed with the cmpByteRun1
algorithm
(packBitmap()
). In some cases, bitmap data is not
compressed (cmpNone
).
pad
is a raw
byte that is only used to
align data. It is ignored in the interpretation.
transparentColour
is a numeric
value that indicates
which colour number in the palette should be treated as fully
transparent (when Masking
equals
"mskHasTransparentColour
").
xAspect
and yAspect
or positive numeric
values that indicate the aspect ratio of
the pixels in the image. Amiga screen modes allowed for some
extreme pixel aspect ratios. These values are used to stretch
the image to their intended display mode.
pageWidth
and pageHeight
are positive
numeric
values indicating the size of the screen in which
the image should be displayed. They are ignored in the
interpretation of the image.
IFF.CMAP
represents the colour map (CMAP) or palette of a bitmap image. Although common,
the chunk is optional and can be omitted from the parent ILBM chunk. It is interpreted as a
vector of colours (i.e., a character
string formatted as '#RRGGBB' or named colours such as
'blue').
IFF.CAMG
represents a chunk with information with respect
to the display mode in which the bitmap image should be displayed.
This information can be used to determine the correct pixel aspect
ratio, or is sometimes required to correctly interpret the bitmap
information. The IFF.CAMG
chunk is interpreted as a named list
containing the following elements:
monitor
: a factor
indicating the hardware monitor
on which the image was created and should be displayed (see
amiga_monitors()
).
display.mode
: a factor
indicating the display
mode in which the image should be displayed (see
amiga_display_modes()
).
IFF.CRNG
is an optional chunk nested in an ILBM chunk.
It represents a ‘colour range’ and is used to cycle through
colours in the bitmap's palette in order to achieve
animation effects. It is interpreted as a named list with the
following elements. This chunk is currently not used with
the interpretation of ILBM images.
padding
are two raw
padding bytes and are
ignored when interpreted.
rate
is a numeric
value specifying the rate
at which the colours are cycled. The rate is in steps per
second.
flags
is a flag that indicates how colours should
be cycled. It is a character
string that can equal
any of the following: "RNG_OFF
", "RNG_ACTIVE
",
"RNG_REVERSE
" or "RNG_UNKNOWN
". When equal to the
first, colours are not cycled. When equal to the second, colours
are cycled. When equal to the third, colours are cycled in
reverse direction. When equal to the latter, an undocumented
form of cycling is applied.
low
and high
are numeric
indices of
colours between which should be cycled. Only colour from
index low
up to index high
are affected.
IFF.8SVX
represents 8-bit sampled voice chunks (8SVX). The original
Amiga supported 8-bit audio which could be stored using the IFF. 8SVX chunks
can contain separate audio samples for each octave. 8SVX chunks are usually
stored inside a FORM container. Its body chunk contains 8-bit PCM wave data that
could be compressed. When the 8SVX chunk is
interpreted with this package, a list
is returned where each element
represents an octave given as a tuneR::Wave()
object. Possible
chunks nested in 8SVX chunks and currently supported by this package are
as follows.
IFF.VHDR
represents voice header chunks (VHDR). It contains (meta-)information about
the audio stored in the body of the parent 8SVX chunk. When interpreted, a named list
is
returned with the following elements:
oneShotHiSamples
is a numeric
value indicating how many samples there are in the
audio wave of the first octave in the file, that should not be looped (repeated).
repeatHiSamples
is a numeric
value indicating how many samples there are in the
audio wave of the first octave in the file, that should be looped (repeated).
samplesPerHiCycle
is a numeric
value specifying the
number of samples per repeat cycle in the first octave, or 0 when unknown.
The number of repeatHiSamples
should be an exact multiple of
samplesPerHiCycle
.
samplesPerSec
is a numeric
value specifying the data
sampling rate.
ctOctave
a positive whole numeric
value indicating how many octaves are included.
In 8SVX files the audio wave is resampled for each octave. The wave data in the body starts with
the audio sample in the highest octave (least number of samples). The data is then followed by
each subsequent octave, where the number of samples increase by a factor of 2 for each octave.
sCompression
is a character
string indicating whether and how the wave data in the body
is compressed. It can have one of the following values: "sCmpNone
" (no compression),
"sCmpFibDelta
" (deltaFibonacciCompress()
ion is applied), "sCmpUnknown
" (an
undocumented and unknown form of compression is applied).
volume
is a numeric value between 0
(minimum) and 0x10000
(maximum) playback volume.
IFF.CHAN
represents the channel chunk (CHAN). When interpreted it returns a named list
with 1 named element:
"channel
". It's value can be one of the following character
strings "LEFT
", "RIGHT
" or
"STEREO
". This indicates for how many (one or two) audio channels data is available in the
body of the parent
8SVX chunk. It also indicates two which channels the audio should be played back.
IFF.ANNO
, IFF.AUTH
, IFF.CHRS
, IFF.NAME
, IFF.TEXT
and IFF.copyright
are all unformatted text chunks that can be included optionally in any of the chunk types.
Respectively, they
represent an annotation, the author's name, a generic character string, the name of the work,
generic unformatted text,
and copyright text. They are interpreted as a character
string.
Returns an IFFChunk-class()
representation of x
.
https://wiki.amigaos.net/wiki/IFF_FORM_and_Chunk_Registry
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## interpret the IFF file (in some cases information ## will get lost in this step): example.itpt <- interpretIFFChunk(example.iff) ## now coerce back to a formal IFFChunk class object. ## Only information in the interpreted object is used ## The coerced object may therefore depart from the ## original read from the file. example.coerce <- IFFChunk(example.itpt) ## and indeed the objects are not identical, as shown below. ## In this case the difference is not disastrous, the order ## of the colours in the palette have shifted. But be careful ## with switching between formal IFFChunk objects and ## interpreted IFF.ANY objects. identical(example.iff, example.coerce) ## It is also possible to create simple IFFChunk objects ## by providing the desired chunk type identifier as a ## character string. ## This creates a basic bitmap header: bmhd <- IFFChunk("BMHD") ## This creates a basic colour palette: cmap <- IFFChunk("CMAP") ## End(Not run)
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## interpret the IFF file (in some cases information ## will get lost in this step): example.itpt <- interpretIFFChunk(example.iff) ## now coerce back to a formal IFFChunk class object. ## Only information in the interpreted object is used ## The coerced object may therefore depart from the ## original read from the file. example.coerce <- IFFChunk(example.itpt) ## and indeed the objects are not identical, as shown below. ## In this case the difference is not disastrous, the order ## of the colours in the palette have shifted. But be careful ## with switching between formal IFFChunk objects and ## interpreted IFF.ANY objects. identical(example.iff, example.coerce) ## It is also possible to create simple IFFChunk objects ## by providing the desired chunk type identifier as a ## character string. ## This creates a basic bitmap header: bmhd <- IFFChunk("BMHD") ## This creates a basic colour palette: cmap <- IFFChunk("CMAP") ## End(Not run)
This file is provided to demonstrate the structure of an Interchange File Format and is used in several examples throughout this package.
See IFFChunk-class()
and references for more information
about the Interchange File Format.
The Interchange File Format stores information compartmentally in separate
containers called 'chunks'. This file demonstrates how a bitmap image
is stored in this format. In addition to the raw bitmap data, the file
also contains meta-information on the bitmap dimensions, its colour palette and
the display mode that should be used on an Amiga. See also
interpretIFFChunk()
, IFFChunk-class()
and the example for bitmapToRaster()
.
https://en.wikipedia.org/wiki/Interchange_File_Format
https://wiki.amigaos.net/wiki/A_Quick_Introduction_to_IFF
## Not run: filename <- system.file("ilbm8lores.iff", package = "AmigaFFH") example.iff <- read.iff(filename) ## show the structure of the IFF file: print(example.iff) ## End(Not run)
## Not run: filename <- system.file("ilbm8lores.iff", package = "AmigaFFH") example.iff <- read.iff(filename) ## show the structure of the IFF file: print(example.iff) ## End(Not run)
Converts an image represented by a grDevices raster
object into a
matrix containing numeric indices of a quantised colour palette.
index.colours( x, length.out = 8, palette = NULL, background = "#FFFFFF", dither = c("none", "floyd-steinberg", "JJN", "stucki", "atkinson", "burkse", "sierra", "two-row-sierra", "sierra-lite"), colour.depth = c("12 bit", "24 bit"), ... )
index.colours( x, length.out = 8, palette = NULL, background = "#FFFFFF", dither = c("none", "floyd-steinberg", "JJN", "stucki", "atkinson", "burkse", "sierra", "two-row-sierra", "sierra-lite"), colour.depth = c("12 bit", "24 bit"), ... )
x |
A raster object ( |
length.out |
A It can also be a |
palette |
A vector of no more than |
background |
On the Amiga, indexed images could not be semi-transparent. Only a single colour could be designated as being fully transparent. The “background'' argument should contain a background colour with which semi-transparent colours should be mixed, before colour quantisation. It is white by default. |
dither |
Dither the output image using the algorithm specified here.
See the usage section for possible options. By default no dithering (" |
colour.depth |
A This argument is overruled when |
... |
Arguments that are passed onto |
Determines the optimal limited palette by clustering colours in an image
with stats::kmeans()
. The result of the optimisation routine
will depend on the randomly chosen cluster centres by this algorithm. This
means that the result may slightly differ for each call to this function. If
you want reproducible results, you may want to reset the random seed
(set.seed()
) before each call to this function.
Returns a matrix
with the same dimensions as x
containing
numeric
index values. The corresponding palette is returned as attribute,
as well as the index value for the fully transparent colour in the palette.
When x
is a list
a list
of matrices is returned.
Pepijn de Vries
Other colour.quantisation.operations:
dither()
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## This will create an image of the original raster using an indexed palette: volcano.index <- index.colours(volcano.raster) ## The index values can be converted back into colours, using the palette: volcano.index <- as.raster(apply(volcano.index, 2, function(x) attributes(volcano.index)$palette[x])) ## Create an indexed image using dithering volcano.dith <- index.colours(volcano.raster, dither = "floyd-steinberg") volcano.dith <- as.raster(apply(volcano.dith, 2, function(x) attributes(volcano.dith)$palette[x])) ## plot the images side by side for comparison par(mfcol = c(1, 3)) plot(volcano.raster, interpolate = F) plot(volcano.index, interpolate = F) plot(volcano.dith, interpolate = F) ## End(Not run)
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## This will create an image of the original raster using an indexed palette: volcano.index <- index.colours(volcano.raster) ## The index values can be converted back into colours, using the palette: volcano.index <- as.raster(apply(volcano.index, 2, function(x) attributes(volcano.index)$palette[x])) ## Create an indexed image using dithering volcano.dith <- index.colours(volcano.raster, dither = "floyd-steinberg") volcano.dith <- as.raster(apply(volcano.dith, 2, function(x) attributes(volcano.dith)$palette[x])) ## plot the images side by side for comparison par(mfcol = c(1, 3)) plot(volcano.raster, interpolate = F) plot(volcano.index, interpolate = F) plot(volcano.dith, interpolate = F) ## End(Not run)
IFFChunk()
s represent the structure of the Interchange File Format well,
but the iformation is stored as raw
data. This method tries to interpret and
translate the information into a more comprehensive format.
## S4 method for signature 'IFFChunk' interpretIFFChunk(x, ...)
## S4 method for signature 'IFFChunk' interpretIFFChunk(x, ...)
x |
An |
... |
Currently ignored. |
Interchange File Format chunks can hold any kind of information (images, audio,
(formatted) text, etc.). This method will try to convert this information into
something useful. Information may get lost in the translation, so be careful when
converting back to an IFFChunk-class()
object using
IFFChunk-method()
.
An error is thrown when the IFFChunk()
object is currently not
interpretable by this package. See IFFChunk-method()
for an overview
of currently supported IFF chunks. This list may increase while this package
matures.
If x
is interpretable by this package an S3 class object of
IFF.ANY
is returned. The content of the returned object will depend
on the type of IFFChunk()
provided for x
. The result can
for instance be a raster
image (grDevices::as.raster()
),
a list of audio tuneR::Wave()
s, a character
string or a named
list
.
Pepijn de Vries
Other iff.operations:
IFFChunk-class
,
WaveToIFF()
,
as.raster.AmigaBasicShape()
,
getIFFChunk()
,
rasterToIFF()
,
rawToIFFChunk()
,
read.iff()
,
write.iff()
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## in this case, the file is a FORM container with a bitmap image, and a ## list with a raster object is returned when interpreted: example.itpt <- interpretIFFChunk(example.iff) class(example.itpt) typeof(example.itpt) class(example.itpt[[1]]) ## Let's extraxt the bitmap header from the main chunk: bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD")) ## When interpreted, a named list is returned with (meta-)information ## on the bitmap image: bmhd.itpt <- interpretIFFChunk(bmhd) class(bmhd.itpt) typeof(bmhd.itpt) print(bmhd.itpt) ## End(Not run)
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## in this case, the file is a FORM container with a bitmap image, and a ## list with a raster object is returned when interpreted: example.itpt <- interpretIFFChunk(example.iff) class(example.itpt) typeof(example.itpt) class(example.itpt[[1]]) ## Let's extraxt the bitmap header from the main chunk: bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD")) ## When interpreted, a named list is returned with (meta-)information ## on the bitmap image: bmhd.itpt <- interpretIFFChunk(bmhd) class(bmhd.itpt) typeof(bmhd.itpt) print(bmhd.itpt) ## End(Not run)
In the binary Amiga Basic files, names for labels and variables in the code are stored at the end of the file. In the encoded there is only a pointer to the index of the name in that list. Use this function to list, select or replace names included in the code
## S3 method for class 'AmigaBasic' names(x) ## S3 replacement method for class 'AmigaBasic' names(x) <- value
## S3 method for class 'AmigaBasic' names(x) ## S3 replacement method for class 'AmigaBasic' names(x) <- value
x |
An |
value |
A ( |
Make sure that variable and label names are valid for the basic script (see check.names.AmigaBasic).
A vector
of character
strings with label and variable names in the basic script.
In case of the replacement method a AmigaBasic()
-class with replaced names is returned.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
## Let's create some Basic code with labels and variables: bas <- as.AmigaBasic(c( "REM - This will loop forever...", "my.label:", " my.variable% = 0", " WHILE my.variable% < 10", " my.variable% = my.variable% + 1", " WEND", " GOTO my.label" )) ## list the names in the script above: names(bas) ## change the first name: names(bas)[1] <- "better.label"
## Let's create some Basic code with labels and variables: bas <- as.AmigaBasic(c( "REM - This will loop forever...", "my.label:", " my.variable% = 0", " WHILE my.variable% < 10", " my.variable% = my.variable% + 1", " WEND", " GOTO my.label" )) ## list the names in the script above: names(bas) ## change the first name: names(bas)[1] <- "better.label"
A very simplistic lossless routine to (un)pack repetitive bitmap data. Often
used in InterLeaved BitMap (ILBM) images in IFF containers (IFFChunk()
).
packBitmap(x) unPackBitmap(x)
packBitmap(x) unPackBitmap(x)
x |
|
InterLeaved BitMap (ILBM) images on the Amiga often use a packing algorithm referred to as ‘ByteRun1’. This routine was introduced first on the Macintosh where it was called PackBits. It is a form of run-length encoding and is very simple: when a specific byte is repeated in a bitmap, it is replaced by a (signed negative) byte telling how many times the following byte should be repeated. When a series of bytes are not repetitive, it is preceded by a (signed positive) byte telling how long the non repetitive part is.
Not very complicated, but for most images some bytes can be shaved off the file. This was very useful when everything had to be stored on 880 kilobyte floppy disks with little CPU time to spare. Note that the file size can also increase for (noisy) images.
This packing routine will pack the entire bitmap (x
)
at once. The IFF file format requires packing of bitmap data per
scanline. This is done automatically by the rasterToIFF()
function, which calls this packing routine per scanline.
Returns packed or unpacked raw
data, depending on
whether packBitmap
or unPackBitmap
was called.
Pepijn de Vries
http://amigadev.elowar.com/read/ADCD_2.1/Devices_Manual_guide/node01C0.html
https://en.wikipedia.org/wiki/PackBits
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## generate some random raw data: dat.rnd <- as.raw(sample.int(10, 100, TRUE)) ## try to pack it: pack.rnd <- packBitmap(dat.rnd) ## due to the random nature of the source data ## the data could not be packed efficiently. ## The length of the packed data is close to ## the length of the original data: length(pack.rnd) - length(dat.rnd) ## Now generate similar data but sort it ## to generate more repetitive data: dat.srt <- as.raw(sort(sample.int(10, 100, TRUE))) pack.srt <- packBitmap(dat.srt) ## This time the packing routing is more successful: length(pack.srt) - length(dat.srt) ## The original data can always be obtained ## from the packed data: all(dat.rnd == unPackBitmap(pack.rnd)) all(dat.srt == unPackBitmap(pack.srt))
## generate some random raw data: dat.rnd <- as.raw(sample.int(10, 100, TRUE)) ## try to pack it: pack.rnd <- packBitmap(dat.rnd) ## due to the random nature of the source data ## the data could not be packed efficiently. ## The length of the packed data is close to ## the length of the original data: length(pack.rnd) - length(dat.rnd) ## Now generate similar data but sort it ## to generate more repetitive data: dat.srt <- as.raw(sort(sample.int(10, 100, TRUE))) pack.srt <- packBitmap(dat.srt) ## This time the packing routing is more successful: length(pack.srt) - length(dat.srt) ## The original data can always be obtained ## from the packed data: all(dat.rnd == unPackBitmap(pack.rnd)) all(dat.srt == unPackBitmap(pack.srt))
A wrapper for tuneR()
-package's tuneR::play()
routine. Allowing it to play
Amiga audio (for instance stored in an 8SVX Interchange File Format).
## S4 method for signature 'ANY' play(object, player = NULL, ...) ## S4 method for signature 'IFFChunk' play(object, player = NULL, ...)
## S4 method for signature 'ANY' play(object, player = NULL, ...) ## S4 method for signature 'IFFChunk' play(object, player = NULL, ...)
object |
An |
player |
Path to the external audio player. See |
... |
Arguments passed onto the tuneR |
A wrapper for tuneR()
-package's tuneR::play()
routine. It will try to play
audio using an external audio player. When 8SVX audio is played, each octave is played separately.
When a FORM container contains multiple 8SVX samples, they are also played successively.
Note that a separate package is developed to interpret and play ProTracker modules and samples
(ProTrackR()
).
Returns a list of data returned by tuneR's tuneR::play()
, for which the output
is undocumented.
Pepijn de Vries
## Not run: ## First get an audio sample from the ProTrackR package snare.samp <- ProTrackR::PTSample(ProTrackR::mod.intro, 2) ## Coerce it into an IFFChunk object: snare.iff <- WaveToIFF(snare.samp) ## Play the 8SVX sample: play(snare.iff) ## End(Not run)
## Not run: ## First get an audio sample from the ProTrackR package snare.samp <- ProTrackR::PTSample(ProTrackR::mod.intro, 2) ## Coerce it into an IFFChunk object: snare.iff <- WaveToIFF(snare.samp) ## Play the 8SVX sample: play(snare.iff) ## End(Not run)
Plot AmigaFFH objects using base
plotting routines.
## S3 method for class 'AmigaBasicShape' plot(x, y, ...) ## S3 method for class 'AmigaBitmapFont' plot(x, y, ...) ## S3 method for class 'AmigaBitmapFontSet' plot(x, y, ...) ## S3 method for class 'hardwareSprite' plot(x, y, ...) ## S3 method for class 'IFFChunk' plot(x, y, ...) ## S3 method for class 'IFF.FORM' plot(x, y, ...) ## S3 method for class 'IFF.8SVX' plot(x, y, ...) ## S3 method for class 'IFF.ILBM' plot(x, y, ...) ## S3 method for class 'IFF.ANIM' plot(x, y, ...) ## S3 method for class 'SysConfig' plot(x, y, ...) ## S3 method for class 'AmigaIcon' plot(x, y, asp = 2, ...)
## S3 method for class 'AmigaBasicShape' plot(x, y, ...) ## S3 method for class 'AmigaBitmapFont' plot(x, y, ...) ## S3 method for class 'AmigaBitmapFontSet' plot(x, y, ...) ## S3 method for class 'hardwareSprite' plot(x, y, ...) ## S3 method for class 'IFFChunk' plot(x, y, ...) ## S3 method for class 'IFF.FORM' plot(x, y, ...) ## S3 method for class 'IFF.8SVX' plot(x, y, ...) ## S3 method for class 'IFF.ILBM' plot(x, y, ...) ## S3 method for class 'IFF.ANIM' plot(x, y, ...) ## S3 method for class 'SysConfig' plot(x, y, ...) ## S3 method for class 'AmigaIcon' plot(x, y, asp = 2, ...)
x |
An AmigaFFH object to be plotted. See usage section for supported object
classes. If |
y |
When When When |
... |
Parameters passed onto the generic When |
asp |
A When A custom aspect ratio can also be used and will override the ratios specified above. |
A plotting routine is implemented for most AmigaFFH objects. See the usage section for all supported objects.
Returns NULL
silently.
Pepijn de Vries
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## and plot it: plot(example.iff) ## AmigaIcons can also be plotted: plot(simpleAmigaIcon()) ## As can the cursor from a SysConfig object: plot(simpleSysConfig()) ## As can Amiga fonts: data(font_example) plot(font_example) plot(font_example, text = "foo bar", style = "underlined", interpolate = F) ## As can AmigaBasicShapes: ball <- read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) plot(ball) ## End(Not run)
## Not run: ## load an IFF file example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## and plot it: plot(example.iff) ## AmigaIcons can also be plotted: plot(simpleAmigaIcon()) ## As can the cursor from a SysConfig object: plot(simpleSysConfig()) ## As can Amiga fonts: data(font_example) plot(font_example) plot(font_example, text = "foo bar", style = "underlined", interpolate = F) ## As can AmigaBasicShapes: ball <- read.AmigaBasicShape(system.file("ball.shp", package = "AmigaFFH")) plot(ball) ## End(Not run)
Convert a raster()
object into an AmigaBasicShape()
class object.
rasterToAmigaBasicShape( x, type = c("blitter object", "sprite"), palette, shadow, collision, ... )
rasterToAmigaBasicShape( x, type = c("blitter object", "sprite"), palette, shadow, collision, ... )
x |
A |
type |
A |
palette |
A |
shadow |
An optional layer that could be stored with the graphics. This layer could be used for specific
shadow effects when blitting the graphics to the screen. It needs to be a |
collision |
An optional layer that could be stored with the graphics. This layer could be used for collision
detection between graphical objects. It needs to be a |
... |
Arguments passed onto |
This method can be used to turn any graphics into an AmigaBasicShape()
class object. In order to do
so, the colours of the input image (a raster()
object) will be quantized to a
limited palette. This palette can be forced as an argument to this function. Otherwise, it will be based on
the input image.
Returns an AmigaBasicShape()
class object based on x
.
Pepijn de Vries
Other AmigaBasicShape.operations:
AmigaBasicShape
,
read.AmigaBasicShape()
,
write.AmigaBasicShape()
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: ## get a raster image: ilbm <- as.raster(read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH"))) ## convert to an Amiga Basic blitter object: bob <- rasterToAmigaBasicShape(ilbm, "blitter object") ## End(Not run)
## Not run: ## get a raster image: ilbm <- as.raster(read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH"))) ## convert to an Amiga Basic blitter object: bob <- rasterToAmigaBasicShape(ilbm, "blitter object") ## End(Not run)
Convert a two-coloured grDevices::as.raster()
image into
an AmigaBitmapFont()
class object.
rasterToAmigaBitmapFont( x, glyphs, default_glyph, baseline, glyph_width, glyph_space, glyph_kern, palette, ... )
rasterToAmigaBitmapFont( x, glyphs, default_glyph, baseline, glyph_width, glyph_space, glyph_kern, palette, ... )
x |
A |
glyphs |
Specify which glyphs are included in the image
A single A A Note that Amiga bitmap fonts represent ASCII characters and may not include all special characters or symbols. |
default_glyph |
A single |
baseline |
The baseline of the font, specified in number of
pixels from the top ( |
glyph_width |
A |
glyph_space |
A |
glyph_kern |
Note that in Amiga bitmap fonts not the formal
definition from typography is used for kerning. Here, kerning is
used as the number of pixels the cursor should be moved forward or
backward after typesetting a character. It should be a
|
palette |
A When missing, it will be checked whether |
... |
Currently ignored. |
Create an AmigaBitmapFont()
class object by providing
a two-coloured raster image and specifying which characters are
depicted by the image.
Returns a AmigaBitmapFont()
class object based on x
.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: data("font_example") ## make a raster that we can use to create a bitmap font font9.rast <- as.raster(getAmigaBitmapFont(font_example, 9)) ## note the glyphs and the order in which they are included in ## the raster image: plot(font9.rast) ## let's build a simple font, using only the first few glyphs ## in the raster: font9 <- rasterToAmigaBitmapFont( ## 'x' needs the raster image: x = font9.rast, ## 'glyphs' are the graphical representation of the characters ## that we will include in our font. We will only use the ## first 7 characters in the raster image: glyphs = " !\"#$%&", ## We will use the '&' glyph to represent all characters that ## are not specified in the font: default_glyph = "&", ## The raster image is 9 pixels tall, as will be the font. ## Let's use 7 as the base (it needs to be less than the height) baseline = 7, ## Let's define the width in pixels for each of the 7 ## characters. This is their width in the raster image: glyph_width = c(0, 1, 3, 6, 5, 5, 5), ## Let's define the space the character should take in pixels ## when it is used to format text: glyph_space = c(4, 2, 4, 7, 6, 6, 6), ## the raster uses white as background colour and black as ## foreground: palette = c("white", "black") ) ## note that for all characters that are not specified, ## the default glyph ('&') is used: plot(font9, text = "!@#$%ABCD") ## Let's take a subset from the font's bitmap (rasteer): font9abc.rast <- font9.rast[,263:282] ## as you can see this bitmap only contains the lowercase ## characters 'a', 'b', 'c', 'd' and 'e': plot(font9abc.rast) font9.abc <- rasterToAmigaBitmapFont( x = font9abc.rast, ## Each glyph in the image can be represented by a single ## element in a list. By specifying multiple characters in ## each element, you can recycle a glyph to represent different ## characters. So in this case, the glyph 'a' is used for ## all the accented variants of the character 'a'. glyphs = list("a\xE0\xE1\xE2\xE3\xE4\xE5", "b", "c\xA2\xE7", "d", "e\xE8\xE9\xEA\xEB"), default_glyph = "c", ## 'c' is used as default glyph for all other characters baseline = 7, glyph_width = c(4, 4, 4, 4, 4), glyph_space = c(5, 5, 5, 5, 5), palette = c("white", "black") ) ## see what happens when you format text using the font we just created: plot(font9.abc, text = "a\xE0\xE1\xE2\xE3\xE4\xE5bc\xA2\xE7de\xE8\xE9\xEA\xEB, foo bar") ## End(Not run)
## Not run: data("font_example") ## make a raster that we can use to create a bitmap font font9.rast <- as.raster(getAmigaBitmapFont(font_example, 9)) ## note the glyphs and the order in which they are included in ## the raster image: plot(font9.rast) ## let's build a simple font, using only the first few glyphs ## in the raster: font9 <- rasterToAmigaBitmapFont( ## 'x' needs the raster image: x = font9.rast, ## 'glyphs' are the graphical representation of the characters ## that we will include in our font. We will only use the ## first 7 characters in the raster image: glyphs = " !\"#$%&", ## We will use the '&' glyph to represent all characters that ## are not specified in the font: default_glyph = "&", ## The raster image is 9 pixels tall, as will be the font. ## Let's use 7 as the base (it needs to be less than the height) baseline = 7, ## Let's define the width in pixels for each of the 7 ## characters. This is their width in the raster image: glyph_width = c(0, 1, 3, 6, 5, 5, 5), ## Let's define the space the character should take in pixels ## when it is used to format text: glyph_space = c(4, 2, 4, 7, 6, 6, 6), ## the raster uses white as background colour and black as ## foreground: palette = c("white", "black") ) ## note that for all characters that are not specified, ## the default glyph ('&') is used: plot(font9, text = "!@#$%ABCD") ## Let's take a subset from the font's bitmap (rasteer): font9abc.rast <- font9.rast[,263:282] ## as you can see this bitmap only contains the lowercase ## characters 'a', 'b', 'c', 'd' and 'e': plot(font9abc.rast) font9.abc <- rasterToAmigaBitmapFont( x = font9abc.rast, ## Each glyph in the image can be represented by a single ## element in a list. By specifying multiple characters in ## each element, you can recycle a glyph to represent different ## characters. So in this case, the glyph 'a' is used for ## all the accented variants of the character 'a'. glyphs = list("a\xE0\xE1\xE2\xE3\xE4\xE5", "b", "c\xA2\xE7", "d", "e\xE8\xE9\xEA\xEB"), default_glyph = "c", ## 'c' is used as default glyph for all other characters baseline = 7, glyph_width = c(4, 4, 4, 4, 4), glyph_space = c(5, 5, 5, 5, 5), palette = c("white", "black") ) ## see what happens when you format text using the font we just created: plot(font9.abc, text = "a\xE0\xE1\xE2\xE3\xE4\xE5bc\xA2\xE7de\xE8\xE9\xEA\xEB, foo bar") ## End(Not run)
raster
object into binary bitmap dataConverts an image represented by a grDevices raster
object into binary
(Amiga) bitmap data.
rasterToBitmap(x, depth = 3, interleaved = T, indexing = index.colours)
rasterToBitmap(x, depth = 3, interleaved = T, indexing = index.colours)
x |
A raster object created with |
depth |
The colour depth of the bitmap image. The image will be composed
of
|
interleaved |
A |
indexing |
A function that accepts two arguments: |
Images represented by grDevices raster
objects are virtually true colour (24 bit
colour depth) and an alpha layer (transparency). On the early Amiga's the chipset
(in combination with memory restrictions) only allowed images with indexed
palettes. The colour depth was 12 bit with the original chipset and the number
of colours allowed in a palette also depended on the chipset. This function
will allow you to convert a raster
object into binary bitmap data with
an indexed palette. This means that the image is converted in a lossy way
(information will be lost). So don't expect the result to have the same quality as
the original image.
With the depth
argument, the raster can also be converted
to special mode bitmap images. One of these modes is the
‘hold and modify’ (HAM). In this mode two of the bitplanes
are reserved as modifier switches. If the this switch equals
zero, the remainder of the bitplanes are used as an index for
colours in a fixed palette. If the switch equals 1, 2 or 3, the
red, green or blue component of the previous is modified, using the
number in the remainder of the bitplanes. So it holds the previous
colour but modifies one of the colour components (hence the term
‘hold and modify’.) Here only the HAM6 and
the HAM8 mode are implemented. HAM6 uses 6 bitplanes and a 12 bit
colour depth, HAM8 uses 8 bitplanes and a 24 bit colour depth.
The HAM mode was a special video modes supported by Amiga hardware. Normal mode bitmap images with a 6 bit depth would allow for a palette of 64 (2^6) colours, HAM6 can display 4096 colours with the same bit depth.
In addition to HAM6 and HAM8, sliced HAM (or SHAM) was another HAM variant. Using the coprocessor on the Amiga, it was possible to change the palette at specific scanlines, increasing the number of available colours even further. The SHAM mode is currently not supported by this package.
The bitmap is returned as a vector
of logical
values.
The logical
values reflect the bits for each bitplane. The palette used
for the bitmap is returned as attribute to the vector
. There will also be
an attribute called transparent'. This will hold a numeric index corresponding with the colour in the palette that will be treated as transparent. It will be
NA' when transparency is not used.
Pepijn de Vries
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## convert the raster into binary (logical) bitmap data: volcano.bm <- rasterToBitmap(volcano.raster) ## The palette for the indexed colours of the generated bitmap is returned as ## attribute. There is no transparency is the image: attributes(volcano.bm) ## We can also include a custom function for colour quantisation. Let's include ## some dithering: volcano.dither <- rasterToBitmap(volcano.raster, indexing = function(x, length.out) { index.colours(x, length.out, dither = "floyd-steinberg") }) ## You can also use a custom indexing function to force a specified palette, ## in this case black and white: volcano.bw <- rasterToBitmap(volcano.raster, indexing = function(x, length.out) { index.colours(x, length.out, palette = c("black", "white"), dither = "floyd-steinberg") }) ## Make a bitmap using a special display mode (HAM6): volcano.HAM <- rasterToBitmap(volcano.raster, "HAM6") ## End(Not run)
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## convert the raster into binary (logical) bitmap data: volcano.bm <- rasterToBitmap(volcano.raster) ## The palette for the indexed colours of the generated bitmap is returned as ## attribute. There is no transparency is the image: attributes(volcano.bm) ## We can also include a custom function for colour quantisation. Let's include ## some dithering: volcano.dither <- rasterToBitmap(volcano.raster, indexing = function(x, length.out) { index.colours(x, length.out, dither = "floyd-steinberg") }) ## You can also use a custom indexing function to force a specified palette, ## in this case black and white: volcano.bw <- rasterToBitmap(volcano.raster, indexing = function(x, length.out) { index.colours(x, length.out, palette = c("black", "white"), dither = "floyd-steinberg") }) ## Make a bitmap using a special display mode (HAM6): volcano.HAM <- rasterToBitmap(volcano.raster, "HAM6") ## End(Not run)
Convert a grDevices raster object into an Amiga hardwareSprite class object.
rasterToHWSprite(x, indexing = index.colours)
rasterToHWSprite(x, indexing = index.colours)
x |
A |
indexing |
A function that accepts two arguments: |
A grDevices()
raster image can be converted into a
hardwareSprite()
class object with this function. For this purpose
the any true-colour image will be converted to an indexed palette with 4 colours.
The Amiga hardware sprite will reserve one of the colours as transparent. Thos function
will use fully transparent colours in the original image (i.e., the alpha level equals 0)
for this purpose. Or when the image has no fully transparent colours, it will use the
most frequently occuring colour (at least when the default indexing
function
is used).
Returns a hardwareSprite()
class object based on x
Pepijn de Vries
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToIFF()
Other HWSprite.operations:
rawToHWSprite()
## Not run: ## first create a raster object that can be used as input ## (making sure that the background is transparent): rst <- as.raster(simpleSysConfig()$PointerMatrix, "#AAAAAA00") ## now turn it into a hardware sprite: spr <- rasterToHWSprite(rst) ## and plot it as a check: plot(spr) ## End(Not run)
## Not run: ## first create a raster object that can be used as input ## (making sure that the background is transparent): rst <- as.raster(simpleSysConfig()$PointerMatrix, "#AAAAAA00") ## now turn it into a hardware sprite: spr <- rasterToHWSprite(rst) ## and plot it as a check: plot(spr) ## End(Not run)
Convert grDevices raster images (grDevices::as.raster()
)
into a formal IFFChunk()
object, as an interleaved bitmap (ILBM)
image.
rasterToIFF( x, display.mode = as.character(AmigaFFH::amiga_display_modes$DISPLAY_MODE), monitor = as.character(AmigaFFH::amiga_monitors$MONITOR_ID), anim.options, ... )
rasterToIFF( x, display.mode = as.character(AmigaFFH::amiga_display_modes$DISPLAY_MODE), monitor = as.character(AmigaFFH::amiga_monitors$MONITOR_ID), anim.options, ... )
x |
A raster object created with |
display.mode |
Specify the Amiga display mode that should be used.
See |
monitor |
The Amiga monitor on which the needs to be displayed.
See |
anim.options |
Currently ignored. This argument will potentitally be implemented
in future versions of this package. Currently, animations are always encoded
with the "ByteVerticalCompression" in this package (when |
... |
Arguments passed on to |
Convert any modern image into a interleaved bitmap (image) conform Interchange File Format (IFF) specifications. If your original image is in true colour (i.e., a 24 bit colour depth) it will be converted into a bitmap image with an indexed palette.
Returns an IFFChunk()
object holding an Interleaved
Bitmap (ILBM) image based on x
.
Pepijn de Vries
Other iff.operations:
IFFChunk-class
,
WaveToIFF()
,
as.raster.AmigaBasicShape()
,
getIFFChunk()
,
interpretIFFChunk()
,
rawToIFFChunk()
,
read.iff()
,
write.iff()
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToAmigaBitmapFont()
,
rasterToBitmap()
,
rasterToHWSprite()
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## Turning the raster into an IFFChunk object is easy: volcano.iff <- rasterToIFF(volcano.raster) ## This object can be saved as an IFF file using write.iff ## in special modes HAM6 and HAM 8 higher quality images ## can be obtained. See 'rasterToBitmap' for more info on the ## special HAM modes. volcano.ham <- rasterToIFF(volcano.raster, "HAM_KEY", depth = "HAM8") ## The result can be further improved by applying dithering volcano.ham.dither <- rasterToIFF(volcano.raster, "HAM_KEY", depth = "HAM8", indexing = function(x, length.out) { index.colours(x, length.out, dither = "JJN", iter.max = 20) }) ## End(Not run)
## Not run: ## first: Let's make a raster out of the 'volcano' data, which we can use in the example: volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano - min(volcano) + 1], nrow(volcano)))) ## Turning the raster into an IFFChunk object is easy: volcano.iff <- rasterToIFF(volcano.raster) ## This object can be saved as an IFF file using write.iff ## in special modes HAM6 and HAM 8 higher quality images ## can be obtained. See 'rasterToBitmap' for more info on the ## special HAM modes. volcano.ham <- rasterToIFF(volcano.raster, "HAM_KEY", depth = "HAM8") ## The result can be further improved by applying dithering volcano.ham.dither <- rasterToIFF(volcano.raster, "HAM_KEY", depth = "HAM8", indexing = function(x, length.out) { index.colours(x, length.out, dither = "JJN", iter.max = 20) }) ## End(Not run)
AmigaBasic()
objects are comprehensive representations of binary-encode Amiga Basic scripts.
Use this function to convert raw content from encoded Amiga Basic scripts to an AmigaBasic()
object.
rawToAmigaBasic(x, ...)
rawToAmigaBasic(x, ...)
x |
A |
... |
Currently ignored. |
This function will convert raw data as stored in Amiga Basic files into its corresponding S3
AmigaBasic()
-class object.
An AmigaBasic()
class object based on x
.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: ## First create an AmigaBAsic object: bas <- as.AmigaBasic("PRINT \"Hello world!\"") ## Make it raw: bas.raw <- as.raw(bas) ## Now convert it back to an AmigaBasic object: bas <- rawToAmigaBasic(bas.raw) ## End(Not run)
## Not run: ## First create an AmigaBAsic object: bas <- as.AmigaBasic("PRINT \"Hello world!\"") ## Make it raw: bas.raw <- as.raw(bas) ## Now convert it back to an AmigaBasic object: bas <- rawToAmigaBasic(bas.raw) ## End(Not run)
Coerce raw data into an AmigaBasicBMAP()
class object
rawToAmigaBasicBMAP(x, ...)
rawToAmigaBasicBMAP(x, ...)
x |
A |
... |
Currently ignored. |
An Amiga Basic BMAP file maps the offset of routines in Amiga libraries. This function converts the raw format in which it would be stored as a file into a comprehensive S3 class object.
An AmigaBasicBMAP()
class object based on x
.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
write.AmigaBasic()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: ## A small fragment of the dos.library BMAP would look like this: dos.bmap <- as.AmigaBasicBMAP(list( xOpen = list( libraryVectorOffset = -30, registers = as.raw(2:3) ), xClose = list( libraryVectorOffset = -36, registers = as.raw(2) ), xRead = list( libraryVectorOffset = -42, registers = as.raw(2:4) ) )) ## The raw representation would be dos.bmap.raw <- as.raw(dos.bmap) ## And the reverse rawToAmigaBasicBMAP(dos.bmap.raw) ## End(Not run)
## Not run: ## A small fragment of the dos.library BMAP would look like this: dos.bmap <- as.AmigaBasicBMAP(list( xOpen = list( libraryVectorOffset = -30, registers = as.raw(2:3) ), xClose = list( libraryVectorOffset = -36, registers = as.raw(2) ), xRead = list( libraryVectorOffset = -42, registers = as.raw(2:4) ) )) ## The raw representation would be dos.bmap.raw <- as.raw(dos.bmap) ## And the reverse rawToAmigaBasicBMAP(dos.bmap.raw) ## End(Not run)
Coerce raw data into an AmigaBasicShape()
-class object
rawToAmigaBasicShape(x, palette)
rawToAmigaBasicShape(x, palette)
x |
A |
palette |
A |
AmigaBasicShape()
objects are comprehensive representations of blitter
and sprite graphics that can be used in AmigaBasic()
scripts. Use this function
to convert raw
content to an AmigaBasicShape()
object.
returns an AmigaBasicShape()
-class object.
Pepijn de Vries
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: filename <- system.file("ball.shp", package = "AmigaFFH") ## read as binary: con <- file(filename, "rb") ball.raw <- readBin(con, "raw", file.size(filename)) close(con) ## convert raw data into something useful: ball <- rawToAmigaBasicShape(ball.raw) ## A shortcut would be to call read.AmigaBasicShape ball2 <- read.AmigaBasicShape(filename) ## End(Not run)
## Not run: filename <- system.file("ball.shp", package = "AmigaFFH") ## read as binary: con <- file(filename, "rb") ball.raw <- readBin(con, "raw", file.size(filename)) close(con) ## convert raw data into something useful: ball <- rawToAmigaBasicShape(ball.raw) ## A shortcut would be to call read.AmigaBasicShape ball2 <- read.AmigaBasicShape(filename) ## End(Not run)
AmigaBitmapFont()
objects are comprehensive representations of binary Amiga
font subset files. The file name is usually simply a numeric number
indicating the font height in pixels. Use this function to convert
raw
content from such a file to an AmigaBitmapFont()
object.
rawToAmigaBitmapFont(x, ...)
rawToAmigaBitmapFont(x, ...)
x |
An |
... |
Currently ignored. |
This function converts raw
data as stored in font bitmap
files. These files are stored in subdirectories with the font's
name and usually have the font height in pixels as file name.
This function is effectively the inverse of as.raw()
.
A vector
of raw
data representing x
.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: ## first create raw data that can be converted into a AmigaBitmapFont data(font_example) font.raw <- as.raw(getAmigaBitmapFont(font_example, 9)) ## Convert it back into an AmigaBitmapFont object: font <- rawToAmigaBitmapFont(font.raw) ## End(Not run)
## Not run: ## first create raw data that can be converted into a AmigaBitmapFont data(font_example) font.raw <- as.raw(getAmigaBitmapFont(font_example, 9)) ## Convert it back into an AmigaBitmapFont object: font <- rawToAmigaBitmapFont(font.raw) ## End(Not run)
AmigaBitmapFontSet()
objects are comprehensive representations of binary Amiga
font files (*.font). Use this function to convert raw
data from
such a file to an AmigaBitmapFontSet object.
rawToAmigaBitmapFontSet(x, file, disk = NULL)
rawToAmigaBitmapFontSet(x, file, disk = NULL)
x |
A |
file |
The |
disk |
A virtual Commodore Amiga disk from which the |
This function converts raw
data as stored in *.font
files. The function also needs the file location, in order
to load the nested bitmap images for each font height.
This function is effectively the inverse of as.raw()
.
Returns an AmigaBitmapFontSet()
object.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: data(font_example) ## First create raw font set data. Note that this raw data ## does not include the nested font bitmap images. fontset.raw <- as.raw(font_example) ## Therefore it is necesary to have the entire font stored as files: write.AmigaBitmapFontSet(font_example, tempdir()) font.restored <- rawToAmigaBitmapFontSet(fontset.raw, file.path(tempdir(), "AmigaFFH.font")) ## End(Not run)
## Not run: data(font_example) ## First create raw font set data. Note that this raw data ## does not include the nested font bitmap images. fontset.raw <- as.raw(font_example) ## Therefore it is necesary to have the entire font stored as files: write.AmigaBitmapFontSet(font_example, tempdir()) font.restored <- rawToAmigaBitmapFontSet(fontset.raw, file.path(tempdir(), "AmigaFFH.font")) ## End(Not run)
AmigaIcon()
objects are comprehensive representations of binary Amiga
Workbench icon files (*.info). Use this function to convert raw
data from
such a file to an AmigaIcon()
object.
rawToAmigaIcon(x, palette = NULL)
rawToAmigaIcon(x, palette = NULL)
x |
A vector of |
palette |
Provide a palette ( |
Icons files (*.info) were used as a graphical representations of files and
directories on the Commodore Amiga. This function will convert the raw data from such files
into a more comprehensive names list (see AmigaIcon()
). Use
as.raw()
to achieve the inverse.
Returns an AmigaIcon()
class object based on x
.
Pepijn de Vries
Other AmigaIcon.operations:
AmigaIcon
,
read.AmigaIcon()
,
simpleAmigaIcon()
,
write.AmigaIcon()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: ## generate a simple AmigaIcon object: icon <- simpleAmigaIcon() ## convert it into raw data: icon.raw <- as.raw(icon) ## convert the raw data back into an icon: icon.restored <- rawToAmigaIcon(icon.raw) ## End(Not run)
## Not run: ## generate a simple AmigaIcon object: icon <- simpleAmigaIcon() ## convert it into raw data: icon.raw <- as.raw(icon) ## convert the raw data back into an icon: icon.restored <- rawToAmigaIcon(icon.raw) ## End(Not run)
Convert raw
data structured conform a Commodore Amiga hardware
sprite (see references) into a hardwareSprite()
object.
## S4 method for signature 'raw,missing' rawToHWSprite(x, col) ## S4 method for signature 'raw,character' rawToHWSprite(x, col)
## S4 method for signature 'raw,missing' rawToHWSprite(x, col) ## S4 method for signature 'raw,character' rawToHWSprite(x, col)
x |
|
col |
A |
Information to set up a hardware sprite is stored as raw
data
on Commodore Amigas. This method can be used to convert this data
into a hardwareSprite()
object. This object can in turn
be converted with as.raster()
such that it can be plotted in R.
Returns a hardwareSprite()
object based on the provided raw data
Pepijn de Vries
http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node00B9.html
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToIFFChunk()
,
rawToSysConfig()
,
simpleAmigaIcon()
Other HWSprite.operations:
rasterToHWSprite()
## Let's generate a 16x16 sprite with a random bitmap: dat <- as.raw(c(0x00, 0x00, 0x10, 0x00, sample.int(255, 64, replace = TRUE), 0x00, 0x00, 0x00, 0x00)) ## make it a hardware sprite object: spr <- rawToHWSprite(dat) ## and plot it: plot(spr, interpolate = FALSE) ## with some imagination when can make ## a more structured image: dat <- as.raw(c(0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x7f, 0x80, 0x80, 0x70, 0x7f, 0x00, 0xbe, 0xe0, 0x7e, 0x00, 0x85, 0xc0, 0x7d, 0x80, 0x82, 0x40, 0x6b, 0xc0, 0x95, 0xa0, 0x57, 0xe0, 0xa8, 0xd0, 0x2f, 0xf0, 0xd1, 0x68, 0x4f, 0xf8, 0xb0, 0x34, 0x07, 0xfc, 0xf8, 0x5a, 0x03, 0xfe, 0xe4, 0x0d, 0x01, 0xfc, 0xc2, 0x12, 0x00, 0xf8, 0x81, 0x04, 0x00, 0x70, 0x00, 0x88, 0x00, 0x20, 0x00, 0x50, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00)) spr <- rawToHWSprite(dat, c("#EE4444", "#000000", "#EEEECC")) plot(spr, interpolate = FALSE)
## Let's generate a 16x16 sprite with a random bitmap: dat <- as.raw(c(0x00, 0x00, 0x10, 0x00, sample.int(255, 64, replace = TRUE), 0x00, 0x00, 0x00, 0x00)) ## make it a hardware sprite object: spr <- rawToHWSprite(dat) ## and plot it: plot(spr, interpolate = FALSE) ## with some imagination when can make ## a more structured image: dat <- as.raw(c(0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x7f, 0x80, 0x80, 0x70, 0x7f, 0x00, 0xbe, 0xe0, 0x7e, 0x00, 0x85, 0xc0, 0x7d, 0x80, 0x82, 0x40, 0x6b, 0xc0, 0x95, 0xa0, 0x57, 0xe0, 0xa8, 0xd0, 0x2f, 0xf0, 0xd1, 0x68, 0x4f, 0xf8, 0xb0, 0x34, 0x07, 0xfc, 0xf8, 0x5a, 0x03, 0xfe, 0xe4, 0x0d, 0x01, 0xfc, 0xc2, 0x12, 0x00, 0xf8, 0x81, 0x04, 0x00, 0x70, 0x00, 0x88, 0x00, 0x20, 0x00, 0x50, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00)) spr <- rawToHWSprite(dat, c("#EE4444", "#000000", "#EEEECC")) plot(spr, interpolate = FALSE)
Coerce raw data, as it would be stored in the Interchange File Format (IFF), and
convert it into an IFFChunk()
class object.
## S4 method for signature 'raw' rawToIFFChunk(x)
## S4 method for signature 'raw' rawToIFFChunk(x)
x |
A vector of raw data that needs to be converted into a |
This method should work for all IFF chunk types that are implemented in this package
(see IFFChunk-method()
for details). For non-implemented chunks this method
may work properly as long as the chunks are nested inside a FORM type container chunk.
This method is provided for your convenience, but it is recommended to import IFFChunk
methods using the read.iff()
function. Use as.raw()
to achieve the inverse of this method.
Returns an IFFChunk()
class object based on x
.
Pepijn de Vries
Other iff.operations:
IFFChunk-class
,
WaveToIFF()
,
as.raster.AmigaBasicShape()
,
getIFFChunk()
,
interpretIFFChunk()
,
rasterToIFF()
,
read.iff()
,
write.iff()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToSysConfig()
,
simpleAmigaIcon()
## Not run: ## Get an IFFChunk object: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## Coerce it to raw data: example.raw <- as.raw(example.iff) ## Coerce raw data to IFF chunk: example.iff.new <- rawToIFFChunk(example.raw) ## These conversions were non-destructive: identical(example.iff, example.iff.new) ## End(Not run)
## Not run: ## Get an IFFChunk object: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## Coerce it to raw data: example.raw <- as.raw(example.iff) ## Coerce raw data to IFF chunk: example.iff.new <- rawToIFFChunk(example.raw) ## These conversions were non-destructive: identical(example.iff, example.iff.new) ## End(Not run)
SysConfig objects are comprehensive representations of binary Amiga
system-configuration files. Use this function to convert raw
data from
such a file to a SysConfig object.
rawToSysConfig(x)
rawToSysConfig(x)
x |
A vector of |
The Amiga used the system-configuration file to store certain system preferences
in a binary file. With this function such raw
data can be converted into
a more comprehensive SysConfig object. Use as.raw()
to achieve the inverse.
Returns a SysConfig class object based on x
.
Pepijn de Vries
Other SysConfig.operations:
SysConfig
,
read.SysConfig()
,
simpleSysConfig()
,
write.SysConfig()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
simpleAmigaIcon()
## Not run: ## get the system-configuration from the adfExplorer example disk: sc <- adfExplorer::get.adf.file(adfExplorer::adf.example, "devs/system-configuration") ## This will get you the raw data from the file: typeof(sc) ## Convert the raw data to a more comprehensive named list (and S3 SysConfig class): sc <- rawToSysConfig(sc) ## End(Not run)
## Not run: ## get the system-configuration from the adfExplorer example disk: sc <- adfExplorer::get.adf.file(adfExplorer::adf.example, "devs/system-configuration") ## This will get you the raw data from the file: typeof(sc) ## Convert the raw data to a more comprehensive named list (and S3 SysConfig class): sc <- rawToSysConfig(sc) ## End(Not run)
Read an AmigaBasic()
script from its binary format.
read.AmigaBasic(file, disk = NULL, ...)
read.AmigaBasic(file, disk = NULL, ...)
file |
A |
disk |
A virtual Commodore Amiga disk from which the |
... |
Currently ignored |
Normally Amiga Basic code is stored encoded in a binary format
(rawToAmigaBasic()
).
This function reads the binary data from a file (which can be
stored on a virtual disk (amigaDisk()
))
and converts in into an AmigaBasic()
class objec.
Returns an AmigaBasic()
class object read from the file
.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
write.AmigaBasic()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: ## First create an AmigaBasic file write.AmigaBasic(as.AmigaBasic("PRINT \"Hello world\""), file.path(tempdir(), "helloworld.bas")) ## Now let's read the same file: bas <- read.AmigaBasic(file.path(tempdir(), "helloworld.bas")) ## End(Not run) ## There's also a demo file included with the package demo.bas <- read.AmigaBasic(system.file("demo.bas", package = "AmigaFFH")) demo.bas
## Not run: ## First create an AmigaBasic file write.AmigaBasic(as.AmigaBasic("PRINT \"Hello world\""), file.path(tempdir(), "helloworld.bas")) ## Now let's read the same file: bas <- read.AmigaBasic(file.path(tempdir(), "helloworld.bas")) ## End(Not run) ## There's also a demo file included with the package demo.bas <- read.AmigaBasic(system.file("demo.bas", package = "AmigaFFH")) demo.bas
Read and write AmigaBasicBMAP()
binary file format.
read.AmigaBasicBMAP(file, disk = NULL) write.AmigaBasicBMAP(x, file, disk = NULL)
read.AmigaBasicBMAP(file, disk = NULL) write.AmigaBasicBMAP(x, file, disk = NULL)
file |
A |
disk |
A virtual Commodore Amiga disk from which the |
x |
A |
An Amiga Basic BMAP file maps the offset of routines in Amiga libraries and can be read as a comprehensive list and written back to a binary file using these functions.
Returns an AmigaBasicBMAP()
class object read from the file
in case of
read.AmigaBasicBMAP
. Otherwise, invisibly returns the result of the call of close
to the
file connection. Or, when disk
is specified, a copy of
disk
is returned to which the file is written.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasic()
,
write.AmigaBasic()
Other io.operations:
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: ## A small fragment of the dos.library BMAP would look like this: dos.bmap <- as.AmigaBasicBMAP(list( xOpen = list( libraryVectorOffset = -30, registers = as.raw(2:3) ), xClose = list( libraryVectorOffset = -36, registers = as.raw(2) ), xRead = list( libraryVectorOffset = -42, registers = as.raw(2:4) ) )) ## This will write the BMAP to a file: write.AmigaBasicBMAP(dos.bmap, file.path(tempdir(), "dos.bmap")) ## This will read the same file: dos.bmap.copy <- read.AmigaBasicBMAP(file.path(tempdir(), "dos.bmap")) ## End(Not run)
## Not run: ## A small fragment of the dos.library BMAP would look like this: dos.bmap <- as.AmigaBasicBMAP(list( xOpen = list( libraryVectorOffset = -30, registers = as.raw(2:3) ), xClose = list( libraryVectorOffset = -36, registers = as.raw(2) ), xRead = list( libraryVectorOffset = -42, registers = as.raw(2:4) ) )) ## This will write the BMAP to a file: write.AmigaBasicBMAP(dos.bmap, file.path(tempdir(), "dos.bmap")) ## This will read the same file: dos.bmap.copy <- read.AmigaBasicBMAP(file.path(tempdir(), "dos.bmap")) ## End(Not run)
Read Amiga Basic Shape files
read.AmigaBasicShape(file, disk = NULL, ...)
read.AmigaBasicShape(file, disk = NULL, ...)
file |
A |
disk |
A virtual Commodore Amiga disk from which the |
... |
Arguments passed to |
AmigaBasic used the term 'shapes' for graphics (sprites and blitter objects) which it could display.
These graphics were stored in a specific binary format, which can be read with this function. See
AmigaBasicShape()
for more details. The file can also be read from a virtual Amiga disk
(amigaDisk()
).
Returns an AmigaBasicShape()
class object read from the file
.
Pepijn de Vries
Other AmigaBasicShape.operations:
AmigaBasicShape
,
rasterToAmigaBasicShape()
,
write.AmigaBasicShape()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: filename <- system.file("ball.shp", package = "AmigaFFH") ball <- read.AmigaBasicShape(filename) ## This is a sprite: ball$flags[["fVSprite"]] filename <- system.file("r_logo.shp", package = "AmigaFFH") ## The palette is not stored with an Amiga Basic Shape, so let's provide one: r_logo <- read.AmigaBasicShape(filename, palette = c("#FFFFFF", "#2266BB", "#3366BB", "#4477AA", "#778899", "#999999", "#AAAAAA", "#BBBBBB")) ## This is a blitter object: r_logo$flags[["fVSprite"]] ## Just for fun, plot it: plot(r_logo) ## End(Not run)
## Not run: filename <- system.file("ball.shp", package = "AmigaFFH") ball <- read.AmigaBasicShape(filename) ## This is a sprite: ball$flags[["fVSprite"]] filename <- system.file("r_logo.shp", package = "AmigaFFH") ## The palette is not stored with an Amiga Basic Shape, so let's provide one: r_logo <- read.AmigaBasicShape(filename, palette = c("#FFFFFF", "#2266BB", "#3366BB", "#4477AA", "#778899", "#999999", "#AAAAAA", "#BBBBBB")) ## This is a blitter object: r_logo$flags[["fVSprite"]] ## Just for fun, plot it: plot(r_logo) ## End(Not run)
Amiga Font Bitmaps of distinctive font heights are stored in separate
files, which in combination form a font collection or set. This
function can be used to read a specific bitmap from a set and returns
it as an AmigaBitmapFont()
class object.
read.AmigaBitmapFont(file, disk = NULL, ...)
read.AmigaBitmapFont(file, disk = NULL, ...)
file |
The file name of a font subset is usually simply a numeric number
indicating the font height in pixels. Use |
disk |
A virtual Commodore Amiga disk from which the |
... |
Arguments passed on to |
Individual font bitmaps are stored in a font's subdirectory where
the file name is usually equal to the font height in pixels. This
function will read such a font bitmap file and return it as an
AmigaBitmapFont()
class object. It can also read such
files from adfExplorer::amigaDisk-class()
objects,
but that requires the adfExplorer package to be installed.
Returns an AmigaBitmapFont()
object read from the specified file.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
write.AmigaBitmapFont()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: data(font_example) ## Let's store the example font first: write.AmigaBitmapFontSet(font_example, tempdir()) ## Now read a specific subset from the font files: font.sub <- read.AmigaBitmapFont(file.path(tempdir(), "AmigaFFH", "9")) ## The same can be done with a virtual Amiga disk. The following ## examples require the 'adfExplorer' package. font.disk <- adfExplorer::blank.amigaDOSDisk("font.disk") font.disk <- adfExplorer::dir.create.adf(font.disk, "FONTS") font.disk <- write.AmigaBitmapFontSet(font_example, "DF0:FONTS", font.disk) font.sub <- read.AmigaBitmapFont("DF0:FONTS/AmigaFFH/9", font.disk) ## End(Not run)
## Not run: data(font_example) ## Let's store the example font first: write.AmigaBitmapFontSet(font_example, tempdir()) ## Now read a specific subset from the font files: font.sub <- read.AmigaBitmapFont(file.path(tempdir(), "AmigaFFH", "9")) ## The same can be done with a virtual Amiga disk. The following ## examples require the 'adfExplorer' package. font.disk <- adfExplorer::blank.amigaDOSDisk("font.disk") font.disk <- adfExplorer::dir.create.adf(font.disk, "FONTS") font.disk <- write.AmigaBitmapFontSet(font_example, "DF0:FONTS", font.disk) font.sub <- read.AmigaBitmapFont("DF0:FONTS/AmigaFFH/9", font.disk) ## End(Not run)
Reads AmigaBitmapFontSet()
from *.font file including
all nested bitmap images for all font heights.
read.AmigaBitmapFontSet(file, disk = NULL, ...)
read.AmigaBitmapFontSet(file, disk = NULL, ...)
file |
A |
disk |
A virtual Commodore Amiga disk from which the |
... |
Currently ignored. |
The *.font file only holds meta-information. The bitmap images for
each font height are stored in separate files, which are listed
in the *.font file. The function reads the *.font file, including
all nested bitmap files and returns it as a
AmigaBitmapFontSet()
.
It can also read *.font files
from adfExplorer::amigaDisk-class()
objects,
but that requires the adfExplorer package to be installed.
Returns an AmigaBitmapFontSet()
object read from the specified file.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: data(font_example) ## in order to read, we first need to write a file" write.AmigaBitmapFontSet(font_example, tempdir()) ## The font is written as 'AmigaFFH.font' as that name ## is embedded in the AmigaBitmapFontSet object 'font_example'. ## We can read it as follows: font.read <- read.AmigaBitmapFontSet(file.path(tempdir(), "AmigaFFH.font")) ## similarly, the file can also be written and read from and to ## a virtual amiga disk. The following codes requires the 'adfExplorer' ## package: adf <- adfExplorer::blank.amigaDOSDisk("font.disk") adf <- adfExplorer::dir.create.adf(adf, "FONTS") adf <- write.AmigaBitmapFontSet(font_example, "DF0:FONTS", adf) font.read <- read.AmigaBitmapFontSet("DF0:FONTS/AmigaFFH.font", adf) ## End(Not run)
## Not run: data(font_example) ## in order to read, we first need to write a file" write.AmigaBitmapFontSet(font_example, tempdir()) ## The font is written as 'AmigaFFH.font' as that name ## is embedded in the AmigaBitmapFontSet object 'font_example'. ## We can read it as follows: font.read <- read.AmigaBitmapFontSet(file.path(tempdir(), "AmigaFFH.font")) ## similarly, the file can also be written and read from and to ## a virtual amiga disk. The following codes requires the 'adfExplorer' ## package: adf <- adfExplorer::blank.amigaDOSDisk("font.disk") adf <- adfExplorer::dir.create.adf(adf, "FONTS") adf <- write.AmigaBitmapFontSet(font_example, "DF0:FONTS", adf) font.read <- read.AmigaBitmapFontSet("DF0:FONTS/AmigaFFH.font", adf) ## End(Not run)
Graphical representation of files and directories (icons) are stored as
separate files (with the .info extension) on the Amiga. This function reads such files
and imports them as AmigaIcon()
class objects.
read.AmigaIcon(file, disk = NULL, ...)
read.AmigaIcon(file, disk = NULL, ...)
file |
A |
disk |
A virtual Commodore Amiga disk from which the |
... |
Arguments passed on to |
The AmigaIcon()
S3 object provides a comprehensive format
for Amiga icons, which are used as a graphical representation of files
and directories on the Amiga. The AmigaIcon()
is a named
list containing all information of an icon. Use this function to
read an Amiga icon (with the .info extension) from a file and convert
it into an AmigaIcon()
object.
Returns an AmigaIcon()
class object as read from the file
.
Pepijn de Vries
Other AmigaIcon.operations:
AmigaIcon
,
rawToAmigaIcon()
,
simpleAmigaIcon()
,
write.AmigaIcon()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: ## create a simple AmigaIcon: icon <- simpleAmigaIcon() ## write the icon to the temp dir: write.AmigaIcon(icon, file.path(tempdir(), "icon.info")) ## read the same file: icon2 <- read.AmigaIcon(file.path(tempdir(), "icon.info")) ## End(Not run)
## Not run: ## create a simple AmigaIcon: icon <- simpleAmigaIcon() ## write the icon to the temp dir: write.AmigaIcon(icon, file.path(tempdir(), "icon.info")) ## read the same file: icon2 <- read.AmigaIcon(file.path(tempdir(), "icon.info")) ## End(Not run)
Read the Interchange File Format (IFF) as an IFFChunk()
object.
read.iff(file, disk = NULL)
read.iff(file, disk = NULL)
file |
A filename of an IFF file to be read, or a connection from which binary data can be read. |
disk |
A virtual Commodore Amiga disk from which the |
Information is stored as ‘chunks’ in IFF files (see IFFChunk()
).
Each chunk should at least contain a label of the type of chunk and the data
for that chunk. This function reads all chunks from a valid IFF file, including
all nested chunks and stores them in an IFFChunk()
object. IFF
files can hold any kind of data (e.g. images or audio), this read function
does not interpret the file. Use interpretIFFChunk()
for that
purpose.
Returns a IFFChunk()
object read from the specified file.
Pepijn de Vries
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
Other iff.operations:
IFFChunk-class
,
WaveToIFF()
,
as.raster.AmigaBasicShape()
,
getIFFChunk()
,
interpretIFFChunk()
,
rasterToIFF()
,
rawToIFFChunk()
,
write.iff()
## Not run: ## let's read a bitmap image stored in IFF as provided with this package: filename <- system.file("ilbm8lores.iff", package = "AmigaFFH") example.iff <- read.iff(filename) ## And plot it: plot(example.iff) ## End(Not run)
## Not run: ## let's read a bitmap image stored in IFF as provided with this package: filename <- system.file("ilbm8lores.iff", package = "AmigaFFH") example.iff <- read.iff(filename) ## And plot it: plot(example.iff) ## End(Not run)
Read a binary Amiga system-configuration file and return as SysConfig object.
read.SysConfig(file, disk = NULL)
read.SysConfig(file, disk = NULL)
file |
The file name of a system-configuration file to be read. Can also be a connection that allows reading binary data. |
disk |
A virtual Commodore Amiga disk from which the |
Amiga OS 1.x stored system preferences in a binary system-configuration file. This function returns the file in a comprehensive format (a SysConfig object).
Returns an S3 SysConfig class object based on the file that is read.
Pepijn de Vries
Other SysConfig.operations:
SysConfig
,
rawToSysConfig()
,
simpleSysConfig()
,
write.SysConfig()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: ## Put a simple SysConfig object into the tempdir: write.SysConfig(simpleSysConfig(), file.path(tempdir(), "system-configuration")) ## Now read the same file: sc <- read.SysConfig(file.path(tempdir(), "system-configuration")) ## and plot it plot(sc) ## End(Not run)
## Not run: ## Put a simple SysConfig object into the tempdir: write.SysConfig(simpleSysConfig(), file.path(tempdir(), "system-configuration")) ## Now read the same file: sc <- read.SysConfig(file.path(tempdir(), "system-configuration")) ## and plot it plot(sc) ## End(Not run)
Graphical representation of files and directories (icons) are stored as
separate files (with the .info extension) on the Amiga. This function writes
AmigaIcon()
class objects to such files.
simpleAmigaIcon( version = c("OS1.x", "OS2.x"), type = c("WBDISK", "WBDRAWER", "WBTOOL", "WBPROJECT", "WBGARBAGE", "WBDEVICE", "WBKICK", "WBAPPICON"), two.images = TRUE, back.fill = FALSE, ... )
simpleAmigaIcon( version = c("OS1.x", "OS2.x"), type = c("WBDISK", "WBDRAWER", "WBTOOL", "WBPROJECT", "WBGARBAGE", "WBDEVICE", "WBKICK", "WBAPPICON"), two.images = TRUE, back.fill = FALSE, ... )
version |
A |
type |
A |
two.images |
A single |
back.fill |
A single |
... |
Reserved for additional arguments. Currently ignored. |
This function creates basic AmigaIcon()
objects which
can be modified afterwards. It uses simple generic images to represent
different types of files or directories.
Returns a simple S3 object of class AmigaIcon()
.
Pepijn de Vries
Other AmigaIcon.operations:
AmigaIcon
,
rawToAmigaIcon()
,
read.AmigaIcon()
,
write.AmigaIcon()
Other raw.operations:
as.AmigaBasic()
,
as.raw.AmigaBasic()
,
colourToAmigaRaw()
,
packBitmap()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasicShape()
,
rawToAmigaBasic()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
rawToAmigaIcon()
,
rawToHWSprite()
,
rawToIFFChunk()
,
rawToSysConfig()
## Not run: ## Create an AmigaIcon object using the default arguments: icon <- simpleAmigaIcon() ## End(Not run)
## Not run: ## Create an AmigaIcon object using the default arguments: icon <- simpleAmigaIcon() ## End(Not run)
SysConfig objects are comprehensive representations of binary Amiga system-configuration files. Use this function to create a simple SysConfig object.
simpleSysConfig(options)
simpleSysConfig(options)
options |
A named |
The Amiga used the system-configuration file to store certain system preferences in a binary file. In the AmigaFFH package such files can be represented by the more comprehensive SysConfig class object. Use this function to create such an object with basic settings (which can be modified).
Returns a comprehensive representation of a system-configuration file in the for of a SysConfig class object.
Pepijn de Vries
Other SysConfig.operations:
SysConfig
,
rawToSysConfig()
,
read.SysConfig()
,
write.SysConfig()
## Not run: ## Create a simple system-configuration (S3 SysConfigClass) sc <- simpleSysConfig() ## And modify it as you wish. ## in this case change the setting for the printer ## from the parallel port to the serial port: sc$PrinterPort <- factor("SERIAL_PRINTER", levels(sc$PrinterPort)) ## It is also to provide modifications to the configuration ## via the 'options' argument: sc <- simpleSysConfig(options = list(FontHeight = 9)) ## End(Not run)
## Not run: ## Create a simple system-configuration (S3 SysConfigClass) sc <- simpleSysConfig() ## And modify it as you wish. ## in this case change the setting for the printer ## from the parallel port to the serial port: sc$PrinterPort <- factor("SERIAL_PRINTER", levels(sc$PrinterPort)) ## It is also to provide modifications to the configuration ## via the 'options' argument: sc <- simpleSysConfig(options = list(FontHeight = 9)) ## End(Not run)
A comprehensive representation of an Amiga system-configuration file.
The system-configuration file is a binary file stored in the ‘devs’ folder of the root of a bootable Amiga DOS device, containing system preferences. It was used in Amiga OS 1.x. Although it could be used in later versions, it was gradually phased out and some settings may not be usable in the later versions. See references below for more details.
Definitions of the system-configuration have file been revised at some points. Revisions are minor and usually targeted at backward compatibility. Here revision V38.2 (released on 16 September 1992) is implemented, which is the latest documented version.
The sytem-configuration file contains settings for the serial and parallel port and the printer. It also contains some settings for the ‘workbench’ which was the Amiga equivalent of what is now mostly known as the computers desktop. Colours for the workbench and the shape of the mouse pointer are also stored in this file. Settings for the mouse and basic screen resolution are also part of the file.
The SysConfig object is a comprehensive representation of the binary
system-configuration file. It is a a list
where the elements have identical
names as listed in the documents provided the references. The names are usually
self-explanatory, but the referred documents can also be
consulted to obtain more detailed information with respect to each of
these elements. The mouse pointer is included as a hardwareSprite()
object
in the list. The pointer image can be replaced by a different hardwareSprite()
,
but make sure it has an height of 16 pixels.
It is possible to change the values of the list, but not all values may be valid.
Note that they will not be fully checked for validity. Invalid values may result in errors
when writing to a binary file using write.SysConfig()
, or may simply not
work properly on an Amiga or in an emulator.
Use simpleSysConfig()
for creating a simple SysConfig object which can
be modified. Use read.SysConfig()
to read, and write.SysConfig()
to write system-configuration files. With rawToSysConfig()
and
as.raw()
SysConfig can be coerced back and forth from and to
its raw (binary) form.
Pepijn de Vries
https://wiki.amigaos.net/wiki/Preferences#Preferences_in_1.3_and_Older_Versions_of_the_OS http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_2._guide/node00D5.html http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_3._guide/node063B.html
Other SysConfig.operations:
rawToSysConfig()
,
read.SysConfig()
,
simpleSysConfig()
,
write.SysConfig()
Some Amiga applications use a timeval struct (see references) to represent a time span in seconds. This function coerces raw data to such a numeric time span.
timeval(x)
timeval(x)
x |
a |
Timeval is a structure (struct) as specified in device/timer.h on the Amiga (see
references). It represents a timespan in seconds. This function retrieves the
numeric value from raw
data. Amongst others, the timeval struct was used
in the system-configuration file (see SysConfig) to specify key repeat speed,
key repeat delay and mouse double click speed. Use as.raw
for the inverse
of this function and get the original raw data.
Returns a numeric
vector
of a timespan in seconds. It is
represented as an S3 AmigaTimeVal class.
Pepijn de Vries
http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_2._guide/node0053.html
## First four raw values represent seconds, the latter four microseconds: temp <- timeval(as.raw(c(0, 0, 0, 1, 0, 0, 0, 1))) print(temp) ## You can use 'as.raw' to get the original raw data again: as.raw(temp)
## First four raw values represent seconds, the latter four microseconds: temp <- timeval(as.raw(c(0, 0, 0, 1, 0, 0, 0, 1))) print(temp) ## You can use 'as.raw' to get the original raw data again: as.raw(temp)
Convert tuneR::WaveMC()
objects (or objects that can be coerced to
WaveMC
objects) into an IFFChunk-class()
object which
can be stored as a valid Iterchange File Format (write.iff()
).
WaveToIFF( x, loop.start = NA, octaves = 1, compress = c("sCmpNone", "sCmpFibDelta"), ... )
WaveToIFF( x, loop.start = NA, octaves = 1, compress = c("sCmpNone", "sCmpFibDelta"), ... )
x |
A |
loop.start |
If the sample should be looped from a specific position to the
end of the sample, this argument specifies the starting position in samples (with
a base of 0) for looping. |
octaves |
A whole positive |
compress |
A |
... |
Currently ignored. |
tuneR::WaveMC()
objects can be read from contemporary file containers
with tuneR::readWave()
or tuneR::readMP3()
. With this
function such objects can be converted into an IFFChunk-class()
object
which can be stored conform the Interchange File Format (write.iff()
).
When x
is not a pcm formatted 8-bit sample, x
will first be
normalised and scaled to a pcm-formatted 8-bit sample using
tuneR::normalize()
. If you don't like the result you need to convert
the sample to 8-bit pcm yourself before calling this function.
Returns an IFFChunk-class()
object with a FORM container that
contains an 8SVX waveform based on x
.
Pepijn de Vries
https://en.wikipedia.org/wiki/8SVX
Other iff.operations:
IFFChunk-class
,
as.raster.AmigaBasicShape()
,
getIFFChunk()
,
interpretIFFChunk()
,
rasterToIFF()
,
rawToIFFChunk()
,
read.iff()
,
write.iff()
## Not run: ## First get an audio sample from the ProTrackR package snare.samp <- ProTrackR::PTSample(ProTrackR::mod.intro, 2) ## The sample can easily be converted into an IFFChunk: snare.iff <- WaveToIFF(snare.samp) ## You could also first convert the sample into a Wave object: snare.wav <- as(snare.samp, "Wave") ## And then convert into an IFFChunk. The result is the same: snare.iff <- WaveToIFF(snare.wav) ## You could also use a sine wave as input (although you will get some warnings). ## This will work because the vector of numeric data can be coerced to ## a WaveMC object sine.iff <- WaveToIFF(sin((0:2000)/20)) ## End(Not run)
## Not run: ## First get an audio sample from the ProTrackR package snare.samp <- ProTrackR::PTSample(ProTrackR::mod.intro, 2) ## The sample can easily be converted into an IFFChunk: snare.iff <- WaveToIFF(snare.samp) ## You could also first convert the sample into a Wave object: snare.wav <- as(snare.samp, "Wave") ## And then convert into an IFFChunk. The result is the same: snare.iff <- WaveToIFF(snare.wav) ## You could also use a sine wave as input (although you will get some warnings). ## This will work because the vector of numeric data can be coerced to ## a WaveMC object sine.iff <- WaveToIFF(sin((0:2000)/20)) ## End(Not run)
Write an AmigaBasic()
class object to a file in its binary format.
write.AmigaBasic(x, file, disk = NULL)
write.AmigaBasic(x, file, disk = NULL)
x |
The |
file |
A |
disk |
A virtual Commodore Amiga disk to which the |
This function encodes the Amiga Basic code in its binary format
(using as.raw()
) and writes it to a file. The file
can also be stored onto a virtual Amiga disk
(amigaDisk()
).
Invisibly returns the result of the call of close
to the
file connection. Or, when disk
is specified, a copy of
disk
is returned to which the file(s) is/are written.
Pepijn de Vries
Other AmigaBasic.operations:
AmigaBasic.reserved()
,
AmigaBasicBMAP
,
AmigaBasic
,
[.AmigaBasic()
,
as.AmigaBasicBMAP()
,
as.AmigaBasic()
,
as.character()
,
check.names.AmigaBasic()
,
names.AmigaBasic()
,
rawToAmigaBasicBMAP()
,
rawToAmigaBasic()
,
read.AmigaBasicBMAP()
,
read.AmigaBasic()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: ## First create an AmigaBasic object: bas <- as.AmigaBasic("PRINT \"hello world!\"") ## write to tempdir: write.AmigaBasic(bas, file.path(tempdir(), "helloworld.bas")) ## End(Not run)
## Not run: ## First create an AmigaBasic object: bas <- as.AmigaBasic("PRINT \"hello world!\"") ## write to tempdir: write.AmigaBasic(bas, file.path(tempdir(), "helloworld.bas")) ## End(Not run)
Write an AmigaBasicShape()
class object to a file in its binary format.
write.AmigaBasicShape(x, file, disk = NULL)
write.AmigaBasicShape(x, file, disk = NULL)
x |
The |
file |
A |
disk |
A virtual Commodore Amiga disk to which the |
This function coerces the Amiga Basic Shape into its binary format
(using as.raw()
) and writes it to a file. The file
can also be stored onto a virtual Amiga disk
(amigaDisk()
).
Invisibly returns the result of the call of close
to the
file connection. Or, when disk
is specified, a copy of
disk
is returned to which the file(s) is/are written.
Pepijn de Vries
Other AmigaBasicShape.operations:
AmigaBasicShape
,
rasterToAmigaBasicShape()
,
read.AmigaBasicShape()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: filename <- system.file("ball.shp", package = "AmigaFFH") ball <- read.AmigaBasicShape(filename) write.AmigaBasicShape(ball, file.path(tempdir(), "ball.shp")) ## End(Not run)
## Not run: filename <- system.file("ball.shp", package = "AmigaFFH") ball <- read.AmigaBasicShape(filename) write.AmigaBasicShape(ball, file.path(tempdir(), "ball.shp")) ## End(Not run)
Functions to write AmigaBitmapFont()
and AmigaBitmapFontSet()
class objects to files.
write.AmigaBitmapFont(x, file, disk = NULL) write.AmigaBitmapFontSet(x, path = getwd(), disk = NULL)
write.AmigaBitmapFont(x, file, disk = NULL) write.AmigaBitmapFontSet(x, path = getwd(), disk = NULL)
x |
Respectively an |
file |
A |
disk |
A virtual Commodore Amiga disk to which the |
path |
A |
AmigaBitmapFontSet()
class objects are written to a *.font
file. The filename used for this purpose is obtained from the object
itself using fontName()
. In addition, a subdirectory is
created automatically (when it doesn't already exist)
to which al the separate bitmap images for each font height are written
to individual files.
AmigaBitmapFont()
class objects can also be written to a
file. In order to use it on a Commodore Amiga or emulator, it is better
to embed the font bitmap in a font set (using c()
)
and write the set to corresponding files.
Invisibly returns the result of the call of close
to the
file connection. Or, when disk
is specified, a copy of
disk
is returned to which the file(s) is/are written.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rasterToAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaIcon()
,
write.SysConfig()
,
write.iff()
## Not run: ## obtain a bitmap font set: data(font_example) ## write the font set to their files. The file name ## is extracted from the font object, so you only have ## to provide the path: write.AmigaBitmapFont(font_example, temp.dir()) ## extract a font bitmap: font <- getAmigaBitmapFont(font_example, 9) ## and write it to the temp dir: write.AmigaBitmapFont(font, file.path(temp.dir(), "9")) ## The following examples require the 'adfExplorer' package: font.disk <- adfExplorer::blank.amigaDOSDisk("font.disk") font.disk <- adfExplorer::dir.create.adf(font.disk, "FONTS") font.disk <- write.AmigaBitmapFontSet(font_example, "DF0:FONTS", font.disk) ## End(Not run)
## Not run: ## obtain a bitmap font set: data(font_example) ## write the font set to their files. The file name ## is extracted from the font object, so you only have ## to provide the path: write.AmigaBitmapFont(font_example, temp.dir()) ## extract a font bitmap: font <- getAmigaBitmapFont(font_example, 9) ## and write it to the temp dir: write.AmigaBitmapFont(font, file.path(temp.dir(), "9")) ## The following examples require the 'adfExplorer' package: font.disk <- adfExplorer::blank.amigaDOSDisk("font.disk") font.disk <- adfExplorer::dir.create.adf(font.disk, "FONTS") font.disk <- write.AmigaBitmapFontSet(font_example, "DF0:FONTS", font.disk) ## End(Not run)
Graphical representation of files and directories (icons) are stored as
separate files (with the .info extension) on the Amiga. This function writes
AmigaIcon()
class objects to such files.
write.AmigaIcon(x, file, disk = NULL)
write.AmigaIcon(x, file, disk = NULL)
x |
An |
file |
A |
disk |
A virtual Commodore Amiga disk to which the |
The AmigaIcon()
S3 object provides a comprehensive format
for Amiga icons, which are used as a graphical representation of files
and directories on the Amiga. The AmigaIcon()
is a named
list containing all information of an icon. Use this function to
write this object to a file which can be used on the Commodore Amiga
or emulator.
Returns NULL
or an integer
status passed on by the
close()
function, that is used to close the file connection.
It is returned invisibly. Or, when disk
is specified, a copy of
disk
is returned to which the file is written.
Pepijn de Vries
Other AmigaIcon.operations:
AmigaIcon
,
rawToAmigaIcon()
,
read.AmigaIcon()
,
simpleAmigaIcon()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.SysConfig()
,
write.iff()
## Not run: ## create a simple AmigaIcon: icon <- simpleAmigaIcon() ## write the icon to the temp dir: write.AmigaIcon(icon, file.path(tempdir(), "icon.info")) ## End(Not run)
## Not run: ## create a simple AmigaIcon: icon <- simpleAmigaIcon() ## write the icon to the temp dir: write.AmigaIcon(icon, file.path(tempdir(), "icon.info")) ## End(Not run)
Write an IFFChunk()
object conform the Interchange File Format (IFF).
write.iff(x, file, disk = NULL)
write.iff(x, file, disk = NULL)
x |
An |
file |
A filename for the IFF file to which the |
disk |
A virtual Commodore Amiga disk to which the |
Writes an IFFChunk()
object (including all nested chunks) to the
specified file. Only the structure of the object needs to be valid, however,
a correctly structured file does not necessarily result in an interpretable file
(see examples).
Returns either NULL
or an integer
status invisibly as passed
by the close()
statement used to close the file connection.
When disk
is specified, a copy of disk
is returned
to which the file is written.
Pepijn de Vries
https://en.wikipedia.org/wiki/Interchange_File_Format
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.SysConfig()
Other iff.operations:
IFFChunk-class
,
WaveToIFF()
,
as.raster.AmigaBasicShape()
,
getIFFChunk()
,
interpretIFFChunk()
,
rasterToIFF()
,
rawToIFFChunk()
,
read.iff()
## Not run: ## read an IFF file as an IFFChunk object: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## This will write the IFF file (in this case a bitmap image) ## to the temp directory: write.iff(example.iff, file.path(tempdir(), "image.iff")) ## End(Not run)
## Not run: ## read an IFF file as an IFFChunk object: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## This will write the IFF file (in this case a bitmap image) ## to the temp directory: write.iff(example.iff, file.path(tempdir(), "image.iff")) ## End(Not run)
Write a SysConfig class object to an Amiga binary system-configuration file.
write.SysConfig(x, file, disk = NULL)
write.SysConfig(x, file, disk = NULL)
x |
An S3 SysConfig class object. |
file |
A file name to which the binary file should be written. |
disk |
A virtual Commodore Amiga disk to which the |
Amiga OS 1.x stored system preferences in a binary system-configuration file. This function writes a SysConfig class object as such a binary file. This file can be used on an Amiga or in an emulator.
Returns NULL
or an integer
status passed on by the
close()
function, that is used to close the file connection.
It is returned invisibly. Or, when disk
is specified, a copy of
disk
is returned to which the file is written.
Pepijn de Vries
Other SysConfig.operations:
SysConfig
,
rawToSysConfig()
,
read.SysConfig()
,
simpleSysConfig()
Other io.operations:
read.AmigaBasicBMAP()
,
read.AmigaBasicShape()
,
read.AmigaBasic()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
read.AmigaIcon()
,
read.SysConfig()
,
read.iff()
,
write.AmigaBasicShape()
,
write.AmigaBasic()
,
write.AmigaBitmapFont()
,
write.AmigaIcon()
,
write.iff()
## Not run: ## First generate a simple SysConfig object to write to a file: sc <- simpleSysConfig() ## And write to the tempdir: write.SysConfig(sc, file.path(tempdir(), "system-configuration")) ## End(Not run)
## Not run: ## First generate a simple SysConfig object to write to a file: sc <- simpleSysConfig() ## And write to the tempdir: write.SysConfig(sc, file.path(tempdir(), "system-configuration")) ## End(Not run)