2025-02-19 02:09:45 +00:00
# define INVENTORY_SIZE 12
# define MAX_OBJECTS_PER_SCENE (30+INVENTORY_SIZE)
2025-02-18 21:03:37 +00:00
# define MAX_SCRIPTS_PER_SCENE 30
# define MAX_STACKED_SCENES 5
2025-02-19 00:55:56 +00:00
# include <stdint.h>
2025-02-18 21:03:37 +00:00
struct object {
2025-02-17 19:11:44 +00:00
int id ; // 0 if slot unused
int x ;
int y ;
int width ;
int height ;
const char * pixels ;
2025-02-18 22:11:20 +00:00
const struct level_clickregion * clickregion ; // if not null, overrides click bounds check
2025-02-18 21:03:37 +00:00
} ;
2025-02-17 19:11:44 +00:00
2025-02-18 01:04:17 +00:00
typedef void ( * script_wake_fn ) ( struct script * scr , int wakeupMode , int arg1 , int arg2 , int arg3 , int arg4 ) ;
# define SCRIPT_HEADER \
int id /* 0 if slot unused */ ; \
int wakeupMode ; \
script_wake_fn wakeupFn ; \
int wakeupArg1 ; /* for SCRIPT_WAKEUP_OTHER_SCRIPT */
2025-02-18 21:03:37 +00:00
struct script {
2025-02-18 01:04:17 +00:00
SCRIPT_HEADER
int vars [ 100 ] ;
2025-02-18 21:03:37 +00:00
} ;
typedef void ( * scene_render_fn ) ( struct scene * s ) ;
2025-02-19 00:55:56 +00:00
typedef void ( * scene_animtimer_fn ) ( struct scene * s ) ;
typedef void ( * scene_handle_tap_fn ) ( struct scene * s , int x , int y ) ;
2025-02-18 21:03:37 +00:00
void standard_scene_render ( struct scene * s ) ;
2025-02-19 00:55:56 +00:00
void standard_handle_tap ( struct scene * s , int x , int y ) ;
2025-02-18 21:03:37 +00:00
extern struct scene {
int id ;
struct object objects [ MAX_OBJECTS_PER_SCENE ] ;
struct script scripts [ MAX_SCRIPTS_PER_SCENE ] ;
2025-02-19 00:55:56 +00:00
scene_render_fn render_fn ; // default standard_scene_render
scene_animtimer_fn animtimer_fn ; // default null
scene_handle_tap_fn handle_tap_fn ; // default standard_handle_tap
2025-02-18 21:03:37 +00:00
struct navmesh * navmesh ; // defaults to non-null pointer to empty navmesh
2025-02-19 02:09:45 +00:00
bool use_standard_inventory ; // defaults to true
2025-02-19 02:17:36 +00:00
bool dim_background ; // defaults to false, because most scenes overwrite the whole screen
2025-02-19 02:09:45 +00:00
2025-02-18 21:03:37 +00:00
} scenes [ MAX_STACKED_SCENES ] ;
extern int scene_depth ; // number of stacked scenes
# define top_scene scenes[scene_depth-1]
2025-02-18 01:04:17 +00:00
struct script_player_walk {
SCRIPT_HEADER
int targetX ;
int targetY ;
int targetNavmeshTri ;
int currentNavmeshTri ;
} ;
# define SCRIPT_WAKEUP_VIDEO_FRAME 1
# define SCRIPT_WAKEUP_OTHER_SCRIPT 2
# define SCRIPT_WAKEUP_OTHER_SCRIPT_INTERRUPTED 3 // Delivered to script that registers for SCRIPT_WAKEUP_OTHER_SCRIPT if that script is interrupted instead of completing.
2025-02-19 02:09:45 +00:00
typedef void ( * scene_setup_fn ) ( scene * s , int scene , int fromscene ) ;
2025-02-18 01:04:17 +00:00
2025-02-17 19:11:44 +00:00
// engine
2025-02-18 21:03:37 +00:00
// Scene changes - even push - may discard remaining events for the scene.
void push_scene ( int scene ) ;
2025-02-19 00:55:56 +00:00
void push_scene ( int scene , scene_setup_fn setup_fn ) ;
2025-02-18 21:03:37 +00:00
void replace_scene ( int scene ) ;
void pop_scene ( ) ;
2025-02-17 19:11:44 +00:00
void scene_add_clickrect ( int id , int x , int y , int width , int height ) ;
2025-02-19 02:09:45 +00:00
struct object * scene_add_object ( scene * s , int id , int x , int y , int width , int height , const char * pixels ) ;
void scene_load_predef ( struct scene * sc , const struct level_predef_data * predef ) ;
2025-02-18 01:04:17 +00:00
struct object * find_object_by_id ( int id ) ;
struct script * scene_add_script ( int id , bool interrupt_existing ) ;
struct script * scene_get_script ( int id ) ;
bool deliver_script_wakeup ( int wakeupMode , int wakeupArg1 , int wakeupType , int arg1 , int arg2 , int arg3 , int arg4 ) ; // deliver to scripts with given wakeupMode and wakeupArg1. Returns true if scene changed.
2025-02-18 15:26:16 +00:00
void start_player_walk_to_point ( int x , int y ) ; // x and y are not corrected to lie within navmesh
2025-02-17 19:11:44 +00:00
2025-02-19 00:55:56 +00:00
void push_scene_textbox ( const char * text ) ;
2025-02-19 02:09:45 +00:00
// standard inventory
void create_standard_inventory ( scene * s ) ;
void standard_inventory_onclick ( struct object * obj ) ;
2025-02-19 03:49:32 +00:00
struct sprite {
int width , height ;
uint32_t * pixels ;
const unsigned char * original_data_source ;
} ;
struct sprite * get_decompressed_sprite ( const unsigned char * spritedata ) ;
2025-02-19 00:55:56 +00:00
// used during rendering
// pixel is 0xRRGGBB
extern uint32_t * curfb ;
extern bool need_rerender ;
void fillrect ( int x1 , int y1 , int width , int height , uint32_t pixel ) ;
void blit ( int x , int y , int width , int height , uint32_t * pixels ) ;
2025-02-17 19:11:44 +00:00
// game-specific constants
# define SCENE_LOBBY 1
# define SCENE_MANAGERS_OFFICE 2
2025-02-18 16:53:24 +00:00
# define SCENE_MANAGERS_OFFICE_SAFE 3
# define SCENE_BASEMENT 4
2025-02-19 00:55:56 +00:00
# define SCENE_TEXTBOX 5
2025-02-17 19:11:44 +00:00
// game.cpp
2025-02-19 02:09:45 +00:00
void scene_setup ( scene * s , int scene , int fromscene ) ;
2025-02-19 00:55:56 +00:00
void onclick ( int curscene , struct object * obj ) ;
2025-02-19 02:51:11 +00:00
extern struct savefile {
bool got_pager_from_basement ;
} savefile ;