HISTORICAL: releases 12/13, before native move entry.

Current8088/8086 source and rebuild notes
=======================================

Rebuilding native GNU Chess for 8088/8086 and Ensemble 1.x
=======================================================

Run these commands from this SOURCE directory. The shipped English and German
applications are installation alternatives with the same gnuchess.app / GnCh
identity. Close GEOS before replacing or changing language.

SDK-FREE REBUILD OF BOTH EDITIONS
--------------------------------
Requirements: Python 3 (standard library only) and NASM 2.16 or later.

    NASM=/path/to/nasm sh port1/rebuild.sh

Equivalent explicit commands:

    NASM=/path/to/nasm sh port1/bilingual/rebuild.sh all
    NASM=/path/to/nasm sh port1/bilingual/rebuild.sh en
    NASM=/path/to/nasm sh port1/bilingual/rebuild.sh de

Outputs and neighboring provenance reports:

    port1/bilingual/dist/en/GNUCHESS.GEO
    port1/bilingual/dist/de/GNUCHESS.GEO

For one language, a custom output follows the language choice:

    NASM=/path/to/nasm sh port1/bilingual/rebuild.sh de --output /tmp/GNUCHESS.GEO

Expected frozen outputs:
English: 170028 bytes; executable release 6.3.0.12
2676a6fb7f2539399a184718cc8aa15b29ab146fe6d5efe281e439ffe31acb70
German:  170012 bytes; executable release 6.3.0.13
4e18a9d01870d7e9b78acf568b5a1b346de19a074dc10c94e0c75ce0b4a10b9e

This route uses the supplied GPL engine intermediate at
port1/engine8086/build/geos/gnuchess.geo. Its matching linker resource map,
link manifest, bridge offsets and allocator/compiler listings are included.
The native builder checks the intermediate and map hashes, canonicalizes
resource IDs by linker name, and rebuilds the 1.x shell, compatibility runtime,
localized call bridges, objects, executable header and relocation tables.
Language-specific generated files go under port1/bilingual/build/en or de.
No user runtime, GEOS SDK, historical compiler or Python extension is needed
for this SDK-free route. The package contains no toolchain executables.

8088/8086 APPLICATION TARGET
-----------------------------
The native shell and movable-code bridge now assemble with NASM CPU 8086.
Manual register frames replace PUSHA/POPA; inverted short conditions plus
near jumps replace 386 near conditional branches. Register/FLAGS preservation
avoids PUSH SP, whose saved value differs on 8086. Each engine target has a
seven-byte near CALL plus inline handle/entry descriptor. A shared 24-byte
entry frame locks and jumps to the callee without moving its C arguments;
22-byte cleanup preserves result registers and conditions before returning.

The engine still uses the exact Watcom -0 intermediate and source. Its flags,
arithmetic, search/evaluation, cache capacities, history and artwork are
unchanged. The compatibility runtime was already 8086 assembly. No 8087 is
required. The smaller shared bridge offsets the longer native UI encodings.

The strict execution gate in tests/cpu8086_gate.py independently decodes raw
documented 8086 encodings, rather than trusting Capstone's CPU classification.
It rejects selected same-opcode differences that a later interpreter could
hide: PUSH SP, CL counts>=32, signed IDIV minimum quotients and accesses crossing
a segment boundary. Engine static review found no PUSH SP or FLAGS inspection,
no IDIV, all CL counts 0..15, no undefined multiply/divide/shift flag use before
redefinition/C ABI boundary, and no multiply-prefixed REP instruction. The
32-bit division runtime uses restoring division, not signed IDIV.

These are complementary checks, not a cycle-accurate 8086 model or exhaustive
proof. Native acceptance uses the dedicated DOSBox-X 8086 core and checks the
old kernel's detected CPU code. It is separate from synthetic kernel/graphics
boundaries. Physical 8088/8086 hardware and 4.77 MHz search speed are not measured.
The 8088 and 8086 share this instruction set; their bus/prefetch timing differs.

INCREMENTAL REPAINTING WITHOUT A NEW FRAMEBUFFER
------------------------------------------------
Ordinary selection, typing, depth and thinking updates no longer clear the
whole board. A 64-byte snapshot in previously unused private state records
painted squares. Ordinary draws compare all 64 current engine squares, restore
old selection strips, and repaint only changed cells or the new selection.
An occupied changed cell receives its original complete background Bitmap
directly; a vacated cell clears its own background. Status and typed text use
the footer area without redrawing stable coordinates or pieces.

The cache reuses STATE+c0..ff. The two-byte character scratch moved to+c..d;
previous selection and flags occupy+e..11. DGROUP, arena and stack reservations
are unchanged. No application framebuffer or new persistent heap allocation
is introduced. Added machine code is accounted for in the fixed-resource
figures below. The artwork lock is taken only when a piece is actually drawn.

Expose/uncover and geometry changes still restore the full scene through the
native update path; unchanged game state is not evidence that screen pixels
are intact. This preserves clipped expose recovery, maximize/resize, readable
unscaled text and the verified native scaled-Bitmap margin cleanup.

