When using this document, keep the following in mind:ntialGeneral Notice

1. This document is confidential. By accepting this document you acknowledge that you are boundby the terms set forth in the non-disclosure and confidentiality agreement signed separately and /inthe possession of SEGA. If you have not signed such a non-disclosure agreement, please contact
SEGA immediately and return this document to SEGA.

de2. This document may include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new versions of the
document. SEGA may make improvements and/or changes in the product(s) and/or the
program(s) described in this document at any time.

nfi

3. No one is permitted to reproduce or duplicate, in any form, the whole or part of this document
without SEGA’S written permission. Request for copies of this document and for technicalinformation about SEGA products must be made to your authorized SEGA Technical Services
representative.

Co

4. No license is granted by implication or otherwise under any patents, copyrights, trademarks, orother intellectual property rights of SEGA Enterprises, Ltd., SEGA of America, Inc., or any third
party.
5. Software, circuitry, and other examples described herein are meant merely to indicate the characteristics and performance of SEGA’s products. SEGA assumes no responsibility for any intellectual
property claims or other problems that may result from applications based on the examples
describe herein.

GA

6. It is possible that this document may contain reference to, or information about, SEGA products(development hardware/software) or services that are not provided in countries other than Japan.
Such references/information must not be construed to mean that SEGA intends to provide such
SEGA products or services in countries other than Japan. Any reference of a SEGA licensed product/program in this document is not intended to state or simply that you can use only SEGA’slicensed products/programs. Any functionally equivalent hardware/software can be used instead.
7. SEGA will not be held responsible for any damage to the user that may result from accidents or any
other reasons during operation of the user’s equipment, or programs according to this document.

SE

NOTE: A reader's comment/correction form is provided with thisdocument. Please address comments to :(6/27/95- 002)

SEGA of America, Inc., Developer Technical Support (att. Evelyn Merritt)
150 Shoreline Drive, Redwood City, CA 94065
SEGA may use or distribute whatever information you supply in any way
it believes appropriate without incurring any obligation to you.

SE

GA

Co

nfi

de

nti
al

TM

Program Library
User's Guide 2
Graphics LibraryDoc. # ST-157-R1-092994

VDP 1 Library...................................... 1
VDP 2 Library.................................... 45
Number Calculation Library ........... 87
DSP I/F Library .............................. 107© 1994-95 SEGA. All Rights Reserved.

nti
al

READER CORRECTION/COMMENT SHEETKeep us updated!
If you should come across any incorrect or outdated information while reading through the attacheddocument, or come up with any questions or comments, please let us know so that we can make therequired changes in subsequent revisions. Simply fill out all information below and return this form to
the Developer Technical Support Manager at the address below. Please make more copies of this form if
more space is needed. Thank you.
General Information:

Phone

Document number
Document namedeYour Name

Date

ST-157-R1-092994

Program Library User's Guide 2 Graphics Library

Corrections:
Correction

nfi

pg. #

GA

Co

Chpt.

SE

Questions/comments:

Fax:

Where to send your corrections:(415) 802-1440
Attn: Sr. Coordinator,
Technical Publications Group

Mail:

SEGA OF AMERICA
Attn: Sr. Coordinator,
Technical Publications Group
130 Shoreline Dr.
Redwood City, CA 94065

SE

GA

Co

nfi

de

nti
al

(This page is blank in the original Japanese document.)

i

nti
al

Contents
VDP1 Library......................................................................................................................
1.0 VDP1 Basic Processing Guide ........................................................................
1.1 Objective......................................................................................................
1.2 Explanation .................................................................................................
1.3 Example of a Program Description .........................................................

1
1
1
1
2

VDP1 Expanded Processing Guide ...............................................................
2.1 Objective......................................................................................................
2.2 How to Control the VRAM Area .............................................................
2.3 Drawing Order to the Sprite Command Frame Buffer ........................
2.4 Example of a Program Description .........................................................

4
4
4
6
7

3.0

VDP1 3D Guide ................................................................................................
3.1 Objective......................................................................................................
3.2 3D Coordinate System and Display Model ...........................................
3.3 Example of a Program Description .........................................................
3.4 Polygon Objects that Connect Between Objects .................................

9
9
9
10
13

4.0

VDP1 Basic Processing Reference.................................................................. 15
4.1 Data Specifications .................................................................................... 15
4.2 List of Functions ......................................................................................... 15
4.3 Function Specifications ............................................................................. 16

5.0

VDP1 Expanded Processing Reference......................................................... 19
5.1 Data Specifications .................................................................................... 19
5.2 List of Functions ......................................................................................... 21
5.3 Function Specifications ............................................................................. 22

6.0

VDP1 3D Reference ......................................................................................... 32
6.1 Data Specifications .................................................................................... 32
6.2 List of Functions ......................................................................................... 37
6.3 Function Specifications ............................................................................. 37

GA

Co

nfi

de

2.0

SE

VDP2 Library......................................................................................................................
1.0 Guide .................................................................................................................
1.1 Objective......................................................................................................
1.2 Explanation .................................................................................................
1.3 Basic Library Usage ...................................................................................
2.0

45
45
45
45
48

Reference .......................................................................................................... 55
2.1 Data Specifications .................................................................................... 55
2.2 List of Functions ......................................................................................... 63
2.3 Function Specifications ............................................................................. 65

ii

2.0

nti
al

Mathmatical Calculation Library .................................................................................... 87
1.0 Guide ................................................................................................................. 87
1.1 Objective...................................................................................................... 87

Reference .......................................................................................................... 89
2.1 Data Specifications .................................................................................... 89
2.2 List of Functions ......................................................................................... 91
2.3 Function Specifications ............................................................................. 93

107
107
107
107
107
108

Reference .......................................................................................................... 109
2.1 List of Functions ......................................................................................... 109
2.2 Function Specifications ............................................................................. 109

SE

GA

Co

nfi

2.0

de

DSP I/F Library .................................................................................................................
1.0 Guide .................................................................................................................
1.1 Objective......................................................................................................
1.2 Overview .....................................................................................................
1.3 Function Overview ....................................................................................
1.4 Calling Sequence ........................................................................................

iii

1.0

VDP1 Basic Processing Guidential

VDP1 Library

1.2

de

1.1
Objective· Hides hardware-related processing such as VDP1 initialization, register operation,etc., to reduce the load on the application author.
· Because of differences in processing methods used to speed up applications, thebasic processing library does not write commands to VRAM. The application has
the VRAM addresses, so these can be controlled and written on the applicationside.
(Writing to VRAM and VRAM control is supported by the expanded processing
library.)
Explanation

nfi

Initial Processing· Sets the frame buffer erase area, erase data for each frame change, and the TV
mode.
V-BLANK Interrupt Processing Function

SE

GA

Co

· SPR_WaitDrawEnd () is used in the V_BLANKVDP interrupt routine to check for
VDP1 draw end.

User's Guide 2 Graphics Library

1

1.3

Example of a Program Descriptionntial#include <machine.h>#include “sega_spr.h”#include “sega_scl.h”#include “sega_int.h”*/*/

main(){
Uint8/* VRAM Address Storage Area*//* Enable Interrupt*/*vram;

set_imask(0);deextern void vbStart (void); /* V-BLANK IN Interrupt Routine
extern void vbEnd (void);/* V-BLANK OUT Interrupt Routine

*/

*/

nfi

SCL_Vdp2Init();/* Initialize scroll and priority
SCL_SetPriority(SCL_SP0|SCL_SP1|SCL_SP2|SCL_SP3|SCL_SP4|
SCL_SP5|SCL_SP6|SCL_SP7,7);
SCL_SetSpriteMode(SCL_TYPE1,SCL_MIX,SCL_SP_WINDOW);
SPR_Initial(&vram);/*Initialize SpriteCo

INT_ChgMsk(INT_MSK_NULL, INT_MSK_VBL_IN | INT_MSK_VBL_OUT);/* Disable V-BLANK Interrupt*/
INT_SetFunc(INT_SCU_VBLK_IN, &vbStart);/* Register V-BLANK IN Interrupt Routine*/
INT_SetFunc(INT_SCU_VBLK_OUT, &vbEnd);/* Register V-BLANK OUT Interrupt Routine*/
INT_ChgMsk(INT_MSK_VBL_IN | INT_MSK_VBL_OUT, INT_MSK_NULL);/* Enable V-BLANK Interrupt*/
SCL_SetFrameInterval(2); /* Set the frame change interval to *//* 2/60 seconds*/GA

for(;;) |memcpy(vram,command,sizeof(command));/* Set the Sprite Command in VRAM————/* Set Scroll Data

SCL_DisplayFrame(); /* Wait for V-BLANK Interrupt/* Display Sprite and Move Scroll

}

SE

}

2

*/
*/
*/
*/

#include <machine.h>#include “sega_spr.h”#include “sega_scl.h”#pragma interrupt(VbStart)#pragma interrupt(VbEnd)

ntial- V-Blank Processing Routine (Separate source file from the main shown on previous
page.) -void VbStart(void){
SCL_VblankStart(); /* V-Blank Start VDP Interrupt Processing *//* Other V-Blank Start Processing

Co
GA
SE
User's Guide 2 Graphics Library*//* V-Blank End VDP Interrupt Processing *//* Other V-Blank End Processing*/

nfi

void VbEnd(void){
SCL_VblankEnd();
————
}

de

————
}

3

nti
al

2.0 VDP1 Expanded Processing Guide
2.1
Objective· Supports functions that were not included in the basic processing library such as
VRAM management and writing sprite commands to VRAM.
· Executes a primitive sprite display command that corresponds to the spritecommand.

de

2.2
How to Manage the VRAMArea
The VRAM area (512Kbyte) is assigned as shown below.

00000HVRAM Area Reference Switch Command

nfi

System Command Area

User Command Area

80000HCo

Gouraud Shading Table Area
Color Lookup Table

Block Pool Area
(Character, Subroutine Command)GA

Explanation of EachArea· VRAM Area Reference Switch Command
Sprite jump command that is used to match the VRAM area 0, 1 for frame change.
· System Command Area
This area is used to open the access routine used to erase the frame buffer withpolygon draw when the frame change interval is insufficient. Areas 0 and 1 are
the same size.

SE· User Command Area
Area where sprite commands organized from the top down through the various
command set routines called from the SPR_2OpenCommand() to the
SPR_2CloseCommand() routine. Areas 0 and 1 are the same size.

4

nti
al

· Gouraud Shading Table Area
Area that stores the Gouraud shading table with 8 bytes for each entry and controls
numbers starting at 0. Areas 0 and 1 are the same size.
· Color Lookup Table Area
Area that stores the Color Lookup table with 8 bytes for each entry and controls
numbers starting at 0. Areas 0 and 1 are the same size. Areas 0 and 1 are referenced
commonly.

The Assigned Size of EachAreade· Block Pool Area
Area that is referenced by both command areas 0 and 1 and contains character dataand sub-routine commands, etc. (Subroutine commands are currently notsupported.) Character data is controlled starting at number 0. The assigning ofcharacter data, etc., to this area is dynamically acquired and released in 32 byte
blocks.

nfi

The size of each area is assigned as shown below; one block is 32 bytes.

Co

Area Name
VRAM Area Reference Switch Command
System Command Area
User Command Area
Gouraud Shading Table Area
Color Lookup Table Area
Block Pool Area

Blocks1
4x2
COMMAND_MAX x2(GOUR_TBL_MAX+3)/4x2
LOOKUP_TBL_MAX
All remaining blocks

GA

COMMAND_MAX: Maximum number of commands
GOUR_TBL_MAX: Maximum number of Gouraud shading tables
LOOKUP_TBL_MAX: Maximum number of lookup tables
These values are defined later in the VDP1 expanded processing work area
definition macro.
Block Assign Algorithm Inside the Block Pool
Area

• When Acquiring
Searches for a contiguous block that will hold the block that is being requested andassigns it the minimum area.

SE• When Releasing
Releases the designated block area. If there is an empty block next to the block being
released, both blocks are combined to form a large empty block.

User's Guide 2 Graphics Library

5

nti
al

2.3
Drawing Order to the Sprite Command Frame Buffer
The drawing order can be set for each command by setting the draw priority value
when the sprite command set routines below are called up.
SPR_2LocalCoord() SPR_2SysClip() SPR_2UserClip() SPR_2line()
SPR_2polyLine()
SPR_2Polygon() SPR_2NormSpr() SPR_2ScaleSpr()
SPR_2DistSpr()
SPR_2Cmd()

The draw priority number indicates the draw block number. Block number 0 is
drawn first. Also, commands within the blocks are drawn in the order they wererecorded.

dePriority Number

Command Registered Order0

Block 0

1

n

nfi

2

Co

Drawing Order

Block 1
Block 2Block nThe drawing order is set by calling up the SPR_2CloseCommand() or
SPR_2FlushDrawPrty() routines. The control word jump and link settings in thecommand can be changed here.

SEGA

The number of blocks in the draw order number control block are set in advance. It
can be set in the 2D work area definition or the SPR_2OpenCommand () if the draw
area is not to be attached.

6

#include machine.h>#define _SPR2_#include “sega_spr.h”#include “sega_scl.h”#include “sega_int.h

nti
al

2.4
Example of a Program Description
An actual example program in C language is shown below.
/* Use Sprite Display Extended Libraryde#define COMMAND_MAX
512 /* Maximum commands#define GOUR_TBL_MAX
512 /* Maximum Gouraud tables#define LOOKUP_TBL_MAX 512 /* Maximum Lookup tables#define CHAR_MAX
100 /* Maximum Characters#define DRAW_PRTY_MAX 256/* Maximum Draw Priority Blocks
SPR_2DefineWork(work2d, COMMAND_MAX, GOUR_TBL_MAX,LOOKUP_TBL_MAX, CHAR_MAX)/* Define 2D Work Area
extern void vbStart(void); /* V-BLANK IN Interrupt Routine
extern void vbEnd(void);/* V-BLANK OUT Interrupt Routine

set_imask(0);

*/
*/
*/
*/
*/

*/
*/
*/

nfi

main(){*//* Enable Interrupt*/

Co

SCL_Vdp2Init();/* Initialize Scroll and Priority
SCL_SetPriority(SCL_SP0|SCL_SP1|SCL_SP2|SCL_SP3|SCL_SP4|
SCL_SP5|SCL_SP6|SCL_SP7,7);
SCL_SetSpriteMode(SCL_TYPE1,SCL_MIX,SCL_SP_WINDOW);
SPR_2Initial(&work2d);/*Initialize 2D Sprite Display

*/

*/

GA

INT_ChgMsk(INT_MSK_NULL, INT_MSK_VBL_IN | INT_MSK_VBL_OUT);/* Disable V-BLANK Interrupt*/
INT_SetFunc(INT_SCU_VBLK_IN, &vbStart);/* Register V-BLANK IN Interrupt Routine*/
INT_SetFunc(INT_SCU_VBLK_OUT, &vbEnd);/* Register V-BLANK OUT Interrupt Routine*/
INT_ChgMsk(INT_MSK_VBL_IN | INT_MSK_VBL_OUT, INT_MSK_NULL);/* Enable V-BLANK Interrupt*/
for(;;) {SPR_2SetChar(...);}/* Set Character Data to VRAM*/SE

SPR_2FrameChgIntr(0xffff); /* Set the Frame Change Interval *//* to Undefined*/for(;;) {——————/* Set Scroll Data*/

SPR_2OpenCommand(SPR_2DRAW_PRTY_OFF);/* Open Command Write
SPR_2SysClip(0,&xy);/* System Clip Area Command
SPR_2LocalCoord(0,&xy); /* Local Coordinates Command

User's Guide 2 Graphics Library

*/
*/
*/

7

/* Each Type of Sprite Command
/*

*/

nti
al

SPR_2Polygon(...);
SPR_2NormSpr(...);.
.
.

SPR_2CloseCommand() ; /* Close Command Write*/

SCL_DisplayFrame() ;*/*//* Hold Interrupt V_BLANK/* Display Sprite and Move Scroll}}#pragma interrupt (VbStart)#pragma interrupt (VbEnd)/* VBlank start VDP Intrrpt. Process*//* Other VBlank Start Processes*/

Covoid VbStart(void){
SCL_VblankStart();
————
}

nfi

#include machine.h>#include “sega_spr.h”#include “sega_scl.h”

de- V Blank Process Routine (The main above is a separate source file) -SE

GA

void VbEnd(void){
SCL_VblankEnd();
————
}

8

/* VBlank End VDP Interrupt Process */3.0

VDP1 3D Guide

nti
al

3.1
Objective
The purpose here is to use the VDP1 expansion processing library to display 3D
sprites.

3.2

de· Handles layers of connected models that consist of groupings of polygons.
· There is no need to understand the matrix calculations that accompany the
movement of models or the objects within a model.
· The user application is made aware of the coordinate value of the point after
world coordinates have been converted through the user call back routine.
· Texture mapping and sprite coloring during display can also be applied to polygons.
· Can be matched with 2D sprites when displayed.

3D Coordinate System and Display Modelnfi

Coordinate SystemyyView Point
0

Co

World Coordinates

Light Source

View Point
Coordinate System

Model

GA

Objectscreen
-z

0

1

0

x

y

SE

z

z

0

x
Body Coordinate System

Distance from the screen to the view point is fixed at 1.0.

User's Guide 2 Graphics Library

9

[Display Model]

Object 1

Cluster 10

Cluster 00

Cluster 11

Root Clusterde

Object 0ntial

The display model is a grouping of polygons connected in a layered cluster as an object.
Clusters have a mother/child-type relationship: the position of the object that is the childcluster is placed in the mother cluster body coordinate system. For this reason, when themother cluster is moved, all of the child clusters move along with it.

nfi

Cluster 20

Co

Cluster 12

Cluster 21

3.3
Example of a Program Description
An actual example program in C language is shown below.

GA#include <machine.h>#define _SPR3_/* Use Sprite 3D Display Library#define SPR_3USE_DOUBLE_BUF /* Designates double buffer#include “sega_spr.h”#include “sega_scl.h”#include “sega_int.h*/*/

SprCluster mode10;
SprCluster mode11;SE#define COMMAND_MAX
1000 /* Maximum commands*/#define GOUR_TBL_MAX
1000 /* Maximum Gouraud tables*/#define LOOKUP_TBL_MAX 1000 /* Maximum Lookup tables*/#define CHAR_MAX
100/* Maximum Characters*/#define DRAW_PRTY_MAX 256 /* Maximum Draw Priority Blocks*/
SPR_2DefineWork(work2d, COMMAND_MAX, GOUR_TBL_MAX,LOOKUP_TBL_MAX, CHAR_MAX, DRAW_PRTY_MAX)/* Define 2D Work Area*/
#define OBJ_SURF_MAX
16/* Maximum Surfaces in an Object*/#define OBJ_VERT_MAX
16/* Max. Vertex Points in an Object */SPR_3DefineWork(work3D, OBJ_SURF_MAX, OBJ_VERT_MAX)/* Defines the 3D Work Area*/

10

/* V-BLANK IN Interrupt Routine/* V-BLANK OUT Interrupt Routine

*/
*/

nti
al

extern void vbStart(void);
extern void vbEnd(void);main(){
set_imask(0);/* Enable Interrupt*/*/

SPR_2Initial(&work2d);/*Initialize 2D Sprite Display*/

SPR_3Initial(&work3D);/*Initialize 3D Sprite Display*/de

SCL_Vdp2Init();/* Initialize Scroll and Priority
SCL_SetPriority(SCL_SP0|SCL_SP1|SCL_SP2|SCL_SP3|SCL_SP4|
SCL_SP5|SCL_SP6|SCL_SP7,7);
SCL_SetSpriteMode(SCL_TYPE1,SCL_MIX,SCL_SP_WINDOW);

nfi

INT_ChgMsk(INT_MSK_NULL, INT_MSK_VBL_IN | INT_MSK_VBL_OUT);/* Disable V-BLANK Interrupt*/
INT_SetFunc(INT_SCU_VBLK_IN, &vbStart);/* Register V-BLANK IN Interrupt Routine*/
INT_SetFunc(INT_SCU_VBLK_OUT, &vbEnd);/* Register V-BLANK OUT Interrupt Routine*/
INT_ChgMsk(INT_MSK_VBL_IN | INT_MSK_VBL_OUT, INT_MSK_NULL);/* Enable V-BLANK Interrupt
*/
*/
*/

SPR_3SetTexture(texture); /* Set the 3D Texture Data*/Co

SPR_2FrameChgIntr(0xffff); /* Set the Frame Change Interval/* to Undefinedfor(;;) {——————/* Set Scroll Data

*/

SE

GA

SPR_3SetLight(...);/* Set the 3D light Source*/
SPR_3SetView(...);/* Set the 3D view Point*/
SPR_2OpenCommand(SPR_2DRAW_PRTY_ON);/* Open Sprite Command Write*/
SPR_2SysClip(SPR_2MOST_FAR,&xy);/* System Clip Area Command*/
SPR_2LocalCoord(SPR_2MOST_FAR+1,&xy);/* Local Coordinates Command*/
SPR_3moveCluster(mode10,...);/* Move Root Cluster of 3D model 0*/
SPR_3DrawMode1(mode10,...); /* Register 3D Model 0*/
SPR_3moveCluster(mode11,...);/* Move Root Cluster of 3D model 1*/
SPR_3DrawMode1(mode11,...); /* Register 3D Model 1*/.
.
.
SPR_3Flush();/* Set the 3D Sprite Command*/
SPR_2CloseCommand() ; /* Close sprite command Write*/
SCL_DisplayFrame() ;/* Hold Interrupt V_BLANK*//* Display Sprite and Move Scroll */}}User's Guide 2 Graphics Library11• V Blank Process Routine (The main above is a separate source file) -nti
al#include <machine.h>#include “sega_spr.h”#include “sega_scl.h#pragma interrupt (VbStart)#pragma interrupt (VbEnd)/* VBlank End VDP Interrupt Process/* Other VBlank End Processes

nfi

void VbEnd(void){
SCL_VblankEnd();————}/* V Blank start VDP Interrupt Process/* Other VBlank Start Processesdevoid VbStart(void){
SCL_VblankStart();
————
}

SE

GA

Co

Polygon Z sort in the view coordinate system of the sprite 3D display library uses the
sprite priority draw function of the VDP1 expansion library (2D library). To execute
Z sort, priority draw in the SPR_2OpenCommand() routine must be set to on(SPR_2DRWA_PRTY_ON).

12

*/
*/

*/
*/

nti
al

3.4
Polygon Objects That Connect Between Objects
When Object2 needs to be changed to accomodate the movement of Object1, asshown in the figure below, define the polygon between Object0 and Object1 (Object2) as an inbetween-object polygon and the shape changes are automaticallydrawn.
1
2

Object Movement
0

Object1

5

6

3

Object1

4
Object20

de0

Object2

1

2

4

1
5

Object0nfi

Object0

7

6

5

Co

4

The different tables that contain the cluster, object and inbetween-object polygon
information are connected as shown below.

child

GA

Cluster0

SE

InbetInf0

Cluster1

InbetInf1
Object0

Object1

Object2
InbetInf: Inbetween object polygon information

User's Guide 2 Graphics Library

13

nti
al

• Processing the Inbetween-object Polygon Object
Objects are drawn in order from the parent cluster to the child cluster; if there ismore than one object in a cluster, they are drawn in the order they were connected.
In the previous example, objects would be drawn in order of Object0, Object1,
Object2.

2)

If there is inbetween-object polygon information connected to the cluster, theinbetween-object polygon object vector data table is set using the corresponding
vector data converted from the focal point coordinate system in the set table.
If there is Gouraud shading, the calculated vector brightness is set into theinbetween-object polygon normal vector line data table. In the previous example,
InbetInf0 sets the focal coordinate system vector data (0, 1, 2, 3) to Object2 vector
data (4, 5, 6, 7); InbetInf1 sets the focal coordinate system vector data (4, 5, 6, 7) to
Object2 vector data (0, 1, 2, 3).

3)

