Skip to content

rifxlib

This library makes effects with the bitmap objects of Blitz Basic 2. None of its commands uses the blitter: all of them work with the processor, in Amiga and in Blitz mode.

ClearBitmap and FadeInBitmap clear a bitmap or copy one onto another line by line through a dither pattern, slowed down by a delay so the effect can be seen. ZoomX2, ZoomX4 and ZoomX8 enlarge a rectangle of a bitmap two, four or eight times into another bitmap, and ReduceX2 halves one. Derez makes a picture blocky, and ZoomXY, after InitZoomXY, enlarges by any whole factors.

The zoom commands take the position of the rectangle as a byte offset into the bitplanes, which ADDValue computes from x and y. The position therefore moves in steps of 8 pixels, and widths count whole bytes. Nothing is clipped: the rectangle and its enlargement must fit inside the bitmaps. The destination needs at least the depth of the source; source and destination can be the same bitmap as long as the result does not overwrite the part still to be read.

Derez and ZoomXY work only on low resolution bitmaps 320 pixels (40 bytes) wide, and ZoomyZoom on bitmaps 640 pixels wide; the others work on bitmaps of any width. The bitmaps may have at most 8 bitplanes; with runtime error checking, a bitmap of depth 0 or more than 8 is the error “Illegal BitMap Depth”. The zooms by 2, 4 and 8, ReduceX2 and ZoomyZoom use tables the library builds at program start.

A picture zoomed to twice its size from its middle, then faded in on another bitmap and cleared again:

BitMap 0,320,256,4
BitMap 1,320,256,4
LoadBitMap 0,"picture.iff"
ZoomX2 0,1,ADDValue(0,80,64),0,160,128
FadeInBitmap 0,1,500
ClearBitmap 1,500

Based on the RI FX Lib guide by Reflective Images.

Library number 66.

Commands

ADDValue

Returns the byte offset of the pixel x,y in a bitplane of the bitmap, y times its bytes per row plus x/8, as the zoom commands take it.

