Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fb(4) — NEWS-os 4.1C

Media Vault

Software Library

Restoration Projects

Artifacts Sought

NFB(4)  —  NEWS-OS Programmer’s Manual

NAME

fb − NEWS frame buffer device interface

SYNOPSIS

fb[0−7] at iop priority 44 (2CPU)
fb[0−7] at hb0 priority 44 (1CPU)

#include <newsiop/framebuf.h>

DESCRIPTION

fb[0−7] interface command is used to access the NEWS frame buffer device. 

This frame buffer interface enables read/write data, raster operation, and line drawing. 

The operation is performed using system call ioctl(2).  The ioctl call enables the user-defined (user space) bit map operations and the frame buffer operations as well. 

DATA TYPE

The data structure used for the bit map operation is given below:

 typedef unsigned short     Word;
 #define BitsPerWord     16
 typedef struct {
        int   x, y;
} lPoint;
 typedef struct {
        lPoint  origin;
        lPoint  extent;
} lRectangle;
 typedef struct {
        char            type;      /∗ BM_FB, BM_MEM BM_0, or BM_1 ∗/
        char            depth;     /∗ number of planes of a bit map ∗/
        unsigned short  width;     /∗ width (unit: word) ∗/
        lRectangle      rect;      /∗ defined area ∗/
        Word            ∗base;     /∗ used for BM_MEM ∗/
} lBitmap;
 #define BM_FB        0    /∗ frame buffer ∗/
#define BM_MEM       1    /∗ bit map (XY format) in the memory ∗/
#define BM_0         2    /∗ virtual bit map for data ‘0’ ∗/
#define BM_1         3    /∗ virtual bit map for data ‘1’ ∗/
#define BM_LBP       4    /∗ LBP frame buffer ∗/
 

Word can be defined as any unsigned 16 bits (1 word). 

The lPoint structure is used for the point. 

The lRectangle structure is used to create a rectangle.  The origin is located on the left upper corner and the extent indicates the vertical and horizontal length of rectangle. 

The lBitmap structure is used for defining the bit map.  The type field indicates whether the bit map is located in the main memory or in the frame buffer.  BM_FB indicates the bit map in the frame buffer, and BM_MEM indicates the bit map in the main memory.  The BM_MEM bit map stores data in the xy format.  The plane 0 data is stored followed by the plane 1 data, and so on.  BM_0 and BM_1 are virtual bit maps whose data are always 0 and 1, respectively.  The BM_0 and BM_1 bit maps are used as the source bit map only during the raster operation.  The depth field indicates the number of planes of the bit map.  The number of planes for the black and white frame buffer bit map is 1, and that for the frame buffer bit map is 24, 16, 8 or 4.  The number of planes for the main memory bit map and BM_0/BM_1 bit maps can be 1, 4, 8, 16 or 24 regardless of use or non-use of color display. 

The width (horizonal width) field for the BM_MEM bit map indicates the number of words in the X direction.  The width for the BM_FB and BM_0/BM_1 bit maps cannot be specified. 

The rect field indicates the size of the bit map.  The operation is enabled within this area. 

The base field indicates the starting point of the data. 

For the BM_MEM bit map, the data must be arranged in the word border.  The first bit in the first word of the first line corresponds to the location specified by rect.origin.  This means that the bit map with 1 plane requires the (width ∗ rect.extent.y) word.  In this, the width is assumed to be large enough to contain the rect.extent.x bit. 

IOCTL

FBIOCNSETDIM

FBIOCNGETDIM
FBIOCNSETDIM and FBIOCNGETDIM allow you to examine and select the brightness of the display. Three levels of brightness are provided for the NWB-512 and NWS-711/PWS-1520/PWS-1550. The system default, which is the brightest, is 0. The NWB-251, NWB-514, and PWS-1560 are not provided with brightness selection and you can either set the brightness to ON or OFF. The NWB-225, NWB-223, and NWS-721 are not provided with this function.

 int        dimmer_level;
ioctl(fildes, FBIOCNSETDIM, &dimmer_level);
ioctl(fildes, FBIOCNGETDIM, &dimmer_level);
 

