★ Perspective



ListReference

function

slSetScreenDist


Setting the distance constant to the screen

Form

    #include "sgl.h"

    FIXED dist;

    void slSetScreenDist (dist);

argument

    FIXED dist --Constant distance to the screen.

Number of returns

    void --Nothing is returned.    

function

    Set the distance constant to the screen used for perspective transformation.
Also sets the Z position of the rotation center of the rotation scroll.

Example

    slSetScreenDist ( toFIXED (40.0));

reference

 slWindow
 slZdspLevel
 slPerspective
 ComWrPtr
 ComRdPtr
 MsScreenDist
 Resolution
 RotScrParA
 RotScrParB 



ListReference

function

slGetFrameData


Get framebuffer data

Form

    #include "sgl.h"

    void * dist;
    Uint16 size_x;
    Uint16 size_y;

    void slGetFrameData (dist, size_x, size_y);

argument

    void * dist- 
    Uint16 size_x --X size after being read.
Uint16 size_y --Y size after being read.

Number of returns

    void --Nothing is returned.

function

    Reads the contents of the frame buffer (for one screen), scales (thinns) to the specified size, and sets it.
Since it is processed in units of 4 dots, the X size is a multiple of 4.
The buffer has 2 bytes / dot for low resolution and 1 byte / dot for high resolution. And write.

Example

    If you want to display the read data as a sprite,
    Low resolution:
      slSpriteColMode ( SPR_PAL_RGB ); / * default * /
    year,
      SPR_ATTRIBUTE (PN_???, No_Palet , No_Gouraud , SPdis | ECdis | CL32KRGB ,
        sprNoflip );
    Execute the sprite display function with attributes such as.
For high resolution slSpriteColMode ( SPR_PAL ); SPR_ATTRIBUTE (PN_???, No_Palet , No_Gouraud , SPdis | ECdis | CL256Bnk , sprNoflip ); It is displayed by the attribute of.

caution


    This function waits for VDP1 to finish drawing, skips the frame buffer, and
    It is set in the buffer. Since reading the frame buffer has a considerable weight, it takes about 5 msec. At 32x24 (= 768) dots.
    Please use it paying attention to the processing time.
It is better to take the buffer to be read on the work and transfer it to VRAM by blanking. It seems to have less weight than deploying directly to VRAM.

reference

 MsScreenSizeX
 MsScreenSizeY
 Resolution 



ListReference

function

slPerspective


Viewing volume settings

Form

    #include "sgl.h"

    ANGLE pers;

    void slPerspective (pers);

argument

    ANGLE pers-The angle of the viewing volume.

Number of returns

    void --Nothing is returned.

function

    Set the distance constant to the screen used for perspective transformation.
Also sets the Z position of the rotation center of the rotation scroll.
The angle of view is used as the angle at which the field of view fits into the width of the screen (not the size of the window).

Example

    slPerspective ( DEGtoANG (60.0));

reference

 slWindow
 slZdspLevel
 slSetScreenDist
 ComWrPtr
 ComRdPtr
 MsScreenDist
 SlScreenDist
 MsScreenSizeX
 MsScreenSizeY
 RotScrParA
 RotScrParB 


★ Display limit



ListReference

function

slZdspLevel


Display level setting

Form

    #include "sgl.h"

    Uint16 level;

    Bool slZdspLevel (level);

argument

    Uint16 level --Display level.

Number of returns

    Bool - If you put a non-specified value to the argument FALSE , otherwise TRUE .

function

    Switches how far the polygon (or sprite data) in front of the screen is displayed.
level is one of 1 to 7, otherwise an error will occur.
1: Set the display range up to 1/2 of the distance to the screen (default).
2: The display range is up to 1/4 of the distance to the screen.
3: The display range is up to 1/8 of the distance to the screen.
4: The display range is up to 1/16 of the distance to the screen.
5: The display range is up to 1/32 of the distance to the screen.
6: Set the display range up to 1/64 of the distance to the screen.
7: The display range is up to 1/128 of the distance to the screen.
For the polygon (or sprite) to be displayed in the subsequent when you switch level, SlWindow so will also change in the same way a reference position of the specified zlim in, please be careful.

