#include "sgl.h"
Uint16 mode;
TEXTURE * form_tbl;
Sint8 cnt;
void slInitSystem (mode, form_tbl, cnt);
Uint16 mode --Screen mode.
TEXTURE * form_tbl --Texture definition table.
Sint8 cnt --Frame switching count.
void --Nothing is returned.
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.
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);
::
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.
#include "sgl.h"
Uint16 mode;
Bool slSetTVMode (mode);
Uint16 mode --TV mode (see below).
Bool --Error code (see below).
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.
slInitSystem ( TV_352x224 , NULL , 1);
::
slSetTVMode ( TV_352x480 );
OK.
slInitSystem ( TV_352x224 , NULL , 1);
::
slSetTVMode ( TV_320x224 );
NG.
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.
#include "sgl.h"
Uint16 mode;
Bool slSetScrTVMode (mode);
Uint16 mode --TV mode (see below).
Bool --Error code (see below).
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.
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.
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.
slInitSystem | slSetSprTVMode | slSetTVMode | slTVOff |
slTVOn | Resolution | VDP2_TVSTAT |
#include "sgl.h"
Uint16 mode;
Bool slSetSprTVMode (mode);
Uint16 mode --TV mode (see below).
Bool --Error code (see below).
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.
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.
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.
#include "sgl.h"
Uint16 flag;
Bool slDynamicFrame (flag);
Uint16 flag --Dynamic frame mode switching
Bool --Error status
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.
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 ();
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".
slInitSystem | SynchConst | SynchCount | Resolution |