2018-12-16 13:34:03 +01:00
|
|
|
|
|
|
|
#ifndef GAME_H__
|
|
|
|
#define GAME_H__
|
|
|
|
|
|
|
|
#include "intern.h"
|
|
|
|
|
2018-12-16 15:28:52 +01:00
|
|
|
#define CHEATS_OBJECT_NO_HIT (1 << 0)
|
|
|
|
#define CHEATS_ONE_HIT_VINYL (1 << 1)
|
|
|
|
#define CHEATS_DECOR_NO_HIT (1 << 2)
|
|
|
|
#define CHEATS_UNLIMITED_VINYLS (1 << 3)
|
2018-12-16 16:44:02 +01:00
|
|
|
#define CHEATS_UNLIMITED_TIME (1 << 4)
|
2018-12-16 13:34:03 +01:00
|
|
|
|
|
|
|
extern struct options_t g_options;
|
|
|
|
|
|
|
|
#define TILEMAP_SCREEN_W GAME_SCREEN_W
|
|
|
|
#define TILEMAP_SCREEN_H (GAME_SCREEN_H - PANEL_H)
|
|
|
|
|
|
|
|
#define PANEL_H 24
|
|
|
|
|
|
|
|
#define SOUND_0 0
|
2019-06-01 15:24:36 +02:00
|
|
|
#define SOUND_1 1 /* monster knocked out */
|
|
|
|
#define SOUND_2 2 /* bouncing mushroom */
|
|
|
|
#define SOUND_3 3 /* decor hit */
|
|
|
|
#define SOUND_4 4 /* player hit */
|
|
|
|
#define SOUND_5 5 /* grab vinyl */
|
|
|
|
#define SOUND_8 8 /* no vinyl */
|
|
|
|
#define SOUND_9 9 /* throw vinyl */
|
|
|
|
#define SOUND_10 10 /* "rock,rock,rock and roll" */
|
2018-12-16 13:34:03 +01:00
|
|
|
#define SOUND_11 11
|
2019-06-01 15:24:36 +02:00
|
|
|
#define SOUND_14 14 /* player lost life */
|
|
|
|
#define SOUND_15 15 /* running out time */
|
2018-12-16 13:34:03 +01:00
|
|
|
|
|
|
|
struct object_t {
|
|
|
|
int16_t x_pos;
|
|
|
|
int16_t y_pos;
|
|
|
|
uint16_t spr_num;
|
|
|
|
union {
|
|
|
|
uint8_t b[2];
|
|
|
|
int16_t w;
|
|
|
|
const uint8_t *p;
|
2019-06-02 02:35:19 +02:00
|
|
|
} data[11];
|
2018-12-16 13:34:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PLAYER_FLAGS_STAIRS = 2,
|
|
|
|
PLAYER_FLAGS_FACING_LEFT = 4,
|
|
|
|
PLAYER_FLAGS_THROW_VINYL = 8,
|
|
|
|
PLAYER_FLAGS_POWERUP = 0x20,
|
|
|
|
PLAYER_FLAGS_JAKE = 0x80
|
|
|
|
};
|
|
|
|
|
2019-06-02 02:35:19 +02:00
|
|
|
#define player_obj_num(obj) (obj)->data[0].w
|
|
|
|
#define player_prev_spr_num(obj) (obj)->data[1].w
|
|
|
|
#define player_anim_data(obj) (obj)->data[2].p
|
|
|
|
#define player_idle_counter(obj) (obj)->data[3].b[0]
|
|
|
|
#define player_power(obj) (obj)->data[3].b[1]
|
|
|
|
#define player_x_delta(obj) (obj)->data[4].w
|
|
|
|
#define player_y_delta(obj) (obj)->data[5].w
|
|
|
|
#define player_flags(obj) (obj)->data[6].b[0]
|
|
|
|
#define player_jump_counter(obj) (obj)->data[6].b[1]
|
|
|
|
#define player_bounce_counter(obj) (obj)->data[7].b[0]
|
|
|
|
#define player_tilemap_offset(obj) (obj)->data[8].w
|
|
|
|
#define player_hit_counter(obj) (obj)->data[9].b[0]
|
|
|
|
#define player_throw_counter(obj) (obj)->data[9].b[1]
|
|
|
|
#define player_flags2(obj) (obj)->data[10].b[0]
|
|
|
|
|
|
|
|
#define object_blinking_counter(obj) (obj)->data[6].b[1]
|
2018-12-16 13:34:03 +01:00
|
|
|
|
2019-06-01 15:24:36 +02:00
|
|
|
/* star */
|
2018-12-16 13:34:03 +01:00
|
|
|
#define object2_spr_count(obj) (obj)->data[0].b[0]
|
|
|
|
#define object2_spr_tick(obj) (obj)->data[0].b[1]
|
|
|
|
|
2019-06-01 15:24:36 +02:00
|
|
|
/* vinyl */
|
2018-12-16 13:34:03 +01:00
|
|
|
#define object22_xvelocity(obj) (obj)->data[0].w
|
|
|
|
#define object22_damage(obj) (obj)->data[1].w
|
|
|
|
#define object22_player_num(obj) (obj)->data[2].w
|
|
|
|
|
2019-06-01 15:24:36 +02:00
|
|
|
/* crate */
|
2018-12-16 13:34:03 +01:00
|
|
|
#define object64_counter(obj) (obj)->data[1].w
|
|
|
|
#define object64_yvelocity(obj) (obj)->data[2].w
|
|
|
|
|
2019-06-01 15:24:36 +02:00
|
|
|
/* monster */
|
2018-12-16 13:34:03 +01:00
|
|
|
#define object82_state(obj) (obj)->data[0].b[0]
|
|
|
|
#define object82_type(obj) (obj)->data[0].b[1]
|
|
|
|
#define object82_anim_data(obj) (obj)->data[1].p
|
|
|
|
#define object82_hflip(obj) (obj)->data[3].b[0]
|
|
|
|
#define object82_counter(obj) (obj)->data[3].b[1]
|
|
|
|
#define object82_x_delta(obj) (obj)->data[4].w
|
|
|
|
#define object82_y_delta(obj) (obj)->data[5].w
|
|
|
|
#define object82_energy(obj) (obj)->data[8].w
|
|
|
|
#define object82_type0_init_data(obj) (obj)->data[4].p
|
|
|
|
#define object82_type0_player_num(obj) (obj)->data[5].w
|
|
|
|
#define object82_type0_x_delta(obj) (obj)->data[6].b[0] // signed
|
|
|
|
#define object82_type0_y_delta(obj) (obj)->data[7].b[0] // signed
|
|
|
|
#define object82_type1_hdir(obj) (obj)->data[6].b[0] // signed
|
|
|
|
|
|
|
|
#define object102_x_delta(obj) (obj)->data[0].w
|
|
|
|
#define object102_y_delta(obj) (obj)->data[1].w
|
|
|
|
|
|
|
|
struct player_t {
|
|
|
|
struct object_t obj;
|
2019-06-02 02:35:19 +02:00
|
|
|
int16_t unk_counter;
|
2018-12-16 13:34:03 +01:00
|
|
|
int16_t change_hdir_counter;
|
|
|
|
uint8_t lifes_count;
|
|
|
|
int16_t vinyls_count;
|
|
|
|
int8_t energy;
|
2019-06-02 02:35:19 +02:00
|
|
|
uint8_t dir_mask;
|
|
|
|
uint8_t ticks_counter;
|
2018-12-16 13:34:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define TRIGGERS_COUNT 36
|
|
|
|
#define LEVELS_COUNT 30
|
|
|
|
#define OBJECTS_COUNT 165
|
2019-06-01 15:24:36 +02:00
|
|
|
/*
|
|
|
|
offset count
|
|
|
|
2 20 : animated tiles/vinyls
|
|
|
|
22 10 : vinyls
|
|
|
|
32 8*4 : (rotating) platforms
|
|
|
|
64 8 : crates
|
|
|
|
72 10 : bonuses spr_num:190
|
|
|
|
82 20 : monsters
|
|
|
|
102 10
|
|
|
|
112 9 : vertical bars
|
|
|
|
121 8 : dragon monster (level 26)
|
|
|
|
*/
|
2018-12-16 13:34:03 +01:00
|
|
|
|
|
|
|
struct vars_t {
|
|
|
|
int level;
|
|
|
|
int player;
|
|
|
|
bool input_keystate[128];
|
|
|
|
uint32_t timestamp;
|
2022-03-12 23:41:23 +01:00
|
|
|
uint8_t input_key_left, input_key_right, input_key_down, input_key_up, input_key_space, input_key_jump;
|
2019-06-01 15:24:36 +02:00
|
|
|
uint16_t buffer[128 * 2]; /* level objects state 0xFFFF, 0xFF20 or g_vars.objects_table index */
|
2018-12-16 13:34:03 +01:00
|
|
|
int16_t dragon_coords[1 + 128];
|
|
|
|
struct player_t players_table[2];
|
|
|
|
int16_t player_xscroll, player_map_offset;
|
|
|
|
struct object_t objects_table[OBJECTS_COUNT];
|
|
|
|
int level_start_1p_x_pos, level_start_1p_y_pos;
|
|
|
|
int level_start_2p_player1_x_pos, level_start_2p_player1_y_pos, level_start_2p_player2_x_pos, level_start_2p_player2_y_pos;
|
|
|
|
int level_loop_counter;
|
|
|
|
int throw_vinyl_counter;
|
|
|
|
uint8_t level_num;
|
|
|
|
uint16_t level_time, level_time2;
|
|
|
|
uint8_t level_time_counter;
|
|
|
|
uint8_t triggers_table[19 + TRIGGERS_COUNT * 16];
|
|
|
|
int tilemap_x, tilemap_y, tilemap_w, tilemap_h;
|
|
|
|
int tilemap_end_x, tilemap_end_y;
|
2018-12-16 16:44:02 +01:00
|
|
|
int tilemap_scroll_dx, tilemap_scroll_dy;
|
2018-12-16 13:34:03 +01:00
|
|
|
uint8_t *tilemap_data;
|
|
|
|
uint16_t level_pos_num;
|
|
|
|
uint8_t tilemap_type, tilemap_flags;
|
2019-06-01 15:24:36 +02:00
|
|
|
uint8_t tilemap_lut_type[0x100]; /* type:0,1,2 */
|
2018-12-16 13:34:03 +01:00
|
|
|
uint8_t tilemap_lut_init[6 * 0x100];
|
|
|
|
uint8_t tilemap_lut_init2[0x100];
|
|
|
|
const uint8_t *tilemap_current_lut;
|
|
|
|
uint8_t tile_palette_table[0x100];
|
|
|
|
const uint8_t *level_tiles_lut;
|
|
|
|
uint8_t palette_buffer[256 * 3];
|
|
|
|
bool change_next_level_flag;
|
|
|
|
bool reset_palette_flag;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct vars_t g_vars;
|
|
|
|
|
|
|
|
/* staticres.c */
|
|
|
|
extern const uint16_t sound_offsets[];
|
|
|
|
extern const uint16_t sprite_offsets[];
|
|
|
|
extern const uint16_t sprite_sizes[];
|
|
|
|
extern const uint8_t sprite_palettes[];
|
|
|
|
extern const uint8_t level_data1p[];
|
|
|
|
extern const uint8_t level_data2p[];
|
|
|
|
extern const uint8_t level_data3[];
|
2018-12-16 16:44:02 +01:00
|
|
|
extern const uint8_t vscroll_offsets_table[];
|
2018-12-16 16:46:16 +01:00
|
|
|
extern const uint16_t rotation_table[];
|
2018-12-16 16:44:02 +01:00
|
|
|
extern const uint8_t bonus_spr_table[];
|
|
|
|
extern const uint8_t tiles_5dc9_lut[];
|
|
|
|
extern const uint8_t tiles_yoffset_table[];
|
2018-12-16 13:34:03 +01:00
|
|
|
extern const uint8_t monster_spr_anim_data0[];
|
|
|
|
extern const uint8_t monster_spr_anim_data1[];
|
|
|
|
extern const uint8_t monster_spr_anim_data2[];
|
|
|
|
extern const uint8_t monster_spr_anim_data3[];
|
|
|
|
extern const uint8_t monster_spr_anim_data6[];
|
|
|
|
extern const uint8_t monster_spr_anim_data8[];
|
|
|
|
extern const uint8_t monster_spr_anim_data9[];
|
|
|
|
extern const uint8_t common_palette_data[];
|
|
|
|
extern const uint8_t levels_palette_data[];
|
|
|
|
extern const uint8_t tile_lut_data0[];
|
|
|
|
extern const uint8_t tile_lut_data1[];
|
|
|
|
extern const uint8_t tile_lut_data2[];
|
|
|
|
extern const uint8_t tile_lut_data3[];
|
|
|
|
extern const uint16_t tile_funcs0[];
|
|
|
|
extern const uint16_t tile_funcs1[];
|
|
|
|
extern const uint16_t tile_funcs2[];
|
|
|
|
extern const uint16_t tile_funcs3[];
|
|
|
|
extern const uint8_t level_data_tiles_lut[];
|
|
|
|
extern const uint8_t player_anim_dy[];
|
|
|
|
extern const uint8_t player_anim_lut[];
|
|
|
|
extern const uint8_t *player_anim_table[];
|
|
|
|
|
|
|
|
/* game.c */
|
|
|
|
extern void update_input();
|
|
|
|
extern void do_game_over_screen();
|
|
|
|
extern void do_game_win_screen();
|
|
|
|
extern void do_difficulty_screen();
|
|
|
|
extern void do_level_password_screen();
|
|
|
|
extern void do_level_number_screen();
|
|
|
|
|
|
|
|
/* level.c */
|
|
|
|
extern void do_level();
|
|
|
|
|
|
|
|
/* screen.c */
|
|
|
|
extern void video_draw_dot_pattern(int offset);
|
|
|
|
extern void video_draw_sprite(int num, int x, int y, int flag);
|
|
|
|
extern void video_draw_string(const char *s, int offset, int hspace);
|
|
|
|
extern void video_copy_vga(int size);
|
2018-12-16 16:44:02 +01:00
|
|
|
extern void video_copy_backbuffer(int h);
|
2018-12-16 13:34:03 +01:00
|
|
|
extern void ja_decode_spr(const uint8_t *src, int w, int h, uint8_t *dst, int dst_pitch, uint8_t pal_mask);
|
|
|
|
extern void ja_decode_chr(const uint8_t *buffer, const int size, uint8_t *dst, int dst_pitch);
|
|
|
|
extern void ja_decode_tile(const uint8_t *buffer, uint8_t pal_mask, uint8_t *dst, int dst_pitch, int x, int y);
|
2018-12-16 15:28:52 +01:00
|
|
|
extern void ja_decode_motif(int num, uint8_t color);
|
2018-12-16 13:34:03 +01:00
|
|
|
extern void video_load_sprites();
|
|
|
|
|
|
|
|
/* sound.c */
|
|
|
|
extern void sound_init();
|
|
|
|
extern void sound_fini();
|
|
|
|
extern void play_sound(int num);
|
|
|
|
extern void play_music(int num);
|
|
|
|
|
|
|
|
#endif /* GAME_H__ */
|