If the draw object is an inbetween-object polygon, the normal vector for eachsurface is found after conversion to the focal coordinate system, and the object isdrawn according to the draw mode. In the previous example, Object2 is theinbetween-object polygon object.

4)

Conditions for setting the inbetween-object polygon.
· If set as one of a cluster, connect it last in the object chain.
· The normal vector calculation correction value in the object table is set as anegative value.

SE

GA

Co

nfi

de

1)

14

4.1

Data Specifications

Title

Data

Data Specification

Status Return Area Pointernti
al

4.0 VDP1 Basic Processing Reference

Data Name*1 Frame change Mode

SPR_SpStatus{/* Frame Change Mode*1/* Frame Erase Mode*2/* V-BLANK Intervals/* Frame Buffer Erase Data/* Frame Buffer Erase Left Side/* Frame Buffer Erase Top/* Frame Buffer Erase Right Side/* Frame Buffer Erase Bottom

detypedef struct SprSpStatus
Uint16 frameChgMode;
Uint16 frameEraseMode;
Uint16 vbInterval;
Uint16 eraseData;
Uint16 eraseLeftX;
Uint16 eraseTopY;
Uint16 eraseRightX;
Uint16 eraseBotY;} SprSpStatus;

No

0 /* Auto Change*/
1 /* Manual Change at Fixed Interval*/
2 /* Manual Change at Undefined Interval */3 /* Undefined by Vblank erase*//* Interval Manual Change*/

nfi#define AUTO_FRAME_CHG#define MANUAL_FRAME_CHG#define NO_INTERVAL_FRAME_CHG#define NO_INTER_VBE_FRAME_CHG

*/
*/
*/
*/
*/
*/
*/
*/

Co

*2 Frame Erase Mode#define OFF#define ON

4.2

0 /* Frame Erase OFF
1 /* Frame Erase ON*/*/

List of Functions

Function NameSPR_Initial
SPR_SetTvMode
SPR_GetStatus
SPR_SetEraseData
SPR_WaitDrawEnd
SPR_SetEosMode
SPR_WRITE_REG
SPR_READ_REG

Number
1
2
3
4
5
6
7
8

SE

GA

Function
Initialize the VDP1 basic process library
Set TV ModeGet the Current Sprite Control Information
Set the Frame Buffer Erase Area, Erase data
Check the Frame Buffer Draw End
Set the Sprite Draw Source Coordinate Select Mode
System Register Write Macro
System Register Read Macro

User's Guide 2 Graphics Library

15

4.3

Function Specifications
Function

Function Name

Function Specification

Initialize the VDP1 basic process library

SPR_Initial

void SPR_Initial(Uint8 **vram)

Title

Function

Function Specification

TV Mode Set

void

Input

mode

No

SPR_SetTvMode2

Spr_SetTvMode(Uint16 mode, Uint16 screenSize,
Uint16 doubleInterlace)GA

Co: The following TV mode definition values can be set.
SPR_TV_NORMAL= Normal Mode
SPR_TV_HIREZ0= Hi Resolution Mode
SPR_TV_R0T16= Rotate 16 Mode
SPR_TV_R0T8= Rotate 8 Mode
SPR_TV_HDTV= HDTV Mode
screenSize : Sets the screen size that corresponds to the TV
mode from the definition values shown below.
See the VDP1 manual for detailed configurations.
SPR_TV_320X224 = 320 x 224
SPR_TV_320X240 = 320 x 240
SPR_TV_352X224 = 352 x 224
SPR_TV_352X240 = 352 x 240
SPR_TV_640X224 = 640 x 224
SPR_TV_640X240 = 640 x 240
SPR_TV_704X224 = 704 x 224
SPR_TV_704X240 = 704 x 240
doubleInterlace : Sets the double interlace mode.
ON = Use the double interlace mode.
OFF = Do not use the double interlace mode.
None
None
Sets the TV Mode.

SE
16

Function Name

nfi

FormatOutputFunction Value
Function

1

vram:VRAM address return area pointer
None
None
Sets the following values as default· Erase Data = 0x8000 (Black)· Erase Area = (0, 0) - (319,223)· TV mode is normal, resolution is 320 X 224

deFormatInput
OutputFunction Value
Function

No

nti
al

Title

Function

Function Name

No

Function Specification

Get the Current Sprite Control Information

SPR_GetStatus

3

FormatInput
OutputFunction Value
Function

nti
al

Title

void SPR_GetStatus(SprSpStatus *spStatus)

None
SprSpStatus: Status return area pointerNone
Gets the sprite control information.

Function

Function Specification

Set the Frame Buffer Erase Area, Erase data SPR_SetEraseData

Formatvoid SPR_SetEraseData(Uint16 eraseData, Uint16 leftX,
Uint16 topY, Uint16 rightX, Uint16 botY)

Input

eraseData: RGB erase data
leftX
: Left erase X coordinates
topY: Top erase Y coordinatesrightX : Right erase X coordinates
botY: Bottom erase Y coordinates
None
None
Used to set what color and what area is erased in the erase
process.

Function Specification

4

Function

Function NameNo

Check the Frame Buffer Draw End

SPR_WaitDrawEnd

5

void

SPR_WaitDrawEnd(void)

None
None
None
Waits for the VDP1 to finish drawing to the frame buffer. Thisroutine is called from the V-BLANK VDP interrupt processroutine.

SE

GA

FormatInput
OutputFunction Value
Function

No

nfi

Co

OutputFunction Value
Function

Title

Function Name

de

Title

User's Guide 2 Graphics Library17

Function

Function Specification

Set the Sprite Draw Source
Coordinate Select Mode

Function NameSPR_SetEosMode

No

6

nti
al

Title

FormatInput

void SPR_SetEosMode(Sint32 eosFlag)

OutputFunction Value
Function

None
None
Sets the source picture texture sampling coordinate mode withthe sprite command draw mode when high speed draw is set.

0= Sampling of even coordinates (default)
1= Sampling of odd coordinates

Title

Function

Function Specification

System Register Write Macro

FormatInput

SPR_WRITE_REG(Uint16

Function NameNo

SPR_WRITE_REG

7reg, Uint16 val)

Sets the system register type from the definitions
listed below.
SPR_W_TVMR = Select TV Mode
SPR_W_FBCR = Frame Buffer Change Mode
SPR_W_PTMR = Plot Trigger
SPR_W_EWDR = Erase Write Data
SPR_W_EWLR = Erase Write Upper Left Coordinate
SPR_W_EWRR = Erase Write Lower Right Coordinate
SPR_W_EWDR = End Draw
Write value

OutputFunction Value
Function

Co

nfi

reg :

de

eosFlag :Value:
None
None
Writes to the VDP1 dedicated write system register.

Function

Function Specification

System Register Read Macro

Format
Input

GA

Title

18

No

SPR_READ_REG

8

Uint16 val = SPR_READ_REG(Uint16 reg)reg :Sets the system register type from the definitions
listed below.
SPR_R_EDSR = Transfer End StateSPR_R_LOPR = Process Interrupt Table Address
SPR_R_COPR = Current Process Table Address
SPR_R_MODR = Mode Status

None
val :
Read Value
Reads the register value from the VDP1 dedicated read system
register.

SE

OutputFunction Value
Function

Function Name

VDP1 Expanded Processing Reference

5.1

Data Specifications

Title

Data

Data Specification

Coordinate Indicator Data Type

nti
al

5.0

Data Name

Defined in sega_def.h
{

XyInt

de

typedef struct XyInt
Sint16 x;
Sint16 y;} XyInt;

Title

Data

Data Specification

Gouraud Shading Table

Data Name

Title

Data

Data Specification

Lookup Table Data TypeNo

SprGourTbl{

nfi

typedef struct SprGourTbl
Uint16 entry[4];} SprGourTbl;

No

Data NameNo

SprLookupTbl

Title

Data Specification

Co

typedef struct SprLookupTbl {Uint16 entry[16];} SprLookupTbl;
Data

Data Name

VRAM for Sprite Command Relative
Address Data Type

SprVaddr

SprVaddr;

SE

GA

typedef Uint16

No

User's Guide 2 Graphics Library

19

Data

Data Name

Data Specification

Sprite Command Data Types

SprSp Cmdde{/* Sprite Command Table*//* control word*//* command link*//* drow mode*//* color info.
*//* character address*//* character size*//* point A x*//* point A y*//* point B x*//* point B y*//* point C x*//* point C y*//* point D x*//* point D y*//* goouraud shading table address*//* dummy area
*/

SE

GA

Co

nfi

typedef struct SprSpCmd
Uint16 control;
Uint16 link;
Uint16 drowMode;
Uint16 color;
Uint16 charAddr;
Uint16 charSize;
Sint16 ax;
Sint16 ay;
Sint16 bx;
Sint16 by;
Sint16 cx;
Sint16 cy;
Sint16 dx;
Sint16 dy;
Uint16 grshAddr;
Uint16 dummy;} SprSpCmd;

20

No

nti
al

Title

List of Functions
Function

Function Name
SPR_2DefineWork
SPR_2Initlial

SPR_2SetTvMode
SPR_2FrameChgIntr
SPR_2FrameEraseData
SPR_2SetGourTbl
SPR_2SetLookupTbl
SPR_2SetChar
SPR_2ClrChar
SPR_2ClrAllCharde

VDP1 Expansion Processing Work Area Definition Macro
Initializing Process for the VDP1 Expansion Processing
Library
Set the TV Mode
Set Frame Change V-Blank Interval Count
Set Frame Buffer Erase Data
Set the Gouraud Shading Table
Set the Lookup Table
Set Characters
Clear Character Area
Clear All Character Area
Convert Gouraud Shading Table Number to VRAM Address

SPR_2GourToVRAM
SPR_2LookupTblNoToVRAM
SPR_2CharNoToVRAM
SPR_2OpenCommand
SPR_2CloseCommand
SPR_2LocalCoord
SPR_2SysClip
SPR_2UserClip
SPR_2Line
SPR_2PolyLine
SPR_2PolyGon
SPR_2NormSpr
SPR_2ScaleSpr
SPR_2DistSpr
SPR_2Cmd
SPR_2FlushDrawPrty
SPR_2AllocBlock
SPR_2FreeBlock

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

SE

GA

Co

nfi

Convert Lookup Table Number to VRAM Address
Convert Character Number to VRAM Address
Open Command Write Processing
Close Command Write Processing
Set Local Coordinates
Set the System Clipping Area
Set the User Clipping Area
Draw Line
Draw Polyline
Draw Polygon
Draw Normal Sprite
Draw Scaled Sprite
Draw Distorted Sprite
Set Command
Flush the Command Draw Priority Chain
Allocate VRAM Block area (static)
Free VRAM Block Area (static)

Number

1
2

nti
al

5.2

User's Guide 2 Graphics Library

21

5.3

Function Specifications
Function

Function Name

No

Function Specification

VDP1 Expansion Processing Work Area
Definition Macro

SPR_2DefineWork1

Format

nti
al

Title

SPR_2DefineWork( WORK2D, COMMAND_MAX, GOUR_TBL_MAX,LOOKUP_TBL_MAX, CHAR_MAX, DRAW_PRY_MAX)

WORK2D: Work Area Name
COMMAND_MAX: Maximum Commands
GOUR_TBL_MAX: Maximum Gouraud Shading Tables
LOOKUP_TBL_MAX : Maximum Lookup Tables
CHAR_MAX: Maximum Characters (> 0)
DRAW_PRTY_MAX : Maximum Draw Priority Blocks (>0)
OutputNone
Function Value None
Function
Defines the work area used by VDP1 expanded processing in
the AP data area. When DRAW_PRTY_MAX=1, command
draw priority is not added.

nfi

de

Input

Title

Function

Function Specification

Initializing Process for the VDP1 Expansion
Processing Library

Function Specification

Set the TV ModeGA

Function

Input

22

2

Function NameNo

SPR_2SetTvMode3

void Spr_2SetTvMode(Uint16 mode, Uint16 screenSize,
Uint16 doubleInterlace)mode
screenSize: Sets the definition value for the TV mode.
: Sets the definition value for the screen
resolution that matches the TV mode.
doubleInterlace : Sets the double interlace mode.
None
None
Same as the VDP1 basic processing library TV mode set
routine.

SE

OutputFunction Value
Function

SPR_2Initial

workArea: Work Area Definition Table
None
None
Calls up the initializing routine from the VDP1 basic processing
library and, after initializing the display environment, initializes
the work area for this library.

Title

FormatNo

void SPR_2Initial(Spr2WorkArea *workArea)

Co

FormatInput
OutputFunction Value
Function

Function Name

Function

Function Name

No

Function Specification

Set Frame Change V-Blank Interval Count

SPR_2FrameChgIntr

4

void SPR_2FrameChgIntr(Uint16 interval)interval :V-BLANK interval count
None
None
Set the frame change V-BLANK interval count.
The interval values have different meanings as shown below.
0= Sets the frame change mode to auto change mode and theintervals to 1. Cannot be sychornized with SCL_DisplayFrame ().
1= Sets the frame change mode to auto change mode and theintervals to 1. Can be sychornized with SCL_DisplayFrame ().
0xffff = Does polygon draw frame erase-write inthe undefined interval
manual change mode.
0xfffe = The V-BLANK undefined interval manual change mode. The
user polygon erase-write function is be used for areas not erased.
Changes the frame without confirming VDP1 draw end.
Other = Fixed interval manual change mode defined by setting theinterval count.
b14=0: Does erase-write=1: Does not do erase-write.
Calls up the SCL_SetFrameInterval () routine.
Function

Function Specification

Title

Set Frame Buffer Erase Data
void

Function Specification

Function NameNo

SPR_2FrameEraseData5

SPR_2FrameEraseData(Uint16 rgbColor)

rgbColor: Erase data (RGB color)
None
None
Sets the color to be painted over the erased area in the erase processing.

Function

Function NameNo

Set the Gouraud Shading Table

SPR_2SetGourTbl

6

GA

FormatInput
OutputFunction Value
Function

Co

Title

nfi

de

FormatInput
OutputFunction Value
Function

nti
al

Title

Formatvoid SPR_2SetGourTbl(Uint16 gourTblNo, SprGourTbl*gourTbl);

Input

gourTblNo: Gouraud shading table number
gourTbl: Gouraud shading table
None
None
Copies the contents of the designated Gouraud shading table to
the Gouraud shading table area in VRAM.

SE

OutputFunction Value
Function

User's Guide 2 Graphics Library23

Function

Function Name

No

Function Specification

Set the Lookup Table

SPR_2SetLookupTbl

7

nti
al

Title

Formatvoid SPR_2SetlookupTbl(Uint16 LookupTblNo, SprLookupTbl*lookupTbl)

Input

LookupTblNo : Lookup table number
LookupTbl: Lookup table
None
None
Copies the contents of the designated lookup table to thelookup table area in VRAM.

Title

Function

Function Specification

Set Characters

Function NameNo

SPR_2SetChar

8de

OutputFunction Value
Function

void SPR_2SetChar(Uint16 charNo, Uint16 colorMode,
Unit16 color,Ui nt 16 wi dth, Uni t 16 height , Ui nt 8 *cha r I mage)

Input

charNo: Character Number
colorMode : Color Mode (b5~b3: Same in draw mode word)color: Color data
When color mode = 1, lookup table number.
When color mode = 0, 2, 3, 4, color bank code.
When color mode = 5, it is ignored.
width: X sizeheight: Y size
charImage : Character data pointerWhen = 0, only aquires the character area,
None
None
When the designated charNo is not assigned, or if it is assigned
and the area acquired is too small for the character size, thisfunction calculates the number of blocks required for thecharacters and acquires that number of blocks from the block
pool and copies the character data. If overwrite is possible, thecharacter data will be written to the same area.

Title

GA

OutputFunction Value
FunctionCo

nfi

FormatFunction Specification

Function NameNo

Clear Character Area

SPR_2ClrChar

9void SPR_2ClrChar(Uint16 charNo)

charNo : Character Number
None
None
Clears the VRAM block used by the character of the designatedcharacter number.

SE

FormatInput
OutputFunction Value
Function

Function24

Function

Function Name

No

Function Specification

Clear All Character Area

SPR_2ClrAllChar

10

FormatInput
OutputFunction Value
Function

SPR_2ClrAllChar(void)

None
None
None
Clears the entire character area.

Function Specification
FormatInput
OutputFunction Value
FunctionNo

SPR_2GourTblNoToVRAM

11

SprVaddr addr = SPR_2GourTblNoToVram(Uint16 gourTblNo)

gourTblNo: GouraudShading Table Number
None
addr
: VRAM internal relative address/8
Converts the Gouraudshading table number to VRAM address.

Title

Function

Function Specification

Convert Lookup Table Number to
VRAM Address

Function NameNo

SPR_2LookupTblNoToVRAM

12

SprVaddr addr = SPR_2LookupTblNoToVram(Uint16
LookupTblNo)

Co

FormatFunction NamedeFunction
Convert Gouraud Shading Table Number to
VRAM Address

nfi

Title

void

nti
al

Title

Input
OutputFunction Value
Function

Title

Function
Convert Character Number to VRAM
AddressGA

Function Specification

LookupTblNo : Lookup Table Number
None
addr
: VRAM internal relative address/8
Converts the lookup table number to VRAM address.

No

SPR_2CharNoToVRAM

13

SprVaddr addr = SPR_2CharNoToVram(Uint16 charNo)

charNo : Character Number
None
addr
: VRAM internal relative address/8
Converts the character number to VRAM address.

SE

FormatInput
OutputFunction Value
Function

Function Name

User's Guide 2 Graphics Library25

Function

Function Name

No

Function Specification

Open Command Write Processing

SPR_2OpenCommand

14

Format
Input

nti
al

Title

void SPR_2OpenCommand(Uint16 drawPrtyFlag)

OutputFunction Value
Function

drawPrtyFlag : Command draw priority enable/disable flag.
SPR_2DRAW_PRTY_ON = Enable command draw priority
SPR_2DRAW_PRTY_OFF = Disable command draw priority
None
None
Sets the sprite command write start position to the start of the
VRAM command area. This routine must be called before
calling any of the following routines.

Title

Function

Function Specification

Close Command Write Processing

Function

Function Specification

Set Local Coordinates
void

26

SPR_2CloseCommand

15

Function NameNo

SPR_2Local Coord16

SPR_2LocalCoord(Sint32 drawPrty,

XyInt

*xy)

GA

drawPrty: Command draw priority numberxy: Local coordinate relative coordinate
None
None
Sets the local coordinates.

SE

OutputFunction Value
Function

No

None
None
None
Chains the commands contained in VRAM according to thepriority number when command draw priority is enabled.
It writes the end sprite command and toggles the VRAM area
reference switch.

Title

FormatInput

Function Namenfivoid SPR_2CloseCommand(void)

Co

FormatInput
OutputFunction Value
Function

SPR_2line()
SPR_2ScaleSprdeSPR_2LocalCoord() SPR_2SysClip() SPR_2UserClip()
SPR_2polyLine()
SPR_2Polygon() SPR_2NormSpr()
SPR_2DistSpr()
SPR_2Cmd()

Function

Function Name

No

Function Specification

Set the System Clipping Area

SPR_2SysClip

17

FormatInput
OutputFunction Value
Functionvoid

SPR_2SysClip(Sint32 drawPrty,

Function Specification

Set the User Clipping Area
void

SPR_2UserClip(Sint32 drawPrty,

Draw Linenfi

Function Specification

18

XyInt

xy[2])

Function NameNo

SPR_2Line19

void SPR_2Line(Sint32 drawPrty, Uint16 drowMode,
Uint16 color, XyInt xy[2], Uint16 gourTblNo)

GA

drawPrty
drowMode
color
xy[2]
gourTblNo: Command draw priority number: Draw Mode(Same in draw mode word): Color mode or lookup table number: 2 points of the line
: GouraudShading Table Number
NO_GOUR(=0xffff) = No Gouraud shading table
designation

None
None
Draws a line.

SE

OutputFunction Value
Function

SPR_2UserClip

Co

Function

Input

No

drawPrty: Command draw priority number
xy [0]: Upper left coordinates
xy [1]: Lower right coordinates
None
None
Set the user clipping area.

Title

Format*xy)

Function NamedeFunction

OutputFunction Value
Function

XyInt

drawPrty: Command draw priority numberxy: Lower right coordinates
None
None
Set the system clipping area.

Title

Format
Input

nti
al

Title

User's Guide 2 Graphics Library27

Function

Function Name

No

Function Specification

Draw Polyline

SPR_2PolyLine

20

Formatvoid SPR_2PolyLine(Sint32 drawPrty, Uint16 drowMode,
Uint16 color, XyInt xy[4], Uint16 gourTblNo)

Input

drawPrty
drowMode
color
xy[4]
gourTblNo

OutputFunction Value
Function

None
None
Draws a polyline.

Function Specification

Draw Polygon

deFunction: Command draw priority number: Draw Mode(Same in draw mode word): Color mode or lookup table number: 4 points of the polyline: GouraudShading Table Number
NO_GOUR(=0xffff) = No Gouraudshading table
designation

Function NameNo

SPR_2PolyGon

21

nfi

Title

Formatvoid SPR_2Polygon(Sint32 drawPrty, Uint16 drowMode,
Uint16 color, XyInt xy[4], Uint16 gourTblNo)

Input

drawPrty
drowMode
color
xy[4]
gourTblNo

OutputFunction Value
Function

None
None
Draws a polygon.

Co: Command draw priority number: Draw Mode(Same in draw mode word): Color mode or lookup table number: 4 points of the polygon: GouraudShading Table Number
NO_GOUR(=0xffff) = No Gouraudshading table
designation

GA
SE
28

nti
al

Title

Function

Function Name

No

Function Specification

Draw Normal Sprite

SPR_2NormSpr

22

nti
al

Title

Formatvoid SPR_2NormSpr(Sint32 drawPrty, Uint16 dir, Uint16
drowMode, Uint16 color, Uint16 charNo, XyInt *xy,
Uint16 gourTblNo)

Input

drawPrty
dir

chrNo
xy
gourTblNo

None
None
Draws a normal sprite.

nfi

OutputFunction Value
FunctiondedrowModecolor: Command draw priority number: Character reverse instructions (b11~b8: same incontrol word): Draw Mode(Same in draw mode word): Color code or lookup table number
When 0xffff, The color data set using
SPR_2SetChar () is set.
: Character Number: Upper left Coordinates: GouraudShading Table Number
NO_GOUR(=0xffff) = No Gouraudshading table
designation

Function

Function Specification

Draw Scaled Sprite

FormatInput

No

SPR_2ScaleSpr23

void SPR_2ScalSpr(Sint32 drawPrty, Uint16 zoomDir,
Uint16 drowMode, Uint16 color, Uint16 charNo, XyInt
xy[2], Uint16 gourTblNo)

drawPrty
zoomDirGA

drowMode
color
charNoxy [2]
gourTblNo

OutputFunction Value
FunctionSE

Function Name

Co

Title

: Command draw priority number: Zoom and character reverse instructions(b11~b8, b5, b4: same in control word): Draw Mode(Same in draw mode word): Color code or lookup table number
When 0xffff, The color data set using
SPR_2SetChar () is set.
: Character Number: 2 point vertex, or fixed point coordinate/display width: GouraudShading Table Number
NO_GOUR(=0xffff) = No Gouraud shading table
designation

None
None
Draws a scaled sprite.

User's Guide 2 Graphics Library29

Function

Function Name

No

Function Specification

Draw Distorted Sprite

SPR_2DistSpr

24

Formatvoid SPR_2DistSpr(Sint32 drawPrty, Uint16 dir, Uint16
drowMode, Uint16 color, Uint16 charNo, XyInt xy[4],Uint16 gourTblNo)

Input

drawPrty
dircharNoxy[4]gourTblNo

None
None
Draws a distorted sprite.

Function

Function Specification

Set Command

FormatInput

No

SPR_2Cmd

25

void SPR_2Cmd(Sint32 drawPrty, SprSpCmd *spCmd)

drawPrty: Command draw priority number
spCmd: 32 byte sprite command.
None
None
Sets the designated sprite command in the user command area
as is.

GA

OutputFunction Value
Function

Function Specification

Function

Function Name

No

Flush the Command Draw Priority Chain

SPR_2FlushDrawPrty

26

void

SPR_2FlashDrawPrty(void)

None
None
None
Chains the commands contained in VRAM according to thepriority number when command draw priority is enabled andclears the draw priority control area.

SE

FormatInput
OutputFunction Value
Function30

Function Name

Co

Title

nfi

OutputFunction Value
Function: Command draw priority number: Character reverse instructions (b11~b8: same incontrol word): Draw Mode(Same in draw mode word): Color code or lookup table number
When 0xffff, The color data set using
SPR_2SetChar () is set.
: Character Number: 4 vertex points: GouraudShading Table Number
NO_GOUR(=0xffff) = No Gouraud shading table
designation

dedrowMode
color

Title

nti
al

Title

Function

Function Name

No

Function Specification

Allocate VRAM Block area (static)

SPR_2AllocBlock27

Function

SprVaddr

addr =SPR_2AllocBlock(Uint16 size)

size
None
addr

: Block size (32 bytes is 1 unit): Returns VRAM relative address /8 of the acquired
block area positions.
Acquires from the VRAM block pool the designated size block.
This routine cannot be freed externally, but the specification
was included in the event that functions were added to thislibrary.

deFormatInput
OutputFunction Value

nti
al

Title

Title

Function

Function Specification

Free VRAM Block Area (static)

FormatInput

Function NameNo

SPR_2FreeBlock28

void SPR_2FreeBlock(SPRVaddr addr, Uint16 size)

size
None
None
Frees the designated block area from the VRAM block pool.
This routine cannot be freed externally, but the specification
was included in the event that functions were added to thislibrary.

SE

GA

Co

OutputFunction Value
Function: Returns the freed block area in VRAM relative
address/8.
: Block size (32 bytes is 1 unit)

nfi

addr

User's Guide 2 Graphics Library

31

VDP1 3D Reference

6.1

Data Specifications

nti
al

6.0

Title

Data

Data Name

Data Specification

Cluster Definition

SprCluster

No

nfi

de

typedef struct SprCluster {Uint16no;/* Cluster Number*/
Uint16angleSeq; /* Rotation order*/
MthXyzangle;/* Rotate on parent cluster coord. system */MthXyzpoint;/* Base coord. parent cluster coor. sys.*/
SprObject3D*object/* 3D Object*/
SprCluster*next;/* Next cluster*/
SprCluster*child;/* child cluster*/
SprInbetInf*inbetInf;/* Inbetween object polygon infor. */void(*transStart) (SprCluster*);/* Before coord. coversion start, user*//* callbak routine */void(transEnd) (SprCluster*, SprObject3D*, MthMatrix, MthXyz*);/* Before coord. coversion end, user*//* callbak routine */void*context; /* User context area*/
} SprCluster;“no” is used by the user callback routine to identify the cluster table, it canbe set as desired.

Co

angleSeq = ROT_SEQ_ZYX : Rotate object in Z→Y→X order.
= ROT_SEQ_ZXY :
“
Z→X→Y
“
= ROT_SEQ_YZX :
“
Y→Z→X
“
= ROT_SEQ_YXZ :
“
Y→X→Z
“
= ROT_SEQ_XYZ :
“
X→Y→Z
“
= ROT_SEQ_XZY :
“
X→Z→Y
“

If a 3D object, the next cluster or a child cluster will not connect, each of theobject, the next cluster, and the child are set to 0.
inbetInf is 0 if there is no inbetween-object polyon information.

GAtransStart indicates the user call back routine that is called before coordinate
conversion begins. In the routine, items such as cluster movement andobject data changes, take place. This is 0 if there is no call back routine.
[transStart routine calling sequence]SEvoid transStart(SprCluster *cluster);cluster: Auto cluster table32

[transStart routine calling sequence]nti
altransEnd indicates the user call back routine that is called after the coordinate
conversion begins. This call back routine is called up for each 3D object
connected to the object. This is 0 if there is no call back routine.

devoid transEnd(SprCluster *cluster, SprObject3D *object,
MthMatrix *worldMatrix, MthXyz *worldVertPoint);
cluster: Auto cluster tableobject: 3D object tableworldMatrix: Conversion matrix (3 column, 4 row) to word coord. systemworldVertPoint : vertex coordinate value table in the world coordinate system.
(Returns when #define SPR_3NEED_WORLD_VERT is
defined with the 3D sprite work area definition macro.)

SE

GA

Co

nfi

Context indicates the context area that is used for each cluster by the user callback routine.

User's Guide 2 Graphics Library

33

Data

Data Name

Data Specification

Object Definition

SprObject3D

No

nti
al

Title

de

typedef struct SprObject3D {Uint16no;/* Object Number*/
Uint16
dispFlag;/* Display Flag*/
Uint16
vertCount; /* Vertex count*/Uint16surfaceCount; /* Surface count*/
MthXyz*vertPoint; /* Vertex coordinate table*/
MthXyz*vertNormal;/* Vertex line vector table*/
SprSurface*surface/* Surface definition table*/
MthXyz*surfaceNormal;/* Surface vector table*/
MthXyz*surfacceVert;/* Surface coord. table*/
Uint16**shdIdxTbl;/* Shading Index Table*/
Fixed32
surfNormK;/*Correction calc. for surface normal vector */SprObject3D*next;/* Next 3D Object*/} SprObject3D;“no” is used by the user call back routine to identify the cluster table; it canbe set as desired.
Display Polygon
Display Polyline
Double surface polygon
No Shading
Flat Shading
Gouraud Shading
Inbetween-object polygon object

nfi

dispFlag b15,b14 = 00:= 10:
b12 = 1:
b9,b8
= 00:
01:
10:
b4
= 1:
vertNormal
surface: Set when using Gouraud shading.
: Pointer to the table that defines the vertexes andsurfaceNormal: Pointer to the table that defines the line for eachsurfaceVert

surface.
: Sets the coordinate table pointer of a representative
point (center point) on the surface used to calculate
brightness.
: Sets the shading table index table when using theshading table to do flat shading. If this parameter is
set while setting Gouraud shading, the shdIdxTbl [0]becomes the Gouraud shading gray code table. If
this parameter is set in flat shading while surface
definition draw mode is set to texture, the shdIdxTbl[0] becomes the flat shading gray code table.
: Set when surface normal vector calculation using the
SPR_SetNormVect () routine is used, or when thisobject is an inbetween-object polygon object. For
details, see the mathmatical calculation library
MTH_ComputeNormVect () routine, surfNorm
parameter. When an inbetween-object polygon
object is utilized, a negative value must be used.

GA

shdIdxTbl

Co

color information that make up each surface.

SE

surfNormK

34

nti
al

If the normal vector table, shading index table, ornext object is not connected, each of vertNormal,
shdInxTbl, and next is set to 0.

The shading table is set at 32 tones in the RGB code
format.
Uint16 shadingTbl[32];0 ← dark

bright → 31

Title

Data

Data Specification

Surface DefinitiondeIf the line vector ta If surface polygon designation is1, half of polygon data indicates both surfaces.

Data NameNo

SprSurface

nfi

typedef struct SprSurface {Uint16
vertNo[4]; /* Vertex number to configure the surface */Uint16
drawMode;/* Draw Mode*/
Uint16color;/* Color Data*/
} SprSurface;drawMode b15,b14 = 00:
01:
10:
11:

After a coordinate change, the lowest value of the
4 coordinates is used for z Sort No Shading
After a coordinate change, the highest value ofthe 4 coordinates is used for z Sort No Shading
After a coordinate change, the middle value of the
4 coordinates is used for z Sort No ShadingCo

b13,b12 = 00:

color is color code
color is the texture character number
color is the shading table index number
color is the auto shading base RGB code

01:
10:

b11-b0:Same as the sprite draw mode word.

If the texture was set using the drawMode, the color bit changes as follows.
color b15,b14 indicate texture reverse mode.
No Reversal
Reverse left-rightReverse Up-downReverse left-right, up-down

b13-b0

Luxture character number

:

SE

GA

b15,b14 = 00:
01:
10:
11:

User's Guide 2 Graphics Library35

TitleData

Data Name

Data Specification

Inbetween-object polygon object information SprInbetInf

No

nti
al

typedef struct SprInbetInfo {Sint32
vertCount; /* Number of vertexes called*/
SprObject3D*fromObj;/* Connecting vertex data object*/
Uint16*fromVertNo;/*Called vertex number distribution*/
SprObject3D*toObj;/* Connecting vertex data set object */Uint16*toVertNo; /* Set vertex number distribution*/
SprInbetInf*next; /* Next inbetween-object polygon info. */} SprTexture;

If there is no inbetween-object polygon object information, next is set to 0.
Data

Data Name

Data Specification

Texture Table

SprTexture

No

de

Title

typedef struct SprTexture {Uint16charNo;/* Character number*/
Uint16
ColorMode; /* Color Mode
Uint16
Color;/* Color data
Uint16width;/* Character width
Uint16height;/* Character height
Uint8*charData; /* Character data pointer
SprLookupTbl *lookupTbl; /* Lookup table pointer} SprTexture;

nfi

*/
*/
*/
*/
*/
*/

Co

SprTexture texture[n]; The charNo of the last entry is set to 0xffff(stopper).
colorMode : b5-b3 are the same as sprite draw mode word.
color: Color data
When color mode = 1, lookup table number.
When color mode = 0, 2, 3, 4, color bank code.
When color mode = 5, it is ignored.
Title

Data

Data Specification

3D Status Data Table

Data NameNo

Spr3DStatus

SEGA

typedef struct Spr3dStatus {MthXyzlightAngle;/* Light source angle
MthXyzviewCoordPoint; /* View Coord. sys. focal point
MthXyzviewPoint;/* View coordinate
MthXyzviewAngle;/* View angle
Sint32
viewAngleSeq;/* View angle rotate sequence
Sint32
zSortMode;/* Z sort Z coord. value use mode
Fixed32 zSortZMin;/* Min value of Z sort view coord.
Fixed32 zSortZMax;/* Max value of Z sort view coord.
Fixed32 clipZMin;/* Min Z value of view coord. clip
Fixed32 clipZMax;/* Max Z value of view coord. clip
Sint32
clipLevel;/* Clipping Level
MthXyzunitPixel;/* Screen pixels for x, y1.0
} Spr3dStatus;

36

*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/

List of Functions
Function Name
SPR_3DefineWork
SPR_3Initial

SPR_3SetClipLevel

SPR_3SetPixelCount
SPR_3SetLight
SPR_3SetView

SPR_3MoveCluster
SPR_3DrawModel
SPR_3Flush
SPR_3SetTexture
SPR_3ClrTexturedeFunction
3D Sprite Work Area Definition Macro
Initialize 3D Sprite Display
Set Clipping Mode
Set Unit Pixel Count
Set Light
Set View
Move Cluster
Record Model
Draw Model
Set Texture
Clear Texture Area
Function call for all clusters
Change texture color data
Set Z sort minimum and maximum
Get current 3D status data
Set object normal surface vector
VDP1 high speed draw parameter set
Function Specifications

SPR_3CallAllCluster
SPR_3ChangeTexColor
SPR_3SetZSortMinMax
SPR_3GetStatus
SPR_3SetSurfNormVect

nfi

6.3

SPR_3SetDrawSpeed

Function

Function Specification

VDP1 3D Work Area Definition Macro

Input

Function NameNo

SPR_3DefineWork1[#define SPR_3USE_DOUBLE_BUF][#define SPR_3NEED_WORLD_VERT]#include “sega_spr.h”
SPR_3DefineWork(WORK3D, OBJ_SURF_MAX, OBJ_VERT_MAX)

WORK3D: Name of work area
OBJ_SURF_MAX: Maximum surfaces of an object
OBJ_VERT_MAX: Maximum vertexes of an object
Defines the work area used by VDP1 3D display in the AP dataarea.
The #define SPR_3USE_DOUBLE_BUF can be skipped byusing two of the designated object vertex coordinates or thesurface brightness tables, and running the DSP coordinate
conversion and SH processing in parallel to increase speed.
The #define SPR_3NEED_WORLD_VERT can be skipped by
notifying the vertex coordinate table in the world coordinate
system when the coordinate conversion results are notified.
#define SPR_3USE_DOUBLE_BUF and #define
SPR_3NEED_WORD_VERTH must be defined before defining#define “sega_spr.h”.

SE

GA

Function

Co

Title

FormatNumber
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

nti
al

6.2

User's Guide 2 Graphics Library37

Function

Function Name

No

Function Specification

Initialize 3D VDP1

SPR_3Initial2

void SPR_3Initial(Spr3WorkArea*workArea)

Title

Function

Function Specification

Set Clipping ModedeworkArea: Work area definition table
None
None
Initializes the VDP1 3D display.
· The view point is the world coordinate system base point,
the focal angle is (0,0,0) (Z positive direction), and rotation is
set in order of X →Y→ Z.
· The light source direction is (0,0,0) (Z positive direction).
· The clipping level is 2, the Z coordinate are from -0.005 to theminimum negative value display range max/min values ofthe view coordinate system.
Function NameNo

SPR_3SetClipLevel3

nfi

FormatInput
OutputFunction Value
Function

nti
al

Title

Formatvoid SPR_SetCl i pLevel( Ui nt 16 c li pLevel, Fi xed32 c li pZmi n,
c li pZmax)

Input

clipLevelFi xed32: Clipping level number
0= No clipping

Title

Function Specification
FormatInput

clipZmin: View coordinate system, Z coordinate min. clip value
clipZmax: View coordinate system, Z coordinate max. clip value
None
None
Sets the polygon clipping level. The upper level includes thefunctions of the lower level. Clipping can be done in level 1,
with the polygon max Z coordinate value in the view
coordinate system, but that range has to be set in clipZmin andclipZmax before executing SPR3_DrawMode().

GA

OutputFunction Value
FunctionCo

1= Clip at view coord. system Z range (After coord. conversion)
2= Delete polygons that are not on screen. (After transparent conversion)
3= Clip the frame buffer boundary (After transparent conversion)

Function NameNo

Set Unit Pixel Count

SPR_3SetPexelCount

4

void SPR_3SetPi xelCount ( Ui nt 16 pi xelCount X, Ui nt 16 pi xelCount Y)

pixelCountX: Screen X unit pixel countpixelCountY: Screen Y unit pixel count
None
None
Sets the screen pixel count for converting the screen totransparent XY at 1.0 each. Each is set at 256 when initialized.

SE

OutputFunction Value
Function

Function38

Function Specification
FormatSet Light

No

SPR_3SetLight
void SPR_3SetLight (Uint16 moveKind, MthXyz*lightAngle)

5

moveKindlightAngle

OutputFunction Value
Function

None
None
Sets the light angle.

Title

Function

Function Specification
FormatSet View

Function Name

SPR_3SetView
void SPR_3SetVi ew( Ui nt 16 moveKi nd, Mt hXyz *pi votVi ewPoint ,Mt hXyz *vi ewPoint , Mt hXyz *vi ewAngle, Ui nt 16 angleSeq)

moveKindNo

6: Type of move amountb0:
0= Relative Move
1= Absolute moveb1:
0= Rotate move amount is angle
1= Rotate move amount is unit vector
viewPoint: Position of viewpoint or amount ofhorizontal move.
Ignored when it is 0 at the rotation position of
viewpoint within the world coordinate system.
viewAngle: If the viewpoint rotation amount is an angle,
the designated range of the move is calculated
according to the equation below. Vector
designations are converted to angles.
FIXED(-180.0)≤ Rotate amount≤FIXED(180.0)
angleSeq: Viewpoint rotation operation
viewCoordPoint: horizontal movement or view point in theview coordinate system.
Ignored when 0.
Initial value is (0, 0, 0).
None
None

SE

GA

Co

Input

: Type of move amountb0:
0= Relative Move
1= Absolute moveb1:
0= Rotate move amount is angle
1= Rotate move amount is unit vector: If the light source rotation amount is an angle,
the designated range of the move is calculated
according to the equation below. Vector
designations are converted to angles.
FIXED(-180.0)≤ Rotate amount≤FIXED(180.0)
Rotate operation is done in X→Y→Z order.

nfi

Input

Function NamentialFunction

de

Title

OutputFunction Value

User's Guide 2 Graphics Library39

Viewpoint is moved within the world coordinate system; that
position is center for rotation. If there is a viewCoordPoint
designation, the viewpoint is moved to the designated position
from the start point using the view point coordinate system.

ntialFunctionangleSeq = ROT_SEQ_ZYX : Rotate object in Z→Y→X order.
= ROT_SEQ_ZXY :
“
Z→X→Y
“
= ROT_SEQ_YZX :
“
Y→Z→X
“
= ROT_SEQ_YXZ :
“
Y→X→Z
“
= ROT_SEQ_XYZ :
“
X→Y→Z
“
= ROT_SEQ_XZY :
“
X→Z→Y
“
Function

Function Name

No

Function Specification

Move Cluster

SPR_3MoveCluster

7

Formatvoid SPR_3MoveCluster(SprCluster *cluster, Uint16
moveKind, MthXyz *angle,MthXyz *point)

Input

cluster:
moveKind :Title

Function Specification
FormatInput

Function

Function Name

No

Record Model

SPR_3DrawModel

8

void

SPR_3DrawModel (SprCluster*rootCluster)

rootCluster : Pointer to the root cluster table of the model to be
displayed.
None
None
Records the model.

SE

OutputFunction Value
Function

nfi

point
:
None
None
Rotates the cluster move, executes in the order of the horizontal
move. When either angle or point are 0, they are ignored.

GA

OutputFunction Value
Function:

Pointer to the cluster table to be moved
Type of move amountb0: 0= Relative Move
1= Absolute moveb1: 0= Rotate move amount is angle
1= Rotate move amount is unit vector
If the amount is an angle, the designated rangeof the move is calculated according to theequation below. Vector designations areconverted to angles.
FIXED(-180.0)≤ Rotate amount≤FIXED(180.0)
Amount of horizontal movement

Co

angle

40

de

Title

Function

Function Name

No

Function Specification

Draw Model

SPR_3Flush9void SPR_3Flush (void)

None
None
None
Draws the model.
Completes Z sort of the polygon group’s viewpoint coordinate
system registered by the SPR_3DrawMode ().

Title

Function

Function Specification

Set Texture
void

SPR_3SetTexture(SprTexture

Title

Function

Function Specification

Clear Texture Area
void

SPR_3ClrTexture(SprTexture

Co

FormatInput
OutputFunction Value
Function

Title

SPR_3SetTexture

10*texture)

Function NameNo

SPR_3ClrTexture

11*texture)texture : Texture table pointer
None
None
Clears the texture.

Function

Function Name

No

Function call for all clusters

SPR_3CallAllCluster

12GA

Function SpecificationNo

texture : Texture table pointer
None
None
Sets the texture.

nfi

FormatInput
OutputFunction Value
Function

Function NamedeFormatInput
OutputFunction Value
Function

nti
al

Title

Formatvoid SPR_3CallAllCluster(SprCluster *cluster
void (*userFunc) (SprCluster*))

Input

cluster : Root cluster table pointeruserFunc: User function
None
None
Calls the indicated function using the class table from eachcluster connected to the root cluster as parameters.

SE

OutputFunction Value
Function

User's Guide 2 Graphics Library41

Function

Function Name

Function Specification

Change texture color data

SPR_3ChangeTexColor 13

void SPR_3ChangeTexColor (Uint16 charNo, Uint16 color,
SprLookupTbl *lookupTbl)

Inputchar No : Character number
color: Color data
lookup table number or color bank code
lookupTbl: Lookup table pointer
None
None
Changes the texture color data and color lookup table indicatedby the registered character number. If lookupTbl is 0, only thecolor is changed, the color lookup table is not registered.

Title

Function

Function Specification

SetZ sort min.imum and maximum

deFormatOutputFunction Value
Function

Function NameNo

SPR_3SetZSortMinMax

14

void SPR_3SetZSortMinMax1 (Uint16 zSortMode,
Fixed32 zSortMin, Fixed32 zSortMax)

Input

zSortMode: Use Z sort Z coordinate value mode
ZSORT_FLOAT_MODE=Float mode
ZSORT_FIXED_MODE= Fized modezSortMin: Min value of view coordinate Z sort Z coordinate
zSortMax: Max value of view coordinate Z sort Z coordinate
None
None
zSortMin and zSortMax are parameters used to set the Z range
used to allocate the draw number blocks and is set before the
SPR3DrawMode () routine is executed.
If the Z coordinate value mode is set to the float mode, thenzSortMin and zSortMax are used as initial values. After that,the maximum and minimum Z coordinate values of the view
coordinate system from the last draw is used for the Z range.
In the fixed mode, the designated zSortMin and zSortMax
values are used.
When initial values are set during the SPR_3Initial () routine,zSortMin is set at -10.0 and zSortMax at 0.0; the Z coordinate
value mode is set to floating. The view coordinate system
heads in the minus direction when the view coordinate value is0.0. The block used for Z sort is the VDP1 expanded processdraw priority block. To make Z sort faster, the priority blocks
in the 2D work area definition must be set to maximum.
Also, when doing Z sort, the drawPrtyFlag in the
SPR_2OpenCommand () routine must be set to
SPR_2DRAW_PRTY_ON.

SE

GA

Co

nfi

FormatOutputFunction Value
Function

42

No

nti
al

Title

Function

Function Name

No

Function Specification

Get current 3D status data

SPR_3GetStatus

15

FormatInput
OutputFunction Value
Functionvoid

SPR_3GetStatus(Spr3dStatus *spr3dStatus)

None
spr3dStatus : 3D status data table pointerNone
Gets the current 3D status data.

Title

Function

Function Specification

Set object normal surface vector

SPR_3SetSurfNormVect (SprObject3D

Function

Function Specification

VDP1 high speed draw parameter set

Function NameNo

SPR_3SetDrawSpeed

17

Co

void
SPR_3SetDr awSpeed ( Si nt 32 hssFl ag, Si nt 32 eosFl ag, Si nt 32
pc lpFl ag)

hssFlag : High speed shrink flag
(Set in the texture polygon draw mode)0= Precision priority draw (default)
1= Speed priority draw
eosFlag : Sampling coordinates of the source texture when
speed priority is selected.
0= Even coordinate sampling (default)
1= Odd coordinate sampling
pclpFlag : Preclipping enable/disable flag
0= Enable (default)
1= Disable
None
None
Sets the high speed draw mode in the VDP1 sprite command
draw mode. See the VDP1 hardware manual about high speed
clipping and preclipping.

GA

Input

*obj)

None
obj
: 3D object
None
Calculates the normal vector from the designated 3D object
surface vertex and sets the normal surface vector table. The
surface vertex order of the normal vector is clockwise andvertical. The 3D object surfNormK parameter must be set.

Title

FormatNo

SPR_3SetSurfNormVect 16

de

void

Function Name

nfi

FormatInput
OutputFunction Value
Function

nti
al

Title

SE

OutputFunction Value
Function

User's Guide 2 Graphics Library

43

SE

GA

Co

nfi

de

nti
al

(This page is blank in the original Japanese document.)

44

nti
al

VDP2 Library
1.0 Guidede1.1 Objective· Automates hardware-related processing such as VDP1 initialization, register
operation, etc., to reduce the load on the application author.
· Using this library enables one to set the registers without really being aware of
V-BLANK. Automates hardware-related processing related to V-BLANK interrupt
processing to reduce the load on the application author. Also supplies the VBLANK interrupt processing routine and frame change settings routine needed todisplay VDP1 and VDP2.
1.2 Explanation
VDP2 is only allowed to access a register or color RAM during V-BLANK. In addition, it cannot read many registers.

nfi

The VDP2 library contains a register buffer; normal reading and writing to registers
occur in this buffer and are copied to the register during the next V-BLANK. (Seethe reference for more information on the register buffer.) The functions of thislibrary are divided into larger groups as shown below.

Co

Initializing Function

Must be executed first when starting up the VDP2 library.
Table Creation & Data Set Functions

Refer to the VDP2 user’s manual or reference manual when setting each of theparameters.
Functions Relating to Screen Display Operations

GA

Enables scroll screen movement, enlarge/reduce, and rotation.
Line Screen Setting Functions

Sets line screen and back screen data.
Window Setting Function

Executes window settings.
Functions Related to VDP1

SE

Functions that must be set in order to display VDP1 (sprite) frame buffer contents.
Functions related to Color RAM

Used to set or change the pallet.

User's Guide 2 Graphics Library45

Functions Related to PriorityntialGets information and sets priorities.
Color Calculation Functions

Processes color calculations. Used to add gradated effects and depict translucent
objects or cause ghosts to appear, space ships to warp out, etc.
Color offset Functions

Processing that adds offset to color. Used for fade-in, fade-out, black-out, whiteout, etc. Also effective when used to change a blue sky to a red sunset sky.
Other Special Effect Functions

Register Buffer W
rite / Read Macrode

Used for shade calculations, adding line color screen, and shadow bit settings.
(Line color screen can only be used in color calculations.)

Co

nfi

Supplies the bit access macro for reading the register buffer of priority-related
functions used by this library. There are about 90 varieties, each of read and write
macros.
• Write macro command line
SCL_SET_<BitName>(arg);• Read macro command line
ret = SCL_GET_,BitName>();<BitName> : Bit name (Refer to “VDP2 User’s Manual”)
arg, ret: Refer to the “VDP2 User’s Manual”
V-BLANK Interrupt Processing Functions

Explains the frame change process used to display sprite (VDP1) and scroll (VDP2)
through the V-BLANK VDP interrupt routine supplied by this library.
Frame Change Process

GA• Auto Change Mode (Non-synchronous Mode)
Every 1/60th of a second, the VRAM is automatically changed and erase data is
written to the frame buffer and the sprite is written (frame change). For thisreason, the SCL_DisplayFrame() routine does not need to be called.

SE• Fixed Interval Manual Change (Synchronous Mode)
If a number greater than one is set into the SCL_SetFrameInterval, describedlater, then frame change is executed by the V-BLANK VDP interrupt routine
one time for each interval count. However, to accomplish this, command write
to VRAM must end and the SCL_DisplayFrame() routine must be called.
Waiting for frame change is done within the SCL_DisplayFrame routine.

46

nti
al

• Undefined Interval Manual Change Mode (Synchronous Mode)
The undefined interval manual change mode starts when 0xffff is set as the VBLANK interval count in the SCL_SetFrameInterval().
In the undefined mode, the frame is changed simultaneously with the first VBLANK interrupt when the VRAM command write ends and the
SCL_DisplayFrame routine is called. However, before frame change, the VDP1
must have finished writing to the frame buffer or it goes into a loop to wait.
Also, the frame buffer cannot be erased during frame change, so the user must
use the VRAM command lead to clear the frame buffer with a polygon.
V-BLANK Interrupt ProcessingdeWhen the user uses the sprite (VDP1), or scroll (VDP2) display library,
INT_SetScuFunc() must be used to set the following routine that is used to create the
V-BLANK interrupt routine. Also, an independent interrupt process routine can beused without calling the following routines.
• V-BLANK Start VDP Interrupt Process Routine

nfi

If the fixed interval manual change mode is being used, the V-BLANK repetitions
are counted and the frame change flag is set to on when the interval count isreached. In the undefined interval manual change mode, the flag is always on.

Co

Also, by writing the contents of the scroll data to the scroll register during VBLANK with the frame change timing in this access routine, scroll motion andsprite frame change are simultaneous. If this method does not match AP, an
independent interrupt routine must be used.
• V-BLANK End VDP Interrupt Process RoutineSEGA

If the frame change flag is on, frame change is executed.

User's Guide 2 Graphics Library

47

nti
al

1.3
Basic Library Usage
Basic VDP2 library usage is contained in “15.1 Operation Flow in Chapter 15 Using
VDP2, of the VDP2 User’s Manual”. Follow that flow with the appropriate library.

VRAM mapping is particularly important for using this library; along with thesetting of cycle patterns which have a high degree of freedom in the settings, but arealso quite complex, and sample programs are explained.
VRAM Mappingde

VRAM and Data Size Comparison Chart

VRAM A0

16,770,000 Color Bit
Map Data(512x256)

VRAM A1

32,000 Colors (2048colors) Bit Map Data
(512x256)
2M bit4M bitnfi

VRAM B0

Rotation Parametert
Coefficienct Table(2word)2M bit16 Colors Bit Map Data
(512x256)0.5M bit

Co

VRAM B1

256 Colors Bit Map
Data (512x256)1M bit

Rotation Parameter
Coefficienct Table(1word) 1M bit

GA

Figure 1 VRAM and DA TA Size Comparison

Effective use of VDP2 depends on how the data is placed in the VRAM.
For example, to display a 16,770,000 color bitmap image, all of the VRAM would be
filled with no room to display other images.

SE

Next, VRAM mapping examples will be explained. The image data used in theexample is bitmap data. This is because the data size is fixed and can be used for
direct mapping. In the cell format, the data size changes depending on how the datais stored. If there are many common parts, the memory usage is more efficient than
bitmapping.

48

[Example 1]

Using Five Screens Displayable by the VDP2ntialOther than NBG2 and NBG3, all data is bitmap. If rotating screen 1 is
256 colors and the normal 4 screens are 16 colors, it will be as follows.
To move the rotating screen, a rotation parameter table is required. If
X and Y axis rotation is to be done, a rotation parameter coefficient
table must also be prepared.

VRAM A1

VRAM B0RBG 0Rotation Parameter
Coefficienct Table (1word)

Co

VRAM B1

256 Colors Bit Map
Data (512x256)1M bit

nfi

VRAM A0de

In this library, the rotation parameter coefficient table is usuallyplaced at the lead of each bank (VRAM A0, VRAM A1, VRAM B0,
VRAM B1). However, the X and Y axis rotation can only be used in
2kWord (4kByte). This allows the remaining area (124kByte) to be
filled with the rotation parameter table, line scroll table, line color
table, back screen data, etc. (1M bit = 128kByte)

Rotation Parameter Table
16 Colors Bit Map Data
(512x256)0.5M bit
16 Colors Bit Map Data
(512x256)0.5M bit
Character Parameter
Data Pattern Name Data
Character Parameter
Data Pattern Name Data

NBG 0
NBG 1
NBG 2
NBG3

SE

GA

Figure 2 Using 5 Screens that can be displayed by the VDP2

User's Guide 2 Graphics Library49

[Example 2]

Using 2 Rotation ScreensntialOnly one type of rotation data, such as character data (bitmap data),
pattern name data, rotation parameter coefficient data, etc., can beplaced in each bank. Furthermore, RGB1 placement is fixed withcharacter pattern data in VRAM B0, and pattern name data is VRAM
B1.

256 Colors Bit Map
Data (512x256)1M bit

VRAM A1

Rotation Parameter
Coefficienct Table (1word)

RBG 0

de

VRAM A0

Rotation Parameter Table
Character Pattern Data

VRAM B0

RBG 1

1Mbit

Pattern Name Data

nfi

VRAM B1

1Mbit

SE

GA

Co

Figure 3 Using 2 Rotation Screens

50Setting VRAMAssignments and Cycle PatternsntialVDP2 displays by reading from VRAM at the same time as the scroll screen data is
being scanned on the TV. VRAM access during display is either 4 times (hi-res
display) or 8 times (normal display) being one access unit (1 cycle) with cycles being
repeated.
There is a cycle pattern register prepared for each VRAM and bank, VRAM
A(VRAM A0, VRAM A1) and VRAM B (VRAM B0, VRAM B1). Access is displayed
as 4 bit for one command. (Refer to “3.4 VRAM Access during display in the VDP2
User’s Manual”).

de

The number of accesses set in the cycle pattern depends on the data type and use.
These need to be applied to the cycle pattern table.
Table 1 Access count for the required pattern name table data for 1 cycle

Item
Compression
VRAM access needed for 1 cycle

NBG0 ~ NBG3
Times 1Times 1/2 Times 1/4

2

4

nfi

1

RBG0, RBG1–
8

Table 2 Data Access for character pattern data (bitmap pattern data)

Item

NBG0 ~ NBG3TV Display Mode
Character colors

VRAM access neededfor one cycle

16

256

NormalHi-resCustom

2048

32768

16770000

–

–

–

1

1/2 1/4

1

1/2

1

1

1

–

–

–

1

2

2

4

4

4

8

8

4

4

Co

Compression Rate

RBG0, RBG1

4

SE

GA

For example, with 16 color bitmap data (uses character pattern data), up to four setsof 512 x 256 data can placed in just one or in either VRAM A or VRAM B. If this isapplied to the normal scroll screen, the access amount would total 4 times. However, normal scroll screens NBG0 and NBG1 have compression functions. Using thisfunction and setting the compression ratio to 1/4 would increase the access count to10, which exceeds 8, and the screen would not be displayed correctly. In this case, if
VRAM allocation is done, the access count will be distributed and the screen will
display correctly.

User's Guide 2 Graphics Library51

16 color bitmap data

NBG0 1 times

16 color bitmap data
Character pattern data
Pattern nameCharacter pattern data
Pattern name

NBG1 1 times
NBG2 1 times

VRAM 016 color bitmap data

NBG0 1/4 times

NBG1 1/4 times

VRAM 1

16 color bitmap data
Character pattern data
Pattern nameCharacter pattern data
Pattern namential

VRAM A

NBG3 1 times

NBG2 1 timesde

NBG3 1 times

Figure 4 16 Color Bitmap Data
Program Examples#include <machine.h>#include “sega_scl.h”

nfi

Program examples using the C language are shown below.

*/

extern Uint16 ColData[];/* Pallet data pointer*/

SclConfig scfg;
main(){
SCL_Vdp2Init();/* Initial VDP2 library*/Co/* Set the cycle pattern table
Uint16 n0_cycle[]={0x44ff, 0x0fff,/* VRAM A(A0)NBG0 Character pattern
and pattern name table on
0xffff, 0xffff, /* VRAM A1 VRAM A is not allocated so/* is not used */0xffff, 0xffff, /* VRAM B(B0) Non Table
0xffff, 0xffff};/* VRAM B1 VRAM B is not allocated so/* is not used */SEGA

SCL_SetDisplayMode(SCL_NON_INTER, SCL_224LINE, SCL_NOMAL_A);/* Sets the screen mode
SCL_SetColRamMode(SCL_CRM_2048):/* Sets the color RAM mode
SCL_AlloColRam(SCL_NBG0, 256, ON);/* Reserve pallet area
SCL_SetColRam(SCL_NBG0, 0, 265, ColData);/* Sets the pallet data

52

*/
*/
*/
*/

*/
*/
*/
*/

...................

/* Store the scroll data in VDP2 VRAM*/*/

SCL_SetPriority(SCL_NBG0, 7); /* Set the priority to maximum*/

SCL_SetCycleTable(n0_cycle);/* Set the cycle pattern*/

INT_SetScuFunc(.....);/* Record the V-Blank routine*/

set_imask(0);/* Enables the interrupt.+*/

SCL_Open(SCL_NBG0);/* NBG0 open processing
SCL_Move(FIXED(1), FIXED(1), 0);/* Types of scroll move functions.
.
.
SCL_Close(SCL_NBG0);/* End scroll processing*/*/

SCL_DisplayFrame();

nfi

de

nti
al

SCL_InitConfigTb(&scfg);/* Initialize scroll NBG0 configuration
scfg.dispenbl = ON;/* Display NBG0 on the screen
scfg.charsize = SCL_CHAR_SIZE_1X1;
scfg.pnamesize = SCL_PN1WORD;
scfg.platesize = SCL_PL_SIZE_1X1;
scfg.coltype = SCL_COL_TYPE_256;
scfg.flip = SCL_PN_12BIT;
scfg.datatype = SCL_CELL;
scfg.plate_addr[0] = SCL_VDP2_VRAM_A+0x0000;
scfg.plate_addr[1] = SCL_VDP2_VRAM_A+0x2000;
scfg.plate_addr[2] = SCL_VDP2_VRAM_A+0x4000;
scfg.plate_addr[3] = SCL_VDP2_VRAM_A+0x6000;
SCL_SetConfig(SCL_NBG0, &scfg);

*/

*/

Co

/* Wait for V-BLANK display scroll

SE

GA

}

*/

User's Guide 2 Graphics Library

53

SE

GA

Co

nfi

de

nti
al

(There is no page 54 in the original Japanese document.)

54

2.1

Data Specifications

Title

Data

Data Specification

2D Data StructurentialReference

Data Name

typedef struct SclXy
Fixed32 x;
Fixed32 y;} SclXy;

Title

Data

Data Specification

3D Data Structure

SclXy

{

Data NameNo

SclXyz{nfi

typedef struct SclXyz
Fixed32 x;
Fixed32 y;
Fixed32 z;} SclXyz;

No

de

2.0

Title

Data

Data Specification

Data Structure of the Line Parameter Table

Data NameNo

SclLineTb

Title

Data Specification

Co

typedef struct SclLineTb {Fixed32 h;/* Horizontal screen scroll value
Fixed32 v;/* Vertical screen scroll value
Fixed32 dh;/* Increment of horizontal coordinates} SclLineTb;

Data

Data Name

Data Structure of the line window

SclLinWindowTb

*/
*/
*/

No

*/
*/

User's Guide 2 Graphics Library

55

SE

GA

typedef struct SclLinWindowTb {Uint16 start;/* Horizontal start point coordinate
Uint16 end;/* Horizontal end point coordinate} SclLinWindowTb;

Data

Data Name

Data Specification

Structure of the RGB Color Table Data

SclRgbtypedef struct SclRgb
Sint16 red;
Sint16 green;
Sint16 blue;} SclRgb;{/* Red/* Green/* Blue

*/
*/
*/

No

nti
al

Title

Title

Data

Data Name

Data Specification

VRAM Configuration Data Structure

SclVramConfig

No

GA

Co

nfi

de

typedef struct SclVramConfig {Uint32
ktboffsetA; /* Indicates the coefficient rotation*//* parameter table in the relative VRAM *//* address. If SCL_RBG_K is indicated, *//* the relative address is designated there.
*/
Uint32
ktboffsetB; /* Designated units are 2048 (0x400) byte*//* Specified in relative address*/
Uint8
vramModeA; /* Separate VRAM A into 2 patterns*//* ON/OFF*/
Uint8
vramModeB; /* Separate VRAM B into 2 patterns*//* ON/OFF*/
Uint8
vramA0;/* Use VRAM A0 for which rotation screen*//* If not separated, uses all of VRAM A *//* SCL_NON*//*
Do not place rotation data*//* SCL_RBG0_K*//*
Place RBG0 coefficient data*//* SCL_RBG0_PN*//*
Place RGB0n pattern name data *//* SCL_RBG0_CHAR*//*
Place RGB0 character*/
Uint8
vramA1;/* Use VRAMA1 for which rotation screen *//* Invalid if VRAMA is not separated*/
Uint8
vramB0;/* Use VRAM B0 for which rotation screen*//* If not separated, uses all of VRAM B */Uint8
vramB1;/* Use VRAM B1 for which rotation screen*//* Invalid if VRAM B is not separated*/
Uint8
colram;/* Indicates whether to place coefficient data *//* into color RAM. If coefficient data is*//* placed in VRAM, it can’t be used. Unless the*//* color RAM mode is SCL_CRM15-2048, it can’t *//* be used. Specified with SCL_RBG0_K or SCL_NON*/} SclVramConfig;
If any type of rotation data is placed in a VRAM bank, other datacannot be placed there. However, if ktboffsetA or ktboffsetB is set, other data canbe placed with coefficient data.

SE

Note:

56

Data

Data Name

Data Specification

Structure of the Scroll Configuration Data

Sclconfig

No

nti
al

Title

Refer to the “VDP2 User’s Manual” for details on parameter settings.

*/
*/
*/
*/
*/
*/

*/

SE

GA

Co

nfi

de

typedef struct SclConfig {Uint8
dispenbl;/* Display ON/OFF/* Screen display enable register (180020h)/*
ON Display picture on screen/*
OFF Do not display picture on screen
Uint8
charsize;/* Character size/* Char. control reg.(180028h~18002ah)/*
SCL_CHAR_SIZE_1X1*//*
Set to 1X1*//*
SCL_CHAR_SIZE_2x2*//*
Set to 2x2*/
Uint8
pnamesize/* Pattern Name Size*//* Pattern Name Cntrl. reg.(180030h~18038h)/*
SCL_PN2WORD*//*
Set to 2Word units*//*
SCL_PN1WORD*//*
Set to 1Word units*/
Uint8
platesize;/* Plane Size*//* Plane size register (18003ah)*//*
SCL_PL_SIZE_1X1*//*
Set to 1X1*//*
SCL_PL_SIZE_2X1*//*
Set to 2X1*//*
SCL_PL_SIZE_2X2*//*
Set to 2X2*/
Uint8
bmpsize;/* Bitmap size *//* Char. control reg.(180028h~18002ah)/*
SCL_BMP_SIZE_512X256*//*
Set to 512X256*//*
SCL_BMP_SIZE_512X512*//*
Set to 512X512*//*
SCL_BMP_SIZE_1024X256*//*
Set to 1024X256*//*
SCL_BMP_SIZE_1024X512*//*
Set to 1024X512*/
Uint8
coltype;/* Character Colors *//* Char. control reg.(180028h~18002ah)/*
SCL_COL_TYPE_16*//*
Sets to 16 colors*//*
SCL_COL_TYPE_256*//*
Sets to 256 colors*//*
SCL_COL_TYPE_2048*//*
Sets to 2048 colors*//*
SCL_COL_TYPE_32K*//*
Sets to 32K colors*//*
SCL_COL_TYPE_1M*//*
Sets to 16,770,000 colors */Uint8
datatype;/*
Enable bitmap*//* Char. control reg.(180028h~18002ah)/*
SCL_BITMAP/*
Set to bitmap format

User's Guide 2 Graphics Library

*/

*/

*/
*/
*/

57

Uint8

flip

SE

GA
58

nfi

Co

Uint16 patnamecontrl;
Uint32 plate_addr[16];} Sclconfig;

ntialmapover;

de

Uint8

/*
SCL_CELL*//*
Sets the cell format*//* Over screen processing*//* Over screen process register (18003ah)*//* SCL_OVER0*//*
Repeat image that was set as display area *//*outside the display area.
*//* SCL_OVER1*//*
Repeat pattern designated by the screen*//*over pattern name register*//*(Only rotation screen)*//* SCL_OVER_2*//*
Make areas outside of display transparent *//* SCL_OVER_3*//*
Make the display area 512X512 and make all*//*other areas transparent.
*//* Character number support mode*//* Designates whether to use special functions *//* and reverse functions when the pattern name *//* size is 1Word. If designated, the character *//* number is 10bit, if not 12bit*//* Pattern Name Cntrl Register (180030h~180038h)*//*
SCL_PN_10BIT*//*
Enables special and reverse functions *//*SCL_PN_12BIT*//*
Disables special and reverse functions *//* Aux data in the pattern name control register*//* Scroll Screen Map Register*//* If cell format, designates pattern name*//* table lead address*//* If bitmap format, designates bitmap data*//* lead address*//* Normal(180040h~18004eh)*//* Rotate(180050h~18006eh)*/

Data Specification

Data
Structure of line & and vertical cell scroll
parameter data

Data NameNo

SclLineParam

nti
al

Title

Refer to the “VDP2 User’s Manual” for details on parameter settings.

SE

GA

Co

nfi

de

typedef struct SclLineParam {Uint8
delta_enbl;/* Enable Line Zoom*//* Line & Vertical cell scroll register (18009ah)*//*
ON/OFF*/Uint8
v_enbl;/* Enable line scroll (perpendicular)*//* Line & Vertical cell scroll register (18009ah)*//*
ON/OFF*/Uint8
h_enbl/* Enable line scroll (horizontal)*//* Line & Vertical cell scroll register (18009ah)*//*
ON/OFF*/
Uint8
cell_enbl;/* Enable vertical cell scroll*//* Line & Vertical cell scroll register (18009ah)*//*
ON/OFF*/
Uint8
interval;/* Line scroll interval*//* Line & Vertical cell scroll register (18009ah)*//*
SCL_1_LINE*//*
Sets the line scroll data table every 1 */
/*
line.
*/
/*
SCL_2_LINE*//*
Sets the line scroll data table every 2 *//*lines.
*//*
SCL_4_LINE*//*
Sets the line scroll data table every 4 *//*lines.
*/
Uint32
line_addr;/* Line scroll address register(18009ch~18009eh)*//* Sets the VRAM address for line scroll table */Uint32
cell_addr;/* Vert. cell scroll table address register (18009c~18009e)*//* Sets VRAM address for cell scroll table*/
GlbLineTb line_tbl[];/* Line scroll table*/
Fixed32
cell_tbl[];/* Vertical cell scroll address register*/} SclLineParam;

User's Guide 2 Graphics Library

59

Data

Data Name

Data Specification

VDP2 Register Buffer 1

SclSysReg

No

nti
al

Title

de

typedef struct SclSysReg {/* Address contents
Uint16 tvmode;/* 18000H TV screen mode
Unit16 extenbl;/* 18002H External signal
Unit16 tvstatus;/* 18004H Screen status
Unit16 vramsize;/* 18006H VRAM size
Unit16 H_val;/* 18008H H counter
Unit16 V_val;/* 1800AH V counter
Unit16 vramchg;/* 1800CH
Unit16 ramcontrl;/* 1800EH RAM control
Unit16 vramcyc[8];/* 18010H VRAM cycle pattern
Unit16 dispenbl;/* 18020H Enable screen display
Unit16 mosaic;/* 18022H Mosaic control
Unit16 specialcode_sel;/* 18024H Select special code
Unit16 specialcode; /* 18026H Special function control} SclSysReg;

*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/

SclSysReg

Scl_s_reg;

Data

Data Name

Data Specification

VDP2 Register Buffer 2No

SclDataset

Co

Title

nfi

Symbols are recorded in this library as shown below. After thissymbol is written, and the global variable “SclProcess” has a 1
written to it, then that will be reflected in the register during thenext V-BLANK.

GA

typedef struct SclDataset {/* Address contents*/
Uint16 charcontrl0; /* 18028H Charater control (NBG0, NBG1) */Unit16 charcontrl1; /* 1802AH Character control (NBG2, NBG3, RBG0) */Unit16 bmpalnum0;/* 1802CH Bitmap pallet number (NBG0, NBG1)*/
Unit16 bmpalnum1;/* 1802EH Bitmap pallet number (RBG0)*/
Unit16 patnamecontrl[15]/* 18030H Pattern name control*/
Unit16 platesize;/* 1803AH Plane size*/
Unit16 mapoffset0;/* 1803CH Map offset (NBG0~NBG3)*/
Unit16 mapoffset1;/* 1803EH Map offset (rotate parameter A, B)*/
Unit16 normap[8];/* 18040H Map (normal scroll)*/Unit16 rotmap[16];/* 18050H Map (rotate parameter A, B)*/} SclDataset;

SE

Symbols are recorded in this library as shown below. After thissymbol is written, and the global variable “SclProcess” has a 1
written to it, then that will be reflected in the register during thenext V-BLANK.
SclDataset

60

Scl_d_reg;

Data

Data Name

Data Specification

VDP2 Register Buffer 3

SclNorscl

No

nti
al

Title

{
/* Address contents*/
Fixed32 n0_move_x;/* 18070H H screen scroll value (NBG0) */Fixed32 n0_move_y;/* 18074H V screen scroll value (NBG0) */Fixed32 n0_delta_x; /* 18078H H coordinate increase (NBG0) */Fixed32 n0_delta_y; /* 1807CH V coordinate increase (NBG0) */Fixed32 n1_move_x;/* 18080H H screen scroll value (NBG1) */Fixed32 n1_move_y;/* 18084H V screen scroll value (NBG1) */Fixed32 n1_delta_x; /* 18088H H coordinate increase (NBG1) */Fixed32 n1_delta_y; /* 1808CH V coordinate increase (NBG1) */Uint16 n2_move_x;/* 18090H H screen scroll value (NBG2) */Unit16 n2_move_y;/* 18092H V screen scroll value (NBG2) */Unit16 n3_move_x;/* 18094H H screen scroll value (NBG3) */Unit16 n3_move_y;/* 18096H V screen scroll value (NBG3) */Unit16 zoomenbl;/* 18098H Enable compression*/
Unit16 linecontrl; /* 1809AH line & V cell cntrl (NBG0, NBG1)*/
Unit16 celladdr;/* 1809CH V cell scroll tbl addr (NBG0, NBG1) */Unit16 lineaddr[2]; /* 180A0H Line control table address*/
Unit16 linecolmode; /* 180A8H Line color screen table address*/
Unit16 backcolmode; /* 180ACH Back screen table address*/} SclNorscl;

nfi

de

typedef struct SclNorscl

Co

Symbols are recorded in this library as shown below. After thissymbol is written, and the global variable “SclProcess” has a 1
written to it, then that will be reflected in the register during thenext V-BLANK.
SclNorscl
Title

Data Specification

Scl_n_reg;

Data

Data Name

VDP2 Register Buffer 4

SclRotscl

No{/* Address contents*/
Uint16 paramode;/* 1800B0H Rotate parameter mode*/
Unit16 paramcontrl; /* 1800B2H Rotate parameter list control*/Unit16 k_contrl;/* 1800B4H Coefficient table control*/
Unit16 k_offset;/* 1800B6H Coefficient table address offset */Unit16 mapover[2]/* 1800B8H Screen over pattern name*/Unit16 paramaddr;/* 1800BAH Rotate parameter table address*/} SclRotsel;

SEGA

typedef struct SclRotsel

Symbols are recorded in this library as shown below. After thissymbol is written, and the global variable “SclProcess” has a 1
written to it, then that will be reflected in the register during thenext V-BLANK.
SclRotscl

User's Guide 2 Graphics Library

Scl_r_reg;

61

Data

Data Name

Data Specification

VDP2 Register Buffer 5

SclWinscl

typedef struct SclWinscl
Uint16 win0_start[2];Unit16 win0_end[2];Unit16 win0_start[2];Unit16 win0_end[2];Unit16 wincontrl940;
Unit16 linewin0_addr;
Unit16 linewin1_addr;} SclWinscl;

No

nti
al

Title

{
/* Address contents*//* 1800C0H Window position (w0, start XY) *//* 1800C4H Window position (w0, end XY) *//* 1800C8H Window position (w0, start XY) *//* 1800CCH Window position (w0, end XY) *//* 1800D0H Window control *//* 1800D8H Line Window table address (W0)*//* 1800DCH Line Window table address (W0)*/

SclWinscl

deSymbols are recorded in this library as shown below. After thissymbol is written, and the global variable “SclProcess” has a 1
written to it, then that will be reflected in the register during thenext V-BLANK.
Scl_w_reg;

Data

Data Name

Data Specification

XY Size of screens used in the library

nfi

Title

No

SclDisplayX, SclDisplayY

SclDisplayX;
SclDisplayY;

SE

GA

Uint16
Uint16

Co

This is a 2Byte global variable. When this variable is referenced, thedisplay vertical and horizontal size changes. By using the libraryand setting the display mode, this can automatically be reflected.

62

2.2

List of Functions
Function Name

NumberntialFunction[Initializing Functions]
Initialize Library[Table Creation and Data Set Functions]Set display mode
Initialize VRAM configuration data table
Initialize scroll configuration data table
Set the VDP2 VRAM usage method
Set the scroll configuration
Set cycle patterns[Functions Related to the Display Screen Functions]
Scroll open process
Scroll close process
Initialize line and vertical cell scroll parameter table
Set line and vertical cell scroll parameters
Move scroll (Amount of move : absolute coord.)Move scroll (Amount of move : relative coord.)
Enlarge or reduce scroll
Initialize the rotation parameter table
Set rotation viewSet the display rotate center coordinates
Set rotation center
Scroll rotate (angle : absolute coord.)
Scroll rotate (angle : relative coord.)
Set scale coefficient data in therotate coefficient table
Set mosaic process[Line Screen Setting Functions]
Set line color screen data
Set back screen data
[Window Setting Functions]Set normal rectangle window
Set normal line window
Set sprite window

SCL_Vdp2Init

1

SCL_SetDisplay Mode
SCL_InitVramConfigTb

2
3
4
5
6
7

SCL_InitConfigTb

SCL_SetVramConfig
SCL_SetConfig

89
SCL_InitLineParamTb
10
SCL_SetLineParam
11
SCL_MoveTo
12
SCL_Move
13
SCL_Scale
14
SCL_InitRotateTable
15
SCL_SetRotateViewPoint 16
SCL_SetRotateCenterDisp 17
SCL_SetRotateCenter
18
SCL_RotateTo
19
SCL_Rotate
20
SCL_SetCoefficientData 21
SCL_SetMosaic
22
SCL_Open
SCL_Close

SCL_SetLncl
SCL_SetBack
SCL_SetWindow
SCL_SetLineWindow
SCL_SetSpriteWindow

23
24
25
26
27

SE

GA

Co

nfi

de

SCL_SetCycleTable

User's Guide 2 Graphics Library63

SCL_SetSpriteMode28

SCL_SetColRamMode

29
30
31
32
33
34
35

SCL_GetColRamMode
SCL_SetColRamCol
SCL_AllocColRam
SCL_FreeColRam

SCL_SetAutoColChg
SCL_GetColRamOffset
SCL_SetPriority
SCL_GetPriority

36
37

SCL_SetColMixMode
SCL_SetColMixRate
SCL_SetAutoColMix

38
39
40

SCL_SetColOffset
SCL_IncColOffset
SCL_SetAutoColOffset

41
42
43

SCL_EnableBlur

SCL_SetShadowBit

44
45
46
47
48

SCL_SetFrameInterval
SCL_DisplayFrame
SCL_VblankStart
SCL_VblankEnd

49
50
51
52

SCL_AborAutoVe

53

nfi

Co

GA

SE
64

NumberntialFunction NamedeFunction[Functions Related to VDP1]
Set different sprite modes[Functions Related to Color RAM]Set color RAM modeGet color RAM mode
Set color RAM color data
Allocate area for color RAM
Free area allocated for color RAM
Set auto color change
Get the color RAM address offset[Functions Related to Priority]
Set priorities
Get priorities[Functions Related to Color Calculations]Set color calculation conditions (SPRITE)
Set color calculation mix
Set auto color calculation[Functions Related to Color Offset]
Set color offset
Increase and decrease the color offset value
Set the auto color offset[Other Special Effect Functions]
Enable blur calculations
Disable blur calculations
Enable line color screen
Disable line color screen
Set shadow bit[Functions Related to V-BLANK Interrupt Processing]Set frame change interval count
Wait for frame change request to end
V-BLANK start VDP interrupt processing
V-BLANK end VDP interrupt processing[Abort Function]
Force abort of automatic VE

SCL-DisableBlur
SCL_EnableLineCol
SCL_DisableLineColFunction Specifications
Function

Function Specification

Initialize library

FormatInput
OutputFunction Value
Function

void

Function Name
SCL_Vdp2Init

SCL_Vdp2Init(void)

No

nti
al

Title

1

None
None
None
Initializes the library. This command must be executed once
before using the library.

Title

Function

Function Name

Function Specification

Set display mode

de

2.3

SCL_SetDisplayModeNo

2

Formatvoid SCL_SetDi spl ayMode(Ui nt 8 i nt e rl ace, Ui nt 8 ve rt i cal, Ui nt 8
ho ri zont al)InputinterlaceCo

nfi: Interlace mode setting
SCL_NON_INTER: Noninterlace
SCL_SINGLE_INTER: Single interlace
SCL_DOUBLE_INTER : Double interlace
vertical: Vertical resolution bit
SCL_224LINE: 224 lines
SCL_240LINE: 240 lines
SCL_256LINE: 256 lines
horizontal : Horizontal resolution bit
SCL_NORMAL_A
SCL_NORMAL_B
SCL_HIRESO_A
SCL_HIRESO_B

GA

SCL_NORMAL_AE

SE

OutputFunction Value
Function
Comments

SCL_NORMAL_BE
SCL_HIRESO_AE
SCL_HIRESO_BE: 320 Pixels: Normal Graphic A: 352 Pixels: Normal Graphic B: 640 Pixels: Hi-res Normal Graphic A:704 Pixels: Hi-res Normal Graphic B: 320 Pixels: Custom Normal Graphic A: 352 Pixels: Custom Normal Graphic B: 640 Pixels: Custom Hi-res Graphic A: 704 Pixels: Custom HIi-res Graphic B

None
None
Sets the display mode.
When changing the horizontal resolution from A to B, SH2
clock changes from 76 to 78. (Example: SCL_NORMAL)A →SCL_NORMAL_B) Be careful because VDP1 and VDP2 settings
are reset at this time.

User's Guide 2 Graphics Library65

Function

Function Name

No

Function Specification

Initialize VRAM configuration table

SCL_InitVramConfigTb

3

FormatInput
OutputFunction Value
Function

nti
al

Title

void SCL_InitVramConfigTb(SclVramConfig *tp)

tp
: VRAM configuration table
None
None
Writes the default values to the VRAM configuration table.

Function

Function Name

No

Function Specification

Initialize scroll configuration data
table

SCL_InitConfigTb

4void SCL_InitConfigTb(SclConfig *scfg)

scfg: Scroll configuration data
None
None
Initializes the scroll configuration data table.

nfi

FormatInput
OutputFunction Value
Function

de

Title

Title

Function

Function Specification

Set the VDP2 VRAM usage method

No

SCL_SetVramConfig

5void SCL_SetVramConfig(SclVramConfig *tp)

Co

FormatInput
OutputFunction Value
Function
ExampleFunction Name

tp
: VRAM configuration table.
None
None
Sets the VDP2 VRAM usage method.
Allocates VRAM B; each bank is identified for RBG0 characterand pattern name data.

GAsample(){SclVramConfig tp;

SCL_InitVramConfigTb(&tp);
tp.vramModeB = ON/* Allocates VRAM B for use
tp.vramB0 = SCL_RBG0_CHAR; /* Places RBG0 character data
tp.vramB1 = SCL_RBG0_PN; /* Places RBG0 pattern name data
SCL_SetVramConfig(&tp);

SE

}

66

*/
*/
*/

Function

Function Name

No

Function Specification

Set the scroll configuration

SCL_SetConfig

6

Format
Input

nti
al

Title

void SCL_SetConfig(Uint16 sclnum, SclConfig *scfg)

sclnum :

scfg
:
None
None
Sets the scroll configuration.
When setting rotation screen data, the SCL_IntRotateTable()must be run first.

deOutputFunction Value
Function
Comments

scroll screen number
Select one of six screens SCL_NBG0, SCL_NBG1,
SCL_NBG2, SCL_NBG3, SCL_RBG0, SCL_RBG1
Scroll configuration table pointer

Title

Function

Function Specification

Set VRAM cycle pattern table

Example 1

No

SCL_SetCycleTable

7

nfi

void SCL_SetCycleTable(Uint16 *tp)tp
: Cycle pattern table
None
None
Sets the cycle pattern table.
If the cycle pattern table is not set correctly, the normal scroll
screen will not display properly. It is advised to have an
understanding of Chapter 3 RAM, “3.4 VRAM Access Methods
During Display Intervals” in the VDP2 User’s Manual.
Image : NBG0 256 colors (with 1/2 scale display)
VRAM A: Places the NBG0 character pattern data.
VRAM B : Places the NBG0 pattern name table.

Co

FormatInput
OutputFunction Value
Function
Comments

Function Name

*/
*/
*/
*/
*/

SE

GA

Uint16 cycle[] = {/* Cycle pattern table
0x4444, 0xffff,/* VRAM A(A0)0xffff, 0xffff,/* VRAM A1 Not used
0x00ff, 0xffff,/* VRAM B(B0)0xffff, 0xffff,/* VRAM B1 Not used}sample(){SCL_SetCycleTable(&cycle);}

User's Guide 2 Graphics Library67

Image : NBG0 16.77 million colors bitmap data
VRAM A: Places the NBG0 bitmap data.
VRAM B : Places the NBG0 bitmap data.

ntialExample 2

Image: RBG0 256 color bitmap data
NBG0 16 colors bitmap data (1/4 reduced)
NBG1 16 colors bitmap data (1/2 reduced)
NBG2 16 colors character data / pattern name data
NBG3 16 colors character data / pattern name data
VRAM A0 : Places the RBG0 bitmap data.
VRAM A1 : Places the rotate parameter coefficient table.
Places the rotate parameter table.
VRAM B0 : Places the NBG0 bitmap data.
Places the NBG1 bitmap data.
VRAM B1 : Places NBG2 character and pattern name data
Places NBG3 character and pattern name data

Co

nfi

Example 3

*/
*/
*/
*/
*/

de

Uint16 cycle[] = {/* Cycle pattern table
0x4444, 0x4444,/* VRAM A(A0)0xffff, 0xffff,/* VRAM A1 Not used
0x4444, 0x4444,/* VRAM B(B0)0xffff, 0xffff,/* VRAM B1 Not used}sample(){SCL_SetCycleTable(&cycle);}GA

Uint16 cycle[] = {0xffff, 0xffff,
0xffff, 0xffff,
0x4444, 0xff55,
0x23ff, 0x67ff,}
sample(){SCLVramConfig/* Cycle pattern table/* VRAM A0/* VRAM A1/* VRAM B0/* VRAM B1

tp;

SE

SCL_InitVramConfigTb(&tp);
tb.vramModeA = ON
tp.vramA0 = SCL_RBG0_CHAR;
tp.vramA1 = SCL_RGB0_K;
SCL_SetVramConfig(&tp);

}

68

*/
*/
*/
*/
*/

SCL_SetCycleTable(&cycle);/* Allocate and use VRAM A*//* Place RBG0 bitmap data*//* Place rotate coeff. param.tbl. */Function

Function Name

No

Function Specification

Scroll open process

SCL_Open8

OutputFunction Value
Function

void SCL_Open(Uint32 sclnum)

sclnum : Select the scroll screen number or 4 rotate parameter
table normal screens (SCL_NBG0, SCL_NBG1,
SCL_NBG2, SCL_NBG3), or rotate parameter table
A, B (SCL_RBG_TB_A, SCL_RBG_TB_B).
None
None
Depending on the scroll screen selected, the following
functions become available for use.
SCL_SetLineParam SCL_Move SCL_MoveTo
SCL_Scale
SCL_Rotate SCL_RotateTo

Function

Function Specification

Scroll close process

Title

Function Specification

SCL_Close

9

None
None
None
Closes the functions selected with SclOpen().

Function

Function Name

No

Initialize line and vertical cell scroll parameter
table

SCL_InitLineParamTb

10

void

SCL_InitLineParamTb(SclLineParam

*lp)

lp
: Line & vertical scroll parameter data
None
None
Initializes the line and cell scroll parameter table.

SE

GA

FormatInput
OutputFunction Value
FunctionNo

void SCL_Close(void)

Co

FormatInput
OutputFunction Value
Function

Function Name

nfi

Title

de

Format
Input

nti
al

Title

User's Guide 2 Graphics Library69

Function

Function Name

No

Function Specification

Set line and vertical cell scroll
parameters

SCL_SetLineParam

11

void SCL_SetLineParam(SclLineParam *lp)

lp
: Line parameter table
None
None
None
Runs from the time that SclOpen() is executed until SclClose()is executed. It can only set NBG0, NBG1.

Title

Function

Function Specification

Move scroll (Amount of move :absolute coord.)

FormatInput

No

SCL_MoveTo

12

Co

nfi

Indicates the coordinates of where to put the scroll screen.
x : X coordinates
y : Y coordinatesz : Z coordinates
None
None
Moves the scroll to absolute coordinates
Runs from the time that SclOpen() is executed until SclClose()is executed. The Z coordinate can only be used with the rotate
parameter table.

Title

Function

Function Specification

Move scroll (Amount of move :relative coord.)

Function NameNo

SCL_Move13

GA

void SCL_Move(Fixed32 x, Fixed32 y, Fized32 z)

x : Indicates move distance in X direction
y : Indicates move distance in Y directionz : Indicates move distance in Z direction
None
None
Moves the scroll relatively
Runs from the time that SclOpen() is executed until SclClose()is executed. The Z coordinate can only be used with the rotate
parameter table.

SE

OutputFunction Value
Function
Remarks70

Function Name

void SCL_MoveTo(Fixed32 x, Fixed32 y, Fized32 z)

OutputFunction Value
Function
Remarks

FormatInput

deFormatInput
OutputFunction Value
Function
Remarks

nti
al

Title

Function

Function Name

No

Function Specification

Enlarge or reduce scroll

SCL_Scale

14

Format
Input

nti
al

Title

void SCL_Scale(Fixed32 sx, Fixed32 sy)

sx
sy

None
None
Scales the scroll screen.
Runs from the time that SclOpen() is executed until SclClose()is executed. NBG2, NBG3 cannot be used.

deOutputFunction Value
Function
Comments: Size designation in the X direction: Size designation in the Y direction
NBG0, NBG1
: 1/4~256
RBG0, RBG1
: FreeTitle

Function

Function Name

Function Specification

Initialize the rotation parameter table SCL_InitRotateTable

No

15

FormatUint32Input

address : Indicates the address to place the rotate parameter
table.
num: Table Count
1 : Only uses rotate parameter A
2 : Uses rotate parameters A and B
rotateA : Select what to display using rotate parameter A.
SCL_SPR : Only display the sprite frame buffer
SCL_RBG0 : Display RBG0 and sprite frame buffer
SCL_NON : Do not display
rotateB : Select what to display using rotate parameter B.
SCL_RBG0 : Display RBG0
SCL_RBG1 : Display RBG1
SCL_ NON : Do not display
None
0: Normal
1: Misallocation
2: Contradictions in the settings
Initializes the rotate parameter table and sets which location in
VRAM to place the rotate parameter table.
When using both rotate parameter tables A and B, screen
repetition, XY axis rotate combination and Y axis rotation will
not display correctly unless window display is designated.

Co

nfi

SCL_InitRotateTable(Uint32 address, Uint16 num,
Uint32 rotateA, Uint32 rotateB)

GA

OutputFunction Value
FunctionSE

Comments

User's Guide 2 Graphics Library71

Function

Function Name

Function Specification

Set rotation view

SCL_SetRotateViewPoint 16

void

OutputFunction Value
Function
Comments

SCL_SetRotateViewPoint(Uint16 x, Uint16 y, Uint16 z)

x : X coordinates
y : Y coordinatesz : Z coordinates
None
None
Sets the rotate viewpoint.
Runs from the time that SclOpen() is executed until SclClose()is executed. SCL_NBG0~3 cannot be used.

Title

Function

Function Specification

Set rotation center

FormatInput

deFormatInput

Function NameNo

SCL_SetRotateCenter

17

void SCL_SetRotateCenterDisp(Uint16 x, Uint16 y)nfi

x : X coordinates
y : Y coordinatesz : Z coordinates
None
None
Sets the rotate center point.
Runs from the time that SclOpen() is executed until SclClose()is executed. SCL_NBG0~3 cannot be used.

Co

OutputFunction Value
Function
Comments

Title

Function

Function Specification

Set the display rotate center coordinates

FormatInput

Function NameNo

SCL_SetRotateCenterDisp

18

void SCL_SetRotateCenter(Uint16 x, Uint16 y, Uint16 z)

x : X coordinates
y : Y coordinates
Output None
None
Sets the display rotate center point.
Runs from the time that SclOpen() is executed until SclClose()is executed. SCL_NBG0~3 cannot be used.

SE

GA

Function Value
Function
Comments

72

No

nti
al

Title

TitleFunction

Function Name

No

Function Specification

Scroll rotate (angle : absolute coord.)

SCL_RotateTo

19

void SCL_RotateTo(Fixed32 angelXy, Fixed32 angleZ, Fixed32
angleD, Uint16 mode)

Input

angelXy : Sets the X axis or Y axis angle
angleZ : Sets the Z axis angle
angleD : Sets the screen rotate anglemode: Rotate mode. Sets which axis, X or Y, to enable as
the first argument.
SCL_X_AXIS : Rotate scroll X axis.
SCL_Y_AXIS : Rotate scroll Y axis. (Can’t use with
RBG1 screen designation.)
None
None
Rotate scroll screen.
Runs from the time that SclOpen() is executed until SclClose()is executed. SCL_NBG0~3 cannot be used.

deOutputFunction Value
Function
Commentsnti
alFormatFunction

Function Specification

Scroll rotate (angle : relative coord.)No

SCL_Rotate

20

Fi xed32 angelXy, Fi xed32 angleZ, Fi xed32 angleD)angelXy : Sets the X axis or Y axis angle increase
angleZ : Sets the Z axis angle increase
angleD : Sets the screen rotate angle increase
None
None
Rotates the rotate scroll screen.
Runs from the time that SclOpen() is executed until SclClose()is executed. SCL_NBG0~3 cannot be used.

SE

GA

OutputFunction Value
Function
Comments

void SCL_Rotate(

Function NameCo

Format
Input

nfi

Title

User's Guide 2 Graphics Library73

Function

Function Name

No

Function Specification

Set scale coefficient data in therotate
parameter coefficient table

SCL_SetCoefficientData

21

nti
al

Title

Format

void

Input

surface

OutputFunction Value
Function

datap
x
y
None
None
Sets scale coefficient data into the rotate coefficient table.

SCL_SetCoefficientData(Uint32, surface, Uint16*datap, Uint16 x, Uint16

Function

Function Specification

Set mosaic process

de

Title

FormatInputy): Indicates which rotate parameter table to use fordata set. (SCL_RBG_TB_A, SCL_RBG_TB_B): Data table pointer.
: X data size
: Y data size

Function NameNo

SCL_SetMosaic

22

surface: Screen Typenfi

void SCL_SetMosaic(Uint32 surface, Uint8 x, Uint8 y)

SCL_NBG0 | SCL_NBG1 |SCL_NBG2 | SCL_NBG3 |

None
None
Sets the mosaic functions for each screen.
If the mosaic process is used, the vertical cell scroll function
cannot be used.

SE

GA

OutputFunction Value
Function
Comment

SCL_RBG0 | SCL_RBG1
Horizontal size of the mosaic (0~15, 0 is mosaic off)
Vertical size of the mosaic (0~15)
Cannot set for rotate surface (RBG0, RBG1).

Co

x :
y :

74

Function

Function Name

No

Function Specification

Set line color screen data

SCL_SetLncl

23

nti
al

Title

void SCL_Lncl(Uint32 address, Uint16 tbsize, Uint16*palNumTb)

Input

address: Location in VRAM to place the line color tabletbsize: Indicates the size of the table
PalNumTb : Indicates each line data with the palette number.
16 color
0~15
256 colors
0~255
2048 colors
0~2047
None
None
Sets the line color screen data.
Set the pallet data into color RAM using the SCL_AllocRam()and SCL_SetColRam() beforehand.

OutputFunction Value
Function
Comments

Function

Function Specification
FormatInput

No

Set back screen data

SCL_SetBack

24

void SCL_SetBack(

Ui nt 32 address, Ui nt 16 dataSi ze, Ui nt 16 *dataTb)

address : Location in VRAM to place the line color table
dataSize : Indicates the number of data tables
dataTb : Indicates each line data in 5bitRGB.
None
None
Sets the back screen data and address.
Sets back screen address in VRAM and sets the color to black.

Co

OutputFunction Value
Function
ExampleFunction Name

nfi

Title

de

Formatvoid sample(void){
Uint16 DataTB;

GA

DataTB = 0x0000;/* Black */SCL_SetBack(SCL_VDP2_VRAM, 1, &DataTB);

SE}

User's Guide 2 Graphics Library75

Function

Function Name

No

Function Specification

Set normal rectangle window

SCL_SetWindow

25

nti
al

Title

Formatvoid SCL_SetWindow ( Ui nt 8 wi n, Ui nt 32 l ogi c, Ui nt 32 enabl e, Ui nt 32
ar ea, Ui nt 16 st ar t X, Ui nt 16 st ar t Y, Ui nt 16 endX, Ui nt 16 endY)

Input

win

logic enablearea

Meaning

Transparent process window NBG0
Transparent process window NBG1
Transparent process window NBG2
Transparent process window NBG3
Transparent process window RBG0
Transparent process window RBG1
Transparent process window EXBG
Transparent process window sprite
Rotate parameter window
Color calculation window
Not indicatednfi

SCL_NBG0
SCL_NBG1
SCL_NBG2
SCL_NBG3
SCL_RBG0SCL_RBG1
SCL_EXBGSCL_SPR
SCL_RP
SCL_CCSCL_NON

Co

Constantde: Indicates the type of window.
SCL_W0: Indicates a W0 window
SCL_W1: Indicates a W1 window
logic: Here, layering of multiple windows on the screen isprocessed by AND. Default is OR.
enable : Indicates the screen to display the window on.
area: Indicates use of the outside area of a window,
default is inside area.
The variables logic, enable and area can be calculated together
by using OR.

∆: Can be designated ∆: Cannot be designated on a sprite windowGA

startX: Rectangle data start point X coordinate
startY: Rectangle data start point Y coordinate
endX: Rectangle data end point X coordinate
endY: Rectangle data end point Y coordinate
None
None
Sets normal rectangle windows.

SE

OutputFunction Value
Function76

Function

Function Name

No

Function Specification

Set normal line window

SCL_SetLineWindow

26

nti
al

Title

Formatvoid SCL_SetLineWindow ( Ui nt 8 wi n, Ui nt 32 l ogic, Ui nt 32 enabl e,
Ui nt 32 a rea, Ui nt 32 address, Ui nt 32 sy, Ui nt 32 t bSi ze, Sc lLi nW
i ndowTb
*t b)

Input

win

OutputFunction Value
Function

Function

Function Specification
FormatSet sprite window

void SCL_SetSpriteWindow
a rea)

Function NameNo

SCL_SetSpriteWindow

27( Ui nt 32 l ogic, Ui nt 32 enabl e, Ui nt 32

logic: Here, layering of multiple windows on the screen isprocessed by AND. Default is OR.
enable : Indicates the screen to display the window on.
area: Indicates use of the outside area of a window,
default is inside area.
The variables logic, enable and area can be calculated together
by using OR.
None
None
Sets the sprite line window.
Sprites for the window must be prepared in advance using
VDP1.

GA

Input

Co

Title

nfi

de

: Indicates the type of window
SCL_W0: Indicates a W0 window
SCL_W1: Indicates a w1 window
logic: Here, layering of multiple windows on the screen isprocessed by AND. Default is OR.
enable : Indicates the screen to display the window on.
area: Indicates use of the outside area of a window,
default is inside area.
address : Location of the line window table in VRAM.
sy: Lead Y coordinate.
tbSize : Size of the line window tabletb: Line window table pointerThe variables logic, enable and area can be calculated together
by using OR.
None
None
Sets normal line window.

SE

OutputFunction Value
Function
Comments

User's Guide 2 Graphics Library77

Function

Function Name

No

Function Specification

Set different sprite modes

SCL_SetSpriteMode28

FormatInput

void SCL_SetSpriteMode( Ui nt 8 t ype, Ui nt 8 colMode, Ui nt 8 wi nMode): Sprite type
SCL_SPR_TYPE0, SCL_SPR_TYPE1 . . . SCL_SPR_TYPEF
colMode : Color mode
SCL_PALETTE, SCL_MIX(SCL_MIX: palette and RGB mixture)
winMode: Window mode
SCL_MSB_SHADOW, SCL_SP_WINDOW
None
None
Sets the sprite type.

Function

Function Specification

Set color RAM mode

FormatInput

void SCL_SetColRamMode(Uint32 mode)

OutputFunction Value
Function

None
None
Sets the color RAM mode.

Title

Function

Function Specification

Get color RAM mode

29

Function NameNo

SCL_GetColRamMode

30

None
None
Color RAM mode
SCL_CRM15_1024, SCL_CRM15_2048, SCL_CRM24_1024
Sets the color RAM mode.

SE

Function

SCL_SetColRamMode

Uint32 SCL_GetColRamMode(void)GA

FormatInput
OutputFunction ValueNo: Color RAM mode
SCL_CRM15_1024, SCL_CRM15_2048, SCL_CRM24_1024

Co

mode

Function Name

nfi

Title

de

type

OutputFunction Value
Function

78

nti
al

Title

Function

Function Name

No

Function Specification

Set color RAM color data

SCL_SetColRam

31

nti
al

Title

void SCL_SetColRam(Uint32 surface, Uint32 index, Uint32
num, void *color)Input

surface : Screen type
SCL_SPR, SCL_NBG0, SCL_NBG1, SCL_NBG2, SCL_NBG3,
SCL_RBG0, SCL_RBG1, SCL_LNCL
index: Write start palette numbernum: Size of the color data tablecolor: Color data table (Unit 32 or Unit 16)
None
None
Sets color data into the color RAM.
If using color RAM commonly, you can set just one of thescreens if desired.

OutputFunction Value
Function
Comments

deFormatFunction

Function Specification

Allocate area for color RAM

nfi

Title

Function NameNo

SCL_AlllocColRam

32

FormatUint32 SCL_AllocColRam(Uint32 surface, Uint32 numOfColors,
Uint8 transparent)

Input

surface : Screen type

SCL_SPR | SCL_NBG0 | SCL_NBG1 | SCL_NBG2| SCL_NBG3|
SCL_RBG0| SCL_RBG1| SCL_LNCLCo

Use OR calculation to use the same palette for multiple screens.
numOfColors: Number of colors
transparent:
Sets whether to use transparent or not.
ON Palette 0 is not transparent
OFF Palette 0 is transparent
None
The lead allocated address
Allocates the color RAM area.

OutputFunction Value
Function

Function

Function Name

No

Function Specification

Free area allocated for color RAM

SCL_FreeColRam

33

GA

Title

FormatInput

SE

OutputFunction Value
Function

void SCL_FreeColRam(Uint32 surface)surface : Screen type
SCL_SPR | SCL_NBG0 | SCL_NBG1 | SCL_NBG2 | SCL_NBG3 |SCL_RBG0 | SCL_RBG1

Use OR calculation to use the same palette for multiple screens.
None
None
Frees the area allocated for color RAM.

User's Guide 2 Graphics Library79

Function

Function Name

No

Function Specification

Set auto color change

SCL_SetAutoColChg

34

nti
al

Title

void SCL_SetAutoColChg( Ui nt 32 sur f ace, Ui nt 32 i nt e rval, Ui nt 32
i ndex, Ui nt 32 numOf Col, Ui nt 32 numOf Tbl , Ui nt 32 changeTbl [ ] )Input

surface : Screen type
SCL_SPR, SCL_NBG0, SCL_NBG1, SCL_NBG2, SCL_NBG3,
SCL_RBG0, SCL_RBG1
interval : Interval
designated in units of 1/60th of a second
index: Start palette number to be changed
numOfCol: Number of colors
numOfTbl: Number of Tables
changeTbl[]: Change tables
None
None
Changes a portion of each pallet a little at a time towards a
specific color. The number of pallets is limited to 256 colors. It
is not compatible with 2048, or 1024 colors.

nfi

OutputFunction Value
FunctiondeFormatTitle

Function

Function Specification

Get the color RAM address offset

FormatInput

SCL_GetColRamOffset

35

Co

surface : Screen type
SCL_SPR, SCL_NBG0, SCL_NBG1, SCL_NBG2, SCL_NBG3,
SCL_RBG0, SCL_RBG1
None
Offset address from the VDP2 VRAM.
Gets the color RAM address offset.

Function

Function Specification

Set priorities

GA

Title

void

Function NameNo

SCL_SetPriority

36

SCL_SetPriority(Uint32 surface, Uint8 priority)

surfaces: Screen types
SCL_SP0|SCL_SP1. . . SCLSP7|SCL_NBG0|SCL_NBG1|
SCL_NBG2| SCL_NBG3| SCL_RBG0|SCL_RBG1|SCL_EXBG
priority: Priority number
None
None
Sets the priority.

SE

OutputFunction Value
Function

80

No

Uint32 = SCL_GetColRamOffset(Uint32 surface)

OutputFunction Value
Function

FormatInput

Function Name

Function

Function Name

No

Function Specification

Get priorities

SCL_GetPriority

37

OutputFunction Value
Function

Uint8 Priority = SCL_GetPriority(Uint32 surface)surfaces :Screen types
SCL_SPR, SCL_NBG0, SCL_NBG1, SCL_NBG2, SCL_NBG3,
SCL_RBG0, SCL_RBG1, SCL_EXBG
priority: Priority number
None
None
Gets the priority.

deFormat
Input

nti
al

Title

Title

Function

Function Specification

Set color calculation conditions (SPRITE)

Title

Function Specification

SCL_SetColMixMode38

SCL_SetColMixMode(Uint32 colMixPriority, Uint8 mode)

colMixPriority : Sprite priority number
0~7
mode: ModeSCL_IF_FRONT, SCL_IF_EQUAL, SCL_IF_BEHIND
None
None
Sets the color calculation conditions.

Function

Function NameNo

Set color calculation mix

SCL_SetColMixRate

39

void SCL_SetColMixRate(Uint32 surfaces, Uint8 rate)surfaces : Screen types
SCL_SP0|SCL_SP1. . . SCL_SP7|SCL_NBG0|SCL_NBG1|
SCL_NBG2| SCL_NBG3| SCL_RBG0,|SCL_RBG1|SCL_EXBG
Use OR calculation to use the same palette for multiple screensrate: Rate
0~31
None
None
Sets the color calculation rate.

GA

Format
Input

No

nfi

OutputFunction Value
Functionvoid

Co

FormatInput

Function Name

SE

OutputFunction Value
Function

User's Guide 2 Graphics Library81

Function

Function Name

No

Function Specification

Set auto color calculation

SCL_SetAutoColMix

40

nti
al

Title

void SCL_SetAutoColMix(Uint32 surfaces, Uint32 interval,
Uint32 time, uint8 startRate, Uint8 endRate)Input

surfaces : Screen types
SCL_SP0|SCL_SP1. . . SCL_SP7|SCL_NBG0|SCL_NBG1|
SCL_NBG2| SCL_NBG3| SCL_RBG0,|SCL_RBG1|SCL_EXBG
Use OR calculation to use the same palette for multiple screensinterval : Interval
Designated in units of 1/60th of a second.
time: Indicates the time to complete the color change.
Designated in units of 1/60th of a second.
startRate : Rate at the starting point
endRate : Rate at the ending point
None
None
Changes the color mix according the designated time orinterval.

Title

Function

Function Specification

Set color offset

Function NameNo

SCL_SetColOffset

41

void SCL_SetColOffset(Uint32 offsetreg, Uint32 surfaces,
Sint16 red, Sint16 green, Sint16 blue)

Input

offsetreg :Co

FormatGA

Indicates which color offset register to use.
SCL_OFFSET_A, SCL_OFFSET_B
surfaces : Screen types
SCL_SP0|SCL_SP1. . . SCL_SP7|SCL_NBG0|SCL_NBG1|
SCL_NBG2| SCL_NBG3| SCL_RBG0|SCL_RBG1|SCL_EXBG
Use OR calculation to use the same palette for multiple screens
Red: Color indicator (red)green : Color indicator (green)
blue : Color indicator (blue)
None
None
Sets the color offset.

SE

OutputFunction Value
Function82

nfi

OutputFunction Value
FunctiondeFormatFunction

Function Name

No

Function Specification

Increase/decrease the color offset
value

SCL_IncColOffset

42

nti
al

Title

Formatvoid SCL_IncColOffset(Uint16 offsetReg, Sint16 red,
Sint16 green, Sint16 blue)

Input

offsetreg :deOutputFunction Value
Function

Indicates which color offset register to use.
SCL_OFFSET_A, SCL_SCL_OFFSET_B
red: Color indicator (red)-255~255
green : Color indicator (green)-255~255
blue: Color indicator (blue)-255~255
None
None
Increases/decrease the color offset values.

Title

Function

Function Specification

Set the auto color offset

Function NameNo

SCL_SetAutoColOffset

43

void SCL_SetAutoColOffset( Ui nt 32 off setReg, Ui nt 32 i nt e rval,
Ui nt 32 t i me, Sc lRgb *sta rt , Sc lRgb *end )Input

offsetreg :CoIndicates which color offset register to use.
SCL_OFFSET_A, SCL_OFFSET_B
interval : Interval
Designated in units of 1/60th of a second.
time: Indicates the time to complete the color change.
Designated in units of 1/60th of a second.
start: Start color indicator (red)-255~255: Start color indicator (green)-255~255: Start color indicator (blue)-255~255
end: End color indicator (red)-255~255: End color indicator (green)-255~255: End color indicator (blue)-255~255
None
None
Changes the color offset according to the designated time orinterval.

SE

GA

OutputFunction Value
Functionnfi

FormatUser's Guide 2 Graphics Library83

Function

Function Name

No

Function Specification

Enable blur calculations

SCL_EnableBlur

44

void

OutputFunction Value
Function

SCL_EnableBlur(Uint32 surface)surfaces :Screen types
SCL_SPR, SCL_NBG0, SCL_NBG1, SCL_NBG2, SCL_NBG3,
SCL_RBG0, SCL_RBG1, SCL_EXBG
None
None
Enables blur calculations.

Title

Function

Function Specification

Disable blur calculations
void

SCL_DisableBlur(void)

None
None
None
Disables blur calculations.

Function

Function Specification

Bring in line color screen

No

SCL_EnableLineCol

46

Function

Function NameNo

Disable line color screen

SCL_DisableLineCol

47

void

SCL_DisableLineCol(Uint32 surface);

surfaces :Screen types
SCL_SPR, SCL_NBG0, SCL_NBG1, SCL_NBG2, SCL_NBG3,
SCL_RBG0, SCL_RBG1, SCL_EXBG
None
None
Disables line color screens.

SE

OutputFunction Value
Function

84

Function Namesurfaces :Screen types
SCL_SPR, SCL_NBG0, SCL_NBG1, SCL_NBG2, SCL_NBG3,
SCL_RBG0, SCL_RBG1, SCL_EXBG
None
None
Brings in line color screens.

GA

Function Specification
FormatInput

45void SCL_EnableLineCol(Uint32 surface);

OutputFunction Value
Function

Title

SCL_DisableBlur

Co

Title

Format
Input

No

nfi

FormatInput
OutputFunction Value
Function

Function NamedeFormat
Input

nti
al

Title

TitleFunction

Function Name

No

Function Specification
FormatInput

Set shadow bit

SCL_SetShadowBit

48

nti
al

Title

enable: Indicates which screen will have shadow. Use OR
to indicate multiple screens simultaneously.
SCL_NBG0| SCL_NBG1| SCL_NBG2|SCL_NBG3|
SCL_RBG0| SCL_RBG1|SCL_BACK|SCL_EXBG|SCL_NON

None
None
Sets the shows bit.
Shadow sprites must be prepared in advance using VDP1.
Function

Function NamedeOutputFunction Value
Function
Comments

void SCL_SetShadowBit(Uint32 enable);

No

Title

GA

Co

nfi

Set frame change interval countFunction Specification
49
SCL_SetFrameInterval
Formatvoid SCL_SetFrameInterval(Uint16 count)
Input
count
: V-BLANK interval countOutputNone
Function Value None
Function
Sets the frame change interval count.
The interval count values have the following meanings.
0= Frame change is set to auto change mode and theinterval count to 1. Cannot be synchronous with
SCL_DisplayFrame().
1= Frame change is set to auto change mode and theinterval count to 1. Can be synchronous with
SCL_DisplayFrame().
0xffff = Frame change is set to undefined interval manualchange mode. Confirms VDP1 draw end before
frame change.
0xfffe = Undefined interval manual change mode through V-BLANK
erase. Changes frame without confirming VDP1 draw end.
Other = Frame change is set to defined interval manualchange mode through the designated interval count.
b15=0: Does erase write.
=1: Does not erase write.

SE

Function Specification
FormatInput
OutputFunction Value
Function

Function

Function Name

No

Wait for frame change request to end SCL_DisplayFrame

50

void

SCL_DisplayFrame(void)

None
None
None
Turns on the frame change request flag and waits for the
V-BLANK interrupt routine sprite and scroll frame display to
end.

User's Guide 2 Graphics Library85

Function

Function Name

No

Function Specification

V-BLANK start VDP interrupt processing

SCL_VblankStart

51

FormatInput
OutputFunction Value
Functionvoid

SCL_VblankStart(void)

None
None
None
VDP1, 2 display V-BLANK start processing (scroll parameter
set, etc.).

Function

Function Name

Function Specification

V-BLANK end VDP interrupt processing
void SCL_VblankEnd(void)

nfi

Function

Function Specification

Force abort of automatic VE

Covoid SCL_AbortAutoVE(void)

GA

None
None
None
Forced abort of automatic VE.

SE86

SCL_VblankEnd

No

52

None
None
None
VDP1, 2 display V-BLANK end processing (scroll parameter
set, etc.).

Title

FormatInput
OutputFunction Value
Function

de

Title

FormatInput
OutputFunction Value
Function

nti
al

Title

Function NameNo

SCL_AbortAutoVE

53

nti
al

Mathematical Calculation Library
1.0 Guide

1.1 Objective
The mathematical calculation library is a group of routines designed to simplify 3D
display, 3D object move calculations, 32-bit fixed decimal calculations, etc.
These routines are separated into the following categories.

de• Triangle Functions
Sin, cos values are pulled from the table. Tables are recorded once each, andbetween each is a straight line complement.

nfi• Matrix Calculation Processing
Used for matrix stack control and matrix combination processing.
• 3D Coordinate Conversion Processing through the DSP
The polygon data hide surface determination, brightness calculation and coordinate conversion process used by the sprite 3D display library are all done together
by the DSP.

Co

• Perspective Conversion Process
Perspective conversion is done using the view coordinate system to convert from
3D to 2D screen. The view point position is the origin point and the screen position is the Z axis -1.0 position.

SEGA• Random Number Generator
Generates random numbers with a range of 0 to 0xffffffff that are used in games.

User's Guide 2 Graphics Library

87

nti
al

• Spline Curve Calculation
This curve calculation function is used to calculate 3D spline curves and has thefollowing characteristics.
1) Supports both 2D and 3D coordinate systems.
2) Can get the output coordinate connecting vectors.

nfi

de

As shown in Figure 1, by just specifying a few points, the curve that passes
through those points can be extrapolated. In Figure 1, the input coordinates are
P0~3; by entering the number of points to be entered, four, and the number ofpoints wanted, 10, then the output coordinates that pass through those points areshown by c0~c9. Also, by using a connecting line function, the connecting vectorof the output coordinates can be obtained. Connecting line vectors can be used
for character direction, etc.

Co

P0~P3: Input Coordinatesc0~c9: Output Coordinates

Figure 1 Curve Calculation DiagramGA• Fixed Point Calculation
There are routines and macros for 32-bit fixed point data (16 bit integer + 16 bit
decimal), multiplication and division calculations, and integer, floating point datacompatibility conversion.

SE• Other Functions
Calculation function other than that listed above.

88

2.1

Data Specifications

Title

Data

Data Specification

2D Point DatantialReference

Data Name

typedef struct MthXy
Fixed32 x;
Fixed32 y;} NthXy;

Title

Data

Data Specification

3D Data Structure

MthXy

{

/* X Coordinate *//* Y Coordinate */Data Name{/* X Coordinate *//* Y Coordinate *//* Z Coordinate */

Title

Data

Data Specification

3 Line, 4 Column Matrix Data

Data Specification

Data Name

MthMatrix/* 3 line, 4 column fixed point data */Data

Data Name

Matrix Stack Table

MthMatrixTbl

typedef struct MthMatrixTbl {Uint16stackSize; /* Matrix stack entries
MthMatrix*current; /* Current matrix pointer
MthMatrix*stack;/* Matrix stack pointer} MthMatrixTbl;

No

*/
*/
*/

SE

GA

No

{

Co

typedef struct MthMatrix
Fixed32 val[3][4];} MthMatrix

Title

No

MthXyznfi

typedef struct MthXyz
Fixed32 x;
Fixed32 y;
Fixed32 z;} MthXyz;

No

de

2.0

User's Guide 2 Graphics Library89

Data Specification

Data
Polygon Data Coordinate Conversion
Parameter

Data NameNo

MthPolyTransParm

nti
al

Title

typedef struct MthPolyTransParm {MthViewLight *viewLight; /* Coord. system conversion parameters*/
Uint32 surfCount;/* Polygon surfaces*/
MthXyz *surfPoint;/* Point on polygon for brightness calculation*/
MthXyz *surfNormal;/* Polygon surface lines*/
Uint32
MthXyz
MthXyzUint32
MthXyzSint32}*surfBright;

transViewVertCount;*transViewVertSrc;*transViewVertAns;
gourVertCount;*vertNormal;*vertBright;/* Polygon surface brightness calc. results*//* View conversion vertex entries*//* Vertex data before view conversion*//* Vertex data after view conversion*//* Vertex point brightness vertex entries *//* Vertex point brightness calc. normal *//* Vertex point brightness calc. reultsdeSint32*/

Uint32 transWorldVertCount; /* World coord. conversion vertex entries */MthXyz *transWorldVertSrc; /* Vertex data before World conversion*/
MthXyz *transWorldVertAns; /* Vertex data after World conversion*/
MthPolyTransParm;

Data

Data Name

Data Specification

Coordinate System Conversion Parameters MthViewLight

nfi

Title

No

SE

GA

Co

typedef struct MthViewLight {MthMatrix viewMatrix;/* Conversion matrix to view coordinates */MthXyzlightVector; /* Light source toggle in view coord. sys*/
MthMatrix worldMatrix; /* Conversion matrix to world coord. sys.*/} MthViewLight;

90

2.2

List of Functions
Function Name
MTH_Sin
MTH_Cos
MTH_Atan1
2
3

MTH_InitialMatrix
MTH_ClearMatrix
MTH_PushMatrix
MTH_PopMatrix

MTH_CordTrans
MTH_NormalTrans

4
5
6
7
8
9
10
11
12
13
14
15

MTH_PolyDataTransInit
MTH_PolyDataTansExec
MTH_PolyDataTransCheck

16
17
18

MTH_Pers2D

19

MTH_InitialRand
MTH_GetRand

20
21

MTH_INIT_CURVE
MTH_Curve2

22
23
24
25
26

MTH_MoveMatrix
MTH_RotateMatrixX
MTH_RotateMatrixY
MTH_RotateMatrixZ
MTH_ReverseZ
MTH_MulMatrix

MTH_Curve2t
MTH_Curve3
MTH_Curve3t

SE

GA

Co

nfi

de

<Triangle Functions>sin functioncos function
atan function<Matrix Calculation>
Initialize matrix stack
Clear current matrix
Push matrix
Pop matrix
Combine matrix and move horizontally
Combine matrix and rotate X
Combine matrix and rotate Y
Combine matrix and rotate Z
Combine matrix and reverse Z
Matrix calculation and multiplication
Matrix calculation and vertex coordinate conversion
Matrix calculation, line toggle coordinate conversion<3D Polygon Data Coordinate Conversionthrough the DSP>
Initialize Coordinate Conversion Process
Execute the Coordinate Conversion Process
Check the Coordinate Conversion Process<Perspective Conversion>
3D perspective conversion<Random Number Generator>
Initialize the Random Number Generator
Get Random Number<Spline Curve Calculation>
Curve calculation, work area definition macro
Curve calculation, 2D
Curve calculation, 2D with tangent
Curve calculation, 3D
Curve calculation, 3D with tangent

NumberntialFunction

User's Guide 2 Graphics Library91

Function Name

MTH_Div

MTH_FLOAT

MTH_FIXEDMTH_IntToFixed
MTH_FixedToInt
MTH_Product

27
28
29
30
31
32
33

34
35
MTH_CompateNormVect 36
MTH_Sqrt

MTH_Hypot

nfi
Co
GA
SE
92

Numbernti
al

MTH_MuldeFunction<Fixed Point Calculations>
Multiplication Routine
Division routine
Fixed to floating point conversion macro
Floating to fixed point conversion macro
Integer to fixed conversion routine
Fixed to integer conversion routine
3 item sum of product calculation<Other Functions>
Square Root
Hypotenuse calculation of a right angle triangle
Surface normal vector calculation

2.3

Function Specifications

Title

Function

Function Specification

sin function

Function Specificationcos function

1

Function NameNo

MTH_Cos

2

Fixed32 val = MTH_Cos(Fixed32 degree)nfi

degree: Angles from -180.0 to 180.0
Noneval: cos value
Returns the cos value of the indicated angle.

Function

Function Specification

atan function

Co

Title

Function NameNo

MTH_Atan

3

Fixed32 degree = MTH_Atan(Fixed32 y, Fixed32 x)y: Height from -1.0 to 1.0x: Base from -1.0 to 1.0
None
degree: Angles from -180.0 to 180.0
Returns the atan value from the indicated x, y values.

SE

GA

OutputFunction Value
Function

MTH_Sindegree: Angles from -180.0 to 180.0
Noneval: sin value
Returns the sin value of the indicated angle.

Function

FormatInput

No

Fixed32 val = MTH_Sin(Fixed32 degree)

Title

FormatInput
OutputFunction Value
Function

Function NamedeFormatInput
OutputFunction Value
Functionntial<Triangle Functions>User's Guide 2 Graphics Library93

<3D Matrix Calculation>
Function

Function Name

Function Specification

Initialize matrix stack

MTH_InitialMatrix

Formatvoid MTH_InitialMatrix( Mt hMatr i xTbl
stackSi ze, Mt hMatr i x *matr i x)

Input

matrixTbl : Matrix table
stackSize : Maximum entries on a matrix stackmatrix: Matrix stack area
matrixTbl : Matrix table
None
Initializes the matrix table.

4*matr i xTbl , Ui nt 16

deOutputFunction Value
Function

No

nti
al

Title

5

Title

Function

Function Name

No

Function Specification

Push matrix

MTH_PushMatrix

6

void

*matrixTbl)

Title

Function

Function Specification

Clear current matrix

Title

Function Specification

No

MTH_ClearMatrix*matrixTbl)

nfi

matrixTbl : Matrix table
None
None
Clears the current matrix to a unit matrix.

MTH_PushMatrix(MthMatrixTbl

matrixTbl : Matrix table
None
None
Pushes the current matrix.

Function

Function NameNo

Pop matrix

MTH_PopMatrix

7

void

*matrixTbl)

MTH_PopMatrix(MthMatrixTbl

matrixTbl : Matrix table
None
None
Pops the current matrix.

SE

FormatInput
OutputFunction Value
Function

94

MTH_ClearMatrix(MthMatrixTbl

GA

FormatInput
OutputFunction Value
Functionvoid

Co

FormatInput
OutputFunction Value
Function

Function Name

Function

Function Name

No

Function Specification

Combine matrix and move horizontally

MTH_MoveMatrix

8

nti
al

Title

Formatvoid MTH_MoveMatrix(MthMatrixTbl
Fixed32 x, Fixed32 y, Fixed32 z)

Input

matrixTbl : Matrix tablex: Amount to move in X directiony: Amount to move in Y directionz: Amount to move in Z direction
None
None
Combines the matrix for a horizontal move in the XYZ
direction for the current matrix.

deOutputFunction Value
Function

Title

Function

Function Specification

Combine matrix and rotate X

Title

Function Specification
Format
Input

Title

Function Specification

SE

FormatInput

OutputFunction Value
FunctionNo

MTH_RotateMatrixX

9*matr i xTbl , Fi xed32 xDegree)

matrixTbl : Matrix table
xDegree : X axis rotation angle (Range from -180.0 to 180.0)
None
None
Combines the matrix for X axis rotation for the current matrix.

Function

Function Name

No

Combine matrix and rotate Y

MTH_RotateMatrixX

10void MTH_RotateMatrixY( Mt hMatr i xTbl

*matr i xTbl , Fi xed32 yDegree)

matrixTbl : Matrix table
yDegree : Y axis rotation angle (Range from -180.0 to 180.0)
None
None
Combines the matrix for Y axis rotation for the current matrix.

GA

OutputFunction Value
Function( Mt hMatr i xTbl

Function Name

nfi

OutputFunction Value
Function

void MTH_RotateMatrixX

Co

FormatInput*matrixTbl,

Function

Function Name

No

Combine matrix and rotate Z

MTH_RotateMatrixZ

11

void MTH_RotateMatrixZ( Mt hMatr i xTbl

*matr i xTbl , Fi xed32 zDegree)

matrixTbl : Matrix table
zDegree : Z axis rotation angle (Range from -180.0 to 180.0)
None
None
Combines the matrix for Z axis rotation for the current matrix.

User's Guide 2 Graphics Library95

Function

Function Name

No

Function Specification

Combine matrix and reverse Z

MTH_ReverseZ

12

FormatInput
OutputFunction Value
Functionvoid

MTH_ReverseZ(MthMatrixTbl

nti
al

Title

*matrixTbl)

matrixTbl : Matrix table
None
None
Combines the current matrix for Z axis reversal.

Function

Function Name

No

Function Specification

Matrix calculation, multiplication

MTH_MulMatrix

13

void

OutputFunction Value
Function

MTH_MulMatrix(MthMatrix*a, MthMatrix*b, MthMatrix*c)a: Multiplicand matrixb: Multiplier matrixc: Multiplication results matrix
None
Multiplies matrix a and b and outputs the result to c.

nfi

Format
Input

de

Title

Function

Function Name

No

Function Specification

Matrix calculation, vertex coordinate
MTH_CordTrans
conversion

14

FormatInput

void MTH_CoordTrans ( Mt hMatr i x *matr i x, Mt hXyz *s rc, Mt hXyz *ans )Function Specification
FormatInputmatrix: Conversion matrix
src: Vertex coordinates before conversion
ans: Vertex coordinates after conversion
None
Converts vertex coordinates in the conversion matrix.

Function

Function Name

No

Matrix calculation, normal vector coordinate
conversion

MTH_NormalTrans

15

GA

OutputFunction Value
Function

Title

Co

Title

matrix: Conversion matrix
src: Normal vector before conversion
ans: Normal vector after conversion
None
Converts normal vector in the conversion matrix.

SE

OutputFunction Value
Function

void MTH_NormalTrans ( Mt hMatr i x *matr i x, Mt hXyz *s rc, Mt hXyz
*ans )

96

<3D Polygon Data Coordinate Conversion through the DSP>
Function

Function Specification

Initialize Coordinate Conversion Process

FormatInput
OutputFunction Value
Function

void

No

MTH_PolyDataTransInit

16

MTH_PolyDataTransInit(void)

None
None
None
Initializes the DSP and loads the coordinate conversion
program.
Function

Function Name

Function Specification

3D Polygon Data Coordinate Conversion

de

Title

FormatInput
OutputFunction Name

nti
al

Title

void MTH_PolyDataTransExec(No

MTH_PolyDataTransExec 17

Mt hPolyTr ansPa rm *polyTr ansPa rm)

nfi

polyTransParm: Coordinate conversion parameter table
PolyTransParm: The areas below are outputfrom thecoordinate
conversion table.
surfBright
Polygon surface brightness calc. resultstransViewVertAns Vertex data after view conversion
vertBright

Vertex point brightness calc. resultstransWorldVertAns Vertex data after World conversion
None
The DSP runs the following continuous process of an example
of polygon data (3D object) used by the 3D sprite display
library.

Co

Function Value
FunctionSE

GA· Polygon Surface Hide Determine and Brightness Calculation– Related Parameters –<Input> surfCount Polygon surfaces
surfPoint Point on polygon for bright calculation
surfNormal Polygon surface normal
matrixConversion matrix to view coordinates
light Vector Light source vector in the view coord. system<Output> surfBright
Polygon surface brightness calc. results=1:
Hide surface
631=0:Show surface
b4-b0 =0x00: Darkest
0x1f =0x1f: Lightest· Conversion to the Vertex Coordinate System– Related Parameters –<Input> transViewVertCount View conversion vertex entries
transViewVertSrc
Vertex data before view conversion
Conversion matrix to the view coord. system
viewMatrix<Output> transViewVertAns
Vertex data after view conversion

User's Guide 2 Graphics Library

97

nti
al

· Gouraud Display Vertex Brightness Calculation– Related Parameters –<Input> gourVertCount Vertex point brightness vertex entries
If = 0, then brightness not calculated
vertNormal
Vertex point brightness calc. normal table
matrixConversion matrix to view coordinates
lightVector
Light source vector in the view coord. sys.
<Output> vertBright
Vertex brightness calculation results table
0x00= Darkest
0x1f= Lightest

nfi

de

· Conversion to the Vertex World Coordinate System– Related Parameters –<Input> transWorldVertCount Vertex data before World conversion
If = 0, conversion to world not
executed.
transWorldVertSrc
Vertex data table before world coord.
conversion
worldMatrix
Conversion matrix to world coordinates<Output> transWorldVertAns Vertex data table after conversion toworld coordinate system
Function

Function Specification

Check the Coordinate Conversion Process

FormatInput
OutputFunction Value
Function

Function NameNo

MTH_PolyDataTansCheck

18

Co

Title

void MTH_PolyDataTransCheck(void)

None
None
None
Waits until the DSP coordinate conversion process is finished.

<Perspective Conversion>
Function

Function Name

No

Function Specification

3D perspective conversion

MTH_Pers2D

19

Format
Input

GA

Title

98

*p2d )

p3d: View coordinate system 3D vertex coordinates
unitPixel : Screen XY unit pixels
p2d: 2D screen coordinates after perspective conversion
None
Converts from 3D to 2D perspective by setting the screen to -1.0
as the view of the coordinate system base point. The size of 1.0
on the screen corresponds to the XY unit pixels.

SE

OutputFunction Value
Function

void MTH_Pers2D ( Mt hXyz *p3d, Mt hXy *uni t Pi xel, XyI ni t<Random Number Generator>
Function

Function Specification

Initialize the Random Number Generator
void

MTH_InitialRand

20

MTH_InitalRand(Uint32 initVal)

initVal: Initial parameter value of the random number generator
None
None
Sets the initial parameter for calculation of the random number
returned by MTH_GetRand. Unless this routine is called, theinitial value of the random number generator will be 0.

Title

Function

Function Specification

Get Random Number

Function NameNo

MTH_GetRand

21

Uint32 randVal = MTH_GetRand(void)

nfi

None
None
randVal : Generates a random number from 0x00000000 to 0xffffffff.
Returns a random number each time it is run.

SE

GA

Co

FormatInput
OutputFunction Value
FunctionNodeFormatInput
OutputFunction Value
Function

Function Name

nti
al

Title

User's Guide 2 Graphics Library99

<Spline Curve Calculation>
Function

Function Name

Function Specification

Curve calculation, work area
definition macro

MTH_INIT_CURVE

FormatInput

22

MTH_INIT_CURVEWORK(WORK_AREA, POINT_MAX)

Function

Function Specification

2D

Function NameNo

MTH_Curve2

23

nfi

Title

de

WORK_AREA : Work area name
POINT_MAX : Maximum input points
Defines as user area the area needed to execute the curve
calculation function. This definition area pointer is returned toeach curve calculation function as a parameter.
The area reserved is the maximum input points x 36bytes.
The count of the output coordinate is (in_n - 1) *step+ 1, so
prepare an aray larger than that size.

Function

Ui nt 32 count = MTH_Cur ve2( Mt hCur veWo rk *wo rk, Mt hXy *i n_a ray,Ui nt 32 i n_n, Ui nt 32 out _n, Mt hXy *out _a ray)

Input

work
: Work area pointerin_aray: Input coordinate aray
in_n
: Input coordinate countout_n: Output coordinate count
out_aray : Output coordinate aray
count
: More than 2 output coordinates
0: parametererror
work indicates the work area reserved by the
MTH_INIT_CURVE macro.
- in_aray indicates the pointer to input coordinates that passthrough the curve.
- in_n indicates the number in in_aray. Please indicate morethan 3.
- out_n indicates the number in out_aray. Please indicate morethan 2.
- out_aray indicates the pointer that receives the calculation
results. It returns the aray of the output coordinates that passthrough the curve.

SE

GA

Co

FormatOutputFunction Value
Function

100

No

nti
al

Title

Function

Function Name

No

Function Specification

Curve calculation, 2D with connectors

MTH_Curve2t

24

nti
al

Title

Uni t 32 count = MTH_Cur ve2( Mt hCur veWo rk *wo rk, Mt hXy *i n_a ray,Uni t 32 i n_n, Uni t 32 out _n, Mt hXy *out _a ray Mt hXy *t an_a ray)

Input

work
: Work area pointerin_aray: Input coordinate aray
in_n
: Input coordinate countout_n: Output coordinate count
out_aray : Output coordinate aray
tan_aray : Connector line toggle of each output coordinates
count: More than 2 output coordinates
0: parametererror
work indicates the work area reserved by the
MTH_INIT_CURVE macro.
- in_aray indicates the pointer to input coordinates that passthrough the curve.
- in_n indicates the number in in_aray. Indicate more than 3.
- bout_n indicates the number in out_aray. Indicate more than2.
- out_aray indicates the pointer that receives the calculation
results. It returns the aray of the output coordinates that passthrough the curve.
- tan_aray returns the tangent vector toggle that shows the
direction of progress for each output coordinate. The size ofthe tangent vector is 1.0.

OutputTitle

Function Specification
FormatFunction

Function Name

No

3D

MTH_Curve3

25

Ui nt 32 count = MTH_Cur ve3( Mt hCur veWo rk *wo rk, Mt hXyz *i n_a ray,Uni t 32 i n_n, Uni t 32 out _n, Mt hXyz *out _a ray)work
: Work area pointerin_aray: Input coordinate aray
in_n
: Input coordinate countout_n: Output coordinate count
out_aray : Output coordinate aray
count
: More than 2 output coordinates
0: parametererror
work indicates the work area reserved by the
MTH_INIT_CURVE macro.
- in_aray indicates the pointer to input coordinates that passthrough the curve.
- in_n indicates the number in in_aray. Indicate more than 3.
- out_n indicates the number in out_aray. Indicate more than 2.
- out_aray indicates the pointer that receives the calculation
results. It returns the aray of the output coordinates that passthrough the curve.

GA

Input

Co

nfi

Function Value
FunctiondeFormatSE

OutputFunction Value
Function

User's Guide 2 Graphics Library101

Function

Function Name

No

Function Specification

Curve calculation, 3D with tangent

MTH_Cruve3t

26

nti
al

Title

Ui nt 32 count = MTH_Cur ve3t ( Mt hCur veWo rk *wo rk, Mt hXyz *i n_a ray,Uni t 32 i n_n, Uni t 32 out _n, Mt hXyz *out _a ray, Mt hXyz *t an_a ray)

Input

work
: Work area pointerin_aray: Input coordinate aray
in_n
: Input coordinate countout_n: Output coordinate count
out_aray : Output coordinate aray
tan_aray : Tangent vector toggle of each output coordinates
count: More than 2 output coordinates
0: parametererror
work indicates the work area reserved by the
MTH_INIT_CURVE macro.
- in_aray indicates the pointer to input coordinates that passthrough the curve.
- in_n indicates the number in in_aray. Indicate more than 3.
- out_n indicates the number in out_aray. Indicate more than 2.
- out_aray indicates the pointer that receives the calculation
results. It returns the aray of the output coordinates that passthrough the curve.
- tan_aray returns the tangent vector toggle that shows the
direction of progress for each output coordinate. The size oftangent vector is 1.0.

Function Value
FunctionCo

Cautions on Use

nfi

OutputdeFormatSE

GA

These curve calculation functions were developed with process
speed as a top priority, so there is no overflow check. But, if alarge number is encountered during function calculation, an
overflow will occur. The allowable range of input data is asfollows:· Distance between points: more than 0.1.
· Point coordinate value range: between -1000 and 1000.
Also, because of possible algorithm changes in future versions,the same output coordinates may not be produced with thesame parameters.

102

<Fixed Point Calculations>
Function

Function Specification

Multiplication Routine

FormatInput

Function Name

No

nti
al

Title

MTH_Mul27

Fixed32 result = MTH_Mul(Fixed32 a, Fixed32 b)

Title

Function

Function Specification

Division routine

FormatInput

Function NameNo

MTH_Div

28

deOutputFunction Value
Functiona: Multiplicandb: Multiplier
None
result: Multiplication results
Does fixed point multiplication.

Fixed32 result = MTH_Div(Fixed32 a, Fixed32 b)

nfi

OutputFunction Value
Functiona: Dividendb: Divisor
None
result: Division results
Does fixed point division.

Function

Function Specification

Fixed to floating point conversion macro

Co

Title

FormatInput
OutputFunction Value
Function

Function NameNo

MTH_FLOAT

29

Float b = MTH_FLOAT(Fixed32 a)a: Fixed point dataNoneb
: Conversion results to floating point format.
Macro to convert fixed point data to floating point data.

Function

Function Name

No

Function Specification

Floating to fixed point conversion macro

MTH_FIXED

30

GA

Title

Fixed32 b = MTH_FIXED(Float a)a: Floating point dataNoneb
: Conversion results to fixed point format.
Macro to convert floating point data to fixed point data.

SE

FormatInput
OutputFunction Value
Function

User's Guide 2 Graphics Library103

Function

Function Name

No

Function Specification

Integer to fixed conversion routine

MTH_IntToFixed

31

FormatInput
OutputFunction Value
Function

Fixed32 b = MTH_IntToFixed(Sint32 a);

nti
al

Title

a
: Integer dataNoneb
: Conversion results to fixed point data.
Macro to convert integer data to fixed point data.

Function

Function Name

No

Function Specification

Fixed to integer conversion routine

MTH_FixedToInt

32

Sint32 b = MTH_FixedToInt(Fixed a)

Title

Function

Function Specification
FormatInput

Function NameNo

3 item sum of product calculation

MTH_Product33

Fixed32 result = MTH_Product(Fixed32*a, Fixed32

SE
104

*b)

a
: 3 Multiplicand data linesb: 3 multiplier data lines
None
results: Product sum of the multiplication results
Does calculation processing as follows:
result = a[0]*b[0] + a[1]*b[1] + a[2]*b[2]GA

OutputFunction Value
Functionnfia: Fixed point dataNoneb
: Conversion results to integer data format.
Macro to convert fixed point data to integer data.

Co

FormatInput
OutputFunction Value
Function

de

Title

<Other Functions>
Function

Function Specification

Square RootFormatInput
OutputFunction Value
Function

Function Name
MTH_Sqrt

x: Correct fixed point real number value
None
result: Calculated square root value
Calculates and returns the square root of the input value.

Function Specification

Hypotenuse calculation of a rightangle triangle

Function NameNo

MTH_Hypot

35deFunction

Fixed32 z = MTH_Hypot(Fixed32 x, Fixed32 y)x: Right angle triangle base lengthy: Right angle triangle perpendicular length
Nonez: Hypotenuse length of the right angle triangle
Returns z that fulfills the following equation.
z2=x2+y 2 but z≥0

nfi

OutputFunction Value
Function

Title

Function

Function Specification

Surface normal vector calculation

Function NameNo

MTH_ComputeNormVect 36

void MTH_ComputeNormVect (Fixed32 surfNormK,
MthXyz *p0, MthXyz *p1, MthXyz *p3, MthXyz *normal)

Co

FormatInput

34

Fixed32 result = MTH_Sqrt(Fixed32x)

Title

Format
Input

No

nti
al

Title

SE

GA

OutputFunction Value
Function

surfNormK : Vertex distance correction valuep0: Coordinate of first vertex right of top of screen.
p1: Coordinate of second vertex right of top of screen.
p2: Coordinate of third vertex to right of top of screen.
Normal : Normal screen vecter (uint vecter)None
Calculates normally for the indicated right hand vertex on thescreen. The direction in relation to the normal vector is the
opposite of right twist. The normal vertor calculation is basedon the difference between 2 of 3 vertexes on the screen andfinding the relationship.
The correction value of the indicated vertex interval isconverted to absolute values to find the maternal relationshipbased on the 2 vectors. This is because if the 3 pointers on thescreen are too small or too large, the 32 bit fixed decimal
calculation either underflows or overflows, making a correct
calculation difficult. To avoid this, the correction value is used
to make sure the absolute value is around 1.0 when the
difference of the 23 screen points vector is found. If the vertex
interval correction flag is negative, the normal vector will be in
the opposite direction.

User's Guide 2 Graphics Library

105

SE

GA

Co

nfi

de

nti
al

(There is no page 106 in the original Japanese document.)1061.0 Guidential

DSP I/F Library

1.1 Objective
The purpose of this library is to provide an interface for DSP program control.

de

1.2 Overview
This library has the following interfaces prepared.
· Program load
· Data write· Data read
· Start program execution· Stop program execution· Check for execution end

nfi

An overview of each function is provided below.

Co

1.3 Function Overview• Program load
Transfers the DSP program stored in work RAM, etc., to DSP program RAM.
• Data write
Transfers the DSP program data (parameters) stored in work RAM, etc., to DSP
data RAM.
• Data read
Reads DSP data and RAM data (results, etc.)

GA• Start program execution
Sets the program counter and starts the DSP program execution.
• Stop program execution
Stops execution of the DSP program.

SE• Check for execution end
Checks to see if the DSP program has stopped executing.

User's Guide 2 Graphics Library

107

nti
al

1.4 Calling Sequence
The calling sequence from program load until results appearing is shown below.
void GoDsp (){Uint32 dsp_result[10]; /* DSP result storage variable */de

DSP_WriteData(DSP_RAM_1 | 0, (Uint32 *)0x6050000, 15);/* Transfer 15 times of data to DSP data RAM, RAM1 from work RAM*/
DSP_LoadProgram(0, (Uint32 *)0x6050100, 256);/* Transfer 256 times of data to DSP program RAM from work RAM*/
DSP_Start(0);/* Execute DSP program from 0x00*/
while(DSP_CheckEnd(&dsp_status) == DSP_NOT_END); /* Loop
until ends */DSP_ReadData(dsp_result, DSP_RAM_2 | 0, 10);/* Transfer 10 times of data from DSP data RAM, RAM2 to DSP result storage variable */......

SE

GA

Co

nfi

}

108

2.0 Referencenti
al

2.1 List of Functions
Function

Function NameDSP_LoadProgram
DSP_WriteData
DSP_ReadData
DSP_Start
DSP_Stop
DSP_CheckEnd

2.2 Function Specifications
Title

Function

Function Specification

Program load

FormatInput

DSP_LoadProgram1

nfi

Function

Function NameNo

Data write

DSP_WriteData2

void DSP_WriteData(Uint8 dst, Uint32 *src, Uint16 count)

dst: DSP data RAM address
src: DSP data storage lead address
count: Transfer repetitions (long word units)
None
None
Transfers from the indicated DSP data storage address data
equal to the number of repetitions specified (long word units)
to the address in the DSP data RAM. Designates the DSP data
RAM address, including the selector flag in 8bit.
DSP_RAM_0
DSP_RAM_1
DSP_RAM_2
DSP_RAM_3
DSP_RAM_2 |3 = Relative third long word RAM2 page.

GA

Format
Input

No

dst
: DSP program RAM address
src: DSP program storage lead address
count: Transfer repetitions (long word units)
None
None
Transfers from the indicated DSP program storage lead address
data equal to the number of repetitions specified (long word
units) to the DSP program RAM address.

Co

Function Specification

Function Name

void DSP_LoadProgram(Uint8 dst, Uint32 *src, Uint16 count)OutputFunction Value
Function

Title

Number

1
2
3
4
5
6

de

Program load
Data write
Data readStart program execution
Stop program execution
Check for execution end

SE

OutputFunction Value
Function

User's Guide 2 Graphics Library109

Function

Function Name

No

Function Specification

Data read

DSP_ReadData3

Format
Input

nti
al

Title

void DSP_ReadData(Uint32 *dst, Uint8 src, Uint16 count)

Title

Function

Function Specification

Start program execution

Function

Function Specification

Stop program execution

DSP_Start

4

Function NameNo

DSP_Stop5

void DSP_Stop(void)

GA

None
None
None
Stops the DSP program currently running.

SE
110

No

pc
: Program counter
None
None
Executes the DSP program from the indicated program
counter.

Title

FormatInput
OutputFunction Value
Function

Function Namenfivoid DSP_Start(Uint8 pc)

Co

FormatInput
OutputFunction Value
FunctiondeOutputFunction Value
Functiondst: DSP data storage lead address
src: DSP data RAM address
count: Transfer repetitions (long word units)
None
None
Transfers from the indicated DSP data RAM, data equal to thenumber of repetitions specified (long word units) to the DSP
data storage address. Designates the DSP data RAM address,
including the selector flag in 8bit.

Function

Function Name

No

Function Specification

Check for execution end

DSP_CheckEnd

6FormatInput
OutputFunction Value
Constant Name

Uint8 DSP_CheckEnd(void)

None
None
End flag

Checks to see if the DSP program has finished running or not.

SE

GA

Co

nfi

Function

Explanation
Finished executing
ExecutingdeConstant NameDSP_END
DSP_NOT_END

nti
al

Title

User's Guide 2 Graphics Library

111

de

S
SCL_AbortAutoVE .....................
SCL_AllocColRam ......................
SCL_Close ....................................
SCL_DisableBlur .........................
SCL_DisableLineCol...................
SCL_DisplayFrame .....................
SCL_EnableBlur ..........................
SCL_EnableLineCol ....................
SCL_FreeColRam ........................
SCL_GetColRamMode ...............
SCL_GetColRamOffset ..............
SCL_GetPriority ..........................
SCL_IncColOffset ........................
SCL_InitConfigTb .......................
SCL_InitLineParamTb ................
SCL_InitLineParmTb ..................
SCL_InitRotateTable ...................
SCL_InitVramConfigTb .............
SCL_Move ....................................
SCL_MoveTo ...............................
SCL_Open ....................................
SCL_Rotate ..................................
SCL_RotateTo ..............................
SCL_Scale .....................................
SCL_SetAutoColChg ..................
SCL_SetAutoColMix ..................
SCL_SetAutoColOffset ...............
SCL_SetBack ................................

SE

GA

Co

M
MTH_Atan ................................... 93
MTH_ClearMatrix ...................... 94
MTH_ComputeNormVect ......... 105
MTH_CordTrans ......................... 96
MTH_Cos ..................................... 93
MTH_Curve2 ............................... 100
MTH_Curve2 ............................... 101
MTH_Curve3 ............................... 101
MTH_Curve3t ............................. 102
MTH_Div ..................................... 103
MTH_FIXED ................................ 103
MTH_FixedToInt......................... 104
MTH_FLOAT............................... 103
MTH_GetRand ............................ 109
MTH_Hypot ................................ 105
MTH_INIT-CURVE .................... 100
MTH_Initial Matrix .................... 94
MTH_InitialRand ........................ 99
MTH_IntToFixed......................... 104
MTH_MoveMatrix...................... 95
MTH_Mul .................................... 103
MTH_MulMatrix ........................ 96
MTH_NormalTrans .................... 96
MTH_Pers2d................................ 98
MTH_PolyDataTransCheck ...... 98
MTH_PolyDateTransExec ......... 97
MTH_PolyDataTransInit ........... 97
MTH_PopMatrix ......................... 94
MTH_Product.............................. 104
MTH_PushMatrix ....................... 94
MTH_ReverseZ ........................... 96
MTH_RotateMatrixX .................. 95

MTH_RotateMatrixY .................. 95
MTH_RotateMatrixZ .................. 95
MTH_Sin ...................................... 93
MTH_Sqrt .................................... 105
MthMatrix .................................... 89
MthMatrixTbl .............................. 89
MthPolyTransParm..................... 90
MthViewLight ............................. 90
MthXy ........................................... 89
MthXyz ......................................... 89nfi

D
DSP_CheckEnd ........................... 111
DSP_LoadProgram ..................... 109
DSP_ReadData ............................ 110
DSP_Start ..................................... 110
DSP_Stop ...................................... 110
SDP_WriteData ........................... 109

nti
al

INDEX

112

86
79
69
84
84
85
84
84
79
78
80
81
83
66
69
69
71
66
70
70
69
73
73
71
80
82
83
75

Co

GA

SE

User's Guide 2 Graphics Library

26
25
24
30
22
22
30
30
23
23
31
25
25
22
27
26
25
25
29
26
28
28
28
29
24
23
24
22
27
27
27
41
42
41
37
37
40
41
43
38
40
38
43
39
38

nti
al

SPR_2CloseCommand ...............
SPR_2ClrAllChar ........................
SPR_2ClrChar ..............................
SPR_2Cmd ...................................
SPR_2DEFINE_WORK ..............
SPR_2DefineWork .......................
SPR_2DistSpr ...............................
SPR_2FlushDrawPrty .................
SPR_2FrameChgIntr ...................
SPR_2FrameEraseData ...............
SPR_2FreeBlock ...........................
SPR_2GourTblNo .......................
SPR_2GourTblNooV ram .........
SPR_2Initial..................................
SPR_2Line ....................................
SPR_2LocalCoord .......................
SPR_2LookupTblNo ...................
SPR_LookupTblNoToVram .......
SPR_2NormSpr ...........................
SPR_2OpenCommand ...............
SPR_2PolyGon ............................
SPR_2Polygon .............................
SPR_2PolyLine ............................
SPR_2ScaleSpr .............................
SPR_2SetChar ..............................
SPR_2SetGourTbl ........................
SPR_2SetLookupTbl ...................
SPR_2SetTvMode ........................
SPR_2Sysclip ...............................
SPR_2UserClip ............................
SPR_2UsrClip ..............................
SPR_3CallAllCluster ..................
SPR_3ChangeTexColor ..............
SPR_3ClrTexture .........................
SPR_3DEFINE_WORK ..............
SPR_3DefineWork .......................
SPR_3DrawModel ......................
SPR_3Flush ..................................
SPR_3GetStatus ...........................
SPR_3Initial..................................
SPR_3MoveCluster .....................
SPR_3SetClipLevel .....................
SPR_3SetDrawSpeed ..................
SPR_3SetLight .............................
SPR_3SetPixelCount ...................

de

74
81
81
82
79
78
67
67
65
85
70
77
75
74
80
72
72
72
85
78
77
66
76
86
86
65
57
60
62
59
55
55
61
56
56
61
57
60
56
62
55
55
31
25
25

nfi

SCL_SetCoefficientData .............
SCL_SetColMixMode .................
SCL_SetColMixRate ...................
SCL_SetColOffset ........................
SCL_SetColRam ..........................
SCL_SetColRamMode ................
SCL_SetConfig ............................
SCL_SetCycleTable .....................
SCL_SetDisplayMode ................
SCL_SetFrameInterval ...............
SCL_SetLineParam .....................
SCL_SetLineWindow .................
SCL_SetLncl .................................
SCL_SetMosaic ............................
SCL_SetPriority ...........................
SCL_SetRotateCenter .................
SCL_SetRotateCenterDisp .........
SCL_ SetRotateViewPoint..........
SCL_SetShadowBit .....................
SCL_SetSpriteMode ....................
SCL_SetSpriteWindow ...............
SCL_SetVramconfig ....................
SCL_SetWindow .........................
SCL_VblankEnd ..........................
SCL_VblankStart .........................
SCL_Vdp2Init ..............................
Sclconfig .......................................
SclDataset .....................................
SclDisplayX, SclDisplayY ..........
ScILineParam...............................
SclLineTb ......................................
SclLineWindowTb ......................
SclNorscl ......................................
SclRgb ...........................................
SclRgb ...........................................
SclRotscl .......................................
SclSclconfig ..................................
SclSysreg ......................................
SclVramConfig ............................
SclWinscl ......................................
SclXy .............................................
SclXyz ...........................................
SPR_2AllocBlock .........................
SPR_2CharNo ..............................
SPR_2CharNoToVram ................

113

nti
al
de
nfi

Co

SPR_3SetSurfNormVect ............. 43
SPR_3SetTexture ......................... 41
SPR_3SetView .............................. 39
SPR_3SeyZSortMinMax ............. 42
SPR_GetStatus ............................. 17
SPR_Initial.................................... 16
SPR_READ_REG ........................ 18
SPR_SetEosMode ........................ 18
SPR_SetEraseData ....................... 17
SPR_SetTvMode .......................... 16
SPR_WaitDrawEnd ................. 17, 18
SPR_WRITE_REG ....................... 18
Spr3dStatus ................................. 36
SprCluster .................................... 32
SprGourTbl .................................. 19
SprInbetInf ................................... 36
SprLookupTbl ............................. 19
SprObject3D ................................. 34
SprSpCmd .................................... 20
SprSpStatus .................................. 15
SprSurface .................................... 35
SprTexture .................................... 36
SprVaddr ...................................... 19

SE

GA

X
XyInt ............................................. 19114