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_state.c
File editor
#include <stdint.h> #include <stdbool.h> #include "wp_layout_state.h" #include "wp_layout_shared.h" #include "wp_record_stream.h" extern uint32_t __cdecl16near layout_apply_variant_carry_flow(WpLayoutGlobals *wl); extern void __cdecl16near check_layout_state_update_gate(WpLayoutGlobals *wl, uint8_t *in_CF); extern void __cdecl16near layout_record_wide_temp_lo_hi_route_stage_3(WpLayoutGlobals *wl); extern void __cdecl16near layout_table_search_or_scan(WpLayoutGlobals *wl); extern void __cdecl16near copy_layout_state_words_to_destination(WpLayoutGlobals *wl); extern void __cdecl16near layout_metric_word_adjust(WpLayoutGlobals *wl); extern uint8_t __cdecl16near engine_far_call_1094(WpLayoutGlobals *wl, uint16_t arg); extern uint16_t __cdecl16near layout_sub_metrics_line_accum_from_variant_anchor_and_total(WpLayoutGlobals *wl); void __cdecl16near restore_layout_state_snapshot_if_valid(WpLayoutGlobals *wl) { if (wl->wrap_value == wl->saved_wrap_value) { wl->saved_snapshot.primary_limit = wl->primary_limit; wl->saved_snapshot.secondary_limit = wl->secondary_limit; wl->saved_snapshot.primary_origin = wl->primary_origin; wl->saved_snapshot.secondary_origin = wl->secondary_origin; } } void __cdecl16near store_layout_state_snapshot(WpLayoutGlobals *wl) { wl->saved_wrap_value = wl->wrap_value; wl->saved_snapshot.pending_offset = wl->pending_offset; wl->saved_snapshot.pending_level = wl->pending_level.word; wl->saved_snapshot.primary_limit = wl->primary_limit; wl->saved_snapshot.secondary_limit = wl->secondary_limit; wl->saved_snapshot.primary_origin = wl->primary_origin; wl->saved_snapshot.secondary_origin = wl->secondary_origin; } void __cdecl16near call_2377_if_layout_state_gate_passes(WpLayoutGlobals *wl) { int iVar1; if ((wl->state_flags == '\x02') && (wl->feature_enabled != '\0')) { iVar1 = 0; if ((wl->variant_count != '\0') && ((wl->variant_flags & 0xc0) == 0)) { iVar1 = wl->variant_limit; } if (wl->carry_width == iVar1) { layout_apply_variant_carry_flow(wl); } } } uint16_t __cdecl16near increment_layout_state_update_depth(WpLayoutGlobals *wl) { uint16_t uVar1; uint8_t in_CF; bool bVar2; check_layout_state_update_gate(wl, &in_CF); if (!in_CF) { if ((((wl->state_flags & 2) != 0) && (wl->update_depth == 0)) && (bVar2 = false, (wl->runtime_flags & 0x82) == 0)) { layout_record_wide_temp_lo_hi_route_stage_3(wl); /* bVar2 = some_logic_here; // If we can determine how it was set */ if (bVar2) { uVar1 = wl->cursor - wl->line_start; if ((uVar1 <= wl->cursor_window) && ((uVar1 < wl->cursor_window) || (wl->cursor != wl->line_start))) { layout_table_search_or_scan(wl); } } } wl->update_depth = wl->update_depth + 1; } return 0; } void __cdecl16near append_layout_state_record(WpLayoutGlobals *wl, uint8_t al) { LayoutStateRecordHeader *record; uint8_t *puVar1; uint16_t *puVar2; uint8_t *puVar3; uint8_t cVar4; uint16_t uVar5; int iVar6; uint16_t *puVar7; uint8_t *puVar8; uint16_t *puVar9; if (wl->record_buffer_space < 0x800) { invoke_overlay_expand_primary_buffer(wl); } record = (LayoutStateRecordHeader *)wl->primary_record.as_record_p; record->tag0 = 0xd4; record->tag1 = 0xd4; record->record_type = 0x1600; record->carry_width = (uint16_t)wl->carry_width; record->wrap_value = wl->wrap_value; record->pending_offset = wl->pending_offset; record->pending_level = wl->pending_level.bytes[0]; record->extra_byte = wl->record_extra_byte; record->state_flags = wl->state_flags; record->mode_flags = wl->record_mode_flags; record->mode_flags_2 = wl->record_mode_flags_2; record->restore_flags = wl->restore_flags; record->pending_total = wl->pending_total; record->primary_limit = wl->primary_limit; record->secondary_limit = wl->secondary_limit; record->primary_origin = wl->primary_origin; record->secondary_origin = wl->secondary_origin; puVar9 = (uint16_t *)(record + 1); cVar4 = (uint8_t)wl->variant_count; if (((cVar4 != 0) && (cVar4 == (uint8_t)wl->active_variant_index)) && ((wl->variant_flags & 0xc0) == 0)) { *puVar9 = CONCAT11((cVar4 - 1) * 6 + 0x14, 1); copy_layout_state_words_to_destination(wl); copy_layout_state_words_to_destination(wl); copy_layout_state_words_to_destination(wl); puVar7 = (uint16_t *)record; puVar7[0xf] = wl->variant_limit; puVar7[0x10] = wl->saved_wrap_value; puVar9 = puVar7 + 0x12; puVar7[0x11] = wl->variant_anchor; *puVar9 = wl->variant_live_limit; puVar7 = (uint16_t *)&wl->saved_snapshot; for (iVar6 = 6; iVar6 != 0; iVar6--) { puVar9++; puVar2 = puVar7; puVar7++; *puVar9 = *puVar2; } } if (wl->record_extension_block_count != 0) { *(uint8_t *)puVar9 = 2; iVar6 = (int)wl->record_extension_block_count * 0x10; puVar3 = (uint8_t *)((uintptr_t)puVar9 + 3); *(uint16_t *)((uintptr_t)puVar9 + 1) = (uint16_t)iVar6 + 1; *puVar3 = wl->record_extension_block_count; puVar8 = (uint8_t *)wl->record_extension_buffer; for (; iVar6 != 0; iVar6--) { puVar3++; puVar1 = puVar8; puVar8++; *puVar3 = *puVar1; } } layout_finalize_record_envelope_commit(wl); } void __cdecl16near restore_layout_state_record(WpLayoutGlobals *wl, uint8_t al) { LayoutStateRecordHeader *record; uint8_t *pbVar1; uint16_t *puVar2; uint8_t bVar3; uint16_t uVar4; int iVar5; uint16_t uVar6; uint16_t uVar7; uint16_t *puVar8; uint8_t *pbVar9; uint16_t uVar10; int iVar11; uint16_t *puVar12; uint16_t *puVar13; bool bVar14; uint16_t record_len; if (wl->record_used_bytes < 4) { invoke_overlay_consume_record_stream(wl); } record_len = *(uint16_t *)(wl->primary_record.word - 4); if (wl->record_used_bytes < (int)record_len) { invoke_overlay_consume_record_stream(wl); record_len = *(uint16_t *)(wl->primary_record.word - 4); } iVar11 = wl->primary_record.word - record_len; record = (LayoutStateRecordHeader *)iVar11; puVar8 = (uint16_t *)(wl->primary_record.word - 4); iVar5 = (int)(int16_t)record->carry_width; if ((wl->restore_mode == 1) && ((wl->restore_control_flags & 8) != 0)) { iVar5 = (iVar5 - wp_span_word_as_int(wl->default_span_a)) - wp_span_word_as_int(wl->default_span_b); } wl->carry_width = iVar5; LOCK(); iVar5 = wl->wrap_value; wl->wrap_value = record->wrap_value; UNLOCK(); wl->running_wrap_total = wl->running_wrap_total - (iVar5 - wl->wrap_value); wl->pending_offset = record->pending_offset; wl->pending_level.word = (uint16_t)record->pending_level; if ((wl->restore_control_flags & 4) != 0) { wl->record_extra_byte = record->extra_byte; } wl->state_flags = record->state_flags; wl->record_mode_flags = record->mode_flags; wl->record_mode_flags_2 = record->mode_flags_2; wl->restore_flags = record->restore_flags; wl->pending_total = record->pending_total; wl->primary_limit = record->primary_limit; wl->secondary_limit = record->secondary_limit; wl->primary_origin = record->primary_origin; puVar12 = (uint16_t *)(record + 1); wl->secondary_origin = record->secondary_origin; if (puVar12 < puVar8) { if (*(uint8_t *)puVar12 == 1) { layout_metric_word_adjust(wl); layout_metric_word_adjust(wl); layout_metric_word_adjust(wl); wl->variant_limit = *(uint16_t *)(iVar11 + 0x1a); wl->saved_wrap_value = *(uint16_t *)(iVar11 + 0x1c); puVar12 = (uint16_t *)(iVar11 + 0x20); wl->variant_anchor = *(uint16_t *)(iVar11 + 0x1e); wl->variant_live_limit = *puVar12; puVar13 = (uint16_t *)&wl->saved_snapshot; for (iVar5 = 6; iVar5 != 0; iVar5--) { puVar12++; puVar2 = puVar13; puVar13++; *puVar2 = *puVar12; } } if ((puVar12 < puVar8) && (*(uint8_t *)puVar12 == 2)) { pbVar1 = (uint8_t *)((uintptr_t)puVar12 + 3); bVar3 = *pbVar1; wl->record_extension_block_count = bVar3; bVar14 = bVar3 < wl->record_extension_block_capacity; if ((wl->record_extension_block_capacity < bVar3) && (bVar3 = engine_far_call_1094(wl, 0x1000), bVar14)) { wl->record_extension_block_count = bVar3; } iVar5 = (int)bVar3 * 0x10; pbVar9 = (uint8_t *)wl->record_extension_buffer; do { pbVar1++; *pbVar9 = *pbVar1; pbVar9++; iVar5--; } while (iVar5 != 0); } } if (wl->variant_count == 0) { return; } uVar6 = 0; uVar10 = 0; while( true ) { iVar5 = (uVar10 / 2) + 1; if ((int8_t)iVar5 == (int8_t)wl->variant_count) break; uVar10 = iVar5 * 2; // NOTE: 0x52ea is likely a pointer to an array of variant limits in the original image. // In our project, it should probably be wl->variant_limits[iVar5]. // For now, I'll keep the offset math but it might need adjustment if variant_limits is moved. if (uVar6 < *(uint16_t *)(uVar10 + 0x52ea)) { uVar6 = *(uint16_t *)(uVar10 + 0x52ea); } } wl->variant_cached_limit = uVar6; if ((wl->variant_flags & 0xc0) != 0) { return; } if ((int8_t)iVar5 == (int8_t)wl->active_variant_index) { if (((wl->variant_anchor_flags & 8) == 0) && ((int)uVar6 - (int)wl->variant_anchor >= 0)) { iVar5 = (int)uVar6 - (int)wl->variant_anchor; goto LAB_1000_4f7e; } } else { iVar5 = *(int16_t *)(iVar5 * 2 + 0x52ea); wl->variant_anchor = (uint16_t)iVar5; if ((wl->variant_anchor_flags & 8) == 0) { wl->variant_total = wl->variant_total + (iVar5 - (int)(int16_t)wl->variant_live_limit); return; } } iVar5 = 0; LAB_1000_4f7e: wl->variant_total = wl->variant_total - iVar5; wl->variant_anchor = layout_sub_metrics_line_accum_from_variant_anchor_and_total(wl); }
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