Function, result .l. Help text: (bitmap#,x,y)
Arguments: .b, .w, .w

ClearBitmap

Clears a bitmap line by line from the bottom up, each line first through a dither pattern and 19 lines later fully. delay slows the effect down; with height and offset only height lines from line offset on are cleared.

Statement. Help text: bitmap#,delay[,height,offset]
2 forms:

  • .l, .l
  • .l, .l, .w, .w

The delay is the number of turns of an empty loop after every line, so its effect depends on the speed of the machine. It is a long. A delay of 0 waits 4294967296 turns per line, and the program seems to hang; with runtime error checking it is the error “Delay must not be 0”. Also with runtime error checking, a bitmap of depth 0 or more than 8 is the error “Illegal BitMap Depth”.

The RI FX Lib guide gives the optional parameters in the other order, offset,height, and calls the delay a word. The library takes height first and the delay as a long, as its help line shows, and compiled programs depend on that order.

Derez

Copies a rectangle of a low resolution bitmap to another and makes it blocky, every block of derez_value x derez_value pixels in the colour of its top left pixel. The result is 320 pixels wide and height lines high; a derez_value of 1 copies, 0 does nothing.

Statement or function, result .l. Help text: source#,dest#,sourceadd,destadd,derez_value,height
Arguments: .l, .l, .l, .l, .w, .w

Both bitmaps must be 320 pixels (40 bytes) wide. Used as a function, it returns -1 when it worked and 0 for a derez_value of 0. With runtime error checking, a bitmap of depth 0 or more than 8 is the error “Illegal BitMap Depth”; without it, a source of depth 0 overwrites memory.

FadeInBitmap

Copies one bitmap onto another line by line from the top down, each line first through a dither pattern and 19 lines later fully, so that the picture fades in. delay slows the effect down; with the optional values only height lines are copied, from line offset1 of the source to line offset2 of the destination.

Statement. Help text: bitmapsource#,bitmapdest#,delay[,height,offset1,offset2]
2 forms:

  • .l, .l, .l
  • .l, .l, .l, .w, .w, .w

Width and depth come from the source bitmap, and the destination is walked with the width of the source, so both should have the same width and the destination at least the depth of the source. The delay, and the runtime errors for a delay of 0 and for a depth of 0 or more than 8, are as for ClearBitmap.

The RI FX Lib guide gives the optional parameters in the other order, offset1,offset2,height, and calls the delay a word. The library takes height first and the delay as a long, as its help line shows, and compiled programs depend on that order.

GetZoomTables

Returns the address of four longs, the addresses of the library’s tables for ReduceX2 (256 bytes), the zoom by 2 (256 words), by 4 (256 longs) and by 8 (16 longs).

Function, result .l. Help text: - return pointer to array of tables
No arguments.

InitZoomXY

Chooses the source and destination bitmap of ZoomXY and the byte offsets in them where it starts reading and writing.

Statement. Help text: source#,dest#,sourceadd,destadd
Arguments: .l, .l, .l, .l

The choice holds for the rest of the run. Every run of a program starts with none, also a second run from the editor.

ReduceX2

Halves a rectangle of width x height pixels in both directions, from byte offset sourceadd of the source bitmap to byte offset destadd of the destination, keeping every second pixel of every second line.

Statement. Help text: source#,dest#,sourceadd,destadd,width,height
Arguments: .b, .b, .l, .l, .w, .w

The width should be a multiple of 16; nothing happens with a width below 16 or a height below 2.

ZoomX2

Enlarges a rectangle of width x height pixels twice in both directions, from byte offset sourceadd of the source bitmap to byte offset destadd of the destination.

Statement. Help text: source#,dest#,sourceadd,destadd,width,height
Arguments: .l, .l, .l, .l, .w, .w

The width counts whole bytes (multiples of 8 pixels); nothing happens with a width below 8 or a height below 1. The number of bitplanes is that of the source.

ZoomX4

Enlarges a rectangle of width x height pixels four times in both directions, from byte offset sourceadd of the source bitmap to byte offset destadd of the destination. With xy_select 1 only the width is enlarged, with 2 only the height.

Statement. Help text: source#,dest#,sourceadd,destadd,width,height[,xy_select]
2 forms:

  • .b, .b, .l, .l, .w, .w
  • .b, .b, .l, .l, .w, .w, .b

Nothing happens with a width below 8 or a height below 1. The number of bitplanes is that of the source.

ZoomX8

Enlarges a rectangle of width x height pixels eight times in both directions, from byte offset sourceadd of the source bitmap to byte offset destadd of the destination.

Statement. Help text: source#,dest#,sourceadd,destadd,width,height
Arguments: .b, .b, .l, .l, .w, .w

Works on bitmaps of any width. Nothing happens with a width below 8 or a height below 1. The number of bitplanes is that of the source.

ZoomXY

Enlarges the source chosen with InitZoomXY into its destination, every pixel xzoom pixels wide and every line yzoom lines high. The result is clipped to 320 pixels in width and height lines; 1,1 copies, and a factor of 0 does nothing.

Statement. Help text: xzoom,yzoom,height
Arguments: .w, .w, .w

Only for low resolution bitmaps 320 pixels (40 bytes) wide, and only after InitZoomXY. With runtime error checking, a ZoomXY before any InitZoomXY of the run is the error “ZoomXY needs InitZoomXY”; without it, such a ZoomXY reads a bitmap at address 0 and writes through the processor’s exception vectors there. The bitmaps of InitZoomXY are checked as with Derez.

ZoomyZoom

Doubles the left half of the first 32 lines of a bitmap 640 pixels wide in place, so it fills the whole width.

Statement. Help text: bitmap#
Arguments: .w

The command always works on 32 lines of 80 bytes. With runtime error checking, a smaller bitmap is the error “ZoomyZoom needs a bitmap of at least 640 x 32”; without it, the size of the bitmap is not looked at.