★ Event



ListReference

function

slInitEvent


Initialize the buffer for event and work management

Form

    #include "sgl.h"

    void slInitEvent (void);

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    Initialize the buffer for event and work management. 64 events,
    256 works are prepared.

Example

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

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

        slInitEvent (); / * Initialization of 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 * /
    }    

caution


    Since the RAM itself for events and work is not initialized, when the area is taken out,
    Please initialize the user program.

reference

 slGetEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 slReturnEvent
 slExecuteEvent
 slGetWork
 slReturnWork 



ListReference

function

slGetEvent


Get RAM for events

Form

    #include "sgl.h"

    EVENT * slGetEvent (void);

argument

    void --Do not give anything.

Number of returns

    EVENT * --A pointer to the acquired RAM address for the event.

function

    Fetches 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;    

caution


    The 128-byte area is free for users. 64 pieces are prepared,
    Returns a null code if it is used up.

reference

 slInitEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 slReturnEvent
 EventTop
 EventCount 



ListReference

function

slSetEvent


Add event

Form

    #include "sgl.h"

    void * (func) (void);

    EVENT * slSetEvent (func);

argument

    void * (func) (void) --Execution function to register in the event.

Number of returns

    EVENT * --EVENT type pointer to the acquired event.

function

    Take the event and add it to the end of the run list. At this time, the specified function is registered as an execution function.

Example

    slInitEvent ();

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

caution


    The area is 128 bytes, but the first 16 bytes are used by the system.
Returns a null code if no events remain.

reference

 slInitEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 slReturnEvent
 slExecuteEvent 



ListReference

function

slSetEventNext


Registration of next candidate for event

Form

    #include "sgl.h"

    EVENT * evnt;
    void * (func) (void);

    EVENT * slSetEventNext (evnt, func);

argument

    EVENT * evnt --Event before the event to register.
void * (func) (void) --Execution function to register.

Number of returns

    EVENT *-A pointer to an EVENT type structure that indicates the retrieved event.

function

    Takes an event and adds it to the run list so that it runs next to the specified event. At this time, the specified function is registered as an execution function.

Example

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

    ss_main () {
      EVENT * evnt;

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

caution


    The area is 128 bytes, but the first 16 bytes are used by the system.
Returns a null code if no events remain.

reference

 slInitEvent
 slSetEvent
 slGetEvent
 slCloseEvent
 slReturnEvent
 slExecuteEvent 



ListReference

function

slReturnEvent


Search for unregistered events

Form

    #include "sgl.h"

    EVENT * evnt;

    void slReturnEvent (evnt);

argument

    EVENT * evnt --A pointer to an EVENT type structure that represents the event requesting release.

Number of returns

    void --Nothing is returned.

function

    Returns an event that is not registered in the execution list to the system.

Example

    EVENT * evnt;

    evnt = slGetEvent ();
    slReturnEvent (evnt);

caution


    When this function is executed for an event registered in the execution list, it remains registered in the list and execution continues. The returned pointer is re-registered in the system buffer, but it is not checked even if it is registered at this time, so if the same pointer is returned multiple times, it will be executed after that.
    slGetEvent (), slSetEvent (), slSetEventNext ()
    Will cause a problem.

reference

 slInitEvent
 slGetEvent
 slSetEvent
 slSetEventNext
 slCloseEvent
 EventLast 



ListReference

function

slCloseEvent


Delete event

Form

    #include "sgl.h"

    EVENT * evnt;

    void slCloseEvent (evnt);

argument

    EVENT * evnt --A pointer to an EVENT type structure that represents the event to delete.

Number of returns

    void --Nothing is returned.

function

    Detach the event registered in the execution list from the list and return it to the system.
Also, if the workpieces are set, these are also returned.

Example

    EVENT * evnt;

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

caution


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

reference

 slInitEvent
 slGetEvent
 slSetEvent
 slSetEventNext
 slReturnEvent 



ListReference

function

slExecuteEvent


Event execution

Form

    #include "sgl.h"

    void slExecuteEvent (void);

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    The events registered in the execution list are executed in order from the beginning.

Example

    slInitEvent ();

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

caution


    Execute it for each main loop.

reference

 slInitEvent
 slSetEvent
 slSetEventNext
 slSynch
 slInitSynch
 EventTop
 EventNow
 EventCount 


★ Work



ListReference

function

slGetWork


Get work RAM for events

Form

    #include "sgl.h"

    WORK * slGetWork (void);

argument

    void --Do not give anything.

Number of returns

    WORK *-A pointer to a WORK structure that points to the assigned work area.

function

    Takes out the RAM area allocated for the work and returns its pointer.

Example

    WORK * work;
    EVENT * evnt;

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

caution


    The work is a 64-byte area, with the first 4 bytes as a pointer for the list.
    Used in the system. The remaining 60 bytes are freely available to the user.
If the pointer is set to WORK of the EVENT structure, it will be returned to the system when the event is closed.

reference

 slInitEvent
 slReturnWork
 WorkCount 



ListReference

function

slReturnWork


Release work RAM for events

Form

    #include "sgl.h"

    WORK * wk;

    void slReturnWork (wk);

argument

    WORK * wk-A pointer to a WORK structure that represents the work RAM to release.

Number of returns

    void --Nothing is returned.

function

    Return the RAM area used as the work to the system.

Example

    WORK * work;

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

caution


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

reference

 slInitEvent
 slGetWork
 WorkCount 


★ Global variables for events



ListReference

Global variables

EventBuf


Form

    #include "sgl.h"

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

reference

 slInitEvent
 slGetEvent
 slReturnEvent 



ListReference

Global variables

WorkBuf


Form

    #include "sgl.h"

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

reference

 slGetWork 



ListReference

Global variables

RemainEvent


Form

    #include "sgl.h"

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

reference

 slSetEvent
 slSetEventNext
 slReturnEvent
 slExecuteEvent 



ListReference

Global variables

RemainWork


Form

    #include "sgl.h"

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

reference

 slReturnWork

return
Copyright SEGA ENTERPRISES, LTD., 1997