diff options
author | Sebastian Leonhardt <sebastian.leonhardt@web.de> | 2016-01-08 01:05:36 +0100 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2024-06-30 17:24:16 -0400 |
commit | 102c3742487dba76ec72d5f56a2c3041344b2d68 (patch) | |
tree | 4931ad34d2cc0bac56d9984b9ead355d012ad63a /apps/plugins/xrick/scr_imap.c | |
parent | 6f1e67e5e318ba2fd0f5ec1892c7b6633ec6521c (diff) | |
download | rockbox-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/scr_imap.c')
-rw-r--r-- | apps/plugins/xrick/scr_imap.c | 293 |
1 files changed, 293 insertions, 0 deletions
diff --git a/apps/plugins/xrick/scr_imap.c b/apps/plugins/xrick/scr_imap.c new file mode 100644 index 0000000000..5be80a24e4 --- /dev/null +++ b/apps/plugins/xrick/scr_imap.c | |||
@@ -0,0 +1,293 @@ | |||
1 | /* | ||
2 | * xrick/scr_imap.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/screens.h" | ||
17 | |||
18 | #include "xrick/game.h" | ||
19 | #include "xrick/rects.h" | ||
20 | #include "xrick/draw.h" | ||
21 | #include "xrick/control.h" | ||
22 | #include "xrick/maps.h" | ||
23 | |||
24 | /* | ||
25 | * local vars | ||
26 | */ | ||
27 | static U16 step; /* current step */ | ||
28 | static U16 count; /* number of loops for current step */ | ||
29 | static U16 run; /* 1 = run, 0 = no more step */ | ||
30 | static U8 flipflop; /* flipflop for top, bottom, left, right */ | ||
31 | static U8 spnum; /* sprite number */ | ||
32 | static U16 spx, spdx; /* sprite x position and delta */ | ||
33 | static U16 spy, spdy; /* sprite y position and delta */ | ||
34 | static U16 spbase, spoffs; /* base, offset for sprite numbers table */ | ||
35 | static U8 seq = 0; /* anim sequence */ | ||
36 | |||
37 | static rect_t anim_rect = { 128, 16 + 16, 64, 64, NULL }; /* anim rectangle */ | ||
38 | |||
39 | /* | ||
40 | * prototypes | ||
41 | */ | ||
42 | static void drawtb(void); | ||
43 | static void drawlr(void); | ||
44 | static void drawsprite(void); | ||
45 | static void drawcenter(void); | ||
46 | static void nextstep(void); | ||
47 | static void anim(void); | ||
48 | static void init(void); | ||
49 | |||
50 | /* | ||
51 | * Map introduction | ||
52 | * | ||
53 | * ASM: 1948 | ||
54 | * | ||
55 | * return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT | ||
56 | */ | ||
57 | U8 | ||
58 | screen_introMap(void) | ||
59 | { | ||
60 | switch (seq) { | ||
61 | case 0: | ||
62 | sysvid_clear(); | ||
63 | |||
64 | #ifdef GFXPC | ||
65 | draw_tilesBank = 1; | ||
66 | draw_filter = 0xAAAA; | ||
67 | #endif | ||
68 | #ifdef GFXST | ||
69 | draw_tilesBank = 0; | ||
70 | #endif | ||
71 | draw_tllst = screen_imaptext[game_map]; | ||
72 | draw_setfb(40, 16); | ||
73 | draw_tilesSubList(); | ||
74 | |||
75 | draw_setfb(40, 104); | ||
76 | #ifdef GFXPC | ||
77 | draw_filter = 0x5555; | ||
78 | #endif | ||
79 | draw_tilesList(); | ||
80 | |||
81 | game_rects = NULL; | ||
82 | |||
83 | #ifdef GFXPC | ||
84 | draw_filter = 0xFFFF; | ||
85 | #endif | ||
86 | |||
87 | init(); | ||
88 | nextstep(); | ||
89 | drawcenter(); | ||
90 | drawtb(); | ||
91 | drawlr(); | ||
92 | drawsprite(); | ||
93 | draw_drawStatus(); | ||
94 | |||
95 | game_rects = &draw_SCREENRECT; | ||
96 | |||
97 | #ifdef ENABLE_SOUND | ||
98 | game_setmusic(map_maps[game_map].tune, 1); | ||
99 | #endif | ||
100 | |||
101 | seq = 1; | ||
102 | break; | ||
103 | case 1: /* top and bottom borders */ | ||
104 | drawtb(); | ||
105 | game_rects = &anim_rect; | ||
106 | seq = 2; | ||
107 | break; | ||
108 | case 2: /* background and sprite */ | ||
109 | anim(); | ||
110 | drawcenter(); | ||
111 | drawsprite(); | ||
112 | game_rects = &anim_rect; | ||
113 | seq = 3; | ||
114 | break; | ||
115 | case 3: /* all borders */ | ||
116 | drawtb(); | ||
117 | drawlr(); | ||
118 | game_rects = &anim_rect; | ||
119 | seq = 1; | ||
120 | break; | ||
121 | case 4: /* wait for key release */ | ||
122 | if (!(control_test(Control_FIRE))) | ||
123 | seq = 5; | ||
124 | break; | ||
125 | } | ||
126 | |||
127 | if (control_test(Control_FIRE)) { /* end as soon as key pressed */ | ||
128 | seq = 4; | ||
129 | } | ||
130 | |||
131 | if (control_test(Control_EXIT)) /* check for exit request */ | ||
132 | return SCREEN_EXIT; | ||
133 | |||
134 | if (seq == 5) { /* end as soon as key pressed */ | ||
135 | sysvid_clear(); | ||
136 | seq = 0; | ||
137 | return SCREEN_DONE; | ||
138 | } | ||
139 | else | ||
140 | return SCREEN_RUNNING; | ||
141 | } | ||
142 | |||
143 | |||
144 | /* | ||
145 | * Display top and bottom borders (0x1B1F) | ||
146 | * | ||
147 | */ | ||
148 | static void | ||
149 | drawtb(void) | ||
150 | { | ||
151 | U8 i; | ||
152 | |||
153 | flipflop++; | ||
154 | if (flipflop & 0x01) { | ||
155 | draw_setfb(136, 16 + 16); | ||
156 | for (i = 0; i < 6; i++) | ||
157 | draw_tile(0x40); | ||
158 | draw_setfb(136, 72 + 16); | ||
159 | for (i = 0; i < 6; i++) | ||
160 | draw_tile(0x06); | ||
161 | } | ||
162 | else { | ||
163 | draw_setfb(136, 16 + 16); | ||
164 | for (i = 0; i < 6; i++) | ||
165 | draw_tile(0x05); | ||
166 | draw_setfb(136, 72 + 16); | ||
167 | for (i = 0; i < 6; i++) | ||
168 | draw_tile(0x40); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | |||
173 | /* | ||
174 | * Display left and right borders (0x1B7C) | ||
175 | * | ||
176 | */ | ||
177 | static void | ||
178 | drawlr(void) | ||
179 | { | ||
180 | U8 i; | ||
181 | |||
182 | if (flipflop & 0x02) { | ||
183 | for (i = 0; i < 8; i++) { | ||
184 | draw_setfb(128, 16 + i * 8 + 16); | ||
185 | draw_tile(0x04); | ||
186 | draw_setfb(184, 16 + i * 8 + 16); | ||
187 | draw_tile(0x04); | ||
188 | } | ||
189 | } | ||
190 | else { | ||
191 | for (i = 0; i < 8; i++) { | ||
192 | draw_setfb(128, 16 + i * 8 + 16); | ||
193 | draw_tile(0x2B); | ||
194 | draw_setfb(184, 16 + i * 8 + 16); | ||
195 | draw_tile(0x2B); | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | |||
200 | |||
201 | /* | ||
202 | * Draw the sprite (0x19C6) | ||
203 | * | ||
204 | */ | ||
205 | static void | ||
206 | drawsprite(void) | ||
207 | { | ||
208 | draw_sprite(spnum, 136 + ((spx << 1) & 0x1C), 24 + (spy << 1) + 16); | ||
209 | } | ||
210 | |||
211 | |||
212 | /* | ||
213 | * Draw the background (0x1AF1) | ||
214 | * | ||
215 | */ | ||
216 | static void | ||
217 | drawcenter(void) | ||
218 | { | ||
219 | static U8 tn0[] = { 0x07, 0x5B, 0x7F, 0xA3, 0xC7 }; | ||
220 | U8 i, j, tn; | ||
221 | |||
222 | tn = tn0[game_map]; | ||
223 | for (i = 0; i < 6; i++) { | ||
224 | draw_setfb(136, (24 + 8 * i) + 16); | ||
225 | for (j = 0; j < 6; j++) | ||
226 | draw_tile(tn++); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | |||
231 | /* | ||
232 | * Next Step (0x1A74) | ||
233 | * | ||
234 | */ | ||
235 | static void | ||
236 | nextstep(void) | ||
237 | { | ||
238 | if (screen_imapsteps[step].count) { | ||
239 | count = screen_imapsteps[step].count; | ||
240 | spdx = screen_imapsteps[step].dx; | ||
241 | spdy = screen_imapsteps[step].dy; | ||
242 | spbase = screen_imapsteps[step].base; | ||
243 | spoffs = 0; | ||
244 | step++; | ||
245 | } | ||
246 | else { | ||
247 | run = 0; | ||
248 | } | ||
249 | } | ||
250 | |||
251 | |||
252 | /* | ||
253 | * Anim (0x1AA8) | ||
254 | * | ||
255 | */ | ||
256 | static void | ||
257 | anim(void) | ||
258 | { | ||
259 | U8 i; | ||
260 | |||
261 | if (run) { | ||
262 | i = screen_imapsl[spbase + spoffs]; | ||
263 | if (i == 0) { | ||
264 | spoffs = 0; | ||
265 | i = screen_imapsl[spbase]; | ||
266 | } | ||
267 | spnum = i; | ||
268 | spoffs++; | ||
269 | spx += spdx; | ||
270 | spy += spdy; | ||
271 | count--; | ||
272 | if (count == 0) | ||
273 | nextstep(); | ||
274 | } | ||
275 | } | ||
276 | |||
277 | |||
278 | /* | ||
279 | * Initialize (0x1A43) | ||
280 | * | ||
281 | */ | ||
282 | static void | ||
283 | init(void) | ||
284 | { | ||
285 | run = 0; run--; | ||
286 | step = screen_imapsofs[game_map]; | ||
287 | spx = screen_imapsteps[step].dx; | ||
288 | spy = screen_imapsteps[step].dy; | ||
289 | step++; | ||
290 | spnum = 0; /* NOTE spnum in [8728] is never initialized ? */ | ||
291 | } | ||
292 | |||
293 | /* eof */ | ||