Japanese

ListReference

macro

MAX


returns the larger of the two

Format

    #include "sl_def.h"

    MAX( a, b );

argument

    a, b : numbers of any type

Return number

    The larger of a and b

function

    It is declared as follows.
#define MAX(x, y) ((x) > (y) ? (x) : (y))



ListReference

macro

MIN


returns the smaller of the two

Format

    #include "sl_def.h"

    MIN( a, b );

argument

    a, b : numbers of any type

Return number

    The smaller of a and b

function

    It is declared as follows.
#define MIN(x, y) ((x) < (y) ? (x) : (y))



ListReference

macro

ABS


take absolute value

Format

    #include "sl_def.h"

    ABS( a );

argument

    a : number of any type

Return number

    Absolute value of a.

function

    #define ABS(x) ((x) < 0 ? -(x) : (x))




ListReference

macro

toFIXED


Convert integer to fixed decimal

Format

    #include "sl_def.h"

    toFIXED ( a );

argument

    a: Number of integer type (variable/constant/number can be any)

Return number

    SGL fixed decimal type (FIXED) number

function

    #define toFIXED (a) (( FIXED )(65536.0 * (a)))




ListReference

macro

POStoFIXED


Convert integer to fixed decimal

Format

    #include "sl_def.h"

    POStoFIXED( a, b, c );

argument

    a, b, c: Integer type number (variables/constants/numbers can be any)

Return number

    Array of SGL fixed decimal type ( FIXED ) numbers ( POINT type, etc.)

function

    #define POStoFIXED(x,y,z) { toFIXED (x), toFIXED (y), toFIXED (z)}




ListReference

macro

ATTRIBUTE


Format

    #include "sl_def.h"

    ATTRIBUTE( plane, sort, tex, col, gouraud, mode, dir, opt );

argument

    plane - Double-sided display or single-sided display (described later)
    sort - reference point for sorting (described later)
    tex - texture number (described later)
    col - Color palette number (described later)
    gouraud - Gouraud shading table for user Gouraud (described later)
    mode - polygon attribute (described later)
    dir - How to draw polygons (described later)
    opt - options (see below)

function

    #define ATTRIBUTE(f,s,t,c,g,a,d,o) ¥
          {f,(s)|(((d)>>16)&0x1c)|(o),t,(a)|(((d)>>24)&0xc0),c,g,(d)&0x3f}
    The argument value list is as follows:
plane Single_Plane : Single-plane (direction of normal vector) display.
Dual_Plane : Double-sided display.
sort SORT_MIN : Based on the nearest vertex.
SORT_CEN : Based on the average value of 4 vertices.
SORT_MAX : Based on the farthest vertex.
SORT_BFR : Display in front of the previous polygon.
tex No_Texture : No texture is pasted.
Uint16 value: Texture number.
col No_Palet : Do not use a palette. (If the texture is in RGB mode.) Uint16 value: Color code when tex is No_Texture .
Otherwise, the pallet number.
gouraud No_Gouraud : Do not use user Gouraud shading.
Uint16 value: Gouraud shading table address Expressed as an 8-byte boundary from the beginning of VDP1's VRAM.
mode Specify 0 or 1 entry from each group below using "|".
group 1 MSBoff : Do not write MSB when writing to frame buffer (default).
MSBon : Set MSB when writing to frame buffer.
group 2 No_Window : Not subject to window constraints. (default) Window_In : Display inside the window.
Window_Out : Display outside the window.
group 3 HSSoff : Does not apply high speed shrink. (default) HSson : Apply high speed shrink.
group 4 MESHoff : Does not apply mesh. (default) MESHon : Apply mesh.
group 5 ECdis : Disable end code. (default) ECenb : Enable end code.
group 6 SPdis : Transparent pixel display. (default) SPenb : Transparent pixels disabled.
group 7 CL16Bnk : 16-color color bank mode. (default) CL16Look : Color lookup mode.
CL64Bnk : 64 color color bank mode.
CL128Bnk : 128 color color bank mode.
CL256Bnk : 256 color color bank mode.
CL32KRGB : RGB mode.
group 8 CL_Replace : Normal drawing mode. (default) CL_Shadow : Shadow mode.
CL_Half : Half brightness mode.
CL_Trans : Translucent mode.
CL_Gouraud : User Gouraud shading mode.
dir sprNoflip : Normal display.
sprHflip : Horizontally flipped display.
sprVflip : Display upside down.
sprHVflip : Flip the display vertically and horizontally.
sprPolygon : No texture.
sprPolyLine : Polyline display.
opt UseLight : Perform flat shading.
UseNearClip : Perform near clipping processing.
UsePalette : Palette display.
UseDepth : Perform depth cueing.
UseGouraud : Perform real-time Gouraud processing.
No_Option : No special processing is performed.

example

    ATTR attr;
    attr = ATTRIBUTE ( Single_Plane , 5, 0, No_Gouraud , CL16Bnk ,
                      sprNoflip , UseNearClip );




ListReference

macro

SPR_ATTRIBUTE


Format

    #include "sl_def.h"

    SPR_ATTRIBUTE( tex, col, gouraud, mode, dir );

