#include "sl_def.h" MAX( a, b );
a, b : numbers of any type
The larger of a and b
It is declared as follows.
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#include "sl_def.h" MIN( a, b );
a, b : numbers of any type
The smaller of a and b
It is declared as follows.
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#include "sl_def.h" ABS( a );
a : number of any type
Absolute value of a.
#define ABS(x) ((x) < 0 ? -(x) : (x))
#include "sl_def.h" toFIXED ( a );
a: Number of integer type (variable/constant/number can be any)
SGL fixed decimal type (FIXED) number
#define toFIXED (a) (( FIXED )(65536.0 * (a)))
#include "sl_def.h" POStoFIXED( a, b, c );
a, b, c: Integer type number (variables/constants/numbers can be any)
Array of SGL fixed decimal type ( FIXED ) numbers ( POINT type, etc.)
#define POStoFIXED(x,y,z) { toFIXED (x), toFIXED (y), toFIXED (z)}
#include "sl_def.h" ATTRIBUTE( plane, sort, tex, col, gouraud, mode, dir, opt );
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)
#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.
ATTR attr; attr = ATTRIBUTE ( Single_Plane , 5, 0, No_Gouraud , CL16Bnk , sprNoflip , UseNearClip );
#include "sl_def.h" SPR_ATTRIBUTE( tex, col, gouraud, mode, dir );
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)
#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.
#include "sl_def.h" DEGtoANG( a );
a: Number of integer type (variable/constant/number can be any)
SGL angle type ( ANGLE ) numerical value
#define DEGtoANG(d) (( ANGLE )((65536.0 * (d)) / 360.0))
#include "sl_def.h" RADtoANG( a );
a: Number of integer type (variable/constant/number can be any)
SGL angular type ( ANGLE ) numerical value
#define RADtoANG(d) (( ANGLE )((65536.0 * (d)) / (2* M_PI )))
#include "sl_def.h" RGB( r, g, b );
r : Red integer value g : Green integer value b : Blue integer value
15-bit Saturn color code.
#define RGB(r,g,b) (0x8000|((b)<<10)|((g)<<5)|(r))
#include "sl_def.h" DGTtoRGB( a );
a : RGB value in SEGA DGT format.
15-bit Saturn color code.
#define DGTtoRGB(c) (0x8000|(((c)&0x0f00)<<3)|(((c)&0x4000)>>4)|\ (((c)&0x00f0)<<2)|(((c)&0x2000)>>8)|(((c)&0x000f)¥ <<1)|(((c)&0x1000)>>12))
#include "sl_def.h" SLocate( page, x, y );
page : Page number.
x, y: x,y position of the cell.
cell address
#define SLocate(SLocax,y,p) ((p) * Page + (y) * Line + (x))
#include "sgl.h" NORMAL( x, y, z );
x, y, z: Any number (integer/float) representing the normal vector
Array of SGL fixed decimal type ( FIXED ) numbers ( POINT type, etc.)
#define NORMAL(x,y,z) { POStoFIXED (x,y,z)}
#include "sgl.h" VERTICES( a, b, c, d );
a, b, c, d: Index in 3D vertex data table expressed as POINT type etc.
Quaternary array of indexes
#define VERTICES(v0,v1,v2,v3) {v0 , v1 , v2 , v3}}
#include "sgl.h" C_RGB( r, g, b );
r: Data representing any type of red color.
g : Data representing any type of green color.
b: Data representing any type of blue color.
Direct color data in VDP1 RGB format.
#define C_RGB(r,g,b) (((b)&0x1f)<<10|((g)&0x1f)<<5|((r)&0x1f)|0x8000)
#include "sgl.h" TEXDEF( h_size, v_size, addr );
h_size: Horizontal size of texture (dots) v_size: Texture vertical size (dots) addr: VRAM address with texture data
TEXTURE type structure data
#define TEXDEF(h,v,presize) {h,v,( cgaddress +(((presize)*4)>>( pal )))/8,¥ (((h)&0x1f8)<<5 | (v))}
This macro is kept for compatibility with older versions.
Please use TEXTBL , which has the same functionality as this macro.
#include "sgl.h" PICDEF( tex_no, col_mode, src )
tex_no: Texture number.
col_mode :Color mode ( COL_16 , COL_256 , etc.) src: Address containing the original texture data.
PICTURE type structure data
#define PICDEF (texno,cmode,pcsrc){( Uint16 )(texno),( Uint16 )(cmode),\ (void *)(pcsrc)}
This macro is kept for compatibility with older versions.
Please use PICTBL , which has the same functionality as this macro.
#include "sgl.h" AdjCG( adr, h, v, col )
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.)
the top address of that character
#define AdjCG(cga,hs,vs,col) ((cga) +(((((hs)*(vs)*4)>>(col))+0x1f)\ &0x7ffe0))
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.
#include "sgl.h" TEXTBL( h, v, addr );
h, v: Texture horizontal and vertical size addr: VRAM address with texture data
TEXTURE type structure
#define TEXTBL(hs,vs,cga) {hs , vs , (cga)>>3 , ((hs)&0x1f8)<<5|(vs)}
#include "sgl.h" PICTBL( tex, col_mode, addr );
tex_no: Texture number col_mode: Texture color mode src: Original address of texture data (not necessarily on VDP1's VRAM)
PICTURE type structure
#define PICTBL(texno,cmode,pcsrc) {( Uint16 )(texno),( Uint16 )(cmode),¥ (void *)(pcsrc)}
#include "sgl.h" TRANSLATION( x, y, z );
x, y, z: Numeric values of any type (integer/floating point) that represent the amount of movement of an object, etc.
3-dimensional movement array expressed in FIXED type
#define TRANSLATION(x,y,z) { toFIXED (x), toFIXED (y), toFIXED (z)}
#include "sgl.h" ROTATION( x, y, z );
x, y, z: Numeric values of any type (integer/float) that represent the amount of rotation of an object, etc.
3D rotation amount array expressed as ANGLE type
#define ROTATION(x,y,z) { DEGtoANG (x), DEGtoANG (y), DEGtoANG (z)}
#include "sgl.h" SCALING( x, y, z );
x, y, z: A number of any type (integer/float) that represents the scale amount of an object, etc.
3-dimensional scale amount array expressed in FIXED type
#define SCALING(x,y,z) { toFIXED (x), toFIXED (y), toFIXED (z)}