From 745d5a072d8669d1bc35e7c1f28b75b3484542e8 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 30 Mar 2016 20:29:08 +0200 Subject: Finish ITC; implement async sim control. --- src/common.h | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'src/common.h') diff --git a/src/common.h b/src/common.h index ee9c3fe..1b8e719 100644 --- a/src/common.h +++ b/src/common.h @@ -149,6 +149,28 @@ static inline void mst2_dump(mst2_t M) printf("[%f\t%f\t%f]\n", 0.0, 0.0, 1.0); } +// itc + +typedef struct itc_message_s itc_message; +struct itc_message_s { + int number; + void *data; + + itc_message *older, *newer; +}; + +typedef struct { + itc_message *newest, *oldest; + SDL_mutex *mutex; + SDL_sem *sem; +} itc_chan; + +void itc_chan_create(itc_chan *chan); +void itc_chan_destroy(itc_chan *chan); +void itc_chan_push(itc_chan *chan, int number, void *data); +int itc_chan_pop(itc_chan *chan, int *number, void **data); +int itc_chan_pop_block(itc_chan *chan, int *number, void **data); + // physics typedef struct { @@ -164,12 +186,12 @@ typedef struct { float *H; } phy_field_em; -/* -typedef struct { - int num; - void *data; -} phy_command; -*/ +enum { + PHY_CMD_QUIT, + PHY_CMD_PAUSE, + PHY_CMD_RESUME, + PHY_CMD_STEP +}; typedef struct { phy_field_info field_info; @@ -177,6 +199,9 @@ typedef struct { float *field_eps, *field_mu; //permittivity and permeability float time; + // UI stuff + bool running; + itc_chan ctl; SDL_mutex *rotate_lock; } phy_sim; @@ -253,4 +278,3 @@ void ui_renderer_window_register(r_window *rw); void ui_event(SDL_Event *event); void ui_draw(phy_sim *sim); - -- cgit