Japanese

ListReference

function

slInitSystem


Initializing the SGL system

Format

    #include "sgl.h"

    Uint16 mode;
    TEXTURE *form_tbl;
    Sint8 cnt;

    void slInitSystem( mode, form_tbl , cnt );

argument

    Uint16 mode - Screen mode.
TEXTURE *form_tbl - Texture definition table.
Sint8 cnt - count of frame switches.

Return number

    void - returns nothing.

function

Initialize the entire system, register the texture definition table, and set the frame switching count.
The screen mode "mode" has
        TV_320x224 , TV_320x240 , TV_320x256
        TV_352x224 , TV_352x240 , TV_352x256
        TV_640x224 , TV_640x240 , TV_640x256
        TV_704x224 , TV_704x240 , TV_704x256
        TV_320x448 , TV_320x480 , TV_320x512
        TV_352x448 , TV_352x480 , TV_352x512
        TV_640x448 , TV_640x480 , TV_640x512
        TV_704x448 , TV_704x480 , TV_704x512
is entered.
Also, the value of the argument form_tbl is set to the system variable " FormTbl ".
What is set when slInitSystem () is executed.
Window size and vanishing point position for sprites and polygons
        Left             : 0
        Top              : 0
        Right            : ScreenXSize - 1
        Bottom           : ScreenYSize - 1
        Zlimit           : 0x7fff
        CenterX          : ScreenXSize / 2
        CenterY          : ScreenYSize / 2
        PersAngle        : 90゜
        ZdspLevel        : 1
        ClipSizeX        : 320
        ClipSizeY        : 512
     Scroll related
        Displayed scroll surface     : NBG0 , NBG1 , RBG0
        Scroll priority:             : NBG0 NBG1 NBG2 NBG3 RBG0
                                        7    7    2    1    4
        Sprite 0 (polygon) priority  : 6
        Other sprites                : 5
        Number of scroll colors      : 256 colors on each side
        Color RAM mode               : 1 (2048 out of 32768 colors)
        VRAM division                : Both banks A and B are divided
        Character data               : NBG0, NBG1 25E60000~
                                        : RBG0 25E00000~
        Character size               : 8x8 dots on each side
        Pattern name data            : NBG0 25E76000~
                                        : NBG1 25E78000~
                                        : RBG0 PA 25E40000~
                                        : RBG0PB 25E50000〜
        Pattern name size            : NBG0 1 word
                                        : 10-bit pattern name with inversion for each cell
                                        : NBG1 and RGB0 1 word
                                        : No inversion, 12-bit pattern name
        Plane size                   : 64x64 cells on each side
        Back screen color            : 25E3FFFE to black (R= 0, G=0, B=0)
        Rotation parameters          : From 25E3FF00
        Sprite data                  : Mixed mosaic with palette and RGB format, special effect functions such as color offset are not used
        SCU interrupt priority (not the default of SCU)
          High     Name            SCU Interrupt Mask Register
           ^   H Blank In                FFFF
           |   Level 2 DMA Ended         FFFB (Reserved with SGL)
           |   Level 1 DMA Ended         FDFB (Reserved with SGL)
           |   Level 0 DMA End           F9FB (Reserve with SGL)
           |   DMA Illegal               F1FB
           |   V Blank In                E1FB (Reserve with SGL)
           |   V Blank Out               E1FA (Reserve with SGL)
           |   Timer 0                   E1F8
           |   Timer 1                   E1F0
           |   DSP end                   E1E0
           |   Sound Request             E1C0 (Reserve with SGL)
           |   SMPC                      E180 (Reserved with SGL)
           |   Pad                       E100
          Low  Sprite drawing finished   E000
Sound initialization is not performed, so when using sound-related functions, Please initialize using the sound initialization function of each library.