FBIOCNBITBLT
FBIOCNBITBLT allows you to request a 2-operand raster operation (bitblt). The source and destination bit maps are stored in the main memory or frame buffer. The BM_0/BM_1 bit map can be used for the source bit map only. The number of planes for the source and destination bit maps must be equal, or the number of planes for either bit map must be 1.

 /∗ the 2-operand bitblt ∗/
typedef struct {
        unsigned char  func;         /∗ function code ∗/
        char           transp;       /∗ transparency ∗/
        int            fore_color;   /∗ foreground color ∗/
        int            aux_color;    /∗ auxiliary color ∗/
        int            planemask;    /∗ plane selection ∗/
        lBitmap        srcBitmap;    /∗ source bit map ∗/
        lRectangle     srcRect;      /∗ source rectangle ∗/
        lBitmap        destBitmap;   /∗ destination bit map ∗/
        lRectangle     destClip;     /∗ clip rectangle ∗/
        lPoint         destPoint;    /∗ destination point ∗/
} lBitblt;
 /∗ function ∗/
#define BF_0    0x0     /∗ 0 ∗/
#define BF_SDA  0x1     /∗ Src(source) & Dest(destination) ∗/
#define BF_SDIA 0x2     /∗ Src & ~Dest ∗/
#define BF_S    0x3     /∗ Src ∗/
#define BF_SIDA 0x4     /∗ ~Src & Dest ∗/
#define BF_D    0x5     /∗ Dest ∗/
#define BF_SDX  0x6     /∗ Src ^ Dest ∗/
#define BF_SDO  0x7     /∗ Src | Dest ∗/
#define BF_SDOI 0x8     /∗ ~(Src | Dest) ∗/
#define BF_SDXI 0x9     /∗ ~(Src ^ Dest) ∗/
#define BF_DI   0xa     /∗ ~Dest ∗/
#define BF_SDIO 0xb     /∗ Src | ~Dest ∗/
#define BF_SI   0xc     /∗ ~Src ∗/
#define BF_SIDO 0xd     /∗ ~Src | Dest ∗/
#define BF_SDAI 0xe     /∗ ~(Src & Dest) ∗/
#define BF_1    0xf     /∗ 1 ∗/
 /∗ plane mask ∗/
#define FB_PLANEALL     0x00ffffff
#define FB_PLANE0       0x00000001
#define FB_PLANE1       0x00000002
#define FB_PLANE2       0x00000004
#define FB_PLANE3       0x00000008
#define FB_PLANE4       0x00000010
#define FB_PLANE5       0x00000020
#define FB_PLANE6       0x00000040
#define FB_PLANE7       0x00000080
#define FB_PLANE8       0x00000100
#define FB_PLANE9       0x00000200
#define FB_PLANE10      0x00000400
#define FB_PLANE11      0x00000800
#define FB_PLANE12      0x00001000
#define FB_PLANE13      0x00002000
#define FB_PLANE14      0x00004000
#define FB_PLANE15      0x00008000
#define FB_PLANE16      0x00010000
#define FB_PLANE17      0x00020000
#define FB_PLANE18      0x00040000
#define FB_PLANE19      0x00080000
#define FB_PLANE20      0x00100000
#define FB_PLANE21      0x00200000
#define FB_PLANE22      0x00400000
#define FB_PLANE23      0x00800000

The lBitblt structure is used for the parameter.  The func field indicates the function code for the raster operation.  The transp field is used for the transparency and the value will be 0 or 1.  When the value is 1, a destination pixel that corresponds to a 0-value source pixel will not be affected. 

The fore_color and aux_color fields are not effective when the number of planes for the source bit map is 1.  The source bit with the value 1 will be treated as the bit pattern for fore_color before executing operation with the pixel of the corresponding destination bit.  On the other hand, bitblt will treat the source bit with the value 0 as the pattern for aux_color during the bitblt function execution.  For example, if func is BF_S (copying from source to destination), the pixel which corresponds to the source bit with value 1 is displayed using fore_color, and other pixels are displayed using aux_color. 

