SGL User's ManualPROGRAMMER'S STRUCT
BackForward

8-12. Character / numerical display

The SGL library functions described here are mainly used for debugging programs. The function displays the specified character string / numerical value / matrix on the monitor using the scroll surface. ASCII cell data is used for scroll data, and a rotary scroll screen is used for the scroll surface, and each is set to be available by default (at the stage of system initialization).

<Fig. 8-30 Character numerical display image>

Character-numerical display functions can be broadly classified into the following four types.

Display Position Calculation: Create display position parameters for use in the function.
Display character string: Displays the specified character string on the screen.
Numerical value display: Displays the specified numerical value on the screen.
Matrix display: Displays the specified matrix on the screen.

Below, we will explain each of these four function groups.

1) Calculation of display position
Set the display position of characters and numbers for each cell, and convert it to a form that can be used by the following functions.

[Void * slLocate (Uint16 cell_x, Uint16 cell_y);]
Create a display position parameter variable (void * type) that can be used in the character-numerical display function. Substitute the XY coordinate value indicating the display position on the monitor screen for the parameter in cell units (8 dots are counted as 1 cell).

2) Display of character string
A character string composed of half-width alphanumeric characters is displayed on the screen.

[Void slPrint (char * disp_character, void * disp_pos);]
Displays the specified character string on the screen. Substitute the character string to be displayed (char type variable enclosed in "") and display position (converted to void * type with "slLocate") to the parameters. However, the character string is limited to single-byte alphanumeric characters.

3) Numerical display
The numerical value is displayed on the screen.

[Void slPrintFX (FIXED disp_num, void * disp_pos);]
Displays the specified FIXED type numerical value on the screen.
Substitute the numerical value to be displayed (FIXED type variable) and the display position (converted to void * type by "slLocate") to the parameters.

[Void slPrintHex (Uint32 disp_num, void * disp_pos);]
Displays the specified HEX type numerical value on the screen. Substitute the numerical value to be displayed (HEX type variable) and the display position (converted to void * type by "slLocate") to the parameters.
The function “slPrintHex” does not display the high-order bit 0 when displaying numbers (a space is inserted instead).

[Void slDispHex (Uint32 disp_num, void * disp_pos);]
Displays the specified HEX type numerical value on the screen. Substitute the numerical value to be displayed (HEX type variable) and the display position (converted to void * type by "slLocate") to the parameters.
In the case of the function “slDispHex”, unlike “slPrintHex”, the high-order bit 0 is also displayed when displaying numerical values.

The functions “slPrintHex” and “slDispHex” are both for displaying HEX type numerical values on the screen, but they differ in whether or not to display the high-order bit 0. However, the numbers are always displayed right-justified.

Table 8-26 Differences between “slPrintHex” and “slDispHex”
Substituted value Output value
slPrintHex 00001111 1111
slDispHex 00001111 00001111
Note) The output value is the numerical value actually drawn on the screen.

4) Matrix display
Display the matrix on the screen.

[Void slPrintMatrix (MATRIX disp_matrix, void * dsp_pos);]
Displays the specified matrix on the screen. Substitute the matrix variable to be displayed and the display position (converted to void * type by slLocate) as parameters.

The following sample program (Listing 8-10) actually uses a group of character / numerical display functions to realize screen display of character strings and numerical values using a scroll screen.

Listing 8-10 sample_8_12: Character / numerical display

/ * ------------------------------------------------ ---------------------- * /
/ * Text & Value Display * /
/ * ------------------------------------------------ ---------------------- * /
#include "sgl.h"

extern PDATA PD_PLANE1, PD_PLANE2, PD_PLANE3;

static void set_poly (ANGLE ang [XYZ], FIXED pos [XYZ])
{
	slTranslate (pos [X], pos [Y], pos [Z]);
	slRotX (ang [X]);
	slRotY (ang [Y]);
	slRotZ (ang [Z]);
}

void ss_main (void)
{
	static ANGLE ang1 [XYZ], ang2 [XYZ], ang3 [XYZ];
	static FIXED pos1 [XYZ], pos2 [XYZ], pos3 [XYZ];
	static MATRIX mtptr;
	static ANGLE adang = DEGtoANG (0.5);
	static ANGLE tmp = DEGtoANG (0.0);

	slInitSystem (TV_320x224, NULL, 1);

	slPrint ("Sample program 8.12", slLocate (6,2));

	ang1 [X] = ang1 [Y] = ang1 [Z] = DEGtoANG (0.0);
	ang2 [X] = ang2 [Y] = ang2 [Z] = DEGtoANG (0.0);
	ang3 [X] = ang3 [Y] = ang3 [Z] = DEGtoANG (0.0);
	pos1 [X] = toFIXED (0.0);
	pos1 [Y] = toFIXED (40.0);
	pos1 [Z] = toFIXED (170.0);
	pos2 [X] = toFIXED (0.0);
	pos2 [Y] = toFIXED (-40.0);
	pos2 [Z] = toFIXED (0.0);
	pos3 [X] = toFIXED (0.0);
	pos3 [Y] = toFIXED (-40.0);
	pos3 [Z] = toFIXED (0.0);

	slPrint ("POLYGON ANGLE [Hex] =", slLocate (1,4));
	slPrint ("POLYGON ANGLE [Dec] =", slLocate (1,6));
	slPrint ("POLYGON ANGLE [Hex & 0] =", slLocate (1,8));
	slPrint ("POLYGON ANGLE [Dec & 0] =", slLocate (1,10));
	slPrint ("POLYGON ANGLE [FIX] =", slLocate (1,12));
	slPrint ("DISPLAY Matrix:", slLocate (1,18));

	while (-1) {
		slUnitMatrix (CURRENT);
		ang1 [Z] = tmp;
		ang2 [Z] = tmp;
		tmp + = adang;
		if (tmp <DEGtoANG (-90.0)) {
			adang = DEGtoANG (0.5);
		} else if (tmp> DEGtoANG (90.0)) {
			adang = DEGtoANG (-0.5);
		}

		slDispHex (slAng2Hex (tmp), slLocate (26,4));
		slDispHex (slAng2Dec (tmp), slLocate (26,6));
		slPrintHex (slAng2Hex (tmp), slLocate (26,8));
		slPrintHex (slAng2Dec (tmp), slLocate (26,10));
		slPrintFX (slAng2FX (tmp), slLocate (26,12));

		slPushMatrix ();
		{
			set_poly (ang1, pos1);
			slPutPolygon (& PD_PLANE1);

			slPushMatrix ();
			{
				set_poly (ang2, pos2);
				slPutPolygon (& PD_PLANE2);

				slPushMatrix ();
				{
					set_poly (ang3, pos3);
					ang3 [Y] + = DEGtoANG (5.0);
					slPutPolygon (& PD_PLANE3);
					slGetMatrix (mtptr);
					slPrintMatrix (mtptr, slLocate (0,20));
				}
				slPopMatrix ();
			}	
			slPopMatrix ();
		}
		slPopMatrix ();

		slSynch ();
	}
}

Flow 8-14 sample_8_12: Character numerical display


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