Skip to content

rishapeslib

This library works on the shape objects of Blitz Basic 2 and adds what the shapes library of Acid Software lacks. It brings a shapes file format of its own, the LE shapes file: an IFF file (FORM LESH) that holds the shapes, optionally a palette, and optionally packed shape data. LESaveShapes writes such a file, LELoadShapes reads it from disk and LECludgeShapes decodes one that is already in memory, for example included with IncBin. LELoadShapes hands a file that is no IFF file to LoadShapes of the shapes library.

CludgeShapes and CludgeShapesToAddress make shapes from memory that holds them in the form SaveShapes writes. The other commands make an empty shape (LEInitShape), find the largest width, height and depth of a range of shapes (LEScanShapes) and check whether a shape fits into the current bitmap (SafeToBlit).

Shape data and cookies go into chip memory. Packing and unpacking use the pack library of Reflective Images (RIPackLib), which must be installed too. The commands that read or write files go through AmigaDOS, so call them in Amiga mode.

A shape that a command replaces is freed first, with its cookie. LEAutoCookie is on and the LEMaxShape values are 0 at the start of every run, also of a program run again from the editor.

The largest size of ten shapes:

LoadShapes 0,9,"ship.shapes"
LEScanShapes 0,9
NPrint LEMaxShapeWidth," x ",LEMaxShapeHeight

The fixed bugs of the library are listed in Fixes in rishapeslib.

Based on the RI Shapes Lib guide by Red When Excited.

Library number 46.

Commands

CludgeShapes

Makes numshapes shapes from shape# on out of shapes in memory at address, in the form SaveShapes writes (a 32-byte header and the data of each shape), and copies their data into chip memory. As a function it returns -1, or 0 if numshapes is 0.

Statement or function, result .l. Help text: shape#,numshapes,address
Arguments: .l, .l, .l

Shapes that are in use are freed first. A cookie is made for each shape while LEAutoCookie is on, which it is at the start. A shape in memory whose width, height or data size is 0 is an empty shape: it has only its 32-byte header, and the next shape follows directly behind it.

CludgeShapesToAddress

Like CludgeShapes, but the shapes are made in numshapes shape objects of 32 bytes each at Address, memory of the program’s own, instead of in the shape objects of Blitz Basic. As a function it returns -1, or 0 if numshapes is 0.

Statement or function, result .l. Help text: Address,numshapes,address
Arguments: .l, .l, .l

LEAutoCookie

Switches the cookies that CludgeShapes and CludgeShapesToAddress make on (any value but 0) or off (0). It is on at the start.

Statement. Help text: on|off
Arguments: .l

LECludgeShapes

Decodes an LE shapes file that is in memory at address into the shapes from the first shape# to the second, and its palette into palette#.

Statement. Help text: shape#,shape#,address,palette#[,copymemflag]
2 forms:

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

Shapes in use are freed first, and every shape gets a cookie. If the file is not packed and lies in chip memory (below 2 MB), the shapes use the data where it is instead of a copy, unless copymemflag is negative (-1): then the data is always copied into chip memory. Packed data is always unpacked into chip memory, and so are shapes whose data lie at an odd address, as in a file with an odd number of colours, since the blitter cannot draw them there. Nothing happens if the memory does not hold an LE shapes file.

LECompressShapes

Switches the packing of LESaveShapes on (True) or off (False). It is off at the start.

Statement. Help text: True|False
Arguments: .w

The library guide says that packing is on at the start; the library starts with it off, so call LECompressShapes True to pack.

LEInitShape

Makes an empty shape of the given width, height and depth, with cleared data and cookie in chip memory and both handles at 0.

Statement. Help text: shape#,width,height,depth
Arguments: .w, .w, .w, .w

A shape in use is freed first. The cookie is cleared, not made from the data.

LELoadShapes

Loads the shapes of an LE shapes file into the shapes from the first shape# to the second, or to the last shape if only one is given, and its palette into palette# if the file has one and a palette is given.

Statement. Help text: shape#[,shape#],filename$[,palette#]
4 forms:

  • .w, .w, $, .w
  • .w, .w, $
  • .w, $
  • .w, $, .w

Shapes in use are freed first. Packed shapes are unpacked; every shape gets a cookie. A file that is not an IFF file goes to LoadShapes of the shapes library. Nothing happens if the file cannot be opened.

A palette chunk that holds no whole colour leaves the palette as it is.

The library guide names a form shape#,filename$,palette# and says that it cannot be used: with three arguments the compiler takes the form shape#,shape#,filename$. To load a palette, give both shape numbers.

LEMaxShapeDepth

The largest depth found by the last LEScanShapes.

Function, result .w. No help text.
No arguments.

LEMaxShapeHeight

The largest height found by the last LEScanShapes.

Function, result .w. No help text.
No arguments.

LEMaxShapeWidth

The largest width found by the last LEScanShapes.

Function, result .w. No help text.
No arguments.

LESaveShapes

Saves the shapes from the first shape# to the second as an LE shapes file, with the colours of palette# if it is given. The data is packed while LECompressShapes is on.

Statement. Help text: shape#,shape#,filename$[,palette#]
2 forms:

  • .w, .w, $
  • .w, .w, $, .w

A shape that the packer cannot pack is stored unpacked. Nothing happens if the file cannot be opened. A palette of 0 colours is not saved. The palette chunk has no pad byte, so with an odd number of colours the chunks behind it start at an odd offset; LELoadShapes and LECludgeShapes read such files.

LEScanShapes

Finds the largest width, height and depth among the used shapes from startshape# to endshape#, for LEMaxShapeWidth, LEMaxShapeHeight and LEMaxShapeDepth.

Statement. Help text: startshape#,endshape#
Arguments: .w, .w

SafeToBlit

Returns -1 if the shape can be drawn at x,y in the current bitmap, else 0. The shape number must be below the maximum number of shapes, the shape must have a cookie, x and y must not be negative, and the shape must fit into the bitmap’s width and height.

Function, result .w. Help text: shape,x,y
Arguments: .w, .w, .w