mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
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
This commit is contained in:
parent
6f1e67e5e3
commit
102c374248
88 changed files with 16514 additions and 62 deletions
|
@ -200,5 +200,6 @@ wavview,viewers
|
|||
wolf3d,games
|
||||
wormlet,games
|
||||
xobox,games
|
||||
xrick,games
|
||||
xworld,games
|
||||
zxbox,viewers
|
||||
|
|
|
@ -89,3 +89,7 @@ lua
|
|||
lua_scripts
|
||||
picross
|
||||
#endif
|
||||
|
||||
#if (LCD_DEPTH > 1)
|
||||
xrick
|
||||
#endif
|
||||
|
|
4928
apps/plugins/xrick/3rd_party/miniz/miniz.c
vendored
Normal file
4928
apps/plugins/xrick/3rd_party/miniz/miniz.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
88
apps/plugins/xrick/README.md
Normal file
88
apps/plugins/xrick/README.md
Normal file
|
@ -0,0 +1,88 @@
|
|||
xrick
|
||||
=====
|
||||
|
||||
xrick is a clone of [Rick Dangerous](http://en.wikipedia.org/wiki/Rick_Dangerous),
|
||||
known to run on Linux, Windows, BeOs, Amiga, QNX, all sorts of gaming consoles...
|
||||
|
||||
License agreement & legal bable
|
||||
-------------------------------
|
||||
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net) (http://www.bigorno.net/xrick/)
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza (pierluigi DOT vicinanza AT gmail.com)
|
||||
|
||||
I (BigOrno) have written the initial [xrick](http://www.bigorno.net/xrick/) code.
|
||||
However, graphics and maps and sounds are by the authors of the original Rick Dangerous
|
||||
game, and "Rick Dangerous" remains a trademark of its owner(s) -- maybe
|
||||
Core Design (who wrote the game) or FireBird (who published it).
|
||||
As of today, I have not been successful at contacting Core Design.
|
||||
|
||||
This makes it a bit difficult to formally release the whole code,
|
||||
including data for graphics and maps and sounds, under the terms of
|
||||
licences such as the GNU General Public Licence. So the code is
|
||||
released "in the spirit" of the GNU GPL. Whatever that means.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
**Requirements:**
|
||||
|
||||
* [CMake](http://www.cmake.org/)
|
||||
* [SDL](https://www.libsdl.org/download-1.2.php) version 1.2.x
|
||||
* [zlib](http://www.zlib.net/)
|
||||
|
||||
1. *Create a build directory*
|
||||
|
||||
```
|
||||
$ cd xrick-x.x.x
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
```
|
||||
|
||||
2. *Generate your Makefile*
|
||||
|
||||
`$ cmake ../source/xrick/projects/cmake`
|
||||
|
||||
3. *Build*
|
||||
|
||||
`$ make`
|
||||
|
||||
4. *Install (optional)*
|
||||
|
||||
`$ make install`
|
||||
|
||||
Platform specific notes can be found in README.platforms.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
`xrick --help` will tell you all about command-line options.
|
||||
|
||||
Controls
|
||||
--------
|
||||
|
||||
- left, right, up (jump) or down (crawl): arrow keys or Z, X, O and K.
|
||||
- fire: SPACE, end: E, pause: P, exit: ESC.
|
||||
- use left, right, up, down + fire to poke something with your stick,
|
||||
lay a stick of dynamite, or fire a bullet.
|
||||
- toggle fullscreen: F1 ; zoom in/out: F2, F3.
|
||||
- mute: F4 ; volume up/down: F5, F6.
|
||||
- cheat modes, "trainer": F7 ; "never die": F8 ; "expose": F9.
|
||||
|
||||
More details at http://www.bigorno.net/xrick/
|
||||
|
||||
Release History
|
||||
---------------
|
||||
|
||||
Please see the file called CHANGELOG.md.
|
||||
|
||||
Contacts
|
||||
--------
|
||||
|
||||
Report problems or ask questions to:
|
||||
|
||||
* _BigOrno_ (bigorno@bigorno.net)
|
||||
* _Pierluigi Vicinanza_ (pierluigi DOT vicinanza AT gmail.com)
|
16
apps/plugins/xrick/README.rockbox
Normal file
16
apps/plugins/xrick/README.rockbox
Normal file
|
@ -0,0 +1,16 @@
|
|||
xrick on Rockbox
|
||||
----------------
|
||||
|
||||
Based on the upstream #021212 release.
|
||||
|
||||
Currently enabled on all players that have at least 2-bit (ie greyscale)
|
||||
display, but is optimized for color displays of 320x200 or larger.
|
||||
|
||||
You will need the data files extracted into your player's root
|
||||
directory. For example:
|
||||
|
||||
$ unzip xrick-data.zip -d /mnt/myMp3Player
|
||||
|
||||
Note that most players do not have a tuned keymap for xrick, instead
|
||||
relying on the standard "pluginlib" bindings that are most likely
|
||||
sub-optimal. Patches welcome!
|
40
apps/plugins/xrick/SOURCES
Normal file
40
apps/plugins/xrick/SOURCES
Normal file
|
@ -0,0 +1,40 @@
|
|||
control.c
|
||||
devtools.c
|
||||
draw.c
|
||||
e_bomb.c
|
||||
e_bonus.c
|
||||
e_box.c
|
||||
e_bullet.c
|
||||
e_rick.c
|
||||
e_sbonus.c
|
||||
e_them.c
|
||||
ents.c
|
||||
game.c
|
||||
maps.c
|
||||
rects.c
|
||||
res_magic.c
|
||||
resources.c
|
||||
scr_gameover.c
|
||||
scr_getname.c
|
||||
scr_imain.c
|
||||
scr_imap.c
|
||||
scr_pause.c
|
||||
scr_xrick.c
|
||||
scroller.c
|
||||
util.c
|
||||
|
||||
data/img.c
|
||||
data/pics.c
|
||||
data/sounds.c
|
||||
data/sprites.c
|
||||
data/tiles.c
|
||||
|
||||
system/main_rockbox.c
|
||||
system/sysarg_rockbox.c
|
||||
system/sysevt_rockbox.c
|
||||
system/sysfile_rockbox.c
|
||||
system/sysmem_rockbox.c
|
||||
system/sysmenu_rockbox.c
|
||||
system/syssnd_rockbox.c
|
||||
system/system_rockbox.c
|
||||
system/sysvid_rockbox.c
|
58
apps/plugins/xrick/config.h
Normal file
58
apps/plugins/xrick/config.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef XRICK_CONFIG_H
|
||||
#define XRICK_CONFIG_H
|
||||
|
||||
/* graphics (choose one) */
|
||||
#define GFXST
|
||||
#undef GFXPC
|
||||
|
||||
/* sound support */
|
||||
#define ENABLE_SOUND
|
||||
|
||||
/* cheats support */
|
||||
#define ENABLE_CHEATS
|
||||
|
||||
/* development tools */
|
||||
#undef ENABLE_DEVTOOLS
|
||||
|
||||
/* Print debug info to screen */
|
||||
#undef ENABLE_SYSPRINTF_TO_SCREEN
|
||||
|
||||
/* enable/disable subsystem debug */
|
||||
#undef DEBUG_MEMORY
|
||||
#undef DEBUG_ENTS
|
||||
#undef DEBUG_SCROLLER
|
||||
#undef DEBUG_MAPS
|
||||
#undef DEBUG_JOYSTICK
|
||||
#undef DEBUG_EVENTS
|
||||
#undef DEBUG_AUDIO
|
||||
#undef DEBUG_AUDIO2
|
||||
#undef DEBUG_VIDEO
|
||||
#undef DEBUG_VIDEO2
|
||||
|
||||
#endif /* ndef XRICK_CONFIG_H */
|
||||
|
||||
/* eof */
|
24
apps/plugins/xrick/control.c
Normal file
24
apps/plugins/xrick/control.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* xrick/control.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/control.h"
|
||||
|
||||
unsigned control_status = 0;
|
||||
extern inline bool control_test(control_t c);
|
||||
extern inline void control_set(control_t c);
|
||||
extern inline void control_clear(control_t c);
|
||||
bool control_active = true;
|
||||
|
||||
/* eof */
|
41
apps/plugins/xrick/control.h
Normal file
41
apps/plugins/xrick/control.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* xrick/control.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _CONTROL_H
|
||||
#define _CONTROL_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Control_UP = (1 << 0),
|
||||
Control_DOWN = (1 << 1),
|
||||
Control_LEFT = (1 << 2),
|
||||
Control_RIGHT = (1 << 3),
|
||||
Control_PAUSE = (1 << 4),
|
||||
Control_END = (1 << 5),
|
||||
Control_EXIT = (1 << 6),
|
||||
Control_FIRE = (1 << 7)
|
||||
} control_t;
|
||||
|
||||
extern unsigned control_status;
|
||||
inline bool control_test(control_t c) { return control_status & c; }
|
||||
inline void control_set(control_t c) { control_status |= c; }
|
||||
inline void control_clear(control_t c) { control_status &= ~c; }
|
||||
extern bool control_active;
|
||||
|
||||
#endif /* ndef _CONTROL_H */
|
||||
|
||||
/* eof */
|
23
apps/plugins/xrick/data/img.c
Normal file
23
apps/plugins/xrick/data/img.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* xrick/data/img.c
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/data/img.h"
|
||||
|
||||
#include <stddef.h> /* NULL */
|
||||
|
||||
/*
|
||||
* globals
|
||||
*/
|
||||
img_t *img_splash = NULL;
|
||||
|
||||
/* eof */
|
39
apps/plugins/xrick/data/img.h
Normal file
39
apps/plugins/xrick/data/img.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* xrick/data/img.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _IMG_H
|
||||
#define _IMG_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
typedef struct {
|
||||
U8 r, g, b, nothing;
|
||||
} img_color_t;
|
||||
|
||||
typedef struct {
|
||||
U16 width;
|
||||
U16 height;
|
||||
U16 xPos;
|
||||
U16 yPos;
|
||||
U16 ncolors;
|
||||
img_color_t *colors;
|
||||
U8 *pixels;
|
||||
} img_t;
|
||||
|
||||
extern img_t *img_splash;
|
||||
|
||||
#endif /* ndef _IMG_H */
|
||||
|
||||
/* eof */
|
29
apps/plugins/xrick/data/pics.c
Normal file
29
apps/plugins/xrick/data/pics.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* xrick/data/pics.c
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/data/pics.h"
|
||||
|
||||
#ifdef GFXST
|
||||
|
||||
#include <stddef.h> /* NULL */
|
||||
|
||||
/*
|
||||
* globals
|
||||
*/
|
||||
pic_t *pic_haf = NULL;
|
||||
pic_t *pic_congrats = NULL;
|
||||
pic_t *pic_splash = NULL;
|
||||
|
||||
#endif /* GFXST */
|
||||
|
||||
/* eof */
|
41
apps/plugins/xrick/data/pics.h
Normal file
41
apps/plugins/xrick/data/pics.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* xrick/data/pics.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _PICS_H
|
||||
#define _PICS_H
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
#ifdef GFXST
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
typedef struct {
|
||||
U16 width;
|
||||
U16 height;
|
||||
U16 xPos;
|
||||
U16 yPos;
|
||||
U32 *pixels;
|
||||
} pic_t;
|
||||
|
||||
extern pic_t *pic_haf;
|
||||
extern pic_t *pic_congrats;
|
||||
extern pic_t *pic_splash;
|
||||
|
||||
#endif /* GFXST */
|
||||
|
||||
#endif /* ndef _PICS_H */
|
||||
|
||||
/* eof */
|
44
apps/plugins/xrick/data/sounds.c
Normal file
44
apps/plugins/xrick/data/sounds.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* xrick/data/sounds.c
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/data/sounds.h"
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
|
||||
#include <stddef.h> /* NULL */
|
||||
|
||||
sound_t *soundBombshht = NULL;
|
||||
sound_t *soundBonus = NULL;
|
||||
sound_t *soundBox = NULL;
|
||||
sound_t *soundBullet = NULL;
|
||||
sound_t *soundCrawl = NULL;
|
||||
sound_t *soundDie = NULL;
|
||||
sound_t *soundEntity[SOUNDS_NBR_ENTITIES];
|
||||
sound_t *soundExplode = NULL;
|
||||
sound_t *soundGameover = NULL;
|
||||
sound_t *soundJump = NULL;
|
||||
sound_t *soundPad = NULL;
|
||||
sound_t *soundSbonus1 = NULL;
|
||||
sound_t *soundSbonus2 = NULL;
|
||||
sound_t *soundStick = NULL;
|
||||
sound_t *soundTune0 = NULL;
|
||||
sound_t *soundTune1 = NULL;
|
||||
sound_t *soundTune2 = NULL;
|
||||
sound_t *soundTune3 = NULL;
|
||||
sound_t *soundTune4 = NULL;
|
||||
sound_t *soundTune5 = NULL;
|
||||
sound_t *soundWalk = NULL;
|
||||
|
||||
#endif /* ENABLE_SOUND */
|
||||
|
||||
/* eof */
|
87
apps/plugins/xrick/data/sounds.h
Normal file
87
apps/plugins/xrick/data/sounds.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* xrick/data/sounds.h
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _SOUNDS_H
|
||||
#define _SOUNDS_H
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
U8 *buf;
|
||||
U32 len;
|
||||
bool dispose;
|
||||
} sound_t;
|
||||
|
||||
enum
|
||||
{
|
||||
/* expected format is 8-bit mono at 22050Hz */
|
||||
Wave_SAMPLE_RATE = 22050,
|
||||
Wave_AUDIO_FORMAT = 1, /* PCM = 1 (i.e. Linear quantization) */
|
||||
Wave_CHANNEL_COUNT = 1,
|
||||
Wave_BITS_PER_SAMPLE = 8,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
/* "RIFF" chunk descriptor */
|
||||
U8 riffChunkId[4];
|
||||
U8 riffChunkSize[4];
|
||||
U8 riffType[4];
|
||||
/* "fmt" sub-chunk */
|
||||
U8 formatChunkId[4];
|
||||
U8 formatChunkSize[4];
|
||||
U8 audioFormat[2];
|
||||
U8 channelCount[2];
|
||||
U8 sampleRate[4];
|
||||
U8 byteRate[4];
|
||||
U8 blockAlign[2];
|
||||
U8 bitsPerSample[2];
|
||||
/* "data" sub-chunk */
|
||||
U8 dataChunkId[4];
|
||||
U8 dataChunkSize[4];
|
||||
} wave_header_t;
|
||||
|
||||
/* apparently there are 10 entity sounds in original game (ref. "e_them.c" notes)? However we only have 9 so far... */
|
||||
enum { SOUNDS_NBR_ENTITIES = 10 };
|
||||
|
||||
extern sound_t *soundBombshht;
|
||||
extern sound_t *soundBonus;
|
||||
extern sound_t *soundBox;
|
||||
extern sound_t *soundBullet;
|
||||
extern sound_t *soundCrawl;
|
||||
extern sound_t *soundDie;
|
||||
extern sound_t *soundEntity[SOUNDS_NBR_ENTITIES];
|
||||
extern sound_t *soundExplode;
|
||||
extern sound_t *soundGameover;
|
||||
extern sound_t *soundJump;
|
||||
extern sound_t *soundPad;
|
||||
extern sound_t *soundSbonus1;
|
||||
extern sound_t *soundSbonus2;
|
||||
extern sound_t *soundStick;
|
||||
extern sound_t *soundTune0;
|
||||
extern sound_t *soundTune1;
|
||||
extern sound_t *soundTune2;
|
||||
extern sound_t *soundTune3;
|
||||
extern sound_t *soundTune4;
|
||||
extern sound_t *soundTune5;
|
||||
extern sound_t *soundWalk;
|
||||
|
||||
#endif /* ENABLE_SOUND */
|
||||
|
||||
#endif /* ndef _SOUNDS_H */
|
||||
|
||||
/* eof */
|
22
apps/plugins/xrick/data/sprites.c
Normal file
22
apps/plugins/xrick/data/sprites.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* xrick/data/sprites.c
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/data/sprites.h"
|
||||
|
||||
/*
|
||||
* globals
|
||||
*/
|
||||
size_t sprites_nbr_sprites = 0;
|
||||
sprite_t *sprites_data = NULL;
|
||||
|
||||
/* eof */
|
70
apps/plugins/xrick/data/sprites.h
Normal file
70
apps/plugins/xrick/data/sprites.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* xrick/data/sprites.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTES -- PC version
|
||||
*
|
||||
* A sprite consists in 4 columns and 21 rows of (U16 mask, U16 pict),
|
||||
* each pair representing 8 pixels (cga encoding, two bits per pixels).
|
||||
* Sprites are stored in 'sprites.bin' and are loaded by spr_init. Memory
|
||||
* is freed by spr_shutdown.
|
||||
*
|
||||
* There are four sprites planes. Plane 0 is the raw content of 'sprites.bin',
|
||||
* and planes 1, 2 and 3 contain copies of plane 0 with all sprites shifted
|
||||
* 2, 4 and 6 pixels to the right.
|
||||
*/
|
||||
|
||||
#ifndef _SPRITES_H_
|
||||
#define _SPRITES_H_
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
#ifdef GFXPC
|
||||
|
||||
typedef struct {
|
||||
U16 mask;
|
||||
U16 pict;
|
||||
} spriteX_t;
|
||||
|
||||
enum {
|
||||
SPRITES_NBR_ROWS = 21,
|
||||
SPRITES_NBR_COLS = 4
|
||||
};
|
||||
typedef spriteX_t sprite_t[SPRITES_NBR_COLS][SPRITES_NBR_ROWS]; /* one sprite */
|
||||
|
||||
#endif /* GFXPC */
|
||||
|
||||
|
||||
#ifdef GFXST
|
||||
|
||||
enum {
|
||||
SPRITES_NBR_ROWS = 21,
|
||||
SPRITES_NBR_COLS = 4,
|
||||
SPRITES_NBR_DATA = SPRITES_NBR_ROWS * SPRITES_NBR_COLS
|
||||
};
|
||||
typedef U32 sprite_t[SPRITES_NBR_DATA];
|
||||
|
||||
#endif /* GFXST */
|
||||
|
||||
extern size_t sprites_nbr_sprites;
|
||||
extern sprite_t *sprites_data;
|
||||
|
||||
#endif /* ndef _SPRITES_H_ */
|
||||
|
||||
/* eof */
|
22
apps/plugins/xrick/data/tiles.c
Normal file
22
apps/plugins/xrick/data/tiles.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* xrick/data/tiles.c
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/data/tiles.h"
|
||||
|
||||
/*
|
||||
* globals
|
||||
*/
|
||||
size_t tiles_nbr_banks = 0;
|
||||
tile_t *tiles_data = NULL;
|
||||
|
||||
/* eof */
|
70
apps/plugins/xrick/data/tiles.h
Normal file
70
apps/plugins/xrick/data/tiles.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* xrick/data/tiles.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTES
|
||||
*
|
||||
* A tile consists in one column and 8 rows of 8 U16 (cga encoding, two
|
||||
* bits per pixel). The tl_tiles array contains all tiles, with the
|
||||
* following structure:
|
||||
*
|
||||
* 0x0000 - 0x00FF tiles for main intro
|
||||
* 0x0100 - 0x01FF tiles for map intro
|
||||
* 0x0200 - 0x0327 unused
|
||||
* 0x0328 - 0x0427 game tiles, page 0
|
||||
* 0x0428 - 0x0527 game tiles, page 1
|
||||
* 0x0527 - 0x05FF unused
|
||||
*/
|
||||
|
||||
#ifndef _TILES_H
|
||||
#define _TILES_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
/*
|
||||
* three special tile numbers
|
||||
*/
|
||||
enum {
|
||||
TILES_BULLET = 0x01,
|
||||
TILES_BOMB = 0x02,
|
||||
TILES_RICK = 0x03
|
||||
};
|
||||
|
||||
/*
|
||||
* one single tile
|
||||
*/
|
||||
enum { TILES_NBR_LINES = 0x08 };
|
||||
|
||||
#ifdef GFXPC
|
||||
typedef U16 tile_t[TILES_NBR_LINES];
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
typedef U32 tile_t[TILES_NBR_LINES];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* tiles banks (each bank is 0x100 tiles)
|
||||
*/
|
||||
enum { TILES_NBR_TILES = 0x100 };
|
||||
extern size_t tiles_nbr_banks;
|
||||
extern tile_t *tiles_data;
|
||||
|
||||
#endif /* ndef _TILES_H */
|
||||
|
||||
/* eof */
|
84
apps/plugins/xrick/debug.h
Normal file
84
apps/plugins/xrick/debug.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* xrick/debug.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _DEBUG_H
|
||||
#define _DEBUG_H
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
/* define IFDEBUG macros */
|
||||
#ifdef DEBUG_MEMORY
|
||||
#define IFDEBUG_MEMORY(X); X
|
||||
#else
|
||||
#define IFDEBUG_MEMORY(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ENTS
|
||||
#define IFDEBUG_ENTS(X); X
|
||||
#else
|
||||
#define IFDEBUG_ENTS(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SCROLLER
|
||||
#define IFDEBUG_SCROLLER(X); X
|
||||
#else
|
||||
#define IFDEBUG_SCROLLER(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MAPS
|
||||
#define IFDEBUG_MAPS(X); X
|
||||
#else
|
||||
#define IFDEBUG_MAPS(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_JOYSTICK
|
||||
#define IFDEBUG_JOYSTICK(X); X
|
||||
#else
|
||||
#define IFDEBUG_JOYSTICK(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_EVENTS
|
||||
#define IFDEBUG_EVENTS(X); X
|
||||
#else
|
||||
#define IFDEBUG_EVENTS(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_AUDIO
|
||||
#define IFDEBUG_AUDIO(X); X
|
||||
#else
|
||||
#define IFDEBUG_AUDIO(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_AUDIO2
|
||||
#define IFDEBUG_AUDIO2(X); X
|
||||
#else
|
||||
#define IFDEBUG_AUDIO2(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_VIDEO
|
||||
#define IFDEBUG_VIDEO(X); X
|
||||
#else
|
||||
#define IFDEBUG_VIDEO(X);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_VIDEO2
|
||||
#define IFDEBUG_VIDEO2(X); X
|
||||
#else
|
||||
#define IFDEBUG_VIDEO2(X);
|
||||
#endif
|
||||
|
||||
#endif /* ndef _DEBUG_H */
|
||||
|
||||
/* eof */
|
247
apps/plugins/xrick/devtools.c
Normal file
247
apps/plugins/xrick/devtools.c
Normal file
|
@ -0,0 +1,247 @@
|
|||
/*
|
||||
* xrick/devtools.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
#ifdef ENABLE_DEVTOOLS
|
||||
|
||||
#include "xrick/devtools.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/screens.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/data/sprites.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
/*
|
||||
* DevTools
|
||||
*/
|
||||
|
||||
U8
|
||||
devtools_run(void)
|
||||
{
|
||||
static U8 seq = 0;
|
||||
static U8 pos = 0;
|
||||
static U8 pos2 = 0;
|
||||
U8 i, j, k, l;
|
||||
U8 s[128];
|
||||
|
||||
if (seq == 0) {
|
||||
sysvid_clear();
|
||||
game_rects = &draw_SCREENRECT;
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xffff;
|
||||
#endif
|
||||
seq = 1;
|
||||
}
|
||||
|
||||
switch (seq) {
|
||||
case 1: /* draw tiles */
|
||||
sysvid_clear();
|
||||
draw_tilesBank = 0;
|
||||
sys_snprintf(s, sizeof(s), "TILES@BANK@%d\376", pos);
|
||||
draw_setfb(4, 4);
|
||||
draw_tilesListImm(s);
|
||||
k = 0;
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
draw_setfb(80 + i * 0x0a, 14);
|
||||
draw_tile((i<10?0x30:'A'-10) + i);
|
||||
draw_setfb(64, 30 + i * 0x0a);
|
||||
draw_tile((i<10?0x30:'A'-10) + i);
|
||||
}
|
||||
draw_tilesBank = pos;
|
||||
for (i = 0; i < 0x10; i++)
|
||||
for (j = 0; j < 0x10; j++) {
|
||||
draw_setfb(80 + j * 0x0a, 30 + i * 0x0a);
|
||||
draw_tile(k++);
|
||||
}
|
||||
seq = 10;
|
||||
break;
|
||||
case 10: /* wait for key pressed */
|
||||
if (control_test(Control_FIRE))
|
||||
seq = 98;
|
||||
if (control_test(Control_UP))
|
||||
seq = 12;
|
||||
if (control_test(Control_DOWN))
|
||||
seq = 13;
|
||||
if (control_test(Control_RIGHT))
|
||||
seq = 11;
|
||||
break;
|
||||
case 11: /* wait for key released */
|
||||
if (!(control_test(Control_RIGHT))) {
|
||||
pos = 0;
|
||||
seq = 21;
|
||||
}
|
||||
break;
|
||||
case 12: /* wait for key released */
|
||||
if (!(control_test(Control_UP))) {
|
||||
if (pos < 4) pos++;
|
||||
seq = 1;
|
||||
}
|
||||
break;
|
||||
case 13: /* wait for key released */
|
||||
if (!(control_test(Control_DOWN))) {
|
||||
if (pos > 0) pos--;
|
||||
seq = 1;
|
||||
}
|
||||
break;
|
||||
case 21: /* draw sprites */
|
||||
sysvid_clear();
|
||||
draw_tilesBank = 0;
|
||||
sys_snprintf(s, sizeof(s), "SPRITES\376");
|
||||
draw_setfb(4, 4);
|
||||
draw_tilesListImm(s);
|
||||
for (i = 0; i < 8; i++) {
|
||||
draw_setfb(0x08 + 0x20 + i * 0x20, 0x30 - 26);
|
||||
draw_tile((i<10?0x30:'A'-10) + i);
|
||||
draw_setfb(0x08 + 0x20 + i * 0x20, 0x30 - 16);
|
||||
draw_tile((i+8<10?0x30:'A'-10) + i+8);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
k = pos + i * 8;
|
||||
draw_setfb(0x20 - 16, 0x08 + 0x30 + i * 0x20);
|
||||
j = k%16;
|
||||
k /= 16;
|
||||
draw_tile((j<10?0x30:'A'-10) + j);
|
||||
draw_setfb(0x20 - 26, 0x08 + 0x30 + i * 0x20);
|
||||
j = k%16;
|
||||
draw_tile((j<10?0x30:'A'-10) + j);
|
||||
}
|
||||
k = pos;
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 8; j++) {
|
||||
draw_sprite(k++, 0x20 + j * 0x20, 0x30 + i * 0x20);
|
||||
}
|
||||
seq = 30;
|
||||
break;
|
||||
case 30: /* wait for key pressed */
|
||||
if (control_test(Control_FIRE))
|
||||
seq = 98;
|
||||
if (control_test(Control_UP))
|
||||
seq = 32;
|
||||
if (control_test(Control_DOWN))
|
||||
seq = 33;
|
||||
if (control_test(Control_LEFT))
|
||||
seq = 31;
|
||||
if (control_test(Control_RIGHT))
|
||||
seq = 40;
|
||||
break;
|
||||
case 31: /* wait for key released */
|
||||
if (!(control_test(Control_LEFT))) {
|
||||
pos = 0;
|
||||
seq = 1;
|
||||
}
|
||||
break;
|
||||
case 32: /* wait for key released */
|
||||
if (!(control_test(Control_UP))) {
|
||||
if (pos < sprites_nbr_sprites - 32) pos += 32;
|
||||
seq = 21;
|
||||
}
|
||||
break;
|
||||
case 33: /* wait for key released */
|
||||
if (!(control_test(Control_DOWN))) {
|
||||
if (pos > 0) pos -= 32;
|
||||
seq = 21;
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
sysvid_clear();
|
||||
#ifdef GFXPC
|
||||
if (pos2 == 0) pos2 = 2;
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
if (pos2 == 0) pos2 = 1;
|
||||
#endif
|
||||
sys_snprintf(s, sizeof(s), "BLOCKS@%#04X@TO@%#04X@WITH@BANK@%d\376",
|
||||
pos, pos + 4*8-1, pos2);
|
||||
draw_setfb(4, 4);
|
||||
draw_tilesBank = 0;
|
||||
draw_tilesListImm(s);
|
||||
draw_tilesBank = pos2;
|
||||
for (l = 0; l < 8; l++)
|
||||
for (k = 0; k < 4; k++)
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++) {
|
||||
draw_setfb(20 + j * 8 + l * 36, 30 + i * 8 + k * 36);
|
||||
draw_tile(map_blocks[pos + l + k * 8][i * 4 + j]);
|
||||
}
|
||||
seq = 41;
|
||||
break;
|
||||
case 41:
|
||||
if (control_test(Control_FIRE))
|
||||
seq = 98;
|
||||
if (control_test(Control_UP))
|
||||
seq = 42;
|
||||
if (control_test(Control_DOWN))
|
||||
seq = 43;
|
||||
if (control_test(Control_LEFT))
|
||||
seq = 44;
|
||||
if (control_test(Control_PAUSE))
|
||||
seq = 45;
|
||||
break;
|
||||
case 42:
|
||||
if (!(control_test(Control_UP))) {
|
||||
if (pos < map_nbr_blocks - 8*4) pos += 8 * 4;
|
||||
seq = 40;
|
||||
}
|
||||
break;
|
||||
case 43:
|
||||
if (!(control_test(Control_DOWN))) {
|
||||
if (pos > 0) pos -= 8 * 4;
|
||||
seq = 40;
|
||||
}
|
||||
break;
|
||||
case 44:
|
||||
if (!(control_test(Control_LEFT))) {
|
||||
pos = 0;
|
||||
pos2 = 0;
|
||||
seq = 21;
|
||||
}
|
||||
break;
|
||||
case 45:
|
||||
if (!(control_test(Control_PAUSE))) {
|
||||
#ifdef GFXPC
|
||||
if (pos2 == 2) pos2 = 3;
|
||||
else pos2 = 2;
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
if (pos2 == 1) pos2 = 2;
|
||||
else pos2 = 1;
|
||||
#endif
|
||||
seq = 40;
|
||||
}
|
||||
break;
|
||||
case 98: /* wait for key released */
|
||||
if (!(control_test(Control_FIRE)))
|
||||
seq = 99;
|
||||
break;
|
||||
}
|
||||
|
||||
if (control_test(Control_EXIT)) /* check for exit request */
|
||||
return SCREEN_EXIT;
|
||||
|
||||
if (seq == 99) { /* we're done */
|
||||
sysvid_clear();
|
||||
seq = 0;
|
||||
return SCREEN_DONE;
|
||||
}
|
||||
|
||||
return SCREEN_RUNNING;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_DEVTOOLS */
|
||||
|
||||
/* eof */
|
25
apps/plugins/xrick/devtools.h
Normal file
25
apps/plugins/xrick/devtools.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* xrick/devtools.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _DEVTOOLS_H
|
||||
#define _DEVTOOLS_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
extern U8 devtools_run(void);
|
||||
|
||||
#endif /* ndef _DEVTOOLS_H */
|
||||
|
||||
/* eof */
|
702
apps/plugins/xrick/draw.c
Normal file
702
apps/plugins/xrick/draw.c
Normal file
|
@ -0,0 +1,702 @@
|
|||
/*
|
||||
* xrick/draw.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTES
|
||||
*
|
||||
* This is the only file which accesses the video. Anything calling d_*
|
||||
* function should be video-independant.
|
||||
*
|
||||
* draw.c draws into a 320x200 or 0x0140x0xc8 8-bits depth frame buffer,
|
||||
* using the CGA 2 bits color codes. It is up to the video to figure out
|
||||
* how to display the frame buffer. Whatever draw.c does, does not show
|
||||
* until the screen is explicitely refreshed.
|
||||
*
|
||||
* The "screen" is the whole 0x0140 by 0x00c8 screen, coordinates go from
|
||||
* 0x0000,0x0000 to 0x013f,0x00c7.
|
||||
*
|
||||
* The "map" is a 0x0100 by 0x0140 rectangle that represents the active
|
||||
* game area.
|
||||
*
|
||||
* Relative to the screen, the "map" is located at 0x0020,-0x0040 : the
|
||||
* "map" is composed of two hidden 0x0100 by 0x0040 rectangles (one at the
|
||||
* top and one at the bottom) and one visible 0x0100 by 0x00c0 rectangle (in
|
||||
* the middle).
|
||||
*
|
||||
* The "map screen" is the visible rectangle ; it is a 0x0100 by 0xc0
|
||||
* rectangle located at 0x0020,0x00.
|
||||
*
|
||||
* Coordinates can be relative to the screen, the map, or the map screen.
|
||||
*
|
||||
* Coordinates can be expressed in pixels. When relative to the map or the
|
||||
* map screen, they can also be expressed in tiles, the map being composed
|
||||
* of rows of 0x20 tiles of 0x08 by 0x08 pixels.
|
||||
*/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/draw.h"
|
||||
|
||||
#include "xrick/data/sprites.h"
|
||||
#include "xrick/data/tiles.h"
|
||||
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/rects.h"
|
||||
#include "xrick/data/img.h"
|
||||
|
||||
|
||||
/*
|
||||
* counters positions (pixels, screen)
|
||||
*/
|
||||
#ifdef GFXPC
|
||||
#define DRAW_STATUS_SCORE_X 0x28
|
||||
#define DRAW_STATUS_LIVES_X 0xE8
|
||||
#define DRAW_STATUS_Y 0x08
|
||||
#endif
|
||||
#define DRAW_STATUS_BULLETS_X 0x68
|
||||
#define DRAW_STATUS_BOMBS_X 0xA8
|
||||
#ifdef GFXST
|
||||
#define DRAW_STATUS_SCORE_X 0x20
|
||||
#define DRAW_STATUS_LIVES_X 0xF0
|
||||
#define DRAW_STATUS_Y 0
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* public vars
|
||||
*/
|
||||
U8 *draw_tllst; /* pointer to tiles list */
|
||||
#ifdef GFXPC
|
||||
U16 draw_filter; /* CGA colors filter */
|
||||
#endif
|
||||
U8 draw_tilesBank; /* tile number offset */
|
||||
|
||||
rect_t draw_STATUSRECT = {
|
||||
DRAW_STATUS_SCORE_X, DRAW_STATUS_Y,
|
||||
DRAW_STATUS_LIVES_X + 6 * 8 - DRAW_STATUS_SCORE_X, 8,
|
||||
NULL
|
||||
};
|
||||
const rect_t draw_SCREENRECT = { 0, 0, SYSVID_WIDTH, SYSVID_HEIGHT, NULL };
|
||||
|
||||
size_t game_color_count = 0;
|
||||
img_color_t *game_colors = NULL;
|
||||
|
||||
/*
|
||||
* private vars
|
||||
*/
|
||||
static U8 *fb; /* frame buffer pointer */
|
||||
|
||||
|
||||
/*
|
||||
* Set the frame buffer pointer
|
||||
*
|
||||
* x, y: position (pixels, screen)
|
||||
*/
|
||||
void
|
||||
draw_setfb(U16 x, U16 y)
|
||||
{
|
||||
fb = sysvid_fb + x + y * SYSVID_WIDTH;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Clip to map screen
|
||||
*
|
||||
* x, y: position (pixels, map) CHANGED clipped
|
||||
* width, height: dimension CHANGED clipped
|
||||
* return: true if fully clipped, false if still (at least partly) visible
|
||||
*/
|
||||
bool
|
||||
draw_clipms(S16 *x, S16 *y, U16 *width, U16 *height)
|
||||
{
|
||||
if (*x < 0) {
|
||||
if (*x + *width < 0)
|
||||
return true;
|
||||
else {
|
||||
*width += *x;
|
||||
*x = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (*x > 0x0100)
|
||||
return true;
|
||||
else if (*x + *width > 0x0100) {
|
||||
*width = 0x0100 - *x;
|
||||
}
|
||||
}
|
||||
|
||||
if (*y < DRAW_XYMAP_SCRTOP) {
|
||||
if ((*y + *height) < DRAW_XYMAP_SCRTOP)
|
||||
return true;
|
||||
else {
|
||||
*height += *y - DRAW_XYMAP_SCRTOP;
|
||||
*y = DRAW_XYMAP_SCRTOP;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (*y >= DRAW_XYMAP_HBTOP)
|
||||
return true;
|
||||
else if (*y + *height > DRAW_XYMAP_HBTOP)
|
||||
*height = DRAW_XYMAP_HBTOP - *y;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw a list of tiles onto the frame buffer
|
||||
* start at position indicated by fb ; at the end of each (sub)list,
|
||||
* perform a "carriage return + line feed" i.e. go back to the initial
|
||||
* position then go down one tile row (8 pixels)
|
||||
*
|
||||
* ASM 1e33
|
||||
* fb: CHANGED (see above)
|
||||
* draw_tllst: CHANGED points to the element following 0xfe/0xff end code
|
||||
*/
|
||||
void
|
||||
draw_tilesList(void)
|
||||
{
|
||||
U8 *t;
|
||||
|
||||
t = fb;
|
||||
while (draw_tilesSubList() != 0xFE) { /* draw sub-list */
|
||||
t += 8 * SYSVID_WIDTH; /* go down one tile i.e. 8 lines */
|
||||
fb = t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw a list of tiles onto the frame buffer -- same as draw_tilesList,
|
||||
* but accept an immediate string as parameter. Note that the string needs
|
||||
* to be properly terminated with 0xfe (\376) and 0xff (\377) chars.
|
||||
*/
|
||||
void
|
||||
draw_tilesListImm(U8 *list)
|
||||
{
|
||||
draw_tllst = list;
|
||||
draw_tilesList();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw a sub-list of tiles onto the frame buffer
|
||||
* start at position indicated by fb ; leave fb pointing to the next
|
||||
* tile to the right of the last tile drawn
|
||||
*
|
||||
* ASM 1e41
|
||||
* fpb: CHANGED (see above)
|
||||
* draw_tllst: CHANGED points to the element following 0xfe/0xff end code
|
||||
* returns: end code (0xfe : end of list ; 0xff : end of sub-list)
|
||||
*/
|
||||
U8
|
||||
draw_tilesSubList()
|
||||
{
|
||||
U8 i;
|
||||
|
||||
i = *(draw_tllst++);
|
||||
while (i != 0xFF && i != 0xFE) { /* while not end */
|
||||
draw_tile(i); /* draw tile */
|
||||
i = *(draw_tllst++);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw a tile
|
||||
* at position indicated by fb ; leave fb pointing to the next tile
|
||||
* to the right of the tile drawn
|
||||
*
|
||||
* ASM 1e6c
|
||||
* tlnbr: tile number
|
||||
* draw_filter: CGA colors filter
|
||||
* fb: CHANGED (see above)
|
||||
*/
|
||||
void
|
||||
draw_tile(U8 tileNumber)
|
||||
{
|
||||
U8 i, k, *f;
|
||||
|
||||
#ifdef GFXPC
|
||||
U16 x;
|
||||
#endif
|
||||
|
||||
#ifdef GFXST
|
||||
U32 x;
|
||||
#endif
|
||||
|
||||
f = fb; /* frame buffer */
|
||||
for (i = 0; i < TILES_NBR_LINES; i++) { /* for all 8 pixel lines */
|
||||
|
||||
#ifdef GFXPC
|
||||
x = tiles_data[draw_tilesBank * TILES_NBR_TILES + tileNumber][i] & draw_filter;
|
||||
/*
|
||||
* tiles / perform the transformation from CGA 2 bits
|
||||
* per pixel to frame buffer 8 bits per pixels
|
||||
*/
|
||||
for (k = 8; k--; x >>= 2)
|
||||
f[k] = x & 3;
|
||||
f += SYSVID_WIDTH; /* next line */
|
||||
#endif
|
||||
|
||||
#ifdef GFXST
|
||||
x = tiles_data[draw_tilesBank * TILES_NBR_TILES + tileNumber][i];
|
||||
/*
|
||||
* tiles / perform the transformation from ST 4 bits
|
||||
* per pixel to frame buffer 8 bits per pixels
|
||||
*/
|
||||
for (k = 8; k--; x >>= 4)
|
||||
f[k] = x & 0x0F;
|
||||
f += SYSVID_WIDTH; /* next line */
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
fb += 8; /* next tile */
|
||||
}
|
||||
|
||||
/*
|
||||
* Draw a sprite
|
||||
*
|
||||
* ASM 1a09
|
||||
* nbr: sprite number
|
||||
* x, y: sprite position (pixels, screen)
|
||||
* fb: CHANGED
|
||||
*/
|
||||
#ifdef GFXPC
|
||||
void
|
||||
draw_sprite(U8 nbr, U16 x, U16 y)
|
||||
{
|
||||
U8 i, j, k, *f;
|
||||
U16 xm = 0, xp = 0;
|
||||
|
||||
draw_setfb(x, y);
|
||||
|
||||
for (i = 0; i < SPRITES_NBR_COLS; i++) { /* for each tile column */
|
||||
f = fb; /* frame buffer */
|
||||
for (j = 0; j < SPRITES_NBR_ROWS; j++) { /* for each pixel row */
|
||||
xm = sprites_data[nbr][i][j].mask; /* mask */
|
||||
xp = sprites_data[nbr][i][j].pict; /* picture */
|
||||
/*
|
||||
* sprites / perform the transformation from CGA 2 bits
|
||||
* per pixel to frame buffer 8 bits per pixels
|
||||
*/
|
||||
for (k = 8; k--; xm >>= 2, xp >>= 2)
|
||||
f[k] = (f[k] & (xm & 3)) | (xp & 3);
|
||||
f += SYSVID_WIDTH;
|
||||
}
|
||||
fb += 8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Draw a sprite
|
||||
*
|
||||
* foobar
|
||||
*/
|
||||
#ifdef GFXST
|
||||
void
|
||||
draw_sprite(U8 number, U16 x, U16 y)
|
||||
{
|
||||
U8 i, j, k, *f;
|
||||
U16 g;
|
||||
U32 d;
|
||||
|
||||
draw_setfb(x, y);
|
||||
g = 0;
|
||||
for (i = 0; i < SPRITES_NBR_ROWS; i++) { /* rows */
|
||||
f = fb;
|
||||
for (j = 0; j < SPRITES_NBR_COLS; j++) { /* cols */
|
||||
d = sprites_data[number][g++];
|
||||
for (k = 8; k--; d >>= 4)
|
||||
if (d & 0x0F) f[k] = (f[k] & 0xF0) | (d & 0x0F);
|
||||
f += 8;
|
||||
}
|
||||
fb += SYSVID_WIDTH;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Draw a sprite
|
||||
*
|
||||
* NOTE re-using original ST graphics format
|
||||
*/
|
||||
#ifdef GFXST
|
||||
void
|
||||
draw_sprite2(U8 number, U16 x, U16 y, bool front)
|
||||
{
|
||||
U32 d = 0; /* sprite data */
|
||||
S16 x0, y0; /* clipped x, y */
|
||||
U16 w, h; /* width, height */
|
||||
S16 g, /* sprite data offset*/
|
||||
r, c, /* row, column */
|
||||
i, /* frame buffer shifter */
|
||||
im; /* tile flag shifter */
|
||||
U8 flg; /* tile flag */
|
||||
|
||||
x0 = x;
|
||||
y0 = y;
|
||||
w = SPRITES_NBR_COLS * 8; /* each tile column is 8 pixels */
|
||||
h = SPRITES_NBR_ROWS;
|
||||
|
||||
if (draw_clipms(&x0, &y0, &w, &h)) /* return if not visible */
|
||||
return;
|
||||
|
||||
g = 0;
|
||||
draw_setfb(x0 - DRAW_XYMAP_SCRLEFT, y0 - DRAW_XYMAP_SCRTOP + 8);
|
||||
|
||||
for (r = 0; r < SPRITES_NBR_ROWS; r++) {
|
||||
if (r >= h || y + r < y0) continue;
|
||||
|
||||
i = 0x1f;
|
||||
im = x - (x & 0xfff8);
|
||||
flg = map_eflg[map_map[(y + r) >> 3][(x + 0x1f)>> 3]];
|
||||
|
||||
#ifdef ENABLE_CHEATS
|
||||
#define LOOP(N, C0, C1) \
|
||||
d = sprites_data[number][g + N]; \
|
||||
for (c = C0; c >= C1; c--, i--, d >>= 4, im--) { \
|
||||
if (im == 0) { \
|
||||
flg = map_eflg[map_map[(y + r) >> 3][(x + c) >> 3]]; \
|
||||
im = 8; \
|
||||
} \
|
||||
if (c >= w || x + c < x0) continue; \
|
||||
if (!front && !game_cheat3 && (flg & MAP_EFLG_FGND)) continue; \
|
||||
if (d & 0x0F) fb[i] = (fb[i] & 0xF0) | (d & 0x0F); \
|
||||
if (game_cheat3) fb[i] |= 0x10; \
|
||||
}
|
||||
#else
|
||||
#define LOOP(N, C0, C1) \
|
||||
d = sprites_data[number][g + N]; \
|
||||
for (c = C0; c >= C1; c--, i--, d >>= 4, im--) { \
|
||||
if (im == 0) { \
|
||||
flg = map_eflg[map_map[(y + r) >> 3][(x + c) >> 3]]; \
|
||||
im = 8; \
|
||||
} \
|
||||
if (!front && (flg & MAP_EFLG_FGND)) continue; \
|
||||
if (c >= w || x + c < x0) continue; \
|
||||
if (d & 0x0F) fb[i] = (fb[i] & 0xF0) | (d & 0x0F); \
|
||||
}
|
||||
#endif
|
||||
LOOP(3, 0x1f, 0x18);
|
||||
LOOP(2, 0x17, 0x10);
|
||||
LOOP(1, 0x0f, 0x08);
|
||||
LOOP(0, 0x07, 0x00);
|
||||
|
||||
#undef LOOP
|
||||
|
||||
fb += SYSVID_WIDTH;
|
||||
g += SPRITES_NBR_COLS;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Draw a sprite
|
||||
* align to tile column, determine plane automatically, and clip
|
||||
*
|
||||
* nbr: sprite number
|
||||
* x, y: sprite position (pixels, map).
|
||||
* fb: CHANGED
|
||||
*/
|
||||
#ifdef GFXPC
|
||||
void
|
||||
draw_sprite2(U8 number, U16 x, U16 y, bool front)
|
||||
{
|
||||
U8 k, *f, c, r, dx;
|
||||
U16 cmax, rmax;
|
||||
U16 xm = 0, xp = 0;
|
||||
S16 xmap, ymap;
|
||||
|
||||
/* align to tile column, prepare map coordinate and clip */
|
||||
xmap = x & 0xFFF8;
|
||||
ymap = y;
|
||||
cmax = SPRITES_NBR_COLS * 8; /* width, 4 tile columns, 8 pixels each */
|
||||
rmax = SPRITES_NBR_ROWS; /* height, 15 pixels */
|
||||
dx = (x - xmap) * 2;
|
||||
if (draw_clipms(&xmap, &ymap, &cmax, &rmax)) /* return if not visible */
|
||||
return;
|
||||
|
||||
/* get back to screen */
|
||||
draw_setfb(xmap - DRAW_XYMAP_SCRLEFT, ymap - DRAW_XYMAP_SCRTOP);
|
||||
xmap >>= 3;
|
||||
cmax >>= 3;
|
||||
|
||||
/* draw */
|
||||
for (c = 0; c < cmax; c++) { /* for each tile column */
|
||||
f = fb;
|
||||
for (r = 0; r < rmax; r++) { /* for each pixel row */
|
||||
/* check that tile is not hidden behind foreground */
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (front || game_cheat3 ||
|
||||
!(map_eflg[map_map[(ymap + r) >> 3][xmap + c]] & MAP_EFLG_FGND)) {
|
||||
#else
|
||||
if (front ||
|
||||
!(map_eflg[map_map[(ymap + r) >> 3][xmap + c]] & MAP_EFLG_FGND)) {
|
||||
#endif
|
||||
xp = xm = 0;
|
||||
if (c > 0) {
|
||||
xm |= sprites_data[number][c - 1][r].mask << (16 - dx);
|
||||
xp |= sprites_data[number][c - 1][r].pict << (16 - dx);
|
||||
}
|
||||
else
|
||||
xm |= 0xFFFF << (16 - dx);
|
||||
if (c < cmax) {
|
||||
xm |= sprites_data[number][c][r].mask >> dx;
|
||||
xp |= sprites_data[number][c][r].pict >> dx;
|
||||
}
|
||||
else
|
||||
xm |= 0xFFFF >> dx;
|
||||
/*
|
||||
* sprites / perform the transformation from CGA 2 bits
|
||||
* per pixel to frame buffer 8 bits per pixels
|
||||
*/
|
||||
for (k = 8; k--; xm >>= 2, xp >>= 2) {
|
||||
f[k] = ((f[k] & (xm & 3)) | (xp & 3));
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (game_cheat3) f[k] |= 4;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
f += SYSVID_WIDTH;
|
||||
}
|
||||
fb += 8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Redraw the map behind a sprite
|
||||
* align to tile column and row, and clip
|
||||
*
|
||||
* x, y: sprite position (pixels, map).
|
||||
*/
|
||||
void
|
||||
draw_spriteBackground(U16 x, U16 y)
|
||||
{
|
||||
U8 r, c;
|
||||
U16 rmax, cmax;
|
||||
S16 xmap, ymap;
|
||||
U16 xs, ys;
|
||||
|
||||
/* aligne to column and row, prepare map coordinate, and clip */
|
||||
xmap = x & 0xFFF8;
|
||||
ymap = y & 0xFFF8;
|
||||
cmax = (x - xmap == 0 ? 0x20 : 0x28); /* width, 4 tl cols, 8 pix each */
|
||||
rmax = (y & 0x04) ? 0x20 : 0x18; /* height, 3 or 4 tile rows */
|
||||
if (draw_clipms(&xmap, &ymap, &cmax, &rmax)) /* don't draw if fully clipped */
|
||||
return;
|
||||
|
||||
/* get back to screen */
|
||||
xs = xmap - DRAW_XYMAP_SCRLEFT;
|
||||
ys = ymap - DRAW_XYMAP_SCRTOP;
|
||||
xmap >>= 3;
|
||||
ymap >>= 3;
|
||||
cmax >>= 3;
|
||||
rmax >>= 3;
|
||||
|
||||
/* draw */
|
||||
for (r = 0; r < rmax; r++) { /* for each row */
|
||||
#ifdef GFXPC
|
||||
draw_setfb(xs, ys + r * 8);
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_setfb(xs, 8 + ys + r * 8);
|
||||
#endif
|
||||
for (c = 0; c < cmax; c++) { /* for each column */
|
||||
draw_tile(map_map[ymap + r][xmap + c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw entire map screen background tiles onto frame buffer.
|
||||
*
|
||||
* ASM 0af5, 0a54
|
||||
*/
|
||||
void
|
||||
draw_map(void)
|
||||
{
|
||||
U8 i, j;
|
||||
|
||||
draw_tilesBank = map_tilesBank;
|
||||
|
||||
for (i = 0; i < 0x18; i++) /* 0x18 rows */
|
||||
{
|
||||
#ifdef GFXPC
|
||||
draw_setfb(-DRAW_XYMAP_SCRLEFT, (i * 8));
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_setfb(-DRAW_XYMAP_SCRLEFT, 8 + (i * 8));
|
||||
#endif
|
||||
for (j = 0; j < 0x20; j++) /* 0x20 tiles per row */
|
||||
{
|
||||
draw_tile(map_map[i + 8][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw status indicators
|
||||
*
|
||||
* ASM 0309
|
||||
*/
|
||||
void
|
||||
draw_drawStatus(void)
|
||||
{
|
||||
S8 i;
|
||||
U32 sv;
|
||||
static U8 s[7] = {0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xfe};
|
||||
|
||||
draw_tilesBank = 0;
|
||||
|
||||
for (i = 5, sv = game_score; i >= 0; i--) {
|
||||
s[i] = 0x30 + (U8)(sv % 10);
|
||||
sv /= 10;
|
||||
}
|
||||
draw_tllst = s;
|
||||
|
||||
draw_setfb(DRAW_STATUS_SCORE_X, DRAW_STATUS_Y);
|
||||
draw_tilesList();
|
||||
|
||||
draw_setfb(DRAW_STATUS_BULLETS_X, DRAW_STATUS_Y);
|
||||
for (i = 0; i < game_bullets; i++)
|
||||
draw_tile(TILES_BULLET);
|
||||
|
||||
draw_setfb(DRAW_STATUS_BOMBS_X, DRAW_STATUS_Y);
|
||||
for (i = 0; i < game_bombs; i++)
|
||||
draw_tile(TILES_BOMB);
|
||||
|
||||
draw_setfb(DRAW_STATUS_LIVES_X, DRAW_STATUS_Y);
|
||||
for (i = 0; i < game_lives; i++)
|
||||
draw_tile(TILES_RICK);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw info indicators
|
||||
*/
|
||||
#ifdef ENABLE_CHEATS
|
||||
void
|
||||
draw_infos(void)
|
||||
{
|
||||
draw_tilesBank = 0;
|
||||
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xffff;
|
||||
#endif
|
||||
|
||||
draw_setfb(0x00, DRAW_STATUS_Y);
|
||||
draw_tile(game_cheat1 ? 'T' : '@');
|
||||
draw_setfb(0x08, DRAW_STATUS_Y);
|
||||
draw_tile(game_cheat2 ? 'N' : '@');
|
||||
draw_setfb(0x10, DRAW_STATUS_Y);
|
||||
draw_tile(game_cheat3 ? 'V' : '@');
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Clear status indicators
|
||||
*/
|
||||
void
|
||||
draw_clearStatus(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
#ifdef GFXPC
|
||||
draw_tilesBank = map_tilesBank;
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_tilesBank = 0;
|
||||
#endif
|
||||
draw_setfb(DRAW_STATUS_SCORE_X, DRAW_STATUS_Y);
|
||||
for (i = 0; i < DRAW_STATUS_LIVES_X/8 + 6 - DRAW_STATUS_SCORE_X/8; i++) {
|
||||
#ifdef GFXPC
|
||||
draw_tile(map_map[MAP_ROW_SCRTOP + (DRAW_STATUS_Y / 8)][i]);
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_tile('@');
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Draw a picture
|
||||
*/
|
||||
#ifdef GFXST
|
||||
void
|
||||
draw_pic(const pic_t * picture)
|
||||
{
|
||||
U8 *f;
|
||||
U16 i, j, k, pp;
|
||||
U32 v;
|
||||
|
||||
draw_setfb(picture->xPos, picture->yPos);
|
||||
pp = 0;
|
||||
|
||||
for (i = 0; i < picture->height; i++) { /* rows */
|
||||
f = fb;
|
||||
for (j = 0; j < picture->width; j += 8) { /* cols */
|
||||
v = picture->pixels[pp++];
|
||||
for (k = 8; k--; v >>= 4)
|
||||
f[k] = v & 0x0F;
|
||||
f += 8;
|
||||
}
|
||||
fb += SYSVID_WIDTH;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Draw a bitmap
|
||||
*/
|
||||
void
|
||||
draw_img(img_t *image)
|
||||
{
|
||||
U8 *f;
|
||||
U16 i, j, pp;
|
||||
|
||||
sysvid_setPalette(image->colors, image->ncolors);
|
||||
|
||||
draw_setfb(image->xPos, image->yPos);
|
||||
pp = 0;
|
||||
|
||||
for (i = 0; i < image->height; i++) /* rows */
|
||||
{
|
||||
f = fb;
|
||||
for (j = 0; j < image->width; j++) /* cols */
|
||||
{
|
||||
f[j] = image->pixels[pp++];
|
||||
}
|
||||
fb += SYSVID_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
65
apps/plugins/xrick/draw.h
Normal file
65
apps/plugins/xrick/draw.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* xrick/draw.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _DRAW_H
|
||||
#define _DRAW_H
|
||||
|
||||
#include "xrick/rects.h"
|
||||
#include "xrick/data/img.h"
|
||||
#ifdef GFXST
|
||||
#include "xrick/data/pics.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
/* map coordinates of the screen */
|
||||
#define DRAW_XYMAP_SCRLEFT (-0x0020)
|
||||
#define DRAW_XYMAP_SCRTOP (0x0040)
|
||||
/* map coordinates of the top of the hidden bottom of the map */
|
||||
#define DRAW_XYMAP_HBTOP (0x0100)
|
||||
|
||||
extern U8 *draw_tllst;
|
||||
#ifdef GFXPC
|
||||
extern U16 draw_filter;
|
||||
#endif
|
||||
extern U8 draw_tilesBank;
|
||||
|
||||
extern rect_t draw_STATUSRECT;
|
||||
extern const rect_t draw_SCREENRECT; /* whole fb */
|
||||
|
||||
extern size_t game_color_count;
|
||||
extern img_color_t *game_colors;
|
||||
|
||||
extern void draw_setfb(U16, U16);
|
||||
extern bool draw_clipms(S16 *, S16 *, U16 *, U16 *);
|
||||
extern void draw_tilesList(void);
|
||||
extern void draw_tilesListImm(U8 *);
|
||||
extern U8 draw_tilesSubList(void);
|
||||
extern void draw_tile(register U8);
|
||||
extern void draw_sprite(U8, U16, U16);
|
||||
extern void draw_sprite2(U8, U16, U16, bool);
|
||||
extern void draw_spriteBackground(U16, U16);
|
||||
extern void draw_map(void);
|
||||
extern void draw_drawStatus(void);
|
||||
extern void draw_clearStatus(void);
|
||||
#ifdef GFXST
|
||||
extern void draw_pic(const pic_t *);
|
||||
#endif
|
||||
extern void draw_infos(void);
|
||||
extern void draw_img(img_t *);
|
||||
|
||||
#endif /* ndef _DRAW_H */
|
||||
|
||||
/* eof */
|
158
apps/plugins/xrick/e_bomb.c
Normal file
158
apps/plugins/xrick/e_bomb.c
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* xrick/e_bomb.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/e_bomb.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/e_rick.h"
|
||||
#include "xrick/system/system.h"
|
||||
#ifdef ENABLE_SOUND
|
||||
#include "xrick/data/sounds.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* public vars (for performance reasons)
|
||||
*/
|
||||
bool e_bomb_lethal;
|
||||
U8 e_bomb_xc;
|
||||
U16 e_bomb_yc;
|
||||
|
||||
/*
|
||||
* private vars
|
||||
*/
|
||||
U8 e_bomb_ticker;
|
||||
|
||||
/*
|
||||
* Bomb hit test
|
||||
*
|
||||
* ASM 11CD
|
||||
* returns: true/hit, false/not
|
||||
*/
|
||||
bool e_bomb_hit(U8 e)
|
||||
{
|
||||
if (ent_ents[e].x > (E_BOMB_ENT.x >= 0xE0 ? 0xFF : E_BOMB_ENT.x + 0x20))
|
||||
return false;
|
||||
if (ent_ents[e].x + ent_ents[e].w < (E_BOMB_ENT.x > 0x04 ? E_BOMB_ENT.x - 0x04 : 0))
|
||||
return false;
|
||||
if (ent_ents[e].y > (E_BOMB_ENT.y + 0x1D))
|
||||
return false;
|
||||
if (ent_ents[e].y + ent_ents[e].h < (E_BOMB_ENT.y > 0x0004 ? E_BOMB_ENT.y - 0x0004 : 0))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize bomb
|
||||
*/
|
||||
void e_bomb_init(U16 x, U16 y)
|
||||
{
|
||||
E_BOMB_ENT.n = 0x03;
|
||||
E_BOMB_ENT.x = x;
|
||||
E_BOMB_ENT.y = y;
|
||||
e_bomb_ticker = E_BOMB_TICKER;
|
||||
e_bomb_lethal = false;
|
||||
|
||||
/*
|
||||
* Atari ST dynamite sprites are not centered the
|
||||
* way IBM PC sprites were ... need to adjust things a little bit
|
||||
*/
|
||||
#ifdef GFXST
|
||||
E_BOMB_ENT.x += 4;
|
||||
E_BOMB_ENT.y += 5;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Entity action
|
||||
*
|
||||
* ASM 18CA
|
||||
*/
|
||||
void
|
||||
e_bomb_action(U8 e/*unused*/)
|
||||
{
|
||||
(void)e;
|
||||
|
||||
/* tick */
|
||||
e_bomb_ticker--;
|
||||
|
||||
if (e_bomb_ticker == 0)
|
||||
{
|
||||
/*
|
||||
* end: deactivate
|
||||
*/
|
||||
E_BOMB_ENT.n = 0;
|
||||
e_bomb_lethal = false;
|
||||
}
|
||||
else if (e_bomb_ticker >= 0x0A)
|
||||
{
|
||||
/*
|
||||
* ticking
|
||||
*/
|
||||
#ifdef ENABLE_SOUND
|
||||
if ((e_bomb_ticker & 0x03) == 0x02)
|
||||
syssnd_play(soundBombshht, 1);
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
/* ST bomb sprites sequence is longer */
|
||||
if (e_bomb_ticker < 40)
|
||||
E_BOMB_ENT.sprite = 0x99 + 19 - (e_bomb_ticker >> 1);
|
||||
else
|
||||
#endif
|
||||
E_BOMB_ENT.sprite = (e_bomb_ticker & 0x01) ? 0x23 : 0x22;
|
||||
}
|
||||
else if (e_bomb_ticker == 0x09)
|
||||
{
|
||||
/*
|
||||
* explode
|
||||
*/
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundExplode, 1);
|
||||
#endif
|
||||
#ifdef GFXPC
|
||||
E_BOMB_ENT.sprite = 0x24 + 4 - (e_bomb_ticker >> 1);
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
/* See above: fixing alignment */
|
||||
E_BOMB_ENT.x -= 4;
|
||||
E_BOMB_ENT.y -= 5;
|
||||
E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
|
||||
#endif
|
||||
e_bomb_xc = E_BOMB_ENT.x + 0x0C;
|
||||
e_bomb_yc = E_BOMB_ENT.y + 0x000A;
|
||||
e_bomb_lethal = true;
|
||||
if (e_bomb_hit(E_RICK_NO))
|
||||
e_rick_gozombie();
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* exploding
|
||||
*/
|
||||
#ifdef GFXPC
|
||||
E_BOMB_ENT.sprite = 0x24 + 4 - (e_bomb_ticker >> 1);
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
|
||||
#endif
|
||||
/* exploding, hence lethal */
|
||||
if (e_bomb_hit(E_RICK_NO))
|
||||
e_rick_gozombie();
|
||||
}
|
||||
}
|
||||
|
||||
/* eof */
|
36
apps/plugins/xrick/e_bomb.h
Normal file
36
apps/plugins/xrick/e_bomb.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* xrick/e_bomb.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _E_BOMB_H
|
||||
#define _E_BOMB_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
#define E_BOMB_NO 3
|
||||
#define E_BOMB_ENT ent_ents[E_BOMB_NO]
|
||||
#define E_BOMB_TICKER (0x2D)
|
||||
|
||||
extern bool e_bomb_lethal;
|
||||
extern U8 e_bomb_ticker;
|
||||
extern U8 e_bomb_xc;
|
||||
extern U16 e_bomb_yc;
|
||||
|
||||
extern bool e_bomb_hit(U8);
|
||||
extern void e_bomb_init(U16, U16);
|
||||
extern void e_bomb_action(U8);
|
||||
|
||||
#endif /* ndef _E_BOMB_H */
|
||||
|
||||
/* eof */
|
60
apps/plugins/xrick/e_bonus.c
Normal file
60
apps/plugins/xrick/e_bonus.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* xrick/e_bonus.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/e_bonus.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
|
||||
#include "xrick/e_rick.h"
|
||||
#include "xrick/maps.h"
|
||||
|
||||
|
||||
/*
|
||||
* Entity action
|
||||
*
|
||||
* ASM 242C
|
||||
*/
|
||||
void
|
||||
e_bonus_action(U8 e)
|
||||
{
|
||||
#define seq c1
|
||||
|
||||
if (ent_ents[e].seq == 0) {
|
||||
if (e_rick_boxtest(e)) {
|
||||
game_score += 500;
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundBonus, 1);
|
||||
#endif
|
||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
||||
ent_ents[e].seq = 1;
|
||||
ent_ents[e].sprite = 0xad;
|
||||
ent_ents[e].front = true;
|
||||
ent_ents[e].y -= 0x08;
|
||||
}
|
||||
}
|
||||
|
||||
else if (ent_ents[e].seq > 0 && ent_ents[e].seq < 10) {
|
||||
ent_ents[e].seq++;
|
||||
ent_ents[e].y -= 2;
|
||||
}
|
||||
|
||||
else {
|
||||
ent_ents[e].n = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
25
apps/plugins/xrick/e_bonus.h
Normal file
25
apps/plugins/xrick/e_bonus.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* xrick/e_bonus.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _E_BONUS_H
|
||||
#define _E_BONUS_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
extern void e_bonus_action(U8);
|
||||
|
||||
#endif /* ndef _E_BONUS_H */
|
||||
|
||||
/* eof */
|
109
apps/plugins/xrick/e_box.c
Normal file
109
apps/plugins/xrick/e_box.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* xrick/e_box.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/e_box.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/e_bullet.h"
|
||||
#include "xrick/e_bomb.h"
|
||||
#include "xrick/e_rick.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/util.h"
|
||||
|
||||
/*
|
||||
* FIXME this is because the same structure is used
|
||||
* for all entities. Need to replace this w/ an inheritance
|
||||
* solution.
|
||||
*/
|
||||
#define cnt c1
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
#define SEQ_INIT 0x0A
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
static void explode(U8);
|
||||
|
||||
/*
|
||||
* Entity action
|
||||
*
|
||||
* ASM 245A
|
||||
*/
|
||||
void
|
||||
e_box_action(U8 e)
|
||||
{
|
||||
static U8 sp[] = {0x24, 0x25, 0x26, 0x27, 0x28}; /* explosion sprites sequence */
|
||||
|
||||
if (ent_ents[e].n & ENT_LETHAL) {
|
||||
/*
|
||||
* box is lethal i.e. exploding
|
||||
* play sprites sequence then stop
|
||||
*/
|
||||
ent_ents[e].sprite = sp[ent_ents[e].cnt >> 1];
|
||||
if (--ent_ents[e].cnt == 0) {
|
||||
ent_ents[e].n = 0;
|
||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* not lethal: check to see if triggered
|
||||
*/
|
||||
if (e_rick_boxtest(e)) {
|
||||
/* rick: collect bombs or bullets and stop */
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundBox, 1);
|
||||
#endif
|
||||
if (ent_ents[e].n == 0x10)
|
||||
game_bombs = GAME_BOMBS_INIT;
|
||||
else /* 0x11 */
|
||||
game_bullets = GAME_BULLETS_INIT;
|
||||
ent_ents[e].n = 0;
|
||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
||||
}
|
||||
else if (e_rick_state_test(E_RICK_STSTOP) &&
|
||||
u_fboxtest(e, e_rick_stop_x, e_rick_stop_y)) {
|
||||
/* rick's stick: explode */
|
||||
explode(e);
|
||||
}
|
||||
else if (E_BULLET_ENT.n && u_fboxtest(e, e_bullet_xc, e_bullet_yc)) {
|
||||
/* bullet: explode (and stop bullet) */
|
||||
E_BULLET_ENT.n = 0;
|
||||
explode(e);
|
||||
}
|
||||
else if (e_bomb_lethal && e_bomb_hit(e)) {
|
||||
/* bomb: explode */
|
||||
explode(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Explode when
|
||||
*/
|
||||
static void explode(U8 e)
|
||||
{
|
||||
ent_ents[e].cnt = SEQ_INIT;
|
||||
ent_ents[e].n |= ENT_LETHAL;
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundExplode, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* eof */
|
25
apps/plugins/xrick/e_box.h
Normal file
25
apps/plugins/xrick/e_box.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* xrick/e_box.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _E_BOX_H
|
||||
#define _E_BOX_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
extern void e_box_action(U8);
|
||||
|
||||
#endif /* ndef _E_BOX_H */
|
||||
|
||||
/* eof */
|
84
apps/plugins/xrick/e_bullet.c
Normal file
84
apps/plugins/xrick/e_bullet.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* xrick/e_bullet.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/e_bullet.h"
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/maps.h"
|
||||
|
||||
/*
|
||||
* public vars (for performance reasons)
|
||||
*/
|
||||
S8 e_bullet_offsx;
|
||||
S16 e_bullet_xc, e_bullet_yc;
|
||||
|
||||
/*
|
||||
* Initialize bullet
|
||||
*/
|
||||
void
|
||||
e_bullet_init(U16 x, U16 y)
|
||||
{
|
||||
E_BULLET_ENT.n = 0x02;
|
||||
E_BULLET_ENT.x = x;
|
||||
E_BULLET_ENT.y = y + 0x0006;
|
||||
if (game_dir == LEFT) {
|
||||
e_bullet_offsx = -0x08;
|
||||
E_BULLET_ENT.sprite = 0x21;
|
||||
}
|
||||
else {
|
||||
e_bullet_offsx = 0x08;
|
||||
E_BULLET_ENT.sprite = 0x20;
|
||||
}
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundBullet, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Entity action
|
||||
*
|
||||
* ASM 1883, 0F97
|
||||
*/
|
||||
void
|
||||
e_bullet_action(U8 e/*unused*/)
|
||||
{
|
||||
(void)e;
|
||||
|
||||
/* move bullet */
|
||||
E_BULLET_ENT.x += e_bullet_offsx;
|
||||
|
||||
if (E_BULLET_ENT.x <= -0x10 || E_BULLET_ENT.x > 0xe8)
|
||||
{
|
||||
/* out: deactivate */
|
||||
E_BULLET_ENT.n = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* update bullet center coordinates */
|
||||
e_bullet_xc = E_BULLET_ENT.x + 0x0c;
|
||||
e_bullet_yc = E_BULLET_ENT.y + 0x05;
|
||||
if (map_eflg[map_map[e_bullet_yc >> 3][e_bullet_xc >> 3]] & MAP_EFLG_SOLID)
|
||||
{
|
||||
/* hit something: deactivate */
|
||||
E_BULLET_ENT.n = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
32
apps/plugins/xrick/e_bullet.h
Normal file
32
apps/plugins/xrick/e_bullet.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* xrick/e_bullet.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _E_BULLET_H
|
||||
#define _E_BULLET_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
#define E_BULLET_NO 2
|
||||
#define E_BULLET_ENT ent_ents[E_BULLET_NO]
|
||||
|
||||
extern S8 e_bullet_offsx;
|
||||
extern S16 e_bullet_xc, e_bullet_yc;
|
||||
|
||||
extern void e_bullet_init(U16, U16);
|
||||
extern void e_bullet_action(U8);
|
||||
|
||||
#endif /* ndef _E_BULLET_H */
|
||||
|
||||
/* eof */
|
606
apps/plugins/xrick/e_rick.c
Normal file
606
apps/plugins/xrick/e_rick.c
Normal file
|
@ -0,0 +1,606 @@
|
|||
/*
|
||||
* xrick/e_rick.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/e_rick.h"
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/e_bullet.h"
|
||||
#include "xrick/e_bomb.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/util.h"
|
||||
|
||||
/*
|
||||
* public vars
|
||||
*/
|
||||
S16 e_rick_stop_x = 0;
|
||||
S16 e_rick_stop_y = 0;
|
||||
unsigned e_rick_state = 0;
|
||||
|
||||
/*
|
||||
* public functions
|
||||
*/
|
||||
extern inline void e_rick_state_set(e_rick_state_t s);
|
||||
extern inline void e_rick_state_clear(e_rick_state_t s);
|
||||
extern inline bool e_rick_state_test(e_rick_state_t s);
|
||||
|
||||
|
||||
/*
|
||||
* local vars
|
||||
*/
|
||||
static U8 scrawl;
|
||||
|
||||
static bool trigger = false;
|
||||
|
||||
static S8 offsx;
|
||||
static U8 ylow;
|
||||
static S16 offsy;
|
||||
|
||||
static U8 seq;
|
||||
|
||||
static U8 save_crawl, save_direction;
|
||||
static U16 save_x, save_y;
|
||||
|
||||
|
||||
/*
|
||||
* Box test
|
||||
*
|
||||
* ASM 113E (based on)
|
||||
*
|
||||
* e: entity to test against (corresponds to SI in asm code -- here DI
|
||||
* is assumed to point to rick).
|
||||
* ret: true/intersect, false/not.
|
||||
*/
|
||||
bool
|
||||
e_rick_boxtest(U8 e)
|
||||
{
|
||||
/*
|
||||
* rick: x+0x05 to x+0x11, y+[0x08 if rick's crawling] to y+0x14
|
||||
* entity: x to x+w, y to y+h
|
||||
*/
|
||||
|
||||
if (E_RICK_ENT.x + 0x11 < ent_ents[e].x ||
|
||||
E_RICK_ENT.x + 0x05 > ent_ents[e].x + ent_ents[e].w ||
|
||||
E_RICK_ENT.y + 0x14 < ent_ents[e].y ||
|
||||
E_RICK_ENT.y + (e_rick_state_test(E_RICK_STCRAWL) ? 0x08 : 0x00) > ent_ents[e].y + ent_ents[e].h - 1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Go zombie
|
||||
*
|
||||
* ASM 1851
|
||||
*/
|
||||
void
|
||||
e_rick_gozombie(void)
|
||||
{
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (game_cheat2) return;
|
||||
#endif
|
||||
|
||||
/* already zombie? */
|
||||
if (e_rick_state_test(E_RICK_STZOMBIE)) return;
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundDie, 1);
|
||||
#endif
|
||||
|
||||
e_rick_state_set(E_RICK_STZOMBIE);
|
||||
offsy = -0x0300;
|
||||
offsx = (E_RICK_ENT.x > 0x80 ? -3 : +3);
|
||||
ylow = 0;
|
||||
E_RICK_ENT.front = true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action sub-function for e_rick when zombie
|
||||
*
|
||||
* ASM 17DC
|
||||
*/
|
||||
static void
|
||||
e_rick_z_action(void)
|
||||
{
|
||||
U32 i;
|
||||
|
||||
/* sprite */
|
||||
E_RICK_ENT.sprite = (E_RICK_ENT.x & 0x04) ? 0x1A : 0x19;
|
||||
|
||||
/* x */
|
||||
E_RICK_ENT.x += offsx;
|
||||
|
||||
/* y */
|
||||
i = (E_RICK_ENT.y << 8) + offsy + ylow;
|
||||
E_RICK_ENT.y = i >> 8;
|
||||
offsy += 0x80;
|
||||
ylow = i;
|
||||
|
||||
/* dead when out of screen */
|
||||
if (E_RICK_ENT.y < 0 || E_RICK_ENT.y > 0x0140)
|
||||
{
|
||||
e_rick_state_set(E_RICK_STDEAD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action sub-function for e_rick.
|
||||
*
|
||||
* ASM 13BE
|
||||
*/
|
||||
void
|
||||
e_rick_action2(void)
|
||||
{
|
||||
U8 env0, env1;
|
||||
S16 x, y;
|
||||
U32 i;
|
||||
|
||||
e_rick_state_clear(E_RICK_STSTOP | E_RICK_STSHOOT);
|
||||
|
||||
/* if zombie, run dedicated function and return */
|
||||
if (e_rick_state_test(E_RICK_STZOMBIE))
|
||||
{
|
||||
e_rick_z_action();
|
||||
return;
|
||||
}
|
||||
|
||||
/* climbing? */
|
||||
if (e_rick_state_test(E_RICK_STCLIMB))
|
||||
{
|
||||
goto climbing;
|
||||
}
|
||||
/*
|
||||
* NOT CLIMBING
|
||||
*/
|
||||
e_rick_state_clear(E_RICK_STJUMP);
|
||||
/* calc y */
|
||||
i = (E_RICK_ENT.y << 8) + offsy + ylow;
|
||||
y = i >> 8;
|
||||
/* test environment */
|
||||
u_envtest(E_RICK_ENT.x, y, e_rick_state_test(E_RICK_STCRAWL), &env0, &env1);
|
||||
/* stand up, if possible */
|
||||
if (e_rick_state_test(E_RICK_STCRAWL) && !env0)
|
||||
{
|
||||
e_rick_state_clear(E_RICK_STCRAWL);
|
||||
}
|
||||
/* can move vertically? */
|
||||
if (env1 & (offsy < 0 ?
|
||||
MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD :
|
||||
MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))
|
||||
goto vert_not;
|
||||
|
||||
/*
|
||||
* VERTICAL MOVE
|
||||
*/
|
||||
e_rick_state_set(E_RICK_STJUMP);
|
||||
/* killed? */
|
||||
if (env1 & MAP_EFLG_LETHAL) {
|
||||
e_rick_gozombie();
|
||||
return;
|
||||
}
|
||||
/* save */
|
||||
E_RICK_ENT.y = y;
|
||||
ylow = i;
|
||||
/* climb? */
|
||||
if ((env1 & MAP_EFLG_CLIMB) && (control_test(Control_UP | Control_DOWN)))
|
||||
{
|
||||
offsy = 0x0100;
|
||||
e_rick_state_set(E_RICK_STCLIMB);
|
||||
return;
|
||||
}
|
||||
/* fall */
|
||||
offsy += 0x0080;
|
||||
if (offsy > 0x0800) {
|
||||
offsy = 0x0800;
|
||||
ylow = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* HORIZONTAL MOVE
|
||||
*/
|
||||
horiz:
|
||||
/* should move? */
|
||||
if (!(control_test(Control_LEFT | Control_RIGHT))) {
|
||||
seq = 2; /* no: reset seq and return */
|
||||
return;
|
||||
}
|
||||
if (control_test(Control_LEFT)) { /* move left */
|
||||
x = E_RICK_ENT.x - 2;
|
||||
game_dir = LEFT;
|
||||
if (x < 0) { /* prev submap */
|
||||
game_chsm = true;
|
||||
E_RICK_ENT.x = 0xe2;
|
||||
return;
|
||||
}
|
||||
} else { /* move right */
|
||||
x = E_RICK_ENT.x + 2;
|
||||
game_dir = RIGHT;
|
||||
if (x >= 0xe8) { /* next submap */
|
||||
game_chsm = true;
|
||||
E_RICK_ENT.x = 0x04;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* still within this map: test environment */
|
||||
u_envtest(x, E_RICK_ENT.y, e_rick_state_test(E_RICK_STCRAWL), &env0, &env1);
|
||||
|
||||
/* save x-position if it is possible to move */
|
||||
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
||||
E_RICK_ENT.x = x;
|
||||
if (env1 & MAP_EFLG_LETHAL) e_rick_gozombie();
|
||||
}
|
||||
|
||||
/* end */
|
||||
return;
|
||||
|
||||
/*
|
||||
* NO VERTICAL MOVE
|
||||
*/
|
||||
vert_not:
|
||||
if (offsy < 0) {
|
||||
/* not climbing + trying to go _up_ not possible -> hit the roof */
|
||||
e_rick_state_set(E_RICK_STJUMP); /* fall back to the ground */
|
||||
E_RICK_ENT.y &= 0xF8;
|
||||
offsy = 0;
|
||||
ylow = 0;
|
||||
goto horiz;
|
||||
}
|
||||
/* else: not climbing + trying to go _down_ not possible -> standing */
|
||||
/* align to ground */
|
||||
E_RICK_ENT.y &= 0xF8;
|
||||
E_RICK_ENT.y |= 0x03;
|
||||
ylow = 0;
|
||||
|
||||
/* standing on a super pad? */
|
||||
if ((env1 & MAP_EFLG_SPAD) && offsy >= 0X0200) {
|
||||
offsy = (control_test(Control_UP)) ? 0xf800 : 0x00fe - offsy;
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundPad, 1);
|
||||
#endif
|
||||
goto horiz;
|
||||
}
|
||||
|
||||
offsy = 0x0100; /* reset*/
|
||||
|
||||
/* standing. firing ? */
|
||||
if (scrawl || !(control_test(Control_FIRE)))
|
||||
goto firing_not;
|
||||
|
||||
/*
|
||||
* FIRING
|
||||
*/
|
||||
if (control_test(Control_LEFT | Control_RIGHT)) { /* stop */
|
||||
if (control_test(Control_RIGHT))
|
||||
{
|
||||
game_dir = RIGHT;
|
||||
e_rick_stop_x = E_RICK_ENT.x + 0x17;
|
||||
} else {
|
||||
game_dir = LEFT;
|
||||
e_rick_stop_x = E_RICK_ENT.x;
|
||||
}
|
||||
e_rick_stop_y = E_RICK_ENT.y + 0x000E;
|
||||
e_rick_state_set(E_RICK_STSTOP);
|
||||
return;
|
||||
}
|
||||
|
||||
if (control_test(Control_UP)) { /* bullet */
|
||||
e_rick_state_set(E_RICK_STSHOOT);
|
||||
/* not an automatic gun: shoot once only */
|
||||
if (trigger)
|
||||
return;
|
||||
else
|
||||
trigger = true;
|
||||
/* already a bullet in the air ... that's enough */
|
||||
if (E_BULLET_ENT.n)
|
||||
return;
|
||||
/* else use a bullet, if any available */
|
||||
if (!game_bullets)
|
||||
return;
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (!game_cheat1)
|
||||
#endif
|
||||
{
|
||||
game_bullets--;
|
||||
}
|
||||
|
||||
/* initialize bullet */
|
||||
e_bullet_init(E_RICK_ENT.x, E_RICK_ENT.y);
|
||||
return;
|
||||
}
|
||||
|
||||
trigger = false; /* not shooting means trigger is released */
|
||||
seq = 0; /* reset */
|
||||
|
||||
if (control_test(Control_DOWN)) { /* bomb */
|
||||
/* already a bomb ticking ... that's enough */
|
||||
if (E_BOMB_ENT.n)
|
||||
return;
|
||||
/* else use a bomb, if any available */
|
||||
if (!game_bombs)
|
||||
return;
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (!game_cheat1)
|
||||
#endif
|
||||
{
|
||||
game_bombs--;
|
||||
}
|
||||
|
||||
/* initialize bomb */
|
||||
e_bomb_init(E_RICK_ENT.x, E_RICK_ENT.y);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
* NOT FIRING
|
||||
*/
|
||||
firing_not:
|
||||
if (control_test(Control_UP)) { /* jump or climb */
|
||||
if (env1 & MAP_EFLG_CLIMB) { /* climb */
|
||||
e_rick_state_set(E_RICK_STCLIMB);
|
||||
return;
|
||||
}
|
||||
offsy = -0x0580; /* jump */
|
||||
ylow = 0;
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundJump, 1);
|
||||
#endif
|
||||
goto horiz;
|
||||
}
|
||||
if (control_test(Control_DOWN)) { /* crawl or climb */
|
||||
if ((env1 & MAP_EFLG_VERT) && /* can go down */
|
||||
!(control_test(Control_LEFT | Control_RIGHT)) && /* + not moving horizontaly */
|
||||
(E_RICK_ENT.x & 0x1f) < 0x0a) { /* + aligned -> climb */
|
||||
E_RICK_ENT.x &= 0xf0;
|
||||
E_RICK_ENT.x |= 0x04;
|
||||
e_rick_state_set(E_RICK_STCLIMB);
|
||||
}
|
||||
else { /* crawl */
|
||||
e_rick_state_set(E_RICK_STCRAWL);
|
||||
goto horiz;
|
||||
}
|
||||
|
||||
}
|
||||
goto horiz;
|
||||
|
||||
/*
|
||||
* CLIMBING
|
||||
*/
|
||||
climbing:
|
||||
/* should move? */
|
||||
if (!(control_test(Control_UP | Control_DOWN | Control_LEFT | Control_RIGHT))) {
|
||||
seq = 0; /* no: reset seq and return */
|
||||
return;
|
||||
}
|
||||
|
||||
if (control_test(Control_UP | Control_DOWN)) {
|
||||
/* up-down: calc new y and test environment */
|
||||
y = E_RICK_ENT.y + ((control_test(Control_UP)) ? -0x02 : 0x02);
|
||||
u_envtest(E_RICK_ENT.x, y, e_rick_state_test(E_RICK_STCRAWL), &env0, &env1);
|
||||
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP) &&
|
||||
!(control_test(Control_UP))) {
|
||||
/* FIXME what? */
|
||||
e_rick_state_clear(E_RICK_STCLIMB);
|
||||
return;
|
||||
}
|
||||
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) ||
|
||||
(env1 & MAP_EFLG_WAYUP)) {
|
||||
/* ok to move, save */
|
||||
E_RICK_ENT.y = y;
|
||||
if (env1 & MAP_EFLG_LETHAL) {
|
||||
e_rick_gozombie();
|
||||
return;
|
||||
}
|
||||
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB))) {
|
||||
/* reached end of climb zone */
|
||||
offsy = (control_test(Control_UP)) ? -0x0300 : 0x0100;
|
||||
#ifdef ENABLE_SOUND
|
||||
if (control_test(Control_UP))
|
||||
syssnd_play(soundJump, 1);
|
||||
#endif
|
||||
e_rick_state_clear(E_RICK_STCLIMB);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (control_test(Control_LEFT | Control_RIGHT)) {
|
||||
/* left-right: calc new x and test environment */
|
||||
if (control_test(Control_LEFT)) {
|
||||
x = E_RICK_ENT.x - 0x02;
|
||||
if (x < 0) { /* (i.e. negative) prev submap */
|
||||
game_chsm = true;
|
||||
/*6dbd = 0x00;*/
|
||||
E_RICK_ENT.x = 0xe2;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
x = E_RICK_ENT.x + 0x02;
|
||||
if (x >= 0xe8) { /* next submap */
|
||||
game_chsm = true;
|
||||
/*6dbd = 0x01;*/
|
||||
E_RICK_ENT.x = 0x04;
|
||||
return;
|
||||
}
|
||||
}
|
||||
u_envtest(x, E_RICK_ENT.y, e_rick_state_test(E_RICK_STCRAWL), &env0, &env1);
|
||||
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD)) return;
|
||||
E_RICK_ENT.x = x;
|
||||
if (env1 & MAP_EFLG_LETHAL) {
|
||||
e_rick_gozombie();
|
||||
return;
|
||||
}
|
||||
|
||||
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) return;
|
||||
e_rick_state_clear(E_RICK_STCLIMB);
|
||||
if (control_test(Control_UP))
|
||||
offsy = -0x0300;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action function for e_rick
|
||||
*
|
||||
* ASM 12CA
|
||||
*/
|
||||
void e_rick_action(U8 e/*unused*/)
|
||||
{
|
||||
static U8 stopped = false; /* is this the most elegant way? */
|
||||
|
||||
(void)e;
|
||||
|
||||
e_rick_action2();
|
||||
|
||||
scrawl = e_rick_state_test(E_RICK_STCRAWL);
|
||||
|
||||
if (e_rick_state_test(E_RICK_STZOMBIE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* set sprite
|
||||
*/
|
||||
|
||||
if (e_rick_state_test(E_RICK_STSTOP))
|
||||
{
|
||||
E_RICK_ENT.sprite = (game_dir ? 0x17 : 0x0B);
|
||||
#ifdef ENABLE_SOUND
|
||||
if (!stopped)
|
||||
{
|
||||
syssnd_play(soundStick, 1);
|
||||
stopped = true;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
stopped = false;
|
||||
|
||||
if (e_rick_state_test(E_RICK_STSHOOT))
|
||||
{
|
||||
E_RICK_ENT.sprite = (game_dir ? 0x16 : 0x0A);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e_rick_state_test(E_RICK_STCLIMB))
|
||||
{
|
||||
E_RICK_ENT.sprite = (((E_RICK_ENT.x ^ E_RICK_ENT.y) & 0x04) ? 0x18 : 0x0c);
|
||||
#ifdef ENABLE_SOUND
|
||||
seq = (seq + 1) & 0x03;
|
||||
if (seq == 0) syssnd_play(soundWalk, 1);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (e_rick_state_test(E_RICK_STCRAWL))
|
||||
{
|
||||
E_RICK_ENT.sprite = (game_dir ? 0x13 : 0x07);
|
||||
if (E_RICK_ENT.x & 0x04) E_RICK_ENT.sprite++;
|
||||
#ifdef ENABLE_SOUND
|
||||
seq = (seq + 1) & 0x03;
|
||||
if (seq == 0) syssnd_play(soundCrawl, 1);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (e_rick_state_test(E_RICK_STJUMP))
|
||||
{
|
||||
E_RICK_ENT.sprite = (game_dir ? 0x15 : 0x06);
|
||||
return;
|
||||
}
|
||||
|
||||
seq++;
|
||||
|
||||
if (seq >= 0x14)
|
||||
{
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundWalk, 1);
|
||||
#endif
|
||||
seq = 0x04;
|
||||
}
|
||||
#ifdef ENABLE_SOUND
|
||||
else
|
||||
{
|
||||
if (seq == 0x0C)
|
||||
{
|
||||
syssnd_play(soundWalk, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
E_RICK_ENT.sprite = (seq >> 2) + 1 + (game_dir ? 0x0c : 0x00);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Save status
|
||||
*
|
||||
* ASM part of 0x0BBB
|
||||
*/
|
||||
void e_rick_save(void)
|
||||
{
|
||||
save_x = E_RICK_ENT.x;
|
||||
save_y = E_RICK_ENT.y;
|
||||
save_crawl = e_rick_state_test(E_RICK_STCRAWL);
|
||||
save_direction = game_dir;
|
||||
/* FIXME
|
||||
* save_C0 = E_RICK_ENT.b0C;
|
||||
* plus some 6DBC stuff?
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Restore status
|
||||
*
|
||||
* ASM part of 0x0BDC
|
||||
*/
|
||||
void e_rick_restore(void)
|
||||
{
|
||||
E_RICK_ENT.x = save_x;
|
||||
E_RICK_ENT.y = save_y;
|
||||
if (save_crawl)
|
||||
{
|
||||
e_rick_state_set(E_RICK_STCRAWL);
|
||||
}
|
||||
else
|
||||
{
|
||||
e_rick_state_clear(E_RICK_STCRAWL);
|
||||
}
|
||||
game_dir = save_direction;
|
||||
|
||||
E_RICK_ENT.front = false;
|
||||
e_rick_state_clear(E_RICK_STCLIMB); /* should we clear other states? */
|
||||
/* FIXME
|
||||
* E_RICK_ENT.b0C = save_C0;
|
||||
* plus some 6DBC stuff?
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* eof */
|
50
apps/plugins/xrick/e_rick.h
Normal file
50
apps/plugins/xrick/e_rick.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* xrick/e_rick.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _E_RICK_H
|
||||
#define _E_RICK_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
#define E_RICK_NO 1
|
||||
#define E_RICK_ENT ent_ents[E_RICK_NO]
|
||||
|
||||
typedef enum
|
||||
{
|
||||
E_RICK_STSTOP = (1 << 0),
|
||||
E_RICK_STSHOOT = (1 << 1),
|
||||
E_RICK_STCLIMB = (1 << 2),
|
||||
E_RICK_STJUMP = (1 << 3),
|
||||
E_RICK_STZOMBIE = (1 << 4),
|
||||
E_RICK_STDEAD = (1 << 5),
|
||||
E_RICK_STCRAWL = (1 << 6),
|
||||
} e_rick_state_t;
|
||||
|
||||
extern unsigned e_rick_state;
|
||||
inline void e_rick_state_set(e_rick_state_t s) { e_rick_state |= s; }
|
||||
inline void e_rick_state_clear(e_rick_state_t s) { e_rick_state &= ~s; }
|
||||
inline bool e_rick_state_test(e_rick_state_t s) { return e_rick_state & s; }
|
||||
|
||||
extern S16 e_rick_stop_x, e_rick_stop_y;
|
||||
|
||||
extern void e_rick_save(void);
|
||||
extern void e_rick_restore(void);
|
||||
extern void e_rick_action(U8);
|
||||
extern void e_rick_gozombie(void);
|
||||
extern bool e_rick_boxtest(U8);
|
||||
|
||||
#endif /* ndef _E_RICK_H */
|
||||
|
||||
/* eof */
|
88
apps/plugins/xrick/e_sbonus.c
Normal file
88
apps/plugins/xrick/e_sbonus.c
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* xrick/e_sbonus.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/e_sbonus.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/util.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/e_rick.h"
|
||||
|
||||
|
||||
/*
|
||||
* public vars
|
||||
*/
|
||||
bool e_sbonus_counting = false;
|
||||
U8 e_sbonus_counter = 0;
|
||||
U16 e_sbonus_bonus = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Entity action / start counting
|
||||
*
|
||||
* ASM 2182
|
||||
*/
|
||||
void
|
||||
e_sbonus_start(U8 e)
|
||||
{
|
||||
ent_ents[e].sprite = 0; /* invisible */
|
||||
if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
|
||||
/* rick is within trigger box */
|
||||
ent_ents[e].n = 0;
|
||||
e_sbonus_counting = true; /* 6DD5 */
|
||||
e_sbonus_counter = 0x1e; /* 6DDB */
|
||||
e_sbonus_bonus = 2000; /* 291A-291D */
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundSbonus1, 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Entity action / stop counting
|
||||
*
|
||||
* ASM 2143
|
||||
*/
|
||||
void
|
||||
e_sbonus_stop(U8 e)
|
||||
{
|
||||
ent_ents[e].sprite = 0; /* invisible */
|
||||
|
||||
if (!e_sbonus_counting)
|
||||
return;
|
||||
|
||||
if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
|
||||
/* rick is within trigger box */
|
||||
e_sbonus_counting = false; /* stop counting */
|
||||
ent_ents[e].n = 0; /* deactivate entity */
|
||||
game_score += e_sbonus_bonus; /* add bonus to score */
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundSbonus2, 1);
|
||||
#endif
|
||||
/* make sure the entity won't be activated again */
|
||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
||||
}
|
||||
else {
|
||||
/* keep counting */
|
||||
if (--e_sbonus_counter == 0) {
|
||||
e_sbonus_counter = 0x1e;
|
||||
if (e_sbonus_bonus) e_sbonus_bonus--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* eof */
|
30
apps/plugins/xrick/e_sbonus.h
Normal file
30
apps/plugins/xrick/e_sbonus.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* xrick/e_sbonus.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _E_SBONUS_H
|
||||
#define _E_SBONUS_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
extern bool e_sbonus_counting;
|
||||
extern U8 e_sbonus_counter;
|
||||
extern U16 e_sbonus_bonus;
|
||||
|
||||
extern void e_sbonus_start(U8);
|
||||
extern void e_sbonus_stop(U8);
|
||||
|
||||
#endif /* ndef _E_SBONUS_H */
|
||||
|
||||
/* eof */
|
738
apps/plugins/xrick/e_them.c
Normal file
738
apps/plugins/xrick/e_them.c
Normal file
|
@ -0,0 +1,738 @@
|
|||
/*
|
||||
* xrick/e_them.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/e_them.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/e_rick.h"
|
||||
#include "xrick/e_bomb.h"
|
||||
#include "xrick/e_bullet.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/util.h"
|
||||
|
||||
#define TYPE_1A (0x00)
|
||||
#define TYPE_1B (0xff)
|
||||
|
||||
/*
|
||||
* public vars
|
||||
*/
|
||||
U32 e_them_rndseed = 0;
|
||||
|
||||
/*
|
||||
* local vars
|
||||
*/
|
||||
static U16 e_them_rndnbr = 0;
|
||||
|
||||
/*
|
||||
* Check if entity boxtests with a lethal e_them i.e. something lethal
|
||||
* in slot 0 and 4 to 8.
|
||||
*
|
||||
* ASM 122E
|
||||
*
|
||||
* e: entity slot number.
|
||||
* ret: true/boxtests, false/not
|
||||
*/
|
||||
static bool
|
||||
u_themtest(U8 e)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
if ((ent_ents[0].n & ENT_LETHAL) && u_boxtest(e, 0))
|
||||
return true;
|
||||
|
||||
for (i = 4; i < 9; i++)
|
||||
if ((ent_ents[i].n & ENT_LETHAL) && u_boxtest(e, i))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Go zombie
|
||||
*
|
||||
* ASM 237B
|
||||
*/
|
||||
void
|
||||
e_them_gozombie(U8 e)
|
||||
{
|
||||
#define offsx c1
|
||||
ent_ents[e].n = 0x47; /* zombie entity */
|
||||
ent_ents[e].front = true;
|
||||
ent_ents[e].offsy = -0x0400;
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_play(soundDie, 1);
|
||||
#endif
|
||||
game_score += 50;
|
||||
if (ent_ents[e].flags & ENT_FLG_ONCE) {
|
||||
/* make sure entity won't be activated again */
|
||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
||||
}
|
||||
ent_ents[e].offsx = (ent_ents[e].x >= 0x80 ? -0x02 : 0x02);
|
||||
#undef offsx
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action sub-function for e_them _t1a and _t1b
|
||||
*
|
||||
* Those two types move horizontally, and fall if they have to.
|
||||
* Type 1a moves horizontally over a given distance and then
|
||||
* u-turns and repeats; type 1b is more subtle as it does u-turns
|
||||
* in order to move horizontally towards rick.
|
||||
*
|
||||
* ASM 2242
|
||||
*/
|
||||
void
|
||||
e_them_t1_action2(U8 e, U8 type)
|
||||
{
|
||||
#define offsx c1
|
||||
#define step_count c2
|
||||
U32 i;
|
||||
S16 x, y;
|
||||
U8 env0, env1;
|
||||
|
||||
/* by default, try vertical move. calculate new y */
|
||||
i = (ent_ents[e].y << 8) + ent_ents[e].offsy + ent_ents[e].ylow;
|
||||
y = i >> 8;
|
||||
|
||||
/* deactivate if outside vertical boundaries */
|
||||
/* no need to test zero since e_them _t1a/b don't go up */
|
||||
/* FIXME what if they got scrolled out ? */
|
||||
if (y > 0x140) {
|
||||
ent_ents[e].n = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* test environment */
|
||||
u_envtest(ent_ents[e].x, y, false, &env0, &env1);
|
||||
|
||||
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
||||
/* vertical move possible: falling */
|
||||
if (env1 & MAP_EFLG_LETHAL) {
|
||||
/* lethal entities kill e_them */
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
/* save, cleanup and return */
|
||||
ent_ents[e].y = y;
|
||||
ent_ents[e].ylow = i;
|
||||
ent_ents[e].offsy += 0x0080;
|
||||
if (ent_ents[e].offsy > 0x0800)
|
||||
ent_ents[e].offsy = 0x0800;
|
||||
return;
|
||||
}
|
||||
|
||||
/* vertical move not possible. calculate new sprite */
|
||||
ent_ents[e].sprite = ent_ents[e].sprbase
|
||||
+ ent_sprseq[(ent_ents[e].x & 0x1c) >> 3]
|
||||
+ (ent_ents[e].offsx < 0 ? 0x03 : 0x00);
|
||||
|
||||
/* reset offsy */
|
||||
ent_ents[e].offsy = 0x0080;
|
||||
|
||||
/* align to ground */
|
||||
ent_ents[e].y &= 0xfff8;
|
||||
ent_ents[e].y |= 0x0003;
|
||||
|
||||
/* latency: if not zero then decrease and return */
|
||||
if (ent_ents[e].latency > 0) {
|
||||
ent_ents[e].latency--;
|
||||
return;
|
||||
}
|
||||
|
||||
/* horizontal move. calculate new x */
|
||||
if (ent_ents[e].offsx == 0) /* not supposed to move -> don't */
|
||||
return;
|
||||
|
||||
x = ent_ents[e].x + ent_ents[e].offsx;
|
||||
if (ent_ents[e].x < 0 || ent_ents[e].x > 0xe8) {
|
||||
/* U-turn and return if reaching horizontal boundaries */
|
||||
ent_ents[e].step_count = 0;
|
||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
||||
return;
|
||||
}
|
||||
|
||||
/* test environment */
|
||||
u_envtest(x, ent_ents[e].y, false, &env0, &env1);
|
||||
|
||||
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
|
||||
/* horizontal move not possible: u-turn and return */
|
||||
ent_ents[e].step_count = 0;
|
||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
||||
return;
|
||||
}
|
||||
|
||||
/* horizontal move possible */
|
||||
if (env1 & MAP_EFLG_LETHAL) {
|
||||
/* lethal entities kill e_them */
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/* save */
|
||||
ent_ents[e].x = x;
|
||||
|
||||
/* depending on type, */
|
||||
if (type == TYPE_1B) {
|
||||
/* set direction to move horizontally towards rick */
|
||||
if ((ent_ents[e].x & 0x1e) != 0x10) /* prevents too frequent u-turns */
|
||||
return;
|
||||
ent_ents[e].offsx = (ent_ents[e].x < E_RICK_ENT.x) ? 0x02 : -0x02;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
/* set direction according to step counter */
|
||||
ent_ents[e].step_count++;
|
||||
/* FIXME why trig_x (b16) ?? */
|
||||
if ((ent_ents[e].trig_x >> 1) > ent_ents[e].step_count)
|
||||
return;
|
||||
}
|
||||
|
||||
/* type is 1A and step counter reached its limit: u-turn */
|
||||
ent_ents[e].step_count = 0;
|
||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
||||
#undef offsx
|
||||
#undef step_count
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ASM 21CF
|
||||
*/
|
||||
void
|
||||
e_them_t1_action(U8 e, U8 type)
|
||||
{
|
||||
e_them_t1_action2(e, type);
|
||||
|
||||
/* lethal entities kill them */
|
||||
if (u_themtest(e)) {
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/* bullet kills them */
|
||||
if (E_BULLET_ENT.n &&
|
||||
u_fboxtest(e, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 0 : 0x18),
|
||||
E_BULLET_ENT.y)) {
|
||||
E_BULLET_ENT.n = 0;
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/* bomb kills them */
|
||||
if (e_bomb_lethal && e_bomb_hit(e)) {
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/* rick stops them */
|
||||
if (e_rick_state_test(E_RICK_STSTOP) &&
|
||||
u_fboxtest(e, e_rick_stop_x, e_rick_stop_y))
|
||||
ent_ents[e].latency = 0x14;
|
||||
|
||||
/* they kill rick */
|
||||
if (e_rick_boxtest(e))
|
||||
e_rick_gozombie();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action function for e_them _t1a type (stays within boundaries)
|
||||
*
|
||||
* ASM 2452
|
||||
*/
|
||||
void
|
||||
e_them_t1a_action(U8 e)
|
||||
{
|
||||
e_them_t1_action(e, TYPE_1A);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action function for e_them _t1b type (runs for rick)
|
||||
*
|
||||
* ASM 21CA
|
||||
*/
|
||||
void
|
||||
e_them_t1b_action(U8 e)
|
||||
{
|
||||
e_them_t1_action(e, TYPE_1B);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action function for e_them _z (zombie) type
|
||||
*
|
||||
* ASM 23B8
|
||||
*/
|
||||
void
|
||||
e_them_z_action(U8 e)
|
||||
{
|
||||
#define offsx c1
|
||||
U32 i;
|
||||
|
||||
/* calc new sprite */
|
||||
ent_ents[e].sprite = ent_ents[e].sprbase
|
||||
+ ((ent_ents[e].x & 0x04) ? 0x07 : 0x06);
|
||||
|
||||
/* calc new y */
|
||||
i = (ent_ents[e].y << 8) + ent_ents[e].offsy + ent_ents[e].ylow;
|
||||
|
||||
/* deactivate if out of vertical boundaries */
|
||||
if (ent_ents[e].y < 0 || ent_ents[e].y > 0x0140) {
|
||||
ent_ents[e].n = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* save */
|
||||
ent_ents[e].offsy += 0x0080;
|
||||
ent_ents[e].ylow = i;
|
||||
ent_ents[e].y = i >> 8;
|
||||
|
||||
/* calc new x */
|
||||
ent_ents[e].x += ent_ents[e].offsx;
|
||||
|
||||
/* must stay within horizontal boundaries */
|
||||
if (ent_ents[e].x < 0)
|
||||
ent_ents[e].x = 0;
|
||||
if (ent_ents[e].x > 0xe8)
|
||||
ent_ents[e].x = 0xe8;
|
||||
#undef offsx
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action sub-function for e_them _t2.
|
||||
*
|
||||
* Must document what it does.
|
||||
*
|
||||
* ASM 2792
|
||||
*/
|
||||
void
|
||||
e_them_t2_action2(U8 e)
|
||||
{
|
||||
#define flgclmb c1
|
||||
#define offsx c2
|
||||
U32 i;
|
||||
S16 x, y, yd;
|
||||
U8 env0, env1;
|
||||
|
||||
/*
|
||||
* vars required by the Black Magic (tm) performance at the
|
||||
* end of this function.
|
||||
*/
|
||||
static U16 bx;
|
||||
static U8 *bl = (U8 *)&bx;
|
||||
static U8 *bh = (U8 *)&bx + 1;
|
||||
static U16 cx;
|
||||
static U8 *cl = (U8 *)&cx;
|
||||
static U8 *ch = (U8 *)&cx + 1;
|
||||
static U16 *sl = (U16 *)&e_them_rndseed;
|
||||
static U16 *sh = (U16 *)&e_them_rndseed + 2;
|
||||
|
||||
/*sys_printf("e_them_t2 ------------------------------\n");*/
|
||||
|
||||
/* latency: if not zero then decrease */
|
||||
if (ent_ents[e].latency > 0) ent_ents[e].latency--;
|
||||
|
||||
/* climbing? */
|
||||
if (!ent_ents[e].flgclmb) goto climbing_not;
|
||||
|
||||
/* CLIMBING */
|
||||
|
||||
/*sys_printf("e_them_t2 climbing\n");*/
|
||||
|
||||
/* latency: if not zero then return */
|
||||
if (ent_ents[e].latency > 0) return;
|
||||
|
||||
/* calc new sprite */
|
||||
ent_ents[e].sprite = ent_ents[e].sprbase + 0x08 +
|
||||
(((ent_ents[e].x ^ ent_ents[e].y) & 0x04) ? 1 : 0);
|
||||
|
||||
/* reached rick's level? */
|
||||
if ((ent_ents[e].y & 0xfe) != (E_RICK_ENT.y & 0xfe)) goto ymove;
|
||||
|
||||
xmove:
|
||||
/* calc new x and test environment */
|
||||
ent_ents[e].offsx = (ent_ents[e].x < E_RICK_ENT.x) ? 0x02 : -0x02;
|
||||
x = ent_ents[e].x + ent_ents[e].offsx;
|
||||
u_envtest(x, ent_ents[e].y, false, &env0, &env1);
|
||||
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))
|
||||
return;
|
||||
if (env1 & MAP_EFLG_LETHAL) {
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
ent_ents[e].x = x;
|
||||
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
|
||||
return;
|
||||
goto climbing_not; /* not climbing anymore */
|
||||
|
||||
ymove:
|
||||
/* calc new y and test environment */
|
||||
yd = ent_ents[e].y < E_RICK_ENT.y ? 0x02 : -0x02;
|
||||
y = ent_ents[e].y + yd;
|
||||
if (y < 0 || y > 0x0140) {
|
||||
ent_ents[e].n = 0;
|
||||
return;
|
||||
}
|
||||
u_envtest(ent_ents[e].x, y, false, &env0, &env1);
|
||||
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
|
||||
if (yd < 0)
|
||||
goto xmove; /* can't go up */
|
||||
else
|
||||
goto climbing_not; /* can't go down */
|
||||
}
|
||||
/* can move */
|
||||
ent_ents[e].y = y;
|
||||
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
|
||||
return;
|
||||
|
||||
/* NOT CLIMBING */
|
||||
|
||||
climbing_not:
|
||||
/*sys_printf("e_them_t2 climbing NOT\n");*/
|
||||
|
||||
ent_ents[e].flgclmb = false; /* not climbing */
|
||||
|
||||
/* calc new y (falling) and test environment */
|
||||
i = (ent_ents[e].y << 8) + ent_ents[e].offsy + ent_ents[e].ylow;
|
||||
y = i >> 8;
|
||||
u_envtest(ent_ents[e].x, y, false, &env0, &env1);
|
||||
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
||||
/*sys_printf("e_them_t2 y move OK\n");*/
|
||||
/* can go there */
|
||||
if (env1 & MAP_EFLG_LETHAL) {
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
if (y > 0x0140) { /* deactivate if outside */
|
||||
ent_ents[e].n = 0;
|
||||
return;
|
||||
}
|
||||
if (!(env1 & MAP_EFLG_VERT)) {
|
||||
/* save */
|
||||
ent_ents[e].y = y;
|
||||
ent_ents[e].ylow = i;
|
||||
ent_ents[e].offsy += 0x0080;
|
||||
if (ent_ents[e].offsy > 0x0800)
|
||||
ent_ents[e].offsy = 0x0800;
|
||||
return;
|
||||
}
|
||||
if (((ent_ents[e].x & 0x07) == 0x04) && (y < E_RICK_ENT.y)) {
|
||||
/*sys_printf("e_them_t2 climbing00\n");*/
|
||||
ent_ents[e].flgclmb = true; /* climbing */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*sys_printf("e_them_t2 ymove nok or ...\n");*/
|
||||
/* can't go there, or ... */
|
||||
ent_ents[e].y = (ent_ents[e].y & 0xf8) | 0x03; /* align to ground */
|
||||
ent_ents[e].offsy = 0x0100;
|
||||
if (ent_ents[e].latency != 00)
|
||||
return;
|
||||
|
||||
if ((env1 & MAP_EFLG_CLIMB) &&
|
||||
((ent_ents[e].x & 0x0e) == 0x04) &&
|
||||
(ent_ents[e].y > E_RICK_ENT.y)) {
|
||||
/*sys_printf("e_them_t2 climbing01\n");*/
|
||||
ent_ents[e].flgclmb = true; /* climbing */
|
||||
return;
|
||||
}
|
||||
|
||||
/* calc new sprite */
|
||||
ent_ents[e].sprite = ent_ents[e].sprbase +
|
||||
ent_sprseq[(ent_ents[e].offsx < 0 ? 4 : 0) +
|
||||
((ent_ents[e].x & 0x0e) >> 3)];
|
||||
/*sys_printf("e_them_t2 sprite %02x\n", ent_ents[e].sprite);*/
|
||||
|
||||
|
||||
/* */
|
||||
if (ent_ents[e].offsx == 0)
|
||||
ent_ents[e].offsx = 2;
|
||||
x = ent_ents[e].x + ent_ents[e].offsx;
|
||||
/*sys_printf("e_them_t2 xmove x=%02x\n", x);*/
|
||||
if (x < 0xe8) {
|
||||
u_envtest(x, ent_ents[e].y, false, &env0, &env1);
|
||||
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
||||
ent_ents[e].x = x;
|
||||
if ((x & 0x1e) != 0x08)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Black Magic (tm)
|
||||
*
|
||||
* this is obviously some sort of randomizer to define a direction
|
||||
* for the entity. it is an exact copy of what the assembler code
|
||||
* does but I can't explain.
|
||||
*/
|
||||
bx = e_them_rndnbr + *sh + *sl + 0x0d;
|
||||
cx = *sh;
|
||||
*bl ^= *ch;
|
||||
*bl ^= *cl;
|
||||
*bl ^= *bh;
|
||||
e_them_rndnbr = bx;
|
||||
|
||||
ent_ents[e].offsx = (*bl & 0x01) ? -0x02 : 0x02;
|
||||
|
||||
/* back to normal */
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* U-turn */
|
||||
/*sys_printf("e_them_t2 u-turn\n");*/
|
||||
if (ent_ents[e].offsx == 0)
|
||||
ent_ents[e].offsx = 2;
|
||||
else
|
||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
||||
#undef offsx
|
||||
}
|
||||
|
||||
/*
|
||||
* Action function for e_them _t2 type
|
||||
*
|
||||
* ASM 2718
|
||||
*/
|
||||
void
|
||||
e_them_t2_action(U8 e)
|
||||
{
|
||||
e_them_t2_action2(e);
|
||||
|
||||
/* they kill rick */
|
||||
if (e_rick_boxtest(e))
|
||||
e_rick_gozombie();
|
||||
|
||||
/* lethal entities kill them */
|
||||
if (u_themtest(e)) {
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/* bullet kills them */
|
||||
if (E_BULLET_ENT.n &&
|
||||
u_fboxtest(e, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 00 : 0x18),
|
||||
E_BULLET_ENT.y)) {
|
||||
E_BULLET_ENT.n = 0;
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/* bomb kills them */
|
||||
if (e_bomb_lethal && e_bomb_hit(e)) {
|
||||
e_them_gozombie(e);
|
||||
return;
|
||||
}
|
||||
|
||||
/* rick stops them */
|
||||
if (e_rick_state_test(E_RICK_STSTOP) &&
|
||||
u_fboxtest(e, e_rick_stop_x, e_rick_stop_y))
|
||||
ent_ents[e].latency = 0x14;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action sub-function for e_them _t3
|
||||
*
|
||||
* FIXME always starts asleep??
|
||||
*
|
||||
* Waits until triggered by something, then execute move steps from
|
||||
* ent_mvstep with sprite from ent_sprseq. When done, either restart
|
||||
* or disappear.
|
||||
*
|
||||
* Not always lethal ... but if lethal, kills rick.
|
||||
*
|
||||
* ASM: 255A
|
||||
*/
|
||||
void
|
||||
e_them_t3_action2(U8 e)
|
||||
{
|
||||
#define sproffs c1
|
||||
#define step_count c2
|
||||
U8 i;
|
||||
S16 x, y;
|
||||
int wav_index;
|
||||
|
||||
while (1) {
|
||||
|
||||
/* calc new sprite */
|
||||
i = ent_sprseq[ent_ents[e].sprbase + ent_ents[e].sproffs];
|
||||
if (i == 0xff)
|
||||
i = ent_sprseq[ent_ents[e].sprbase];
|
||||
ent_ents[e].sprite = i;
|
||||
|
||||
if (ent_ents[e].sproffs != 0) { /* awake */
|
||||
|
||||
/* rotate sprseq */
|
||||
if (ent_sprseq[ent_ents[e].sprbase + ent_ents[e].sproffs] != 0xff)
|
||||
ent_ents[e].sproffs++;
|
||||
if (ent_sprseq[ent_ents[e].sprbase + ent_ents[e].sproffs] == 0xff)
|
||||
ent_ents[e].sproffs = 1;
|
||||
|
||||
if (ent_ents[e].step_count < ent_mvstep[ent_ents[e].step_no].count) {
|
||||
/*
|
||||
* still running this step: try to increment x and y while
|
||||
* checking that they remain within boudaries. if so, return.
|
||||
* else switch to next step.
|
||||
*/
|
||||
ent_ents[e].step_count++;
|
||||
x = ent_ents[e].x + ent_mvstep[ent_ents[e].step_no].dx;
|
||||
|
||||
/* check'n save */
|
||||
if (x > 0 && x < 0xe8) {
|
||||
ent_ents[e].x = x;
|
||||
/*FIXME*/
|
||||
/*
|
||||
y = ent_mvstep[ent_ents[e].step_no].dy;
|
||||
if (y < 0)
|
||||
y += 0xff00;
|
||||
y += ent_ents[e].y;
|
||||
*/
|
||||
y = ent_ents[e].y + ent_mvstep[ent_ents[e].step_no].dy;
|
||||
if (y > 0 && y < 0x0140) {
|
||||
ent_ents[e].y = y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* step is done, or x or y is outside boundaries. try to
|
||||
* switch to next step
|
||||
*/
|
||||
ent_ents[e].step_no++;
|
||||
if (ent_mvstep[ent_ents[e].step_no].count != 0xff) {
|
||||
/* there is a next step: init and loop */
|
||||
ent_ents[e].step_count = 0;
|
||||
}
|
||||
else {
|
||||
/* there is no next step: restart or deactivate */
|
||||
if (!e_rick_state_test(E_RICK_STZOMBIE) &&
|
||||
!(ent_ents[e].flags & ENT_FLG_ONCE)) {
|
||||
/* loop this entity */
|
||||
ent_ents[e].sproffs = 0;
|
||||
ent_ents[e].n &= ~ENT_LETHAL;
|
||||
if (ent_ents[e].flags & ENT_FLG_LETHALR)
|
||||
ent_ents[e].n |= ENT_LETHAL;
|
||||
ent_ents[e].x = ent_ents[e].xsave;
|
||||
ent_ents[e].y = ent_ents[e].ysave;
|
||||
if (ent_ents[e].y < 0 || ent_ents[e].y > 0x140) {
|
||||
ent_ents[e].n = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* deactivate this entity */
|
||||
ent_ents[e].n = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* ent_ents[e].sprseq1 == 0 -- waiting */
|
||||
|
||||
/* ugly GOTOs */
|
||||
|
||||
if (ent_ents[e].flags & ENT_FLG_TRIGRICK) { /* reacts to rick */
|
||||
/* wake up if triggered by rick */
|
||||
if (u_trigbox(e, E_RICK_ENT.x + 0x0C, E_RICK_ENT.y + 0x0A))
|
||||
goto wakeup;
|
||||
}
|
||||
|
||||
if (ent_ents[e].flags & ENT_FLG_TRIGSTOP) { /* reacts to rick "stop" */
|
||||
/* wake up if triggered by rick "stop" */
|
||||
if (e_rick_state_test(E_RICK_STSTOP) &&
|
||||
u_trigbox(e, e_rick_stop_x, e_rick_stop_y))
|
||||
goto wakeup;
|
||||
}
|
||||
|
||||
if (ent_ents[e].flags & ENT_FLG_TRIGBULLET) { /* reacts to bullets */
|
||||
/* wake up if triggered by bullet */
|
||||
if (E_BULLET_ENT.n && u_trigbox(e, e_bullet_xc, e_bullet_yc)) {
|
||||
E_BULLET_ENT.n = 0;
|
||||
goto wakeup;
|
||||
}
|
||||
}
|
||||
|
||||
if (ent_ents[e].flags & ENT_FLG_TRIGBOMB) { /* reacts to bombs */
|
||||
/* wake up if triggered by bomb */
|
||||
if (e_bomb_lethal && u_trigbox(e, e_bomb_xc, e_bomb_yc))
|
||||
goto wakeup;
|
||||
}
|
||||
|
||||
/* not triggered: keep waiting */
|
||||
return;
|
||||
|
||||
/* something triggered the entity: wake up */
|
||||
/* initialize step counter */
|
||||
wakeup:
|
||||
if (e_rick_state_test(E_RICK_STZOMBIE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
#ifdef ENABLE_SOUND
|
||||
/*
|
||||
* FIXME the sound should come from a table, there are 10 of them
|
||||
* but I dont have the table yet. must rip the data off the game...
|
||||
* FIXME is it 8 of them, not 10?
|
||||
* FIXME testing below...
|
||||
*/
|
||||
|
||||
/* FIXME this is defensive, need to figure out whether there
|
||||
is simply missing sound (and possibly rip it)
|
||||
or wrong data in sumbmap 47 (when making the switch explode)
|
||||
and submap 13 (when touching jewel) */
|
||||
wav_index = (ent_ents[e].trigsnd & 0x1F) - 0x14;
|
||||
if((0 <= wav_index) && (wav_index < SOUNDS_NBR_ENTITIES - 1))
|
||||
{
|
||||
syssnd_play(soundEntity[wav_index], 1);
|
||||
}
|
||||
/*syssnd_play(WAV_ENTITY[0], 1);*/
|
||||
#endif /* ENABLE_SOUND */
|
||||
ent_ents[e].n &= ~ENT_LETHAL;
|
||||
if (ent_ents[e].flags & ENT_FLG_LETHALI)
|
||||
ent_ents[e].n |= ENT_LETHAL;
|
||||
ent_ents[e].sproffs = 1;
|
||||
ent_ents[e].step_count = 0;
|
||||
ent_ents[e].step_no = ent_ents[e].step_no_i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#undef step_count
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Action function for e_them _t3 type
|
||||
*
|
||||
* ASM 2546
|
||||
*/
|
||||
void
|
||||
e_them_t3_action(U8 e)
|
||||
{
|
||||
e_them_t3_action2(e);
|
||||
|
||||
/* if lethal, can kill rick */
|
||||
if ((ent_ents[e].n & ENT_LETHAL) &&
|
||||
!e_rick_state_test(E_RICK_STZOMBIE) && e_rick_boxtest(e)) { /* CALL 1130 */
|
||||
e_rick_gozombie();
|
||||
}
|
||||
}
|
||||
|
||||
/* eof */
|
31
apps/plugins/xrick/e_them.h
Normal file
31
apps/plugins/xrick/e_them.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* xrick/e_them.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _E_THEM_H
|
||||
#define _E_THEM_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
extern U32 e_them_rndseed;
|
||||
|
||||
extern void e_them_t1a_action(U8);
|
||||
extern void e_them_t1b_action(U8);
|
||||
extern void e_them_t2_action(U8);
|
||||
extern void e_them_t3_action(U8);
|
||||
extern void e_them_z_action(U8);
|
||||
|
||||
#endif /* ndef _E_THEM_H */
|
||||
|
||||
/* eof */
|
540
apps/plugins/xrick/ents.c
Normal file
540
apps/plugins/xrick/ents.c
Normal file
|
@ -0,0 +1,540 @@
|
|||
/*
|
||||
* xrick/ents.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/ents.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/debug.h"
|
||||
#include "xrick/e_bullet.h"
|
||||
#include "xrick/e_bomb.h"
|
||||
#include "xrick/e_rick.h"
|
||||
#include "xrick/e_them.h"
|
||||
#include "xrick/e_bonus.h"
|
||||
#include "xrick/e_box.h"
|
||||
#include "xrick/e_sbonus.h"
|
||||
#include "xrick/rects.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/draw.h"
|
||||
|
||||
#include <stdlib.h> /* abs */
|
||||
|
||||
/*
|
||||
* global vars
|
||||
*/
|
||||
ent_t ent_ents[ENT_ENTSNUM + 1];
|
||||
|
||||
size_t ent_nbr_entdata = 0;
|
||||
entdata_t *ent_entdata = NULL;
|
||||
|
||||
rect_t *ent_rects = NULL;
|
||||
|
||||
size_t ent_nbr_sprseq = 0;
|
||||
U8 *ent_sprseq = NULL;
|
||||
|
||||
size_t ent_nbr_mvstep = 0;
|
||||
mvstep_t *ent_mvstep = NULL;
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
*/
|
||||
static void ent_addrect(S16, S16, U16, U16);
|
||||
static bool ent_creat1(U8 *);
|
||||
static bool ent_creat2(U8 *, U16);
|
||||
|
||||
|
||||
/*
|
||||
* Reset entities
|
||||
*
|
||||
* ASM 2520
|
||||
*/
|
||||
void
|
||||
ent_reset(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
e_rick_state_clear(E_RICK_STSTOP);
|
||||
e_bomb_lethal = false;
|
||||
|
||||
ent_ents[0].n = 0;
|
||||
for (i = 2; ent_ents[i].n != 0xff; i++)
|
||||
ent_ents[i].n = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an entity on slots 4 to 8 by using the first slot available.
|
||||
* Entities of type e_them on slots 4 to 8, when lethal, can kill
|
||||
* other e_them (on slots 4 to C) as well as rick.
|
||||
*
|
||||
* ASM 209C
|
||||
*
|
||||
* e: anything, CHANGED to the allocated entity number.
|
||||
* return: true/OK false/not
|
||||
*/
|
||||
static bool
|
||||
ent_creat1(U8 *e)
|
||||
{
|
||||
/* look for a slot */
|
||||
for (*e = 0x04; *e < 0x09; (*e)++)
|
||||
if (ent_ents[*e].n == 0) { /* if slot available, use it */
|
||||
ent_ents[*e].c1 = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an entity on slots 9 to C by using the first slot available.
|
||||
* Entities of type e_them on slots 9 to C can kill rick when lethal,
|
||||
* but they can never kill other e_them.
|
||||
*
|
||||
* ASM 20BC
|
||||
*
|
||||
* e: anything, CHANGED to the allocated entity number.
|
||||
* m: number of the mark triggering the creation of the entity.
|
||||
* ret: true/OK false/not
|
||||
*/
|
||||
static bool
|
||||
ent_creat2(U8 *e, U16 m)
|
||||
{
|
||||
/* make sure the entity created by this mark is not active already */
|
||||
for (*e = 0x09; *e < 0x0c; (*e)++)
|
||||
if (ent_ents[*e].n != 0 && ent_ents[*e].mark == m)
|
||||
return false;
|
||||
|
||||
/* look for a slot */
|
||||
for (*e = 0x09; *e < 0x0c; (*e)++)
|
||||
if (ent_ents[*e].n == 0) { /* if slot available, use it */
|
||||
ent_ents[*e].c1 = 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Process marks that are within the visible portion of the map,
|
||||
* and create the corresponding entities.
|
||||
*
|
||||
* absolute map coordinate means that they are not relative to
|
||||
* map_frow, as any other coordinates are.
|
||||
*
|
||||
* ASM 1F40
|
||||
*
|
||||
* frow: first visible row of the map -- absolute map coordinate
|
||||
* lrow: last visible row of the map -- absolute map coordinate
|
||||
*/
|
||||
void
|
||||
ent_actvis(U8 frow, U8 lrow)
|
||||
{
|
||||
U16 m;
|
||||
U8 e;
|
||||
U16 y;
|
||||
|
||||
/*
|
||||
* go through the list and find the first mark that
|
||||
* is visible, i.e. which has a row greater than the
|
||||
* first row (marks being ordered by row number).
|
||||
*/
|
||||
for (m = map_submaps[game_submap].mark;
|
||||
map_marks[m].row != 0xff && map_marks[m].row < frow;
|
||||
m++);
|
||||
|
||||
if (map_marks[m].row == 0xff) /* none found */
|
||||
return;
|
||||
|
||||
/*
|
||||
* go through the list and process all marks that are
|
||||
* visible, i.e. which have a row lower than the last
|
||||
* row (marks still being ordered by row number).
|
||||
*/
|
||||
for (;
|
||||
map_marks[m].row != 0xff && map_marks[m].row < lrow;
|
||||
m++) {
|
||||
|
||||
/* ignore marks that are not active */
|
||||
if (map_marks[m].ent & MAP_MARK_NACT)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* allocate a slot to the new entity
|
||||
*
|
||||
* slot type
|
||||
* 0 available for e_them (lethal to other e_them, and stops entities
|
||||
* i.e. entities can't move over them. E.g. moving blocks. But they
|
||||
* can move over entities and kill them!).
|
||||
* 1 xrick
|
||||
* 2 bullet
|
||||
* 3 bomb
|
||||
* 4-8 available for e_them, e_box, e_bonus or e_sbonus (lethal to
|
||||
* other e_them, identified by their number being >= 0x10)
|
||||
* 9-C available for e_them, e_box, e_bonus or e_sbonus (not lethal to
|
||||
* other e_them, identified by their number being < 0x10)
|
||||
*
|
||||
* the type of an entity is determined by its .n as detailed below.
|
||||
*
|
||||
* 1 xrick
|
||||
* 2 bullet
|
||||
* 3 bomb
|
||||
* 4, 7, a, d e_them, type 1a
|
||||
* 5, 8, b, e e_them, type 1b
|
||||
* 6, 9, c, f e_them, type 2
|
||||
* 10, 11 box
|
||||
* 12, 13, 14, 15 bonus
|
||||
* 16, 17 speed bonus
|
||||
* >17 e_them, type 3
|
||||
* 47 zombie
|
||||
*/
|
||||
|
||||
if (!(map_marks[m].flags & ENT_FLG_STOPRICK)) {
|
||||
if (map_marks[m].ent >= 0x10) {
|
||||
/* boxes, bonuses and type 3 e_them go to slot 4-8 */
|
||||
/* (c1 set to 0 -> all type 3 e_them are sleeping) */
|
||||
if (!ent_creat1(&e)) continue;
|
||||
}
|
||||
else {
|
||||
/* type 1 and 2 e_them go to slot 9-c */
|
||||
/* (c1 set to 2) */
|
||||
if (!ent_creat2(&e, m)) continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* entities stopping rick (e.g. blocks) go to slot 0 */
|
||||
if (ent_ents[0].n) continue;
|
||||
e = 0;
|
||||
ent_ents[0].c1 = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize the entity
|
||||
*/
|
||||
ent_ents[e].mark = m;
|
||||
ent_ents[e].flags = map_marks[m].flags;
|
||||
ent_ents[e].n = map_marks[m].ent;
|
||||
|
||||
/*
|
||||
* if entity is to be already running (i.e. not asleep and waiting
|
||||
* for some trigger to move), then use LETHALR i.e. restart flag, right
|
||||
* from the beginning
|
||||
*/
|
||||
if (ent_ents[e].flags & ENT_FLG_LETHALR)
|
||||
ent_ents[e].n |= ENT_LETHAL;
|
||||
|
||||
ent_ents[e].x = map_marks[m].xy & 0xf8;
|
||||
|
||||
y = (map_marks[m].xy & 0x07) + (map_marks[m].row & 0xf8) - map_frow;
|
||||
y <<= 3;
|
||||
if (!(ent_ents[e].flags & ENT_FLG_STOPRICK))
|
||||
y += 3;
|
||||
ent_ents[e].y = y;
|
||||
|
||||
ent_ents[e].xsave = ent_ents[e].x;
|
||||
ent_ents[e].ysave = ent_ents[e].y;
|
||||
|
||||
/*ent_ents[e].w0C = 0;*/ /* in ASM code but never used */
|
||||
|
||||
ent_ents[e].w = ent_entdata[map_marks[m].ent].w;
|
||||
ent_ents[e].h = ent_entdata[map_marks[m].ent].h;
|
||||
ent_ents[e].sprbase = ent_entdata[map_marks[m].ent].spr;
|
||||
ent_ents[e].step_no_i = ent_entdata[map_marks[m].ent].sni;
|
||||
ent_ents[e].trigsnd = (U8)ent_entdata[map_marks[m].ent].snd;
|
||||
|
||||
/*
|
||||
* FIXME what is this? when all trigger flags are up, then
|
||||
* use .sni for sprbase. Why? What is the point? (This is
|
||||
* for type 1 and 2 e_them, ...)
|
||||
*
|
||||
* This also means that as long as sprite has not been
|
||||
* recalculated, a wrong value is used. This is normal, see
|
||||
* what happens to the falling guy on the right on submap 3:
|
||||
* it changes when hitting the ground.
|
||||
*
|
||||
* Note: sprite recalculation has been fixed, refer to the commit log.
|
||||
*/
|
||||
#define ENT_FLG_TRIGGERS \
|
||||
(ENT_FLG_TRIGBOMB|ENT_FLG_TRIGBULLET|ENT_FLG_TRIGSTOP|ENT_FLG_TRIGRICK)
|
||||
if ((ent_ents[e].flags & ENT_FLG_TRIGGERS) == ENT_FLG_TRIGGERS
|
||||
&& e >= 0x09)
|
||||
ent_ents[e].sprbase = (U8)(ent_entdata[map_marks[m].ent].sni & 0x00ff);
|
||||
#undef ENT_FLG_TRIGGERS
|
||||
|
||||
ent_ents[e].sprite = (U8)ent_ents[e].sprbase;
|
||||
ent_ents[e].trig_x = map_marks[m].lt & 0xf8;
|
||||
ent_ents[e].latency = (map_marks[m].lt & 0x07) << 5; /* <<5 eq *32 */
|
||||
|
||||
ent_ents[e].trig_y = 3 + 8 * ((map_marks[m].row & 0xf8) - map_frow +
|
||||
(map_marks[m].lt & 0x07));
|
||||
|
||||
ent_ents[e].c2 = 0;
|
||||
ent_ents[e].offsy = 0;
|
||||
ent_ents[e].ylow = 0;
|
||||
|
||||
ent_ents[e].front = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a tile-aligned rectangle containing the given rectangle (indicated
|
||||
* by its MAP coordinates) to the list of rectangles. Clip the rectangle
|
||||
* so it fits into the display zone.
|
||||
*/
|
||||
static void
|
||||
ent_addrect(S16 x, S16 y, U16 width, U16 height)
|
||||
{
|
||||
S16 x0, y0;
|
||||
U16 w0, h0;
|
||||
rect_t *r;
|
||||
|
||||
/*sys_printf("rect %#04x,%#04x %#04x %#04x ", x, y, width, height);*/
|
||||
|
||||
/* align to tiles */
|
||||
x0 = x & 0xfff8;
|
||||
y0 = y & 0xfff8;
|
||||
w0 = width;
|
||||
h0 = height;
|
||||
if (x - x0) w0 = (w0 + (x - x0)) | 0x0007;
|
||||
if (y - y0) h0 = (h0 + (y - y0)) | 0x0007;
|
||||
|
||||
/* clip */
|
||||
if (draw_clipms(&x0, &y0, &w0, &h0)) { /* do not add if fully clipped */
|
||||
/*sys_printf("-> [clipped]\n");*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*sys_printf("-> %#04x,%#04x %#04x %#04x\n", x0, y0, w0, h0);*/
|
||||
|
||||
#ifdef GFXST
|
||||
y0 += 8;
|
||||
#endif
|
||||
|
||||
/* get to screen */
|
||||
x0 -= DRAW_XYMAP_SCRLEFT;
|
||||
y0 -= DRAW_XYMAP_SCRTOP;
|
||||
|
||||
/* add rectangle to the list */
|
||||
r = rects_new(x0, y0, w0, h0, ent_rects);
|
||||
if (!r)
|
||||
{
|
||||
control_set(Control_EXIT);
|
||||
return;
|
||||
}
|
||||
ent_rects = r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw all entities onto the frame buffer.
|
||||
*
|
||||
* ASM 07a4
|
||||
*
|
||||
* NOTE This may need to be part of draw.c. Also needs better comments,
|
||||
* NOTE and probably better rectangles management.
|
||||
*/
|
||||
void
|
||||
ent_draw(void)
|
||||
{
|
||||
U8 i;
|
||||
#ifdef ENABLE_CHEATS
|
||||
static bool ch3 = false;
|
||||
#endif
|
||||
S16 dx, dy;
|
||||
|
||||
draw_tilesBank = map_tilesBank;
|
||||
|
||||
/* reset rectangles list */
|
||||
rects_free(ent_rects);
|
||||
ent_rects = NULL;
|
||||
|
||||
/*sys_printf("\n");*/
|
||||
|
||||
/*
|
||||
* background loop : erase all entities that were visible
|
||||
*/
|
||||
for (i = 0; ent_ents[i].n != 0xff; i++) {
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (ent_ents[i].prev_n && (ch3 || ent_ents[i].prev_s))
|
||||
#else
|
||||
if (ent_ents[i].prev_n && ent_ents[i].prev_s)
|
||||
#endif
|
||||
/* if entity was active, then erase it (redraw the map) */
|
||||
draw_spriteBackground(ent_ents[i].prev_x, ent_ents[i].prev_y);
|
||||
}
|
||||
|
||||
/*
|
||||
* foreground loop : draw all entities that are visible
|
||||
*/
|
||||
for (i = 0; ent_ents[i].n != 0xff; i++) {
|
||||
/*
|
||||
* If entity is active now, draw the sprite. If entity was
|
||||
* not active before, add a rectangle for the sprite.
|
||||
*/
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (ent_ents[i].n && (game_cheat3 || ent_ents[i].sprite))
|
||||
#else
|
||||
if (ent_ents[i].n && ent_ents[i].sprite)
|
||||
#endif
|
||||
/* If entitiy is active, draw the sprite. */
|
||||
draw_sprite2(ent_ents[i].sprite,
|
||||
ent_ents[i].x, ent_ents[i].y,
|
||||
ent_ents[i].front);
|
||||
}
|
||||
|
||||
/*
|
||||
* rectangles loop : figure out which parts of the screen have been
|
||||
* impacted and need to be refreshed, then save state
|
||||
*/
|
||||
for (i = 0; ent_ents[i].n != 0xff; i++) {
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (ent_ents[i].prev_n && (ch3 || ent_ents[i].prev_s)) {
|
||||
#else
|
||||
if (ent_ents[i].prev_n && ent_ents[i].prev_s) {
|
||||
#endif
|
||||
/* (1) if entity was active and has been drawn ... */
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (ent_ents[i].n && (game_cheat3 || ent_ents[i].sprite)) {
|
||||
#else
|
||||
if (ent_ents[i].n && ent_ents[i].sprite) {
|
||||
#endif
|
||||
/* (1.1) ... and is still active now and still needs to be drawn, */
|
||||
/* then check if rectangles intersect */
|
||||
dx = abs(ent_ents[i].x - ent_ents[i].prev_x);
|
||||
dy = abs(ent_ents[i].y - ent_ents[i].prev_y);
|
||||
if (dx < 0x20 && dy < 0x16) {
|
||||
/* (1.1.1) if they do, then create one rectangle */
|
||||
ent_addrect((ent_ents[i].prev_x < ent_ents[i].x)
|
||||
? ent_ents[i].prev_x : ent_ents[i].x,
|
||||
(ent_ents[i].prev_y < ent_ents[i].y)
|
||||
? ent_ents[i].prev_y : ent_ents[i].y,
|
||||
dx + 0x20, dy + 0x15);
|
||||
}
|
||||
else {
|
||||
/* (1.1.2) else, create two rectangles */
|
||||
ent_addrect(ent_ents[i].x, ent_ents[i].y, 0x20, 0x15);
|
||||
ent_addrect(ent_ents[i].prev_x, ent_ents[i].prev_y, 0x20, 0x15);
|
||||
}
|
||||
}
|
||||
else
|
||||
/* (1.2) ... and is not active anymore or does not need to be drawn */
|
||||
/* then create one single rectangle */
|
||||
ent_addrect(ent_ents[i].prev_x, ent_ents[i].prev_y, 0x20, 0x15);
|
||||
}
|
||||
#ifdef ENABLE_CHEATS
|
||||
else if (ent_ents[i].n && (game_cheat3 || ent_ents[i].sprite)) {
|
||||
#else
|
||||
else if (ent_ents[i].n && ent_ents[i].sprite) {
|
||||
#endif
|
||||
/* (2) if entity is active and needs to be drawn, */
|
||||
/* then create one rectangle */
|
||||
ent_addrect(ent_ents[i].x, ent_ents[i].y, 0x20, 0x15);
|
||||
}
|
||||
|
||||
/* save state */
|
||||
ent_ents[i].prev_x = ent_ents[i].x;
|
||||
ent_ents[i].prev_y = ent_ents[i].y;
|
||||
ent_ents[i].prev_n = ent_ents[i].n;
|
||||
ent_ents[i].prev_s = ent_ents[i].sprite;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CHEATS
|
||||
ch3 = game_cheat3;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Clear entities previous state
|
||||
*
|
||||
*/
|
||||
void
|
||||
ent_clprev(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
for (i = 0; ent_ents[i].n != 0xff; i++)
|
||||
ent_ents[i].prev_n = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Table containing entity action function pointers.
|
||||
*/
|
||||
void (*ent_actf[])(U8) = {
|
||||
NULL, /* 00 - zero means that the slot is free */
|
||||
e_rick_action, /* 01 - 12CA */
|
||||
e_bullet_action, /* 02 - 1883 */
|
||||
e_bomb_action, /* 03 - 18CA */
|
||||
e_them_t1a_action, /* 04 - 2452 */
|
||||
e_them_t1b_action, /* 05 - 21CA */
|
||||
e_them_t2_action, /* 06 - 2718 */
|
||||
e_them_t1a_action, /* 07 - 2452 */
|
||||
e_them_t1b_action, /* 08 - 21CA */
|
||||
e_them_t2_action, /* 09 - 2718 */
|
||||
e_them_t1a_action, /* 0A - 2452 */
|
||||
e_them_t1b_action, /* 0B - 21CA */
|
||||
e_them_t2_action, /* 0C - 2718 */
|
||||
e_them_t1a_action, /* 0D - 2452 */
|
||||
e_them_t1b_action, /* 0E - 21CA */
|
||||
e_them_t2_action, /* 0F - 2718 */
|
||||
e_box_action, /* 10 - 245A */
|
||||
e_box_action, /* 11 - 245A */
|
||||
e_bonus_action, /* 12 - 242C */
|
||||
e_bonus_action, /* 13 - 242C */
|
||||
e_bonus_action, /* 14 - 242C */
|
||||
e_bonus_action, /* 15 - 242C */
|
||||
e_sbonus_start, /* 16 - 2182 */
|
||||
e_sbonus_stop /* 17 - 2143 */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Run entities action function
|
||||
*
|
||||
*/
|
||||
void
|
||||
ent_action(void)
|
||||
{
|
||||
U8 i, k;
|
||||
|
||||
IFDEBUG_ENTS(
|
||||
sys_printf("xrick/ents: --------- action ----------------\n");
|
||||
for (i = 0; ent_ents[i].n != 0xff; i++)
|
||||
if (ent_ents[i].n) {
|
||||
sys_printf("xrick/ents: slot %#04x, entity %#04x", i, ent_ents[i].n);
|
||||
sys_printf(" (%#06x, %#06x), sprite %#04x.\n",
|
||||
ent_ents[i].x, ent_ents[i].y, ent_ents[i].sprite);
|
||||
}
|
||||
);
|
||||
|
||||
for (i = 0; ent_ents[i].n != 0xff; i++) {
|
||||
if (ent_ents[i].n) {
|
||||
k = ent_ents[i].n & 0x7f;
|
||||
if (k == 0x47)
|
||||
e_them_z_action(i);
|
||||
else if (k >= 0x18)
|
||||
e_them_t3_action(i);
|
||||
else
|
||||
ent_actf[k](i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
118
apps/plugins/xrick/ents.h
Normal file
118
apps/plugins/xrick/ents.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* xrick/ents.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _ENTS_H
|
||||
#define _ENTS_H
|
||||
|
||||
#include "xrick/rects.h"
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
#define ENT_XRICK ent_ents[1]
|
||||
|
||||
/*
|
||||
* flags for ent_ents[e].n ("yes" when set)
|
||||
*
|
||||
* ENT_LETHAL: is entity lethal?
|
||||
*/
|
||||
#define ENT_LETHAL 0x80
|
||||
|
||||
/*
|
||||
* flags for ent_ents[e].flag ("yes" when set)
|
||||
*
|
||||
* ENT_FLG_ONCE: should the entity run once only?
|
||||
* ENT_FLG_STOPRICK: does the entity stops rick (and goes to slot zero)?
|
||||
* ENT_FLG_LETHALR: is entity lethal when restarting?
|
||||
* ENT_FLG_LETHALI: is entity initially lethal?
|
||||
* ENT_FLG_TRIGBOMB: can entity be triggered by a bomb?
|
||||
* ENT_FLG_TRIGBULLET: can entity be triggered by a bullet?
|
||||
* ENT_FLG_TRIGSTOP: can entity be triggered by rick stop?
|
||||
* ENT_FLG_TRIGRICK: can entity be triggered by rick?
|
||||
*/
|
||||
#define ENT_FLG_ONCE 0x01
|
||||
#define ENT_FLG_STOPRICK 0x02
|
||||
#define ENT_FLG_LETHALR 0x04
|
||||
#define ENT_FLG_LETHALI 0x08
|
||||
#define ENT_FLG_TRIGBOMB 0x10
|
||||
#define ENT_FLG_TRIGBULLET 0x20
|
||||
#define ENT_FLG_TRIGSTOP 0x40
|
||||
#define ENT_FLG_TRIGRICK 0x80
|
||||
|
||||
typedef struct {
|
||||
U8 n; /* b00 */
|
||||
/*U8 b01;*/ /* b01 in ASM code but never used */
|
||||
S16 x; /* b02 - position */
|
||||
S16 y; /* w04 - position */
|
||||
U8 sprite; /* b08 - sprite number */
|
||||
/*U16 w0C;*/ /* w0C in ASM code but never used */
|
||||
U8 w; /* b0E - width */
|
||||
U8 h; /* b10 - height */
|
||||
U16 mark; /* w12 - number of the mark that created the entity */
|
||||
U8 flags; /* b14 */
|
||||
S16 trig_x; /* b16 - position of trigger box */
|
||||
S16 trig_y; /* w18 - position of trigger box */
|
||||
S16 xsave; /* b1C */
|
||||
S16 ysave; /* w1E */
|
||||
U16 sprbase; /* w20 */
|
||||
U16 step_no_i; /* w22 */
|
||||
U16 step_no; /* w24 */
|
||||
S16 c1; /* b26 */
|
||||
S16 c2; /* b28 */
|
||||
U8 ylow; /* b2A */
|
||||
S16 offsy; /* w2C */
|
||||
U8 latency; /* b2E */
|
||||
U8 prev_n; /* new */
|
||||
S16 prev_x; /* new */
|
||||
S16 prev_y; /* new */
|
||||
U8 prev_s; /* new */
|
||||
bool front; /* new */
|
||||
U8 trigsnd; /* new */
|
||||
} ent_t;
|
||||
|
||||
typedef struct {
|
||||
U8 w, h;
|
||||
U16 spr, sni;
|
||||
U8 trig_w, trig_h;
|
||||
U8 snd;
|
||||
} entdata_t;
|
||||
|
||||
typedef struct {
|
||||
U8 count;
|
||||
S8 dx, dy;
|
||||
} mvstep_t;
|
||||
|
||||
enum { ENT_ENTSNUM = 12 };
|
||||
extern ent_t ent_ents[ENT_ENTSNUM + 1];
|
||||
|
||||
extern size_t ent_nbr_entdata;
|
||||
extern entdata_t *ent_entdata;
|
||||
|
||||
extern rect_t *ent_rects;
|
||||
|
||||
extern size_t ent_nbr_sprseq;
|
||||
extern U8 *ent_sprseq;
|
||||
|
||||
extern size_t ent_nbr_mvstep;
|
||||
extern mvstep_t *ent_mvstep;
|
||||
|
||||
extern void ent_reset(void);
|
||||
extern void ent_actvis(U8, U8);
|
||||
extern void ent_draw(void);
|
||||
extern void ent_clprev(void);
|
||||
extern void ent_action(void);
|
||||
|
||||
#endif /* ndef _ENTS_H */
|
||||
|
||||
/* eof */
|
722
apps/plugins/xrick/game.c
Normal file
722
apps/plugins/xrick/game.c
Normal file
|
@ -0,0 +1,722 @@
|
|||
/*
|
||||
* xrick/game.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/game.h"
|
||||
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/e_rick.h"
|
||||
#include "xrick/e_sbonus.h"
|
||||
#include "xrick/e_them.h"
|
||||
#include "xrick/screens.h"
|
||||
#include "xrick/rects.h"
|
||||
#include "xrick/scroller.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/resources.h"
|
||||
|
||||
#ifdef ENABLE_DEVTOOLS
|
||||
#include "xrick/devtools.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* local typedefs
|
||||
*/
|
||||
typedef enum {
|
||||
#ifdef ENABLE_DEVTOOLS
|
||||
DEVTOOLS,
|
||||
#endif
|
||||
XRICK,
|
||||
INIT_GAME, INIT_BUFFER,
|
||||
INTRO_MAIN, INTRO_MAP,
|
||||
PAUSE_PRESSED1, PAUSE_PRESSED1B, PAUSED, PAUSE_PRESSED2,
|
||||
PLAY0, PLAY1, PLAY2, PLAY3,
|
||||
CHAIN_SUBMAP, CHAIN_MAP, CHAIN_END,
|
||||
SCROLL_UP, SCROLL_DOWN,
|
||||
RESTART, GAMEOVER, GETNAME, EXIT
|
||||
} game_state_t;
|
||||
|
||||
|
||||
/*
|
||||
* global vars
|
||||
*/
|
||||
U8 game_period = 0;
|
||||
bool game_waitevt = false;
|
||||
const rect_t *game_rects = NULL;
|
||||
|
||||
U8 game_lives = 0;
|
||||
U8 game_bombs = 0;
|
||||
U8 game_bullets = 0;
|
||||
U32 game_score = 0;
|
||||
|
||||
U16 game_map = 0;
|
||||
U16 game_submap = 0;
|
||||
|
||||
U8 game_dir = RIGHT;
|
||||
bool game_chsm = false;
|
||||
|
||||
bool game_cheat1 = false;
|
||||
bool game_cheat2 = false;
|
||||
bool game_cheat3 = false;
|
||||
|
||||
|
||||
/*
|
||||
* local vars
|
||||
*/
|
||||
static U8 isave_frow;
|
||||
static game_state_t game_state;
|
||||
#ifdef ENABLE_SOUND
|
||||
static sound_t *currentMusic = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
*/
|
||||
static void frame(void);
|
||||
static void init(void);
|
||||
static void play0(void);
|
||||
static void play3(void);
|
||||
static void restart(void);
|
||||
static void isave(void);
|
||||
static void irestore(void);
|
||||
|
||||
|
||||
/*
|
||||
* Cheats
|
||||
*/
|
||||
#ifdef ENABLE_CHEATS
|
||||
void
|
||||
game_toggleCheat(cheat_t cheat)
|
||||
{
|
||||
if (game_state != INTRO_MAIN && game_state != INTRO_MAP &&
|
||||
game_state != GAMEOVER && game_state != GETNAME &&
|
||||
#ifdef ENABLE_DEVTOOLS
|
||||
game_state != DEVTOOLS &&
|
||||
#endif
|
||||
game_state != XRICK && game_state != EXIT)
|
||||
{
|
||||
switch (cheat)
|
||||
{
|
||||
case Cheat_UNLIMITED_ALL:
|
||||
{
|
||||
game_cheat1 = !game_cheat1;
|
||||
game_lives = 6;
|
||||
game_bombs = 6;
|
||||
game_bullets = 6;
|
||||
break;
|
||||
}
|
||||
case Cheat_NEVER_DIE:
|
||||
{
|
||||
game_cheat2 = !game_cheat2;
|
||||
break;
|
||||
}
|
||||
case Cheat_EXPOSE:
|
||||
{
|
||||
game_cheat3 = !game_cheat3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
draw_infos();
|
||||
/* FIXME this should probably only raise a flag ... */
|
||||
/* plus we only need to update INFORECT not the whole screen */
|
||||
sysvid_update(&draw_SCREENRECT);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
/*
|
||||
* Music
|
||||
*/
|
||||
void
|
||||
game_setmusic(sound_t * newMusic, S8 loop)
|
||||
{
|
||||
if (!newMusic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentMusic)
|
||||
{
|
||||
game_stopmusic();
|
||||
}
|
||||
|
||||
syssnd_play(newMusic, loop);
|
||||
|
||||
currentMusic = newMusic;
|
||||
}
|
||||
|
||||
void
|
||||
game_stopmusic(void)
|
||||
{
|
||||
syssnd_stop(currentMusic);
|
||||
currentMusic = NULL;
|
||||
}
|
||||
#endif /*ENABLE_SOUND */
|
||||
|
||||
/*
|
||||
* Main loop
|
||||
*/
|
||||
void
|
||||
game_run(void)
|
||||
{
|
||||
U32 currentTime,
|
||||
#ifdef ENABLE_SOUND
|
||||
lastSoundTime = 0,
|
||||
#endif
|
||||
lastFrameTime = 0;
|
||||
|
||||
if (!resources_load())
|
||||
{
|
||||
resources_unload();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sys_cacheData())
|
||||
{
|
||||
sys_uncacheData();
|
||||
return;
|
||||
}
|
||||
|
||||
game_period = sysarg_args_period ? sysarg_args_period : GAME_PERIOD;
|
||||
game_state = XRICK;
|
||||
|
||||
/* main loop */
|
||||
while (game_state != EXIT)
|
||||
{
|
||||
currentTime = sys_gettime();
|
||||
|
||||
if (currentTime - lastFrameTime >= game_period)
|
||||
{
|
||||
/* frame */
|
||||
frame();
|
||||
|
||||
/* video */
|
||||
/*DEBUG*//*game_rects=&draw_SCREENRECT;*//*DEBUG*/
|
||||
sysvid_update(game_rects);
|
||||
|
||||
/* reset rectangles list */
|
||||
rects_free(ent_rects);
|
||||
ent_rects = NULL;
|
||||
draw_STATUSRECT.next = NULL; /* FIXME freerects should handle this */
|
||||
|
||||
/* events */
|
||||
if (game_waitevt)
|
||||
{
|
||||
sysevt_wait(); /* wait for an event */
|
||||
}
|
||||
else
|
||||
{
|
||||
sysevt_poll(); /* process events (non-blocking) */
|
||||
}
|
||||
|
||||
lastFrameTime = currentTime;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
if (currentTime - lastSoundTime >= syssnd_period)
|
||||
{
|
||||
/* sound */
|
||||
syssnd_update();
|
||||
|
||||
lastSoundTime = currentTime;
|
||||
}
|
||||
#endif /* ENABLE_SOUND */
|
||||
|
||||
sys_yield();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_stopAll();
|
||||
#endif
|
||||
|
||||
sys_uncacheData();
|
||||
|
||||
resources_unload();
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare frame
|
||||
*
|
||||
* This function loops forever: use 'return' when a frame is ready.
|
||||
* When returning, game_rects must contain every parts of the buffer
|
||||
* that have been modified.
|
||||
*/
|
||||
static void
|
||||
frame(void)
|
||||
{
|
||||
while (1) {
|
||||
|
||||
switch (game_state) {
|
||||
|
||||
|
||||
|
||||
#ifdef ENABLE_DEVTOOLS
|
||||
case DEVTOOLS:
|
||||
switch (devtools_run()) {
|
||||
case SCREEN_RUNNING:
|
||||
return;
|
||||
case SCREEN_DONE:
|
||||
game_state = INIT_GAME;
|
||||
break;
|
||||
case SCREEN_EXIT:
|
||||
game_state = EXIT;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
case XRICK:
|
||||
switch(screen_xrick()) {
|
||||
case SCREEN_RUNNING:
|
||||
return;
|
||||
case SCREEN_DONE:
|
||||
#ifdef ENABLE_DEVTOOLS
|
||||
game_state = DEVTOOLS;
|
||||
#else
|
||||
game_state = INIT_GAME;
|
||||
#endif
|
||||
break;
|
||||
case SCREEN_EXIT:
|
||||
game_state = EXIT;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case INIT_GAME:
|
||||
init();
|
||||
game_state = INTRO_MAIN;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case INTRO_MAIN:
|
||||
switch (screen_introMain()) {
|
||||
case SCREEN_RUNNING:
|
||||
return;
|
||||
case SCREEN_DONE:
|
||||
game_state = INTRO_MAP;
|
||||
break;
|
||||
case SCREEN_EXIT:
|
||||
game_state = EXIT;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case INTRO_MAP:
|
||||
switch (screen_introMap()) {
|
||||
case SCREEN_RUNNING:
|
||||
return;
|
||||
case SCREEN_DONE:
|
||||
game_waitevt = false;
|
||||
game_state = INIT_BUFFER;
|
||||
break;
|
||||
case SCREEN_EXIT:
|
||||
game_state = EXIT;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case INIT_BUFFER:
|
||||
sysvid_clear(); /* clear buffer */
|
||||
draw_map(); /* draw the map onto the buffer */
|
||||
draw_drawStatus(); /* draw the status bar onto the buffer */
|
||||
#ifdef ENABLE_CHEATS
|
||||
draw_infos(); /* draw the info bar onto the buffer */
|
||||
#endif
|
||||
game_rects = &draw_SCREENRECT; /* request full buffer refresh */
|
||||
game_state = PLAY0;
|
||||
return;
|
||||
|
||||
|
||||
|
||||
case PAUSE_PRESSED1:
|
||||
screen_pause(true);
|
||||
game_state = PAUSE_PRESSED1B;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case PAUSE_PRESSED1B:
|
||||
if (control_test(Control_PAUSE))
|
||||
return;
|
||||
game_state = PAUSED;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case PAUSED:
|
||||
if (control_test(Control_PAUSE))
|
||||
game_state = PAUSE_PRESSED2;
|
||||
if (control_test(Control_EXIT))
|
||||
game_state = EXIT;
|
||||
return;
|
||||
|
||||
|
||||
|
||||
case PAUSE_PRESSED2:
|
||||
if (!(control_test(Control_PAUSE))) {
|
||||
game_waitevt = false;
|
||||
screen_pause(false);
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_pauseAll(false);
|
||||
#endif
|
||||
game_state = PLAY2;
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
|
||||
case PLAY0:
|
||||
play0();
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case PLAY1:
|
||||
if (control_test(Control_PAUSE)) {
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_pauseAll(true);
|
||||
#endif
|
||||
game_waitevt = true;
|
||||
game_state = PAUSE_PRESSED1;
|
||||
}
|
||||
else if (!control_active) {
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_pauseAll(true);
|
||||
#endif
|
||||
game_waitevt = true;
|
||||
screen_pause(true);
|
||||
game_state = PAUSED;
|
||||
}
|
||||
else
|
||||
game_state = PLAY2;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case PLAY2:
|
||||
if (e_rick_state_test(E_RICK_STDEAD)) { /* rick is dead */
|
||||
if (game_cheat1 || --game_lives) {
|
||||
game_state = RESTART;
|
||||
} else {
|
||||
game_state = GAMEOVER;
|
||||
}
|
||||
}
|
||||
else if (game_chsm) /* request to chain to next submap */
|
||||
game_state = CHAIN_SUBMAP;
|
||||
else
|
||||
game_state = PLAY3;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case PLAY3:
|
||||
play3();
|
||||
return;
|
||||
|
||||
|
||||
|
||||
case CHAIN_SUBMAP:
|
||||
if (map_chain())
|
||||
game_state = CHAIN_END;
|
||||
else {
|
||||
game_bullets = 0x06;
|
||||
game_bombs = 0x06;
|
||||
game_map++;
|
||||
|
||||
if (game_map == map_nbr_maps - 1) {
|
||||
/* reached end of game */
|
||||
/* FIXME @292?*/
|
||||
}
|
||||
|
||||
game_state = CHAIN_MAP;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case CHAIN_MAP: /* CHAIN MAP */
|
||||
switch (screen_introMap()) {
|
||||
case SCREEN_RUNNING:
|
||||
return;
|
||||
case SCREEN_DONE:
|
||||
if (game_map >= map_nbr_maps - 1) { /* reached end of game */
|
||||
sysarg_args_map = 0;
|
||||
sysarg_args_submap = 0;
|
||||
game_state = GAMEOVER;
|
||||
}
|
||||
else { /* initialize game */
|
||||
ent_ents[1].x = map_maps[game_map].x;
|
||||
ent_ents[1].y = map_maps[game_map].y;
|
||||
map_frow = (U8)map_maps[game_map].row;
|
||||
game_submap = map_maps[game_map].submap;
|
||||
game_state = CHAIN_END;
|
||||
}
|
||||
break;
|
||||
case SCREEN_EXIT:
|
||||
game_state = EXIT;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case CHAIN_END:
|
||||
map_init(); /* initialize the map */
|
||||
isave(); /* save data in case of a restart */
|
||||
ent_clprev(); /* cleanup entities */
|
||||
draw_map(); /* draw the map onto the buffer */
|
||||
draw_drawStatus(); /* draw the status bar onto the buffer */
|
||||
game_rects = &draw_SCREENRECT; /* request full screen refresh */
|
||||
game_state = PLAY0;
|
||||
return;
|
||||
|
||||
|
||||
|
||||
case SCROLL_UP:
|
||||
switch (scroll_up()) {
|
||||
case SCROLL_RUNNING:
|
||||
return;
|
||||
case SCROLL_DONE:
|
||||
game_state = PLAY0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case SCROLL_DOWN:
|
||||
switch (scroll_down()) {
|
||||
case SCROLL_RUNNING:
|
||||
return;
|
||||
case SCROLL_DONE:
|
||||
game_state = PLAY0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case RESTART:
|
||||
restart();
|
||||
game_state = PLAY0;
|
||||
return;
|
||||
|
||||
|
||||
|
||||
case GAMEOVER:
|
||||
switch (screen_gameover()) {
|
||||
case SCREEN_RUNNING:
|
||||
return;
|
||||
case SCREEN_DONE:
|
||||
game_state = GETNAME;
|
||||
break;
|
||||
case SCREEN_EXIT:
|
||||
game_state = EXIT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case GETNAME:
|
||||
switch (screen_getname()) {
|
||||
case SCREEN_RUNNING:
|
||||
return;
|
||||
case SCREEN_DONE:
|
||||
game_state = INIT_GAME;
|
||||
return;
|
||||
case SCREEN_EXIT:
|
||||
game_state = EXIT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case EXIT:
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the game
|
||||
*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
e_rick_state_clear(0xff);
|
||||
|
||||
game_lives = 6;
|
||||
game_bombs = 6;
|
||||
game_bullets = 6;
|
||||
game_score = 0;
|
||||
|
||||
game_map = sysarg_args_map;
|
||||
|
||||
if (sysarg_args_submap == 0)
|
||||
{
|
||||
game_submap = map_maps[game_map].submap;
|
||||
map_frow = (U8)map_maps[game_map].row;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* dirty hack to determine frow */
|
||||
game_submap = sysarg_args_submap;
|
||||
i = 0;
|
||||
while (i < map_nbr_connect &&
|
||||
(map_connect[i].submap != game_submap ||
|
||||
map_connect[i].dir != RIGHT))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
map_frow = map_connect[i].rowin - 0x10;
|
||||
ent_ents[1].y = 0x10 << 3;
|
||||
}
|
||||
|
||||
ent_ents[1].x = map_maps[game_map].x;
|
||||
ent_ents[1].y = map_maps[game_map].y;
|
||||
ent_ents[1].w = 0x18;
|
||||
ent_ents[1].h = 0x15;
|
||||
ent_ents[1].n = 0x01;
|
||||
ent_ents[1].sprite = 0x01;
|
||||
ent_ents[1].front = false;
|
||||
ent_ents[ENT_ENTSNUM].n = 0xFF;
|
||||
|
||||
map_resetMarks();
|
||||
|
||||
map_init();
|
||||
isave();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* play0
|
||||
*
|
||||
*/
|
||||
static void
|
||||
play0(void)
|
||||
{
|
||||
if (control_test(Control_END)) { /* request to end the game */
|
||||
game_state = GAMEOVER;
|
||||
return;
|
||||
}
|
||||
|
||||
if (control_test(Control_EXIT)) { /* request to exit the game */
|
||||
game_state = EXIT;
|
||||
return;
|
||||
}
|
||||
|
||||
ent_action(); /* run entities */
|
||||
e_them_rndseed++; /* (0270) */
|
||||
|
||||
game_state = PLAY1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* play3
|
||||
*
|
||||
*/
|
||||
static void
|
||||
play3(void)
|
||||
{
|
||||
draw_clearStatus(); /* clear the status bar */
|
||||
ent_draw(); /* draw all entities onto the buffer */
|
||||
/* sound */
|
||||
draw_drawStatus(); /* draw the status bar onto the buffer*/
|
||||
|
||||
game_rects = &draw_STATUSRECT; /* refresh status bar too */
|
||||
draw_STATUSRECT.next = ent_rects; /* take care to cleanup draw_STATUSRECT->next later! */
|
||||
|
||||
if (!e_rick_state_test(E_RICK_STZOMBIE)) { /* need to scroll ? */
|
||||
if (ent_ents[1].y >= 0xCC) {
|
||||
game_state = SCROLL_UP;
|
||||
return;
|
||||
}
|
||||
if (ent_ents[1].y <= 0x60) {
|
||||
game_state = SCROLL_DOWN;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
game_state = PLAY0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* restart
|
||||
*
|
||||
*/
|
||||
static void
|
||||
restart(void)
|
||||
{
|
||||
e_rick_state_clear(E_RICK_STDEAD|E_RICK_STZOMBIE);
|
||||
|
||||
game_bullets = 6;
|
||||
game_bombs = 6;
|
||||
|
||||
ent_ents[1].n = 1;
|
||||
|
||||
irestore();
|
||||
map_init();
|
||||
isave();
|
||||
ent_clprev();
|
||||
draw_map();
|
||||
draw_drawStatus();
|
||||
game_rects = &draw_SCREENRECT;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* isave (0bbb)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
isave(void)
|
||||
{
|
||||
e_rick_save();
|
||||
isave_frow = map_frow;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* irestore (0bdc)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
irestore(void)
|
||||
{
|
||||
e_rick_restore();
|
||||
map_frow = isave_frow;
|
||||
}
|
||||
|
||||
/* eof */
|
73
apps/plugins/xrick/game.h
Normal file
73
apps/plugins/xrick/game.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* xrick/game.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _GAME_H
|
||||
#define _GAME_H
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/rects.h"
|
||||
#ifdef ENABLE_SOUND
|
||||
#include "xrick/data/sounds.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h> /* NULL */
|
||||
|
||||
#define LEFT 1
|
||||
#define RIGHT 0
|
||||
|
||||
#define GAME_PERIOD 40
|
||||
|
||||
#define GAME_BOMBS_INIT 6
|
||||
#define GAME_BULLETS_INIT 6
|
||||
|
||||
extern U8 game_lives; /* lives counter */
|
||||
extern U8 game_bombs; /* bombs counter */
|
||||
extern U8 game_bullets; /* bullets counter */
|
||||
|
||||
extern U32 game_score; /* score */
|
||||
|
||||
extern U16 game_map; /* current map */
|
||||
extern U16 game_submap; /* current submap */
|
||||
|
||||
extern U8 game_dir; /* direction (LEFT, RIGHT) */
|
||||
extern bool game_chsm; /* change submap request (true, false) */
|
||||
|
||||
extern bool game_waitevt; /* wait for events (true, false) */
|
||||
extern U8 game_period; /* time between each frame, in millisecond */
|
||||
|
||||
extern const rect_t *game_rects; /* rectangles to redraw at each frame */
|
||||
|
||||
extern void game_run(void);
|
||||
#ifdef ENABLE_SOUND
|
||||
extern void game_setmusic(sound_t * sound, S8 loop);
|
||||
extern void game_stopmusic(void);
|
||||
#endif /* ENABLE_SOUND */
|
||||
|
||||
#ifdef ENABLE_CHEATS
|
||||
typedef enum
|
||||
{
|
||||
Cheat_UNLIMITED_ALL,
|
||||
Cheat_NEVER_DIE,
|
||||
Cheat_EXPOSE
|
||||
} cheat_t;
|
||||
extern bool game_cheat1; /* infinite lives, bombs and bullets */
|
||||
extern bool game_cheat2; /* never die */
|
||||
extern bool game_cheat3; /* highlight sprites */
|
||||
extern void game_toggleCheat(cheat_t);
|
||||
#endif /* ENABLE_CHEATS */
|
||||
|
||||
#endif /* ndef _GAME_H */
|
||||
|
||||
/* eof */
|
253
apps/plugins/xrick/maps.c
Normal file
253
apps/plugins/xrick/maps.c
Normal file
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* xrick/maps.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTES
|
||||
*
|
||||
* A map is composed of submaps, which in turn are composed of rows of
|
||||
* 0x20 tiles. map_map contains the tiles for the current portion of the
|
||||
* current submap, i.e. a little bit more than what appear on the screen,
|
||||
* but not the whole submap.
|
||||
*
|
||||
* map_frow is map_map top row within the submap.
|
||||
*
|
||||
* Submaps are stored as arrays of blocks, each block being a 4x4 tile
|
||||
* array. map_submaps[].bnum points to the first block of the array.
|
||||
*
|
||||
* Before a submap can be played, it needs to be expanded from blocks
|
||||
* to map_map.
|
||||
*/
|
||||
|
||||
#include "xrick/maps.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/debug.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/screens.h"
|
||||
#include "xrick/e_sbonus.h"
|
||||
|
||||
/*
|
||||
* global vars
|
||||
*/
|
||||
U8 map_map[0x2C][0x20];
|
||||
|
||||
size_t map_nbr_maps = 0;
|
||||
map_t *map_maps = NULL;
|
||||
|
||||
size_t map_nbr_submaps = 0;
|
||||
submap_t *map_submaps = NULL;
|
||||
|
||||
size_t map_nbr_connect = 0;
|
||||
connect_t *map_connect = NULL;
|
||||
|
||||
size_t map_nbr_blocks = 0;
|
||||
block_t *map_blocks = NULL;
|
||||
|
||||
size_t map_nbr_marks = 0;
|
||||
mark_t *map_marks = NULL;
|
||||
|
||||
size_t map_nbr_bnums = 0;
|
||||
U8 *map_bnums = NULL;
|
||||
|
||||
size_t map_nbr_eflgc = 0;
|
||||
U8 *map_eflg_c = NULL;
|
||||
U8 map_eflg[0x100];
|
||||
|
||||
U8 map_frow;
|
||||
U8 map_tilesBank;
|
||||
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
*/
|
||||
static void map_eflg_expand(U8);
|
||||
|
||||
|
||||
/*
|
||||
* Fill in map_map with tile numbers by expanding blocks.
|
||||
*
|
||||
* add map_submaps[].bnum to map_frow to find out where to start from.
|
||||
* We need to /4 map_frow to convert from tile rows to block rows, then
|
||||
* we need to *8 to convert from block rows to block numbers (there
|
||||
* are 8 blocks per block row). This is achieved by *2 then &0xfff8.
|
||||
*/
|
||||
void
|
||||
map_expand(void)
|
||||
{
|
||||
U8 i, j, k, l;
|
||||
U8 row, col;
|
||||
U16 pbnum;
|
||||
|
||||
pbnum = map_submaps[game_submap].bnum + ((2 * map_frow) & 0xfff8);
|
||||
row = col = 0;
|
||||
|
||||
for (i = 0; i < 0x0b; i++) { /* 0x0b rows of blocks */
|
||||
for (j = 0; j < 0x08; j++) { /* 0x08 blocks per row */
|
||||
for (k = 0, l = 0; k < 0x04; k++) { /* expand one block */
|
||||
map_map[row][col++] = map_blocks[map_bnums[pbnum]][l++];
|
||||
map_map[row][col++] = map_blocks[map_bnums[pbnum]][l++];
|
||||
map_map[row][col++] = map_blocks[map_bnums[pbnum]][l++];
|
||||
map_map[row][col] = map_blocks[map_bnums[pbnum]][l++];
|
||||
row += 1; col -= 3;
|
||||
}
|
||||
row -= 4; col += 4;
|
||||
pbnum++;
|
||||
}
|
||||
row += 4; col = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize a new submap
|
||||
*
|
||||
* ASM 0cc3
|
||||
*/
|
||||
void
|
||||
map_init(void)
|
||||
{
|
||||
/*sys_printf("xrick/map_init: map=%#04x submap=%#04x\n", g_map, game_submap);*/
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xffff;
|
||||
map_tilesBank = 2 + map_submaps[game_submap].page;
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
map_tilesBank = 1 + map_submaps[game_submap].page;
|
||||
#endif
|
||||
map_eflg_expand(map_submaps[game_submap].page << 4);
|
||||
map_expand();
|
||||
ent_reset();
|
||||
ent_actvis(map_frow + MAP_ROW_SCRTOP, map_frow + MAP_ROW_SCRBOT);
|
||||
ent_actvis(map_frow + MAP_ROW_HTTOP, map_frow + MAP_ROW_HTBOT);
|
||||
ent_actvis(map_frow + MAP_ROW_HBTOP, map_frow + MAP_ROW_HBBOT);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Expand entity flags for this map
|
||||
*
|
||||
* ASM 1117
|
||||
*/
|
||||
void
|
||||
map_eflg_expand(U8 offs)
|
||||
{
|
||||
U8 i, j, k;
|
||||
|
||||
for (i = 0, k = 0; i < 0x10; i++) {
|
||||
j = map_eflg_c[offs + i++];
|
||||
while (j--) map_eflg[k++] = map_eflg_c[offs + i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Chain (sub)maps
|
||||
*
|
||||
* ASM 0c08
|
||||
* return: true/next submap OK, false/map finished
|
||||
*/
|
||||
bool
|
||||
map_chain(void)
|
||||
{
|
||||
U16 c, t;
|
||||
|
||||
game_chsm = false;
|
||||
e_sbonus_counting = false;
|
||||
|
||||
/* find connection */
|
||||
c = map_submaps[game_submap].connect;
|
||||
t = 3;
|
||||
|
||||
IFDEBUG_MAPS(
|
||||
sys_printf("xrick/maps: chain submap=%#04x frow=%#04x .connect=%#04x %s\n",
|
||||
game_submap, map_frow, c,
|
||||
(game_dir == LEFT ? "-> left" : "-> right"));
|
||||
);
|
||||
|
||||
/*
|
||||
* look for the first connector with compatible row number. if none
|
||||
* found, then panic
|
||||
*/
|
||||
for (c = map_submaps[game_submap].connect ; ; c++)
|
||||
{
|
||||
if (map_connect[c].dir == 0xff)
|
||||
{
|
||||
sys_error("(map_chain) can not find connector\n");
|
||||
control_set(Control_EXIT);
|
||||
return false;
|
||||
}
|
||||
if (map_connect[c].dir != game_dir)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
t = (ent_ents[1].y >> 3) + map_frow - map_connect[c].rowout;
|
||||
if (t < 3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* got it */
|
||||
IFDEBUG_MAPS(
|
||||
sys_printf("xrick/maps: chain frow=%#04x y=%#06x\n",
|
||||
map_frow, ent_ents[1].y);
|
||||
sys_printf("xrick/maps: chain connect=%#04x rowout=%#04x - ",
|
||||
c, map_connect[c].rowout);
|
||||
);
|
||||
|
||||
if (map_connect[c].submap == 0xff)
|
||||
{
|
||||
/* no next submap - request next map */
|
||||
IFDEBUG_MAPS(
|
||||
sys_printf("chain to next map\n");
|
||||
);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* next submap */
|
||||
IFDEBUG_MAPS(
|
||||
sys_printf("chain to submap=%#04x rowin=%#04x\n",
|
||||
map_connect[c].submap, map_connect[c].rowin);
|
||||
);
|
||||
map_frow = map_frow - map_connect[c].rowout + map_connect[c].rowin;
|
||||
game_submap = map_connect[c].submap;
|
||||
IFDEBUG_MAPS(
|
||||
sys_printf("xrick/maps: chain frow=%#04x\n",
|
||||
map_frow);
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Reset all marks, i.e. make them all active again.
|
||||
*
|
||||
* ASM 0025
|
||||
*
|
||||
*/
|
||||
void
|
||||
map_resetMarks(void)
|
||||
{
|
||||
U16 i;
|
||||
for (i = 0; i < map_nbr_marks; i++)
|
||||
map_marks[i].ent &= ~MAP_MARK_NACT;
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
159
apps/plugins/xrick/maps.h
Normal file
159
apps/plugins/xrick/maps.h
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* xrick/maps.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _MAPS_H
|
||||
#define _MAPS_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
#include "xrick/system/system.h"
|
||||
#ifdef ENABLE_SOUND
|
||||
#include "xrick/data/sounds.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
/*
|
||||
* map row definitions, for three zones : hidden top, screen, hidden bottom
|
||||
* the three zones compose map_map, which contains the definition of the
|
||||
* current portion of the submap.
|
||||
*/
|
||||
#define MAP_ROW_HTTOP 0x00
|
||||
#define MAP_ROW_HTBOT 0x07
|
||||
#define MAP_ROW_SCRTOP 0x08
|
||||
#define MAP_ROW_SCRBOT 0x1F
|
||||
#define MAP_ROW_HBTOP 0x20
|
||||
#define MAP_ROW_HBBOT 0x27
|
||||
|
||||
extern U8 map_map[0x2c][0x20];
|
||||
|
||||
/*
|
||||
* main maps
|
||||
*/
|
||||
typedef struct {
|
||||
U16 x, y; /* initial position for rick */
|
||||
U16 row; /* initial map_map top row within the submap */
|
||||
U16 submap; /* initial submap */
|
||||
#ifdef ENABLE_SOUND
|
||||
sound_t * tune; /* map tune */
|
||||
#endif
|
||||
} map_t;
|
||||
|
||||
extern size_t map_nbr_maps;
|
||||
extern map_t *map_maps;
|
||||
|
||||
/*
|
||||
* sub maps
|
||||
*/
|
||||
typedef struct {
|
||||
U16 page; /* tiles page */
|
||||
U16 bnum; /* first block number */
|
||||
U16 connect; /* first connection */
|
||||
U16 mark; /* first entity mark */
|
||||
} submap_t;
|
||||
|
||||
extern size_t map_nbr_submaps;
|
||||
extern submap_t *map_submaps;
|
||||
|
||||
/*
|
||||
* connections
|
||||
*/
|
||||
typedef struct {
|
||||
U8 dir;
|
||||
U8 rowout;
|
||||
U8 submap;
|
||||
U8 rowin;
|
||||
} connect_t;
|
||||
|
||||
extern size_t map_nbr_connect;
|
||||
extern connect_t *map_connect;
|
||||
|
||||
/*
|
||||
* blocks - one block is 4 by 4 tiles.
|
||||
*/
|
||||
typedef U8 block_t[0x10];
|
||||
|
||||
extern size_t map_nbr_blocks;
|
||||
extern block_t *map_blocks;
|
||||
|
||||
/*
|
||||
* flags for map_marks[].ent ("yes" when set)
|
||||
*
|
||||
* MAP_MARK_NACT: this mark is not active anymore.
|
||||
*/
|
||||
#define MAP_MARK_NACT (0x80)
|
||||
|
||||
/*
|
||||
* mark structure
|
||||
*/
|
||||
typedef struct {
|
||||
U8 row;
|
||||
U8 ent;
|
||||
U8 flags;
|
||||
U8 xy; /* bits XXXX XYYY (from b03) with X->x, Y->y */
|
||||
U8 lt; /* bits XXXX XNNN (from b04) with X->trig_x, NNN->lat & trig_y */
|
||||
} mark_t;
|
||||
|
||||
extern size_t map_nbr_marks;
|
||||
extern mark_t *map_marks;
|
||||
|
||||
/*
|
||||
* block numbers, i.e. array of rows of 8 blocks
|
||||
*/
|
||||
extern size_t map_nbr_bnums;
|
||||
extern U8 *map_bnums;
|
||||
|
||||
/*
|
||||
* flags for map_eflg[map_map[row][col]] ("yes" when set)
|
||||
*
|
||||
* MAP_EFLG_VERT: vertical move only (usually on top of _CLIMB).
|
||||
* MAP_EFLG_SOLID: solid block, can't go through.
|
||||
* MAP_EFLG_SPAD: super pad. can't go through, but sends entities to the sky.
|
||||
* MAP_EFLG_WAYUP: solid block, can't go through except when going up.
|
||||
* MAP_EFLG_FGND: foreground (hides entities).
|
||||
* MAP_EFLG_LETHAL: lethal (kill entities).
|
||||
* MAP_EFLG_CLIMB: entities can climb here.
|
||||
* MAP_EFLG_01:
|
||||
*/
|
||||
#define MAP_EFLG_VERT (0x80)
|
||||
#define MAP_EFLG_SOLID (0x40)
|
||||
#define MAP_EFLG_SPAD (0x20)
|
||||
#define MAP_EFLG_WAYUP (0x10)
|
||||
#define MAP_EFLG_FGND (0x08)
|
||||
#define MAP_EFLG_LETHAL (0x04)
|
||||
#define MAP_EFLG_CLIMB (0x02)
|
||||
#define MAP_EFLG_01 (0x01)
|
||||
|
||||
extern size_t map_nbr_eflgc;
|
||||
extern U8 *map_eflg_c; /* compressed */
|
||||
extern U8 map_eflg[0x100]; /* current */
|
||||
|
||||
/*
|
||||
* map_map top row within the submap
|
||||
*/
|
||||
extern U8 map_frow;
|
||||
|
||||
/*
|
||||
* tiles offset
|
||||
*/
|
||||
extern U8 map_tilesBank;
|
||||
|
||||
extern void map_expand(void);
|
||||
extern void map_init(void);
|
||||
extern bool map_chain(void);
|
||||
extern void map_resetMarks(void);
|
||||
|
||||
#endif /* ndef _MAPS_H */
|
||||
|
||||
/* eof */
|
57
apps/plugins/xrick/rects.c
Normal file
57
apps/plugins/xrick/rects.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* xrick/rects.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/rects.h"
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
/*
|
||||
* Free a list of rectangles and set the pointer to NULL.
|
||||
*
|
||||
* p: rectangle list CHANGED to NULL
|
||||
*/
|
||||
void
|
||||
rects_free(rect_t *r)
|
||||
{
|
||||
while (r)
|
||||
{
|
||||
rect_t * next = r->next;
|
||||
sysmem_pop(r);
|
||||
r = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a rectangle to a list of rectangles
|
||||
*/
|
||||
rect_t *
|
||||
rects_new(U16 x, U16 y, U16 width, U16 height, rect_t *next)
|
||||
{
|
||||
rect_t *r;
|
||||
|
||||
r = sysmem_push(sizeof(*r));
|
||||
if (!r)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
r->x = x;
|
||||
r->y = y;
|
||||
r->width = width;
|
||||
r->height = height;
|
||||
r->next = next;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* eof */
|
32
apps/plugins/xrick/rects.h
Normal file
32
apps/plugins/xrick/rects.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* xrick/rects.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _RECTS_H
|
||||
#define _RECTS_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
typedef struct rect_s {
|
||||
U16 x, y;
|
||||
U16 width, height;
|
||||
struct rect_s *next;
|
||||
} rect_t;
|
||||
|
||||
extern void rects_free(rect_t *);
|
||||
extern rect_t *rects_new(U16, U16, U16, U16, rect_t *);
|
||||
|
||||
#endif /* ndef _RECTS_H */
|
||||
|
||||
/* eof */
|
18
apps/plugins/xrick/res_magic.c
Normal file
18
apps/plugins/xrick/res_magic.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* xrick/res_magic.c
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/resources.h"
|
||||
|
||||
const U8 resource_magic[4] = { 0x52, 0x49, 0x43, 0x4B }; /* 'R','I','C','K' */
|
||||
|
||||
/* eof */
|
1297
apps/plugins/xrick/resources.c
Normal file
1297
apps/plugins/xrick/resources.c
Normal file
File diff suppressed because it is too large
Load diff
165
apps/plugins/xrick/resources.h
Normal file
165
apps/plugins/xrick/resources.h
Normal file
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* xrick/resources.h
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _RESOURCES_H
|
||||
#define _RESOURCES_H
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/screens.h"
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
/*
|
||||
* All data is assumed to be Little Endian
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
U8 magic[4];
|
||||
U8 version[2];
|
||||
U8 resourceId[2];
|
||||
} resource_header_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 w;
|
||||
U8 h;
|
||||
U8 spr[2];
|
||||
U8 sni[2];
|
||||
U8 trig_w;
|
||||
U8 trig_h;
|
||||
U8 snd;
|
||||
} resource_entdata_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 x[2];
|
||||
U8 y[2];
|
||||
U8 row[2];
|
||||
U8 submap[2];
|
||||
U8 tuneId[2];
|
||||
} resource_map_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 page[2];
|
||||
U8 bnum[2];
|
||||
U8 connect[2];
|
||||
U8 mark[2];
|
||||
} resource_submap_t;
|
||||
|
||||
typedef struct {
|
||||
U8 count[2];
|
||||
U8 dx[2];
|
||||
U8 dy[2];
|
||||
U8 base[2];
|
||||
} resource_imapsteps_t;
|
||||
|
||||
typedef struct {
|
||||
U8 width[2];
|
||||
U8 height[2];
|
||||
U8 xPos[2];
|
||||
U8 yPos[2];
|
||||
} resource_pic_t;
|
||||
|
||||
typedef struct {
|
||||
U8 score[4];
|
||||
U8 name[HISCORE_NAME_SIZE];
|
||||
} resource_hiscore_t;
|
||||
|
||||
#ifdef GFXPC
|
||||
typedef struct {
|
||||
U8 mask[2];
|
||||
U8 pict[2];
|
||||
} resource_spriteX_t;
|
||||
#endif /* GFXPC */
|
||||
|
||||
extern const U8 resource_magic[4];
|
||||
|
||||
enum
|
||||
{
|
||||
DATA_VERSION = 3,
|
||||
|
||||
/* "bootstrap" file */
|
||||
Resource_FILELIST = 0,
|
||||
|
||||
/* graphics, misc, texts */
|
||||
Resource_PALETTE,
|
||||
Resource_ENTDATA,
|
||||
Resource_SPRSEQ,
|
||||
Resource_MVSTEP,
|
||||
Resource_MAPS,
|
||||
Resource_SUBMAPS,
|
||||
Resource_CONNECT,
|
||||
Resource_BNUMS,
|
||||
Resource_BLOCKS,
|
||||
Resource_MARKS,
|
||||
Resource_EFLGC,
|
||||
Resource_IMAPSL,
|
||||
Resource_IMAPSTEPS,
|
||||
Resource_IMAPSOFS,
|
||||
Resource_IMAPTEXT,
|
||||
Resource_GAMEOVERTXT,
|
||||
Resource_PAUSEDTXT,
|
||||
Resource_SPRITESDATA,
|
||||
Resource_TILESDATA,
|
||||
Resource_HIGHSCORES,
|
||||
Resource_IMGSPLASH,
|
||||
Resource_PICHAF, /* ST version only */
|
||||
Resource_PICCONGRATS, /* ST version only */
|
||||
Resource_PICSPLASH, /* ST version only */
|
||||
Resource_IMAINHOFT, /* PC version only */
|
||||
Resource_IMAINRDT, /* PC version only */
|
||||
Resource_IMAINCDC, /* PC version only */
|
||||
Resource_SCREENCONGRATS, /* PC version only */
|
||||
|
||||
/* sounds */
|
||||
Resource_SOUNDBOMBSHHT,
|
||||
Resource_SOUNDBONUS,
|
||||
Resource_SOUNDBOX,
|
||||
Resource_SOUNDBULLET,
|
||||
Resource_SOUNDCRAWL,
|
||||
Resource_SOUNDDIE,
|
||||
Resource_SOUNDENTITY0,
|
||||
Resource_SOUNDENTITY1,
|
||||
Resource_SOUNDENTITY2,
|
||||
Resource_SOUNDENTITY3,
|
||||
Resource_SOUNDENTITY4,
|
||||
Resource_SOUNDENTITY5,
|
||||
Resource_SOUNDENTITY6,
|
||||
Resource_SOUNDENTITY7,
|
||||
Resource_SOUNDENTITY8,
|
||||
Resource_SOUNDEXPLODE,
|
||||
Resource_SOUNDGAMEOVER,
|
||||
Resource_SOUNDJUMP,
|
||||
Resource_SOUNDPAD,
|
||||
Resource_SOUNDSBONUS1,
|
||||
Resource_SOUNDSBONUS2,
|
||||
Resource_SOUNDSTICK,
|
||||
Resource_SOUNDTUNE0,
|
||||
Resource_SOUNDTUNE1,
|
||||
Resource_SOUNDTUNE2,
|
||||
Resource_SOUNDTUNE3,
|
||||
Resource_SOUNDTUNE4,
|
||||
Resource_SOUNDTUNE5,
|
||||
Resource_SOUNDWALK,
|
||||
|
||||
Resource_MAX_COUNT,
|
||||
};
|
||||
|
||||
#define BOOTSTRAP_RESOURCE_NAME "filelist.dat"
|
||||
|
||||
bool resources_load(void);
|
||||
void resources_unload(void);
|
||||
|
||||
#endif /* ndef _RESOURCES_H */
|
||||
|
||||
/* eof */
|
92
apps/plugins/xrick/scr_gameover.c
Normal file
92
apps/plugins/xrick/scr_gameover.c
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* xrick/scr_gameover.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/screens.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
/*
|
||||
* Display the game over screen
|
||||
*
|
||||
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
|
||||
*/
|
||||
U8
|
||||
screen_gameover(void)
|
||||
{
|
||||
static U8 seq = 0;
|
||||
static U8 period = 0;
|
||||
#ifdef GFXST
|
||||
static U32 tm = 0;
|
||||
#endif
|
||||
if (seq == 0) {
|
||||
draw_tilesBank = 0;
|
||||
seq = 1;
|
||||
period = game_period; /* save period, */
|
||||
game_period = 50; /* and use our own */
|
||||
#ifdef ENABLE_SOUND
|
||||
game_setmusic(soundGameover, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (seq) {
|
||||
case 1: /* display banner */
|
||||
#ifdef GFXST
|
||||
sysvid_clear();
|
||||
tm = sys_gettime();
|
||||
#endif
|
||||
draw_tllst = screen_gameovertxt;
|
||||
draw_setfb(120, 80);
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xAAAA;
|
||||
#endif
|
||||
draw_tilesList();
|
||||
draw_drawStatus();
|
||||
|
||||
game_rects = &draw_SCREENRECT;
|
||||
seq = 2;
|
||||
break;
|
||||
|
||||
case 2: /* wait for key pressed */
|
||||
if (control_test(Control_FIRE))
|
||||
seq = 3;
|
||||
#ifdef GFXST
|
||||
else if (sys_gettime() - tm > SCREEN_TIMEOUT)
|
||||
seq = 4;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 3: /* wait for key released */
|
||||
if (!(control_test(Control_FIRE)))
|
||||
seq = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
if (control_test(Control_EXIT)) /* check for exit request */
|
||||
return SCREEN_EXIT;
|
||||
|
||||
if (seq == 4) { /* we're done */
|
||||
sysvid_clear();
|
||||
seq = 0;
|
||||
game_period = period;
|
||||
return SCREEN_DONE;
|
||||
}
|
||||
|
||||
return SCREEN_RUNNING;
|
||||
}
|
||||
|
||||
/* eof */
|
290
apps/plugins/xrick/scr_getname.c
Normal file
290
apps/plugins/xrick/scr_getname.c
Normal file
|
@ -0,0 +1,290 @@
|
|||
/*
|
||||
* xrick/scr_getname.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/screens.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/data/pics.h"
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
/*
|
||||
* local vars
|
||||
*/
|
||||
static U8 seq = 0;
|
||||
static U8 x, y, p;
|
||||
static U8 player_name[HISCORE_NAME_SIZE];
|
||||
|
||||
#define TILE_POINTER '\072'
|
||||
#define TILE_CURSOR '\073'
|
||||
#define TOPLEFT_X 116
|
||||
#define TOPLEFT_Y 64
|
||||
#define NAMEPOS_X 120
|
||||
#define NAMEPOS_Y 160
|
||||
#define AUTOREPEAT_TMOUT 100
|
||||
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
*/
|
||||
static void pointer_show(bool);
|
||||
static void name_update(void);
|
||||
static void name_draw(void);
|
||||
|
||||
|
||||
/*
|
||||
* Get name
|
||||
*
|
||||
* return: 0 while running, 1 when finished.
|
||||
*/
|
||||
U8
|
||||
screen_getname(void)
|
||||
{
|
||||
static U32 tm = 0;
|
||||
U8 i, j;
|
||||
|
||||
if (seq == 0)
|
||||
{
|
||||
/* figure out if this is a high score */
|
||||
if (game_score < screen_highScores[screen_nbr_hiscores - 1].score)
|
||||
return SCREEN_DONE;
|
||||
|
||||
/* prepare */
|
||||
draw_tilesBank = 0;
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xffff;
|
||||
#endif
|
||||
for (i = 0; i < HISCORE_NAME_SIZE; i++)
|
||||
{
|
||||
player_name[i] = '@';
|
||||
}
|
||||
x = 5, y = 4, p = 0;
|
||||
game_rects = &draw_SCREENRECT;
|
||||
seq = 1;
|
||||
}
|
||||
|
||||
switch (seq)
|
||||
{
|
||||
case 1: /* prepare screen */
|
||||
{
|
||||
sysvid_clear();
|
||||
#ifdef GFXPC
|
||||
draw_setfb(32, 8);
|
||||
draw_filter = 0xaaaa; /* red */
|
||||
draw_tilesListImm(screen_congrats);
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_pic(pic_congrats);
|
||||
#endif
|
||||
draw_setfb(72, 40);
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xffff; /* yellow */
|
||||
#endif
|
||||
draw_tilesListImm((U8 *)"PLEASE@ENTER@YOUR@NAME\376");
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0x5555; /* green */
|
||||
#endif
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
draw_setfb(TOPLEFT_X + i * 8 * 2, TOPLEFT_Y + j * 8 * 2);
|
||||
draw_tile('A' + i + j * 6);
|
||||
}
|
||||
}
|
||||
draw_setfb(TOPLEFT_X, TOPLEFT_Y + 64);
|
||||
#ifdef GFXST
|
||||
draw_tilesListImm((U8 *)"Y@Z@.@@@\074\373\374\375\376");
|
||||
#endif
|
||||
#ifdef GFXPC
|
||||
draw_tilesListImm((U8 *)"Y@Z@.@@@\074@\075@\376");
|
||||
#endif
|
||||
name_draw();
|
||||
pointer_show(true);
|
||||
seq = 2;
|
||||
break;
|
||||
}
|
||||
case 2: /* wait for key pressed */
|
||||
{
|
||||
if (control_test(Control_FIRE))
|
||||
seq = 3;
|
||||
if (control_test(Control_UP)) {
|
||||
if (y > 0) {
|
||||
pointer_show(false);
|
||||
y--;
|
||||
pointer_show(true);
|
||||
tm = sys_gettime();
|
||||
}
|
||||
seq = 4;
|
||||
}
|
||||
if (control_test(Control_DOWN)) {
|
||||
if (y < 4) {
|
||||
pointer_show(false);
|
||||
y++;
|
||||
pointer_show(true);
|
||||
tm = sys_gettime();
|
||||
}
|
||||
seq = 5;
|
||||
}
|
||||
if (control_test(Control_LEFT)) {
|
||||
if (x > 0) {
|
||||
pointer_show(false);
|
||||
x--;
|
||||
pointer_show(true);
|
||||
tm = sys_gettime();
|
||||
}
|
||||
seq = 6;
|
||||
}
|
||||
if (control_test(Control_RIGHT)) {
|
||||
if (x < 5) {
|
||||
pointer_show(false);
|
||||
x++;
|
||||
pointer_show(true);
|
||||
tm = sys_gettime();
|
||||
}
|
||||
seq = 7;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: /* wait for FIRE released */
|
||||
{
|
||||
if (!(control_test(Control_FIRE)))
|
||||
{
|
||||
if (x == 5 && y == 4)
|
||||
{ /* end */
|
||||
i = 0;
|
||||
while (game_score < screen_highScores[i].score) i++;
|
||||
j = 7;
|
||||
while (j > i)
|
||||
{
|
||||
screen_highScores[j].score = screen_highScores[j - 1].score;
|
||||
for (x = 0; x < HISCORE_NAME_SIZE; x++)
|
||||
{
|
||||
screen_highScores[j].name[x] = screen_highScores[j - 1].name[x];
|
||||
}
|
||||
j--;
|
||||
}
|
||||
screen_highScores[i].score = game_score;
|
||||
for (x = 0; x < HISCORE_NAME_SIZE; x++)
|
||||
{
|
||||
screen_highScores[i].name[x] = player_name[x];
|
||||
}
|
||||
seq = 99;
|
||||
}
|
||||
else
|
||||
{
|
||||
name_update();
|
||||
name_draw();
|
||||
seq = 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: /* wait for UP released */
|
||||
{
|
||||
if (!(control_test(Control_UP)) ||
|
||||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
|
||||
seq = 2;
|
||||
break;
|
||||
}
|
||||
case 5: /* wait for DOWN released */
|
||||
{
|
||||
if (!(control_test(Control_DOWN)) ||
|
||||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
|
||||
seq = 2;
|
||||
break;
|
||||
}
|
||||
case 6: /* wait for LEFT released */
|
||||
{
|
||||
if (!(control_test(Control_LEFT)) ||
|
||||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
|
||||
seq = 2;
|
||||
break;
|
||||
}
|
||||
case 7: /* wait for RIGHT released */
|
||||
{
|
||||
if (!(control_test(Control_RIGHT)) ||
|
||||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
|
||||
seq = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (control_test(Control_EXIT)) /* check for exit request */
|
||||
return SCREEN_EXIT;
|
||||
|
||||
if (seq == 99) { /* seq 99, we're done */
|
||||
sysvid_clear();
|
||||
seq = 0;
|
||||
return SCREEN_DONE;
|
||||
}
|
||||
else
|
||||
return SCREEN_RUNNING;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pointer_show(bool show)
|
||||
{
|
||||
draw_setfb(TOPLEFT_X + x * 8 * 2, TOPLEFT_Y + y * 8 * 2 + 8);
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xaaaa; /* red */
|
||||
#endif
|
||||
draw_tile(show? TILE_POINTER:'@');
|
||||
}
|
||||
|
||||
static void
|
||||
name_update(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
i = x + y * 6;
|
||||
if (i < 26 && p < 10)
|
||||
player_name[p++] = 'A' + i;
|
||||
if (i == 26 && p < 10)
|
||||
player_name[p++] = '.';
|
||||
if (i == 27 && p < 10)
|
||||
player_name[p++] = '@';
|
||||
if (i == 28 && p > 0) {
|
||||
p--;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
name_draw(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
draw_setfb(NAMEPOS_X, NAMEPOS_Y);
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xaaaa; /* red */
|
||||
#endif
|
||||
for (i = 0; i < p; i++)
|
||||
draw_tile(player_name[i]);
|
||||
for (i = p; i < 10; i++)
|
||||
draw_tile(TILE_CURSOR);
|
||||
|
||||
#ifdef GFXST
|
||||
draw_setfb(NAMEPOS_X, NAMEPOS_Y + 8);
|
||||
for (i = 0; i < 10; i++)
|
||||
draw_tile('@');
|
||||
draw_setfb(NAMEPOS_X + 8 * (p < 9 ? p : 9), NAMEPOS_Y + 8);
|
||||
draw_tile(TILE_POINTER);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
170
apps/plugins/xrick/scr_imain.c
Normal file
170
apps/plugins/xrick/scr_imain.c
Normal file
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* xrick/scr_imain.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/screens.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/control.h"
|
||||
#ifdef GFXST
|
||||
#include "xrick/data/pics.h"
|
||||
#endif
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
/*
|
||||
* Main introduction
|
||||
*
|
||||
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
|
||||
*/
|
||||
U8
|
||||
screen_introMain(void)
|
||||
{
|
||||
static U8 seq = 0;
|
||||
static U8 seen = 0;
|
||||
static bool first = true;
|
||||
static U8 period = 0;
|
||||
static U32 tm = 0;
|
||||
|
||||
if (seq == 0) {
|
||||
draw_tilesBank = 0;
|
||||
if (first)
|
||||
seq = 1;
|
||||
else
|
||||
seq = 4;
|
||||
period = game_period;
|
||||
game_period = 50;
|
||||
game_rects = &draw_SCREENRECT;
|
||||
#ifdef ENABLE_SOUND
|
||||
game_setmusic(soundTune5, -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (seq)
|
||||
{
|
||||
case 1: /* display Rick Dangerous title and Core Design copyright */
|
||||
{
|
||||
sysvid_clear();
|
||||
tm = sys_gettime();
|
||||
#ifdef GFXPC
|
||||
/* Rick Dangerous title */
|
||||
draw_tllst = (U8 *)screen_imainrdt;
|
||||
draw_setfb(32, 16);
|
||||
draw_filter = 0xaaaa;
|
||||
draw_tilesList();
|
||||
|
||||
/* Core Design copyright + press space to start */
|
||||
draw_tllst = (U8 *)screen_imaincdc;
|
||||
draw_setfb(64, 80);
|
||||
draw_filter = 0x5555;
|
||||
draw_tilesList();
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_pic(pic_splash);
|
||||
#endif
|
||||
seq = 2;
|
||||
break;
|
||||
}
|
||||
case 2: /* wait for key pressed or timeout */
|
||||
{
|
||||
if (control_test(Control_FIRE))
|
||||
seq = 3;
|
||||
else if (sys_gettime() - tm > SCREEN_TIMEOUT) {
|
||||
seen++;
|
||||
seq = 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: /* wait for key released */
|
||||
{
|
||||
if (!(control_test(Control_FIRE))) {
|
||||
if (seen++ == 0)
|
||||
seq = 4;
|
||||
else
|
||||
seq = 7;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: /* dispay hall of fame */
|
||||
{
|
||||
U8 s[32];
|
||||
size_t i;
|
||||
|
||||
sysvid_clear();
|
||||
tm = sys_gettime();
|
||||
/* hall of fame title */
|
||||
#ifdef GFXPC
|
||||
draw_tllst = (U8 *)screen_imainhoft;
|
||||
draw_setfb(32, 0);
|
||||
draw_filter = 0xaaaa;
|
||||
draw_tilesList();
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_pic(pic_haf);
|
||||
#endif
|
||||
/* hall of fame content */
|
||||
draw_setfb(56, 48);
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0x5555;
|
||||
#endif
|
||||
for (i = 0; i < screen_nbr_hiscores; i++) {
|
||||
sys_snprintf((char *)s, sizeof(s), "%06d@@@====@@@%s",
|
||||
screen_highScores[i].score, screen_highScores[i].name);
|
||||
s[26] = (U8)'\377';
|
||||
s[27] = (U8)'\377';
|
||||
s[28] = (U8)'\376';
|
||||
draw_tllst = s;
|
||||
draw_tilesList();
|
||||
}
|
||||
seq = 5;
|
||||
break;
|
||||
}
|
||||
case 5: /* wait for key pressed or timeout */
|
||||
{
|
||||
if (control_test(Control_FIRE))
|
||||
seq = 6;
|
||||
else if (sys_gettime() - tm > SCREEN_TIMEOUT) {
|
||||
seen++;
|
||||
seq = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: /* wait for key released */
|
||||
{
|
||||
if (!(control_test(Control_FIRE))) {
|
||||
if (seen++ == 0)
|
||||
seq = 1;
|
||||
else
|
||||
seq = 7;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (control_test(Control_EXIT)) /* check for exit request */
|
||||
return SCREEN_EXIT;
|
||||
|
||||
if (seq == 7) { /* we're done */
|
||||
sysvid_clear();
|
||||
seq = 0;
|
||||
seen = 0;
|
||||
first = false;
|
||||
game_period = period;
|
||||
return SCREEN_DONE;
|
||||
}
|
||||
else
|
||||
return SCREEN_RUNNING;
|
||||
}
|
||||
|
||||
/* eof */
|
293
apps/plugins/xrick/scr_imap.c
Normal file
293
apps/plugins/xrick/scr_imap.c
Normal file
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
* xrick/scr_imap.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/screens.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/rects.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/maps.h"
|
||||
|
||||
/*
|
||||
* local vars
|
||||
*/
|
||||
static U16 step; /* current step */
|
||||
static U16 count; /* number of loops for current step */
|
||||
static U16 run; /* 1 = run, 0 = no more step */
|
||||
static U8 flipflop; /* flipflop for top, bottom, left, right */
|
||||
static U8 spnum; /* sprite number */
|
||||
static U16 spx, spdx; /* sprite x position and delta */
|
||||
static U16 spy, spdy; /* sprite y position and delta */
|
||||
static U16 spbase, spoffs; /* base, offset for sprite numbers table */
|
||||
static U8 seq = 0; /* anim sequence */
|
||||
|
||||
static rect_t anim_rect = { 128, 16 + 16, 64, 64, NULL }; /* anim rectangle */
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
*/
|
||||
static void drawtb(void);
|
||||
static void drawlr(void);
|
||||
static void drawsprite(void);
|
||||
static void drawcenter(void);
|
||||
static void nextstep(void);
|
||||
static void anim(void);
|
||||
static void init(void);
|
||||
|
||||
/*
|
||||
* Map introduction
|
||||
*
|
||||
* ASM: 1948
|
||||
*
|
||||
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
|
||||
*/
|
||||
U8
|
||||
screen_introMap(void)
|
||||
{
|
||||
switch (seq) {
|
||||
case 0:
|
||||
sysvid_clear();
|
||||
|
||||
#ifdef GFXPC
|
||||
draw_tilesBank = 1;
|
||||
draw_filter = 0xAAAA;
|
||||
#endif
|
||||
#ifdef GFXST
|
||||
draw_tilesBank = 0;
|
||||
#endif
|
||||
draw_tllst = screen_imaptext[game_map];
|
||||
draw_setfb(40, 16);
|
||||
draw_tilesSubList();
|
||||
|
||||
draw_setfb(40, 104);
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0x5555;
|
||||
#endif
|
||||
draw_tilesList();
|
||||
|
||||
game_rects = NULL;
|
||||
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xFFFF;
|
||||
#endif
|
||||
|
||||
init();
|
||||
nextstep();
|
||||
drawcenter();
|
||||
drawtb();
|
||||
drawlr();
|
||||
drawsprite();
|
||||
draw_drawStatus();
|
||||
|
||||
game_rects = &draw_SCREENRECT;
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
game_setmusic(map_maps[game_map].tune, 1);
|
||||
#endif
|
||||
|
||||
seq = 1;
|
||||
break;
|
||||
case 1: /* top and bottom borders */
|
||||
drawtb();
|
||||
game_rects = &anim_rect;
|
||||
seq = 2;
|
||||
break;
|
||||
case 2: /* background and sprite */
|
||||
anim();
|
||||
drawcenter();
|
||||
drawsprite();
|
||||
game_rects = &anim_rect;
|
||||
seq = 3;
|
||||
break;
|
||||
case 3: /* all borders */
|
||||
drawtb();
|
||||
drawlr();
|
||||
game_rects = &anim_rect;
|
||||
seq = 1;
|
||||
break;
|
||||
case 4: /* wait for key release */
|
||||
if (!(control_test(Control_FIRE)))
|
||||
seq = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
if (control_test(Control_FIRE)) { /* end as soon as key pressed */
|
||||
seq = 4;
|
||||
}
|
||||
|
||||
if (control_test(Control_EXIT)) /* check for exit request */
|
||||
return SCREEN_EXIT;
|
||||
|
||||
if (seq == 5) { /* end as soon as key pressed */
|
||||
sysvid_clear();
|
||||
seq = 0;
|
||||
return SCREEN_DONE;
|
||||
}
|
||||
else
|
||||
return SCREEN_RUNNING;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Display top and bottom borders (0x1B1F)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
drawtb(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
flipflop++;
|
||||
if (flipflop & 0x01) {
|
||||
draw_setfb(136, 16 + 16);
|
||||
for (i = 0; i < 6; i++)
|
||||
draw_tile(0x40);
|
||||
draw_setfb(136, 72 + 16);
|
||||
for (i = 0; i < 6; i++)
|
||||
draw_tile(0x06);
|
||||
}
|
||||
else {
|
||||
draw_setfb(136, 16 + 16);
|
||||
for (i = 0; i < 6; i++)
|
||||
draw_tile(0x05);
|
||||
draw_setfb(136, 72 + 16);
|
||||
for (i = 0; i < 6; i++)
|
||||
draw_tile(0x40);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Display left and right borders (0x1B7C)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
drawlr(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
if (flipflop & 0x02) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
draw_setfb(128, 16 + i * 8 + 16);
|
||||
draw_tile(0x04);
|
||||
draw_setfb(184, 16 + i * 8 + 16);
|
||||
draw_tile(0x04);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < 8; i++) {
|
||||
draw_setfb(128, 16 + i * 8 + 16);
|
||||
draw_tile(0x2B);
|
||||
draw_setfb(184, 16 + i * 8 + 16);
|
||||
draw_tile(0x2B);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw the sprite (0x19C6)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
drawsprite(void)
|
||||
{
|
||||
draw_sprite(spnum, 136 + ((spx << 1) & 0x1C), 24 + (spy << 1) + 16);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw the background (0x1AF1)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
drawcenter(void)
|
||||
{
|
||||
static U8 tn0[] = { 0x07, 0x5B, 0x7F, 0xA3, 0xC7 };
|
||||
U8 i, j, tn;
|
||||
|
||||
tn = tn0[game_map];
|
||||
for (i = 0; i < 6; i++) {
|
||||
draw_setfb(136, (24 + 8 * i) + 16);
|
||||
for (j = 0; j < 6; j++)
|
||||
draw_tile(tn++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Next Step (0x1A74)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
nextstep(void)
|
||||
{
|
||||
if (screen_imapsteps[step].count) {
|
||||
count = screen_imapsteps[step].count;
|
||||
spdx = screen_imapsteps[step].dx;
|
||||
spdy = screen_imapsteps[step].dy;
|
||||
spbase = screen_imapsteps[step].base;
|
||||
spoffs = 0;
|
||||
step++;
|
||||
}
|
||||
else {
|
||||
run = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Anim (0x1AA8)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
anim(void)
|
||||
{
|
||||
U8 i;
|
||||
|
||||
if (run) {
|
||||
i = screen_imapsl[spbase + spoffs];
|
||||
if (i == 0) {
|
||||
spoffs = 0;
|
||||
i = screen_imapsl[spbase];
|
||||
}
|
||||
spnum = i;
|
||||
spoffs++;
|
||||
spx += spdx;
|
||||
spy += spdy;
|
||||
count--;
|
||||
if (count == 0)
|
||||
nextstep();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize (0x1A43)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
run = 0; run--;
|
||||
step = screen_imapsofs[game_map];
|
||||
spx = screen_imapsteps[step].dx;
|
||||
spy = screen_imapsteps[step].dy;
|
||||
step++;
|
||||
spnum = 0; /* NOTE spnum in [8728] is never initialized ? */
|
||||
}
|
||||
|
||||
/* eof */
|
50
apps/plugins/xrick/scr_pause.c
Normal file
50
apps/plugins/xrick/scr_pause.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* xrick/scr_pause.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/screens.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/ents.h"
|
||||
|
||||
/*
|
||||
* Display the pause indicator
|
||||
*/
|
||||
void
|
||||
screen_pause(bool pause)
|
||||
{
|
||||
if (pause) {
|
||||
draw_tilesBank = 0;
|
||||
draw_tllst = screen_pausedtxt;
|
||||
draw_setfb(120, 80);
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xAAAA;
|
||||
#endif
|
||||
draw_tilesList();
|
||||
}
|
||||
else {
|
||||
#ifdef GFXPC
|
||||
draw_filter = 0xFFFF;
|
||||
#endif
|
||||
draw_map();
|
||||
ent_draw();
|
||||
draw_drawStatus();
|
||||
}
|
||||
game_rects = &draw_SCREENRECT;
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
101
apps/plugins/xrick/scr_xrick.c
Normal file
101
apps/plugins/xrick/scr_xrick.c
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* xrick/scr_xrick.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/screens.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/data/img.h"
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
/*
|
||||
* global vars
|
||||
*/
|
||||
size_t screen_nbr_imapsl = 0;
|
||||
U8 *screen_imapsl = NULL;
|
||||
|
||||
size_t screen_nbr_imapstesps = 0;
|
||||
screen_imapsteps_t *screen_imapsteps = NULL;
|
||||
|
||||
size_t screen_nbr_imapsofs = 0;
|
||||
U8 *screen_imapsofs = NULL;
|
||||
|
||||
size_t screen_nbr_imaptext = 0;
|
||||
U8 **screen_imaptext = NULL;
|
||||
|
||||
size_t screen_nbr_hiscores = 0;
|
||||
hiscore_t *screen_highScores = NULL;
|
||||
|
||||
#ifdef GFXPC
|
||||
U8 *screen_imainhoft = NULL;
|
||||
U8 *screen_imainrdt = NULL;
|
||||
U8 *screen_imaincdc = NULL;
|
||||
U8 *screen_congrats = NULL;
|
||||
#endif
|
||||
U8 *screen_gameovertxt = NULL;
|
||||
U8 *screen_pausedtxt = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Display XRICK splash screen
|
||||
*
|
||||
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
|
||||
*/
|
||||
U8
|
||||
screen_xrick(void)
|
||||
{
|
||||
static U8 seq = 0;
|
||||
static U8 wait = 0;
|
||||
|
||||
if (seq == 0) {
|
||||
sysvid_clear();
|
||||
draw_img(img_splash);
|
||||
game_rects = &draw_SCREENRECT;
|
||||
seq = 1;
|
||||
}
|
||||
|
||||
switch (seq) {
|
||||
case 1: /* wait */
|
||||
if (wait++ > 0x2) {
|
||||
#ifdef ENABLE_SOUND
|
||||
game_setmusic(soundBullet, 1);
|
||||
#endif
|
||||
seq = 2;
|
||||
wait = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* wait */
|
||||
if (wait++ > 0x20) {
|
||||
seq = 99;
|
||||
wait = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (control_test(Control_EXIT)) /* check for exit request */
|
||||
return SCREEN_EXIT;
|
||||
|
||||
if (seq == 99) { /* we're done */
|
||||
sysvid_clear();
|
||||
sysvid_setGamePalette();
|
||||
seq = 0;
|
||||
return SCREEN_DONE;
|
||||
}
|
||||
|
||||
return SCREEN_RUNNING;
|
||||
}
|
||||
|
||||
/* eof */
|
74
apps/plugins/xrick/screens.h
Normal file
74
apps/plugins/xrick/screens.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* xrick/screens.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _SCREENS_H
|
||||
#define _SCREENS_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
#include "xrick/config.h"
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
#define SCREEN_TIMEOUT 4000
|
||||
#define SCREEN_RUNNING 0
|
||||
#define SCREEN_DONE 1
|
||||
#define SCREEN_EXIT 2
|
||||
|
||||
typedef struct {
|
||||
U16 count; /* number of loops */
|
||||
U16 dx, dy; /* sprite x and y deltas */
|
||||
U16 base; /* base for sprite numbers table */
|
||||
} screen_imapsteps_t; /* description of one step */
|
||||
|
||||
enum { HISCORE_NAME_SIZE = 10 };
|
||||
typedef struct {
|
||||
U32 score;
|
||||
U8 name[HISCORE_NAME_SIZE];
|
||||
} hiscore_t;
|
||||
|
||||
extern size_t screen_nbr_imapsl;
|
||||
extern U8 *screen_imapsl; /* sprite lists */
|
||||
|
||||
extern size_t screen_nbr_imapstesps;
|
||||
extern screen_imapsteps_t *screen_imapsteps; /* map intro steps */
|
||||
|
||||
extern size_t screen_nbr_imapsofs;
|
||||
extern U8 *screen_imapsofs; /* first step for each map */
|
||||
|
||||
extern size_t screen_nbr_imaptext;
|
||||
extern U8 **screen_imaptext; /* map intro texts */
|
||||
|
||||
extern size_t screen_nbr_hiscores;
|
||||
extern hiscore_t *screen_highScores; /* highest scores (hall of fame) */
|
||||
|
||||
#ifdef GFXPC
|
||||
extern U8 *screen_imainhoft; /* hall of fame title */
|
||||
extern U8 *screen_imainrdt; /* rick dangerous title */
|
||||
extern U8 *screen_imaincdc; /* core design copyright text */
|
||||
extern U8 *screen_congrats; /* congratulations */
|
||||
#endif /* GFXPC */
|
||||
extern U8 *screen_gameovertxt; /* game over */
|
||||
extern U8 *screen_pausedtxt; /* paused */
|
||||
|
||||
extern U8 screen_xrick(void); /* splash */
|
||||
extern U8 screen_introMain(void); /* main intro */
|
||||
extern U8 screen_introMap(void); /* map intro */
|
||||
extern U8 screen_gameover(void); /* gameover */
|
||||
extern U8 screen_getname(void); /* enter you name */
|
||||
extern void screen_pause(bool); /* pause indicator */
|
||||
|
||||
#endif /* ndef _SCREENS_H */
|
||||
|
||||
/* eof */
|
165
apps/plugins/xrick/scroller.c
Normal file
165
apps/plugins/xrick/scroller.c
Normal file
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* xrick/scroller.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/scroller.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/debug.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/ents.h"
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
static U8 period;
|
||||
|
||||
/*
|
||||
* Scroll up
|
||||
*
|
||||
*/
|
||||
U8
|
||||
scroll_up(void)
|
||||
{
|
||||
U8 i, j;
|
||||
static U8 n = 0;
|
||||
|
||||
/* last call: restore */
|
||||
if (n == 8) {
|
||||
n = 0;
|
||||
game_period = period;
|
||||
return SCROLL_DONE;
|
||||
}
|
||||
|
||||
/* first call: prepare */
|
||||
if (n == 0) {
|
||||
period = game_period;
|
||||
game_period = SCROLL_PERIOD;
|
||||
}
|
||||
|
||||
/* translate map */
|
||||
for (i = MAP_ROW_SCRTOP; i < MAP_ROW_HBBOT; i++)
|
||||
for (j = 0x00; j < 0x20; j++)
|
||||
map_map[i][j] = map_map[i + 1][j];
|
||||
|
||||
/* translate entities */
|
||||
for (i = 0; ent_ents[i].n != 0xFF; i++) {
|
||||
if (ent_ents[i].n) {
|
||||
ent_ents[i].ysave -= 8;
|
||||
ent_ents[i].trig_y -= 8;
|
||||
ent_ents[i].y -= 8;
|
||||
if (ent_ents[i].y & 0x8000) { /* map coord. from 0x0000 to 0x0140 */
|
||||
IFDEBUG_SCROLLER(
|
||||
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
|
||||
);
|
||||
ent_ents[i].n = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* display */
|
||||
draw_map();
|
||||
ent_draw();
|
||||
draw_drawStatus();
|
||||
map_frow++;
|
||||
|
||||
/* loop */
|
||||
if (n++ == 7) {
|
||||
/* activate visible entities */
|
||||
ent_actvis(map_frow + MAP_ROW_HBTOP, map_frow + MAP_ROW_HBBOT);
|
||||
|
||||
/* prepare map */
|
||||
map_expand();
|
||||
|
||||
/* display */
|
||||
draw_map();
|
||||
ent_draw();
|
||||
draw_drawStatus();
|
||||
}
|
||||
|
||||
game_rects = &draw_SCREENRECT;
|
||||
|
||||
return SCROLL_RUNNING;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scroll down
|
||||
*
|
||||
*/
|
||||
U8
|
||||
scroll_down(void)
|
||||
{
|
||||
U8 i, j;
|
||||
static U8 n = 0;
|
||||
|
||||
/* last call: restore */
|
||||
if (n == 8) {
|
||||
n = 0;
|
||||
game_period = period;
|
||||
return SCROLL_DONE;
|
||||
}
|
||||
|
||||
/* first call: prepare */
|
||||
if (n == 0) {
|
||||
period = game_period;
|
||||
game_period = SCROLL_PERIOD;
|
||||
}
|
||||
|
||||
/* translate map */
|
||||
for (i = MAP_ROW_SCRBOT; i > MAP_ROW_HTTOP; i--)
|
||||
for (j = 0x00; j < 0x20; j++)
|
||||
map_map[i][j] = map_map[i - 1][j];
|
||||
|
||||
/* translate entities */
|
||||
for (i = 0; ent_ents[i].n != 0xFF; i++) {
|
||||
if (ent_ents[i].n) {
|
||||
ent_ents[i].ysave += 8;
|
||||
ent_ents[i].trig_y += 8;
|
||||
ent_ents[i].y += 8;
|
||||
if (ent_ents[i].y > 0x0140) { /* map coord. from 0x0000 to 0x0140 */
|
||||
IFDEBUG_SCROLLER(
|
||||
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
|
||||
);
|
||||
ent_ents[i].n = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* display */
|
||||
draw_map();
|
||||
ent_draw();
|
||||
draw_drawStatus();
|
||||
map_frow--;
|
||||
|
||||
/* loop */
|
||||
if (n++ == 7) {
|
||||
/* activate visible entities */
|
||||
ent_actvis(map_frow + MAP_ROW_HTTOP, map_frow + MAP_ROW_HTBOT);
|
||||
|
||||
/* prepare map */
|
||||
map_expand();
|
||||
|
||||
/* display */
|
||||
draw_map();
|
||||
ent_draw();
|
||||
draw_drawStatus();
|
||||
}
|
||||
|
||||
game_rects = &draw_SCREENRECT;
|
||||
|
||||
return SCROLL_RUNNING;
|
||||
}
|
||||
|
||||
/* eof */
|
31
apps/plugins/xrick/scroller.h
Normal file
31
apps/plugins/xrick/scroller.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* xrick/scroller.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _SCROLLER_H
|
||||
#define _SCROLLER_H
|
||||
|
||||
#define SCROLL_RUNNING 1
|
||||
#define SCROLL_DONE 0
|
||||
|
||||
#define SCROLL_PERIOD 24
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
extern U8 scroll_up(void);
|
||||
extern U8 scroll_down(void);
|
||||
|
||||
#endif /* ndef _SCROLLER_H */
|
||||
|
||||
/* eof */
|
33
apps/plugins/xrick/system/basic_funcs.c
Normal file
33
apps/plugins/xrick/system/basic_funcs.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* xrick/system/basic_funcs.c
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/system/basic_funcs.h"
|
||||
|
||||
#ifdef USE_DEFAULT_ENDIANNESS_FUNCTIONS
|
||||
|
||||
extern inline uint16_t swap16(uint16_t x);
|
||||
extern inline uint32_t swap32(uint32_t x);
|
||||
|
||||
extern inline uint16_t htobe16(uint16_t host);
|
||||
extern inline uint16_t htole16(uint16_t host);
|
||||
extern inline uint16_t betoh16(uint16_t big_endian);
|
||||
extern inline uint16_t letoh16(uint16_t little_endian);
|
||||
|
||||
extern inline uint32_t htobe32(uint32_t host);
|
||||
extern inline uint32_t htole32(uint32_t host);
|
||||
extern inline uint32_t betoh32(uint32_t big_endian);
|
||||
extern inline uint32_t letoh32(uint32_t little_endian);
|
||||
|
||||
#endif /* USE_DEFAULT_ENDIANNESS_FUNCTIONS */
|
||||
|
||||
/* eof */
|
141
apps/plugins/xrick/system/basic_funcs.h
Normal file
141
apps/plugins/xrick/system/basic_funcs.h
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* xrick/system/basic_funcs.h
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _BASIC_FUNCS_H
|
||||
#define _BASIC_FUNCS_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
/* Windows is little endian only */
|
||||
# define __ORDER_LITTLE_ENDIAN__ 1234
|
||||
# define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
# define USE_DEFAULT_ENDIANNESS_FUNCTIONS
|
||||
# include <stdlib.h> /* _byteswap_XXX */
|
||||
|
||||
#elif defined(ROCKBOX)
|
||||
/* Rockbox*/
|
||||
# include "plugin.h"
|
||||
# define __ORDER_LITTLE_ENDIAN__ 1234
|
||||
# define __ORDER_BIG_ENDIAN__ 4321
|
||||
# ifdef ROCKBOX_BIG_ENDIAN
|
||||
# define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
|
||||
# else
|
||||
# define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
# endif
|
||||
|
||||
#elif (defined(__FreeBSD__) && __FreeBSD_version >= 470000) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
/* *BSD */
|
||||
# include <sys/endian.h>
|
||||
# define __ORDER_BIG_ENDIAN__ BIG_ENDIAN
|
||||
# define __ORDER_LITTLE_ENDIAN__ LITTLE_ENDIAN
|
||||
# define __BYTE_ORDER__ BYTE_ORDER
|
||||
|
||||
#elif (defined(BSD) && (BSD >= 199103)) || defined(__MacOSX__)
|
||||
/* more BSD */
|
||||
# include <machine/endian.h>
|
||||
# define __ORDER_BIG_ENDIAN__ BIG_ENDIAN
|
||||
# define __ORDER_LITTLE_ENDIAN__ LITTLE_ENDIAN
|
||||
# define __BYTE_ORDER__ BYTE_ORDER
|
||||
|
||||
#elif defined(__linux__) /*|| defined (__BEOS__)*/
|
||||
/* Linux, BeOS */
|
||||
# include <endian.h>
|
||||
# define betoh16(x) be16toh(x)
|
||||
# define letoh16(x) le16toh(x)
|
||||
# define betoh32(x) be32toh(x)
|
||||
# define letoh32(x) le32toh(x)
|
||||
|
||||
#else
|
||||
/* shall we just '#include <endian.h>'? */
|
||||
# define USE_DEFAULT_ENDIANNESS_FUNCTIONS
|
||||
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
/* define default endianness */
|
||||
#ifndef __ORDER_LITTLE_ENDIAN__
|
||||
# define __ORDER_LITTLE_ENDIAN__ 1234
|
||||
#endif
|
||||
|
||||
#ifndef __ORDER_BIG_ENDIAN__
|
||||
# define __ORDER_BIG_ENDIAN__ 4321
|
||||
#endif
|
||||
|
||||
#ifndef __BYTE_ORDER__
|
||||
# warning "Byte order not defined on your system, assuming little endian!"
|
||||
# define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
#endif
|
||||
|
||||
/* provide default endianness functions */
|
||||
#ifdef USE_DEFAULT_ENDIANNESS_FUNCTIONS
|
||||
|
||||
# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
|
||||
inline uint32_t swap32(uint32_t x)
|
||||
{
|
||||
# ifdef _MSC_VER
|
||||
return _byteswap_ulong(x);
|
||||
# elif (GCC_VERSION > 40300) || defined(__clang__)
|
||||
return __builtin_bswap32(x);
|
||||
# else
|
||||
return (x >> 24) |
|
||||
((x >> 8) & 0x0000FF00) |
|
||||
((x << 8) & 0x00FF0000) |
|
||||
(x << 24);
|
||||
# endif /* _MSC_VER */
|
||||
}
|
||||
|
||||
inline uint16_t swap16(uint16_t x)
|
||||
{
|
||||
# ifdef _MSC_VER
|
||||
return _byteswap_ushort(x);
|
||||
# elif (GCC_VERSION > 40800) || defined(__clang__)
|
||||
return __builtin_bswap16(x);
|
||||
# else
|
||||
return (x << 8)|(x >> 8);
|
||||
# endif /* _MSC_VER */
|
||||
}
|
||||
|
||||
# if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__)
|
||||
inline uint16_t htobe16(uint16_t host) { return swap16(host); }
|
||||
inline uint16_t htole16(uint16_t host) { return host; }
|
||||
inline uint16_t betoh16(uint16_t big_endian) { return swap16(big_endian); }
|
||||
inline uint16_t letoh16(uint16_t little_endian) { return little_endian; }
|
||||
|
||||
inline uint32_t htobe32(uint32_t host) { return swap32(host); }
|
||||
inline uint32_t htole32(uint32_t host) { return host; }
|
||||
inline uint32_t betoh32(uint32_t big_endian) { return swap32(big_endian); }
|
||||
inline uint32_t letoh32(uint32_t little_endian) { return little_endian; }
|
||||
|
||||
# elif (__BYTE_ORDER__==__ORDER_BIG_ENDIAN__)
|
||||
inline uint16_t htobe16(uint16_t host) { return host; }
|
||||
inline uint16_t htole16(uint16_t host) { return swap16(host); }
|
||||
inline uint16_t betoh16(uint16_t big_endian) { return big_endian; }
|
||||
inline uint16_t letoh16(uint16_t little_endian) { return swap16(little_endian); }
|
||||
|
||||
inline uint32_t htobe32(uint32_t host) { return host; }
|
||||
inline uint32_t htole32(uint32_t host) { return swap32(host); }
|
||||
inline uint32_t betoh32(uint32_t big_endian) { return big_endian; }
|
||||
inline uint32_t letoh32(uint32_t little_endian) { return swap32(little_endian); }
|
||||
|
||||
# else
|
||||
# error "Unknown/unsupported byte order!"
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* USE_DEFAULT_ENDIANNESS_FUNCTIONS */
|
||||
|
||||
#endif /* ndef _BASIC_FUNCS_H */
|
||||
|
||||
/* eof */
|
48
apps/plugins/xrick/system/basic_types.h
Normal file
48
apps/plugins/xrick/system/basic_types.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* xrick/system/basic_types.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _BASIC_TYPES_H
|
||||
#define _BASIC_TYPES_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
typedef enum { false, true } bool;
|
||||
|
||||
#define inline __inline
|
||||
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
|
||||
#else /* ndef _MSC_VER */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
typedef uint8_t U8; /* 8 bits unsigned */
|
||||
typedef uint16_t U16; /* 16 bits unsigned */
|
||||
typedef uint32_t U32; /* 32 bits unsigned */
|
||||
typedef int8_t S8; /* 8 bits signed */
|
||||
typedef int16_t S16; /* 16 bits signed */
|
||||
typedef int32_t S32; /* 32 bits signed */
|
||||
|
||||
#endif /* ndef _BASIC_TYPES_H */
|
||||
|
||||
/* eof */
|
43
apps/plugins/xrick/system/main_rockbox.c
Normal file
43
apps/plugins/xrick/system/main_rockbox.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
#include "xrick/game.h"
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
/* Plug-in entry point */
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
{
|
||||
char *filename = (char*)parameter;
|
||||
bool success = sys_init(1, &filename);
|
||||
if (success)
|
||||
{
|
||||
game_run();
|
||||
}
|
||||
sys_shutdown();
|
||||
return (success? PLUGIN_OK : PLUGIN_ERROR);
|
||||
}
|
||||
|
||||
/* eof */
|
38
apps/plugins/xrick/system/miniz_config.h
Normal file
38
apps/plugins/xrick/system/miniz_config.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* xrick/system/miniz_config.h
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza. All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _MINIZ_CONFIG_H
|
||||
#define _MINIZ_CONFIG_H
|
||||
|
||||
/*
|
||||
* miniz used only for crc32 calculation
|
||||
*/
|
||||
#define MINIZ_NO_STDIO
|
||||
#define MINIZ_NO_TIME
|
||||
#define MINIZ_NO_ARCHIVE_APIS
|
||||
#define MINIZ_NO_ARCHIVE_WRITING_APIS
|
||||
#define MINIZ_NO_ZLIB_APIS
|
||||
#define MINIZ_NO_MALLOC
|
||||
#ifdef ROCKBOX
|
||||
# define MINIZ_NO_ASSERT
|
||||
# ifndef SIMULATOR
|
||||
# define MINIZ_X86_OR_X64_CPU 0
|
||||
# define MINIZ_HAS_64BIT_REGISTERS 0
|
||||
# define TINFL_USE_64BIT_BITBUF 0
|
||||
# define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
|
||||
# endif /* ndef SIMULATOR */
|
||||
#endif
|
||||
|
||||
#endif /* ndef _MINIZ_CONFIG_H */
|
||||
|
||||
/* eof */
|
110
apps/plugins/xrick/system/rockboxcodes.h
Normal file
110
apps/plugins/xrick/system/rockboxcodes.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _ROCKBOXCODES_H
|
||||
#define _ROCKBOXCODES_H
|
||||
|
||||
/* keypad mappings */
|
||||
#include "plugin.h"
|
||||
|
||||
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
||||
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
||||
#define XRICK_BTN_UP BUTTON_UP | BUTTON_REC
|
||||
#define XRICK_BTN_DOWN BUTTON_DOWN | BUTTON_MODE
|
||||
#define XRICK_BTN_LEFT BUTTON_LEFT
|
||||
#define XRICK_BTN_RIGHT BUTTON_RIGHT
|
||||
#define XRICK_BTN_FIRE BUTTON_ON
|
||||
#define XRICK_BTN_PAUSE BUTTON_SELECT
|
||||
#define XRICK_BTN_MENU BUTTON_OFF
|
||||
|
||||
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
|
||||
#define XRICK_BTN_MENU BUTTON_POWER
|
||||
#define XRICK_BTN_FIRE BUTTON_PLAY
|
||||
#define XRICK_BTN_PAUSE BUTTON_REW
|
||||
#define XRICK_BTN_UP BUTTON_SCROLL_UP
|
||||
#define XRICK_BTN_DOWN BUTTON_SCROLL_DOWN
|
||||
#define XRICK_BTN_LEFT BUTTON_LEFT
|
||||
#define XRICK_BTN_RIGHT BUTTON_RIGHT
|
||||
|
||||
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
||||
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
||||
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
||||
#define XRICK_BTN_UP BUTTON_MENU
|
||||
#define XRICK_BTN_DOWN BUTTON_PLAY
|
||||
#define XRICK_BTN_LEFT BUTTON_LEFT
|
||||
#define XRICK_BTN_RIGHT BUTTON_RIGHT
|
||||
#define XRICK_BTN_FIRE BUTTON_SELECT
|
||||
#define XRICK_BTN_PAUSE BUTTON_SCROLL_BACK
|
||||
#define XRICK_BTN_MENU BUTTON_SCROLL_FWD
|
||||
|
||||
#elif (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD)
|
||||
#define XRICK_BTN_UP BUTTON_UP
|
||||
#define XRICK_BTN_UPLEFT BUTTON_BACK
|
||||
#define XRICK_BTN_UPRIGHT BUTTON_PLAYPAUSE
|
||||
#define XRICK_BTN_DOWN BUTTON_DOWN
|
||||
#define XRICK_BTN_DOWNLEFT BUTTON_BOTTOMLEFT
|
||||
#define XRICK_BTN_DOWNRIGHT BUTTON_BOTTOMRIGHT
|
||||
#define XRICK_BTN_LEFT BUTTON_LEFT
|
||||
#define XRICK_BTN_RIGHT BUTTON_RIGHT
|
||||
#define XRICK_BTN_FIRE BUTTON_VOL_DOWN
|
||||
#define XRICK_BTN_PAUSE BUTTON_VOL_UP
|
||||
#define XRICK_BTN_MENU BUTTON_POWER
|
||||
|
||||
#elif (CONFIG_KEYPAD == SAMSUNG_YH92X_PAD)
|
||||
#define XRICK_BTN_UP BUTTON_UP
|
||||
#define XRICK_BTN_DOWN BUTTON_DOWN
|
||||
#define XRICK_BTN_LEFT BUTTON_LEFT
|
||||
#define XRICK_BTN_RIGHT BUTTON_RIGHT
|
||||
#define XRICK_BTN_FIRE BUTTON_PLAY
|
||||
#define XRICK_BTN_PAUSE BUTTON_FFWD
|
||||
#define XRICK_BTN_MENU BUTTON_REW
|
||||
|
||||
#elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD)
|
||||
#define XRICK_BTN_UP BUTTON_UP
|
||||
#define XRICK_BTN_DOWN BUTTON_DOWN
|
||||
#define XRICK_BTN_LEFT BUTTON_LEFT
|
||||
#define XRICK_BTN_RIGHT BUTTON_RIGHT
|
||||
#define XRICK_BTN_FIRE BUTTON_PLAY
|
||||
#define XRICK_BTN_PAUSE BUTTON_FFWD
|
||||
#define XRICK_BTN_MENU BUTTON_REW
|
||||
|
||||
/* place other keypad mappings here
|
||||
#elif CONFIG_KEYPAD ==...
|
||||
#define XRICK_BTN...
|
||||
*/
|
||||
|
||||
#else
|
||||
# include "lib/pluginlib_actions.h"
|
||||
#define XRICK_BTN_UP PLA_UP
|
||||
#define XRICK_BTN_DOWN PLA_DOWN
|
||||
#define XRICK_BTN_LEFT PLA_LEFT
|
||||
#define XRICK_BTN_RIGHT PLA_RIGHT
|
||||
#define XRICK_BTN_FIRE PLA_SELECT
|
||||
#define XRICK_BTN_PAUSE PLA_CANCEL
|
||||
#define XRICK_BTN_MENU PLA_EXIT
|
||||
#endif
|
||||
|
||||
#endif /* ndef _ROCKBOXCODES_H */
|
||||
|
||||
/* eof */
|
49
apps/plugins/xrick/system/sysarg_rockbox.c
Normal file
49
apps/plugins/xrick/system/sysarg_rockbox.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
/*
|
||||
* globals
|
||||
*/
|
||||
int sysarg_args_period = 0; /* time between each frame, in milliseconds. The default is 40. */
|
||||
int sysarg_args_map = 0;
|
||||
int sysarg_args_submap = 0;
|
||||
bool sysarg_args_nosound = false;
|
||||
const char *sysarg_args_data = NULL;
|
||||
|
||||
/*
|
||||
* Read and process arguments
|
||||
*/
|
||||
bool sysarg_init(int argc/*unused*/, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
|
||||
/* note: "*argv" is truly a "const *" */
|
||||
sysarg_args_data = *argv;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* eof */
|
156
apps/plugins/xrick/system/sysevt_rockbox.c
Normal file
156
apps/plugins/xrick/system/sysevt_rockbox.c
Normal file
|
@ -0,0 +1,156 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/system/sysmenu_rockbox.h"
|
||||
#include "xrick/system/rockboxcodes.h"
|
||||
|
||||
/*
|
||||
* Helper function to set/clear controls according to key press
|
||||
*/
|
||||
static inline void checkKey(int key, unsigned button, control_t control)
|
||||
{
|
||||
if (key & button)
|
||||
{
|
||||
control_set(control);
|
||||
}
|
||||
else
|
||||
{
|
||||
control_clear(control);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process events, if any, then return
|
||||
*/
|
||||
void sysevt_poll(void)
|
||||
{
|
||||
static int previousKey, currentKey;
|
||||
|
||||
/* this is because "Restart Game" is handled via menu */
|
||||
if (control_test(Control_END))
|
||||
{
|
||||
control_clear(Control_END);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* check for USB connection */
|
||||
if ((rb->default_event_handler(rb->button_get(false)) == SYS_USB_CONNECTED)
|
||||
#if defined(HAS_BUTTON_HOLD)
|
||||
|| rb->button_hold()
|
||||
#endif
|
||||
)
|
||||
{
|
||||
sysmenu_exec();
|
||||
}
|
||||
|
||||
currentKey = rb->button_status();
|
||||
if (currentKey != previousKey)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (game_waitevt)
|
||||
{
|
||||
rb->yield();
|
||||
}
|
||||
else /* (currentKey == previousKey) && !game_waitevt */
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef XRICK_BTN_MENU
|
||||
if (currentKey & XRICK_BTN_MENU)
|
||||
{
|
||||
sysmenu_exec();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XRICK_BTN_PAUSE
|
||||
checkKey(currentKey, XRICK_BTN_PAUSE, Control_PAUSE);
|
||||
#endif
|
||||
|
||||
checkKey(currentKey, XRICK_BTN_UP, Control_UP);
|
||||
|
||||
checkKey(currentKey, XRICK_BTN_DOWN, Control_DOWN);
|
||||
|
||||
checkKey(currentKey, XRICK_BTN_LEFT, Control_LEFT);
|
||||
|
||||
checkKey(currentKey, XRICK_BTN_RIGHT, Control_RIGHT);
|
||||
|
||||
checkKey(currentKey, XRICK_BTN_FIRE, Control_FIRE);
|
||||
|
||||
#ifdef XRICK_BTN_UPLEFT
|
||||
if (!control_test(Control_UP | Control_LEFT))
|
||||
{
|
||||
checkKey(currentKey, XRICK_BTN_UPLEFT, Control_UP | Control_LEFT);
|
||||
}
|
||||
#endif /* XRICK_BTN_UPLEFT */
|
||||
|
||||
#ifdef XRICK_BTN_UPRIGHT
|
||||
if (!control_test(Control_UP | Control_RIGHT))
|
||||
{
|
||||
checkKey(currentKey, XRICK_BTN_UPRIGHT, Control_UP | Control_RIGHT);
|
||||
}
|
||||
#endif /* XRICK_BTN_UPRIGHT */
|
||||
|
||||
#ifdef XRICK_BTN_DOWNLEFT
|
||||
if (!control_test(Control_DOWN | Control_LEFT))
|
||||
{
|
||||
checkKey(currentKey, XRICK_BTN_DOWNLEFT, Control_DOWN | Control_LEFT);
|
||||
}
|
||||
#endif /* XRICK_BTN_DOWNLEFT */
|
||||
|
||||
#ifdef XRICK_BTN_DOWNRIGHT
|
||||
if (!control_test(Control_DOWN | Control_RIGHT))
|
||||
{
|
||||
checkKey(currentKey, XRICK_BTN_DOWNRIGHT, Control_DOWN | Control_RIGHT);
|
||||
}
|
||||
#endif /* XRICK_BTN_DOWNRIGHT */
|
||||
|
||||
previousKey = currentKey;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for an event, then process it and return
|
||||
*/
|
||||
void sysevt_wait(void)
|
||||
{
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(false);
|
||||
#endif
|
||||
|
||||
sysevt_poll(); /* sysevt_poll deals with blocking case as well */
|
||||
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* eof */
|
122
apps/plugins/xrick/system/sysfile_rockbox.c
Normal file
122
apps/plugins/xrick/system/sysfile_rockbox.c
Normal file
|
@ -0,0 +1,122 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/util.h"
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
#define XRICK_GAME_DIR ROCKBOX_DIR "/xrick/"
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
const char *sysfile_defaultPath = XRICK_GAME_DIR;
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
static char *rootPath = NULL;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
bool sysfile_setRootPath(const char *name)
|
||||
{
|
||||
rootPath = u_strdup(name);
|
||||
return (rootPath != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void sysfile_clearRootPath()
|
||||
{
|
||||
sysmem_pop(rootPath);
|
||||
rootPath = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open a data file.
|
||||
*/
|
||||
file_t sysfile_open(const char *name)
|
||||
{
|
||||
int fd;
|
||||
|
||||
size_t fullPathLength = rb->strlen(rootPath) + rb->strlen(name) + 2;
|
||||
char *fullPath = sysmem_push(fullPathLength);
|
||||
if (!fullPath)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
rb->snprintf(fullPath, fullPathLength, "%s/%s", rootPath, name);
|
||||
fd = rb->open(fullPath, O_RDONLY);
|
||||
sysmem_pop(fullPath);
|
||||
|
||||
/*
|
||||
* note: I've never seen zero/NULL being used as a file descriptor under Rockbox.
|
||||
* Putting a check here in case this will ever happen (will need a fix).
|
||||
*/
|
||||
if (fd == 0)
|
||||
{
|
||||
sys_error("(file) unsupported file descriptor (zero/NULL) being used");
|
||||
}
|
||||
if (fd < 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (file_t)fd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a file within a data archive.
|
||||
*/
|
||||
int sysfile_read(file_t file, void *buf, size_t size, size_t count)
|
||||
{
|
||||
int fd = (int)file;
|
||||
return (rb->read(fd, buf, size * count) / size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Seek.
|
||||
*/
|
||||
int sysfile_seek(file_t file, long offset, int origin)
|
||||
{
|
||||
int fd = (int)file;
|
||||
return rb->lseek(fd, offset, origin);
|
||||
}
|
||||
|
||||
/*
|
||||
* Close a file within a data archive.
|
||||
*/
|
||||
void sysfile_close(file_t file)
|
||||
{
|
||||
int fd = (int)file;
|
||||
rb->close(fd);
|
||||
}
|
||||
|
||||
/* eof */
|
156
apps/plugins/xrick/system/sysmem_rockbox.c
Normal file
156
apps/plugins/xrick/system/sysmem_rockbox.c
Normal file
|
@ -0,0 +1,156 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include "xrick/debug.h"
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ALIGNMENT = sizeof(void*) /* this is more of an educated guess; might want to adjust for your specific architecture */
|
||||
};
|
||||
static U8 * stackBuffer;
|
||||
static U8 * stackTop;
|
||||
static size_t stackSize;
|
||||
static size_t stackMaxSize;
|
||||
static bool isMemoryInitialised = false;
|
||||
IFDEBUG_MEMORY( static size_t maxUsedMemory = 0; );
|
||||
|
||||
/*
|
||||
* Initialise memory stack
|
||||
*/
|
||||
bool sysmem_init(void)
|
||||
{
|
||||
if (isMemoryInitialised)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rb->audio_status())
|
||||
{
|
||||
/* Playback must be stopped the entire time the sound buffer is used.*/
|
||||
rb->audio_stop();
|
||||
}
|
||||
|
||||
stackBuffer = rb->plugin_get_audio_buffer(&stackMaxSize);
|
||||
stackTop = stackBuffer;
|
||||
stackSize = 0;
|
||||
isMemoryInitialised = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup memory stack
|
||||
*/
|
||||
void sysmem_shutdown(void)
|
||||
{
|
||||
if (!isMemoryInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stackTop != stackBuffer || stackSize != 0)
|
||||
{
|
||||
sys_error("(memory) improper deallocation detected");
|
||||
}
|
||||
|
||||
IFDEBUG_MEMORY(
|
||||
sys_printf("xrick/memory: max memory usage was %u bytes\n", maxUsedMemory);
|
||||
);
|
||||
|
||||
isMemoryInitialised = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a memory-aligned block on top of the memory stack
|
||||
*/
|
||||
void *sysmem_push(size_t size)
|
||||
{
|
||||
uintptr_t alignedPtr;
|
||||
size_t * allocatedSizePtr;
|
||||
|
||||
size_t neededSize = sizeof(size_t) + size + (ALIGNMENT - 1);
|
||||
if (stackSize + neededSize > stackMaxSize)
|
||||
{
|
||||
sys_error("(memory) tried to allocate a block when memory full");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
alignedPtr = (((uintptr_t)stackTop) + sizeof(size_t) + ALIGNMENT) & ~((uintptr_t)(ALIGNMENT - 1));
|
||||
|
||||
allocatedSizePtr = (size_t *)(alignedPtr);
|
||||
allocatedSizePtr[-1] = neededSize;
|
||||
|
||||
stackTop += neededSize;
|
||||
stackSize += neededSize;
|
||||
|
||||
IFDEBUG_MEMORY(
|
||||
sys_printf("xrick/memory: allocated %u bytes\n", neededSize);
|
||||
if (stackSize > maxUsedMemory) maxUsedMemory = stackSize;
|
||||
);
|
||||
|
||||
return (void *)alignedPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release block from the top of the memory stack
|
||||
*/
|
||||
void sysmem_pop(void * alignedPtr)
|
||||
{
|
||||
size_t allocatedSize;
|
||||
|
||||
if (!alignedPtr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stackSize == 0)
|
||||
{
|
||||
sys_error("(memory) tried to release a block when memory empty");
|
||||
return;
|
||||
}
|
||||
|
||||
allocatedSize = ((size_t *)(alignedPtr))[-1];
|
||||
stackTop -= allocatedSize;
|
||||
stackSize -= allocatedSize;
|
||||
|
||||
IFDEBUG_MEMORY(
|
||||
if ((uintptr_t)alignedPtr != ((((uintptr_t)stackTop) + sizeof(size_t) + ALIGNMENT) & ~((uintptr_t)(ALIGNMENT - 1))))
|
||||
{
|
||||
sys_error("(memory) tried to release a wrong block");
|
||||
return;
|
||||
}
|
||||
);
|
||||
|
||||
IFDEBUG_MEMORY(
|
||||
sys_printf("xrick/memory: released %u bytes\n", allocatedSize);
|
||||
);
|
||||
}
|
||||
|
||||
/* eof */
|
200
apps/plugins/xrick/system/sysmenu_rockbox.c
Normal file
200
apps/plugins/xrick/system/sysmenu_rockbox.c
Normal file
|
@ -0,0 +1,200 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/sysmenu_rockbox.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/control.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/system/system.h"
|
||||
#include "xrick/system/syssnd_rockbox.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
#include "lib/grey.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
static fb_data *lcd_fb=NULL;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_CHEATS
|
||||
/*
|
||||
* Cheat settings menu
|
||||
*/
|
||||
static char * sysmenu_cheatItemText(int selected_item, void *data, char *buffer, size_t buffer_len)
|
||||
{
|
||||
(void)selected_item;
|
||||
cheat_t cheat = (cheat_t)data;
|
||||
(void)buffer;
|
||||
(void)buffer_len;
|
||||
char * messages[] =
|
||||
{
|
||||
"Disable Unlimited Lives/Ammo Mode",
|
||||
"Enable Unlimited Lives/Ammo Mode",
|
||||
"Disable Never Die Mode",
|
||||
"Enable Never Die Mode",
|
||||
"Disable Expose Mode",
|
||||
"Enable Expose Mode"
|
||||
};
|
||||
|
||||
switch (cheat)
|
||||
{
|
||||
case Cheat_UNLIMITED_ALL:
|
||||
{
|
||||
return game_cheat1? messages[0] : messages[1];
|
||||
}
|
||||
case Cheat_NEVER_DIE:
|
||||
{
|
||||
return game_cheat2? messages[2] : messages[3];
|
||||
}
|
||||
case Cheat_EXPOSE:
|
||||
{
|
||||
return game_cheat3? messages[4] : messages[5];
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback invoked by cheat menu item
|
||||
*/
|
||||
static int sysmenu_doToggleCheat(void *param)
|
||||
{
|
||||
cheat_t cheat = (cheat_t)param;
|
||||
game_toggleCheat(cheat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MENUITEM_FUNCTION_DYNTEXT(sysmenu_unlimitedAllItem, MENU_FUNC_USEPARAM, sysmenu_doToggleCheat,
|
||||
sysmenu_cheatItemText, NULL, (void *)Cheat_UNLIMITED_ALL,
|
||||
NULL, Icon_NOICON);
|
||||
|
||||
MENUITEM_FUNCTION_DYNTEXT(sysmenu_neverDieItem, MENU_FUNC_USEPARAM, sysmenu_doToggleCheat,
|
||||
sysmenu_cheatItemText, NULL, (void *)Cheat_NEVER_DIE,
|
||||
NULL, Icon_NOICON);
|
||||
|
||||
MENUITEM_FUNCTION_DYNTEXT(sysmenu_exposeItem, MENU_FUNC_USEPARAM, sysmenu_doToggleCheat,
|
||||
sysmenu_cheatItemText, NULL, (void *)Cheat_EXPOSE,
|
||||
NULL, Icon_NOICON);
|
||||
|
||||
MAKE_MENU(sysmenu_cheatItems, "Cheat Settings", NULL, Icon_NOICON,
|
||||
&sysmenu_unlimitedAllItem, &sysmenu_neverDieItem, &sysmenu_exposeItem);
|
||||
|
||||
#endif /* ENABLE_CHEATS */
|
||||
|
||||
/*
|
||||
* Display main menu
|
||||
*/
|
||||
void sysmenu_exec(void)
|
||||
{
|
||||
int result;
|
||||
bool done;
|
||||
|
||||
enum
|
||||
{
|
||||
Menu_RESUME,
|
||||
Menu_RESTART,
|
||||
#ifdef ENABLE_CHEATS
|
||||
Menu_CHEAT_SETTINGS,
|
||||
#endif
|
||||
Menu_QUIT
|
||||
};
|
||||
|
||||
MENUITEM_STRINGLIST(sysmenu_mainItems, "xrick Menu", NULL,
|
||||
"Resume Game",
|
||||
"Restart Game",
|
||||
#ifdef ENABLE_CHEATS
|
||||
"Cheat Settings",
|
||||
#endif
|
||||
ID2P(LANG_MENU_QUIT));
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_pauseAll(true);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
grey_show(false);
|
||||
#endif
|
||||
|
||||
done = false;
|
||||
do
|
||||
{
|
||||
rb->button_clear_queue();
|
||||
|
||||
result = rb->do_menu(&sysmenu_mainItems, NULL, NULL, false);
|
||||
switch(result)
|
||||
{
|
||||
case Menu_RESUME:
|
||||
{
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
case Menu_RESTART:
|
||||
{
|
||||
control_set(Control_END);
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_CHEATS
|
||||
case Menu_CHEAT_SETTINGS:
|
||||
{
|
||||
rb->do_menu(&sysmenu_cheatItems, NULL, NULL, false);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case Menu_QUIT:
|
||||
{
|
||||
control_set(Control_EXIT);
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
if (!(control_test(Control_EXIT)))
|
||||
{
|
||||
if(!lcd_fb)
|
||||
{
|
||||
struct viewport *vp_main = rb->lcd_set_viewport(NULL);
|
||||
lcd_fb = vp_main->buffer->fb_ptr;
|
||||
}
|
||||
rb->memset(lcd_fb, 0, sizeof(fb_data) * LCD_WIDTH * LCD_HEIGHT);
|
||||
sysvid_update(&draw_SCREENRECT);
|
||||
rb->lcd_update();
|
||||
}
|
||||
#else
|
||||
grey_show(true);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_pauseAll(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* eof */
|
32
apps/plugins/xrick/system/sysmenu_rockbox.h
Normal file
32
apps/plugins/xrick/system/sysmenu_rockbox.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _SYSMENU_ROCKBOX_H
|
||||
#define _SYSMENU_ROCKBOX_H
|
||||
|
||||
extern void sysmenu_exec(void);
|
||||
|
||||
#endif /* ndef _SYSMENU_ROCKBOX_H */
|
||||
|
||||
/* eof */
|
483
apps/plugins/xrick/system/syssnd_rockbox.c
Normal file
483
apps/plugins/xrick/system/syssnd_rockbox.c
Normal file
|
@ -0,0 +1,483 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/debug.h"
|
||||
#include "xrick/system/syssnd_rockbox.h"
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
const U8 syssnd_period = 20;
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
enum
|
||||
{
|
||||
SYSSND_MIX_CHANNELS = 5,
|
||||
SYSSND_MIX_SAMPLES = 1024, /* try changing this value if sound mixing is too slow or choppy */
|
||||
SYSSND_SOURCE_SAMPLES = SYSSND_MIX_SAMPLES / 2
|
||||
};
|
||||
|
||||
/* channels to be mixed */
|
||||
static channel_t channels[SYSSND_MIX_CHANNELS];
|
||||
/* buffer used to mix sounds sent to pcm playback, stores 16b stereo 44Khz audio samples */
|
||||
enum { AUDIO_BUFFER_COUNT = 4 };
|
||||
typedef struct
|
||||
{
|
||||
U32 data[SYSSND_MIX_SAMPLES];
|
||||
size_t length; /* in 8 bit mono samples */
|
||||
} mix_buffer_t;
|
||||
static mix_buffer_t mixBuffers[AUDIO_BUFFER_COUNT];
|
||||
static size_t writeIndex;
|
||||
static size_t readIndex;
|
||||
static size_t fillCount;
|
||||
static bool isAudioPlaying;
|
||||
static bool isAudioInitialised = false;
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
static void endChannel(size_t c);
|
||||
static void get_more(const void **start, size_t *size);
|
||||
|
||||
/*
|
||||
* Deactivate channel
|
||||
*/
|
||||
static void endChannel(size_t c)
|
||||
{
|
||||
channels[c].loop = 0;
|
||||
channels[c].sound = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Audio callback
|
||||
*/
|
||||
static void get_more(const void **start, size_t *size)
|
||||
{
|
||||
if (fillCount > 0)
|
||||
{
|
||||
/* Store output data address and size. */
|
||||
*start = mixBuffers[readIndex].data;
|
||||
*size = mixBuffers[readIndex].length * 8;
|
||||
|
||||
/* Free this part of output buffer. */
|
||||
mixBuffers[readIndex].length = 0;
|
||||
|
||||
/* Advance to the next part of output buffer. */
|
||||
readIndex = (readIndex + 1) & (AUDIO_BUFFER_COUNT - 1);
|
||||
fillCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Nothing to play. */
|
||||
isAudioPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Mix audio samples and fill playback buffer
|
||||
*/
|
||||
void syssnd_update(void)
|
||||
{
|
||||
if (!isAudioInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
size_t c;
|
||||
size_t sampleOffset;
|
||||
size_t maxSampleCount;
|
||||
bool isFirstSound;
|
||||
U8 *sourceBuf, *sourceBufEnd;
|
||||
U32 *destBuf;
|
||||
|
||||
/* Cancel if whole buffer filled. */
|
||||
if (fillCount >= (AUDIO_BUFFER_COUNT - 1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
maxSampleCount = 0;
|
||||
|
||||
sampleOffset = mixBuffers[writeIndex].length;
|
||||
destBuf = mixBuffers[writeIndex].data + sampleOffset * 2;
|
||||
|
||||
isFirstSound = true;
|
||||
for (c = 0; c < SYSSND_MIX_CHANNELS ; ++c)
|
||||
{
|
||||
U32 * mixBuffer;
|
||||
size_t sampleCount;
|
||||
channel_t * channel = &channels[c];
|
||||
|
||||
if (!channel->sound /* no sound to play on this channel */
|
||||
|| (channel->loop == 0)) /* channel is inactive */
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isFirstSound)
|
||||
{
|
||||
/* clear mixing buffer */
|
||||
rb->memset(destBuf, 0, (SYSSND_MIX_SAMPLES - (sampleOffset * 2)) * sizeof(U32));
|
||||
isFirstSound = false;
|
||||
}
|
||||
|
||||
sampleCount = MIN(SYSSND_SOURCE_SAMPLES - sampleOffset, channel->len);
|
||||
if (maxSampleCount < sampleCount)
|
||||
{
|
||||
maxSampleCount = sampleCount;
|
||||
}
|
||||
|
||||
/* mix sound samples */
|
||||
mixBuffer = destBuf;
|
||||
sourceBuf = channel->buf;
|
||||
sourceBufEnd = channel->buf + sampleCount;
|
||||
while (sourceBuf < sourceBufEnd)
|
||||
{
|
||||
/* Convert from unsigned 8 bit mono 22khz to signed 16 bit stereo 44khz */
|
||||
const int sourceSample = *sourceBuf++;
|
||||
int monoSample = (sourceSample - 0x80) << 8;
|
||||
U32 stereoSample = *mixBuffer;
|
||||
monoSample += (S32)(stereoSample) >> 16;
|
||||
if (monoSample >= 0x8000)
|
||||
{
|
||||
monoSample = 0x7FFF;
|
||||
}
|
||||
else if (monoSample < -0x8000)
|
||||
{
|
||||
monoSample = -0x8000;
|
||||
}
|
||||
stereoSample = (U16)monoSample | ((U16)monoSample << 16);
|
||||
*mixBuffer++ = stereoSample;
|
||||
*mixBuffer++ = stereoSample;
|
||||
}
|
||||
channel->buf = sourceBufEnd;
|
||||
|
||||
channel->len -= sampleCount;
|
||||
if (channel->len == 0) /* ending ? */
|
||||
{
|
||||
if (channel->loop > 0)
|
||||
{
|
||||
channel->loop--;
|
||||
}
|
||||
if (channel->loop)
|
||||
{
|
||||
/* just loop */
|
||||
IFDEBUG_AUDIO2(sys_printf("xrick/audio: channel %d - loop\n", c););
|
||||
channel->buf = channel->sound->buf;
|
||||
channel->len = channel->sound->len;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* end for real */
|
||||
IFDEBUG_AUDIO2(sys_printf("xrick/audio: channel %d - end\n", c););
|
||||
endChannel(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (maxSampleCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mixBuffers[writeIndex].length += maxSampleCount;
|
||||
|
||||
/* Advance one part of audio buffer. */
|
||||
writeIndex = (writeIndex + 1) & (AUDIO_BUFFER_COUNT - 1);
|
||||
fillCount++;
|
||||
|
||||
if (!isAudioPlaying && fillCount > 0)
|
||||
{
|
||||
rb->pcm_play_data(&get_more, NULL, NULL, 0);
|
||||
isAudioPlaying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise audio
|
||||
*/
|
||||
bool syssnd_init(void)
|
||||
{
|
||||
if (isAudioInitialised)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IFDEBUG_AUDIO(sys_printf("xrick/audio: start\n"););
|
||||
|
||||
rb->talk_disable(true);
|
||||
|
||||
/* Stop playback to reconfigure audio settings and acquire audio buffer */
|
||||
rb->mixer_channel_stop(PCM_MIXER_CHAN_PLAYBACK);
|
||||
|
||||
#if INPUT_SRC_CAPS != 0
|
||||
/* Select playback */
|
||||
rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
||||
rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
|
||||
#endif
|
||||
|
||||
rb->pcm_set_frequency(HW_FREQ_44);
|
||||
rb->pcm_apply_settings();
|
||||
|
||||
rb->memset(channels, 0, sizeof(channels));
|
||||
rb->memset(mixBuffers, 0, sizeof(mixBuffers));
|
||||
|
||||
writeIndex = 0;
|
||||
readIndex = 0;
|
||||
fillCount = 0;
|
||||
isAudioPlaying = false;
|
||||
|
||||
isAudioInitialised = true;
|
||||
IFDEBUG_AUDIO(sys_printf("xrick/audio: ready\n"););
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown
|
||||
*/
|
||||
void syssnd_shutdown(void)
|
||||
{
|
||||
if (!isAudioInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Stop playback. */
|
||||
rb->pcm_play_stop();
|
||||
|
||||
/* Reset playing status. */
|
||||
isAudioPlaying = false;
|
||||
|
||||
/* Restore default sampling rate. */
|
||||
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
|
||||
rb->pcm_apply_settings();
|
||||
|
||||
rb->talk_disable(false);
|
||||
|
||||
isAudioInitialised = false;
|
||||
IFDEBUG_AUDIO(sys_printf("xrick/audio: stop\n"););
|
||||
}
|
||||
|
||||
/*
|
||||
* Play a sound
|
||||
*
|
||||
* loop: number of times the sound should be played, -1 to loop forever
|
||||
*
|
||||
* NOTE if sound is already playing, simply reset it (i.e. can not have
|
||||
* twice the same sound playing -- tends to become noisy when too many
|
||||
* bad guys die at the same time).
|
||||
*/
|
||||
void syssnd_play(sound_t *sound, S8 loop)
|
||||
{
|
||||
size_t c;
|
||||
|
||||
if (!isAudioInitialised || !sound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
c = 0;
|
||||
while (channels[c].sound != sound &&
|
||||
channels[c].loop != 0 &&
|
||||
c < SYSSND_MIX_CHANNELS)
|
||||
{
|
||||
c++;
|
||||
}
|
||||
if (c >= SYSSND_MIX_CHANNELS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sound->buf)
|
||||
{
|
||||
syssnd_load(sound);
|
||||
if (!sound->buf)
|
||||
{
|
||||
sys_error("(audio) can not load %s", sound->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IFDEBUG_AUDIO(
|
||||
if (channels[c].sound == sound)
|
||||
{
|
||||
sys_printf("xrick/audio: already playing %s on channel %d - resetting\n",
|
||||
sound->name, c);
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_printf("xrick/audio: playing %s on channel %d\n", sound->name, c);
|
||||
}
|
||||
);
|
||||
|
||||
channels[c].loop = loop;
|
||||
channels[c].sound = sound;
|
||||
channels[c].buf = sound->buf;
|
||||
channels[c].len = sound->len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pause all sounds
|
||||
*/
|
||||
void syssnd_pauseAll(bool pause)
|
||||
{
|
||||
if (!isAudioInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rb->pcm_play_lock();
|
||||
rb->mixer_channel_play_pause(PCM_MIXER_CHAN_PLAYBACK, !pause);
|
||||
rb->pcm_play_unlock();
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop a sound
|
||||
*/
|
||||
void syssnd_stop(sound_t *sound)
|
||||
{
|
||||
size_t c;
|
||||
|
||||
if (!isAudioInitialised || !sound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (c = 0; c < SYSSND_MIX_CHANNELS; c++)
|
||||
{
|
||||
if (channels[c].sound == sound)
|
||||
{
|
||||
endChannel(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Stops all channels.
|
||||
*/
|
||||
void syssnd_stopAll(void)
|
||||
{
|
||||
size_t c;
|
||||
|
||||
if (!isAudioInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (c = 0; c < SYSSND_MIX_CHANNELS; c++)
|
||||
{
|
||||
if (channels[c].sound)
|
||||
{
|
||||
endChannel(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a sound.
|
||||
*/
|
||||
void syssnd_load(sound_t *sound)
|
||||
{
|
||||
int bytesRead;
|
||||
file_t fp;
|
||||
bool success;
|
||||
|
||||
if (!isAudioInitialised || !sound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
success = false;
|
||||
do
|
||||
{
|
||||
sound->buf = sysmem_push(sound->len);
|
||||
if (!sound->buf)
|
||||
{
|
||||
sys_error("(audio) not enough memory for \"%s\", %d bytes needed", sound->name, sound->len);
|
||||
break;
|
||||
}
|
||||
|
||||
fp = sysfile_open(sound->name);
|
||||
if (!fp)
|
||||
{
|
||||
sys_error("(audio) unable to open \"%s\"", sound->name);
|
||||
break;
|
||||
}
|
||||
|
||||
sysfile_seek(fp, sizeof(wave_header_t), SEEK_SET); /* skip WAVE header */
|
||||
|
||||
bytesRead = sysfile_read(fp, sound->buf, sound->len, 1);
|
||||
sysfile_close(fp);
|
||||
if (bytesRead != 1)
|
||||
{
|
||||
sys_error("(audio) unable to read from \"%s\"", sound->name);
|
||||
break;
|
||||
}
|
||||
|
||||
success = true;
|
||||
} while (false);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
sysmem_pop(sound->buf);
|
||||
sound->buf = NULL;
|
||||
sound->len = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
IFDEBUG_AUDIO(sys_printf("xrick/audio: successfully loaded \"%s\"\n", sound->name););
|
||||
}
|
||||
|
||||
/*
|
||||
* Unload a sound.
|
||||
*/
|
||||
void syssnd_unload(sound_t *sound)
|
||||
{
|
||||
if (!isAudioInitialised || !sound || !sound->buf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sysmem_pop(sound->buf);
|
||||
sound->buf = NULL;
|
||||
sound->len = 0;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_SOUND */
|
||||
|
||||
/* eof */
|
48
apps/plugins/xrick/system/syssnd_rockbox.h
Normal file
48
apps/plugins/xrick/system/syssnd_rockbox.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _SYSSND_ROCKBOX_H
|
||||
#define _SYSSND_ROCKBOX_H
|
||||
|
||||
#include "xrick/config.h"
|
||||
|
||||
#ifdef ENABLE_SOUND
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
typedef struct {
|
||||
sound_t *sound;
|
||||
U8 *buf;
|
||||
U32 len;
|
||||
S8 loop;
|
||||
} channel_t;
|
||||
|
||||
extern void syssnd_load(sound_t *);
|
||||
extern void syssnd_unload(sound_t *);
|
||||
|
||||
#endif /* ENABLE_SOUND */
|
||||
|
||||
#endif /* ndef _SYSSND_ROCKBOX_H */
|
||||
|
||||
/* eof */
|
178
apps/plugins/xrick/system/system.h
Normal file
178
apps/plugins/xrick/system/system.h
Normal file
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* xrick/system/system.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _SYSTEM_H
|
||||
#define _SYSTEM_H
|
||||
|
||||
/*
|
||||
* Detect GCC
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
/*
|
||||
* make POSIX functions available
|
||||
*/
|
||||
# ifndef _POSIX_SOURCE
|
||||
# define _POSIX_SOURCE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Detect Microsoft Visual C
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* FIXME disable "integral size mismatch in argument; conversion supplied" warning
|
||||
* as long as the code has not been cleared -- there are so many of them...
|
||||
*/
|
||||
#pragma warning( disable : 4761 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Detect Microsoft Windows
|
||||
*/
|
||||
#if !defined( __WIN32__ ) && ( defined( WIN32 ) || defined( _WIN32 ) )
|
||||
#define __WIN32__
|
||||
#endif
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/rects.h"
|
||||
#include "xrick/data/img.h"
|
||||
#ifdef ENABLE_SOUND
|
||||
#include "xrick/data/sounds.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
#include <sys/types.h> /* off_t */
|
||||
|
||||
/*
|
||||
* main section
|
||||
*/
|
||||
extern bool sys_init(int, char **);
|
||||
extern void sys_shutdown(void);
|
||||
extern void sys_error(const char *, ...);
|
||||
extern void sys_printf(const char *, ...);
|
||||
extern void sys_snprintf(char *, size_t, const char *, ...);
|
||||
extern size_t sys_strlen(const char *);
|
||||
extern U32 sys_gettime(void);
|
||||
extern void sys_yield(void);
|
||||
extern bool sys_cacheData(void);
|
||||
extern void sys_uncacheData(void);
|
||||
|
||||
/*
|
||||
* memory section
|
||||
*/
|
||||
extern bool sysmem_init(void);
|
||||
extern void sysmem_shutdown(void);
|
||||
extern void *sysmem_push(size_t);
|
||||
extern void sysmem_pop(void *);
|
||||
|
||||
/*
|
||||
* video section
|
||||
*/
|
||||
#define SYSVID_ZOOM 2
|
||||
#define SYSVID_MAXZOOM 4
|
||||
#define SYSVID_WIDTH 320
|
||||
#define SYSVID_HEIGHT 200
|
||||
|
||||
extern U8 *sysvid_fb; /* frame buffer */
|
||||
|
||||
extern bool sysvid_init(void);
|
||||
extern void sysvid_shutdown(void);
|
||||
extern void sysvid_update(const rect_t *);
|
||||
extern void sysvid_clear(void);
|
||||
extern void sysvid_zoom(S8);
|
||||
extern void sysvid_toggleFullscreen(void);
|
||||
extern void sysvid_setGamePalette(void);
|
||||
extern void sysvid_setPalette(img_color_t *, U16);
|
||||
|
||||
/*
|
||||
* file management section
|
||||
*/
|
||||
typedef void *file_t;
|
||||
|
||||
extern const char *sysfile_defaultPath;
|
||||
|
||||
extern bool sysfile_setRootPath(const char *);
|
||||
extern void sysfile_clearRootPath(void);
|
||||
|
||||
extern file_t sysfile_open(const char *);
|
||||
extern int sysfile_seek(file_t file, long offset, int origin);
|
||||
extern int sysfile_tell(file_t);
|
||||
extern off_t sysfile_size(file_t);
|
||||
extern int sysfile_read(file_t, void *, size_t, size_t);
|
||||
extern void sysfile_close(file_t);
|
||||
|
||||
/*
|
||||
* events section
|
||||
*/
|
||||
extern void sysevt_poll(void);
|
||||
extern void sysevt_wait(void);
|
||||
|
||||
/*
|
||||
* keyboard section
|
||||
*/
|
||||
extern U8 syskbd_up;
|
||||
extern U8 syskbd_down;
|
||||
extern U8 syskbd_left;
|
||||
extern U8 syskbd_right;
|
||||
extern U8 syskbd_pause;
|
||||
extern U8 syskbd_end;
|
||||
extern U8 syskbd_xtra;
|
||||
extern U8 syskbd_fire;
|
||||
|
||||
/*
|
||||
* sound section
|
||||
*/
|
||||
#ifdef ENABLE_SOUND
|
||||
extern const U8 syssnd_period; /* time between each sound update, in millisecond */
|
||||
|
||||
extern bool syssnd_init(void);
|
||||
extern void syssnd_shutdown(void);
|
||||
extern void syssnd_update(void);
|
||||
extern void syssnd_vol(S8);
|
||||
extern void syssnd_toggleMute(void);
|
||||
extern void syssnd_play(sound_t *, S8);
|
||||
extern void syssnd_pauseAll(bool);
|
||||
extern void syssnd_stop(sound_t *);
|
||||
extern void syssnd_stopAll(void);
|
||||
#endif /* ENABLE_ SOUND */
|
||||
|
||||
/*
|
||||
* args section
|
||||
*/
|
||||
extern int sysarg_args_period;
|
||||
extern int sysarg_args_map;
|
||||
extern int sysarg_args_submap;
|
||||
extern int sysarg_args_fullscreen;
|
||||
extern int sysarg_args_zoom;
|
||||
#ifdef ENABLE_SOUND
|
||||
extern bool sysarg_args_nosound;
|
||||
extern int sysarg_args_vol;
|
||||
#endif /* ENABLE_ SOUND */
|
||||
extern const char *sysarg_args_data;
|
||||
|
||||
extern bool sysarg_init(int, char **);
|
||||
|
||||
/*
|
||||
* joystick section
|
||||
*/
|
||||
#ifdef ENABLE_JOYSTICK
|
||||
extern bool sysjoy_init(void);
|
||||
extern void sysjoy_shutdown(void);
|
||||
#endif
|
||||
|
||||
#endif /* ndef _SYSTEM_H */
|
||||
|
||||
/* eof */
|
262
apps/plugins/xrick/system/system_rockbox.c
Normal file
262
apps/plugins/xrick/system/system_rockbox.c
Normal file
|
@ -0,0 +1,262 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
#ifdef ENABLE_SOUND
|
||||
#include "xrick/system/syssnd_rockbox.h"
|
||||
#endif
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
enum { LINE_LENGTH = 80 };
|
||||
|
||||
/*
|
||||
* Error
|
||||
*/
|
||||
void sys_error(const char *err, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char s[LINE_LENGTH];
|
||||
|
||||
/* prepare message */
|
||||
va_start(argptr, err);
|
||||
rb->vsnprintf(s, sizeof(s), err, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
/* print error message */
|
||||
rb->splashf(HZ*3, ID2P(LANG_ERROR_FORMATSTR), s);
|
||||
DEBUGF("Error: %s\n", s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a message to standard output
|
||||
*/
|
||||
void sys_printf(const char *msg, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char s[LINE_LENGTH];
|
||||
|
||||
/* prepare message */
|
||||
va_start(argptr, msg);
|
||||
rb->vsnprintf(s, sizeof(s), msg, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
/* print message */
|
||||
DEBUGF("%s",s);
|
||||
|
||||
#ifdef ENABLE_SYSPRINTF_TO_SCREEN
|
||||
{
|
||||
static int currentYPos = 0;
|
||||
size_t i;
|
||||
|
||||
/* Device LCDs display newlines funny. */
|
||||
for(i = 0; s[i] != '\0'; ++i)
|
||||
{
|
||||
if(s[i] == '\n')
|
||||
{
|
||||
s[i] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
rb->lcd_putsxy(1, currentYPos, (unsigned char *)s);
|
||||
rb->lcd_update();
|
||||
|
||||
currentYPos += 12;
|
||||
if(currentYPos > LCD_HEIGHT-12)
|
||||
{
|
||||
currentYPos = 0;
|
||||
rb->lcd_clear_display();
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_SYSPRINTF_TO_SCREEN */
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a message to string buffer
|
||||
*/
|
||||
void sys_snprintf(char *buf, size_t size, const char *msg, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr, msg);
|
||||
rb->vsnprintf(buf, size, msg, argptr);
|
||||
va_end(argptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns string length
|
||||
*/
|
||||
size_t sys_strlen(const char * str)
|
||||
{
|
||||
return rb->strlen(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return number of milliseconds elapsed since first call
|
||||
*/
|
||||
U32 sys_gettime(void)
|
||||
{
|
||||
long ticks = *(rb->current_tick);
|
||||
return (U32)((ticks * 1000) / HZ);
|
||||
}
|
||||
|
||||
/*
|
||||
* Yield execution to another thread
|
||||
*/
|
||||
void sys_yield(void)
|
||||
{
|
||||
rb->yield();
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize system
|
||||
*/
|
||||
bool sys_init(int argc, char **argv)
|
||||
{
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(true);
|
||||
#endif
|
||||
|
||||
if (!sysarg_init(argc, argv))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!sysmem_init())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!sysvid_init())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#ifdef ENABLE_SOUND
|
||||
if (!sysarg_args_nosound && !syssnd_init())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (!sysfile_setRootPath(sysarg_args_data? sysarg_args_data : sysfile_defaultPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown system
|
||||
*/
|
||||
void sys_shutdown(void)
|
||||
{
|
||||
sysfile_clearRootPath();
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_shutdown();
|
||||
#endif
|
||||
sysvid_shutdown();
|
||||
sysmem_shutdown();
|
||||
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Preload data before entering main loop
|
||||
*/
|
||||
bool sys_cacheData(void)
|
||||
{
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_load(soundGameover);
|
||||
syssnd_load(soundSbonus2);
|
||||
syssnd_load(soundBullet);
|
||||
syssnd_load(soundBombshht);
|
||||
syssnd_load(soundExplode);
|
||||
syssnd_load(soundStick);
|
||||
syssnd_load(soundWalk);
|
||||
syssnd_load(soundCrawl);
|
||||
syssnd_load(soundJump);
|
||||
syssnd_load(soundPad);
|
||||
syssnd_load(soundBox);
|
||||
syssnd_load(soundBonus);
|
||||
syssnd_load(soundSbonus1);
|
||||
syssnd_load(soundDie);
|
||||
syssnd_load(soundEntity[0]);
|
||||
syssnd_load(soundEntity[1]);
|
||||
syssnd_load(soundEntity[2]);
|
||||
syssnd_load(soundEntity[3]);
|
||||
syssnd_load(soundEntity[4]);
|
||||
syssnd_load(soundEntity[5]);
|
||||
syssnd_load(soundEntity[6]);
|
||||
syssnd_load(soundEntity[7]);
|
||||
syssnd_load(soundEntity[8]);
|
||||
syssnd_load(soundTune0);
|
||||
syssnd_load(soundTune1);
|
||||
syssnd_load(soundTune2);
|
||||
syssnd_load(soundTune3);
|
||||
syssnd_load(soundTune4);
|
||||
syssnd_load(soundTune5);
|
||||
#endif /* ENABLE_SOUND */
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear preloaded data before shutdown
|
||||
*/
|
||||
void sys_uncacheData(void)
|
||||
{
|
||||
#ifdef ENABLE_SOUND
|
||||
syssnd_unload(soundTune5);
|
||||
syssnd_unload(soundTune4);
|
||||
syssnd_unload(soundTune3);
|
||||
syssnd_unload(soundTune2);
|
||||
syssnd_unload(soundTune1);
|
||||
syssnd_unload(soundTune0);
|
||||
syssnd_unload(soundEntity[8]);
|
||||
syssnd_unload(soundEntity[7]);
|
||||
syssnd_unload(soundEntity[6]);
|
||||
syssnd_unload(soundEntity[5]);
|
||||
syssnd_unload(soundEntity[4]);
|
||||
syssnd_unload(soundEntity[3]);
|
||||
syssnd_unload(soundEntity[2]);
|
||||
syssnd_unload(soundEntity[1]);
|
||||
syssnd_unload(soundEntity[0]);
|
||||
syssnd_unload(soundDie);
|
||||
syssnd_unload(soundSbonus1);
|
||||
syssnd_unload(soundBonus);
|
||||
syssnd_unload(soundBox);
|
||||
syssnd_unload(soundPad);
|
||||
syssnd_unload(soundJump);
|
||||
syssnd_unload(soundCrawl);
|
||||
syssnd_unload(soundWalk);
|
||||
syssnd_unload(soundStick);
|
||||
syssnd_unload(soundExplode);
|
||||
syssnd_unload(soundBombshht);
|
||||
syssnd_unload(soundBullet);
|
||||
syssnd_unload(soundSbonus2);
|
||||
syssnd_unload(soundGameover);
|
||||
#endif /* ENABLE_SOUND */
|
||||
}
|
||||
|
||||
/* eof */
|
402
apps/plugins/xrick/system/sysvid_rockbox.c
Normal file
402
apps/plugins/xrick/system/sysvid_rockbox.c
Normal file
|
@ -0,0 +1,402 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Port of xrick, a Rick Dangerous clone, to Rockbox.
|
||||
* See http://www.bigorno.net/xrick/
|
||||
*
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/draw.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/data/img.h"
|
||||
#include "xrick/debug.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
U8 *sysvid_fb = NULL; /* xRick generic 320x200 8bpp frame buffer */
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
static fb_data palette[256] IBSS_ATTR;
|
||||
static bool isVideoInitialised = false;
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
# include "lib/grey.h"
|
||||
GREY_INFO_STRUCT_IRAM
|
||||
static unsigned char greybuffer[LCD_HEIGHT * LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
|
||||
static unsigned char *gbuf;
|
||||
# if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
||||
enum { GREYBUFSIZE = (((LCD_WIDTH+7)/8)*LCD_HEIGHT*16+200) };
|
||||
# else
|
||||
enum { GREYBUFSIZE = (LCD_WIDTH*((LCD_HEIGHT+7)/8)*16+200) };
|
||||
# endif
|
||||
#endif /* ndef HAVE_LCD_COLOR */
|
||||
|
||||
static fb_data *lcd_fb = NULL;
|
||||
|
||||
#if (LCD_HEIGHT < SYSVID_HEIGHT)
|
||||
enum { ROW_RESIZE_STEP = (LCD_HEIGHT << 16) / SYSVID_HEIGHT };
|
||||
|
||||
static bool rowsToSkip[SYSVID_HEIGHT];
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
static void calculateRowsToSkip(void)
|
||||
{
|
||||
U32 currentRow, prevResizedRow;
|
||||
|
||||
prevResizedRow = 0;
|
||||
rowsToSkip[0] = false;
|
||||
|
||||
for (currentRow = 1; currentRow < SYSVID_HEIGHT; ++currentRow)
|
||||
{
|
||||
U32 resizedRow = (currentRow * ROW_RESIZE_STEP) >> 16;
|
||||
if (resizedRow == prevResizedRow)
|
||||
{
|
||||
rowsToSkip[currentRow] = true;
|
||||
}
|
||||
prevResizedRow = resizedRow;
|
||||
}
|
||||
}
|
||||
#endif /* (LCD_HEIGHT < SYSVID_HEIGHT) */
|
||||
|
||||
#if (LCD_WIDTH < SYSVID_WIDTH)
|
||||
enum { COLUMN_RESIZE_STEP = (LCD_WIDTH << 16) / (SYSVID_WIDTH + (DRAW_XYMAP_SCRLEFT*2)) };
|
||||
|
||||
static bool columnsToSkip[SYSVID_WIDTH + (DRAW_XYMAP_SCRLEFT*2)];
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
static void calculateColumnsToSkip(void)
|
||||
{
|
||||
U32 currentColumn, prevResizedColumn;
|
||||
|
||||
prevResizedColumn = 0;
|
||||
columnsToSkip[0] = false;
|
||||
|
||||
for (currentColumn = 1; currentColumn < (SYSVID_WIDTH + (DRAW_XYMAP_SCRLEFT*2)); ++currentColumn)
|
||||
{
|
||||
U32 resizedColumn = (currentColumn * COLUMN_RESIZE_STEP) >> 16;
|
||||
if (resizedColumn == prevResizedColumn)
|
||||
{
|
||||
columnsToSkip[currentColumn] = true;
|
||||
}
|
||||
prevResizedColumn = resizedColumn;
|
||||
}
|
||||
}
|
||||
#endif /* (LCD_WIDTH < SYSVID_WIDTH) */
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void sysvid_setPalette(img_color_t *pal, U16 n)
|
||||
{
|
||||
U16 i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
palette[i] = LCD_RGBPACK(pal[i].r, pal[i].g, pal[i].b);
|
||||
#else
|
||||
palette[i] = ((3 * pal[i].r) + (6 * pal[i].g) + pal[i].b) / 10;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void sysvid_setGamePalette()
|
||||
{
|
||||
sysvid_setPalette(game_colors, game_color_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update screen
|
||||
*/
|
||||
void sysvid_update(const rect_t *rects)
|
||||
{
|
||||
unsigned sourceRow, sourceLastRow;
|
||||
unsigned sourceColumn, sourceLastColumn;
|
||||
unsigned resizedRow, resizedColumn;
|
||||
unsigned resizedWidth, resizedHeight;
|
||||
unsigned x, y;
|
||||
U8 *sourceBuf, *sourceTemp;
|
||||
fb_data *destBuf, *destTemp;
|
||||
|
||||
if (!rects)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (rects)
|
||||
{
|
||||
sourceRow = rects->y;
|
||||
sourceLastRow = sourceRow + rects->height;
|
||||
sourceColumn = rects->x;
|
||||
sourceLastColumn = sourceColumn + rects->width;
|
||||
|
||||
#if (LCD_WIDTH < SYSVID_WIDTH)
|
||||
/* skip black borders */
|
||||
if (sourceColumn < -DRAW_XYMAP_SCRLEFT)
|
||||
{
|
||||
sourceColumn = -DRAW_XYMAP_SCRLEFT;
|
||||
}
|
||||
if (sourceLastColumn > (SYSVID_WIDTH + DRAW_XYMAP_SCRLEFT))
|
||||
{
|
||||
sourceLastColumn = SYSVID_WIDTH + DRAW_XYMAP_SCRLEFT;
|
||||
}
|
||||
|
||||
/* skip unwanted columns */
|
||||
while (columnsToSkip[sourceColumn + DRAW_XYMAP_SCRLEFT] /* && sourceColumn < (SYSVID_WIDTH + DRAW_XYMAP_SCRLEFT) */)
|
||||
{
|
||||
++sourceColumn;
|
||||
}
|
||||
|
||||
resizedColumn = ((sourceColumn + DRAW_XYMAP_SCRLEFT) * COLUMN_RESIZE_STEP) >> 16;
|
||||
resizedWidth = 0;
|
||||
#else
|
||||
resizedColumn = sourceColumn;
|
||||
resizedWidth = rects->width;
|
||||
#endif /* (LCD_WIDTH < SYSVID_WIDTH) */
|
||||
|
||||
#if (LCD_HEIGHT < SYSVID_HEIGHT)
|
||||
/* skip unwanted rows */
|
||||
while (rowsToSkip[sourceRow] /* && sourceRow < SYSVID_HEIGHT */)
|
||||
{
|
||||
++sourceRow;
|
||||
}
|
||||
|
||||
resizedRow = (sourceRow * ROW_RESIZE_STEP) >> 16;
|
||||
resizedHeight = 0;
|
||||
#else
|
||||
resizedRow = sourceRow;
|
||||
resizedHeight = rects->height;
|
||||
#endif /* (LCD_HEIGHT < SYSVID_HEIGHT) */
|
||||
|
||||
sourceBuf = sysvid_fb;
|
||||
sourceBuf += sourceColumn + sourceRow * SYSVID_WIDTH;
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
if(!lcd_fb)
|
||||
{
|
||||
struct viewport *vp_main = rb->lcd_set_viewport(NULL);
|
||||
lcd_fb = vp_main->buffer->fb_ptr;
|
||||
}
|
||||
destBuf = lcd_fb;
|
||||
#else
|
||||
destBuf = greybuffer;
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
destBuf += resizedColumn + resizedRow * LCD_WIDTH;
|
||||
|
||||
#if (LCD_WIDTH < SYSVID_WIDTH)
|
||||
sourceColumn += DRAW_XYMAP_SCRLEFT;
|
||||
sourceLastColumn += DRAW_XYMAP_SCRLEFT;
|
||||
#endif /* (LCD_WIDTH < SYSVID_WIDTH) */
|
||||
|
||||
for (y = sourceRow; y < sourceLastRow; ++y)
|
||||
{
|
||||
#if (LCD_HEIGHT < SYSVID_HEIGHT)
|
||||
if (rowsToSkip[y])
|
||||
{
|
||||
sourceBuf += SYSVID_WIDTH;
|
||||
continue;
|
||||
}
|
||||
|
||||
++resizedHeight;
|
||||
#endif /* (LCD_HEIGHT < SYSVID_HEIGHT) */
|
||||
|
||||
sourceTemp = sourceBuf;
|
||||
destTemp = destBuf;
|
||||
for (x = sourceColumn; x < sourceLastColumn; ++x)
|
||||
{
|
||||
#if (LCD_WIDTH < SYSVID_WIDTH)
|
||||
if (columnsToSkip[x])
|
||||
{
|
||||
++sourceTemp;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (y == sourceRow)
|
||||
{
|
||||
++resizedWidth;
|
||||
}
|
||||
#endif /* (LCD_WIDTH < SYSVID_WIDTH) */
|
||||
|
||||
*destTemp = palette[*sourceTemp];
|
||||
|
||||
++sourceTemp;
|
||||
++destTemp;
|
||||
}
|
||||
|
||||
sourceBuf += SYSVID_WIDTH;
|
||||
destBuf += LCD_WIDTH;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
IFDEBUG_VIDEO2(
|
||||
for (y = resizedRow; y < resizedRow + resizedHeight; ++y)
|
||||
{
|
||||
destBuf = lcd_fb + resizedColumn + y * LCD_WIDTH;
|
||||
*destBuf = palette[0x01];
|
||||
*(destBuf + resizedWidth - 1) = palette[0x01];
|
||||
}
|
||||
|
||||
for (x = resizedColumn; x < resizedColumn + resizedWidth; ++x)
|
||||
{
|
||||
destBuf = rb->lcd_fb + x + resizedRow * LCD_WIDTH;
|
||||
*destBuf = palette[0x01];
|
||||
*(destBuf + (resizedHeight - 1) * LCD_WIDTH) = palette[0x01];
|
||||
}
|
||||
);
|
||||
|
||||
rb->lcd_update_rect(resizedColumn, resizedRow, resizedWidth, resizedHeight);
|
||||
#else
|
||||
grey_ub_gray_bitmap_part(greybuffer, resizedColumn, resizedRow, LCD_WIDTH, resizedColumn, resizedRow, resizedWidth, resizedHeight);
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
|
||||
rects = rects->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear screen
|
||||
* (077C)
|
||||
*/
|
||||
void sysvid_clear(void)
|
||||
{
|
||||
rb->memset(sysvid_fb, 0, sizeof(U8) * SYSVID_WIDTH * SYSVID_HEIGHT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise video
|
||||
*/
|
||||
bool sysvid_init()
|
||||
{
|
||||
bool success;
|
||||
|
||||
if (isVideoInitialised)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IFDEBUG_VIDEO(sys_printf("xrick/video: start\n"););
|
||||
|
||||
success = false;
|
||||
do
|
||||
{
|
||||
/* allocate xRick generic frame buffer into memory */
|
||||
sysvid_fb = sysmem_push(sizeof(U8) * SYSVID_WIDTH * SYSVID_HEIGHT);
|
||||
if (!sysvid_fb)
|
||||
{
|
||||
sys_error("(video) unable to allocate frame buffer");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
gbuf = sysmem_push(GREYBUFSIZE);
|
||||
if (!gbuf)
|
||||
{
|
||||
sys_error("(video) unable to allocate buffer for greyscale functions");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!grey_init(gbuf, GREYBUFSIZE, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL))
|
||||
{
|
||||
sys_error("(video) not enough memory to initialise greyscale functions");
|
||||
break;
|
||||
}
|
||||
#endif /* ndef HAVE_LCD_COLOR */
|
||||
|
||||
success = true;
|
||||
} while (false);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
sysmem_pop(gbuf);
|
||||
#endif
|
||||
sysmem_pop(sysvid_fb);
|
||||
return false;
|
||||
}
|
||||
|
||||
#if (LCD_HEIGHT < SYSVID_HEIGHT)
|
||||
calculateRowsToSkip();
|
||||
#endif
|
||||
#if (LCD_WIDTH < SYSVID_WIDTH)
|
||||
calculateColumnsToSkip();
|
||||
#endif
|
||||
|
||||
#if LCD_DEPTH > 1
|
||||
rb->lcd_set_backdrop(NULL);
|
||||
#endif
|
||||
/* Turn off backlight timeout */
|
||||
backlight_ignore_timeout();
|
||||
|
||||
rb->lcd_set_foreground(LCD_WHITE);
|
||||
rb->lcd_set_background(LCD_BLACK);
|
||||
rb->lcd_clear_display();
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
rb->lcd_update();
|
||||
#else
|
||||
/* switch on greyscale overlay */
|
||||
grey_show(true);
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
|
||||
isVideoInitialised = true;
|
||||
IFDEBUG_VIDEO(sys_printf("xrick/video: ready\n"););
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown video
|
||||
*/
|
||||
void sysvid_shutdown(void)
|
||||
{
|
||||
if (!isVideoInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
grey_show(false);
|
||||
grey_release();
|
||||
|
||||
sysmem_pop(gbuf);
|
||||
#endif /* ndef HAVE_LCD_COLOR */
|
||||
sysmem_pop(sysvid_fb);
|
||||
|
||||
/* Turn on backlight timeout (revert to settings) */
|
||||
backlight_use_settings();
|
||||
|
||||
isVideoInitialised = false;
|
||||
IFDEBUG_VIDEO(sys_printf("xrick/video: stop\n"););
|
||||
}
|
||||
|
||||
/* eof */
|
230
apps/plugins/xrick/util.c
Normal file
230
apps/plugins/xrick/util.c
Normal file
|
@ -0,0 +1,230 @@
|
|||
/*
|
||||
* xrick/util.c
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#include "xrick/util.h"
|
||||
|
||||
#include "xrick/config.h"
|
||||
#include "xrick/game.h"
|
||||
#include "xrick/ents.h"
|
||||
#include "xrick/e_rick.h"
|
||||
#include "xrick/maps.h"
|
||||
#include "xrick/system/system.h"
|
||||
|
||||
#include <string.h> /* memcpy */
|
||||
|
||||
/*
|
||||
* Full box test.
|
||||
*
|
||||
* ASM 1199
|
||||
*
|
||||
* e: entity to test against.
|
||||
* x,y: coordinates to test.
|
||||
* ret: true/(x,y) is within e's space, false/not.
|
||||
*/
|
||||
bool
|
||||
u_fboxtest(U8 e, S16 x, S16 y)
|
||||
{
|
||||
if (ent_ents[e].x >= x ||
|
||||
ent_ents[e].x + ent_ents[e].w < x ||
|
||||
ent_ents[e].y >= y ||
|
||||
ent_ents[e].y + ent_ents[e].h < y)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Box test (then whole e2 is checked agains the center of e1).
|
||||
*
|
||||
* ASM 113E
|
||||
*
|
||||
* e1: entity to test against (corresponds to DI in asm code).
|
||||
* e2: entity to test (corresponds to SI in asm code).
|
||||
* ret: true/intersect, false/not.
|
||||
*/
|
||||
bool
|
||||
u_boxtest(U8 e1, U8 e2)
|
||||
{
|
||||
/* rick is special (may be crawling) */
|
||||
if (e1 == E_RICK_NO)
|
||||
return e_rick_boxtest(e2);
|
||||
|
||||
/*
|
||||
* entity 1: x+0x05 to x+0x011, y to y+0x14
|
||||
* entity 2: x to x+ .w, y to y+ .h
|
||||
*/
|
||||
if (ent_ents[e1].x + 0x11 < ent_ents[e2].x ||
|
||||
ent_ents[e1].x + 0x05 > ent_ents[e2].x + ent_ents[e2].w ||
|
||||
ent_ents[e1].y + 0x14 < ent_ents[e2].y ||
|
||||
ent_ents[e1].y > ent_ents[e2].y + ent_ents[e2].h - 1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Compute the environment flag.
|
||||
*
|
||||
* ASM 0FBC if !crawl, else 103E
|
||||
*
|
||||
* x, y: coordinates where to compute the environment flag
|
||||
* crawl: is rick crawling?
|
||||
* rc0: anything CHANGED to the environment flag for crawling (6DBA)
|
||||
* rc1: anything CHANGED to the environment flag (6DAD)
|
||||
*/
|
||||
void
|
||||
u_envtest(S16 x, S16 y, bool crawl, U8 *rc0, U8 *rc1)
|
||||
{
|
||||
U8 i, xx;
|
||||
|
||||
/* prepare for ent #0 test */
|
||||
ent_ents[ENT_ENTSNUM].x = x;
|
||||
ent_ents[ENT_ENTSNUM].y = y;
|
||||
|
||||
i = 1;
|
||||
if (!crawl) i++;
|
||||
if (y & 0x0004) i++;
|
||||
|
||||
x += 4;
|
||||
xx = (U8)x; /* FIXME? */
|
||||
|
||||
x = x >> 3; /* from pixels to tiles */
|
||||
y = y >> 3; /* from pixels to tiles */
|
||||
|
||||
*rc0 = *rc1 = 0;
|
||||
|
||||
if (xx & 0x07) { /* tiles columns alignment */
|
||||
if (crawl) {
|
||||
*rc0 |= (map_eflg[map_map[y][x]] &
|
||||
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
|
||||
*rc0 |= (map_eflg[map_map[y][x + 1]] &
|
||||
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
|
||||
*rc0 |= (map_eflg[map_map[y][x + 2]] &
|
||||
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
|
||||
y++;
|
||||
}
|
||||
do {
|
||||
*rc1 |= (map_eflg[map_map[y][x]] &
|
||||
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
|
||||
MAP_EFLG_LETHAL|MAP_EFLG_01));
|
||||
*rc1 |= (map_eflg[map_map[y][x + 1]] &
|
||||
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
|
||||
MAP_EFLG_LETHAL|MAP_EFLG_CLIMB|MAP_EFLG_01));
|
||||
*rc1 |= (map_eflg[map_map[y][x + 2]] &
|
||||
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
|
||||
MAP_EFLG_LETHAL|MAP_EFLG_01));
|
||||
y++;
|
||||
} while (--i > 0);
|
||||
|
||||
*rc1 |= (map_eflg[map_map[y][x]] &
|
||||
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP|MAP_EFLG_FGND|
|
||||
MAP_EFLG_LETHAL|MAP_EFLG_01));
|
||||
*rc1 |= (map_eflg[map_map[y][x + 1]]);
|
||||
*rc1 |= (map_eflg[map_map[y][x + 2]] &
|
||||
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP|MAP_EFLG_FGND|
|
||||
MAP_EFLG_LETHAL|MAP_EFLG_01));
|
||||
}
|
||||
else {
|
||||
if (crawl) {
|
||||
*rc0 |= (map_eflg[map_map[y][x]] &
|
||||
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
|
||||
*rc0 |= (map_eflg[map_map[y][x + 1]] &
|
||||
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
|
||||
y++;
|
||||
}
|
||||
do {
|
||||
*rc1 |= (map_eflg[map_map[y][x]] &
|
||||
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
|
||||
MAP_EFLG_LETHAL|MAP_EFLG_CLIMB|MAP_EFLG_01));
|
||||
*rc1 |= (map_eflg[map_map[y][x + 1]] &
|
||||
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
|
||||
MAP_EFLG_LETHAL|MAP_EFLG_CLIMB|MAP_EFLG_01));
|
||||
y++;
|
||||
} while (--i > 0);
|
||||
|
||||
*rc1 |= (map_eflg[map_map[y][x]]);
|
||||
*rc1 |= (map_eflg[map_map[y][x + 1]]);
|
||||
}
|
||||
|
||||
/*
|
||||
* If not lethal yet, and there's an entity on slot zero, and (x,y)
|
||||
* boxtests this entity, then raise SOLID flag. This is how we make
|
||||
* sure that no entity can move over the entity that is on slot zero.
|
||||
*
|
||||
* Beware! When game_cheat2 is set, this means that a block can
|
||||
* move over rick without killing him -- but then rick is trapped
|
||||
* because the block is solid.
|
||||
*/
|
||||
if (!(*rc1 & MAP_EFLG_LETHAL)
|
||||
&& ent_ents[0].n
|
||||
&& u_boxtest(ENT_ENTSNUM, 0)) {
|
||||
*rc1 |= MAP_EFLG_SOLID;
|
||||
}
|
||||
|
||||
/* When game_cheat2 is set, the environment can not be lethal. */
|
||||
#ifdef ENABLE_CHEATS
|
||||
if (game_cheat2) *rc1 &= ~MAP_EFLG_LETHAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check if x,y is within e trigger box.
|
||||
*
|
||||
* ASM 126F
|
||||
* return: false if not in box, true if in box.
|
||||
*/
|
||||
bool
|
||||
u_trigbox(U8 e, S16 x, S16 y)
|
||||
{
|
||||
U16 xmax, ymax;
|
||||
|
||||
xmax = ent_ents[e].trig_x + (ent_entdata[ent_ents[e].n & 0x7F].trig_w << 3);
|
||||
ymax = ent_ents[e].trig_y + (ent_entdata[ent_ents[e].n & 0x7F].trig_h << 3);
|
||||
|
||||
if (xmax > 0xFF) xmax = 0xFF;
|
||||
|
||||
if (x <= ent_ents[e].trig_x || x > xmax ||
|
||||
y <= ent_ents[e].trig_y || y > ymax)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Custom implementation of strdup function
|
||||
*/
|
||||
char *
|
||||
u_strdup(const char *sourceStr)
|
||||
{
|
||||
char *destStr;
|
||||
size_t length;
|
||||
|
||||
length = sys_strlen(sourceStr) + 1;
|
||||
destStr = sysmem_push(length);
|
||||
if (!destStr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
memcpy(destStr, sourceStr, length);
|
||||
return destStr;
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
29
apps/plugins/xrick/util.h
Normal file
29
apps/plugins/xrick/util.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* xrick/util.h
|
||||
*
|
||||
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
|
||||
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The use and distribution terms for this software are contained in the file
|
||||
* named README, which can be found in the root of this distribution. By
|
||||
* using this software in any fashion, you are agreeing to be bound by the
|
||||
* terms of this license.
|
||||
*
|
||||
* You must not remove this notice, or any other, from this software.
|
||||
*/
|
||||
|
||||
#ifndef _UTIL_H
|
||||
#define _UTIL_H
|
||||
|
||||
#include "xrick/system/basic_types.h"
|
||||
|
||||
extern void u_envtest(S16, S16, bool, U8 *, U8 *);
|
||||
extern bool u_boxtest(U8, U8);
|
||||
extern bool u_fboxtest(U8, S16, S16);
|
||||
extern bool u_trigbox(U8, S16, S16);
|
||||
extern char * u_strdup(const char *);
|
||||
|
||||
#endif /* ndef _UTIL_H */
|
||||
|
||||
/* eof */
|
31
apps/plugins/xrick/xrick.make
Normal file
31
apps/plugins/xrick/xrick.make
Normal file
|
@ -0,0 +1,31 @@
|
|||
# __________ __ ___.
|
||||
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
# \/ \/ \/ \/ \/
|
||||
# $Id$
|
||||
#
|
||||
|
||||
XRICKSRCDIR := $(APPSDIR)/plugins/xrick
|
||||
XRICKBUILDDIR := $(BUILDDIR)/apps/plugins/xrick
|
||||
|
||||
INCLUDES += -I$(XRICKSRCDIR)../ \
|
||||
-I$(XRICKSRCDIR)/3rd_party
|
||||
|
||||
ROCKS += $(XRICKBUILDDIR)/xrick.rock
|
||||
|
||||
XRICK_SRC := $(call preprocess, $(XRICKSRCDIR)/SOURCES)
|
||||
XRICK_OBJ := $(call c2obj, $(XRICK_SRC))
|
||||
|
||||
# add source files to OTHER_SRC to get automatic dependencies
|
||||
OTHER_SRC += $(XRICK_SRC)
|
||||
|
||||
XRICKCFLAGS = $(PLUGINFLAGS) -std=gnu99 -O2
|
||||
|
||||
$(XRICKBUILDDIR)/xrick.rock: $(XRICK_OBJ)
|
||||
|
||||
# new rule needed to use extra compile flags
|
||||
$(XRICKBUILDDIR)/%.o: $(XRICKSRCDIR)/%.c
|
||||
$(SILENT)mkdir -p $(dir $@)
|
||||
$(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(XRICKCFLAGS) -c $< -o $@
|
127
docs/CREDITS
127
docs/CREDITS
|
@ -8,7 +8,7 @@
|
|||
|
||||
People that have contributed to the project, one way or another. Friends!
|
||||
|
||||
Björn Stenberg
|
||||
Björn Stenberg
|
||||
Linus Nielsen Feltzing
|
||||
Andy Choi
|
||||
Andrew Jamieson
|
||||
|
@ -20,17 +20,17 @@ Gary Czvitkovicz
|
|||
Stuart Martin
|
||||
Felix Arends
|
||||
Ulf Ralberg
|
||||
David Härdeman
|
||||
David Härdeman
|
||||
Thomas Saeys
|
||||
Grant Wier
|
||||
Julien Labruyére
|
||||
Julien Labruyére
|
||||
Nicolas Sauzede
|
||||
Robert Hak
|
||||
Dave Chapman
|
||||
Stefan Meyer
|
||||
Eric Linenberg
|
||||
Tom Cvitan
|
||||
Magnus Öman
|
||||
Magnus Öman
|
||||
Jerome Kuptz
|
||||
Julien Boissinot
|
||||
Nuutti Kotivuori
|
||||
|
@ -59,14 +59,14 @@ Kjell Ericson
|
|||
Jim Hagani
|
||||
Ludovic Lange
|
||||
Mike Holden
|
||||
Simon Elén
|
||||
Simon Elén
|
||||
Matthew P. O'Reilly
|
||||
Christian Schönberger
|
||||
Christian Schönberger
|
||||
Henrik Backe
|
||||
Craig Sather
|
||||
José Maria Garcia-Valdecasas Bernal
|
||||
José Maria Garcia-Valdecasas Bernal
|
||||
Stevie Oh
|
||||
Jörg Hohensohn
|
||||
Jörg Hohensohn
|
||||
Dave Jones
|
||||
Thomas Paul Diffenbach
|
||||
Roland Kletzing
|
||||
|
@ -96,7 +96,7 @@ Jiri Jurecek
|
|||
Jacob Erlbeck
|
||||
Jean-Philippe Bernardy
|
||||
Dave Hooper
|
||||
Jonas Häggqvist
|
||||
Jonas Häggqvist
|
||||
Thom Johansen
|
||||
Rinat Zakirov
|
||||
Manuel Dejonghe
|
||||
|
@ -105,12 +105,12 @@ Michiel van der Kolk
|
|||
Tony Motakis
|
||||
Andy Young
|
||||
Alexandre Bourget
|
||||
Richard S. La Charité III
|
||||
Richard S. La Charité III
|
||||
Christian Gmeiner
|
||||
Tomas Salfischberger
|
||||
Miika Pekkarinen
|
||||
Tapio Karppinen
|
||||
Richard Ottó O'Brien
|
||||
Richard Ottó O'Brien
|
||||
Luca Burelli
|
||||
Alessio Lenzi
|
||||
David Bryant
|
||||
|
@ -126,9 +126,9 @@ Hristo Kovachev
|
|||
Sander Sweers
|
||||
Antonius Hellman
|
||||
Ryan Jackson
|
||||
Per Holmäng
|
||||
Per Holmäng
|
||||
Frederic Devernay
|
||||
José M. Fandiño
|
||||
José M. Fandiño
|
||||
Gadi Cohen
|
||||
Naftali Goldstein
|
||||
David Dent
|
||||
|
@ -171,19 +171,19 @@ Mikael Magnusson
|
|||
Dominik Wenger
|
||||
Henrico Witvliet
|
||||
Andrew Scott
|
||||
Miguel A. Arévalo
|
||||
Miguel A. Arévalo
|
||||
Aaron F. Gonzalez
|
||||
Aleksey Kozyulin
|
||||
Jani Kinnunen
|
||||
Rui Marinho
|
||||
Alun Thomas
|
||||
Nils Wallménius
|
||||
Nils Wallménius
|
||||
Naoaki Okazaki
|
||||
Will Dyson
|
||||
Matthias Mohr
|
||||
Christian Marg
|
||||
Eli Sherer
|
||||
Fredrik Öhrn
|
||||
Fredrik Öhrn
|
||||
Nicolas Pennequin
|
||||
Ralf Herz
|
||||
Michael DiFebbo
|
||||
|
@ -204,18 +204,18 @@ Frederik Vestre
|
|||
Wenbin Leo
|
||||
Tom Evans
|
||||
Ewan Davies
|
||||
Frédéric François
|
||||
Marc-André Moreau
|
||||
Frédéric François
|
||||
Marc-André Moreau
|
||||
Ioannis Koutoulakis
|
||||
Alistair Marshall
|
||||
Karl Ove Hufthammer
|
||||
Víctor Zabalza
|
||||
Víctor Zabalza
|
||||
Ulrich Pegelow
|
||||
Andreas Mattsson
|
||||
Daniel Ankers
|
||||
Paul Louden
|
||||
Rainer Sinsch
|
||||
Plácido Revilla
|
||||
Plácido Revilla
|
||||
Michael Sevakis
|
||||
Lukas Sabota
|
||||
Emanuel Zephir
|
||||
|
@ -243,13 +243,13 @@ Robert Kukla
|
|||
David Quesada
|
||||
Jared Stafford
|
||||
Martin Hensel
|
||||
Stéphane Doyon
|
||||
Stéphane Doyon
|
||||
Austin Appel
|
||||
Andre Smith
|
||||
Travis Hyyppa
|
||||
Ian Webber
|
||||
Pavel Gnelitsa
|
||||
Lutz Böhne
|
||||
Lutz Böhne
|
||||
Will Robertson
|
||||
Robert Carboneau
|
||||
Ye Wei
|
||||
|
@ -259,13 +259,13 @@ Chris Taylor
|
|||
Tobias Langhoff
|
||||
Steve Gotthardt
|
||||
Greg White
|
||||
Mattieu Favréaux
|
||||
Mattieu Favréaux
|
||||
Malcolm Tyrrell
|
||||
Piotr Jafiszow
|
||||
Gary Allen
|
||||
John BouAntoun
|
||||
Tomasz Mon
|
||||
Jakub Matoušek
|
||||
Jakub Matou?ek
|
||||
Albert Veli
|
||||
Chris Dohan
|
||||
Takashi Obara
|
||||
|
@ -276,7 +276,7 @@ Sean Morrisey
|
|||
Shay Green
|
||||
Nick Vanderweit
|
||||
Simon Menzel
|
||||
Timo Horstschäfer
|
||||
Timo Horstschäfer
|
||||
Jacco Koning
|
||||
Chris Ham
|
||||
Jose Ramon Garcia
|
||||
|
@ -335,7 +335,7 @@ Alexander Eickhoff
|
|||
Ken Fazzone
|
||||
David Bishop
|
||||
Hein-Pieter van Braam
|
||||
Przemysław Hołubowski
|
||||
Przemys?aw Ho?ubowski
|
||||
Stepan Moskovchenko
|
||||
John S. Gwynne
|
||||
Brian J. Morey
|
||||
|
@ -343,12 +343,12 @@ Stijn Hisken
|
|||
Bertrik Sikken
|
||||
Karim Boucher
|
||||
James Espinoza
|
||||
Franz Rühmland
|
||||
Franz Rühmland
|
||||
Jordan Anderson
|
||||
Maurus Cuelenaere
|
||||
Chris Allegretta
|
||||
Alastair S
|
||||
Martin Crkovský
|
||||
Martin Crkovský
|
||||
Ariya Hidayat
|
||||
Jonas Hurrelmann
|
||||
Lee Kang Hyuk
|
||||
|
@ -356,7 +356,7 @@ Clemens Werther
|
|||
Robert Menes
|
||||
Henri Valta
|
||||
Melba Sitjar
|
||||
Mehmet Ş. Çatalbaş
|
||||
Mehmet ?. Çatalba?
|
||||
Scott Tinman
|
||||
Alexander Kuzmenkov
|
||||
Thomas Martitz
|
||||
|
@ -366,7 +366,7 @@ Apoorva Mahajan
|
|||
Vuong Minh Hiep
|
||||
Mateusz Kubica
|
||||
Frank Gevaerts
|
||||
Chelo Sacristán
|
||||
Chelo Sacristán
|
||||
Sascha Wolf
|
||||
Nickolay Jordanov
|
||||
Johannes Voggenthaler
|
||||
|
@ -380,7 +380,7 @@ Ivan Pesic
|
|||
Marcel Barbulescu
|
||||
Phil Light
|
||||
Rob Purchase
|
||||
Andreas Müller
|
||||
Andreas Müller
|
||||
Christopher Williams
|
||||
Martin Ritter
|
||||
Justin Hannigan
|
||||
|
@ -409,39 +409,39 @@ Shunsuke Shimizu
|
|||
Tadayuki Nishizono
|
||||
Jun Gu
|
||||
Daniel Weck
|
||||
Clément Pit-Claudel
|
||||
Clément Pit-Claudel
|
||||
Jelle Geerts
|
||||
Tadeusz Pyś
|
||||
Tadeusz Py?
|
||||
Rostislav Chekan
|
||||
Florin Popescu
|
||||
Volker Mische
|
||||
Vitja Makarov
|
||||
Francisco Vila
|
||||
Christian Lees
|
||||
Rafaël Carré
|
||||
Rafaël Carré
|
||||
Denes Balatoni
|
||||
Roy Wallace
|
||||
Eric Lassauge
|
||||
François Dinel
|
||||
François Dinel
|
||||
Francesco Rigoni
|
||||
Joël Puik
|
||||
Joël Puik
|
||||
Klaas Bosteels
|
||||
Teruaki Kawashima
|
||||
Marcin Łukasik
|
||||
Marcin ?ukasik
|
||||
Le Jin
|
||||
Alex Bennee
|
||||
Stéphane Quertinmont
|
||||
Stéphane Quertinmont
|
||||
Bartosz Fabianowski
|
||||
Adam Hogan
|
||||
Andrew Mahone
|
||||
Anton Veretenenko
|
||||
Vicente Ibarra
|
||||
Rui Araújo
|
||||
Rui Araújo
|
||||
Brian Cloutier
|
||||
Olivier Barbut
|
||||
Yoshihisa Uchida
|
||||
Sanggon Lee
|
||||
Kaspar Rothenfußer
|
||||
Kaspar Rothenfußer
|
||||
Ryan Press
|
||||
Craig Elliott
|
||||
Kenderes Tamas
|
||||
|
@ -453,7 +453,7 @@ Gareth Schakel
|
|||
Brian Sutherland
|
||||
Sam Bouwer
|
||||
Johannes Linke
|
||||
Michaël Burtin
|
||||
Michaël Burtin
|
||||
Sasha Khamkov
|
||||
Kai Posadowsky
|
||||
Jack Halpin
|
||||
|
@ -504,14 +504,14 @@ Yann Muller
|
|||
Sascha Wilde
|
||||
Fred Bauer
|
||||
Simon Rothen
|
||||
Pavel Rzehák
|
||||
Pavel Rzehák
|
||||
Diego Herranz
|
||||
Viktor Varga
|
||||
Juliusz Chroboczek
|
||||
Christian Beier
|
||||
Giovanni Zilli
|
||||
Shiloh Hawley
|
||||
Peter Lecký
|
||||
Peter Lecký
|
||||
Wilfred Hughes
|
||||
Laurent Gautier
|
||||
Simon Zhukovsky
|
||||
|
@ -528,36 +528,36 @@ Mark Borgerding
|
|||
Tobias Diedrich
|
||||
Andrew Engelbrecht
|
||||
Kevin Schoedel
|
||||
Jens Theeß
|
||||
Jens Theeß
|
||||
Alexey Nemtsev
|
||||
Pascal Below
|
||||
Danny Attar
|
||||
Philipp Stephani
|
||||
Tore Johnny Bråtveit
|
||||
Tore Johnny Bråtveit
|
||||
Marcin Bukat
|
||||
Andrew Rodland
|
||||
Luca Leonardo Scorcia
|
||||
Gerhard Zintel
|
||||
Adrián Cereto Massagué
|
||||
Adrián Cereto Massagué
|
||||
Chris Savery
|
||||
Raphaël Jakse
|
||||
Raphaël Jakse
|
||||
Wincent Balin
|
||||
Aaron Rothbaum
|
||||
Nejc Lotric
|
||||
Hinrik Örn Sigurðsson
|
||||
Hinrik Örn Sigurðsson
|
||||
Stephen Carroll
|
||||
Joe Balough
|
||||
Jérôme Heil
|
||||
Jérôme Heil
|
||||
Tim Graf
|
||||
Martin Sägmüller
|
||||
Martin Sägmüller
|
||||
Joshua Hulst
|
||||
Pierre-Yves Roosens
|
||||
Hayden Pearce
|
||||
Rodrigo Barretto
|
||||
Daniel Rigby
|
||||
Alexey Polkhirev
|
||||
István Nagy
|
||||
Wojciech Leśniak
|
||||
István Nagy
|
||||
Wojciech Le?niak
|
||||
Tuomas Airaksinen
|
||||
Calvin Walden
|
||||
Michael Gentry
|
||||
|
@ -572,12 +572,12 @@ Craig Mann
|
|||
William Peters
|
||||
Li Jie
|
||||
Cristina Talpiga
|
||||
Ştefan Moisei
|
||||
?tefan Moisei
|
||||
Alexander Meshcheryakov
|
||||
Ryan Sawhill
|
||||
Thomas Jarosch
|
||||
Will Sowerbutts
|
||||
Łukasz Stelmach
|
||||
?ukasz Stelmach
|
||||
Gabriel Maia
|
||||
Robert Horn
|
||||
Ante Maretic
|
||||
|
@ -586,12 +586,12 @@ Uwe Wiebach
|
|||
Mikhail Titov
|
||||
Dave Slusher
|
||||
Jean-Marie Moraux
|
||||
Ismael Castiñeira Álvarez
|
||||
Mārtiņš Šimis
|
||||
Ismael Castiñeira Álvarez
|
||||
M?rti?? ?imis
|
||||
Huan Zhang
|
||||
Leif Andersen
|
||||
Sergiu Rotaru
|
||||
Noé Lojkine
|
||||
Noé Lojkine
|
||||
Ophir Lojkine
|
||||
Stephan Grossklass
|
||||
John Morris
|
||||
|
@ -616,7 +616,7 @@ Artur Juraszek
|
|||
Wieland Hoffmann
|
||||
Nathan Korth
|
||||
Igor Petelin
|
||||
Cástor Muñoz
|
||||
Cástor Muñoz
|
||||
Albert Barca
|
||||
Fukuda Takafumi
|
||||
Dimitar Dimitrov
|
||||
|
@ -649,8 +649,8 @@ Semyon Zhukovsky
|
|||
Kostadin Kolev
|
||||
Jordi Prenafeta
|
||||
Tiago Medeiros
|
||||
Udo Schläpfer
|
||||
Åka Sikrom
|
||||
Udo Schläpfer
|
||||
Åka Sikrom
|
||||
Thomas White
|
||||
Karl Huber
|
||||
Adam Sampson
|
||||
|
@ -685,15 +685,16 @@ Martin Buck
|
|||
Stefan Ott
|
||||
David Chionne
|
||||
Wilfried Winkler
|
||||
Johannes König
|
||||
Johannes König
|
||||
Alexander Drammen
|
||||
Kei Miyamoto
|
||||
James D. Smith
|
||||
Howard Richardson
|
||||
Aurélien Coudurier
|
||||
Sylvain Saubier
|
||||
Adrián Tinoco
|
||||
Boris Kovačević
|
||||
Stéphane Moutard-Martin
|
||||
Stéphane Moutard-Martin
|
||||
Rune Pade
|
||||
Michael Rey
|
||||
Yuxuan Shui
|
||||
|
@ -720,6 +721,7 @@ JJ Style
|
|||
Jerry Chapman
|
||||
Leander Lismond
|
||||
Eren Akpolat
|
||||
Pierluigi Vicinanza
|
||||
|
||||
The libmad team
|
||||
The wavpack team
|
||||
|
@ -761,3 +763,4 @@ The bsdiff team
|
|||
The libtomcrypt team
|
||||
The microtar team (rxi and others)
|
||||
The UnifontEX and GNU Unifont teams
|
||||
The XRick team
|
||||
|
|
BIN
manual/plugins/images/ss-xrick-220x176x16.png
Executable file
BIN
manual/plugins/images/ss-xrick-220x176x16.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
BIN
manual/plugins/images/ss-xrick-240x320x16.png
Executable file
BIN
manual/plugins/images/ss-xrick-240x320x16.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
BIN
manual/plugins/images/ss-xrick-320x240x16.png
Executable file
BIN
manual/plugins/images/ss-xrick-320x240x16.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
|
@ -111,8 +111,13 @@ text files%
|
|||
|
||||
\input{plugins/xobox.tex}
|
||||
|
||||
\opt{lcd_non-mono}{\input{plugins/xrick.tex}}
|
||||
|
||||
\opt{lcd_color}{\input{plugins/xworld.tex}}
|
||||
|
||||
|
||||
|
||||
|
||||
\section{Demos}
|
||||
|
||||
\input{plugins/bounce.tex}
|
||||
|
|
107
manual/plugins/xrick.tex
Executable file
107
manual/plugins/xrick.tex
Executable file
|
@ -0,0 +1,107 @@
|
|||
% $Id$ %
|
||||
\subsection{xrick}
|
||||
\screenshot{plugins/images/ss-xrick}{xrick}{img:xrick}
|
||||
xrick is a clone of the platform game
|
||||
\emph{'Rick Dangerous'}
|
||||
(\url{http://en.wikipedia.org/wiki/Rick_Dangerous}),
|
||||
originally written by 'BigOrno'
|
||||
(\url{http://www.bigorno.net/xrick/}),
|
||||
modified and ported to Rockbox by Pierluigi Vicinanza
|
||||
(\url{https://github.com/pierluigi-vicinanza/xrick}).
|
||||
|
||||
Walk through the maps, avoid traps, kill the Bad Guys... and
|
||||
try to stay alive long enough to accomplish your mission!
|
||||
|
||||
Rick can fire bullets, lay sticks of dynamite, walk, crawl,
|
||||
climb, and also poke walls or Bad Guys with his stick.
|
||||
Poking walls can trigger traps, open doors, etc. although
|
||||
sometimes a dynamite stick or a bullet is needed.
|
||||
Go figure.
|
||||
|
||||
\subsubsection{Getting started}
|
||||
For the game to run you need \fname{.dat} game files located in
|
||||
\fname{/.rockbox/xrick} on your \dap.
|
||||
Create the directory and extract xrick \fname{data.zip} archive into it.
|
||||
The needed files can be found at
|
||||
\url{https://github.com/pierluigi-vicinanza/xrick/blob/master/game/data.zip}.
|
||||
|
||||
\subsubsection{Controls}
|
||||
By holding down \emph{Fire} and pressing \emph{Left} or \emph{Right},
|
||||
you can poke a wall (or anything else) with your stick.
|
||||
By holding down \emph{Fire} and pressing \emph{Down}, you can lay a stick of dynamite.
|
||||
By holding down \emph{Fire} and pressing \emph{Up}, you can fire a bullet.
|
||||
|
||||
Throughout the game, use these buttons to control Rick:
|
||||
|
||||
\begin{btnmap}
|
||||
%
|
||||
\opt{iriverh300}{\ButtonUp/\ButtonRec}
|
||||
\opt{fuzeplus}{\ButtonUp}
|
||||
\opt{ipodvideo}{\ButtonMenu}
|
||||
\nopt{iriverh300,fuzeplus,ipodvideo}{\PluginUp}
|
||||
\opt{HAVEREMOTEKEYMAP}{& }
|
||||
& Jump or Climb Up\\
|
||||
%
|
||||
\opt{fuzeplus}{\ButtonPlay & Jump Right or Climb Up and Right\\}
|
||||
%
|
||||
\opt{fuzeplus}{\ButtonBack & Jump Left or Climb Up and Left\\}
|
||||
%
|
||||
\opt{iriverh300}{\ButtonDown/\ButtonMode}
|
||||
\opt{fuzeplus}{\ButtonDown}
|
||||
\opt{ipodvideo}{\ButtonPlay}
|
||||
\nopt{iriverh300,fuzeplus,ipodvideo}{\PluginDown}
|
||||
\opt{HAVEREMOTEKEYMAP}{& }
|
||||
& Crouch or Climb Down\\
|
||||
%
|
||||
\opt{fuzeplus}{\ButtonBottomRight & Crouch and Move Right or Climb Down and Right\\}
|
||||
%
|
||||
\opt{fuzeplus}{\ButtonBottomLeft & Crouch and Move Left or Climb Down and Left\\}
|
||||
%
|
||||
\opt{iriverh300,fuzeplus,ipodvideo}{\ButtonLeft}
|
||||
\nopt{iriverh300,fuzeplus,ipodvideo}{\PluginLeft}
|
||||
\opt{HAVEREMOTEKEYMAP}{& }
|
||||
& Move Left\\
|
||||
%
|
||||
\opt{iriverh300,fuzeplus,ipodvideo}{\ButtonRight}
|
||||
\nopt{iriverh300,fuzeplus,ipodvideo}{\PluginRight}
|
||||
\opt{HAVEREMOTEKEYMAP}{& }
|
||||
& Move Right\\
|
||||
%
|
||||
\opt{iriverh300}{\ButtonOn}
|
||||
\opt{fuzeplus}{\ButtonVolDown}
|
||||
\opt{ipodvideo}{\ButtonSelect}
|
||||
\nopt{iriverh300,fuzeplus,ipodvideo}{\PluginSelect}
|
||||
|
||||
\opt{HAVEREMOTEKEYMAP}{& }
|
||||
& Fire\\
|
||||
%
|
||||
\opt{iriverh300}{\ButtonSelect}
|
||||
\opt{fuzeplus}{\ButtonVolUp}
|
||||
\opt{ipodvideo}{\ButtonScrollBack}
|
||||
\nopt{iriverh300,fuzeplus,ipodvideo}{\PluginCancel}
|
||||
\opt{HAVEREMOTEKEYMAP}{& }
|
||||
& Pause\\
|
||||
%
|
||||
\opt{iriverh300}{\ButtonOff}
|
||||
\opt{fuzeplus}{\ButtonPower}
|
||||
\opt{ipodvideo}{\ButtonScrollFwd}
|
||||
\nopt{iriverh300,fuzeplus,ipodvideo}{\PluginExit}
|
||||
\opt{hold_button}{/\ButtonHold}
|
||||
\opt{HAVEREMOTEKEYMAP}{& }
|
||||
& Menu\\
|
||||
%
|
||||
\end{btnmap}
|
||||
|
||||
\subsubsection{Menu}
|
||||
\begin{description}
|
||||
\item[Resume Game. ] Resume the game
|
||||
\item[Restart Game. ] Restart the game
|
||||
\item[Cheat Settings. ] This menu has the following options:
|
||||
|
||||
\emph{Enable Unlimited Lives/Ammo Mode. } Toggle trainer mode (always six bullets, six sticks, six Rick).\\
|
||||
\emph{Enable Never Die Mode. } Toggle 'never die' mode (nothing can kill Rick). Use with care.
|
||||
Although it lets you walk through Bad Guys unharmed, it can produce strange results.\\
|
||||
\emph{Enable Expose Mode. } Toggle 'expose' mode (see all entities).%\\
|
||||
|
||||
\item[Quit. ] Quit the game
|
||||
\end{description}
|
|
@ -49,6 +49,7 @@ const static struct {
|
|||
{ PlayerBuildInfo::PuzzFontsUrl, "other/puzzfonts_url" },
|
||||
{ PlayerBuildInfo::QuakeUrl, "other/quake_url" },
|
||||
{ PlayerBuildInfo::Wolf3DUrl, "other/wolf3d_url" },
|
||||
{ PlayerBuildInfo::XRickUrl, "other/xrick_url" },
|
||||
{ PlayerBuildInfo::XWorldUrl, "other/xworld_url" },
|
||||
{ PlayerBuildInfo::MidiPatchsetUrl, "other/patcheset_url" },
|
||||
};
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
QuakeUrl,
|
||||
Wolf3DUrl,
|
||||
XWorldUrl,
|
||||
XRickUrl,
|
||||
MidiPatchsetUrl,
|
||||
};
|
||||
enum DeviceInfo {
|
||||
|
|
|
@ -610,6 +610,7 @@ static const struct {
|
|||
{ "Quake", "games/quake.rock", PlayerBuildInfo::QuakeUrl },
|
||||
{ "Puzzles fonts", "games/sgt-blackbox.rock", PlayerBuildInfo::PuzzFontsUrl },
|
||||
{ "Wolf3D", "games/wolf3d.rock", PlayerBuildInfo::Wolf3DUrl },
|
||||
{ "XRick", "games/xrick.rock", PlayerBuildInfo::XRickUrl },
|
||||
{ "XWorld", "games/xworld.rock", PlayerBuildInfo::XWorldUrl },
|
||||
{ "MIDI Patchset", "viewers/midi.rock", PlayerBuildInfo::MidiPatchsetUrl },
|
||||
};
|
||||
|
|
|
@ -14,6 +14,7 @@ quake_url=https://download.rockbox.org/useful/quake.zip
|
|||
puzzfonts_url=https://download.rockbox.org/useful/sgt-fonts.zip
|
||||
wolf3d_url=https://download.rockbox.org/useful/wolf3d.zip
|
||||
xworld_url=https://download.rockbox.org/useful/xworld.zip
|
||||
xrick_url=https://download.rockbox.org/useful/xrick-data.zip
|
||||
rbutil_url=https://download.rockbox.org/rbutil/
|
||||
|
||||
[bootloader]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue