★ Cursor



ListReference

function

slCurScrn


Specifying the NBG to display the debug string

Form

    #include "sgl.h"

    Uint16 mode;

    void slCurScrn (mode);

argument

    Uint16 screen --A substitute variable that indicates the type of BG.

Number of returns

    void --Nothing is returned.

function

    Set the screen used by slLocate and set_vbar.
For mode, specify one of the following six.
scnNBG0 , scnNBG1 , scnNBG2 , scnNBG3 , scnRBGA , scnRBGB The default value is scnNBG0 .

Example

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

caution


    If a value other than NBG0 is specified on the debug character string display screen, it is necessary to set the cycle pattern table accordingly. In that case,
    Automatically set using slScrAutoDisp or slScrCycleSet
    You need to manually set the cycle pattern automatically using slScrDisp and.

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

Form

    #include "sgl.h"

    Uint16 pal;

    void slCurColor (pal);

argument

    Uint16 pal --Palette number.

Number of returns

    void --Nothing is returned.

function

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

Example

    Set palette 2 (0x25f00006 in 16-bit mode, 0x25f0000c in 32-bit mode) as 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

Form

    #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 by slLocate.

Number of returns

    void --Nothing is returned.

function

    Displays the specified variable in 8-digit hexadecimal number.
When changing the BG surface to be displayed, slCurScrn , when changing the display color, 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

Form

    #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 by slLocate.

Number of returns

    void --Nothing is returned.

function

    Similar to slDispHex, it displays the specified variable as an 8-digit hexadecimal number, but the leading 0s are replaced with spaces.
When changing the BG surface to be displayed, slCurScrn , when changing the display color, 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


Display of fixed decimal representation

Form

    #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 by slLocate.

Number of returns

    void --Nothing is returned.

function

    Displays fixed-point data as a decimal point.
The upper 0 of the integer part and the 0 of the lower decimal part replace the space.
The integer part and the decimal part are each 5-digit decimal number.

Example

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

reference

 slPrintHex
 slCurScrn
 slCurColor
 slLocate
 slDispHex
 slPrint
 slPrintMatrix
 PrintColor 



ListReference

function

slPrintMatrix


Display of fixed decimal representation

Form

    #include "sgl.h"

    MATRIX val;
    void addr_A;

    void slPrintMatrix (val, addr_A);

argument

    MATRIX val --A MATRIX type value that indicates the matrix you want to display.
void * addr_A --VRAM address of VDP2 you want to display. (Absolute address) Usually specified by slLocate.

Number of returns

    void --Nothing is returned.

function

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

Example

    Display a 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


Display debug string

Form

    #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 character string shall end with'\ 0'.
void * addr_A --VRAM address of VDP2 you want to display. (Absolute address) Usually specified by slLocate.

Number of returns

    void --Nothing is returned.

function

    Displays a string that ends with a null character (code 0'\ 0').

Example

    "That's SGL" is displayed at the position of 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

Form

    #include "sgl.h"

    Uint32 val;

    Uint32 slHex2Dec (val);

argument

    Uint32 val --The value you want to convert.

Number of returns

    Uint32 -Converted BCD format number.

function

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

Example

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

reference


★ Simple scroll drawing



ListReference

function

slExtendScroll


Extraction of scroll data compressed in command format

Form

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

    void tbl;
    void addr_A;

    void slExtendScroll (tbl, addr_A);

argument

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

Number of returns

    void --Nothing is returned.

function

    Extracts the command-compressed scroll map into VRAM.
