Japanese

★Perspective



ListReference

function

slSetScreenDist


Setting distance constant to screen

Format

    #include "sgl.h"

    FIXED dist;

    void slSetScreenDist( dist );

argument

    FIXED dist - Distance constant to screen.

Return number

    void - returns nothing.    

function

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

example

    slSetScreenDist ( toFIXED ( 40.0 ) );

reference

 slWindow
 slZdspLevel
 slPerspective
 ComWrPtr
 ComRdPtr
 MsScreenDist
 Resolution
 RotScrParA
 RotScrParB 



ListReference

function

slGetFrameData


Get framebuffer data

Format

    #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.

Return number

    void - returns nothing.

function

Reads the contents of the frame buffer (one screen worth), scales it to the specified size, and sets it.
Since processing is done in units of 4 dots, the X size should be a multiple of 4.
Buffer contains 2 bytes/dot for low resolution, 1 byte/dot for high resolution So, I'll 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 );
    Executes a sprite display function with an attribute such as
slSpriteColMode ( SPR_PAL ) for high resolution; SPR_ATTRIBUTE ( PN_???, No_Palet , No_Gouraud , SPdis | ECdis | CL256Bnk , sprNoflip ); Display it with the attributes.

Note

This function waits for VDP1 to finish drawing, skips the frame buffer, and It is set in the buffer. Reading the frame buffer takes a considerable amount of time, so it takes about 5msec. for 32x24 (=768) dots. Please pay attention to the processing time when using it.
It is better to take the buffer to be read on the workpiece and transfer it to VRAM with blanking. It seems to have less weight than deploying directly to VRAM.

reference

 MsScreenSizeX
 MsScreenSizeY
 Resolution 



ListReference

function

slPerspective


Viewing volume settings

Format

    #include "sgl.h"

    ANGLE pers;

    void slPerspective( pers );

argument

    ANGLE pers - Viewing volume angle.

Return number

    void - returns nothing.

function

Set the distance constant to the screen used when performing perspective transformation.
Also sets the rotation center Z position of the rotating scroll.
The angle of view is used as the angle at which the field of view covers 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


Setting the display level

Format

    #include "sgl.h"

    Uint16 level;

    Bool slZdspLevel( level );

argument

    Uint16 level - Display level.

Return number

    Bool - FALSE if the argument contains a value other than the default value, otherwise TRUE .

function

Changes how far polygons (or sprite data) in front of the screen are displayed.
level is between 1 and 7; anything else will result in an error.
1: Display range up to 1/2 of the distance to the screen (default).
2: Display range up to 1/4 of the distance to the screen.
3: Display range up to 1/8 of the distance to the screen.
4: Display range up to 1/16 of the distance to the screen.
5: Display range up to 1/32 of the distance to the screen.
6: Display range up to 1/64 of the distance to the screen.
7: Display range up to 1/128 of the distance to the screen.
Please note that when you switch the level, the reference position of zlim specified in slWindow will also change for polygons (or sprites) displayed after that.

example

    Set the display level to 7 (1/128 of 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


drawing sprites

Format

    #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.

Return number

    Bool - Error code (described below).

function

Display the sprite by specifying its position, scale, and rotation angle.
Similar to slPutPolygon (), it also sorts by Z value.
If you specify a negative value for the scale, the scale will be calculated based on the Z position, Multiply by the complement of the scale to create the display scale.
For example, if you specify -2.0 for the scale, if it is at a position (Z position) that would be displayed at 0.5 times, it will be displayed at 1.0 times.
If the scale is zero, the sprite's display coordinate (Z) is too far away, or you try to display a sprite that exceeds the maximum display number, an error code of FALSE will be 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 ) );

Note

This function uses the slave CPU to obtain coordinate values and determine sorting.

reference

 slWindow
 slZdspLevel
 slPutSprite
 slSetSprite
 slDispSpriteHV
 slDispSpriteSZ
 slDispSprite4P
 SpritePtr
 ComWrPtr
 ComRdPtr
 MsScreenDist
 MsZlimit
 WinUseFlag
 TotalPolygons
 MXPolygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 Put Count
 SPR_ATTR
 SPR_ATTRIBUTE 



ListReference

function

slDispSpriteHV


drawing sprites

Format

    #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.

Return number

    Bool - Error code (described below).

function

Displays the deformed sprite by specifying the vertical and horizontal display scales.
Unlike the slDispSprite () function above, if you specify a negative value for the scale, the character will be displayed inverted.
If the scale is zero, the sprite display coordinate (Z) is too far away, or you try to display sprites that exceed the number of displays, an error FALSE will be 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 ) );

Note

This function uses the master CPU to obtain coordinate values and determine sorting.

reference

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



ListReference

function

slDispSpriteSZ


drawing sprites

Format

    #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.

Return number

    Bool - Error code (described below).

function

Displays the transformed sprite by specifying the vertical and horizontal display sizes.
If a negative size is specified, it will be displayed in reverse.
If you try to display a sprite whose size is zero, the display coordinate (Z) of the sprite is too far, or the number of sprites exceeds the display limit, an error FALSE will be returned.

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 ) );

Note

This function uses the master CPU to obtain coordinate values and determine sorting.

reference

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



ListReference

function

slDispSprite4P


drawing sprites

Format

    #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; - sorting criteria.
SPR_ATTR *attr; - Attribute.

Return number

    Bool - Error code (described below).

function

