BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
ridatatypeslib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include "blitzexec.h"
#include <proto/datatypes.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <datatypes/datatypes.h>
#include <datatypes/datatypesclass.h>
#include <datatypes/pictureclass.h>
#include <intuition/classes.h>
#include <intuition/gadgetclass.h>
#include <intuition/icclass.h>
#include <graphics/displayinfo.h>

Data Structures

struct  pcolour
struct  pdata

Macros

#define __NOLIBBASE__
#define DATATYPES_BASE_NAME   database
#define DOS_BASE_NAME   dosbase
#define INTUITION_BASE_NAME   intuibase
#define GRAPHICS_BASE_NAME   gfxbase
#define database   libbases[0]
#define dosbase   libbases[1]
#define intuibase   libbases[2]
#define gfxbase   libbases[3]
#define TAG(t, tag, data)
#define PALDATA(o)

Functions

void _datatypeopen (void)
void _datatypeclose (void)
void _datatypename (void)
void _datatypebasename (void)
void _datatypeid (void)
void _datatypecreate2 (void)
void _datatypecreate (void)
void _attachdatatype (void)
void _attachdatatype2 (void)
void _attachdatatype3 (void)
void _detachdatatype (void)
void _datatypesuper (void)
void _datatypebitmap (void)
void _datatypespalette (void)
void _datatypewidth (void)
void _datatypeheight (void)
void _datatypedepth (void)
void _datatypeready (void)
void _setdatatypeattr (void)
void _setdatatypeattr2 (void)
void _getdatatypeattr (void)
void _getmodeid (void)
void _getmodeid2 (void)
void _datatypegroup (void)
void ridatatypeslib_libinit (void)
void ridatatypeslib_libfinit (void)
static void c_libinit (void)
 init: opens datatypes, dos, intuition and graphics.library (V37) and allocates the 1024 byte buffer (memlib globalloc, MEMF_CLEAR).
void c_detachdatatype (void)
 DetachDataType: removes the object from the window it is attached to.
static void freename (void)
void c_datatypeclose (void)
 DataTypeClose: detaches the object, disposes of it, releases the DataType and unlocks the file.
static void c_libfinit (void)
 finit: DetachDataType, DataTypeClose, closes the libraries and frees the buffer.
static ULONG putstring (const UBYTE *s)
static ULONG putid (const UBYTE *s)
ULONG c_datatypeopen (CONST_STRPTR name)
 DataTypeOpen filename$: locks a file and obtains its DataType.
ULONG c_datatypename (void)
 DataTypeName: the name of the file's DataType (dth_Name).
ULONG c_datatypebasename (void)
 DataTypeBaseName: the base name of the file's DataType (dth_BaseName), written at a3 like DataTypeName.
ULONG c_datatypeid (void)
 DataTypeID: the ID of the file's DataType (dth_ID), up to four characters (up to a 0) at a3.
ULONG c_datatypegroup (void)
 DataTypeGroup: the group ID of the file's DataType (dth_GroupID), up to four characters at a3.
static ULONG create (struct TagItem *tags)
ULONG c_datatypecreate2 (void)
 DataTypeCreate: NewDTObject of the file's name without tags.
ULONG c_datatypecreate (struct TagItem *tags)
 DataTypeCreate &taglist: NewDTObject of the file's name with a tag list.
ULONG c_datatypebitmap (void)
 DataTypeBitmap: gets the object's BitMapHeader (PDTA_BitMapHeader) for DataTypeWidth/Height/Depth/ModeID and AttachDataType.
static BB_BOOL doattach (const ULONG *winobj)
static struct TagItem * tailtags (struct TagItem *t)
BB_BOOL c_attachdatatype (ULONG id, ULONG *winobj)
 AttachDataType window,id: attaches the object to a window at 0,0 with the size of the BitMapHeader.
BB_BOOL c_attachdatatype2 (ULONG id, WORD x, WORD y, WORD w, WORD h, ULONG *winobj)
 AttachDataType window,id,x,y,width,height: attaches the object to a window at a position and size.