The search engine, caches, original piece/app-icon artwork, titles, shared
font and single application identity remain unchanged. Incremental repainting
is retained from releases 10/11; current release numbers identify the 8086
shell/bridge revision. No engine optimization is included.

UNCHANGED SLIM ENGINE, NEW NATIVE INTERFACE
------------------------------------------
This interface release uses the exact engine intermediate and engine sources
from the preceding slim release. Search, evaluation and engine representations
are unchanged. The native shell now measures its actual view, centers and
uniformly scales the board, and uses the same geometry for mouse selection.
It supports native window resizing/maximizing, redraws the full changed view,
and has a shared Berkeley font 0x0202 for both editions. The window title is
GNU Chess 6.3.0; the application and file caption is GNU Chess.

Resource 55 contains the original 48x30 color and monochrome application
Bitmaps with verified native 1.2 visual-moniker/GString wrappers. Both pixel
payloads match the included original source and compiled intermediate exactly.
The 1360-byte icon block is movable, initially loaded by ObjLockObjBlock, swapable and
nondiscardable (0x1c5a), adding no fixed icon Bitmap allocation. The initial-load flag is required for fresh native GeoManager token import.
Application resource 58 uses
a native moniker list with independent caption and window-title text.

The old 1.2 per-axis view bits are verified from its actual UI implementation:
0x80 enables a scrollable viewport, 0x20 hides its scrollbar, and 0x02 bypasses
the maximum-size constraint. The later SDK assigns a different hide-scrollbar
bit. Native primary/view geometry hints are based on the supplied GeoWrite and
GeoDraw objects. CPU geometry tests model boundary calls; native acceptance is
separate evidence for the actual UI layout, font, bitmap scaling and inputs.

The genuine GNU Chess 6.3.0 search and evaluation retain their algorithms,
pruning, move ordering, cache capacities, 256-entry history and depth limits.
The slim source compacts bounded board/tables, removes the duplicate input
board/list, and uses separate smaller main/quiescence sorter records. Bad
captures keep every move in the original order without unused score storage.
The preceding slim representation and search-controller edits require a full
C++ rebuild; the pre-slim intermediate will not produce these binaries.

Arena capacity is shared through src/engine/arena_limit.h: 34336 bytes for
34260 bytes allocated at successful initialization, leaving 76 bytes. Normal
play does not allocate. The native runtime validates the same arena bound.
The reserved process stack remains 49152 bytes. Smaller sorter frames improve
headroom; observed high-water marks do not justify claiming a smaller safe
reserved stack.

Artwork is unchanged and now lives in separately locked, movable/swappable,
read-only, nondiscardable resource 62 (0x0850). Movable engine code 26..54
remains preloaded, swappable and nondiscardable (0x0a50), called through fixed
lock/return thunks. Resource 2 stays fixed for its raw callback pointer.
Compact DGROUP places shell class/state/context records after all engine
initialized data and zero-filled BSS; generated offsets are checked for overlap.
Fixed initialized resources plus stack are 127616 bytes in either edition, before actual GEOS loader/UI/heap overhead. See DEVELOPMENT
and EVIDENCE/slim in the package for accounting and test limitations.

FULL ENGINE SOURCE REBUILD
--------------------------
Provide public PC/GEOS source and SDK trees, Open Watcom 2 Linux tools, NASM,
and a Linux C compiler/ar/patch for the optional GOC/Glue bootstrap. Tool
provenance is retained in port1/toolchain/environment.json.

    export ROOT_DIR=/path/to/pcgeos-source
    export GEOS_SDK=/path/to/pcgeos-sdk
    export WATCOM=/path/to/openwatcom
    export NASM=/path/to/nasm
    sh port1/rebuild.sh --compile-engine all

If GEOS_HOST_TOOLS is unset, bootstrap_host.py builds patched GOC and Glue from
ROOT_DIR/Tools. Alternatively set GEOS_HOST_TOOLS to your patched goc/glue bin
directory. Included patches fix host64 structure packing and empty debug maps.
The build compiles all 30 adapted engine translation units with Open Watcom
-0 -ml -zp1, links a fresh GEOS2 intermediate, saves its resource map/manifest,
and extracts bridge/allocator offsets with wdis before rebuilding both native
editions. This intermediate is a build input, not the application to install.
A different compiler/tool version may change code bytes; rerun behavioral and
native checks rather than treating a hash difference as a compatibility result.

CURRENT TEST ENTRY POINTS
-------------------------
After rebuilding both editions, run the portable standard-library suite:

    python3 -m unittest discover -s tests -p 'test_*.py' -v

All 13 tests are run from the staged SOURCE tree. They check language content,
strict GEOS text encoding, native moniker lists, 25 UI text slots, font
metrics, identity/protocols, class/state/resource policy, report hashes,
normalized engine equality against the frozen slim release and between both
editions, the 8086 shared bridge descriptors/frames, the native icon resource,
and all 24 unchanged playing-piece bitmaps.
No old application binary is needed. test_artwork.py parses the included GPL
artwork source and checks its frozen artwork digest.

Nine additional source/icon/object-format tests use only the standard library:

    python3 port1/bilingual/audit/test_native_icons.py