The following functions are available and are registered in sl_macro.h.
Function: Function End () End of compressed data LocateA0 (adr) Address specification in VRAM A0 area LocateA1 (adr) Address specification in VRAM A1 area Locate B0 (adr) Address specification in VRAM B0 area Locate B1 (adr) VRAM B1 area Address specification in Set (cnt) Set the specified number of data (this is followed by the actual data) Stock (cnt) Set data while setting in the stock buffer (″) Same (cnt, chr) Set the same character in succession Inc (cnt, chr) Set while increasing the character number Inc2 (cnt, chr) Set while increasing the character number by 2 Dec (cnt, chr) Dec (cnt, chr) Set the character number Set while decreasing Dec2 (cnt, chr) Set while decreasing the character number by 2 Vline (cnt, chr) Arrange the same characters vertically VlineMinus (cnt, chr) Arrange the same characters vertically (upward) Skip (offset) Shifts the display address by offset (offset is 1 byte) Skip2 (offset) Shift the display address by the offset (offset is 2 bytes) Copy (src, cnt) Copy the already set data (copy source is address) RelCopy (src, cnt) Copy the already set data (copy source is relative) Fill (cnt, chr) Set the same character in succession (pointer does not move) (Using CPU DMA) Block (hcnt, vcnt) Specify the number of horizontal and vertical cells, and set the data following it.
(The pointer moves to the right of the block) BlockInc (hcnt, vcnt, chr) Specify the number of horizontal and vertical cells and fill it 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 it by 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) Sets the same character in the high-order byte.
For the count, set the number including this cell, 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 of the block).
Add (cnt, chr, add) Sets the character number while 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 them while increasing the character number.
(The pointer moves to the right of the block.) (The value to be added is signed 8 bits) Loop (cnt) Repeats the specified number of times until the next Until ().
Until () However, it cannot be nested.
Char1 (c) 1 cell of real data Char2 (c1, c2) 2 cells of real data ...: Char8 (c1, c2, c3, c4, c5, c6, c7, c8) Real 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 in the specified table to the beginning (25e20000h) of VRAM A1 in VDP2.
#include "sgl.h" #include "sl_macro.h" #define SpaceCHR 0x0000 #define WhiteCHR 0x00fe Uint8 SceneMap_1 [] = { Fill (Page, Space), / * Fill one page with space * / Loop (4), / * After this, repeat up to Until () 4 times * / BlockFill (8, 8, WhiteCHR), / * Fill 8x8 blocks with WhiteCHR * / Skip (8), / * Move the pointer by 8 cells from the position next to 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 movement amount of the pointer 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


CPU load gauge display

Form

    #include "sgl.h"

    Uint16 pos_x;

    set_vbar (pos_x);

argument

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

Number of returns

    void --Nothing is returned.

function

    A vertical bar for checking the CPU operating time is displayed at the digit position represented by x_pos.

Example

    The CPU load is displayed at the position of 10 cells horizontally.
set_vbar (10); slSynch (); reset_vbar (10);

caution


    This function cannot measure the load on the slave CPU.
This result may not always be true if the slave is under load.

reference

 slCurScrn
 slCurColor
 slLocate
 reset_vbar
 slSynch
 slInitSynch
 PrintColor
 VDP2_MPABN0 



ListReference

function

reset_vbar


Hide CPU load gauge

Form

    #include "sgl.h"

    Uint16 pos_x;

    reset_vbar (pos_x);

argument

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

Number of returns

    void --Nothing is returned.

function

    Erase the vertical bar at the digit position represented by x_pos written in set_vbar.

Example

    Combine this function with set_vbar and the video synchronization function slSynch to find out the uptime of the master CPU.
while (-1) { slExecuteEvent (); / * Event processing * / reset_vbar (39); / * Erase vertical bars * / slSynch (); / * Waiting for video sync * / set_vbar (39); / * Display vertical bars * / } [Explanation] Since the screen display starts immediately after the end of slSynch , set the vertical bar in VRAM here. When event processing is executed by slExecuteEvent and all events are completed, if this vertical bar is deleted from VRAM, the vertical bar will not be visible in the display after that timing, and the length that the vertical bar was visible will be the CPU. It will be the time when it was in operation.

caution


    This function changes the number of lines of the character 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), rewrite 64 lines.
Also, this function and the set_vbar pair 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

Form

    #include "sgl.h"

    Uint16 x_pos, y_pos;

    void * slLocate (x_pos, y_pos);

argument

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

Number of returns

    void * --VRAM address of VDP2.

function

    Returns the text display address (current screen).
x_pos and y_pos specify the cell position (usually 0 to 63) on the screen.

Example

    Debug string "This is Test." At a 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

Form

    #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.

Number of returns

    void * --Void pointer to the (absolute) address of VDP2 VRAM.

function

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

Example

    Find the VRAM address at cell (10,5) on 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

Form

    #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 VRAM of VDP2.

Number of returns

    void * --Void pointer to the (absolute) address of VDP2 VRAM.

function

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

Example

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

reference

 slLocate
 slLocatePage

return
Copyright SEGA ENTERPRISES, LTD., 1997