Japanese

★Cursor



ListReference

function

slCurScrn


Specifying NBG to display debug strings

Format

    #include "sgl.h"

    Uint16 mode;

    void slCurScrn( mode );

argument

    Uint16 screen - Substitute variable indicating the type of BG.

Return number

    void - returns nothing.

function

Set the screen to use with slLocate and set_vbar .
Specify one of the following six for mode.
scnNBG0 , scnNBG1 , scnNBG2 , scnNBG3 , scnRBGA , scnRBGB The default value is scnNBG0 .

example

    Set the debug string display screen to NBG2.
slCurScrn ( scnNBG2 );

Note

If a value other than NBG0 is specified on the debug string display screen, you will need to set the cycle pattern table accordingly. Automatically configure using slScrAutoDisp or slScrCycleSet You need to manually set the cycle pattern automatically using and slScrDisp .

reference

 slPrintHex
 slPrintFX
 slPrint
 slPrintMatrix
 slScrAutoDisp
 slScrCycleSet
 slScrDisp
 VDP2_MPABN0
 VDP2_MPABN1
 VDP2_MPABN2
 VDP2_MPABN3
 VDP2_MPABRA 



ListReference

function

slCurColor


Specify debug text color

Format

    #include "sgl.h"

    Uint16 pal;

    void slCurColor( pal );

argument

    Uint16 pal - pallet number.

Return number

    void - returns nothing.

function

slPrint , slPrintHex , slPrintFX , slDispHex Specify the palette number of the character to be displayed.
Specify one from 0 to 15 for pal.
The palette is set from the first 16 colors in the color RAM.

example

    Set palette number 2 (0x25f00006 in 16-bit mode, 0x25f0000c in 32-bit mode) to be the display color of the debug string.
void slCurColor ( 2 );

reference

 slPrintHex
 slPrintFX
 slPrint
 slPrintMatrix
 slScrAutoDisp
 slScrCycleSet
 slScrDisp
 PrintColor
 VDP2_MPABN0
 VDP2_MPABN1
 VDP2_MPABN2
 VDP2_MPABN3
 VDP2_MPABRA 


★Debug print



ListReference

function

slDispHex


Hexadecimal display

Format

    #include "sgl.h"

    Uint32 val;
    void *addr_A;

    void slDispHex( val, addr_A );

argument

    Uint32 val - the value you want to display.
void *addr_A - VRAM address of VDP2 you want to display. (absolute address) Usually specified with slLocate .

Return number

    void - returns nothing.

function

Displays the specified variable as an 8-digit hexadecimal number.
To change the BG surface to be displayed, use slCurScrn , and to change the display color, use slCurScrn. Use slCurColor .

example

    Displays 100 ("00000064") at the (10,20) cell position of the specified BG.
slDispHex ( 100, slLocate ( 10, 20 ) );

reference

 slPrintHex
 slCurScrn
 slCurColor
 slLocate
 slPrintFX
 slPrint
 slPrintMatrix
 PrintColor 



ListReference

function

slPrintHex


Hexadecimal display

Format

    #include "sgl.h"

    Uint32 val;
    void *addr_A;

    void slPrintHex( val, addr_A );

argument

    Uint32 val - the value you want to display.
void *addr_A - VRAM address of VDP2 you want to display. (absolute address) Usually specified with slLocate .

Return number

    void - returns nothing.

function

Similar to slDispHex , it displays the specified variable as an 8-digit hexadecimal number, but the leading zeros are replaced with spaces.
To change the BG surface to be displayed, use slCurScrn , and to change the display color, use slCurScrn. Use slCurColor .

example

    Displays 100 (" 64") at the (10,20) cell position of the specified BG.
void slPrintHex ( 100, slLocate ( 10, 20 ) );

reference

 slPrintHex
 slCurScrn
 slCurColor
 slLocate
 slPrintFX
 slPrint
 slPrintMatrix
 PrintColor 



ListReference

function

slPrintFX


Displaying fixed decimal representation

Format

    #include "sgl.h"

    FIXED val;
    void addr_A;

    void slPrintFX( val, addr_A );

argument

    Uint32 val - the value you want to display.
void *addr_A - VRAM address of VDP2 you want to display. (absolute address) Usually specified with slLocate .

Return number

    void - returns nothing.

function

Displays fixed-point data as a decimal point.
The 0s above the integer part and the 0s below the decimal part are replaced by spaces.
The integer part and decimal part are each a 5-digit decimal number.

example

    Displays 10.32 at cell (10,20) of the specified BG.