BB_BOOL c_attachdatatype3 (ULONG id, struct TagItem *tags, ULONG *winobj)
 AttachDataType window,id,&taglist: attaches the object to a window with a tag list of the program's.
BB_BOOL c_datatypeready (void)
 DataTypeReady: whether the attached object's layout is done (DTA_LayoutProc 0).
ULONG c_datatypesuper (void)
 DataTypeSuper: the ID of the object's class (cl_ID), written at a3 like DataTypeName.
ULONG c_datatypespalette (struct bb_palette *palobj)
 DataTypesPalette palette#: the object's colours (PDTA_ColorRegisters) into a palette object.
UWORD c_datatypewidth (void)
 DataTypeWidth: the picture's width (bmh_Width).
UWORD c_datatypeheight (void)
 DataTypeHeight: the picture's height (bmh_Height).
UWORD c_datatypedepth (void)
 DataTypeDepth: the picture's depth (bmh_Depth, sign-extended).
void c_setdatatypeattr (struct TagItem *tags)
 SetDataTypeAttr &taglist: SetAttrs on the object.
void c_setdatatypeattr2 (UWORD n, const ULONG *sp)
 SetDataTypeAttr attr,data[,attr,data..]: SetAttrs with the pairs as a tag list in the buffer.
ULONG c_getdatatypeattr (ULONG attr)
 GetDataTypeAttr(attribute): GetAttr of one attribute into the buffer.
static ULONG domodeid (struct TagItem *more)
ULONG c_getmodeid (void)
 DataTypeModeID: BestModeID for the picture's size and depth (the tags in the buffer).
ULONG c_getmodeid2 (struct TagItem *tags)
 DataTypeModeID taglist: as DataTypeModeID, with the program's tag list behind the library's tags (TAG_MORE; the library's come first). Fixed (#603): the original wrote its tags over the list.

Variables

static struct Library * libbases [5]
static const char *const libnames []
union { 
   ULONG   value 
   struct TagItem   tags [128] 
} * storage
static BPTR lock
static struct DataType * dtype
static struct DataTypeHeader * dtypehead
static Object * object
static UBYTE * fname
static struct BitMapHeader * bitmapheader
static ULONG attached
static UWORD attachtobitmap

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ database

#define database   libbases[0]

◆ DATATYPES_BASE_NAME

#define DATATYPES_BASE_NAME   database

◆ DOS_BASE_NAME

#define DOS_BASE_NAME   dosbase

◆ dosbase

#define dosbase   libbases[1]

◆ gfxbase

#define gfxbase   libbases[3]

◆ GRAPHICS_BASE_NAME

#define GRAPHICS_BASE_NAME   gfxbase

◆ intuibase

#define intuibase   libbases[2]

◆ INTUITION_BASE_NAME

#define INTUITION_BASE_NAME   intuibase

◆ PALDATA

#define PALDATA ( o)
Value:
((struct pdata *)(o)->pdata)
Definition ridatatypeslib.c:763

◆ TAG

#define TAG ( t,
tag,
data )
Value:
((t)->ti_Tag = (tag), (t)->ti_Data = (data), (t)++)
void data(void)
struct TagItem tag
Definition gtlib.c:432

Function Documentation

◆ _attachdatatype()

void _attachdatatype ( void )

◆ _attachdatatype2()

void _attachdatatype2 ( void )

◆ _attachdatatype3()

void _attachdatatype3 ( void )

◆ _datatypebasename()

void _datatypebasename ( void )

◆ _datatypebitmap()

void _datatypebitmap ( void )

◆ _datatypeclose()

void _datatypeclose ( void )

◆ _datatypecreate()

void _datatypecreate ( void )

◆ _datatypecreate2()

void _datatypecreate2 ( void )

◆ _datatypedepth()

void _datatypedepth ( void )

◆ _datatypegroup()

void _datatypegroup ( void )

◆ _datatypeheight()

void _datatypeheight ( void )

