Browse Source

Add demos and main menu (only some options work, currently)

master
Alec Murphy 2 years ago
parent
commit
66964416db
  1. 1
      Actor_WorkType.HC
  2. 46
      Demo.HC
  3. 21
      Dialog.HC
  4. 38
      Game.HC
  5. 32
      Input.HC
  6. 51
      Main.HC
  7. 1
      Run.HC

1
Actor_WorkType.HC

@ -1,5 +1,4 @@
extern U0 actor_add_new(I64 image_index, I64 x_pos, I64 y_pos);
extern I64 game_play_mode;
extern U0 map_write_tile_cell(U16 map_tile_cell, I64 x, I64 y);
extern U0 map_write_row_of_tiles(U16 map_tile_cell, U16 length_in_tiles, I64 x, I64 y);
extern U8 byte_2E21C;

46
Demo.HC

@ -0,0 +1,46 @@
U16 demo_input_index = 0;
U16 demo_input_length = 0;
U8 *demo_data = NULL;
U0 load_demo()
{
demo_input_index = 0;
demo_input_length = 0;
if(demo_data)
{
Free(demo_data);
}
U32 file_size;
demo_data = load_file_in_new_buf("PREVDEMO.MNI", &file_size);
if(!demo_data)
{
"Error: Loading demo data.\n";
return;
}
demo_input_length = (file_size - 2);
}
U8 read_input_from_demo()
{
if(demo_input_index >= demo_input_length)
{
return 1;
}
U8 input = demo_data[demo_input_index + 2];
demo_input_index++;
left_key_pressed = (input & 1);
right_key_pressed = ((input >> 1) & 1);
up_key_pressed = ((input >> 2) & 1);
down_key_pressed = ((input >> 3) & 1);
jump_key_pressed = ((input >> 4) & 1);
bomb_key_pressed = ((input >> 5) & 1);
finished_level_flag_maybe = ((input >> 6) & 1);
return 0;
}

21
Dialog.HC