planemask field specifies the plane to be used for the operation.  The planemask 1 informs bitblt that the corresponding plane will be the target of the operation.  When a planemask is 0, the corresponding plane will be ignored.  The bit N corresponds to the plane N. 

The srcBitmap and srcRect fields indicate the source bit map to be used for the operation. 

The destBitmap and destPoint fields indicate the destination bit map to be used for the operation.  The destPoint field indicates the left upper corner.  The size of the rectangle used for the raster operation is equal to srcRect.  The destClip field is used for specifying the clipping portion of the destination. 

 lBitblt    bitblt;
ioctl(fildes, FBIOCNBITBLT, &bitblt);
 

FBIOCNBATCHBITBLT
FBIOCNBATCHBITBLT allows you to request batch processing of several bitblt operations. The source and destination bit maps must be same throughout each operation. However, the source rectangle and destination point can be different in each operation.

 typedef struct {
        lRectangle     srcRect;       /∗ source rectangle ∗/
        lPoint         destPoint;     /∗ destination point ∗/
} lSrcDest
  /∗
 ∗ batch bitblt
 ∗/
typedef struct {
        unsigned char  func;         /∗ function code ∗/
        char           transp;       /∗ transparency ∗/
        int            fore_color;   /∗ foreground color ∗/
        int            aux_color;    /∗ auxiliary color ∗/
        int            planemask;    /∗ plane selection ∗/
        lBitmap        srcBitmap;    /∗ source bit map ∗/
        lBitmap        destBitmap;   /∗ destination bit map ∗/
        lRectangle     destClip;     /∗ clip rectangle ∗/
        int            nSrcDest;     /∗ number of src-dest
                                        points in the list ∗/
        lSrcDest       ∗srcDestList  /∗ pointer specified
                                        by src-dest ∗/
} lBatchBitblt;
 #define MAX_BATCHBITBLT 1024    /∗ maximum number of src-dest lists ∗/
 

The lBatchBitblt structure is similar to the lBitblt structure and consists of the source and destination bit maps.  The srcDestList field indicates the source rectangle list and destination point list.  The number of elements is given in the nSrcDest field. 

 lBatchBitblt       bbitblt;
ioctl(fildes, FBIOCNBATCHBITBLT, &bbitblt);
 

FBIOCNTILEBITBLT
FBIOCNTILEBITBLT allows you to fill in a pattern with colors during the raster operation.

 /∗ tile 2-operand bitblt ∗/
typedef struct {
        unsigned char   func;        /∗ function code ∗/
        char            transp;      /∗ transparency ∗/
        int             fore_color;  /∗ foreground color ∗/
        int             aux_color;   /∗ auxiliary color ∗/
        int             planemask;   /∗ plane selection ∗/
        lBitmap         ptnBitmap;   /∗ pattern bit msp ∗/
        lRectangle      ptnRect;     /∗ pattern rectangle ∗/
        lPoint          refPoint;    /∗ reference point ∗/
        lBitmap         destBitmap;  /∗ destination bit map ∗/
        lRectangle      destClip;    /∗ clip rectangle ∗/
        lRectangle      destRect;    /∗ destination rectangle ∗/
} lTileBitblt;
 

The lTileBitblt structure is used to transfer the parameter.  The ptnBitmap and ptnRect fields specify the pattern to be used.  The refPoint field indicates the point to be referred to for the coloring operation.  The reference point and the left upper corner of the pattern will match on the destination bit map.  The reference point can be specified on the outside of the destination rectangle or its clip rectangle. 

 lTileBitblt        tbitblt;
ioctl(fildes, FBIOCNTILEBITBLT, &tbitblt);
 

FBIOCNPOLYLINE
FBIOCNPOLYLINE allows you to draw a polyline (straight line). You can specify the line’s color line pattern, and function code the raster operation.

 /∗ line ∗/
