Return to previous page | Return to menu | Go to next page


Rotating scroll screen rotation

In SEGA Saturn, it is possible to rotate the scroll with an arbitrary axis and arbitrary angle on the rotary scroll screen
(image model below).

Figure 8-22 Scroll rotation image

● 2D rotation (Z-axis rotation)
Use the library function “slZrotR” to perform 2D rotation operation (Z-axis rotation) of the rotary scroll screen with SGL.
The point set by the library function “slDispCenterR” is used as the center of rotation (one point on the scroll map).

[void slZrotR (ANGLE z_angle);]
Rotate the scroll screen “RBG0” with respect to the Z axis.
In the parameter, specify the Z-axis rotation angle of the current rotation parameter.
For the rotation angle, substitute the absolute rotation angle value, not the rotation angle value from the current state.
(The current parameter can be switched with the function “slCurRpara”).
The rotation center uses the point set by the library function “slLookR”.

Figure 8-23 Actual operation of scroll rotation

Notes on using functions
The function group “slZrotR”, “slZoomR”, “slLookR” used for the rotary scroll conversion operation is the same rotation parameter as the function “slScrMatSet” that performs various rotary scroll conversion operations (including 3D rotation). Please note that they cannot be used together.
This is because the above function group rewrites a specific area of ​​the rotation parameter, whereas the function group described below rewrites the entire rotation parameter.

The following sample program (Listing 8-5) is an example of actually rotating the rotating scroll screen using the SGL library function.

List 8-5 sample_8_9_1: Scroll 2D rotation

Flow 8-6 sample_8_9_1: Scroll 2D rotation

● 3D rotation using current matrix
To perform 3D rotation operation (rotation of all axes) of the rotary scroll screen using the current matrix in SGL, it is necessary to take the following steps.

1) Settings for rotating scroll
Complete the settings required for using rotary scrolling, such as rotating parameter settings, screen overprocessing, and coefficient table settings.

2) Coordinate operation
First, the 3D rotation operation multiplied by the scroll is executed for the current matrix.
Use the same function group such as “slRorX”, “slTranslate”, “slScale”.
However, the operation sequence for rotation, movement, and enlargement / reduction operations is the reverse of the normal coordinate conversion operation (see “Chapter 4: Coordinate Conversion” for the conversion operation sequence).
The scroll coordinate system is the left-handed coordinate system with the positive and negative of the Z axis reversed, but it looks exactly the same because it is captured by the image of the monitor rotating relative to the scroll.
If you want to perform coordinate transformation with the same matrix manipulation procedure as normal coordinate transformation, use the function “slScrMatConv” before transferring the matrix data.
The function “slScrMatConv” converts the current matrix converted by the normal coordinate conversion procedure into a coordinate conversion matrix for scrolling and uses it as the current matrix.

[void slScrMatConv (void);]
Converts the current matrix to scroll coordinate conversion data and replaces the current matrix.
Naturally, if the function is used for the current matrix after the scroll coordinate conversion operation is executed, the current matrix is ​​replaced with the normal coordinate conversion matrix.

3) Transfer the calculation result to the rotation parameter
Transfers the coordinate calculation result executed for the current matrix to the rotation parameter.
Rotating scroll is transformed / drawn based on the rotation parameter data transferred to the calculation result.
Use the function “slScrMatSet” to transfer data.

[void slScrMatSet (void);]
Transfers the current matrix data to the current rotation parameter.
Use this to transfer the current matrix that has undergone coordinate transformation operations in accordance with the rotating scroll.

Flow 8-7 3D rotation operation procedure using current matrix

● Control zoom ratio using coefficient table
When performing 3D rotation operation of rotating scroll, rotating scroll scales the scroll according to the depth of the scroll. Usually, this scale ratio is calculated based on each parameter used for 3D coordinate calculation such as perspective transformation, and the scroll is deformed, but this deformation ratio is preset in line units or dot units, It is available at runtime and is called the coefficient table.
When using the coefficient table, the following two functions are required.

1) Creating a coefficient table
First, it is necessary to reserve an area for the coefficient table in the VRAM area.
Be sure to create the coefficient table in VRAM.
The coefficient table occupies one bank in the VRAM area. This is because the coefficient table refers to the VRAM area at the maximum number of accesses (8 times) per bank.

[void slMakeKtable (void * adr);]
Creates a coefficient table to be used for 3D rotation operation at the specified address.
For the parameter, substitute the start address of the area where the coefficient table is created.
The coefficient table must be secured in the VRAM area.

2) Coefficient table usage mode setting
When using the area specified as the coefficient table as the coefficient table, it determines the usage mode of how to use the coefficient table.

[void slKtableRA, RB (void * table_adr, Uint16 mode);]
Specify the address of the coefficient table to be used, and further determine the usage contents of the coefficient table.
For the parameter, substitute the coefficient table start address and the value shown in the figure below indicating the use mode of the coefficient table (concatenation can be used with the or operator "|").
The function “slKtableRA” sets the coefficient table used by the rotation parameter A, and the function “slKtableRB” sets the coefficient table used by the rotation parameter B.

Figure 8-24 “slKtableRA, RB” parameter substitution value (mode)

Note) When fixed coefficient is specified for the parameter, the coefficient table is assumed to be prepared in advance, and the calculation of the coefficient table in real time is not executed.

Caution
For details on the coefficient table, refer to “HARDWARE MANUAL vol.2: VDP2 User's Manual”.

List 8-6 sample_8_9_2: 3D rotation

Flow 8-8 sample_8_9_2: 3D rotation


Return to previous page | Return to menu | Go to next page