example

    When not using textures (sprites). (Polygons can be used.)
    ss_main() {
      slInitSystem ( TV_352x224 , NULL , 1 );
                        :

    When using textures.
extern TEXTURE textbl[]; ss_main() { slInitSystem ( TV_320x240 , textbl, 1 ); : When using dynamic frame (drawing waiting frame switching) mode.
ss_main() { slInitSystem ( TV_320x240 , NULL , -3 ); :

Note

Be sure to execute this function before executing all SGL functions.
If other SGL functions access uninitialized system areas, it becomes a breeding ground for bugs.
Since the system clock is switched depending on the resolution (TV mode), the contents of VRAM etc. may be corrupted, so please execute this only once immediately after the system starts.
If a negative value is specified for the frame switching count, after the switching count has elapsed (2 blanking if -2), the end of writing to the frame buffer of VDP1 is checked, and switching is performed after waiting for the writing completion. however, This specification is ignored if interlace mode is specified.
When executing slInitSystem (), if the operating clock of SH2 is changed due to a change in screen mode, a clock change will occur. At this time, depending on the model of your home TV, synchronization may momentarily become impossible.
The operating clock of SH2 is 26MHz because Horizontal resolution 320 or 640 DOT This is the case.
The operating clock of SH2 is 28MHz because Horizontal resolution 352 or 704 DOT This is the case.
Of the devices affected by clock changes, caution is required: It is as follows.
・VDP1 VDP2 All registers and VRAM are not guaranteed.
The registers are reconfigured inside slInitSystem (), but the user data needs to be loaded again.
・WORKRAM-LOW(1M byte) Memory contents are not guaranteed.
Be sure to reload all data.
・Both Sound Block 68000 and SCSP will be reset.
Also, the contents of SOUND-RAM are not guaranteed, so as soon as slInitSystem () finishes, you need to reload the sound driver, etc., and restart the 68000.
・SCU All settings will be initialized.
・Slave SH After the reset, it will be back under SGL control.
User registration functions must be re-registered.
Calling this function many times for purposes other than clock changes is This is not very convenient when creating an application, so other than changing the clock, try to initialize using other functions as much as possible.

reference

 slDynamicFrame
 slSetTVMode
 slSetScrTVMode
 slSetSprTVMode
 slInitPeripheral
 slGetStatus
 slGetPeripheral
 Sprbuf Bias
 MsLightVector
 MsScreenDist
 SlScreenDist
 MsZlimit
 Window Number
 TotalPolygons
 Total Vertices
 MsScreenLeft
 MsScreenTop
 MsScreenRight
 MsScreenBottom
 MXPolygons
 MXVertices
 FrameSizeX
 FrameSizeY
 MsWinXAdder
 MsWinYAdder
 SlWinXAdder
 SlWinYAdder
 MsClipXAdder
 MsClipYAdder
 DMAEndFlag
 DMASetFlag
 Resolution
 NbPCMBf
 PCMBufFlag
 VDP2_VRSIZE
 VDP2_HCNT
 VDP2_VCNT
 VDP2_RAMCTL
 VDP2_CYCA0L
 VDP2_CYCA0U
 VDP2_CYCA1L
 VDP2_CYCA1U
 VDP2_CYCB0L
 VDP2_CYCB0U
 VDP2_CYCB1L
 VDP2_CYCB1U
 VDP2_BGON
 VDP2_MZCTL
 VDP2_SFSEL
 VDP2_SFCODE
 VDP2_CHCTLA
 VDP2_CHCTLB
 VDP2_BMPNA
 VDP2_BMPNB
 VDP2_PNCN0
 VDP2_PNCN1
 VDP2_PNCN2
 VDP2_PNCN3
 VDP2_PNCR
 VDP2_PLSZ
 VDP2_MPOFN
 VDP2_MPOFR
 VDP2_MPABRA
 VDP2_MPCDRA
 VDP2_MPEFRA
 VDP2_MPGHRA
 VDP2_MPIJRA
 VDP2_M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_adr
 nbg1_char_adr
 nbg2_char_adr
 nbg3_char_adr
 nbg0_char_adr
 ra_char_adr
 rb_char_adr
 nbg0_page_adr
 nbg1_page_adr
 nbg2_page_adr
 nbg3_page_adr
 ra_page_adr
 rb_page_adr
 rpara_vram_adr
 RotScrParA
 RotScrParB
 Nbg2_PosX
 Nbg2_PosY
 Nbg3_PosX
 Nbg3_PosY 



ListReference

function

slSetTVMode


Switch resolution

Format

    #include "sgl.h"

    Uint16 mode;

    Bool slSetTVMode( mode );

argument

    Uint16 mode - TV mode (described later).

Return number

    Bool - Error code (described below).

function

Sets the specified TV mode.
Returns FALSE if the system clock is being switched.
There are two system clocks, which are switched depending on the horizontal resolution.
         320,640 dots <--> 352,704 dots
         (26.84MHz)             (28.64MHz)                <NTSC>
         (26.66MHz)             (28.44MHz)                <PAL>
Therefore, although it is possible to switch from 320 dot mode to 640 dot mode, an error will occur if you try to switch to 352 dot mode.
Also, if the vertical resolution is set to 448 or 480 lines, it will be interlaced, so 2 interrupts will result in 1 frame, so the frame switching counter will be adjusted to be a multiple of 2. If you want to process interlaced mode with one interrupt, after executing this function, ( Sint8 ) Set SynchConst to 1 and execute the slInitSynch function.
This function initializes the sprite window (full screen size), changes the perspective (angle of view 90°), and changes the sprite data type according to the specified resolution.
Sprite data type changes only bit 3 out of 4 bits.
The screen mode "mode" has
        TV_320x224 , TV_320x240 , TV_320x256
        TV_352x224 , TV_352x240 , TV_352x256
        TV_640x224 , TV_640x240 , TV_640x256
        TV_704x224 , TV_704x240 , TV_704x256
        TV_320x448 , TV_320x480 , TV_320x512
        TV_352x448 , TV_352x480 , TV_352x512
        TV_640x448 , TV_640x480 , TV_640x512
        TV_704x448 , TV_704x480 , TV_704x512
is entered.

example

    slInitSystem ( TV_352x224 , NULL , 1 );
                     :
    slSetTVMode ( TV_352x480 );
                             OK.

    slInitSystem ( TV_352x224 , NULL , 1 );
                     :
    slSetTVMode ( TV_320x224 );
                             NG.   

Note

This function does not change the following settings. Set as necessary after executing this function.
○ VDP2 cycle mode ○ Window for scroll screen ○ Sprite display forward limit value (ZdspLevel) Also, noise may appear on the screen, so please turn off slTVOff as necessary. Please run the function.

reference

 slInitSystem
 slSetScrTVMode
 slSetSprTVMode
 slTVOff
 slTVOn
 ComWrPtr
 ComRdPtr
 MsScreenDist
 Window Number
 WinUseFlag
 MsScreenLeft
 MsScreenTop
 MsScreenRight
 MsScreenBottom
 MsScreenSizeX
 MsScreenSizeY
 MsWindowSizeX
 MsWindowSizeY
 MsWinXAdder
 MsWinYAdder
 SlWinXAdder
 SlWinYAdder
 MsClipXAdder
 MsClipYAdder
 SlClipXAdder
 SlClipYAdder
 Resolution
 VDP2_TVSTAT
 VDP2_SPCTL
 RotScrParA
 RotScrParB 



ListReference

function

slSetScrTVMode


VDP2 resolution switching

Format

    #include "sgl.h"

    Uint16 mode;

    Bool slSetScrTVMode( mode );

argument

    Uint16 mode - TV mode (described later).

Return number

    Bool - Error code (described below).

function

Set the TV mode for the part related to scroll control (VDP2).
Similar to the slSetTVMode function above, it returns FALSE when switching the system clock.
The screen mode "mode" has
        TV_320x224 , TV_320x240 , TV_320x256
        TV_352x224 , TV_352x240 , TV_352x256
        TV_640x224 , TV_640x240 , TV_640x256
        TV_704x224 , TV_704x240 , TV_704x256
        TV_320x448 , TV_320x480 , TV_320x512
        TV_352x448 , TV_352x480 , TV_352x512
        TV_640x448 , TV_640x480 , TV_640x512
        TV_704x448 , TV_704x480 , TV_704x512
is entered.

example

    slInitSystem ( TV_352x224 , NULL , 1 );
                     :
    slSetScrTVMode ( TV_352x480 );
                             OK.

    slInitSystem ( TV_352x448 , NULL , 1 );
                     :
    slSetScrTVMode ( TV_320x448 );
                             NG.   

    slInitSystem ( TV_352x448 , NULL , 1 );
                     :
    slSetScrTVMode ( TV_352x240 );
                             NG.

Note

If the sprite is displayed in interlaced mode, be sure to also scroll in interlaced mode.
This is because EvenFrame and OddFrame are obtained from the VDP2 status.

reference

 slInitSystem
 slSetSprTVMode
 slSetTVMode
 slTVOff
 slTVOn
 Resolution
 VDP2_TVSTAT 



ListReference

function

slSetSprTVMode


VDP1 resolution switching

Format

    #include "sgl.h"

    Uint16 mode;

    Bool slSetSprTVMode( mode );

argument

    Uint16 mode - TV mode (described later).

Return number

    Bool - Error code (described below).

function

Set the TV mode for the part related to sprite control (VDP1).
Similar to the slSetTVMode function above, it returns FALSE when switching the system clock.
Also, when switching to interlace mode, adjust the counter so that 2 interrupts equal 1 frame.
The sprite window will be initialized, the perspective setting (angle of view 90°), and the sprite data type will be changed.
Sprite data type changes only bit 3 out of 4 bits.
The screen mode "mode" has
        TV_320x224 , TV_320x240 , TV_320x256
        TV_352x224 , TV_352x240 , TV_352x256
        TV_640x224 , TV_640x240 , TV_640x256
        TV_704x224 , TV_704x240 , TV_704x256
        TV_320x448 , TV_320x480 , TV_320x512
        TV_352x448 , TV_352x480 , TV_352x512
        TV_640x448 , TV_640x480 , TV_640x512
        TV_704x448 , TV_704x480 , TV_704x512
is entered.

example

    slInitSystem ( TV_352x448 , NULL , 1 );
                     :
    slSetSprTVMode ( TV_352x240 );
                             OK.   

    slInitSystem ( TV_352x224 , NULL , 1 );
                     :
    slSetSprTVMode ( TV_352x480 );
                             NG.

    slInitSystem ( TV_352x448 , NULL , 1 );
                     :
    slSetSprTVMode ( TV_320x448 );
                             NG.   

    slInitSystem ( TV_320x448 , NULL , 1 );
                     :
    slSetScrTVMode ( TV_320x224 );
    slSetSprTVMode ( TV_320x224 );
                             OK.   

Note

You cannot put a sprite in interlaced mode if scrolling is not in interlaced mode.
This is because EvenFrame and OddFrame are obtained from the VDP2 status.

reference

 slInitSystem
 slSetScrTVMode
 slSetTVMode
 ComWrPtr
 ComRdPtr
 MsScreenDist
 Window Number
 WinUseFlag
 MsScreenLeft
 MsScreenTop
 MsScreenRight
 MsScreenBottom
 MsScreenSizeX
 MsScreenSizeY
 MsWindowSizeX
 MsWindowSizeY
 MsWinXAdder
 MsWinYAdder
 SlWinXAdder
 SlWinYAdder
 MsClipXAdder
 MsClipYAdder
 SlClipXAdder
 SlClipYAdder
 Resolution
 VDP2_TVSTAT
 VDP2_SPCTL
 RotScrParA
 RotScrParB 



ListReference

function

slDynamicFrame


Setting the wait mode for drawing completion

Format

    #include "sgl.h"

    Uint16 flag;

    Bool slDynamicFrame( flag );

argument

    Uint16 flag - toggle dynamic frame mode

Return number

    Bool - error status

function

    Switches between a constant frame change and a dynamic frame change that waits for VDP1 to finish drawing.
Specify either ON or OFF for flag.
Returns FALSE if in interlaced mode.

example

    Fixed interval → Indeterminate interval /* Switch from 1 int fixed to 2 int base indeterminate mode */
      extern Uint8 SynchConst ; /* unsigned int instead of signed int */
                               /* ^^^^^^ ^^^^^^^^ */
      slInitSystem ( TV_320x224 , NULL , 1 );
                  :
                  :
      /* Set indefinite interval mode-2 */
      slDynamicFrame ( ON );
      SynchConst = 2; /* not -2 */
      slSynch ();

    Indeterminate interval → Fixed interval /* Change from 1 int indeterminate interval to 1 int fixed interval */
      slInitSystem ( TV_320x224 , NULL , -1 );
                   :
                   :
      /* Set fixed interval mode 1 */
      slDynamicFrame ( OFF );
      /* No need to change SynchConst */
      slSynch ();

Note

When changing from fixed interval to indefinite interval (dynamic frame mode), enter a positive number instead of a negative number in the system variable " SynchConst ".

reference

 slInitSystem
 SynchConst
 SynchCount
 Resolution

return
Copyright SEGA ENTERPRISES, LTD., 1997