typedef struct {
        unsigned int    lptn;        /∗ line pattern ∗/
        short           np;          /∗ number of points ∗/
        lPoint          ∗plist;      /∗ point list ∗/
        int             fore_color;  /∗ foreground color ∗/
        int             aux_color;   /∗ auxiliary color ∗/
        int             planemask;   /∗ plane selection ∗/
        char            transp;      /∗ transparency ∗/
        unsigned char   func;        /∗ raster operation
                                        function code ∗/
        char            dlpf;        /∗ last point drawing flag ∗/
        lRectangle      clip;        /∗ clip rectangle ∗/
        lBitmap         drawBM;      /∗ bit map to be drawn ∗/
} lPrimLine;
 /∗ line pattern (example) ∗/
#define LINE_SLD        (unsigned)0xffffffff    /∗ solid ∗/
#define LINE_DSH        (unsigned)0xfcfcfcfc    /∗ dash − ∗/
#define LINE_DOT        (unsigned)0xcccccccc    /∗ dot . ∗/
#define LINE_DSHDOT     (unsigned)0xfff18fff    /∗ dashed dot −. ∗/
#define LINE_DSHDOTDOT  (unsigned)0xff8c63ff    /∗ dashed dot dot −.. ∗/
 

The lPrimLine structure is used to request the polyline.  The lptn field specifies the 32-bit line pattern.  The plist field is used to transfer the up point for call.  The np is not the number of lines.  It is the number of points.  See FBIOCNBITBLT for the explanations on the fore_color, aux_color, planemask, transp, and func fields.  The dlpf flag specifies whether or not the last point in the list is drawn.  In other words, when the flag is 0, this point is not drawn; otherwise, it is drawn.  To draw a closed diagram, 0 is assigned to this field.  The drawBM and clip fields are used to specify the bit map and the clip rectangle separately. 

 lPrimline  primline;
ioctl(fildes, FBIOCNPOLYLINE, &primline);
 

FBIOCNDJPOLYLINE
FBIOCNDJPOLYLINE is similar to FBIOCNPOLYLINE. FBIOCNPOLYLINE allows you to draw a line with continuity. FBIOCNDJPOLYLINE, on the other hand, allows you to draw a line in segments. The dlpf field is used to specify whether or not the last point of each line segment is drawn. 

 lPrimline  primline;
ioctl(fildes, FBIOCNDJPOLYLINE, &primline);
 

FBIOCNPOLYMARKER
FBIOCNPOLYMARKER allows you to draw a polymarker. This request is used to execute the raster operation between the specified pattern and several bit maps.

 /∗ marker ∗/
typedef struct {
        short          np;           /∗ number of points ∗/
        lPoint         ∗plist;       /∗ point list ∗/
        lRectangle     ptnRect;      /∗ pattern rectangle ∗/
        lBitmap        ptnBM;        /∗ pattern bit map ∗/
        int            fore_color;   /∗ forground color ∗/
        int            aux_color;    /∗ auxiliary color ∗/
        int            planemask;    /∗ plane selection ∗/
        char           transp;       /∗ trasparency ∗/
        unsigned char  func;         /∗ raster operation
                                        function code∗/
        lRectangle     clip;         /∗ clip rectangle ∗/
        lBitmap        drawBM;       /∗ bit map to be drawn ∗/
} lPrimMarker;
 

The lPrimMaker structure is used to draw the polymarker.  The ptnBM and ptnRect fields are used to specify the pattern to be used for the raster operation.  The plist field indicates the point list, and np indicates the number of points. 

 lPrimMarker        primmarkers;
ioctl(fildes, FBIOCNPOLYMARKER, &primmaker);
 

FBIOCNRECTANGLE
FBIOCNRECTANGLE allows you to fill a rectangle with a specified pattern.

 /∗ filling the rectangle ∗/
typedef struct {
        lRectangle      rect;         /∗ rectangle ∗/
        lPoint          refPoint;     /∗ reference point for
                                         filling ∗/
        lRectangle      ptnRect;      /∗ pattern rectangle ∗/
        lBitmap         ptnBM;        /∗ pattern bit map ∗/
        int             fore_color;   /∗ foreground color ∗/
        int             aux_color;    /∗ auxiliary color ∗/
        int             planemask;    /∗ plane selection ∗/
        char            transp;       /∗ transparency ∗/
        unsigned char   func;         /∗ raster operation
                                         function code ∗/
        lRectangle      clip;         /∗ clip rectangle ∗/
        lBitmap         drawBM;       /∗ bit map to be draw ∗/
} lPrimRect;
 

