★ Basic data type



ListReference

Data type

Uint8


Unsigned 1-byte integer

function


    typedef unsigned char Uint8;







ListReference

Data type

Sint8


Signed 1-byte integer

function


    typedef signed char Sint8;







ListReference

Data type

Uint16


Unsigned 2-byte integer

function


    typedef unsigned short Uint16;







ListReference

Data type

Sint16


Signed 2-byte integer

function


    typedef signed short Sint16;







ListReference

Data type

Uint32


Unsigned 4-byte integer

function


    typedef unsigned long Uint32;





ListReference

Data type

Sint32


Signed 4-byte integer

function


    typedef signed long Sint32;







ListReference

Data type

Float32


4-byte real number

function


    typedef float Float32;







ListReference

Data type

Float64


8-byte real number

function


    typedef double Float64;







ListReference

Data type

Int


INT type

function


    typedef int Int;







ListReference

Data type

Bool


Logical type (takes a logical constant as a value)

function


    typedef int Bool;






★ Applied data type



ListReference

Data type

ANGLE


16-bit representation of 360 degrees around

function


    typedef Sint16 ANGLE;







ListReference

Data type

FIXED


Fixed-point type in which the upper 16 bits represent the integer part and the lower 16 bits represent the decimal part.

function


    typedef Sint32 FIXED;







ListReference

Data type

MATRIX


Matrix data

function


    typedef FIXED MATRIX [4] [3];







ListReference

Data type

VECTOR


Vector data

function


    typedef FIXED VECTOR [ XYZ ];







ListReference

Data type

POINT


Vertex position data

function


    typedef FIXED POINT [ XYZ ];







ListReference

Data type

TEXDAT


Texture data

function


    typedef Uint16 TEXDAT;







ListReference

Data type

GOURAUDT BL


Gouraud shading table

function


    typedef Uint16 GOURAUDTBL [4];







ListReference

Data type

CELL


1 cell size

function


    typedef Uint16 CELL;







ListReference

Data type

DmaCpuStatus


function


    typedef Uint32 DmaCpuStatus;







ListReference

Structure

WORK


Event data container

structure


    typedef struct work {

      struct work * next;

      Uint8 user [ WORK_SIZE --sizeof (struct work *)];

    } WORK;

function


    next --A pointer to the next work.
user --Data body.



ListReference

Structure

EVENT


Event container for events

structure


    typedef struct evnt {

      WORK * work;

      struct evnt * next;

      struct evnt * before;

      void (* exam) ();

      Uint8 user [ EVENT_SIZE- (sizeof ( WORK *) + sizeof (struct evnt *)) 

                       * 2 + sizeof (void (*) ()))];

      } EVENT;

function


    work --A pointer to a WORK structure.
next --Pointer to the next EVENT.
before --A pointer to the previous EVENT.
exad --The execution address of the callback function.
user --User area.



ListReference

Structure

POLYGON


Polygon data management structure

structure


    typedef struct {

      VECTOR norm;

      Uint16 Vertices [4];

    } POLYGON;

function


    norm --normal vector Vertices --vertex numbers that make up the polygon 



ListReference

Structure

ATTR


Texture attributes

structure


    typedef struct {

      Uint8 flag;

      Uint8 sort;

      Uint16 texno;

      Uint16 atrb;

      Uint16 colno;

      Uint16 gstb;

      Uint16 dir;

    } ATTR;

function


    flag --One-sided or two-sided flag sort --Sort reference position and option settings 

    texno --texture number atrb --attribute data (display mode)

    colno --color number gstb --Gouraud shading table dir --texture inversion and function number 



ListReference

Structure

SPR_ATTR


Sprite attributes

structure


    typedef struct {

      Uint16 texno;

      Uint16 atrb;

      Uint16 colno;

      Uint16 gstb;

      Uint16 dir;

    } SPR_ATTR;

function


    texno --Picture number atrb --Attribute data (display mode)

    colno --color number gstb --Gouraud shading table dir --texture inversion and function number 







