Skip to content

rimapeditorlib

This library was written by Reflective Images for their block map editor, MapEd, and holds what the editor needed beside the standard libraries.

Its object is the MapObject, a block map: a grid of width by height cells of one word each, with the size of a block in pixels (bwidth, bheight), a name and a “changed” flag. MapObjects are numbered from 0; there are 5 unless the program asks for more. CreateMap makes a map and makes it the current one; all other map commands work on the current map. The data of a map is plain memory: MapDataAdr gives its address, so a program can read and write the cells with Peek.w and Poke.w. By the convention of MapCanDraw, a cell holds a shape number plus 1, and 0 for an empty cell.

MapCanDraw tells whether a shape may be put into a cell. It can take two more things into account: a stencil, a byte array set with SetStencil that forbids drawing over certain cell values, and a rub-through map, a second map whose cells give the value instead of the shape number.

The other commands are independent of the maps: shape helpers (ScanShapes, ShapeTo1616, ShapeMaskFill), a mesh pattern for a bitmap (FillBitplane) or a window (SetWindowDraw), text output into any RastPort (MapOutText and its forms), and a parser that splits a text at commas (M_InitParse, M_NextArg$). The library opens graphics.library for the text commands.

A map of 40 by 25 cells of 16 by 16 pixels, and a shape put into a cell:

CreateMap 0,40,25,16,16,"level1"
Dim stc.b(255)
SetStencil stc()
v=MapCanDraw(3,10,5)
If v<>-1 Then Poke.w MapDataAdr(10,5),v

Library number 8. It manages MapObject objects, by default at most 5 (the compiler options set the maximum).

Commands

ClearRubThroughMap

Removes the rub-through map of the current map.

Statement. No help text.
No arguments.

CreateMap

Makes a map of width by height cells, all 0, with blocks of bwidth by bheight pixels and the name name$, and makes it the current map. A map the object held before is freed.

Statement. Help text: map#,width,height,bwidth,bheight,name$
Arguments: .w, .w, .w, .w, .w, $

If there is no memory, or width or height is 0, the map gets the size 0 and has no data. A width above 32767 is a runtime error with runtime error checking; without it, such a map gets too little memory.

FillBitplane

Fills the first bitplane of a bitmap with a mesh, width pixels (rounded down to a multiple of 16) by height rows from the top left corner.

Statement. Help text: bitmap#,width,height
Arguments: .w, .w, .w

With runtime error checking, a width below 16 or a height of 0 is a runtime error. Without it they are not checked and write 65536 words or rows over memory.

M_InitParse

Sets the text that M_NextArg$ splits, given as the address of a text that ends in a zero byte. The text is copied, at most 255 characters of it.

Statement. Help text: string
Arguments: .l

M_NextArg$

The next part of the text of M_InitParse, up to the next comma; after the last part, and before any M_InitParse, an empty string.

Function, result $. Help text: - get next parameter
No arguments.

Spaces are kept. An empty part between two commas gives an empty string too.

MapCanDraw

Whether a shape may be put at mapx,mapy of the current map. Returns -1 if not - outside the map, the cell holds this value already, or the stencil forbids the value in the cell - and otherwise the value for the cell, shape# plus 1.

