ball/st_start.o \
ball/st_title.o \
ball/st_name.o \
+ ball/st_shared.o \
ball/main.o
PUTT_OBJS= \
share/i18n.o \
#include "game.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_conf.h"
#include "st_title.h"
gui_paint(id);
}
-static void conf_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static void conf_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void conf_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int conf_click(int b, int d)
-{
- if (b < 0 && d == 1)
- return conf_action(gui_token(gui_click()));
- return 1;
-}
-
static int conf_buttn(int b, int d)
{
if (d)
conf_enter,
conf_leave,
conf_paint,
- conf_timer,
- conf_point,
- conf_stick,
- conf_click,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
conf_buttn,
1, 0
#include "audio.h"
#include "solid.h"
#include "config.h"
+#include "st_shared.h"
#include "st_demo.h"
#include "st_title.h"
return id;
}
-static void demo_leave(int id)
-{
- gui_delete(id);
-}
-
static void demo_paint(int id, float st)
{
game_draw(0, st);
gui_paint(id);
}
-static void demo_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
static void demo_point(int id, int x, int y, int dx, int dy)
{
- int jd = gui_point(id, x, y);
+ int jd = shared_point_basic(id, x, y);
int i = gui_token(jd);
- gui_pulse(jd, 1.2f);
if (jd && i>=0)
demo_status(i);
}
static void demo_stick(int id, int a, int v)
{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int demo_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return demo_action(gui_token(gui_click()));
- return 1;
+ int jd = shared_stick_basic(id, a, v);
+ int i = gui_token(jd);
+ if (jd && i>=0)
+ demo_status(i);
}
static int demo_buttn(int b, int d)
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return demo_click(0, 1);
+ return demo_action(gui_token(gui_click()));
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
return demo_action(DEMO_BACK);
}
return id;
}
-static void demo_play_leave(int id)
-{
- gui_delete(id);
-}
-
static void demo_play_paint(int id, float st)
{
game_draw(0, st);
return id;
}
-static void demo_end_leave(int id)
-{
- gui_delete(id);
-}
-
-static void demo_end_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
static void demo_end_timer(int id, float dt)
{
float g[3] = { 0.0f, -9.8f, 0.0f };
audio_timer(dt);
}
-static void demo_end_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void demo_end_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int demo_end_click(int b, int d)
-{
- if (d && b < 0)
- return demo_end_action(gui_token(gui_click()));
- return 1;
-}
-
static int demo_end_buttn(int b, int d)
{
if (d)
return id;
}
-static void demo_del_leave(int id)
-{
- gui_delete(id);
-}
-
-static void demo_del_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
-static void demo_del_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static void demo_del_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void demo_del_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int demo_del_click(int b, int d)
-{
- if (d && b < 0)
- return demo_del_action(gui_token(gui_click()));
- return 1;
-}
-
static int demo_del_buttn(int b, int d)
{
if (d)
struct state st_demo = {
demo_enter,
- demo_leave,
+ shared_leave,
demo_paint,
- demo_timer,
+ shared_timer,
demo_point,
demo_stick,
- demo_click,
+ shared_click,
NULL,
demo_buttn,
0
struct state st_demo_play = {
demo_play_enter,
- demo_play_leave,
+ shared_leave,
demo_play_paint,
demo_play_timer,
NULL,
struct state st_demo_end = {
demo_end_enter,
- demo_end_leave,
- demo_end_paint,
+ shared_leave,
+ shared_paint,
demo_end_timer,
- demo_end_point,
- demo_end_stick,
- demo_end_click,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
demo_end_buttn,
1, 0
struct state st_demo_del = {
demo_del_enter,
- demo_del_leave,
- demo_del_paint,
- demo_del_timer,
- demo_del_point,
- demo_del_stick,
- demo_del_click,
+ shared_leave,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
demo_del_buttn,
1, 0
#include "level.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_done.h"
#include "st_start.h"
return done_init(NULL);
}
-static void done_leave(int id)
-{
- gui_delete(id);
-}
-
-static void done_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
-static void done_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static void done_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void done_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int done_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return done_action(gui_token(gui_click()));
- return 1;
-}
-
static int done_buttn(int b, int d)
{
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return done_click(0, 1);
+ return done_action(gui_token(gui_click()));
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
return done_action(DONE_OK);
}
struct state st_done = {
done_enter,
- done_leave,
- done_paint,
- done_timer,
- done_point,
- done_stick,
- done_click,
+ shared_leave,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
done_buttn,
1, 0
struct state st_done_bis = {
done_bis_enter,
- done_leave,
- done_paint,
- done_timer,
- done_point,
- done_stick,
- done_click,
+ shared_leave,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
done_buttn,
1, 0
#include "level.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_fail.h"
#include "st_over.h"
return 1;
}
+static int fail_buttn(int b, int d)
+{
+ if (d)
+ {
+ if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
+ return fail_action(gui_token(gui_click()));
+ if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
+ return fail_action(FAIL_BACK);
+ }
+ return 1;
+}
+
static int fall_out_enter(void)
{
int id, jd, kd;
return id;
}
-static void fall_out_leave(int id)
-{
- gui_delete(id);
-}
-
-static void fall_out_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
-static void fall_out_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void fall_out_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int fall_out_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return fail_action(gui_token(gui_click()));
- return 1;
-}
-
static void fall_out_timer(int id, float dt)
{
float g[3] = { 0.0f, -9.8f, 0.0f };
audio_timer(dt);
}
-static int fall_out_buttn(int b, int d)
-{
- if (d)
- {
- if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return fall_out_click(0, 1);
- if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
- return fail_action(FAIL_BACK);
- }
- return 1;
-}
/*---------------------------------------------------------------------------*/
return id;
}
-static void time_out_leave(int id)
-{
- gui_delete(id);
-}
-
-static void time_out_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
-static void time_out_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void time_out_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int time_out_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return fail_action(gui_token(gui_click()));
- return 1;
-}
-
-static void time_out_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static int time_out_buttn(int b, int d)
-{
- if (d)
- {
- if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return time_out_click(0, 1);
- if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
- return fail_action(FAIL_BACK);
- }
- return 1;
-}
-
/*---------------------------------------------------------------------------*/
struct state st_fall_out = {
fall_out_enter,
- fall_out_leave,
- fall_out_paint,
+ shared_leave,
+ shared_paint,
fall_out_timer,
- fall_out_point,
- fall_out_stick,
- fall_out_click,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
- fall_out_buttn,
+ fail_buttn,
1, 0
};
struct state st_time_out = {
time_out_enter,
- time_out_leave,
- time_out_paint,
- time_out_timer,
- time_out_point,
- time_out_stick,
- time_out_click,
+ shared_leave,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
- time_out_buttn,
+ fail_buttn,
1, 0
};
#include "audio.h"
#include "config.h"
#include "demo.h"
+#include "st_shared.h"
#include "st_goal.h"
#include "st_save.h"
return goal_init(NULL);
}
-static void goal_leave(int id)
-{
- gui_delete(id);
-}
-
-static void goal_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
static void goal_timer(int id, float dt)
{
static float DT = 0.0f;
audio_timer(dt);
}
-static void goal_bis_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static void goal_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void goal_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int goal_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return goal_action(gui_token(gui_click()));
- return 1;
-}
-
static int goal_buttn(int b, int d)
{
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return goal_click(0, 1);
+ return goal_action(gui_token(gui_click()));
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
goal_action(GOAL_BACK);
}
struct state st_goal = {
goal_enter,
- goal_leave,
- goal_paint,
+ shared_leave,
+ shared_paint,
goal_timer,
- goal_point,
- goal_stick,
- goal_click,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
goal_buttn,
1, 0
struct state st_goal_bis = {
goal_bis_enter,
- goal_leave,
- goal_paint,
- goal_bis_timer,
- goal_point,
- goal_stick,
- goal_click,
+ shared_leave,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
goal_buttn,
1, 0
#include "level.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_level.h"
#include "st_play.h"
return id;
}
-static void level_leave(int id)
-{
- gui_delete(id);
-}
-
static void level_timer(int id, float dt)
{
game_step_fade(dt);
audio_timer(dt);
}
-static void level_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
static int level_click(int b, int d)
{
return (b < 0 && d == 1) ? goto_state(&st_play_ready) : 1;
struct state st_level = {
level_enter,
- level_leave,
- level_paint,
+ shared_leave,
+ shared_paint,
level_timer,
NULL,
NULL,
#include "audio.h"
#include "config.h"
#include "game.h"
+#include "st_shared.h"
#include "st_name.h"
gui_delete(id);
}
-static void name_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
-static void name_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static void name_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void name_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int name_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return name_action(gui_token(gui_click()));
- return 1;
-}
-
static int name_keybd(int c, int d)
{
if (d)
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return name_click(0, 1);
+ return name_action(gui_token(gui_click()));
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
name_action(NAME_BACK);
}
struct state st_name = {
name_enter,
name_leave,
- name_paint,
- name_timer,
- name_point,
- name_stick,
- name_click,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
name_keybd,
name_buttn,
1, 0
#include "audio.h"
#include "config.h"
#include "demo.h"
+#include "st_shared.h"
#include "st_over.h"
#include "st_start.h"
return id;
}
-static void over_leave(int id)
-{
- gui_delete(id);
-}
-
-static void over_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
static void over_timer(int id, float dt)
{
if (dt > 0.f && time_state() > 3.f)
struct state st_over = {
over_enter,
- over_leave,
- over_paint,
+ shared_leave,
+ shared_paint,
over_timer,
NULL,
NULL,
#include "level.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_play.h"
#include "st_fail.h"
return id;
}
-static void play_ready_leave(int id)
-{
- gui_delete(id);
-}
-
-static void play_ready_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
static void play_ready_timer(int id, float dt)
{
float t = time_state();
return id;
}
-static void play_set_leave(int id)
-{
- gui_delete(id);
-}
-
-static void play_set_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
static void play_set_timer(int id, float dt)
{
float t = time_state();
return id;
}
-static void play_loop_leave(int id)
-{
- gui_delete(id);
-}
-
static void play_loop_paint(int id, float st)
{
game_draw(0, st);
struct state st_play_ready = {
play_ready_enter,
- play_ready_leave,
- play_ready_paint,
+ shared_leave,
+ shared_paint,
play_ready_timer,
NULL,
NULL,
struct state st_play_set = {
play_set_enter,
- play_set_leave,
- play_set_paint,
+ shared_leave,
+ shared_paint,
play_set_timer,
NULL,
NULL,
struct state st_play_loop = {
play_loop_enter,
- play_loop_leave,
+ shared_leave,
play_loop_paint,
play_loop_timer,
play_loop_point,
#include "audio.h"
#include "config.h"
#include "demo.h"
+#include "st_shared.h"
#include "st_save.h"
#define SAVE_SAVE 2
#define SAVE_CANCEL 3
-static int file_id;
+static int file_id;
static int save_action(int i)
{
gui_delete(id);
}
-static void save_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
-static void save_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static void save_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void save_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int save_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return save_action(gui_token(gui_click()));
- return 1;
-}
-
static int save_keybd(int c, int d)
{
if (d)
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return save_click(0, 1);
+ return save_action(gui_token(gui_click()));
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
return save_action(SAVE_CANCEL);
}
return id;
}
-static void clobber_leave(int id)
-{
- gui_delete(id);
-}
-
-static void clobber_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
-static void clobber_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-static void clobber_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void clobber_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int clobber_click(int b, int d)
-{
- if (d && b < 0)
- return clobber_action(gui_token(gui_click()));
- return 1;
-}
-
static int clobber_buttn(int b, int d)
{
if (d)
struct state st_save = {
save_enter,
save_leave,
- save_paint,
- save_timer,
- save_point,
- save_stick,
- save_click,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
save_keybd,
save_buttn,
1, 0
struct state st_clobber = {
clobber_enter,
- clobber_leave,
- clobber_paint,
- clobber_timer,
- clobber_point,
- clobber_stick,
- clobber_click,
+ shared_leave,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_click,
NULL,
clobber_buttn,
1, 0
#include "game.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_set.h"
#include "st_title.h"
return id;
}
-static void set_leave(int id)
-{
- gui_delete(id);
-}
-
static void set_paint(int id, float st)
{
game_draw(0, st);
gui_paint(id);
}
-static void set_timer(int id, float dt)
+static void set_over(int i)
{
- gui_timer(id, dt);
- audio_timer(dt);
+ gui_set_image(shot_id, set_shot(i));
+ gui_set_multi(desc_id, _(set_desc(i)));
}
static void set_point(int id, int x, int y, int dx, int dy)
{
- int jd;
-
- if ((jd = gui_point(id, x, y)))
- {
- int i = gui_token(jd);
-
- if (set_exists(i))
- {
- gui_set_image(shot_id, set_shot(i));
- gui_set_multi(desc_id, _(set_desc(i)));
- gui_pulse(jd, 1.2f);
- }
- }
+ int jd = shared_point_basic(id, x, y);
+ int i = gui_token(jd);
+ if (jd && set_exists(i))
+ set_over(i);
}
static void set_stick(int id, int a, int v)
{
- int jd;
-
- int x = (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a)) ? v : 0;
- int y = (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a)) ? v : 0;
-
- if ((jd = gui_stick(id, x, y)))
- {
- int i = gui_token(jd);
-
- if (set_exists(i))
- {
- gui_set_image(shot_id, set_shot(i));
- gui_set_multi(desc_id, _(set_desc(i)));
- gui_pulse(jd, 1.2f);
- }
- }
-}
-
-static int set_click(int b, int d)
-{
- return (b < 0 && d == 1) ? set_action(gui_token(gui_click())) : 1;
+ int jd = shared_stick_basic(id, a, v);
+ int i = gui_token(jd);
+ if (jd && set_exists(i))
+ set_over(i);
}
static int set_buttn(int b, int d)
struct state st_set = {
set_enter,
- set_leave,
+ shared_leave,
set_paint,
- set_timer,
+ shared_timer,
set_point,
set_stick,
- set_click,
+ shared_click,
NULL,
set_buttn,
1, 0
--- /dev/null
+#include "gui.h"
+#include "config.h"
+#include "audio.h"
+#include "game.h"
+#include "state.h"
+
+#include "st_shared.h"
+
+void shared_leave(int id)
+{
+ gui_delete(id);
+}
+
+void shared_paint(int id, float st)
+{
+ game_draw(0, st);
+ gui_paint(id);
+}
+
+void shared_timer(int id, float dt)
+{
+ gui_timer(id, dt);
+ audio_timer(dt);
+}
+
+int shared_point_basic(int id, int x, int y)
+/* Pulse, activate and return the active id (if changed)*/
+{
+ int jd = gui_point(id, x, y);
+ if (jd)
+ gui_pulse(jd, 1.2f);
+ return jd;
+}
+
+void shared_point(int id, int x, int y, int dx, int dy)
+{
+ shared_point_basic(id, x, y);
+}
+
+int shared_stick_basic(int id, int a, int v)
+/* Pulse, activate and return the active id (if changed)*/
+{
+ int jd = 0;
+ if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
+ jd = gui_stick(id, v, 0);
+ else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
+ jd = gui_stick(id, 0, v);
+ if (jd)
+ gui_pulse(jd, 1.2f);
+ return jd;
+}
+
+void shared_stick(int id, int a, int v)
+{
+ shared_stick_basic(id, a, v);
+}
+
+int shared_click(int b, int d)
+{
+ if (b < 0 && d == 1)
+ return st_buttn(config_get_d(CONFIG_JOYSTICK_BUTTON_A), 1);
+ else
+ return 1;
+}
+
--- /dev/null
+#ifndef ST_SHARED_H
+#define ST_SHARED_H
+
+void shared_leave(int id);
+void shared_paint(int id, float st);
+void shared_timer(int id, float dt);
+int shared_point_basic(int id, int x, int y);
+void shared_point(int id, int x, int y, int dx, int dy);
+int shared_stick_basic(int id, int a, int v);
+void shared_stick(int id, int a, int v);
+int shared_click(int b, int d);
+
+
+#endif /* ST_SHARED_H */
#include "level.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_set.h"
#include "st_over.h"
return id;
}
-static void start_leave(int id)
-{
- gui_delete(id);
-}
-
static void start_paint(int id, float st)
{
game_draw(0, st);
gui_paint(id);
}
-static void start_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
-
static void start_point(int id, int x, int y, int dx, int dy)
{
start_over(gui_point(id, x, y));
start_over(gui_stick(id, x, y));
}
-static int start_click(int b, int d)
-{
- if (d && b < 0)
- return start_action(gui_token(gui_click()));
- return 1;
-}
-
static int start_keybd(int c, int d)
{
if (d && c == SDLK_c && config_get_d(CONFIG_CHEAT))
struct state st_start = {
start_enter,
- start_leave,
+ shared_leave,
start_paint,
- start_timer,
+ shared_timer,
start_point,
start_stick,
- start_click,
+ shared_click,
start_keybd,
start_buttn,
1, 0
#include "game.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_title.h"
#include "st_demo.h"
gui_delete(id);
}
-static void title_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
-
static void title_timer(int id, float dt)
{
static const char *demo = NULL;
game_step_fade(dt);
}
-static void title_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
-}
-
-static void title_stick(int id, int a, int v)
-{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
-
-static int title_click(int b, int d)
-{
- if (d && b < 0)
- return title_action(gui_token(gui_click()));
- return 1;
-}
-
static int title_keybd(int c, int d)
{
if (d && c == SDLK_c && ALLOW_CHEAT)
return id;
}
-static void help_leave(int id)
-{
- gui_delete(id);
-}
-
static void help_paint(int id, float st)
{
game_draw(0, st);
gui_paint(id);
}
-static void help_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
-
static int help_click(int b, int d)
{
return d ? goto_state(&st_title) : 1;
struct state st_title = {
title_enter,
title_leave,
- title_paint,
+ shared_paint,
title_timer,
- title_point,
- title_stick,
- title_click,
+ shared_point,
+ shared_stick,
+ shared_click,
title_keybd,
title_buttn,
1, 0
struct state st_help = {
help_enter,
- help_leave,
+ shared_leave,
help_paint,
- help_timer,
+ shared_timer,
NULL,
NULL,
help_click,