They verify exact original icon Bitmaps, native 1.2 moniker/GString/LMem
format, movable resource flags, application caption/title separation, view
geometry fields and the recorded Berkeley bitmap-face text advances.

Optional actual 16-bit CPU/ABI checks need installed Unicorn and Capstone:

    python3 tests/strict8086.py

The aggregate command runs all four optional suites below and binds their
reports to the rebuilt English/German hashes. Alternatively run individually:

    python3 tests/native_smoke.py --language de
    python3 tests/native_smoke.py --language en
    python3 tests/thunk_abi_8086.py
    python3 tests/geometry_cpu.py
    python3 tests/incremental_cpu.py

After those complete, aggregate existing reports without repeating tests:

    python3 tests/strict8086.py --reports-only

The bridge harness checks every production target stub, all 256 defined
FLAGS/IF/DF combinations, actual RETF N callee cleanup, nesting and failure
paths. Its small target code executes rather than synthesizing returns.
The other CPU harnesses enable the raw 8086 gate by default.

The incremental harness checks exact dirty-square sets, selection/footer-only
updates, thinking, special moves, Undo, cache recovery, canaries and expose
behavior. Native video/pixel evidence is separate from the modeled graphics.

These execute the generated machine code with stubbed kernel boundaries,
relocate and poison unlocked code/artwork, check lock/stack/context balance,
exercise startup/paint, illegal/legal moves, depth 4 and Undo, and verify
cdecl/Pascal argument/return/register/FLAGS behavior. They do not emulate the
GEOS loader, real graphics, scheduling or swap I/O. Current native runtime evidence under EVIDENCE/cpu8086 provides separate
acceptance on the supplied English GeoWorks Pro / Ensemble 1.2 runtime using
the dedicated 8086 emulator core. EVIDENCE/slim and ui-history folders retain
historical tests with their original CPU configurations. A German GEOS
runtime was unavailable.

Optional paired host regression requires a C++11 compiler with UBSan:

    python3 tests/paired-host/run_comparison.py

It compiles the GPL historical baseline source in tests/baseline-engine and
the current engine independently, then compares all result records. No old
executable is supplied or required. It covers perft/rules, 113 FEN positions
at depths 1..4, self-play, coordinate actions, Undo/replay, scores, nodes, PV,
flags and active board/hash/history state. Host tests cannot establish native
segmented-pointer or GEOS-loader correctness. Generated host executables and
reports stay in tests/paired-host and are not part of the source distribution.
The engine source is unchanged in this interface release, so historical paired
engine acceptance remains applicable; the staged quick rebuild checks engine
resource bytes directly. It does not claim that the old 19-million-check host
suite was rerun for this UI-only release.

The current default port1/rebuild.sh selects port1/bilingual/rebuild.sh and
builds these 8086 editions. Unused port1/ui, port1/low_memory and other retained
legacy source files document previous 386/286 revisions; they are historical
routes, not this release's 8086 build entry points. The GEOS2 engine intermediate
is a linker input whose old UI is replaced by the native builder; do not install
that intermediate as the application.

Do not use older port1/low_memory tests or the previous translation-only test
as this package's acceptance check. Historical source/reference files retain
their original assumptions; tests/ is the current portable entry point.

SOURCE AND LOCALIZATION MAP
---------------------------
port1/engine8086/src/engine     Current shared GNU Chess engine and arena bound.
port1/engine8086/src/geos       GOC/intermediate application compilation input.
port1/engine8086/tools          Full source compilation, host bootstrap/patches.
port1/engine8086/build/geos      Exact engine intermediate and link manifest.
port1/engine8086/logs/glue.log   Matching resource names/sizes/relocation counts.
port1/bilingual/ui              Native 1.x shell, drawing and GPL artwork bytes.
port1/bilingual/l10n            UTF-8 English/German strings and layout values.
port1/bilingual/locale_encoding.py
                               Strict source-to-GEOS SBCS conversion.
port1/bilingual/audit           Native object builder, factual format/font
                               metrics and independent thunk ABI test.
port1/bilingual/memory_layout.py
                               Nonoverlapping class/state/context layout.
port1/bilingual/canonical-engine-resources.json
                               Stable resource identities across table splits.
port1/bilingual/build_port.py   Native format/import/resource linker.
tests                          Current portable acceptance/optional CPU tests.
tests/baseline-engine           Historical GPL source used only for comparison.
work/gnuchess-pcgeos            Original adaptation/vendor source/archive/assets.

German text is encoded as audited native GEOS SBCS, not UTF-8, CP850 or Latin-1.
Both editions select Berkeley font ID 0x0202 from the user's installation; no font is
redistributed. Developer identifiers and legal texts retain their languages.
The entire generated application now targets documented 8086 instructions;
the engine's -0 flag is only one part of the combined static/execution/native
acceptance. No physical 8088 timing or universal runtime compatibility is claimed.

LICENSING
---------
GPL version 3 or later, with retained Apache-2.0 notices for adapted portions.
The user's Ensemble runtime, kernel, fonts, SDK and compiler are not bundled.