The lPrimRect structure is used to fill in the rectangle with the specified pattern.  The rect field specifies the rectangle.  The ptnBM and ptnRect fields are used to specify the pattern with which the target rectangle is to be filled.  The refPoint field contains the point to match the left upper corner of the pattern.  The refPoint may be outside the rectangle or clip. 

 lPrimRect  rect;
ioctl(fildes, FBIOCNRECTANGLE, &rect);
 

FBIOCNFILLSCAN
FBIOCNFILLSCAN allows you to fill in a pattern along the specified scan line.

 /∗ scan line arrangement ∗/
#define SSCANL
typedef struct {
        short   y;
        short   x0, x1;
} lScanl;
 /∗ filling the pattern ∗/
typedef struct {
        short           nscan;       /∗ number of scan line ∗/
        lScanl          ∗scan;       /∗ scan line data ∗/
        lPoint          refPoint;    /∗ reference point for
                                        filling ∗/
        lRectangle      ptnRect;     /∗ pattern rectangle ∗/
        lBitmap         ptnBM;       /∗ pattern bit map ∗/
        int             fore_color;  /∗ foreground color ∗/
        int             aux_color;   /∗ auxiliary color ∗/
        int             planemask;   /∗ plane selection ∗/
        char            transp;      /∗ transparency ∗/
        unsigned char   func;        /∗ raster operation
                                        function code ∗/
        lRectangle      clip;        /∗ clip rectangle ∗/
        lBitmap         drawBM;      /∗ bit map to be drawn ∗/
} lPrimFill;
 

The lScanl structure is used for the scan line.  The lPrimFill structure is used to trnsfer all the parameters.  The scan field contains the pointer to the scan line arrangement.  The nscan field indicates the number of scan lines.  The ptnBM and ptnRect fields are used to specify the pattern with which the target rectangle is to be filled.  The refPoint field is the reference point to be set on the left upper corner of the pattern. 

 lPrimFill  fill;
ioctl(fildes, FBIOCNFILLSCAN, &fill);
 

FBIOCNTEXT
FBIOCNTEXT allows you to write a character string using the specified font. The fonts to be used are the bit map font and ROM font.

 /∗ text ∗/
typedef struct {
        int             dx, dy;         /∗ vector (16bit left shifted) ∗/
        lPoint          fp;             /∗ bitmap font upper-left ∗/
        short           width, height;  /∗ font width, font height ∗/
        short           column;         /∗ number of characters in a row ∗/
        unsigned short  first_chr;      /∗ first character code ∗/
        unsigned short  last_chr;       /∗ last character code ∗/
        lBitmap         fontBM;         /∗ font bitmap ∗/
        int             fore_color;     /∗ foreground color ∗/
        int             aux_color;      /∗ auxiliary color ∗/
        int             planemask;      /∗ select plane ∗/
        lBitmap         drawBM;         /∗ drawing bitmap ∗/
        lRectangle      clip;           /∗ clip rectangle ∗/
        lPoint          p;              /∗ output position ∗/
        unsigned char   ∗str;           /∗ string ∗/
        short           len;            /∗ string length (byte) ∗/
        char            type;           /∗ ROM-font, etc ∗/
        char            transp;         /∗ transparency ∗/
        unsigned char   func;           /∗ rop function code ∗/
        char            ex_factor;      /∗ expansion factor ∗/
} lPrimText;
 /∗ bit map font type ∗/
#define ROM_ASCII       0
#define ROM_KANJI       1
#define ASCII           2
 

The lPrimText structure is used to write the characters.  The type field specifies the font to be used. 

    ROM_ASCIIROM font (1-byte code)
    ROM_KANJIROM font (JIS Kanji code)
    ASCIIbit map font(1-byte code)