Function, result .w. Help text: (shape#,mapx,mapy)
Arguments: .w, .w, .w

With a rub-through map, the value is that map’s cell at the position instead of shape# plus 1. The address of the cell is kept for MapCanDrawAddr, unless the position is outside the map.

With runtime error checking, a call before any SetStencil, a cell value of 32768 or more that is looked up in the stencil, and a map without data are runtime errors.

MapCanDrawAddr

The address of the cell that the last MapCanDraw on the current map looked at.

Function, result .l. Help text: - returns last address calculated by DoDraw
No arguments.

MapDataAdr

Without values, the address of the data of the current map; with x,y, the address of the cell at that position.

Function, result .l. Help text: [x,y] - returns adress of the current map
2 forms:

  • no arguments
  • .w, .w

With runtime error checking, a position outside the map is a runtime error; without it, the position is not checked.

MapDataChanged

Without a value, returns the changed flag of the current map; with newstate, sets the flag and returns the old one.

Statement or function, result .w. Help text: [newstate] - has map changed since last load?
2 forms:

  • no arguments
  • .w

The library only keeps the flag: CreateMap sets it to 0, and the program sets it when it changes the map.

MapDataGrab

Fills all cells of the current map from memory at address, with mapnull added to every value. A datasize of 0 reads one byte per cell, any other value one word.

Statement. Help text: address,datasize,mapnull
Arguments: .l, .w, .w

Into a map without data, such as one of width or height 0, nothing is filled; with runtime error checking, it is a runtime error.

MapDataSize

The size of the data of the current map in bytes, 2 bytes per cell.

Function, result .l. Help text: - returns byte size of map data
No arguments.

MapObject

The object of a block map, as the introduction describes.

Object name. No help text.

When a MapObject is freed, its data and its name are freed with it.

MapObjheight

The height of the current map, in cells.

Function, result .w. Help text: - returns height of the current map
No arguments.

MapObjName$

The name of the current map, or an empty string if it has none.

Function, result $. Help text: - returns name of the current map
No arguments.

MapObjViewX

The view x position stored with the current map. CreateMap sets it to 0; no command of the library changes it.

Function, result .w. Help text: - returns viewx of the current map
No arguments.

MapObjViewY

The view y position stored with the current map. CreateMap sets it to 0; no command of the library changes it.

Function, result .w. Help text: - returns viewy of the current map
No arguments.

MapObjWidth

The width of the current map, in cells.

Function, result .w. Help text: - returns width of the current map
No arguments.

MapOutText

Prints a text into a RastPort with its top left corner at x,y, in the RastPort’s font and pen. The text is a string or the address of a text that ends in a zero byte.

Statement. Help text: x,y,rastport,address/string
Arguments: .w, .w, .l, any

MapOutTextCenter

Like MapOutText, but the text is centred on x.

Statement. Help text: x,y,rastport,address/string
Arguments: .w, .w, .l, any

MapOutTextPen

Sets the foreground pen of a RastPort, the colour in which the text commands print.

Statement. Help text: rastport,pen
Arguments: .l, .w

MapOutTextRight

Like MapOutText, but the text ends at x.

Statement. Help text: x,y,rastport,address/string
Arguments: .w, .w, .l, any

RubThroughMap

With a map number, makes that map the rub-through map of the current map; without, returns the address of the current map’s rub-through map, or 0 if it has none.

Statement or function, result .l. Help text: [mapobject#]
2 forms:

  • no arguments
  • .l

While a map has a rub-through map, MapCanDraw takes the value of a cell from the rub-through map instead of the shape number, and also refuses positions outside the rub-through map.

ScanMaxdepth

The largest depth found by the last ScanShapes.

Function, result .w. Help text: - returns max depth found after Scan
No arguments.

ScanMaxheight

The largest height found by the last ScanShapes.

Function, result .w. Help text: - returns max height found after Scan
No arguments.

ScanMaxWidth

The largest width found by the last ScanShapes.

Function, result .w. Help text: - returns max width found after Scan
No arguments.

ScanShapes

Finds the largest width, height and depth of the shapes from startnum on, up to highest or the first empty shape, for ScanMaxWidth, ScanMaxheight and ScanMaxdepth. Returns the number of the last shape scanned, the empty one or highest.

Statement or function, result .w. Help text: startnum,highest - returns last shape scanned (null shape)
Arguments: .w, .w

If startnum is above highest, the scan goes on to the first empty shape.

SetMapObjName$

Gives the current map a new name.

Statement. Help text: name$
Arguments: $

SetStencil

Sets the stencil of MapCanDraw, a byte array with one byte for each cell value; a byte other than 0 forbids drawing over cells of that value.

Statement. Help text: <array> - a byte array holding stencil data
Arguments: array()

Call SetStencil before MapCanDraw, and keep the cell values below 32768. With runtime error checking, MapCanDraw without a stencil or with a larger value is a runtime error; without it, the stencil is read at address 0, and larger values index the array backwards.

SetWindowDraw

Sets the area pattern of the current window’s RastPort to a mesh (every other pixel) for a mode other than 0, and removes it for 0.

Statement. Help text: mode -- 0=normal, 1=meshed
Arguments: .w, .w

The command takes two values, a window number and the mode, although its help names only the mode. The window number is not used: the pattern always goes to the current window.

ShapeMaskFill

Sets the first 32 bytes of the shape’s cookie, which make the whole cookie of a 16 by 16 shape of one plane, so the shape is drawn as a solid block.

Statement. Help text: shape#
Arguments: .w

The shape must have a cookie.

ShapeTo1616

Copies the top left 16 by 16 pixels of every plane of the source shape into the data of the destination shape, which must be a 16 by 16 shape with at least the depth of the source. Rows the source does not have are cleared.

Statement. Help text: source shape,dest shape
Arguments: .w, .w

With runtime error checking, a source shape of height or depth 0 and a destination that is not 16 by 16 pixels with at least the depth of the source are runtime errors. Without it they are not checked, and 16 rows are written for every plane of the source.