Japanese

★Event



ListReference

function

slInitEvent


Initialize buffer for event and work management

Format

    #include "sgl.h"

    void slInitEvent( void );

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Initializes the buffer for event and work management. There are 64 events, 256 pieces of work will be prepared.

example

    void *eventtbl[] = {
        init_camera,
        init_player1,
        init_player2,
        init_enemyctrl
    };

    void InitGame(){
        void **evrdptr;
        EVENT *evptr;
        int cnt;

        slInitEvent (); /* Initialize event management variables */
        evrptr = eventtbl;
        for( cnt = sizeof( eventtbl ) / sizeof( void * ) ; cnt-- > 0 ; ) {
            evptr = slSetEvent ( *evrptr++ );
        }
        slSetSprTVMode ( TV_320x224 );
    }

    void Game(){
        slExecuteEvent (); /* Execute event */
        slSynch (); /* Polygon data output and video display synchronization */
    }    

Note

The event and work RAM itself is not initialized, so when the area is extracted, Please initialize the user program.

reference

 slGetEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 slReturnEvent
 slExecuteEvent
 slGetWork
 slReturnWork 



ListReference

function

slGetEvent


Acquisition of RAM for events

Format

    #include "sgl.h"

    EVENT *slGetEvent( void );

argument

    void - gives nothing.

Return number

    EVENT * - Pointer to the retrieved event RAM address.

function

Retrieves the RAM area allocated for the event and returns a pointer to it.

example

    void func() {
      /* This is executed in event loop. */
    }

    EVENT *evnt1, *evnt2;

    evnt1 = slGetEvent ();

    evnt2 = slSetEvent ( func );
    evnt2->user = ( Uint8 * )evnt1;    

Note

This is a 128-byte area that can be used freely by the user. There are 64 pieces available, If it is used up, a NULL code is returned.

reference

 slInitEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 slReturnEvent
 EventTop
 EventCount 



ListReference

function

slSetEvent


Add event

Format

    #include "sgl.h"

    void *( func )( void );

    EVENT *slSetEvent( func );

argument

    void *( func )( void ) - Executable function that registers for the event.

Return number

    EVENT * - EVENT type pointer to the retrieved event.

function

Fetches the event and adds it to the end of the execution list. At this time, the specified function will be registered as an execution function.

example

    slInitEvent ();

    slSetEvent ( user_func1 );
    slSetEvent ( user_func2 );
         :
    while( -1 ) {
         :
      slExecuteEvent ();
      slSynch ();
    }

Note

It is a 128-byte area, but the first 16 bytes are used by the system.
Returns a NULL code if there are no events left.

reference

 slInitEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 slReturnEvent
 slExecuteEvent 



ListReference

function

slSetEventNext


Registration of next candidate for event

Format

    #include "sgl.h"

    EVENT *event;
    void *( func )( void );

    EVENT *slSetEventNext( evnt, func );

argument

    EVENT *evnt - The event before the event to register for.
void *( func )( void ) - Executable function to register.

Return number

    EVENT * - Pointer to a structure of type EVENT indicating the retrieved event.

function

Fetches an event and adds it to the execution list so that it is executed next to the specified event. At this time, the specified function will be registered as an execution function.