The len field indicates the length of the character string in bytes.  Note that the length of the character string in bytes doesn’t match the number of characters if Kanji is used.  The str field contains the pointer to the character string.  The p field should be the point that matches the left upper corner of the first character.  The dx and dy fields indicate the direction in which the string will be written.  For example, to write a character at a location horizontally 26 dots to the right of the previously written character, specify: dx = 26 << 16; dy=0 The ex_factor field indicates the extended factor in the horizontal direction.  For example, when this value is 1, the width will be the regular width; when it is 2, the width will be double.  The fp, width, and height fields define the font bit map.  The left upper corner of a font bit map is determined by fp; the font width is determined by width; and the font height is determined by height.  (The size of a font is fixed and the system does not support the variable font pitch.)  The column field indicates the number of characters in a string.  The first_chr and last_chr fields indicate the first and last characters in the front bit map. 

 lPrimtText text;
ioctl(fildes, FBIOCNTEXT, &text);
 

FBIOCNGETSCRTYPE
FBIOCNGETSCRTYPE returns the type of the bit map display.

 /∗
 ∗      screen type
 ∗/
typedef struct {
        short        colorwidth;     /∗ color width ∗/
        short        plane;          /∗ number of planes ∗/
        char         type;           /∗ device type ∗/
        char         unit;           /∗ unit number ∗/
        lRectangle   bufferrect;     /∗ frame buffer area ∗/
        lRectangle   visiblerect;    /∗ display screen area ∗/
} lScrType;
 

The lScrType structure is used to transfer the parameter.  The colorwidth field indicates the bit numbers to be used for each value of red, green, and blue of the color palette.  The width will be 4 or 8.  When the width is 4, the higher 4 bits in the byte are used; and when it is 8, the entire 8 bits are used.  The plane field indicates the number of planes.  When plane is 1, the display is monochrome; and when plane is 8 (or 4), the display is color or gray scale.  The type field indicates the type of the bit map display.  Unique values are assigned to the corresponding interface boards as shown below:


#define FB_NWB512       1
#define FB_NWB225       2
#define FB_POPM         3
#define FB_POPC         4
#define FB_NWB514       5
#define FB_NWB251       6
#define FB_LCDM         7
#define FB_LCDC         8
#define FB_NWB518       9
#define FB_NWB252       10
#define FB_NWB253       11
#define FB_NWB254       12
#define FB_NWB255       13
#define FB_SLB101       14

The unit field indicates the board number in accordance with the address sequence of the dip switch setting on the board when several interface boards of the same kind are used.  The bufferrect field indicates the frame buffer size.  The visiblerect field indicates the display area of the frame buffer. 

 lScrType   scrtype;
ioctl(fildes, FBIOCNGETSCRTYPE, &scrtype);
 

FBIOCNGETPALETTE

FBIOCNSETPALETTE
FBIOCNGETPALETTE and FBIOCNSETPALETTE allow you to read and write the color palette data.

 /∗
 ∗     color
 ∗/
 typedef struct {
        short   index;  /∗ palette number ∗/
        struct {
                short   r, g, b;
        } rgb;
} sPalette;
 typedef struct {
        int             count;
        sPalette        ∗palette;
} lPalette;
 

The parette number can be between 0 and 255 (8 planes) or between 0 and 16 (4 planes).  The palette field contains the pointer to the sPalette structure arrays whose number is indicated by count.  FBIOCNGETPALETTE requests the palette number that was delivered to the index field.  The rgb field is written after begin called.  FBIOCNSETPALETTE allows you to set the index and rgb fields (rgb: red, green, blue). 

 lPalette   palette;
ioctl(fildes, FBIOCNGETPALETTE, &palette);
ioctl(fildes, FBIOCNSETPALETTE, &palette);
 

FILES

/dev/fb[0−7]

SEE ALSO

NWM-660

BUG

When the NWS-1830/50 is accessed from different processes at the same time, system down may occur. 

For requests that require the array as a parameter, such as FBIOCNBATCHBITBLT, the array size has a limit. 

The LBP interface is not yet supported. 

NEWS-OSRelease 4.1C

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026