summaryrefslogtreecommitdiff
path: root/apps/plugins/xrick/e_box.c
diff options
context:
space:
mode:
authorSebastian Leonhardt <sebastian.leonhardt@web.de>2016-01-08 01:05:36 +0100
committerSolomon Peachy <pizza@shaftnet.org>2024-06-30 17:24:16 -0400
commit102c3742487dba76ec72d5f56a2c3041344b2d68 (patch)
tree4931ad34d2cc0bac56d9984b9ead355d012ad63a /apps/plugins/xrick/e_box.c
parent6f1e67e5e318ba2fd0f5ec1892c7b6633ec6521c (diff)
downloadrockbox-102c3742487dba76ec72d5f56a2c3041344b2d68.tar.gz
rockbox-102c3742487dba76ec72d5f56a2c3041344b2d68.zip
added xrick game
original xrick code by 'BigOrno' at: http://www.bigorno.net/xrick/ Rockbox port, plus bugfixes at: https://github.com/pierluigi-vicinanza/xrick Further changes: * Additonal fixes from g#3026 * Port to modern plugin API * Add Pluginlib keymap fallback * Support all >1bpp screens * Fix build warnings in miniz * Better error message when resources are missing Change-Id: Id83928bc2539901b0221692f65cbca41389c58e7
Diffstat (limited to 'apps/plugins/xrick/e_box.c')
-rw-r--r--apps/plugins/xrick/e_box.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/apps/plugins/xrick/e_box.c b/apps/plugins/xrick/e_box.c
new file mode 100644
index 0000000000..25884b1a12
--- /dev/null
+++ b/apps/plugins/xrick/e_box.c
@@ -0,0 +1,109 @@
1/*
2 * xrick/e_box.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_box.h"
17
18#include "xrick/game.h"
19#include "xrick/ents.h"
20#include "xrick/e_bullet.h"
21#include "xrick/e_bomb.h"
22#include "xrick/e_rick.h"
23#include "xrick/maps.h"
24#include "xrick/util.h"
25
26/*
27 * FIXME this is because the same structure is used
28 * for all entities. Need to replace this w/ an inheritance
29 * solution.
30 */
31#define cnt c1
32
33/*
34 * Constants
35 */
36#define SEQ_INIT 0x0A
37
38/*
39 * Prototypes
40 */
41static void explode(U8);
42
43/*
44 * Entity action
45 *
46 * ASM 245A
47 */
48void
49e_box_action(U8 e)
50{
51 static U8 sp[] = {0x24, 0x25, 0x26, 0x27, 0x28}; /* explosion sprites sequence */
52
53 if (ent_ents[e].n & ENT_LETHAL) {
54 /*
55 * box is lethal i.e. exploding
56 * play sprites sequence then stop
57 */
58 ent_ents[e].sprite = sp[ent_ents[e].cnt >> 1];
59 if (--ent_ents[e].cnt == 0) {
60 ent_ents[e].n = 0;
61 map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
62 }
63 } else {
64 /*
65 * not lethal: check to see if triggered
66 */
67 if (e_rick_boxtest(e)) {
68 /* rick: collect bombs or bullets and stop */
69#ifdef ENABLE_SOUND
70 syssnd_play(soundBox, 1);
71#endif
72 if (ent_ents[e].n == 0x10)
73 game_bombs = GAME_BOMBS_INIT;
74 else /* 0x11 */
75 game_bullets = GAME_BULLETS_INIT;
76 ent_ents[e].n = 0;
77 map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
78 }
79 else if (e_rick_state_test(E_RICK_STSTOP) &&
80 u_fboxtest(e, e_rick_stop_x, e_rick_stop_y)) {
81 /* rick's stick: explode */
82 explode(e);
83 }
84 else if (E_BULLET_ENT.n && u_fboxtest(e, e_bullet_xc, e_bullet_yc)) {
85 /* bullet: explode (and stop bullet) */
86 E_BULLET_ENT.n = 0;
87 explode(e);
88 }
89 else if (e_bomb_lethal && e_bomb_hit(e)) {
90 /* bomb: explode */
91 explode(e);
92 }
93 }
94}
95
96
97/*
98 * Explode when
99 */
100static void explode(U8 e)
101{
102 ent_ents[e].cnt = SEQ_INIT;
103 ent_ents[e].n |= ENT_LETHAL;
104#ifdef ENABLE_SOUND
105 syssnd_play(soundExplode, 1);
106#endif
107}
108
109/* eof */