Example

    Set the display level to 7 (1/128 to the screen distance).
slZdspLevel (7);

reference

 slPutPolygon
 slPutPolygonS
 slPutPolygonX
 slDispPolygon
 slPutSprite
 slSetSprite
 slDispSprite
 slDispSpriteHV
 slDispSpriteSZ
 slDispSprite4P
 slWindow
 slPutObject
 ComWrPtr
 ComRdPtr
 SlZlimit 


★ Sprite drawing function



ListReference

function

slDispSprite


Sprite drawing

Form

    #include "sgl.h"

    FIXED pos [ XYZS ];
    ATTR * attr;
    ANGLE z_ang;

    Bool slDispSprite (pos, atrb, z_ang);

argument

    FIXED pos [ XYZS ] --Sprite position.
ATTR * attr --Sprite attributes.
ANGLE z_ang --Sprite rotation angle.

Number of returns

    Bool --Error code (see below).

function

    Specify the position, scale, and angle of rotation to display the sprite.
Similar to slPutPolygon (), it also sorts by Z value.
If a negative value is specified for the scale, the scale will be calculated based on the Z position. Multiply the scale complement to get the scale for display.
For example, if you specify -2.0 for the scale and it is in a position (Z position) where it is displayed at 0.5 times, it will be displayed at 1.0 times.
If the scale is zero, the sprite's display coordinates (Z) are too far, or an attempt is made to display a sprite that exceeds the maximum display number, the error code FALSE is returned.

Example

    FIXED pos [ XYZS ] = {
      toFIXED (0.0), toFIXED (0.0), toFIXED (110.0), toFIXED ( ORIGINAL )
    };
    SPR_ATTR attr = SPR_ATTRIBUTE (0, 0, No_Gouraud , CL16Bnk , sprNoflip | _ZmCC );

    slDispSprite (pos, attr, DEGtoANG (0.0));

caution


    This function uses the slave CPU to get the coordinate values and determine the sort.

reference

 slWindow
 slZdspLevel
 slPutSprite
 slSetSprite
 slDispSpriteHV
 slDispSpriteSZ
 slDispSprite4P
 SpritePtr
 ComWrPtr
 ComRdPtr
 MsScreenDist
 MsZlimit
 WinUseFlag
 TotalPolygons
 MX Polygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount
 SPR_ATTR
 SPR_ATTRIBUTE 



ListReference

function

slDispSpriteHV


Sprite drawing

Form

    #include "sgl.h"

    FIXED pos [ XYZSS ];
    ATTR * attr;
    ANGLE z_ang;

    Bool slDispSpriteHV (pos, attr, z_ang);

argument

    FIXED pos [ XYZSS ] --Sprite position.
ATTR * attr --Sprite attributes.
ANGLE z_ang --Sprite rotation angle.

Number of returns

    Bool --Error code (see below).

function

    Display the deformed sprite by specifying the vertical and horizontal display scales.
Unlike the slDispSprite () function above, if you specify a negative scale, the character will be highlighted.
If the scale is zero, the sprite's display coordinates (Z) are too far, or an attempt is made to display a sprite that exceeds the number displayed, the error FALSE is returned.

Example

    #define FX0 toFIXED (0.0)

    FIXED pos [ XYZSS ] = {
      FX0, FX0, toFIXED (110.0), toFIXED ( ORIGINAL ), toFIXED (2.0)
    };
    SPR_ATTR attr = SPR_ATTRIBUTE (0, 0, No_Gouraud , CL16Bnk , sprNoflip | _ZmCC );

    slDispSpriteHV (pos, attr, DEGtoANG (0.0));

caution


    This function uses the master CPU to get the coordinate values and determine the sort.

reference

 slWindow
 slZdspLevel
 slPutSprite
 slSetSprite
 slDispSprite
 slDispSpriteSZ
 slDispSprite4P
 SpritePtr
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount
 SPR_ATTR
 SPR_ATTRIBUTE 



ListReference

function

slDispSpriteSZ


Sprite drawing

Form

    #include "sgl.h"

    FIXED pos [ XYZSS ];
    ATTR * attr;
    ANGLE z_ang;

    Bool slDispSpriteSZ (pos, attr, ang_z);