@ -9,18 +9,11 @@ extern U0 fade_in_from_black_with_delay_3();
extern U0 fade_to_white(U16 wait_time);
extern U0 fade_in_from_black(U16 wait_time);
#define SDLK_UP 1
#define SDLK_DOWN 2
#define SDLK_LEFT 3
#define SDLK_RIGHT 4
#define PLAY_GAME 0
#define PLAY_DEMO 1
#define RECORD_DEMO 2
#define QUIT_GAME 3
class MenuItem {
U16 x_pos;
U16 y_pos;
@ -237,7 +230,7 @@ I64 wait_for_input_with_repeat(I64 spinner_x, I64 spinner_y, Bool allow_key_repe
U16 spinner_idx = 0;
I64 keycode = poll_for_key_press(allow_key_repeat);
while(keycode == SDLK_UNKNOWN && !Bt(kbd.down_bitmap, SC_ESC))
while(keycode == SDLK_UNKNOWN && !keys_down())
{
//Draw spinning cursor
video_draw_tile(map_get_bg_tile(1987+spinner_idx), spinner_x * TILE_WIDTH, spinner_y * TILE_HEIGHT);
@ -542,7 +535,7 @@ I64 main_menu() {
Bool key_handled = FALSE;
I64 key;
for(i=0;i=i;i+=3)
for(i=0;i==i;i+=3)
{
if (Bt(kbd.down_bitmap, Char2ScanCode('q')) || Bt(kbd.down_bitmap, SC_ESC))
{
@ -552,6 +545,8 @@ I64 main_menu() {
}
}
U16 restore_status = 0;
if (keys_down)
{
for(return_to_title=0;!return_to_title;)
{
main_menu_dialog();
@ -675,8 +670,9 @@ I64 main_menu() {
if (Bt(kbd.down_bitmap, Char2ScanCode('c')))
{
display_fullscreen_image(2);
while(poll_for_key_press(FALSE)==SDLK_UNKNOWN)
{}
while (!keys_down()) Sleep(1);
return_to_title = 1;
i = 0;
}
//break;
@ -695,7 +691,8 @@ I64 main_menu() {
if (i<600) display_fullscreen_image(1);
}
}
}
if(i==600)
{
display_fullscreen_image(2);

38
Game.HC

@ -265,14 +265,13 @@ Bool executeTick() {
update_palette_anim();
input_state = read_input();
//if (input_state == QUIT) {
// return FALSE;
//}
//if (input_state == PAUSED) {
// return TRUE;
//}
if (input_state == QUIT) {
return FALSE;
}
if (input_state == PAUSED) {
return TRUE;
}
handle_player_input_maybe();
if (player_hoverboard_counter != 0)
@ -352,10 +351,31 @@ U0 game_wait()
U0 game_loop()
{
while (1)
while (executeTick())
{
executeTick();
game_wait();
}
}
U8 *load_file_in_new_buf(U8 *filename, U32 *file_size)
{
U8 *buf;
buf = vol_file_load(get_game_vol_filename(), filename, NULL, 0, file_size);
if(buf)
{
return buf;
}
return vol_file_load(get_game_stn_filename(), filename, NULL, 0, file_size);
}
U0 set_episode_number(U8 episode)
{
episode_number = episode;
}
U0 enable_quick_start_mode()
{
quick_start_mode = TRUE;
}

32
Input.HC

@ -1,3 +1,11 @@
extern U8 read_input_from_demo();
extern I64 game_play_mode;
#define PLAY_GAME 0
#define PLAY_DEMO 1
#define RECORD_DEMO 2
#define QUIT_GAME 3
//input_state_enum
#define QUIT 0
#define PAUSED 1
@ -37,6 +45,26 @@ U0 flush_input()
FifoI64Flush(kbd.scan_code_fifo);
}
Bool keys_down()
{
I64 i;
for (i=0; i<8; i++)
{
if (kbd.down_bitmap[i]) return TRUE;
}
return FALSE;
}
I64 handle_demo_input()
{
if (keys_down) return QUIT;
if(read_input_from_demo())
{
return QUIT;
}
return CONTINUE;
}
U0 reset_player_control_inputs()
{
up_key_pressed = 0;
@ -62,6 +90,10 @@ U0 wait_for_time_or_key(I64 delay_in_game_cycles)
I64 read_input()
{
if (game_play_mode == PLAY_DEMO)
{
return handle_demo_input();
}
if (Bt(kbd.down_bitmap, SC_CURSOR_UP))
{
up_key_pressed = 1;

51
Main.HC

@ -12,13 +12,10 @@ I64 cleanup_and_exit()
I64 main(...)
{
//load_config_from_command_line(argc, argv);
video_init();
Fs->draw_it = &video_draw_it;
game_init();
//audio_init();
video_fill_screen_with_black();
@ -27,47 +24,21 @@ I64 main(...)
U16 x = create_text_dialog_box(4, 13, 0x1a, "A game by", "Copyright (c) 1992");
display_dialog_text(x, 7, " Todd J Replogle");
display_dialog_text(x + 11, 9, "and");
display_dialog_text(x, 11, " Stephen A Hornback");
display_dialog_text(x, 11, "\xfd027 Stephen A Hornback\xfd004");
display_dialog_text(x, 13, " Version 1.20");
//wait_for_time_or_key(0x2bc);
//game_play_mode = main_menu();
show_one_moment_screen_flag = 1;
show_monster_attack_hint = 0;
//play_sfx(0x30);
set_initial_game_state();
game_play_mode = PLAY_GAME;
video_update;
wait_for_time_or_key(0x2bc);
//fade_to_black_speed_3();
/*
if(!is_quick_start())
{
//
}
else
{
game_play_mode = PLAY_GAME;
}
*/
game_play_mode = main_menu();
video_update;
while(game_play_mode != QUIT_GAME)
{
load_level(current_level);
//if(game_play_mode == PLAY_DEMO)
//{
// load_demo();
//}
if(game_play_mode == PLAY_DEMO)
{
load_demo();
}
//Spawn(&game_loop,,,2);
//while (1) { Sleep(1); };
game_loop();
//stop_music();
/*
@ -75,8 +46,8 @@ I64 main(...)
{
//show_high_scores();
}
game_play_mode = main_menu();
*/
game_play_mode = main_menu();
}
//stop_music();
@ -84,10 +55,6 @@ I64 main(...)
return cleanup_and_exit();
}
main;

1
Run.HC

@ -24,6 +24,7 @@
#include "Config";
#include "Game";
#include "Demo";
#include "Palette";
#include "Video";

Loading…
Cancel
Save