2 * Copyright (C) 2003 Robert Kooima
4 * NEVERPUTT is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
32 /*---------------------------------------------------------------------------*/
34 static SDL_Joystick *joystick = NULL;
36 void set_joystick(SDL_Joystick *j)
41 /*---------------------------------------------------------------------------*/
43 static char *number(int i)
45 static char str[MAXSTR];
47 sprintf(str, "%02d", i);
52 static int score_card(const char *title,
58 int p1 = (curr_party() >= 1) ? 1 : 0, l1 = (curr_party() == 1) ? 1 : 0;
59 int p2 = (curr_party() >= 2) ? 1 : 0, l2 = (curr_party() == 2) ? 1 : 0;
60 int p3 = (curr_party() >= 3) ? 1 : 0, l3 = (curr_party() == 3) ? 1 : 0;
61 int p4 = (curr_party() >= 4) ? 1 : 0, l4 = (curr_party() == 4) ? 1 : 0;
64 int n = curr_count() - 1;
65 int m = curr_count() / 2;
67 if ((id = gui_vstack(0)))
69 gui_label(id, title, GUI_MED, GUI_ALL, c0, c1);
72 if ((jd = gui_hstack(id)))
74 if ((kd = gui_varray(jd)))
76 if (p1) gui_label(kd, _("O"), 0, GUI_NE, 0, 0);
77 if (p1) gui_label(kd, hole_out(0), 0, 0, gui_wht, gui_wht);
78 if (p1) gui_label(kd, hole_out(1), 0, GUI_SE * l1, gui_red, gui_wht);
79 if (p2) gui_label(kd, hole_out(2), 0, GUI_SE * l2, gui_grn, gui_wht);
80 if (p3) gui_label(kd, hole_out(3), 0, GUI_SE * l3, gui_blu, gui_wht);
81 if (p4) gui_label(kd, hole_out(4), 0, GUI_SE * l4, gui_yel, gui_wht);
84 if ((kd = gui_harray(jd)))
85 for (i = m; i > 0; i--)
86 if ((ld = gui_varray(kd)))
88 if (p1) gui_label(ld, number(i), 0, (i == 1) ? GUI_NW : 0, 0, 0);
89 if (p1) gui_label(ld, hole_score(i, 0), 0, 0, gui_wht, gui_wht);
90 if (p1) gui_label(ld, hole_score(i, 1), 0, 0, gui_red, gui_wht);
91 if (p2) gui_label(ld, hole_score(i, 2), 0, 0, gui_grn, gui_wht);
92 if (p3) gui_label(ld, hole_score(i, 3), 0, 0, gui_blu, gui_wht);
93 if (p4) gui_label(ld, hole_score(i, 4), 0, 0, gui_yel, gui_wht);
95 if ((kd = gui_varray(jd)))
98 if (p1) gui_label(kd, _("Par"), 0, GUI_NW, gui_wht, gui_wht);
99 if (p1) gui_label(kd, _("P1"), 0, GUI_SW * l1, gui_red, gui_wht);
100 if (p2) gui_label(kd, _("P2"), 0, GUI_SW * l2, gui_grn, gui_wht);
101 if (p3) gui_label(kd, _("P3"), 0, GUI_SW * l3, gui_blu, gui_wht);
102 if (p4) gui_label(kd, _("P4"), 0, GUI_SW * l4, gui_yel, gui_wht);
108 if ((jd = gui_hstack(id)))
110 if ((kd = gui_varray(jd)))
112 if (p1) gui_label(kd, _("Tot"), 0, GUI_TOP, 0, 0);
113 if (p1) gui_label(kd, hole_tot(0), 0, 0, gui_wht, gui_wht);
114 if (p1) gui_label(kd, hole_tot(1), 0, GUI_BOT * l1, gui_red, gui_wht);
115 if (p2) gui_label(kd, hole_tot(2), 0, GUI_BOT * l2, gui_grn, gui_wht);
116 if (p3) gui_label(kd, hole_tot(3), 0, GUI_BOT * l3, gui_blu, gui_wht);
117 if (p4) gui_label(kd, hole_tot(4), 0, GUI_BOT * l4, gui_yel, gui_wht);
119 if ((kd = gui_varray(jd)))
121 if (p1) gui_label(kd, _("I"), 0, GUI_NE, 0, 0);
122 if (p1) gui_label(kd, hole_in(0), 0, 0, gui_wht, gui_wht);
123 if (p1) gui_label(kd, hole_in(1), 0, GUI_SE * l1, gui_red, gui_wht);
124 if (p2) gui_label(kd, hole_in(2), 0, GUI_SE * l2, gui_grn, gui_wht);
125 if (p3) gui_label(kd, hole_in(3), 0, GUI_SE * l3, gui_blu, gui_wht);
126 if (p4) gui_label(kd, hole_in(4), 0, GUI_SE * l4, gui_yel, gui_wht);
128 if ((kd = gui_harray(jd)))
129 for (i = n; i > m; i--)
130 if ((ld = gui_varray(kd)))
132 if (p1) gui_label(ld, number(i), 0, (i == m+1) ? GUI_NW : 0, 0, 0);
133 if (p1) gui_label(ld, hole_score(i, 0), 0, 0, gui_wht, gui_wht);
134 if (p1) gui_label(ld, hole_score(i, 1), 0, 0, gui_red, gui_wht);
135 if (p2) gui_label(ld, hole_score(i, 2), 0, 0, gui_grn, gui_wht);
136 if (p3) gui_label(ld, hole_score(i, 3), 0, 0, gui_blu, gui_wht);
137 if (p4) gui_label(ld, hole_score(i, 4), 0, 0, gui_yel, gui_wht);
139 if ((kd = gui_varray(jd)))
142 if (p1) gui_label(kd, _("Par"), 0, GUI_NW, gui_wht, gui_wht);
143 if (p1) gui_label(kd, _("P1"), 0, GUI_SW * l1, gui_red, gui_wht);
144 if (p2) gui_label(kd, _("P2"), 0, GUI_SW * l2, gui_grn, gui_wht);
145 if (p3) gui_label(kd, _("P3"), 0, GUI_SW * l3, gui_blu, gui_wht);
146 if (p4) gui_label(kd, _("P4"), 0, GUI_SW * l4, gui_yel, gui_wht);
150 gui_layout(id, 0, 0);
156 /*---------------------------------------------------------------------------*/
158 static int shared_stick_basic(int id, int a, float v, int bump)
162 if ((jd = gui_stick(id, a, v, bump)))
168 static void shared_stick(int id, int a, float v, int bump)
170 shared_stick_basic(id, a, v, bump);
173 /*---------------------------------------------------------------------------*/
179 static int title_action(int i)
181 audio_play(AUD_MENU, 1.0f);
185 case TITLE_PLAY: return goto_state(&st_course);
186 case TITLE_CONF: return goto_state(&st_conf);
187 case TITLE_EXIT: return 0;
192 static int title_enter(struct state *st, struct state *prev)
196 /* Build the title GUI. */
198 if ((id = gui_vstack(0)))
200 gui_label(id, "Neverputt", GUI_LRG, GUI_ALL, 0, 0);
203 if ((jd = gui_harray(id)))
207 if ((kd = gui_varray(jd)))
209 gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1);
210 gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0);
211 gui_state(kd, sgettext("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
216 gui_layout(id, 0, 0);
225 static void title_leave(struct state *st, struct state *next, int id)
230 static void title_paint(int id, float t)
236 static void title_timer(int id, float dt)
238 float g[3] = { 0.f, 0.f, 0.f };
241 game_set_fly(fcosf(time_state() / 10.f));
246 static void title_point(int id, int x, int y, int dx, int dy)
248 gui_pulse(gui_point(id, x, y), 1.2f);
251 static int title_click(int b, int d)
253 return d && b == SDL_BUTTON_LEFT ? title_action(gui_token(gui_click())) : 1;
256 static int title_buttn(int b, int d)
260 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
261 return title_action(gui_token(gui_click()));
262 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
263 return title_action(TITLE_EXIT);
268 /*---------------------------------------------------------------------------*/
273 #define COURSE_BACK -1
275 static int course_action(int i)
277 if (course_exists(i))
280 goto_state(&st_party);
282 if (i == COURSE_BACK)
283 goto_state(&st_title);
288 static int comp_size(int n, int s)
290 return n <= s * s ? s : comp_size(n, s + 1);
293 static int comp_cols(int n)
295 return comp_size(n, 1);
298 static int comp_rows(int n)
300 int s = comp_size(n, 1);
302 return n <= s * (s - 1) ? s - 1 : s;
305 static int course_enter(struct state *st, struct state *prev)
307 int w = config_get_d(CONFIG_WIDTH);
308 int h = config_get_d(CONFIG_HEIGHT);
310 int id, jd, kd, ld, md;
319 if ((id = gui_vstack(0)))
321 gui_label(id, _("Select Course"), GUI_MED, GUI_ALL, 0, 0);
324 if ((jd = gui_hstack(id)))
326 shot_id = gui_image(jd, course_shot(0), w / 3, h / 3);
330 if ((kd = gui_varray(jd)))
332 for(i = 0; i < r; i++)
334 if ((ld = gui_harray(kd)))
336 for (j = c - 1; j >= 0; j--)
342 md = gui_image(ld, course_shot(k),
343 w / 3 / c, h / 3 / r);
344 gui_active(md, k, 0);
358 desc_id = gui_multi(id, _(course_desc(0)), GUI_SML, GUI_ALL, gui_yel, gui_wht);
361 if ((jd = gui_hstack(id)))
364 gui_state(jd, _("Back"), GUI_SML, COURSE_BACK, 0);
367 gui_layout(id, 0, 0);
370 audio_music_fade_to(0.5f, "bgm/inter.ogg");
375 static void course_leave(struct state *st, struct state *next, int id)
380 static void course_paint(int id, float t)
386 static void course_timer(int id, float dt)
391 static void course_point(int id, int x, int y, int dx, int dy)
395 if ((jd = gui_point(id, x, y)))
397 int i = gui_token(jd);
399 if (course_exists(i))
401 gui_set_image(shot_id, course_shot(i));
402 gui_set_multi(desc_id, _(course_desc(i)));
408 static void course_stick(int id, int a, float v, int bump)
412 if ((jd = shared_stick_basic(id, a, v, bump)))
414 int i = gui_token(jd);
416 if (course_exists(i))
418 gui_set_image(shot_id, course_shot(i));
419 gui_set_multi(desc_id, _(course_desc(i)));
425 static int course_click(int b, int d)
427 return d && b == SDL_BUTTON_LEFT ? course_action(gui_token(gui_click())) : 1;
430 static int course_buttn(int b, int d)
434 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
435 return course_action(gui_token(gui_click()));
436 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
437 return course_action(COURSE_BACK);
442 /*---------------------------------------------------------------------------*/
451 static int party_action(int i)
456 audio_play(AUD_MENU, 1.f);
458 goto_state(&st_next);
461 audio_play(AUD_MENU, 1.f);
463 goto_state(&st_next);
466 audio_play(AUD_MENU, 1.f);
468 goto_state(&st_next);
471 audio_play(AUD_MENU, 1.f);
473 goto_state(&st_next);
476 audio_play(AUD_MENU, 1.f);
477 goto_state(&st_course);
483 static int party_enter(struct state *st, struct state *prev)
487 if ((id = gui_vstack(0)))
489 gui_label(id, _("Players?"), GUI_MED, GUI_ALL, 0, 0);
492 if ((jd = gui_harray(id)))
494 int p4 = gui_state(jd, "4", GUI_LRG, PARTY_4, 0);
495 int p3 = gui_state(jd, "3", GUI_LRG, PARTY_3, 0);
496 int p2 = gui_state(jd, "2", GUI_LRG, PARTY_2, 0);
497 int p1 = gui_state(jd, "1", GUI_LRG, PARTY_1, 0);
499 gui_set_color(p1, gui_red, gui_wht);
500 gui_set_color(p2, gui_grn, gui_wht);
501 gui_set_color(p3, gui_blu, gui_wht);
502 gui_set_color(p4, gui_yel, gui_wht);
509 if ((jd = gui_hstack(id)))
512 gui_state(jd, _("Back"), GUI_SML, PARTY_B, 0);
515 gui_layout(id, 0, 0);
521 static void party_leave(struct state *st, struct state *next, int id)
526 static void party_paint(int id, float t)
532 static void party_timer(int id, float dt)
537 static void party_point(int id, int x, int y, int dx, int dy)
539 gui_pulse(gui_point(id, x, y), 1.2f);
542 static int party_click(int b, int d)
544 return d && b == SDL_BUTTON_LEFT ? party_action(gui_token(gui_click())) : 1;
547 static int party_buttn(int b, int d)
551 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
552 return party_action(gui_token(gui_click()));
553 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
554 return party_action(PARTY_B);
559 /*---------------------------------------------------------------------------*/
561 static int paused = 0;
563 static struct state *st_continue;
564 static struct state *st_quit;
566 #define PAUSE_CONTINUE 1
569 int goto_pause(struct state *s, int e)
571 if (curr_state() == &st_pause)
574 if (e && !config_tst_d(CONFIG_KEY_PAUSE, SDLK_ESCAPE))
575 return goto_state(s);
577 st_continue = curr_state();
581 return goto_state(&st_pause);
584 static int pause_action(int i)
586 audio_play(AUD_MENU, 1.0f);
591 return goto_state(st_continue ? st_continue : &st_title);
594 return goto_state(st_quit);
599 static int pause_enter(struct state *st, struct state *prev)
603 audio_music_fade_out(0.2f);
605 if ((id = gui_vstack(0)))
607 td = gui_label(id, _("Paused"), GUI_LRG, GUI_ALL, 0, 0);
610 if ((jd = gui_harray(id)))
612 gui_state(jd, _("Quit"), GUI_SML, PAUSE_QUIT, 0);
613 gui_start(jd, _("Continue"), GUI_SML, PAUSE_CONTINUE, 1);
617 gui_layout(id, 0, 0);
624 static void pause_leave(struct state *st, struct state *next, int id)
628 audio_music_fade_in(0.5f);
631 static void pause_paint(int id, float t)
638 static void pause_timer(int id, float dt)
643 static void pause_point(int id, int x, int y, int dx, int dy)
645 gui_pulse(gui_point(id, x, y), 1.2f);
648 static int pause_click(int b, int d)
650 return d && b == SDL_BUTTON_LEFT ? pause_action(gui_token(gui_click())) : 1;
653 static int pause_keybd(int c, int d)
655 if (d && config_tst_d(CONFIG_KEY_PAUSE, c))
656 return pause_action(PAUSE_CONTINUE);
660 static int pause_buttn(int b, int d)
664 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
665 return pause_action(gui_token(gui_click()));
666 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
667 return pause_action(PAUSE_CONTINUE);
672 /*---------------------------------------------------------------------------*/
674 static int shared_keybd(int c, int d)
678 if (config_tst_d(CONFIG_KEY_PAUSE, c))
679 return goto_pause(&st_over, 0);
684 /*---------------------------------------------------------------------------*/
688 static int next_enter(struct state *st, struct state *prev)
693 sprintf(str, _("Hole %02d"), curr_hole());
695 if ((id = gui_vstack(0)))
697 gui_label(id, str, GUI_MED, GUI_ALL, 0, 0);
700 gui_label(id, _("Player"), GUI_SML, GUI_TOP, 0, 0);
702 switch (curr_player())
705 gui_label(id, "1", GUI_LRG, GUI_BOT, gui_red, gui_wht);
706 if (curr_party() > 1) audio_play(AUD_PLAYER1, 1.f);
709 gui_label(id, "2", GUI_LRG, GUI_BOT, gui_grn, gui_wht);
710 if (curr_party() > 1) audio_play(AUD_PLAYER2, 1.f);
713 gui_label(id, "3", GUI_LRG, GUI_BOT, gui_blu, gui_wht);
714 if (curr_party() > 1) audio_play(AUD_PLAYER3, 1.f);
717 gui_label(id, "4", GUI_LRG, GUI_BOT, gui_yel, gui_wht);
718 if (curr_party() > 1) audio_play(AUD_PLAYER4, 1.f);
721 gui_layout(id, 0, 0);
733 static void next_leave(struct state *st, struct state *next, int id)
739 static void next_paint(int id, float t)
746 static void next_timer(int id, float dt)
751 static void next_point(int id, int x, int y, int dx, int dy)
753 gui_pulse(gui_point(id, x, y), 1.2f);
756 static int next_click(int b, int d)
758 return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_flyby) : 1;
761 static int next_keybd(int c, int d)
766 return goto_state(&st_poser);
767 if (config_tst_d(CONFIG_KEY_PAUSE, c))
768 return goto_pause(&st_over, 0);
769 if ('0' <= c && c <= '9')
770 num = num * 10 + c - '0';
775 static int next_buttn(int b, int d)
779 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
785 return goto_state(&st_next);
787 return goto_state(&st_flyby);
789 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
790 return goto_pause(&st_over, 1);
795 /*---------------------------------------------------------------------------*/
797 static int poser_enter(struct state *st, struct state *prev)
803 static void poser_paint(int id, float t)
808 static int poser_buttn(int b, int d)
812 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
813 return goto_state(&st_next);
814 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
815 return goto_state(&st_next);
820 /*---------------------------------------------------------------------------*/
822 static int flyby_enter(struct state *st, struct state *prev)
832 static void flyby_leave(struct state *st, struct state *next, int id)
837 static void flyby_paint(int id, float t)
843 static void flyby_timer(int id, float dt)
845 float t = time_state();
847 if (dt > 0.f && t > 1.f)
848 goto_state(&st_stroke);
850 game_set_fly(1.f - t);
855 static int flyby_click(int b, int d)
857 if (d && b == SDL_BUTTON_LEFT)
860 return goto_state(&st_stroke);
865 static int flyby_buttn(int b, int d)
869 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
872 return goto_state(&st_stroke);
874 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
875 return goto_pause(&st_over, 1);
880 /*---------------------------------------------------------------------------*/
882 static int stroke_rotate = 0;
883 static int stroke_mag = 0;
885 static int stroke_enter(struct state *st, struct state *prev)
889 config_set_d(CONFIG_CAMERA, 2);
890 video_set_grab(!paused);
898 static void stroke_leave(struct state *st, struct state *next, int id)
902 config_set_d(CONFIG_CAMERA, 0);
905 static void stroke_paint(int id, float t)
911 static void stroke_timer(int id, float dt)
913 float g[3] = { 0.f, 0.f, 0.f };
917 if (SDL_GetModState() & KMOD_SHIFT ||
918 (joystick && SDL_JoystickGetButton(joystick,
919 config_get_d(CONFIG_JOYSTICK_BUTTON_B))))
924 game_set_rot(stroke_rotate * k);
925 game_set_mag(stroke_mag * k);
927 game_update_view(dt);
931 static void stroke_point(int id, int x, int y, int dx, int dy)
937 static void stroke_stick(int id, int a, float v, int bump)
939 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
940 stroke_rotate = 6 * v;
941 else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
945 static int stroke_click(int b, int d)
947 return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_roll) : 1;
950 static int stroke_buttn(int b, int d)
954 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
955 return goto_state(&st_roll);
956 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
957 return goto_pause(&st_over, 1);
962 /*---------------------------------------------------------------------------*/
964 static int roll_enter(struct state *st, struct state *prev)
976 static void roll_leave(struct state *st, struct state *next, int id)
981 static void roll_paint(int id, float t)
987 static void roll_timer(int id, float dt)
989 float g[3] = { 0.0f, -9.8f, 0.0f };
991 switch (game_step(g, dt))
993 case GAME_STOP: goto_state(&st_stop); break;
994 case GAME_GOAL: goto_state(&st_goal); break;
995 case GAME_FALL: goto_state(&st_fall); break;
999 static int roll_buttn(int b, int d)
1003 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1004 return goto_pause(&st_over, 1);
1009 /*---------------------------------------------------------------------------*/
1011 static int goal_enter(struct state *st, struct state *prev)
1015 if ((id = gui_label(0, _("It's In!"), GUI_MED, GUI_ALL, gui_grn, gui_grn)))
1016 gui_layout(id, 0, 0);
1028 static void goal_leave(struct state *st, struct state *next, int id)
1034 static void goal_paint(int id, float t)
1041 static void goal_timer(int id, float dt)
1043 if (time_state() > 3)
1046 goto_state(&st_next);
1048 goto_state(&st_score);
1052 static int goal_click(int b, int d)
1054 if (b == SDL_BUTTON_LEFT && d == 1)
1057 goto_state(&st_next);
1059 goto_state(&st_score);
1064 static int goal_buttn(int b, int d)
1068 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1071 goto_state(&st_next);
1073 goto_state(&st_score);
1075 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1076 return goto_pause(&st_over, 1);
1081 /*---------------------------------------------------------------------------*/
1083 static int stop_enter(struct state *st, struct state *prev)
1095 static void stop_leave(struct state *st, struct state *next, int id)
1100 static void stop_paint(int id, float t)
1106 static void stop_timer(int id, float dt)
1108 float g[3] = { 0.f, 0.f, 0.f };
1110 game_update_view(dt);
1113 if (time_state() > 1)
1116 goto_state(&st_next);
1118 goto_state(&st_score);
1122 static int stop_click(int b, int d)
1124 if (b == SDL_BUTTON_LEFT && d == 1)
1127 goto_state(&st_next);
1129 goto_state(&st_score);
1134 static int stop_buttn(int b, int d)
1138 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1141 goto_state(&st_next);
1143 goto_state(&st_score);
1145 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1146 return goto_pause(&st_over, 1);
1151 /*---------------------------------------------------------------------------*/
1153 static int fall_enter(struct state *st, struct state *prev)
1157 if ((id = gui_label(0, _("1 Stroke Penalty"), GUI_MED, GUI_ALL, gui_blk, gui_red)))
1158 gui_layout(id, 0, 0);
1165 /* game_draw(0);*/ /*TODO: is this call ok? */ /* No, it's not. */
1173 static void fall_leave(struct state *st, struct state *next, int id)
1179 static void fall_paint(int id, float t)
1186 static void fall_timer(int id, float dt)
1188 if (time_state() > 3)
1191 goto_state(&st_next);
1193 goto_state(&st_score);
1197 static int fall_click(int b, int d)
1199 if (b == SDL_BUTTON_LEFT && d == 1)
1202 goto_state(&st_next);
1204 goto_state(&st_score);
1209 static int fall_buttn(int b, int d)
1213 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1216 goto_state(&st_next);
1218 goto_state(&st_score);
1220 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1221 return goto_pause(&st_over, 1);
1226 /*---------------------------------------------------------------------------*/
1228 static int score_enter(struct state *st, struct state *prev)
1230 audio_music_fade_out(2.f);
1235 return score_card(_("Scores"), gui_yel, gui_red);
1238 static void score_leave(struct state *st, struct state *next, int id)
1243 static void score_paint(int id, float t)
1249 static void score_timer(int id, float dt)
1254 static int score_click(int b, int d)
1256 if (b == SDL_BUTTON_LEFT && d == 1)
1259 return goto_state(&st_next);
1261 return goto_state(&st_title);
1266 static int score_buttn(int b, int d)
1270 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1273 goto_state(&st_next);
1275 goto_state(&st_score);
1277 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1278 return goto_pause(&st_over, 1);
1283 /*---------------------------------------------------------------------------*/
1285 static int over_enter(struct state *st, struct state *prev)
1287 audio_music_fade_out(2.f);
1288 return score_card(_("Final Scores"), gui_yel, gui_red);
1291 static void over_leave(struct state *st, struct state *next, int id)
1296 static void over_paint(int id, float t)
1302 static void over_timer(int id, float dt)
1307 static int over_click(int b, int d)
1309 return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_title) : 1;
1312 static int over_buttn(int b, int d)
1316 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1317 return goto_state(&st_title);
1318 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1319 return goto_state(&st_title);
1324 /*---------------------------------------------------------------------------*/
1326 struct state st_title = {
1339 struct state st_course = {
1352 struct state st_party = {
1365 struct state st_next = {
1378 struct state st_poser = {
1391 struct state st_flyby = {
1404 struct state st_stroke = {
1417 struct state st_roll = {
1430 struct state st_goal = {
1443 struct state st_stop = {
1456 struct state st_fall = {
1469 struct state st_score = {
1482 struct state st_over = {
1495 struct state st_pause = {