argument

    FIXED pos [ XYZSS ] --Sprite position.
ATTR * attr --Sprite attributes.
ANGLE z_ang --Sprite rotation angle.

Number of returns

    Bool --Error code (see below).

function

    Display the deformed sprite by specifying the vertical and horizontal display sizes.
If a negative size is specified, it will be displayed in reverse.
Returns error FALSE if the size is zero, the sprite's display coordinates (Z) are too far, or if you try to display more sprites than the number displayed.

Example

    #define FX0 toFIXED (0.0)

    FIXED pos [ XYZSS ] = {
      toFIXED (30.0), FX0, toFIXED (110.0), toFIXED (0.5), toFIXED (2.0)
    };
    SPR_ATTR attr = SPR_ATTRIBUTE (0, 0, No_Gouraud , CL16Bnk [a], sprNoflip | _ZmCC );

    slDispSpriteSZ (pos, attr, DEGtoANG (0.0));

caution


    This function uses the master CPU to get the coordinate values and determine the sort.

reference

 slWindow
 slZdspLevel
 slPutSprite
 slSetSprite
 slDispSprite
 slDispSpriteHV
 slDispSprite4P
 SpritePtr
 FrameSizeX
 FrameSizeY
 MsClipXAdder
 MsClipYAdder
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount
 SPR_ATTR
 SPR_ATTRIBUTE 



ListReference

function

slDispSprite4P


Sprite drawing

Form

    #include "sgl.h"

    FIXED pos [4] [ XY ];
    FIXED pos_z;
    SPR_ATTR * attr;

    Bool slDispSprite4P (pos, pos_z, attr);

argument

    FIXED pos [4] [ XY ] --Coordinates of 4 vertices.
FIXED pos_z; --Sort reference value.
SPR_ATTR * attr; --Attribute.

Number of returns

    Bool --Error code (see below).

function

    Specify 4 points on the screen to display the deformed sprite.
The four points are specified by the offset position with respect to the center of the window, and the Z position that represents the whole is specified separately.
Specify the 4 points in the order of upper left, upper right, lower right, lower left (clockwise).
If any of the four points exceed the range of the clip, the error code FALSE is returned.

Example

    FIXED pos [4] [ XY ] = {
      { toFIXED (0.0), toFIXED (0.0)},
      { toFIXED (40.0), toFIXED (10.0)},
      { toFIXED (70.0), toFIXED (60.0)},
      { toFIXED (10.0), toFIXED (50.0)}
    };
    SPR_ATTR attr = SPR_ATTRIBUTE (2, 0x100, No_Gouraud , CL16Bnk , 
                                  sprNoflip | _ZmCC );

    slDispSprite4P (pos, toFIXED (150.0), attr);

caution


    This function uses the master CPU to get the coordinate values and determine the sort.

reference

 slWindow
 slZdspLevel
 slPutSprite
 slSetSprite
 slDispSprite
 slDispSpriteSZ
 slDispSpriteHV
 SpritePtr
 FrameSizeX
 FrameSizeY
 MsClipXAdder
 MsClipYAdder
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount
 SPR_ATTR
 SPR_ATTRIBUTE 



ListReference

function

slPutSprite


Sprite drawing

Form

    #include "sgl.h"

    FIXED pos [ XYZS ];
    ATTR * attr;
    ANGLE ang_z;

    Bool slPutSprite (pos, attr, ang_z);

argument

    FIXED pos [ XYZS ];
    ATTR * attr;
    ANGLE ang_z;

Number of returns

    Bool --Error code (see below).

function

    Calculates the position using the current matrix and displays the sprite scaled to the perspective transformation.
Similar to slDispSprite () above, it will be scaled by the specified scale, but if you specify minus, it will be scaled with sign inversion.
If the maximum number of polygons or the maximum number of vertices is exceeded, the error code'FALSE'is returned.

Example

    FIXED pos [ XYZS ] = {
      toFIXED (0.0), toFIXED (0.0), toFIXED (110.0), toFIXED ( ORIGINAL )
    };
    SPR_ATTR attr = SPR_ATTRIBUTE (0, 0, No_Gouraud , CL16Bnk , sprNoflip | _ZmCC );

    slPutSprite (pos, attr, DEGtoANG (0.0));

