BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
rimapshapeslib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include "blitzexec.h"
#include <exec/memory.h>
#include <graphics/gfx.h>
#include <graphics/rastport.h>
#include <intuition/intuition.h>

Data Structures

struct  mapshape
struct  member

Macros

#define MAPSHAPE(n)

Functions

void _shapetomapshape (void)
void _blitmapshape (void)
 BlitMapShape window#,mapshape#,x,y: a map shape blitted into the window's RastPort (assembler entry).
void _remapmapshape (void)
 RemapMapShape mapshape#,botcol,topcol: does nothing.
void _blitmapshapesize (void)
 BlitMapShapeSize window#,mapshape#,x,y,width,height: a part of a map shape blitted into the window's RastPort (assembler entry).
void _setnummapshapes (void)
void _mapshapeaddr (void)
void _freemapshapes (void)
void _addgroupmember (void)
void _blitgroup (void)
 BlitGroup window#,x,y: every member of the group blitted at x+dx, y+dy.
void _resetgroup (void)
void rimapshapeslib_libinit (void)
void rimapshapeslib_libfinit (void)
void _shapetomapshapechk (void)
void _addgroupmemberchk (void)
void _blitmapshapechk (void)
void _blitmapshapesizechk (void)
void _mapshapeaddrchk (void)
void _freemapshapeschk (void)
static void libinit_c (void)
 init: the group block (512 bytes, AllocMem MEMF_PUBLIC|MEMF_CLEAR).
static void libfinit_c (void)
 finit: frees the map shapes and the group block.
static void shapetomapshape_c (UWORD n, const struct bb_shape *sh)
 ShapeToMapShape shape#,mapshape#: a map shape from a Blitz shape.
static void setnummapshapes_c (UWORD num)
 SetNumMapShapes num: (re)allocates num map shapes.
static struct mapshape * mapshapeaddr_c (UWORD n)
 MapShapeAddr(mapshape#): the address of a map shape.
static void freemapshapes_c (UWORD first, UWORD last)
 FreeMapShapes first,last: the map shapes first to last made empty.
static struct member * resetgroup_c (UWORD bw, UWORD bh)
 ResetGroup(blockwidth,blockheight): empties the group and sets the block size for AddGroupMember.
static void addgroupmember_c (UWORD n, UWORD dx, UWORD dy)
 AddGroupMember mapshape#,dx,dy: a map shape added to the group.
static void numchk (UWORD n)
static void shapetomapshapechk_c (UWORD n, const struct bb_shape *sh)
 The error check of ShapeToMapShape (debugger only).
static void addgroupmemberchk_c (UWORD n)
 The error check of AddGroupMember (debugger only).
static void blitmapshapechk_c (UWORD n)
 The error check of BlitMapShape (debugger only).
static void blitmapshapesizechk_c (UWORD n, UWORD w)
 The error check of BlitMapShapeSize (debugger only).
static void mapshapeaddrchk_c (UWORD n)
 The error check of MapShapeAddr (debugger only).
static void freemapshapeschk_c (UWORD first, UWORD last)
 The error check of FreeMapShapes (debugger only).

Variables

static UWORD blockwidth
static UWORD blockheight
static struct mapshape * baseshape
static UWORD nummapshapes
static struct member * nextgroupmember
static struct member * groupaddr
static struct member * groupend

Macro Definition Documentation

◆ MAPSHAPE

#define MAPSHAPE ( n)
Value:
((struct mapshape *)((UBYTE *)baseshape + ((ULONG)(UWORD)(n) << 6)))
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498
static struct mapshape * baseshape
Definition rimapshapeslib.c:190
Definition rimapshapeslib.c:174

Function Documentation

◆ _addgroupmember()

void _addgroupmember ( void )

◆ _addgroupmemberchk()

void _addgroupmemberchk ( void )

◆ _blitgroup()

void _blitgroup ( void )

BlitGroup window#,x,y: every member of the group blitted at x+dx, y+dy.

As BlitMapShape for each member (empty ones skipped); x+dx and y+dy are words, with the upper words of the caller's d2/d3. The original's d5 is the member's address when _blitmapshape2 loads the height into its low word. d2 comes in with y in its low word and becomes xbase. Without a group block it does nothing (fixed #905: the original read the members from address 0). a6 is graphics.library: fixed (#902), the original's !libs had no graphicslib, so a6 was the caller's. Assembler entry, the original's code: d1 x, d2 y, a1 the window object, a6 graphics.library; a5 is kept on the stack, each member's a1/a5/d2/d3 around the call of _blitmapshape2.

◆ _blitmapshape()

void _blitmapshape ( void )

BlitMapShape window#,mapshape#,x,y: a map shape blitted into the window's RastPort (assembler entry).

BltBitMapRastPort from 0,0, minterm $C0, the map shape's width and height; nothing for an empty map shape (width 0). Registers on entry: d1 the map shape number, d2/d3 x and y (the caller's longs go to the call), a1 the window object, a6 graphics.library; width, height and minterm replace the low words of the caller's d4/d5/d6 (MOVE.w). It falls into _blitmapshape2 (a0 = the map shape, a1 = the RastPort), which BlitGroup calls for each member and which ends in the JMP to BltBitMapRastPort. Without map shapes it does nothing (fixed #906: the original blitted a "map shape" from address n * 64; one test of the pointer per call); the number is checked by blitmapshapechk only (fixed #906).

