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

8-6.Scroll function settings

In this article, we will explain how to set up scrolling, starting with each character and finally setting up the map. In SGL, scroll functions (number of character colors, character size, etc.) are set at each stage of scroll settings.
The table below is a list of scroll functions.

Table 8-6 Scroll function list
function normal scroll rotating scroll
NBG0 NBG1 NBG2 NBG3 RBG0
Number of character colors 16 colors
256 colors
2048 colors*
32768 colors
16.77 million colors
more selection
16 colors
256 colors
2048 colors*
32768 colors
more selection
16 colors
256 colors
more selection
16 colors
256 colors
more selection
16 colors
256 colors
2048 colors*
32768 colors
16.77 million colors
more selection
character size Select from 1 cell horizontally x 1 cell vertically or 2 cells horizontally x 2 cells vertically.
Pattern name data size Select from 1 word or 2 words
plane size Select from 1 page wide x 1 page tall, 2 pages wide x 1 page tall, or 2 pages wide x 2 pages tall.
Number of planes 4 4 4 4 16
Scaling function 1/4x ~ 256x none Any magnification
Rotation function none can be

note)
*2048 colors are available when the color RAM mode is mode 1.
For mode 0 or mode 2 it will be 1024 colors

About VRAM access restrictions

The list of functions listed in Table 8-6 is only a display of functions for each scroll surface. When actually using these scroll surfaces in a program, it is not always possible to use the maximum performance of each scroll surface, nor can all scroll surfaces be drawn at the same time.
This is caused by restrictions on access to VRAM, and the number of scroll screens and function settings that can be used at the same time are limited by these access restrictions.
For details on access restrictions, refer to “HARDWARE MANUAL vol.2: VDP2 User's Manual”.

In addition to VRAM access specification restrictions, there are also scroll drawing restrictions that come from the character color settings for the normal scroll screen "NBG0-3".
(See character pattern section)

These two limitations limit and determine the number of scroll planes that can be drawn at the same time and their functions.

character pattern

A character pattern is a square pattern made up of 1x1 cells or 2x2 cells, and stores information in units of dots (information such as the drawing color of the dots). In SGL, a block of character pattern information (data table) is stored in VRAM as character pattern data, and accessed and used.
At this stage in SGL, specify the number of character colors for each scroll surface.
Also, when one character is composed of four cells, the cell data used for the same character pattern must be stored consecutively in the character pattern table.

Figure 8-9 Character pattern image

Table 8-7 Number of character colors
 color format
 Number of character colors
 Number of bits per dot
 Number of colors available depending on scroll surface
NBG0 NBG1 NBG2 NBG3 RBG0
pallet format 16 colors 4 bits
256 colors 8 bit
2048 colors 16 bit
(Uses only lower 11 bits)
× ×
RGB format 32768 colors 16 bit × ×
16.77 million colors 32 bit
(Use MSB and lower 24 bits>
× × ×

note)
In color RAM modes 0 and 2, 2048 colors become 1024 colors.

To determine the number of character colors and character size in SGL, use the library functions "slCharNbg0~3" and "slCharRbg0".

[void slCharNbg0~3 ( Uint16 color_type , Uint16 char_size ) ;] [void slCharRbg0 ( Uint16 color_type , Uint16 char_size ) ;]
Specify the number of character colors and character size for each scroll screen (for the scroll screen name at the end of slChar). Assign the #define value according to the table below that corresponds to the number of colors and character size to the parameter.
However, the number of colors that can be used is limited depending on the scroll screen (see “Table 8-6 Scroll function list”).

Table 8-8 Parameter substitution values for “slCharNbg0 to 3” and “slCharRbg0”
Number of character colors character size
pallet format RGB format
16 colors 256 colors 2048 colors 32768 colors 16.77 million colors 1x1 2x2
 Substitution value
COL_TYPE_16 COL_TYPE_256 COL_TYPE_2048 COL_TYPE_32768 COL_TYPE_1M CHAR_SIZE_1x1 CHAR_SIZE_2x2

Note 1)
When the color RAM mode is 0 or 2, 2048 colors become 1024 colors.

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

Scroll restrictions based on number of character colors

