Word Unperfect
public
Read
Owner: themaster
Branch: main
Commits: 0
Git CLI clone URL
git clone https://www.xt-emporium.com/git/word-unperfect.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
word-unperfect
/
rev
/
wp_layout_shared.h
File editor
#ifndef WP_LAYOUT_SHARED_H #define WP_LAYOUT_SHARED_H #include "wp_host_compat.h" /* Extracted subsystem slices from decompiled_wp_exe.c. * Layout globals were originally modeled as absolute linear addresses (DOS data * segment offsets). They are now fields of WpLayoutGlobals; pass * WpLayoutGlobals *wl into extracted subsystem entrypoints. For the monolith, * include wp_layout_legacy_macros.h to map g_layout_* / g_parser_* to g_wp_layout. * * Original Ghidra linear addresses are kept in comments on each field. */ /* Packed record views: use #pragma pack for Open Watcom (no GCC __attribute__). */ #pragma pack(push, 1) typedef struct LayoutStateRecordHeader { undefined2 tag0; undefined2 tag1; undefined2 record_type; undefined2 carry_width; undefined2 wrap_value; undefined2 pending_offset; byte pending_level; byte extra_byte; byte state_flags; byte mode_flags; byte mode_flags_2; byte restore_flags; undefined2 pending_total; undefined2 primary_limit; undefined2 secondary_limit; undefined2 primary_origin; undefined2 secondary_origin; } LayoutStateRecordHeader; typedef struct LayoutStateSnapshot { undefined2 pending_offset; undefined2 pending_level; undefined2 primary_limit; undefined2 secondary_limit; undefined2 primary_origin; undefined2 secondary_origin; } LayoutStateSnapshot; typedef struct LayoutPendingSpanRecord { undefined2 tag0; undefined2 tag1; undefined2 record_type; undefined2 span_a; undefined2 span_b; undefined2 carry_width; } LayoutPendingSpanRecord; typedef struct LayoutRecordEnvelopeHeader { undefined2 tag; undefined2 byte_length; } LayoutRecordEnvelopeHeader; #pragma pack(pop) /* 0x4b2e and 0x4b0b were aliased int / pointer in the 16-bit image; keep one * intptr_t word per cursor and view it as int-like offset or as a pointer. */ typedef union WpNearPtrWord { intptr_t word; undefined2 *as_record_p; undefined *as_secondary_p; } WpNearPtrWord; /* 0x5b27: decomp used both a 16-bit word and a char* slot at the same linear cell. */ typedef union WpOverlayCell5b27 { undefined2 as_u16; char *as_lpstr; } WpOverlayCell5b27; /* 0x7902: IRQ/timer byte and 16-bit stack copy alias the same linear cell. */ typedef union WpIrqTimer7902 { char as_char; undefined2 as_u16; } WpIrqTimer7902; #define irq_timer_7902_char irq_timer_7902.as_char #define irq_timer_7902_u16 irq_timer_7902.as_u16 typedef union WpPack7264 { undefined2 as_u16; byte as_byte; } WpPack7264; /* Not packed: host code takes addresses of nested snapshots and cursors. */ typedef struct WpLayoutGlobals { char parse_depth_counter; /* 0x16c */ char feature_enabled; /* 0x503b */ int explicit_span_total; /* 0x503c */ uint measure_compare_word_50b2; /* 0x50b2 */ int measured_span_total; /* 0x50b4 */ byte runtime_flags; /* 0x50b9 */ int carry_width; /* 0x51ca */ byte status_dirty_flags; /* 0x4974 */ byte render_dirty_flags; /* 0x4975 */ byte status_extend_4976; /* 0x4976 */ undefined2 status_stream_word_4985; /* 0x4985 */ int status_stream_gate_4987; /* 0x4987 */ undefined2 default_span_a; /* 0x4bd2 */ undefined2 default_span_b; /* 0x4bd4 */ byte record_heap_flags_4bd6; /* 0x4bd6 */ uint record_buffer_space; /* 0x4b2a */ WpNearPtrWord primary_record; /* 0x4b2e int / undefined2 ** */ uint record_stream_offset_low; /* 0x4b30 */ uint record_stream_offset_high; /* 0x4b32 */ uint cursor; /* 0x4b36 */ uint measure_extent_50c8; /* 0x50c8 — layout measure / gate extent */ uint cursor_window; /* 0x4b38 */ uint line_start; /* 0x4b3a */ undefined2 secondary_origin; /* 0x4b48 */ undefined2 primary_origin; /* 0x4b4a */ undefined2 record_offset_checkpoint_4b4c; /* 0x4b4c */ undefined2 pending_total; /* 0x4b53 */ int running_wrap_total; /* 0x4b56 */ undefined2 wrap_value; /* 0x4b58 */ WpNearPtrWord secondary_record; /* 0x4b0b int / undefined ** */ undefined2 primary_limit; /* 0x4dc1 */ undefined2 secondary_limit; /* 0x4dc3 */ undefined2 variant_origin_extra_4dbe; /* 0x4dbe */ byte restore_control_flags; /* 0x4e47 */ byte stream_update_gate_5205; /* 0x5205 */ byte state_flags; /* 0x5207 */ undefined2 pending_offset; /* 0x5208 */ union { undefined2 word; /* 0x520a */ byte bytes[2]; /* low byte == legacy pending_level_byte */ } pending_level; /* 0x520a */ union { struct { uint remaining_low; /* 0x5219 */ uint remaining_high; /* 0x521b */ } remaining; struct { undefined2 lo_u16; /* 0x5219 */ undefined2 hi_u16; /* 0x521b */ } u16; } position_gate; #define position_gate_remaining_low position_gate.remaining.remaining_low #define position_gate_remaining_high position_gate.remaining.remaining_high #define position_gate_lo_u16 position_gate.u16.lo_u16 #define position_gate_hi_u16 position_gate.u16.hi_u16 byte variant_flags; /* 0x5221 */ char active_variant_index; /* 0x5226 */ byte measured_span_total_flags; /* 0x5211 */ char variant_count; /* 0x5287 */ undefined2 variant_limit; /* 0x5288 */ undefined2 saved_wrap_value; /* 0x528a */ undefined2 variant_live_limit; /* 0x528c */ uint variant_cached_limit; /* 0x528e */ byte variant_runtime_flags; /* 0x4be9 */ int variant_checkpoint; /* 0x4bea */ int variant_total; /* 0x53f2 */ undefined2 variant_anchor; /* 0x53f4 */ undefined2 measured_span_a; /* 0x53a9 */ undefined2 measured_span_b; /* 0x53ab */ byte measured_span_flags; /* 0x53ad */ undefined2 measured_span_cursor; /* 0x53ae */ undefined2 measured_span_shadow; /* 0x53b0 */ byte measured_span_dirty_flags; /* 0x53b2 */ int processed_segments; /* 0x53b9 */ char update_depth; /* 0x53bb */ undefined2 record_extension_buffer_segment; /* 0x53dc */ undefined *record_extension_buffer; /* 0x53de (decomp typed **; walk uses *) */ byte record_extension_block_capacity; /* 0x53e3 */ byte record_extension_block_count; /* 0x53e4 */ char record_extension_needs_flush; /* 0x53e5 */ byte record_extra_byte; /* 0x53fe */ char restore_mode; /* 0x53fa */ byte restore_flags; /* 0x53fd */ byte record_mode_flags; /* 0x5400 */ byte record_mode_flags_2; /* 0x5401 */ undefined2 stream_resume_token; /* 0x5404 */ int record_used_bytes; /* 0x51c6 */ byte emit_flags; /* 0x51ef */ char postprocess_mode; /* 0x51f0 */ char record_replay_depth; /* 0x51c1 */ byte parser_runtime_flags; /* 0x51cf */ uint record_block_index; /* 0x5438 */ int secondary_record_used_bytes; /* 0x54af */ uint secondary_record_block_index; /* 0x54a7 */ int secondary_record_stream_gate_54a9; /* 0x54a9 */ byte secondary_stream_flags_54a6; /* 0x54a6 */ byte variant_shadow_flags_66b8; /* 0x66b8 */ byte variant_anchor_flags; /* 0x66b9 */ byte parse_dirty_flags; /* 0x66c0 */ byte decode_io_flags_8749; /* 0x8749 */ char layout_counter_531c; /* 0x531c */ byte parser_reentry_guard; /* 0x7969 */ LayoutStateSnapshot saved_snapshot; /* was 0x531a */ uint emit_record_line_extent; /* 0x4b3c — layout_emit_or_measure_line_window / parser window */ undefined2 emit_record_scratch_5031; /* 0x5031 */ undefined2 emit_record_scratch_5033; /* 0x5033 */ undefined2 emit_record_carry_scratch_7dc1; undefined2 emit_record_carry_scratch_7dc3; undefined2 emit_record_carry_scratch_7dc5; undefined2 emit_record_carry_scratch_7dc7; int emit_record_carry_scratch_7dc9; /* Legacy DS cells migrated from raw *(T *)0x… in parser / metrics paths */ int record_aux_4b34; /* 0x4b34 */ undefined2 record_wide_temp_lo_4b26; /* 0x4b26 */ undefined2 record_wide_temp_hi_4b28; /* 0x4b28 */ undefined2 cursor_alias_shadow_4b3e; /* 0x4b3e */ byte record_cursor_mode_4b78; /* 0x4b78 */ int record_cursor_metric_4b79; /* 0x4b79 */ int record_accum_cap_4c4a; /* 0x4c4a */ undefined record_aux_flag_4bfb; /* 0x4bfb */ uint measure_extent_bound_50c6; /* 0x50c6 */ byte line_parse_gate_flags_4b52; /* 0x4b52 */ int heap_chain_checkpoint_4bec; /* 0x4bec */ byte heap_control_flags_4bf1; /* 0x4bf1 */ int heap_aux_int_4bf2; /* 0x4bf2 */ undefined2 span_aux_word_53f6; /* 0x53f6 */ undefined2 line_build_word_51f1; /* 0x51f1 */ undefined2 line_build_word_51f3; /* 0x51f3 */ undefined2 line_build_word_51f5; /* 0x51f5 */ undefined2 line_build_word_51f7; /* 0x51f7 */ undefined2 line_build_word_51f9; /* 0x51f9 */ byte irq_driver_state[256]; /* 0x7800 — IRQ / driver scratch region */ byte irq_driver_scratch_7820; /* 0x7820 (aliased into state) */ byte machine_flags_bios_9a1; /* 0x9a1 */ int pending_compact_counter_520a; /* 0x520a — int view used by parser */ uint span_scale_q8_5039; /* 0x5039 */ int span_width_adj_5041; /* 0x5041 */ int span_width_adj_5043; /* 0x5043 */ /* PSP / low linear region (IVT+PSP) and misc decomp cells */ byte psp_io_flags_016b; /* 0x16b */ byte ivt_psp_byte_0036; /* 0x36 — decomp *(byte*)0x36 flag tests */ byte decode_state_byte_0008; /* 0x8 — parse/scanner state */ byte decode_flags_byte_000b; /* 0xb — transient flags */ WpNearPtrWord decode_slot_000c; /* 0xc — int* / word alias */ WpNearPtrWord decode_slot_0006; /* 0x6 */ WpNearPtrWord decode_slot_0009; /* 0x9 */ WpNearPtrWord decode_slot_000e; /* 0xe */ WpNearPtrWord decode_slot_0012; /* 0x12 */ WpNearPtrWord decode_slot_0014; /* 0x14 */ WpNearPtrWord decode_slot_0061; /* 0x61 */ byte decode_slot_byte_005f; /* 0x5f */ byte decode_slot_byte_0060; /* 0x60 */ byte decode_slot_byte_0067; /* 0x67 */ WpNearPtrWord decode_slot_0000; /* 0x0 — decomp linear (not (T*)0 null) */ byte decode_io_port_0005; /* 0x5 — out() port cell */ WpNearPtrWord decode_slot_0002; /* 0x2 — int / byte** alias */ WpNearPtrWord decode_slot_0003; /* 0x3 */ WpNearPtrWord decode_slot_0004; /* 0x4 */ WpNearPtrWord decode_slot_000f; /* 0xf */ WpNearPtrWord decode_slot_0017; /* 0x17 */ WpNearPtrWord decode_slot_0069; /* 0x69 */ WpNearPtrWord decode_slot_7e4f; /* 0x7e4f */ byte decode_slot_byte_0010; /* 0x10 */ byte decode_slot_byte_0037; /* 0x37 */ byte decode_slot_byte_005e; /* 0x5e */ byte decode_slot_byte_0075; /* 0x75 */ char layout_refcount_44c6; /* 0x44c6 */ int video_rows_minus_one_44dc; /* 0x44dc — BIOS / mode lines scratch */ uint metrics_window_base_50ba; /* 0x50ba */ uint metrics_window_limit_50bc; /* 0x50bc */ uint emit_gate_mask_51bf; /* 0x51bf */ int scale_fixed_point_51c4; /* 0x51c4 */ int variant_balance_51bd; /* 0x51bd */ uint span_compare_word_51fb; /* 0x51fb */ uint span_compare_word_51ff; /* 0x51ff */ int span_metric_delta_4bd8; /* 0x4bd8 */ int span_metric_delta_4bda; /* 0x4bda */ uint measure_extent_cap_50be; /* 0x50be */ byte span_band_low_5046; /* 0x5046 */ byte span_band_high_5049; /* 0x5049 */ uint record_path_mask_51c2; /* 0x51c2 */ int record_variant_gate_51c8; /* 0x51c8 */ int record_stream_cursor_543a; /* 0x543a */ int record_stream_cursor_highwater_496c; /* 0x496c */ undefined2 record_window_word_502d; /* 0x502d */ undefined2 record_window_word_4b40; /* 0x4b40 */ int record_axis_base_4b44; /* 0x4b44 */ int record_axis_run_4b46; /* 0x4b46 */ byte record_stream_byte_4b10; /* 0x4b10 */ uint line_emit_flags_521d; /* 0x521d */ int metrics_line_accum_5037; /* 0x5037 */ char span_band_char_5047; /* 0x5047 */ byte span_band_aux_5048; /* 0x5048 */ int span_table_ofs_4bdc; /* 0x4bdc */ undefined2 span_table_word_a_4be0; /* 0x4be0 */ undefined2 span_table_word_b_4be2; /* 0x4be2 */ int display_metric_44de; /* 0x44de */ int display_metric_44e0; /* 0x44e0 */ int display_metric_44e2; /* 0x44e2 */ int display_metric_44e4; /* 0x44e4 */ char display_palette_guard_44ee; /* 0x44ee */ int display_segment_sel_44ef; /* 0x44ef */ int display_mode_field_44f1; /* 0x44f1 */ byte video_bios_option_4512; /* 0x4512 */ undefined2 bios_save_word_4356; /* 0x4356 */ int screen_extent_4741; /* 0x4741 */ byte graphics_xfer_flags_60e0; /* 0x60e0 */ char overlay_gate_char_5ad0; /* 0x5ad0 */ char overlay_busy_char_5ad1; /* 0x5ad1 */ uint overlay_pack_word_5ad5; /* 0x5ad5 */ byte overlay_scratch_5ad7[512]; /* 0x5ad7+ — format/overlay copy buffer (DOS-linear base) */ WpOverlayCell5b27 overlay_slot_5b27; /* 0x5b27 */ char video_slot_byte_5b79; /* 0x5b79 */ undefined2 video_bios_tag_66e; /* 0x66e */ WpNearPtrWord video_arg_slot_670; /* 0x670 — u16 / near-ptr alias */ byte video_ctrl_672; /* 0x672 */ byte video_ctrl_673; /* 0x673 */ byte video_ctrl_674; /* 0x674 */ int video_stride_bytes_67a; /* 0x67a */ uint video_extent_guard_67c; /* 0x67c */ undefined2 video_plane_size_lo_67e; /* 0x67e */ undefined2 video_plane_size_hi_680; /* 0x680 */ undefined2 video_saved_es_682; /* 0x682 */ undefined2 video_aux_word_684; /* 0x684 */ byte video_status_686; /* 0x686 */ byte format_overlay_flag_b10f; /* 0xb10f */ char stack_adj_counter_b16; /* 0xb16 */ byte rom_io_flags_c9e0; /* 0xc9e0 */ int rom_metric_c9e1; /* 0xc9e1 */ byte pack_xor_state_7265; /* 0x7265 */ char idle_gate_char_81f6; /* 0x81f6 */ char dos_char_01f5; /* 0x1f5 */ char scratch_char_0804; /* 0x804 */ char config_digit_1699; /* 0x1699 */ char config_digit_169b; /* 0x169b */ undefined2 decode_pair_b9d7; /* 0xb9d7 */ undefined2 decode_pair_b9d9; /* 0xb9d9 */ char counter_6f54; /* 0x6f54 */ byte flags_08c1; /* 0x8c1 */ undefined2 token_812c; /* 0x812c */ WpNearPtrWord ptr_slot_ca6f; /* 0xca6f */ uint heap_cursor_c5b4; /* 0xc5b4 */ int heap_extent_c5ae; /* 0xc5ae */ byte machine_flags_676c; /* 0x676c */ undefined2 save_word_81be; /* 0x81be */ byte scratch_byte_7eae; /* 0x7eae */ char gate_char_7eaf; /* 0x7eaf */ int decode_accum_0400; /* 0x400 */ char decode_accum_1401; /* 0x1401 */ undefined scratch_byte_9e9e; /* 0x9e9e */ uint compare_bound_411c; /* 0x411c */ uint emu_flags_ca6b; /* 0xca6b */ uint emu_flags_ca6d; /* 0xca6d */ WpNearPtrWord metrics_base_7e65; /* 0x7e65 */ int metrics_scratch_7e74; /* 0x7e74 */ byte irq_shadow_lo_7900; /* 0x7900 */ byte irq_shadow_hi_7901; /* 0x7901 */ WpIrqTimer7902 irq_timer_7902; /* 0x7902 */ char irq_state_7903; /* 0x7903 */ byte status_scratch_479f; /* 0x479f */ int startup_word_0142; /* 0x0142 */ char obfuscated_char_1cff; /* 0x1cff */ char obfuscated_char_36d0; /* 0x36d0 */ int modulo_slot_3efc; /* 0x3efc */ char shell_gate_418a; /* 0x418a */ byte shell_index_418c; /* 0x418c */ int variant_limit_c664; /* 0xc664 */ uint stream_flags_c546; /* 0xc546 */ int stream_lo_c52d; /* 0xc52d */ int stream_hi_c535; /* 0xc535 */ int dos_word_0148; /* 0x148 */ int dos_word_014c; /* 0x14c */ int dos_word_0160; /* 0x160 */ int dos_word_0162; /* 0x162 */ int dos_word_0164; /* 0x164 */ byte dos_byte_016a; /* 0x16a */ char dos_char_0179; /* 0x179 */ byte flags_0359; /* 0x359 */ char gate_char_0805; /* 0x805 */ int ivt_timer_ad0; /* 0xad0 */ undefined2 gate_shadow_7768; /* 0x7768 */ undefined2 gate_shadow_776a; /* 0x776a */ undefined2 gate_shadow_776c; /* 0x776c */ undefined2 gate_shadow_776e; /* 0x776e */ uint shift_reg_77fe; /* 0x77fe */ int stack_adjust_bae4; /* 0xbae4 */ WpNearPtrWord near_word_65e1; /* 0x65e1 */ int bios_token_81aa; /* 0x81aa */ undefined2 unwind_ss_bc44; /* 0xbc44 */ undefined2 unwind_hi_bc4e; /* 0xbc4e */ undefined2 unwind_lo_bc52; /* 0xbc52 */ char obf_char_28ff; /* 0x28ff */ char obf_char_2020; /* 0x2020 */ char obf_char_202e; /* 0x202e */ uint xor_key_2032; /* 0x2032 */ char parser_gate_5c05; /* 0x5c05 */ int stack_save_5c06; /* 0x5c06 */ byte parser_flags_49e8; /* 0x49e8 */ char fmt_gate_7ead; /* 0x7ead */ char stream_state_b9c6; /* 0xb9c6 */ byte irq_mask_08be; /* 0x8be */ uint table_base_4223; /* 0x4223 */ byte pack_hi_2d86; /* 0x2d86 */ byte video_flags_66c7; /* 0x66c7 */ int alloc_slot_69bb; /* 0x69bb */ int alloc_slot_69bd; /* 0x69bd */ WpPack7264 pack_slot_7264; /* 0x7264 */ WpNearPtrWord ivt_edge_fffe; /* 0xfffe — BIOS data / hook cell */ WpNearPtrWord near_ptr_slot_a3a3; /* 0xa3a3 — near pointer scratch */ WpNearPtrWord near_ptr_slot_cfa4; /* 0xcfa4 */ WpNearPtrWord near_ptr_slot_ffa4; /* 0xffa4 */ uint xor_const_2930; /* 0x2930 */ byte code_ctor_byte_a041; /* 0xa041 */ int env_word_03f9; /* 0x3f9 */ undefined2 psp_swap_012b; /* 0x12b */ undefined2 psp_swap_013d; /* 0x13d */ byte bios_flag_81ae; /* 0x81ae */ byte bios_flag_81af; /* 0x81af */ undefined2 bios_word_8134; /* 0x8134 */ undefined2 video_word_0676; /* 0x676 */ char video_gate_67b9; /* 0x67b9 */ undefined2 video_word_020b; /* 0x20b */ undefined2 io_port_arg_2b6e; /* 0x2b6e */ WpNearPtrWord ptr_slot_ca71; /* 0xca71 */ byte irq_misc_77ff; /* 0x77ff */ undefined2 stack_frame_7977; /* 0x7977 */ undefined2 stack_frame_7971; /* 0x7971 */ undefined2 stack_frame_796f; /* 0x796f */ int scale_factor_4b14; /* 0x4b14 */ int heap_delta_c5b6; /* 0xc5b6 */ char stream_char_ba6b; /* 0xba6b */ int stream_metric_66dc; /* 0x66dc */ byte stream_type_char_b9c3; /* 0xb9c3 */ int16_t bresenham_p1_c3ce; /* 0xc3ce */ int16_t bresenham_p2_c3d0; /* 0xc3d0 */ int16_t bresenham_p3_c3d2; /* 0xc3d2 */ int16_t bresenham_p4_c3d4; /* 0xc3d4 */ int16_t bresenham_aux_c3c6; /* 0xc3c6 */ int16_t bresenham_aux_c3c8; /* 0xc3c8 */ int16_t bresenham_aux_c3ca; /* 0xc3ca */ int16_t bresenham_aux_c3cc; /* 0xc3cc */ byte firmware_flag_b113; /* 0xb113 */ char table_type_char_c53f; /* 0xc53f */ } WpLayoutGlobals; /* Little-endian 32-bit overlay of pending_offset (0x5208) + pending_level (0x520a). */ static __inline uint32_t wp_pending_pair_le_5208(WpLayoutGlobals *wl) { uint32_t lo = (uint32_t)(uint16_t)wl->pending_offset; uint32_t hi = (uint32_t)(uint16_t)wl->pending_level.word; return lo | (hi << 16u); } static __inline void wp_store_pending_pair_le_5208(WpLayoutGlobals *wl, int32_t packed) { uint32_t u = (uint32_t)packed; wl->pending_offset = (undefined2)u; wl->pending_level.word = (undefined2)(u >> 16u); } static __inline int wp_span_word_as_int(undefined2 w) { return (int)(int16_t)(uint16_t)w; } #if !defined(__WATCOMC__) _Static_assert(sizeof(intptr_t) == sizeof(undefined2 *), "WpNearPtrWord must hold undefined2 *"); _Static_assert(sizeof(intptr_t) == sizeof(undefined *), "WpNearPtrWord must hold undefined *"); #endif #endif
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
main
Visibility
public
Your access
Read
Remote
None
File activity
View file history