Japanese
SGL User's ManualPROGRAMMER'S TUTORIAL
BackForward
8.Scroll

8-7. Drawing scrolls

Here, we will explain the flow from the scroll function settings and scroll registration to the actual drawing of the scroll screen, step by step using the library functions used.

Back screen settings

●Back screen settings
Select the color of the back screen.
The back screen refers to the monochrome display surface that is drawn at the very back of the monitor and is displayed in areas where nothing is drawn (in dot units).
The library function “slBack1ColSet” is used to set the back screen.

[void slBack1ColSet ( void *back_col_adr , Uint16 RGB_col ) ;]
Specify the color of the monochrome back screen.
Assign the start address in VRAM that stores the color data of the back screen and the 1-word RGB value (#define value) that indicates the color of the back screen to the parameters.
The values used to specify RGB colors are defined in the header file "sl_def.h", so please refer to them.

Figure 8-15 RGB color mode sample (RGB_Flag)

● RGB mode color sample ●
#define	CD_Blank	(0<<10)  | (0<<5)  | (0)  | RGB_Flag
#define	CD_DarkRed	(0<<10)  | (0<<5)  | (8)  | RGB_Flag
#define	CD_DarkGreen	(0<<10)  | (8<<5)  | (0)  | RGB_Flag
		:
		:
#define	CD_Purple	(31<<10) | (0<<5)  | (31) | RGB_Flag
#define	CD_Magenta	(31<<10) | (31<<5) | (0)  | RGB_Flag
#define	CD_White	(31<<10) | (31<<5) | (31) | RGB_Flag

Note) The above values are defined in “sl_def.h”.

Display position setting

●Normal scroll screen
Determines the display position of the normal scroll screen with the function set.
Library functions “slScrPosNbg0 to 3” are used to determine the display position of the normal scroll screen.

[void slScrPosNbg0~3 ( FIXED posx , FIXED posy ) ;]
Set the display coordinates of the normal scroll screen.
Assign the XY coordinate values (scroll coordinate system) to the parameters to determine where on the scroll map the monitor should be placed.
The placement reference point for the normal scroll screen is the upper left corner of the monitor.

●Rotating scroll screen
Function Determines the placement coordinates and rotation center coordinates of the set rotating scroll surface.
The function “slLookR” is used to determine the display position of the rotating scroll screen, and the function “slDispCenterR” is used to determine the rotation center coordinates.

[void slLookR ( FIXED posx, FIXED posy) ;]
Sets the placement coordinates of the rotation scroll screen and saves the information in the current rotation parameter
. Assign the scroll XY coordinate values with the origin at the top left of the scroll map to the parameters.
The display position of the rotating scroll is determined by the placement coordinates and rotation center coordinates.

[void slDispCenterR ( FIXED posx , FIXED posy ) ;]
Set the rotation center coordinates (vanishing point) of the rotation scroll screen and save the information in the current rotation parameter.
Assign the screen XY coordinate values where the rotating scroll screen will be placed to the parameters.
The display position of the rotating scroll is determined by the placement coordinates and rotation center coordinates.

Figure 8-16 Relationship between display position and rotation center position

Note) The front of the screen is the positive direction of the Z axis of the scroll surface.

In addition, the functions "slLookR" and "slDispCenterR" can be set for each rotation parameter A and B, and the rotation parameter to be set (currently used rotation parameter) can be switched using the function "slCurRpara". Among the functions used for rotational scrolling, for all functions whose names end with "R", the function performed by the function can be set separately for rotation parameters A and B.

scroll registration

After storing the scroll data and setting the scroll function, it is necessary to register the scroll screen using the SGL library function "slScrAutoDisp".
Scroll registration refers to setting cycle patterns and drawing settings for each scroll screen for which function settings have been completed.

Additionally, scroll registration may fail depending on the function settings of the scroll to be registered, the number of scroll pages, and the VRAM bank in which the scroll data is stored.
This is due to several scrolling limitations, including the scrolling limitation due to the number of colors on the normal scroll screen mentioned above (limitations are discussed in the next section).

[Bool slScrAutoDisp ( Uint32 disp_bit );]
Register the scroll screen with function settings.
Assign the values in the table below that correspond to the scroll screen to be registered to the parameters.
The function returns a return value of 0 if the scroll registration is successful, and -1 if it fails.

Table 8-18 Scroll registration parameter substitution value (disp_bit)

Scroll image to register
NBG0 NBG1 NBG2 NBG3 RBG0
Assignment value NBG0ON NBG1ON NBG2ON NBG3ON RBG0ON

Note) The values in the table above are defined in “sl_def.h” that comes with the system.

When registering multiple scroll screens, it is convenient to combine the #define values corresponding to each scroll with the or operator "|" for the parameter assignment value of the library function "slScrAutoDisp" (an example is shown below). indicate).