caution


    This function uses the slave CPU to get the coordinate values and determine the sort.

reference

 slWindow
 slZdspLevel
 slSetSprite
 slDispSprite
 slDispSpriteSZ
 slDispSprite4P
 slDispSpriteHV
 SpritePtr
 ComWrPtr
 ComRdPtr
 MsScreenDist
 MsZlimit
 MX Polygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount
 SPR_ATTR
 SPR_ATTRIBUTE 



ListReference

function

slSetSprite


Sprite drawing

Form

    #include "sgl.h"

    SPRITE * spr;
    FIXED pos_z;

    Bool slSetSprite (spr, pos_z);

argument

    SPRITE * spr --VDP1 command data to display.
FIXED pos_z --Criteria for sorting.

Number of returns

    Bool --Error code (see below).

function

    Sets the sprite control command data to be passed to the hardware in the transfer list.
Use this when you want to set a modified sprite that cannot be created by a library function, or a window that affects only a specific sprite.
Returns the error code FALSE if the maximum number of polygons is exceeded or if it is used beyond the Z clipping boundary.

Example

    SPRITE attr = {
      FUNC_Sprite , / * Drawing Sprite * /
      0, / * Link (Ignore) * /
      ECdis | SPenb | CL16Look | CL_Trans , / * Color mode. * /
      (0x1b000 >> 3), / * Color bank number. * /
      (0x12400 >> 3), / * Character address. * /
      ((64/8) << 8 | 96), / * Character size ((x / 8) << 8 | y) * /
      0, / * A (x) * /
      0, / * A (y) * /
      64, / * B (x) * /
      0, / * B (y) * /
      64, / * C (x) * /
      96, / * C (y) * /
      0, / * D (x) * /
      96, / * D (y) * /
      0, / * Gouraud table address * /
      0 / * Dummy. * /
    };

    slSetSprite (attr, toFIXED (145.0));

caution


    This function uses the slave CPU to determine the sort.

reference

 slWindow
 slZdspLevel
 slPutSprite
 slDispSprite
 slDispSpriteSZ
 slDispSprite4P
 slDispSpriteHV
 SpritePtr
 ComWrPtr
 ComRdPtr
 MsScreenDist
 MsZlimit
 WinUseFlag
 TotalPolygons
 MX Polygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount
 SPRITE 


★ Window



ListReference

function

slWindow


Sprite window settings

Form

    #include "sgl.h"

    Sint16 left, top, right, bottom;
    Uint16 zlim;
    Sint16 cen_x, cen_y;

    Bool slWindow (left, top, right, bottom, zlim, cen_x, cen_y);

argument

    Sint16 left --The right edge of the window.
Sint16 top --The top of the window.
Sint16 right --The left edge of the window.
Sint16 bottom --The bottom of the window.
Uint16 zlim --Z limit.
Sint16 cen_x --X coordinate of vanishing point (coordinate origin).
Sint16 cen_y --Y coordinate of vanishing point (coordinate origin).

Number of returns

    Bool --Error code (see below).

function

    Set the range to limit the display of sprites and polygons.
The display range is the position on the TV screen and can be specified up to twice during display.
zlim will not be displayed beyond this.
cen_x and cen_y are the vanishing point positions for polygons and the coordinate origins for sprites.
The position on the screen is (0, 0) in the upper left and (319, 223) in the lower right <normal screen size> is.
When the total number of windows is 3 or more, FALSE is returned as the return value of the function. If successful, TRUE will be returned.

Example

    The upper left coordinate (10,15) and lower right coordinate (300,195) of the window, the vanishing point is the center of this window, and the Z limit value is 5000h.
slWindow (10, 15, 300, 195, 0x5000, 145, 75); See also the note below.

caution


    slPutPolygon (), before calling slWindow ()
    If you use a sprite-setting function such as slPutSprite (), they will use a full-screen window, and the second window will be set by the renamed slWindow ().
Usually slWindow (...); / * Window 1 * / ... slPutPolygon (...); slPutSprite (...); ... slWindow (...); / * Window 2 * / ... slPutSprite (...); slPutPolygon (...); Set the window at the beginning of the process, and set another window again where you want to switch.

