summaryrefslogtreecommitdiff
path: root/apps/plugins/xrick/e_sbonus.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/xrick/e_sbonus.c')
-rw-r--r--apps/plugins/xrick/e_sbonus.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/apps/plugins/xrick/e_sbonus.c b/apps/plugins/xrick/e_sbonus.c
new file mode 100644
index 0000000000..1630d419aa
--- /dev/null
+++ b/apps/plugins/xrick/e_sbonus.c
@@ -0,0 +1,88 @@
1/*
2 * xrick/e_sbonus.c
3 *
4 * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
5 * Copyright (C) 2008-2014 Pierluigi Vicinanza.
6 * All rights reserved.
7 *
8 * The use and distribution terms for this software are contained in the file
9 * named README, which can be found in the root of this distribution. By
10 * using this software in any fashion, you are agreeing to be bound by the
11 * terms of this license.
12 *
13 * You must not remove this notice, or any other, from this software.
14 */
15
16#include "xrick/e_sbonus.h"
17
18#include "xrick/game.h"
19#include "xrick/ents.h"
20#include "xrick/util.h"
21#include "xrick/maps.h"
22#include "xrick/e_rick.h"
23
24
25/*
26 * public vars
27 */
28bool e_sbonus_counting = false;
29U8 e_sbonus_counter = 0;
30U16 e_sbonus_bonus = 0;
31
32
33/*
34 * Entity action / start counting
35 *
36 * ASM 2182
37 */
38void
39e_sbonus_start(U8 e)
40{
41 ent_ents[e].sprite = 0; /* invisible */
42 if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
43 /* rick is within trigger box */
44 ent_ents[e].n = 0;
45 e_sbonus_counting = true; /* 6DD5 */
46 e_sbonus_counter = 0x1e; /* 6DDB */
47 e_sbonus_bonus = 2000; /* 291A-291D */
48#ifdef ENABLE_SOUND
49 syssnd_play(soundSbonus1, 1);
50#endif
51 }
52}
53
54
55/*
56 * Entity action / stop counting
57 *
58 * ASM 2143
59 */
60void
61e_sbonus_stop(U8 e)
62{
63 ent_ents[e].sprite = 0; /* invisible */
64
65 if (!e_sbonus_counting)
66 return;
67
68 if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
69 /* rick is within trigger box */
70 e_sbonus_counting = false; /* stop counting */
71 ent_ents[e].n = 0; /* deactivate entity */
72 game_score += e_sbonus_bonus; /* add bonus to score */
73#ifdef ENABLE_SOUND
74 syssnd_play(soundSbonus2, 1);
75#endif
76 /* make sure the entity won't be activated again */
77 map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
78 }
79 else {
80 /* keep counting */
81 if (--e_sbonus_counter == 0) {
82 e_sbonus_counter = 0x1e;
83 if (e_sbonus_bonus) e_sbonus_bonus--;
84 }
85 }
86}
87
88/* eof */