◆ _blitmapshapechk()

void _blitmapshapechk ( void )

◆ _blitmapshapesize()

void _blitmapshapesize ( void )

BlitMapShapeSize window#,mapshape#,x,y,width,height: a part of a map shape blitted into the window's RastPort (assembler entry).

As BlitMapShape with the given width (d4) and height (d5), the height at most the map shape's (CMP.w: signed words; the width is not limited); nothing for an empty map shape. The caller's longs of d2-d5 go to the call, the low word of d6 becomes $C0. Without map shapes it does nothing (fixed #906); the number and the width are checked by blitmapshapesizechk only (fixed #906).

◆ _blitmapshapesizechk()

void _blitmapshapesizechk ( void )

◆ _freemapshapes()

void _freemapshapes ( void )

◆ _freemapshapeschk()

void _freemapshapeschk ( void )

◆ _mapshapeaddr()

void _mapshapeaddr ( void )

◆ _mapshapeaddrchk()

void _mapshapeaddrchk ( void )

◆ _remapmapshape()

void _remapmapshape ( void )

RemapMapShape mapshape#,botcol,topcol: does nothing.

The original computes the map shape's address and returns (the ReMap call is commented out in the source: a command left unfinished, not a defect). No result.

◆ _resetgroup()

void _resetgroup ( void )

◆ _setnummapshapes()

void _setnummapshapes ( void )

◆ _shapetomapshape()

void _shapetomapshape ( void )

◆ _shapetomapshapechk()

void _shapetomapshapechk ( void )

◆ addgroupmember_c()

void addgroupmember_c ( UWORD n,
UWORD dx,
UWORD dy )
static

AddGroupMember mapshape#,dx,dy: a map shape added to the group.

The member {map shape, dx*blockwidth, dy*blockheight (MULU.w, the low words)}, then the end mark. Before the first ResetGroup it adds to the empty group of init (fixed #901: the original wrote at address 0). A member is added only below the group's end (an unsigned compare): at most 63, further ones are ignored (fixed #904: the original wrote the 64th member's end mark behind the 512-byte block, and each further member 8 bytes more), and none without a group block (fixed #905: the end is 0 then), nor without map shapes (fixed #906: the original's member pointed into low memory).

Parameters
nd0: the map shape number
dxd1: the column in blocks
dyd2: the row in blocks

◆ addgroupmemberchk_c()

void addgroupmemberchk_c ( UWORD n)
static

The error check of AddGroupMember (debugger only).

Fixed (#904), not in the original: the group block has room for 63 members and the end mark; the release code ignores further members, the check tells the programmer. Without a group block (init's allocation failed) the release code adds nothing, silently (D-018).

Fixed (#906): the map shape number must be below the count of the last SetNumMapShapes.

Errors: "Map shape not allocated by SetNumMapShapes"; "Group holds at most 63 members" when the group is full.

Parameters
nd0: the map shape number

◆ blitmapshapechk_c()

void blitmapshapechk_c ( UWORD n)
static

The error check of BlitMapShape (debugger only).

Fixed (#906), not in the original: the map shape number must be below the count of the last SetNumMapShapes; the release code takes baseshape + number * 64 without a compare.

Errors: "Map shape not allocated by SetNumMapShapes".

Parameters
nd1: the map shape number

◆ blitmapshapesizechk_c()

void blitmapshapesizechk_c ( UWORD n,
UWORD w )
static

The error check of BlitMapShapeSize (debugger only).

Fixed (#906), not in the original: the number as BlitMapShape's, and the width at most the map shape's (the release code limits the height only: a wider blit reads each row on into the next rows and the last one behind the shape's data). An empty map shape (width 0) is not blitted and its width not checked.

Errors: "Map shape not allocated by SetNumMapShapes"; "BlitMapShapeSize wider than the map shape".

Parameters
nd1: the map shape number
wd4: the width

◆ freemapshapes_c()

void freemapshapes_c ( UWORD first,
UWORD last )
static

FreeMapShapes first,last: the map shapes first to last made empty.

Nothing if last < first (signed words), else the widths of the map shapes from first to last cleared (the addresses compared signed); the memory stays allocated. Without map shapes nothing (fixed #906: the original cleared words from address 0 on); the numbers are checked by freemapshapeschk only.

Parameters
firstd0: the first map shape number
lastd1: the last map shape number

◆ freemapshapeschk_c()

void freemapshapeschk_c ( UWORD first,
UWORD last )
static

The error check of FreeMapShapes (debugger only).

Fixed (#906), not in the original: when the range is not empty (last not below first, signed words, as the release code), both numbers must be below the count of the last SetNumMapShapes.

Errors: "Map shape not allocated by SetNumMapShapes".

Parameters
firstd0: the first map shape number
lastd1: the last map shape number

◆ libfinit_c()

void libfinit_c ( void )
static

finit: frees the map shapes and the group block.

FreeMem with the sizes the library keeps (fixed #1141: the original's FreeVec is exec V36).

◆ libinit_c()

void libinit_c ( void )
static

init: the group block (512 bytes, AllocMem MEMF_PUBLIC|MEMF_CLEAR).

AllocMem, not the original's AllocVec (exec V36): the library runs on Kickstart 1.x (fixed #1141).

The next-member pointer is set to the (cleared, so empty) group and the block size to 0, as at the first load: fixed (#901, #1134), the original set only the group's address, so an AddGroupMember before ResetGroup wrote at 0, and in a second run from the editor into the run before's freed group with its block size. The group's end, the place of a 64th member, is kept for AddGroupMember (fixed #904). Without memory groupaddr, the pointer and the end are 0: the group commands then do nothing (fixed #905, the original did not check the AllocVec).

◆ mapshapeaddr_c()

struct mapshape * mapshapeaddr_c ( UWORD n)
static

MapShapeAddr(mapshape#): the address of a map shape.

Without map shapes 0 (fixed #906: the original returned n * 64).

Parameters
nd0: the map shape number (checked by mapshapeaddrchk only)
Returns
d0: the map shape's address, 0 without map shapes

◆ mapshapeaddrchk_c()

void mapshapeaddrchk_c ( UWORD n)
static

The error check of MapShapeAddr (debugger only).

Fixed (#906), not in the original: the number as BlitMapShape's.

Errors: "Map shape not allocated by SetNumMapShapes".

Parameters
nd0: the map shape number

◆ numchk()

void numchk ( UWORD n)
static

◆ resetgroup_c()

struct member * resetgroup_c ( UWORD bw,
UWORD bh )
static

ResetGroup(blockwidth,blockheight): empties the group and sets the block size for AddGroupMember.

Without init's block (its allocation failed) it writes nothing and returns 0 (fixed #905: the original cleared the long at address 0).

Parameters
bwd0: the block width
bhd1: the block height
Returns
d0: the group's address, 0 without a group block

◆ rimapshapeslib_libfinit()

void rimapshapeslib_libfinit ( void )

◆ rimapshapeslib_libinit()

void rimapshapeslib_libinit ( void )

◆ setnummapshapes_c()

void setnummapshapes_c ( UWORD num)
static

SetNumMapShapes num: (re)allocates num map shapes.

The old block is freed (FreeMem with the count kept), num * 64 bytes allocated (AllocMem MEMF_PUBLIC|MEMF_CLEAR; fixed #1141: the original's AllocVec and FreeVec are exec V36). After a failure, or with num 0, there are no map shapes: the commands then do nothing (fixed #906: the original took them from address 0 on). The number is kept for FreeMem and the error checks (0 without a block).

Parameters
numd0: the number of map shapes (a word)

◆ shapetomapshape_c()

void shapetomapshape_c ( UWORD n,
const struct bb_shape * sh )
static

ShapeToMapShape shape#,mapshape#: a map shape from a Blitz shape.

Width, height, depth and ebwidth of the shape; the plane pointers point into the shape's data (onebpmem apart, not copied). Without map shapes it does nothing (fixed #906: the original wrote from address 0 on); the number is checked by shapetomapshapechk only (fixed #906). Depth 0 writes 65536 plane pointers (DBRA), depths above 8 run into unused[] and the next map shapes: an invalid object, refused by shapetomapshapechk with runtime error checking (fixed #903), here unchecked.

Parameters
nd1: the map shape number
sha0: the shape (!libs shapeslib,ia0|pd0)

◆ shapetomapshapechk_c()

void shapetomapshapechk_c ( UWORD n,
const struct bb_shape * sh )
static

The error check of ShapeToMapShape (debugger only).

Fixed (#903), not in the original (rimapshapeslib had no error check area): ShapeToMapShape copies one plane pointer per plane of the shape with SUBQ.w #1 ... DBRA into the 8 of the map shape, so a shape of depth 0 writes 65536 pointers and one of more than 8 planes runs into the unused bytes and the next map shape. The release code is unchanged (an invalid object, D-005).

Fixed (#906): the map shape number must be below the count of the last SetNumMapShapes (the release code does not compare it).

Errors: "Map shape not allocated by SetNumMapShapes"; "Illegal Shape Depth" (shapeslib's text) for a depth of 0 or above 8.

Parameters
nd1: the map shape number
sha0: the shape (!libs shapeslib,ia0|pd0)

Variable Documentation

◆ baseshape

struct mapshape* baseshape
static

◆ blockheight

UWORD blockheight
static

◆ blockwidth

UWORD blockwidth
static

◆ groupaddr

struct member* groupaddr
static

◆ groupend

struct member* groupend
static

◆ nextgroupmember

struct member* nextgroupmember
static

◆ nummapshapes

UWORD nummapshapes
static