|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include "blitzlib.h"#include "blitzobj.h"#include "blitzexec.h"#include <exec/memory.h>#include <graphics/gfx.h>#include <graphics/rastport.h>#include <graphics/text.h>#include <intuition/intuition.h>#include <stddef.h>#include <proto/graphics.h>Data Structures | |
| struct | mapobject |
Macros | |
| #define | __NOLIBBASE__ |
| #define | GRAPHICS_BASE_NAME gfx |
Functions | |
| void | _shapetosquare (void) |
| void | _shapemaskfill (void) |
| void | _scanshapes (void) |
| void | _scanmaxwidth (void) |
| void | _scanmaxheight (void) |
| void | _scanmaxdepth (void) |
| void | _mapdatachanged (void) |
| MapDataChanged: whether the used map has changed since the last load. | |
| void | _mapdatachanged2 (void) |
| void | _fillbitplane (void) |
| void | _newmap (void) |
| void | _mapdataadr (void) |
| MapDataAdr: the address of the used map's data (+10). | |
| void | _mapdataadr2 (void) |
| MapDataAdr(x,y): the address of a map word. | |
| void | _mapdatasize (void) |
| MapDataSize: the byte size of the used map's data. | |
| void | _mapobjwidth (void) |
| MapObjWidth: the width of the used map. | |
| void | _mapobjheight (void) |
| MapObjheight: the height of the used map. | |
| void | _mapgrab (void) |
| void | _mapobjname (void) |
| void | _setmapobjname (void) |
| void | _mapobjviewx (void) |
| MapObjViewX: the view x of the used map. | |
| void | _mapobjviewy (void) |
| MapObjViewY: the view y of the used map. | |
| void | _OutText (void) |
| void | _rubthroughmap1 (void) |
| RubThroughMap: the rub-through map of the used map (+28). | |
| void | _rubthroughmap2 (void) |
| RubThroughMap(mapobject#): sets the rub-through map of the used map. | |
| void | _setstencil (void) |
| void | _candraw (void) |
| void | _lastcandrawaddress (void) |
| MapCanDrawAddr: the address of the map word of the last MapCanDraw (+24). | |
| void | _clearrubthroughmap (void) |
| ClearRubThroughMap: removes the rub-through map of the used map. | |
| void | _OutTextPen (void) |
| void | _OutTextCenter (void) |
| void | _OutTextRight (void) |
| void | rimapeditorlib_SetWindowDraw (void) |
| void | _InitParse (void) |
| void | rimapeditorlib_nextparsearg (void) |
| void | _freemap (void) |
| void | rimapeditorlib_libinit (void) |
| void | rimapeditorlib_libfinit (void) |
| void | candrawchk (void) |
| void | mapgrabchk (void) |
| void | mapdataadrchk (void) |
| void | to1616chk (void) |
| void | fillbpchk (void) |
| void | newmapchk (void) |
| static ULONG | rol1 (ULONG v) |
| static void | libinit_c (void) |
| init: opens graphics.library (any version). | |
| static void | libfinit_c (void) |
| finit: closes graphics.library. | |
| static void | setstencil_c (const UBYTE *a) |
| SetStencil array: the stencil of MapCanDraw. | |
| static ULONG | candraw_c (ULONG shapenum, UWORD x, UWORD y, struct mapobject *map) |
| MapCanDraw(shape#,mapx,mapy): whether a shape can be drawn at a map position. | |
| static ULONG | scanshapes_c (ULONG shapenum, UWORD highest, const struct bb_shape *sh) |
| ScanShapes(startnum,highest): the largest width/height/depth of a run of shapes. | |
| static ULONG | scanmaxwidth_c (ULONG incoming) |
| ScanMaxWidth: the largest width of the last ScanShapes. | |
| static ULONG | scanmaxheight_c (ULONG incoming) |
| ScanMaxheight: the largest height of the last ScanShapes. | |
| static ULONG | scanmaxdepth_c (ULONG incoming) |
| ScanMaxdepth: the largest depth of the last ScanShapes. | |
| static void | shapetosquare_c (const struct bb_shape *src, struct bb_shape *dst) |
| ShapeTo1616 source shape,dest shape: the left 16 pixels of a shape, 16 rows. | |
| static void | shapemaskfill_c (const struct bb_shape *sh) |
| ShapeMaskFill shape#: sets the first 32 bytes (8 longs) of the shape's cookie. | |
| static void | fillbitplane_c (UWORD w, UWORD h, const struct BitMap *bm) |
| FillBitplane bitmap#,width,height: a mesh in plane 0 of a bitmap. | |
| static void | freemap (struct mapobject *map) |
| static void | freemap_c (struct mapobject *map) |
| The MapObject's free routine (!libfin _free): frees a map. | |
| static void | newmap_c (UWORD w, UWORD h, UWORD bw, UWORD bh, ULONG name, UWORD used, const ULONG *lens, struct mapobject *map) |
| CreateMap map#,width,height,bwidth,bheight,name$: creates a map and uses it. | |
| static void | mapgrab_c (const UBYTE *src, UWORD type, UWORD null, struct mapobject *map) |
| MapDataGrab address,datasize,mapnull: fills the used map from memory. | |
| static ULONG | mapobjname_c (const struct mapobject *map) |
| MapObjName$: the name of the used map. | |
| static void | setmapobjname_c (ULONG name, const ULONG *lens, struct mapobject *map) |
| SetMapObjName$ name$: the name of the used map. | |
| static ULONG | mapdatachanged2_c (ULONG newstate, struct mapobject *map) |
| MapDataChanged(newstate): sets the changed state of the used map. | |
| static void | outtext (struct Library *gfx, ULONG x, ULONG y, struct RastPort *rp, const UBYTE *s) |
| static UWORD | textlength (struct Library *gfx, struct RastPort *rp, const UBYTE *s) |
| static void | outtext_c (ULONG x, ULONG y, struct RastPort *rp, const UBYTE *s) |
| MapOutText x,y,rastport,address/string: prints a text into a RastPort. | |
| static void | outtextcenter_c (ULONG x, ULONG y, struct RastPort *rp, const UBYTE *s) |
| MapOutTextCenter x,y,rastport,address/string: as MapOutText, centred on x. | |
| static void | outtextright_c (ULONG x, ULONG y, struct RastPort *rp, const UBYTE *s) |
| MapOutTextRight x,y,rastport,address/string: as MapOutText, ending at x. | |
| static void | outtextpen_c (ULONG rp, UWORD pen) |
| MapOutTextPen rastport,pen: the pen of MapOutText. | |
| static void | setwindowdraw_c (UWORD mode, struct Window **win) |
| SetWindowDraw window#,mode: the area pattern of the used window (0 normal, 1 meshed). | |
| static void | initparse_c (const UBYTE *s) |
| M_InitParse string: the string for M_NextArg$. | |
| static ULONG | nextparsearg_c (void) |
| M_NextArg$: the next comma separated argument of M_InitParse's string. | |
| static void | candrawchk_c (ULONG shapenum, UWORD x, UWORD y, const struct mapobject *map) |
| The error check of MapCanDraw (debugger only). | |
| static void | mapgrabchk_c (const struct mapobject *map) |
| The error check of MapDataGrab (debugger only). | |
| static void | mapdataadrchk_c (UWORD x, UWORD y, const struct mapobject *map) |
| The error check of MapDataAdr(x,y) (debugger only). | |
| static void | to1616chk_c (const struct bb_shape *src, const struct bb_shape *dst) |
| The error check of ShapeTo1616 (debugger only). | |
| static void | fillbpchk_c (UWORD w, UWORD h) |
| The error check of FillBitplane (debugger only). | |
| static void | newmapchk_c (UWORD w) |
| The error check of CreateMap (debugger only). | |
Variables | |
| static struct Library * | gfxbase |
| static const UBYTE * | mapstencil |
| static UWORD | maxwidth |
| static UWORD | maxheight |
| static UWORD | maxdepth |
| static const UWORD | mypattern [2] = { 0xaaaa, 0x5555 } |
| struct { | |
| UBYTE parseadr [256] | |
| UBYTE * curadr | |
| } | parse |
| #define __NOLIBBASE__ |
| #define GRAPHICS_BASE_NAME gfx |
| void _candraw | ( | void | ) |
| void _clearrubthroughmap | ( | void | ) |
ClearRubThroughMap: removes the rub-through map of the used map.
| void _fillbitplane | ( | void | ) |
| void _freemap | ( | void | ) |
| void _InitParse | ( | void | ) |
| void _lastcandrawaddress | ( | void | ) |
MapCanDrawAddr: the address of the map word of the last MapCanDraw (+24).
| void _mapdataadr | ( | void | ) |
MapDataAdr: the address of the used map's data (+10).
| void _mapdataadr2 | ( | void | ) |
MapDataAdr(x,y): the address of a map word.
Inline: the data + (y*width)*2 + (x*2 as a word); no range check in the release code (a position outside the map is refused by mapdataadrchk with runtime error checking: fixed, under #892).
| void _mapdatachanged | ( | void | ) |
MapDataChanged: whether the used map has changed since the last load.
| void _mapdatachanged2 | ( | void | ) |
| void _mapdatasize | ( | void | ) |
MapDataSize: the byte size of the used map's data.
Inline: (width*2 as a word) * height (MULU.w).
| void _mapgrab | ( | void | ) |
| void _mapobjheight | ( | void | ) |
MapObjheight: the height of the used map.
| void _mapobjname | ( | void | ) |
| void _mapobjviewx | ( | void | ) |
MapObjViewX: the view x of the used map.
| void _mapobjviewy | ( | void | ) |
MapObjViewY: the view y of the used map.
| void _mapobjwidth | ( | void | ) |
MapObjWidth: the width of the used map.
| void _newmap | ( | void | ) |
| void _OutText | ( | void | ) |
| void _OutTextCenter | ( | void | ) |
| void _OutTextPen | ( | void | ) |
| void _OutTextRight | ( | void | ) |
| void _rubthroughmap1 | ( | void | ) |
RubThroughMap: the rub-through map of the used map (+28).
| void _rubthroughmap2 | ( | void | ) |
RubThroughMap(mapobject#): sets the rub-through map of the used map.
Inline: a0 = that map (ia0|pd0), a3 = the used one (ua3); the map's rubthrough (+28) = a0. MapCanDraw then tests that map too. Returns nothing (d0 unchanged).
| void _scanmaxdepth | ( | void | ) |
| void _scanmaxheight | ( | void | ) |
| void _scanmaxwidth | ( | void | ) |
| void _scanshapes | ( | void | ) |
| void _setmapobjname | ( | void | ) |
| void _setstencil | ( | void | ) |
| void _shapemaskfill | ( | void | ) |
| void _shapetosquare | ( | void | ) |
|
static |
MapCanDraw(shape#,mapx,mapy): whether a shape can be drawn at a map position.
-1 if x/y lie outside the map (or the rub-through map), the map's word there is shape# + 1 (with a rub-through map: that map's word), or the stencil byte of the map's word is set; else shape# + 1 (resp. the rub-through map's word). The address of the map's word is kept at 24 (MapCanDrawAddr). d0's upper word stays (ADDQ.w). x/y are compared unsigned: fixed (#892), the original compared them signed, so negative values passed and indexed far behind the data (nothing is kept at 24 for them now). The stencil index is the map value as a signed word, and without SetStencil the stencil is at address 0: refused by candrawchk (fixed #893; the release code keeps both).
| void candrawchk | ( | void | ) |
|
static |
The error check of MapCanDraw (debugger only).
Fixed (#893), not in the original (rimapeditorlib had no error check area): MapCanDraw looked up the map word in the stencil of SetStencil without looking whether there is one - before the first SetStencil of a run (also after init, #1133) the stencil is at address 0 and the lookup read low memory - and used the map word as a signed index, so a value of $8000 or more read up to 32 KB before the stencil. Fixed (under #893): nor did it look whether the used map has a map (after Free MapObject, or a CreateMap that could not allocate the data, width, height and data are 0, and every position counts as outside). The value check follows the routine: only for a position inside the map (and the rub-through map) whose word the routine looks up in the stencil. The release code is unchanged (a command before its setup command, D-005, as #686 and #1131).
Errors: "MapObject has no map data", "MapCanDraw needs SetStencil", "Map value above 32767 for the stencil".
|
static |
FillBitplane bitmap#,width,height: a mesh in plane 0 of a bitmap.
Plane 0 of the bitmap object (a struct BitMap: its ebwidth at 0, planes at 8) gets width/16 words per row (65536 for a width below 16: DBRA from -1) of $5555/$AAAA, alternating per row; height 0 -> 65536 rows. Both refused by fillbpchk (fixed #895; the release code keeps them). DIFF: a2 unchanged (the original uses it as its pointer).
| void fillbpchk | ( | void | ) |
|
static |
The error check of FillBitplane (debugger only).
Fixed (#895), not in the original: the width / 16 - 1 words per row and the height - 1 rows were DBRA counts without a test: a width below 16 wrote 65536 words (128 KB) per row, a height of 0 65536 rows. Arguments the programmer controls (D-005); the release code is unchanged.
Errors: "FillBitplane width must be at least 16", "FillBitplane height must be at least 1".
|
static |
|
static |
The MapObject's free routine (!libfin _free): frees a map.
The data (FreeMem, width*2*height), the name (maxslib freest), the 32 bytes cleared.
| map | a3: the map object |
|
static |
M_InitParse string: the string for M_NextArg$.
Copied into the 256 byte buffer, at most 255 characters and a 0: fixed (#897), the original copied without a limit, so a longer string overwrote the pointer behind the buffer (and from 260 characters the code of M_NextArg$ behind it). A longer string is cut to its first 255 characters.
| s | d0: the string |
|
static |
finit: closes graphics.library.
BUG(orig) (#896): CloseLibrary also of a base 0.
|
static |
init: opens graphics.library (any version).
Then it clears the stencil of SetStencil, the ScanShapes results and the parse position of M_InitParse, as at the first load: fixed (#1133), the original kept those of the run before.
| void mapdataadrchk | ( | void | ) |
|
static |
The error check of MapDataAdr(x,y) (debugger only).
Fixed (under #892), not in the original: the inline routine computes the address of the map word at x,y without a range check - x at or beyond the width gives a word of a later row, a y at or beyond the height (or a negative x or y) an address behind the map. x and y are compared unsigned with the width and height, as MapCanDraw does since #892 (a map without data has width and height 0: every position is refused). The release code is unchanged (D-005).
Errors: "Map position outside the map".
|
static |
MapDataChanged(newstate): sets the changed state of the used map.
| newstate | d0: the new state (a word) |
| map | a3: the used map (ua3) |
|
static |
MapDataGrab address,datasize,mapnull: fills the used map from memory.
width*height values from address (datasize 0: bytes, else words) + mapnull into the data. Each byte is zero-extended: fixed (#898), in the original the upper byte of the previous value stayed in the register (MOVE.b), so a byte + mapnull beyond 255 carried into the following values. A map without data (its CreateMap could not allocate them, also for a width or height of 0) gets nothing: fixed (#895), the original's DBRA loops took its width and height 0 as 65536 each and wrote from address 0 over all memory.
| void mapgrabchk | ( | void | ) |
|
static |
The error check of MapDataGrab (debugger only).
Fixed (under #893), not in the original: MapDataGrab did not look whether the used map has a map; on one without data (after Free MapObject, or a CreateMap that could not allocate the data) the original wrote from address 0 over all memory, the release code fills nothing into it since #895.
Errors: "MapObject has no map data".
| map | a3: the used map (ua3) |
|
static |
MapObjName$: the name of the used map.
The name's characters at a3 (no 0). The length is counted as a long: fixed (#899), the original counted it as a byte (ADDQ.b), so a name of 256 characters or more came back with its length modulo 256.
| map | a1: the used map (ua1) |
|
static |
CreateMap map#,width,height,bwidth,bheight,name$: creates a map and uses it.
The map becomes the used one; an old map is freed; data: width*height words (MEMF_PUBLIC|MEMF_CLEAR), datasize 1, mapnull 0, view 0,0, the name a maxslib string. Without memory (also width or height 0) width, height, bwidth, bheight are cleared (datasize stays 1: not a defect). The size is (width * 2 as a word) * height, too small for a width above 32767, which the other commands take whole: refused by newmapchk (fixed #1152; the release code keeps it). a3 ends behind the last field written (24, or 10 if the data could not be allocated). The old map is freed by the free routine, which tests the data and the name itself: fixed (#894), the original freed it only if the long at 12 was set (data's low word and viewx), else it was lost and 24/28 were not cleared. DIFF: a2 unchanged (the original pops the length).
| void newmapchk | ( | void | ) |
|
static |
The error check of CreateMap (debugger only).
Fixed (#1152), not in the original: CreateMap sizes the data as (width
Errors: "Map width above 32767".
| w | d1: the width |
|
static |
M_NextArg$: the next comma separated argument of M_InitParse's string.
The characters up to the next ',' (skipped) or the end at a3; after the last one (and before M_InitParse) "". Leading spaces are not stripped (the source's comment says so; not a defect).
|
static |
|
static |
|
static |
|
static |
MapOutTextPen rastport,pen: the pen of MapOutText.
SetAPen with d0 = the rastport's upper word and the pen (MOVE.w d1,d0).
| rp | d0: the RastPort |
| pen | d1: the pen (a word) |
|
static |
| void rimapeditorlib_libfinit | ( | void | ) |
| void rimapeditorlib_libinit | ( | void | ) |
| void rimapeditorlib_nextparsearg | ( | void | ) |
| void rimapeditorlib_SetWindowDraw | ( | void | ) |
|
inlinestatic |
|
static |
ScanMaxdepth: the largest depth of the last ScanShapes.
| incoming | d0: the caller's d0 |
|
static |
ScanMaxheight: the largest height of the last ScanShapes.
| incoming | d0: the caller's d0 |
|
static |
ScanMaxWidth: the largest width of the last ScanShapes.
MOVE.w: d0's upper word stays (also for ScanMaxheight/ScanMaxdepth).
| incoming | d0: the caller's d0 |
|
static |
ScanShapes(startnum,highest): the largest width/height/depth of a run of shapes.
From shape startnum to the first empty shape or highest, the largest width, height and depth (signed) for ScanMaxWidth/height/depth.
| shapenum | d0: the offset of shape startnum (shape# << 5) |
| highest | d1: the last shape number to scan |
| sh | a0: shape startnum (ia0|pd0) |
|
static |
|
static |
SetStencil array: the stencil of MapCanDraw.
A byte per map value; a set byte makes MapCanDraw fail for that value.
| a | d0: the byte array |
|
static |
|
static |
ShapeMaskFill shape#: sets the first 32 bytes (8 longs) of the shape's cookie.
| sh | a0: the shape (ia0|pd0) |
ShapeTo1616 source shape,dest shape: the left 16 pixels of a shape, 16 rows.
The first word of every row of every plane of src into dest's data, 16 rows per plane (missing rows 0, more rows skipped). Height or depth 0 -> 65536 (DBRA): refused by to1616chk (fixed #895; the release code keeps it). 16 words per plane are written regardless of the destination's size: a destination that is not 16 x 16 with at least the source's depth is refused by to1616chk (fixed #900; the release code keeps it).
| src | a0: the source shape (ia0|pd0) |
| dst | a1: the destination shape (ia1|pd1) |
|
static |
| void to1616chk | ( | void | ) |
The error check of ShapeTo1616 (debugger only).
Fixed (#895), not in the original: the source shape's depth and (for a shape lower than 16) its height were taken - 1 as DBRA counts without a test for 0: depth 0 copied 65536 planes, height 0 65536 rows into the destination. An invalid shape object (Blitz's own commands make none of depth or height 0); the release code is unchanged (as #429 and #947). Fixed (#900): nor was the destination looked at - ShapeTo1616 writes 16 words per plane of the source, one per row, into its data, so a destination with fewer planes or rows overflowed (another shape's data or memory list headers behind it) and a wider one got the words packed as if it were 16 wide. The destination is the programmer's (D-005); the release code is unchanged.
Errors: "ShapeTo1616 source of height or depth 0", "ShapeTo1616 needs a 16 x 16 destination as deep as the source" (width or height not 16, or fewer planes than the source).
| src | a0: the source shape |
| dst | a1: the destination shape |
| UBYTE* curadr |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| struct { ... } parse |
| UBYTE parseadr[256] |