#include "sl_def.h"
MAX (a, b);
a, b: number of arbitrary types
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: number of arbitrary types
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: Any number of types
Absolute value of a.
#define ABS (x) ((x) <0?-(X): (x))
#include "sl_def.h"
toFIXED (a);
a: Integer type number (variable / constant / number is acceptable)
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 (variable / constant / number is acceptable)
SGL fixed decimal type ( FIXED ) number array ( 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 --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)
#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.
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 (see below)
#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.
#include "sl_def.h"
DEGtoANG (a);
a: Integer type number (variable / constant / number is acceptable)
SGL angle type ( ANGLE ) numerical value
#define DEGtoANG (d) (( ANGLE ) ((65536.0 * (d)) / 360.0))
#include "sl_def.h"
RADtoANG (a);
a: Integer type number (variable / constant / number is acceptable)
SGL angle 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 color code for Saturn.
#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 color code for Saturn.
#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: The 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: Arbitrary number (integer / floating point) representing normal vector
SGL fixed decimal type ( FIXED ) number array ( 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 represented by POINT type, etc.
Fourth-order 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.
g: Data representing any type of green.
b: Data representing any type of blue.
Direct color data in RGB format of VDP1.
#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: Vertical size of texture (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 reserved for compatibility with older versions.
Please use TEXTBL , which has the same function 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 with the original texture data.
PICTURE type structure data
#define PICDEF (texno, cmode, pcsrc) {( Uint16 ) (texno), ( Uint16 ) (cmode), \
(void *) (pcsrc)}
This macro is reserved for compatibility with older versions.
Please use PICTBL , which has the same function as this macro.
#include "sgl.h"
AdjCG (adr, h, v, col)
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.)
Top address of the 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 has
CGADDRESS + (16/2) * 8 = 0x25c00040
^ ^^ ^ ^
Horizontal size | Vertical size Color mode Contains 16 color banks.
#include "sgl.h"
TEXTBL (h, v, addr);
h, v: Horizontal and vertical size of texture 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 VRAM of VDP1)
PICTURE type structure
#define PICTBL (texno, cmode, pcsrc) {( Uint16 ) (texno), ( Uint16 ) (cmode), \
(void *) (pcsrc)}
#include "sgl.h"
TRANSLATION (x, y, z);
x, y, z: A number of any type (integer / floating point) that represents the amount of movement of an object or the like.
Three-dimensional movement amount array represented by FIXED type
#define TRANSLATION (x, y, z) { toFIXED (x), toFIXED (y), toFIXED (z)}
#include "sgl.h"
ROTATION (x, y, z);
x, y, z: A number of any type (integer / floating point) that represents the amount of rotation of an object or the like.
Three-dimensional rotation amount array represented by ANGLE type
#define ROTATION (x, y, z) { debugtoANG (x), DEGtoANG (y), DEGtoANG (z)}
#include "sgl.h"
SCALING (x, y, z);
x, y, z: A number of any type (integer / floating point) that represents a scale quantity such as an object.
Three-dimensional scale amount array represented by FIXED type
#define SCALING (x, y, z) { toFIXED (x), toFIXED (y), toFIXED (z)}