added GDash source files prepared for game engine integration into R'n'D
[rocksndiamonds.git] / src / game_bd / main_bd.c
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2024 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // main_bd.c
10 // ============================================================================
11
12 #include "main_bd.h"
13
14
15 struct GameInfo_BD game_bd;
16 struct LevelInfo_BD native_bd_level;
17 struct EngineSnapshotInfo_BD engine_snapshot_bd;
18
19
20 // ============================================================================
21 // level file functions
22 // ============================================================================
23
24 int map_action_RND_to_BD(int action)
25 {
26   GdDirection player_move = gd_direction_from_keypress(action & JOY_UP,
27                                                        action & JOY_DOWN,
28                                                        action & JOY_LEFT,
29                                                        action & JOY_RIGHT);
30   boolean player_fire = (action & (JOY_BUTTON_1 | JOY_BUTTON_2));
31
32   return (player_move | (player_fire ? GD_REPLAY_FIRE_MASK : 0));
33 }
34
35 int map_action_BD_to_RND(int action)
36 {
37   GdDirection player_move = action & GD_REPLAY_MOVE_MASK;
38   boolean     player_fire = action & GD_REPLAY_FIRE_MASK;
39
40   int action_move = (player_move == GD_MV_UP            ? JOY_UP                :
41                      player_move == GD_MV_UP_RIGHT      ? JOY_UP   | JOY_RIGHT  :
42                      player_move == GD_MV_RIGHT         ?            JOY_RIGHT  :
43                      player_move == GD_MV_DOWN_RIGHT    ? JOY_DOWN | JOY_RIGHT  :
44                      player_move == GD_MV_DOWN          ? JOY_DOWN              :
45                      player_move == GD_MV_DOWN_LEFT     ? JOY_DOWN | JOY_LEFT   :
46                      player_move == GD_MV_LEFT          ?            JOY_LEFT   :
47                      player_move == GD_MV_UP_LEFT       ? JOY_UP   | JOY_LEFT   : JOY_NO_ACTION);
48   int action_fire = (player_fire ? JOY_BUTTON_1 : JOY_NO_ACTION);
49
50   return (action_move | action_fire);
51 }
52
53 boolean checkGameRunning_BD(void)
54 {
55   return (game_bd.game != NULL && game_bd.game->state_counter == GAME_INT_CAVE_RUNNING);
56 }
57
58 void setLevelInfoToDefaults_BD_Ext(int width, int height)
59 {
60   // ...
61 }
62
63 void setLevelInfoToDefaults_BD(void)
64 {
65   setLevelInfoToDefaults_BD_Ext(0, 0);
66 }