ListReference

Structure

PDATA


Model data management structure

structure


    typedef struct {

      POINT * pntbl;

      Uint32 nbPoint;

      POLYGON * pltbl;

      Uint32 nbPolygon;

      ATTR * attbl;

   } PDATA;

function


    pntbl --Vertex position data table nbPoint --Number of vertices pltbl --Polygon definition table nbPolygon --Number of polygons attbl --Polygon attribute table 



ListReference

Structure

XPDATA


Model data management structure for real-time gourd

structure


    typedef struct {

      POINT * pntbl;

      Uint32 nbPoint;

      POLYGON * pltbl;

      Uint32 nbPolygon;

      ATTR * attbl;

      VECTOR * vntbl;

    } XPDATA;

function


    pntbl --Vertex position data table nbPoint --Number of vertices * pltbl --Polygon definition table nbPolygon --Number of polygons attbl --Polygon attribute table * vntbl --Normal vector table of each vertex 



ListReference

Structure

OBJECT


Hierarchical model management structure

structure


    typedef struct obj {

      PDATA * pat;

      FIXED pos [ XYZ ];

      ANGLE ang [ XYZ ];

      FIXED scl [ XYZ ];

      struct obj * child;

      struct obj * sibling;

    } OBJECT;

function


    pat --Polygon model data table pos --Relative position data ang --Rotation angle data scl --Scale data child --Pointer to child object data sibling --Pointer to sibling object data 



ListReference

Structure

TEXTURE


Sprite data information index

structure


    typedef struct {

      Uint16 Hsize;

      Uint16 Vsize;

      Uint16 CGadr;

      Uint16 HVsize;

    } TEXTURE;

function


    Hsize --Sprite H size Vsize --Sprite V size CGadr --Sprite CG address / 8

    HVsize --H size / 8 x V size (for hardware)







ListReference

Structure

PICTURE


Picture data information for sprites

structure


    typedef struct {

      Uint16 texno;

      Uint16 cmode;

      void * pcsrc;

    } PICTURE ;

function


    texno --texture number cmode --color mode pcsrc --location of original data

caution



    This structure is used as auxiliary information when transferring texture data to VRAM.

    It is used and is not related to the operation of the SGL system itself.



ListReference

Structure

SPRITE


Sprite management structure with the same configuration as the VDP1 command table

structure


    typedef struct {

      Uint16 CTRL;

      Uint16 LINK;

      Uint16 PMOD;

      Uint16 COLR;

      Uint16 SRCA;

      Uint16 SIZE;

      Sint16 XA;

      Sint16 YA;

      Sint16 XB;

      Sint16 YB;

      Sint16 XC;

      Sint16 YC;

      Sint16 XD;

      Sint16 YD;

      Uint16 GRDA;

      Uint16 DMMY;

    } SPRITE;

function


    CTRL --Control function LINK --Link address PMOD --Put mode COLR --Color data SRCA --CG address SIZE --Character size XA, YA --Display position A

    XB, YB-Display position B

    XC, YC-Display position C

    XD, YD-Display position D

    GRDA --Gouraud shading table DMMY --Dummy data for size matching

caution



    The structure of this structure is exactly the same as that of the VDP1 command table.
For more information See Chapter 7, "Commands" in the VDP1 User's Manual.



ListReference

Structure

ROTSCROLL


Rotation parameter table

structure


    typedef struct rdat {

      FIXED XST;

      FIXED YST;

      FIXED ZST;

      FIXED DXST;

      FIXED DYST;

      FIXED DX;

      FIXED DY;

      FIXED MATA;

      FIXED MATB;

      FIXED MATC;

      FIXED MATD;

      FIXED MATE;

      FIXED MATF;

      Sint16 PX;

      Sint16 PY;

      Sint16 PZ;

      Sint16 dummy0;

      Sint16 CX;

      Sint16 CY;

      Sint16 CZ;

      Sint16 dummy1;

      FIXED MX;

      FIXED MY;

      FIXED KX;

      FIXED KY;

      Uint32 KAST;

      Sint32 DKAST;

      Sint32 DKA;

    } ROTSCROLL;

