#include "sgl.h"
void slInitEvent (void);
void --Do not give anything.
void --Nothing is returned.
Initialize the buffer for event and work management. 64 events,
256 works are prepared.
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 * /
}
Since the RAM itself for events and work is not initialized, when the area is taken out,
Please initialize the user program.
slGetEvent | slSetEvent | slSetEventNext | slCloseEvent |
slReturnEvent | slExecuteEvent | slGetWork | slReturnWork |
#include "sgl.h"
EVENT * slGetEvent (void);
void --Do not give anything.
EVENT * --A pointer to the acquired RAM address for the event.
Fetches the RAM area allocated for the event and returns a pointer to it.
void func () {
/ * This is executed in event loop. * /
}
EVENT * evnt1, * evnt2;
evnt1 = slGetEvent ();
evnt2 = slSetEvent (func);
evnt2-> user = ( Uint8 *) evnt1;
The 128-byte area is free for users. 64 pieces are prepared,
Returns a null code if it is used up.
slInitEvent | slSetEvent | slSetEventNext | slCloseEvent |
slReturnEvent | EventTop | EventCount |
#include "sgl.h"
void * (func) (void);
EVENT * slSetEvent (func);
void * (func) (void) --Execution function to register in the event.
EVENT * --EVENT type pointer to the acquired event.
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.
slInitEvent ();
slSetEvent (user_func1);
slSetEvent (user_func2);
::
while (-1) {
::
slExecuteEvent ();
slSynch ();
}
The area is 128 bytes, but the first 16 bytes are used by the system.
Returns a null code if no events remain.
slInitEvent | slSetEvent | slSetEventNext | slCloseEvent |
slReturnEvent | slExecuteEvent |
#include "sgl.h"
EVENT * evnt;
void * (func) (void);
EVENT * slSetEventNext (evnt, func);
EVENT * evnt --Event before the event to register.
void * (func) (void) --Execution function to register.
EVENT *-A pointer to an EVENT type structure that indicates the retrieved event.
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.
void func () {
/ * This is executed in event loop. * /
}
ss_main () {
EVENT * evnt;
evnt = slGetEvent ();
evnt-> work = ...
::
slSetEventNext (evnt, func);
::
The area is 128 bytes, but the first 16 bytes are used by the system.
Returns a null code if no events remain.
slInitEvent | slSetEvent | slGetEvent | slCloseEvent |
slReturnEvent | slExecuteEvent |
#include "sgl.h"
EVENT * evnt;
void slReturnEvent (evnt);
EVENT * evnt --A pointer to an EVENT type structure that represents the event requesting release.
void --Nothing is returned.
Returns an event that is not registered in the execution list to the system.
EVENT * evnt;
evnt = slGetEvent ();
slReturnEvent (evnt);
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.
slInitEvent | slGetEvent | slSetEvent | slSetEventNext |
slCloseEvent | EventLast |
#include "sgl.h"
EVENT * evnt;
void slCloseEvent (evnt);
EVENT * evnt --A pointer to an EVENT type structure that represents the event to delete.
void --Nothing is returned.
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.
EVENT * evnt;
evnt = slSetEvent (user_func);
::
slCloseEvent (evnt);
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.
slInitEvent | slGetEvent | slSetEvent | slSetEventNext |
slReturnEvent |
#include "sgl.h"
void slExecuteEvent (void);
void --Do not give anything.
void --Nothing is returned.
The events registered in the execution list are executed in order from the beginning.
slInitEvent ();
slSetEvent (...);
::
while (-1) {
slExecuteEvent ();
slSynch ();
}
Execute it for each main loop.
slInitEvent | slSetEvent | slSetEventNext | slSynch |
slInitSynch | EventTop | EventNow | EventCount |
#include "sgl.h"
WORK * slGetWork (void);
void --Do not give anything.
WORK *-A pointer to a WORK structure that points to the assigned work area.
Takes out the RAM area allocated for the work and returns its pointer.
WORK * work;
EVENT * evnt;
work = slGetWork ();
evnt = slSetEvent ();
evnt-> work = work;
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.
slInitEvent | slReturnWork | WorkCount |
#include "sgl.h"
WORK * wk;
void slReturnWork (wk);
WORK * wk-A pointer to a WORK structure that represents the work RAM to release.
void --Nothing is returned.
Return the RAM area used as the work to the system.
WORK * work;
work = slGetWork ();
::
slReturnWork (work);
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. ..
slInitEvent | slGetWork | WorkCount |
#include "sgl.h"
extern EVENT EventBuf []; / * buffer for Event use * /
slInitEvent | slGetEvent | slReturnEvent |
#include "sgl.h"
extern WORK WorkBuf []; / * buffer for Work use * /
slGetWork |
#include "sgl.h"
extern EVENT * RemainEvent []; / * Remain Event address buffer * /
slSetEvent | slSetEventNext | slReturnEvent | slExecuteEvent |
#include "sgl.h"
extern WORK * RemainWork []; / * Remain Work address buffer * /
slReturnWork |