◆ _datatypeid()

void _datatypeid ( void )

◆ _datatypename()

void _datatypename ( void )

◆ _datatypeopen()

void _datatypeopen ( void )

◆ _datatypeready()

void _datatypeready ( void )

◆ _datatypespalette()

void _datatypespalette ( void )

◆ _datatypesuper()

void _datatypesuper ( void )

◆ _datatypewidth()

void _datatypewidth ( void )

◆ _detachdatatype()

void _detachdatatype ( void )

◆ _getdatatypeattr()

void _getdatatypeattr ( void )

◆ _getmodeid()

void _getmodeid ( void )

◆ _getmodeid2()

void _getmodeid2 ( void )

◆ _setdatatypeattr()

void _setdatatypeattr ( void )

◆ _setdatatypeattr2()

void _setdatatypeattr2 ( void )

◆ c_attachdatatype()

BB_BOOL c_attachdatatype ( ULONG id,
ULONG * winobj )

AttachDataType window,id: attaches the object to a window at 0,0 with the size of the BitMapHeader.

SetAttrs (GA_Left/Top/Width/Height/ID, ICA_TARGET ICTARGET_IDCMP, PDTA_Remap 0), then AddDTObject. Without a BitMapHeader it is got first, as DataTypeBitmap does (fixed, #595: the original read the size through the unchecked pointer, without DataTypeBitmap at address 0). Does not test datatypes.library (an open file needs it).

Parameters
idd1: the gadget id
winobja0: the window object (windowslib, parameter 0)
Returns
d0: BB_TRUE, BB_FALSE without an open file or object, if the object has no BitMapHeader or if attached already

◆ c_attachdatatype2()

BB_BOOL c_attachdatatype2 ( ULONG id,
WORD x,
WORD y,
WORD w,
WORD h,
ULONG * winobj )

AttachDataType window,id,x,y,width,height: attaches the object to a window at a position and size.

The word arguments go into the tag list sign-extended (fixed, #597: the original wrote the registers, with the upper words they had). Needs an object (fixed, #1098: the original checked only the file and passed the object 0 to SetAttrsA and AddDTObject).

Parameters
idd1: the gadget id
xd2: left (word)
yd3: top (word)
wd4: width (word)
hd5: height (word)
winobja0: the window object
Returns
d0: BB_TRUE, BB_FALSE without datatypes.library, an open file or an object, or if attached already

◆ c_attachdatatype3()

BB_BOOL c_attachdatatype3 ( ULONG id,
struct TagItem * tags,
ULONG * winobj )

AttachDataType window,id,&taglist: attaches the object to a window with a tag list of the program's.

SetAttrs (GA_ID, ICA_TARGET ICTARGET_IDCMP, PDTA_Remap 0), SetAttrs with the program's tag list (fixed, #596: the original passed the id as the tag list and ignored the program's), then AddDTObject. Needs an object (fixed, #1098, as the form with coordinates).

Parameters
idd1: the gadget id
tagsd2: the program's tag list
winobja0: the window object
Returns
d0: BB_TRUE, BB_FALSE without an open file or object, or if attached already

◆ c_datatypebasename()

ULONG c_datatypebasename ( void )

DataTypeBaseName: the base name of the file's DataType (dth_BaseName), written at a3 like DataTypeName.

Returns
d0: its length, 0 without datatypes.library or DataType

◆ c_datatypebitmap()

ULONG c_datatypebitmap ( void )

DataTypeBitmap: gets the object's BitMapHeader (PDTA_BitMapHeader) for DataTypeWidth/Height/Depth/ModeID and AttachDataType.

The buffer is cleared first (fixed, #598: the original took whatever the command before had left in it when GetAttr failed).

Returns
d0: the BitMapHeader, 0 without datatypes.library or object, or if the object has none

◆ c_datatypeclose()

void c_datatypeclose ( void )

DataTypeClose: detaches the object, disposes of it, releases the DataType and unlocks the file.

Detached first (fixed, #599: the original disposed of an attached object, the window kept the freed gadget). The file is unlocked whenever it is locked (fixed, #605: the original unlocked it, and cleared the BitMapHeader, only if there was a DataType). Nothing without datatypes.library.

◆ c_datatypecreate()

ULONG c_datatypecreate ( struct TagItem * tags)

DataTypeCreate &taglist: NewDTObject of the file's name with a tag list.

While an object exists: 0, the object stays (fixed, #600: the original lost it).

Parameters
tagsd0: the tag list
Returns
d0: the object, 0 without datatypes.library or open file, while an object exists, or on failure

◆ c_datatypecreate2()

ULONG c_datatypecreate2 ( void )

DataTypeCreate: NewDTObject of the file's name without tags.

Needs an open file, as the form with a tag list (fixed, #601: the original made an object of the name the last DataTypeOpen had copied, at first ""). While an object exists: 0, the object stays (fixed, #600: the original lost it).

Returns
d0: the object, 0 without datatypes.library or open file, while an object exists, or on failure

◆ c_datatypedepth()

UWORD c_datatypedepth ( void )

DataTypeDepth: the picture's depth (bmh_Depth, sign-extended).

Returns
d0.w: the depth, 0 without DataTypeBitmap

◆ c_datatypegroup()

ULONG c_datatypegroup ( void )

DataTypeGroup: the group ID of the file's DataType (dth_GroupID), up to four characters at a3.

Returns
d0: the number of characters, 0 without datatypes.library or DataType

◆ c_datatypeheight()

UWORD c_datatypeheight ( void )

DataTypeHeight: the picture's height (bmh_Height).

Returns
d0.w: the height, 0 without DataTypeBitmap

◆ c_datatypeid()

ULONG c_datatypeid ( void )

DataTypeID: the ID of the file's DataType (dth_ID), up to four characters (up to a 0) at a3.

Returns
d0: the number of characters, 0 without datatypes.library or DataType

◆ c_datatypename()

ULONG c_datatypename ( void )

DataTypeName: the name of the file's DataType (dth_Name).

The string is written at a3 (a3 behind its 0).

Returns
d0: its length, 0 without datatypes.library or DataType

◆ c_datatypeopen()

ULONG c_datatypeopen ( CONST_STRPTR name)

DataTypeOpen filename$: locks a file and obtains its DataType.

The name is copied for DataTypeCreate into a block of its own length (fixed, #604: the original copied it into a 384 byte buffer without a limit); out of memory: 0. Without a DataType the file is unlocked again (fixed, #605: the original read the DataTypeHeader through address 28 and kept the lock).

Parameters
named0: the file name
Returns
d0: the DataType, 0 without datatypes.library, if a file is already open, out of memory, the file does not lock or has no DataType

◆ c_datatypeready()

BB_BOOL c_datatypeready ( void )

DataTypeReady: whether the attached object's layout is done (DTA_LayoutProc 0).

Returns
d0: BB_TRUE when done, BB_FALSE while laying out, without datatypes.library or when not attached

◆ c_datatypespalette()

ULONG c_datatypespalette ( struct bb_palette * palobj)

DataTypesPalette palette#: the object's colours (PDTA_ColorRegisters) into a palette object.

Into the palette's colour block (count.w, first.w, then a long per component; the top bytes set). The smaller of the picture's (PDTA_NumColors) and the palette's number of colours (fixed, #606: the original copied the palette's number, behind the picture's table for a larger palette, 65536 for 0). Does not test datatypes.library.

Parameters
palobja0: the palette object (palettelib, parameter 0) The buffer is cleared before GetAttr (fixed, #607: the original took what the command before had left in it for an object that does not know the attribute).
Returns
d0: the address of the buffer; 0 without object or colour table (fixed, #607: the original returned GetAttr's result)

◆ c_datatypesuper()

ULONG c_datatypesuper ( void )

DataTypeSuper: the ID of the object's class (cl_ID), written at a3 like DataTypeName.

Returns
d0: its length, 0 without datatypes.library or object

◆ c_datatypewidth()

UWORD c_datatypewidth ( void )

DataTypeWidth: the picture's width (bmh_Width).

Returns
d0.w: the width, 0 without datatypes.library or DataTypeBitmap

◆ c_detachdatatype()

void c_detachdatatype ( void )

DetachDataType: removes the object from the window it is attached to.

Nothing if it is not attached, or attached to a bitmap.

◆ c_getdatatypeattr()

ULONG c_getdatatypeattr ( ULONG attr)

GetDataTypeAttr(attribute): GetAttr of one attribute into the buffer.

Parameters
attrd0: the attribute
Returns
d0: the address of the value (the buffer), 0 without object

◆ c_getmodeid()

ULONG c_getmodeid ( void )

DataTypeModeID: BestModeID for the picture's size and depth (the tags in the buffer).

Returns
d0: the mode id, 0 without DataTypeBitmap

◆ c_getmodeid2()

ULONG c_getmodeid2 ( struct TagItem * tags)

DataTypeModeID taglist: as DataTypeModeID, with the program's tag list behind the library's tags (TAG_MORE; the library's come first). Fixed (#603): the original wrote its tags over the list.

Parameters
tagsd0: the tag list (0: none)
Returns
d0: the mode id, 0 without DataTypeBitmap

◆ c_libfinit()

void c_libfinit ( void )
static

finit: DetachDataType, DataTypeClose, closes the libraries and frees the buffer.

Each of the four that opened is closed (fixed, #602: the original stopped at the first one that had not opened).

◆ c_libinit()

void c_libinit ( void )
static

init: opens datatypes, dos, intuition and graphics.library (V37) and allocates the 1024 byte buffer (memlib globalloc, MEMF_CLEAR).

A library that does not open leaves its base 0; the commands that test the base then do nothing.

◆ c_setdatatypeattr()

void c_setdatatypeattr ( struct TagItem * tags)

SetDataTypeAttr &taglist: SetAttrs on the object.

Parameters
tagsd0: the tag list

◆ c_setdatatypeattr2()

void c_setdatatypeattr2 ( UWORD n,
const ULONG * sp )

SetDataTypeAttr attr,data[,attr,data..]: SetAttrs with the pairs as a tag list in the buffer.

BUG(orig) (#608): 0 pairs are 65536 (DBRA), more than 127 overflow the 1024 byte buffer. DIFF: a2 stays unchanged.

Parameters
nd7: the number of pairs
spa2: the argument stack (the pairs below it)

◆ create()

ULONG create ( struct TagItem * tags)
static

◆ doattach()

BB_BOOL doattach ( const ULONG * winobj)
static

◆ domodeid()

ULONG domodeid ( struct TagItem * more)
static

◆ freename()

void freename ( void )
static

◆ putid()

ULONG putid ( const UBYTE * s)
static

◆ putstring()

ULONG putstring ( const UBYTE * s)
static

◆ ridatatypeslib_libfinit()

void ridatatypeslib_libfinit ( void )

◆ ridatatypeslib_libinit()

void ridatatypeslib_libinit ( void )

◆ tailtags()

struct TagItem * tailtags ( struct TagItem * t)
static

Variable Documentation

◆ attached

ULONG attached
static

◆ attachtobitmap

UWORD attachtobitmap
static

◆ bitmapheader

struct BitMapHeader* bitmapheader
static

◆ dtype

struct DataType* dtype
static

◆ dtypehead

struct DataTypeHeader* dtypehead
static

◆ fname

UBYTE* fname
static

◆ libbases

struct Library* libbases[5]
static

◆ libnames

const char* const libnames[]
static
Initial value:
= {
"datatypes.library", "dos.library", "intuition.library", "graphics.library", NULL
}

◆ lock

BPTR lock
static

◆ object

Object* object
static

◆ [union]

union { ... } * storage

◆ tags

struct TagItem tags[128]

◆ value

ULONG value