SGL User's ManualPROGRAMMER'S STRUCT
BackForward

8-11. Priority

In Sega Saturn, it is possible to set a drawing priority called priority for all face types to be drawn. By using priority, for example, it is possible to draw multiple scroll planes separately for the background and for displaying characters, and to insert a 3D polygon plane between them. However, the back screen is always drawn on the back.

Figure 8-28 Priority image

To set the priority for scrolling in SGL, use the library functions "slPriorityNbg0 to 3" and "slPriorityRbg0" corresponding to the scroll surface type.

[Void slPriorityNbg0 ~ 3 (Uint16 priority_num);]
[Void slPriorityRbg0 (Uint16 priority_num);]
Set the priority for each scroll plane.
Assign a value from 0 to 7 called the priority number to the parameter.
The higher the priority number, the more the scroll plane is drawn to the front.
If 0 is specified, the scroll surface is treated as transparent and is not actually drawn.
Refer to the figure below for the priority when the same priority number is assigned to multiple face types.

Figure 8-29 Priority when priority numbers are equal>
● Priority when the priority numbers are the same ●

SPRITE> RBG0> NBG0> NBG1> NBG2> NBG3

High (front) ← −−−−−−−−−−− → Low (rear)

Note) POLYGON is included in SPRITE.

Also, in SGL, in the default state, the priority is assigned to each drawing surface as follows.

Table 8-25 Priority of each drawing surface in the default state
Priority number
7 6 5 4 3 2 1 0
Drawing surface NBG0 SPRITE SPRITE RGB0 NBG1 NBG2 NBG3 Not set
Note) Polygon faces are included in SPRITE.

The following sample program (Listing 8-9) actually uses the SGL library function "slPriorityNbg0-3, Rbg0" to realize scroll priority processing.

Listing 8-9 sample_8_11: Scroll display priority

/ * ------------------------------------------------ ---------------------- * /
/ * Scroll Priority Change * /
/ * ------------------------------------------------ ---------------------- * /
#include "sgl.h"
#include "ss_scrol.h"

#define NBG1_CEL_ADR (VDP2_VRAM_B1 + 0x02000)
#define NBG1_MAP_ADR (VDP2_VRAM_B1 + 0x12000)
#define NBG1_COL_ADR (VDP2_COLRAM + 0x00200)
#define RBG0_CEL_ADR VDP2_VRAM_A0
#define RBG0_MAP_ADR VDP2_VRAM_B0 
#define RBG0_PAR_ADR (VDP2_VRAM_A1 + 0x1fe00)
#define BACK_COL_ADR (VDP2_VRAM_A1 + 0x1fffe)

void ss_main (void)
{
	Uint16 PryNBG = 4, PryRBG = 1, PryWRK;
	FIXED yama_posx = SIPOSX, yama_posy = SIPOSY;
	ANGLE ascii_angz = DEGtoANG (0.0);

	slInitSystem (TV_320x224, NULL, 1);
	slTVOff ();
	slPrint ("Sample program 8.11", slLocate (9,2));

	slColRAMMode (CRM16_1024);
	slBack1ColSet ((void *) BACK_COL_ADR, 0);

	slCharNbg1 (COL_TYPE_256, CHAR_SIZE_1x1);
	slPageNbg1 ((void *) NBG1_CEL_ADR, 0, PNB_1WORD | CN_12BIT);
	slPlaneNbg1 (PL_SIZE_1x1);
	slMapNbg1 ((void *) NBG1_MAP_ADR, (void *) NBG1_MAP_ADR, (void *) NBG1_MAP_ADR, (void *) NBG1_MAP_ADR);
	Cel2VRAM (yama_cel, (void *) NBG1_CEL_ADR, 31808);
	Map2VRAM (yama_map, (void *) NBG1_MAP_ADR, 32, 16, 1, 256);
	Pal2CRAM (yama_pal, (void *) NBG1_COL_ADR, 256);

	slRparaInitSet ((void *) RBG0_PAR_ADR);
	slCharRbg0 (COL_TYPE_256, CHAR_SIZE_1x1);
	slPageRbg0 ((void *) RBG0_CEL_ADR, 0, PNB_1WORD | CN_10BIT);
	slPlaneRA (PL_SIZE_1x1);
	sl1MapRA ((void *) RBG0_MAP_ADR);
	slOverRA (2);
	Map2VRAM (ascii_map, (void *) RBG0_MAP_ADR, 32, 4, 0, 0);

	slScrPosNbg1 (yama_posx, yama_posy);
	slDispCenterR (toFIXED (160.0), toFIXED (112.0));
	slLookR (toFIXED (128.0), toFIXED (24.0));

	slPriorityNbg1 (PryNBG);
	slPriorityRbg0 (PryRBG);

	slScrAutoDisp (NBG0ON | NBG1ON | RBG0ON);
	slTVOn ();

	while (1) {
		if (yama_posx> = (SX + SIPOSX)) {
			PryWRK = PryNBG;
			PryNBG = PryRBG;
			PryRBG = PryWRK;
			slPriorityNbg1 (PryNBG);
			slPriorityRbg0 (PryRBG);
			yama_posx = SIPOSX;
		}

		slScrPosNbg1 (yama_posx, yama_posy);
		yama_posx + = POSX_UP;

		slZrotR (ascii_angz);
		ascii_angz + = DEGtoANG (1.0);

		slSynch ();
	} 
}

Flow 8-13 sample_8_11: Scroll display priority


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