reference

 slPutPolygon
 slPutPolygonS
 slPutPolygonX
 slDispPolygon
 slPutSprite
 slSetSprite
 slDispSprite
 slDispSpriteHV
 slDispSpriteSZ
 slDispSprite4P
 slZdspLevel
 slCurWindow
 slSprWinNum
 ComWrPtr
 ComRdPtr
 MsZlimit
 WindowNumber
 WinUseFlag
 TotalPolygons
 MsScreenLeft
 MsScreenTop
 MsScreenRight
 MsScreenBottom
 MsWindowSizeX
 MsWindowSizeY
 FrameSizeX
 FrameSizeY
 MsWinXAdder
 MsWinYAdder
 SlWinXAdder
 SlWinYAdder
 MsClipXAdder
 MsClipYAdder
 SlClipXAdder
 SlClipYAdder 



ListReference

function

slCurWindow


Window switching

Form

    #include "sgl.h"

    Uint8 win;

    void slCurWindow (win);

argument

    Uint8 win --Type of window to switch to (see below).

Number of returns

    void --Nothing is returned.

function

    Switch the window to display.
For win, specify either winFar (back side) or winNear (front side).
When this function is executed, the screen position and display area will be set. Note that the light source vector does not change.

Example

    Move the window to be displayed to the back.
slCurWindow ( winFar );

reference

 slWindow
 slSprWinNum
 ComWrPtr
 ComRdPtr
 MsScreenDist
 WindowNumber
 MsScreenLeft
 MsScreenTop
 MsScreenRight
 MsScreenBottom
 MsWindowSizeX
 MsWindowSizeY
 MsWinXAdder
 MsWinYAdder
 SlWinXAdder
 SlWinYAdder
 MsClipXAdder
 MsClipYAdder
 SlClipXAdder
 SlClipYAdder
 SlZlimit 



ListReference

function

slSprWinNum


Get window number

Form

    #include "sgl.h"

    Uint8 slSprWinNum (void);

argument

    void --Do not give anything.

Number of returns

    Uint8 --The window number used for display.

function

    Returns the window number used for display.

Example

    Uint8 winno;

    winno = slSprWinNum ();

reference

 slWindow
 slCurWindow
 WindowNumber 



ListReference

function

slFrameClipSize


Specify clipping size

Form

    #include "sgl.h"

    Sint16 size_x, size_y;

    void slFrameClipSize (size_x, size_y);

argument

    Sint16 size_x --The X size of the clip.
Sint16 size_y --Y size of the clip.

Number of returns

    void --Nothing is returned.

function

    Sprite display functions slDispSprite , slDispSpriteHV ,
    slDispSpriteSZ , slDispSprite4P , slPutSprite ,
    Sets the range in which polygons with the UseClip option are displayed.
Hides points outside the area where the specified width is added to the top, bottom, left, and right of the window size.

Example

    slFrameClipSize (10, 5, 190, 200);

reference

 slInitSystem
 slWindow
 WindowNumber
 MsWindowSizeX
 MsWindowSizeY
 FrameSizeX
 FrameSizeY
 SlClipXAdder
 SlClipYAdder 


★ Slave activity status



ListReference

function

slCheckSlave


Slave activity status check

Form

    #include "sgl.h"

    Bool slCheckSlave (void)

argument

    void --Do not give anything.

Number of returns

    Bool --Slave status (see below).

function

    Check the operating status of the slave.

Example

    Wait for the slave task (geometry calculation) to finish, then
    Call slSynch .
while ( slCheckSlave ()! = TRUE ); slSynch ();

caution


    This function knows whether the calculation of the sprite / polygon drawing function that requires perspective transformation and geometry calculation is completed, and does not check the operation of the function set by the user with slSlaveFunc. 

reference

 slPutPolygon
 slPutPolygonS
 slDispPolygon
 slPutObject
 slPutSprite
 slDispSprite
 slDispSpriteSZ
 slDispSprite4P
 slDispSpriteHV
 slPutPolygonX

return
Copyright SEGA ENTERPRISES, LTD., 1997