function


    XST --Screen screen start coordinates Xst

    YST --Screen screen start coordinates Yst

    ZST --Screen screen start coordinates Zst

    DXST --Screen screen vertical coordinate increment dXst

    DYST --Screen screen vertical coordinate increment dYst

    DX --Screen screen Horizontal coordinate increment dX

    DY --Screen screen Horizontal coordinate increment dY

    MATA-Rotation matrix parameter A

    MATB-Rotation Matrix Parameter B

    MATC-Rotation matrix parameter C

    MATD-Rotation matrix parameter D

    MATE-Rotation matrix parameter E

    MATF-Rotation matrix parameter F

    PX-Viewpoint coordinates Px

    PY-Viewpoint coordinates Py

    PZ-Viewpoint coordinates Pz

    dummy0 --Dummy CX to match the rotation coefficient parameter of VDP2 with the byte position --Center coordinates Cx

    CY-Center coordinates Cy

    CZ-Center coordinates Cz

    dummy1 --Dummy MX to align the bite position with the rotation coefficient parameter of VDP2 --Translation amount Mx

    MY-Translation amount My

    KX-Scale factor kx

    KY --Scale factor ky

    KAST-coefficient table start address KAst

    DKAST-Coefficient table vertical address increment ΔKAst

    DKA-coefficient table horizontal address increment KA

caution



    The structure of this structure is exactly the same as the rotation parameters of VDP2.
For more information See 6.3 Rotation Parameters in Chapter 6, “Rotation Scrolls” of the VDP2 User's Manual.



ListReference

Structure

PCM


Structure for PCM playback

structure


    typedef struct {

      Uint8 mode;

      Uint8 channel;

      Uint8 level;

      Sint8 pan;

      Uint16 pitch;

      Uint8 eflevelR;

      Uint8 efselectR;

      Uint8 eflevelL;

      Uint8 efselectL;

      Uint8 totalLevel;

    } PCM;

function


    mode --Stereo / monaural channel --Channel number of PCM being played level --Playback volume 7 steps pan --Pan pitch --Playback pitch eflevelR --R channel effect degree efselectR --R channel effect selector eflevelL --R channel effect Degree efselectL --R channel effect selector totalLevel --Total level of playback slot 256 levels 



ListReference

Structure

SmpcDateTime


RTC time information

structure


    typedef struct {

      Uint 16 year;

      Uint8 month;

      Uint8 date;

      Uint8 hour;

      Uint8 minute;

      Uint8 second;

      Uint8 dummy;

    } SmpcDateTime;

function


    year --year year month --day of the week / month date --day hour --hour minute --minute second --second dummy --dummy 



ListReference

Structure

SmpcStatus


SMPC status

structure


    typedef struct {

      Uint8 cond;

      Uint8 dummy1;

      Uint16 dummy2;

      SmpcDateTime rtc;

      Uint8 ctg;

      Uint8 area;

      Uint16 system;

      Uint32 smem;

    } SmpcStatus;

function


    cond --status status dummy1 --dummy 1

    dummy2 --dummy 2

    rtc --RTC time ctg --Cartridge code area --Area code system --System status smem --SMPC Memory retention data 



ListReference

Structure

PerDigital


Digital device

structure


    typedef struct {

      Uint8 id;

      Uint8 ext;

      Uint16 data;

      Uint16 push;

      Uint16 pull;

      Uint32 dummy2 [4];

    } PerDigital;

function


    id --peripheral ID

    ext --Extended data size data --Button current data push --Button press data pull --Button pull data dummy2 [4] --Dummy 



ListReference

Structure

PerAnalog


Analog devices

structure


    typedef struct {

      Uint8 id;

      Uint8 ext;

      Uint16 data;

      Uint16 push;

      Uint16 pull;

      Uint8 x;

      Uint8 y;

      Uint8 z;

      Uint8 dummy1;

      Uint32 dummy2 [3];

    } PerAnalog;

