[Scummvm-git-logs] scummvm master -> 61764e4b3d6b9e4db122561161191fff4ad0721f
dreammaster
noreply at scummvm.org
Tue Apr 21 07:36:31 UTC 2026
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
eeecd7400f MADS: PHANTOM: Janitorial for core/ header files
10e001627d MADS: PHANTOM: Janitorial for core/ cpp comments
8a0f5d4f89 MADS: PHANTOM: sprite_0.cpp comments cleanup
61764e4b3d MADS: PHANTOM: pfab pointer fixes
Commit: eeecd7400fa72576fda45e7e9b8b4ccf6cd92d79
https://github.com/scummvm/scummvm/commit/eeecd7400fa72576fda45e7e9b8b4ccf6cd92d79
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-04-21T17:31:10+10:00
Commit Message:
MADS: PHANTOM: Janitorial for core/ header files
Changed paths:
engines/mads/madsv2/core/anim.h
engines/mads/madsv2/core/attr.h
engines/mads/madsv2/core/btype.h
engines/mads/madsv2/core/buffer.h
engines/mads/madsv2/core/cycle.h
engines/mads/madsv2/core/demo.h
engines/mads/madsv2/core/game.h
engines/mads/madsv2/core/heap.h
engines/mads/madsv2/core/implode.h
engines/mads/madsv2/core/inter.h
engines/mads/madsv2/core/kernel.h
engines/mads/madsv2/core/lbm.h
engines/mads/madsv2/core/lib.h
engines/mads/madsv2/core/lock.h
engines/mads/madsv2/core/magic.h
engines/mads/madsv2/core/matte.h
engines/mads/madsv2/core/mem.h
engines/mads/madsv2/core/object.h
engines/mads/madsv2/core/pack.h
engines/mads/madsv2/core/pfab.h
engines/mads/madsv2/core/popup.h
engines/mads/madsv2/core/qual.h
engines/mads/madsv2/core/sort.h
engines/mads/madsv2/core/video.h
diff --git a/engines/mads/madsv2/core/anim.h b/engines/mads/madsv2/core/anim.h
index 04f086527bd..1a1f51527ed 100644
--- a/engines/mads/madsv2/core/anim.h
+++ b/engines/mads/madsv2/core/anim.h
@@ -425,7 +425,6 @@ typedef AnimInter *AnimInterPtr;
extern int anim_error;
-/* anim_1.cpp */
int anim_load_background(AnimFile *anim_in,
Buffer *this_orig,
Buffer *this_depth,
@@ -438,7 +437,6 @@ int anim_load_background(AnimFile *anim_in,
int load_flags, int star_search);
-/* anim_2.cpp */
void anim_unload(AnimPtr anim);
AnimPtr anim_load(const char *file_name,
@@ -450,17 +448,14 @@ AnimPtr anim_load(const char *file_name,
RoomPtr *room, CycleListPtr cycle_list,
int load_flags);
-/* anim_3.cpp */
int anim_get_sound_info(char *file_name,
char *sound_file_buffer,
int *sound_load_flag);
-/* anim_4.cpp */
int anim_get_header_info(char *file_name,
AnimFile *anim_in);
-/* anim_5.cpp */
int anim_himem_preload(char *name, int level);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/attr.h b/engines/mads/madsv2/core/attr.h
index d9acef14a60..4a5c306cfa5 100644
--- a/engines/mads/madsv2/core/attr.h
+++ b/engines/mads/madsv2/core/attr.h
@@ -37,16 +37,12 @@ namespace MADSV2 {
#define ATTR_PACKED_WALK_MASK 0x02
#define ATTR_PACKED_DEPTH_MASK 0x01
-/* attr_1.cpp */
extern int attr_walk(Buffer *attr, int x, int y);
-/* attr_2.cpp */
extern int attr_depth(TileMapHeader *depth_map, int x, int y);
-/* attr_3.cpp */
extern int attr_special(Buffer *attr, int x, int y);
-/* attr_4.c */
extern int attr_load(char *base_name, int item_type, int variant,
Buffer *target, int size_x, int size_y);
diff --git a/engines/mads/madsv2/core/btype.h b/engines/mads/madsv2/core/btype.h
index a80c02944c8..0c844167a04 100644
--- a/engines/mads/madsv2/core/btype.h
+++ b/engines/mads/madsv2/core/btype.h
@@ -27,19 +27,14 @@
namespace MADS {
namespace MADSV2 {
-/* btype_1.c */
byte upcaseb(byte inp);
-/* btype_2.c */
int upcasei(int inp);
-/* btype_3.c */
int xtoi(char *string);
-/* btype_4.c */
int btoi(char *string);
-/* btype_5.c */
int stoi(char *string);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/buffer.h b/engines/mads/madsv2/core/buffer.h
index fabb355925a..05b6a302282 100644
--- a/engines/mads/madsv2/core/buffer.h
+++ b/engines/mads/madsv2/core/buffer.h
@@ -45,7 +45,6 @@ extern int buffer_restore_keep_flag;
extern word pattern_control_value;
extern int auto_pattern;
-/* buffer_1.cpp */
/**
* Allocates space for a buffer, and fills in embedded data.
diff --git a/engines/mads/madsv2/core/cycle.h b/engines/mads/madsv2/core/cycle.h
index 8df81e5b497..6335c5ea360 100644
--- a/engines/mads/madsv2/core/cycle.h
+++ b/engines/mads/madsv2/core/cycle.h
@@ -37,7 +37,6 @@ extern int total_cycle_colors; /* Total # of colors being cycled */
extern long cycle_timing[COLOR_MAX_CYCLES]; /* Timing for each cycle */
-/* cycle_1.c */
void cycle_init(CycleListPtr new_cycle_list, int activate);
void cycle_colors(void);
diff --git a/engines/mads/madsv2/core/demo.h b/engines/mads/madsv2/core/demo.h
index 9e8d9bdf430..c4101af881c 100644
--- a/engines/mads/madsv2/core/demo.h
+++ b/engines/mads/madsv2/core/demo.h
@@ -27,11 +27,9 @@
namespace MADS {
namespace MADSV2 {
-/* demo_1.asm */
int demo_checksum(byte **source, int *pack_size, int *unpack_size);
int demo_check(void);
-/* demo_2.cpp */
void demo_log_in(char *release_version, char *release_date);
void demo_verify(void);
diff --git a/engines/mads/madsv2/core/game.h b/engines/mads/madsv2/core/game.h
index 339b5e651f3..7da23eafddc 100644
--- a/engines/mads/madsv2/core/game.h
+++ b/engines/mads/madsv2/core/game.h
@@ -238,13 +238,32 @@ extern void game_set_camera_speed(void);
extern void game_exec_function(void (*(target))());
extern void game_debugger_reset(void);
extern void game_debugger(void);
+/*
+ * game_write_save_directory()
+ * Writes the list of save files.
+ */
extern void game_write_save_directory(void);
+/*
+ * game_menu_setup()
+ * Sets up for the main menu routines to run--this mainly involves
+ * getting enough memory to hold the save directory and menu heap.
+ */
extern void game_menu_setup(void);
+/*
+ * game_menu_shutdown()
+ * Tells the menu structures to bite down hard.
+ */
extern void game_menu_shutdown(void);
extern int main_cheating_key(int mykey);
extern int main_normal_key(int mykey);
extern int main_copy_verify(void);
extern void game_cold_data_init();
+/*
+ * game_control()
+ * This is the main outer control structure for the game, that
+ * determines which section and room level information should be
+ * loaded into and out of memory.
+ */
extern void game_control();
/*
diff --git a/engines/mads/madsv2/core/heap.h b/engines/mads/madsv2/core/heap.h
index d6448d6f1d9..ff44cbec971 100644
--- a/engines/mads/madsv2/core/heap.h
+++ b/engines/mads/madsv2/core/heap.h
@@ -36,12 +36,10 @@ typedef struct {
long size; /* Free space remaining */
} Heap;
-/* heap_1.c */
int heap_create(Heap *heap, int module_id, long heap_size, const char *heap_name);
void heap_destroy(Heap *heap);
void heap_declare(Heap *heap, int module_id, char *buffer, long heap_size);
-/* heap_1.c */
void *heap_get(Heap *heap, long size);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/implode.h b/engines/mads/madsv2/core/implode.h
index aaaa5d1b278..60125afe1ab 100644
--- a/engines/mads/madsv2/core/implode.h
+++ b/engines/mads/madsv2/core/implode.h
@@ -39,6 +39,16 @@ extern word explode(
word (*write_buff)(char *buffer, word *size),
char *work_buff);
+/*
+ * CRC32
+ * Standard CRC-32 (ISO 3309, polynomial 0xEDB88320, reflected).
+ * Not present in the two ASM files but declared in the shared header.
+ *
+ * @param buffer
+ * @param size
+ * @param old_crc
+ * @return
+ */
extern long crc32(unsigned char *buffer, word *size, long *old_crc);
diff --git a/engines/mads/madsv2/core/inter.h b/engines/mads/madsv2/core/inter.h
index c33d077c938..c268f79b118 100644
--- a/engines/mads/madsv2/core/inter.h
+++ b/engines/mads/madsv2/core/inter.h
@@ -272,13 +272,54 @@ extern char inter_object_buf[20];
extern void (*inter_object_routine)();
-/* inter_1.c */
+/*
+ * inter_prepare_background()
+ * Writes all relevant words to the interface work buffer.
+ */
extern void inter_prepare_background(void);
+/*
+ * inter_setup_hotspots()
+ * Sets up the hotspot list for the interface module. Hotspots only
+ * need to be set up once for each room.
+ */
extern void inter_setup_hotspots(void);
+/*
+ * inter_set_active_inven()
+ * Picks a new active object from the inventory list. This involves
+ * changing the list of object-specific verbs.
+ *
+ * @param new_active
+ */
extern void inter_set_active_inven(int inven_id);
+/*
+ * inter_give_to_player ()
+ * Adds the specified object to the player's inventory.
+ *
+ * @param this_
+ */
extern void inter_give_to_player(int this_);
+/*
+ * inter_move_object()
+ * Moves an object to a new location, taking into account any
+ * player_inventory problems.
+ *
+ * @param object_id
+ * @param location
+ */
extern void inter_move_object(int object_id, int location);
+/*
+ * inter_init_sentence()
+ * Begins accepting a new sentence.
+ */
extern void inter_init_sentence(void);
+/*
+ * inter_main_loop()
+ * The main interface loop. Called by run-time kernel to perform one
+ * round of interface checking. Provides mouse interface for the whole
+ * program.
+ *
+ * @param allow_input
+ */
extern void inter_main_loop(int allow_input);
extern void inter_screen_update(void);
@@ -291,7 +332,6 @@ extern void inter_deallocate_objects(void);
extern void inter_reset_dialog(void);
extern int inter_add_dialog(char *string, int result);
-/* inter_2.c */
extern int inter_load_background(const char *name, Buffer *target);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/kernel.h b/engines/mads/madsv2/core/kernel.h
index 8e8bf9e96e4..11f0c8dbedf 100644
--- a/engines/mads/madsv2/core/kernel.h
+++ b/engines/mads/madsv2/core/kernel.h
@@ -336,7 +336,6 @@ struct KernelGame {
#define kernel_dialog(q) inter_add_dialog(quote_string(kernel.quotes, q), q)
-/* kernel_1.cpp */
extern RoomPtr room; /* Pointer to current room's data */
extern int room_id; /* Current room # */
extern int section_id; /* Current section # */
@@ -459,6 +458,15 @@ extern void kernel_unload_all_series();
*/
extern int kernel_load_series(const char *name, int load_flags);
+/*
+ * kernel_flip_hotspot()
+ * Toggles an interface hotspot (referenced by its vocabulary word)
+ * on or off. Hotspots that are off do not interact with the mouse
+ * cursor.
+ *
+ * @param vocab_code
+ * @param active
+ */
extern void kernel_flip_hotspot(int vocab_code, int active);
/**
diff --git a/engines/mads/madsv2/core/lbm.h b/engines/mads/madsv2/core/lbm.h
index 7e85a7724ed..62a462aeddb 100644
--- a/engines/mads/madsv2/core/lbm.h
+++ b/engines/mads/madsv2/core/lbm.h
@@ -28,13 +28,10 @@
namespace MADS {
namespace MADSV2 {
-/* lbm_1.c */
void lbm_read_page(const char *filename, byte *image, Palette *pal);
-/* lbm_2.c */
Buffer lbm_read_buffer(const char *filename, Palette *pal, CycleListPtr cycle);
-/* lbm_3.c */
int lbm_read_buffer_main(const char *name, Buffer *target, int reserved_flag,
CycleListPtr cycle_list);
diff --git a/engines/mads/madsv2/core/lib.h b/engines/mads/madsv2/core/lib.h
index 5636a6f0e0a..2cb025ec536 100644
--- a/engines/mads/madsv2/core/lib.h
+++ b/engines/mads/madsv2/core/lib.h
@@ -35,7 +35,6 @@ extern char mads_dev_lib_version[5];
extern char mads_dev_lib_date[11];
#endif
-/* lib.c */
void lib_show_version(void);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/lock.h b/engines/mads/madsv2/core/lock.h
index acad379e386..33389c65a70 100644
--- a/engines/mads/madsv2/core/lock.h
+++ b/engines/mads/madsv2/core/lock.h
@@ -32,32 +32,23 @@ extern char *lock_search_mark;
extern int lock_search_length;
extern word *lock_hash_value;
-/* lock_2.cpp */
word lock_get_disk_hash(void);
-/* lock_3.cpp */
long lock_search_hash_offset(void);
-/* lock_4.cpp */
void lock_write_new_hash(void);
-/* lock_5.cpp */
int lock_get_copy_code(void);
-/* lock_6.cpp */
void lock_short_protection_check(void);
-/* lock_7.cpp */
int lock_verification(void);
void lock_sabotage(void);
-/* lock_8.cpp */
void lock_long_protection_check(void);
-/* lock_9.cpp */
void lock_secret_protection_check(void);
-/* lock_a.cpp */
void lock_preliminary_check(void);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/magic.h b/engines/mads/madsv2/core/magic.h
index 64db7750ad2..26ad9ac4140 100644
--- a/engines/mads/madsv2/core/magic.h
+++ b/engines/mads/madsv2/core/magic.h
@@ -61,6 +61,16 @@ extern int magic_special_center_y;
extern void magic_get_grey_values(Palette *pal, byte *grey_value,
int base_color, int num_colors);
extern void magic_grey_palette(Palette *pal);
+/*
+ * magic_grey_popularity()
+ * Given a "grey_list" containing "num_colors" grey values (0-63),
+ * produces a 64-byte "grey_table" containing the number of grey
+ * values of each intensity level.
+ *
+ * @param grey_list
+ * @param grey_table
+ * @param num_colors
+ */
extern void magic_grey_popularity(byte *grey_list, byte *grey_table, int num_colors);
extern void magic_set_color_flags(byte r, byte g, byte b);
extern void magic_set_color_values(byte r, byte g, byte b);
@@ -72,12 +82,63 @@ extern void magic_fade_to_grey(Palette pal, byte *map_pointer,
int tick_delay, int steps);
extern void magic_fade_from_grey(RGBcolor *pal, Palette target, int base_color,
int num_colors, int base_grey, int num_greys, int tick_delay, int steps);
+/*
+ * magic_screen_change_corner()
+ * Picture-to-picture transition in which one of the screen
+ * corners is pulled diagonally across the screen to bring in
+ * the new view.
+ *
+ * @param new_screen
+ * @param pal
+ * @param corner_id
+ * @param buffer_base_x
+ * @param buffer_base_y
+ * @param screen_base_x
+ * @param screen_base_y
+ * @param thru_black
+ * @param set_palette
+ * @param tick_delay
+ */
extern void magic_screen_change_corner(Buffer *new_screen, Palette pal, int corner_id,
int buffer_base_x, int buffer_base_y, int screen_base_x, int screen_base_y,
int thru_black, int set_palette, int tick_delay);
+/*
+ * magic_screen_change_edge()
+ * Picture-to-picture transition in which the new picture sweeps
+ * in from either the right or left edge.
+ *
+ * @param new_screen
+ * @param pal
+ * @param edge_id
+ * @param buffer_base_x
+ * @param buffer_base_y
+ * @param screen_base_x
+ * @param screen_base_y
+ * @param thru_black
+ * @param set_palette
+ * @param tick_delay
+ */
extern void magic_screen_change_edge(Buffer *new_screen, Palette pal, int edge_id,
int buffer_base_x, int buffer_base_y, int screen_base_x, int screen_base_y,
int thru_black, int set_palette, int tick_delay);
+/*
+ * magic_screen_change_circle()
+ * Picture-to-picture transition in which the new picture is
+ * brought in with either expanding or contracting concentric
+ * circles.
+ *
+ * @param new_screen
+ * @param pal
+ * @param inward_flag
+ * @param buffer_base_x
+ * @param buffer_base_y
+ * @param screen_base_x
+ * @param screen_base_y
+ * @param thru_black
+ * @param set_palette
+ * @param tick_delay
+ * @param pixel_rate
+ */
extern void magic_screen_change_circle(Buffer *new_screen, Palette pal,
int inward_flag, int buffer_base_x, int buffer_base_y,
int screen_base_x, int screen_base_y, int thru_black, int set_palette,
diff --git a/engines/mads/madsv2/core/matte.h b/engines/mads/madsv2/core/matte.h
index 22cf0e779e3..48e3d0cf922 100644
--- a/engines/mads/madsv2/core/matte.h
+++ b/engines/mads/madsv2/core/matte.h
@@ -125,35 +125,28 @@ extern TileResource picture_resource, depth_resource; /* Tile resources */
-/* matte_1.c */
void matte_init(int init_series);
int matte_map_work_screen(void);
-/* matte_1.c */
void matte_frame(int special_effect, int full_screen);
-/* matte_1.c */
//void matte_init_series(void);
int matte_load_series(const char *name, int load_flags, int bonus_series_number);
void matte_deallocate_series(int id, int free_memory);
int matte_allocate_series(SeriesPtr series,
int bonus_series_number);
-/* matte_1.c */
//void matte_init_messages(void);
int matte_add_message(FontPtr font, char *text,
int x, int y, int message_color,
int auto_spacing);
void matte_clear_message(int handle);
-/* matte_1.c */
int matte_allocate_image(void);
-/* matte_1.c */
void matte_refresh_work(void);
-/* matte_2.c */
void matte_inter_frame(int update_live, int clear_chaff);
int matte_allocate_inter_image(void);
void matte_refresh_inter(void);
diff --git a/engines/mads/madsv2/core/mem.h b/engines/mads/madsv2/core/mem.h
index 377ac71f9d4..9148098bca1 100644
--- a/engines/mads/madsv2/core/mem.h
+++ b/engines/mads/madsv2/core/mem.h
@@ -90,12 +90,10 @@ extern void mem_restore_free();
*/
extern void mem_get_block_name(byte *block, char *block_name);
-/* mem_4.cpp */
extern long mem_get_avail();
extern long mem_conv_get_avail();
extern void mem_set_video_mode(int mode);
-/* mem_5.cpp */
extern long mem_program_block();
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/object.h b/engines/mads/madsv2/core/object.h
index ce22a8c34ba..db5f77c6661 100644
--- a/engines/mads/madsv2/core/object.h
+++ b/engines/mads/madsv2/core/object.h
@@ -106,7 +106,6 @@ extern void object_unload(void);
extern int object_named(int vocab_id);
extern int object_is_here(int object_id);
-/* object_3.cpp */
extern int object_has_quality(int object_id, int quality_id);
extern long object_check_quality(int object_id, int quality_id);
extern void object_set_quality(int object_id, int quality_id, long quality_value);
diff --git a/engines/mads/madsv2/core/pack.h b/engines/mads/madsv2/core/pack.h
index e62ecb6816b..923a092a62d 100644
--- a/engines/mads/madsv2/core/pack.h
+++ b/engines/mads/madsv2/core/pack.h
@@ -184,11 +184,65 @@ extern word pack_read_memory(char *buffer, word *size);
extern word pack_write_memory(char *buffer, word *size);
extern word pack_read_file(char *buffer, word *size);
extern word pack_write_file(char *buffer, word *size);
+/*
+ * pack_a_packet()
+ * Given that our packing parameters are set up (i.e.
+ * pack_read_size, pack_write_size, and so forth), this
+ * routine uses the specified packing strategy to move
+ * a record.
+ *
+ * @param packing_flag
+ * @param explode_mode
+ * @return
+ */
extern word pack_a_packet(int packing_flag, int explode_mode);
+/*
+ * pack_data()
+ * Transfers a data packet from the specified source to the specified
+ * destination, using the specified packing strategy.
+ * packing_flag Specifies the packing strategy:
+ * PACK_IMPLODE (Compresses data)
+ * PACK_EXPLODE (Decompresses data)
+ * PACK_RAW_COPY (Copies data)
+ * size # of bytes to move
+ * source_type Specifies the source type:
+ * FROM_DISK or FROM_MEMORY.
+ * source If FROM_DISK, then this is a FILE *handle.
+ * If FROM_MEMORY, this is a far memory pointer.
+ * dest_type Specifies the destination type:
+ * TO_DISK, TO_MEMORY, or TO_EMS.
+ * dest Same as "source" but for destination. For
+ * TO_EMS, "dest" is a far pointer to an
+ * EmsPtr structure.
+ * Example:
+ * result =pack_data (PACK_EXPLODE, 132000,
+ * FROM_DISK, file_handle,
+ * TO_MEMORY, memory_pointer);
+ * (Decompresses 132000 bytes from the already open
+ * disk file "file_handle", and writes it to memory
+ * far the specified address. Size is always the
+ * uncompressed size of the data. Result will be
+ * the # of bytes actually written -- 132000 if successful).
+ *
+ * @param packing_flag
+ * @param size
+ * @param source_type
+ * @param source
+ * @param dest_type
+ * @param dest
+ * @return
+ */
extern long pack_data(int packing_flag, long size, int source_type, void *source,
int dest_type, void *dest);
extern void pack_set_special_buffer(byte *buffer_address,
void (*(special_function))());
+/*
+ * pack_check()
+ * Asks user to choose between compressed and uncompressed data
+ * formats.
+ *
+ * @return
+ */
extern int pack_check(void);
extern void pack_enable_zip(void);
extern void pack_enable_pfab(void);
diff --git a/engines/mads/madsv2/core/pfab.h b/engines/mads/madsv2/core/pfab.h
index 775baab8258..f4b943f4ce4 100644
--- a/engines/mads/madsv2/core/pfab.h
+++ b/engines/mads/madsv2/core/pfab.h
@@ -37,6 +37,16 @@ namespace MADSV2 {
#define CMP_ABORT 4
+/*
+ * Public API: pFABcomp
+ *
+ * @param read_buff
+ * @param write_buff
+ * @param work_buff
+ * @param type
+ * @param dsize
+ * @return
+ */
extern word pFABcomp(
word (*read_buff)(char *buffer, word *size),
word (*write_buff)(char *buffer, word *size),
@@ -54,6 +64,19 @@ extern word pFABexp1(
char *write_buf,
char *work_buff);
+/*
+ * pFABexp2 -- memory-to-memory decompressor (PFABEXP2.ASM)
+ * read_buf points to compressed data.
+ * write_buf points to destination buffer (must be large enough).
+ * work_buff must be at least 4 bytes (for the output length result),
+ * or NULL to query required size.
+ * Returns 0 on success. Decompressed byte count stored at work_buff[0..3].
+ *
+ * @param read_buf
+ * @param write_buf
+ * @param work_buff
+ * @return
+ */
extern word pFABexp2(
byte *read_buf,
byte *write_buf,
diff --git a/engines/mads/madsv2/core/popup.h b/engines/mads/madsv2/core/popup.h
index 25997987f93..ab9af5b3d3b 100644
--- a/engines/mads/madsv2/core/popup.h
+++ b/engines/mads/madsv2/core/popup.h
@@ -411,13 +411,11 @@ extern byte popup_num_colors;
extern BoxParam box_param;
-/* popup_1.c */
int popup_create(int horiz_pieces, int x, int y);
void popup_add_icon(SeriesPtr series, int id, int center);
int popup_draw(int save_screen, int depth_code);
void popup_destroy(void);
-/* popup_1.c */
void popup_next_line(void);
void popup_set_ask(void);
void popup_add_string(const char *string);
@@ -428,39 +426,47 @@ void popup_downpixel(void);
void popup_tab(int tab_level);
void popup_center_string(const char *string, int underline);
-/* popup_1.c */
int popup_and_wait(int save_screen);
int popup_and_dont_wait(int save_screen);
-/* popup_1.c */
void popup_update_ask(char *string, int maxlen);
int popup_ask_string(char *target, int maxlen, int save_screen);
int popup_ask_number(long *value, int maxlen, int save_screen);
-/* popup_2.c */
int popup_estimate_pieces(int maxlen);
int popup_get_string(char *target, const char *top, const char *left, int maxlen);
int popup_get_long(long *value, const char *top, const char *left, int maxlen);
int popup_get_number(int16 *value, const char *top, const char *left, int maxlen);
-/* popup_3.c */
int popup_alert(int width, const char *message_line, ...);
-/* popup_4.c */
int popup_box_load(void);
-/* popup_5.c */
+/*
+ * popup_dialog_create()
+ * Sets up popup dialog structure, allocating memory dynamically
+ * if necessary.
+ *
+ * @param memory
+ * @param heap_size
+ * @param max_items
+ * @return
+ */
Popup *popup_dialog_create(void *memory, long heap_size, int max_items);
+/*
+ * popup_dialog_destroy()
+ * Destroys a popup dialog, deallocating any dynamic memory.
+ *
+ * @return
+ */
Popup *popup_dialog_destroy(void);
-/* popup_5.c */
PopupItem *popup_button(const char *prompt, int x);
PopupItem *popup_cancel_button(const char *prompt);
PopupItem *popup_message(const char *prompt, int x, int y);
PopupItem *popup_execute(void);
-/* popup_5.c */
PopupItem *popup_savelist(const char *data,
const char *empty_string,
int elements,
@@ -471,13 +477,11 @@ PopupItem *popup_savelist(const char *data,
int accept_input,
int default_element);
-/* popup_5.c */
void popup_blank(int num_lines);
void popup_blank_line(void);
void popup_width_force(int width);
-/* popup_5.c */
void popup_menu_option(PopupItem *item, char *option);
PopupItem *popup_menu(const char *prompt,
int x, int y, int pixel_width,
@@ -485,7 +489,6 @@ PopupItem *popup_menu(const char *prompt,
int elements, int element_max_length,
int default_element);
-/* popup_5.c */
PopupItem *popup_sprite(SeriesPtr series, int sprite, int x, int y);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/qual.h b/engines/mads/madsv2/core/qual.h
index 9a4bc015388..bf9b6ec85f5 100644
--- a/engines/mads/madsv2/core/qual.h
+++ b/engines/mads/madsv2/core/qual.h
@@ -64,33 +64,25 @@ extern int qual_allocation;
extern int qual_words;
extern char *qual;
-/* qual_1.cpp */
int qual_destroy(void);
-/* qual_2.cpp */
int qual_load(int allocation_flag);
int qual_get_code(char *inp);
char *qual_get_word(char *out, int inp);
-/* qual_3.cpp */
int qual_write_file(char *last_word);
int qual_add_word(char *inp);
-/* qual_4.c */
void qual_report_error(int number);
-/* qual_5.cpp */
char *qual_select_word(char *out,
char *prompt,
char *default_word);
-/* qual_6.cpp */
void qual_maint(void);
-/* qual_7.cpp */
int qual_build(void);
-/* qual_8.cpp */
void qual_unload_active(void);
void qual_init_active(void);
int qual_active_id(word id);
diff --git a/engines/mads/madsv2/core/sort.h b/engines/mads/madsv2/core/sort.h
index 6af4f36075e..e6af444f9d0 100644
--- a/engines/mads/madsv2/core/sort.h
+++ b/engines/mads/madsv2/core/sort.h
@@ -27,13 +27,10 @@
namespace MADS {
namespace MADSV2 {
-/* sort_1.cpp */
extern void sort_insertion(int elements, int *id, long *value);
-/* sort_2.cpp */
extern void sort_insertion_16(int elements, byte *id, word *value);
-/* sort_3.cpp */
extern void sort_insertion_8(int elements, byte *id, byte *value);
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/video.h b/engines/mads/madsv2/core/video.h
index 985685b4cdd..26a21ae2002 100644
--- a/engines/mads/madsv2/core/video.h
+++ b/engines/mads/madsv2/core/video.h
@@ -29,7 +29,6 @@ namespace MADSV2 {
extern byte video_mode;
-/* video.asm */
void video_init(int mode, int set_mode);
void video_update(Buffer *from, int from_x, int from_y,
Commit: 10e001627d8943a0f52227c924285d3e7e77389a
https://github.com/scummvm/scummvm/commit/10e001627d8943a0f52227c924285d3e7e77389a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-04-21T17:31:10+10:00
Commit Message:
MADS: PHANTOM: Janitorial for core/ cpp comments
Changed paths:
engines/mads/madsv2/core/anim.cpp
engines/mads/madsv2/core/buffer.cpp
engines/mads/madsv2/core/camera.cpp
engines/mads/madsv2/core/color.cpp
engines/mads/madsv2/core/copy.cpp
engines/mads/madsv2/core/dialog.cpp
engines/mads/madsv2/core/env.cpp
engines/mads/madsv2/core/fileio.cpp
engines/mads/madsv2/core/font.cpp
engines/mads/madsv2/core/game.cpp
engines/mads/madsv2/core/game.h
engines/mads/madsv2/core/himem.cpp
engines/mads/madsv2/core/hspot.cpp
engines/mads/madsv2/core/imath.cpp
engines/mads/madsv2/core/implode.cpp
engines/mads/madsv2/core/inter.cpp
engines/mads/madsv2/core/kernel.cpp
engines/mads/madsv2/core/loader.cpp
engines/mads/madsv2/core/magic.cpp
engines/mads/madsv2/core/matte.cpp
engines/mads/madsv2/core/mcga.cpp
engines/mads/madsv2/core/mouse.cpp
engines/mads/madsv2/core/object.cpp
engines/mads/madsv2/core/pack.cpp
engines/mads/madsv2/core/pal.cpp
engines/mads/madsv2/core/pfab.cpp
engines/mads/madsv2/core/player.cpp
engines/mads/madsv2/core/popup.cpp
engines/mads/madsv2/core/quote.cpp
engines/mads/madsv2/core/rail.cpp
engines/mads/madsv2/core/room.cpp
engines/mads/madsv2/core/sort.cpp
engines/mads/madsv2/core/text.cpp
engines/mads/madsv2/core/tile.cpp
engines/mads/madsv2/core/vocab.cpp
engines/mads/madsv2/core/window.cpp
diff --git a/engines/mads/madsv2/core/anim.cpp b/engines/mads/madsv2/core/anim.cpp
index 4653ee676d1..411510420de 100644
--- a/engines/mads/madsv2/core/anim.cpp
+++ b/engines/mads/madsv2/core/anim.cpp
@@ -423,7 +423,7 @@ AnimPtr anim_load(const char *file_name, Buffer *orig, Buffer *depth,
// we'll get back a pointer to the actual sprite series for
// each id number
- /* printf("temp_buf=%s",temp_buf); keys_get(); */
+ // printf("temp_buf=%s",temp_buf); keys_get();
anim->series_id[count] = matte_load_series(temp_buf, load_flags, 0);
if (anim->series_id[count] < 0) {
anim_error = 9;
diff --git a/engines/mads/madsv2/core/buffer.cpp b/engines/mads/madsv2/core/buffer.cpp
index 636d2fc5702..db877b0f225 100644
--- a/engines/mads/madsv2/core/buffer.cpp
+++ b/engines/mads/madsv2/core/buffer.cpp
@@ -38,7 +38,7 @@ word pattern_initial_value = 0xb78e;
int auto_pattern = true;
int buffer_restore_keep_flag = false;
-static word accum; /* Pattern accumulator */
+static word accum; // Pattern accumulator
static Buffer buffer_preserve_conventional;
char buffer_disk_filename[8] = "$MPOP.$";
@@ -388,7 +388,7 @@ void buffer_line_xor(Buffer target, int x1, int y1, int x2, int y2) {
}
static inline byte ror8(byte val, int count) {
- count &= 7; /* ror by 8 is identity; keep in 0..7 */
+ count &= 7; // ror by 8 is identity; keep in 0..7
return (val >> count) | (val << (8 - count));
}
@@ -415,19 +415,19 @@ int buffer_legal(const Buffer &walk, int orig_wrap,
if (delta_x < 0) {
delta_x = -delta_x;
x_sign = -1;
- dAccum = (delta_y < delta_x) ? delta_x : delta_y; /* max, not min */
+ dAccum = (delta_y < delta_x) ? delta_x : delta_y; // max, not min
}
int x_count = delta_x + 1;
int y_count = delta_y + 1;
byte *ptr = walk.data + y1 * walk.x + (x1 / 8);
- int bit_pos = 8 - (x1 % 8); /* cl: 1=MSB side, 8=LSB side */
+ int bit_pos = 8 - (x1 % 8); // cl: 1=MSB side, 8=LSB side
for (int col = x_count; col > 0; col--) {
dAccum += y_count;
- bool blocked = (ror8(*ptr, bit_pos) & 1) != 0; /* carry from ror */
+ bool blocked = (ror8(*ptr, bit_pos) & 1) != 0; // carry from ror
if (blocked) {
if (!currently_illegal) {
currently_illegal = true;
@@ -453,7 +453,7 @@ int buffer_legal(const Buffer &walk, int orig_wrap,
ptr += y_sign;
}
- /* Advance one pixel in X */
+ // Advance one pixel in X
int new_cl = ((bit_pos - x_sign - 1) & 7) + 1;
if ((bit_pos - x_sign - 1) & ~7)
ptr += x_sign;
@@ -463,13 +463,15 @@ int buffer_legal(const Buffer &walk, int orig_wrap,
return legality;
}
-/* Advance the pattern accumulator one step. */
+/**
+ * Advance the pattern accumulator one step.
+ */
static void pattern_math(void) {
word bx = accum;
accum += pattern_control_value;
- bx = (bx >> 9) | (bx << 7); /* ror 9 */
+ bx = (bx >> 9) | (bx << 7); // ror 9
accum ^= bx;
- bx = (bx >> 3) | (bx << 13); /* ror 3 */
+ bx = (bx >> 3) | (bx << 13); // ror 3
accum += bx;
}
@@ -566,12 +568,12 @@ word buffer_rect_fill_pattern(Buffer target, int ul_x, int ul_y, int size_x, int
if (result) {
accum = pattern_initial_value;
- /* Wind the accumulator forward to account for rows above ul_y */
+ // Wind the accumulator forward to account for rows above ul_y
for (int row = 0; row < (ul_y - base_y); row++)
for (int col = 0; col < base_xs; col++)
pattern_math();
- /* Wind the accumulator forward to account for columns left of ul_x */
+ // Wind the accumulator forward to account for columns left of ul_x
for (int col = 0; col < (ul_x - base_x); col++)
pattern_math();
@@ -600,7 +602,7 @@ word buffer_rect_fill_pattern(Buffer target, int ul_x, int ul_y, int size_x, int
target_ptr += target_wrap;
- /* Wind accumulator past the columns not being drawn */
+ // Wind accumulator past the columns not being drawn
for (int col = 0; col < line_wrap; col++)
pattern_math();
}
@@ -650,12 +652,12 @@ void buffer_peel_horiz(Buffer *target, int peel) {
for (int row = 0; row < y; row++)
{
if (peel_sign > 0) {
- /* Save the first peel_val bytes, shift row left, append saved bytes at end */
+ // Save the first peel_val bytes, shift row left, append saved bytes at end
memcpy(temp_buf, scan, peel_val);
memmove(scan, scan + peel_val, x - peel_val);
memcpy(scan + x - peel_val, temp_buf, peel_val);
} else {
- /* Save the last peel_val bytes, shift row right, prepend saved bytes at start */
+ // Save the last peel_val bytes, shift row right, prepend saved bytes at start
memcpy(temp_buf, scan + x - peel_val, peel_val);
memmove(scan + peel_val, scan, x - peel_val);
memcpy(scan, temp_buf, peel_val);
@@ -688,9 +690,9 @@ void buffer_peel_vert(Buffer *target, int peel, byte *work_memory, long work_siz
}
if (peel_sign > 0) {
- /* Positive peel: rotate buffer upward by peel_val rows.
- Save the bottom peel_val rows, shift everything down,
- then place the saved rows at the top. */
+ // Positive peel: rotate buffer upward by peel_val rows.
+ // Save the bottom peel_val rows, shift everything down,
+ // then place the saved rows at the top.
byte *deep_scan = buffer_pointer(target, 0, (y - 1) - (peel_val - 1));
memcpy(work_area, deep_scan, peel_memory);
@@ -704,9 +706,9 @@ void buffer_peel_vert(Buffer *target, int peel, byte *work_memory, long work_siz
memcpy(scan, work_area, peel_memory);
} else {
- /* Negative peel: rotate buffer downward by peel_val rows.
- Save the top peel_val rows, shift everything up,
- then place the saved rows at the bottom. */
+ // Negative peel: rotate buffer downward by peel_val rows.
+ // Save the top peel_val rows, shift everything up,
+ // then place the saved rows at the bottom.
byte *deep_scan = buffer_pointer(target, 0, (y - 1) - (peel_val - 1));
memcpy(work_area, scan, peel_memory);
@@ -735,8 +737,7 @@ int buffer_preserve(Buffer *source, int flags, int source_ems_handle, int x, int
goto done;
}
- /* Try to preserve in conventional memory, if requested */
-
+ // Try to preserve in conventional memory, if requested
if (flags == BUFFER_ATTEMPT_CONVENTIONAL) {
buffer_init_name(&buffer_preserve_conventional, xs, ys, "$preserv");
if (buffer_preserve_conventional.data != NULL) {
@@ -747,15 +748,13 @@ int buffer_preserve(Buffer *source, int flags, int source_ems_handle, int x, int
}
}
- /* Try to preserve in EMS memory */
-
+ // Try to preserve in EMS memory
preserve_handle = buffer_to_ems(source, flags, source_ems_handle, x, y, xs, ys);
if (preserve_handle >= 0) {
goto done;
}
- /* Try to preserve on disk */
-
+ // Try to preserve on disk
if (flags != BUFFER_PRESERVE_RAM) {
disk_number = buffer_to_disk(source, x, y, xs, ys);
if (disk_number >= 0) {
diff --git a/engines/mads/madsv2/core/camera.cpp b/engines/mads/madsv2/core/camera.cpp
index 718fe6072b3..bb2482f8cdd 100644
--- a/engines/mads/madsv2/core/camera.cpp
+++ b/engines/mads/madsv2/core/camera.cpp
@@ -91,8 +91,7 @@ static int camera_pan(Camera *camera, int *picture_view, int *player_loc,
if (camera->pans) {
camera->pan_this_frame = false;
- /* Try to keep player & panning in synch */
-
+ // Try to keep player & panning in synch
if ((abs(camera->pan_clock - player.clock) < camera->pan_rate) &&
(player.frame_delay == camera->pan_rate)) {
determining_clock = player.clock;
diff --git a/engines/mads/madsv2/core/color.cpp b/engines/mads/madsv2/core/color.cpp
index ce9d832ecec..0f9c35e85c8 100644
--- a/engines/mads/madsv2/core/color.cpp
+++ b/engines/mads/madsv2/core/color.cpp
@@ -129,8 +129,7 @@ int color_list_update(ColorListPtr list, Buffer *scan_buf, Palette *scan_pal, by
color_flags[count] = (byte)true;
}
- /* First, deal with any colors involved in cycling */
-
+ // First, deal with any colors involved in cycling
if (cycle != NULL) {
for (cycle_count = 0; cycle_count < cycle->num_cycles; cycle_count++) {
lo = cycle->table[cycle_count].first_palette_color;
@@ -168,8 +167,7 @@ int color_list_update(ColorListPtr list, Buffer *scan_buf, Palette *scan_pal, by
}
}
- /* Now deal with any other colors used in the picture */
-
+ // Now deal with any other colors used in the picture
scan = (byte *)mem_normalize(scan_buf->data);
for (row = 0; row < scan_buf->y; row++) {
@@ -219,9 +217,8 @@ int color_list_update(ColorListPtr list, Buffer *scan_buf, Palette *scan_pal, by
scan = (byte *)mem_check_overflow(scan);
}
- /* Sort color list so that cycle colors appear first */
- /* The various tables must also be corrected. */
-
+ // Sort color list so that cycle colors appear first
+ // The various tables must also be corrected.
if (cycle != NULL) {
for (count = 0; count < list->num_colors; count++) {
cycle_value = list->table[count].cycle;
@@ -247,8 +244,7 @@ int color_list_update(ColorListPtr list, Buffer *scan_buf, Palette *scan_pal, by
}
memcpy(list, &temp_list, sizeof(ColorList));
- /* Switch cycle list color #'s from palette to list */
-
+ // Switch cycle list color #'s from palette to list
for (cycle_count = 0; cycle_count < cycle->num_cycles; cycle_count++) {
found = false;
for (count = 0; !found && (count < list->num_colors); count++) {
@@ -301,12 +297,10 @@ int color_list_palette(ColorListPtr list, Buffer *scan_buf, Palette *scan_pal, i
Color *c1ptr;
Palette out_pal;
- /* Make a copy of our starting palette */
-
+ // Make a copy of our starting palette
memcpy(out_pal, *scan_pal, sizeof(RGBcolor) * 256);
- /* Mark all list colors as unmapped */
-
+ // Mark all list colors as unmapped
for (count = 0; count < 256; count++) {
flags[count] = (byte)false;
}
diff --git a/engines/mads/madsv2/core/copy.cpp b/engines/mads/madsv2/core/copy.cpp
index 9999f08ca41..83cbe2ac799 100644
--- a/engines/mads/madsv2/core/copy.cpp
+++ b/engines/mads/madsv2/core/copy.cpp
@@ -101,7 +101,7 @@ static int copy_pop_and_ask() {
CopyProt copy_prot;
Common::SeekableReadStream *handle = NULL;
- box_param.erase_on_first = false; /* Allow keep of first letter */
+ box_param.erase_on_first = false; // Allow keep of first letter
if (copy_load(©_prot)) goto finish;
@@ -186,7 +186,7 @@ finish:
error_flag = COPY_SUCCEED;
done:
- box_param.erase_on_first = true; /* Reset */
+ box_param.erase_on_first = true; // Reset
delete handle;
if (load_buffer != NULL)
diff --git a/engines/mads/madsv2/core/dialog.cpp b/engines/mads/madsv2/core/dialog.cpp
index 2321fbd071d..f8ba367f1d6 100644
--- a/engines/mads/madsv2/core/dialog.cpp
+++ b/engines/mads/madsv2/core/dialog.cpp
@@ -115,6 +115,8 @@ int dialog_read_dir_to_list(ListPtr target, const char *wild, int dirflag) {
* Appends a list of valid drive letters to the end of the specified
* list structure. This is done by attempting to "change drive" to
* each drive letter beginning with "A", and stopping when an attempt fails.
+ *
+ * @param dirslist Directory list structure
*/
static void dialog_read_drives_to_list(ListPtr dirslist) {
char *myptr;
@@ -126,33 +128,32 @@ static void dialog_read_drives_to_list(ListPtr dirslist) {
/**
* Loads directory (and subdirectory list w/ drives) for a filename item
+ *
+ * @param dialog Dialog
+ * @param item Filename item
*/
static void dialog_load_directory(DialogPtr dialog, ItemPtr item) {
ItemPtr fileitem, dirsitem;
ListPtr filelist, dirslist;
- /* Get our file list item and dirs list item */
-
+ // Get our file list item and dirs list item
fileitem = &dialog->item[item->status];
dirsitem = &dialog->item[fileitem->id + 1];
- /* Get the associated list structures */
-
+ // Get the associated list structures
filelist = &dialog->lists[fileitem->buf_id];
dirslist = &dialog->lists[dirsitem->buf_id];
filelist->elements = 0;
dirslist->elements = 0;
- /* Try to read them in */
-
+ // Try to read them in
dialog_read_dir_to_list(dirslist, "*.*", true);
dialog_read_dir_to_list(filelist, dialog->buffer[item->buf_id], false);
dialog_read_drives_to_list(dirslist);
- /* Reset window cursors */
-
+ // Reset window cursors
filelist->base_entry = 0;
dirslist->base_entry = 0;
@@ -163,7 +164,12 @@ static void dialog_load_directory(DialogPtr dialog, ItemPtr item) {
/**
* Item to determine the proper X and Y values for an item based
* on the X and Y values passed by the user (handles the various
- * special codes).
+ * special codes).
+ *
+ * @param dialog Dialog
+ * @param item Filename item
+ * @param x X position
+ * @param y Y position
*/
static void item_locate(DialogPtr dialog, ItemPtr item, int x, int y) {
switch (x) {
@@ -209,6 +215,10 @@ static void item_locate(DialogPtr dialog, ItemPtr item, int x, int y) {
/**
* Attempts to allocate a new item handle from the dialog box's
* item array. Returns NULL if fails.
+ *
+ * @param dialog Dialog Dialog
+ * @param item_type Item type
+ * @return New item
*/
static ItemPtr item_allocate(DialogPtr dialog, int item_type) {
ItemPtr item;
@@ -244,6 +254,9 @@ done:
/**
* Attempts to allocate one of the dialog box's string buffers.
* Returns -1 if no buffer was available.
+ *
+ * @param dialog Dialog
+ * @return Buffer handle
*/
static int buffer_allocate(DialogPtr dialog) {
int my_buffer = -1;
@@ -269,6 +282,9 @@ done:
/**
* Attempts to allocate one of the dialog box's list window structures.
* Returns -1 if all are in use.
+ *
+ * @param dialog Dialog
+ * @return List window structure handle
*/
static int list_allocate(DialogPtr dialog) {
int my_list;
@@ -288,6 +304,9 @@ static int list_allocate(DialogPtr dialog) {
* Returns the "hotkey" keystroke value, if any, for the
* passed string. Returns 0 if no hotkey found. Hotkeys
* are marked by preceding "~" characters.
+ *
+ * @param prompt Prompt
+ * @return Keystroke value
*/
static int get_keystroke(const char *prompt) {
const char *key_finder;
@@ -325,9 +344,8 @@ ItemPtr dialog_add_button(DialogPtr dialog, int x, int y, const char *prompt) {
item->x2 = -1;
- /* Adjust cursor location to appear over the first letter (not */
- /* over a space). */
-
+ // Adjust cursor location to appear over the first letter (not
+ // over a space).
for (space_look = 0; ((unsigned)space_look < strlen(prompt)) && (item->x2 < 0); space_look++) {
if (prompt[space_look] != ' ') item->x2 = space_look + 1;
}
@@ -372,7 +390,7 @@ ItemPtr dialog_add_checkbox(DialogPtr dialog, int x, int y, const char *prompt,
item_locate(dialog, item, x, y);
item->x2 = 1;
- item->status = (!!default_val) & DD_CHECK_TRUE; /* (sic) */
+ item->status = (!!default_val) & DD_CHECK_TRUE; // (sic)
dialog->width = MAX<short>(dialog->width, (item->x + item->width + 1));
@@ -447,8 +465,7 @@ ItemPtr dialog_add_string(DialogPtr dialog, int x, int y, const char *prompt,
item->x2 = strlen(prompt) + 1;
- /* Account for any hotkey stroke in setting proper cursor location */
-
+ // Account for any hotkey stroke in setting proper cursor location
if (strchr(prompt, '~') != NULL) {
item->width--;
item->x2--;
@@ -460,8 +477,7 @@ ItemPtr dialog_add_string(DialogPtr dialog, int x, int y, const char *prompt,
item->prompt = space;
Common::strcpy_s(item->prompt, 65536, prompt);
- /* Set up a buffer in the dialog's buffer space */
-
+ // Set up a buffer in the dialog's buffer space
item->buf_width = width;
item->buf_id = buffer_allocate(dialog);
@@ -472,8 +488,7 @@ ItemPtr dialog_add_string(DialogPtr dialog, int x, int y, const char *prompt,
} else {
- /* Copy the default value (if any) into the buffer */
-
+ // Copy the default value (if any) into the buffer
if (default_val != NULL) {
Common::strcpy_s(dialog->buffer[item->buf_id], 65536, default_val);
if (strlen(default_val) > (unsigned)width) {
@@ -485,8 +500,7 @@ ItemPtr dialog_add_string(DialogPtr dialog, int x, int y, const char *prompt,
default_val = &dialog->buffer[item->buf_id][0];
}
- /* Mark the entire buffer contents as "selected" */
-
+ // Mark the entire buffer contents as "selected"
dialog->buf_status[item->buf_id] = 0;
dialog->buf_base_x[item->buf_id] = item->x2;
if (strlen(default_val) > 0) {
@@ -511,12 +525,10 @@ ItemPtr dialog_add_listbased(DialogPtr dialog, int x, int y, const char *prompt,
int listnum;
int temp_width;
- /* First, just add the normal string entry area part */
-
+ // First, just add the normal string entry area part
item = dialog_add_string(dialog, x, y, prompt, default_val, width);
- /* Then, do all the additional stuff for a list window */
-
+ // Then, do all the additional stuff for a list window
if (item != NULL) {
item->type = DD_I_LISTBASED;
@@ -555,8 +567,7 @@ ItemPtr dialog_add_listbased(DialogPtr dialog, int x, int y, const char *prompt,
list->picked_entry = -1;
list->thumb = -1;
- /* Set items up to point at one another */
-
+ // Set items up to point at one another
item->status = listitem->id;
listitem->status = item->id;
listitem->buf_id = listnum;
@@ -585,12 +596,10 @@ ItemPtr dialog_append_list(DialogPtr dialog, int x, int y, ItemPtr base_string,
int listnum;
int temp_width;
- /* First, just add the normal string entry area part */
-
+ // First, just add the normal string entry area part
item = base_string;
- /* Then, do all the additional stuff for a list window */
-
+ // Then, do all the additional stuff for a list window
if (item != NULL) {
listitem = item_allocate(dialog, DD_I_LIST);
@@ -627,8 +636,7 @@ ItemPtr dialog_append_list(DialogPtr dialog, int x, int y, ItemPtr base_string,
list->picked_entry = -1;
list->thumb = -1;
- /* Set items up to point at one another */
-
+ // Set items up to point at one another
listitem->status = item->id;
listitem->buf_id = listnum;
@@ -659,7 +667,7 @@ ItemPtr dialog_add_filename(DialogPtr dialog, int x, int y, const char *prompt,
char mypath2[80];
int mydrive;
- dialog->status |= DD_FILEMENU; /* Note that we do in fact use files */
+ dialog->status |= DD_FILEMENU; // Note that we do in fact use files
base_item = dialog->num_items;
@@ -783,8 +791,7 @@ void dialog_set_string_space(DialogPtr dialog, char *space, long size) {
DialogPtr dialog_create(DialogPtr dialog, int ul_x, int ul_y, int width,
int normal_color, int select_color, int hilite_color) {
- /* Allocate memory for dialog if necessary */
-
+ // Allocate memory for dialog if necessary
if (dialog == NULL) {
dialog = (DialogPtr)mem_get(sizeof(struct DialogBox));
dialog->status = DD_DYNAMIC;
@@ -938,12 +945,13 @@ void dialog_set_checkbox_callback(DialogPtr dialog, void (*(callback))()) {
}
/**
- *
* Computes all necessary item coordinates and sizes => resolves
* all "indefinite" coordinates (i.e. centered dialogs, etc) into
* proper absolute screen coordinates (or dialog-relative coordinates)
* in preparation for actually executing the dialog.
-*/
+ *
+ * @param dialog Dialog
+ */
static void dialog_compute_window(DialogPtr dialog) {
int height;
int count;
@@ -954,8 +962,7 @@ static void dialog_compute_window(DialogPtr dialog) {
ItemPtr item;
ListPtr list;
- /* Find out if there's anything scheduled for the "button row" */
-
+ // Find out if there's anything scheduled for the "button row"
dialog->button_flag = false;
extra_height = 2;
@@ -966,7 +973,7 @@ static void dialog_compute_window(DialogPtr dialog) {
}
}
- /* Figure out which checkbox items are in the same class as another */
+ // Figure out which checkbox items are in the same class as another
for (count = 0; count < dialog->num_items; count++) {
if (dialog->item[count].type == DD_I_CHECKBOX) {
for (count2 = 0; count2 < dialog->num_items; count2++) {
@@ -982,13 +989,11 @@ static void dialog_compute_window(DialogPtr dialog) {
}
}
- /* Conform the dialog to the width of the button row, if necessary */
-
+ // Conform the dialog to the width of the button row, if necessary
button_width = (dialog->button_left + abs(dialog->button_right) + 1);
dialog->width = MAX<short>(dialog->width, button_width);
- /* Center the dialog box, if requested */
-
+ // Center the dialog box, if requested
if (dialog->window.ul_x == DD_CENTER) {
center = screen_center_x ? screen_center_x : ((screen_max_x + 1) >> 1);
dialog->window.ul_x = (center - ((dialog->width + 3) >> 1));
@@ -1003,13 +1008,11 @@ static void dialog_compute_window(DialogPtr dialog) {
dialog->base_y = dialog->window.ul_y + 1;
}
- /* Get the lower left dialog coordinates */
-
+ // Get the lower left dialog coordinates
dialog->window.lr_x = dialog->window.ul_x + dialog->width + 1;
dialog->window.lr_y = dialog->window.ul_y + height - 1;
- /* Resolve any right-margin relative items and compute all list windows */
-
+ // Resolve any right-margin relative items and compute all list windows
for (count = 0; count < dialog->num_items; count++) {
item = &dialog->item[count];
@@ -1078,6 +1081,9 @@ char *dialog_read_filepath(DialogPtr dialog, ItemPtr item) {
/**
* Updates the status of a dialog box based on its status flag
+ *
+ * @param dialog Dialog
+ * @param item
*/
static void dialog_update_checkbox(DialogPtr dialog, ItemPtr item) {
char temp1[2];
@@ -1105,6 +1111,9 @@ static void dialog_update_checkbox(DialogPtr dialog, ItemPtr item) {
/**
* Displays the specified dialog string item's buffer, highlighting
* any selected text if the item is currently active.
+ *
+ * @param dialog Dialog
+ * @param item Item
*/
static void dialog_update_string(DialogPtr dialog, ItemPtr item) {
int buf;
@@ -1124,8 +1133,7 @@ static void dialog_update_string(DialogPtr dialog, ItemPtr item) {
screenptr = screen + screen_char_add(cx, cy);
textptr = dialog->buffer[buf];
- /* First, output as much of the string as we can */
-
+ // First, output as much of the string as we can
while ((*textptr != 0) && (out_count < item->buf_width)) {
*(screenptr++) = *(textptr++);
if (dialog->buf_select[buf] && (item->id == dialog->active_item) &&
@@ -1138,8 +1146,7 @@ static void dialog_update_string(DialogPtr dialog, ItemPtr item) {
out_count++;
}
- /* Then, be sure the rest of the entry area is cleared */
-
+ // Then, be sure the rest of the entry area is cleared
while (out_count < item->buf_width) {
*(screenptr++) = 0x20;
if (dialog->buf_select[buf] &&
@@ -1157,6 +1164,9 @@ static void dialog_update_string(DialogPtr dialog, ItemPtr item) {
/**
* Updates the list window associated with an item.
+ *
+ * @param dialog Dialog
+ * @param item Item
*/
static void dialog_update_window(DialogPtr dialog, ItemPtr item) {
int row, col;
@@ -1180,24 +1190,20 @@ static void dialog_update_window(DialogPtr dialog, ItemPtr item) {
list = &dialog->lists[item->buf_id];
- /* Clear our old cursor off by wipe-ing the window in a single color */
-
+ // Clear our old cursor off by wipe-ing the window in a single color
window_color(&list->window, dialog->normal_color);
- /* Now, go through the rows and columns one by one, displaying each entry */
-
+ // Now, go through the rows and columns one by one, displaying each entry
for (col = 0; col < list->columns; col++) {
for (row = 0; row < list->rows; row++) {
screenptr = screen + screen_char_add(list->base_x + (col * (list->entry_width + 1)),
list->base_y + row);
id = list->base_entry + row + (col * list->rows);
- /* Point at the text for this entry */
-
+ // Point at the text for this entry
textptr = list->list + (id * list->element_offset);
- /* Check if the cursor is on this item */
-
+ // Check if the cursor is on this item
if (id != list->picked_entry) {
my_color = dialog->normal_color;
} else {
@@ -1230,9 +1236,8 @@ static void dialog_update_window(DialogPtr dialog, ItemPtr item) {
}
- /* Update the thumb mark in a scroll bar; routine is different */
- /* depending on whether bar is vertical or horizontal */
-
+ // Update the thumb mark in a scroll bar; routine is different
+ // depending on whether bar is vertical or horizontal
temp_pick = list->picked_entry;
if (temp_pick < 0) temp_pick = 0;
@@ -1293,6 +1298,10 @@ static void dialog_update_window(DialogPtr dialog, ItemPtr item) {
* currently being picked by the mouse. Otherwise, the angle
* brackets are automatically highlighted if the button is the
* active button.
+ *
+ * @param dialog Dialog
+ * @param item Button item
+ * @param selected Selected flag
*/
static void dialog_show_button(DialogPtr dialog, ItemPtr item, int selected) {
int angle_color, text_color, hi_color;
@@ -1329,6 +1338,9 @@ static void dialog_show_button(DialogPtr dialog, ItemPtr item, int selected) {
/**
* Outputs a dialog message string at the appropriate location
* in the dialog box.
+ *
+ * @param dialog Dialog
+ * @param item Message string
*/
static void dialog_show_message(DialogPtr dialog, ItemPtr item) {
mouse_hide();
@@ -1348,6 +1360,9 @@ static void dialog_show_message(DialogPtr dialog, ItemPtr item) {
* Currently, the only kind of message that could change (and thus
* need to be cleared) is the pathname for file items, which is
* handled internally.
+ *
+ * @param dialog Dialog
+ * @param item Message item
*/
static void dialog_clear_message(DialogPtr dialog, ItemPtr item) {
int cx, cy;
@@ -1368,6 +1383,9 @@ static void dialog_clear_message(DialogPtr dialog, ItemPtr item) {
/**
* Displays (and updates) a checkbox item
+ *
+ * @param dialog Dialog
+ * @param item Checkbox item
*/
static void dialog_show_checkbox(DialogPtr dialog, ItemPtr item) {
int cx;
@@ -1402,6 +1420,9 @@ static void dialog_show_checkbox(DialogPtr dialog, ItemPtr item) {
/**
* Displays (and updates) a string item
+ *
+ * @param dialog Dialog
+ * @param item String item
*/
static void dialog_show_string(DialogPtr dialog, ItemPtr item) {
int cx;
@@ -1421,6 +1442,9 @@ static void dialog_show_string(DialogPtr dialog, ItemPtr item) {
/**
* Displays (and updates) a list-based item (including file lists)
+ *
+ * @param dialog Dialog
+ * @param item List-based item
*/
static void dialog_show_window(DialogPtr dialog, ItemPtr item) {
ListPtr list;
@@ -1451,6 +1475,9 @@ static void dialog_show_window(DialogPtr dialog, ItemPtr item) {
/**
* Displays the item whose handle is passed, no matter what type
* of item it is (calls the appropriate one of the above routines)
+ *
+ * @param dialog Dialog
+ * @param item Item
*/
static void dialog_show_any(DialogPtr dialog, ItemPtr item) {
switch (item->type) {
@@ -1522,6 +1549,10 @@ void dialog_show_all(DialogPtr dialog) {
/**
* Routine to update the item whose handle is passed to it, no matter
* what type of item it is.
+ *
+ * @param dialog Dialog
+ * @param item Item
+ * @param mouse_button_flag Mouse button flag
*/
static void dialog_update_any(DialogPtr dialog, ItemPtr item, int mouse_button_flag) {
switch (item->type) {
@@ -1553,6 +1584,8 @@ static void dialog_update_any(DialogPtr dialog, ItemPtr item, int mouse_button_f
/**
* Moves the cursor to the active item, at the appropriate place
* within that item (appropriate place depends on item type)
+ *
+ * @param dialog Dialog
*/
static void dialog_update_cursor(DialogPtr dialog) {
ListPtr list;
@@ -1603,14 +1636,15 @@ static void dialog_update_cursor(DialogPtr dialog) {
/**
* Routine to update & move the cursor to the active item, after
* possibly changing the active item.
- *
- * displace = "displacement" by which to change the active item #.
- * 0 to leave active item unchanged. Item #'s will loop
- * around.
- *
* If active item changes, then the old active item will be
* updated also, to make sure its appearance conforms to its
* new, inactive, status.
+ *
+ * @param dialog Dialog
+ * @param displace "Displacement" by which to change the active
+ * item #. 0 to leave active item unchanged. Item #'s will loop around.
+ * @param mouse_button_flag Mouse button flag
+ * @param out_of_class Out of class flag
*/
static void dialog_update_active(DialogPtr dialog, int displace, int mouse_button_flag, int out_of_class) {
int old_item;
@@ -1762,6 +1796,8 @@ done:
/**
* If a sub-string was being selected in the dialog box, cancel
* that selection.
+ *
+ * @param dialog Dialog
*/
static void dialog_cancel_selection(DialogPtr dialog) {
ItemPtr item;
@@ -1782,6 +1818,8 @@ static void dialog_cancel_selection(DialogPtr dialog) {
/**
* If a substring was being selected in the dialog, erase that substring.
+ *
+ * @param dialog Dialog
*/
static void dialog_wipe_selection(DialogPtr dialog) {
ItemPtr item;
@@ -1825,6 +1863,9 @@ static void dialog_wipe_selection(DialogPtr dialog) {
/**
* Routine to move the cursor within a string item
+ *
+ * @param dialog Dialog
+ * @param displace Displacement amount
*/
static void dialog_move_cursor(DialogPtr dialog, int displace) {
ItemPtr item;
@@ -1858,6 +1899,9 @@ static void dialog_move_cursor(DialogPtr dialog, int displace) {
/**
* Routine to insert a character into the active string item,
* at the current cursor location.
+ *
+ * @param dialog Dialog
+ * @param mykey Character
*/
static void dialog_string_insert(DialogPtr dialog, int mykey) {
ItemPtr item;
@@ -1915,6 +1959,8 @@ static void dialog_string_insert(DialogPtr dialog, int mykey) {
/**
* Routine to delete a character or selection from the active
* string item, at the current cursor location.
+ *
+ * @param dialog Dialog
*/
static void dialog_string_delete(DialogPtr dialog) {
ItemPtr item;
@@ -1939,6 +1985,8 @@ static void dialog_string_delete(DialogPtr dialog) {
/**
* Routine to execute the "backspace key" function on the active
* string item
+ *
+ * @param dialog Dialog
*/
static void dialog_string_backspace(DialogPtr dialog) {
ItemPtr item;
@@ -1975,6 +2023,10 @@ static void dialog_string_backspace(DialogPtr dialog) {
* Routine to check if two strings are equivalent for at least
* the entire length of the second, shorter, string. Compare
* is done without regard for case.
+ *
+ * @param big Big string
+ * @param little Substring
+ * @return Comparison result
*/
static int dialog_quick_compare(const char *big, const char *little) {
int biglen, litlen;
@@ -2000,6 +2052,11 @@ static int dialog_quick_compare(const char *big, const char *little) {
/**
* Routine to find the item in a list window that most closely matches
* a given string.
+ *
+ * @param dialog Dialog
+ * @param item Item
+ * @param checkstring Matching string
+ * @return Item index
*/
static int dialog_quick_search(DialogPtr dialog, ItemPtr item, const char *checkstring) {
ListPtr list;
@@ -2029,6 +2086,9 @@ done:
* extra text of the found entry is loaded to the right of the cursor
* and is "selected" so that if the user types another letter key the
* extraneous text will be automatically removed.
+ *
+ * @param dialog Dialog
+ * @param item Item
*/
static void dialog_do_search(DialogPtr dialog, ItemPtr item) {
ItemPtr listitem;
@@ -2049,8 +2109,7 @@ static void dialog_do_search(DialogPtr dialog, ItemPtr item) {
match = dialog_quick_search(dialog, listitem, dialog->buffer[buf]);
- /* Get an appropriate view of the window which will make our entry visible */
-
+ // Get an appropriate view of the window which will make our entry visible
if (match >= 0) {
if ((match >= list->base_entry) && (match < (list->base_entry + (list->rows * list->columns)))) {
list->picked_entry = match;
@@ -2090,9 +2149,8 @@ static void dialog_do_search(DialogPtr dialog, ItemPtr item) {
newlen = strlen(dialog->buffer[buf]);
- /* Now, "case magic" attempts to conform the case of the searched-in */
- /* string to the case format that the user is typing. */
-
+ // Now, "case magic" attempts to conform the case of the searched-in
+ // string to the case format that the user is typing.
case_magic = false;
if (mylen > 0) {
@@ -2132,6 +2190,9 @@ static void dialog_do_search(DialogPtr dialog, ItemPtr item) {
/**
* Routine to change the directory of the filename window
+ *
+ * @param dialog Dialog
+ * @param item Item
*/
static void dialog_set_new_directory(DialogPtr dialog, ItemPtr item) {
int buf;
@@ -2146,7 +2207,7 @@ static void dialog_set_new_directory(DialogPtr dialog, ItemPtr item) {
pathitem = dialog->path_item;
#ifdef TODO
if (temp_buf[1] == ':') {
- /* Change to a new drive, if requested */
+ // Change to a new drive, if requested
newdrive = ((int)temp_buf[0]) - 64;
mads_chdrive(newdrive);
@@ -2156,7 +2217,7 @@ static void dialog_set_new_directory(DialogPtr dialog, ItemPtr item) {
Common::strcpy_s(pathitem->prompt, 65536, temp_buf);
} else {
- /* otherwise, change to a new directory */
+ // otherwise, change to a new directory
mads_chdir(temp_buf);
dialog_clear_message(dialog, pathitem);
@@ -2169,8 +2230,7 @@ static void dialog_set_new_directory(DialogPtr dialog, ItemPtr item) {
}
}
- /* Load a wildcard into the entry area */
-
+ // Load a wildcard into the entry area
if ((strchr(dialog->buffer[buf], '*') == NULL) &&
(strchr(dialog->buffer[buf], '?') == NULL)) {
Common::strcpy_s(dialog->buffer[buf], "*.*");
@@ -2180,8 +2240,7 @@ static void dialog_set_new_directory(DialogPtr dialog, ItemPtr item) {
dialog->buf_seltarget[buf] = 3;
}
- /* Load up the new directory and display */
-
+ // Load up the new directory and display
dialog_load_directory(dialog, baseitem);
dialog_show_any(dialog, pathitem);
dialog_update_any(dialog, baseitem, false);
@@ -2196,6 +2255,10 @@ static void dialog_set_new_directory(DialogPtr dialog, ItemPtr item) {
/**
* Routine to handle scrolling around in a list window. Used to
* drive both mouse and cursor scroll routines.
+ *
+ * @param dialog Dialog
+ * @param item Item
+ * @param direction Scroll direction
*/
static void dialog_scroll_list(DialogPtr dialog, ItemPtr item, int direction) {
int my_dif, my_col, my_row;
@@ -2331,6 +2394,10 @@ static void dialog_scroll_list(DialogPtr dialog, ItemPtr item, int direction) {
/**
* Routine to allow keyboard scrolling within a list window
+ *
+ * @param dialog Dialog
+ * @param item Item
+ * @param mykey Scrolling character
*/
static void dialog_key_exec_list(DialogPtr dialog, ItemPtr item, int mykey) {
ItemPtr baseitem;
@@ -2387,6 +2454,10 @@ static void dialog_key_exec_list(DialogPtr dialog, ItemPtr item, int mykey) {
/**
* Returns true if the mouse is in the specified item.
+ *
+ * @param dialog Dialog
+ * @param count Item index
+ * @return True if mouse is within the item
*/
static int in_item(DialogPtr dialog, int count) {
ItemPtr item;
@@ -2446,6 +2517,10 @@ static int in_item(DialogPtr dialog, int count) {
/**
* If the mouse has been pressed within a scroll bar area, returns
* the proper type of action to be taken.
+ *
+ * @param list Listbox
+ * @param button Button number
+ * @return Action to be taken
*/
static int in_scroll_box(ListPtr list, int button) {
int result;
@@ -2496,6 +2571,9 @@ static int in_scroll_box(ListPtr list, int button) {
/**
* Routine to handle selection of a substring with the mouse
+ *
+ * @param dialog Dialog
+ * @param item String item
*/
static void dialog_exec_mouse_string(DialogPtr dialog, ItemPtr item) {
int buf;
@@ -2525,6 +2603,9 @@ static void dialog_exec_mouse_string(DialogPtr dialog, ItemPtr item) {
/**
* Routine to deal with the mouse when it is doing something
* in a list window (clicking, double-clicking, or dragging).
+ *
+ * @param dialog Dialog
+ * @param item Item
*/
static void dialog_exec_mouse_list(DialogPtr dialog, ItemPtr item) {
ListPtr list;
@@ -2549,8 +2630,7 @@ static void dialog_exec_mouse_list(DialogPtr dialog, ItemPtr item) {
} else {
looking = true;
- /* Find out which list entry is being picked */
-
+ // Find out which list entry is being picked
for (col = 0; (col < list->columns) && (looking); col++) {
for (row = 0; (row < list->rows) && (looking); row++) {
look_x = list->base_x + ((list->entry_width + 1) * col);
@@ -2575,8 +2655,7 @@ static void dialog_exec_mouse_list(DialogPtr dialog, ItemPtr item) {
abort = false;
- /* Handle double-click if any */
-
+ // Handle double-click if any
if (mouse_start_stroke && (old_pick == list->picked_entry)) {
if ((long)timer_read_dos() <= mouse_list_timing + MOUSE_DOUBLE_TIMING) {
if (item->type == DD_I_DIRSLIST) {
@@ -2602,8 +2681,7 @@ static void dialog_exec_mouse_list(DialogPtr dialog, ItemPtr item) {
}
}
- /* Handle click-and-drag */
-
+ // Handle click-and-drag
if (looking && (mouse_start_stroke || ((long)timer_read_dos() >= mouse_drag_timing))) {
mouse_override = true;
mouse_drag_timing = (long)timer_read_dos() + MOUSE_TIMING_TWO;
@@ -2634,6 +2712,9 @@ static void dialog_exec_mouse_list(DialogPtr dialog, ItemPtr item) {
* Deals with the mouse when it is in a scroll bar. Calls
* dialog_scroll_list () for most functions, but handles click-and-drag
* on the thumb mark itself.
+ *
+ * @param dialog Dialog
+ * @param item Item
*/
static void dialog_exec_mouse_scroll(DialogPtr dialog, ItemPtr item) {
ListPtr list;
@@ -2723,6 +2804,8 @@ void dialog_set_stroke_type(DialogPtr dialog, int type, int toggle) {
* Called whenever a mouse stroke is detected; loops until the
* mouse button is released. Performs whatever actions are necessary
* to execute the mouse function.
+ *
+ * @param dialog Dialog
*/
static void dialog_exec_mouse(DialogPtr dialog) {
int count, count2;
@@ -2734,7 +2817,7 @@ static void dialog_exec_mouse(DialogPtr dialog) {
mouse_init_cycle();
- mouse_stroke_going = false; /* (so that "start stroke" will be true) */
+ mouse_stroke_going = false; // (so that "start stroke" will be true)
mouse_stroke_type = DD_MC_NONE;
mouse_override = false;
@@ -3220,7 +3303,6 @@ ItemPtr dialog_execute(DialogPtr dialog, ItemPtr active_item, ItemPtr default_bu
return item;
}
-
char *dialog_select_file(const char *prompt, const char *path, const char *filespec, char *output) {
DialogPtr dialog;
ItemPtr ok, first_item, result;
@@ -3266,7 +3348,7 @@ char *dialog_enter_string(char *reply, const char *top_prompt, const char *left_
ItemPtr string, ok, cancel, result;
if (strlen(my_default) > (size_t)maxlen)
- my_default[maxlen - 1] = 0; /* Trim default */
+ my_default[maxlen - 1] = 0; // Trim default
if (left_prompt == NULL)
Common::strcpy_s(work, "~Reply: ");
diff --git a/engines/mads/madsv2/core/env.cpp b/engines/mads/madsv2/core/env.cpp
index 22d1fbf2089..f044f3a8876 100644
--- a/engines/mads/madsv2/core/env.cpp
+++ b/engines/mads/madsv2/core/env.cpp
@@ -288,7 +288,7 @@ char *env_get_path(char *madspath, const char *infile) {
}
Common::strcat_s(madspath, 65536, CONCAT_EXT);
- /* returns 'global.hag', 'section9.hag', etc */
+ // returns 'global.hag', 'section9.hag', etc
}
}
@@ -321,7 +321,7 @@ Common::SeekableReadStream *env_open(const char *filename, const char *options)
mads_strupr(file_path);
- /* if CD version and checking RAW or RAC file */
+ // If CD version and checking RAW or RAC file
if (env_search_cd && (strstr(file_path, ".RAW") || strstr(file_path, ".RAC"))) {
Common::strcpy_s(check_buf, env_speech1_string);
Common::strcat_s(check_buf, env_slash_string);
@@ -331,7 +331,7 @@ Common::SeekableReadStream *env_open(const char *filename, const char *options)
} else {
Common::strcat_s(check_buf, file_path);
}
- /* Common::strcat_s (check_buf, temp_buf); */
+
Common::strcpy_s(load_file, check_buf);
if (fileio_exist(load_file)) {
@@ -355,7 +355,6 @@ Common::SeekableReadStream *env_open(const char *filename, const char *options)
Common::strcat_s(check_buf, file_path);
}
- /* Common::strcat_s (check_buf, temp_buf); */
Common::strcpy_s(load_file, check_buf);
if (fileio_exist(load_file)) {
@@ -379,17 +378,16 @@ Common::SeekableReadStream *env_open(const char *filename, const char *options)
Common::strcpy_s(temp_buf, mark);
mads_strupr(temp_buf);
- /* load_file = 'global.hag' */
+ // Load_file = 'global.hag'
if (art_hags_are_on_hd) {
Common::strcpy_s(index_file, load_file);
} else {
fileio_new_ext(index_file, load_file, "IDX");
}
- /* index_file = 'global.idx' */
-
+ // Index_file = 'global.idx'
if (env_search_cd && !art_hags_are_on_hd) {
if (fileio_exist(index_file)) {
- /* if 'global.idx' exists */
+ // If 'global.idx' exists
Common::File *f = new Common::File();
f->open(index_file);
assert(f->isOpen());
@@ -404,7 +402,7 @@ Common::SeekableReadStream *env_open(const char *filename, const char *options)
if (!fileio_exist(load_file)) {
if (env_verify()) {
- /* 'MADS' is set in DOS environment */
+ // 'MADS' is set in DOS environment
Common::strcpy_s(temp_file, load_file);
Common::strcpy_s(load_file, ConfMan.get(MADS_ENV).c_str());
Common::strcat_s(load_file, "\\");
@@ -486,7 +484,7 @@ int env_exist(const char *filename) {
Common::strcpy_s(file_name, filename);
mads_strupr(file_name);
- /* if CD version and checking RAW or RAC file */
+ // If CD version and checking RAW or RAC file
if (env_search_cd && (strstr(file_name, ".RAW") || strstr(file_name, ".RAC"))) {
Common::strcpy_s(check_buf, env_speech1_string);
@@ -539,7 +537,7 @@ char *env_get_level_path(char *out, int item_type, const char *file_spec, int fi
if ((item_type == SECTION) || (item_type == ROOM)) {
if ((item_type == ROOM) && (first_level == 0)) {
first_level = second_level / 100;
- /* first_level = room_get_section (second_level); */
+ // first_level = room_get_section (second_level);
}
}
@@ -618,12 +616,12 @@ char *env_next(char *variable) {
}
char *env_find_end(char *environment) {
- /* Scan through variables */
+ // Scan through variables
while (*environment) {
environment = env_next(environment);
}
- /* Scan past load name if exists */
+ // Scan past load name if exists
if ((*(environment + 1) == 1) && (*(environment + 2) == 0)) {
environment += 3;
while (*environment) {
@@ -631,7 +629,7 @@ char *env_find_end(char *environment) {
}
}
- /* Point to byte after everything */
+ // Point to byte after everything
environment++;
return environment;
@@ -706,22 +704,21 @@ int env_insert(char *environment, char *variable, char *value) {
Common::strcpy_s(var_name, variable);
mads_strupr(var_name);
- /* Delete any previous copy of this variable */
+ // Delete any previous copy of this variable
env_delete(environment, var_name);
- /* Prepare full string for insertion */
+ // Prepare full string for insertion
Common::strcpy_s(var_string, var_name);
Common::strcat_s(var_string, "=");
Common::strcat_s(var_string, value);
- /* Get size of string & check of there is space in the environment */
+ // Get size of string & check of there is space in the environment
new_size = strlen(var_string) + 1;
free = env_free(environment);
if (new_size > free) goto done;
- /* Find end of environment (for new string). Also find end of whole */
- /* environment structure (must be moved out of the way). */
-
+ // Find end of environment (for new string). Also find end of whole
+ // environment structure (must be moved out of the way).
target = environment;
while (*target) {
target = env_next(target);
@@ -731,7 +728,7 @@ int env_insert(char *environment, char *variable, char *value) {
copy_size = bottom - target;
new_home = target + new_size;
- /* Insert string */
+ // Insert string
memmove(new_home, target, copy_size);
memmove(target, var_string, new_size);
diff --git a/engines/mads/madsv2/core/fileio.cpp b/engines/mads/madsv2/core/fileio.cpp
index fbcee18c714..676c0ca2e4d 100644
--- a/engines/mads/madsv2/core/fileio.cpp
+++ b/engines/mads/madsv2/core/fileio.cpp
@@ -238,7 +238,7 @@ char *fileio_read_header(char *target, Common::SeekableReadStream *handle) {
mark++;
count++;
}
- (void)handle->readByte(); /* Throw away EOF mark */
+ (void)handle->readByte(); // Throw away EOF mark
return target;
}
@@ -252,7 +252,7 @@ void fileio_write_header(char *text, Common::WriteStream *handle) {
text++;
handle->writeByte(next);
}
- handle->writeByte(26); /* Write fake EOF mark */
+ handle->writeByte(26); // Write fake EOF mark
}
char *fileio_get_line(char *target, Common::SeekableReadStream *handle) {
diff --git a/engines/mads/madsv2/core/font.cpp b/engines/mads/madsv2/core/font.cpp
index 5092483c775..3eed447ac54 100644
--- a/engines/mads/madsv2/core/font.cpp
+++ b/engines/mads/madsv2/core/font.cpp
@@ -150,23 +150,23 @@ int font_write(FontPtr font, Buffer *target, const char *out_string,
screen_loc = x;
for (char *str = temp_buf; *str != '\0'; str++) {
- /* char_loop: decrement character for pointer (original did dec dl / jns),
- so '\0' (0) decrements to -1 (negative) and exits. Characters are
- 1-based indices into the font table. */
+ // char_loop: decrement character for pointer (original did dec dl / jns),
+ // so '\0' (0) decrements to -1 (negative) and exits. Characters are
+ // 1-based indices into the font table.
byte ch_idx = (byte)(*str - 1);
byte char_width = font->width[ch_idx];
if (char_width == 0)
- continue; /* char_next with zero width: no spacing applied */
+ continue; // char_next with zero width: no spacing applied
screen_loc += char_width;
if (screen_loc >= target_wrap)
- break; /* terminate */
+ break; // Terminate
- /* Locate the character's pixel data in the font, skipping clipped rows.
- Each row of a character is packed 4 pixels per byte, so row stride
- is ceil(char_width / 4) = (char_width - 1) / 4 + 1 = (char_width + 3) >> 2 */
+ // Locate the character's pixel data in the font, skipping clipped rows.
+ // Each row of a character is packed 4 pixels per byte, so row stride
+ // is ceil(char_width / 4) = (char_width - 1) / 4 + 1 = (char_width + 3) >> 2
byte *glyph = font->data[ch_idx];
if (skip_top > 0) {
@@ -174,20 +174,20 @@ int font_write(FontPtr font, Buffer *target, const char *out_string,
glyph += skip_top * row_stride;
}
- /* Draw the character glyph */
+ // Draw the character glyph
byte *row_ptr = target_ptr;
for (int row = 0; row < height; row++) {
byte *pixel_ptr = row_ptr;
int pixels_left = char_width;
byte data = *glyph++;
- int pack_count = 4; /* 4 pixels packed per byte, 2 bits each */
+ int pack_count = 4; // 4 pixels packed per byte, 2 bits each
while (pixels_left > 0) {
- /* Shift next 2-bit color index into the high bits of AX,
- then read into the low byte. Original: xor ah,ah / shl ax,2
- with AL holding the packed byte - shifts top 2 bits of AL
- into AH as the color index (0-3). */
+ // Shift next 2-bit color index into the high bits of AX,
+ // then read into the low byte. Original: xor ah,ah / shl ax,2
+ // with AL holding the packed byte - shifts top 2 bits of AL
+ // into AH as the color index (0-3).
byte color_idx = (data >> 6) & 0x03;
data <<= 2;
@@ -211,12 +211,12 @@ int font_write(FontPtr font, Buffer *target, const char *out_string,
row_ptr += target_wrap;
}
- /* char_next: advance target pointer by character width + autospacing */
+ // char_next: advance target pointer by character width + autospacing
target_ptr += char_width + auto_spacing;
screen_loc += auto_spacing;
}
- /* Return value is the final X coordinate reached */
+ // Return value is the final X coordinate reached
return_value = (int)(target_ptr - buffer_pointer(target, x, y)) + x;
finish:
diff --git a/engines/mads/madsv2/core/game.cpp b/engines/mads/madsv2/core/game.cpp
index b6212fd59c3..2ede5376fc2 100644
--- a/engines/mads/madsv2/core/game.cpp
+++ b/engines/mads/madsv2/core/game.cpp
@@ -236,9 +236,7 @@ static int scan_past(const char **myscan, char scan) {
void flag_parse(const char **myscan) {
long mem_max;
- /* long mem_avail; */
-
-
+ // long mem_avail;
if (kernel.cheating == (byte)kernel_cheating_forbidden) {
if (scumm_stricmp(*myscan, kernel_cheating_password) == 0) {
kernel.cheating = (byte)kernel_cheating_allowed;
@@ -256,22 +254,19 @@ void flag_parse(const char **myscan) {
}
break;
- /*
- case 'A':
- if (scan_past(myscan, ':')) {
- abort_value = atoi(*myscan);
- scan_past(myscan, 0);
- }
- break;
- */
-
+ // case 'A':
+ // if (scan_past(myscan, ':')) {
+ // abort_value = atoi(*myscan);
+ // scan_past(myscan, 0);
+ // }
+ // break;
case 'C':
if (scan_past(myscan, ':')) {
kernel.sound_card = **myscan;
if (scan_past(myscan, ',')) {
- /* pl sound_board_address = xtoi(*myscan); */
+ // pl sound_board_address = xtoi(*myscan);
if (scan_past(myscan, ',')) {
- /* pl sound_board_type = xtoi(*myscan); */
+ // pl sound_board_type = xtoi(*myscan);
scan_past(myscan, 0);
}
}
@@ -320,8 +315,8 @@ void flag_parse(const char **myscan) {
case 'K':
inter_report_hotspots = true;
- /* config_file.interface_hotspots = INTERFACE_BRAINDEAD; */
- /* inter_report_hotspots = !inter_report_hotspots; */
+ // config_file.interface_hotspots = INTERFACE_BRAINDEAD;
+ // inter_report_hotspots = !inter_report_hotspots;
break;
case 'L':
@@ -334,19 +329,17 @@ void flag_parse(const char **myscan) {
if (scan_past(myscan, ':')) {
mem_max = atol(*myscan);
mem_get_name(mem_max, "$HIDE$");
- /*
- mem_avail = mem_get_avail() - mem_program_block();
- if (mem_avail > mem_max) {
- mem_get_name(mem_avail - mem_max, "$HIDE$");
- }
- */
+ // mem_avail = mem_get_avail() - mem_program_block();
+ // if (mem_avail > mem_max) {
+ // mem_get_name(mem_avail - mem_max, "$HIDE$");
+ // }
scan_past(myscan, 0);
}
break;
case 'O':
- /* config_file.inventory_mode = INVENTORY_SQUAT; */
- /* inter_spinning_objects = false; */
+ // config_file.inventory_mode = INVENTORY_SQUAT;
+ // inter_spinning_objects = false;
break;
case 'P':
@@ -392,7 +385,7 @@ void flag_parse(const char **myscan) {
break;
case 'Y':
- /* *lock_hash_value = 0; */
+ // lock_hash_value = 0;
break;
case 'Z':
@@ -450,8 +443,8 @@ void show_version() {
echo(global_release_copyright, false);
echo(" by Sanctuary Woods Multimedia Corp.", true);
echo(" ", true);
- /* echo (" FOR INTERNAL USE ONLY", true); */
- /* echo (" ", true); */
+ // echo (" FOR INTERNAL USE ONLY", true);
+ // echo (" ", true);
}
@@ -538,10 +531,10 @@ static void game_player_status() {
popup_alert(20, "PLAYER GRAPHICS STATUS",
" ",
temp_buf_3,
- /* temp_buf, */
- /* temp_buf_2, */
- /* temp_buf_4, */
- /* temp_buf_5, */
+ // temp_buf,
+ // temp_buf_2,
+ // temp_buf_4,
+ // temp_buf_5,
NULL);
}
@@ -574,10 +567,10 @@ int game_parse_keystroke(int mykey) {
break;
case ctrl_d_key:
- /* temp = game.difficulty; */
- /* if (!popup_get_number (&temp, "CHANGE DIFFICULTY FACTOR", "New Factor:", 3)) { */
- /* game.difficulty = (byte)temp; */
- /* } */
+ // temp = game.difficulty;
+ // if (!popup_get_number (&temp, "CHANGE DIFFICULTY FACTOR", "New Factor:", 3)) {
+ // game.difficulty = (byte)temp;
+ // }
break;
case ctrl_e_key:
@@ -633,7 +626,7 @@ int game_parse_keystroke(int mykey) {
move_target = object[move_object].location;
popup_get_number(&move_target, "MOVE OBJ TO", "Loc:", 3);
inter_move_object(move_object, move_target);
- /* kernel.force_restart = true; */
+ // kernel.force_restart = true;
}
}
break;
@@ -647,26 +640,23 @@ int game_parse_keystroke(int mykey) {
game_set_camera_speed();
switch (kernel_panning_speed) {
case PANNING_INSTANT:
- /* popup_alert (22, "Pan INS", NULL); */
+ // popup_alert (22, "Pan INS", NULL);
break;
case PANNING_MEDIUM:
- /* popup_alert (22, "Pan MEDIUM.", NULL); */
+ // popup_alert (22, "Pan MEDIUM.", NULL);
break;
case PANNING_SMOOTH:
default:
- /* popup_alert (22, "Panning = SMOOTH.", NULL); */
+ // popup_alert (22, "Panning = SMOOTH.", NULL);
break;
}
break;
- /*
- case ctrl_r_key:
- box_param.font_spacing = 1 - box_param.font_spacing;
- break;
- */
-
+ // case ctrl_r_key:
+ // box_param.font_spacing = 1 - box_param.font_spacing;
+ // break;
case ctrl_t_key:
popup_get_number(&new_room, "TELEPORT", "New Room:", 3);
kernel.teleported_in = (byte)(mykey == ctrl_t_key);
@@ -687,10 +677,10 @@ int game_parse_keystroke(int mykey) {
break;
case ctrl_w_key:
- /* popup_get_string (player.series_name, "WALKER SERIES", "Series:", 8); */
- /* player.force_series = (byte)strlen(player.series_name); */
- /* if (!scumm_stricmp(player.series_name, "NULL")) player.series_name[0] = 0; */
- /* kernel.force_restart = true; */
+ // popup_get_string (player.series_name, "WALKER SERIES", "Series:", 8);
+ // player.force_series = (byte)strlen(player.series_name);
+ // if (!scumm_stricmp(player.series_name, "NULL")) player.series_name[0] = 0;
+ // kernel.force_restart = true;
break;
case ctrl_z_key:
@@ -698,9 +688,9 @@ int game_parse_keystroke(int mykey) {
break;
case alt_b_key:
- /* if (!popup_get_string (box_param.name, "POPUP BOX SERIES", "Series:", 16)) { */
- /* kernel.force_restart = true; */
- /* } */
+ // if (!popup_get_string (box_param.name, "POPUP BOX SERIES", "Series:", 16)) {
+ // kernel.force_restart = true;
+ // }
break;
case ctrl_y_key:
@@ -790,23 +780,23 @@ int game_parse_keystroke(int mykey) {
break;
case alt_a_key:
- /* if (debugger_watch < DEBUGGER_MAX_WATCH) {
- temp = -1;
- if (debugger_watch > 0) temp = debugger_watch_index[debugger_watch - 1];
- if (!popup_get_number (&temp, "ADD GLOBAL WATCH", "Variable #:", 3)) {
- if ((temp >= 0) && (temp < 500)) {
- for (count = 0; count < debugger_watch; count++) {
- if (debugger_watch_index[count] == temp) {
- temp = -1;
- }
- }
-
- if (temp > 0) {
- debugger_watch_index[debugger_watch++] = temp;
- }
- }
- }
- } */
+ // if (debugger_watch < DEBUGGER_MAX_WATCH) {
+ // temp = -1;
+ // if (debugger_watch > 0) temp = debugger_watch_index[debugger_watch - 1];
+ // if (!popup_get_number (&temp, "ADD GLOBAL WATCH", "Variable #:", 3)) {
+ // if ((temp >= 0) && (temp < 500)) {
+ // for (count = 0; count < debugger_watch; count++) {
+ // if (debugger_watch_index[count] == temp) {
+ // temp = -1;
+ // }
+ // }
+ //
+ // if (temp > 0) {
+ // debugger_watch_index[debugger_watch++] = temp;
+ // }
+ // }
+ // }
+ // }
break;
case alt_e_key:
@@ -861,13 +851,13 @@ int game_parse_keystroke(int mykey) {
break;
case alt_w_key:
- /* player.walk_freedom = !player.walk_freedom; */
- /* player.walk_anywhere = player.walk_freedom; */
- /* if (player.walk_freedom) { */
- /* popup_alert (26, "Player walks anywhere.", NULL); */
- /* } else { */
- /* popup_alert (26, "Player walk restricted.", NULL); */
- /* } */
+ // player.walk_freedom = !player.walk_freedom;
+ // player.walk_anywhere = player.walk_freedom;
+ // if (player.walk_freedom) {
+ // popup_alert (26, "Player walks anywhere.", NULL);
+ // } else {
+ // popup_alert (26, "Player walk restricted.", NULL);
+ // }
break;
case alt_v_key:
@@ -909,7 +899,7 @@ int game_parse_keystroke(int mykey) {
Common::strcat_s(temp_buf_2, temp_buf);
Common::strcat_s(temp_buf_2, ".rac");
- /* if exist RAC file */
+ // if exist RAC file
if (env_exist(temp_buf_2)) {
digi_play(temp_buf, 1);
digi_trigger_dialog = false;
@@ -919,7 +909,7 @@ int game_parse_keystroke(int mykey) {
Common::strcat_s(temp_buf_2, temp_buf);
Common::strcat_s(temp_buf_2, ".raw");
- /* if exist RAW */
+ // if exist RAW
if (env_exist(temp_buf_2)) {
digi_play(temp_buf, 1);
digi_trigger_dialog = false;
@@ -1050,7 +1040,7 @@ int game_parse_keystroke(int mykey) {
switch (mykey) {
case space_key:
- global[3] = true; /* player_hyperwalked */
+ global[3] = true; // player_hyperwalked
if (!kernel.paused) {
if (player.walking && (new_room == room_id) && (player.walk_off_edge == 0)) {
if (!kernel.disable_fastwalk || (kernel.cheating == (byte)kernel_cheating_allowed)) {
@@ -1094,7 +1084,7 @@ int game_parse_keystroke(int mykey) {
break;
case f4_key:
- /* kernel.activate_menu = GAME_SCORE_MENU; */
+ // kernel.activate_menu = GAME_SCORE_MENU;
break;
case f5_key:
@@ -1128,7 +1118,7 @@ int game_parse_keystroke(int mykey) {
case ctrl_k_key:
inter_report_hotspots = !inter_report_hotspots;
- /* config_file.interface_hotspots = inter_report_hotspots ? INTERFACE_BRAINDEAD : INTERFACE_MACINTOSH; */
+ // config_file.interface_hotspots = inter_report_hotspots ? INTERFACE_BRAINDEAD : INTERFACE_MACINTOSH;
inter_init_sentence();
break;
@@ -1150,19 +1140,18 @@ int game_parse_keystroke(int mykey) {
NULL);
break;
- /* case I_key: */
- /* case B_key: */
- /* case i_key: */
- /* case b_key: */
- /* if (room_id != 199 && section_id != 9 && */
- /* player.commands_allowed && */
- /* !kernel.trigger && */
- /* inter_input_mode == INTER_LIMITED_SENTENCES && */
- /* !global[2]) {*/ /* inventory_is_displayed */
- /* display_inventory(); */
- /* } */
- /* break; */
-
+ // case I_key:
+ // case B_key:
+ // case i_key:
+ // case b_key:
+ // if (room_id != 199 && section_id != 9 &&
+ // player.commands_allowed &&
+ // !kernel.trigger &&
+ // inter_input_mode == INTER_LIMITED_SENTENCES &&
+ // !global[2]) {*/ /* inventory_is_displayed
+ // display_inventory();
+ // }
+ // break;
case 0:
break;
@@ -1212,11 +1201,6 @@ void game_pause_mode() {
-/*
- * game_error_service ()
- *
- * Handle fatal error situations
- */
void game_error_service() {
if (inter_spinning_objects || inter_animation_running) {
if (mem_last_alloc_failed) {
@@ -1254,21 +1238,12 @@ void game_set_camera_speed() {
}
}
-/*
- * game_control()
- *
- * This is the main outer control structure for the game, that
- * determines which section and room level information should be
- * loaded into and out of memory.
- */
-
void game_control() {
int count, color;
int result = COPY_SUCCEED;
bool aborted_conv = true;
- /* Start up game level functions */
-
+ // Start up game level functions
error_service_routine_2 = game_error_service;
if (game_mouse_cursor_fix) {
@@ -1292,9 +1267,9 @@ void game_control() {
game.going = false;
force_chain = true;
game_restore_flag = false;
- /* new_room = 804; */
- /* global_init_code(); */
- /* global[copy_protect_failed] = true; */
+ // new_room = 804;
+ // global_init_code();
+ // global[copy_protect_failed] = true;
error_report(ERROR_COPY_PROTECTION, SEVERE, MODULE_LOCK, 0, 0);
} else if (result == COPY_ESCAPE) {
game.going = false;
@@ -1309,9 +1284,9 @@ void game_control() {
}
if (!game_restore_flag && (result != COPY_FAIL) && (result != COPY_ESCAPE)) {
- /* Get difficulty level if new game */
+ // Get difficulty level if new game
if (!kernel.teleported_in && (game.difficulty == -1)) {
- /* Difficulty menu */
+ // Difficulty menu
if (g_engine->getGameID() == GType_Phantom)
kernel.activate_menu = GAME_DIFFICULTY_MENU;
game_exec_function(game_menu_routine);
@@ -1350,14 +1325,12 @@ void game_control() {
}
}
- /* Game level control loop */
-
+ // Game level control loop
int_sprite[fx_int_journal] = -1;
while (game.going) {
- /* Start up next section */
-
+ // Start up next section
kernel_mode = KERNEL_SECTION_PRELOAD;
global_sound_driver();
@@ -1369,7 +1342,7 @@ void game_control() {
game.going = (byte)!kernel_section_startup(new_section);
- /* Load sound driver */
+ // Load sound driver
kernel_load_sound_driver(kernel.sound_driver, kernel.sound_card, sound_board_address, sound_board_type, sound_board_irq);
kernel_mode = KERNEL_SECTION_INIT;
@@ -1379,12 +1352,10 @@ void game_control() {
matte_init(true);
- /* Section level control loop */
-
+ // Section level control loop
while ((new_section == section_id) && game.going) {
- /* Load up next room */
-
+ // Load up next room
kernel_mode = KERNEL_ROOM_PRELOAD;
// Return of the Phantom has this hardcoded true, due to text cutscenes like
@@ -1393,8 +1364,7 @@ void game_control() {
!player.walker_is_loaded);
quote_emergency = false;
- /* vocab_emergency = false; */
-
+ // vocab_emergency = false;
game_wait_cursor();
#ifdef demo
@@ -1403,7 +1373,7 @@ void game_control() {
kernel.quotes = NULL;
- /* vocab_init_active(); */
+ // vocab_init_active();
kernel_init_dynamic();
game_exec_function(section_room_constructor);
@@ -1417,8 +1387,7 @@ void game_control() {
player_discover_room(new_room);
- /* Reset interface mode */
-
+ // Reset interface mode
inter_input_mode = INTER_BUILDING_SENTENCES;
inter_force_rescan = true;
@@ -1494,8 +1463,7 @@ void game_control() {
for (count = 0; count < master_shadow->num_shadow_colors; count++) {
color = PAL_FORCE_SHADOW + count;
color_status[color] = 0;
- /* error_watch_point ("color_status", count, 0); */
-
+ // error_watch_point ("color_status", count, 0);
}
@@ -1507,20 +1475,18 @@ void game_control() {
sound_queue_hold();
- /* Load current player walker set */
-
+ // Load current player walker set
if (!player.walker_is_loaded) {
game.going |= !player_load_series(NULL);
player.walker_loaded_first = false;
}
- /* Set up control structures for new room */
-
+ // Set up control structures for new room
mouse_init_cycle();
- left_command = -1; /* Left mouse main verb */
- left_inven = -1; /* Left mouse inventory */
- left_action = -1; /* Left mouse secondary verb */
+ left_command = -1; // Left mouse main verb
+ left_inven = -1; // Left mouse inventory
+ left_action = -1; // Left mouse secondary verb
inter_init_sentence();
@@ -1531,16 +1497,15 @@ void game_control() {
kernel_mode = KERNEL_ROOM_INIT;
- /* Use a graphics fade in for room transition */
-
+ // Use a graphics fade in for room transition
if (kernel_screen_fade == SCREEN_FADE_SMOOTH) {
- /* kernel.fx = MATTE_FX_CIRCLE_OUT_SLOW; */
+ // kernel.fx = MATTE_FX_CIRCLE_OUT_SLOW;
kernel.fx = MATTE_FX_FADE_THRU_BLACK;
} else if (kernel_screen_fade == SCREEN_FADE_FAST) {
- /* kernel.fx = MATTE_FX_CIRCLE_OUT_SLOW; */
+ // kernel.fx = MATTE_FX_CIRCLE_OUT_SLOW;
kernel.fx = MATTE_FX_FAST_THRU_BLACK;
} else {
- /* kernel.fx = MATTE_FX_CIRCLE_OUT_SLOW; */
+ // kernel.fx = MATTE_FX_CIRCLE_OUT_SLOW;
kernel.fx = MATTE_FX_FAST_AND_FANCY;
}
@@ -1565,16 +1530,16 @@ void game_control() {
game_exec_function(room_init_code_pointer);
#if 0
- /* paul - oh no! magic numbers! */
+ // paul - oh no! magic numbers!
stamp_sprite_to_interface(BP_X, BP_Y, 1, int_sprite[fx_int_backpack]);
- if (global[5]) { /* candle_is_on */
+ if (global[5]) { // candle_is_on
stamp_sprite_to_interface(CANDLE_X, CANDLE_Y, 1, int_sprite[fx_int_candle_on]);
} else {
stamp_sprite_to_interface(CANDLE_X, CANDLE_Y, 1, int_sprite[fx_int_candle]);
}
stamp_sprite_to_interface(DOOR_X, DOOR_Y, 1, int_sprite[fx_int_exit]);
- if (room_id != 199) { /* Taranjeet, if this is not journal room */
+ if (room_id != 199) { // Taranjeet, if this is not journal room
stamp_sprite_to_interface(JOURNAL_X, JOURNAL_Y, 1, int_sprite[fx_int_journal]);
}
#endif
@@ -1584,8 +1549,7 @@ void game_control() {
buffer_rect_fill(scr_main, 0, viewing_at_y + scr_work.y, video_x, video_y, 0);
}
- /* pl conv_restore_running = -1; */
-
+ // pl conv_restore_running = -1;
player.target_x = player.x;
player.target_y = player.y;
player.target_facing = player.turn_to_facing = player.facing;
@@ -1596,8 +1560,7 @@ void game_control() {
player.special_code = attr_special(&scr_special, player.x, player.y);
- /* Reset player clock to make sure walker appears in first frame */
-
+ // Reset player clock to make sure walker appears in first frame
player.clock = kernel.clock;
player_stationary_update();
@@ -1607,12 +1570,10 @@ void game_control() {
inter_turn_off_object();
}
- /* Just in case something goes horribly wrong. */
-
+ // Just in case something goes horribly wrong.
error_service_routine = game_emergency_save;
- /* Call main loop as long as player remains in same room */
-
+ // Call main loop as long as player remains in same room
kernel_mode = KERNEL_ACTIVE_CODE;
kernel.teleported_in = false;
@@ -1629,12 +1590,9 @@ void game_control() {
game_control_loop();
- /* ********************************************************************************************** */
-
- /* LEAVE ROOM */
-
- /* ********************************************************************************************** */
-
+ // **********************************************************************************************
+ // LEAVE ROOM
+ // **********************************************************************************************
if (speech_system_active && speech_on)
speech_all_off();
@@ -1647,8 +1605,7 @@ emergency:
aborted_conv = conv_control.running;
conv_abort();
- /* Shutdown the current room structures */
-
+ // Shutdown the current room structures
if (kernel.quotes != NULL)
mem_free(kernel.quotes);
@@ -1672,8 +1629,7 @@ emergency:
new_section = new_room / 100;
- /* Flush all EMS/XMS preloads at the room level */
-
+ // Flush all EMS/XMS preloads at the room level
himem_flush(ROOM);
if (!game.going && !win_status) {
@@ -1709,47 +1665,36 @@ emergency:
game_wait_cursor();
- /* pl kernel_unload_sound_driver(); */
-
- /* Shut down current section */
-
+ // pl kernel_unload_sound_driver();
+ // Shut down current section
kernel_section_shutdown();
- /* Flush all EMS/XMS preloads at the section level */
-
+ // Flush all EMS/XMS preloads at the section level
himem_flush(SECTION);
}
- /* Shut down the game */
-
+ // Shut down the game
game_exec_function(game_menu_exit);
kernel_game_shutdown();
- /* pl conv_system_cleanup(); */
-
+ // pl conv_system_cleanup();
mcga_reset();
}
-
-/*
- * Execute a function-pointer routine.
- */
void game_exec_function(void (*(target))()) {
if (target)
target();
}
-/*
- * game_system_maintenance()
- *
- * Perform any system maintenance for this frame. Mostly involves
- * reading the keyboard.
+/**
+ * Perform any system maintenance for this frame. Mostly involves
+ * reading the keyboard.
*/
static void game_system_maintenance() {
int unparsed_key = false;
- global[3] = false; /* player_hyperwalked */
+ global[3] = false; // player_hyperwalked
if (keys_any()) {
game_any_keystroke = true;
@@ -1761,7 +1706,7 @@ static void game_system_maintenance() {
if (section_id != 9 && room_id != 199) {
if (((mouse_status & 3) == 3) && player.commands_allowed) {
- /* kernel.force_restart = true; */
+ // kernel.force_restart = true;
kernel.activate_menu = GAME_MAIN_MENU;
inter_init_sentence();
inter_sentence_ready = false;
@@ -1786,8 +1731,7 @@ void do_interface_for_ouaf() {
inter_input_mode == INTER_LIMITED_SENTENCES &&
!global[2] /* inventory_is_displayed */
/* pl conv_control.running < 0 */) {
-
- if (room_id == 199) { /* Taranjeet's Journal */
+ if (room_id == 199) { // Taranjeet's Journal
leave_journal();
@@ -1810,18 +1754,16 @@ void do_interface_for_ouaf() {
}
-/*
- * game_daemon_code()
- *
- * Calls, in proper order, all daemon code for this framing round.
+/**
+ * Calls, in proper order, all daemon code for this framing round.
*/
static void game_daemon_code() {
#if 0
- global[4] = -1; /* turn off global[player_selected_object] */
+ global[4] = -1; // turn off global[player_selected_object]
digi_read_another_chunk();
- if (global[9]) midi_loop(); /* please loop the damn music */
+ if (global[9]) midi_loop(); // please loop the damn music
if (section_id != 9) {
do_interface_for_ouaf();
@@ -1841,34 +1783,29 @@ static void game_daemon_code() {
}
-/*
- * game_handle_preparse()
- *
- * Handles incoming player commands BEFORE any walk action can take
- * place. Player walk for the command can be postponed by setting
- * player.ready_to_walk to false, and then returning it to true when
- * ready for the walk to begin (additional player commands are auto-
- * matically disabled during the interim period). Player walk for
- * the command can be cancelled permanently by setting the value of
- * player.need_to_walk to false.
+/**
+ * Handles incoming player commands BEFORE any walk action can take
+ * place. Player walk for the command can be postponed by setting
+ * player.ready_to_walk to false, and then returning it to true when
+ * ready for the walk to begin (additional player commands are auto-
+ * matically disabled during the interim period). Player walk for
+ * the command can be cancelled permanently by setting the value of
+ * player.need_to_walk to false.
*/
static void game_handle_preparse() {
- /* if (global[4] >= 0 || global[5]) player.command_ready = true; */
- /* if (global[4] >= 0 || global[5]) player.command_error = false; */
-
- /* if (global[4] >= 0 ) player.command_ready = true; */
- /* if (global[4] >= 0 ) player.command_error = false; */
-
+ // if (global[4] >= 0 || global[5]) player.command_ready = true;
+ // if (global[4] >= 0 || global[5]) player.command_error = false;
+ // if (global[4] >= 0 ) player.command_ready = true;
+ // if (global[4] >= 0 ) player.command_error = false;
if ((inter_input_mode == INTER_BUILDING_SENTENCES) ||
(inter_input_mode == INTER_LIMITED_SENTENCES)) {
kernel.trigger_setup_mode = KERNEL_TRIGGER_PREPARSE;
- /* if (global[4] >= 0) { */
- /* player_verb = -1; */
- /* player_main_noun = -1; */
- /* player_second_noun = -1; */
- /* } */
-
+ // if (global[4] >= 0) {
+ // player_verb = -1;
+ // player_main_noun = -1;
+ // player_second_noun = -1;
+ // }
global_pre_parser_code();
game_exec_function(section_pre_parser_code_pointer);
game_exec_function(room_pre_parser_code_pointer);
@@ -1881,11 +1818,9 @@ static void game_handle_preparse() {
-/*
- * game_handle_command()
- *
- * Handles incoming player commands -- they are filtered down through
- * various levels of parser code and error code.
+/**
+ * Handles incoming player commands -- they are filtered down through
+ * various levels of parser code and error code.
*/
static void game_handle_command() {
int handled_this_one;
@@ -1967,73 +1902,69 @@ done:
}
}
-
void do_looping_sounds() {
switch (room_id) {
case 304:
- /* do water trickle */
+ // do water trickle
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 107); /* PLAY_MORE_TRICKLE */
+ kernel_timing_trigger(1, 107); // PLAY_MORE_TRICKLE
break;
case 305:
- /* do bird crowd */
+ // do bird crowd
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 109); /* DO_CROWD */
+ kernel_timing_trigger(1, 109); // DO_CROWD
break;
case 306:
- /* if global[phineas_status] <= PHIN_IS_IN_CONTROL_AGAIN) { */
+ // if global[phineas_status] <= PHIN_IS_IN_CONTROL_AGAIN) {
if (global[66] <= 2) {
- /* bird crowd talking */
+ // bird crowd talking
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 117); /* DO_CROWD */
+ kernel_timing_trigger(1, 117); // DO_CROWD
} else {
- /* water flowing */
+ // water flowing
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 118); /* DO_WATER */
+ kernel_timing_trigger(1, 118); // DO_WATER
}
break;
case 401:
- /* do dragon noise */
+ // do dragon noise
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 106); /* DRAGON_NOISE */
+ kernel_timing_trigger(1, 106); // DRAGON_NOISE
break;
case 403:
- /* do water noise */
+ // do water noise
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 105); /* WATER */
+ kernel_timing_trigger(1, 105); // WATER
break;
case 404:
- /* do dragon noise */
+ // do dragon noise
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 110); /* DRAGON_NOISE */
+ kernel_timing_trigger(1, 110); // DRAGON_NOISE
break;
case 405:
- /* do dragon noise */
+ // do dragon noise
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 106); /* DRAGON_NOISE */
+ kernel_timing_trigger(1, 106); // DRAGON_NOISE
break;
case 210:
- /* rush MORE_RUSH_RUSH */
+ // rush MORE_RUSH_RUSH
kernel.trigger_setup_mode = KERNEL_TRIGGER_DAEMON;
- kernel_timing_trigger(1, 109); /* MORE_RUSH_RUSH */
+ kernel_timing_trigger(1, 109); // MORE_RUSH_RUSH
break;
}
}
-
-/*
- * game_main_loop()
- *
- * This is the main inner graphics control loop for the game,
- * and is executed once for each framing round.
+/**
+ * This is the main inner graphics control loop for the game,
+ * and is executed once for each framing round.
*/
static void game_main_loop() {
int id;
@@ -2049,12 +1980,12 @@ static void game_main_loop() {
static char temp_buf_4[20];
#if 0
- /* these 3 are for the background efx */
+ // these 3 are for the background efx
int yy;
long dif;
- if (global[10]) { /* please play the damn targets */
+ if (global[10]) { // please play the damn targets
- /* this is for the background sound efx */
+ // this is for the background sound efx
dif = kernel.clock - noise_clock;
if ((dif >= 0) && (dif <= 4)) {
noise_timer += dif;
@@ -2066,11 +1997,11 @@ static void game_main_loop() {
if (noise_length == -1) {
if (room_id == 220 || room_id == 221 || room_id == 307 || room_id == 322 || room_id == 420 ||
room_id == 308 || room_id == 204 || room_id == 211) {
- /* night time */
+ // night time
noise_length = imath_random(50, 80);
} else {
- /* day time */
+ // day time
noise_length = imath_random(150, 220);
}
}
@@ -2078,35 +2009,32 @@ static void game_main_loop() {
if (noise_timer >= (noise_length + global[13])) {
if (room_id == 220 || room_id == 221 || room_id == 307 || room_id == 322 || room_id == 420 ||
room_id == 308 || room_id == 204 || room_id == 211) {
- /* night time */
- /* digi_initial_volume (75); */
+ // night time
+ // digi_initial_volume (75);
digi_trigger_effect = false;
- digi_play_build(220, '_', 5, 2); /* EFFECT */
- /* digi_trigger_ambiance = false; */
-
+ digi_play_build(220, '_', 5, 2); // EFFECT
+ // digi_trigger_ambiance = false;
} else {
- /* day time */
-
+ // day time
yy = imath_random(1, 6);
while (last_bird_sound == (byte)yy) yy = imath_random(1, 6);
last_bird_sound = (byte)yy;
- /* digi_initial_volume (imath_random (25, 100)); */
-
+ // digi_initial_volume (imath_random (25, 100));
digi_trigger_effect = false;
switch (yy) {
- case 1: digi_play_build(321, '_', 500, 2); break; /* EFFECT */
- case 2: digi_play_build(321, '_', 501, 2); break; /* EFFECT */
- case 3: digi_play_build(321, '_', 502, 2); break; /* EFFECT */
- case 4: digi_play_build(321, '_', 503, 2); break; /* EFFECT */
- case 5: digi_play_build(321, '_', 504, 2); break; /* EFFECT */
- case 6: digi_play_build(321, '_', 505, 2); break; /* EFFECT */
+ case 1: digi_play_build(321, '_', 500, 2); break; // EFFECT
+ case 2: digi_play_build(321, '_', 501, 2); break; // EFFECT
+ case 3: digi_play_build(321, '_', 502, 2); break; // EFFECT
+ case 4: digi_play_build(321, '_', 503, 2); break; // EFFECT
+ case 5: digi_play_build(321, '_', 504, 2); break; // EFFECT
+ case 6: digi_play_build(321, '_', 505, 2); break; // EFFECT
}
}
- /* digi_trigger_ambiance = false; */
+ // digi_trigger_ambiance = false;
noise_length = -1;
noise_timer = 0;
}
@@ -2122,7 +2050,7 @@ static void game_main_loop() {
if (move_your_butt_enabled) {
- /* this is for the background sound efx */
+ // this is for the background sound efx
dif = kernel.clock - move_your_butt_clock;
if ((dif >= 0) && (dif <= 4)) {
move_your_butt_timer += dif;
@@ -2175,18 +2103,18 @@ static void game_main_loop() {
switch (move_your_butt_anim_frame) {
- case 24: /* ab in a 2 */
- case 28: /* ab in a 2 */
- /* AB we need to keep moving, michelle needs those herbs */
+ case 24: // ab in a 2
+ case 28: // ab in a 2
+ // AB we need to keep moving, michelle needs those herbs
digi_trigger_dialog = false;
digi_play_build_ii('b', 4, 1);
- /* digi_send_dialog_trigger = false; */
+ // digi_send_dialog_trigger = false;
kernel_reset_animation(move_your_butt_anim_handle, 0);
move_your_butt_anim_frame = 0;
break;
- case 20: /* end of talking */
- /* end AB we need to keep moving, michelle needs those herbs */
+ case 20: // end of talking
+ // end AB we need to keep moving, michelle needs those herbs
dont_frag_the_palette();
kernel_abort_animation(move_your_butt_anim_handle);
move_your_butt_anim_handle = -1;
@@ -2206,7 +2134,7 @@ static void game_main_loop() {
}
- /* Clear any remaining player command message from screen */
+ // Clear any remaining player command message from screen
#endif
if (inter_sentence_ready || !player.commands_allowed) {
@@ -2214,27 +2142,21 @@ static void game_main_loop() {
inter_sentence_ready = false;
}
- /* Interface processing -- accept new commands */
-
-
-
+ // Interface processing -- accept new commands
if (!kernel.trigger && !player.trigger) {
if (kernel_dynamic_changed) kernel_refresh_dynamic();
inter_main_loop(player.commands_allowed && !player.need_to_walk && !kernel.fx);
}
- /* Get official timing clock (in 60th/sec) for this round */
-
+ // Get official timing clock (in 60th/sec) for this round
if (!kernel.fx) {
kernel.clock = timer_read();
}
- /* Update camera view if necessary */
-
+ // Update camera view if necessary
camera_update();
- /* If new command came in, accept it and set up to perform any necessary walking */
-
+ // If new command came in, accept it and set up to perform any necessary walking
if (inter_sentence_ready &&
player.commands_allowed &&
!player.need_to_walk &&
@@ -2256,7 +2178,7 @@ static void game_main_loop() {
player_new_walk();
- /* Handle parser commands and parser triggers */
+ // Handle parser commands and parser triggers
if ((player.command_ready && !player.walking && !player.need_to_walk && (player.facing == player.turn_to_facing) && !kernel.trigger) ||
(kernel.trigger && (kernel.trigger_mode == KERNEL_TRIGGER_PARSER))/* ||
global[4] >= 0*/) {
@@ -2269,10 +2191,9 @@ static void game_main_loop() {
goto skip_frame;
}
- /* Execute daemon code, and do system maintenance */
-
+ // Execute daemon code, and do system maintenance
if (!kernel.trigger || (kernel.trigger_mode == KERNEL_TRIGGER_DAEMON)) {
- game_daemon_code(); /* interface, room,sect,global daemon */
+ game_daemon_code(); // interface, room,sect,global daemon
}
game_system_maintenance();
@@ -2283,7 +2204,7 @@ static void game_main_loop() {
goto skip_frame;
}
- /* Update all active conversations */
+ // Update all active conversations
if (!kernel.trigger) {
if (conv_control.running >= 0) {
if (!camera_x.panning && !camera_y.panning) {
@@ -2292,8 +2213,7 @@ static void game_main_loop() {
}
}
- /* Update the player image, if it is time to do so */
-
+ // Update the player image, if it is time to do so
if ((kernel.clock >= player.clock) && !kernel.trigger) {
player.clock = kernel.clock + player.frame_delay;
@@ -2308,7 +2228,8 @@ static void game_main_loop() {
player_set_image();
}
- cursor_id = 1; /* here */
+ cursor_id = 1;
+
if ((inter_awaiting == AWAITING_COMMAND) && !mouse_button) {
if (inter_spot_class == STROKE_INTERFACE) {
id = inter_spot_index - spot_base[STROKE_INTERFACE - 1];
@@ -2336,15 +2257,13 @@ static void game_main_loop() {
}
- /* Update any active graphics sequences */
-
+ // Update any active graphics sequences
kernel_seq_update_all();
- /* Update any active animations */
-
+ // Update any active animations
kernel_process_all_animations();
- /* Special mouse cursor update mode */
+ // Special mouse cursor update mode
if (kernel.mouse_cursor_point) {
Common::strcpy_s(temp_buf, "(");
mads_itoa(mouse_x, &temp_buf[1], 10);
@@ -2354,39 +2273,33 @@ static void game_main_loop() {
temp_message = kernel_message_add(temp_buf, 5, 5, 515, 1, 0, 0);
}
- /* if (kernel.memory_tracking) { */
- /* Common::strcpy_s (temp_buf_2, "(Mem: "); */
- /* ltoa (mem_get_avail(), &temp_buf_2[6], 10); */
- /* Common::strcat_s (temp_buf_2, ") "); */
- /* temp_message_2 = kernel_message_add (temp_buf_2, 315, 5, 515, 1, 0, KERNEL_MESSAGE_RIGHT); */
- /* } */
-
- /* if (kernel.player_tracking) { */
- /* Common::strcpy_s (temp_buf_3, "(Plyr: "); */
- /* mads_itoa (player.x, &temp_buf_3[strlen(temp_buf_3)], 10); */
- /* Common::strcat_s (temp_buf_3, ","); */
- /* mads_itoa (player.y, &temp_buf_3[strlen(temp_buf_3)], 10); */
- /* Common::strcat_s (temp_buf_3, ")"); */
- /* yy = 5; */
- /* if (kernel.mouse_cursor_point) yy += 15; */
- /* temp_message_3 = kernel_message_add (temp_buf_3, 5, yy, 515, 1, 0, 0); */
-
- /* Common::strcpy_s (temp_buf_4, "Scale %"); */
- /* mads_itoa (player.scale, &temp_buf_4[strlen(temp_buf_4)], 10); */
-
- /* yy += 15; */
- /* temp_message_4 = kernel_message_add (temp_buf_4, 5, yy, 515, 1, 0, 0); */
- /* } */
-
- /* Update any messages */
-
+ // if (kernel.memory_tracking) {
+ // Common::strcpy_s (temp_buf_2, "(Mem: ");
+ // ltoa (mem_get_avail(), &temp_buf_2[6], 10);
+ // Common::strcat_s (temp_buf_2, ") ");
+ // temp_message_2 = kernel_message_add (temp_buf_2, 315, 5, 515, 1, 0, KERNEL_MESSAGE_RIGHT);
+ // }
+ // if (kernel.player_tracking) {
+ // Common::strcpy_s (temp_buf_3, "(Plyr: ");
+ // mads_itoa (player.x, &temp_buf_3[strlen(temp_buf_3)], 10);
+ // Common::strcat_s (temp_buf_3, ",");
+ // mads_itoa (player.y, &temp_buf_3[strlen(temp_buf_3)], 10);
+ // Common::strcat_s (temp_buf_3, ")");
+ // yy = 5;
+ // if (kernel.mouse_cursor_point) yy += 15;
+ // temp_message_3 = kernel_message_add (temp_buf_3, 5, yy, 515, 1, 0, 0);
+ // Common::strcpy_s (temp_buf_4, "Scale %");
+ // mads_itoa (player.scale, &temp_buf_4[strlen(temp_buf_4)], 10);
+ // yy += 15;
+ // temp_message_4 = kernel_message_add (temp_buf_4, 5, yy, 515, 1, 0, 0);
+ // }
+ // Update any messages
if (!kernel.trigger) {
if (kernel.force_restart || (new_room != room_id)) kernel_message_purge();
kernel_message_update_all();
}
- /* Matte out the next graphics frame */
-
+ // Matte out the next graphics frame
if (!viewing_at_y) {
matte_inter_frame(!kernel.fx, kernel.fx);
if (kernel.fx) {
@@ -2426,8 +2339,7 @@ static void game_main_loop() {
skip_frame:
- /* if (mcga_shakes) mcga_shake(); */
-
+ // if (mcga_shakes) mcga_shake();
if (kernel.fx) {
cycling_active = true;
}
@@ -2439,7 +2351,6 @@ skip_frame:
while ((mouse_clock == timer_read()) && !kernel.trigger);
}
-
static void game_control_loop() {
game_any_keystroke = false;
@@ -2473,16 +2384,12 @@ static void game_control_loop() {
if (debugger) game_exec_function(debugger_reset);
}
-
void chain_execute() {
error("TODO: chain_execute");
}
-
-/*
- * game_read_save_directory()
- *
- * Reads the list of save files.
+/**
+ * Reads the list of save files.
*/
static void game_read_save_directory() {
int error_flag = true;
@@ -2505,12 +2412,6 @@ done:
}
}
-
-/*
- * game_write_save_directory()
- *
- * Writes the list of save files.
- */
void game_write_save_directory() {
#ifdef TODO
int error_flag = true;
@@ -2537,24 +2438,15 @@ done:
#endif
}
-
-
-/*
- * game_menu_setup()
- *
- * Sets up for the main menu routines to run--this mainly involves
- * getting enough memory to hold the save directory and menu heap.
- */
void game_menu_setup() {
long mem_to_get;
game_preserve_handle = BUFFER_NOT_PRESERVED;
game_menu_heap.base = NULL;
- /* Get enough memory to work with. If none available from the */
- /* main heap, attempt to preserve the depth buffer and steal */
- /* its memory temporarily. */
-
+ // Get enough memory to work with. If none available from the
+ // main heap, attempt to preserve the depth buffer and steal
+ // its memory temporarily.
if (mem_get_avail() >= GAME_MENU_HEAP) {
heap_create(&game_menu_heap, MODULE_GAME_MENU, GAME_MENU_HEAP, "MENUHEAP");
} else if (scr_depth.data != NULL) {
@@ -2571,18 +2463,15 @@ void game_menu_setup() {
error_report(ERROR_NO_MORE_MEMORY, SEVERE, MODULE_GAME_MENU, GAME_MENU_HEAP, 2);
}
- /* Get memory for save slots */
-
+ // Get memory for save slots
mem_to_get = (long)GAME_MAX_SAVE_SLOTS * (GAME_MAX_SAVE_LENGTH + 1);
game_save_directory = (char *)heap_get(&game_menu_heap, mem_to_get);
- /* Get memory for popup */
-
+ // Get memory for popup
mem_to_get = GAME_DIALOG_HEAP;
game_menu_popup = (Popup *)heap_get(&game_menu_heap, mem_to_get);
- /* Read the save list */
-
+ // Read the save list
game_read_save_directory();
cursor_id = 1;
@@ -2593,11 +2482,6 @@ void game_menu_setup() {
}
}
-/*
- * game_menu_shutdown()
- *
- * Tells the menu structures to bite down hard.
- */
void game_menu_shutdown() {
heap_destroy(&game_menu_heap);
@@ -2607,12 +2491,10 @@ void game_menu_shutdown() {
}
}
-
static void debugger_name(const char *name, int where) {
screen_printf(where, 0, "%s", name);
}
-
static void game_file_show(const char *filename, int show_at) {
Common::SeekableReadStream *handle = NULL;
@@ -2631,8 +2513,6 @@ done:
delete handle;
}
-
-
void game_debugger_reset() {
//screen = mono_text_video;
@@ -2644,8 +2524,6 @@ void game_debugger_reset() {
debugger_previous = DEBUGGER_NONE;
}
-
-
static void game_main_update() {
char temp_buf[80];
char temp_buf_2[80];
@@ -2658,8 +2536,7 @@ static void game_main_update() {
screen_printf(0, 2, "%-3d, %-3d Mem: %-6ld Min: %-6ld", room_id, previous_room, mem_get_avail(), mem_min_free);
screen_printf(0, 4, "%s @ %3d, %3d Dpt: %d ", player.series_name, player.x, player.y, player.depth);
- /* screen_printf (0, 5, " Series: %d Sprite: %-2d Mirror: %-2d Frame Rate: %d ", player.series, player.sprite, player.mirror, player.frame_delay); */
-
+ // screen_printf (0, 5, " Series: %d Sprite: %-2d Mirror: %-2d Frame Rate: %d ", player.series, player.sprite, player.mirror, player.frame_delay);
screen_printf(0, 7, "Sc: %-3d Fr %d => %d%, Bk %d => %d%", player.scale, room->front_y, room->front_scale, room->back_y, room->back_scale);
if (!player.walker_visible) {
@@ -2817,8 +2694,8 @@ static void game_palette_update() {
delta = old_free - free;
}
- /* screen_printf (0, 22, "Free: %-3d", free); */
- /* screen_printf (0, 23, "Previous: %-3d", old_free); */
+ // screen_printf (0, 22, "Free: %-3d", free);
+ // screen_printf (0, 23, "Previous: %-3d", old_free);
screen_printf(0, 24, "Added: %-3d", delta);
@@ -2848,8 +2725,6 @@ top:
}
}
-
-
static void game_scratch_update() {
int count;
@@ -2871,7 +2746,6 @@ static void game_scratch_update() {
}
}
-
static void game_global_update() {
int count;
@@ -2893,17 +2767,12 @@ static void game_global_update() {
}
}
-
-
-
static void game_help_update() {
debugger_name("5", 23);
game_file_show("*HELP.DB", 2);
}
-
-
static void game_conversation() {
int x, y;
int count, count2;
@@ -2998,7 +2867,6 @@ done:
;
}
-
static void game_matte() {
int count;
int image_max;
@@ -3021,23 +2889,23 @@ static void game_matte() {
if (count < image_max) {
switch (image_list[count].flags) {
case IMAGE_UPDATE:
- /* Common::strcpy_s (flags_buf, "Update"); */
+ // Common::strcpy_s (flags_buf, "Update");
break;
case IMAGE_STATIC:
- /* Common::strcpy_s (flags_buf, "Static"); */
+ // Common::strcpy_s (flags_buf, "Static");
break;
case IMAGE_ERASE:
- /* Common::strcpy_s (flags_buf, "Erase"); */
+ // Common::strcpy_s (flags_buf, "Erase");
break;
case IMAGE_REFRESH:
- /* Common::strcpy_s (flags_buf, "Refresh"); */
+ // Common::strcpy_s (flags_buf, "Refresh");
break;
case IMAGE_DELTA:
- /* Common::strcpy_s (flags_buf, "Delta"); */
+ // Common::strcpy_s (flags_buf, "Delta");
break;
default:
@@ -3161,8 +3029,6 @@ static void game_state() {
}
}
-
-
void game_debugger() {
if (debugger_state != debugger_previous) game_debugger_reset();
@@ -3203,7 +3069,7 @@ void game_debugger() {
game_memory();
break;
- case 8: /* DEBUGGER_STATE */
+ case 8: // DEBUGGER_STATE
game_state();
break;
}
diff --git a/engines/mads/madsv2/core/game.h b/engines/mads/madsv2/core/game.h
index 7da23eafddc..7727af63094 100644
--- a/engines/mads/madsv2/core/game.h
+++ b/engines/mads/madsv2/core/game.h
@@ -235,43 +235,49 @@ extern int art_hags_are_on_hd;
extern void game_save_name(int id);
extern void game_set_camera_speed(void);
+
+/**
+ * Execute a function-pointer routine.
+ */
extern void game_exec_function(void (*(target))());
+
extern void game_debugger_reset(void);
extern void game_debugger(void);
-/*
- * game_write_save_directory()
+
+/**
* Writes the list of save files.
*/
extern void game_write_save_directory(void);
-/*
- * game_menu_setup()
+
+/**
* Sets up for the main menu routines to run--this mainly involves
* getting enough memory to hold the save directory and menu heap.
*/
+
extern void game_menu_setup(void);
-/*
- * game_menu_shutdown()
+
+/**
* Tells the menu structures to bite down hard.
*/
extern void game_menu_shutdown(void);
+
extern int main_cheating_key(int mykey);
extern int main_normal_key(int mykey);
extern int main_copy_verify(void);
extern void game_cold_data_init();
-/*
- * game_control()
+
+/**
* This is the main outer control structure for the game, that
* determines which section and room level information should be
* loaded into and out of memory.
*/
extern void game_control();
-/*
- * flag_parse()
- *
- * Routine to parse command line flags.
+/**
+ * Routine to parse command line flags.
*/
extern void flag_parse(const char **myscan);
+
extern void show_logo();
extern void show_version();
diff --git a/engines/mads/madsv2/core/himem.cpp b/engines/mads/madsv2/core/himem.cpp
index 2981380db11..697c3f1d8c0 100644
--- a/engines/mads/madsv2/core/himem.cpp
+++ b/engines/mads/madsv2/core/himem.cpp
@@ -307,8 +307,7 @@ int himem_preload(char *filename, int level) {
if (ems_copy_it_up(new_handle, &page_marker, &page_offset, load_buf, read_size)) goto done;
} else {
- /* printf ("Record %d (Size: %ld, Offset: %ld)\n", count, read_size, xms_offset); */
-
+ // printf ("Record %d (Size: %ld, Offset: %ld)\n", count, read_size, xms_offset);
if (xms_copy(read_size,
MEM_CONV, load_buf,
xms_handle, (XMS)xms_offset)) goto done;
@@ -398,7 +397,7 @@ int himem_preload_series(const char *fname, int level) {
Common::strcpy_s(file_buf, fname);
char *filename = file_buf;
- fileio_add_ext(filename, "SS"); /* Default to Sprite Series */
+ fileio_add_ext(filename, "SS"); // Default to Sprite Series
if ((himem_resident(filename) >= 0) || !himem_active) goto done;
diff --git a/engines/mads/madsv2/core/hspot.cpp b/engines/mads/madsv2/core/hspot.cpp
index aed044459b9..966661f4085 100644
--- a/engines/mads/madsv2/core/hspot.cpp
+++ b/engines/mads/madsv2/core/hspot.cpp
@@ -80,20 +80,17 @@ int hspot_pop() {
return(yes);
}
-/**
- * Packs the hotspot list by removing any blank entries
- */
void hspot_pack() {
int from, unto;
unto = 0;
for (from = 1; from <= numspots; from++) {
- if (spot[from].num != HS_DEATH) /* If it's still alive */
- {
+ // If it's still alive
+ if (spot[from].num != HS_DEATH) {
unto++;
- if (from != unto) /* If it's actually going to move */
- spot[unto] = spot[from]; /* Shift spot down */
+ if (from != unto) // If it's actually going to move
+ spot[unto] = spot[from]; // Shift spot down
}
}
@@ -104,7 +101,7 @@ void hspot_pack() {
int hspot_remove(int class_, int num) {
int a, cleared;
- /* Clear ALL hotspots */
+ // Clear ALL hotspots
if (class_ == HS_ALL) {
a = numspots;
numspots = 0;
diff --git a/engines/mads/madsv2/core/imath.cpp b/engines/mads/madsv2/core/imath.cpp
index ce2ed3098a0..f051700ac49 100644
--- a/engines/mads/madsv2/core/imath.cpp
+++ b/engines/mads/madsv2/core/imath.cpp
@@ -43,23 +43,22 @@ int imath_distance(int side_A, int side_B, int thresh) {
dx = ABS(side_A);
dy = ABS(side_B);
- /* Ensure dx >= dy for the approximation formula. */
+ // Ensure dx >= dy for the approximation formula.
if (dx < dy) {
int tmp = dx; dx = dy; dy = tmp;
}
- /* Base approximation: ds = dx + dy/4 */
+ // Base approximation: ds = dx + dy/4
ds = dx + (dy >> 2);
- /* Correction term if 2*dy >= dx: ds += (2*dy - dx) * 3/16 */
+ // Correction term if 2*dy >= dx: ds += (2*dy - dx) * 3/16
if (2 * dy > dx) {
ds += ((2 * dy - dx) * 3) >> 4;
}
- /* Subtract ~3% to ensure result is a lower bound. */
- ds -= (ds >> 6); /* ds -= ds/64, approximately 1.5% ... */
- /* Note: assembly uses shr cx,6 but comment says 3% - see below */
-
+ // Subtract ~3% to ensure result is a lower bound.
+ ds -= (ds >> 6); // ds -= ds/64, approximately 1.5% ...
+ // Note: assembly uses shr cx,6 but comment says 3% - see below
if (ds < thresh)
return imath_hypot(side_A, side_B);
diff --git a/engines/mads/madsv2/core/implode.cpp b/engines/mads/madsv2/core/implode.cpp
index a8f6f106965..10fca7dac7e 100644
--- a/engines/mads/madsv2/core/implode.cpp
+++ b/engines/mads/madsv2/core/implode.cpp
@@ -105,66 +105,75 @@ typedef struct {
int di; /* write index into flat[], starts at EXP_LEMPEL */
} ExpState;
-/*
- * explode_RBin -- fill the read buffer.
- *
+/**
+ * Fill the read buffer.
* Before reading: save rb[si] (which is rb[EXP_RBLEN+1] after last refill,
* i.e. one past end) into rb[0] (the guard slot). Then reset si to 1.
+ *
+ * @param s State
*/
static void explode_RBin(ExpState *s) {
- /* Save the byte just past the current buffer end into the guard slot.
- * In the assembly this is: mov al,[si]; sub si,RBlen; mov [si],al
- * which saves rb[EXP_RBLEN] to rb[0] (= guard word low byte). */
- s->rb[0] = s->rb[s->si]; /* save guard byte */
- s->si = 1; /* reset to start of data region */
+ // Save the byte just past the current buffer end into the guard slot.
+ // In the assembly this is: mov al,[si]; sub si,RBlen; mov [si],al
+ // which saves rb[EXP_RBLEN] to rb[0] (= guard word low byte).
+ s->rb[0] = s->rb[s->si]; // save guard byte
+ s->si = 1; // reset to start of data region
word size = EXP_RBLEN;
s->read_buff((char *)(s->rb + 1), &size);
- /* If fewer bytes were read than requested, the remainder of rb[]
- * retains its previous content (harmless for a decompressor consuming
- * exactly the right number of bytes from a well-formed stream). */
+ // If fewer bytes were read than requested, the remainder of rb[]
+ // retains its previous content (harmless for a decompressor consuming
+ // exactly the right number of bytes from a well-formed stream).
}
-/*
- * explode_WBout -- flush the write (output) buffer.
- *
+/**
+ * Flush the write (output) buffer.
* Writes flat[EXP_LEMPEL .. di-1] to the output callback, then performs the
* Lempel fixup: copies flat[EXP_LEMPEL-4096 .. EXP_LEMPEL-1] (the second half
* of the Lempel window) to flat[0 .. 4095] (the first half), then resets di.
- *
* This preserves the last 4096 bytes of history so back-references up to
* -8192 bytes remain valid after the reset. The fixup only happens when a
* full WBlen buffer was flushed (matching the assembly's "cmp RWlen,WBlen").
+ *
+ * @param s State
*/
static void explode_WBout(ExpState *s) {
- int bytes = s->di - EXP_LEMPEL; /* bytes currently in WBuff */
+ int bytes = s->di - EXP_LEMPEL; // bytes currently in WBuff
word size = (word)bytes;
s->write_buff((char *)(s->flat + EXP_LEMPEL), &size);
if (bytes == EXP_WBLEN) {
- /* Lempel fixup: copy second half of Lempel to first half.
- * Assembly: lea si, WBuff-4096 (= Lempel+4096)
- * lea di, WBuff-8192 (= Lempel+0)
- * mov cx, 4096; rep movsw (copies 8192 bytes) */
+ // Lempel fixup: copy second half of Lempel to first half.
+ // Assembly: lea si, WBuff-4096 (= Lempel+4096)
+ // lea di, WBuff-8192 (= Lempel+0)
+ // mov cx, 4096; rep movsw (copies 8192 bytes)
memmove(s->flat, s->flat + EXP_LEMPEL - 4096, 4096);
}
- s->di = EXP_LEMPEL; /* reset write pointer to WBuff base */
+ s->di = EXP_LEMPEL; // reset write pointer to WBuff base
}
-/* GetByte: if si > EXP_RBLEN (= RBend+1, one past last byte), refill.
+/**
+ * If si > EXP_RBLEN (= RBend+1, one past last byte), refill.
* Then return rb[si++].
- * Assembly: cmp si, RBend; jbe skip; call RBin; skip: lodsb */
+ *
+ * @param s State
+ * @return Next byte
+ */
static inline byte exp_get_byte(ExpState *s) {
if (s->si > EXP_RBLEN)
explode_RBin(s);
return s->rb[s->si++];
}
-/* GetWord: if si >= EXP_RBLEN (= RBend, only 1 byte left), refill first.
- * Assembly: cmp si, RBend; jb skip; call RBin; skip: lodsw
+/**
+ * If si >= EXP_RBLEN (= RBend, only 1 byte left), refill first.
* The guard byte at rb[0] ensures the second byte of the word is available
- * even when si pointed to the very last slot before the refill. */
+ * even when si pointed to the very last slot before the refill.
+ *
+ * @param s State
+ * @return Next word
+ */
static inline word exp_get_word(ExpState *s) {
if (s->si >= EXP_RBLEN)
explode_RBin(s);
@@ -173,27 +182,16 @@ static inline word exp_get_word(ExpState *s) {
return val;
}
-/* GetHuff: extract one bit from the Huffman bit pump.
+/**
+ * Extract one bit from the Huffman bit pump.
* Returns the bit in CF position (0 or 1).
*
- * Assembly macro:
- * dec dx
- * jnz getc
- * GetWord ; ax = next word
- * mov dl, 16
- * shr bp, 1 ; CF = old bp[0]
- * mov bp, ax ; bp = new word (CF unchanged)
- * rcl bp, 1 ; bp = (ax<<1) | old_CF
- * getc:
- * rcr bp, 1 ; CF = bp[0], bp = (bp>>1) | (in_CF<<15)
- *
- * The shr/rcl/rcr dance on reload:
- * shr bp,1 captures the carry from the now-exhausted old accumulator.
- * rcl bp,1 after "mov bp,ax" stitches that carry into bit0 of the new word.
- * rcr bp,1 then extracts bit0 (= saved carry) as the current bit.
- * Net effect: we get the saved carry bit as the 17th bit extracted, giving
- * seamless 16-bit-boundary crossing. Verified by simulation to produce bits
+ * We get the saved carry bit as the 17th bit extracted, giving seamless
+ * 16-bit-boundary crossing. Verified by simulation to produce bits
* in LSB-first order, one word at a time.
+ *
+ * @param s State
+ * @return Next bit
*/
static inline int exp_get_huff(ExpState *s) {
int bit;
@@ -202,37 +200,41 @@ static inline int exp_get_huff(ExpState *s) {
if (s->dx == 0) {
word ax = exp_get_word(s);
s->dx = 16;
- /* shr bp,1 -> CF = bp & 1 */
+ // shr bp,1 -> CF = bp & 1
int carry = s->bp & 1;
- /* mov bp, ax then rcl bp,1 -> bp = (ax<<1)|carry, new CF = ax>>15 */
+ // mov bp, ax then rcl bp,1 -> bp = (ax<<1)|carry, new CF = ax>>15
s->bp = (word)((ax << 1) | carry);
- /* fall through: rcr bp,1 below extracts bp[0] = carry as current bit */
+ // fall through: rcr bp,1 below extracts bp[0] = carry as current bit
}
- /* rcr bp,1: CF = bp[0], bp = (bp >> 1) | (CF_in << 15)
- * CF_in at this point is the CF left by the last operation above (or the
- * previous iteration's rcr). In the assembly CF is a real flag and
- * carries implicitly; here we must track it. But note: the ONLY place
- * CF matters going into rcr is on the reload path (where it was set by
- * rcl), and on the non-reload path CF is not used (the rcr just rotates
- * bit15 in, but since we never inspect bp's high bits, it doesn't matter
- * what rotates in). We use 0 for CF_in on non-reload iterations; the
- * high bit of bp is never examined by the decoder. */
+ // rcr bp,1: CF = bp[0], bp = (bp >> 1) | (CF_in << 15)
+ // CF_in at this point is the CF left by the last operation above (or the
+ // previous iteration's rcr). In the assembly CF is a real flag and
+ // carries implicitly; here we must track it. But note: the ONLY place
+ // CF matters going into rcr is on the reload path (where it was set by
+ // rcl), and on the non-reload path CF is not used (the rcr just rotates
+ // bit15 in, but since we never inspect bp's high bits, it doesn't matter
+ // what rotates in). We use 0 for CF_in on non-reload iterations; the
+ // high bit of bp is never examined by the decoder.
bit = s->bp & 1;
- s->bp >>= 1; /* bp >> 1, high bit = 0 (safe: only bit0 is inspected) */
+ s->bp >>= 1; // bp >> 1, high bit = 0 (safe: only bit0 is inspected)
return bit;
}
-/* PutByte: if di > WBend (= EXP_LEMPEL + EXP_WBLEN - 1), flush first.
- * Assembly: cmp di, WBend; jbe skip; call WBout; skip: stosb */
+/**
+ * If di > WBend (= EXP_LEMPEL + EXP_WBLEN - 1), flush first.
+ *
+ * @param s State
+ * @param val Byte
+ */
static inline void exp_put_byte(ExpState *s, byte val) {
if (s->di > EXP_LEMPEL + EXP_WBLEN - 1)
explode_WBout(s);
s->flat[s->di++] = val;
}
-/*
- * explode -- LZ77 decompressor
+/**
+ * LZ77 decompressor
*
* Reads compressed data via read_buff, writes decompressed data via write_buff.
* work_buff must point to at least 14364 bytes of writable memory (ignored
@@ -249,122 +251,114 @@ word explode(
s.read_buff = read_buff;
s.write_buff = write_buff;
- /* Force immediate refill on first GetByte/GetWord.
- * Assembly: lea si, RBuff; add si, RBlen (si = one past end of RBuff) */
+ // Force immediate refill on first GetByte/GetWord.
+ // Assembly: lea si, RBuff; add si, RBlen (si = one past end of RBuff)
s.si = EXP_RBLEN + 1;
- /* ES:DI = WBuff base (flat index EXP_LEMPEL) */
+ // ES:DI = WBuff base (flat index EXP_LEMPEL)
s.di = EXP_LEMPEL;
- /* Prime the Huffman pump: GetWord, bp = ax, dx = 16 */
+ // Prime the Huffman pump: GetWord, bp = ax, dx = 16
s.bp = exp_get_word(&s);
s.dx = 16;
- /*
- * FABin: main decode loop
- *
- * GetHuff returns the next control bit in CF (carry).
- * Bit=1 => literal byte follows.
- * Bit=0 => back-reference.
- */
+ // FABin: main decode loop
+ //
+ // GetHuff returns the next control bit in CF (carry).
+ // Bit=1 => literal byte follows.
+ // Bit=0 => back-reference.
for (;;) {
int bit = exp_get_huff(&s);
if (bit) {
- /* Literal: GetByte then PutByte */
+ // Literal: GetByte then PutByte
byte al = exp_get_byte(&s);
exp_put_byte(&s, al);
continue;
}
- /* Back-reference. Second control bit selects near (<00>) or far (<01>). */
+ // Back-reference. Second control bit selects near (<00>) or far (<01>).
int cx = 0;
bit = exp_get_huff(&s);
if (!bit) {
- /*
- * Code <00XY>: near copy.
- * Two more Huffman bits give XY (2-bit length field).
- * Length = XY + 2, range [2..5].
- * One raw byte gives the negative offset (BH=-1, BL=byte => BX=0xFF00|byte).
- *
- * Assembly:
- * GetHuff; rcl cx,1 (cx = ...X)
- * GetHuff; rcl cx,1 (cx = ...XY)
- * inc cx; inc cx (cx = XY + 2)
- * GetByte
- * mov bh,-1; mov bl,al (bx = 0xFF00 | al)
- */
+ // Code <00XY>: near copy.
+ // Two more Huffman bits give XY (2-bit length field).
+ // Length = XY + 2, range [2..5].
+ // One raw byte gives the negative offset (BH=-1, BL=byte => BX=0xFF00|byte).
+ //
+ // Assembly:
+ // GetHuff; rcl cx,1 (cx = ...X)
+ // GetHuff; rcl cx,1 (cx = ...XY)
+ // inc cx; inc cx (cx = XY + 2)
+ // GetByte
+ // mov bh,-1; mov bl,al (bx = 0xFF00 | al)
int x = exp_get_huff(&s);
cx = (cx << 1) | x;
int y = exp_get_huff(&s);
cx = (cx << 1) | y;
- cx += 2; /* length [2..5] */
+ cx += 2; // length [2..5]
byte al = exp_get_byte(&s);
- int bx = (int)(int16_t)(0xFF00 | (word)al); /* signed 16-bit: [-255..-1] */
+ int bx = (int)(int16_t)(0xFF00 | (word)al); // signed 16-bit: [-255..-1]
- /* LP3: copy cx bytes from flat[di + bx] to flat[di], advancing di.
- * Overlapping copies are intentional (run-length expansion).
- * Assembly: mov al, es:[bx+di]; PutByte; loop LP3 */
+ // LP3: copy cx bytes from flat[di + bx] to flat[di], advancing di.
+ // Overlapping copies are intentional (run-length expansion).
+ // Assembly: mov al, es:[bx+di]; PutByte; loop LP3
while (cx-- > 0) {
- /* di+bx: since bx is negative and di>=EXP_LEMPEL, result >= 0 */
+ // di+bx: since bx is negative and di>=EXP_LEMPEL, result >= 0
byte b = s.flat[s.di + bx];
exp_put_byte(&s, b);
}
} else {
- /*
- * Code <01>: far copy (or special sentinel).
- * One raw word encodes offset and length:
- * BL = low byte of word = offset[7:0]
- * BH = high byte, after processing:
- * shr bh,3; or bh,0E0h => offset[12:8] packed into bh
- * AH & 7 = length field (original high byte before shr):
- * 0 => read aux byte (exit/normalize/long count)
- * 1..7 => length = field + 2
- *
- * Signed offset reconstruction:
- * bx = (int16_t)( (((ah >> 3) | 0xE0) << 8) | al )
- * Range: [-8192..-1]
- */
+ // Code <01>: far copy (or special sentinel).
+ // One raw word encodes offset and length:
+ // BL = low byte of word = offset[7:0]
+ // BH = high byte, after processing:
+ // shr bh,3; or bh,0E0h => offset[12:8] packed into bh
+ // AH & 7 = length field (original high byte before shr):
+ // 0 => read aux byte (exit/normalize/long count)
+ // 1..7 => length = field + 2
+ //
+ // Signed offset reconstruction:
+ // bx = (int16_t)( (((ah >> 3) | 0xE0) << 8) | al )
+ // Range: [-8192..-1]
word ax = exp_get_word(&s);
byte ah = (byte)(ax >> 8);
byte al = (byte)(ax & 0xFF);
- /* Reconstruct BH: shr bh,3 then or bh,0E0h */
+ // Reconstruct BH: shr bh,3 then or bh,0E0h
byte bh = (byte)((ah >> 3) | 0xE0);
- /* BX as signed 16-bit */
+ // BX as signed 16-bit
int bx = (int)(int16_t)((word)((word)bh << 8) | al);
- /* Length field = original AH & 7 (before the shr) */
+ // Length field = original AH & 7 (before the shr)
int len_field = ah & 7;
if (len_field != 0) {
- /* count = len_field + 2.
- * Assembly: mov cl, ah (ah already anded to 7); inc cx; inc cx */
+ // count = len_field + 2.
+ // Assembly: mov cl, ah (ah already anded to 7); inc cx; inc cx
cx = len_field + 2;
- /* LP3 copy */
+ // LP3 copy
while (cx-- > 0) {
byte b = s.flat[s.di + bx];
exp_put_byte(&s, b);
}
} else {
- /*
- * LP3a: aux byte determines action.
- * 0 => EXIT
- * 1 => NORMALIZE (no-op in flat model; just continue)
- * n => count = n + 1, then LP3 copy
- */
+ // LP3a: aux byte determines action.
+ // 0 => EXIT
+ // 1 => NORMALIZE (no-op in flat model; just continue)
+ // n => count = n + 1, then LP3 copy
byte aux = exp_get_byte(&s);
if (aux == 0) {
- /* EXIT sentinel */
+ // EXIT sentinel
break;
} else if (aux == 1) {
- /* LP4: NORMALIZE. In the original this re-normalised
- * segment:offset pointers for the decompressor's internal
- * buffers. In the flat C model this is a no-op. */
+ // LP4: NORMALIZE. In the original this re-normalised
+ // segment:offset pointers for the decompressor's internal
+ // buffers. In the flat C model this is a no-op.
continue;
} else {
cx = (int)aux + 1;
@@ -377,7 +371,7 @@ word explode(
}
}
- /* Exit: flush any remaining output bytes */
+ // Exit: flush any remaining output bytes
explode_WBout(&s);
return CMP_NO_ERROR;
@@ -463,47 +457,52 @@ typedef struct {
/* ---- I/O helpers ---- */
-/*
- * implode_RBin -- fill the read buffer.
- * Returns bytes read (0 = EOF).
+/**
+ * Fill the read buffer.
* Assembly increments RBcnt by (bytes_read+1) then decrements before each use,
* so RBcnt==1 means "need refill on next access".
+ *
+ * @param s State
+ * @return bytes read (0 = EOF).
*/
static word imp_rb_refill(ImpState *s) {
word size = IMP_RBLEN;
s->read_buff((char *)s->rb, &size);
s->rb_ptr = s->rb;
- s->rb_cnt = size + 1; /* +1: assembly sets RBcnt = bytes+1 (see RBin) */
+ s->rb_cnt = size + 1; // +1: assembly sets RBcnt = bytes+1 (see RBin)
return size;
}
-/*
+/**
* Read one byte from the input. Returns -1 (as int) on EOF.
- *
* Assembly pattern (inside Fabrice loop):
- * dec RBcnt; jnz Gin; call implode_RBin; or ax,ax; jz Zin; jmp @B
+ * dec RBcnt; jnz Gin; call implode_RBin; or ax,ax; jz Zin; jmp @B
* Gin: mov bx,RBptr; inc RBptr; mov al,[bx]
- *
* RBcnt starts at 1 after init; first dec makes it 0, triggering refill.
* After refill: RBcnt = bytes_read + 1.
+ *
+ * @param s State
+ * @return Next byte
*/
static int imp_get_byte(ImpState *s) {
for (;;) {
s->rb_cnt--;
if (s->rb_cnt != 0)
return *s->rb_ptr++;
- /* RBcnt hit 0: refill */
+ // RBcnt hit 0: refill
word got = imp_rb_refill(s);
if (got == 0)
- return -1; /* EOF */
- /* rb_cnt = got + 1, loop back to decrement */
+ return -1; // EOF
+ // rb_cnt = got + 1, loop back to decrement
}
}
-/*
- * implode_WBout -- flush the write (output) buffer.
+/**
+ * Flush the write (output) buffer.
* Resets wb_ptr and wb_cnt. Assembly version:
- * WBcnt = WBlen, compute bytes = WBptr - &WBuff, reset WBptr = &WBuff
+ * WBcnt = WBlen, compute bytes = WBptr - &WBuff, reset WBptr = &WBuff
+ *
+ * @param s State
*/
static void imp_wb_flush(ImpState *s) {
word bytes = (word)(s->wb_ptr - s->wb);
@@ -513,7 +512,12 @@ static void imp_wb_flush(ImpState *s) {
s->write_buff((char *)s->wb, &bytes);
}
-/* Write one byte to the output buffer, flushing when full. */
+/**
+ * Write one byte to the output buffer, flushing when full.
+ *
+ * @param s State
+ * @param val Byte
+ */
static void imp_wb_put(ImpState *s, byte val) {
*s->wb_ptr++ = val;
s->wb_cnt--;
@@ -523,57 +527,63 @@ static void imp_wb_put(ImpState *s, byte val) {
/* ---- Packet / Huffman output ---- */
-/*
- * Packet -- flush the current Huffman packet to the write buffer and reset.
- *
+/**
+ * Flush the current Huffman packet to the write buffer and reset.
* Assembly walks si from offset(Huffman) to Huffptr, writing each byte.
* The packet layout is: huff_man word (2 bytes LE) followed by data bytes.
* After flush: Huffbit=1, Huffman=0, Huffptr = &Huffman+2 (start of data).
+ *
+ * @param s State
*/
static void imp_packet(ImpState *s) {
- /* Store the current Huffman accumulator into packet[0..1] (little-endian).
- * Note: packet[] was already reset to 0 at start; partial huff_man is
- * whatever was accumulated before Huffbit overflowed. */
+ // Store the current Huffman accumulator into packet[0..1] (little-endian).
+ // Note: packet[] was already reset to 0 at start; partial huff_man is
+ // whatever was accumulated before Huffbit overflowed.
s->packet[0] = (byte)(s->huff_man & 0xFF);
s->packet[1] = (byte)(s->huff_man >> 8);
- /* Assembly: inc Delta at start of Packet */
+ // Assembly: inc Delta at start of Packet
s->delta++;
- /* Flush all bytes from packet[0] to huff_ptr-1 */
+ // Flush all bytes from packet[0] to huff_ptr-1
byte *p = s->packet;
while (p < s->huff_ptr)
imp_wb_put(s, *p++);
- /* Reset packet state */
+ // Reset packet state
s->huff_bit = 1;
s->huff_man = 0;
s->packet[0] = 0;
s->packet[1] = 0;
- s->huff_ptr = s->packet + 2; /* data starts after the 2-byte Huffman word */
+ s->huff_ptr = s->packet + 2; // data starts after the 2-byte Huffman word
}
-/*
- * Huff1 -- emit one Huffman control bit.
- *
+/**
+ * Emit one Huffman control bit.
* Assembly:
- * or al,al; jz @F
- * mov ax,Huffbit; or Huffman,ax (set bit if val != 0)
+ * or al,al; jz @F
+ * mov ax,Huffbit; or Huffman,ax (set bit if val != 0)
* @@: shl Huffbit,1; jnz @F; call Packet (flush when bit overflows 16-bit)
+ *
+ * @param s State
+ * @param val Value
*/
static void imp_huff1(ImpState *s, int val) {
if (val)
s->huff_man |= s->huff_bit;
s->huff_bit <<= 1;
if (s->huff_bit == 0) {
- /* Huffbit has shifted out of 16-bit range: flush packet */
+ // Huffbit has shifted out of 16-bit range: flush packet
imp_packet(s);
}
}
-/*
- * push1 -- append one raw data byte to the current packet buffer.
+/**
+ * Append one raw data byte to the current packet buffer.
* Assembly: mov di,Huffptr; inc Huffptr; mov [di],al
+ *
+ * @param s State
+ * @param val Value
*/
static void imp_push1(ImpState *s, byte val) {
*s->huff_ptr++ = val;
@@ -581,60 +591,66 @@ static void imp_push1(ImpState *s, byte val) {
/* ---- Dictionary management ---- */
-/*
+/**
* Hash key computation.
* Assembly (in Link and Match):
- * mov si, word ptr Lempel[di] ; 16-bit word at lempel[di]
- * and si, HASH-1 ; mask to [0..IMP_HASH-1]
- * add si, LEMPEL+1 ; shift into key-table region
- * shl si, 1 ; convert to byte offset
- *
+ * mov si, word ptr Lempel[di] ; 16-bit word at lempel[di]
+ * and si, HASH-1 ; mask to [0..IMP_HASH-1]
+ * add si, LEMPEL+1 ; shift into key-table region
+ * shl si, 1 ; convert to byte offset
* Result is a BYTE OFFSET into hash[] pointing at the key root slot.
* In C we use a WORD index = si>>1 into the hash[] word array.
+ *
+ * @param s State
+ * @param pos
+ * @return
*/
static inline int imp_hash_key_idx(ImpState *s, int pos) {
word w = (word)s->lempel[pos] | ((word)s->lempel[pos + 1] << 8);
- return (int)(((w & (IMP_HASH - 1)) + IMP_LEMPEL + 1)); /* word index */
+ return (int)(((w & (IMP_HASH - 1)) + IMP_LEMPEL + 1)); // word index
}
-/*
- * Link -- insert lempel[di] at the root of its hash chain.
- *
+/**
+ * Insert lempel[di] at the root of its hash chain.
* Assembly (byte-offset based):
- * si = key byte offset (= hash_key_idx * 2)
- * di2 = di * 2
- * bx = Hash[si>>1] ; old root byte-offset
- * Hash[di2>>1] = bx ; di's next = old root
- * Hash[si>>1] = di2 ; new root = di
- * UnDo[bx>>1] = di2 ; old root back-ptr = di
- * UnDo[di2>>1] = si ; di back-ptr = key slot
- *
+ * si = key byte offset (= hash_key_idx * 2)
+ * di2 = di * 2
+ * bx = Hash[si>>1] ; old root byte-offset
+ * Hash[di2>>1] = bx ; di's next = old root
+ * Hash[si>>1] = di2 ; new root = di
+ * UnDo[bx>>1] = di2 ; old root back-ptr = di
+ * UnDo[di2>>1] = si ; di back-ptr = key slot
* All values stored are BYTE OFFSETS (position << 1), with NIL = 0x4000.
* We store them directly as word values in hash[]/undo[] word arrays,
* using word-index = byte-offset >> 1 to access them.
+ *
+ * @param s State
+ * @param di Value
*/
static void imp_link(ImpState *s, int di) {
- int si_idx = imp_hash_key_idx(s, di); /* word index of key slot */
- int di2 = di * 2; /* byte offset of di's slot */
- int si2 = si_idx * 2; /* byte offset of key slot */
+ int si_idx = imp_hash_key_idx(s, di); // word index of key slot
+ int di2 = di * 2; // byte offset of di's slot
+ int si2 = si_idx * 2; // byte offset of key slot
- word bx = s->hash[si_idx]; /* old root (byte offset) */
+ word bx = s->hash[si_idx]; // old root (byte offset)
- s->hash[di2 / 2] = bx; /* di's next = old root */
- s->hash[si_idx] = (word)di2; /* new root = di */
- s->undo[bx / 2] = (word)di2; /* old root back-ptr = di (byte off) */
- s->undo[di2 / 2] = (word)si2; /* di's back-ptr = key slot (byte off) */
+ s->hash[di2 / 2] = bx; // di's next = old root
+ s->hash[si_idx] = (word)di2; // new root = di
+ s->undo[bx / 2] = (word)di2; // old root back-ptr = di (byte off)
+ s->undo[di2 / 2] = (word)si2; // di's back-ptr = key slot (byte off)
}
-/*
- * UnLink -- remove lempel[si] from its hash chain.
- *
+/**
+ * Remove lempel[si] from its hash chain.
* Assembly:
- * si2 = si << 1
- * bx = UnDo[si2>>1] ; the slot that currently holds si2
- * if bx != NIL:
- * Hash[bx>>1] = NIL ; remove si2 from that slot
- * UnDo[si2>>1] = NIL
+ * si2 = si << 1
+ * bx = UnDo[si2>>1] ; the slot that currently holds si2
+ * if bx != NIL:
+ * Hash[bx>>1] = NIL ; remove si2 from that slot
+ * UnDo[si2>>1] = NIL
+ *
+ * @param s State
+ * @param si Index
*/
static void imp_unlink(ImpState *s, int si) {
int si2 = si * 2;
@@ -645,49 +661,45 @@ static void imp_unlink(ImpState *s, int si) {
}
}
-/*
- * Match -- find the longest matching string and insert lempel[di] into
- * the hash table. Sets s->qlen and s->qoff.
- *
+/**
+ * Find the longest matching string and insert lempel[di] into
+ * the hash table. Sets s->qlen and s->qoff.
* Entry: di = current encode position (ring index, not DS offset).
- *
* The assembly proc adds offset(Lempel) to get DS-relative pointers for
* string comparison. In C we just index s->lempel[] directly.
- *
* The Ziv[] shadow array (s->lempel[IMP_LEMPEL .. IMP_LEMPEL+IMP_ZIV])
* mirrors s->lempel[0..IMP_ZIV-1], so repe cmpsb can cross the ring
* boundary without explicit wraparound -- comparisons starting near the
* end of lempel[] continue into the shadow without going out of bounds.
- *
* AX encodes "remaining CX after repe cmpsb":
- * AX = ZIV-1 initially (no match found yet)
- * AX = 0 (ZIV-1 chars matched after hash char = ZIV total)
- * AX = 0xFFFF (-1 uint16) set by can1 for a full match (je from repe cmpsb)
- *
+ * AX = ZIV-1 initially (no match found yet)
+ * AX = 0 (ZIV-1 chars matched after hash char = ZIV total)
+ * AX = 0xFFFF (-1 uint16) set by can1 for a full match (je from repe cmpsb)
* Qlen = (uint16)(ZIV - AX) - 1 (wraps correctly for AX=0xFFFF -> Qlen=ZIV)
- *
* Qoff = -(( (di - best_pos/2) & (IMP_LEMPEL-1) ))
- * where best_pos is the BYTE OFFSET of the best candidate.
- *
+ * where best_pos is the BYTE OFFSET of the best candidate.
* Match also links lempel[di] into the hash table (same as Link but
* inlined at the end of can2, so it does NOT call imp_link separately
* before the first Match call -- Fabrice calls Match before the main loop).
+ *
+ * @param s State
+ * @param di Value
*/
static void imp_match(ImpState *s, int di) {
- int si_idx = imp_hash_key_idx(s, di); /* word index of key slot */
+ int si_idx = imp_hash_key_idx(s, di); // word index of key slot
int di2 = di * 2;
- word ax = (word)(IMP_ZIV - 1); /* best "remaining CX" so far */
- word bp = IMP_NIL; /* byte offset of best candidate */
+ word ax = (word)(IMP_ZIV - 1); // best "remaining CX" so far
+ word bp = IMP_NIL; // byte offset of best candidate
- /* Walk the hash chain */
+ // Walk the hash chain
word bx = s->hash[si_idx];
while (bx != IMP_NIL) {
- int cand = bx / 2; /* candidate position in lempel[] */
+ int cand = bx / 2; // candidate position in lempel[]
- /* Compare lempel[cand+1 .. cand+ZIV-1] against lempel[di+1 .. di+ZIV-1].
- * First character is guaranteed to match by the hash function.
- * The Ziv shadow allows comparisons to run past lempel[8191] safely. */
+ // Compare lempel[cand+1 .. cand+ZIV-1] against lempel[di+1 .. di+ZIV-1].
+ // First character is guaranteed to match by the hash function.
+ // The Ziv shadow allows comparisons to run past lempel[8191] safely.
int max_cmp = IMP_ZIV - 1;
int matched = 0;
while (matched < max_cmp &&
@@ -695,29 +707,29 @@ static void imp_match(ImpState *s, int di) {
matched++;
if (matched == max_cmp) {
- /* Full ZIV-1 chars matched (= can1: full ZIV match with hash char) */
+ // Full ZIV-1 chars matched (= can1: full ZIV match with hash char)
bp = bx;
- ax = (word)(-1); /* sentinel: 0xFFFF */
+ ax = (word)(-1); // sentinel: 0xFFFF
break;
}
- /* Remaining = max_cmp - matched. Lower remaining = longer match. */
+ // Remaining = max_cmp - matched. Lower remaining = longer match.
word cx = (word)(max_cmp - matched);
if (cx < ax) {
bp = bx;
ax = cx;
}
- bx = s->hash[bx / 2]; /* follow collision chain */
+ bx = s->hash[bx / 2]; // follow collision chain
}
- /* Compute Qlen: (uint16)(ZIV - ax) - 1
- * Works for ax=0xFFFF: (uint16)(253 - 65535) = 254, -1 = 253 = ZIV. */
+ // Compute Qlen: (uint16)(ZIV - ax) - 1
+ // Works for ax=0xFFFF: (uint16)(253 - 65535) = 254, -1 = 253 = ZIV.
word qlen = (word)(IMP_ZIV - ax) - 1;
s->qlen = qlen;
- /* Compute Qoff (only meaningful when qlen >= 2):
- * Assembly: ax = di2 - bp; shr ax,1; and ax, LEMPEL-1; neg ax */
+ // Compute Qoff (only meaningful when qlen >= 2):
+ // Assembly: ax = di2 - bp; shr ax,1; and ax, LEMPEL-1; neg ax
if (qlen >= 2) {
word diff = (word)((word)di2 - bp);
diff >>= 1;
@@ -725,77 +737,77 @@ static void imp_match(ImpState *s, int di) {
s->qoff = -(int16_t)diff;
}
- /* Insert di into hash table (mirrors the inlined Link at end of can2).
- * bx here is the current root of the key slot (from the final iteration
- * of the chain walk, or the initial value if chain was empty). */
- bx = s->hash[si_idx]; /* re-read current root */
+ // Insert di into hash table (mirrors the inlined Link at end of can2).
+ // bx here is the current root of the key slot (from the final iteration
+ // of the chain walk, or the initial value if chain was empty).
+ bx = s->hash[si_idx]; // re-read current root
s->hash[di2 / 2] = bx;
s->hash[si_idx] = (word)di2;
s->undo[bx / 2] = (word)di2;
s->undo[di2 / 2] = (word)(si_idx * 2);
}
-/*
- * RWinit -- initialise I/O pointers. Mirrors RWinit proc.
+/**
+ * Initialise I/O pointers. Mirrors RWinit proc.
+ *
+ * @param s State
*/
static void imp_rwinit(ImpState *s) {
- s->rb_cnt = 1; /* triggers refill on first access */
+ s->rb_cnt = 1; // triggers refill on first access
s->wb_ptr = s->wb;
s->wb_cnt = IMP_WBLEN;
}
-/*
- * Fabrice -- the main LZ77 encode loop.
- *
+/**
+ * The main LZ77 encode loop.
* Corresponds to the Fabrice proc in IMPLODE.ASM.
- *
* DI (ring pos) = current encode/input position in lempel[] ring.
* SI (ring pos) = oldest position (evicted from dictionary as we advance).
* Both wrap mod IMP_LEMPEL via "and si/di, LEMPEL-1".
+ *
+ * @param s State
*/
static void imp_fabrice(ImpState *s) {
int di, si;
imp_rwinit(s);
- /* Initialise UnDo to NIL */
+ // Initialise UnDo to NIL
for (int i = 0; i <= IMP_LEMPEL; i++)
s->undo[i] = IMP_NIL;
- /* Initialise Hash to NIL */
+ // Initialise Hash to NIL
for (int i = 0; i < IMP_LEMPEL + 1 + IMP_HASH; i++)
s->hash[i] = IMP_NIL;
- /* Zero Lempel + Ziv area */
+ // Zero Lempel + Ziv area
memset(s->lempel, 0, IMP_LEMPEL + IMP_ZIV - 1);
- /* Initialise Huffman packet state */
+ // Initialise Huffman packet state
s->huff_bit = 1;
s->huff_man = 0;
memset(s->packet, 0, IMP_PKTMAX);
s->huff_ptr = s->packet + 2;
- /* Initialise LZ state */
+ // Initialise LZ state
s->norms = 0;
s->delta = 0;
s->paraz = 0;
- /*
- * Read the first IMP_ZIV bytes into lempel[IMP_LEMPEL-ZIV .. IMP_LEMPEL-1].
- * Also mirror the first ZIV-1 of them into the Ziv shadow at
- * lempel[IMP_LEMPEL .. IMP_LEMPEL + ZIV - 2].
- *
- * Assembly:
- * di = offset Ziv - ZIV (= Lempel + LEMPEL - ZIV in DS-relative)
- * cx = ZIV
- * Loop1: dec RBcnt; jnz @F; call implode_RBin; jz GotZIV; jmp Loop1
- * @@: mov si,RBptr; inc RBptr; movsb; loop Loop1
- *
- * In flat C: write to lempel[IMP_LEMPEL - ZIV + i], and also to
- * lempel[IMP_LEMPEL + i] for i < ZIV-1 (the Ziv shadow).
- */
- di = IMP_LEMPEL - IMP_ZIV; /* ring index: encode ptr starts here */
- si = 0; /* ring index: oldest (tail) ptr */
+ // Read the first IMP_ZIV bytes into lempel[IMP_LEMPEL-ZIV .. IMP_LEMPEL-1].
+ // Also mirror the first ZIV-1 of them into the Ziv shadow at
+ // lempel[IMP_LEMPEL .. IMP_LEMPEL + ZIV - 2].
+ //
+ // Assembly:
+ // di = offset Ziv - ZIV (= Lempel + LEMPEL - ZIV in DS-relative)
+ // cx = ZIV
+ // Loop1: dec RBcnt; jnz @F; call implode_RBin; jz GotZIV; jmp Loop1
+ // @@: mov si,RBptr; inc RBptr; movsb; loop Loop1
+ //
+ // In flat C: write to lempel[IMP_LEMPEL - ZIV + i], and also to
+ // lempel[IMP_LEMPEL + i] for i < ZIV-1 (the Ziv shadow).
+ di = IMP_LEMPEL - IMP_ZIV; // ring index: encode ptr starts here
+ si = 0; // ring index: oldest (tail) ptr
s->zlen = 0;
for (int i = 0; i < IMP_ZIV; i++) {
@@ -803,134 +815,120 @@ static void imp_fabrice(ImpState *s) {
if (ch < 0) break;
s->lempel[IMP_LEMPEL - IMP_ZIV + i] = (byte)ch;
if (i < IMP_ZIV - 1)
- s->lempel[IMP_LEMPEL + i] = (byte)ch; /* Ziv shadow */
+ s->lempel[IMP_LEMPEL + i] = (byte)ch; // Ziv shadow
s->zlen++;
}
- /* GotZIV: Zlen = min(ZIV, file_size). Call initial Match. */
+ // GotZIV: Zlen = min(ZIV, file_size). Call initial Match.
imp_match(s, di);
- /*
- * Main encode loop (Next label in assembly).
- */
+ // Main encode loop (Next label in assembly).
while (s->zlen > 0) {
- /* Clip Qlen to available lookahead */
+ // Clip Qlen to available lookahead
if (s->qlen > s->zlen)
s->qlen = s->zlen;
int save_di = di;
int save_si = si;
- /*
- * Decide encoding type.
- *
- * Assembly:
- * cmp ax, 2; jb DoLit => Qlen < 2: literal
- * ja DoMov => Qlen > 2: copy
- * ; Qlen == 2:
- * cmp Qoff, -100h; jg DoMov => Qoff > -256: copy; else literal
- */
- int qlen = (int)(int16_t)s->qlen; /* treat as signed for comparison */
+ // Decide encoding type.
+ //
+ // Assembly:
+ // cmp ax, 2; jb DoLit => Qlen < 2: literal
+ // ja DoMov => Qlen > 2: copy
+ // ; Qlen == 2:
+ // cmp Qoff, -100h; jg DoMov => Qoff > -256: copy; else literal
+ int qlen = (int)(int16_t)s->qlen; // treat as signed for comparison
int qoff = (int)s->qoff;
if (qlen < 2 || (qlen == 2 && qoff <= -256)) {
- /*
- * DoLit: emit a literal byte.
- * Huff bit 1, then push the raw byte.
- * Qlen forced to 1 so we advance by exactly 1 character.
- */
+ // DoLit: emit a literal byte.
+ // Huff bit 1, then push the raw byte.
+ // Qlen forced to 1 so we advance by exactly 1 character.
s->qlen = 1;
imp_huff1(s, 1);
imp_push1(s, s->lempel[di]);
} else {
- imp_huff1(s, 0); /* first Huff bit = 0 for all copies */
+ imp_huff1(s, 0); // first Huff bit = 0 for all copies
if (qlen <= 5 && qoff > -256) {
- /*
- * NearCopy: Qlen in [2..5], Qoff in [-255..-1].
- * Code: <00XY>, offset_byte.
- * XY encodes Qlen-2 as 2 bits: bit1=(enc>>1)&1, bit0=enc&1.
- * Offset byte = -(Qoff) = positive offset magnitude.
- *
- * Assembly:
- * Huff1(0); Huff1(0)
- * mov ax,Qlen; dec ax; dec ax; push ax
- * and al,2; Huff1(al) (= bit1 of enc)
- * pop ax; and al,1; Huff1(al) (= bit0 of enc)
- * mov ax,Qoff; call push1 (low byte = -offset)
- */
+ // NearCopy: Qlen in [2..5], Qoff in [-255..-1].
+ // Code: <00XY>, offset_byte.
+ // XY encodes Qlen-2 as 2 bits: bit1=(enc>>1)&1, bit0=enc&1.
+ // Offset byte = -(Qoff) = positive offset magnitude.
+ //
+ // Assembly:
+ // Huff1(0); Huff1(0)
+ // mov ax,Qlen; dec ax; dec ax; push ax
+ // and al,2; Huff1(al) (= bit1 of enc)
+ // pop ax; and al,1; Huff1(al) (= bit0 of enc)
+ // mov ax,Qoff; call push1 (low byte = -offset)
imp_huff1(s, 0);
- int enc = qlen - 2; /* 0..3 */
- imp_huff1(s, (enc >> 1) & 1); /* bit1 */
- imp_huff1(s, enc & 1); /* bit0 */
- imp_push1(s, (byte)(-qoff)); /* positive offset byte */
+ int enc = qlen - 2; // 0..3
+ imp_huff1(s, (enc >> 1) & 1); // bit1
+ imp_huff1(s, enc & 1); // bit0
+ imp_push1(s, (byte)(-qoff)); // positive offset byte
} else {
- /*
- * FarCopy: Qlen in [2..9] and Qoff in [-8191..-1], or Qlen > 5.
- * Code: <01>, then a 2-byte vector word, then optional length byte.
- *
- * Vector word format:
- * Low byte: Qoff & 0xFF (offset low 8 bits)
- * High byte: (Qoff >> 8) << 3 ORed with length field
- * Length field (3 bits):
- * 0 => LongCopy (aux length byte follows)
- * 1..7 => FarCopy, length = field + 2 (range [3..9])
- *
- * Note: Qlen == 2 and Qoff <= -256 hits DoLit (above), so
- * minimum FarCopy length is 2 with Qoff <= -256... actually
- * the assembly checks: DoMov if Qlen>5 OR Qoff<=-256 when Qlen==2.
- * But "Far5" label handles Qlen>5 OR Qoff<=-255.
- * For Qlen==2 and Qoff<=-256 we already went to DoLit.
- * So here Qlen >= 2 and (Qlen > 5 OR Qoff <= -256 OR Qlen==2 case not reached).
- *
- * Assembly Far5:
- * Huff1(1)
- * mov ax,Qoff; push1(al) [low byte of offset]
- * mov al,ah; shl al,3 [high byte, shifted up 3]
- * mov bx,Qlen; cmp bx,9; ja Far9
- * dec bx; dec bx; or al,bl; push1(al) [length in low 3 bits]
- * Far9: (LongCopy, Qlen > 9)
- * push1(al) [high byte with length=0]
- * mov ax,bx; dec ax; push1(al) [Qlen-1 as aux byte]
- */
+ // FarCopy: Qlen in [2..9] and Qoff in [-8191..-1], or Qlen > 5.
+ // Code: <01>, then a 2-byte vector word, then optional length byte.
+ //
+ // Vector word format:
+ // Low byte: Qoff & 0xFF (offset low 8 bits)
+ // High byte: (Qoff >> 8) << 3 ORed with length field
+ // Length field (3 bits):
+ // 0 => LongCopy (aux length byte follows)
+ // 1..7 => FarCopy, length = field + 2 (range [3..9])
+ //
+ // Note: Qlen == 2 and Qoff <= -256 hits DoLit (above), so
+ // minimum FarCopy length is 2 with Qoff <= -256... actually
+ // the assembly checks: DoMov if Qlen>5 OR Qoff<=-256 when Qlen==2.
+ // But "Far5" label handles Qlen>5 OR Qoff<=-255.
+ // For Qlen==2 and Qoff<=-256 we already went to DoLit.
+ // So here Qlen >= 2 and (Qlen > 5 OR Qoff <= -256 OR Qlen==2 case not reached).
+ //
+ // Assembly Far5:
+ // Huff1(1)
+ // mov ax,Qoff; push1(al) [low byte of offset]
+ // mov al,ah; shl al,3 [high byte, shifted up 3]
+ // mov bx,Qlen; cmp bx,9; ja Far9
+ // dec bx; dec bx; or al,bl; push1(al) [length in low 3 bits]
+ // Far9: (LongCopy, Qlen > 9)
+ // push1(al) [high byte with length=0]
+ // mov ax,bx; dec ax; push1(al) [Qlen-1 as aux byte]
imp_huff1(s, 1);
- imp_push1(s, (byte)(qoff & 0xFF)); /* offset low byte */
- byte hi = (byte)(((qoff >> 8) & 0xFF) << 3); /* hi byte, length field = 0 */
+ imp_push1(s, (byte)(qoff & 0xFF)); // offset low byte
+ byte hi = (byte)(((qoff >> 8) & 0xFF) << 3); // hi byte, length field = 0
if (qlen <= 9) {
- hi |= (byte)(qlen - 2); /* pack length into low 3 bits */
+ hi |= (byte)(qlen - 2); // pack length into low 3 bits
imp_push1(s, hi);
} else {
- imp_push1(s, hi); /* length field = 0 => aux follows */
- imp_push1(s, (byte)(qlen - 1)); /* aux length byte */
+ imp_push1(s, hi); // length field = 0 => aux follows
+ imp_push1(s, (byte)(qlen - 1)); // aux length byte
}
}
}
- /*
- * Cont: bookkeeping after emitting the code.
- *
- * Assembly:
- * sub Delta, Qlen; jge Zok
- * @@: inc ParaZ; add Delta,10h; cmp Delta,0; jl @B
- */
+ // Cont: bookkeeping after emitting the code.
+ //
+ // Assembly:
+ // sub Delta, Qlen; jge Zok
+ // @@: inc ParaZ; add Delta,10h; cmp Delta,0; jl @B
s->delta -= (int16_t)s->qlen;
while (s->delta < 0) {
s->paraz++;
s->delta += 0x10;
}
- /*
- * Norms tracking: emit a NORMALIZE code every ~40 KB (0xA000 bytes).
- * The NORMALIZE code tells explode to re-normalise its segment pointers;
- * in the flat C decompressor it is a no-op, but we must emit it to
- * keep the bitstream format compatible.
- *
- * Code: Huff(0), Huff(1), push(0x00), push(0xF0), push(0x01)
- */
+ // Norms tracking: emit a NORMALIZE code every ~40 KB (0xA000 bytes).
+ // The NORMALIZE code tells explode to re-normalise its segment pointers;
+ // in the flat C decompressor it is a no-op, but we must emit it to
+ // keep the bitstream format compatible.
+ //
+ // Code: Huff(0), Huff(1), push(0x00), push(0xF0), push(0x01)
s->norms = (word)(s->norms + s->qlen);
if (s->norms >= 0xA000) {
imp_huff1(s, 0);
@@ -941,43 +939,41 @@ static void imp_fabrice(ImpState *s) {
s->norms = 0;
}
- /*
- * Restore DI and SI, then advance through the input by Qlen characters,
- * maintaining the hash dictionary.
- *
- * Assembly (Loop2):
- * call Link ; add lempel[di] to dict (skipped on first iteration
- * call UnLink ; via the "jmp short @F" before Loop2)
- * ; read next character into lempel[si]
- * if si < ZIV-1: also write lempel[LEMPEL+si] (Ziv shadow)
- * inc si; inc di; and si,LEMPEL-1; and di,LEMPEL-1
- * dec Qlen; jnz Loop2
- *
- * Note: on the FIRST iteration we skip Link (jump to UnLink directly)
- * because the current di was already linked by Match().
- */
+ // Restore DI and SI, then advance through the input by Qlen characters,
+ // maintaining the hash dictionary.
+ //
+ // Assembly (Loop2):
+ // call Link ; add lempel[di] to dict (skipped on first iteration
+ // call UnLink ; via the "jmp short @F" before Loop2)
+ // ; read next character into lempel[si]
+ // if si < ZIV-1: also write lempel[LEMPEL+si] (Ziv shadow)
+ // inc si; inc di; and si,LEMPEL-1; and di,LEMPEL-1
+ // dec Qlen; jnz Loop2
+ //
+ // Note: on the FIRST iteration we skip Link (jump to UnLink directly)
+ // because the current di was already linked by Match().
di = save_di;
si = save_si;
int qlen_advance = (int)(int16_t)s->qlen;
for (int k = 0; k < qlen_advance; k++) {
if (k > 0) {
- /* Link lempel[di] into dictionary (skipped on k=0 since
- * Match already inserted it). */
+ // Link lempel[di] into dictionary (skipped on k=0 since
+ // Match already inserted it).
imp_link(s, di);
}
- /* UnLink the oldest entry (evict from tail of window) */
+ // UnLink the oldest entry (evict from tail of window)
imp_unlink(s, si);
- /* Read next character and store it at lempel[si] */
+ // Read next character and store it at lempel[si]
int ch = imp_get_byte(s);
if (ch >= 0) {
s->lempel[si] = (byte)ch;
if (si < IMP_ZIV - 1)
- s->lempel[IMP_LEMPEL + si] = (byte)ch; /* Ziv shadow */
+ s->lempel[IMP_LEMPEL + si] = (byte)ch; // Ziv shadow
} else {
- /* EOF: Zin label -- shrink Zlen */
+ // EOF: Zin label -- shrink Zlen
s->zlen--;
}
@@ -985,26 +981,24 @@ static void imp_fabrice(ImpState *s) {
di = (di + 1) & (IMP_LEMPEL - 1);
}
- /* Find next match for the new di position */
+ // Find next match for the new di position
imp_match(s, di);
}
- /*
- * Exit: emit the EXIT sentinel code, flush packet and write buffer.
- * Code: Huff(0), Huff(1), push(0x00), push(0xF0), push(0x00)
- */
+ // Exit: emit the EXIT sentinel code, flush packet and write buffer.
+ // Code: Huff(0), Huff(1), push(0x00), push(0xF0), push(0x00)
imp_huff1(s, 0);
imp_huff1(s, 1);
imp_push1(s, 0x00);
imp_push1(s, 0xF0);
imp_push1(s, 0x00);
- imp_packet(s); /* WBend: flush final packet */
- imp_wb_flush(s); /* flush write buffer */
+ imp_packet(s); // WBend: flush final packet
+ imp_wb_flush(s); // flush write buffer
}
-/*
- * implode -- LZ77 compressor.
+/**
+ * LZ77 compressor.
*
* type and dsize are accepted for API compatibility but ignored; the
* assembly original also ignored them (always binary mode, 8 KB window).
@@ -1020,7 +1014,7 @@ word implode(
(void)type;
(void)dsize;
- /* ImpState is large (~53 KB); allocate on heap, not stack. */
+ // ImpState is large (~53 KB); allocate on heap, not stack.
ImpState *s = (ImpState *)malloc(sizeof(ImpState));
if (!s) return CMP_ABORT;
memset(s, 0, sizeof * s);
@@ -1034,15 +1028,8 @@ word implode(
return CMP_NO_ERROR;
}
-/* =========================================================================
- * CRC32
- *
- * Standard CRC-32 (ISO 3309, polynomial 0xEDB88320, reflected).
- * Not present in the two ASM files but declared in the shared header.
- * ========================================================================= */
-
long crc32(unsigned char *buffer, word *size, long *old_crc) {
- /* Build table at first call for polynomial 0xEDB88320 (reflected CRC-32) */
+ // Build table at first call for polynomial 0xEDB88320 (reflected CRC-32)
static uint32_t crc_table[256];
static int table_init = 0;
if (!table_init) {
diff --git a/engines/mads/madsv2/core/inter.cpp b/engines/mads/madsv2/core/inter.cpp
index 74a99613816..5476fe435cd 100644
--- a/engines/mads/madsv2/core/inter.cpp
+++ b/engines/mads/madsv2/core/inter.cpp
@@ -221,11 +221,11 @@ void VerbBuf::synchronize(Common::Serializer &s) {
}
-/*
-/* inter_set_colors()
-/*
-/* Picks out font colors based on the current mode.
-*/
+/**
+ * Picks out font colors based on the current mode.
+ *
+ * @param color_code Color code
+ */
static void inter_set_colors(int color_code) {
switch (color_code) {
case NORMAL:
@@ -240,12 +240,9 @@ static void inter_set_colors(int color_code) {
}
}
-/*
-/* inter_get_spot()
-/*
-/* Returns hot spot coordinates for a particular stroke class and
-/* spot #.
-*/
+/**
+ * Returns hot spot coordinates for a particular stroke class and spot #.
+ */
static int inter_get_spot(int class_, int id, int *x1, int *y1, int *xs, int *ys) {
int row, col;
int base_x, base_y, delta_x;
@@ -343,13 +340,13 @@ done:
return(valid_flag);
}
-
-/*
-/* inter_show_word()
-/*
-/* Writes vocabulary word for the particular class_ & id # to the
-/* interface work buffer.
-*/
+/**
+ * Writes vocabulary word for the particular class_ & id # to the
+ * interface work buffer.
+ *
+ * @param class_ Class
+ * @param id Id
+ */
static void inter_show_word(int class_, int id) {
int x, y, junk;
int word_id = 0;
@@ -448,7 +445,6 @@ done:
;
}
-
static void inter_show_scrollbar(void) {
if (scrollbar_active > 0) {
inter_show_word(STROKE_SCROLL, scrollbar_active);
@@ -457,13 +453,9 @@ static void inter_show_scrollbar(void) {
inter_show_word(STROKE_SCROLL, SCROLL_THUMB);
}
-
-
-/*
-/* inter_show_all_inven()
-/*
-/* Writes the current inventory list to the interface work buffer.
-*/
+/**
+ * Writes the current inventory list to the interface work buffer.
+ */
static void inter_show_all_inven(void) {
int count;
@@ -472,13 +464,11 @@ static void inter_show_all_inven(void) {
}
}
-
-/*
-/* inter_show_all_actions()
-/*
-/* Writes the current list of object-specific verbs to the interface
-/* work buffer.
-*/
+/**
+ * inter_show_all_actions()
+ * Writes the current list of object-specific verbs to the interface
+ * work buffer.
+ */
static void inter_show_all_actions(void) {
int count;
int id;
@@ -487,9 +477,9 @@ static void inter_show_all_actions(void) {
for (count = 0; count < (int)object[inven[active_inven]].num_verbs; count++) {
id = object[inven[active_inven]].vocab_id;
id = object_named(id);
- /* id = object[inven[active_inven]].verb[count].count; */
- if (id == 8) { /* pid doll */
- if (global[86]) { /* heal_verbs_visible */
+ // id = object[inven[active_inven]].verb[count].count;
+ if (id == 8) { // pid doll
+ if (global[86]) { // heal_verbs_visible
inter_show_word(STROKE_ACTION, count);
} else if (count == 0) {
inter_show_word(STROKE_ACTION, count);
@@ -502,9 +492,6 @@ static void inter_show_all_actions(void) {
}
}
-/*
-/* inter_show_all_dialog()
-*/
static void inter_show_all_dialog(void) {
int count;
@@ -515,12 +502,6 @@ static void inter_show_all_dialog(void) {
}
}
-
-/*
-/* inter_prepare_background()
-/*
-/* Writes all relevant words to the interface work buffer.
-*/
void inter_prepare_background(void) {
int count;
@@ -543,16 +524,13 @@ void inter_prepare_background(void) {
}
}
-
static void inter_refresh(void) {
- /*
- int count;
- for (count = 0; count < (int)image_inter_marker; count++) {
- if (image_inter_list[count].segment_id == INTER_SPINNING_OBJECT) {
- image_inter_list[count].flags = IMAGE_REFRESH + IMAGE_UPDATE_ONLY;
- }
- }
- */
+ // int count;
+ // for (count = 0; count < (int)image_inter_marker; count++) {
+ // if (image_inter_list[count].segment_id == INTER_SPINNING_OBJECT) {
+ // image_inter_list[count].flags = IMAGE_REFRESH + IMAGE_UPDATE_ONLY;
+ // }
+ // }
image_inter_marker = 0;
matte_refresh_inter();
@@ -561,8 +539,6 @@ static void inter_refresh(void) {
inter_prepare_background();
}
-
-
void inter_reset_dialog(void) {
int count;
@@ -572,13 +548,12 @@ void inter_reset_dialog(void) {
}
}
-
int inter_add_dialog(char *string, int result) {
int count, id;
char *mark;
char *mark2;
- do { /* Double hyphens to dashes */
+ do { // Double hyphens to dashes
mark = strstr(string, "--");
if (mark != NULL) {
*mark = '{';
@@ -603,13 +578,14 @@ int inter_add_dialog(char *string, int result) {
return (id);
}
-
-
/*
-/* inter_update()
-/*
-/* Updates the specified region of the interface on the live screen.
-*/
+ * Updates the specified region of the interface on the live screen.
+ *
+ * @param x1 Top-left X
+ * @param y1 Top-left Y
+ * @param xs X size
+ * @param ys Y size
+ */
static void inter_update(int x1, int y1, int xs, int ys) {
int refresh_flag;
int y1a;
@@ -655,7 +631,6 @@ static void inter_image(int x1, int y1, int xs, int ys) {
#endif
}
-
static void inter_scrollbar_refresh(void) {
int x1, y1, xs, ys;
@@ -673,15 +648,12 @@ static void inter_scrollbar_refresh(void) {
inter_update(x1, y1, xs, ys);
}
-
-/*
-/* inter_set_active_word()
-/*
-/* Sets an active word of the specific class_ to the "new" value.
-/* "old" is a pointer to the main control variable for that value,
-/* which also contains the old value of that variable. The old
-/* word is "turned off" automatically.
-*/
+/**
+ * Sets an active word of the specific class_ to the "new" value.
+ * "old" is a pointer to the main control variable for that value,
+ * which also contains the old value of that variable. The old
+ * word is "turned off" automatically.
+ */
static void inter_set_active_word(int class_, int *old, int new_) {
int x1, y1, xs, ys;
int temp;
@@ -728,14 +700,6 @@ static void inter_set_active_word(int class_, int *old, int new_) {
}
}
-
-
-/*
-/* inter_set_active_inven()
-/*
-/* Picks a new active object from the inventory list. This involves
-/* changing the list of object-specific verbs.
-*/
void inter_set_active_inven(int new_active) {
int new_verbs, old_verbs, max_verbs;
int x1, y1, xs, ys;
@@ -807,19 +771,12 @@ void inter_set_active_inven(int new_active) {
}
}
-
static void inter_purge_inven_stroke(void) {
left_inven = -1;
mouse_init_cycle();
stroke_type = STROKE_NONE;
}
-
-/*
-/* inter_give_to_player ()
-/*
-/* Adds the specified object to the player's inventory.
-*/
void inter_give_to_player(int this_) {
if (inven_num_objects >= INVEN_MAX_OBJECTS) {
error_report(ERROR_PLAYER_INVENTORY_FULL, ERROR, MODULE_INTER, this_, INVEN_MAX_OBJECTS);
@@ -829,12 +786,10 @@ void inter_give_to_player(int this_) {
inven[inven_num_objects] = this_;
- /* if (!inven_num_objects) { */
-
+ // if (!inven_num_objects) {
active_inven = inven_num_objects;
- /* } */
-
+ // }
first_inven = MAX(0, first_inven);
if (first_inven > inven_num_objects) first_inven = inven_num_objects;
@@ -849,11 +804,11 @@ void inter_give_to_player(int this_) {
inven_num_objects++;
- /* Paul moved this from below */
+ // Paul moved this from below
done:
;
- /* Paul here */
+ // Paul here
if ((kernel_mode == KERNEL_ACTIVE_CODE) &&
(inter_input_mode == INTER_BUILDING_SENTENCES ||
inter_input_mode == INTER_LIMITED_SENTENCES)) {
@@ -862,14 +817,6 @@ done:
}
}
-
-
-/*
-/* inter_take_from_player ()
-/*
-/* Moves the specified object from the player's inventory to
-/* the designated location.
-*/
void inter_take_from_player(int this_, int where_to) {
int id = -1;
int count;
@@ -918,13 +865,6 @@ void inter_take_from_player(int this_, int where_to) {
}
}
-
-/*
-/* inter_move_object()
-/*
-/* Moves an object to a new location, taking into account any
-/* player_inventory problems.
-*/
void inter_move_object(int object_id, int location) {
if (object_id == paul_object_showing &&
@@ -939,22 +879,17 @@ void inter_move_object(int object_id, int location) {
object[object_id].location = location;
}
- /* extra_blank_knothole(); */
-
+ // extra_blank_knothole();
done:
;
extra_display_object = false;
}
-
-
-/*
-/* inter_spot_correct()
-/*
-/* Takes a set of hotspot coordinates that is interface window relative
-/* and converts it to absolute screen coordinates.
-*/
+/**
+ * Takes a set of hotspot coordinates that is interface window relative
+ * and converts it to absolute screen coordinates.
+ */
static void inter_spot_correct(int *x1, int *y1, int *x2, int *y2, int xs, int ys) {
*x1 += inter_base_x;
*x2 = *x1 + xs - 1;
@@ -962,13 +897,6 @@ static void inter_spot_correct(int *x1, int *y1, int *x2, int *y2, int xs, int y
*y2 = *y1 + ys - 1;
}
-
-/*
-/* inter_setup_hotspots()
-/*
-/* Sets up the hotspot list for the interface module. Hotspots only
-/* need to be set up once for each room.
-*/
void inter_setup_hotspots(void) {
int count;
int x1, y1, xs, ys;
@@ -1038,12 +966,9 @@ void inter_setup_hotspots(void) {
inter_base_hotspots = numspots;
}
-
-/*
-/* inter_drag_check()
-/*
-/* Handles up/down "dragging" for inventory list.
-*/
+/**
+ * Handles up/down "dragging" for inventory list.
+ */
static void inter_drag_check(void) {
long timing_level;
long current_time;
@@ -1073,12 +998,10 @@ static void inter_drag_check(void) {
}
}
-/*
-/* inter_select_word()
-/*
-/* Determines which word is being picked off the screen, and makes
-/* it active.
-*/
+/**
+ * Determines which word is being picked off the screen, and makes
+ * it active.
+ */
static void inter_select_word(void) {
int x1, y1, x2, y2;
int junk;
@@ -1104,7 +1027,7 @@ static void inter_select_word(void) {
if (mouse_button && (right_action >= 0)) {
inter_set_active_word(STROKE_ACTION, &right_action, -1);
}
- /* tight_boxes = (end_of_selection && !mouse_button); */
+ // tight_boxes = (end_of_selection && !mouse_button);
tight_boxes = true;
break;
@@ -1115,7 +1038,7 @@ static void inter_select_word(void) {
strict = 0;
delta = first_inven;
selection = &left_inven;
- /* tight_boxes = (end_of_selection && ((!mouse_any_stroke) || !(inter_awaiting == AWAITING_COMMAND))); */
+ // tight_boxes = (end_of_selection && ((!mouse_any_stroke) || !(inter_awaiting == AWAITING_COMMAND)));
tight_boxes = true;
break;
@@ -1124,7 +1047,7 @@ static void inter_select_word(void) {
paul_id = object[inven[active_inven]].vocab_id;
paul_id = object_named(paul_id);
- if (paul_id == 8 && !global[86]) { /* pid doll / global [heal_verbs_visible] */
+ if (paul_id == 8 && !global[86]) { // pid doll / global [heal_verbs_visible]
quantity = 1;
} else {
quantity = object[inven[active_inven]].num_verbs;
@@ -1141,7 +1064,7 @@ static void inter_select_word(void) {
if (mouse_button && (right_command >= 0)) {
inter_set_active_word(STROKE_COMMAND, &right_command, -1);
}
- /* tight_boxes = end_of_selection && !mouse_button; */
+ // tight_boxes = end_of_selection && !mouse_button;
tight_boxes = true;
break;
@@ -1189,13 +1112,11 @@ static void inter_select_word(void) {
for (count = 0; (count < quantity) && (new_ < 0); count++) {
if (stroke_type == STROKE_INTERFACE) {
this_spot = base_spot + (quantity - (count + 1));
- /*
- if (count >= difference) {
- this_spot = base_spot + (room_num_spots - ((count - difference) + 1));
- } else {
- this_spot = base_spot + room_num_spots + count;
- }
- */
+ // if (count >= difference) {
+ // this_spot = base_spot + (room_num_spots - ((count - difference) + 1));
+ // } else {
+ // this_spot = base_spot + room_num_spots + count;
+ // }
} else {
this_spot = base_spot + count;
}
@@ -1348,13 +1269,6 @@ done:
;
}
-
-
-/*
-/* inter_init_sentence()
-/*
-/* Begins accepting a new sentence.
-*/
void inter_init_sentence(void) {
inter_awaiting = AWAITING_COMMAND;
@@ -1381,13 +1295,12 @@ void inter_init_sentence(void) {
inter_sentence_changed = true;
}
-
-
-/*
-/* inter_add_word_to_sentence()
-/*
-/* Adds the text for a vocabulary word to the current sentence.
-*/
+/**
+ * Adds the text for a vocabulary word to the current sentence.
+ *
+ * @param vocab_id Vocabulary Id
+ * @param capitalize Capitalization flag
+ */
static void inter_add_word_to_sentence(int vocab_id, int capitalize) {
int len;
@@ -1401,13 +1314,10 @@ static void inter_add_word_to_sentence(int vocab_id, int capitalize) {
Common::strcat_s(inter_sentence, istring_space);
}
-
-/*
-/* inter_compile_sentence()
-/*
-/* Puts together a string for the current sentence, based on the
-/* information currently available.
-*/
+/**
+ * Puts together a string for the current sentence, based on the
+ * information currently available.
+ */
static void inter_compile_sentence(void) {
int prep_special;
int verb;
@@ -1463,7 +1373,7 @@ static void inter_compile_sentence(void) {
inter_add_word_to_sentence(inter_verb, true);
if (inter_verb == words_look) {
- /* inter_prep = PREP_AT; */
+ // inter_prep = PREP_AT;
Common::strcat_s(inter_sentence, istring_prep_names[PREP_AT]);
Common::strcat_s(inter_sentence, istring_space);
}
@@ -1557,14 +1467,10 @@ done:
inter_sentence_changed = true;
}
-
-
-/*
-/* inter_analyze_stroke()
-/*
-/* Analyzes the potential effect of the current stroke on the sentence --
-/* w/ the proviso that the stroke is not yet finished.
-*/
+/**
+ * Analyzes the potential effect of the current stroke on the sentence --
+ * w/ the proviso that the stroke is not yet finished.
+ */
static void inter_analyze_stroke(void) {
if ((stroke_type == STROKE_COMMAND) || (stroke_type == STROKE_ACTION)) {
if ((inter_awaiting != AWAITING_COMMAND) && (picked_word >= 0)) {
@@ -1697,13 +1603,10 @@ done:
;
}
-
-/*
-/* inter_complete_stroke()
-/*
-/* Determines the final effect of a stroke on the sentence, after
-/* that stroke has been completed.
-*/
+/**
+ * Determines the final effect of a stroke on the sentence, after
+ * that stroke has been completed.
+ */
static void inter_complete_stroke(void) {
int demand_abort;
@@ -1756,7 +1659,7 @@ static void inter_complete_stroke(void) {
break;
case STROKE_SPECIAL_INVEN:
- /* (Remove break to have clicking on spinning object reset inven list) */
+ // (Remove break to have clicking on spinning object reset inven list)
break;
case STROKE_INVEN:
@@ -1845,15 +1748,11 @@ done:
;
}
-
-
-/*
-/* inter_background_animation()
-/*
-/* Manages the background animation for the interface screen, by
-/* advancing segment counters and changing matteing lists when
-/* appropriate.
-*/
+/**
+ * Manages the background animation for the interface screen, by
+ * advancing segment counters and changing matteing lists when
+ * appropriate.
+ */
static void inter_background_animation(void) {
int count, count2;
int temp;
@@ -1927,7 +1826,6 @@ done:
;
}
-
void inter_spinning_object(void) {
int count;
@@ -1964,8 +1862,6 @@ done:
;
}
-
-
void inter_turn_off_object(void) {
if (inter_object_series >= 0) {
delete_sprite_in_interface(inter_object_series);
@@ -1974,8 +1870,8 @@ void inter_turn_off_object(void) {
inter_object_series = -1;
}
- /* if last inventory object, copy section of interface */
- /* over inventory object after removed from list (removed above) */
+ // if last inventory object, copy section of interface
+ // over inventory object after removed from list (removed above)
if (active_inven == -1) {
if (kernel_mode == KERNEL_ACTIVE_CODE) {
video_update(&scr_inter, OUAF_OBJECT_X, 0,
@@ -1989,11 +1885,10 @@ void inter_turn_off_object(void) {
paul_object_showing = -1;
}
- /* will wipe out other 4 sprites */
+ // will wipe out other 4 sprites
if (inter_input_mode == INTER_BUILDING_SENTENCES) inter_refresh();
}
-
int inter_allocate_objects(void) {
int error_flag = true;
@@ -2014,7 +1909,6 @@ done:
return error_flag;
}
-
void inter_deallocate_objects(void) {
if (inter_objects_block != NULL) {
mem_free(inter_objects_block);
@@ -2022,7 +1916,6 @@ void inter_deallocate_objects(void) {
}
}
-
void inter_screen_update(void) {
if (kernel_mode == KERNEL_ACTIVE_CODE) {
if (inter_input_mode == INTER_BUILDING_SENTENCES) {
@@ -2034,7 +1927,6 @@ void inter_screen_update(void) {
}
}
-
static void inter_exec_function(void (*(target))()) {
target();
}
@@ -2045,8 +1937,8 @@ void inter_spin_object(int object_id) {
inter_turn_off_object();
- /* update to live screen chunk of interface that selected object */
- /* is on (it has been deleted in list by now) */
+ // Update to live screen chunk of interface that selected object
+ // is on (it has been deleted in list by now)
if (kernel_mode == KERNEL_ACTIVE_CODE) {
video_update(&scr_inter, OUAF_OBJECT_X, 0,
OUAF_OBJECT_X, 156,
@@ -2055,7 +1947,6 @@ void inter_spin_object(int object_id) {
if (!inter_spinning_objects) goto done;
- /* Paul */
if (inter_input_mode == INTER_BUILDING_SENTENCES ||
inter_input_mode == INTER_LIMITED_SENTENCES) inter_screen_update();
@@ -2099,15 +1990,6 @@ done:
sprite_force_size = 0;
}
-
-
-/*
-/* inter_main_loop()
-/*
-/* The main interface loop. Called by run-time kernel to perform one
-/* round of interface checking. Provides mouse interface for the whole
-/* program.
-*/
void inter_main_loop(int allow_input) {
int width, x, y;
int count;
@@ -2254,7 +2136,6 @@ void inter_main_loop(int allow_input) {
}
}
-
int inter_load_background(const char *name, Buffer *target) {
Color color[16];
int count;
diff --git a/engines/mads/madsv2/core/kernel.cpp b/engines/mads/madsv2/core/kernel.cpp
index 880871d5b57..79b573915b5 100644
--- a/engines/mads/madsv2/core/kernel.cpp
+++ b/engines/mads/madsv2/core/kernel.cpp
@@ -180,14 +180,12 @@ int kernel_load_vocab() {
long before, after;
#endif
- /* Load all main command verbs */
-
+ // Load all main command verbs
for (count = 0; count < INTER_COMMANDS; count++) {
vocab_make_active(command[count].id);
}
- /* Load all object names, and all verbs associated with objects */
-
+ // Load all object names, and all verbs associated with objects
for (count = 0; count < num_objects; count++) {
vocab_make_active(object[count].vocab_id);
@@ -196,8 +194,7 @@ int kernel_load_vocab() {
}
}
- /* Load vocabulary for this room's hot spots */
-
+ // Load vocabulary for this room's hot spots
for (count = 0; count < room_num_spots; count++) {
vocab_make_active(room_spots[count].vocab);
if (room_spots[count].verb > 0) {
@@ -233,26 +230,21 @@ void kernel_game_shutdown() {
vocab_unload_active();
- /* Drop cursor */
-
+ // Drop cursor
if (cursor != NULL) mem_free(cursor);
cursor = NULL;
- /* Free main video work buffer */
-
+ // Free main video work buffer
pack_set_special_buffer(NULL, NULL);
object_unload();
- /* inter_deallocate_objects(); */
-
+ // inter_deallocate_objects();
popup_available = false;
- /* Remove special keyboard handler */
-
+ // Remove special keyboard handler
keys_remove();
- /* Unload interface fonts */
-
+ // Unload interface fonts
if (font_misc != NULL) mem_free(font_misc);
if (font_menu != NULL) mem_free(font_menu);
if (font_conv != NULL) mem_free(font_conv);
@@ -261,29 +253,24 @@ void kernel_game_shutdown() {
font_main = font_conv = font_inter = NULL;
- /* Deallocate main screen buffer */
-
+ // Deallocate main screen buffer
if (work_screen_ems_handle < 0)
buffer_free(&scr_main);
- /* Turn of speech system */
-
+ // Turn of speech system
if (speech_system_active)
speech_shutdown();
- /* Return video to text mode */
-
+ // Return video to text mode
mouse_hide();
check_mode = video_mode;
mouse_init(false, text_mode);
video_init(text_mode, (check_mode != text_mode));
- /* Deallocate EMS/XMS memory */
-
+ // Deallocate EMS/XMS memory
himem_shutdown();
- /* Remove timer interrupt stuff */
-
+ // Remove timer interrupt stuff
timer_activate_low_priority(NULL);
timer_remove();
@@ -317,8 +304,7 @@ int kernel_game_startup(int game_video_mode, int load_flag,
int error_code = 0;
#endif
- /* Set up EMS/XMS paging system, if any */
-
+ // Set up EMS/XMS paging system, if any
himem_startup();
speech_init();
@@ -383,17 +369,13 @@ int kernel_game_startup(int game_video_mode, int load_flag,
}
}
- /* Some preliminary copy protection stuff */
-
- /* lock_preliminary_check(); */
-
- /* Initialize sound driver jump table */
-
- /* pl sound_driver_null(); */
+ // Some preliminary copy protection stuff
+ // lock_preliminary_check();
+ // Initialize sound driver jump table
+ // pl sound_driver_null();
timer_set_sound_flag(0);
- /* Video initialization */
-
+ // Video initialization
screen_dominant_mode(game_video_mode);
video_init(game_video_mode, (game_video_mode != text_mode));
mouse_init(true, game_video_mode);
@@ -402,8 +384,7 @@ int kernel_game_startup(int game_video_mode, int load_flag,
mcga_compute_retrace_parameters();
}
- /* Initialize the main screen work buffer & its sub-buffers */
-
+ // Initialize the main screen work buffer & its sub-buffers
if (work_screen_ems_handle >= 0) {
scr_main.x = video_x;
scr_main.y = video_y;
@@ -456,14 +437,12 @@ int kernel_game_startup(int game_video_mode, int load_flag,
keys_install();
}
- /* Log in demo copy */
-
+ // Log in demo copy
#ifdef demo
if (game_video_mode != text_mode) demo_log_in(release_version, release_date);
#endif
- /* Mention EMS paging situation */
-
+ // Mention EMS paging situation
#ifdef demo
if (ems_paging_active) {
ltoa(((long)ems_pages * EMS_PAGE_SIZE) >> 10, temp_buf, 10);
@@ -512,7 +491,7 @@ int kernel_game_startup(int game_video_mode, int load_flag,
}
// Load cursor sprite series
- cursor = sprite_series_load("*CURSOR.SS", PAL_MAP_RESERVED /* | PAL_MAP_DEFINE_RESERVED*/);
+ cursor = sprite_series_load("*CURSOR.SS", PAL_MAP_RESERVED);
if (cursor == NULL) {
#ifndef disable_error_check
error_code = ERROR_KERNEL_NO_CURSOR;
@@ -559,8 +538,7 @@ void kernel_section_shutdown() {
int kernel_section_startup(int newSection) {
int error_flag = true;
- /* Make note of new section number */
-
+ // Make note of new section number
previous_section = section_id;
section_id = newSection;
@@ -581,15 +559,14 @@ void kernel_room_shutdown() {
buffer_free(&scr_inter_orig);
}
- /* Dump the room hot spots */
+ // Dump the room hot spots
if (room_spots != NULL) {
mem_free(room_spots);
room_spots = NULL;
room_num_spots = 0;
}
- /* Remove our palette shadowing list */
-
+ // Remove our palette shadowing list
pal_activate_shadow(NULL);
if (room != NULL) {
@@ -613,44 +590,35 @@ int kernel_room_startup(int newRoom, int initial_variant, const char *interface,
int error_data = 0;
#endif
- /* Make a note of the new room number & variant */
-
+ // Make a note of the new room number & variant
previous_room = room_id;
room_id = newRoom;
room_variant = initial_variant;
scr_inter_orig.data = nullptr;
- /* Start a brand new palette, reserving the proper # of colors */
+ // Start a brand new palette, reserving the proper # of colors
if (new_palette)
pal_init(KERNEL_RESERVED_LOW_COLORS, KERNEL_RESERVED_HIGH_COLORS);
pal_white(master_palette);
- /* Load up popup box frame */
-
- /*
- if (popup_box_load()) {
- error_code = ERROR_KERNEL_NO_POPUP;
- goto done;
- }
- */
-
- /* Initialize the matteing system */
-
+ // Load up popup box frame
+ // if (popup_box_load()) {
+ // error_code = ERROR_KERNEL_NO_POPUP;
+ // goto done;
+ // }
+ // Initialize the matteing system
matte_init(false);
- /* Initialize graphics sequence data structures */
-
+ // Initialize graphics sequence data structures
kernel_seq_init();
kernel_message_init();
- /* Activate the main shadow list */
-
+ // Activate the main shadow list
pal_activate_shadow(&kernel_shadow_main);
- /* Load header, picture, and attribute screen for this room */
-
+ // Load header, picture, and attribute screen for this room
load_flags = ROOM_LOAD_HARD_SHADOW;
if (kernel.translating) load_flags |= ROOM_LOAD_TRANSLATE;
@@ -677,35 +645,29 @@ int kernel_room_startup(int newRoom, int initial_variant, const char *interface,
tile_pan(&picture_map, picture_view_x, picture_view_y);
tile_pan(&depth_map, picture_view_x, picture_view_y);
- /* Set up color cycling table for this room */
-
+ // Set up color cycling table for this room
cycle_init(&room->cycle_list, false);
- /* Initialize rail-system parameters for this room */
-
+ // Initialize rail-system parameters for this room
rail_num_nodes = room->num_rails + 2;
rail_base = &room->rail[0];
rail_connect_all_nodes();
- /* Make preliminary scaling computations */
-
+ // Make preliminary scaling computations
kernel_room_bound_dif = room->front_y - room->back_y;
kernel_room_scale_dif = room->front_scale - room->back_scale;
- /* Initialize the graphics image lists */
-
+ // Initialize the graphics image lists
image_marker = 1;
image_list[0].flags = IMAGE_REFRESH;
image_list[0].segment_id = KERNEL_SEGMENT_SYSTEM;
- /* Set up graphics window locations */
-
+ // Set up graphics window locations
viewing_at_y = 0;
inter_viewing_at_y = inter_base_y;
- /* Mark the boundary between interface and room sprite series */
-
+ // Mark the boundary between interface and room sprite series
kernel_room_series_marker = series_list_marker;
if (barebones) {
@@ -762,8 +724,7 @@ done:
void kernel_unload_all_series() {
int count;
- /* Unload all series (but don't unload those for the interface background) */
-
+ // Unload all series (but don't unload those for the interface background)
for (count = series_list_marker - 1; count >= kernel_room_series_marker; count--) {
if (series_user[count] > 1) series_user[count] = 1;
matte_deallocate_series(count, true);
@@ -787,13 +748,6 @@ int kernel_load_series(const char *name, int load_flags) {
return handle;
}
-/*
-/* kernel_flip_hotspot()
-/*
-/* Toggles an interface hotspot (referenced by its vocabulary word)
-/* on or off. Hotspots that are off do not interact with the mouse
-/* cursor.
-*/
void kernel_flip_hotspot(int vocab_code, int active) {
int count;
@@ -1013,7 +967,6 @@ void kernel_synch(int slave_type, int slave_id, int master_type, int master_id)
break;
}
-
switch (slave_type) {
case KERNEL_SERIES:
sequence_list[slave_id].base_time = master_time;
@@ -1773,7 +1726,7 @@ static void kernel_process_animation(int handle, int asynchronous) {
if (!asynchronous) {
if (kernel_anim[handle].anim->frame[kernel_anim[handle].frame].sound) {
- /* pl sound_play(kernel_anim[handle].anim->frame[kernel_anim[handle].frame].sound); */
+ // pl sound_play(kernel_anim[handle].anim->frame[kernel_anim[handle].frame].sound);
}
if ((kernel_anim[handle].anim->misc_peel_x != 0) || (kernel_anim[handle].anim->misc_peel_y != 0)) {
@@ -1841,18 +1794,15 @@ static void kernel_process_animation(int handle, int asynchronous) {
seg_id = image_list[id].segment_id;
- /* image_list[id].segment_id += KERNEL_SEGMENT_ANIMATION; */
+ // image_list[id].segment_id += KERNEL_SEGMENT_ANIMATION;
image_list[id].segment_id = (byte)(KERNEL_SEGMENT_ANIMATION + handle);
image_list[id].flags = series_list[image_list[id].series_id]->delta_series ? IMAGE_DELTA : IMAGE_UPDATE;
- /*
- if (kernel_anim[handle].anim->misc_any_packed) {
- if (image_list[id].series_id == (byte)kernel_anim[handle].anim->series_id[kernel_anim[handle].anim->misc_packed_series]) {
- series_id = image_list[id].series_id;
- sprite_data_load (series_list[series_id], image_list[id].sprite_id, series_list[series_id]->arena);
- }
- }
- */
-
+ // if (kernel_anim[handle].anim->misc_any_packed) {
+ // if (image_list[id].series_id == (byte)kernel_anim[handle].anim->series_id[kernel_anim[handle].anim->misc_packed_series]) {
+ // series_id = image_list[id].series_id;
+ // sprite_data_load (series_list[series_id], image_list[id].sprite_id, series_list[series_id]->arena);
+ // }
+ // }
if (hot >= 0) {
kernel_hot_check(hot, id, seg_id);
}
@@ -2743,8 +2693,7 @@ int kernel_generate_random_message(int chance_major, int chance_minor) {
for (count = 0; count < random_max_messages; count++) {
if (random_message_handle[count] < 0) {
- /* Don't allow two phrases to teletype at once */
-
+ // Don't allow two phrases to teletype at once
bad = false;
for (scan = 0; scan < random_max_messages; scan++) {
if (random_message_handle[scan] >= 0) {
@@ -2754,12 +2703,10 @@ int kernel_generate_random_message(int chance_major, int chance_minor) {
}
}
- /* Check random chance for message to appear */
-
+ // Check random chance for message to appear
if ((imath_random(1, chance_major) <= chance_minor) && !bad) {
- /* Pick randomly from our list of allowable quotes */
-
+ // Pick randomly from our list of allowable quotes
do {
idx = imath_random(0, random_quote_list_size - 1);
quote = random_quote_list[idx];
@@ -2773,12 +2720,10 @@ int kernel_generate_random_message(int chance_major, int chance_minor) {
random_message_quote[count] = quote;
- /* Put message in a random location */
-
+ // Put message in a random location
message_x = imath_random(random_min_x, random_max_x);
- /* Be sure Y values are properly spaced */
-
+ // Be sure Y values are properly spaced
crash_timeout = 0;
do {
@@ -2796,8 +2741,7 @@ int kernel_generate_random_message(int chance_major, int chance_minor) {
}
} while (bad);
- /* Put our new message in the list */
-
+ // Put our new message in the list
random_message_handle[count] =
kernel_message_add(quote_string(kernel.quotes, random_message_quote[count]),
message_x, message_y, random_message_color, random_message_duration,
@@ -2840,21 +2784,18 @@ void kernel_set_interface_mode(int mode) {
image_inter_list[0].flags = IMAGE_REFRESH;
image_inter_list[0].segment_id = (byte)-1;
- /* Set up interface animation clock */
-
+ // Set up interface animation clock
inter_base_time = timer_read();
left_command = -1;
left_action = -1;
left_inven = -1;
- /* Initialize interface work area */
-
+ // Initialize interface work area
if (!viewing_at_y) {
buffer_rect_copy(scr_inter_orig, scr_inter, 0, 0, video_x, inter_size_y);
- /* Initialize interface grammar driver */
-
+ // Initialize interface grammar driver
if (kernel_mode == KERNEL_ACTIVE_CODE) matte_inter_frame(false, false);
}
@@ -2879,12 +2820,10 @@ void kernel_room_scale(int front_y, int front_scale,
}
void kernel_background_shutdown() {
- /* Remove our palette shadowing list */
-
+ // Remove our palette shadowing list
pal_activate_shadow(NULL);
- /* Dump the picture & attribute buffers, along with the room header */
-
+ // Dump the picture & attribute buffers, along with the room header
if (room != NULL) {
room_unload(room,
&scr_orig,
@@ -2903,32 +2842,26 @@ int kernel_background_startup(int newRoom, int initial_variant) {
int error_code = 0;
int error_data = 0;
- /* Make a note of the new room number & variant */
-
+ // Make a note of the new room number & variant
previous_room = room_id;
room_id = newRoom;
room_variant = initial_variant;
- /* Start a brand new palette, reserving the proper # of colors */
-
+ // Start a brand new palette, reserving the proper # of colors
pal_init(KERNEL_RESERVED_LOW_COLORS, KERNEL_RESERVED_HIGH_COLORS);
pal_white(master_palette);
- /* Initialize the matteing system */
-
+ // Initialize the matteing system
matte_init(false);
- /* Initialize graphics sequence data structures */
-
+ // Initialize graphics sequence data structures
kernel_seq_init();
kernel_message_init();
- /* Activate the main shadow list */
-
+ // Activate the main shadow list
pal_activate_shadow(&kernel_shadow_main);
- /* Load header, picture, and attribute screen for this room */
-
+ // Load header, picture, and attribute screen for this room
load_flags = ROOM_LOAD_HARD_SHADOW;
if (kernel.translating) load_flags |= ROOM_LOAD_TRANSLATE;
@@ -2953,18 +2886,15 @@ int kernel_background_startup(int newRoom, int initial_variant) {
tile_pan(&picture_map, picture_view_x, picture_view_y);
tile_pan(&depth_map, picture_view_x, picture_view_y);
- /* Set up color cycling table for this room */
-
+ // Set up color cycling table for this room
cycle_init(&room->cycle_list, false);
- /* Initialize the graphics image lists */
-
+ // Initialize the graphics image lists
image_marker = 1;
image_list[0].flags = IMAGE_REFRESH;
image_list[0].segment_id = KERNEL_SEGMENT_SYSTEM;
- /* Mark the boundary between interface and room sprite series */
-
+ // Mark the boundary between interface and room sprite series
kernel_room_series_marker = series_list_marker;
error_flag = false;
diff --git a/engines/mads/madsv2/core/loader.cpp b/engines/mads/madsv2/core/loader.cpp
index 0a99227e5ae..83210a925fe 100644
--- a/engines/mads/madsv2/core/loader.cpp
+++ b/engines/mads/madsv2/core/loader.cpp
@@ -92,10 +92,7 @@ int loader_open(LoadHandle handle, const char *filename, const char *options, in
handle->pack_list_marker = 0;
handle->reading = true;
- /*
- printf ("Opened %d with xms handle %d\n", found_himem, himem_directory_entry->xms_handle);
- */
-
+ // printf ("Opened %d with xms handle %d\n", found_himem, himem_directory_entry->xms_handle);
for (count = 0; count < (int)handle->pack.num_records; count++) {
handle->pack.strategy[count].type = PACK_NONE;
handle->pack.strategy[count].size = himem_directory_entry->packet_size[count];
@@ -173,14 +170,14 @@ int loader_close(LoadHandle handle) {
handle->ems_page_marker = -1;
handle->ems_page_offset = EMS_PAGE_SIZE;
handle->xms_offset = 0;
- /* if (ems_paging_active) ems_unmap_all(); */
+ // if (ems_paging_active) ems_unmap_all();
} else {
if (!handle->reading) {
#ifdef TODO
handle->handle->seek(0);
error_flag = !fileio_fwrite_f(&handle->pack, sizeof(PackList), 1, handle->handle);
#else
- error("TODO: loader_closer for writing");
+ error("TODO: loader_close for writing");
#endif
}
@@ -230,10 +227,7 @@ long loader_read(void *target, long record_size, long record_count, LoadHandle h
} else if (handle->mode == LOADER_XMS) {
result = 0;
- /*
- printf ("Reading (%d) at %ld for size %ld\n", handle->xms_handle, handle->xms_offset, total_size);
- */
-
+ // printf ("Reading (%d) at %ld for size %ld\n", handle->xms_handle, handle->xms_offset, total_size);
if (xms_copy(total_size,
handle->xms_handle, (XMS)handle->xms_offset,
MEM_CONV, target)) goto done;
@@ -297,9 +291,7 @@ done:
}
}
-
-long loader_write(void *target, long record_size, long record_count,
- LoadHandle handle) {
+long loader_write(void *target, long record_size, long record_count, LoadHandle handle) {
long total_size, result = 0;
long file_pos;
int packing_flag;
@@ -343,7 +335,6 @@ long loader_write(void *target, long record_size, long record_count,
return (result / record_size);
}
-
long loader_write_2(Common::WriteStream *source_handle, long total_size, LoadHandle handle) {
long result;
long file_pos;
diff --git a/engines/mads/madsv2/core/magic.cpp b/engines/mads/madsv2/core/magic.cpp
index f8416336f6a..44c191194f3 100644
--- a/engines/mads/madsv2/core/magic.cpp
+++ b/engines/mads/madsv2/core/magic.cpp
@@ -81,13 +81,6 @@ void magic_grey_palette(Palette *pal) {
}
-/*
-/* magic_grey_popularity()
-/*
-/* Given a "grey_list" containing "num_colors" grey values (0-63),
-/* produces a 64-byte "grey_table" containing the number of grey
-/* values of each intensity level.
-*/
void magic_grey_popularity(byte *grey_list, byte *grey_table, int num_colors) {
int i;
memset(grey_table, 0, 64);
@@ -169,7 +162,7 @@ void magic_map_to_grey_ramp(Palette *pal,
}
}
- /* pal_pointer = (byte *) &(((RGBcolor *) pal)[base_grey]); */
+ // pal_pointer = (byte *) &(((RGBcolor *) pal)[base_grey]);
pal_pointer = ((byte *) pal + (base_grey * 3));
for (greys = 0; greys < num_greys; greys++) {
for (color = 0; color < 3; color++) {
@@ -225,10 +218,9 @@ void magic_fade_to_grey(Palette pal, byte *map_pointer,
byte *pal_index;
char *signs;
MagicGrey *magic_map;
- /* Palette temp_pal; */
- /* char signs[256][3]; */
- /* MagicGrey magic_map[256]; */
-
+ // Palette temp_pal;
+ // char signs[256][3];
+ // MagicGrey magic_map[256];
memory_needed = (sizeof(Palette) << 1) + (sizeof(MagicGrey) << 8);
if (timer_low_semaphore) {
@@ -266,8 +258,8 @@ void magic_fade_to_grey(Palette pal, byte *map_pointer,
dif = (intensity - pal_color(pal, count, color));
*(pal_index + (color << 8) + count) = (byte)abs(dif);
*(signs + (color << 8) + count) = (char)sgn(dif);
- /* pal_color(temp_pal,count,color) = (byte)abs(dif); */
- /* signs[count][color] = (char)sgn(dif); */
+ // pal_color(temp_pal,count,color) = (byte)abs(dif);
+ // signs[count][color] = (char)sgn(dif);
}
}
@@ -278,11 +270,11 @@ void magic_fade_to_grey(Palette pal, byte *map_pointer,
index = count - base_color;
for (color = 0; color < 3; color++) {
magic_map[index].accum[color] += *(pal_index + (color << 8) + count);
- /* magic_map[index].accum[color] += pal_color(temp_pal, count, color); */
+ // magic_map[index].accum[color] += pal_color(temp_pal, count, color);
while (magic_map[index].accum[color] >= (word)steps) {
magic_map[index].accum[color] -= steps;
pal_color(pal, count, color) += *(signs + (color << 8) + count);
- /* pal_color(pal,count,color) += signs[count][color]; */
+ // pal_color(pal,count,color) += signs[count][color];
}
}
}
@@ -326,10 +318,9 @@ void magic_fade_from_grey(RGBcolor *pal, Palette target,
byte *pal_index;
char *signs;
MagicGrey *magic_map;
- /* Palette temp_pal; */
- /* char signs[256][3]; */
- /* MagicGrey magic_map[256]; */
-
+ // Palette temp_pal;
+ // char signs[256][3];
+ // MagicGrey magic_map[256];
memory_needed = (sizeof(Palette) << 1) + (sizeof(MagicGrey) << 8);
if (timer_low_semaphore) {
@@ -368,9 +359,9 @@ void magic_fade_from_grey(RGBcolor *pal, Palette target,
}
dif = (pal_color(target, count, color) - intensity);
*(pal_index + (count * 3) + color) = (byte)abs(dif);
- /* pal_color(pal_index,count,color) = (byte)abs(dif); */
+ // pal_color(pal_index,count,color) = (byte)abs(dif);
*(signs + (color << 8) + count) = (char)sgn(dif);
- /* signs[count][color] = (char)sgn(dif); */
+ // signs[count][color] = (char)sgn(dif);
magic_map[index].accum[color] = 0;
}
}
@@ -382,12 +373,12 @@ void magic_fade_from_grey(RGBcolor *pal, Palette target,
index = count - base_color;
for (color = 0; color < 3; color++) {
magic_map[index].accum[color] += *(pal_index + (count * 3) + color);
- /* magic_map[index].accum[color] += pal_color(pal_index ,count, color); */
+ // magic_map[index].accum[color] += pal_color(pal_index ,count, color);
while (magic_map[index].accum[color] >= (word)steps) {
magic_map[index].accum[color] -= steps;
*((byte *)pal + (count * 3) + color) += *(signs + (color << 8) + count);
- /* *(((byte *)&pal[count])+color) += *(signs + (color << 8) + count); */
- /* *(((byte *)&pal[count])+color) += signs[count][color]; */
+ // (((byte *)&pal[count])+color) += *(signs + (color << 8) + count);
+ // (((byte *)&pal[count])+color) += signs[count][color];
}
}
}
@@ -407,13 +398,6 @@ done:
}
-/*
-/* magic_screen_change_corner()
-/*
-/* Picture-to-picture transition in which one of the screen
-/* corners is pulled diagonally across the screen to bring in
-/* the new view.
-*/
void magic_screen_change_corner(Buffer *new_screen, Palette pal,
int corner_id,
int buffer_base_x, int buffer_base_y,
@@ -564,11 +548,6 @@ void magic_screen_change_corner(Buffer *new_screen, Palette pal,
}
-/* magic_screen_change_edge()
-/*
-/* Picture-to-picture transition in which the new picture sweeps
-/* in from either the right or left edge.
-*/
void magic_screen_change_edge(Buffer *new_screen, Palette pal,
int edge_id,
int buffer_base_x, int buffer_base_y,
@@ -672,13 +651,6 @@ void magic_screen_change_edge(Buffer *new_screen, Palette pal,
}
-/*
-/* magic_screen_change_circle()
-/*
-/* Picture-to-picture transition in which the new picture is
-/* brought in with either expanding or contracting concentric
-* circles.
-*/
void magic_screen_change_circle(Buffer *new_screen, Palette pal,
int inward_flag,
int buffer_base_x, int buffer_base_y,
@@ -859,7 +831,7 @@ void magic_shrink_buffer(Buffer *from, Buffer *unto) {
y_count = from->y;
x_count = from->x;
- /* Build X Bresenham table */
+ // Build X Bresenham table
bres = 0;
for (i = 0; i < from_wrap; i++) {
bres += unto_wrap;
@@ -871,7 +843,7 @@ void magic_shrink_buffer(Buffer *from, Buffer *unto) {
}
}
- /* Shrink pixels using Y Bresenham + X table */
+ // Shrink pixels using Y Bresenham + X table
bres = 0;
do {
bres += unto_size;
@@ -1101,7 +1073,7 @@ void magic_swap_foreground(byte *background_table,
int count;
byte *old_palette;
byte swap_table[256];
- /* Palette old_palette; */
+ // Palette old_palette;
long memory_needed;
byte *work_memory = NULL;
Heap magic_heap;
diff --git a/engines/mads/madsv2/core/matte.cpp b/engines/mads/madsv2/core/matte.cpp
index b6e6b5c3835..2c26cd0d36b 100644
--- a/engines/mads/madsv2/core/matte.cpp
+++ b/engines/mads/madsv2/core/matte.cpp
@@ -226,8 +226,7 @@ void matte_deallocate_series(int id, int free_memory) {
sprite_free(&series_list[id], free_memory);
series_list[id] = NULL;
- /* Protect against memory fragmentation */
-
+ // Protect against memory fragmentation
if (id < SERIES_LIST_SIZE) {
if (id == series_list_marker - 1) {
series_list_marker--;
@@ -328,35 +327,33 @@ void bound_matte(MattePtr matte, int xs, int ys, int maxx, int maxy) {
}
#endif
- x2 = matte->x + xs - 1; /* Determine right most point */
- matte->x = MAX(0, matte->x); /* Scale coordinates to work */
+ x2 = matte->x + xs - 1; // Determine right most point
+ matte->x = MAX(0, matte->x); // Scale coordinates to work
x2 = MAX(0, x2);
x2 = MIN((maxx - 1), x2);
- matte->xs = (x2 - matte->x) + 1; /* Determine horizontal size */
+ matte->xs = (x2 - matte->x) + 1; // Determine horizontal size
- matte->xh = matte->xs >> 1; /* Set half-width */
- matte->xc = matte->x + (((matte->xs + 1) >> 1) - 1); /* Set center mark */
+ matte->xh = matte->xs >> 1; // Set half-width
+ matte->xc = matte->x + (((matte->xs + 1) >> 1) - 1); // Set center mark
- y2 = matte->y + ys - 1; /* Determine lower most point */
- matte->y = MAX(0, matte->y); /* Scale coordinates to work */
+ y2 = matte->y + ys - 1; // Determine lower most point
+ matte->y = MAX(0, matte->y); // Scale coordinates to work
y2 = MAX(0, y2);
y2 = MIN((maxy - 1), y2);
- matte->ys = (y2 - matte->y) + 1; /* Determine vertical size */
+ matte->ys = (y2 - matte->y) + 1; // Determine vertical size
- matte->yh = matte->ys >> 1; /* Set half-height */
- matte->yc = matte->y + (((matte->ys + 1) >> 1) - 1); /* Set center mark */
+ matte->yh = matte->ys >> 1; // Set half-height
+ matte->yc = matte->y + (((matte->ys + 1) >> 1) - 1); // Set center mark
matte->valid = true;
matte->linked_matte = nullptr;
}
-/*
-/* static make_matte (ImagePtr image, MattePtr matte)
-/*
-/* Proposes a matte-ing scheme (matte) for the specified image. This
-/* initial matte is the smallest possible rectangle which will completely
-/* enclose its sprite.
-*/
+/**
+ * Proposes a matte-ing scheme (matte) for the specified image. This
+ * initial matte is the smallest possible rectangle which will completely
+ * enclose its sprite.
+ */
static void make_matte(ImagePtr image, MattePtr matte) {
SpritePtr sprite;
int xs, ys;
@@ -394,49 +391,39 @@ static void make_message_matte(int handle, MattePtr matte) {
scr_work.x, scr_work.y);
}
-/*
-/* static int check_collisions (MattePtr matte1, MattePtr matte2)
-/*
-/* matte1, matte2 = pointers to mattes to be checked for
-/* collisions (i.e. overlapping areas).
-/*
-/* Returns TRUE if the two specified mattes overlap and need to be
-/* combined into one big matte.
-/*
-/* (Algorithm: overlap if on each axis the distance between the centers
-/* of the mattes is less-than/equal-to the sum of the half widths)
-*/
+/**
+ * matte1, matte2 = pointers to mattes to be checked for
+ * collisions (i.e. overlapping areas).
+ * Returns TRUE if the two specified mattes overlap and need to be
+ * combined into one big matte.
+ * (Algorithm: overlap if on each axis the distance between the centers
+ * of the mattes is less-than/equal-to the sum of the half widths)
+ */
static int check_collisions(MattePtr matte1, MattePtr matte2) {
return (ABS(matte1->xc - matte2->xc) <= (matte1->xh + matte2->xh)) &&
(ABS(matte1->yc - matte2->yc) <= (matte1->yh + matte2->yh));
}
-/*
-/* static int combine_mattes (MattePtr matte1, MattePtr matte2)
-/*
-/* matte1, matte2 = pointers to the mattes to be merged (matte1
-/* will receive the combined matte).
-/*
-*/
+/**
+ * matte1, matte2 = pointers to the mattes to be merged (matte1
+ * will receive the combined matte).
+ */
static void combine_mattes(MattePtr matte1, MattePtr matte2) {
int highx, highy;
- /* Get the maximum x and y values (+1) of the two mattes */
-
+ // Get the maximum x and y values (+1) of the two mattes
highx = MAX((matte1->x + matte1->xs), (matte2->x + matte2->xs));
highy = MAX((matte1->y + matte1->ys), (matte2->y + matte2->ys));
- /* Get the minimum x and y values of the two mattes; these will */
- /* serve as the x/y base position of the combined matte. */
-
+ // Get the minimum x and y values of the two mattes; these will
+ // serve as the x/y base position of the combined matte.
matte1->x = MIN(matte1->x, matte2->x);
matte1->y = MIN(matte1->y, matte2->y);
- /* Subtract the minimums from the maximums+1 to get the new matte's */
- /* size. Then, compute the half heights/widths and the center points. */
- /* Note that since we are doing integer "division", we must adjust to */
- /* make sure that lost bits do not result in a failed collision test. */
-
+ // Subtract the minimums from the maximums+1 to get the new matte's
+ // size. Then, compute the half heights/widths and the center points.
+ // Note that since we are doing integer "division", we must adjust to
+ // make sure that lost bits do not result in a failed collision test.
matte1->xs = highx - matte1->x;
matte1->xh = matte1->xs >> 1;
matte1->xc = matte1->x + (((matte1->xs + 1) >> 1) - 1);
@@ -445,86 +432,58 @@ static void combine_mattes(MattePtr matte1, MattePtr matte2) {
matte1->yh = matte1->ys >> 1;
matte1->yc = matte1->y + (((matte1->ys + 1) >> 1) - 1);
- /* Mark matte2 as EMPTY, but leave behind a pointer to matte1 */
+ // Mark matte2 as EMPTY, but leave behind a pointer to matte1
matte2->valid = false;
matte2->linked_matte = matte1;
- /* Set matte1's update flag TRUE; we need to redraw everything in */
- /* this matte. */
+ // Set matte1's update flag TRUE; we need to redraw everything in
+ // this matte.
matte1->changed = true;
}
-/*
-/* static void filter_matte_list (MattePtr matte, int size, int base_index)
-/*
-/* size length of the matte list to be filtered
-/* base_index index at which unfiltered mattes begin.
-/*
-/* Filters the matte list, resolving any collisions by combining
-/* the two mattes into one big matte. Since the filter iterates until
-/* no collisions are found, the combined matte could again collide
-/* with another matte, and so forth (so the worst case is one BIG
-/* matte for all of the active series). Note that there is no need
-/* to combine two overlapping mattes when *neither* has its changed
-/* flag set. The "size" parameter is used to specify whether to
-/* filter mattes from this round only, or to merge in the old matte
-/* list from last round (which is used to perform erasures). "Base_index"
-/* can be used when merging an unfiltered list into a pre-filtered list
-/* in order to avoid checking the originals against each other all over
-/* again.
-*/
void filter_matte_list(MattePtr matte, int size, int base_index) {
int index1, index2, any_more;
MattePtr matte1;
MattePtr matte2;
- /* Loop until we make a perfect pass (no collisions) through list */
-
+ // Loop until we make a perfect pass (no collisions) through list
for (any_more = true; any_more;) {
any_more = false;
- /* Outer index counts through unfiltered mattes only */
-
+ // Outer index counts through unfiltered mattes only
matte1 = &matte[base_index] - 1;
for (index1 = base_index; index1 < size; index1++) {
matte1++;
- /* Ignore empty matte blocks */
-
+ // Ignore empty matte blocks
if (matte1->valid) {
- /* Inner index counts through all mattes with lower indices */
- /* than our current outer index. */
-
+ // Inner index counts through all mattes with lower indices
+ // than our current outer index.
matte2 = matte - 1;
for (index2 = 0; index2 < index1; index2++) {
matte2++;
- /* Again, ignore empty matte blocks */
-
+ // Again, ignore empty matte blocks
if (matte2->valid) {
- /* We've got two real mattes; check for collisions */
-
+ // We've got two real mattes; check for collisions
if (check_collisions(matte1, matte2)) {
- /* Mattes overlap; check if either has changed flag set */
-
+ // Mattes overlap; check if either has changed flag set
if (matte1->changed || matte2->changed) {
- /* Active ("changed") matte triggers collision; combine into */
- /* one big messy matte. */
-
+ // Active ("changed") matte triggers collision; combine into
+ // one big messy matte.
combine_mattes(matte1, matte2);
- /* Mark that this is no longer a perfect pass; we'll have to */
- /* loop through the whole thing again. */
-
+ // Mark that this is no longer a perfect pass; we'll have to
+ // loop through the whole thing again.
any_more = true;
- /* And now, for your pleasure, we have no less */
- /* than EIGHT consecutive close braces!!! What */
- /* fun! Whoopee! This is C's finest hour! */
+ // And now, for your pleasure, we have no less
+ // than EIGHT consecutive close braces!!! What
+ // fun! Whoopee! This is C's finest hour!
}
}
}
@@ -545,7 +504,7 @@ static void matte_quick_to_black(byte *special_pal, int ticks) {
source = special_pal;
dest = increments;
- /* Build increment table: each entry is ceil(source[i] / 4), minimum 1 */
+ // Build increment table: each entry is ceil(source[i] / 4), minimum 1
for (int i = 0; i < 768; i++)
{
byte inc = (source[i] >> 2) + ((source[i] & 3) ? 1 : 0);
@@ -595,7 +554,7 @@ static void matte_quick_from_black(byte *special_pal, int ticks) {
special = increments;
dest = special_pal;
- /* Build increment table from master palette: ceil(source[i] / 4), minimum 1 */
+ // Build increment table from master palette: ceil(source[i] / 4), minimum 1
for (int i = 0; i < 768; i++) {
byte inc = (source[i] >> 2) + ((source[i] & 3) ? 1 : 0);
if (inc == 0)
@@ -608,16 +567,16 @@ static void matte_quick_from_black(byte *special_pal, int ticks) {
fade_clock = timer_read_600() + ticks;
for (int i = 0; i < 768; i++) {
- byte current = dest[i]; /* current fading value (starts at black) */
- byte target = source[i]; /* master palette ceiling for this channel */
+ byte current = dest[i]; // current fading value (starts at black)
+ byte target = source[i]; // master palette ceiling for this channel
byte inc = special[i];
if ((int)current + inc >= target)
- current = target; /* clamp to target; channel is done */
+ current = target; // clamp to target; channel is done
else
{
current += inc;
- going = true; /* still short of target, keep going */
+ going = true; // still short of target, keep going
}
dest[i] = current;
@@ -672,8 +631,7 @@ static void matte_special_effect(int special_effect, int full_screen) {
if (special_effect == MATTE_FX_FADE_THRU_BLACK) {
mcga_getpal(&special_pal);
matte_quick_to_black(&special_pal[0].r, 1);
- /* magic_fade_to_grey (special_pal, NULL, 0, 256, 0, 1, 1, 16); */
-
+ // magic_fade_to_grey (special_pal, NULL, 0, 256, 0, 1, 1, 16);
buffer_fill(scr_live, 0);
}
@@ -685,7 +643,7 @@ static void matte_special_effect(int special_effect, int full_screen) {
work_screen->x, work_screen->y);
matte_quick_from_black(&special_pal[0].r, 1);
- /* magic_fade_from_grey (special_pal, master_palette, 0, 256, 0, 1, 1, 16); */
+ // magic_fade_from_grey (special_pal, master_palette, 0, 256, 0, 1, 1, 16);
break;
case MATTE_FX_CORNER_LOWER_LEFT:
@@ -771,7 +729,7 @@ void matte_frame(int special_effect, int full_screen) {
int count;
#endif
- /* Make sure work buffer is mapped into the page frame */
+ // Make sure work buffer is mapped into the page frame
matte_map_work_screen();
any_refresh = false;
@@ -822,12 +780,12 @@ void matte_frame(int special_effect, int full_screen) {
for (id = image_marker; id < FIRST_MESSAGE_MATTE; id++) {
matte->valid = false;
matte++;
- /* matte_list[id].valid = false; */
+ // matte_list[id].valid = false;
}
message = message_list;
for (id = 0; id < MESSAGE_LIST_SIZE; id++) {
- /* index = id + FIRST_MESSAGE_MATTE; */
+ // index = id + FIRST_MESSAGE_MATTE;
if ((message->status < 0) && message->active) {
matte->changed = true;
make_message_matte(id, matte);
@@ -838,8 +796,7 @@ void matte_frame(int special_effect, int full_screen) {
matte++;
}
- /* Erasures */
-
+ // Erasures
if (!any_refresh) {
filter_matte_list(matte_list, MATTE_LIST_SIZE, 1);
@@ -896,30 +853,26 @@ void matte_frame(int special_effect, int full_screen) {
message++;
}
- /* Check our new matte list for collisions */
-
+ // Check our new matte list for collisions
if (!any_refresh) filter_matte_list(matte_list, MATTE_LIST_SIZE, 1);
- /* Now, create the depth list for our currently active series. Only */
- /* create depth list entries for those images which belong to mattes */
- /* that have their "changed" flags set (i.e. mattes which need to be */
- /* redrawn this round. */
-
+ // Now, create the depth list for our currently active series. Only
+ // create depth list entries for those images which belong to mattes
+ // that have their "changed" flags set (i.e. mattes which need to be
+ // redrawn this round.
image = image_list;
matte = matte_list;
for (id = depth_size = 0; id < (int)image_marker; id++) {
if (image->flags >= IMAGE_STATIC) {
- /* Search through the matte list to find the matte of which this */
- /* image is a part. */
-
+ // Search through the matte list to find the matte of which this
+ // image is a part.
for (matte2 = matte; !matte2->valid; matte2 = matte2->linked_matte) {
}
- /* If its matte is being updated, make a depth list entry for */
- /* our sprite. */
-
+ // If its matte is being updated, make a depth list entry for
+ // our sprite.
if (matte2->changed || any_refresh) {
depth_list_id[depth_size] = (byte)id;
depth_list[depth_size] = 16 - image->depth;
@@ -930,22 +883,18 @@ void matte_frame(int special_effect, int full_screen) {
image++;
}
- /* Sort the depth list so that "deeper" sprites will be drawn first */
- /* and thus appear "behind" the other "nearer" sprites. */
-
+ // Sort the depth list so that "deeper" sprites will be drawn first
+ // and thus appear "behind" the other "nearer" sprites.
sort_insertion_16(depth_size, depth_list_id, depth_list);
- /* Now, run through our depth list, and for each entry, draw the */
- /* indicated sprite into the work buffer. */
-
+ // Now, run through our depth list, and for each entry, draw the
+ // indicated sprite into the work buffer.
for (id = 0; id < depth_size; id++) {
- /* Get the index for the series for this depth list entry */
-
+ // Get the index for the series for this depth list entry
id2 = depth_list_id[id];
- /* Draw the sprite into the work buffer at the appropriate depth */
-
+ // Draw the sprite into the work buffer at the appropriate depth
if (image_list[id2].scale >= 100) {
if (image_list[id2].scale == IMAGE_UNSCALED) {
x = image_list[id2].x - picture_map.pan_x;
@@ -981,8 +930,7 @@ void matte_frame(int special_effect, int full_screen) {
}
}
- /* Now draw any messages that need to be updated */
-
+ // Now draw any messages that need to be updated
message = message_list;
matte = &matte_list[FIRST_MESSAGE_MATTE];
for (id = 0; id < MESSAGE_LIST_SIZE; id++) {
@@ -1007,19 +955,18 @@ void matte_frame(int special_effect, int full_screen) {
matte++;
}
- /* Finally, run through our combined matte list, and update any */
- /* areas of the screen flagged as "changed" by copying from the */
- /* work screen to the live video screen. */
-
+ // Finally, run through our combined matte list, and update any
+ // areas of the screen flagged as "changed" by copying from the
+ // work screen to the live video screen.
mouse_set_work_buffer(scr_work.data, scr_work.x);
mouse_set_view_port_loc(viewing_at_x, viewing_at_y,
viewing_at_x + scr_work.x - 1,
viewing_at_y + scr_work.y - 1);
- mouse_freeze(); /* Lock out mouse driver */
+ mouse_freeze(); // Lock out mouse driver
if ((video_mode != ega_mode) && !special_effect) {
- beware_the_mouse = mouse_refresh_view_port(); /* Prepare cursor overlay */
+ beware_the_mouse = mouse_refresh_view_port(); // Prepare cursor overlay
}
if (!matte_disable_screen_update) {
@@ -1032,16 +979,14 @@ void matte_frame(int special_effect, int full_screen) {
for (id = 0; id < MATTE_LIST_SIZE; id++) {
- /* Get next matte */
-
+ // Get next matte
#ifdef show_mattes
sprintf(temp_buf, "(%d, %d) => (%d, %d) valid: %d changed: %d ",
matte->x, matte->y, matte->xs, matte->ys, matte->valid, matte->changed);
screen_show(temp_buf, 0, id);
#endif
- /* Ignore empty mattes, or images which did not change */
-
+ // Ignore empty mattes, or images which did not change
if (matte->valid && matte->changed && (matte->xs > 0) && (matte->ys > 0)) {
video_update(&scr_work,
@@ -1065,8 +1010,8 @@ void matte_frame(int special_effect, int full_screen) {
#ifdef sixteen_colors
if (video_mode == ega_mode) {
- beware_the_mouse = mouse_refresh_view_port(); /* Prepare cursor overlay */
- video_flush_ega(viewing_at_y, scr_work.y); /* Update the EGA screen */
+ beware_the_mouse = mouse_refresh_view_port(); // Prepare cursor overlay
+ video_flush_ega(viewing_at_y, scr_work.y); // Update the EGA screen
}
#endif
} else {
@@ -1080,13 +1025,12 @@ void matte_frame(int special_effect, int full_screen) {
#endif
if (beware_the_mouse) {
- mouse_refresh_done(); /* Remove cursor image from work buffer */
+ mouse_refresh_done(); // Remove cursor image from work buffer
}
- mouse_thaw(); /* Release the mouse driver */
-
- /* Delete erasures from image list */
+ mouse_thaw(); // Release the mouse driver
+ // Delete erasures from image list
new_marker = 0;
image = image_list;
image2 = image_list;
@@ -1102,8 +1046,7 @@ void matte_frame(int special_effect, int full_screen) {
}
image_marker = new_marker;
- /* Delete erasures from message list */
-
+ // Delete erasures from message list
message = message_list;
for (id = 0; id < MESSAGE_LIST_SIZE; id++) {
if (message->status < 0) {
@@ -1200,12 +1143,11 @@ void matte_inter_frame(int update_live, int clear_chaff) {
int count;
#endif
- /* Make sure work buffer is mapped into the page frame */
+ // Make sure work buffer is mapped into the page frame
matte_map_work_screen();
- /* Before performing erasures, make a matte for each potential erasure */
- /* image. */
-
+ // Before performing erasures, make a matte for each potential erasure
+ // image.
image = image_inter_list;
matte = matte_inter_list;
for (id = 0; id < (int)image_inter_marker; id++) {
@@ -1229,8 +1171,7 @@ void matte_inter_frame(int update_live, int clear_chaff) {
if (i_am_the_dog_master != NULL) i_am_the_dog_master->valid = true;
- /* Erasures */
-
+ // Erasures
matte = matte_inter_list;
image = image_inter_list;
for (id = 0; id < (int)image_inter_marker; id++) {
@@ -1271,22 +1212,19 @@ void matte_inter_frame(int update_live, int clear_chaff) {
image++;
}
- /* Check our new matte list for collisions */
-
+ // Check our new matte list for collisions
filter_matte_list(matte_inter_list, (int)image_inter_marker, 1);
- /* Now, run through our depth list, and for each entry, draw the */
- /* indicated sprite into the work buffer. */
-
+ // Now, run through our depth list, and for each entry, draw the
+ // indicated sprite into the work buffer.
image = image_inter_list;
matte = matte_inter_list;
for (id = 0; id < (int)image_inter_marker; id++) {
if ((image->flags >= IMAGE_STATIC) && !(image->flags & IMAGE_UPDATE_READY)) {
- /* Search through the matte list to find the matte of which this */
- /* image is a part. */
-
+ // Search through the matte list to find the matte of which this
+ // image is a part.
for (matte2 = matte; !matte2->valid; matte2 = matte2->linked_matte) {
}
@@ -1313,32 +1251,29 @@ void matte_inter_frame(int update_live, int clear_chaff) {
if (update_live) {
- /* Finally, run through our combined matte list, and update any */
- /* areas of the screen flagged as "changed" by copying from the */
- /* work screen to the live video screen. */
-
+ // Finally, run through our combined matte list, and update any
+ // areas of the screen flagged as "changed" by copying from the
+ // work screen to the live video screen.
mouse_set_work_buffer(scr_inter.data, scr_inter.x);
mouse_set_view_port_loc(0, inter_viewing_at_y, 319, inter_viewing_at_y + scr_inter.y - 1);
- mouse_freeze(); /* Lock out mouse driver */
+ mouse_freeze(); // Lock out mouse driver
if (video_mode != ega_mode) {
- beware_the_mouse = mouse_refresh_view_port(); /* Prepare cursor overlay */
+ beware_the_mouse = mouse_refresh_view_port(); // Prepare cursor overlay
}
matte = matte_inter_list;
for (id = 0; id < (int)image_inter_marker; id++) {
- /* Get next matte */
-
+ // Get next matte
#ifdef show_mattes
sprintf(temp_buf, "(%d, %d) => (%d, %d) valid: %d changed: %d ",
matte->x, matte->y, matte->xs, matte->ys, matte->valid, matte->changed);
screen_show(temp_buf, 0, id);
#endif
- /* Ignore empty mattes, or images which did not change */
-
+ // Ignore empty mattes, or images which did not change
if (matte->valid && matte->changed && (matte->xs > 0) && (matte->ys > 0)) {
video_update(&scr_inter,
@@ -1353,8 +1288,8 @@ void matte_inter_frame(int update_live, int clear_chaff) {
#ifdef sixteen_colors
if (video_mode == ega_mode) {
- beware_the_mouse = mouse_refresh_view_port(); /* Prepare cursor overlay */
- video_flush_ega(inter_viewing_at_y, scr_inter.y); /* Update the EGA screen */
+ beware_the_mouse = mouse_refresh_view_port(); // Prepare cursor overlay
+ video_flush_ega(inter_viewing_at_y, scr_inter.y); // Update the EGA screen
}
#endif
@@ -1363,14 +1298,13 @@ void matte_inter_frame(int update_live, int clear_chaff) {
#endif
if (beware_the_mouse) {
- mouse_refresh_done(); /* Remove cursor image from work buffer */
+ mouse_refresh_done(); // Remove cursor image from work buffer
}
- mouse_thaw(); /* Release the mouse driver */
+ mouse_thaw(); // Release the mouse driver
}
- /* Delete erasures from image list */
-
+ // Delete erasures from image list
new_marker = 0;
image = image_inter_list;
image2 = image_inter_list;
diff --git a/engines/mads/madsv2/core/mcga.cpp b/engines/mads/madsv2/core/mcga.cpp
index 77b067753f8..b46de4f8b8c 100644
--- a/engines/mads/madsv2/core/mcga.cpp
+++ b/engines/mads/madsv2/core/mcga.cpp
@@ -194,18 +194,18 @@ static word mcga_time_palette_swap(Palette *pal, int first_color, int num_colors
}
void mcga_compute_retrace_parameters(void) {
- /* In DOS, the BIOS initialised the VGA DAC with a default 256-colour
- palette when the video mode was set; this function read that palette
- back and stored it in master_palette so the engine had a populated
- baseline before any room-specific colours were allocated.
- In ScummVM there is no hardware DAC to read, so we copy the known
- default table directly instead of calling mcga_getpal(). */
+ // In DOS, the BIOS initialised the VGA DAC with a default 256-colour
+ // palette when the video mode was set; this function read that palette
+ // back and stored it in master_palette so the engine had a populated
+ // baseline before any room-specific colours were allocated.
+ // In ScummVM there is no hardware DAC to read, so we copy the known
+ // default table directly instead of calling mcga_getpal().
memcpy(&master_palette, &vga_default_pal, sizeof(Palette));
mcga_setpal(&master_palette);
- /* On original hardware this function also measured how many palette
- entries could be written inside one vertical retrace interval.
- Under a modern graphics API there is no such constraint. */
+ // On original hardware this function also measured how many palette
+ // entries could be written inside one vertical retrace interval.
+ // Under a modern graphics API there is no such constraint.
mcga_palette_fast = true;
mcga_retrace_max_colors = Graphics::PALETTE_COUNT;
mcga_retrace_max_bytes = Graphics::PALETTE_SIZE;
diff --git a/engines/mads/madsv2/core/mouse.cpp b/engines/mads/madsv2/core/mouse.cpp
index 890771e33b4..75e0ec3ffbc 100644
--- a/engines/mads/madsv2/core/mouse.cpp
+++ b/engines/mads/madsv2/core/mouse.cpp
@@ -88,8 +88,7 @@ void mouse_begin_cycle(int double_flag) {
mouse_status = mouse_get_status(&mouse_x, &mouse_y);
mouse_clock = timer_read();
- /* mouse_video_mode = mouse_get_video_mode(); */
-
+ // mouse_video_mode = mouse_get_video_mode();
mouse_stop_stroke = (mouse_latched && (!mouse_status));
mouse_start_stroke = (mouse_status && !mouse_stroke_going);
mouse_stroke_going = mouse_status;
diff --git a/engines/mads/madsv2/core/object.cpp b/engines/mads/madsv2/core/object.cpp
index 2a97d855c93..592a8e97d21 100644
--- a/engines/mads/madsv2/core/object.cpp
+++ b/engines/mads/madsv2/core/object.cpp
@@ -215,7 +215,7 @@ int object_examine(int number, long message, int speech) {
//SeriesPtr object_series = NULL;
RGBcolor top_eight[8];
- /* Wait cursor */
+ // Wait cursor
cursor_id = 2;
if (cursor_id != cursor_last) {
mouse_cursor_sprite(cursor, cursor_id);
@@ -227,52 +227,44 @@ int object_examine(int number, long message, int speech) {
memcpy(top_eight, &master_palette[248].r, 8 * sizeof(RGBcolor));
- /* Use attribute buffer to cheat on memory requirements a bit */
-
+ // Use attribute buffer to cheat on memory requirements a bit
old_master_palette = scr_depth.data;
greyed_master_palette = scr_depth.data + sizeof(Palette);
old_color_status = (dword *) (greyed_master_palette + sizeof(Palette));
sprite_force_memory = ((byte *)old_color_status) + (sizeof(dword) * 256);
- sprite_force_size = 22400; /* Use rest of attribute buffer, at most */
-
- /* Notify "magic" that we intend to do a grey scale on all guns */
+ sprite_force_size = 22400; // Use rest of attribute buffer, at most
+ // Notify "magic" that we intend to do a grey scale on all guns
for (count = 0; count < 3; count++) {
magic_color_flags[count] = true;
}
- /* Turn off all cycling */
-
+ // Turn off all cycling
cycling_save = cycling_active;
cycling_active = false;
- /* Get sprite series name */
-
+ // Get sprite series name
Common::strcpy_s(sprite_name, "*OB");
env_catint(sprite_name, number, 3);
Common::strcat_s(sprite_name, ".SS");
- /* Prepare for flicker-free mouse updates */
-
+ // Prepare for flicker-free mouse updates
mouse_set_work_buffer(scr_main.data, video_x);
mouse_set_view_port_loc(0, 0, video_x - 1, video_y - 1);
- /* Save a copy of our work buffer somewhere (probably in EMS) */
-
+ // Save a copy of our work buffer somewhere (probably in EMS)
matte_map_work_screen();
object_preserve_handle = buffer_preserve(&scr_main, object_ems_handle, work_screen_ems_handle,
0, 0, video_x, video_y);
matte_map_work_screen();
- /* Save a copy of current palette structure */
-
+ // Save a copy of current palette structure
memcpy(old_master_palette, master_palette, sizeof(Palette));
memcpy(old_color_status, color_status, sizeof(dword) << 8);
memcpy(old_flag_used, flag_used, sizeof(int) * PAL_MAXFLAGS);
- /* Clear out all non-reserved colors in the palette */
-
+ // Clear out all non-reserved colors in the palette
num_colors = 256 - (KERNEL_RESERVED_LOW_COLORS + KERNEL_RESERVED_HIGH_COLORS);
for (count = 0; count < 256; count++) {
@@ -288,28 +280,24 @@ int object_examine(int number, long message, int speech) {
flag_used[count] = 0;
}
- /* Fade to a grey-scale picture */
-
+ // Fade to a grey-scale picture
magic_fade_to_grey(master_palette, &map[KERNEL_RESERVED_LOW_COLORS],
KERNEL_RESERVED_LOW_COLORS, num_colors,
OBJECT_GREY_BASE, OBJECT_GREY_COLORS,
OBJECT_GREY_SPEED, OBJECT_GREY_STEPS);
- /* Need to save a copy of greyed out palette */
-
+ // Need to save a copy of greyed out palette
memcpy(greyed_master_palette, master_palette, sizeof(Palette));
- /* Remap the contents of the work screen to the top 8 colors of the */
- /* palette (the true grey scale to which all other colors have been */
- /* faded). This will allow us to change palettes to load the object */
- /* sprite. */
-
+ // Remap the contents of the work screen to the top 8 colors of the
+ // palette (the true grey scale to which all other colors have been
+ // faded). This will allow us to change palettes to load the object
+ // sprite.
object_remap_buffer(&scr_main, map);
- /* Copy the remapped version of the work buffer onto the screen; this */
- /* will have no visible effect but will free up a good portion of the */
- /* palette. */
-
+ // Copy the remapped version of the work buffer onto the screen; this
+ // will have no visible effect but will free up a good portion of the
+ // palette.
mouse_freeze();
refresh_flag = mouse_refresh_view_port();
@@ -320,88 +308,65 @@ int object_examine(int number, long message, int speech) {
mcga_setpal(&master_palette);
- /* Load the object series */
- /* object_series = sprite_series_load (sprite_name, PAL_MAP_BACKGROUND); */
-
+ // Load the object series
+ // object_series = sprite_series_load (sprite_name, PAL_MAP_BACKGROUND);
matte_map_work_screen();
- /* Now set the palette to include the colors for this series. */
- /* mcga_setpal (&master_palette); */
-
+ // Now set the palette to include the colors for this series.
+ // mcga_setpal (&master_palette);
y_base = OBJECT_VIEW_OFFSET;
- /* Draw the object sprite on the screen */
-
- /*
- if (object_series != NULL) {
- x_size = object_series->index[0].xs;
- y_size = object_series->index[0].ys;
- x_base = (video_x >> 1) - (x_size >> 1);
- sprite_draw (object_series, 1, &scr_main, x_base, y_base);
-
- mouse_hide();
-
- video_update (&scr_main, x_base, y_base, x_base, y_base, x_size, y_size);
-
- mouse_show();
-
- y_base += y_size;
- }
- */
-
+ // Draw the object sprite on the screen
+ // if (object_series != NULL) {
+ // x_size = object_series->index[0].xs;
+ // y_size = object_series->index[0].ys;
+ // x_base = (video_x >> 1) - (x_size >> 1);
+ // sprite_draw (object_series, 1, &scr_main, x_base, y_base);
+ //
+ // mouse_hide();
+ //
+ // video_update (&scr_main, x_base, y_base, x_base, y_base, x_size, y_size);
+ //
+ // mouse_show();
+ //
+ // y_base += y_size;
+ // }
y_base += OBJECT_VIEW_OFFSET;
if (message) {
text_saves_screen = false;
- /* text_default_y = y_base; */
-
- /*
- for (count = 0; count < (popup_num_colors - 1); count++) {
- popup_colors[count] -= object_extra_colors;
- }
- */
-
+ // text_default_y = y_base;
+ // for (count = 0; count < (popup_num_colors - 1); count++) {
+ // popup_colors[count] -= object_extra_colors;
+ // }
memcpy(&cycling_palette[248].r, &master_palette[248].r, 8 * sizeof(RGBcolor));
- /* pl if (speech) {
- if (speech_system_active && speech_on) {
- speech_play (object_speech_resource, speech);
- }
- }
- */
-
+ // pl if (speech) {
+ // if (speech_system_active && speech_on) {
+ // speech_play (object_speech_resource, speech);
+ // }
+ // }
text_show(message);
- /* pl if (speech && speech_system_active && speech_on) {
- speech_all_off();
- }
- */
-
- /*
- for (count = 0; count < (popup_num_colors - 1); count++) {
- popup_colors[count] += object_extra_colors;
- }
- */
-
+ // pl if (speech && speech_system_active && speech_on) {
+ // speech_all_off();
+ // }
+ // for (count = 0; count < (popup_num_colors - 1); count++) {
+ // popup_colors[count] += object_extra_colors;
+ // }
text_saves_screen = true;
- /* text_default_y = POPUP_CENTER; */
+ // text_default_y = POPUP_CENTER;
} else {
keys_get();
}
- /* Flush object from memory */
-
- /*
- if (object_series != (SeriesPtr) sprite_force_memory) mem_free (object_series);
- */
-
- /* If we saved the work buffer in EMS, we can now fade back to the */
- /* original screen. */
-
+ // Flush object from memory
+ // if (object_series != (SeriesPtr) sprite_force_memory) mem_free (object_series);
+ // If we saved the work buffer in EMS, we can now fade back to the
+ // original screen.
if (object_preserve_handle != BUFFER_NOT_PRESERVED) {
- /* Restore a copy of the work screen */
-
+ // Restore a copy of the work screen
matte_map_work_screen();
buffer_restore_keep_flag = true;
@@ -410,20 +375,17 @@ int object_examine(int number, long message, int speech) {
matte_map_work_screen();
- /* We must remap to the special grey version first, so that we can */
- /* change back to the first palette. */
-
+ // We must remap to the special grey version first, so that we can
+ // change back to the first palette.
object_remap_buffer(&scr_main, map);
- /* Restore old master palette structure. */
-
+ // Restore old master palette structure.
memcpy(master_palette, old_master_palette, sizeof(Palette));
memcpy(color_status, old_color_status, sizeof(dword) << 8);
memcpy(flag_used, old_flag_used, sizeof(int) * PAL_MAXFLAGS);
- /* Copy a greyed-out version of picture onto the screen (erasing the */
- /* object picture). */
-
+ // Copy a greyed-out version of picture onto the screen (erasing the
+ // object picture).
mouse_freeze();
refresh_flag = mouse_refresh_view_port();
@@ -432,24 +394,21 @@ int object_examine(int number, long message, int speech) {
if (refresh_flag) mouse_refresh_done();
mouse_thaw();
- /* Now we can change back to the fully greyed-out version of the */
- /* original master palette. */
-
+ // Now we can change back to the fully greyed-out version of the
+ // original master palette.
mcga_setpal((Palette *)greyed_master_palette);
- /* We must copy the work buffer from EMS again, since we have destroyed */
- /* the first version we brought back (by remapping to grey again). */
-
+ // We must copy the work buffer from EMS again, since we have destroyed
+ // the first version we brought back (by remapping to grey again).
matte_map_work_screen();
buffer_restore(&scr_main, object_preserve_handle, work_screen_ems_handle, 0, 0, video_x, video_y);
matte_map_work_screen();
- /* We are ready to copy the true work buffer image back onto the screen. */
- /* Since the palette is now fully greyed out, there will be no visible */
- /* change. */
-
+ // We are ready to copy the true work buffer image back onto the screen.
+ // Since the palette is now fully greyed out, there will be no visible
+ // change.
mouse_freeze();
refresh_flag = mouse_refresh_view_port();
@@ -458,8 +417,7 @@ int object_examine(int number, long message, int speech) {
if (refresh_flag) mouse_refresh_done();
mouse_thaw();
- /* Finally, we can fade back to our original palette. */
-
+ // Finally, we can fade back to our original palette.
magic_fade_from_grey((RGBcolor *)greyed_master_palette, master_palette,
KERNEL_RESERVED_LOW_COLORS, num_colors,
OBJECT_GREY_BASE, OBJECT_GREY_COLORS,
@@ -468,17 +426,15 @@ int object_examine(int number, long message, int speech) {
restored_screen = true;
}
- /* done: */
- /* Turn color cycling back on. */
-
+ // done:
+ // Turn color cycling back on.
memcpy(&cycling_palette[248].r, top_eight, 8 * sizeof(RGBcolor));
mcga_setpal_range(&cycling_palette, 248, 8);
cycling_active = cycling_save;
- /* Don't forget to reload the attribute screen which we wrote all */
- /* over. */
-
+ // Don't forget to reload the attribute screen which we wrote all
+ // over.
sprite_force_memory = NULL;
diff --git a/engines/mads/madsv2/core/pack.cpp b/engines/mads/madsv2/core/pack.cpp
index f6ddec50837..bec7a715b17 100644
--- a/engines/mads/madsv2/core/pack.cpp
+++ b/engines/mads/madsv2/core/pack.cpp
@@ -142,7 +142,7 @@ word pack_read_memory(char *buffer, word *mysize) {
pack_read_size -= (uint32)cx;
}
- /* read_infinite: */
+ // read_infinite:
pack_read_count += (uint32)cx;
return_value = cx;
@@ -161,7 +161,7 @@ word pack_write_memory(char *buffer, word *mysize) {
word cx = *mysize;
uint32 remaining = pack_write_size;
- if (pack_write_size != 0xFFFFFFFFUL) /* not "infinite write" */
+ if (pack_write_size != 0xFFFFFFFFUL) // not "infinite write"
{
if (remaining == 0)
goto write_done;
@@ -172,7 +172,7 @@ word pack_write_memory(char *buffer, word *mysize) {
pack_write_size -= (uint32)cx;
}
- /* write_infinite: */
+ // write_infinite:
pack_write_count += (uint32)cx;
if (cx != 0) {
@@ -232,15 +232,6 @@ done:
}
-/*
-/* pack_raw_copy()
-/*
-/* Imitates the behavior of "implode" and "explode", but performs
-/* no data compression --> just copies the data.
-/*
-/* (So that we can have a transparent interface which either
-/* compresses the data or doesn't, depending on our secret desires).
-*/
word pack_raw_copy(void) {
word result = CMP_NO_ERROR;
word read_this_time;
@@ -260,14 +251,6 @@ word pack_raw_copy(void) {
}
-/*
-/* pack_a_packet()
-/*
-/* Given that our packing parameters are set up (i.e.
-/* pack_read_size, pack_write_size, and so forth), this
-/* routine uses the specified packing strategy to move
-/* a record.
-*/
word pack_a_packet(int packing_flag, int explode_mode) {
word result;
word pack_window_size;
@@ -275,11 +258,9 @@ word pack_a_packet(int packing_flag, int explode_mode) {
switch (packing_flag) {
case PACK_IMPLODE:
pack_window_size = PACK_WINDOW_SIZE;
- /*
- while ((pack_read_size < (long)pack_window_size) && ((long)pack_window_size > PACK_MIN_WINDOW_SIZE)) {
- pack_window_size = pack_window_size >> 1;
- }
- */
+ // while ((pack_read_size < (long)pack_window_size) && ((long)pack_window_size > PACK_MIN_WINDOW_SIZE)) {
+ // pack_window_size = pack_window_size >> 1;
+ // }
if (pack_strategy == PACK_PFAB) {
result = (*pack_pFABcomp_routine)(pack_read_routine, pack_write_routine, (char *)pack_buffer,
&pack_mode, &pack_window_size);
@@ -329,46 +310,6 @@ void pack_set_special_buffer(byte *buffer_address, void (*(special_function))())
pack_special_function = special_function;
}
-/*
-/* pack_data()
-/*
-/* Transfers a data packet from the specified source to the specified
-/* destination, using the specified packing strategy.
-/*
-/* packing_flag Specifies the packing strategy:
-/* PACK_IMPLODE (Compresses data)
-/* PACK_EXPLODE (Decompresses data)
-/* PACK_RAW_COPY (Copies data)
-/*
-/* size # of bytes to move
-/*
-/* source_type Specifies the source type:
-/* FROM_DISK or FROM_MEMORY.
-/*
-/* source If FROM_DISK, then this is a FILE *handle.
-/* If FROM_MEMORY, this is a far memory pointer.
-/*
-/* dest_type Specifies the destination type:
-/* TO_DISK, TO_MEMORY, or TO_EMS.
-/*
-/* dest Same as "source" but for destination. For
-/* TO_EMS, "dest" is a far pointer to an
-/* EmsPtr structure.
-/*
-/*
-/* Example:
-/*
-/* result =pack_data (PACK_EXPLODE, 132000,
-/* FROM_DISK, file_handle,
-/* TO_MEMORY, memory_pointer);
-/*
-/* (Decompresses 132000 bytes from the already open
-/* disk file "file_handle", and writes it to memory
-/* far the specified address. Size is always the
-/* uncompressed size of the data. Result will be
-/* the # of bytes actually written -- 132000 if successful).
-/*
-*/
long pack_data(int packing_flag, long size,
int source_type, void *source, int dest_type, void *dest) {
int explode_mode = 0;
@@ -377,19 +318,17 @@ long pack_data(int packing_flag, long size,
EmsPtr *ems_dest;
int result;
- /* Select the read data routine */
-
+ // Select the read data routine
if (source_type == FROM_MEMORY) {
pack_read_routine = pack_read_memory;
pack_read_memory_ptr = (byte *)source;
} else {
- /* FROM_DISK */
+ // FROM_DISK
pack_read_routine = pack_read_file;
pack_read_file_handle = (Common::SeekableReadStream *)source;
}
- /* Select the write data routine */
-
+ // Select the write data routine
if (dest_type == TO_EMS) {
pack_write_routine = pack_write_ems;
ems_dest = (EmsPtr *)dest;
@@ -400,13 +339,12 @@ long pack_data(int packing_flag, long size,
pack_write_routine = pack_write_memory;
pack_write_memory_ptr = (byte *)dest;
} else {
- /* TO_DISK */
+ // TO_DISK
pack_write_routine = pack_write_file;
pack_write_file_handle = (Common::WriteStream *)dest;
}
- /* Set up the packing parameters */
-
+ // Set up the packing parameters
pack_read_count = pack_write_count = 0;
switch (packing_flag) {
@@ -422,31 +360,31 @@ long pack_data(int packing_flag, long size,
error_report(ERROR_EXPLODER_NULL, SEVERE, MODULE_EXPLODER, packing_flag, pack_strategy);
}
}
- pack_read_size = size; /* Stop after reading "size" bytes */
- pack_write_size = -1; /* Write as many bytes as necessary */
- loop_value = &pack_read_size; /* Loop control is # bytes to read */
- return_value = &pack_read_count; /* Return value is # bytes read */
+ pack_read_size = size; // Stop after reading "size" bytes
+ pack_write_size = -1; // Write as many bytes as necessary
+ loop_value = &pack_read_size; // Loop control is # bytes to read
+ return_value = &pack_read_count; // Return value is # bytes read
break;
case PACK_EXPLODE:
- pack_read_size = -1; /* Read as many bytes as necessary */
- pack_write_size = size; /* Stop after writing "size" bytes */
- loop_value = &pack_write_size; /* Loop control is # bytes to write */
+ pack_read_size = -1; // Read as many bytes as necessary
+ pack_write_size = size; // Stop after writing "size" bytes
+ loop_value = &pack_write_size; // Loop control is # bytes to write
if (pack_strategy == PACK_PFAB) {
if ((source_type == FROM_MEMORY) && (dest_type == FROM_MEMORY) &&
(pack_pFABexp2_routine != NULL)) {
- return_value = &size; /* Fake return value */
+ return_value = &size; // Fake return value
pack_buffer_size = PACK_PFABEXP2_SIZE;
explode_mode = 2;
} else if ((dest_type == TO_DISK) || (dest_type == TO_EMS)) {
- return_value = &pack_write_count; /* Return value is # bytes written */
+ return_value = &pack_write_count; // Return value is # bytes written
pack_buffer_size = PACK_PFABEXP0_SIZE;
explode_mode = 0;
if (pack_pFABexp0_routine == NULL) {
error_report(ERROR_EXPLODER_NULL, SEVERE, MODULE_EXPLODER, packing_flag, pack_strategy);
}
} else {
- return_value = &size; /* Fake return value for file-to_mem*/
+ return_value = &size; // Fake return value for file-to_mem
pack_buffer_size = PACK_PFABEXP1_SIZE;
explode_mode = 1;
if (pack_pFABexp1_routine == NULL) {
@@ -465,15 +403,14 @@ long pack_data(int packing_flag, long size,
case PACK_RAW_COPY:
default:
pack_buffer_size = PACK_RAW_COPY_SIZE;
- pack_read_size = size; /* Stop after reading "size" bytes */
- pack_write_size = size; /* ... or after writing "size" bytes */
- loop_value = &pack_read_size; /* Loop control is # bytes to read */
- return_value = &pack_write_count; /* Return value is # bytes written */
+ pack_read_size = size; // Stop after reading "size" bytes
+ pack_write_size = size; // ... or after writing "size" bytes
+ loop_value = &pack_read_size; // Loop control is # bytes to read
+ return_value = &pack_write_count; // Return value is # bytes written
break;
}
- /* Get memory for packing buffer if necessary */
-
+ // Get memory for packing buffer if necessary
pack_buffer = NULL;
if (pack_special_buffer == NULL) {
@@ -486,8 +423,7 @@ long pack_data(int packing_flag, long size,
pack_buffer = pack_special_buffer;
}
- /* Keep moving records until we run out of data or die */
-
+ // Keep moving records until we run out of data or die
if ((packing_flag == PACK_EXPLODE) && (dest_type == TO_MEMORY)) {
result = pack_a_packet(packing_flag, explode_mode);
if (result != CMP_NO_ERROR) {
@@ -505,8 +441,7 @@ long pack_data(int packing_flag, long size,
}
}
- /* Free memory and go away */
-
+ // Free memory and go away
done:
if (pack_special_buffer == NULL) {
if (pack_buffer != NULL) mem_free(pack_buffer);
@@ -518,12 +453,6 @@ done:
}
-/*
-/* pack_check()
-/*
-/* Asks user to choose between compressed and uncompressed data
-/* formats.
-*/
int pack_check(void) {
dialog_declare_ok(dialog);
ItemPtr none_item, zip_item = nullptr, pfab_item = nullptr, default_item;
@@ -634,7 +563,7 @@ read_loop:
if (--cx != 0)
goto read_loop;
- /* loop fell through: store current run and finish */
+ // loop fell through: store current run and finish
*((word *)di) = (word)bh | ((word)bl << 8);
di += 2;
dx += 2;
@@ -647,13 +576,13 @@ make_new:
if (--cx != 0)
goto new_code;
- /* store the final byte as a run of 1 */
+ // store the final byte as a run of 1
*((word *)di) = (word)1 | ((word)al << 8);
di += 2;
dx += 2;
packed:
- /* store terminating zero word */
+ // store terminating zero word
*((word *)di) = 0;
di += 2;
dx += 2;
diff --git a/engines/mads/madsv2/core/pal.cpp b/engines/mads/madsv2/core/pal.cpp
index 501cf9719c1..11af9f7eeac 100644
--- a/engines/mads/madsv2/core/pal.cpp
+++ b/engines/mads/madsv2/core/pal.cpp
@@ -96,8 +96,8 @@ void pal_init(int reserve_bottom, int reserve_top) {
flag_used[count] = false;
}
- flag_used[0] = true; /* Flag[0] is RESERVED status */
- flag_used[1] = true; /* Flag[1] is CYCLE status */
+ flag_used[0] = true; // Flag[0] is RESERVED status
+ flag_used[1] = true; // Flag[1] is CYCLE status
palette_locked = false;
@@ -144,8 +144,7 @@ int pal_deallocate(int use_flag) {
if (!kidney) {
if ((use_flag >= PAL_MAXFLAGS) || (use_flag <= 0)) goto done;
- /* Get a mask of everything but our special bit */
-
+ // Get a mask of everything but our special bit
mask = ~(1L << (dword)use_flag);
for (count = 0; count < 256; count++) {
@@ -245,8 +244,7 @@ static int pal_get_new_flag() {
int return_code;
int count;
- /* First, we need to find an available color handle for the new list */
-
+ // First, we need to find an available color handle for the new list
return_code = PAL_ERR_OUTOFFLAGS;
for (count = 0; (count < PAL_MAXFLAGS); count++) {
@@ -256,8 +254,7 @@ static int pal_get_new_flag() {
}
}
- /* If no handles left to allocate: */
-
+ // If no handles left to allocate:
if (return_code < 0) {
#ifndef disable_error_check
error_report(ERROR_NO_MORE_PALETTE_FLAGS, ERROR, MODULE_PAL, PAL_MAXFLAGS, 100);
@@ -330,21 +327,17 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
search_start = MAX(search_start, palette_low_search_limit);
search_stop = MIN(search_stop, palette_high_search_limit);
- /* Get a new color handle */
-
+ // Get a new color handle
return_code = pal_get_new_flag();
if (return_code < 0) goto done;
- /* Set up the proper masking bit for our chosen color handle */
-
+ // Set up the proper masking bit for our chosen color handle
mask = 1L << (dword)return_code;
- /* Check if we are defining a new background picture */
-
+ // Check if we are defining a new background picture
defining_background = pal_flags & PAL_MAP_BACKGROUND;
- /* If a shadowing description was passed, enable shadow checking */
-
+ // If a shadowing description was passed, enable shadow checking
shadowing_enabled = (shadow_list != NULL);
shadowing_special = false;
if (shadowing_enabled) {
@@ -356,26 +349,23 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
}
}
- /* If we are mapping shadow colors, we need to make a list of all */
- /* shadowable colors in our color list and then sort it by intensity. */
-
+ // If we are mapping shadow colors, we need to make a list of all
+ // shadowable colors in our color list and then sort it by intensity.
if (shadowing_enabled) {
pal_init_shadow(&incoming_shadow, new_list);
pal_shadow_sort(&incoming_shadow, new_list);
}
- /* Get a count of totally free colors in the palette */
-
+ // Get a count of totally free colors in the palette
free_colors = pal_free_colors(&first_free);
first_free = MAX(first_free, search_start);
- /* Sort the color list so that all cycle colors remain at the beginning */
- /* of the list but that all colors which are allowed to use inexact RGB */
- /* mappings are placed at the bottom of the list. That way, colors which */
- /* require an exact RGB mapping are given the first chance to allocate */
- /* free color space. */
-
+ // Sort the color list so that all cycle colors remain at the beginning
+ // of the list but that all colors which are allowed to use inexact RGB
+ // mappings are placed at the bottom of the list. That way, colors which
+ // require an exact RGB mapping are given the first chance to allocate
+ // free color space.
for (count = 0; count < new_list->num_colors; count++) {
reordering_index[count] = (byte)count;
reordering_hash[count] = 0;
@@ -394,9 +384,8 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
reserved_mask = 0xfffffffe;
}
- /* Now, for each color in our color list, find an appropriate mapping or */
- /* create a new one from available color space. */
-
+ // Now, for each color in our color list, find an appropriate mapping or
+ // create a new one from available color space.
for (search_color = 0; search_color < new_list->num_colors; search_color++) {
list_color = reordering_index[search_color];
@@ -404,17 +393,15 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
found = false;
best_target_color = -1;
- /* Don't insert colors that are being forced to skip codes */
-
+ // Don't insert colors that are being forced to skip codes
if (new_list->table[list_color].group & COLOR_GROUP_FORCE_TO_SKIP) {
found = true;
best_target_color = SS_SKIP;
}
- /* If we are doing shadowing, check to see if our color is one of the */
- /* shadow colors. If so, just map it right to the corresponding shadow */
- /* color in the master palette, without regard for RGB match. */
-
+ // If we are doing shadowing, check to see if our color is one of the
+ // shadow colors. If so, just map it right to the corresponding shadow
+ // color in the master palette, without regard for RGB match.
if (shadowing_enabled) {
if (new_list->table[list_color].group & COLOR_GROUP_MAP_TO_SHADOW) {
for (shadow = 0; !found && (shadow < incoming_shadow.num_shadow_colors); shadow++) {
@@ -445,17 +432,15 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
cycle_mask = PAL_CYCLE;
}
- /* Now decide if we should search the existing palette for an already */
- /* existing mapping. The only reasons not to are A) if we have */
- /* found a (shadowing) match; and B) if we are defining an initial */
- /* background and therefore should not have any matches. */
-
+ // Now decide if we should search the existing palette for an already
+ // existing mapping. The only reasons not to are A) if we have
+ // found a (shadowing) match; and B) if we are defining an initial
+ // background and therefore should not have any matches.
conduct_search = !found && !defining_background && cycle_mask != 0;
if (conduct_search) {
- /* Now, decide whether we need an exact match or are willing to just */
- /* take the closest. */
-
+ // Now, decide whether we need an exact match or are willing to just
+ // take the closest.
if ((new_list->table[list_color].group & COLOR_GROUP_FORCE_TO_CLOSEST) ||
(((pal_flags & PAL_MAP_ANY_TO_CLOSEST) || (new_list->table[list_color].group & COLOR_GROUP_MAP_TO_CLOSEST)) &&
((pal_flags & PAL_MAP_ALL_TO_CLOSEST) || (!free_colors)))
@@ -466,8 +451,7 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
}
- /* Search through the existing palette for an appropriate color */
-
+ // Search through the existing palette for an appropriate color
for (target_color = search_start; target_color < search_stop; target_color++) {
if (color_status[target_color]) {
@@ -476,8 +460,8 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
if (best_hash > 1) {
hash = pal_get_hash((RGBcolor *) & new_list->table[list_color], &master_palette[target_color]);
} else {
- /* This is a little hack (or "optimization") to compare the 3 RGB bytes much */
- /* more quickly when we are looking for an exact match only. */
+ // This is a little hack (or "optimization") to compare the 3 RGB bytes much
+ // more quickly when we are looking for an exact match only.
hash = ((*(word *) & new_list->table[list_color] == *(word *) & master_palette[target_color]) &&
(*(((byte *) & new_list->table[list_color]) + 2) == *(((byte *) & master_palette[target_color]) + 2))) ? 0 : 1;
}
@@ -492,11 +476,10 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
}
}
- /* Now, decide if we should insert a new color into the palette. We */
- /* need to if we have not yet found a match, but we must also check */
- /* to see if we are allowed to create a new color for this color list */
- /* item (we are not if the item is being forced to map to closest). */
-
+ // Now, decide if we should insert a new color into the palette. We
+ // need to if we have not yet found a match, but we must also check
+ // to see if we are allowed to create a new color for this color list
+ // item (we are not if the item is being forced to map to closest).
conduct_insert = (!found) &&
(!((pal_flags & PAL_MAP_ALL_TO_CLOSEST) &&
((new_list->table[list_color].group & (COLOR_GROUP_MAP_TO_CLOSEST | COLOR_GROUP_FORCE_TO_CLOSEST)) ||
@@ -511,15 +494,14 @@ int pal_allocate(ColorListPtr new_list, ShadowListPtr shadow_list, int pal_flags
found = true;
best_target_color = target_color;
*(RGBcolor *) &master_palette[target_color].r = *(RGBcolor *) & new_list->table[list_color].r;
- /* memcpy(&(master_palette[target_color].r), &(new_list->table[list_color].r), 3); */
+ // memcpy(&(master_palette[target_color].r), &(new_list->table[list_color].r), 3);
}
}
}
- /* If we found a mapping for this color, flag our handle for it and */
- /* make a note of the list-to-palette mapping for this color in the */
- /* "x16" slot of the color list item. */
-
+ // If we found a mapping for this color, flag our handle for it and
+ // make a note of the list-to-palette mapping for this color in the
+ // "x16" slot of the color list item.
if (found) {
bonus = (defining_background && (new_list->table[list_color].cycle != 0)) ? PAL_CYCLE : 0;
color_status[best_target_color] |= (mask | bonus);
@@ -547,11 +529,10 @@ done:
return return_code;
}
-int pal_get_flags()
-/*
- Returns number of available flags - checksum use
-*/
-{
+/**
+ * Returns number of available flags - checksum use
+ */
+int pal_get_flags() {
int a, out;
out = 0;
@@ -561,11 +542,10 @@ int pal_get_flags()
return(out);
}
-int pal_get_colors()
/*
- Returns number of colors available in palette
-*/
-{
+ * Returns number of colors available in palette
+ */
+int pal_get_colors() {
int a, out;
out = 0;
@@ -644,7 +624,7 @@ int pal_get_color(RGBcolor color, int color_handle, int override_reserved, int *
dword mask;
if (color_handle < 0) {
- result = PAL_ERR_OUTOFFLAGS; /* Default if next loop fails */
+ result = PAL_ERR_OUTOFFLAGS; // Default if next loop fails
for (count = 0; count < PAL_MAXFLAGS; count++) {
if (!flag_used[count]) {
@@ -657,7 +637,7 @@ int pal_get_color(RGBcolor color, int color_handle, int override_reserved, int *
#ifndef disable_error_check
error_report(ERROR_NO_MORE_PALETTE_FLAGS, ERROR, MODULE_PAL, PAL_MAXFLAGS, 1);
#endif
- return result; /* No flags left to allocate */
+ return result; // No flags left to allocate
}
} else {
result = color_handle;
diff --git a/engines/mads/madsv2/core/pfab.cpp b/engines/mads/madsv2/core/pfab.cpp
index 85b10981ac3..3f052d802ec 100644
--- a/engines/mads/madsv2/core/pfab.cpp
+++ b/engines/mads/madsv2/core/pfab.cpp
@@ -135,22 +135,30 @@ struct CompWork {
byte wbuff[WBlen];
};
-/* Required size of work_buff. Paragraph-align to match original. */
+/**
+ * Required size of work_buff. Paragraph-align to match original.
+ */
static unsigned comp_work_size(void) {
return (unsigned)(sizeof(CompWork) + 15u);
}
-/* Obtain aligned pointer to CompWork inside work_buff. */
+/**
+ * Obtain aligned pointer to CompWork inside work_buff.
+ */
static CompWork *get_comp_work(char *work_buff) {
unsigned long addr = (unsigned long)(byte *)work_buff;
addr = (addr + 15u) & ~15u;
return (CompWork *)(byte *)addr;
}
-/* ---- internal helpers ------------------------------------------------- */
+/*
+ * ---- internal helpers -------------------------------------------------
+ *
+ * @param w
+ */
static void wb_out(CompWork *w) {
- unsigned cnt = w->wb_ptr; /* bytes written since last flush */
+ unsigned cnt = w->wb_ptr; // bytes written since last flush
w->wb_ptr = 0;
w->wb_cnt = WBlen;
w->rwlen = (word)cnt;
@@ -164,9 +172,11 @@ static void wb_put(CompWork *w, byte byte) {
wb_out(w);
}
-/* Flush the current Huffman packet to the output stream. */
+/**
+ * Flush the current Huffman packet to the output stream.
+ */
static void pkt_flush(CompWork *w) {
- /* write packet[0..huffptr-1]: control word then data bytes */
+ // write packet[0..huffptr-1]: control word then data bytes
w->packet[0] = (byte)(w->huffman & 0xFF);
w->packet[1] = (byte)(w->huffman >> 8);
@@ -176,23 +186,25 @@ static void pkt_flush(CompWork *w) {
w->huffbit = 1;
w->huffman = 0;
- w->huffptr = 2; /* skip the two control-word bytes */
+ w->huffptr = 2; // skip the two control-word bytes
}
-/* Append one Huffman control bit (0 or non-0). */
+/**
+ * Append one Huffman control bit (0 or non-0).
+ */
static void huff1(CompWork *w, int bit) {
if (bit)
w->huffman |= w->huffbit;
w->huffbit <<= 1;
if (w->huffbit == 0) {
- /* control word is full (16 bits) - flush packet */
- /* The packet array already contains the data bytes at [2..ptr) */
- /* write everything out now */
+ // control word is full (16 bits) - flush packet
+ // The packet array already contains the data bytes at [2..ptr)
+ // write everything out now
byte tmp_ctrl0 = (byte)(w->huffman & 0xFF);
byte tmp_ctrl1 = (byte)(w->huffman >> 8);
unsigned save_ptr = w->huffptr;
- /* emit control bytes then data bytes */
+ // emit control bytes then data bytes
wb_put(w, tmp_ctrl0);
wb_put(w, tmp_ctrl1);
for (unsigned i = 2; i < save_ptr; i++)
@@ -204,34 +216,39 @@ static void huff1(CompWork *w, int bit) {
}
}
-/* Append one literal/copy data byte to the current packet buffer. */
+/**
+ * Append one literal/copy data byte to the current packet buffer.
+ */
static void push1(CompWork *w, byte byte) {
w->packet[w->huffptr++] = byte;
}
-/* ---- rb_in: fill the read buffer -------------------------------------- */
-
+/**
+ * ---- rb_in: fill the read buffer --------------------------------------
+ */
static unsigned rb_in(CompWork *w) {
w->rb_ptr = 0;
w->rwlen = (word)RBlen;
unsigned got = w->zread((char *)w->rbuff, &w->rwlen);
- w->rb_cnt = got + 1; /* +1 so the main loop pre-decrements */
+ w->rb_cnt = got + 1; // +1 so the main loop pre-decrements
return got;
}
/* ---- dictionary link/unlink ------------------------------------------- */
-/*
+/**
* Hash(inword) = (word & (HASH-1)) + LEMPEL + 1
* All indices into hash[]/undo[] are in units of unsigned (words).
* In the assembly, indices are byte offsets and the arrays are word arrays,
* hence the frequent shl/shr 1. Here we use word indices throughout.
+ *
+ * @param w
+ * @param di
*/
-
static void dict_link(CompWork *w, unsigned di) {
unsigned word = w->lempel[di] | ((unsigned)w->lempel[(di + 1) & (LEMPEL - 1)] << 8);
- unsigned key = (word & (HASH - 1)) + LEMPEL + 1; /* key index */
- unsigned di2 = di; /* word index = di */
+ unsigned key = (word & (HASH - 1)) + LEMPEL + 1; // key index
+ unsigned di2 = di; // word index = di
unsigned bx = w->hash[key];
w->hash[di2] = bx;
@@ -248,21 +265,22 @@ static void dict_unlink(CompWork *w, unsigned si) {
}
}
-/* ---- match: find the longest match at lempel[di] ---------------------- */
-
+/**
+ * ---- match: find the longest match at lempel[di] ----------------------
+ */
static void match(CompWork *w, unsigned di) {
- /* Compute hash key for the 2-byte word at lempel[di] */
+ // Compute hash key for the 2-byte word at lempel[di]
unsigned inword = w->lempel[di]
| ((unsigned)w->lempel[(di + 1) & (LEMPEL - 1)] << 8);
unsigned key = (inword & (HASH - 1)) + LEMPEL + 1;
int best_len = 0;
unsigned best_pos = 0;
- int rem = ZIV - 1; /* chars still to match */
+ int rem = ZIV - 1; // chars still to match
unsigned chain = w->hash[key];
while (chain != NIL) {
- /* compare lempel[chain+1 .. chain+ZIV-1] with lempel[di+1 ..] */
+ // compare lempel[chain+1 .. chain+ZIV-1] with lempel[di+1 ..]
unsigned ms = (chain + 1) & (LEMPEL - 1);
unsigned md = (di + 1) & (LEMPEL - 1);
int matched = 0;
@@ -271,10 +289,10 @@ static void match(CompWork *w, unsigned di) {
md = (md + 1) & (LEMPEL - 1);
matched++;
}
- int this_len = matched + 1; /* +1 for the hashed first char */
+ int this_len = matched + 1; // +1 for the hashed first char
if (matched == ZIV - 1) {
- /* full ZIV match */
+ // full ZIV match
best_len = ZIV;
best_pos = chain;
break;
@@ -290,13 +308,13 @@ static void match(CompWork *w, unsigned di) {
w->qlen = best_len;
if (best_len > 0) {
- /* offset = di - best_pos (mod LEMPEL), stored negative */
+ // offset = di - best_pos (mod LEMPEL), stored negative
int off = (int)di - (int)best_pos;
off &= (LEMPEL - 1);
w->qoff = -off;
}
- /* Also link di into the hash table (same as Match does at the end) */
+ // Also link di into the hash table (same as Match does at the end)
unsigned di2 = di;
unsigned bx = w->hash[key];
unsigned di_hash = di2;
@@ -306,39 +324,40 @@ static void match(CompWork *w, unsigned di) {
w->undo[di_hash] = key;
}
-/* ---- Fabrice: main LZ compression loop -------------------------------- */
-
+/**
+ * ---- Fabrice: main LZ compression loop --------------------------------
+ */
static unsigned long fabrice(CompWork *w) {
unsigned si = 0;
- /* Initialise I/O state */
- w->rb_cnt = 1; /* force first read */
+ // Initialise I/O state
+ w->rb_cnt = 1; // force first read
w->wb_ptr = 0;
w->wb_cnt = WBlen;
- /* Initialise dictionary */
- memset(w->undo, 0xFF, sizeof(w->undo)); /* NIL = 0xFFFF (LEMPEL*2)*/
+ // Initialise dictionary
+ memset(w->undo, 0xFF, sizeof(w->undo)); // NIL = 0xFFFF (LEMPEL*2)
memset(w->hash, 0xFF, sizeof(w->hash));
memset(w->lempel, 0, sizeof(w->lempel));
memset(w->ziv, 0, sizeof(w->ziv));
- /* Initialise Huffman packet */
+ // Initialise Huffman packet
w->huffbit = 1;
w->huffman = 0;
- w->huffptr = 2; /* reserve two bytes for ctrl word */
+ w->huffptr = 2; // reserve two bytes for ctrl word
w->norms = 0;
w->delta = 0;
w->paraz = 0;
w->zsize = 0;
- /* Write the 4-byte "FAB" header */
+ // Write the 4-byte "FAB" header
wb_put(w, 'F');
wb_put(w, 'A');
wb_put(w, 'B');
wb_put(w, (byte)DICT);
- /* Read first ZIV bytes into the top of the Lempel buffer */
+ // Read first ZIV bytes into the top of the Lempel buffer
unsigned di = (unsigned)(LEMPEL - ZIV);
unsigned cx = ZIV;
@@ -354,18 +373,18 @@ static unsigned long fabrice(CompWork *w) {
unsigned read_so_far = ZIV - cx;
if (read_so_far == 0)
- goto lz_exit; /* empty input */
+ goto lz_exit; // empty input
w->zlen = (int)read_so_far;
- di = (unsigned)(LEMPEL - ZIV); /* encode pointer */
- si = 0; /* end-of-ziv pointer */
+ di = (unsigned)(LEMPEL - ZIV); // encode pointer
+ si = 0; // end-of-ziv pointer
match(w, di);
- /* ---- main encoding loop ------------------------------------------ */
+ // ---- main encoding loop ------------------------------------------
for (;;) {
- /* clip qlen to zlen */
+ // clip qlen to zlen
if (w->qlen > w->zlen)
w->qlen = w->zlen;
@@ -376,7 +395,7 @@ static unsigned long fabrice(CompWork *w) {
int qoff = w->qoff;
if (qlen < 2 || (qlen == 2 && qoff >= -0x100)) {
- /* LITERAL: control bit = 1, then data byte */
+ // LITERAL: control bit = 1, then data byte
w->qlen = 1;
huff1(w, 1);
push1(w, w->lempel[di]);
@@ -384,16 +403,16 @@ static unsigned long fabrice(CompWork *w) {
huff1(w, 0);
if (qlen <= 5 && qoff > -0x100) {
- /* SHORT COPY: <00XY>, offset_byte (length 2-5, dist 1-255) */
+ // SHORT COPY: <00XY>, offset_byte (length 2-5, dist 1-255)
huff1(w, 0);
- int enc_len = qlen - 2; /* 0..3 */
+ int enc_len = qlen - 2; // 0..3
huff1(w, enc_len & 2);
huff1(w, enc_len & 1);
- push1(w, (byte)qoff); /* qoff is negative; byte cast = low 8 */
+ push1(w, (byte)qoff); // qoff is negative; byte cast = low 8
} else {
- /* LONG COPY: <01>, vector_word */
+ // LONG COPY: <01>, vector_word
huff1(w, 1);
- push1(w, (byte)qoff); /* low byte of offset */
+ push1(w, (byte)qoff); // low byte of offset
byte hi = (byte)((unsigned)(-qoff) >> 8);
int zb = 16 - DICT;
@@ -404,21 +423,21 @@ static unsigned long fabrice(CompWork *w) {
hi |= (byte)(qlen - 2);
push1(w, hi);
} else {
- /* LONG COPY with extra length byte */
+ // LONG COPY with extra length byte
push1(w, hi);
push1(w, (byte)(qlen - 1));
}
}
}
- /* Update delta/paraz counters (track EXPLODE segment boundaries) */
+ // Update delta/paraz counters (track EXPLODE segment boundaries)
w->delta -= w->qlen;
while (w->delta < 0) {
w->paraz++;
w->delta += 16;
}
- /* Insert NORMALIZE marker every 40KB of output */
+ // Insert NORMALIZE marker every 40KB of output
w->norms += w->qlen;
if (w->norms >= 0xA000) {
huff1(w, 0);
@@ -432,7 +451,7 @@ static unsigned long fabrice(CompWork *w) {
di = (unsigned)save_di;
si = (unsigned)save_si;
- /* Advance the dictionary window by qlen positions */
+ // Advance the dictionary window by qlen positions
int advance = w->qlen;
while (advance-- > 0) {
dict_link(w, di);
@@ -448,7 +467,7 @@ static unsigned long fabrice(CompWork *w) {
byte c = w->rbuff[w->rb_ptr++];
w->lempel[si] = c;
if (si < (unsigned)(ZIV - 1))
- w->ziv[si] = c; /* mirror first ZIV-1 chars */
+ w->ziv[si] = c; // mirror first ZIV-1 chars
}
skip_byte:
si = (si + 1) & (LEMPEL - 1);
@@ -462,14 +481,14 @@ skip_byte:
}
lz_exit:
- /* Write EXIT marker: <01>, 0x00, 0x00, 0x00 */
+ // Write EXIT marker: <01>, 0x00, 0x00, 0x00
huff1(w, 0);
huff1(w, 1);
push1(w, 0);
push1(w, 0);
push1(w, 0);
- /* Flush final packet and output buffer */
+ // Flush final packet and output buffer
pkt_flush(w);
if (w->wb_ptr > 0)
wb_out(w);
@@ -477,12 +496,9 @@ lz_exit:
return w->zsize;
}
-/* -------------------------------------------------------------------------
- * Public API: pFABcomp
- * ---------------------------------------------------------------------- */
word pFABcomp(ReadFn read_buff, WriteFn write_buff, char *work_buff,
word *type, word *dsize) {
- /* If work_buff is NULL, return required buffer size */
+ // If work_buff is NULL, return required buffer size
if (!work_buff)
return comp_work_size();
@@ -493,13 +509,13 @@ word pFABcomp(ReadFn read_buff, WriteFn write_buff, char *work_buff,
unsigned long csize = fabrice(w);
- /* Return compressed size via dsize (two 16-bit words = 32-bit size) */
+ // Return compressed size via dsize (two 16-bit words = 32-bit size)
if (dsize) {
((word *)dsize)[0] = (word)(csize & 0xFFFF);
((word *)dsize)[1] = (word)(csize >> 16);
}
- return 0; /* CMP_NO_ERROR */
+ return 0; // CMP_NO_ERROR
}
@@ -546,7 +562,9 @@ struct ExpIO {
unsigned long out_count; /* total bytes decompressed */
};
-/* ---- Buffered-read helpers ------------------------------------------- */
+/*
+ * ---- Buffered-read helpers -------------------------------------------
+ */
static byte exp_getbyte(ExpIO *io) {
if (io->from_file) {
@@ -568,7 +586,9 @@ static unsigned exp_getword(ExpIO *io) {
return lo | (hi << 8);
}
-/* ---- Buffered-write helpers ------------------------------------------ */
+/*
+ * ---- Buffered-write helpers ------------------------------------------
+ */
static void exp_flush_wbuf(ExpIO *io, int force_all) {
if (!io->to_file || io->wbuf_pos == 0)
@@ -584,7 +604,7 @@ static void exp_flush_wbuf(ExpIO *io, int force_all) {
io->wfun((char *)base, &sz);
io->out_count += len;
- /* Shift remaining bytes to front */
+ // Shift remaining bytes to front
unsigned remain = io->wbuf_pos - len;
if (remain)
memmove(base, base + len, remain);
@@ -602,39 +622,39 @@ static void exp_putbyte(ExpIO *io, byte b) {
}
}
-/* ---- read a byte from the output window (back-reference) ------------- */
-
+/**
+ * ---- read a byte from the output window (back-reference) -------------
+ */
static byte exp_readback(ExpIO *io, int dist, unsigned long total_out) {
- /* dist = 1..LEMPEL (positive, 1 = most recent byte written) */
+ // dist = 1..LEMPEL (positive, 1 = most recent byte written)
if (!io->to_file) {
- /* Simple: just look behind in the output buffer */
+ // Simple: just look behind in the output buffer
return *(io->wptr - dist);
} else {
- /* For file-to-file we maintain a sliding window in wbuf. */
- /* wbuf is used as circular output; wbuf_pos is the current head. */
+ // For file-to-file we maintain a sliding window in wbuf.
+ // wbuf is used as circular output; wbuf_pos is the current head.
unsigned idx = (io->wbuf_pos + 4096u - (unsigned)dist) & (4096u - 1u);
return io->wbuf[idx];
}
}
-/* ---- Core decompressor ----------------------------------------------- */
-
+/**
+ * ---- Core decompressor -----------------------------------------------
+ */
static unsigned long fab_explode(ExpIO *io) {
io->out_count = 0;
- /* ---- Verify FAB header ------------------------------------------ */
+ // ---- Verify FAB header ------------------------------------------
if (exp_getbyte(io) != 'F') return 0;
if (exp_getbyte(io) != 'A') return 0;
if (exp_getbyte(io) != 'B') return 0;
- byte shiftVal = exp_getbyte(io); /* dict bits, e.g. 12 */
-
- /*
- * Derive the same masks FabDecompressor uses:
- * copyOfsShift = 16 - shiftVal (e.g. 4)
- * copyOfsMask = 0xFF << (shiftVal - 8) (e.g. 0xF0) -- sign-extends
- * the high offset nibble
- * copyLenMask = (1 << copyOfsShift) - 1 (e.g. 0x0F)
- */
+ byte shiftVal = exp_getbyte(io); // dict bits, e.g. 12
+
+ // Derive the same masks FabDecompressor uses:
+ // copyOfsShift = 16 - shiftVal (e.g. 4)
+ // copyOfsMask = 0xFF << (shiftVal - 8) (e.g. 0xF0) -- sign-extends
+ // the high offset nibble
+ // copyLenMask = (1 << copyOfsShift) - 1 (e.g. 0x0F)
byte copyOfsShift = (byte)(16 - shiftVal);
byte copyOfsMask = (byte)(0xFF << (shiftVal - 8));
byte copyLenMask = (byte)((1 << copyOfsShift) - 1);
@@ -656,18 +676,18 @@ static unsigned long fab_explode(ExpIO *io) {
return bit;
};
- /* ---- Decode loop ------------------------------------------------- */
+ // ---- Decode loop -------------------------------------------------
for (;;) {
int bit0 = get_ctrl_bit();
if (bit0 == 1) {
- /* LITERAL: copy one byte straight through */
+ // LITERAL: copy one byte straight through
byte c = exp_getbyte(io);
exp_putbyte(io, c);
continue;
}
- /* bit0 == 0 */
+ // bit0 == 0
int bit1 = get_ctrl_bit();
if (bit1 == 0) {
@@ -738,11 +758,11 @@ word pFABexp0(ReadFn read_buff, WriteFn write_buff, char *work_buff) {
unsigned long out_len = fab_explode(&io);
- /* Return decompressed size in work_buff[0..3] */
+ // Return decompressed size in work_buff[0..3]
((word *)work_buff)[0] = (word)(out_len & 0xFFFF);
((word *)work_buff)[1] = (word)(out_len >> 16);
- return 0; /* CMP_NO_ERROR */
+ return 0; // CMP_NO_ERROR
}
@@ -771,7 +791,7 @@ word pFABexp1(ReadFn read_buff, char *write_buf, char *work_buff) {
unsigned long out_len = fab_explode(&io);
- /* Return decompressed size in work_buff[0..3] */
+ // Return decompressed size in work_buff[0..3]
((word *)work_buff)[0] = (word)(out_len & 0xFFFF);
((word *)work_buff)[1] = (word)(out_len >> 16);
@@ -779,18 +799,9 @@ word pFABexp1(ReadFn read_buff, char *write_buf, char *work_buff) {
}
-/* =========================================================================
- * pFABexp2 -- memory-to-memory decompressor (PFABEXP2.ASM)
- *
- * read_buf points to compressed data.
- * write_buf points to destination buffer (must be large enough).
- * work_buff must be at least 4 bytes (for the output length result),
- * or NULL to query required size.
- * Returns 0 on success. Decompressed byte count stored at work_buff[0..3].
- * ====================================================================== */
word pFABexp2(byte *read_buf, byte *write_buf, char *work_buff) {
if (!work_buff)
- return 4u; /* original returned 4 */
+ return 4u; // original returned 4
ExpIO io;
memset(&io, 0, sizeof(io));
@@ -802,7 +813,7 @@ word pFABexp2(byte *read_buf, byte *write_buf, char *work_buff) {
unsigned long out_len = fab_explode(&io);
- /* Return decompressed size in work_buff[0..3] */
+ // Return decompressed size in work_buff[0..3]
((word *)work_buff)[0] = (word)(out_len & 0xFFFF);
((word *)work_buff)[1] = (word)(out_len >> 16);
diff --git a/engines/mads/madsv2/core/player.cpp b/engines/mads/madsv2/core/player.cpp
index 3b1fe5d406e..d35bc951763 100644
--- a/engines/mads/madsv2/core/player.cpp
+++ b/engines/mads/madsv2/core/player.cpp
@@ -307,7 +307,7 @@ static void player_keep_turning() {
}
}
- player.clock++; /* Add 1 to player clock for slightly slower turn */
+ player.clock++; // Add 1 to player clock for slightly slower turn
}
void player_stationary_update() {
@@ -584,7 +584,7 @@ void player_set_image() {
depth = 1;
effective_y = player.y;
- /* effective_y = MIN (effective_y, display_y - 1); */
+ // effective_y = MIN (effective_y, display_y - 1);
for (count = 1; count < 15; count++) {
if (effective_y <= room->depth_table[depth]) {
depth = (byte)(count + 1);
@@ -838,8 +838,8 @@ void player_new_command() {
player.ready_to_walk = player.need_to_walk;
- /* Be sure player moves immediately even if in the middle of a long */
- /* stop-walker frame. */
+ // Be sure player moves immediately even if in the middle of a long
+ // stop-walker frame.
player.clock = MIN(player.clock, kernel.clock + series_list[player.series_base + player.series]->walker->frame_rate);
}
diff --git a/engines/mads/madsv2/core/popup.cpp b/engines/mads/madsv2/core/popup.cpp
index 2cdcbcd0db6..81b66291841 100644
--- a/engines/mads/madsv2/core/popup.cpp
+++ b/engines/mads/madsv2/core/popup.cpp
@@ -178,8 +178,7 @@ void popup_next_line(void) {
}
box->text_x = 0;
- /* box->dont_add_space = false; */
-
+ // box->dont_add_space = false;
if (box->text_y >= POPUP_MAX_LINES) {
error_report(ERROR_POPUP_TOO_MANY_LINES, ERROR, MODULE_POPUP, box->text_y, POPUP_MAX_LINES);
}
@@ -243,17 +242,17 @@ void popup_write_string(const char *string) {
cr = true;
marker++;
word_ptr--;
- } else if (*marker == 0x20) { /* Soft space */
+ } else if (*marker == 0x20) { // Soft space
marker++;
any_space = true;
- } else if (*marker == '~') { /* Hard space */
+ } else if (*marker == '~') { // Hard space
word_ptr--;
*word_ptr++ = ' ';
marker++;
- } else if (any_space) { /* (Break after space) */
+ } else if (any_space) { // (Break after space)
word_ptr--;
going = false;
- } else if (*marker == '=') { /* Hard hyphen */
+ } else if (*marker == '=') { // Hard hyphen
word_ptr--;
*word_ptr++ = '-';
if (*(marker + 1) == '-') {
@@ -261,14 +260,14 @@ void popup_write_string(const char *string) {
marker++;
}
marker++;
- } else if (*marker == '-') { /* Soft hyphen */
+ } else if (*marker == '-') { // Soft hyphen
if (*(marker + 1) == '-') {
- *(word_ptr - 1) = '{'; /* Double hyphen */
+ *(word_ptr - 1) = '{'; // Double hyphen
marker++;
}
marker++;
any_hyphen = true;
- } else if (any_hyphen) { /* (Break after hyphen) */
+ } else if (any_hyphen) { // (Break after hyphen)
word_ptr--;
going = false;
stop_on_hyphen = true;
@@ -296,7 +295,7 @@ void popup_write_string(const char *string) {
box->dont_add_space = stop_on_hyphen;
len = strlen(word2);
- width = font_string_width(box_param.font, word2, POPUP_SPACING) /* - POPUP_SPACING */;
+ width = font_string_width(box_param.font, word2, POPUP_SPACING); // - POPUP_SPACING
if (((box->text_x + len) > box->text_width) || ((box->cursor_x + width) > box->text_xs)) {
popup_next_line();
@@ -397,7 +396,7 @@ int popup_draw(int save_screen, int depth_code) {
int icon_x;
int sum_y;
- /* Arrow cursor */
+ // Arrow cursor
cursor_id = 1;
if (cursor_id != cursor_last) {
mouse_cursor_sprite(cursor, cursor_id);
@@ -406,9 +405,8 @@ int popup_draw(int save_screen, int depth_code) {
if (!box->cursor_x) box->text_y--;
- /* Find out how many vertical pieces are needed to contain the text, */
- /* and determine the resulting size. */
-
+ // Find out how many vertical pieces are needed to contain the text,
+ // and determine the resulting size.
if (!box->dialog_system) {
base_text_size = ((box_param.font->max_y_size + 1) * (box->text_y + 1)) + (popup_padding_width << 1);
} else {
@@ -432,9 +430,8 @@ int popup_draw(int save_screen, int depth_code) {
+ pop_ys(POPUP_UPPER_LEFT)
+ pop_ys(POPUP_LOWER_LEFT);
- /* Determine the true size of the entire window (figure out which border */
- /* pieces extend the furthest). */
-
+ // Determine the true size of the entire window (figure out which border
+ // pieces extend the furthest).
top = pop_y(POPUP_UPPER_LEFT);
top = MIN(top, pop_y(POPUP_UPPER_CENTER));
top = MIN(top, pop_y(POPUP_TOP));
@@ -457,8 +454,7 @@ int popup_draw(int save_screen, int depth_code) {
box->xs += (right - pop_x2(POPUP_UPPER_RIGHT));
- /* Determine the popup's coordinates on the screen */
-
+ // Determine the popup's coordinates on the screen
if (box->base_x & POPUP_CENTER) {
temp = (box->base_x & (~POPUP_CENTER));
if (!temp) temp = (video_x >> 1);
@@ -491,13 +487,11 @@ int popup_draw(int save_screen, int depth_code) {
box->y++;
}
- /* Compute base border point */
-
+ // Compute base border point
box->base_x = box->x + x_bonus;
box->base_y = box->y + y_bonus;
- /* Compute window location */
-
+ // Compute window location
box->window_x = box->base_x + box_param.offset_x;
box->window_y = box->base_y + box_param.offset_y;
@@ -550,8 +544,7 @@ int popup_draw(int save_screen, int depth_code) {
x = box->base_x;
y = box->base_y;
- /* Draw top edge */
-
+ // Draw top edge
pop_draw(POPUP_UPPER_LEFT, x, y, depth_code);
x += pop_xs(POPUP_UPPER_LEFT);
@@ -571,8 +564,7 @@ int popup_draw(int save_screen, int depth_code) {
pop_draw(POPUP_UPPER_RIGHT, x, y + box_param.upper_right_adjust_y, depth_code);
- /* Draw right edge */
-
+ // Draw right edge
y += pop_ys(POPUP_UPPER_RIGHT);
for (count = 0; count < box->vert_pieces; count++) {
@@ -580,8 +572,7 @@ int popup_draw(int save_screen, int depth_code) {
y += pop_ys(POPUP_RIGHT);
}
- /* Draw left edge */
-
+ // Draw left edge
x = box->base_x;
y = box->base_y + pop_ys(POPUP_UPPER_LEFT);
@@ -592,8 +583,7 @@ int popup_draw(int save_screen, int depth_code) {
pop_draw(POPUP_LOWER_LEFT, x + box_param.lower_left_adjust_x, y, depth_code);
- /* Draw bottom edge */
-
+ // Draw bottom edge
x += pop_xs(POPUP_LOWER_LEFT);
bottom_pieces = (box->horiz_pieces << 1) + box_param.pieces_per_center;
@@ -605,8 +595,7 @@ int popup_draw(int save_screen, int depth_code) {
pop_draw(POPUP_LOWER_RIGHT, x, y + box_param.lower_right_adjust_y, depth_code);
- /* Fill center */
-
+ // Fill center
loc_y = box->window_y + popup_padding_width + (box->text_extra >> 1);
loc_y += ((box_param.font->max_y_size + 1) * box->ask_y);
@@ -646,8 +635,7 @@ int popup_draw(int save_screen, int depth_code) {
attr_depth_xs, box->window_ys, 0);
}
- /* Draw icon if any */
-
+ // Draw icon if any
if (box->icon != NULL) {
icon_x = 0;
@@ -676,8 +664,7 @@ int popup_draw(int save_screen, int depth_code) {
goto done;
}
- /* Draw text in box */
-
+ // Draw text in box
loc_y = box->window_y + popup_padding_width + (box->text_extra >> 1);
sum_y = 0;
@@ -725,8 +712,7 @@ int popup_draw(int save_screen, int depth_code) {
sum_y += (box_param.font->max_y_size + 1);
}
- /* Update live video */
-
+ // Update live video
mouse_hide();
video_update(&scr_main, box->x, box->y, box->x, box->y, box->xs, box->ys);
mouse_show();
@@ -1152,7 +1138,7 @@ int popup_box_load(void) {
byte special_color;
Buffer data_buf;
- data_buf.x = 1; /* A one pixel buffer */
+ data_buf.x = 1; // A one pixel buffer
data_buf.y = 1;
data_buf.data = &special_color;
@@ -1272,14 +1258,12 @@ done:
}
-/*
-/* popup_activate()
-/*
-/* Causes the specified popup structure to become active (the active
-/* popup structure is considered the target of all popup requests
-/* which do not include a Popup structure or pointer in their
-/* parameter lists).
-*/
+/**
+ * Causes the specified popup structure to become active (the active
+ * popup structure is considered the target of all popup requests
+ * which do not include a Popup structure or pointer in their
+ * parameter lists).
+ */
static Popup *popup_activate(Popup *newpop) {
if (newpop != NULL) {
popup = newpop;
@@ -1287,14 +1271,12 @@ static Popup *popup_activate(Popup *newpop) {
return (popup);
}
-/*
-/* popup_exec_function ()
-/*
-/* Executes the specified function vector for the specified item.
-/* Returns function's return value if function exists; if vector
-/* is NULL, always returns 0. A far pointer to the PopupItem structure
-/* is passed on the stack to the function routine.
-*/
+/**
+ * Executes the specified function vector for the specified item.
+ * Returns function's return value if function exists; if vector
+ * is NULL, always returns 0. A far pointer to the PopupItem structure
+ * is passed on the stack to the function routine.
+ */
static int popup_exec_function(PopupItem *item, int function) {
if (item == NULL || item->vector[function] == NULL)
return 0;
@@ -1302,11 +1284,9 @@ static int popup_exec_function(PopupItem *item, int function) {
return item->vector[function](item);
}
-/*
-/* popup_item_init();
-/*
-/* Initializes an empty item.
-*/
+/**
+ * Initializes an empty item.
+ */
static void popup_item_init(PopupItem *item) {
int count;
@@ -1328,12 +1308,6 @@ static void popup_item_init(PopupItem *item) {
}
-/*
-/* popup_dialog_create()
-/*
-/* Sets up popup dialog structure, allocating memory dynamically
-/* if necessary.
-*/
Popup *popup_dialog_create(void *memory, long heap_size, int max_items) {
int count;
byte *block = NULL;
@@ -1416,11 +1390,6 @@ done:
}
-/*
-/* popup_dialog_destroy()
-/*
-/* Destroys a popup dialog, deallocating any dynamic memory.
-*/
Popup *popup_dialog_destroy(void) {
popup->status &= ~(POPUP_STATUS_VALID);
@@ -1888,7 +1857,7 @@ static int popup_button_x_size(PopupItem *item) {
static int popup_button_y_size(PopupItem *item) {
- item = NULL; /* delete if this routine is to be used */
+ item = NULL; // delete if this routine is to be used
return (box_param.font->max_y_size + 4 + 2);
}
@@ -1917,8 +1886,7 @@ static int popup_button_draw(PopupItem *item) {
popup_mouse_refresh_2(refresh);
}
- /* color = selected ? POPUP_ASK_COLOR : POPUP_TEXT_COLOR; */
-
+ // color = selected ? POPUP_ASK_COLOR : POPUP_TEXT_COLOR;
if (popup->active_item->type == ITEM_BUTTON) {
big_button = (item == popup->active_item);
} else {
@@ -2088,7 +2056,7 @@ static int popup_menu_x_size(PopupItem *item) {
static int popup_menu_y_size(PopupItem *item) {
- item = NULL; /* delete if this routine is to be used */
+ item = NULL; // delete if this routine is to be used
return(box_param.menu->index[0].ys);
}
@@ -2247,7 +2215,7 @@ static int popup_message_x_size(PopupItem *item) {
static int popup_message_y_size(PopupItem *item) {
- item = NULL; /* delete if this routine is to be used */
+ item = NULL; // delete if this routine is to be used
return box_param.font->max_y_size;
}
@@ -2499,7 +2467,7 @@ static void popup_savelist_scroll_draw(PopupItem *item) {
color = POPUP_DIALOG_BORDER_COLOR_1;
color2 = POPUP_DIALOG_BORDER_COLOR_2;
- /* Scroll Bar */
+ // Scroll Bar
buffer_rect_fill(scr_main, list->scroll.x, list->scroll.y,
1, list->scroll.ys, color);
buffer_rect_fill(scr_main, list->scroll.x + 1, list->scroll.y,
@@ -2651,24 +2619,21 @@ static int popup_savelist_draw(PopupItem *item) {
color = POPUP_DIALOG_BORDER_COLOR_1;
color2 = POPUP_DIALOG_BORDER_COLOR_2;
- /* Basic box */
+ // Basic box
popup_double_box_2(item->x, item->y, item->xs, item->ys, color, color2);
- /*
- buffer_rect_fill (scr_main, item->x, item->y,
- item->xs, 1,
- color);
- buffer_rect_fill (scr_main, item->x, item->y,
- 1, item->ys,
- color);
- buffer_rect_fill (scr_main, item->x + item->xs - 1, item->y,
- 1, item->ys,
- color);
- buffer_rect_fill (scr_main, item->x, item->y + item->ys - 1,
- item->xs, 1,
- color);
- */
-
- /* Number list */
+ // buffer_rect_fill (scr_main, item->x, item->y,
+ // item->xs, 1,
+ // color);
+ // buffer_rect_fill (scr_main, item->x, item->y,
+ // 1, item->ys,
+ // color);
+ // buffer_rect_fill (scr_main, item->x + item->xs - 1, item->y,
+ // 1, item->ys,
+ // color);
+ // buffer_rect_fill (scr_main, item->x, item->y + item->ys - 1,
+ // item->xs, 1,
+ // color);
+ // Number list
buffer_rect_fill(scr_main, list->extra_x + list->extra_xs - 2, list->extra_y,
1, list->extra_ys, color);
buffer_rect_fill(scr_main, list->extra_x + list->extra_xs - 1, list->extra_y,
diff --git a/engines/mads/madsv2/core/quote.cpp b/engines/mads/madsv2/core/quote.cpp
index 3b99541372f..fc6ccb7ff78 100644
--- a/engines/mads/madsv2/core/quote.cpp
+++ b/engines/mads/madsv2/core/quote.cpp
@@ -159,7 +159,7 @@ void quote_split_string(const char *source, char *target1, char *target2) {
while (*mark == ' ') mark++;
- /* *(target1++) = '"'; */
+ // (target1++) = '"';
*(target1++) = 0;
do {
diff --git a/engines/mads/madsv2/core/rail.cpp b/engines/mads/madsv2/core/rail.cpp
index 6d1c8411021..0f5b840909b 100644
--- a/engines/mads/madsv2/core/rail.cpp
+++ b/engines/mads/madsv2/core/rail.cpp
@@ -156,14 +156,12 @@ void rail_connect_all_nodes(void) {
/**
- * Parameters (passed in registers in the original):
- * node_id -- BX: node currently being evaluated
- * weight -- DX: cumulative weight for this solution attempt
- * allow_mode -- AX: RAIL_ALLOW_ILLEGAL or RAIL_ALLOW_LEGAL_ONLY
- *
- * Stack state:
- * working_sp -- SI in the original: index into _rail_working_stack,
- * acting as a simple push-down stack pointer.
+ * Used for recursively determing walk path between room rail nodes
+ * @param node_id Node currently being evaluated
+ * @param weight Cumulative weight for this solution attempt
+ * @param allow_mode Mode: RAIL_ALLOW_ILLEGAL or RAIL_ALLOW_LEGAL_ONLY
+ * @param working_sp Index into _rail_working_stack, acting as a simple
+ * push-down stack pointer.
*
* The function is recursive and modifies the globals directly.
*/
@@ -171,58 +169,56 @@ static void recursive_check_path(int node_id,
uint16 weight,
uint16 allow_mode,
int working_sp) {
- /* visited[node_id] = true */
+ // visited[node_id] = true
rail_visited[node_id] = 1;
- /* push(node_id) onto working stack */
+ // push(node_id) onto working stack
rail_working_stack[working_sp] = (unsigned char)node_id;
working_sp++;
- /* Point at rail[node_id] */
+ // Point at rail[node_id]
Rail *node = &rail_base[node_id];
- /* The source node is second-to-last: index = num_nodes - 2.
- We look up the weight from node_id to the source (from_node). */
+ // The source node is second-to-last: index = num_nodes - 2.
+ // We look up the weight from node_id to the source (from_node).
int from_node = rail_num_nodes - 2;
uint16 raw_weight = node->weight[from_node];
- /* Check whether there is a direct legal path to the destination */
+ // Check whether there is a direct legal path to the destination
if (raw_weight & allow_mode) {
uint16 leg_weight = raw_weight & RAIL_WEIGHT_MASK;
uint16 total = weight + leg_weight;
if (total < rail_solution_stack_weight) {
- /* This is a better solution -- save it */
- int stack_len = working_sp; /* number of bytes currently on stack */
+ // This is a better solution -- save it
+ int stack_len = working_sp; // number of bytes currently on stack
memcpy(rail_solution_stack, rail_working_stack, stack_len);
rail_solution_stack_pointer = (uint16)stack_len;
rail_solution_stack_weight = total;
}
} else {
- /*
- * No direct path -- recurse through every unvisited intermediate node.
- * Intermediate nodes are indices 0 .. (num_nodes - 3); the last two
- * entries in the array are the destination and source nodes.
- */
+ // No direct path -- recurse through every unvisited intermediate node.
+ // Intermediate nodes are indices 0 .. (num_nodes - 3); the last two
+ // entries in the array are the destination and source nodes.
int num_intermediate = rail_num_nodes - 2;
for (int i = 0; i < num_intermediate; i++) {
- int test_node = i; /* loop counter - 1 in the ASM */
+ int test_node = i; // loop counter - 1 in the ASM
if (rail_visited[test_node])
continue;
- /* Check edge weight from current node to test_node */
+ // Check edge weight from current node to test_node
uint16 edge_raw = node->weight[test_node];
uint16 edge_legal = edge_raw & allow_mode;
if (!edge_legal)
- continue; /* not a legal connection */
+ continue; // not a legal connection
uint16 edge_weight = edge_raw & RAIL_WEIGHT_MASK;
- /* All further legs must be strictly legal once we step through
- an intermediate node (the ASM forces RAIL_ALLOW_LEGAL_ONLY) */
+ // All further legs must be strictly legal once we step through
+ // an intermediate node (the ASM forces RAIL_ALLOW_LEGAL_ONLY)
recursive_check_path(test_node,
weight + edge_weight,
RAIL_ALLOW_LEGAL_ONLY,
@@ -230,22 +226,22 @@ static void recursive_check_path(int node_id,
}
}
- /* visited[node_id] = false (unwind) */
+ // visited[node_id] = false (unwind)
rail_visited[node_id] = 0;
- /* pop() -- working_sp is a local copy so this just falls off the frame */
+ // pop() -- working_sp is a local copy so this just falls off the frame
}
void rail_check_path(int allow_one_illegal) {
- /* Clear the visited array */
+ // Clear the visited array
memset(rail_visited, 0, rail_num_nodes);
- /* Initialise solution state to "no solution yet" */
+ // Initialise solution state to "no solution yet"
rail_solution_stack_weight = RAIL_WEIGHT_MASK;
rail_solution_stack_pointer = 0;
- /* The last node in the array (index num_nodes - 1) is the starting
- node for the search (the destination, in path terms) */
+ // The last node in the array (index num_nodes - 1) is the starting
+ // node for the search (the destination, in path terms)
int start_node = rail_num_nodes - 1;
uint16 allow_mode = allow_one_illegal ? RAIL_ALLOW_ILLEGAL
diff --git a/engines/mads/madsv2/core/room.cpp b/engines/mads/madsv2/core/room.cpp
index c1991a311a9..4994f72fd97 100644
--- a/engines/mads/madsv2/core/room.cpp
+++ b/engines/mads/madsv2/core/room.cpp
@@ -154,14 +154,12 @@ RoomPtr room_load(int id, int variant, const char *base_path, Buffer *picture,
room_unload(NULL, picture, depth, walk, special, picMap, depthMap);
- /* Initialize structures */
-
+ // Initialize structures
mem_last_alloc_loader = MODULE_ROOM_LOADER;
load_handle.open = false;
- /* Open the room data file */
-
+ // Open the room data file
room_resolve_base(base, temp_buf, id, base_path);
if (loader_open(&load_handle, temp_buf, "rb", true)) {
@@ -169,7 +167,7 @@ RoomPtr room_load(int id, int variant, const char *base_path, Buffer *picture,
goto done;
}
- /* Load room header block */
+ // Load room header block
{
byte buffer[RoomFile::SIZE];
if (!loader_read(buffer, RoomFile::SIZE, 1, &load_handle)) {
@@ -184,8 +182,7 @@ RoomPtr room_load(int id, int variant, const char *base_path, Buffer *picture,
Common::strcpy_s(block_name, "$ROOM");
env_catint(block_name, id, 3);
- /* Determine size needed for room data structure (based on # of rails) */
-
+ // Determine size needed for room data structure (based on # of rails)
mem_needed = (sizeof(Room) - sizeof(Rail)) + (sizeof(Rail) * (roomfile.num_rails + 2));
roomPtr = (RoomPtr)mem_get_name(mem_needed, block_name);
if (roomPtr == NULL) {
@@ -216,7 +213,7 @@ RoomPtr room_load(int id, int variant, const char *base_path, Buffer *picture,
picResource,
picMap,
picture,
- NULL, /* &color_list, */
+ NULL, // &color_list,
&roomPtr->cycle_list,
picture_ems_handle,
load_flags)) {
@@ -505,11 +502,11 @@ void room_himem_preload(int roomNum, int level) {
himem_preload_series(kernel_full_name(roomNum, 0, -1, NULL, KERNEL_DAT), level);
himem_preload_series(kernel_full_name(roomNum, 0, -1, NULL, KERNEL_HH), level);
- /* himem_preload_series (kernel_full_name (room, 0, -1, NULL, KERNEL_TT), level); */
+ // himem_preload_series (kernel_full_name (room, 0, -1, NULL, KERNEL_TT), level);
himem_preload_series(kernel_full_name(roomNum, 0, -1, NULL, KERNEL_MM), level);
himem_preload_series(kernel_full_name(roomNum, 0, -1, NULL, KERNEL_WW), level);
- /* himem_preload_series (kernel_full_name (room, 0, 0, NULL, KERNEL_TT), level); */
+ // himem_preload_series (kernel_full_name (room, 0, 0, NULL, KERNEL_TT), level);
himem_preload_series(kernel_full_name(roomNum, 0, 0, NULL, KERNEL_MM), level);
himem_preload_series(kernel_full_name(roomNum, 0, 0, NULL, KERNEL_WW), level);
}
@@ -547,8 +544,7 @@ int room_picture_load(int roomId, Buffer *picture, int load_flags) {
goto done;
}
- /* memcpy (&room->cycle_list, &art.cycle_list, sizeof(CycleList)); */
-
+ // memcpy (&room->cycle_list, &art.cycle_list, sizeof(CycleList));
if (!(load_flags & ROOM_LOAD_TRANSLATE)) {
color_handle = pal_allocate(&art.color_list, NULL, (load_flags & PAL_MAP_MASK));
if (color_handle < 0) {
@@ -621,30 +617,29 @@ static void room_buffer_invert(Buffer *buffer, byte *work, int granularity) {
byte *src, *dst;
int i;
- /* Copy row into work buffer. */
+ // Copy row into work buffer.
memcpy(work, scan, wrap);
src = work;
- dst = scan + wrap - 1; /* dst walks right-to-left through scan */
+ dst = scan + wrap - 1; // dst walks right-to-left through scan
for (i = 0; i < wrap; i++) {
byte al = *src++;
if (granularity == 8) {
- /* Reverse all 8 bits. */
+ // Reverse all 8 bits.
byte ah = 0;
int b;
for (b = 0; b < 8; b++) {
- ah = (ah >> 1) | (al << 7); /* rcr ah,1 / shl al,1 pair */
+ ah = (ah >> 1) | (al << 7); // rcr ah,1 / shl al,1 pair
al <<= 1;
}
al = ah;
} else if (granularity == 2) {
- /* Swap the two nibbles. */
- al = (al >> 4) | (al << 4); /* ror al,4 */
+ // Swap the two nibbles.
+ al = (al >> 4) | (al << 4); // ror al,4
}
- /* granularity == 1: byte value is used as-is */
-
+ // granularity == 1: byte value is used as-is
*dst-- = al;
}
diff --git a/engines/mads/madsv2/core/sort.cpp b/engines/mads/madsv2/core/sort.cpp
index cdf19ed9a2d..c3a90eacc15 100644
--- a/engines/mads/madsv2/core/sort.cpp
+++ b/engines/mads/madsv2/core/sort.cpp
@@ -45,11 +45,12 @@ void sort_insertion(int elements, int *id, long *value) {
for (count2 = 0; (count2 < elements - 1) && !going; count2++) {
going = (my_value < value[count2]);
}
- /* After the loop, count2 has been post-incremented one step past
- * the found insertion position. If going was set to true inside
- * the loop (i.e. we found a value[count2-1] > my_value), the for
- * loop's count2++ still fired, so the real target index is
- * count2-1. Decrement to correct for this. */
+
+ // After the loop, count2 has been post-incremented one step past
+ // the found insertion position. If going was set to true inside
+ // the loop (i.e. we found a value[count2-1] > my_value), the for
+ // loop's count2++ still fired, so the real target index is
+ // count2-1. Decrement to correct for this.
if (going) {
count2--;
}
@@ -71,50 +72,50 @@ void sort_insertion_16(int elements, byte *id, word *value) {
word my_value;
byte my_id;
- while (1) { /* restart_sort */
+ while (1) { // restart_sort
int si = restart_mark;
int limit = elements - 1;
- /* search_loop: scan forward from restart_mark for an out-of-order pair */
+ // search_loop: scan forward from restart_mark for an out-of-order pair
while (si < limit) {
if (value[si + 1] < value[si])
- break; /* found_anomaly */
+ break; // found_anomaly
si++;
restart_mark = si;
}
if (si >= limit)
- break; /* sort_done */
+ break; // sort_done
- /* found_anomaly: save the out-of-order element at si+1 */
+ // found_anomaly: save the out-of-order element at si+1
my_value = value[si + 1];
my_id = id[si + 1];
- /* Delete element at si+1 by shifting everything above it down one.
- Value array uses word (2-byte) elements; id array uses bytes. */
+ // Delete element at si+1 by shifting everything above it down one.
+ // Value array uses word (2-byte) elements; id array uses bytes.
int deletion = limit - si - 1;
if (deletion > 0) {
memmove(&value[si + 1], &value[si + 2], deletion * sizeof(word));
memmove(&id[si + 1], &id[si + 2], deletion * sizeof(byte));
}
- /* quest_loop: find correct insertion point for my_value in [0..limit-1] */
+ // quest_loop: find correct insertion point for my_value in [0..limit-1]
int count2 = 0;
while (count2 < limit) {
if (my_value <= value[count2])
- break; /* found_spot */
+ break; // found_spot
count2++;
}
- /* found_spot: shift right from count2 to make room */
+ // found_spot: shift right from count2 to make room
int insertion = limit - count2;
if (insertion > 0) {
memmove(&value[count2 + 1], &value[count2], insertion * sizeof(word));
memmove(&id[count2 + 1], &id[count2], insertion * sizeof(byte));
}
- /* Insert saved element at its correct position */
+ // Insert saved element at its correct position
value[count2] = my_value;
id[count2] = my_id;
}
@@ -125,54 +126,54 @@ void sort_insertion_8(int elements, byte *id, byte *value) {
byte my_value;
byte my_id;
- while (1) { /* restart_sort */
+ while (1) { // restart_sort
int si = restart_mark;
int limit = elements - 1;
- /* search_loop: scan forward from restart_mark for an out-of-order pair */
+ // search_loop: scan forward from restart_mark for an out-of-order pair
while (si < limit) {
if (value[si + 1] < value[si])
- break; /* found_anomaly */
+ break; // found_anomaly
si++;
restart_mark = si;
}
if (si >= limit)
- break; /* sort_done */
+ break; // sort_done
- /* found_anomaly: save the out-of-order element at si+1 */
+ // found_anomaly: save the out-of-order element at si+1
my_value = value[si + 1];
my_id = id[si + 1];
- /* Delete element at si+1 by shifting everything above it down one */
+ // Delete element at si+1 by shifting everything above it down one
int deletion = limit - si - 1;
if (deletion > 0) {
memmove(&value[si + 1], &value[si + 2], deletion * sizeof(byte));
memmove(&id[si + 1], &id[si + 2], deletion * sizeof(byte));
}
- /* quest_loop: find correct insertion point for my_value in [0..limit-1] */
+ // quest_loop: find correct insertion point for my_value in [0..limit-1]
int count2 = 0;
while (count2 < limit) {
if (my_value <= value[count2])
- break; /* found_spot */
+ break; // found_spot
count2++;
}
- /* found_spot: shift right from count2 to make room */
+ // found_spot: shift right from count2 to make room
int insertion = limit - count2;
if (insertion > 0) {
- /* shift backwards (std / rep movsb in original) */
+ // shift backwards (std / rep movsb in original)
memmove(&value[count2 + 1], &value[count2], insertion * sizeof(byte));
memmove(&id[count2 + 1], &id[count2], insertion * sizeof(byte));
}
- /* Insert saved element at its correct position */
+ // Insert saved element at its correct position
value[count2] = my_value;
id[count2] = my_id;
- /* restart_sort: loop back and try again from restart_mark */
+ // restart_sort: loop back and try again from restart_mark
}
}
diff --git a/engines/mads/madsv2/core/text.cpp b/engines/mads/madsv2/core/text.cpp
index 7448daaaa9b..8243a4eb02d 100644
--- a/engines/mads/madsv2/core/text.cpp
+++ b/engines/mads/madsv2/core/text.cpp
@@ -252,8 +252,7 @@ static void text_noun(char **source, char **dest, int noun_id) {
syntax = (noun_id != 2) ? player.main_syntax : player.second_syntax;
- /* Check if a simple substitution of word */
-
+ // Check if a simple substitution of word
if (**source != ':') {
if (syntax >= SYNTAX_SINGULAR_MASC) text_capitalization = TEXT_AS_IS;
text_copy_vocab(dest, player2.words[noun_id], (noun_id != 2) ? text_command_noun1 : text_command_noun2);
@@ -275,29 +274,25 @@ static void text_noun(char **source, char **dest, int noun_id) {
}
}
- /* Check for subject pronoun */
-
+ // Check for subject pronoun
if (!scumm_strnicmp(*source, text_command_subject, strlen(text_command_subject))) {
text_copy_string(dest, istring_subject_pronoun[syntax]);
goto done;
}
- /* Check for object pronoun */
-
+ // Check for object pronoun
if (!scumm_strnicmp(*source, text_command_object, strlen(text_command_object))) {
text_copy_string(dest, istring_object_pronoun[syntax]);
goto done;
}
- /* Check for demonstrative */
-
+ // Check for demonstrative
if (!scumm_strnicmp(*source, text_command_demonstrative, strlen(text_command_demonstrative))) {
text_copy_string(dest, istring_demonstrative[syntax]);
goto done;
}
- /* Try for a custom substitution */
-
+ // Try for a custom substitution
if (scumm_strnicmp(*source, text_command_custom, strlen(text_command_custom))) {
goto done;
}
@@ -400,8 +395,8 @@ static void text_icon(char *my_text, SeriesPtr *icon, int *id) {
idd = object_named(player_main_noun);
- if (idd == 9) { /* if == polystone */
- if (global[128] != -1) { /* and it's imitating, make icon == what it's imitating */
+ if (idd == 9) { // if == polystone
+ if (global[128] != -1) { // and it's imitating, make icon == what it's imitating
Common::strcpy_s(name, "*OB0");
env_catint(name, global[128], 2);
Common::strcat_s(name, ".ss");
@@ -467,7 +462,7 @@ int text_show(long id) {
} else if (*scan == TEXT_CLOSE_COMMAND) {
if (brackets_on) {
*cmd = 0;
- /* mads_strupr(command_buf); */
+ // mads_strupr(command_buf);
if (text_compare(command_buf, text_command_center, &more)) {
center = true;
} else if (text_compare(command_buf, text_command_title, &more)) {
diff --git a/engines/mads/madsv2/core/tile.cpp b/engines/mads/madsv2/core/tile.cpp
index 30484bea0fa..26870ab57fd 100644
--- a/engines/mads/madsv2/core/tile.cpp
+++ b/engines/mads/madsv2/core/tile.cpp
@@ -109,8 +109,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
load_handle.open = false;
- /* Load tile map */
-
+ // Load tile map
if (tile_type > TILE_ATTRIBUTE) {
if (!env_exist(map_name)) {
map_name[strlen(map_name) - 1] = '0';
@@ -123,7 +122,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
goto done;
}
- /* Read map header record */
+ // Read map header record
{
byte buffer[TileMapHeader::SIZE];
if (!loader_read(buffer, TileMapHeader::SIZE, 1, &load_handle)) {
@@ -136,8 +135,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
map->load(&src);
}
- /* Compute map size and read map */
-
+ // Compute map size and read map
map->tile_type = tile_type;
map_size = (map->num_x_tiles * map->num_y_tiles) * sizeof(int16);
@@ -165,8 +163,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
loader_close(&load_handle);
- /* Load tile resource */
-
+ // Load tile resource
if (loader_open(&load_handle, resource_name, "rb", true)) {
tile_load_error = 5;
goto done;
@@ -178,7 +175,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
top_of_file = load_handle.handle->pos();
}
- /* Read tile resource header record */
+ // Read tile resource header record
{
byte buffer[TileResource::SIZE];
if (!loader_read(buffer, TileResource::SIZE, 1, &load_handle)) {
@@ -190,8 +187,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
tile_resource->load(&src);
}
- /* Initialize map structure parameters */
-
+ // Initialize map structure parameters
map_x_size = map->tile_x_size * map->num_x_tiles;
map_y_size = map->tile_y_size * map->num_y_tiles;
@@ -204,20 +200,17 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
map->orig_x_tiles = ((map->orig_x_size - 1) / map->tile_x_size) + 1;
map->orig_y_tiles = ((map->orig_y_size - 1) / map->tile_y_size) + 1;
- /* Prepare main ORIG or ATTR buffer */
-
+ // Prepare main ORIG or ATTR buffer
if (tile_type == TILE_PICTURE) {
buffer_init_name(picture, map->orig_x_size, map->orig_y_size, "$scrorig");
} else {
buffer_init_name(picture, ((map->orig_x_size - 1) >> 1) + 1, map->orig_y_size, "$scrdpth");
}
- /* Check if one-to-one correspondence between ORIG and VIEWPORT */
-
+ // Check if one-to-one correspondence between ORIG and VIEWPORT
map->one_to_one = (map->orig_x_size == map->viewport_x) && (map->orig_y_size == map->viewport_y);
- /* Initialize panning parameters */
-
+ // Initialize panning parameters
pan = !map->one_to_one;
map->pan_x = pan;
@@ -240,8 +233,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
buffer_fill(*picture, 0xff);
}
- /* Get a temporary buffer to load tiles into */
-
+ // Get a temporary buffer to load tiles into
if (tile_type == TILE_PICTURE) {
buffer_init_name(&tile_buffer, tile_resource->tile_x, tile_resource->tile_y, "$t-load$");
} else {
@@ -252,8 +244,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
goto done;
}
- /* Load tile file offset list */
-
+ // Load tile file offset list
tile_space = (((long)tile_resource->num_tiles) * sizeof(Tile));
if (tile_space) {
@@ -278,8 +269,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
dest->file_offset = src.readSint32LE();
}
- /* For background pictures, load color lists and allocate palette space */
-
+ // For background pictures, load color lists and allocate palette space
if (tile_type == TILE_PICTURE) {
if (color_list != NULL) my_color_list = color_list;
if (cycle_list != NULL) my_cycle_list = cycle_list;
@@ -365,16 +355,14 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
tile_resource->color_handle = color_handle;
- /* Compute size in bytes of a single tile */
-
+ // Compute size in bytes of a single tile
if (tile_type == TILE_PICTURE) {
tile_resource->chunk_size = (long)tile_resource->tile_x * (long)tile_resource->tile_y;
} else {
tile_resource->chunk_size = ((((long)tile_resource->tile_x - 1) >> 1) + 1) * (long)tile_resource->tile_y;
}
- /* Allocate flat tile store for panning maps */
-
+ // Allocate flat tile store for panning maps
if (!map->one_to_one) {
delete[] tile_resource->tile_data;
tile_resource->tile_data = new byte[(long)tile_resource->num_tiles * tile_resource->chunk_size]();
@@ -384,7 +372,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
}
}
- /* Get current (base) position in file */
+ // Get current (base) position in file
if (memory_mode == LOADER_DISK) {
base_position = load_handle.handle->pos();
} else {
@@ -394,8 +382,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
}
}
- /* Load tile data into memory */
-
+ // Load tile data into memory
for (count = 0; count < tile_resource->num_tiles; count++) {
switch (memory_mode) {
case LOADER_XMS:
@@ -411,8 +398,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
case LOADER_DISK:
default:
- /* Set to appropriate file position */
-
+ // Set to appropriate file position
if (count < (tile_resource->num_tiles - 1)) {
compressed_size = tile[count + 1].file_offset - tile[count].file_offset;
} else {
@@ -423,8 +409,7 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
pack_strategy = tile_resource->compression;
packing_flag = (pack_strategy != PACK_NONE) ? PACK_EXPLODE : PACK_RAW_COPY;
- /* Unpack the tile data */
-
+ // Unpack the tile data
if (packing_flag == PACK_EXPLODE) {
decompress_buffer = (byte *)mem_get_name(compressed_size, "$tilpack");
if (decompress_buffer != NULL) {
@@ -458,15 +443,13 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
break;
}
- /* Translate color information for background pictures */
-
+ // Translate color information for background pictures
if (tile_type == TILE_PICTURE) {
color_buffer_list_to_main(my_color_list, &tile_buffer);
}
- /* If a one-to-one map, just draw the tile into the ORIG buffer; */
- /* if a panning map, copy tile into proper EMS page. */
-
+ // If a one-to-one map, just draw the tile into the ORIG buffer;
+ // if a panning map, copy tile into proper EMS page.
if (map->one_to_one) {
if (tile_type == TILE_PICTURE) {
x_size = map->tile_x_size;
@@ -492,13 +475,11 @@ int tile_load(const char *base, int tile_type, TileResource *tile_resource,
}
}
- /* Store some pointers so we won't have to pass them around separately */
-
+ // Store some pointers so we won't have to pass them around separately
map->resource = tile_resource;
map->buffer = picture;
- /* Store total size so we won't have to multiply it out over and over */
-
+ // Store total size so we won't have to multiply it out over and over
map->total_x_size = map->num_x_tiles * map->tile_x_size;
map->total_y_size = map->num_y_tiles * map->tile_y_size;
diff --git a/engines/mads/madsv2/core/vocab.cpp b/engines/mads/madsv2/core/vocab.cpp
index 7eea99fb4d2..856f0fecb1f 100644
--- a/engines/mads/madsv2/core/vocab.cpp
+++ b/engines/mads/madsv2/core/vocab.cpp
@@ -276,7 +276,7 @@ int vocab_write_file(const char *last_word) {
}
void vocab_report_error(int number) {
- char temp_buf_1[80], temp_buf_2[80], temp_buf_3[80];
+ char temp_buf_1[80], temp_buf_2[80];
int dos_flag;
dos_flag = false;
@@ -542,7 +542,7 @@ void vocab_maint_exec() {
} else {
Common::strcpy_s(word_buf, dialog_read_list(dialog, word_item));
- /* _fstrlwr (word_buf); */
+ // _fstrlwr (word_buf);
fileio_purge_trailing_spaces(word_buf);
vocab_code = vocab_get_code(word_buf);
@@ -650,26 +650,26 @@ char *vocab_string(int vocab_id) {
int bx = vocab_id - 1;
if (bx != 0) {
- /* Search for the bx-th null terminator to find the bx-th string.
- repne scasb scans forward decrementing cx; if cx hits zero before
- finding the null, the id is out of range and we fall back to the
- first string. */
+ // Search for the bx-th null terminator to find the bx-th string.
+ // repne scasb scans forward decrementing cx; if cx hits zero before
+ // finding the null, the id is out of range and we fall back to the
+ // first string.
int cx = vocab_size;
while (bx > 0) {
- /* Find next null terminator */
+ // Find next null terminator
while (cx > 0 && *p != '\0') {
p++;
cx--;
}
if (cx == 0)
- return vocab_text; /* aint_got_it: out of range, return first */
- p++; /* step past the null */
+ return vocab_text; // aint_got_it: out of range, return first
+ p++; // step past the null
cx--;
bx--;
}
}
- return p; /* got_it */
+ return p; // got_it
}
} // namespace MADSV2
diff --git a/engines/mads/madsv2/core/window.cpp b/engines/mads/madsv2/core/window.cpp
index 3cd13b33d12..233f838ea8a 100644
--- a/engines/mads/madsv2/core/window.cpp
+++ b/engines/mads/madsv2/core/window.cpp
@@ -449,13 +449,12 @@ void window_title(WindowPtr window, const char *title, int title_color, int back
begin_x = center_x - ((strlen(title) + 2) / 2);
Common::strcpy_s(temp, " ");
- /* temp[0] = (byte)((title_color == background_color) ? right_join : ' '); */
-
+ // temp[0] = (byte)((title_color == background_color) ? right_join : ' ');
begin_x = screen_put(temp, title_color, title_color, begin_x, window->ul_y);
begin_x = screen_put(title, title_color, title_color, begin_x, window->ul_y);
- /* temp[0] = (byte)((title_color == background_color) ? left_join : ' '); */
+ // temp[0] = (byte)((title_color == background_color) ? left_join : ' ');
begin_x = screen_put(temp, title_color, title_color, begin_x, window->ul_y);
mouse_show();
@@ -639,10 +638,10 @@ void window_draw_box(WindowPtr window, int type) {
break;
default:
- return; /* Invalid line type */
+ return; // Invalid line type
};
- window_line_type = type; /* Set global for reference by other procs */
+ window_line_type = type; // Set global for reference by other procs
orig = screen + screen_char_add(window->ul_x, window->ul_y);
xsize = window->lr_x - window->ul_x + 1;
@@ -671,9 +670,9 @@ void window_draw_box(WindowPtr window, int type) {
}
}
-/*
-/* main interrupt 21 write string server
-*/
+/**
+ * main interrupt 21 write string server
+ */
static void window_server(void) {
error("TODO: window_server");
}
Commit: 8a0f5d4f89613996bf6200a780123d21eb00c219
https://github.com/scummvm/scummvm/commit/8a0f5d4f89613996bf6200a780123d21eb00c219
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-04-21T17:31:10+10:00
Commit Message:
MADS: PHANTOM: sprite_0.cpp comments cleanup
Changed paths:
engines/mads/madsv2/core/sprite_0.cpp
diff --git a/engines/mads/madsv2/core/sprite_0.cpp b/engines/mads/madsv2/core/sprite_0.cpp
index b66690fea56..0d90e887cf3 100644
--- a/engines/mads/madsv2/core/sprite_0.cpp
+++ b/engines/mads/madsv2/core/sprite_0.cpp
@@ -1,73 +1,63 @@
/*
-/* sprite_0.c by Brian Reynolds 24-Jul-91
-/*
-/* Master sprite draw include file. Include as main body of each
-/* desired sprite routine, defining macros as appropriate to generate
-/* the correct algorithm:
-/*
-/* Set "three_d" to true for 3d depth coding
-/* Set "bresenham" to true for Bresenham scaling
-/* Set "packed_attr" to true for packed attribute screen (PANNING rooms)
-/* Set "translate" to true for 16 color translation version
-/*
-/* Set "interface" to true for special interface version (exclusive
-/* of all other options)
-/*
-/* Define "attribute" to draw to attribute page (in depth code) instead.
-/* Define "monodraw" to draw in monochrome color
-/*
-/* Define "on_black" to draw only on top of "zero" pixels.
-/*
-/* If "packed_attr" is true, then "three_d" MUST be true also.
-/*
-/* Parameters required:
-/*
-/* NAME TYPE USAGE DESCRIPTION
-/* ===================================================================
-/* series SeriesPtr (all) Series handle
-/* id int (all) Sprite #
-/* buf buffer * (all) Target buffer
-/* target_x int (all) Sprite base X
-/* target_y int (all) Sprite base Y
-/*
-/* attr buffer * (three_d) Attribute Buffer
-/* target_depth int (three_d) Sprite depth code
-/*
-/* view_port_x int (packed_attr) Work/Orig X mapping
-/* view_port_y int (packed_attr) Work/Orig Y mapping
-/*
-/* scale_factor int (bresenham) Scale % size (10-100)
-/*
-/* <Set high bit of sprite "id" for mirror imaging>
-/*
-/*
-/* DRAW ROUTINES three_d packattr bres. trans.
-/* ====================================================================
-/* sprite_draw() - - - -
-/* sprite_draw_3d() * - - -
-/* sprite_draw_3d_scaled() * - * -
-/* sprite_draw_3d_big() * * - -
-/* sprite_draw_3d_scaled_big() * * * -
-/* sprite_draw_x16() - - - *
-/* sprite_draw_3d_x16() * - - *
-/* sprite_draw_3d_scaled_x16() * - * *
-/* sprite_draw_3d_big_x16() * * - *
-/* sprite_draw_3d_scaled_big_x16() * * * *
-/*
-/* sprite_draw_interface()
-/*
-/*
-/* INCLUDE FILES REQUIRED:
-/* #include <stdlib.h> /* Bresenham only */
-/* #include <general.mac>
-/* #include <color.mac>
-/* #include "sprite.mac"
-/*
-*/
+ * Master sprite draw include file. Include as main body of each
+ * desired sprite routine, defining macros as appropriate to generate
+ * the correct algorithm:
+ *
+ * Set "three_d" to true for 3d depth coding
+ * Set "bresenham" to true for Bresenham scaling
+ * Set "packed_attr" to true for packed attribute screen (PANNING rooms)
+ * Set "translate" to true for 16 color translation version
+ *
+ * Set "interface" to true for special interface version (exclusive
+ * of all other options)
+ *
+ * Define "attribute" to draw to attribute page (in depth code) instead.
+ * Define "monodraw" to draw in monochrome color
+ *
+ * Define "on_black" to draw only on top of "zero" pixels.
+ *
+ * If "packed_attr" is true, then "three_d" MUST be true also.
+ *
+ * Parameters required:
+ *
+ * NAME TYPE USAGE DESCRIPTION
+ * ===================================================================
+ * series SeriesPtr (all) Series handle
+ * id int (all) Sprite #
+ * buf buffer * (all) Target buffer
+ * target_x int (all) Sprite base X
+ * target_y int (all) Sprite base Y
+ *
+ * attr buffer * (three_d) Attribute Buffer
+ * target_depth int (three_d) Sprite depth code
+ *
+ * view_port_x int (packed_attr) Work/Orig X mapping
+ * view_port_y int (packed_attr) Work/Orig Y mapping
+ *
+ * scale_factor int (bresenham) Scale % size (10-100)
+ *
+ * <Set high bit of sprite "id" for mirror imaging>
+ *
+ *
+ * DRAW ROUTINES three_d packattr bres. trans.
+ * ====================================================================
+ * sprite_draw() - - - -
+ * sprite_draw_3d() * - - -
+ * sprite_draw_3d_scaled() * - * -
+ * sprite_draw_3d_big() * * - -
+ * sprite_draw_3d_scaled_big() * * * -
+ * sprite_draw_x16() - - - *
+ * sprite_draw_3d_x16() * - - *
+ * sprite_draw_3d_scaled_x16() * - * *
+ * sprite_draw_3d_big_x16() * * - *
+ * sprite_draw_3d_scaled_big_x16() * * * *
+ *
+ * sprite_draw_interface()
+ */
/*
-/* Filter out illegal compile combinations
-*/
+ * Filter out illegal compile combinations
+ */
#if packed_attr
#if !three_d
@@ -89,8 +79,8 @@
/*
-/* Local variables common to all versions
-*/
+ * Local variables common to all versions
+ */
byte *sprite_ptr;
byte *target_ptr;
@@ -114,8 +104,8 @@ byte *attr_ptr;
#define huge_code (packed_attr && translate)
/*
-/* Local variables for "packed_attr" large attribute screens
-*/
+ * Local variables for "packed_attr" large attribute screens
+ */
#if packed_attr
int attr_wrap;
@@ -123,8 +113,8 @@ int attr_start;
#endif
/*
-/* Local variables for "bresenham" sprite scaling
-*/
+ * Local variables for "bresenham" sprite scaling
+ */
#if bresenham
#define max_bresenham_entries 320
@@ -134,8 +124,8 @@ int temp_x, temp_y;
#endif
/*
-/* Local variables for "translate" 16 color thatching translations
-*/
+ * Local variables for "translate" 16 color thatching translations
+ */
#if translate
byte thatch_base;
@@ -143,19 +133,20 @@ byte thatch_flag;
#endif
/*
-/* In certain configurations, the main draw routine does not need
-/* all of the registers for computations; for those variations,
-/* certain commonly used variables (skip_x & stop_x) are aliased
-/* for clarity. These were originally aliased to CPU registers.
-*/
+ * In certain configurations, the main draw routine does not need
+ * all of the registers for computations; for those variations,
+ * certain commonly used variables (skip_x & stop_x) are aliased
+ * for clarity. These were originally aliased to CPU registers.
+ */
/* SKIP_X and STOP_X were originally aliased to registers (cx, di)
- in certain configurations to save memory accesses. In C they are
- always the plain variables. */
+ * in certain configurations to save memory accesses. In C they are
+ * always the plain variables.
+ */
#define SKIP_X skip_x
#define STOP_X stop_x
- /* Get maximum clipping coordinates */
+/* Get maximum clipping coordinates */
max_x = buf->x - 1;
max_y = buf->y - 1;
@@ -196,12 +187,12 @@ ys = sprite->ys;
#endif
/*
-/* BRESENHAM TABLE
-/*
-/* Generate a Bresenham table useable for both X and Y checks.
-/* Each entry is true if that source pixel maps to a drawn pixel
-/* at the given scale factor.
-*/
+ * BRESENHAM TABLE
+ *
+ * Generate a Bresenham table useable for both X and Y checks.
+ * Each entry is true if that source pixel maps to a drawn pixel
+ * at the given scale factor.
+ */
#if bresenham
{
@@ -234,11 +225,11 @@ ys = sprite->ys;
/*
-/* SPRITE CLIPPING
-/*
-/* Clip the sprite into the target buffer's boundaries.
-/* Generates skip_x, skip_y, draw_x, draw_y, stop_x, stop_y.
-*/
+ * SPRITE CLIPPING
+ *
+ * Clip the sprite into the target buffer's boundaries.
+ * Generates skip_x, skip_y, draw_x, draw_y, stop_x, stop_y.
+ */
/* X clipping */
{
@@ -309,14 +300,14 @@ ys = sprite->ys;
/*
-/* POINTER SETUP
-/*
-/* Compute the flat starting offset into target (and attr) buffers,
-/* accounting for target_y rows and target_x+skip_x columns.
-/* The original code used 16-bit real-mode segment:offset arithmetic
-/* with 32k wrap-around tricks; in a flat memory model we simply use
-/* integer offsets.
-*/
+ * POINTER SETUP
+ *
+ * Compute the flat starting offset into target (and attr) buffers,
+ * accounting for target_y rows and target_x+skip_x columns.
+ * The original code used 16-bit real-mode segment:offset arithmetic
+ * with 32k wrap-around tricks; in a flat memory model we simply use
+ * integer offsets.
+ */
#if translate
{
@@ -353,24 +344,24 @@ ys = sprite->ys;
/*
-/* MAIN DRAW LOOP
-/*
-/* Processes the sprite stream row by row.
-/*
-/* draw_y_pos - vertical draw counter (counts pixels actually drawn/clipped,
-/* excluding Bresenham-squeezed rows)
-/* scan_y - vertical scan counter for Bresenham (indexes bresenham_table)
-/* target_row - pointer to start of current target row
-/* attr_row - pointer to start of current attr row (packed_attr only)
-/*
-/* Per row:
-/* draw_x_pos - horizontal draw counter
-/* scan_x - horizontal scan counter for Bresenham
-/* run_count - RLE run counter
-/* sprite_byte - current byte read from sprite stream
-/* depth_code - depth of current sprite pixel (three_d only)
-/* draw_depth - depth at which we are drawing (three_d only)
-*/
+ * MAIN DRAW LOOP
+ *
+ * Processes the sprite stream row by row.
+ *
+ * draw_y_pos - vertical draw counter (counts pixels actually drawn/clipped,
+ * excluding Bresenham-squeezed rows)
+ * scan_y - vertical scan counter for Bresenham (indexes bresenham_table)
+ * target_row - pointer to start of current target row
+ * attr_row - pointer to start of current attr row (packed_attr only)
+ *
+ * Per row:
+ * draw_x_pos - horizontal draw counter
+ * scan_x - horizontal scan counter for Bresenham
+ * run_count - RLE run counter
+ * sprite_byte - current byte read from sprite stream
+ * depth_code - depth of current sprite pixel (three_d only)
+ * draw_depth - depth at which we are drawing (three_d only)
+ */
{
/* Absolute starting skip_x, adjusted for mirror direction */
Commit: 61764e4b3d6b9e4db122561161191fff4ad0721f
https://github.com/scummvm/scummvm/commit/61764e4b3d6b9e4db122561161191fff4ad0721f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-04-21T17:36:24+10:00
Commit Message:
MADS: PHANTOM: pfab pointer fixes
Changed paths:
engines/mads/madsv2/core/pack.h
engines/mads/madsv2/core/pfab.cpp
diff --git a/engines/mads/madsv2/core/pack.h b/engines/mads/madsv2/core/pack.h
index 923a092a62d..995261970d0 100644
--- a/engines/mads/madsv2/core/pack.h
+++ b/engines/mads/madsv2/core/pack.h
@@ -177,7 +177,7 @@ extern word (*pack_pFABexp2_routine)(
extern byte *pack_special_buffer;
-extern void (*(pack_special_function))();
+extern void (*pack_special_function)();
extern word pack_read_memory(char *buffer, word *size);
diff --git a/engines/mads/madsv2/core/pfab.cpp b/engines/mads/madsv2/core/pfab.cpp
index 3f052d802ec..4abec62e8ad 100644
--- a/engines/mads/madsv2/core/pfab.cpp
+++ b/engines/mads/madsv2/core/pfab.cpp
@@ -146,7 +146,7 @@ static unsigned comp_work_size(void) {
* Obtain aligned pointer to CompWork inside work_buff.
*/
static CompWork *get_comp_work(char *work_buff) {
- unsigned long addr = (unsigned long)(byte *)work_buff;
+ intptr addr = (intptr)(byte *)work_buff;
addr = (addr + 15u) & ~15u;
return (CompWork *)(byte *)addr;
}
@@ -246,8 +246,8 @@ static unsigned rb_in(CompWork *w) {
* @param di
*/
static void dict_link(CompWork *w, unsigned di) {
- unsigned word = w->lempel[di] | ((unsigned)w->lempel[(di + 1) & (LEMPEL - 1)] << 8);
- unsigned key = (word & (HASH - 1)) + LEMPEL + 1; // key index
+ unsigned dictWord = w->lempel[di] | ((unsigned)w->lempel[(di + 1) & (LEMPEL - 1)] << 8);
+ unsigned key = (dictWord & (HASH - 1)) + LEMPEL + 1; // key index
unsigned di2 = di; // word index = di
unsigned bx = w->hash[key];
More information about the Scummvm-git-logs
mailing list