Author Topic: [v2.0]EventLibrary(ELIB) + musicdemo sample  (Read 9811 times)

0 Members and 1 Guest are viewing this topic.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: EventLibrary(ELIB) + musicdemo sample
« Reply #15 on: December 03, 2009, 12:15:08 AM »
An update ->

Effect system for signal-events is finished.Supported types ->

ELF_FOCUS : Will call the function included in Effect until ELF_UNFOCUS is returned.
The structure also supports a sync function for rendering/updates.

ELF_DELAY:
After the execution the system will cause global delay using the configuration of the Effect structure

ELF_TIMED:
Will be executed only if the configured time of the effect is smaller than the current time.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: [v2.0]EventLibrary(ELIB) + musicdemo sample
« Reply #16 on: December 07, 2009, 12:49:14 AM »
V2 is now available  ^-^

Downloads & more info ->
http://www.neoflash.com/forum/index.php/topic,5839.0.html

Elib features ->
-Open source
-Does not uses any library at all(it's super portable!)
-Does not use function stacks
-Supports effects
-All important code is inlined using macros
-Static function allocator
-Stack based execution of commands
-No sorting or pointless data copying at runtime
-Can be used with platforms with limited hardware
-Supports debug handlers
-Configurable stacks
-Execution sync timer
-Supports custom handlers for input listener/host and timer
-Does not allocate/copy buffers  at runtime.
-Can convert values to proper message handlers
-Supports # amount of arguments per cycle ( # = defined in header )
-Supports # amount of total events per cycle ( # = can be changed at runtime )
-The code is efficient and will not cause trouble to an existing project
-Efficient message system and even listener that gives you full control of the events
-Uses index ids for direct access to objects
-Fixed loops to active object's range
« Last Edit: December 07, 2009, 12:55:09 AM by Conle »

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: [v2.0]EventLibrary(ELIB) + musicdemo sample
« Reply #17 on: December 07, 2009, 12:53:41 AM »
Here is a very quick example of how it can be used ->

Code: [Select]
/*
Minimal ELIB example
*/

#include "../elib/elib.h"
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>

static struct timeval timerStart;
static struct timeval timerNow;
static ELIB_Configuration config;

enum
{
MY_RUN_COMMAND_ID = 255,
MY_MSG_ID
};

static ELIB_Ptr getTimeMethod()
{
gettimeofday(&timerNow, NULL);
config.Runtime.SystemTicks = (timerNow.tv_sec-timerStart.tv_sec)*1000+(timerNow.tv_usec-timerStart.tv_usec)/1000;
}

static ELIB_Ptr eventHandler()
{
if(!config.Runtime.BindedEvent)
return;

config.Runtime.Result = ELR_POSITIVE;

switch(config.Runtime.BindedEvent->type)
{
default:
return;

case ELD_MESSAGE:
{
switch(config.Runtime.BindedEvent->callback.message)
{
case MY_MSG_ID:
printf("My message proccessed!\n");
return;
}
return;
}

case ELD_INPUT_EVENT:
{
/*Since keys are only executing specific events , we dont need to push keys!*/
/*if(event->key.state == ELK_PRESSED)
{
switch(config.Runtime.BindedEvent->key.code)
{
case ...
}
}*/
config.Runtime.Result = ELR_POSITIVE;
return;
}
}

config.Runtime.Result = ELR_NEGATIVE;
}

static ELIB_Ptr run()
{
printf("Running...\n");

/*spam!*/
ELIB_PushMessage(config,MY_MSG_ID);

/*Return positive result*/
config.Runtime.Result = ELR_POSITIVE;
}

int main(int argc, char **argv)
{
config.Public.maxIterationsPerCycle = 8;
config.Public.keyRepeat = 0;
config.Public.messageRepeat = 0;
config.Public.cycleSyncTime = 60;

config.Public.eventCallback = eventHandler;
config.Public.timerCallback = getTimeMethod;
//config.Public.debugCallback = ELIB_NULL;

ELIB_Init(&config);

        //Push exlusive to the static function rellocator
ELIB_PushExclusive(config,MY_RUN_COMMAND_ID,run,NULL,NULL);

ELIB_Run();

return 0;
}