ListReference

macro

MAX


Return the larger of the two

Form

    #include "sl_def.h"

    MAX (a, b);

argument

    a, b: number of arbitrary types

Number of returns

    The larger of a and b

function

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



ListReference

macro

MIN


Return the smaller of the two

Form

    #include "sl_def.h"

    MIN (a, b);

argument

    a, b: number of arbitrary types

Number of returns

    The smaller of a and b

function

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



ListReference

macro

ABS


Take the absolute value

Form

    #include "sl_def.h"

    ABS (a);

argument

    a: Any number of types

Number of returns

    Absolute value of a.

function

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




ListReference

macro

toFIXED


Convert integers to fixed decimals

Form

    #include "sl_def.h"

    toFIXED (a);

argument

    a: Integer type number (variable / constant / number is acceptable)

Number of returns

    SGL fixed decimal type (FIXED) number

function

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




ListReference

macro

POStoFIXED


Convert integers to fixed decimals

Form

    #include "sl_def.h"

    POStoFIXED (a, b, c);

argument

    a, b, c: Integer type number (variable / constant / number is acceptable)

Number of returns

    SGL fixed decimal type ( FIXED ) number array ( POINT type, etc.)

function

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




ListReference

macro

ATTRIBUTE


Form

    #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 --Sort reference point (described later)
    tex --texture number (see below)
    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 --option (described later)

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 list of argument values is as follows.
plane Single_Plane: Single- sided (normal vector direction) 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: Displayed in front of the previous polygon.
tex No_Texture : Do not apply texture.
Uint16 value: Texture number.
col No_Palet : Do not use palettes. (When 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.
Value of Uint16 : Represented by the 8-byte boundary from the beginning of VRAM at the address VDP1 of the Gouraud shading table.
mode Specify 0 or 1 entry from each of the following groups with "|".
Group 1 MSBoff : Do not set MSB when writing to framebuffer (default).
MSBon : Create MSB when writing to the framebuffer.
Group 2 No_Window : Not subject to window restrictions. (default) Window_In : Displayed inside the window.
Window_Out : Displayed outside the window.
Group 3 HSSoff : Do not apply high speed shrink. (default) HSSon : Apply high speed shrink.
Group 4 MESHoff : Do not mesh. (default) MESHon : Apply mesh.
Group 5 ECdis : Invalid end code. (default) ECenb : Enabled 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 : Semi-brightness mode.
CL_Trans : Semi-transparent mode.
CL_Gouraud : User Gouraud shading mode.
dir sprNoflip : Normal display.
sprHflip : Left-right inverted display.
sprVflip : Upside down display.
sprHVflip: Up / down / left / right inverted display.
sprPolygon : No texture.
sprPolyLine : Polyline display.
opt UseLight : Performs flat shading.
UseNearClip : Performs near clipping processing.
UsePalette : Palette display.
UseDepth : Performs depth skewing.
UseGouraud : Performs real-time goo 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


Form

    #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 (see below)

function

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

    The list of argument values is as follows.
tex No_Texture : Monochromatic sprite.
Uint16 value: Pattern number.
col No_Palet : Do not use palettes. (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.
Value of Uint16 : Represented by the 8-byte boundary from the beginning of VRAM at the address VDP1 of the Gouraud shading table.
mode Specify 0 or 1 entry from each of the following groups with "|".
Group 1 MSBoff : Do not set MSB when writing to framebuffer (default).
MSBon : Create MSB when writing to the framebuffer.
Group 2 No_Window : Not subject to window restrictions. (default) Window_In : Displayed inside the window.
Window_Out : Displayed outside the window.
Group 3 HSSoff : Do not apply high speed shrink. (default) HSSon : Apply high speed shrink.
Group 4 MESHoff : Do not mesh. (default) MESHon : Apply mesh.
Group 5 ECdis : Invalid end code. (default) ECenb : Enabled 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 : Semi-brightness mode.
CL_Trans : Semi-transparent mode.
CL_Gouraud : User Gouraud shading mode.
dir Select one from each of the following two groups and specify with "|".
Group 1 sprNoflip : Normal display.
sprHflip : Left-right inverted display.
sprVflip : Upside down display.
sprHVflip: Up / down / left / right inverted display.
sprPolygon : Monochromatic sprite.
sprPolyLine : Polyline display.
Group 2 _ZmLT : Set the center point at the time of enlargement to the upper left.
_ZmLC : Set the center point at the time of enlargement to the left center.
_ZmLB : Set the center point at the time of enlargement to the lower left.
_ZmCT : Set the center point at the time of enlargement to the center.
_ZmCC : Center the center point when enlarging.
_ZmCB : Set the center point at the time of enlargement to the bottom center.
_ZmRT : Set the center point at the time of enlargement to the upper right.
_ZmRC : Set the center point at the time of enlargement to the right center.
_ZmRB : Set the center point at the time of enlargement to the lower right.



ListReference

macro

DEGtoANG


Form

    #include "sl_def.h"

    DEGtoANG (a);

argument

    a: Integer type number (variable / constant / number is acceptable)

Number of returns

    SGL angle type ( ANGLE ) numerical value

function

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




ListReference

macro

RADtoANG


Form

    #include "sl_def.h"

    RADtoANG (a);

argument

    a: Integer type number (variable / constant / number is acceptable)

Number of returns

    SGL angle 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 bits)

Form

    #include "sl_def.h"

    RGB (r, g, b);

argument

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

Number of returns

    15-bit color code for Saturn.

function

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




ListReference

macro

DGTtoRGB


Form

    #include "sl_def.h"

    DGTtoRGB (a);

argument

    a: RGB value in SEGA DGT format.

Number of returns

    15-bit color code for Saturn.

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 the cell position address of the page

Form

    #include "sl_def.h"

    SLocate (page, x, y);

argument

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

Number of returns

    Cell address

function

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



ListReference

macro

NORMAL


Form

    #include "sgl.h"

    NORMAL (x, y, z);

argument

    x, y, z: Arbitrary number (integer / floating point) representing normal vector

Number of returns

    SGL fixed decimal type ( FIXED ) number array ( POINT type, etc.)

function

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




ListReference

macro

VERTICES


Make an array of four vertex index data (for vertex data description)

Form

    #include "sgl.h"

    VERTICES (a, b, c, d);

argument

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

Number of returns

    Fourth-order 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

Form

    #include "sgl.h"

    C_RGB (r, g, b);

argument

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

Number of returns

    Direct color data in RGB format of VDP1.

function

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




ListReference

macro

TEXDEF


Form

    #include "sgl.h"

    TEXDEF (h_size, v_size, addr);

argument

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

Number of returns

    TEXTURE type structure data

function

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

caution


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



ListReference

macro

PICDEF


Form

    #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 with the original texture data.

Number of returns

    PICTURE type structure data

function

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

caution


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



ListReference

macro

AdjCG


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

Form

    #include "sgl.h"

    AdjCG (adr, h, v, col)

argument

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

Number of returns

    Top address of the 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 has
    CGADDRESS + (16/2) * 8 = 0x25c00040
                  ^ ^^ ^ ^
           Horizontal size | Vertical size Color mode Contains 16 color banks.



ListReference

macro

TEXTBL


Form

    #include "sgl.h"

    TEXTBL (h, v, addr);

argument

    h, v: Horizontal and vertical size of texture addr: VRAM address with texture data

Number of returns

    TEXTURE type structure

function

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




ListReference

macro

PICTBL


Form

    #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 VRAM of VDP1)

Number of returns

    PICTURE type structure

function

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




ListReference

macro

TRANSLATION


Form

    #include "sgl.h"

    TRANSLATION (x, y, z);

argument

    x, y, z: A number of any type (integer / floating point) that represents the amount of movement of an object or the like.

Number of returns

    Three-dimensional movement amount array represented by FIXED type

function

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




ListReference

macro

ROTATION


Form

    #include "sgl.h"

    ROTATION (x, y, z);

argument

    x, y, z: A number of any type (integer / floating point) that represents the amount of rotation of an object or the like.

Number of returns

    Three-dimensional rotation amount array represented by ANGLE type

function

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




ListReference

macro

SCALING


Form

    #include "sgl.h"

    SCALING (x, y, z);

argument

    x, y, z: A number of any type (integer / floating point) that represents a scale quantity such as an object.

Number of returns

    Three-dimensional scale amount array represented by FIXED type

function

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


return
Copyright SEGA ENTERPRISES, LTD., 1997