slPrintFX ( toFIXED ( 10.32 ), slLocate ( 10, 20 ) );

reference

 slPrintHex
 slCurScrn
 slCurColor
 slLocate
 slDispHex
 slPrint
 slPrintMatrix
 PrintColor 



ListReference

function

slPrintMatrix


Displaying fixed decimal representation

Format

    #include "sgl.h"

    MATRIX val;
    void addr_A;

    void slPrintMatrix( val, addr_A );

argument

    MATRIX val - A MATRIX type value indicating the matrix you want to display.
void *addr_A - VRAM address of VDP2 you want to display. (absolute address) Usually specified with slLocate .

Return number

    void - returns nothing.

function

Use slPrintFX to display a matrix (3x4).
If CURRENT is specified for mtrx, the current matrix of the matrix stack will be displayed.

example

    Displays a certain matrix at the (10,20) cell position of the specified BG.
MATRIX matrix = { { toFIXED ( 1.0 ), toFIXED ( 10.3 ), toFIXED ( 9.2 ) }, { toFIXED ( -10.3 ), toFIXED ( 1.0 ), toFIXED ( 7.5 ) }, { toFIXED ( -9.2 ), toFIXED ( -7.5 ), toFIXED ( 1.0 ) }, { toFIXED ( 1.0 ), toFIXED ( 1.0 ), toFIXED ( 1.0 ) } }; slPrintMatrix ( matrix, slLocate ( 10, 20 );

reference

 slPrintHex
 slCurScrn
 slCurColor
 slLocate
 slPrintFX
 slPrint
 slDispHex
 PrintColor 



ListReference

function

slPrint


Displaying debug strings

Format

    #include "sgl.h"

    char *val;
    void addr_A;

    void slPrint( val, addr_A );

argument

    char *val - The string you want to display. However, the end of the string shall be '\0'.
void *addr_A - VRAM address of VDP2 you want to display. (absolute address) Usually specified with slLocate .

Return number

    void - returns nothing.

function

Displays strings that end with a NULL character (code 0'\0').

example

    Displays "That's SGL" at cell (10,20) of the specified BG.
slPrintFX ( "That's SGL", slLocate ( 10, 20 ) );

reference

 slPrintHex
 slCurScrn
 slCurColor
 slLocate
 slPrintFX
 slDispHex
 slPrintMatrix
 PrintColor 


★Convert



ListReference

function

slHex2Dec


Convert numerical data to BCD format

Format

    #include "sgl.h"

    Uint32 val;

    Uint32 slHex2Dec( val );

argument

    Uint32 val - the value you want to convert.

Return number

    Uint32 - Converted number in BCD format.

function

Converts 32-bit binary data to BCD data up to 8 digits.
Values exceeding 8 digits (10000000(d) = 5F5E100(h) or more) If you specify , the top value will be incorrect.

example

    Convert 100(0x64) to 256(0x100).
ret = slHex2Dec ( 100 );

reference


★Simple scroll drawing



ListReference

function

slExtendScroll


Expanding scroll data compressed in command format

Format

    #include "sgl.h"
    #include "sl_macro.h"

    void tbl;
    void addr_A;

    void slExtendScroll( tbl, addr_A );

argument

    void *tbl - Command table for slExtendScroll . Defined by the "sl_macro.h" header.
void *addr_A - VDP2 VRAM (absolute) address where map data to be expanded is placed

Return number

    void - returns nothing.

function

Command Expand compressed scrollmap to VRAM.
The following functions can be used and are registered in sl_macro.h.
    Function :                    Function
    End()                           End of compressed data
    LocateA0(adr)                   Addressing in VRAM A0 area
    LocateA1(adr)                   Addressing in VRAM A1 area
    LocateB0(adr)                   Addressing in VRAM B0 area
    LocateB1(adr)                   Addressing in VRAM B1 area
    Set(cnt)                        Set the specified number of data (actual data follows)
    Stock(cnt)                      Set data while setting in stock buffer (″)
    Same(cnt,chr)                   Set the same character continuously
    Inc(cnt,chr)                    Set while increasing the character number
    Inc2(cnt,chr)                   Set the character number in increments of 2.
    Dec(cnt,chr)                    Set while decreasing the character number
    Dec2(cnt,chr)                   Set the character number by decreasing it by 2.
    Vline(cnt,chr)                  Arrange the same characters vertically
    VlineMinus(cnt,chr)             Arrange the same characters vertically (upwards)
    Skip(offset)                    Shift the display address by an offset (offset is 1 byte)
    Skip2(offset)                   Shift the display address by an offset (offset is 2 bytes)
    Copy(src,cnt)                   Copy the data that has already been set (copy source is address)
    RelCopy(src,cnt)                Copy the data that has already been set (copy source is relative)
    Fill(cnt,chr)                   Set the same character continuously (pointer does not move) (uses CPU D.M.A.)
    Block(hcnt,vcnt)                Specify the number of horizontal and vertical cells, and set the data that
                                    follows within them. (The pointer moves to the right side of the block)
    BlockInc(hcnt,vcnt,chr)         Specify the number of horizontal and vertical cells, and fill them in while
                                    increasing the character number (the pointer moves to the right side of the block)
    BlockInc2(hcnt,vcnt,chr)        Specify the number of horizontal and vertical cells, and fill them in while
                                    increasing the character number by 2 (the pointer moves to the right side of the block)
    One(chr)                        Set only one character.
    High(cnt,chr)                   Set the same character in the upper byte. The count sets the number including
                                    this cell, and this macro is followed by the LChar macro.
    BlockFill(hcnt,vcnt,chr)        Specify the number of horizontal and vertical cells and fill them with the same
                                    character number (the pointer moves to the right side of the block).
    Add(cnt,chr,add)                Set the character number by increasing it by the specified number.
                                    (The value to be added is signed 8 bits)
    BlockAdd(hcnt,vcnt,chr,add)     Specify the number of horizontal and vertical cells, and set the character numbers within
                                    them by increasing them.
                                    (The pointer moves to the right side of the block.)(The value to be added is signed 8 bits)
    Loop(cnt)                       Repeat until the next Until() for the specified number of times.
    Until()                         However, they cannot be nested.
    Char1(c)                        Actual data for 1 cell
    Char2(c1,c2)                    Actual data for 2 cells
     ...                                    :
    Char8(c1,c2,c3,c4,c5,c6,c7,c8)  Actual data for 8 cells
    LChar1(c)                       Character data for High (lower byte only)
    LChar2(c1,c2)                   Lower byte data for 2 cells
     ...
    LChar8(c1,c2,c3,c4,c5,c6,c7,c8) Lower byte data for 8 cells

example

    Expands the data of the specified table to the beginning of VRAM A1 (25e20000h) of VDP2.
#include "sgl.h" #include "sl_macro.h" #define SpaceCHR 0x0000 #define WhiteCHR 0x00fe Uint8 SceneMap_1[] = { Fill( Page, Space ), /* Fill one page with spaces */ Loop( 4 ), /* After this, repeat up to Until() 4 times */ BlockFill( 8, 8, WhiteCHR ), /* Fill 8x8 block with WhiteCHR */ Skip( 8 ), /* Move the pointer 8 cells from the next position in the block */ BlockFill( 8, 8, WhiteCHR ), Skip( 8 ), BlockFill( 8, 8, WhiteCHR ), Skip( 8 ), BlockFill( 8, 8, WhiteCHR ), Skip2( 7 * Line + 16 ), /* Use Skip2 because the pointer movement distance exceeds 1 byte */ BlockFill( 8, 8, WhiteCHR ), Skip( 8 ), BlockFill( 8, 8, WhiteCHR ), Skip( 8 ), BlockFill( 8, 8, WhiteCHR ), Skip( 8 ), BlockFill( 8, 8, WhiteCHR ), Skip2( 7 * Line ), Until(), End() }; void slExtendScroll ( ( void * )Scene_Map1, ( void * )( VDP2_VRAM_A1 ) );

reference


★CPU load observation



ListReference

function

set_vbar


Displaying CPU load gauge

Format

    #include "sgl.h"

    Uint16 pos_x;

    set_vbar( pos_x );

argument

    Uint16 x_pos - X position to display CPU load gauge (1/cell)

Return number

    void - returns nothing.

function

Displays a vertical bar to check the CPU operating time at the digit position represented by x_pos.

example

    Displays the CPU load at the 10th cell horizontally.
set_vbar ( 10 ); slSynch (); reset_vbar ( 10 );

Note

This function cannot measure the slave CPU load.
If the slave is under load, this result will not necessarily follow.

reference

 slCurScrn
 slCurColor
 slLocate
 reset_vbar
 slSynch
 slInitSynch
 PrintColor
 VDP2_MPABN0 



ListReference

function

reset_vbar


Hide CPU load gauge

Format

    #include "sgl.h"

    Uint16 pos_x;

    reset_vbar( pos_x );

argument

    Uint16 x_pos - X position to clear CPU load gauge (1/cell)

Return number

    void - returns nothing.

function

Erases the vertical bar at the digit position represented by x_pos written with set_vbar.

example

    Combine this function with set_vbar and the video synchronization function slSynch to check the operating time of the master CPU.
while(-1){ slExecuteEvent (); /* Event processing */ reset_vbar ( 39 ); /* Erase vertical bar */ slSynch (); /* Waiting for video synchronization */ set_vbar ( 39 ); /* Display vertical bar */ } [Explanation] Screen display starts immediately after slSynch finishes, so set the vertical bar in VRAM here. When event processing is executed in slExecuteEvent and all events have finished, if this vertical bar is deleted from VRAM, the vertical bar will no longer be visible in subsequent displays from that point on, and the length of the vertical bar that was visible will be reduced by the CPU. This is the time it was in operation.

Note

This function changes the number of character lines to be set depending on the vertical resolution.
For low resolution (224 or 240 lines), the top 32 lines, For high resolution (448 or 480 line interlace), 64 lines are rewritten.
Also, this function and set_vbar can only measure the load on the master CPU.

reference

 slCurScrn
 slCurColor
 slLocate
 set_vbar
 slSynch
 slInitSynch
 PrintColor
 VDP2_MPABN0 


★Location information



ListReference

function

slLocate


Positioning debug text

Format

    #include "sgl.h"

    Uint16 x_pos, y_pos;

    void *slLocate( x_pos, y_pos );

argument

    Uint16 x_pos - X coordinate cell position (1/cell)
    Uint16 y_pos - cell position in Y coordinate (1/cell)

Return number

    void* - VDP2 VRAM address.

function

Returns the address for displaying text (current screen).
x_pos, y_pos specify the cell position on the screen (usually 0 to 63).

example

    The debug string "This is Test." is placed in the position relative to cell (10,10) on the screen.
    It is displayed.
slPrint ( "This is Test.", slLocate ( 10, 10 ) );

reference

 slPrintHex
 slPrintFX
 slPrint
 slPrintMatrix
 VDP2_MPABN0
 VDP2_MPABN1
 VDP2_MPABN2
 VDP2_MPABN3
 VDP2_MPABRA 



ListReference

function

slLocateNbg



ListReference

macro

slLocateNbg0



ListReference

macro

slLocateNbg1



ListReference

macro

slLocateNbg2



ListReference

macro

slLocateNbg3


Know the display address of the normal BG surface

Format

    #include "sgl.h"

    Uint16 pos_x, pos_y;
    Uint16 mode;

    void *slLocateNbg( pos_x, pos_y, mode );
    void *slLocateNbg0( pos_x, pos_y );
    void *slLocateNbg1( pos_x, pos_y );
    void *slLocateNbg2( pos_x, pos_y );
    void *slLocateNbg3( pos_x, pos_y );

argument

      Uint16 pos_x - X coordinate position (1/cell)
    Uint16 pos_y - Y coordinate position (1/cell)
    Uint16 mode - The type of BG surface you want to know.

Return number

    void * - Pointer of type void indicating the (absolute) address of VDP2's VRAM.

function

Returns the display address of the specified cell position and normal scroll surface.
pos_x and pos_y are specified by the cell position on the screen (usually 0 to 127).
In mode, scnNBG0 , scnNBG1 , scnNBG2 , scnNBG3 Specify one of the following.

example

    Check the VRAM address at cell (10,5) of NBG1.
addr = slLocateNbg ( 10, 5, scnNBG1 ); addr = slLocateNbg1 ( 10, 5 );

reference

 slLocate
 slLocatePage
 VDP2_MPABN0 



ListReference

function

slLocatePage


Know the display address of the scroll surface

Format

    #include "sgl.h"

    Uint16 pos_x, pos_y;
    Uint16 page;

    void *slLocatePage( pos_x, pos_y, page )

argument

    Uint16 pos_x - X coordinate position (1/cell)
    Uint16 pos_y - Y coordinate position (1/cell)
    Uint16 page - The page number you want to know. The page number has a boundary of 2000h based on the beginning of VDP2's VRAM.

Return number

    void * - Pointer of type void indicating the (absolute) address of VDP2's VRAM.

function

Returns the display address of the scroll surface for each page.
pos_x and pos_y are specified by the cell position on the screen (usually 0 to 63).
page specifies the page number counted in 0x2000 units from the beginning of VRAM.

example

    Get the display address of cell position (6,4) on page number 4.
slLocatePage ( 6, 4, 4 );

reference

 slLocate
 slLocatePage

return
Copyright SEGA ENTERPRISES, LTD., 1997