argument

    tex - pattern number (described later)
    col - Color palette number (described later)
    gouraud - Gouraud shading table for user Gouraud (described later)
    mode - sprite attribute (described later)
    dir - How to draw sprites (described later)

function

    #define SPR_ATTRIBUTE(t,c,g,a,d) {t,(a)|(((d)>>24)&0xc0),c,g,(d)&0x0f3f}

    The argument value list is as follows:
tex No_Texture : Single color sprite.
Uint16 value: pattern number.
col No_Palet : Do not use a palette. (For RGB mode.) Uint16 value: Color code when tex is No_Texture .
Otherwise, the pallet number.
gouraud No_Gouraud : Do not use user Gouraud shading.
Uint16 value: Gouraud shading table address Expressed as an 8-byte boundary from the beginning of VDP1's VRAM.
mode Specify 0 or 1 entry from each group below using "|".
group 1 MSBoff : Do not write MSB when writing to frame buffer (default).
MSBon : Set MSB when writing to frame buffer.
group 2 No_Window : Not subject to window constraints. (default) Window_In : Display inside the window.
Window_Out : Display outside the window.
group 3 HSSoff : Does not apply high speed shrink. (default) HSson : Apply high speed shrink.
group 4 MESHoff : Does not apply mesh. (default) MESHon : Apply mesh.
group 5 ECdis : Disable end code. (default) ECenb : Enable end code.
group 6 SPdis : Transparent pixel display. (default) SPenb : Transparent pixels disabled.
group 7 CL16Bnk : 16-color color bank mode. (default) CL16Look : Color lookup mode.
CL64Bnk : 64 color color bank mode.
CL128Bnk : 128 color color bank mode.
CL256Bnk : 256 color color bank mode.
CL32KRGB : RGB mode.
group 8 CL_Replace : Normal drawing mode. (default) CL_Shadow : Shadow mode.
CL_Half : Half brightness mode.
CL_Trans : Translucent mode.
CL_Gouraud : User Gouraud shading mode.
dir Select one from each of the following two groups and specify it using "|".
group 1 sprNoflip : Normal display.
sprHflip : Horizontally flipped display.
sprVflip : Display upside down.
sprHVflip : Flip the display vertically and horizontally.
sprPolygon : Single color sprite.
sprPolyLine : Polyline display.
group 2 _ZmLT : Set the center point at the top left when enlarging.
_ZmLC : Set the center point when enlarging to the center left.
_ZmLB : Set the center point at the bottom left when enlarging.
_ZmCT : Set the center point at the top of the center when enlarging.
_ZmCC : Center the center point when enlarging.
_ZmCB : Set the center point at the bottom of the center when enlarging.
_ZmRT : Set the center point at the top right when enlarging.
_ZmRC : Set the center point when enlarging to the center right.
_ZmRB : Set the center point at the bottom right when enlarging.



ListReference

macro

DEGtoANG


Format

    #include "sl_def.h"

    DEGtoANG( a );

argument

    a: Number of integer type (variable/constant/number can be any)

Return number

    SGL angle type ( ANGLE ) numerical value

function

    #define DEGtoANG(d) (( ANGLE )((65536.0 * (d)) / 360.0))




ListReference

macro

RADtoANG


Format

    #include "sl_def.h"

    RADtoANG( a );

argument

    a: Number of integer type (variable/constant/number can be any)

Return number

    SGL angular type ( ANGLE ) numerical value

function

    #define RADtoANG(d) (( ANGLE )((65536.0 * (d)) / (2* M_PI )))




ListReference

macro

RGB


Convert R, G, B individual values to Saturn color code (15 bit)

Format

    #include "sl_def.h"

    RGB( r, g, b );

argument

    r : Red integer value g : Green integer value b : Blue integer value

Return number

    15-bit Saturn color code.

function

    #define RGB(r,g,b) (0x8000|((b)<<10)|((g)<<5)|(r))




ListReference

macro

DGTtoRGB


Format

    #include "sl_def.h"

    DGTtoRGB( a );

argument

    a : RGB value in SEGA DGT format.

Return number

    15-bit Saturn color code.

function

    #define DGTtoRGB(c) (0x8000|(((c)&0x0f00)<<3)|(((c)&0x4000)>>4)|\
                           (((c)&0x00f0)<<2)|(((c)&0x2000)>>8)|(((c)&0x000f)¥
                           <<1)|(((c)&0x1000)>>12))




ListReference

macro

SLocate


Find cell position address on page

Format

    #include "sl_def.h"

    SLocate( page, x, y );

argument

    page : Page number.
x, y: x,y position of the cell.

Return number

    cell address

function

    #define SLocate(SLocax,y,p) ((p) * Page + (y) * Line + (x))



ListReference

macro

NORMAL


Format

    #include "sgl.h"

    NORMAL( x, y, z );

argument

    x, y, z: Any number (integer/float) representing the normal vector

Return number

    Array of SGL fixed decimal type ( FIXED ) numbers ( POINT type, etc.)

function

    #define NORMAL(x,y,z) { POStoFIXED (x,y,z)}