Figure 8-17 Registering multiple scroll surfaces

● Multiple scroll plane registration●

Uint16 slScrAutoDisp(NBG0ON|NBG1ON|RBG0ON); ↑ ↑ ↑ | | RBG0 registration | NBG1 registration NBG0 registration

(| = or operator)

Note) Parameter substitution values are defined in “sl_def.h”.

Notes on scroll registration

When registering scrolling using the SGL library function "slScrAutoDisp", the function may return a return value of -1 in some cases. This means that the function “slScrAutoDisp” failed to register the scroll.
If scroll registration fails, the reasons can be summarized into the following four reasons.

●Cause of scroll registration failure

1) Scroll restrictions based on the number of colors on the normal scroll screen
An attempt was made to register a scroll surface that should not be usable due to the color number settings of NBG0 and NBG1.

2) Bank occupancy by rotating scroll data
Scroll data for the rotary scroll screen and normal scroll screen are stored in the same VRAM bank.

3) Pattern name data storage bank limit
Pattern name data is stored in both VRAM banks with the same end number.

4) Allowable deviations in scrolling functionality
The scroll surface you attempted to register exceeds the scroll function and number of surfaces that can be selected at the same time.

To resolve this, please do the following:

●What to do when scroll registration fails

What to do in case 1)
Reduce the number of colors in NBG0 or NBG1, or give up on registering NBG2 or NBG3.

What to do in case 2)
Scroll data for the rotating scroll screen and normal scroll screen are stored in separate VRAM banks.

What to do in case 3)
Observe VRAM bank storage restrictions for pattern name data.

What to do in case of 4)
Reduce the number of scroll screens to be registered, reduce the number of colors of character patterns during function settings, increase the value of the reduction setting, avoid cramming scroll data from too many scroll screens into one VRAM bank, etc. please look.

About VRAM access restrictions

The reason for 4) is the restriction of access to VRAM banks. However, it is very difficult to explain VRAM access restrictions and understand the accompanying contents. Therefore, here we will provide a solution/workaround by simply reducing the scrolling function and the number of pages.
For details on VRAM access, refer to “HARDWARE MANUAL vol.2: VDP2 User's Manual”.

Start drawing

●Drawing declaration
In SGL, the process of drawing the scroll screen to the monitor begins when the library function "slTVOn" is executed.
After that, the scroll screen continues to draw in synchronization with the scan line according to the stored scroll information (position, scale, rotation angle, graphic data, etc.).
Additionally, there is a function "slTVOff" as a companion function to this function "slTVOn". This is to stop the scroll drawing process.

[void slTVOn ( void );]
Starts the drawing process for the scroll screen that has been set to draw.

[void slTVOff ( void );]
Cancels the drawing process for the scroll screen that has been set to draw.

●Drawing settings
Configure whether to actually draw the scroll screen with the function settings on the monitor.
For scroll planes that have been registered using the function "slScrAutoDisp," the drawing settings are turned on at the time of registration, so drawing will be executed as is, but you can prevent drawing by turning off the drawing settings. It is also possible to In addition, you can draw on a scroll surface whose drawing settings have been turned off by turning it on.

[void slScrDisp ( Uint32 mode );]
Configure the drawing settings for the scroll screen with the function settings.
The values in the table below that correspond to the drawing settings for each scroll surface are assigned to the parameters.

Table 8-19 List of parameter substitution values for “slScrDisp” (mode)
NBG0 NBG1 NBG2 NBG3 RBG0
ON OFF ON OFF ON OFF ON OFF ON OFF
 Assignment value
NBG0ON NBG0OFF NBG1ON NBG1OFF NBG2ON NBG2OFF NBG3ON NBG3OFF RBG0ON RBG0OFF
ON: Draw scroll surface
OFF: Do not draw scroll surface

Note) The values in the table above are defined in “sl_def.h” that comes with the system.

●Screen synchronization (scroll rewriting)
Rewrites the scroll drawing data according to the scan line status.

[void slSynch ( void );]
Rewrites the drawing data while the monitor is not rewriting the screen.

Flow of scroll drawing

Here, we will summarize the steps from scroll function settings to drawing by showing the flowchart from initializing scroll data to actual drawing.

Flow 8-2 Flow up to scroll drawing

About accessing VRAM and color RAM

Any access to VRAM or color RAM during the monitor's display period will cause noise on the monitor.
Therefore, these two RAM areas can be accessed using the function "slSynch" during the monitor's non-display period (during blanking), or by using the function "slTVOff" to interrupt the scroll drawing process. Either do this after you do this, or turn off the drawing settings using the function “slScrDisp” and access the VRAM bank that will not be accessed.


BackForward
SGL User's ManualPROGRAMMER'S TUTORIAL
Copyright SEGA ENTERPRISES, LTD., 1997