function


    id --peripheral ID

    ext --Extended data size data --Button current data push --Button press data pull --Button pull data x --X-axis data absolute value y --Y-axis data absolute value z --Z-axis data absolute value dummy1 --Dummy 1

    dummy2 [3] --Dummy 2









ListReference

Structure

PerPoint


pointing device

structure


    typedef struct {

      Uint8 id;

      Uint8 ext;

      Uint16 data;

      Uint16 push;

      Uint16 pull;

      Uint16 x;

      Uint16 y;

      Uint32 dummy2 [3];

    } PerPoint;

function


    id --peripheral ID

    ext --Extended data size data --Button current data push --Button press data pull --Button pull data x --X coordinate y --Y coordinate dummy2 [3] --Dummy 1









ListReference

Structure

PerKeyBoard


Keyboard device

structure


    typedef struct {

      Uint8 id;

      Uint8 ext;

      Uint16 data;

      Uint16 push;

      Uint16 pull;

      Uint8 cond;

      Uint8 code;

      Uint16 dummy1;

      Uint32 dummy2 [3];

    } PerKeyBoard;

function


    id --peripheral ID

    ext --Extended data size data --Button current data push --Button press data pull --Button pull data cond --Status data code --Key code dummy1 --Dummy 1

    dummy2 [3] --Dummy 2







ListReference

Structure

Per3D Pad


Sega multi controller

structure


    typedef struct {

      Uint8 id;

      Uint8 ext;

      Uint16 data;

      Uint16 push;

      Uint16 pull;

      Uint8 x;

      Uint8 y;

      Uint8 r;

      Uint8 l;

      Uint32 dummy2 [3];

    } Per3DPad;

function


    id; / * Peripheral ID * /

    ext; / * Extended data size * /

    data; / * Button current data * /

    push; / * Button press data * /

    pull; / * Button pull data * /     

    x; / * Absolute value of X-axis data * /

    y; / * Absolute value of Y-axis data * /

    r; / * Absolute value of R-axis data * /

    l; / * Absolute value of L-axis data * /

    dummy2 [3]; / * Dummy 2 * /







ListReference

Structure

DmaCpuComPrm


structure


    typedef struct {

      Uint32 pr;

      Uint32 dme;

      Uint32 msk;

    } DmaCpuComPrm;

function


    pr --Priority mode dme --DMA master enable msk --Mask bit 



ListReference

Structure

DmaCpuPrm


DMA source address transfer parameters (when using SBL function)

structure


    typedef struct {

      Uint32 sar;

      Uint32 dar;

      Uint32 tcr;

      Uint32 dm;

      Uint32 sm;

      Uint32 ts;

      Uint32 ar;

      Uint32 ie;

      Uint32 drcr;

      Uint32 msk;

    } DmaCpuPrm;

function


    sar --DMA source address dar --DMA destination address tcr --DMA transfer count dm --destination address mode bit sm --source address mode bit ts --transfer size ar --auto request mode ie --interrupt enable drcr --DMA request / response selection control msk --mask bit 



ListReference

Structure

DmaCpuComStatus


structure


    typedef struct {

      Uint32 ae;

      Uint32 nmif;

    } DmaCpuComStatus;

function


    ae --address error flag nmif --NMI flag 



ListReference

Structure

DmaScuPrm


structure


    typedef struct {

      Uint32 dxr;

      Uint32 dxw;

      Uint32 dxc;

      Uint32 dxad_r;

      Uint32 dxad_w;

      Uint32 dxmod;

      Uint32 dxrup;

      Uint32 dxwup;

      Uint32 dxft;

      Uint32 msk;

    } DmaScuPrm;

function


    dxr --read address dxw --write address dxc --number of bytes transferred dxad_r --read address addition value dxad_w --write address addition value dxmod --mode bit dxrup --read address update bit dxwup --write address update bit dxft --start factor selection bit msk --mask bit 



ListReference

Structure

