X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_bd%2Fmain_bd.c;h=fdc5cf0c0a6350f576ac309400ad14bb768536e7;hb=dc7bcae20949adb40e3bf797eab98ecb286a2453;hp=efaa78f40a127a40b5ceb76d7f24c0a1441af0ec;hpb=6e1c81b564b748d54aadb2a79235c8fbe3483677;p=rocksndiamonds.git diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index efaa78f4..fdc5cf0c 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -18,43 +18,42 @@ struct EngineSnapshotInfo_BD engine_snapshot_bd; // ============================================================================ -// level file functions +// initialization functions // ============================================================================ -int map_action_RND_to_BD(int action) +void InitGfxBuffers_BD(void) { - GdDirection player_move = gd_direction_from_keypress(action & JOY_UP, - action & JOY_DOWN, - action & JOY_LEFT, - action & JOY_RIGHT); - boolean player_fire = (action & (JOY_BUTTON_1 | JOY_BUTTON_2)); + ReCreateBitmap(&gd_screen_bitmap, SXSIZE, SYSIZE); - return (player_move | (player_fire ? GD_REPLAY_FIRE_MASK : 0)); + set_cell_size(TILESIZE_VAR); + set_play_area(SXSIZE, SYSIZE); } -int map_action_BD_to_RND(int action) +void bd_open_all(void) { - GdDirection player_move = action & GD_REPLAY_MOVE_MASK; - boolean player_fire = action & GD_REPLAY_FIRE_MASK; + InitGraphicInfo_BD(); - int action_move = (player_move == GD_MV_UP ? JOY_UP : - player_move == GD_MV_UP_RIGHT ? JOY_UP | JOY_RIGHT : - player_move == GD_MV_RIGHT ? JOY_RIGHT : - player_move == GD_MV_DOWN_RIGHT ? JOY_DOWN | JOY_RIGHT : - player_move == GD_MV_DOWN ? JOY_DOWN : - player_move == GD_MV_DOWN_LEFT ? JOY_DOWN | JOY_LEFT : - player_move == GD_MV_LEFT ? JOY_LEFT : - player_move == GD_MV_UP_LEFT ? JOY_UP | JOY_LEFT : JOY_NO_ACTION); - int action_fire = (player_fire ? JOY_BUTTON_1 : JOY_NO_ACTION); + gd_cave_init(); + gd_cave_db_init(); - return (action_move | action_fire); + gd_c64_import_init_tables(); + + gd_caveset_clear(); + + gd_init_keystate(); + + gd_sound_init(); } -boolean checkGameRunning_BD(void) +void bd_close_all(void) { - return (game_bd.game != NULL && game_bd.game->state_counter == GAME_INT_CAVE_RUNNING); } + +// ============================================================================ +// level file functions +// ============================================================================ + void setLevelInfoToDefaults_BD_Ext(int width, int height) { GdCave *cave = native_bd_level.cave; @@ -149,3 +148,55 @@ boolean LoadNativeLevel_BD(char *filename, int level_pos, boolean level_info_onl return TRUE; } + + +// ============================================================================ +// game engine functions +// ============================================================================ + +int map_action_RND_to_BD(int action) +{ + GdDirection player_move = gd_direction_from_keypress(action & JOY_UP, + action & JOY_DOWN, + action & JOY_LEFT, + action & JOY_RIGHT); + boolean player_fire = (action & (JOY_BUTTON_1 | JOY_BUTTON_2)); + + return (player_move | (player_fire ? GD_REPLAY_FIRE_MASK : 0)); +} + +int map_action_BD_to_RND(int action) +{ + GdDirection player_move = action & GD_REPLAY_MOVE_MASK; + boolean player_fire = action & GD_REPLAY_FIRE_MASK; + + int action_move = (player_move == GD_MV_UP ? JOY_UP : + player_move == GD_MV_UP_RIGHT ? JOY_UP | JOY_RIGHT : + player_move == GD_MV_RIGHT ? JOY_RIGHT : + player_move == GD_MV_DOWN_RIGHT ? JOY_DOWN | JOY_RIGHT : + player_move == GD_MV_DOWN ? JOY_DOWN : + player_move == GD_MV_DOWN_LEFT ? JOY_DOWN | JOY_LEFT : + player_move == GD_MV_LEFT ? JOY_LEFT : + player_move == GD_MV_UP_LEFT ? JOY_UP | JOY_LEFT : JOY_NO_ACTION); + int action_fire = (player_fire ? JOY_BUTTON_1 : JOY_NO_ACTION); + + return (action_move | action_fire); +} + +boolean checkGameRunning_BD(void) +{ + return (game_bd.game != NULL && game_bd.game->state_counter == GAME_INT_CAVE_RUNNING); +} + +unsigned int InitEngineRandom_BD(int seed) +{ + if (seed == NEW_RANDOMIZE) + { + // get randomly selected seed to render the cave + seed = g_random_int_range(0, GD_CAVE_SEED_MAX); + } + + game_bd.random_seed = seed; + + return (unsigned int)seed; +}