ListReference

macro

VERTICES


Array the four vertex index data (for vertex data description)

Format

    #include "sgl.h"

    VERTICES( a, b, c, d );

argument

    a, b, c, d: Index in 3D vertex data table expressed as POINT type etc.

Return number

    Quaternary array of indexes

function

    #define VERTICES(v0,v1,v2,v3) {v0 , v1 , v2 , v3}}




ListReference

macro

C_RGB


Convert R,G,B data to RGB data for VDP1

Format

    #include "sgl.h"

    C_RGB( r, g, b );

argument

    r: Data representing any type of red color.
g : Data representing any type of green color.
b: Data representing any type of blue color.

Return number

    Direct color data in VDP1 RGB format.

function

    #define C_RGB(r,g,b) (((b)&0x1f)<<10|((g)&0x1f)<<5|((r)&0x1f)|0x8000)




ListReference

macro

TEXDEF


Format

    #include "sgl.h"

    TEXDEF( h_size, v_size, addr );

argument

    h_size: Horizontal size of texture (dots)
    v_size: Texture vertical size (dots)
    addr: VRAM address with texture data

Return number

    TEXTURE type structure data

function

    #define TEXDEF(h,v,presize) {h,v,( cgaddress +(((presize)*4)>>( pal )))/8,¥
                                   (((h)&0x1f8)<<5 | (v))}

Note


    This macro is kept for compatibility with older versions.
Please use TEXTBL , which has the same functionality as this macro.



ListReference

macro

PICDEF


Format

    #include "sgl.h"

    PICDEF( tex_no, col_mode, src )

argument

    tex_no: Texture number.
col_mode :Color mode ( COL_16 , COL_256 , etc.) src: Address containing the original texture data.

Return number

    PICTURE type structure data

function

    #define PICDEF (texno,cmode,pcsrc){( Uint16 )(texno),( Uint16 )(cmode),\
                      (void *)(pcsrc)}

Note


    This macro is kept for compatibility with older versions.
Please use PICTBL , which has the same functionality as this macro.



ListReference

macro

AdjCG


Find the address of the texture data to be stored in VDP1

Format

    #include "sgl.h"

    AdjCG( adr, h, v, col )

argument

    adr: Start address of previous character h, v: Horizontal and vertical size (dots) of previous character
    col: Color mode of previous character ( COL_16 , COL_256 , etc.)

Return number

    the top address of that character

function

    #define AdjCG(cga,hs,vs,col) ((cga) +(((((hs)*(vs)*4)>>(col))+0x1f)\
                                     &0x7ffe0))

example

    enum cga{
       CG_Top = CGADDRESS ,
       CG_Second = AdjCG ( CG_Top, 16, 8, COL_16 ),
       CG_Third = AdjCG ( CG_Second, 32, 32, COL_256 )
    };
    CG_Second contains
    CGADDRESS + ( 16 / 2 ) * 8 = 0x25c00040
                  ^ ^^^ ^
           Horizontal size | Vertical size Contains 16 color banks of color modes.



ListReference

macro

TEXTBL


Format

    #include "sgl.h"

    TEXTBL( h, v, addr );

argument

    h, v: Texture horizontal and vertical size addr: VRAM address with texture data

Return number

    TEXTURE type structure

function

    #define TEXTBL(hs,vs,cga) {hs , vs , (cga)>>3 , ((hs)&0x1f8)<<5|(vs)}




ListReference

macro

PICTBL


Format

    #include "sgl.h"

    PICTBL( tex, col_mode, addr );

argument

    tex_no: Texture number col_mode: Texture color mode src: Original address of texture data (not necessarily on VDP1's VRAM)

Return number

    PICTURE type structure

function

    #define PICTBL(texno,cmode,pcsrc) {( Uint16 )(texno),( Uint16 )(cmode),¥
                                         (void *)(pcsrc)}




ListReference

macro

TRANSLATION


Format

    #include "sgl.h"

    TRANSLATION( x, y, z );

argument

    x, y, z: Numeric values of any type (integer/floating point) that represent the amount of movement of an object, etc.

Return number

    3-dimensional movement array expressed in FIXED type

function

    #define TRANSLATION(x,y,z) { toFIXED (x), toFIXED (y), toFIXED (z)}




ListReference

macro

ROTATION


Format

    #include "sgl.h"

    ROTATION( x, y, z );

argument

    x, y, z: Numeric values of any type (integer/float) that represent the amount of rotation of an object, etc.

Return number

    3D rotation amount array expressed as ANGLE type

function

    #define ROTATION(x,y,z) { DEGtoANG (x), DEGtoANG (y), DEGtoANG (z)}




ListReference

macro

SCALING


Format

    #include "sgl.h"

    SCALING( x, y, z );

argument

    x, y, z: A number of any type (integer/float) that represents the scale amount of an object, etc.

Return number

    3-dimensional scale amount array expressed in FIXED type

function

    #define SCALING(x,y,z) { toFIXED (x), toFIXED (y), toFIXED (z)}


return
Copyright SEGA ENTERPRISES, LTD., 1997