191 lines
7.4 KiB
C
191 lines
7.4 KiB
C
#ifndef GAME_H
|
|
#define GAME_H
|
|
|
|
typedef unsigned short u16;
|
|
|
|
#define RGB(r, g, b) ((u16)((r) | ((g) << 5) | ((b) << 10)))
|
|
#define WIDTH 240
|
|
#define HEIGHT 160
|
|
|
|
enum { A = 1, B = 2, SELECT = 4, START = 8, RIGHT = 16, LEFT = 32, UP = 64, DOWN = 128,
|
|
R_BUTTON = 256 };
|
|
enum { MOVEMENT_HZ = 60, MOVEMENT_CLOCK_HZ = 16384, WALK_SPEED = 2, MAX_MOVEMENT_TICKS = 5 };
|
|
enum { NPC_X = 146, NPC_Y = 106, PROF_X = 113, PROF_Y = 92, RANGER_X = 83, RANGER_Y = 97 };
|
|
/* Room and facing IDs are persistent: never reorder or reuse them. */
|
|
enum Room { OUTSIDE = 0, COTTAGE = 1, ROUTE = 2, MELLON_GARDEN = 3,
|
|
MELLON_HOUSE = 4, BEACH = 5, ROOM_COUNT = 6 };
|
|
enum Facing { FACING_DOWN = 0, FACING_UP = 1, FACING_LEFT = 2, FACING_RIGHT = 3 };
|
|
struct Location { int room, x, y, facing; };
|
|
enum CharacterStyle { BOY_STYLE, GIRL_STYLE };
|
|
enum { DIALOGUE_X = 8, DIALOGUE_Y = 96, DIALOGUE_W = 224, DIALOGUE_H = 44 };
|
|
enum { FOLLOW_STEPS = 14, SPROUT_HP = 24, GOLDEN_HP = 18 };
|
|
enum BattlePhase { BATTLE_OFF, BATTLE_TURN, BATTLE_WON, BATTLE_LOST, BATTLE_FLED, BATTLE_CAUGHT };
|
|
enum Species { GOLDEN, FERNFOX, EMBERWING, PEBBLIT, TIDEFIN, SPECIES_COUNT };
|
|
enum { FISHER_X = 178, FISHER_Y = 80 };
|
|
enum { CAUGHT_CAPACITY = 5, SAVE_RECORD_SIZE = 19 };
|
|
enum BattleNotice { NOTICE_NONE, NOTICE_NO_BALLS, NOTICE_TEAM_FULL, NOTICE_BROKE_FREE };
|
|
enum WalkResult { WALK_NORMAL, WALK_MAP_CHANGED, WALK_ENCOUNTER };
|
|
|
|
struct BattleState {
|
|
enum BattlePhase phase;
|
|
enum Species enemy;
|
|
int sprout_hp, enemy_hp, move, turns;
|
|
enum BattleNotice notice;
|
|
};
|
|
extern struct BattleState battle;
|
|
|
|
struct SpeciesInfo {
|
|
const char *name, *level, *intro, *reply, *type;
|
|
int hp, attack, leaf_damage;
|
|
};
|
|
struct WildArt { const char *const *rows; const u16 *palette; };
|
|
|
|
#ifdef GAME_TEST
|
|
#define TEST_INTERNAL
|
|
extern u16 test_pixels[WIDTH * HEIGHT + 2];
|
|
extern unsigned char test_save[32];
|
|
#define SCREEN (test_pixels + 1)
|
|
#define SAVE_MEMORY test_save
|
|
#else
|
|
#define TEST_INTERNAL static
|
|
extern u16 frame_buffer[WIDTH * HEIGHT];
|
|
#define SCREEN frame_buffer
|
|
#endif
|
|
|
|
extern u16 dirty_first[HEIGHT];
|
|
extern u16 dirty_end[HEIGHT];
|
|
extern enum Room current_room;
|
|
extern int door_open;
|
|
extern enum Facing player_facing;
|
|
extern int follower_x, follower_y, follower_ready;
|
|
extern unsigned random_state;
|
|
extern int grass_steps;
|
|
extern int partner_owned;
|
|
extern int ball_count, balls_given;
|
|
extern int rod_owned;
|
|
int near_water(int x, int y);
|
|
int cast_rod(int x, int y);
|
|
int start_battle(enum Species enemy);
|
|
extern int caught_count;
|
|
extern int active_member;
|
|
int choose_partner(int member);
|
|
int partner_hp(void);
|
|
const char *partner_name(void);
|
|
const char *partner_move(void);
|
|
void draw_member(int member, int x, int y, int small);
|
|
extern unsigned char caught_species[CAUGHT_CAPACITY];
|
|
extern const struct SpeciesInfo species[SPECIES_COUNT];
|
|
|
|
void reset_dirty_rows(void);
|
|
void mark_dirty(int x, int y, int w, int h);
|
|
void rectangle(int x, int y, int w, int h, u16 color);
|
|
void text(int x, int y, const char *message, u16 color);
|
|
void large_text(int x, int y, const char *message, u16 color);
|
|
void blit_sprite(int x, int y, const char *const *art, int width, int rows,
|
|
const u16 *palette, int scale, int mirrored);
|
|
void sprite(int x, int y, const char *const *art, int rows, const u16 *palette,
|
|
int mirrored);
|
|
int in_tall_grass(int x, int y);
|
|
int beach_shoreline(int x);
|
|
u16 beach_scenery(int x, int y);
|
|
void restore(int x, int y, int w, int h);
|
|
void pause_movement_at(unsigned now);
|
|
int movement_ticks_at(unsigned now);
|
|
void reset_follower(int x, int y);
|
|
int indoors(void);
|
|
int near_door(int x, int y);
|
|
int near_map_exit(int x, int y);
|
|
int near_route_sign(int x, int y);
|
|
int use_door(int *x, int *y);
|
|
void reset_position(int *x, int *y);
|
|
int room_walkable(int room, int x, int y);
|
|
int location_valid(const struct Location *location);
|
|
void default_location(struct Location *out);
|
|
void enter_location(const struct Location *location, int *x, int *y);
|
|
enum WalkResult walk_movement(unsigned keys, int *x, int *y, int ticks);
|
|
void scaled_creature(int x, int y, int scale, const u16 *palette);
|
|
void draw_wild_creature(enum Species enemy, int x, int y);
|
|
void draw_sprout(int x, int y, int scale);
|
|
void actors(int x, int y, int step);
|
|
int near_golden(int x, int y);
|
|
int begin_battle(int x, int y);
|
|
int check_grass_encounter(int old_x, int old_y, int x, int y);
|
|
int battle_input(unsigned pressed);
|
|
void draw_battle_hud(void);
|
|
void draw_battle(void);
|
|
void load_progress(void);
|
|
void saved_location(struct Location *out);
|
|
int save_progress(const struct Location *location);
|
|
enum SaveMenuPhase { SAVE_MENU_CLOSED, SAVE_MENU_OPTIONS, SAVE_MENU_SAVED, SAVE_MENU_FAILED,
|
|
SAVE_MENU_TEAM, SAVE_MENU_BAG };
|
|
enum { MENU_TEAM, MENU_BAG, MENU_SAVE, MENU_CLOSE, MENU_COUNT };
|
|
enum { SAVE_MENU_X = 160, SAVE_MENU_Y = 6, SAVE_MENU_W = 74, SAVE_MENU_H = 148 };
|
|
struct SaveMenuState {
|
|
enum SaveMenuPhase phase;
|
|
int selection;
|
|
unsigned previous;
|
|
};
|
|
extern struct SaveMenuState save_menu;
|
|
int save_menu_input(unsigned keys, int can_open, const struct Location *location);
|
|
void draw_save_menu(void);
|
|
void draw_menu_scene(int x, int y);
|
|
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after);
|
|
void draw_menu_panel(enum SaveMenuPhase before);
|
|
void draw_bag(void);
|
|
int has_caught(enum Species kind);
|
|
int near_npc(int x, int y);
|
|
int begin_conversation(int x, int y);
|
|
int advance_conversation(int page);
|
|
void dialogue_box(int page);
|
|
void status(const char *message);
|
|
void location_status(int x, int y);
|
|
void draw_scene(int x, int y);
|
|
void draw_team(void);
|
|
void draw_team_member(int member);
|
|
|
|
#ifdef GAME_TEST
|
|
unsigned save_crc(const unsigned char *bytes, int length);
|
|
extern const unsigned char large_alphabet[26][7];
|
|
extern u16 background_cache[WIDTH * HEIGHT];
|
|
extern enum Room background_room;
|
|
extern int background_valid, background_door_open;
|
|
extern unsigned scenery_samples;
|
|
extern unsigned diagonal_fraction;
|
|
extern const u16 shirt;
|
|
extern const char *const creature_art[16];
|
|
extern const char *const person_art[20];
|
|
extern const char *const person_back_art[20];
|
|
extern const char *const person_side_art[20];
|
|
extern const char *const girl_art[20], *const girl_back_art[20], *const girl_side_art[20];
|
|
extern int gift_conversation;
|
|
extern const char *const dialogue[][2];
|
|
extern const char *const professor_dialogue[][2];
|
|
extern const char *const professor_followup[][2];
|
|
extern const char *const ranger_dialogue[][2];
|
|
extern const char *const ranger_followup[][2];
|
|
extern int trail_head, ball_gift_conversation;
|
|
extern unsigned rectangle_calls, sprite_decodes, sprite_row_marks;
|
|
extern const int DIALOGUE_PAGES;
|
|
extern const char *const fernfox_art[24], *const emberwing_art[24], *const pebblit_art[24];
|
|
extern const char *const tidefin_art[24];
|
|
extern const struct WildArt wild_art[4];
|
|
u16 cottage_scenery(int x, int y);
|
|
u16 route_scenery(int x, int y);
|
|
u16 village_scenery(int x, int y);
|
|
u16 mellon_garden_scenery(int x, int y);
|
|
u16 scenery(int x, int y);
|
|
void move_follower(int old_x, int old_y, int x, int y);
|
|
enum Facing facing_for_keys(unsigned keys, enum Facing previous);
|
|
int use_map_exit(int *x, int *y, unsigned keys);
|
|
int can_walk(int x, int y);
|
|
void person(int x, int y, int step, u16 clothes, u16 hat, enum Facing facing);
|
|
void styled_person(int x, int y, int step, u16 clothes, u16 hair_or_hat,
|
|
enum Facing facing, enum CharacterStyle style);
|
|
unsigned next_random(void);
|
|
int next_dialogue_page(int page);
|
|
int receive_partner(void);
|
|
int receive_balls(void);
|
|
#endif
|
|
|
|
#endif
|