Specify 4 points on the screen to display the transformed sprite.
Specify the four points as offset positions from the window center, and separately specify the Z position that represents the whole.
Specify the four points in the order of top left, top right, bottom right, and bottom left (clockwise).
If any of the four points exceeds the clip range, an error code of FALSE will be 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 );

Note

This function uses the master CPU to obtain coordinate values and determine sorting.

reference

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



ListReference

function

slPutSprite


drawing sprites

Format

    #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;

Return number

    Bool - Error code (described below).

function

Calculates the position using the current matrix and displays the sprite scaled to match the perspective transformation.
Same as slDispSprite () above, it will be multiplied by the specified scale, but if you specify a negative value, it will be scaled with the sign reversed.
If the maximum number of polygons or vertices is exceeded, an error code ' FALSE ' will be 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 ) );

Note

This function uses the slave CPU to obtain coordinate values and determine sorting.

reference

 slWindow
 slZdspLevel
 slSetSprite
 slDispSprite
 slDispSpriteSZ
 slDispSprite4P
 slDispSpriteHV
 SpritePtr
 ComWrPtr
 ComRdPtr
 MsScreenDist
 MsZlimit
 MXPolygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 Put Count
 SPR_ATTR
 SPR_ATTRIBUTE 



ListReference

function

slSetSprite


drawing sprites

Format

    #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.

Return number

    Bool - Error code (described below).

function

Set the sprite control command data to be passed to the hardware in the transfer list.
Use this when you want to create deformed sprites that cannot be created using library functions, or when you want to set a window that only affects a specific sprite.
If the maximum number of polygons is exceeded or the Z clipping boundary is exceeded, an error code of FALSE will be returned.

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 ) );

Note

This function uses the slave CPU for sorting decisions.

reference

 slWindow
 slZdspLevel
 slPutSprite
 slDispSprite
 slDispSpriteSZ
 slDispSprite4P
 slDispSpriteHV
 SpritePtr
 ComWrPtr
 ComRdPtr
 MsScreenDist
 MsZlimit
 WinUseFlag
 TotalPolygons
 MXPolygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 Put Count
 SPRITE 


★Window



ListReference

function

slWindow


Sprite window settings

Format

    #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 - right edge of the window.
Sint16 top - top edge of the window.
Sint16 right - left edge of the window.
Sint16 bottom - Bottom edge of the window.
Uint16 zlim - Z limit.
Sint16 cen_x - X coordinate of the vanishing point (coordinate origin).
Sint16 cen_y - Y coordinate of the vanishing point (coordinate origin).

Return number

    Bool - Error code (described 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 two times during display.
zlim will no longer be displayed beyond this point.
cen_x, cen_y are the vanishing point position for polygons, and the coordinate origin for sprites.
The position on the screen is (0, 0) at the top left and (319, 223) at the bottom right is.
When the total number of windows is 3 or more, the function returns FALSE . Returns TRUE if successful.

example

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

Note

slPutPolygon () before calling slWindow (), When you use functions that set sprites, such as slPutSprite (), they use a full-screen window, and a second window is set with a new call to slWindow ().
Usually slWindow (...) ; /* Window 1 */ ... slPutPolygon (...); slPutSprite (...); ... slWindow (...) ; /* Window 2 */ ... slPutSprite (...); slPutPolygon (...); Set a window at the beginning of the process, and then set another window again at the point where you want to switch.

reference

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



ListReference

function

slCurWindow


Switching windows

Format

    #include "sgl.h"

    Uint8 win;

    void slCurWindow( win );

argument

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

Return number

    void - returns nothing.

function

Switch the displayed window.
For win, specify either winFar (back side) or winNear (front side).
When you execute this function, the screen position and display area are set, but Please note that the light vector will not change.

example

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

reference

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



ListReference

function

slSprWinNum


Get window number

Format

    #include "sgl.h"

    Uint8 slSprWinNum( void );

argument

    void - gives nothing.

Return number

    Uint8 - Window number used for display.

function

Returns the window number used for display.

example

    Uint8 winno;

    winno = slSprWinNum ();

reference

 slWindow
 slCurWindow
 Window Number 



ListReference

function

slFrameClipSize


Specifying clipping size

Format

    #include "sgl.h"

    Sint16 size_x, size_y;

    void slFrameClipSize( size_x, size_y );

argument

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

Return number

    void - returns nothing.

function

Sprite display functions slDispSprite , slDispSpriteHV , slDispSpriteSZ , slDispSprite4P , slPutSprite and Sets the range to display polygons with the UseClip option specified.
Points outside the window size plus the specified widths on the top, bottom, left, and right will be hidden.

example

    slFrameClipSize ( 10, 5, 190, 200 );

reference

 slInitSystem
 slWindow
 Window Number
 MsWindowSizeX
 MsWindowSizeY
 FrameSizeX
 FrameSizeY
 SlClipXAdder
 SlClipYAdder 


★Slave activity status



ListReference

function

slCheckSlave


Check slave activity status

Format

    #include "sgl.h"

    Bool slCheckSlave( void )

argument

    void - gives nothing.

Return number

    Bool - Slave status (see below).

function

Check the operating status of the slave.

example

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

Note

This function is used to check whether the calculations of sprite/polygon drawing functions that require perspective transformation and geometry calculations have been completed, and are not used to check the behavior of the functions set by the user with slSlaveFunc .

reference

 slPutPolygon
 slPutPolygonS
 slDispPolygon
 slPutObject
 slPutSprite
 slDispSprite
 slDispSpriteSZ
 slDispSprite4P
 slDispSpriteHV
 slPutPolygonX

return
Copyright SEGA ENTERPRISES, LTD., 1997