ListReference

function

slInitSystem


Initialization of SGL system

Form

    #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 --Frame switching count.

Number of returns

    void --Nothing is returned.

function

    Initializes the entire system, registers the texture definition table, and sets the frame switching count.
In the screen mode "mode", 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 in the system variable " FormTbl ".
What is set when slInitSystem () is executed.
Window size for sprites and polygons, vanishing point position 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 relation 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 color mode 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 ~ : RBG0 PB 25E50000 ~ Pattern name size: NBG0 1 word: 10 bits with inversion for each cell Pattern name: NBG1 and RGB0 1 word: no inversion, 12 bits Pattern name Plain size: 64x64 cells on each side Back screen color: 25E3FFFE black (R =) 0, G = 0, B = 0) Rotation parameter: From 25E3FF00 Sprite data: Mixing palette and RGB format SCU interrupt priority (not SCU default) without special effects features such as mosaics and color offsets High name SCU interrupt mask register ^ H Blank In FFFF | Level 2 DMA end FFFB (reserved with SGL) | Level 1 DMA end FDFB (reserved by SGL) | Level 0 DMA end F9FB (reserved by SGL) | DMA Illegal F1FB | V Blank In E1FB (Reserved with SGL) | V Blank Out E1FA (Booked with SGL) | Timer 0 E1F8 | Timer 1 E1F0 | DSP end E1E0 | Sound Request E1C0 (Reserved by SGL) | SMPC E180 (Booked with SGL) | Pad E100 Low sprite drawing end E000 Sound is not initialized, so if you use sound-related functions, Initialize with 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 the dynamic frame (switching frames waiting to be drawn) mode.
ss_main () { slInitSystem ( TV_320x240 , NULL , -3); ::

caution


    Be sure to execute this function before executing all SGL functions.
If another SGL function accesses the uninitialized system area, it becomes a hotbed of bugs.
Since the system clock is switched depending on the resolution (TV mode), the contents of VRAM etc. may be damaged, so execute it only once immediately after starting the system.
If a negative is specified for the frame switching count, after the switching count has elapsed (2 blankings if -2), the completion of writing to the frame buffer of VDP1 is checked, and switching is performed after the writing is completed. However, If you specify interlaced mode, this specification is ignored.
When slInitSystem () is executed, if the SH2 operating clock is changed by changing the screen mode, a clock change will occur. At this time, depending on the model of the home TV, synchronization may be lost momentarily.
The operating clock of SH2 is 26MHz. Horizontal resolution 320 or 640 DOT In the case of.
The operating clock of SH2 is 28MHz. Horizontal resolution 352 or 704 DOT In the case of.
Of the devices affected by the clock change, the ones that need attention are It is as follows.
・ VDP1 VDP2 All registers and VRAM are not guaranteed.
The registers are reset inside slInitSystem (), but the user's data needs to be reloaded.
・ WORKRAM-LOW (1MB) Memory contents are not guaranteed.
Be sure to reload all the data.
· Both Sound Block 68000 and SCSP are reset.
In addition, all the contents of SOUND-RAM are not guaranteed, so it is necessary to reload the sound driver etc. and restart the 68000 as soon as slInitSystem () is completed.
・ SCU All settings will be initialized.
・ Slave SH After resetting, it will return to SGL control.
The user registration function needs to be re-registered.
Calling this function many times for purposes other than clock change is This is not very good for creating an application, so please use other functions as much as possible to initialize it, except for changing the clock.

reference

 slDynamicFrame
 slSetTVMode
 slSetScrTVMode
 slSetSprTVMode
 slInit Peripheral
 slGetStatus
 slGetPeripheral
 Sprbuf Bias
 MsLightVector
 MsScreenDist
 SlScreenDist
 MsZlimit
 WindowNumber
 TotalPolygons
 TotalVertices
 MsScreenLeft
 MsScreenTop
 MsScreenRight
 MsScreenBottom
 MX Polygons
 MX Vertices
 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_MPKLRA
 VDP2_MPMNRA
 VDP2_MPOPRA
 VDP2_MPABRB
 VDP2_MPCDRB
 VDP2_MPEFRB
 VDP2_MPGHRB
 VDP2_MPIJRB
 VDP2_MPKLRB
 VDP2_MPMNRB
 VDP2_MPOPRB
 VDP2_SCXN0
 VDP2_SCXIN0
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2_PosX
 Nbg2_PosY
 Nbg3_PosX
 Nbg3_PosY 



ListReference

function

slSetTVMode


Resolution switching

Form

    #include "sgl.h"

    Uint16 mode;

    Bool slSetTVMode (mode);

argument

    Uint16 mode --TV mode (see below).

Number of returns

    Bool --Error code (see below).

function

    Sets to the specified TV mode.
Returns FALSE if you want to switch the system clock.
Two system clocks are available and switch according to the horizontal resolution.
320, 640 dots <-> 352, 704 dots (26.84MHz) (28.64MHz) (26.66MHz) (28.44MHz) Therefore, you can switch from 320 dot mode to 640 dot mode, but you will get an error 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 be 1 frame, so the frame switching counter will be adjusted to be a multiple of 2. If you want to process the interlaced mode with one interrupt, execute this function and then ( Sint8 ) Set SynchConst to 1 and execute the slInitSynch function.
This function initializes the sprite window (total screen size), changes the perspective (angle of view 90 °), and changes the sprite data type according to the specified resolution.
The sprite data type changes only bit 3 of the 4 bits.
In the screen mode "mode", 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.   

caution


    The following settings are not changed by this function. 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 slTV Off if necessary. Execute the function.

reference

 slInitSystem
 slSetScrTVMode
 slSetSprTVMode
 slTVOff
 slTVOn
 ComWrPtr
 ComRdPtr
 MsScreenDist
 WindowNumber
 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

Form

    #include "sgl.h"

    Uint16 mode;

    Bool slSetScrTVMode (mode);

argument

    Uint16 mode --TV mode (see below).

Number of returns

    Bool --Error code (see below).

function

    Set the TV mode of the part related to scroll control (VDP2).
Returns FALSE if the system clock is to be switched, similar to the slSetTVMode function above.
In the screen mode "mode", 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.

caution


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

reference

 slInitSystem
 slSetSprTVMode
 slSetTVMode
 slTVOff
 slTVOn
 Resolution
 VDP2_TVSTAT 



ListReference

function

slSetSprTVMode


VDP1 resolution switching

Form

    #include "sgl.h"

    Uint16 mode;

    Bool slSetSprTVMode (mode);

argument

    Uint16 mode --TV mode (see below).

Number of returns

    Bool --Error code (see below).

function

    Sets the TV mode for the sprite control (VDP1) part.
Returns FALSE if the system clock is to be switched, similar to the slSetTVMode function above.
Also, when switching to interlaced mode, adjust the counter so that 2 interrupts are 1 frame.
The sprite window is initialized, the perspective setting (angle of view 90 °), and the sprite data type are changed.
The sprite data type changes only bit 3 of the 4 bits.
In the screen mode "mode", 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.   

caution


    Sprites cannot be in interlaced mode if scrolling is not in interlaced mode.
This is because EvenFrame and OddFrame are obtained from the status of VDP2.

reference

 slInitSystem
 slSetScrTVMode
 slSetTVMode
 ComWrPtr
 ComRdPtr
 MsScreenDist
 WindowNumber
 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 of drawing end wait mode

Form

    #include "sgl.h"

    Uint16 flag;

    Bool slDynamicFrame (flag);

argument

    Uint16 flag --Dynamic frame mode switching

Number of returns

    Bool --Error status

function

    Switches between a fixed cycle frame change and a VDP1 drawing end waiting (dynamic) frame change.
Specify either ON or OFF for flag.
Returns FALSE for interlaced mode.

Example

    Fixed interval → Indefinite interval / * Switch from 1 int fixed to 2 int base indefinite 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 ();

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

caution


    When changing from a fixed interval to an 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