example

    void func() {
      /* This is executed in event loop. */
    }

    ss_main() {
      EVENT *event;

      evnt = slGetEvent ();
      evnt->work = ...
              :
      slSetEventNext ( evnt, func );
              :

Note

It is a 128-byte area, but the first 16 bytes are used by the system.
Returns a NULL code if there are no events left.

reference

 slInitEvent
 slSetEvent
 slGetEvent
 slCloseEvent
 slReturnEvent
 slExecuteEvent 



ListReference

function

slReturnEvent


Search for unregistered events

Format

    #include "sgl.h"

    EVENT *event;

    void slReturnEvent( evnt );

argument

    EVENT *evnt - Pointer to an EVENT type structure representing the event that requires release.

Return number

    void - returns nothing.

function

Returns events that are not registered in the execution list to the system.

example

    EVENT *event;

    evnt = slGetEvent ();
    slReturnEvent ( evnt );

Note

If you execute this function for an event registered in the execution list, the event will remain registered in the list and execution will continue. The returned pointer is re-registered in the system buffer, but at this time it is not checked even if it has been registered, so if the same pointer is returned multiple times, the slGetEvent (), slSetEvent (), slSetEventNext () A problem will occur.

reference

 slInitEvent
 slGetEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 EventLast 



ListReference

function

slCloseEvent


Delete event

Format

    #include "sgl.h"

    EVENT *event;

    void slCloseEvent( evnt );

argument

    EVENT *evnt - Pointer to an EVENT type structure representing the event to delete.

Return number

    void - returns nothing.

function

Detaches the event registered in the execution list from the list and returns it to the system.
Also, if any workpieces have been set, they will also be returned.

example

    EVENT *event;

    evnt = slSetEvent ( user_func );
                 :
    slCloseEvent ( evnt );

Note

If you specify an event that is not registered in the execution list, the list information will be incorrect, and the list will have to be changed for an invalid event, resulting in writing to an unpredictable address, and in the worst case, the CPU will be overloaded. It may stop.
The returned pointer is re-registered in the system buffer, but at this time it is not checked even if it has already been registered, so if the same pointer is returned multiple times, the slGetEvent (), slSetEvent (), slSetEventNext () A problem will occur.

reference

 slInitEvent
 slGetEvent
 slSetEvent
 slSetEventNext
 slReturnEvent 



ListReference

function

slExecuteEvent


Executing an event

Format

    #include "sgl.h"

    void slExecuteEvent( void );

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Executes the events registered in the execution list in order from the beginning.

example

    slInitEvent ();

    slSetEvent ( ... );
        :
    while( -1 ) {
      slExecuteEvent ();
      slSynch ();
    }

Note

Execute it for each main loop.

reference

 slInitEvent
 slSetEvent
 slSetEventNext
 slSynch
 slInitSynch
 EventTop
 EventNow
 EventCount 


★Work



ListReference

function

slGetWork


Acquisition of work RAM for events

Format

    #include "sgl.h"

    WORK *slGetWork( void );

argument

    void - gives nothing.

Return number

    WORK * - Pointer to a WORK type structure indicating the allocated work area.

function

Fetches the RAM area allocated for work and returns a pointer to it.

example

    WORK *work;
    EVENT *event;

    work = slGetWork ();
    evnt = slSetEvent ();
    evnt->work = work;

Note

The work area is 64 bytes, and the first 4 bytes are used as a list pointer. used in the system. The remaining 60 bytes are free for use by the user.
If a pointer is set in WORK of the EVENT structure, it will be returned to the system when the event is closed.

reference

 slInitEvent
 slReturnWork
 Work Count 



ListReference

function

slReturnWork


Release work RAM for events

Format

    #include "sgl.h"

    WORK *wk;

    void slReturnWork( wk );

argument

    WORK *wk - Pointer to a WORK structure representing the work RAM to free.

Return number

    void - returns nothing.

function

Return the RAM area used for work to the system.

example

    WORK *work;

    work = slGetWork ();
               :
    slReturnWork ( work );

Note

The returned pointer is re-registered in the system buffer, but at this time it is not checked even if it has been registered, so if the same pointer is returned multiple times, a problem will occur in the subsequent slGetWork (). .

reference

 slInitEvent
 slGetWork
 Work Count 


★Global variables for events



ListReference

global variables

EventBuf


Format

    #include "sgl.h"

    extern EVENT EventBuf []; /* buffer for Event use */

reference

 slInitEvent
 slGetEvent
 slReturnEvent 



ListReference

global variables

WorkBuf


Format

    #include "sgl.h"

    extern WORK WorkBuf []; /* buffer for Work use */

reference

 slGetWork 



ListReference

global variables

RemainEvent


Format

    #include "sgl.h"

    extern EVENT * RemainEvent[] ; /* Remain Event address buffer */

reference

 slSetEvent
 slSetEventNext
 slReturnEvent
 slExecuteEvent 



ListReference

global variables

RemainWork


Format

    #include "sgl.h"

    extern WORK * RemainWork[] ; /* Remain Work address buffer */

reference

 slReturnWork

return
Copyright SEGA ENTERPRISES, LTD., 1997