DmaScuStatus


structure


    typedef struct {

      Uint32 dxmv;

    } DmaScuStatus;

function


    dxmv --DMA running flag 


★ Global variables



ListReference

Global variables

MasterStack


Bottom of master CPU stack

Form


    const void * MasterStack;

function


    The address of the stack pointer of the master SH2CPU.



ListReference

Global variables

MaxVertices


Maximum number of vertices that can be calculated

Form


    const Uint16 MaxVertices;

function


    The number of vertices that can be calculated. The SGL system does not perform calculations for calculation requests that exceed this number of vertices. The buffer size should be calculated from this value as it is used to determine if the buffer is over.



ListReference

Global variables

MaxPolygons


Maximum number of polygons that can be calculated

Form


    const Uint16 MaxPolygons;

function


    The number of polygons that can be calculated. If this upper limit is exceeded, the model data will be affected.

    No calculation is done. The buffer size should be calculated from this value as it is used to determine if the buffer is over.



ListReference

Global variables

EventSize


Event size

Form


    const Uint16 EventSize;

function


    The size of the EVENT structure. The default is 128.



ListReference

Global variables

WorkSize


Work size

Form


    const Uint16 WorkSize;

function


    The size of the WORK structure. The default is 64.



ListReference

Global variables

MaxEvents


Maximum number of events

Form


    const Uint16 MaxEvents;

function


    slGetEvent The number of events that can be done. The default is 64.



ListReference

Global variables

MaxWorks


Maximum number of works

Form


    const Uint16 MaxWorks;

function


    slGetWork The number of works that can be done. The default is 128.



ListReference

Global variables

SortList


Sprite sort buffer

Form


    const void * SortList;

function


    The start address of the buffer used to sort sprites.



ListReference

Global variables

SortListSize


Sprite data transfer request table size

Form


    const Uint32 SortListSize;

function


    The size of the buffer used to sort sprites.



ListReference

Global variables

TransList


Form


    const void * TransList;

function


    V-Blank In Queue for user transfer registration at the time of interrupt.
Since SCU DMA is used in indirect mode, be sure to adjust the area with a power of 2 that exceeds the size of the table.
Up to 20 entries.



ListReference

Global variables

Zbuffer


Z buffer

Form


    const void * Zbuffer;

function


    The Z-buffer used to sort sprites. Specify with a 4-byte boundary.



ListReference

Global variables

SpriteBuf


Sprite control data buffer

Form


    const void * SpriteBuf;

function


    A buffer for setting sprite control data. Switch between the first half and the second half of each frame.



ListReference

Global variables

SpriteBufSize


Sprite control data buffer size

Form


    const Uint32 SpriteBufSize;

function


    A buffer for setting sprite control data. Since the first half and the second half are switched for each frame, it is necessary to specify the buffer with the number of sprites (polygons) actually displayed + 5) x 36 bytes x 2 banks.



ListReference

Global variables

Pbuffer


Vertex calculation buffer

Form


    const void * Pbuffer;

function


    A buffer for coordinate transformation and perspective transformation calculations for polygon display functions.
It is not used except for the polygon display function.



ListReference

Global variables

CLOfstBuf


Color offset buffer

Form


    const void * CLOfstBuf;

function


    4 byte boundary with color offset buffer    



ListReference

Global variables

CommandBuf


Command buffer for slave delivery

Form


    const void * CommandBuf;

function


    In SGL, operation requests from the master side to the slave side are made using this buffer. The types of commands for delivery are initialization request,

    There are sprite creation requests, DMA transfer table creation requests, etc. 



ListReference

Global variables

PCM_Work


PCM work area

Form


    const void * PCM_Work;

function


    The address of the internal buffer for PCM playback.



ListReference

Global variables

PCM_WkSize


PCM work size

Form


    const Uint32 PCM_WkSize;

function


    The size of the internal buffer for PCM playback. When changing the size, specify it with a boundary of 2000H.

return
Copyright SEGA ENTERPRISES, LTD., 1997