Depending on the color number settings for normal scroll screens NBG0 and NBG1, there may be restrictions on the number of scroll screens that can be output.
The table below summarizes this.

Table 8-9 Restrictions on scroll surface depending on number of character colors
Number of colors of NBG0, NBG1 valid scroll surface
NBG0 NBG1 NBG0 NBG1 NBG2 NBG3
16.77 million colors * × × ×
2048 colors or 32678 colors * × ×
* 2048 colors or 32678 colors ×
2048 colors or 32678 colors 2048 colors or 32678 colors × ×

Note) * indicates selection of 256 colors or less.

  • If NBG0 is set to 16.77 million colors, NBG1 to 3 cannot be displayed.
  • If NBG0 is set to 2048 colors or 32768 colors, NBG2 cannot be displayed.
  • If NBG1 is set to 2048 colors or 32768 colors, NBG3 cannot be displayed.

    Scroll restrictions due to VRAM access

    Due to hardware performance, Sega Saturn also has scrolling restrictions due to VRAM access.
    This applies in addition to the limitations imposed by the number of character colors on the normal scroll screen.
    In particular, be careful when scaling down the normal scroll surface or using a rotating scroll surface, as the number of character colors and the scroll surface that can be drawn are severely limited.
    For details on access restrictions, refer to “HARDWARE MANUAL vol.2: VDP2 User's Manual”.

    pattern name data

    Pattern name data is created by extracting the following two pieces of information from the dot-by-dot data created as a character pattern.

    Character number: Start address of character pattern (VRAM)
                                  Character patterns are stored in units of 20H.Palette number: Palette number of the color palette to be used (color RAM)
    

    The pattern name data is finally composed of the above two pieces of information plus the following two function control bits related to character patterns.

    Special function bits (2 bits): Controls special color calculations and special priorities
    Reversal function bit (2 bits): Controls the vertical and horizontal reversal of the character pattern.

    Pattern name data is classified into three types shown in a), b), and c) in the figure below based on the difference in the amount of information they contain.
    (See next section for details)
    The figure is an image model of pattern name data. From this figure, you can see that depending on the type of pattern name data, special function bits and inversion function bits may or may not be included.

    Figure 8-10 Pattern name data image
    The pattern name data is used when setting the page, and a pattern name data table is created using 64 x 64 consecutive pattern name data as a group, and placement information is passed to the plane and map.

    Data type of pattern name data

    There are two types of pattern name data: 1 word type and 2 word type.
    The 1-word type is further divided into two types depending on the number of information bits used for character identification (10 or 12 pattern identification bits).
    Each data type has its advantages and disadvantages, but in SGL you must select and use one of these three.

    Table 8-10 Pattern name data size
    word size Character number bit number remarks

    1 word
    lower 10 bits Reverse function can be specified for each character
    lower 12 bits No reversal function
    2 words lower 15 bits Reverse function can be specified for each character

    SGL recommends 1 word size.

    One-word pattern name data is divided into two types depending on whether or not to introduce inversion function bits (2 bits) into the pattern name data.

    As the name suggests, the character pattern reversal function is for controlling and executing the vertical and horizontal reversal of the corresponding character pattern. In order to control this, it is necessary to reserve two inversion function bits in the pattern name data.
    In the case of 2-word type pattern name data, the inversion function bit is always reserved, but in the case of 1-word type, there is not enough bits to use, so if the inversion function bit is secured, the number of character patterns that can be identified is limited. 2 bits can be removed.
    Therefore, 1-word pattern name data can be divided into two types depending on whether the inversion function is used or not, that is, the number of distinguishable character patterns.

    The difference between the 1-word type and the 2-word type is simply the number of character patterns that can be processed. However, the memory area used by the 2-word type is simply double that of the 1-word type, and while the 1-word type can specify offsets, the 2-word type requires absolute addresses to be specified. Therefore, considering the ease of use, SGL recommends one-word pattern name data.

    About auxiliary data

    If the pattern name data type is one word, it will not be possible to specify all the necessary pattern name data. Therefore, the system supplements the pattern name data with the lower 10 bits of the pattern name control register. This is called auxiliary data.
    For details, refer to “HARDWARE MANUAL vol.2: VDP2 Manual”.

    page

    The page is a square of character patterns with a size of 64 cells horizontally and 64 cells vertically. The actual data format is one table of pattern name data for each character pattern, 64 cells wide x 64 cells high, stored consecutively in memory, and this is called a pattern name data table.
    The pattern name table created in page setup is passed to a higher level plane or map and rearranged.

    Figure 8-11 Page image

    To set pages in SGL, use the library functions "slPageNbg0~3" and "slPageRbg0" depending on each scroll screen.

    [void slPageNbg0~3 (void *cell_adr, void *col_adr, Uint16 data_type);] [void slPageRbg0 (void *cell_adr, void *col_adr, Uint16 data_type);]
    Configure the page (pattern name data table).
    Assign the parameters in order: the start address of the character pattern to be used, the start address of the palette to be used (offset can be specified if it is a 1-word type), and the type specification of the pattern name data (see the table below for parameter substitution values). .

    Table 8-11 Parameter substitution values for “slPageNbg0 to 3” and “slPageRbg0” (data_type)
    word count character number bit Substitution value
    1 word lower 10 bits
     PNB_1WORD
    lower 12 bits
     PNB_1WORD|CN_12BIT
    2 words lower 16 bits PNB_2WORD

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

    The following figure shows an example of actual page settings and a list of #defines used for page setting parameters.

    Figure 8-12 Parameter setting example for “slPageNbg0 to 3” and “slPageRbg0”

    slPageNbg0(NBG0_CELL_ADR,0,PNB_1WORD|CN_10BIT); ↑ ↑↑ ↑ : : : Character number bit specification : : Word count specification : Palette start address (offset specification) Character pattern start address

    Listing 8-1 #define related to page setting parameters

    ● #define used for page setting parameters ●
    /* VRAM_BANK ADDRESS */
    #define VDP2_VRAM_A0 0x25e00000
    #define VDP2_VRAM_A1 0x25e20000
    #define VDP2_VRAM_B0 0x25e40000
    #define VDP2_VRAM_B1 0x25e60000
    /* slPage */
    #define PNB_2WORD 0
    #define PNB_1WORD 0x8000
    #define CN_10BIT 0
    #define CN_12BIT 0x4000
    /* others */
    #define NBG_CELL_ADR VDP2_VRAM_B0
    

    note)
    These #defines are defined in “sl_def.h”.

    plane

    A plane page is one in which pages are arranged in one of the following sizes: 1 width x 1 height, 2 width x 1 height, or 2 width x 2 height. When a plane is composed of multiple pages, the page data (pattern name data table) that composes the plane must be stored consecutively in VRAM.
    Plane data is passed to higher-level maps and rearranged.

    Figure 8-13 Plane image

    Note) All are displayed vertically and horizontally.

    To set the plane size in SGL, use the library functions “slPlaneNbg0~3” and “slPlaneRA, B”.

    [void slPlaneNbg0~3 (Uint16 plane_size );]
    [void slPlaneRA,RB( Uint16 plane_size );] Sets the plane size of each scroll surface. Assign the values in the table below that correspond to the plane size to the parameters.

    Table 8-12 Parameter substitution values for “slPlaneNbg0 to 3” and “slPlaneRA,RB” (plane_size)
    plane size
    1 horizontal x 1 vertical 2 horizontal x 1 vertical 2 horizontal x 2 vertical
    Assignment value PL_SIZE_1x1 PL_SIZE_2x1 PL_SIZE_2x2

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

    Regarding plane size specification limitations due to reduction settings

    If you set the reducible range to 1/4 times on normal scroll screens NBG0 and NBG1, do not set the plane size of that scroll screen to 2 x 2 pages. This is because the map size when the reducible range is increased to 1/4 is different from normal.
    1×1 and 2×1 pages can be used without any problems.
    For details on plane size specification restrictions, refer to “HARDWARE MANUAL vol.2: VDP2 User's Manual”.

    map

    The map is the largest unit of scrolling that SGL actually uses to draw scrolls. The map is represented by 2 horizontal x 2 vertical planes on a normal scroll screen, and 4 horizontal x 4 vertical planes on a rotating scroll screen.
    The planes that make up the map can be arbitrarily stored (without having to be stored consecutively in VRAM) by specifying the start address of each plane (actually, the start address where the pattern name data table that makes up the plane is stored). You can decide. For this reason, it is also possible to make all the planes that make up the map the same.
    The scroll movement, scaling, and rotation described below are also performed on a map-by-map basis.

    Figure 8-14 Map image

    The map size is determined by the type of scroll screen.
  • Normal scroll screen: 4 planes (2 horizontally x 2 vertically)
  • Rotating scroll screen: 16 planes in total (4 horizontally x 4 vertically)

    To register each plane that makes up the map in SGL, use the library functions “slMapNbg0~3” and “sl1MapRA,RB”.

    [void slMapNbg0~3 ( void *map_a , void *map_b , void *map_c , void *map_d );]
    Register plane data to the map of each normal scroll screen.
    Assign the start address of each of the four planes to be registered to each parameter. The target scroll screen corresponds to the normal scroll screen name at the end of the function name.

    [void sl1MapRA ( void *map_a );]
    [void sl1MapRB ( void *map_a );]
    Register plane data to the map on the rotating scroll screen.
    Assign the start address of the plane to be registered to each parameter. The function starts from the specified address.
    Register one page of plane data to the map.
    Also, the function "sl1MapRA" is used for map registration when rotation parameter A is used, and the function "sl1MapRB" is used for map registration when rotation parameter B is used.

     Note
     For rotation parameters, see below.
    “Function settings specific to the rotating scroll screen”
    Please refer to.

    Reduce settings

    Of the five types of scroll screens on the Sega Saturn, three of them, the rotating scroll screen "RBG0" and the normal scroll screens "NBG0, NBG1", can be enlarged or reduced for scrolling. Among the three scroll screens that can be enlarged or reduced, the rotating scroll screen “RBG0” can always be enlarged or reduced at any magnification, but the normal scroll screens “NBG0, NBG1” can be enlarged or reduced in the range of 1/4 to 256 times. You can only scale within.
    Furthermore, the normal scroll screen has three modes for scaling depending on the setting of the reducible range. This is called a reduction setting, and therefore, when using the normal scroll screen “NBG0, NBG1”, it is necessary to perform a reduction setting. For details, refer to “HARDWARE MANUAL vol.2: VD P2 User Manual P129-P130”.

    Table 8-13 Scroll screen and scaling range
    scroll type name Scaling Scaling range
    Normal scroll screen NBG0 1/4 to 256 times
    NBG1 1/4 to 256 times
    NBG2 ×
    NBG3 ×
    rotating scroll RBG0 Any magnification

    note)
    The reducible range of NBG0,1 changes depending on the reduction setting.

    To set reduction in SGL, use the library function “slZoomModeNbg0,1” that corresponds to the normal scroll screen for which you want to set reduction.

    [void slZoomModeNbg0,1 ( Uint16 zoom_mode );]
    Determine the reduction setting for the normal scroll screen “NBG0, NBG1” that can be enlarged or reduced.
    The target scroll screen corresponds to the normal scroll screen name at the end of the function name.
    Assign the values in the table below that correspond to the reduction setting mode to the parameters.

    Table 8-14 Parameter substitution value for “slZoomModeNbg0,1” (zoom_mode)
    plane size
     1x
     1/2 times
     1/4 times
    Assignment value ZOOM_1 ZOOM_HALF ZOOM_QUATER

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

    About scaling the rotating scroll screen

    The rotary scroll screen “RBG0” can always be enlarged or reduced at any magnification, so there is no need to make any reduction settings.

    Regarding the limit on the number of scroll pages due to reduction settings

    Depending on the reduction setting of the normal scroll screen "NBG0, NBG1" (if it is possible to reduce it to a smaller value), the number of scroll screens and functions that can be displayed may be limited. This is because the number of VRAM accesses changes depending on the reduction settings. For details on access restrictions, refer to “HARDWARE MANUAL vol.2: VDP2 User's Manual”.

    Function settings specific to rotating scroll screen 1

    In the case of a rotating scroll screen, several function settings are required in addition to the scroll function settings mentioned above.
    These function settings are necessary to use the functions specific to rotary scrolling.

    ●Rotation parameter settings
    When using a rotating scroll screen, an area is required to store and recall some information related to rotation, and this collection of information is called rotation parameters.
    So, if you want to use a rotating scroll screen, you need to store the rotation parameters in VRAM as part of the scroll function settings (size of rotation parameters: 100H).
    Please use the library function “slRparaInitSet” to specify rotation parameters.

    [void slRparaInitSet ( ROTSCROLL *Rpara_adr );]
    Store rotation parameters in VRAM area and set default values at the same time.
    Assign the start address of the area that stores rotation parameters to the parameter.

    ●Rotation parameter usage mode
    There are two types of rotation parameters: rotation parameter A and rotation parameter B. These two types of rotation parameters are stored together in the area secured by the function "slRparaInitSet". Since there are two types of rotation parameters, the rotation scroll will simultaneously hold two types of state data, and when drawing, it is possible to select one of these two and execute drawing on the monitor. Become.
    The user can select how to use the rotation parameters from among the following four rotation parameter usage modes.

    Mode 0: Use rotation parameter A
    Mode 1: Use rotation parameter B
    Mode 2: Switch images according to the coefficient data read from the coefficient table of rotation parameter A
    Mode 3: Switch by rotation parameter window

    [void slRparaMode( Uint16 mode );]
    Switches the usage mode of rotation parameters.
    Assign the flag in the table below that indicates the rotation parameter usage mode to the parameter.

    Table 8-15 Parameter substitution values for “slRparaMode”
    mode 0 mode 1 mode 2 mode 3
    Assignment value R.A. R.B. K_CHANGE W_CHANGE

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

    ●Current rotation parameter switching
    Among the functions used for rotational scrolling, those whose function names end with “R” set the function that each function handles for the current rotation parameter. By switching with ``, you can set separate functions for rotation parameters A and B.

    Also, for function names ending in "RA" or "RB", settings are made for the rotation parameters pointed to by the respective function names.

    [void slCurRpara( Uint16 flag );]
    Switches the current rotation parameter.
    Assign the flag in the table below that indicates the rotation parameter to be switched to the parameter.

    Table 8-16 Parameter substitution values for “slCurRpara”
    Rotation parameter A Rotation parameter B
    Assignment value R.A. R.B.
    Note) The values in the table above are defined in “sl_def.h” that comes with the system.

    Note
    For details on rotation parameters, please refer to “HARDWARE MANUAL vol.2”
    (VDP2 User's Manual)

    Function settings specific to rotating scroll screen 2

    ●Selection of screen over processing mode
    Select the process to be performed when the drawing on the rotating scroll screen exceeds the display area. This is called screen overflow processing, and there are four modes for screen overflow processing:

    Mode 0: Outside the area, the image set in the display area is repeated.
    Mode 1: Outside the area, the character pattern specified by the screen over PN register is repeated.
    Mode 2: Make everything outside the area transparent.
    Mode 3: Forcibly clip the area to “0≦X≦512, 0≦Y≦512” and make everything outside the area transparent.

    Use the library function “slOverRA,RB” to select screen over processing.

    [void slOverRA ( Uint16 over_mode ) ;]
    [void slOverRB ( Uint16 over_mode );]
    Select the screen overflow process when the rotating scroll screen exceeds the display area.
    Assign the values in the table below that correspond to the screen over processing mode to the parameters.
    The function "slOverRA" executes the overprocessing settings when using rotation parameter A, and the function "slOverRB" executes the overprocessing settings when using rotation parameter B.

    Table 8-17 Screen over processing parameter substitution value (over_mode)
    Over processing mode
    mode 0 mode 1 mode 2 mode 3
    Parameter substitution value 0 1 2 3

    Scroll setting flow

    Here, we will use a simple flowchart to explain the scroll setting steps from character pattern settings to page → plane → map settings, reduction settings, and scroll registration, and summarize the scroll function settings.

    Flow 8-1 Flow of scroll function settings


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