Initial commit

This commit is contained in:
Justin Marshall
2026-08-06 08:03:49 -07:00
commit a1c4a1f9ee
1113 changed files with 513472 additions and 0 deletions
+974
View File
@@ -0,0 +1,974 @@
cmake_minimum_required(VERSION 3.25)
project(MicrosoftWordX64Port VERSION 0.2.0 LANGUAGES C CXX RC)
if(NOT WIN32)
message(FATAL_ERROR "The Microsoft Word x64 port currently targets Windows only.")
endif()
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message(FATAL_ERROR "This project must be configured for x64 (use: cmake --preset x64-debug).")
endif()
set(MSWORD_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..")
cmake_path(NORMAL_PATH MSWORD_ROOT)
set(MSWORD_BUILD_ROOT "${MSWORD_ROOT}/build")
set(MSWORD_BIN_ROOT "${MSWORD_ROOT}/bin")
# Reserved for the executable that will be linked from the original Opus
# source graph. The migration bootstrap must not use this product name.
set(MSWORD_PRODUCT_OUTPUT_NAME "WORD1" CACHE STRING
"Filename stem for the original-source Word x64 executable")
file(MAKE_DIRECTORY "${MSWORD_BUILD_ROOT}" "${MSWORD_BIN_ROOT}")
# Keep linked artifacts in the locations requested for this port. CMake's
# generated project and cache live under ../out (see CMakePresets.json).
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BIN_ROOT}")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/pdb")
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/pdb")
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BIN_ROOT}")
set(CMAKE_PDB_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/pdb/${config}")
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/pdb/${config}")
endforeach()
set(MSWORD_BOOTSTRAP_SOURCES
port/winword_x64.cpp
port/legacy_asm_port.cpp
port/legacy_asm_port.h
port/winword_x64.rc
port/winword.manifest
)
# This is a migration aid only. It is deliberately excluded from the default
# build and may never claim the final WORD1.exe product name: that name is
# reserved for the executable linked from the original Opus source graph.
add_executable(WINWORD_BOOTSTRAP WIN32 EXCLUDE_FROM_ALL ${MSWORD_BOOTSTRAP_SOURCES})
target_compile_features(WINWORD_BOOTSTRAP PRIVATE cxx_std_20)
target_compile_definitions(WINWORD_BOOTSTRAP PRIVATE UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX)
target_include_directories(WINWORD_BOOTSTRAP PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/port")
target_link_libraries(WINWORD_BOOTSTRAP PRIVATE
comctl32
comdlg32
gdi32
ole32
shell32
user32
)
if(MSVC)
target_compile_options(WINWORD_BOOTSTRAP PRIVATE /W4 /permissive- /utf-8 /EHsc /guard:cf)
# The application manifest is compiled as resource 1; disable MSVC's
# second auto-generated manifest to avoid a duplicate RT_MANIFEST entry.
target_link_options(WINWORD_BOOTSTRAP PRIVATE /DYNAMICBASE /HIGHENTROPYVA /NXCOMPAT /MANIFEST:NO)
set_property(TARGET WINWORD_BOOTSTRAP PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
set_target_properties(WINWORD_BOOTSTRAP PROPERTIES
OUTPUT_NAME "WINWORD_BOOTSTRAP"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/bootstrap"
VS_GLOBAL_ROOTNAMESPACE "MicrosoftWordX64Port"
# The target uses only Windows system libraries. Disable Visual Studio's
# global vcpkg app-local hook so it does not invoke an unrelated pwsh.exe.
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(WINWORD_BOOTSTRAP PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/bootstrap/${config}"
)
endforeach()
# The original assembly remains in the repository for behavioral reference,
# but no .asm file is permitted to enter the native target.
get_target_property(winword_sources WINWORD_BOOTSTRAP SOURCES)
foreach(source IN LISTS winword_sources)
if(source MATCHES "\\.[aA][sS][mM]$")
message(FATAL_ERROR "Legacy assembly leaked into the x64 target: ${source}")
endif()
endforeach()
file(GLOB_RECURSE LEGACY_ASSEMBLY CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.asm")
set(LEGACY_ASSEMBLY_RELATIVE)
foreach(assembly_file IN LISTS LEGACY_ASSEMBLY)
file(RELATIVE_PATH relative_path "${CMAKE_CURRENT_SOURCE_DIR}" "${assembly_file}")
cmake_path(CONVERT "${relative_path}" TO_CMAKE_PATH_LIST relative_path NORMALIZE)
list(APPEND LEGACY_ASSEMBLY_RELATIVE "${relative_path}")
endforeach()
list(SORT LEGACY_ASSEMBLY_RELATIVE)
# Extract the explicit source paths from the C++ disposition table and compare
# names, not merely counts. Removing one module and adding another cannot pass.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/port/legacy_asm_port.cpp" ASM_PORT_SOURCE)
string(REGEX MATCHALL "AssemblyPortEntry\\{\"[^\"]+\\.asm\"" ASM_PORT_ROWS "${ASM_PORT_SOURCE}")
set(ASM_PORT_PATHS)
foreach(port_row IN LISTS ASM_PORT_ROWS)
string(REGEX REPLACE "AssemblyPortEntry\\{\"([^\"]+)\"" "\\1" port_path "${port_row}")
list(APPEND ASM_PORT_PATHS "${port_path}")
endforeach()
list(SORT ASM_PORT_PATHS)
list(LENGTH LEGACY_ASSEMBLY_RELATIVE LEGACY_ASSEMBLY_COUNT)
if(NOT LEGACY_ASSEMBLY_COUNT EQUAL 59 OR
NOT "${LEGACY_ASSEMBLY_RELATIVE}" STREQUAL "${ASM_PORT_PATHS}")
message(FATAL_ERROR
"The assembly-port manifest does not exactly match the legacy source tree "
"(${LEGACY_ASSEMBLY_COUNT} modules found). Update port/legacy_asm_port.cpp."
)
endif()
add_custom_target(legacy_sources SOURCES ${LEGACY_ASSEMBLY})
set_target_properties(legacy_sources PROPERTIES FOLDER "Legacy reference (not compiled)")
# Start of the real product engine. Every source in this target is from the
# original Opus tree; compatibility code supplies platform services only.
set(OPUS_SDK_ROOT "$ENV{ProgramFiles\(x86\)}/Windows Kits/10")
set(OPUS_WINDOWS_SDK_HEADER
"${OPUS_SDK_ROOT}/Include/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/um/Windows.h")
if(NOT EXISTS "${OPUS_WINDOWS_SDK_HEADER}")
message(FATAL_ERROR "Could not locate the Windows SDK header: ${OPUS_WINDOWS_SDK_HEADER}")
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated/original")
configure_file(
port/original/opus_windows_sdk.h.in
"${CMAKE_CURRENT_BINARY_DIR}/generated/original/opus_windows_sdk.h"
@ONLY
)
# MERGEELX writes a fixed hidden-screen payload in addition to the dialog EL
# tables. Preserve that original payload directly from Microsoft's generator
# source. The archive lacks the Dialog Editor executable that converted its
# .des inputs to MERGEELX's intermediate .elx format, so an explicit inert EL
# table boundary remains until that missing compiler stage is replaced.
set(OPUS_GENERATED_ELXINFO
"${CMAKE_CURRENT_BINARY_DIR}/generated/original/elxinfo.h")
add_custom_command(
OUTPUT "${OPUS_GENERATED_ELXINFO}"
COMMAND powershell -NoProfile -ExecutionPolicy Bypass
-File "${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateElxStid.ps1"
-InputPath "${CMAKE_CURRENT_SOURCE_DIR}/OpusEtAl/tools/src/mergeelx.c"
-OutputPath "${OPUS_GENERATED_ELXINFO}"
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateElxStid.ps1"
"${CMAKE_CURRENT_SOURCE_DIR}/OpusEtAl/tools/src/mergeelx.c"
VERBATIM
)
add_custom_target(opus_generated_elxinfo DEPENDS "${OPUS_GENERATED_ELXINFO}")
set_target_properties(opus_generated_elxinfo PROPERTIES
FOLDER "Original Opus x64/generated"
)
# Rebuild the command constants from Microsoft's checked-in command compiler
# and resource sources. The tool runs natively on x64 but preserves MKCMD's
# original 16-bit serialized word layout.
add_executable(opus_mkcmd_tool EXCLUDE_FROM_ALL
OpusEtAl/tools/src/mkcmd.c
)
target_compile_definitions(opus_mkcmd_tool PRIVATE OPUS_X64_TOOL)
target_include_directories(opus_mkcmd_tool PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/OpusEtAl/tools/src"
)
if(MSVC)
target_compile_options(opus_mkcmd_tool PRIVATE /J /W3 /wd4996)
endif()
set_target_properties(opus_mkcmd_tool PROPERTIES
FOLDER "Original Opus x64/build tools"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tools"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_mkcmd_tool PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tools/${config}"
)
endforeach()
# Preserve Microsoft's original BITAPP resource conversion step. These
# native x64 tool builds consume the checked-in Win16 .cur files and emit the
# same byte initializers that SCREEN2.C historically included.
add_executable(opus_bitapp_tool EXCLUDE_FROM_ALL
OpusEtAl/tools/src/bitapp.c
)
target_compile_definitions(opus_bitapp_tool PRIVATE OPUS_X64_TOOL)
target_include_directories(opus_bitapp_tool PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/OpusEtAl/tools/src"
)
if(MSVC)
target_compile_options(opus_bitapp_tool PRIVATE /J /W3 /wd4996)
endif()
set_target_properties(opus_bitapp_tool PROPERTIES
FOLDER "Original Opus x64/build tools"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tools"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_bitapp_tool PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tools/${config}"
)
endforeach()
set(OPUS_GENERATED_COMMAND_DIR
"${CMAKE_CURRENT_BINARY_DIR}/generated/original")
set(OPUS_CURSOR_RESOURCE_NAMES
styname
mic
help
cross
vertout
horzout
prvwcrs
)
set(OPUS_GENERATED_CURSOR_FILES)
foreach(cursor_name IN LISTS OPUS_CURSOR_RESOURCE_NAMES)
set(cursor_source "${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource/${cursor_name}.cur")
set(cursor_header "${OPUS_GENERATED_COMMAND_DIR}/${cursor_name}.hc")
add_custom_command(
OUTPUT "${cursor_header}"
COMMAND "$<TARGET_FILE:opus_bitapp_tool>" "${cursor_source}" "${cursor_header}"
DEPENDS opus_bitapp_tool "${cursor_source}"
COMMENT "Converting original Opus cursor ${cursor_name}.cur with BITAPP"
VERBATIM
)
list(APPEND OPUS_GENERATED_CURSOR_FILES "${cursor_header}")
endforeach()
add_custom_target(opus_generated_cursors
DEPENDS ${OPUS_GENERATED_CURSOR_FILES}
)
set_target_properties(opus_generated_cursors PROPERTIES
FOLDER "Original Opus x64/build tools"
)
# Recreate the checked-out build's embedded icon/cursor/bitmap C headers
# using Microsoft's original BITAPP source. These headers were intermediate
# build products and are not present in the source archive.
set(OPUS_BITAPP_BITMAP_HEADERS
8hdr.hb 8otlpat.hb 8outline.hg 8pageico.hb 8paralig.hg
8ribbon.hg 8rulmark.hg 8rultgls.hg 8scrptpo.hg
chdr.hb cotlpat.hb coutline.hg cpageico.hb cparalig.hg
cribbon.hg crulmark.hg crultgls.hg cscrptpo.hg
ehdr.hb eotlpat.hb eoutline.hg epageico.hb eparalig.hg
eribbon.hg erulmark.hg erultgls.hg escrptpo.hg
shdr.hb showvis.hb sotlpat.hb soutline.hg spageico.hb
sparalig.hg sribbon.hg srulmark.hg srultgls.hg sscrptpo.hg
vhdr.hb votlpat.hb voutline.hg vpageico.hb vparalig.hg
vribbon.hg vrulmark.hg vrultgls.hg vscrptpo.hg
)
set(OPUS_BITAPP_FIGURE_HEADERS
mopus.hi mword.hi mwhires.hc split.hc column.hc
)
set(OPUS_GENERATED_EMBEDDED_RESOURCES)
foreach(resource_header IN LISTS OPUS_BITAPP_BITMAP_HEADERS OPUS_BITAPP_FIGURE_HEADERS)
get_filename_component(resource_stem "${resource_header}" NAME_WE)
get_filename_component(resource_extension "${resource_header}" EXT)
if(resource_extension STREQUAL ".hi")
set(resource_source_extension ".ico")
elseif(resource_extension STREQUAL ".hc")
set(resource_source_extension ".cur")
else()
set(resource_source_extension ".bmp")
endif()
set(resource_source
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource/${resource_stem}${resource_source_extension}")
set(resource_output
"${OPUS_GENERATED_COMMAND_DIR}/${resource_header}")
if(resource_extension STREQUAL ".hg")
set(bitapp_gray_flag /g)
else()
set(bitapp_gray_flag)
endif()
add_custom_command(
OUTPUT "${resource_output}"
COMMAND "$<TARGET_FILE:opus_bitapp_tool>" ${bitapp_gray_flag}
"${resource_source}" "${resource_output}"
DEPENDS opus_bitapp_tool "${resource_source}"
COMMENT "Regenerating original Opus resource header ${resource_header}"
VERBATIM
)
list(APPEND OPUS_GENERATED_EMBEDDED_RESOURCES "${resource_output}")
endforeach()
add_custom_target(opus_generated_embedded_resources
DEPENDS ${OPUS_GENERATED_EMBEDDED_RESOURCES}
)
set_target_properties(opus_generated_embedded_resources PROPERTIES
FOLDER "Original Opus x64/generated"
)
# DIBAPP itself is not present in the archive. This native compatibility
# tool preserves its build boundary by extracting the original OS/2
# BITMAPCOREHEADER scan lines into the BMDS3 aggregate format consumed by
# Microsoft's rcbmp13/23/43 modules.
add_executable(opus_dibapp_tool EXCLUDE_FROM_ALL
port/tools/opus_dibapp_tool.cpp
)
target_compile_features(opus_dibapp_tool PRIVATE cxx_std_20)
if(MSVC)
target_compile_options(opus_dibapp_tool PRIVATE /W4 /permissive-)
endif()
set_target_properties(opus_dibapp_tool PROPERTIES
FOLDER "Original Opus x64/build tools"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tools"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_dibapp_tool PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tools/${config}"
)
endforeach()
file(GLOB OPUS_DIB_RESOURCE_INPUTS CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource/*.dib")
set(OPUS_GENERATED_DIB_RESOURCE_FILES)
foreach(dib_input IN LISTS OPUS_DIB_RESOURCE_INPUTS)
get_filename_component(dib_stem "${dib_input}" NAME_WE)
set(dib_output "${OPUS_GENERATED_COMMAND_DIR}/${dib_stem}.hb")
add_custom_command(
OUTPUT "${dib_output}"
COMMAND "$<TARGET_FILE:opus_dibapp_tool>" "${dib_input}" "${dib_output}"
DEPENDS opus_dibapp_tool "${dib_input}"
COMMENT "Converting original ${dib_stem}.dib resource"
VERBATIM
)
list(APPEND OPUS_GENERATED_DIB_RESOURCE_FILES "${dib_output}")
endforeach()
add_custom_target(opus_generated_dib_resources
DEPENDS ${OPUS_GENERATED_DIB_RESOURCE_FILES}
)
set_target_properties(opus_generated_dib_resources PROPERTIES
FOLDER "Original Opus x64/generated"
)
set(OPUS_GENERATED_COMMAND_FILES
"${OPUS_GENERATED_COMMAND_DIR}/opuscmd.h"
"${OPUS_GENERATED_COMMAND_DIR}/IBCM.H"
"${OPUS_GENERATED_COMMAND_DIR}/RGBCM.H"
"${OPUS_GENERATED_COMMAND_DIR}/OPUSCMD2.H"
"${OPUS_GENERATED_COMMAND_DIR}/OPUSMENU.H"
"${OPUS_GENERATED_COMMAND_DIR}/MENUHELP.TXT"
"${OPUS_GENERATED_COMMAND_DIR}/menuhelp.h"
"${OPUS_GENERATED_COMMAND_DIR}/opuscmd.asm"
"${OPUS_GENERATED_COMMAND_DIR}/opuscmd_native.inc"
)
add_custom_command(
OUTPUT ${OPUS_GENERATED_COMMAND_FILES}
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource/opuscmd.cmd"
"${OPUS_GENERATED_COMMAND_DIR}/opuscmd.cmd"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource/keys.cmd"
"${OPUS_GENERATED_COMMAND_DIR}/keys.cmd"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource/menus.cmd"
"${OPUS_GENERATED_COMMAND_DIR}/menus.cmd"
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource/ibcm.rel"
"${OPUS_GENERATED_COMMAND_DIR}/IBCM.H"
COMMAND "$<TARGET_FILE:opus_mkcmd_tool>"
-T@13 -s../../../src/Opus/dlg/ opuscmd keys menus
COMMAND "${CMAKE_COMMAND}"
-DINPUT=${OPUS_GENERATED_COMMAND_DIR}/MENUHELP.TXT
-DOUTPUT=${OPUS_GENERATED_COMMAND_DIR}/menuhelp.h
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateMenuHelpHeader.cmake"
DEPENDS
opus_mkcmd_tool
Opus/resource/opuscmd.cmd
Opus/resource/keys.cmd
Opus/resource/menus.cmd
Opus/resource/ibcm.rel
Opus/dlg/elx.txt
cmake/GenerateMenuHelpHeader.cmake
WORKING_DIRECTORY "${OPUS_GENERATED_COMMAND_DIR}"
COMMENT "Regenerating original Opus command tables with MKCMD"
VERBATIM
)
add_custom_target(opus_generated_commands
DEPENDS ${OPUS_GENERATED_COMMAND_FILES}
)
set_target_properties(opus_generated_commands PROPERTIES
FOLDER "Original Opus x64/build tools"
)
# Rebuild the EL dialog range/parse tables with Microsoft's original MKDLG
# source. dlgcheck.h was a generated build artifact and is not checked into
# this archive.
add_executable(opus_mkdlg_tool EXCLUDE_FROM_ALL
OpusEtAl/tools/src/mkdlg.c
)
if(MSVC)
target_compile_options(opus_mkdlg_tool PRIVATE /J /W3 /wd4996)
endif()
set_target_properties(opus_mkdlg_tool PROPERTIES
FOLDER "Original Opus x64/build tools"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tools"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_mkdlg_tool PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tools/${config}"
)
endforeach()
file(GLOB OPUS_DIALOG_ELX CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/dlg/*.elx")
set(OPUS_GENERATED_DLGCHECK
"${OPUS_GENERATED_COMMAND_DIR}/dlgcheck.h")
add_custom_command(
OUTPUT "${OPUS_GENERATED_DLGCHECK}"
COMMAND "$<TARGET_FILE:opus_mkdlg_tool>"
"@elx.txt" "${OPUS_GENERATED_DLGCHECK}"
DEPENDS opus_mkdlg_tool ${OPUS_DIALOG_ELX} Opus/dlg/elx.txt
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Opus/dlg"
COMMENT "Regenerating original Opus dialog validation tables with MKDLG"
VERBATIM
)
add_custom_target(opus_generated_dlgcheck
DEPENDS "${OPUS_GENERATED_DLGCHECK}"
)
set_target_properties(opus_generated_dlgcheck PROPERTIES
FOLDER "Original Opus x64/generated"
)
add_executable(opus_mergeelx_tool EXCLUDE_FROM_ALL
OpusEtAl/tools/src/mergeelx.c
)
target_include_directories(opus_mergeelx_tool PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/OpusEtAl/tools/src"
)
if(MSVC)
target_compile_options(opus_mergeelx_tool PRIVATE /J /W3 /wd4996)
endif()
set_target_properties(opus_mergeelx_tool PROPERTIES
FOLDER "Original Opus x64/build tools"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tools"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_mergeelx_tool PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tools/${config}"
)
endforeach()
add_library(opus_original_engine STATIC
Opus/command.c
Opus/command2.c
Opus/annot.c
Opus/cmd.c
Opus/cmd2.c
Opus/cmd3.c
Opus/cmdcore.c
Opus/cmdwnd.c
Opus/curswin.c
Opus/CLIPBORD.C
Opus/CLIPBRD2.C
Opus/compare.c
Opus/create.c
Opus/CREATE2.C
Opus/EDIT.C
Opus/disp1.c
Opus/dispbrc.c
Opus/dispspec.c
Opus/dialog1.c
Opus/dialog2.c
Opus/dialog3.c
Opus/dialog4.c
Opus/dlglook1.c
Opus/dlglook2.c
Opus/dlgrec.c
Opus/dlgmisc.c
Opus/dlgopen.c
Opus/dlgdoc.c
Opus/edmacro.c
Opus/search.c
Opus/replace.c
Opus/srchfmt.c
Opus/tabs.c
Opus/catalog.c
Opus/customiz.c
Opus/toc.c
Opus/sort.c
Opus/index1.c
Opus/index2.c
Opus/merge.c
Opus/renum.c
Opus/insfield.c
Opus/dlgtable.c
Opus/dlghyph.c
Opus/etcmd.c
Opus/docman1.c
Opus/docman2.c
Opus/print2.c
Opus/ddeclnt.c
Opus/ddesub.c
Opus/DDESRVR.C
Opus/DLBENUM.C
Opus/eldde.c
Opus/eldlg.c
Opus/elfile.c
Opus/elmisc.c
Opus/elmisc2.c
Opus/elsubs.c
Opus/elsubs3.c
Opus/elsubs2.c
Opus/FILE2.C
Opus/ffcrypt.c
Opus/ffread.c
Opus/fieldcr.c
Opus/fieldclc.c
Opus/FIELDCMD.C
Opus/fieldfmt.c
Opus/fieldprs.c
Opus/fieldsc2.c
Opus/fieldspc.c
Opus/fltexp.c
Opus/filecvt.c
Opus/filewin.c
Opus/formula.c
Opus/formatsp.c
Opus/fieldsp.c
Opus/fieldpic.c
Opus/glsy.c
Opus/help.c
Opus/hddwin.c
Opus/GRSPEC.C
Opus/grbit.c
Opus/grswath.c
Opus/grtiff.c
Opus/initwin.c
Opus/init2.c
Opus/interp/corout.c
Opus/interp/elcore.c
Opus/interp/elinit.c
Opus/interp/exp.c
Opus/interp/main.c
Opus/interp/sym.c
Opus/interp/to.c
Opus/idle.c
Opus/LOADFONT.C
Opus/iconbar1.c
Opus/iconbar2.c
Opus/iconbar3.c
Opus/menu.c
Opus/menuhelp.c
Opus/mathapi.c
Opus/wordtech/inssubs.c
Opus/wordtech/insert.c
Opus/open.c
Opus/openrare.c
Opus/outwin.c
Opus/pic.c
Opus/PIC2.C
Opus/pictdrag.c
Opus/prompt.c
Opus/preview.c
Opus/print.c
Opus/print1.c
Opus/prvw2.c
Opus/raremsg.c
Opus/recorder.c
Opus/res.c
Opus/rsb.c
Opus/util2.c
Opus/rulerdrw.c
Opus/rulrib.c
Opus/RTFIN.C
Opus/RTFOUT.C
Opus/RTFRARE.C
Opus/rtfsubs.c
Opus/rtftrans.c
Opus/rcinit.c
Opus/rcbmp1.c
Opus/rcbmp2.c
Opus/rcbmp3.c
Opus/rcbmp4.c
Opus/rcbmp13.c
Opus/rcbmp23.c
Opus/rcbmp43.c
Opus/save.c
Opus/savetext.c
Opus/SCREEN2.C
Opus/statline.c
Opus/style.c
Opus/stylesub.c
Opus/strtbl.c
Opus/splitter.c
Opus/SYSCHG.C
Opus/quit.c
Opus/wproc.c
Opus/wwact.c
Opus/wwchange.c
Opus/token.c
Opus/vars.c
Opus/wordtech/clsplc.c
Opus/wordtech/banter.c
Opus/wordtech/block.c
Opus/wordtech/curskeys.c
Opus/wordtech/disp2.c
Opus/wordtech/disp3.c
Opus/wordtech/disptbl.c
Opus/wordtech/editsub.c
Opus/wordtech/editspec.c
Opus/wordtech/error.c
Opus/wordtech/fetch.c
Opus/wordtech/fetch1.c
Opus/wordtech/fetch2.c
Opus/wordtech/fetchtb.c
Opus/wordtech/footnote.c
Opus/wordtech/format.c
Opus/wordtech/hdd.c
Opus/wordtech/hyph.c
Opus/wordtech/ihdd.c
Opus/wordtech/layout.c
Opus/wordtech/layout1.c
Opus/wordtech/layout2.c
Opus/wordtech/outline.c
Opus/wordtech/layoutap.c
Opus/wordtech/pagevw.c
Opus/wordtech/printsub.c
Opus/wordtech/prcsubs.c
Opus/wordtech/savefast.c
Opus/wordtech/scroll.c
Opus/wordtech/select.c
Opus/wordtech/selectsp.c
Opus/wordtech/sttb.c
Opus/wordtech/stysubs.c
Opus/wordtech/selecttb.c
Opus/wordtech/tablecmd.c
Opus/wordtech/tableins.c
Opus/wordtech/tablesub.c
Opus/wordtech/undo.c
Opus/SPELL.C
Opus/spelcore.c
port/original/opus_asm_layout2.cpp
port/original/opus_asm_file2.cpp
port/original/opus_asm_filewin.cpp
port/original/opus_asm_math.cpp
port/original/opus_asm_natinit_format.cpp
port/original/opus_asm_graphics.cpp
port/original/opus_asm_fetch3.cpp
port/original/opus_asm_prompt.cpp
port/original/opus_asm_misc.cpp
port/original/opus_asm_movecmds.c
port/original/opus_asm_fetch_adapters.cpp
port/original/opus_asm_display_adapters.cpp
port/original/opus_asm_plc_adapters.cpp
port/original/opus_asm_resn2_adapters.cpp
port/original/opus_asm_native_adapters.cpp
port/original/opus_asm_wproc.cpp
port/original/opus_x64_segment_anchors.c
)
add_dependencies(opus_original_engine
opus_generated_commands
opus_generated_cursors
opus_generated_embedded_resources
opus_generated_dib_resources
opus_generated_dlgcheck
opus_generated_elxinfo
)
set_source_files_properties(Opus/wordtech/fetch2.c PROPERTIES
COMPILE_DEFINITIONS CC
)
set_source_files_properties(Opus/wordtech/fetch.c Opus/wordtech/fetch1.c Opus/wordtech/format.c Opus/wordtech/inssubs.c Opus/wordtech/fetchtb.c Opus/wordtech/editspec.c Opus/wordtech/layout.c PROPERTIES
COMPILE_DEFINITIONS DEBUGORNOTWIN
)
set_source_files_properties(Opus/wordtech/clsplc.c PROPERTIES
COMPILE_DEFINITIONS DEBUGORNOTWIN
)
set_source_files_properties(Opus/wordtech/layout1.c Opus/wordtech/layout2.c PROPERTIES
COMPILE_DEFINITIONS DEBUGORNOTWIN
)
set_source_files_properties(Opus/wordtech/disp2.c PROPERTIES
COMPILE_DEFINITIONS DEBUGORNOTWIN
)
set_source_files_properties(Opus/wordtech/disptbl.c PROPERTIES
COMPILE_DEFINITIONS DEBUGORNOTWIN
)
set_source_files_properties(Opus/disp1.c PROPERTIES
COMPILE_DEFINITIONS "NOASM;OPUS_X64_DISPLAY_C"
)
set_source_files_properties(Opus/CLIPBORD.C Opus/CLIPBRD2.C Opus/CREATE2.C Opus/DDESRVR.C Opus/DLBENUM.C Opus/EDIT.C Opus/FIELDCMD.C Opus/FILE2.C Opus/GRSPEC.C Opus/LOADFONT.C Opus/PIC2.C Opus/RTFIN.C Opus/RTFOUT.C Opus/RTFRARE.C Opus/SCREEN2.C Opus/SPELL.C Opus/SYSCHG.C PROPERTIES LANGUAGE C)
set(OPUS_ORIGINAL_INCLUDE_DIRS
"${CMAKE_CURRENT_BINARY_DIR}/generated/original"
"${CMAKE_CURRENT_SOURCE_DIR}/port/original"
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/wordtech"
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/dlg"
"${CMAKE_CURRENT_SOURCE_DIR}/Opus/resource"
"${CMAKE_CURRENT_SOURCE_DIR}/Opus"
)
target_compile_definitions(opus_original_engine PRIVATE
WIN
WIN23
CRLF
NONATIVE
OPUS_X64
NOMINMAX
)
target_include_directories(opus_original_engine PRIVATE ${OPUS_ORIGINAL_INCLUDE_DIRS})
if(MSVC)
# /J preserves the original compiler's unsigned-char default. Do not use
# the C++ compiler for K&R-era original C translation units.
target_compile_options(opus_original_engine PRIVATE /J /W3 /wd4005 /Gy)
endif()
set_target_properties(opus_original_engine PROPERTIES
FOLDER "Original Opus x64"
ARCHIVE_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/lib"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_original_engine PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/lib/${config}"
)
endforeach()
add_library(opus_x64_runtime STATIC
port/original/opus_original_chupper.c
port/original/opus_elx_dispatch.cpp
port/original/opus_startup_diagnostics.cpp
port/original/opus_win16_platform.cpp
port/original/opus_x64_heap.cpp
port/original/opus_x64_layout.c
port/original/opus_asm_fetchn2.cpp
port/original/opus_asm_resn.cpp
port/original/opus_asm_resn_core.cpp
port/original/opus_asm_resn_plc.cpp
port/original/opus_asm_resn2.cpp
port/original/opus_asm_resn2_access.cpp
port/original/opus_asm_resn2_pl.cpp
port/original/opus_asm_resn2_sttb.cpp
port/original/opus_asm_sttb.cpp
port/original/opus_asm_search.cpp
port/original/opus_sdm_cab.cpp
port/original/opus_sdm_runtime.cpp
)
target_compile_features(opus_x64_runtime PRIVATE cxx_std_20)
target_compile_definitions(opus_x64_runtime PRIVATE
WIN
WIN23
CRLF
NONATIVE
OPUS_X64
NOMINMAX
)
target_include_directories(opus_x64_runtime PRIVATE ${OPUS_ORIGINAL_INCLUDE_DIRS})
if(MSVC)
# Opus was built with unsigned plain characters; the byte-oriented string
# and international-character assembly routines depend on that behavior.
target_compile_options(opus_x64_runtime PRIVATE /J /W4 /permissive-)
endif()
set_target_properties(opus_x64_runtime PROPERTIES
FOLDER "Original Opus x64/runtime"
ARCHIVE_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/lib"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_x64_runtime PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/lib/${config}"
)
endforeach()
add_executable(opus_original_sttb_test
Opus/wordtech/sttb.c
port/original/opus_original_sttb_test.c
)
target_compile_definitions(opus_original_sttb_test PRIVATE
WIN WIN23 CRLF NONATIVE OPUS_X64 NOMINMAX
)
target_include_directories(opus_original_sttb_test PRIVATE ${OPUS_ORIGINAL_INCLUDE_DIRS})
target_link_libraries(opus_original_sttb_test PRIVATE opus_x64_runtime user32)
if(MSVC)
target_compile_options(opus_original_sttb_test PRIVATE /J /W3 /wd4005)
endif()
set_target_properties(opus_original_sttb_test PROPERTIES
FOLDER "Original Opus x64/tests"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tests"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_original_sttb_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tests/${config}"
)
endforeach()
add_executable(opus_original_plc_test
Opus/wordtech/clsplc.c
port/original/opus_asm_plc_adapters.cpp
port/original/opus_original_plc_test.c
)
target_compile_definitions(opus_original_plc_test PRIVATE
WIN WIN23 CRLF NONATIVE OPUS_X64 NOMINMAX
)
target_include_directories(opus_original_plc_test PRIVATE ${OPUS_ORIGINAL_INCLUDE_DIRS})
target_link_libraries(opus_original_plc_test PRIVATE opus_x64_runtime user32)
if(MSVC)
target_compile_options(opus_original_plc_test PRIVATE /J /W3 /wd4005)
endif()
set_target_properties(opus_original_plc_test PROPERTIES
FOLDER "Original Opus x64/tests"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tests"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_original_plc_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tests/${config}"
)
endforeach()
add_executable(opus_sdm_cab_test
port/original/opus_sdm_cab_test.cpp
)
target_compile_features(opus_sdm_cab_test PRIVATE cxx_std_20)
target_compile_definitions(opus_sdm_cab_test PRIVATE
WIN WIN23 CRLF NONATIVE OPUS_X64 NOMINMAX
)
target_include_directories(opus_sdm_cab_test PRIVATE ${OPUS_ORIGINAL_INCLUDE_DIRS})
target_link_libraries(opus_sdm_cab_test PRIVATE opus_x64_runtime user32)
if(MSVC)
target_compile_options(opus_sdm_cab_test PRIVATE /J /W4 /permissive-)
endif()
set_target_properties(opus_sdm_cab_test PROPERTIES
FOLDER "Original Opus x64/tests"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tests"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_sdm_cab_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tests/${config}"
)
endforeach()
add_executable(opus_original_command_test
port/original/opus_original_command_test.c
)
add_dependencies(opus_original_command_test opus_generated_commands)
target_include_directories(opus_original_command_test PRIVATE
"${OPUS_GENERATED_COMMAND_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/Opus"
)
if(MSVC)
target_compile_options(opus_original_command_test PRIVATE /W4)
endif()
set_target_properties(opus_original_command_test PROPERTIES
FOLDER "Original Opus x64/tests"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tests"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_original_command_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tests/${config}"
)
endforeach()
# Future product executables link this original-source archive and inherit the
# translated assembly/native-handle runtime at the library boundary.
target_link_libraries(opus_original_engine PUBLIC opus_x64_runtime user32)
# Product executable for Visual Studio's Startup Item list. The Unicode entry
# adapter converts the modern process command line, then transfers control to
# Microsoft's original Opus WinMain and its original window/message loop.
add_executable(WORD1 WIN32
port/original/opus_original_startup_probe.cpp
port/word1.rc
port/winword.manifest
)
add_dependencies(WORD1 opus_original_engine)
target_compile_features(WORD1 PRIVATE cxx_std_20)
target_compile_definitions(WORD1 PRIVATE
WIN WIN23 CRLF NONATIVE OPUS_X64 NOMINMAX UNICODE _UNICODE
)
target_link_libraries(WORD1 PRIVATE opus_original_engine opus_x64_runtime user32 dbghelp)
if(MSVC)
target_compile_options(WORD1 PRIVATE /J /W3 /wd4005 /utf-8)
target_link_options(WORD1 PRIVATE /DYNAMICBASE /HIGHENTROPYVA /NXCOMPAT /MANIFEST:NO)
endif()
set_target_properties(WORD1 PROPERTIES
FOLDER "Original Opus x64/product"
OUTPUT_NAME "${MSWORD_PRODUCT_OUTPUT_NAME}"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
# Diagnostic executable that force-links the same original startup graph as
# WORD1 without product resources. It remains useful as an all-symbol gate.
add_executable(opus_original_startup_probe EXCLUDE_FROM_ALL WIN32
port/original/opus_original_startup_probe.cpp
)
add_dependencies(opus_original_startup_probe opus_original_engine)
target_compile_features(opus_original_startup_probe PRIVATE cxx_std_20)
target_compile_definitions(opus_original_startup_probe PRIVATE
WIN WIN23 CRLF NONATIVE OPUS_X64 NOMINMAX UNICODE _UNICODE
)
target_link_libraries(opus_original_startup_probe PRIVATE opus_original_engine opus_x64_runtime user32 dbghelp)
set_target_properties(opus_original_startup_probe PROPERTIES
FOLDER "Original Opus x64/port probes"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/probes"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_original_startup_probe PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/probes/${config}"
)
endforeach()
add_executable(opus_original_strtbl_test
Opus/strtbl.c
port/original/opus_original_strtbl_test.cpp
)
target_compile_definitions(opus_original_strtbl_test PRIVATE
WIN WIN23 CRLF NONATIVE OPUS_X64 NOMINMAX
)
target_include_directories(opus_original_strtbl_test PRIVATE ${OPUS_ORIGINAL_INCLUDE_DIRS})
target_link_libraries(opus_original_strtbl_test PRIVATE user32)
if(MSVC)
target_compile_options(opus_original_strtbl_test PRIVATE /J /W3 /wd4005)
endif()
set_target_properties(opus_original_strtbl_test PROPERTIES
FOLDER "Original Opus x64/tests"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tests"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_original_strtbl_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tests/${config}"
)
endforeach()
add_executable(opus_x64_runtime_test
port/original/opus_x64_runtime_test.cpp
port/original/opus_x64_layout_test_fixture.c
)
target_compile_features(opus_x64_runtime_test PRIVATE cxx_std_20)
target_compile_definitions(opus_x64_runtime_test PRIVATE
WIN WIN23 CRLF NONATIVE OPUS_X64 NOMINMAX
)
target_include_directories(opus_x64_runtime_test PRIVATE ${OPUS_ORIGINAL_INCLUDE_DIRS})
target_link_libraries(opus_x64_runtime_test PRIVATE opus_x64_runtime user32 gdi32)
set_target_properties(opus_x64_runtime_test PROPERTIES
FOLDER "Original Opus x64/tests"
RUNTIME_OUTPUT_DIRECTORY "${MSWORD_BUILD_ROOT}/tests"
VS_GLOBAL_VcpkgApplocalDeps "false"
)
foreach(config Debug Release RelWithDebInfo MinSizeRel)
string(TOUPPER "${config}" config_upper)
set_target_properties(opus_x64_runtime_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${config_upper} "${MSWORD_BUILD_ROOT}/tests/${config}"
)
endforeach()
enable_testing()
add_test(NAME opus_original_strtbl_test COMMAND $<TARGET_FILE:opus_original_strtbl_test>)
add_test(NAME opus_x64_runtime_test COMMAND $<TARGET_FILE:opus_x64_runtime_test>)
add_test(NAME opus_original_sttb_test COMMAND $<TARGET_FILE:opus_original_sttb_test>)
add_test(NAME opus_original_plc_test COMMAND $<TARGET_FILE:opus_original_plc_test>)
add_test(NAME opus_original_command_test COMMAND $<TARGET_FILE:opus_original_command_test>)
add_test(NAME word1_port_smoke_test COMMAND $<TARGET_FILE:WORD1> --self-test)
+45
View File
@@ -0,0 +1,45 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "x64",
"hidden": true,
"generator": "Visual Studio 17 2022",
"architecture": {
"value": "x64",
"strategy": "set"
},
"binaryDir": "${sourceDir}/../out",
"cacheVariables": {
"CMAKE_INTERMEDIATE_DIR_STRATEGY": "SHORT"
}
},
{
"name": "x64-debug",
"displayName": "Word x64 Debug",
"inherits": "x64"
},
{
"name": "x64-release",
"displayName": "Word x64 Release",
"inherits": "x64"
}
],
"buildPresets": [
{
"name": "x64-debug",
"configurePreset": "x64-debug",
"configuration": "Debug"
},
{
"name": "x64-release",
"configurePreset": "x64-release",
"configuration": "Release"
}
]
}
+1313
View File
File diff suppressed because it is too large Load Diff
+900
View File
@@ -0,0 +1,900 @@
/* clipbord.c -- Cut/Paste to clipboard */
#define NOVIRTUALKEYCODES
#define NOWINSTYLES
#define NOGDICAPMASKS
#define NOSYSMETRICS
#define NOMENUS
#define NOCTLMGR
#define NOFONT
#define NOPEN
#define NOBRUSH
#define NOCOMM
#define NOWNDCLASS
#include "word.h"
DEBUGASSERTSZ /* WIN - bogus macro for assert string */
#include "doc.h"
#include "props.h"
#include "sel.h"
#include "pic.h"
#include "file.h"
#include "disp.h"
#include "screen.h"
#include "prm.h"
#include "opuscmd.h"
#include "debug.h"
#include "format.h"
#include "field.h"
#include "ch.h"
#include "error.h"
extern struct SEL selCur; /* Current selection */
extern int vfSeeSel;
extern struct DOD **mpdochdod[];
extern struct PAP vpapFetch;
extern CP vcpLimParaCache;
extern CP vcpFirstParaCache;
extern struct UAB vuab;
extern struct FCB (**hpfnfcb)[];
extern struct MERR vmerr;
extern HWND vhwndApp; /* handle to parent's window */
extern struct SAB vsab;
extern struct STTB **vhsttbFont;
extern struct PREF vpref;
extern int cfRTF;
extern int cfLink;
extern CHAR HUGE *vhpchFetch;
extern struct CHP vchpFetch;
extern struct CA caPara;
extern CP vcpFetch;
extern int fnFetch;
extern struct PIC vpicFetch;
extern int wwCur;
extern int vwWinVersion;
#ifdef NOTUSED
/* %%Function: CmdClear %%Owner: notused */
CMD CmdClear() /* not implemented [yet?][ever?] */
{
Assert(fFalse);
return cmdOK;
}
#endif
/* %%Function: CmdCopy %%Owner: bobz */
CMD CmdCopy(pcmb)
CMB *pcmb;
{ /* COPY command: copy selection to clipboard */
CMD cmd = cmdOK;
if (selCur.fBlock)
{
/* use FDelCkBlockOk to test for partial fields
in block, which are disallowed */
if (!FDelCkBlockOk(rpkNil, NULL))
return cmdError;
}
if (!FSetUndoBefore(bcmCopy, uccCopy))
return cmdCancelled;
vsab.doc = docNil;
if (selCur.fTable)
cmd = CmdCopyTable(&selCur, docScrap);
else if (selCur.fBlock)
ClBlockSelToScrap();
else
CmdCopy1(&selCur, &selCur.ca);
SetUndoAfter(NULL);
return cmd;
}
/* C M D C O P Y 1 */
/* just sets the scrap to a plain sel */
/* %%Function: CmdCopy1 %%Owner: bobz */
CmdCopy1(psel, pca)
struct SEL *psel; /* describes state of txt in pca */
struct CA *pca; /* text to be copied */
{
struct CA caT;
SetWholeDoc(docScrap, pca);
AssureNestedPropsCorrect(PcaSetWholeDoc(&caT, docScrap), fTrue);
vsab.docStsh = DocMother(pca->doc);
vsab.fFormatted = PdodDoc(vsab.docStsh)->fFormatted;
vsab.fMayHavePic = PdodMother(vsab.docStsh)->fMayHavePic;
vsab.caCopy = *pca; /* for (dde) Link format */
vsab.fTable = fFalse;
/* Need to see if we copied part of a table cell. If so, the
fInTable flag needs to be turned off */
if (psel->fWithinCell)
ApplyTableProps(PcaSetWholeDoc(&caT, docScrap), fFalse);
ChangeClipboard(); /* Force repaint of clipboard display &
Set ownership. also sets vsab.fPict */
}
#ifdef DEBUG
int vTestClip = 0;
#endif /* DEBUG */
/* C M D P A S T E */
/* paste command on the edit menu
*/
/* %%Function: CmdPaste %%Owner: bobz */
CMD CmdPaste(pcmb)
CMB *pcmb;
{
HWND hWndClipOwner;
struct CHP chpSel;
struct CA caScrap;
struct CA caPaste;
struct CA caRM;
struct CA caT;
CMD cmd;
BOOL fAddPara = fFalse;
CP cpFirst;
StartLongOp(); /* Put up an hourglass */
/* We assume multiple Opus instances are not possible - paste cannot
work between instances of Opus */
#ifdef DEBUG
/* a slimy way to let us test RTF clipboard stuff and let us use
slapWnd to put stuff into the clipboard. If true, we will
paste out of the clipboard even though we put it there ourselves.
*/
if (vTestClip)
goto ForceClipRead;
#endif /* DEBUG */
if ( (hWndClipOwner = GetClipboardOwner()) != vhwndApp )
{
#ifdef DEBUG
ForceClipRead:
#endif
if (!FReadExtScrap()) /* clipbrd contents --> docScrap */
{
SetErrorMat( matLow );
cmd = cmdError;
goto PasteEnd;
}
}
/* docScrap now has clipboard contents; paste them in */
/* Here we reoprt and error if we try to paste into a block selection.
We are specifically not pasting into a block because it can be
really disorienting, especially if autodelete is on. We
generally do not autodelete blocks, but require explicit
deletion. You can paste a block into a normal selection,
however. (We could, I suppose, turn the block to an insert
point then paste, but the autodelete case would be strange. (bz) */
if (!DcpCa(PcaSetWholeDoc( &caScrap, docScrap)) ||
selCur.fBlock && !selCur.fTable)
{
ErrorEid(eidInvalidSelection, "CmdPaste");
cmd = cmdError;
goto PasteEnd;
}
PcaPoint(&caRM, selCur.doc, selCur.ca.cpFirst);
/* Are we pasting to a table?? */
if (selCur.fWithinCell || selCur.fTable)
{
LTablePaste:
cmd = CmdPasteToTable();
goto PasteEnd;
}
else if (vsab.fTable && vpref.fAutoDelete && (selCur.cpFirst == cp0 ||
FInTableDocCp(selCur.doc, selCur.cpFirst-1)) &&
FInTableDocCp(selCur.doc, selCur.cpLim))
{
ErrorEid(eidCantPasteTableInTable, "CmdPaste");
cmd = cmdError;
goto PasteEnd;
}
else if (!vpref.fAutoDelete && FInTableDocCp(selCur.doc, selCur.cpFirst))
{
/* selection begins in a table and contains text outside the table */
TurnOffSel(&selCur);
SelectIns(&selCur, selCur.cpFirst);
goto LTablePaste;
}
else if (vsab.fBlock)
{
cmd = CmdPasteBlock();
goto PasteEnd;
}
else
{
#ifdef DAVIDBO
CommSzNum(SzShared("\tBefore doc:\t"), caRM.doc);
CommSzLong(SzShared("\tBefore cpFirst:\t"), caRM.cpFirst);
CommSzLong(SzShared("\tBefore cpLim:\t"), caRM.cpLim);
#endif /* DAVIDBO */
if (!FSetUndoBefore(bcmPaste, uccPaste))
return cmdCancelled;
TurnOffSel(&selCur);
if ((cmd = CmdAutoDelete(&caRM)) != cmdOK)
goto PasteEnd;
if (!vsab.fFormatted) /* save current char props to apply
to inserted text */
{
GetSelCurChp(fFalse);
chpSel = selCur.chp;
}
if (FInTableDocCp(docScrap, cp0))
{
if (!FEopBeforePca(PcaPoint(&caT, selCur.doc, cpFirst = selCur.cpFirst)))
{
cmd = cmdNoMemory;
goto PasteEnd;
}
if (caT.cpFirst != cpFirst)
{
fAddPara = fTrue;
selCur.cpFirst += ccpEop;
if (selCur.fIns)
selCur.cpLim += ccpEop;
}
}
/* must do after selCur adjusted for fAddPara */
PcaSetDcp( &caPaste, selCur.doc, selCur.cpFirst, DcpCa( &caScrap ));
/* do not pass &selCur.ca; AdjustCp might munge it */
caT = selCur.ca;
if (!FReplaceCpsRM( &caT, &caScrap ))
{
cmd = cmdNoMemory;
goto PasteEnd;
}
#ifdef DCLIPPIC
if (vsab.fPict)
{
CachePara(selCur.doc, selCur.cpFirst);
FetchCp(selCur.doc, selCur.cpFirst, fcmProps);
CommSzRgNum(SzShared("vchpFetch after insert pic repl cps : "), &vchpFetch, cwCHP);
}
#endif
if (vsab.fFormatted)
{
CopyStylesFonts( vsab.docStsh != docNil ? vsab.docStsh : docScrap,
caPaste.doc, caPaste.cpFirst, DcpCa( &caPaste ) );
}
else /* picture or unformatted text from clipboard */
{
int cb;
CHAR grpprl[cbMaxGrpprl];
struct CHP chpT;
/* copy char looks.
compute difference: chpT is StandardChp, which
docScrap got when data was read in from clipboard.
chpSel was the previous selection props.
Express difference as grpprl.
Apply grpprl.
picture notes:
for a picture, the char props are standard except for
fSpec and fcPic being set. If we also add in the
current properties at the insert location now, we don't
have to special case the picture when we want char props
and the pic is the start or total of a selection.
*/
StandardChp(&chpT);
/* cb == 0 if no differences */
if (cb = CbGrpprlFromChp(&grpprl, &chpSel, &chpT))
ApplyGrpprlCa(grpprl, cb, &caPaste);
}
}
/* this will make saves be native if formerly plain */
if (vsab.fPict)
PdodDoc(selCur.doc)->fFormatted = fTrue;
if (vsab.fMayHavePic)
PdodMother(selCur.doc)->fMayHavePic = fTrue;
/* "Go back" points before and after the insertion */
SelectIns( &selCur, caPaste.cpFirst );
PushInsSelCur();
AssureNestedPropsCorrect(&caPaste, fTrue);
SelectPostDelete(caPaste.cpLim);
PushInsSelCur();
caRM.cpLim += DcpCa(&caScrap) + (fAddPara ? ccpEop : 0);
#ifdef DAVIDBO
CommSzNum(SzShared("\tAfter doc:\t"), caRM.doc);
CommSzLong(SzShared("\tAfter cpFirst:\t"), caRM.cpFirst);
CommSzLong(SzShared("\tAfter cpLim:\t"), caRM.cpLim);
#endif /* DAVIDBO */
SetUndoAfter(&caRM);
cmd = cmdOK;
PasteEnd:
EndLongOp(fFalse /* fAll */);
/* this will clear out any eop weirdnesses that would reset
vfSeeSel
*/
UpdateWw( wwCur, fFalse /* fAbortOk*/);
vfSeeSel = fTrue;
return cmd;
}
/* %%Function: DestroyClip %%Owner: bobz */
DestroyClip()
{ /* Handles WM_DESTROYCLIPBOARD message. We are being notified that
the clipboard is being emptied & we don't need to keep its
contents around anymore. */
struct CA ca;
if (vsab.fDontDestroyClip)
return;
vsab.fOwnClipboard = fFalse;
/* Clear out the scrap document */
SetWholeDoc(docScrap, PcaSetNil(&ca));
/* Disable UNDO operations that require the clipboard */
/* should only care about copy and cut, which change the clipboard state */
if (vuab.bcm == bcmCut || vuab.bcm == bcmCopy)
SetUndoNil();
}
/* %%Function: ChangeClipboard %%Owner: bobz */
ChangeClipboard()
{ /* Mark clipboard as changed. If we are not the owner of the clipboard, */
/* make us the owner (via EmptyClipboard). The EmptyClipboard call */
/* will result in a WM_DESTROYCLIPBOARD message being sent to the */
/* owning instance. The CloseClipboard call will result in a */
/* WM_DRAWCLIPBOARD message being sent to the clipboard viewer. */
/* If the clipboard viewer is CLIP.EXE, we will get a WM_PAINTCLIPBOARD */
/* message */
/* Added 10/8/85 by BL: If docScrap is empty, relinquish ownership */
/* of the clipboard */
// for more sense in reading
#define CF_UNRENDERABLE CF_TIFF
int cf = CF_UNRENDERABLE;
CP cpMacScrap = CpMacDocEdit(docScrap);
struct CA caT;
int mm;
BOOL fDIBInMetafile = fFalse;
#ifdef DEBUG
/* used for testing paste - forces us to paste in from clipboard
even if we owned it. Set in SlapWnd and for debugging, turned off when
we load something into the clipboard.
*/
vTestClip = 0;
#endif /* DEBUG */
/* we want all fields in the scrap to be consistent with the vpref
values so we can safely put pictures into the clipboard in CF_TEXT
format. DO this here, sice both cut and paste go through this routine.
*/
ClearFDifferFltg (docScrap, fltgAll);
if (!OpenClipboard( vhwndApp ))
{ /* Couldn't open the clipboard, wipe out contents & disable UNDO */
/* a bit harsh huh? */ /* perhaps, but if we can't open the clipbord
we are in an indeterminite state; better to wipe out contents
and be in a known state */
DestroyClip();
return;
}
/* We want to clear out previous data formats in the clipboard.
Unfortunately, the only way to do this is to call EmptyClipboard(),
which has the side effect of calling us with a WM_DESTROYCLIP
message. We use this primitive global comunication to prevent
docScrap from being wiped out in DestroyClip() */
vsab.fDontDestroyClip = fTrue;
EmptyClipboard();
vsab.fDontDestroyClip = fFalse;
/* Re-validate vsab.fPict (in case a docScrap edit changed what it
should be) */
vsab.fPict = FPicRenderable(docScrap, cp0, cpMacScrap, &mm);
/* if ca is a rejected pic type,(flase return but
mm != MM_NIL) set cf to CF_UNRENDERABLE, which
will be rejected below
*/
if (!vsab.fPict)
cf = (mm == MM_NIL ? CF_TEXT : CF_UNRENDERABLE);
else
{
// just a warning. We will ignore other types
Assert (mm == MM_BITMAP || mm < MM_META_MAX ||
mm == MM_DIB);
switch (mm)
{
default:
// note: if not recognized, cf left at CF_UNRENDERABLE and ignored
if (mm < MM_META_MAX)
{
if (!FDIBInMetafile())
cf = CF_METAFILEPICT;
else
fDIBInMetafile = fTrue;
}
break;
case MM_BITMAP:
cf = CF_BITMAP;
break;
}
}
#ifdef BZ
CommSzNum(SzShared("vsab.fPict "), vsab.fPict);
CommSzNum(SzShared("renderable mm "), mm);
CommSzNum(SzShared("cf "), cf);
#endif /* BZ */
vsab.fOwnClipboard = (cpMacScrap != cp0);
if (vsab.fOwnClipboard)
{ /* only set handles if we really have something in docScrap */
SetClipboardData( CF_OWNERDISPLAY, NULL );
/* don't put out cf_tiff or other rejected pic types, or
rtf or link for any of those types
*/
if (cf != CF_UNRENDERABLE || fDIBInMetafile)
{
SetClipboardData( cfRTF, NULL ); /* always avail */
if (fDIBInMetafile)
{
SetClipboardData( CF_METAFILEPICT, NULL );
SetClipboardData( CF_DIB, NULL );
if (vwWinVersion >= 0x0300)
SetClipboardData( CF_BITMAP, NULL);
}
else
SetClipboardData( cf, NULL );
/* can only link if we can still get at the source w/a bookmark */
if (FCanLinkScrap ())
SetClipboardData( cfLink, NULL );
}
}
CloseClipboard();
}
#ifdef NOTUSED
/* %%Function: FSameClassHwndSz %%Owner: notused */
FSameClassHwndSz( hwnd, szClass )
HWND hwnd;
CHAR szClass[];
{ /* Compare the Class name of hWnd with szClass; return TRUE
if they match, FALSE otherwise. */
#define cchClassMax 40 /* longest class name (for compare purposes) */
CHAR rgchWndClass[ cchClassMax ];
int cbCopied;
/* Count returned by GetClassName does not include terminator */
/* But, the count passed in to it does. */
cbCopied = GetClassName( hwnd, (LPSTR) rgchWndClass, cchClassMax ) + 1;
if (cbCopied <= 1)
return FALSE;
rgchWndClass[ cbCopied - 1 ] = '\0';
return FEqNcSz( rgchWndClass, szClass );
}
#endif /* NOTUSED */
/* F C A N L I N K S C R A P */
/* Return true if the data in doc scrap can be Paste-Linked to.
Conditions: must have a non-empty range in a displayed mother
document.
*/
/* %%Function: FCanLinkScrap %%Owner: bobz */
FCanLinkScrap ()
{
return vsab.doc != docNil && vsab.cpFirst < vsab.cpLim
&& PdodDoc (vsab.doc)->fMother &&
WwDisp(vsab.doc,wwNil,fFalse) != wwNil;
}
/* The following was previously in clipdisp.c */
extern struct FLI vfli;
extern struct SAB vsab;
extern struct SCI vsci;
extern CHAR stEmpty[];
int vwwClipboard=wwNil;
int vmwClipboard=mwNil;
int NEAR FGetClipboardDC( void );
int NEAR ReleaseClipboardDC( void );
#ifdef OPUS_X64
csconst char stFmtTextCs[] =
{ 19, 'W', 'o', 'r', 'd', ' ', 'F', 'o', 'r', 'm', 'a', 't', 't', 'e',
'd', ' ', 'T', 'e', 'x', 't' };
#else
csconst char stFmtTextCs[] = StKey("Word Formatted Text",WordFormattedText);
#endif
/* %%Function: PaintClipboard %%Owner: bobz */
PaintClipboard( hwnd, hps )
HWND hwnd;
HANDLE hps;
{ /* Paint portion of clipboard window indicated by hps */
LPPAINTSTRUCT lpps;
struct WWD *pwwd;
if (vwwClipboard == wwNil)
{
ReportSz("Warning - PaintClipboard with vwwClipBoard nil ignored");
return;
}
/* Must set the scroll bar range each time we get a PAINT message;
CLIPBRD.EXE resets it when it gets WM_DRAWCLIPBOARD */
pwwd = PwwdWw(vwwClipboard);
Assert( pwwd->hwnd == hwnd );
SetScrollRange( pwwd->hwnd, SB_VERT, 0, dqMax-1, TRUE );
SetScrollRange( pwwd->hwnd, SB_HORZ, 0, vsci.xpRightMax, FALSE );
/* 0 size followed by non-0 size means clipboard app may have been
taken down, then re-created; so, reset the scroll bars to
what they should be. */
SyncSbHor(vwwClipboard);
SetElevWw(vwwClipboard);
pwwd = PwwdWw(vwwClipboard);
if ( (lpps = (LPPAINTSTRUCT)GlobalLockClip( hps )) != NULL )
{
HDC hdc = lpps->hdc;
struct RC rcT;
rcT.xpLeft = lpps->rcPaint.left;
rcT.ypTop = lpps->rcPaint.top;
rcT.xpRight = lpps->rcPaint.right;
rcT.ypBottom = lpps->rcPaint.bottom;
GlobalUnlock( hps );
if (FSetDcAttribs( pwwd->hdc = hdc, dccDoc ))
{ /* Paint the clipboard */
InvalWwRc(vwwClipboard, &rcT);
UpdateWw( vwwClipboard, fFalse /*fAbortOK*/ );
}
/* BLOCK workaround windows RIP by deselecting our objects */
{
HDC hdc = PwwdWw(vwwClipboard)->hdc;
Assert(hdc != NULL);
SelectObject(hdc, GetStockObject(SYSTEM_FONT));
SelectObject(hdc, GetStockObject(WHITE_BRUSH));
SelectObject(hdc, GetStockObject(BLACK_PEN));
}
}
/* Since the DC is no longer good, we'll set it to NULL */
PwwdWw(vwwClipboard)->hdc = NULL;
}
/* %%Function: SizeClipboard %%Owner: bobz */
SizeClipboard( hwnd, hrc )
HWND hwnd;
HANDLE hrc;
{ /* Set clipboard window to be the rect in hRC */
/* If rectangle is 0 units high or wide, this means we're losing the
necessity for display until the next size message */
LPRECT lprc;
struct RC rc;
struct WWD *pwwd;
if ( (lprc = (LPRECT)GlobalLockClip( hrc )) == NULL )
return;
rc.xpLeft = lprc->left;
rc.ypTop = lprc->top;
rc.xpRight = lprc->right;
rc.ypBottom = lprc->bottom;
GlobalUnlock( hrc );
/* NULL rectangle means no more displaying until we get a nonnull size */
if (FValidateWwClipboard(hwnd))
{
pwwd = PwwdWw( vwwClipboard );
if (FEmptyRc(&rc))
pwwd->dqElevator = 0;
else
{
pwwd->rcwDisp = rc;
if (pwwd->xhScroll < 0)
pwwd->rcwDisp.xwLeft += dxwSelBarSci;
RcToDrc(&pwwd->rcwDisp, &PdrGalley(pwwd)->drcl);
PdrGalley(pwwd)->drcl.xl = PdrGalley(pwwd)->drcl.yl = 0;
TrashWw( vwwClipboard );
/* 0 size followed by non-0 size means clipboard app may have been
taken down, then re-created; so, reset the scroll bars to
what they should be. */
SyncSbHor(vwwClipboard);
SetElevWw(vwwClipboard);
}
}
}
/* %%Function: VScrollClipboard %%Owner: bobz */
VScrollClipboard( hwnd, sbMessage, posNew )
HWND hwnd;
int sbMessage;
int posNew;
{
struct WWD *pwwd;
int dypPage;
CP cpMac, cpT;
if (vwwClipboard == wwNil)
{
Assert( fFalse );
return;
}
Assert( PwwdWw(vwwClipboard)->hwnd == hwnd );
if (!FGetClipboardDC())
/* Unable to create clipboard device context */
return;
pwwd = PwwdWw(vwwClipboard);
switch ( sbMessage )
{
case SB_THUMBPOSITION:
cpMac = CpMacDoc( PdrGalley(pwwd)->doc );
cpT = cpMac > cpMax / (dqMax - 1)
? (cpMac / (dqMax - 1)) * posNew
: (cpMac * posNew) / (dqMax - 1);
ThumbToCp(vwwClipboard, CpMin(cpT, cpMac-ccpEop), fFalse, fFalse, 0);
break;
case SB_LINEUP:
ScrollDown( vwwClipboard, vsci.dysMinAveLine, vsci.dysMacAveLine );
break;
break;
case SB_LINEDOWN:
ScrollUp( vwwClipboard, vsci.dysMinAveLine, vsci.dysMacAveLine );
break;
case SB_PAGEUP:
case SB_PAGEDOWN:
dypPage = pwwd->ywMac - pwwd->ywMin;
if (dypPage > vsci.dysMacAveLine)
dypPage -= vsci.dysMacAveLine;
(*(sbMessage == SB_PAGEUP ? ScrollDown : ScrollUp))
( vwwClipboard, dypPage, dypPage + vsci.dysMacAveLine - vsci.dysMinAveLine );
break;
}
UpdateWw( vwwClipboard, fFalse );
ReleaseClipboardDC();
}
/* %%Function: HScrollClipboard %%Owner: bobz */
HScrollClipboard( hwnd, sbMessage, posNew )
HWND hwnd;
int sbMessage;
int posNew;
{
struct WWD *pwwd;
int dxpWw;
int xpScroll;
int xpThumb;
if (vwwClipboard == wwNil)
{
Assert( fFalse );
return;
}
Assert( PwwdWw(vwwClipboard)->hwnd == hwnd );
if (!FGetClipboardDC())
/* Unable to create clipboard device context */
return;
pwwd = PwwdWw(vwwClipboard);
dxpWw = pwwd->xwMac - pwwd->xwMin;
xpScroll = abs(DxpScrollHorizWw(vwwClipboard));
switch (sbMessage)
{
case SB_LINEUP: /* line left */
if (xpScroll == 0)
Beep();
else if (vsci.dxpMinScroll > xpScroll)
/* scroll to zero */
ScrollRight(vwwClipboard, xpScroll);
else
/* normal scroll */
ScrollRight(vwwClipboard, vsci.dxpMinScroll);
break;
case SB_LINEDOWN: /* line right */
ScrollLeft( vwwClipboard, vsci.dxpMinScroll );
break;
case SB_PAGEUP: /* page left */
ScrollRight( vwwClipboard, min((dxpWw>>1),xpScroll) );
break;
case SB_PAGEDOWN: /* page right */
ScrollLeft( vwwClipboard, dxpWw>>1 );
break;
case SB_THUMBPOSITION:
xpThumb = NMultDiv(posNew,
vsci.xpRightMax - DxOfRc(&pwwd->rcwDisp),
vsci.xpRightMax);
xpScroll = xpThumb + pwwd->xhScroll;
if (xpScroll > 0)
ScrollLeft(vwwClipboard, xpScroll);
else
ScrollRight(vwwClipboard, -xpScroll);
break;
}
UpdateWw( vwwClipboard, fFalse );
ReleaseClipboardDC();
}
/* A s k C b F o r m a t N a m e */
/* %%Function: AskCBFormatName %%Owner: bobz */
AskCBFormatName( lpchName, cchNameMac )
LPCH lpchName;
int cchNameMac;
{ /* Copy the format name for the current contents of the clipboard
(of which we are the owner) to lpchName, copying no more than
cchNameMac characters */
int cchCopy;
Assert( vsab.fOwnClipboard );
/* Don't give a format name for pictures; the name is covered by the
standard types */
if (!vsab.fPict)
{
if ((cchCopy=*stFmtTextCs) >= cchNameMac)
cchCopy = cchNameMac-1;
bltbx((LPSTR)stFmtTextCs+1, (LPSTR)lpchName, cchCopy);
lpchName[cchCopy] = 0;
}
}
/* F G e t C l i p b o a r d D C */
/* %%Function: FGetClipboardDC %%Owner: bobz */
int NEAR FGetClipboardDC()
{ /* Get a DC for the clipboard window. Leave it in rgwwd [wwClipboard].
Select in the background brush for appropriate color behavior.
return TRUE if all is well, FALSE if something went wrong */
struct WWD *pwwd;
if (vwwClipboard == wwNil)
return fFalse;
pwwd = PwwdWw(vwwClipboard);
if ((pwwd->hdc = GetDC( pwwd->hwnd )) == NULL)
return fFalse;
if (!FSetDcAttribs( pwwd->hdc, dccDoc ))
{
ReleaseClipboardDC();
return fFalse;
}
return fTrue;
}
/* R e l e a s e C l i p b o a r d D C */
/* %%Function: ReleaseClipboardDC %%Owner: bobz */
int NEAR ReleaseClipboardDC()
{
struct WWD *pwwd;
Assert( vwwClipboard != wwNil );
pwwd = PwwdWw(vwwClipboard);
ReleaseDC( pwwd->hwnd, pwwd->hdc );
pwwd->hdc = NULL;
}
/* %%Function: FValidateWwClipboard %%Owner: bobz */
int FValidateWwClipboard( hwnd )
HWND hwnd;
{
struct SELS sels;
if (vwwClipboard == wwNil)
{
sels.ca.doc = docNil;
if (!FCreateMw( docScrap, wkClipboard, &sels, NULL))
return fFalse;
Assert( vwwClipboard != wwNil && vmwClipboard != mwNil );
}
PwwdWw(vwwClipboard)->hwnd = hwnd;
return fTrue;
}
+2305
View File
File diff suppressed because it is too large Load Diff
+1211
View File
File diff suppressed because it is too large Load Diff
+1100
View File
File diff suppressed because it is too large Load Diff
+1063
View File
File diff suppressed because it is too large Load Diff
+1216
View File
File diff suppressed because it is too large Load Diff
+219
View File
@@ -0,0 +1,219 @@
/******************************************************************************
**
** COPYRIGHT (C) 1987 MICROSOFT
**
*******************************************************************************
**
** Module: dlbenum.c --- Drop-Down List Box enumeration function
**
** Functions included:
**
** REVISIONS
**
** Date Who Rel Ver Remarks
** 4/17/87 yxy Original
** 5/28/87 bac Put the strings in CS too
**
*****************************************************************************/
#define NOMINMAX
#define NOBRUSH
#define NOICON
#define NOPEN
#define NOGDICAPMASKS
#define NOVIRTUALKEYCODES
#define NOSYSMETRICS
#define NOCLIPBOARD
#define NOKEYSTATE
#define NORASTEROPS
#define NOSHOWINDOW
#define NOCREATESTRUCT
#define NODRAWTEXT
#define NOMB
#define NOMEMMGR
#define NOMETAFILE
#define NOWH
#define NOWNDCLASS
#define NOREGION
#define NOSOUND
#define NOCOMM
#include "word.h"
DEBUGASSERTSZ /* WIN - bogus macro for assert string */
#include "debug.h"
#include "dlbenum.h"
#ifdef OPUS_X64
/* This table is consumed only through CopyEntblToSz. Keep source labels as
* ordinary native literals and convert at that boundary. */
#undef StKey
#undef StShared
#undef StSharedKey
#define StKey(text, key) text
#define StShared(text) text
#define StSharedKey(text, key) text
#endif
csconst ENTBL rgEntbl[] = {
{
cFNPos,
/* Must correspond to ordering of fpc in DOP */
{
StKey("End of Section",NoteEndSec),
StKey("Bottom of Page",NoteBottom),
StKey("Beneath Text",NoteBeneath),
StKey("End of Document",NoteEndDoc)
}
},
{
cSkt,
/* WARNING: these must agree with
the skt's in sort.h in
number and order; update cSkt
in sort.h and rgstSkt in sort.c
if you add more */
{
StKey("Alphanumeric",SortAlphanumeric),
StKey("Numeric",SortNumeric),
StKey("Date",SortDate)
}
},
{
cDffSave,
/* Must correspond to dffSave order in filecvt.h */
{
StKey("Normal",SaveNormal),
StKey("Document Template",SaveTemplate),
StKey("Text Only",SaveText),
StKey("Text+breaks",SaveTextBreaks),
StKey("Text Only (PC-8)",SaveText8),
StKey("Text+breaks (PC-8)",SaveText8Breaks),
StKey("RTF",RTF)
}
},
{ /* page number format */
/* If you change this ordering, also change
mpnfcipg and mpipgnfc in hddwin.c */
cNfc,
{
StShared("1 2 3..."),
StShared("a b c..."),
StShared("A B C..."),
StShared("i ii iii..."),
StShared("I II III...")
}
},
{ /* Catalog Sort Factor */
cCatSort,
{
StKey("Name",SortName),
StKey("Author",SortAuthor),
StKey("Creation Date",SortCreateDate),
StKey("Last Saved Date",SortSaveDate),
StKey("Last Saved by",SortSaveBy),
StKey("Size",SortSize)
}
},
{ /* print source */
cPrSrc,
/* must correspond to ordering in print.h */
{
StKey("Document",PrintDoc),
StKey("Summary Info",PrintSummary),
StKey("Annotations",PrintAnnotations),
StKey("Styles",PrintStyles),
StKey("Glossary",PrintGlsy),
StKey("Key Assignments",PrintKeys)
}
},
{ /* print feed */
/* must correspond to iidBin ordering in print.h */
cPrFeed,
{
StKey("Manual",PrintBinManual),
StKey("Envelope",PrintBinEnvelope),
StKey("Tractor",PrintBinTractor),
StKey("Auto",PrintBinAuto),
StKey("Bin 1",PrintBin1),
StKey("Bin 2",PrintBin2),
StKey("Bin 3",PrintBin3),
StKey("Mixed",PrintMixed)
}
},
{ /* FileOpen converter names */
/* order must correspond to dffOpen in filecvt.h */
cDffOpen,
{
StSharedKey("Text",OpenText),
StSharedKey("Text (PC-8)",OpenText8),
StShared("RTF"),
StShared("BIFF (Excel 2.X)"),
StShared("Multiplan 3.0"),
StShared("WKS")
}
},
{
cBrclTable,
/* For table borders (all except outline) */
{
StKey("None",BrclNone),
StKey("Single",BrclSingle),
StKey("Thick",BrclThick),
StKey("Double",BrclDouble),
}
},
};
/* %%Function: CopyEntblToSz %%Owner: bobz */
CopyEntblToSz(iEntbl, isz, sz)
int iEntbl;
int isz;
CHAR *sz;
{
CHAR FAR *lpch;
Assert(isz < rgEntbl[iEntbl].iMax && iEntbl < iEntblMax);
#ifdef OPUS_X64
strcpy(sz, rgEntbl[iEntbl].rgst[isz]);
#else
bltbx((CHAR FAR *) (rgEntbl[iEntbl].rgst[isz]), (CHAR FAR *) sz,
rgEntbl[iEntbl].rgst[isz][0]+1);
StToSzInPlace(sz);
#endif
}
/* %%Function: FEnumIEntbl %%Owner: bobz */
BOOL FEnumIEntbl(iEntbl, isz, sz)
int iEntbl;
int isz;
CHAR *sz;
{
Assert(iEntbl < iEntblMax);
if (isz < rgEntbl[iEntbl].iMax)
{
CopyEntblToSz(iEntbl, isz, sz);
return (fTrue);
}
else
{
return (fFalse);
}
}
#ifdef PROFILE
/* this is here so that appended native code does not appear in previous
function in pcode profiles. */
Dlbenum_Last(){}
#endif /* PROFILE */
/* ADD NEW CODE *ABOVE* Dlbenum_Last() */
+2750
View File
File diff suppressed because it is too large Load Diff
+1431
View File
File diff suppressed because it is too large Load Diff
+1327
View File
File diff suppressed because it is too large Load Diff
+1750
View File
File diff suppressed because it is too large Load Diff
+977
View File
@@ -0,0 +1,977 @@
/* loadfont.c - MW font support code */
#include "word.h"
DEBUGASSERTSZ /* WIN - bogus macro for assert string */
#include "heap.h"
#include "props.h"
#include "disp.h"
#include "doc.h"
#include "format.h"
#include "print.h"
#include "screen.h"
#include "sel.h"
#include "ch.h"
#include "debug.h"
#ifdef PCJ
/* #define DFONT */
#endif /* PCJ */
#ifdef BRYANL
#define DFONT
#endif
extern struct STTB **vhsttbFont;
extern struct SAB vsab;
extern int wwMac;
extern struct WWD **mpwwhwwd[];
extern struct DOD **mpdochdod[];
extern struct MERR vmerr;
extern struct PRI vpri;
extern struct SCI vsci;
extern struct SEL selCur;
extern struct FLI vfli;
extern int vlm;
extern int vfPrvwDisp;
extern int vifceMac;
extern struct FCE rgfce[ifceMax];
extern struct FTI vfti;
extern struct FTI vftiDxt;
extern struct PREF vpref;
extern struct CHP vchpStc;
extern CHAR szEmpty[];
HANDNATIVE struct FCE *PfceLruGet();
/* LoadFont( pchp, fWidthsOnly )
*
* Description: LoadFont loads the font specified by pchp into appropriate DC's
*/
#if defined(DEBUG) || defined(OPUS_X64)
/* %%Function:C_LoadFont %%Owner:bryanl */
HANDNATIVE C_LoadFont( pchp, fWidthsOnly )
struct CHP *pchp;
int fWidthsOnly;
{
union FCID fcid;
struct DOD *pdod;
Assert( vfli.doc != docNil );
Assert( pchp != NULL);
/* Map font requests in short DOD back through parent DOD */
pdod = PdodMother(vfli.doc);
/* in Print, map docUndo to real mother doc */
if (vfli.doc == docUndo)
{
Assert(vlm == lmPrint);
Assert(PdodDoc(docUndo)->doc != docNil);
pdod = PdodDoc(PdodDoc(docUndo)->doc);
}
/* font table was not actually copied to scrap, so map request back to
data provider doc, just like MapStc does for styles */
else if (pdod == PdodDoc(docScrap) && vsab.docStsh != docNil)
pdod = PdodDoc(vsab.docStsh);
/* Translate chp --> fcid */
fcid.lFcid = 0L;
fcid.fItalic = pchp->fItalic;
fcid.fBold = pchp->fBold;
fcid.fStrike = pchp->fStrike;
#ifdef DFONT
if ((uns)pchp->ftc >= pdod->ftcMac)
{
int rgw [3];
rgw [0] = pchp->ftc;
rgw [1] = pdod->ftcMac;
rgw [2] = vfli.doc;
CommSzRgNum(SzFrame("Font ref out of range, (ftc,ftcMac,doc): "),rgw, 3);
}
#endif
/* protect against out-of-range ftcs in case of bogus doc or
failed ApplyGrpprlCa during font merge after interdoc paste */
fcid.ibstFont = (**pdod->hmpftcibstFont) [min( pchp->ftc, pdod->ftcMac-1)];
Assert( (uns)fcid.ibstFont < (*vhsttbFont)->ibstMac );
fcid.hps = pchp->hps;
fcid.kul = pchp->kul;
vfti.dxpExpanded = vftiDxt.dxpExpanded = 0;
if (vfli.fFormatAsPrint)
{ /* Two-device case: Displaying; formatting for printer */
/* First determine what font we can get for the printer */
C_LoadFcid( fcid, &vftiDxt, fTrue );
if (pchp->qpsSpace != 0)
vftiDxt.dxpExpanded = C_DxuExpand(pchp,vftiDxt.dxpInch);
/* Then request a screen font based on what we got back */
C_LoadFcid( vftiDxt.fcid, &vfti, fWidthsOnly );
}
else
{ /* One-device case: 1. Printing
2. Displaying; formatting for screen */
C_LoadFcid( fcid, &vfti, fWidthsOnly );
}
if (pchp->qpsSpace != 0)
{
vfti.dxpExpanded = C_DxuExpand(pchp,vfti.dxpInch);
#ifdef DFONT
CommSzNum( SzShared( "Font expansion in pixels = "),vfti.dxpExpanded );
#endif
}
}
#endif /* DEBUG || OPUS_X64 */
#if defined(DEBUG) || defined(OPUS_X64)
/* %%Function:C_LoadFcidFull %%Owner:bryanl */
HANDNATIVE C_LoadFcidFull( fcid )
union FCID fcid;
{
C_LoadFcid( fcid, &vfti, fFalse /* fWidthsOnly */);
}
#endif /* DEBUG || OPUS_X64 */
/* LoadFcid( fcid, pfti, fWidthsOnly )
*
* Description:
*
* Loads a font described by fcid. Sets up *pfti to describe the font, and
* selects the font into pfti->hdc
*
* Inputs:
* fcid - a long describing the font
* pfti - pointer to fti structure to fill out
*
* pfti->hdc - If fPrinter is set, this is the printer DC.
* If not, this is some document DC, or maybe the memory DC --
* some screen DC into which FSelectFont selects.
*
* Outputs:
*
* *pfti is filled out with a description of the font actually realized for
* the request. Note that it is frequently true that pfti->fcid != fcid passed
*
* Methods:
*
* The last ifceMax fonts requested through LoadFcid are kept in a LRU cache,
* such that the descriptive information, width tables, and mapping from
* requested to actual font are kept around for quick access.
*
* The fonts that are cached for the device described in *pfti are
* kept on a chain extending from pfti->pfce.
*
* If a font is currently selected into the device, then pfti->hfont
* will be non-null and pfti->fcid will describe the font.
*
* The fcid acts as the key field in looking up a font. FCID is structured
* so that the first word, wProps, contains those fields considered most
* likely to vary.
*
*/
#if defined(DEBUG) || defined(OPUS_X64)
/* %%Function:C_LoadFcid %%Owner:bryanl */
HANDNATIVE C_LoadFcid( fcid, pfti, fWidthsOnly )
union FCID fcid;
struct FTI *pfti;
int fWidthsOnly;
{
extern int vflm;
int dyp;
struct FCE *pfce;
struct FCE *pfceHead;
int fFallback;
LOGFONT lf;
TEXTMETRIC tm;
int dxp;
HDC hdc;
Assert( vflm != flmIdle );
/* CASE 1: No fonts cached for this device */
if ((pfce = pfti->pfce) == NULL)
{
goto LNewFce;
}
/* CASE 2: There is a font already selected in, and it matches the request */
if (pfti->hfont != NULL)
{
if (fcid.wProps == pfce->fcidRequest.wProps &&
fcid.wExtra == pfce->fcidRequest.wExtra)
{
vfli.fGraphics |= pfce->fGraphics;
return;
}
pfce = pfce->pfceNext; /* start following search with 2nd font in chain */
}
/* CASE 3: Font request matches some cached request for this device */
while (pfce != NULL)
{
if (pfce->fcidRequest.wProps == fcid.wProps &&
pfce->fcidRequest.wExtra == fcid.wExtra)
{
HFONT hfontT;
Assert( pfce->hfont != NULL );
if (vfPrvwDisp && !pfce->fPrvw || !vfPrvwDisp && pfce->fPrvw)
goto LNextFce;
/* Remove the FCE from its present position in its chain */
if (pfce == pfti->pfce)
{
pfti->pfce = pfce->pfceNext;
}
else
{
Assert( pfce->pfcePrev != NULL );
if ((pfce->pfcePrev->pfceNext = pfce->pfceNext) != 0)
pfce->pfceNext->pfcePrev = pfce->pfcePrev;
}
/* Optimization: don't actually select in the font if we know
its width and we're just formatting so that's all we need */
if (fWidthsOnly)
pfti->hfont = NULL;
else if (pfce->hfont == hfontSpecNil)
goto LValidateFce;
else if (hfontT = pfce->hfont,
!FSelectFont( pfti, &hfontT, &hdc))
/* font could not be selected so system font was selected in its place */
{
FreeHandlesOfPfce(pfce);
#ifdef DFONT
CommSzSz(SzFrame("Could not re-select cached font"),szEmpty);
#endif
goto LSystemFontErr;
}
goto LLoadFce;
}
LNextFce:
pfce = pfce->pfceNext;
}
/* CASE 4: No FCE in table for requested font, must build one */
LNewFce:
/* Get a free FCE slot in which to build new entry */
pfce = PfceLruGet(); /* Kicks out LRU font, if no unallocated FCE slots exist */
LValidateFce:
pfce->fPrvw = vfPrvwDisp;
fFallback = fFalse;
pfce->fPrinter = pfti->fPrinter;
pfce->fcidRequest = fcid;
pfce->fGraphics = fTrue; /* the safer assumption in case of failure */
if (pfti->fTossedPrinterDC)
{
Assert( pfti->fPrinter );
Assert( fWidthsOnly );
/* up till now, we have cheated -- we don't really have a printer DC,
but we have been able to manage without it since our cache is filled
with font widths. Now comes the time to pay the piper.
Create a printer IC. */
if (!FReviveTossedPrinterDC(pfce))
goto LLoadFce;
}
/* Translate FCID request to a logical font */
if (fcid.ibstFont == ibstFontNil || (!pfti->fPrinter && vpref.fDraftView)) /* ibstFontNil means use system font */
goto LSystemFont;
pfce->fGraphics = FGraphicsFcidToPlf( fcid, &lf, pfce->fPrinter );
/* Call Windows to request the font */
if ((pfce->hfont = CreateFontIndirect( (LPLOGFONT)&lf )) == NULL)
{
#ifdef DFONT
CommSzSz(SzFrame("Failed to create logical font!"),szEmpty);
#endif
LSystemFontErr:
SetErrorMat(matFont);
fFallback = fTrue;
LSystemFont:
pfce->hfont = GetStockObject( pfti->fPrinter ?
DEVICEDEFAULT_FONT : SYSTEM_FONT );
}
LogGdiHandle(pfce->hfont, 10000);
#ifdef DFONT
CommSzNum(SzShared("Font handle: "), pfce->hfont);
#endif /* DFONT */
/* Now fill out the FCE entry with the attributes of the new font */
/* A false return from FSelectFont means we got the system font instead,
but we don't care here */
FSelectFont( pfti, &pfce->hfont, &hdc );
LNewMetrics:
Assert( hdc != NULL );
GetTextMetrics( hdc, (LPTEXTMETRIC) &tm );
#ifdef DFONT
{
char szFace[256];
int rgw [7];
GetTextFace(hdc, LF_FACESIZE, (LPSTR)szFace);
CommSzSz(SzShared(" Actual face name: "), szFace);
rgw [0] = tm.tmHeight - tm.tmInternalLeading;
rgw [1] = tm.tmExternalLeading;
rgw [2] = tm.tmInternalLeading;
rgw [3] = tm.tmAscent;
rgw [4] = tm.tmDescent;
CommSzRgNum( SzShared(" Actual ht(no ldng), e-ldng, i-ldng, asc (w/i-ldng), desc: "),
rgw, 5 );
CommFontAttr( SzShared( " Actual Attributes: "),
tm.tmItalic, tm.tmStruckOut, tm.tmUnderlined, tm.tmWeight > FW_NORMAL);
rgw [0] = tm.tmPitchAndFamily >> 4;
rgw [1] = tm.tmPitchAndFamily & 1;
rgw [2] = tm.tmCharSet;
rgw [3] = tm.tmAveCharWidth;
rgw [4] = tm.tmOverhang;
CommSzRgNum(SzShared(" Actual font family, pitch, charset, avg wid, overhang: "),
rgw, 5 );
}
#endif /* DFONT */
pfce->dypAscent = tm.tmAscent;
pfce->dypDescent = tm.tmDescent;
pfce->dypXtraAscent = tm.tmAscent;
if (pfti->fPrinter)
pfce->dypXtraAscent += tm.tmExternalLeading;
pfce->dxpOverhang = tm.tmOverhang;
/* Initialize the width table.
Fixed Pitch: store fixed width
Variable Pitch, store width table
*/
Debug( vdbs.fShakeHeap ? ShakeHeap() : 0 );
pfce->fFixedPitch = fTrue;
pfce->dxpWidth = tm.tmAveCharWidth;
pfce->fVisiBad = fFalse;
if ((tm.tmPitchAndFamily & maskFVarPitchTM) && !fFallback)
{
int ch; /* MUST be int so chDxpMax == 256 will work */
int far *lpdxpT;
int far *lpdxpMin;
int idxp;
int FAR *lpdxp;
int mpchdxp [chDxpMax];
#ifdef OPUS_X64
if ((pfce->hqrgdxp = HqAllocLcb(
(long)((chDxpMax - chDxpMin) * sizeof(int)))) == hqNil)
#else
if ((pfce->hqrgdxp = HqAllocLcb( (long)((chDxpMax - chDxpMin ) << 1))) == hqNil)
#endif
{
Assert( pfce->hfont != GetStockObject( pfti->fPrinter ?
DEVICEDEFAULT_FONT : SYSTEM_FONT ));
#ifdef DFONT
CommSzSz(SzFrame("Failed to allocate space for font widths!"),szEmpty);
#endif
/* lose track of logical font & hqrgdxp, but that's tolerable */
goto LSystemFontErr;
}
lpdxp = (int FAR *) LpLockHq( pfce->hqrgdxp );
Assert( lpdxp != NULL ); /* Should be guaranteed */
/* WINDOWS BUG WORKAROUND (DAVIDBO): GetCharWidth RIPs on any mapping mode
other than MM_TEXT */
if (vfPrvwDisp)
OurGetCharWidth( hdc, chDxpMin, chDxpMax - 2, lpdxp);
/* DRIVER BUG WORKAROUND (BL): Don't ask for n-255 or the EPSON24 and
several other raster printer drivers will crash when you ask for widths */
else if (!GetCharWidth( hdc, chDxpMin, chDxpMax - 2, lpdxp ))
{
ReportSz("Driver does not support GetCharWidth!");
OurGetCharWidth( hdc, chDxpMin, chDxpMax - 2, lpdxp );
}
OurGetCharWidth( hdc, chDxpMax - 1, chDxpMax - 1, &lpdxp [chDxpMax-1] );
if (pfce->dxpOverhang)
{
lpdxpMin = lpdxp;
lpdxpT = lpdxpMin + (chDxpMax - chDxpMin - 1);
while (lpdxpT >= lpdxpMin)
{
*lpdxpT-- -= pfce->dxpOverhang;
}
}
pfce->fFixedPitch = fFalse;
pfce->fVisiBad = (lpdxp [chSpace] != lpdxp [chVisSpace]);
UnlockHq( pfce->hqrgdxp );
}
/* Now built fcidActual according to the properties of the font we got */
/* We only care about fcidActual for printer fonts */
if (pfti->fPrinter)
{
union FCID fcidActual;
CHAR rgb [cbFfnLast];
struct FFN *pffn = (struct FFN *) &rgb [0];
fcidActual.lFcid = 0L;
/* Store back the real height we got */
fcidActual.hps = umin( 0xFF,
(NMultDiv( tm.tmHeight - tm.tmInternalLeading, czaInch,
vfli.dyuInch ) + (czaPoint / 4)) / (czaPoint / 2));
if (tm.tmWeight > (FW_NORMAL + FW_BOLD) / 2)
fcidActual.fBold = fTrue;
if (tm.tmItalic)
fcidActual.fItalic = fTrue;
if (tm.tmStruckOut)
fcidActual.fStrike = fTrue;
/* following line says: if we got back underlining, we can do double underlining too.
That's because we print double underlines by printing underlined spaces
just below the first underline. Also let dotted ul through
regardless because it is only used on the screen */
if (tm.tmUnderlined || fcid.kul == kulDotted)
fcidActual.kul = fcid.kul;
fcidActual.prq = (tm.tmPitchAndFamily & maskFVarPitchTM)
? VARIABLE_PITCH : FIXED_PITCH;
/* For printer fonts, we may get back a font with a different name than
the one we requested.
If this in fact happened, add the new name to the master font table
*/
GetTextFace( hdc, LF_FACESIZE, (LPSTR) pffn->szFfn );
if (!FNeNcSz(pffn->szFfn, lf.lfFaceName))
{
/* The face name is the same as what we requested; so, the
font index should be the same. */
fcidActual.ibstFont = pfce->fcidRequest.ibstFont;
}
else
{ /* Font supplied by printer is different from request */
int ibst;
pffn->ffid = tm.tmPitchAndFamily & maskFfFfid;
pffn->cbFfnM1 = CbFfnFromCchSzFfn( CchSz( pffn->szFfn ) ) - 1;
ChsPffn(pffn) = tm.tmCharSet;
if ((ibst = IbstFindSzFfn( vhsttbFont, pffn )) == iNil)
/* Font supplied by printer is not in table, add it */
/* note: If ibstNil is returned from IbstAddStToSttb that's fine,
it just means we will select the system font whenever we use the
result. */
{
Assert ((ibstNil & 0xFF) == ibstFontNil);
ibst = IbstAddStToSttb( vhsttbFont, pffn );
}
fcidActual.ibstFont = ibst;
}
pfce->fcidActual = fcidActual;
}
else
{ /* Screen font - don't care about fcidActual */
if (vpref.fDraftView && (fcid.fBold
|| fcid.fItalic
|| fcid.kul != kulNone
|| fcid.fStrike))
fcid.kul = kulSingle;
pfce->fcidActual = fcid;
}
LLoadFce:
/* Put pfce at the head of the chain extending from pfti */
/* When we get here, pfce is not in any chain */
pfceHead = pfti->pfce;
pfti->pfce = pfce;
pfce->pfcePrev = NULL;
pfce->pfceNext = pfceHead;
if (pfceHead != NULL)
pfceHead->pfcePrev = pfce;
/* Load info about fce into *pfti */
vfli.fGraphics |= pfce->fGraphics;
bltbyte( pfce, pfti, cbFtiFceSame );
if (pfce->fFixedPitch)
SetWords( pfti->rgdxp, pfce->dxpWidth, 256 );
else
{
#ifdef OPUS_X64
bltbh(HpOfHq(pfce->hqrgdxp), (int HUGE *)pfti->rgdxp,
sizeof(pfti->rgdxp));
#else
bltbh( HpOfHq( pfce->hqrgdxp ), (int HUGE *)pfti->rgdxp, 512 );
#endif
}
Debug( vdbs.fCkFont ? CkFont() : 0 );
}
#endif /* DEBUG || OPUS_X64 */
#if defined(DEBUG) || defined(OPUS_X64) /* Done in formatn2.asm on Win16 */
/* O U R S E L E C T O B J E C T */
/* performs a SelectObject, reducing the swap area SOME if it fails */
/* %%Function:OurSelectObject %%Owner:bryanl */
HANDLE OurSelectObject(hdc, h)
HDC hdc;
HANDLE h;
{
extern int vsasCur;
HANDLE hRet = SelectObject(hdc, h);
if (hRet == NULL && vsasCur <= sasMin)
{
/* reduce swap area to an acceptable level (won't swap too much, but
may have more room for fonts) */
OurSetSas(sasMin);
hRet = SelectObject(hdc, h);
/* increase the swap area back as far as we can */
OurSetSas(sasFull);
}
return hRet;
}
#endif /* DEBUG || OPUS_X64 */
/* FSelectFont( pfti, phfont, phdc )
*
* Description:
*
* Selects the font hfont into the DC(s) for the screen (!pfti->fPrinter) or
* the printer (pfti->fPrinter).
*
* Inputs:
*
* pfti Specifies device (screen or printer) into which to select font
*
* Outputs:
*
* pfti->hfont Set to *phfont
* *phfont if return is FALSE, may differ from provided value
*
* Returns TRUE if the select succeeded; FALSE if it failed and we
* selected in the system/device default font instead
*
*/
#if defined(DEBUG) || defined(OPUS_X64)
/* %%Function:FSelectFont %%Owner:bryanl */
HANDNATIVE FSelectFont( pfti, phfont, phdc )
struct FTI *pfti;
HFONT *phfont;
HDC *phdc;
{
HFONT hfontOrig = *phfont;
int ww;
#ifdef DFONT
static int fDFComm = fTrue;
#endif
Assert( *phfont != NULL && *phfont != hfontSpecNil );
Assert( pfti != NULL );
if (pfti->fPrinter)
{ /* Selecting into printer DC */
#ifdef DFONT
if (*phfont == GetStockObject( DEVICEDEFAULT_FONT ))
CommSz(SzShared( "Selecting printer font: DEVICEDEFAULT_FONT\r\n"));
else
CommSzNum(SzShared("Selecting printer font: "), *phfont );
#endif /* DFONT */
Assert( vpri.hdc != NULL );
/* We should not have been called if there is no printer device */
Assert( vpri.pfti != NULL );
*phdc = vpri.hdc;
if (OurSelectObject( *phdc, *phfont ) == NULL)
{
/* Selecting a font into the printer DC failed */
/* This probably means we are out of global memory */
/* Use DEVICEDEFAULT_FONT instead; it is guaranteed to succeed */
#ifdef DFONT
CommSzSz(SzFrame("Could not select printer font"),szEmpty);
#endif
SetErrorMat(matFont);
*phfont = GetStockObject( DEVICEDEFAULT_FONT );
AssertDo( OurSelectObject( *phdc, *phfont ) );
}
}
else if (vfPrvwDisp)
{
SelectPrvwFont(phfont, phdc);
}
else
{ /* Selecting into screen DCs */
HFONT hfontSystem = GetStockObject( SYSTEM_FONT );
#ifdef DFONT
if (fDFComm)
if (*phfont == GetStockObject( SYSTEM_FONT ))
CommSz(SzShared( "Selecting screen font: SYSTEM_FONT\r\n"));
else
CommSzNum(SzShared("Selecting screen font: "), *phfont);
#endif /* DFONT */
Assert( vsci.pfti != NULL ); /* This should always be true */
/* or we should not have been called */
Assert( vsci.hdcScratch );
*phdc = vsci.hdcScratch;
#ifdef DEBUG
if (vpref.fDraftView)
Assert( *phfont == hfontSystem );
#endif
#ifdef DISABLE /* GlobalWire taking ~50% of time! */
if (*phfont != hfontSystem)
{
HFONT hfontSav;
HANDLE hfontPhy;
int f;
if (!(hfontSav = OurSelectObject( vsci.hdcScratch, *phfont)))
goto LScreenFail;
hfontPhy = GetPhysicalFontHandle( vsci.hdcScratch );
if (!OurSelectObject( vsci.hdcScratch, hfontSav))
goto LScreenFail;
#ifdef DFONT
fDFComm = fFalse;
#endif
ResetFont(fFalse /*fPrinterFont*/);
#ifdef DFONT
fDFComm = fTrue;
#endif
if (((f=GlobalFlags(hfontPhy)) & GMEM_LOCKCOUNT) == 0 &&
(f & ~GMEM_LOCKCOUNT) != 0)
{
Scribble(ispWireFont, 'W');
GlobalWire(hfontPhy);
GlobalUnlock(hfontPhy); /* because GlobalWire locked it */
}
}
#endif /* DISABLE */
for ( ;; )
{
/* Select the font into the scratchpad memory DC and all window DC's*/
if (vsci.hdcScratch)
if (!OurSelectObject( vsci.hdcScratch, *phfont ))
{
/* could not select in the font: revert back to the system font */
LScreenFail:
#ifdef DFONT
CommSzSz(SzFrame("Failed to select screen font"),szEmpty);
#endif
SetErrorMat(matFont);
if (*phfont != hfontSystem)
{
*phfont = hfontSystem;
continue;
}
/* this should never happen, according to paulk, but just in case.. */
Assert( fFalse );
break;
}
for ( ww = wwDocMin; ww < wwMac; ww++ )
{
struct WWD **hwwd = mpwwhwwd [ww];
HDC hdc;
/* test for hdc == NULL is for wwdtClipboard, whose DC is only
present inside clipboard update messages. See clipdisp.c */
if (hwwd != hNil && (hdc = (*hwwd)->hdc) != NULL)
{
/* Hack to workaround problem with font mapper 3/18/89: for some unknown
reason, the mapper won't select the Preview and Terminal screen
fonts for a window hdc, although it will for a memory DC compatible
with it(!). To workaround this, store away hdc to make sure
the font cache gets the metrics that will accurately reflect the screen
results. (BL) */
*phdc = hdc;
if (!OurSelectObject( hdc, *phfont ))
goto LScreenFail;
}
}
break;
} /* end for ( ;; ) */
}
Scribble(ispWireFont, ' ');
pfti->hfont = *phfont;
return *phfont == hfontOrig;
}
#endif /* DEBUG || OPUS_X64 */
/* R E S E T F O N T */
#if defined(DEBUG) || defined(OPUS_X64)
/* %%Function:C_ResetFont %%Owner:bryanl */
HANDNATIVE C_ResetFont(fPrinterFont)
BOOL fPrinterFont;
{
/* This routine sets to NULL the currently selected printer or screen font,
depending on the value of fPrint. It does not free any fonts, leaving the
device's font chain intact.
This should be done before freeing fonts to assure that none are selected
into DC's. It may also be used if explicit use of the system font is required.
*/
extern BOOL vfPrinterValid;
struct FTI *pfti;
HDC hdcT;
HFONT hfont;
if ((pfti = (fPrinterFont) ? vpri.pfti : vsci.pfti) == NULL)
return; /* device does not exist */
if (fPrinterFont && vpri.pfti->fTossedPrinterDC)
{ /* printer DC was tossed away */
goto LNoFont;
}
hfont = GetStockObject( fPrinterFont ? DEVICEDEFAULT_FONT : SYSTEM_FONT );
AssertDo(FSelectFont( pfti, &hfont, &hdcT ));
LNoFont:
pfti->hfont = NULL; /* So we know there's no cached font in pfti->hdc */
pfti->fcid.lFcid = fcidNil;
}
#endif /* DEBUG || OPUS_X64 */
/* F C I D T O P L F */
#if defined(DEBUG) || defined(OPUS_X64)
/* %%Function:C_FGraphicsFcidToPlf %%Owner:bryanl */
HANDNATIVE C_FGraphicsFcidToPlf( fcid, plf, fPrinterFont )
union FCID fcid;
LOGFONT *plf;
int fPrinterFont;
{ /* Translate an FCID into a windows logical font request structure */
int ps;
struct FFN *pffn;
SetBytes(plf, 0, sizeof(LOGFONT));
/* Scale the request into device units */
Assert( fcid.hps > 0 );
plf->lfHeight = NMultDiv( fcid.hps * (czaPoint / 2),
fPrinterFont ? vfli.dyuInch : vfli.dysInch,
czaInch );
/* (BL) *** HACK *** *** ACK *** **** GAG **** *** BARF ***
The Windows courier font has interesting non-international pixels
in its internal leading area. So, when picking courier
screen fonts, use positive lfHeight, meaning choose the font by
CELL height instead of CHARACTER height.
ChrisLa says this fiasco is Aldus' fault. */
if (fcid.ibstFont != ibstCourier || fPrinterFont)
plf->lfHeight = -plf->lfHeight;
Assert( fcid.ibstFont < (*vhsttbFont)->ibstMac );
pffn = PstFromSttb( vhsttbFont, fcid.ibstFont );
/* bits 0-1: pitch request
bits 4-6: font family */
plf->lfPitchAndFamily = (pffn->ffid & maskFfFfid) | fcid.prq;
Assert( (plf->lfPitchAndFamily & maskPrqLF) == FIXED_PITCH ||
(plf->lfPitchAndFamily & maskPrqLF) == VARIABLE_PITCH ||
(plf->lfPitchAndFamily & maskPrqLF) == DEFAULT_PITCH );
/* Set Bold, Italic, StrikeOut, Underline */
plf->lfWeight = fcid.fBold ? FW_BOLD : FW_NORMAL;
if (fcid.fItalic)
plf->lfItalic = 1;
if (fcid.fStrike)
plf->lfStrikeOut = 1;
/* underlining for the screen is handled by drawing lines */
if (fPrinterFont && fcid.kul != kulNone)
plf->lfUnderline = 1;
plf->lfCharSet = ChsPffn(pffn);
bltbyte( pffn->szFfn, plf->lfFaceName, LF_FACESIZE );
if (vfPrvwDisp && !fPrinterFont)
GenPrvwPlf(plf);
#ifdef DFONT
{
int rgw [5];
CommSzSz(SzShared("Built logfont for : "), plf->lfFaceName);
rgw [0] = -plf->lfHeight;
rgw [1] = plf->lfWidth;
rgw [2] = plf->lfPitchAndFamily >> 4;
rgw [3] = plf->lfPitchAndFamily & 3;
rgw [4] = plf->lfCharSet;
CommFontAttr( SzShared( " Requested Attributes: "),
plf->lfItalic, plf->lfStrikeOut, plf->lfUnderline, plf->lfWeight != FW_NORMAL);
}
#endif /* DFONT */
return pffn->fGraphics;
}
#endif /* DEBUG || OPUS_X64 */
/* P F C E L R U G E T */
#if defined(DEBUG) || defined(OPUS_X64)
/* %%Function:PfceLruGet %%Owner:bryanl */
HANDNATIVE struct FCE *PfceLruGet()
/* tosses out the LRU cache entry's information */
{
struct FCE *pfce, *pfceEndChain;
struct FTI *pfti;
Debug( pfceEndChain = NULL );
/* motivation for algorithm is to free the LRU font if there is only */
/* one device's fonts in the cache; and to alternate randomly between */
/* the LRU fonts for each device if there are 2 */
/* NOTE: This algorithm could repeatedly select the same slot if there */
/* was a length-1 chain and a length-ifcMax-1 chain, but this case */
/* is not interesting here */
/* Search for an appropriate FCE slot to free: */
/* 1. If we find a slot that is free, use that */
/* 2. If not, use the last end-of-chain we come to */
for ( pfce = rgfce; pfce < &rgfce [ifceMax]; pfce++ )
{
if (pfce->hfont == NULL)
return pfce;
else if (pfce->pfceNext == NULL)
pfceEndChain = pfce;
}
#ifdef DFONT
CommSzNum(SzFrame("PfceLruGet: allocate cache slot = "), pfceEndChain - rgfce );
#endif
/* found a currently allocated cache entry at the end of its device's LRU
chain. Remove it from the chain and free its handles */
Assert( pfceEndChain != NULL );
pfti = pfceEndChain->fPrinter ? vpri.pfti : vsci.pfti;
if (pfceEndChain->pfcePrev == NULL)
{
/* Since this font is at the head of the chain, it may be the one */
/* currently selected into the device DC(s). If so, deselect it */
ResetFont( pfti->fPrinter );
pfti->pfce = NULL;
}
else
{
/* also reset font selected into DC if the hfont is null -- we may
have left this font selected in because of the fWidthsOnly
optimization */
if (pfti->hfont == NULL)
ResetFont( pfti->fPrinter );
pfceEndChain->pfcePrev->pfceNext = NULL;
pfceEndChain->pfcePrev = NULL;
}
FreeHandlesOfPfce( pfceEndChain );
return pfceEndChain;
}
#endif /* DEBUG || OPUS_X64 */
#if defined(DEBUG) || defined(OPUS_X64)
/* O u r G e t C h a r W i d t h */
/* %%Function:OurGetCharWidth %%Owner:bryanl */
HANDNATIVE OurGetCharWidth( hdc, chFirst, chLast, lpdxp )
HDC hdc;
int chFirst, chLast;
int far *lpdxp;
{
SIZE size;
CHAR ch;
Assert( hdc != NULL );
Assert( chFirst >= 0 && chLast <= 255 );
while (chFirst <= chLast)
{
ch = (CHAR)chFirst;
*lpdxp++ = GetTextExtentPoint32A(hdc, &ch, 1, &size) ? size.cx : 0;
chFirst++;
}
}
#endif /* DEBUG || OPUS_X64 */
#ifdef DFONT
CommFontAttr(szHeader, fItalic, fStrikeOut,fUnderline,fBold)
char szHeader[];
{
CommNLFFontAttr(szHeader, fItalic, fStrikeOut,fUnderline,fBold);
CommSz( SzShared( "\r\n") );
}
#endif /* DFONT */
+308
View File
@@ -0,0 +1,308 @@
/* pic.h -- definitions for pictures. very Windows-specific. */
#ifdef OPUS_X64
/* Several original modules define NOGDI before including word.h. The SDK
* consequently withholds these two descriptors, although the file-format
* structure still embeds them. Preserve their Win32 field contracts under
* private names without enabling GDI calls in those modules. */
typedef struct _OPUS_X64_METAFILEPICT
{
LONG mm;
LONG xExt;
LONG yExt;
HANDLE hMF;
} OPUS_X64_METAFILEPICT;
typedef struct _OPUS_X64_BITMAP
{
LONG bmType;
LONG bmWidth;
LONG bmHeight;
LONG bmWidthBytes;
WORD bmPlanes;
WORD bmBitsPixel;
LPVOID bmBits;
} OPUS_X64_BITMAP;
#endif
/* following constant needed to prevent dragging to arbitrarily small size */
#define dypPicSizeMin 16 /* Smallest y-extent of a picture, in pixels */
#define MM_NIL -1
#define MM_BITMAP 99 /* phony mapping mode, means "this is a bitmap,
not a metafile" */
#define MM_TIFF 98 /* another phony mapping mode */
#define MM_DIB 97
#define MM_META_MAX (MM_ANISOTROPIC + 1) /* 1 past highest metafile index in windows.h */
/* file type codes for graphics files. Add new codes here. */
#define ftNil (-1)
#define ftfBitmap 128 /* marks bitmap file types */
#define ftfUnknown 64 /* marks file types we can't readily recognize */
/*supported graphics files*/
#define ftClipboard (32 | ftfBitmap)
#define ftPCPaint (33 | ftfBitmap)
#define ftTIFF (34 | ftfBitmap)
#define ftCapture (35 | ftfBitmap)
#define ftDIB (40 | ftfBitmap)
#define dzPicBase (3) // largest side of unsized pic is 3"
/* Following is the definition of a picture, either a bitmap or a Windows
MetaFile. structure appears at chp.fcPic in fn containing chPicture */
struct PIC
{
long lcb; /* # bytes total including header. First field
to ease use of some Mac code */
uns cbHeader; /* # bytes in this header (for future expansion) */
/* Metafile picture descriptor. For bitmaps, only mm/xExt/yExt matter. */
#if defined(OPUS_X64) && defined(NOGDI)
OPUS_X64_METAFILEPICT mfp;
#else
METAFILEPICT mfp;
#endif
union
{
#if defined(OPUS_X64) && defined(NOGDI)
OPUS_X64_BITMAP bm;
#else
BITMAP bm; /* bitmap descriptor; not significant for metafiles*/
#endif
struct RC rcWinMF; /* rect for window org and extents - ignored if 0's */
};
int dxaGoal; /* goal size; 0 == no goal size; nonzero only */
int dyaGoal; /* for imported bitmaps with BitmapDimension set.
affects scaling during: import, printer change.
may not actually scale to this size if it would
require a non-power-of-two StretchBlt) */
unsigned mx, my; /* scale factor applied by the user */
/* offsets for cropping based on original size in dxa/yaGoal */
union
{
struct
{
int dxaCropLeft;
int dyaCropTop;
int dxaCropRight;
int dyaCropBottom;
};
int rgCrop[4];
};
uns brcl: 4;
uns fFrameEmpty: 1;
uns : 11;
char rgb[0]; /* variable size; bitmap bits or metafile contents */
};
#define cbPIC (sizeof (struct PIC))
#define iCropLeft (0)
#define iCropTop (1)
#define iCropRight (2)
#define iCropBottom (3)
struct PICRC
{
struct RC frOut;
struct RC frIn;
struct RC picScl;
struct RC picUnscl;
};
struct PICDIM /* dxp, dyp for picture rc's */
{
struct PT frOut;
struct PT frIn;
struct PT picScl;
struct PT picUnscl;
struct PT frOutZt; /* scaled size in vftiDxt units */
};
struct WMFWINOE /* hand coded windows origin and extent for import field metafile */
{
DWORD cwWinOrigin;
int kwdWinOrigin;
int ypWinOrigin; /* note reverse order for args */
int xpWinOrigin;
DWORD cwWinExtent;
int kwdWinExtent;
int ypWinExtent;
int xpWinExtent;
};
#define cwWMFWINOE (sizeof(struct WMFWINOE) / sizeof(int))
#define WINMETAVERSION (0x0300)
struct METAHDR /* metafile header - should be in Windows h file */
{
WORD mtType;
WORD mtHeaderSize;
WORD mtVersion;
DWORD mtSize;
WORD mtNoOObjects;
DWORD mtMaxRecord;
WORD mtNoParameters;
};
#define cwMETAHDR (sizeof(struct METAHDR) / sizeof(int))
#define METAENDREC (0) /* keyword of metafile end record */
struct WINMRTAG // metafile record tag
{
DWORD rdSize;
int kwd;
};
#define cbWINMRTAG (sizeof(struct WINMRTAG))
#define cwWINMRTAG (sizeof(struct WINMRTAG) / sizeof(int))
struct WMFCOLOR /* hand coded text/bg color recs */
{
DWORD cwTColor; // 5
int kwdTColor; // x209
DWORD rgbTColor;
DWORD cwBColor; // 5
int kwdBColor; // x201
DWORD rgbBColor;
};
#define cwWMFCOLOR (sizeof(struct WMFCOLOR) / sizeof(int))
struct WMFSDIB /* hand coded stretchdibitmap */
{
DWORD cwSDIB;
int kwdSDIB; // xf43
DWORD dwRop;
WORD wUsage;
WORD srcYExt;
WORD srcXExt;
WORD srcY;
WORD srcX;
WORD dstYExt;
WORD dstXExt;
WORD dstY;
WORD dstX;
};
#define cbWMSDIB (sizeof(struct WMFSDIB))
#define cwWMSDIB (sizeof(struct WMFSDIB) / sizeof(int))
struct MFHDRDIBMF /* hand coded metafile header for dib converted to WMF */
{
struct METAHDR metahdr;
struct WMFWINOE winoe; /* hand coded windows origin and extent for import field metafile */
struct WMFCOLOR color; /* hand coded text/bg color recs */
struct WMFSDIB stretchdib; /* hand coded stretchdibitmap */
};
#define cbMFHDRDIBMF (sizeof(struct MFHDRDIBMF))
#define cwMFHDRDIBMF (sizeof(struct MFHDRDIBMF) / sizeof(int))
/* masks for pic grpf */
#define picgFrOut (1)
#define picgFrIn (2)
#define picgPicScl (4)
#define picgPicUnscl (8)
#define picgAll (-1)
#define mx100Pct 1000 /* Scale factor corresponding to 100% size */
#define my100Pct 1000 /* Scale factor corresponding to 100% size */
#define PctTomx100Pct 10 /* Factor for converting dialog % to mx */
#define PctTomy100Pct 10 /* Factor for converting dialog % to my */
#define cbrDragBox 6
#define dxpDragBox (vsci.dxpBorder * cbrDragBox) /* size of drag boxes in frame */
#define dypDragBox (vsci.dypBorder * cbrDragBox) /* size of drag boxes in frame */
#define dxaPicMin (173) /* min picture size ( .12" nearest .01" to 1/8")*/
#define dyaPicMin (173) /* min picture size */
#define dxaPicMinDrag (180) /* some slack to handle dialog rounding */
#define dyaPicMinDrag (180)
#define dxaPicMax (czaMax) /* max picture size (about 22" and around 32K) */
#define dyaPicMax (czaMax) /* max picture size */
/* note: max is scale BEFORE mult by 10, min is scale AFTER mult by 10 */
#define mzPicMax (6550) /* max scale, so 10 * will fit unsigned */
#define mzPicMin (10) /* min scale * 10, so 1/10 will be 1% */
/* drag handle locations order is that which we use to check for
mouse hits, so most likely drag locations are first. */
/* WARNING: GetRcDragLim() [and perhaps other fns] uses the numerical */
/* values defined here, don't change them without modifying this */
/* function (MaxB 9/8/88) */
#define ircsBC 0
#define ircsBR 1
#define ircsCR 2
#define ircsTR 3
#define ircsTC 4
#define ircsTL 5 /* Top Left */
#define ircsCL 6 /* Center Left */
#define ircsBL 7 /* Bottom Left */
#define ircsMax 8
/* In the case of monochrome devices, this raster op will map white in
the bitmap to the background color and black to the foreground color. */
#define ropMonoBm 0x00990066
#ifdef PICTDRAG
/* prompts for pic drag */
#ifdef OPUS_X64
csconst CHAR mstpCropL[] = "\x19" "Cropping: 0.00\" Left";
csconst CHAR mstpCropR[] = "\x1a" "Cropping: 0.00\" Right";
csconst CHAR mstpCropT[] = "\x18" "Cropping: 0.00\" Top";
csconst CHAR mstpCropB[] = "\x1b" "Cropping: 0.00\" Bottom";
csconst CHAR mstpCropTL[] = "\x29" "Cropping: 0.00\" Left 0.00\" Top";
csconst CHAR mstpCropTR[] = "\x29" "Cropping: 0.00\" Right 0.00\" Top";
csconst CHAR mstpCropBL[] = "\x2c" "Cropping: 0.00\" Left 0.00\" Bottom";
csconst CHAR mstpCropBR[] = "\x2c" "Cropping: 0.00\" Right 0.00\" Bottom";
#else
csconst CHAR mstpCropL[] = StKey ("Cropping: 0.00\" Left",CropLeft);
csconst CHAR mstpCropR[] = StKey ("Cropping: 0.00\" Right",CropRight);
csconst CHAR mstpCropT[] = StKey ("Cropping: 0.00\" Top",CropTop);
csconst CHAR mstpCropB[] = StKey ("Cropping: 0.00\" Bottom",CropBottom);
csconst CHAR mstpCropTL[] = StKey ("Cropping: 0.00\" Left 0.00\" Top",CropLeftTop);
csconst CHAR mstpCropTR[] = StKey ("Cropping: 0.00\" Right 0.00\" Top",CropRightTop);
csconst CHAR mstpCropBL[] = StKey ("Cropping: 0.00\" Left 0.00\" Bottom",CropLeftBottom);
csconst CHAR mstpCropBR[] = StKey ("Cropping: 0.00\" Right 0.00\" Bottom",CropRightBottom);
#endif
/* these will change for internationalization */
/* where changing portions start */
#ifndef INTL
#define ichmstCrop1 (10)
#define ichmstCrop2 (27)
#endif
#define cchmstCrop (11) /* # of chars to change */
#ifdef OPUS_X64
csconst CHAR mstpScaleH[] = "\x14" "Scaling: 100% High";
csconst CHAR mstpScaleW[] = "\x14" "Scaling: 100% Wide";
csconst CHAR mstpScaleHW[] = "\x20" "Scaling: 100% High 100% Wide";
#else
csconst CHAR mstpScaleH[] = StKey ("Scaling: 100% High",ScaleHigh);
csconst CHAR mstpScaleW[] = StKey ("Scaling: 100% Wide",ScaleWide);
csconst CHAR mstpScaleHW[] = StKey ("Scaling: 100% High 100% Wide",ScaleHighWide);
#endif
#ifndef INTL
#define ichmstScale1 (10)
#define ichmstScale2 (22)
#endif
#define cchmstScale (5) /* # of chars to change */
#endif /* PICTDRAG */
+876
View File
@@ -0,0 +1,876 @@
/* ****************************************************************************
**
** COPYRIGHT (C) 1987, 1988 MICROSOFT
**
** ****************************************************************************
*
* Module: pic2.c ---- Misc picture routines
*
**
** REVISIONS
**
** Date Who Rel Ver Remarks
** 11/16/87 bobz split off from pic.c
**
** ************************************************************************* */
#define NOGDICAPMASKS
#define NOVIRTUALKEYCODES
#define NONCMESSAGES
#define NOSYSMETRICS
#define NOMENUS
#define NOICON
#define NOKEYSTATE
#define NOSYSCOMMANDS
#define NOSHOWWINDOW
#define OEMRESOURCE
#define NOSYSMETRICS
#define NOCOLOR
#define NOCREATESTRUCT
#define NODRAWTEXT
#define NOFONT
#define NOMB
#define NOMENUS
#define NOOPENFILE
#define NOPEN
#define NOREGION
#define NOSCROLL
#define NOSOUND
#define NOTEXTMETRIC
#define NOWH
#define NOWINOFFSETS
#define NOWNDCLASS
#define NOCOMM
#define NOKANJI
#include "word.h"
DEBUGASSERTSZ /* WIN - bogus macro for assert string */
#include "file.h"
#include "props.h"
#include "format.h"
#include "sel.h"
#include "disp.h"
#include "doc.h"
#include "screen.h"
#include "ch.h"
#include "pic.h"
#include "prm.h"
#include "print.h"
#include "dlbenum.h"
#include "fkp.h"
#include "field.h"
#include "opuscmd.h"
#include "error.h"
#include "core.h"
#include "debug.h"
#include "idd.h"
#include "sdmdefs.h"
#include "sdmver.h"
#include "sdm.h"
#include "sdmtmpl.h"
#include "sdmparse.h"
#include "pict.hs"
#include "pict.sdm"
#include "inspic.hs"
#include "inspic.sdm"
#include "doslib.h"
#ifdef PROTOTYPE
#include "pic2.cpt"
#endif /* PROTOTYPE */
#ifdef PCODE
typedef long ul; /* no unsigned longs in CS compiler */
#else
typedef unsigned long ul;
#endif
/* these is another copy of this in ddeclnt.c */
static csconst CHAR szCSMergeFormat[] = SzSharedKey(" \\* mergeformat",DdeMergeFormat);
extern CHAR szTif[];
TMC TmcGetPicStFile ();
/* E X T E R N A L S */
extern BOOL fElActive;
extern int fnFetch;
extern int wwCur;
extern struct WWD **hwwdCur;
extern struct FLI vfli;
extern struct PIC vpicFetch;
extern struct CHP vchpFetch;
extern struct SEL selCur;
extern struct FMTSS vfmtss;
extern struct FTI vfti;
extern struct FTI vftiDxt;
extern struct MERR vmerr;
extern struct SCI vsci;
extern struct PREF vpref;
extern struct FKPD vfkpdText;
extern struct PRI vpri;
extern CHAR stDOSPath[];
extern BOOL vfFileCacheDirty;
extern CHAR szEmpty[];
extern BOOL vfRecording;
extern CHAR HUGE *vhpchFetch;
extern CP vcpFetch;
extern int vdocFetch;
#define szFPWidthDef SzFrameKey(" W x ",FPWidth)
#define szFPHeightDef SzFrameKey(" H",FPHeight)
/* brclNone is at the end rather than at 0 but the drop list wants
none at index 0
*/
#define IFromPicBrcl(brcl) (((brcl) >= brclSingle && (brcl) < brclNone) ? \
(brcl + 1) : (brcl == brclNone ? 0 : brclInval))
#define PicBrclFromI(i) ((((unsigned) (i)) == 0) ? brclNone : \
(((unsigned) (i)) <= brclNone) ? (i - 1) : brclInval)
/***************************************/
/* C m d P i c t u r e */
/* %%Function: CmdPicture %%Owner: bobz */
CMD CmdPicture(pcmb)
CMB * pcmb;
{
CABFORMATPIC * pcabFp;
HCAB hcabFp;
char * pch;
int cch;
char sz [60]; /* arbitrary size */
CP cpImport;
struct CA caT;
/* we assume that chp is for a picture. SelCur.chp
won't have the fSpec stuff though, so fetch
and use vchpFetch.
In case of an import field, we have to get the cp
of the actual picture character.
*/
AssertDo(FCaIsGraphics(&selCur.ca, selCur.ww, &cpImport));
if (cpImport != cpNil) /* import field - use pic char for ca */
{
caT.cpFirst = cpImport;
caT.cpLim = cpImport + 1;
caT.doc = selCur.doc;
}
else
caT = selCur.ca;
FetchCpAndParaCa(&caT, fcmProps);
Assert(vchpFetch.fSpec);
FetchPe(&vchpFetch, caT.doc, caT.cpFirst);
pcmb->pv = &caT; // for FCheckFmtPic
if (pcmb->fDefaults)
{
struct CHP chp;
unsigned mxRemainder;
pcabFp = (CABFORMATPIC *) *pcmb->hcab;
/* Note:
FetchCp never sets fnPic since it is possible for
fnPic to change during the lifetime of the fetch.
All users of pic chps are required to set fnPic to
fnFetch. This is one case where it is acceptable to
modify vchpFetch without trashing the fetch. FetchPe
is the only real user of a pic chp, so it always sets
chp.fnPic to fnFetch bz
*/
pcabFp = (CABFORMATPIC *) *pcmb->hcab;
pcabFp->iPicBrcl = IFromPicBrcl(vpicFetch.brcl);
pcabFp->wScaleMx = UDiv(vpicFetch.mx, PctTomx100Pct, &mxRemainder);
pcabFp->wScaleMy = UDiv(vpicFetch.my, PctTomy100Pct, &mxRemainder);
pcabFp->wCropTop = vpicFetch.dyaCropTop;
pcabFp->wCropLeft = vpicFetch.dxaCropLeft;
pcabFp->wCropBottom = vpicFetch.dyaCropBottom;
pcabFp->wCropRight = vpicFetch.dxaCropRight;
/* text "Original Size " is already in cab. Build size string */
pch = sz;
CchExpZa(&pch, vpicFetch.dxaGoal, vpref.ut, sizeof(sz), fTrue);
pch += CchCopySz(szFPWidthDef, pch);
CchExpZa(&pch, vpicFetch.dyaGoal, vpref.ut, sizeof(sz), fTrue);
pch += CchCopySz(szFPHeightDef, pch);
Assert ((pch - sz) < sizeof(sz));
if (!FSetCabSz(pcmb->hcab, sz, Iag(CABFORMATPIC, hszOrigSize)))
return cmdNoMemory;
#ifdef XBZTEST
CommSzNum(SzShared("TmcFillCabFp: caT.doc: "), caT.doc);
CommSzLong(SzShared("TmcFillCabFp: caT.cpFirst: "), caT.cpFirst);
CommSzRgNum(SzShared("TmcFillCabFp: cab ag values: "), pcabFp,
IagMacFromHcab(pcmb->hcab));
#endif
}
if (pcmb->fDialog)
{
char dlt [sizeof (dltFormatPic)];
BltDlt(dltFormatPic, dlt);
switch (TmcOurDoDlg(dlt, pcmb))
{
#ifdef DEBUG
default:
Assert(fFalse);
return cmdError;
#endif
case tmcError:
return cmdNoMemory;
case tmcCancel:
return cmdCancelled;
case tmcOK:
break;
}
}
if (pcmb->fCheck)
{
if (!FCheckFmtPic(pcmb, fFalse /* fDialog */))
return cmdError;
}
if (pcmb->fAction)
{
Assert( selCur.fGraphics );
FetchCpAndParaCa(&caT, fcmProps);
Assert(vchpFetch.fSpec);
FetchPe(&vchpFetch, caT.doc, caT.cpFirst);
pcabFp = (CABFORMATPIC *) *pcmb->hcab;
ChangePicFrame(NULL, PicBrclFromI(pcabFp->iPicBrcl),
pcabFp->wScaleMx * PctTomx100Pct /* mx */,
pcabFp->wScaleMy * PctTomy100Pct /* my */,
pcabFp->wCropTop,
pcabFp->wCropLeft,
pcabFp->wCropBottom,
pcabFp->wCropRight);
}
return cmdOK;
}
/***************************************/
/* C m d I n s P i c t u r e */
/* %%Function: CmdInsPicture %%Owner: bobz */
CMD CmdInsPicture(pcmb)
CMB * pcmb;
{
/* insert an empty graphics frame */
CMD cmd;
struct CA caPic, caRM;
HDC hDCMeta;
HANDLE hMeta = NULL;
HANDLE hData = NULL;
METAFILEPICT mfp;
LPCH lpch;
int fOk;
TMC tmc;
CHAR szFilter[6];
CHAR stDOSPathOld[ichMaxFile + 1];
CHAR stFile[ichMaxBufDlg];
if (pcmb->fDefaults)
{
int cch;
((CABINSPIC *)PcabFromHcab(pcmb->hcab))->iDirectory = uNinchList;
CchCopySz(SzShared("*.*"), szFilter); /* since winword 1.1 */
if (!FSetCabSz(pcmb->hcab, szFilter, Iag(CABINSPIC, hszFile)))
return cmdNoMemory;
}
if (pcmb->fDialog)
{
char dlt [sizeof (dltInsPic)];
/* To check if the path was changed by the file name dialog. */
CopySt(stDOSPath, stDOSPathOld);
BltDlt(dltInsPic, dlt);
tmc = TmcOurDoDlg(dlt, pcmb);
/* Path has been changed by the dialog, update window titles. */
if (FNeNcSt(stDOSPath, stDOSPathOld))
{
vfFileCacheDirty = fTrue;
UpdateTitles(); /* changes window menu, vhsttbWnd and captions */
if (vfRecording)
RecordChdir(stDOSPath);
}
switch (tmc)
{
#ifdef DEBUG
default:
Assert(fFalse);
return cmdError;
#endif
case tmcError:
return cmdError;
case tmcCancel:
return cmdCancelled;
case tmcOK:
case tmcNewPic:
if (vfRecording)
{
FRecordCab(pcmb->hcab, IDDInsPic, pcmb->tmc,
pcmb->bcm);
}
break;
}
}
if (pcmb->fCheck && tmc == tmcOK)
{
if (!FTermFile(pcmb, Iag(CABINSPIC, hszFile), tmcNull,
fFalse, fFalse, nfoPic))
return cmdError;
}
if (pcmb->fAction)
{
if (pcmb->tmc == tmcOK)
{
CHAR stNorm[ichMaxFile];
int cch;
*stFile = 0;
GetCabSt(pcmb->hcab, stFile, ichMaxFile, Iag(CABINSPIC, hszFile));
/* this should only be able to fail in a macro */
if (!FNormalizeStFile(stFile, stNorm, nfoPic))
{
ErrorEid(eidBadFileDlg," CmdInsPicture");
return cmdError;
}
StartLongOp();
DoubleBSSt(stNorm, stFile);
cch = *stFile;
StToSzInPlace(stFile);
/* add merge format switch */
if (cch + sizeof(szCSMergeFormat) <= sizeof(stFile))
bltbx(szCSMergeFormat, (CHAR FAR *)&stFile[cch],
sizeof(szCSMergeFormat));
/* this function sets undo and autodelete */
cmd = CmdInsFltSzAtSelCur(fltImport, stFile, imiInsPicture,
fTrue, fTrue, fTrue);
PushInsSelCur();
EndLongOp(fFalse /*fAll*/);
return cmd;
}
if (!FSetUndoBefore(imiInsPicture, uccPaste))
return cmdCancelled;
if ((cmd = CmdAutoDelete(&caRM)) != cmdOK)
return cmd;
Assert (pcmb->tmc == tmcNewPic);
PcaPoint(&caPic, caRM.doc, caRM.cpFirst);
/* create 1" square metafile */
if ((hDCMeta = CreateMetaFile( (LPSTR) NULL)) == hNil)
goto ErrRet; /* memory DC */
LogGdiHandle(hDCMeta, 1086);
if ((hMeta = CloseMetaFile(hDCMeta)) == hNil)
goto ErrRet;
UnlogGdiHandle(hDCMeta, 1086);
LogGdiHandle(hMeta, 1087);
if ( ((hData=OurGlobalAlloc(GMEM_MOVEABLE,
(long)sizeof(METAFILEPICT) ))==NULL) ||
((lpch=GlobalLock( hData ))==NULL))
{
goto ErrRet;
}
else
{
mfp.hMF = hMeta;
mfp.mm = MM_ANISOTROPIC;
mfp.xExt = 0;
mfp.yExt = 0;
bltbx( (LPCH)&mfp, lpch, sizeof(METAFILEPICT) );
GlobalUnlock( hData );
}
/* load metafile into document */
FetchCpAndParaCa(&caPic, fcmProps);
fOk = FReadPict (&caPic, CF_METAFILEPICT,
hData, 0 /* cbInitial */,
fTrue /* fEmptyPic */,
&vchpFetch /* pchp */, NULL /* prcWinMF */);
GlobalFree( hData );
UnlogGdiHandle(hMeta, 1087);
DeleteMetaFile(hMeta);
hMeta = hData = NULL;
if (!fOk)
{
ErrRet:
if (hData != NULL)
GlobalFree( hData );
if (hMeta != NULL)
{
UnlogGdiHandle(hMeta, 1087);
DeleteMetaFile(hMeta);
}
Beep();
return cmdError;
}
/* make document dirty. if it's a subdoc, FDirtyDoc will notice
and declare that the mother doc is dirty. */
PdodDoc(selCur.doc)->fFormatted = fTrue;
caPic.cpLim++;
SelectIns(&selCur, caPic.cpLim);
PushInsSelCur();
caRM.cpLim += DcpCa(&caPic);
SetUndoAfter(&caRM);
}
return cmdOK;
}
/********************************/
/* D l g f F o r m a t P i c */
/* SDM dialog function for Format Picture dialog.
Special interactions:
o when fInLine is ON, the ojc radio buttons are meaningless
and should be disabled.
*/
csconst rgtmcPic[] =
{
tmcScaleMx,
tmcScaleMy,
tmcCropTop,
tmcCropLeft,
tmcCropBottom,
tmcCropRight };
#define itmcMacPic (sizeof(rgtmcPic)/sizeof(int))
/* %%Function: FDlgFormatPic %%Owner: bobz */
BOOL FDlgFormatPic(dlm, tmc, wNew, wOld, wParam)
DLM dlm;
TMC tmc;
WORD wOld, wNew, wParam;
{
TMC rgtmc[itmcMacPic];
CMB * pcmb = PcmbDlgCur();
switch (dlm)
{
case dlmChange:
{
Assert (tmc == tmcScaleMx || tmc == tmcScaleMy ||
tmc == tmcCropTop || tmc == tmcCropLeft ||
tmc == tmcCropBottom || tmc == tmcCropRight);
bltbyte(rgtmcPic, rgtmc, sizeof(rgtmcPic));
GrayRgtmcOnBlank(rgtmc, itmcMacPic, tmcOK);
break;
}
case dlmTerm:
if (tmc == tmcOK)
{
HCAB hcab;
if ((hcab = HcabFromDlg(fFalse)) == hcabNotFilled)
return fFalse;
if (hcab == hcabNull)
{
/* dialog will end without needing to call EndDlg(tmcError) */
return (fTrue);
}
return FCheckFmtPic(pcmb, fTrue /* fDialog */);
}
/* break; */
}
return fTrue;
}
/* %%Function: FCheckFmtPic %%Owner: bobz */
/* Sets up a cmb so it can call FCheckFmtPic */
FCheckPic(ppic, pca)
struct PIC *ppic;
struct CA *pca;
{
CMB cmb;
CABFORMATPIC cab;
CABFORMATPIC *pcab;
unsigned mxRemainder;
/* Note vpicFetch must be set up for this to work. It may be different
from pic
*/
cab.wScaleMx = UDiv(ppic->mx, PctTomx100Pct, &mxRemainder);
cab.wScaleMy = UDiv(ppic->my, PctTomy100Pct, &mxRemainder);
cab.wCropTop = ppic->dyaCropTop;
cab.wCropLeft = ppic->dxaCropLeft;
cab.wCropBottom = ppic->dyaCropBottom;
cab.wCropRight = ppic->dxaCropRight;
pcab = &cab;
cmb.hcab = &pcab;
cmb.pv = pca;
return (FCheckFmtPic(&cmb, fFalse /* fDialog */));
}
/* %%Function: FCheckFmtPic %%Owner: bobz */
FCheckFmtPic(pcmb, fDialog)
CMB * pcmb;
BOOL fDialog;
{
/* Note vpicFetch must be the pic props are applied to for this to work.
Since rtfin kind of hacks its way in here, we can't assert here
anything about vchpFetch or vcpFetch. If pcmb->pv is not NULL,
it is the ca for the picture. We can assure that fetching is set
up properly in that case. It is currently NULL only for the rtfin
call, which is made before the picture is put into the doc.
*/
CABFORMATPIC * pcabFp;
int dxa, dya;
struct FTI *pfti = vfli.fFormatAsPrint ? &vftiDxt : &vfti;
if (pcmb->pv != NULL)
{
// we can check to be sure vpicFetch is set up correctly in this case
struct CA *pca = pcmb->pv;
if (vdocFetch != pca->doc || vcpFetch != pca->cpFirst)
{
ReportSz("FCheckFmtPic vpicFetch moved, reestablishing");
FetchCpAndParaCa(pca, fcmProps+fcmChars);
Assert(vchpFetch.fSpec && *vhpchFetch == chPicture);
FetchPe(&vchpFetch, pca->doc, pca->cpFirst);
}
}
pcabFp = (CABFORMATPIC *) *pcmb->hcab;
/* scaled / cropped dimensions must be > minimum size. Note
that cropping is based on the UNSCALED pic size
and scaling on cropped size */
/* note that the mx, my are parsed items and so
already check for >=0.
Since we are comparing int values, any value > 32767
will show up as negative, so so be rejected as too
big, so this handles < min or > max. dzaPicMax is not
quite 32767, so add the test for dzaMax < x <= 32767
note also that the goal values are really za units, i.e.,
twips, not pixels (zp).
*/
/* cropped sizes */
dxa = (vpicFetch.dxaGoal - pcabFp->wCropLeft - pcabFp->wCropRight);
dya = (vpicFetch.dyaGoal - pcabFp->wCropTop - pcabFp->wCropBottom);
if (pcabFp->wCropLeft ||
pcabFp->wCropRight ||
pcabFp->wCropTop ||
pcabFp->wCropBottom)
{
if (dxa < dxaPicMin || dxa > dxaPicMax ||
dya < dyaPicMin || dya > dyaPicMax)
{
ErrorEid(eidBadCrop, "");
if (fDialog)
{
SetTmcTxs(tmcCropTop,
TxsOfFirstLim(0, ichLimLast));
}
return fFalse;
}
}
if ( pcabFp->wScaleMx != 100 || pcabFp->wScaleMy != 100)
{
/* don't have a parse funct available to add top range check
have to check or 10 x mx/my could overflow unsigned */
if ( pcabFp->wScaleMx > mzPicMax || pcabFp->wScaleMy > mzPicMax)
{
RangeError(1, mzPicMax, fFalse /* fZa */, vpref.ut);
if (fDialog)
{
SetTmcTxs(pcabFp->wScaleMx > mzPicMax ?
tmcScaleMx : tmcScaleMy,
TxsOfFirstLim(0, ichLimLast));
}
return fFalse;
}
/* test thse rects: the scaled/cropped rect, the
scaled uncropped rect in twips, screen pixels
and printer pixels for overflow in an int.
*/
/* scale the cropped rect */
if (!FScaleInRange(dxa, dya, pcabFp->wScaleMx,
pcabFp->wScaleMy, dxaPicMin, dxaPicMax, dyaPicMin,
dyaPicMax, fDialog))
return (fFalse);
/* scale the uncropped rect */
if (!FScaleInRange(vpicFetch.dxaGoal, vpicFetch.dyaGoal, pcabFp->wScaleMx,
pcabFp->wScaleMy, dxaPicMin, dxaPicMax, dyaPicMin,
dyaPicMax, fDialog))
return (fFalse);
if (vpicFetch.mfp.mm == MM_BITMAP ||
vpicFetch.mfp.mm == MM_TIFF)
{
GetBitmapSize(&dxa, &dya);
}
else
/* use calculated goal size in main device units for metafiles.
Calculate in printer pixels, and compute xp's using nonrounding
mechanism for dispasprint so we avoid pageview screen pushout.
*/
{
Assert (vpicFetch.mfp.mm <= MM_META_MAX);
dxa = NMultDiv (vpicFetch.dxaGoal,
pfti->dxpInch, czaInch);
Assert (dxa != 0x7FFF); /* overflow should be caught before now */
dya = NMultDiv (vpicFetch.dyaGoal,
pfti->dypInch, czaInch);
Assert (dya != 0x7FFF);
}
/* check the scaled pixels rect for overflow */
if (!FScaleInRange(dxa, dya, pcabFp->wScaleMx,
pcabFp->wScaleMy,
1, 32767, 1, 32767, fDialog))
return (fFalse);
/* convert to screen units */
/* for the dispas print case */
if (vfli.fFormatAsPrint)
{
dxa = (int)((long)dxa * (long)vfti.dxpInch /
(long) vftiDxt.dxpInch);
dya = (int)((long)dya * (long)vfti.dypInch /
(long) vftiDxt.dypInch);
/* check the scaled screen pixels rect */
if (!FScaleInRange(dxa, dya, pcabFp->wScaleMx,
pcabFp->wScaleMy,
1, 32767, 1, 32767, fDialog))
return (fFalse);
}
}
return fTrue;
}
/* %%Function: FScaleInRange %%Owner: bobz */
FScaleInRange(dx, dy, wScaleMx, wScaleMy, dxMin, dxMax, dyMin, dyMax, fDialog)
int dx, dy;
unsigned wScaleMx, wScaleMy;
int dxMin, dxMax, dyMin, dyMax;
BOOL fDialog;
{
int dxScale, dyScale;
/* test various pic sizes for 22" (czaMax/dzaPicMax)limit
*/
if ( (dxScale = NMultDiv (dx, wScaleMx, 100)) == 0x7FFF
|| dxScale < dxMin || dxScale > dxMax ||
(dyScale = NMultDiv (dy, wScaleMy, 100))
== 0x7FFF || dyScale < dyMin || dyScale > dyMax)
{
ErrorEid(eidBadScale, "");
if (fDialog)
{
SetTmcTxs(tmcScaleMy,
TxsOfFirstLim(0, ichLimLast));
}
return fFalse;
}
return fTrue;
}
/* ****
*
Function: FDlgInsPic
* Author:
* Copyright: Microsoft 1986
* Date: 3/10/86
*
* Description: Dialog function
*
** ***/
/* %%Function: FDlgInsPic %%Owner: bobz */
BOOL FDlgInsPic(dlm, tmc, wNew, wOld, wParam)
DLM dlm;
TMC tmc;
WORD wOld, wNew, wParam;
{
int iT;
CHAR sz [ichMaxBufDlg];
HCAB hcab;
int cch;
switch (dlm)
{
default:
return (fTrue);
case dlmIdle:
if (wNew /* cIdle */ == 0)
return fTrue; /* call FSdmDoIdle and keep idling */
if (wNew /* cIdle */ == 3)
FAbortNewestCmg (cmgLoad1, fTrue, fTrue);
else if (wNew /* cIdle */ == 5)
FAbortNewestCmg (cmgLoad2, fTrue, fTrue);
else if (wNew > 5)
return fTrue; /* stop idling */
return fFalse; /* keep idling */
case dlmInit:
SetDefaultTmc(tmcNewPic);
break;
case dlmClick:
if (tmc == tmcNewPic)
{
/* ugh - need to ignore filename field if empty, so
just fill the cab and bag out
*/
if ((hcab = HcabFromDlg(fFalse)) == hcabNotFilled)
return fFalse;
if (hcab != hcabNull)
{
if (vfRecording)
FRecordCab(hcab, IDDInsPic, tmc, fFalse);
EndDlg(tmcNewPic); /* ok to call EndDlg here */
}
/* if hcabNull, FFilterSdmMsg will take dialog down */
return (fTrue);
}
/* non-atomic combos get no dlmChange on list box click.
if we get any non-nil entry, be sure OK is enabled
*/
if (tmc == tmcIPList || tmc == tmcIPDir)
{
if (wNew != uNinchList)
{
EnableTmc(tmcOK, fTrue);
SetDefaultTmc(tmcOK);
}
}
break;
case dlmChange:
{
/* disable Ok if no filename string */
if (tmc == (tmcInsPic & ~ftmcGrouped))
{
GetTmcText(tmcInsPic, sz, ichMaxBufDlg);
cch = CchStripString(sz, CchSz(sz) - 1);
EnableTmc(tmcOK, Usgn(cch));
SetDefaultTmc(cch ? tmcOK : tmcNewPic);
}
break;
}
case dlmDirFailed:
ErrorEid(eidBadFileDlg," FDlgInsPic");
SetTmcTxs (tmcInsPic, TxsAll());
return fFalse; /* could not fill directory; stay in dlg */
case dlmTerm:
{
UpdateStDOSPath();
if (tmc != tmcOK)
break;
GetTmcText(tmcInsPic, sz, ichMaxBufDlg);
cch = CchStripString(sz, CchSz(sz) - 1);
if (!cch)
return (fTrue);
else
return (FTermFile (PcmbDlgCur(), Iag(CABINSPIC, hszFile),
tmcInsPic, fFalse /* fLink */, fFalse /* fDocCur */,
nfoPic));
} /* dlmTerm */
} /* switch */
return (fTrue);
}
+2045
View File
File diff suppressed because it is too large Load Diff
+51
View File
@@ -0,0 +1,51 @@
/* consolidate all those rarely used global flags into bitfields,
trading rarely-used-code space for precious DS space */
struct RF { /* Rare flag */
int fTablePropsNinch: 1;
int fForcePara: 1;
int fNormalPrev: 1;
int fWaitForDraw: 1;
int fChangeKeys: 1;
int fHotZValid: 1;
int fHyphHaveWord: 1;
int fRanCBT: 1;
int fPgv: 1;
int fCbtInit: 2;
int fRibbonCBT: 2;
int fInExternalCall: 1;
int fPauseRecorder: 1;
int fBorderCropPic : 1;
int fInQueryEndSession: 1;
int fMwCreate: 1;
int fHyphCapitals: 1;
int fSplIgnoreCaps: 1;
int udcDefault: 2;
int fPreloadSelFont: 1;
int fInFormatLine : 1; /* Flag to avoid recursion */
int fInsPgNum: 1;
int fMustStopCBT: 1;
int fNotFirstDlg: 1;
int fCkPgMarg: 1;
int fVetoViewRef: 1; /* true if double click in ref mark */
int fInDyadic: 1;
int fExtendedMemory: 1;
int fInDisplayFli : 1; /* Flag to avoid recursion */
int unused: 7;
int fInFetchCp : 1; /* Flag to avoid recursion */
};
#ifdef DEFVARS
struct RF vrf = { 0,0,0,0,0,1,1,0,
0,2,2,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0 };
#else
extern struct RF vrf;
#endif
+218
View File
@@ -0,0 +1,218 @@
/* resource.h -- Resource information for OPUS */
/* resouce numbers (index to rgrcds in rcinit.c) */
#define ircdsWordIcon 0
#define ircdsRight 1
#define ircdsSplit 2
#define ircdsColumn 3
#define ircdsNonCoreMin 4
#define ircdsStyWnd 4
#define ircdsRecorder 5
#define ircdsHelp 6
#define ircdsOtlCross 7
#define ircdsOtlVert 8
#define ircdsOtlHorz 9
#define ircdsPrvwCross 10
/* bitmap id's */
/* idrb = resource ID of bitmap */
#define idrbChVis 0 /* visi tab, CRJ */
#define idrbMinDeviceDep 1 /* start numbering of bitmaps
for which multiple, device-
dependent versions are available */
#ifdef WIN23
/*** Win 2 set ***/
#define idrbOtlPat2 1 /* outline bullets */
#define idrbScrptPos2 2 /* +- (ribbon) */
#define idrbRulerToggles2 3 /* ruler tabs & other toggles */
#define idrbRulerMarks2 4 /* ruler indent marks */
#define idrbRibbon2 5 /* Ribbon main bitmaps */
#define idrbHdrIconBar2 6 /* header icon bar */
#define idrbOutlineIcnBr2 7 /* outline iconbar */
#define idrbPageview2 8 /* pageview icons */
#define idrbRulerAlign2 9 /* ruler alignment icons */
#define idrbMax2 10
/*** Win 3 set ****/
#define idrbOtlPat3 1 /* outline bullets */
#define idrbScrptPos3 2 /* +- (ribbon) */
#define idrbIScrptPos3 3 /* +- (ribbon) */
#define idrbRulerToggles3 4 /* ruler tabs & other toggles */
#define idrbIRulerToggles3 5 /* inactive ruler tabs & other toggles */
#define idrbRulerMarks3 6 /* ruler indent marks */
#define idrbRibbon3 7 /* Ribbon main bitmaps */
#define idrbIRibbon3 8 /* Inactive Ribbon main bitmaps */
#define idrbHdrIconBar3 9 /* header icon bar */
#define idrbOutlineIcnBr3 10 /* outline iconbar */
#define idrbPageview3 11 /* pageview icons */
#define idrbRulerAlign3 12 /* ruler alignment icons */
#define idrbIRulerAlign3 13 /* Inactive ruler alignment icons */
#define idrbMax3 14
#else
#define idrbOtlPat 1 /* outline bullets */
#define idrbScrptPos 2 /* +- (ribbon) */
#define idrbRulerToggles 3 /* ruler tabs & other toggles */
#define idrbRulerMarks 4 /* ruler indent marks */
#define idrbRibbon 5 /* Ribbon main bitmaps */
#define idrbHdrIconBar 6 /* header icon bar */
#define idrbOutlineIcnBr 7 /* outline iconbar */
#define idrbPageview 8 /* pageview icons */
#define idrbRulerAlign 9 /* ruler alignment icons */
#define idrbMax 10
#endif /* WIN23 */
#ifdef WIN23
/* Win 2 Device BitMap Groups */
#define dbmg85142 0
#define dbmgSigma2 1
#define dbmgVGA2 2
#define dbmgEGA2 3
#define dbmgCGA2 4
#define dbmgLast2 4 /* last must be smallest */
/* number of bitmaps per device group */
#define cbmdsDbmg3 13
/* Win 3 Device BitMap Groups */
#define dbmg85143 0
#define dbmgVGA3 1
#define dbmgEGA3 2
#define dbmgLast3 2 /* last must be smallest */
/* number of bitmaps per device group */
#define cbmdsDbmg2 9
#else
/* Device BitMap Groups */
#define dbmg8514 0
#define dbmgSigma 1
#define dbmgVGA 2
#define dbmgEGA 3
#define dbmgCGA 4
#define dbmgLast 4 /* last must be smallest */
/* number of bitmaps per device group */
#define cbmdsDbmg 9
#endif /* WIN23 */
/* information about resource bitmaps */
/* idcb = index into multiple-bitmaps-in-one, concatenated horizontally */
#define idcbChVisCRJ 0
#define idcbChVisTab 1
#define idcbMaxChVis 2
#define dxpChVisEach 12
#define dxpChVis (dxpChVisEach * idcbMaxChVis)
#define dypChVis 7
#define idcbMaxOtlPat 8
#define dxpOtlPat 10
#ifdef WIN23
#define dypOtlPat2 8
#define dypOtlPat3 10
#else
#define dypOtlPat 8
#endif /* WIN23 */
#define idcbOtlMarkPlus 0
#define idcbOtlMarkHiPlus 1
#define idcbOtlMarkMinus 2
#define idcbOtlMarkHiMinus 3
#define idcbOtlMarkBody 4
#define idcbOtlMarkHiBody 5
#define idcbOtlMarkLeftRight 6
#define idcbOtlMarkUpDown 7
#define idcbMaxScrptPos 2
#define idcbMaxRulerToggles 9
#define idcbMaxRulerMarks 12
#define idcbMaxRibbon 7
#define idcbMaxHdrIconBar 3
#define idcbMaxOutlineIcnBr 16
#define idcbMaxPageview 1
#define idcbMaxRulerAlign 5
#define dyIconBar 15
#ifdef WIN23
struct BMDS3
{
BITMAPCOREHEADER bch;
#ifdef OPUS_X64
/* BITAPP emits a normal aggregate: header, bitmap bytes, then cb.
* The Win16 compiler accepted the old unsized member; reserve enough
* inline storage for every archived source bitmap on native builds. */
CHAR rgchBits[8192];
int cb;
#else
CHAR rgchBits[];
int cb;
#endif
};
struct BMDS
{
BITMAP bm;
#ifdef OPUS_X64
CHAR rgchBits[8192];
int cb;
#else
CHAR rgchBits[];
int cb;
#endif
};
#else
struct BMDS
{
BITMAP bm;
#ifdef OPUS_X64
CHAR rgchBits[8192];
int cb;
#else
CHAR rgchBits[];
int cb;
#endif
};
#endif /* WIN23 */
struct RCDS
{
#ifdef OPUS_X64
/* BITAPP emits the Win16 CUR payload after its two-byte type word:
* a 12-byte RCI followed by two 128-byte 32x32 monochrome masks. */
CHAR rgchBits[268];
int cb;
#else
CHAR rgchBits[];
int cb;
#endif
};
/* GetProcAddress ordinal values (taken from appropriate .DEF files) */
/* for KEYBOARD */
#define idoVkKeyScan 129
#define idoSetSpeed 7
/* for KERNEL */
#define idoAllocDsToCsAlias 171
#define idoGetFreeSpace 169
#define idoAllocSelector 175
#define idoFreeSelector 176
#define idoPrestoChangoSelector 177
/* for printer drivers */
#define idoExtTextOut 14
#define idoDeviceMode 13
/* for USER */
#define idoExitWindowsV3 7
/* for GDI */
#define idoSetDIBits 440
#define idoGetDIBits 441
#define idoCreateDIBitmap 442
+642
View File
@@ -0,0 +1,642 @@
#ifndef OPUS_RTF_H_INCLUDED
#define OPUS_RTF_H_INCLUDED
#ifdef NOASM
int RtfIn();
#endif /* NOASM */
int RtfOut();
int RtfStandardTap();
BOOL FTranslFields();
#define wVersionRTF (1) /* used in the \rtf statement */
#define rooDoc 0x0001
#define rooInfo 0x0002
#define rooBegin 0x0003
#define rooEnd 0x0004
#define rooAll 0x000f
#define rooInternal 0x0010
#define rooNoPict 0x0020
#define rooSub 0x0040
#define roomSub 0xfff0
#define cchMaxRibl 256
#define cbRtfBuf (cchMaxSz - 1)
#define ipcdLarge 2500 /* piece table is about 32K */
#define fsDefRTF (24) /* default rtf font size in half points */
#ifdef DEBUG
#define cchMaxLineRTF 79 /* widest expanse of RTF text w/o EOP */
#else
#define cchMaxLineRTF 255 /* widest expanse of RTF text w/o EOP */
#endif /* DEBUG */
#define icoRTFMax 50
#ifdef RTFDEFS
#ifdef MAC
#define slWord 0
#define slMacwrite 1
#define slWorks 2
#define slMacWord1 3
#define slIBMWord3 4
#endif /* MAC */
#define iBkmkEnd 1
#define iBkmkStart 2
#define iPicWBitmap 0
#define iPicWMetafile 1
#define iPicMacPict 2
#define racChngDest 0
#define racChngProp 1
#define racSpecChar 2
#define racSpecCharAct 3
#define racBinParm 4
#define racIgnore 5
#define racScanByDest 6
#define rrbaFlag 0
#define rrbaBit 1
#define rrbaByte 2
#define rrbaWord 3
#define rrbaUns 4
#define rrbaSpec 7
#define pgcPara 0
#define pgcChar 1
#define pgcSect 2
#define pgcDoc 3
#define pgcPic 4
#define pgcRibl 5
#define pgcBrc 6
#define pgcTable 7
#define pgcDtr 8
#define dof(fld) offset(DOP, fld)
#define sof(fld) offset(SEP, fld)
#define pof(fld) offset(PAP, fld)
#define cof(fld) offset(CHP, fld)
#define riblof(fld) offset(RIBL, fld)
#define rffldof(fld) offset(RFFLD, fld) /* used by fields */
#define dtrof(fld) offset(DTR, fld) /* date/time rtf components */
#define picof(fld) offset(PIC, fld)
#define tapof(fld) offset(TAP, fld)
#define tcof(fld) offset(TC, fld)
#define chRTFBegin 27
#define chRTFEnd 28
#define chRTFBinBreak 29
#define chBackslash 92
#define chRTFOpenBrk '{'
#define chRTFCloseBrk '}'
#define cwRIBL (CwFromCch(sizeof (struct RIBL)))
#ifdef MAC
#define risNorm 0
#define risB4ContSeq 1
#define risContWord 2
#define risNumScan 3
#define risAfContSeq 4
#define risScanPic 5
#define risB4TableName 6
#define risScanTableName 7
#define risDoPop 8
#define risExit 9
#define risB4BinCode 10
#define risBinCode 11
#define risScanBinPic 12
#define risScanByDest 13
#define risB4Private1 14
#define risB4SpecXeTc 15
#else /* WIN */
/* Reorder the ris codes to simplify the assembler jump table in N_RtfIn. */
/* Begin assembler ris cases */
#define risNorm 0
#define risExit 1
#define risB4ContSeq 2
#define risContWord 3
#define risNumScan 4
#define risScanPic 5
#define risB4Private1 6
#define risB4BinCode 7
#define risBinCode 8
#define risB4SpecXeTc 9
#define risB4TableName 10
#define risScanTableName 11
/* Begin pcode ris cases */
#define risAfContSeq 12
#define risScanByDest 13
#define risDoPop 14
#define risAddTableName 15
#endif /* WIN */
#define chsMac 0
#define chsPC 1
#define chsAnsi 2
#define chsPCA 3
#define fmcNil FF_DONTCARE
#define fmcRoman FF_ROMAN
#define fmcSwiss FF_SWISS
#define fmcModern FF_MODERN
#define fmcDecor FF_DECORATIVE
#define fmcScript FF_SCRIPT
#define pgnxyDef (720)
/* bit and word "offsets" for bit fields used in the rgrrbword table
ibitXname is the bit index of field name in struct X
iwordeXname is the word index of field name in struct X
where X is
D for DOP
S for SEP
P for PAP
C for CHP
B for BRC
T for TC
PIC for PIC
R for RIBL
these defines are used in CkDefinesRtf(), a test routine that assures
that the structures referenced do not change and invalidate the values.
Please update that routine (in debug.c) when you add defines.
*/
#define ibitCfBold 0
#define iwordCfBold 0
#define ibitCfItalic 1
#define iwordCfItalic 0
#define ibitCfStrike 2
#define iwordCfStrike 0
#define ibitCfOutline 3
#define iwordCfOutline 0
#ifdef MAC /* fFldVanish for win */
#define ibitCfShadow 4
#define iwordCfShadow 0
#endif /* MAC */
#define ibitCfSmallCaps 5
#define iwordCfSmallCaps 0
#define ibitCfCaps 6
#define iwordCfCaps 0
#define ibitCfVanish 7
#define iwordCfVanish 0
#define ibitCfRMark 8
#define iwordCfRMark 0
#define ibitDfFacingPages 0
#define iwordDfFacingPages 0
#define ibitDfWidowControl 1
#define iwordDfWidowControl 0
#define ibitDfFtnRestart 0
#define iwordDfFtnRestart 1
#define ibitDfWide 7
#define iwordDfWide 0
#define ibitDfRevMarking 15
#define iwordDfRevMarking 2
#define ibitDfBackup 0
#define iwordDfBackup 3
#define ibitDfMirrorMargins 5
#define iwordDfMirrorMargins 3
#define ibitTfFirstMerged 0
#define iwordTfFirstMerged 0
#define ibitTfMerged 1
#define iwordTfMerged 0
#define ibitFFfResDirty 0
#define iwordFFfResDirty 0
#define ibitFFfResEdit 1
#define iwordFFfResEdit 0
#define ibitFFfLocked 2
#define iwordFFfLocked 0
#define ibitFFfPrivRes 3
#define iwordFFfPrivRes 0
#define ibitRfRevisions 13
#define iwordRfRevisions 0
#ifdef MAC
#define cbBlockPic (cbPIC + cbPEBase)
#endif /* MAC */
#ifdef WIN
#define cbBlockPic (cbPIC)
#endif /* WIN */
/* macros */
#define IifdFromRds(rds) (rds - rdsTitle)
/* return true if the range cpFirst - cpLim contains the start or end of
a bookmark. Only callable from within RtfOut.
*/
#define FBkmksInRun(cpFirst, cpLim) ( (bkmkRtf.cpFirstBkmk >= cpFirst && \
bkmkRtf.cpFirstBkmk <= cpLim) || (bkmkRtf.cpLimBkmk >= cpFirst \
&& bkmkRtf.cpLimBkmk <= cpLim) )
struct BKMKRTF
{
int fHaveBkmks;
int fHaveBkmkInRun;
int ibkmkMac;
int icpLimBkmk;
int icpFirstBkmk;
CP cpLimBkmk;
CP cpFirstBkmk;
int **hmpIbklIbst;
};
#endif /* RTFDEFS */
/* Date and Time - Excel's structure */
struct DTR
{
int yr; /* 4-digit */
int mon; /* 1-12 */
int dom; /* 1-31 */
int hr; /* 0-23 */
int mint; /* 0-59 */
int sec; /* 0-59 */
int wdy; /* 1-7 for Sunday-Saturday */
};
#define cwDTR (CwFromCch(sizeof (struct DTR)))
struct RSYM /* RTF symbol table entry */
{
int val : 8;
int fPassVal : 1;
int rac: 7;
union
{
int ipfnAction;
int irrbProp;
int fSpec;
};
};
/* Note: be sure the following structures stay multi
ples of words */
struct RFFLD
/* FLD structure flags */
{
int fResultDirty : 1; /* user has edited or formatted the result */
int fResultEdited : 1;/* user has inserted or deleted to/fm result */
int fLocked : 1; /* this field is locked from recalc */
int fPrivateResult : 1; /* never show the result of this field */
int fSpare : 12;
};
#define cwRFFLD (CwFromCch(sizeof (struct RFFLD)))
struct RCPFLD /* RTF CP area for fields */
{
CP dcpInst; /* size of instruction text */
CP dcpRslt; /* size of result text */
struct RFFLD rffld; /* flags */
};
#define cwRCPFLD (CwFromCch(sizeof (struct RCPFLD)))
struct RCPXETC /* RTF CP area for Xe and TC entries */
{
CP cpFirstEntry;
CP cpLimEntry;
CP cpFirstText;
CP cpLimText;
struct
{
int fVanishEntry : 1;
int fVanishText : 1;
int fInEntry : 1;
int fInText : 1;
int fSpare : 12;
};
int docTemp; /* holder for moving text */
};
#define cwRCPXETC (CwFromCch(sizeof (struct RCPXETC)))
struct RHPCCHW /* used in some RtfOut calls */
{
HANDLE h;
long lcbMac; /* current handle used size */
long lcbMax; /* current handle allocated size */
int wAlloc; /* GMEM for allocations */
};
struct RSTN /* RTF Stack Node */
{
int bPrev;
int bCharInfo;
int bParaInfo;
int bSectInfo;
int bTableInfo;
int rds;
CP cpFirst;
struct RCPFLD **hrcpfld; /* used only by fields */
};
struct RRB
{ /* RTF Record Block */
int rrba : 3;
int pgc : 7;
int b : 6;
int w;
};
struct REBL
{ /* RTF Environment Block */
#ifdef MAC
int sl;
#endif /* MAC */
int (*pfnWrite)();
int *pArgWrite;
char rgch[cchMaxSz - 1];
};
/* cch of worse case RTF tab string: \tqdec\tlhyph\tx99999 */
#define cchMaxTabRtf 21
/* cch of worse case RTF property string: \linerestart99999 */
#define cchMaxPropRtf 17
#ifndef OPUS_RARF_DEFINED
#define OPUS_RARF_DEFINED
struct RARF /* RftAppendRgchtoFn parm */
{
int fn;
};
#endif
#ifdef MAC
struct FTCM /* ftc map entry */
{
int ftcTo; /* order is significant for searching */
int ftcFrom;
};
#else /* !MAC */
/* Really the first iftcMac entries of rgwFtc are the rgwFtcFrom
while the iftcMac entries beginning at rgwFtc[iftcMax] are the
rgwFtcTo. This is better for opus than using a plex of ftcm's
because it allows us to use IScanLprgw on the rgwFtcFrom to
find an entry for an ftcFrom, and simplifies a bunch of code.
*/
struct FTCMAP /* ftc map structure */
{
int iMac;
int iMax;
int rgwFtc[1];
};
#endif /* !MAC */
struct FTF /* ftc to fmc lookup entry */
{
int ftc;
int fmc;
};
struct RIBL
{
int fInBody : 1;
int fCancel : 1;
int fNoColor : 1;
int fXeTcQOpen : 1;
int fSideBySide : 1;
int fHdr: 1; /* hdr/ftr entered in this section */
int fFtr: 1;
#ifdef WIN
int fSpares: 3;
int fInXeTc : 1; /* for hack of killing nested xetc/xert */
int fInXeRT : 1;
int fFldImport: 1; /* true if we just processed an import field */
int fRevisions : 1;
int fDisregardPic : 1;
int fHiNibble : 1;
#else /* !WIN */
int fSpares: 9;
#endif /* !WIN */
#ifdef MAC
char sl;
#endif /* MAC */
char ris;
char i;
char b;
char bPic;
int bchSeqLim;
int bchNumLim;
int bchData;
#ifdef MAC
char *pdfpMacWr;
#endif /* MAC */
char fStcNextOK;
char fNextIsDest; /* if true and don't recognize dest, skip */
int iGrid;
int mts;
int chs; /* type of character set */
int fmc; /* font family code */
int deff; /* default ftc to emit or read in */
int pgnStart; /* doc props Opus stores in first section */
int lineStart;
int vern; /* rtf generator version #, from info block */
struct ESTCP estcp;
char fFonttblDef;
char cRed;
char cGreen;
char cBlue;
long lcb;
uns dxaPgn;
uns dyaPgn;
uns dyaHdrBottom;
uns dxaRight;
uns dyaBottom;
int rds; /* RTF destination */
int doc;
int ihdt;
CP cpRdsFirst;
int iNibble;
#ifdef WIN
int iTypePic;
#endif /* WIN */
#ifdef MAC
int fMacPict;
int itbdm1Mac;
struct TBDM1 tbdm1;
int fBeginMacWrPic;
#endif /* MAC */
char stUsrInitl[ichUsrInitlMax];
char **hrgbStack;
int bStackLim;
int rhc;
FC fcPicFirst;
#ifdef MAC
/* struct CAB **hcab; * opus code never uses this */
#endif /* MAC */
char fWindowMessage;
char fDopPropsRecorded;
#ifdef MAC
struct PL **hplftcm;
#else /* !MAC */
struct FTCMAP **hftcmap;
#endif /* !MAC */
int fPermOK;
#ifdef MAC
int (*pfnCharDefault)();
#endif /* MAC */
int cbCharInfo;
#ifdef MAC
int (*pfnParaDefault)();
#endif /* MAC */
int cbParaInfo;
#ifdef MAC
int (*pfnSectDefault)();
#endif /* MAC */
int cbSectInfo;
#ifdef MAC
int (*pfnTableDefault)();
#endif /* MAC */
int cbTableInfo;
int fParaBrc;
int itc;
int ibrc;
union
{
struct TBD tbd;
int dummy;
};
struct RCPFLD **hrcpfld; /* used only by fields */
struct STTB **hsttbGrid; /* used only by Excel grids */
struct RCPXETC **hrcpxetc; /* used only by index, toc entries */
int ibSea;
char rgbSea[cbSEA];
char rgch[cchMaxRibl];
union
{
struct PAP pap;
#ifdef MAC
struct PFP pfp;
struct PAPM1 papm1;
#endif /* MAC */
char rgbPara[sizeof(struct PAP)];
};
union
{
struct CHP chp;
#ifdef MAC
struct CFP cfp;
#endif /* MAC */
char rgbChar[sizeof(struct CHP)];
};
union
{
struct SEP sep;
#ifdef MAC
struct SFP sfp;
struct SEPM1 sepm1;
#endif /* MAC */
char rgbSect[(sizeof(struct SEP))];
};
union
{
struct TAP tap;
char rgbTable[(sizeof(struct TAP))];
};
char rgbStcPermutation[256];
char **hstGrid;
int icoMac;
int mpicoOldicoNew[icoRTFMax];
/* note: variable size PIC must be at end of struct RIBL! */
struct PIC pic;
};
struct FLDS /* field state for stack */
{
int flt:8;
int fOpenQuote:1;
int fInTRSwText:1; /* have found text associated with t or r switch */
int grpfOpenSw:3;
int fParInFld:1;
int fTableOut:1; /* have written out table props in field */
int fSpare:1;
};
#define grpfSwNone (0)
#define grpfSwXeR (1)
#define grpfSwXeT (2)
#define grpfSwTcF (3)
#define grpfSwTcL (4)
#endif /* OPUS_RTF_H_INCLUDED */
+2608
View File
File diff suppressed because it is too large Load Diff
+1603
View File
File diff suppressed because it is too large Load Diff
+2223
View File
File diff suppressed because it is too large Load Diff
+1701
View File
File diff suppressed because it is too large Load Diff
+1774
View File
File diff suppressed because it is too large Load Diff
+333
View File
@@ -0,0 +1,333 @@
struct BMI /* Bitmap Info */
{
HBITMAP hbm; /* Handle to bitmap */
int dxp; /* x-size of bitmap */
int dyp; /* y-size of bitmap */
int :1;
int fDiscardable:1; /* bitmap may be discarded */
int :6;
int idcbMax:8; /* # of imbedded bitmaps (incl. gray) */
int dxpEach; /* width of each sub-bitmap in this bitmap */
};
/* height of Ribbon window in 1/8 char units */
/* Actually, we add one pixel to the height of the ribbon after
calculating it. this is because of weirdnesses with some screen
resolutions. */
#define dyRibbon 15
#define ddyIconLH 3
#ifdef WIN23
#define dyRuler2 31 /* height of Ruler window in 1/8 char units */
#define dyRuler3 28 /* height of Ruler under Win 3 */
#else
#define dyRuler 31 /* height of Ruler window in 1/8 char units */
#endif /* WIN23 */
/* following constants relate to the x-coordinate limits; users of these
must generally be careful to assure that 16-bit overflow of the
pixel-equivalents is not an issue. */
/* xa limit: about .5 in less than 16 bits */
#define xaRightMaxRaw (22*dxaInch)
#define xaLeftMinRaw (-xaRightMaxRaw/2) /* raw value; limit applied in initwin.c */
#define xaMax (xaRightMaxRaw)
#define xaMin (-xaRightMaxRaw)
#define xaNil (xaMin - 1)
/* Twip constants to be stored in pixels for our screen in SCI structure */
/* amount of gray to reveal above or below page when selection scrolling */
#define dyaPastPage 720
/* amount of page real estate to display initially when new page is reached
via selection scrolling */
#define dyaPageReveal 240
#define dyaMinAveLine 240
#define dyaMacAveLine 600
#define xaSelBar 288
#define dxaMinScroll 1000
#define yaSubSuper 60
#define dyaMinWwInit 60
#define dyaWwMin 720
#define dxaGrayOutside 720 /* PAGE VIEW: Gray area outside page */
#define dyaGrayOutside 720
#define dccmTextColor 0x0001
#define dccmBkgrnd 0x0002
#define dccmTransparent 0x0004
#define dccmHpenBorder 0x0008
#define dccmHpen 0x0010
#define dccmCurFont 0x0020
#define dccmOpaque 0x0100
#define dccmUnlockBrushPen 0x0200
#define dccmColors (dccmTextColor | dccmBkgrnd)
#define dccDoc (dccmColors | dccmOpaque | dccmHpen | dccmCurFont)
#define dccScratch (dccmOpaque | dccmCurFont)
#define dccRuler (dccmColors | dccmTransparent)
#define dccPrompt (dccmColors)
#define dccSEdit (dccmTextColor | dccmBkgrnd | dccmHpen)
#ifdef WIN23
#define dccStatLine2 (dccmColors | dccmOpaque)
#define dccStatLine3 (dccmTransparent)
#define dccIconBar2 (dccmColors | dccmOpaque)
#define dccIconBar3 (dccmTextColor | dccmOpaque)
#else
#define dccStatLine (dccmColors | dccmOpaque)
#define dccIconBar (dccmColors | dccmOpaque)
#endif /* WIN23 */
/* Raster Operations */
#define ROP_S (DWORD) 0x00CC0020 /* same as SRCCOPY */
#define ROP_Sn (DWORD) 0x00330008
#define ROP_PSo (DWORD) 0x00FC008A
#define ROP_PSno (DWORD) 0x00F3022A
#define ROP_DPSxx (DWORD) 0x00960169
#define ROP_PDSxxn (DWORD) 0x00690145
#define ROP_Pn (DWORD) 0x000f0001
#ifdef WIN23
#define ROP_DPSnao (DWORD) 0x00B00E05
#define ROP_DSnx (DWORD) 0x00990066
#define ROP_DPo (DWORD) 0x00FA0089
#endif /* WIN23 */
struct MDCD /* Memory DC Descriptor */
{
HDC hdc;
struct BMI *pbmi;
};
#ifdef OPUS_X64
/* These were supplied by the segmented build's native symbol table. An
* explicit declaration is required on AMD64 so callers retain the complete
* pointer returned by the original display cache implementation. */
struct MDCD *PmdcdCacheIdrb();
struct MDCD *PmdcdCachePbmi();
#endif
struct DCIB /* Display Context Information Block */
{
long ropBitBlt;
long ropErase;
};
struct SCI /* Screen Info */
{
int fMonochrome; /* whether we have a monochrome display */
int fInvertMonochrome : 1; /* monochrome windows w/white on black */
int fUseResCursors : 1; /* cursor resolution not normal */
#ifdef WIN23
int fWin3Visuals: 1; /* Win 3 ruler, ribbon, statline, etc */
int fWin3: 1; /* Win 3 font, dialogs */
int :12;
#else
int :14;
#endif /* WIN23 */
long rgbBkgrnd; /* COLOR_WINDOW */
long rgbText; /* COLOR_WINDOWTEXT */
long rgbBorder; /* COLOR_WINDOWFRAME */
WORD wSpare1;
HBRUSH hbrScrollBar; /* brush for drawing scroll bar */
HBRUSH hbrBkgrnd; /* Background brush */
HBRUSH hbrText; /* handle to text-colored brush */
HBRUSH hbrDesktop; /* brush for desktop background color */
HBRUSH hbrBorder; /* brush for drawing borders */
HPEN hpen; /* Foreground pen, for text etc */
HPEN hpenBorder; /* Pen for drawing borders */
long ropErase; /* raster op for erasing screen */
union { /* scratchpad memory DC: for screen cache and misc uses */
struct MDCD mdcdScratch;
struct {
HDC hdcScratch; /* direct access to fields */
struct BMI *pbmiScratch;
};
};
struct MDCD mdcdBmp; /* extra memory DC for resource bitmaps */
struct DCIB dcibMemDC; /* Info for Memory DC */
struct DCIB dcibScreen; /* Info for Screen DC */
struct FTI *pfti; /* Ptr to fti struct crntly rep screen */
int dxpScreen; /* Width of display device in pixels */
int dypScreen; /* Height of display device in pixels */
int dxpScrlBar; /* Width of vert scroll bar */
int dypScrlBar; /* Height of horiz scroll bar */
int dxpBorder; /* Width of vert window border */
int dypBorder; /* Height of horiz window border */
int dypSplitBox; /* Height of split box */
int dypSplitBar; /* Height of split bar */
int dypRibbon; /* Height of ribbon */
int dypStatLine; /* Height of status line */
int dypRuler; /* Height of ruler */
int dxpTmWidth; /* Width of system font */
int dypTmHeight; /* Height of system font */
int dypScrollArrow; /* Height of arrow in vertical scroll bar */
int dypTmAscent;
int xpScrollMax; /* Largest possible x-scroll offset */
int dypComboSmall; /* size of combo with no list showing */
int dxpComboDelta; /* with change for changed combos */
int xaLeftMin; /* lowest possible xaLeft for FormatLine */
int xaRightMax; /* xaRightMaxRaw, limited to 16-bit pixel equivalent */
int dypIconBar; /* height of icon bar */
int dxmmScreen; /* Width of display device in mm */
int dymmScreen; /* Height of display device in mm */
int dxpBmpSystem;/* Width of doc window system menu bitmap */
int dypMenuBar; /* Height of a one line menu bar */
int dypBdrCapt; /* Height of thick border + caption bar */
/* Start of table of twip-to-pixel constants */
/* Must match rgdxaConvert array in initwin.c */
/* dxp */
int dxpMinScroll; /* Horiz scrolling increment */
int dxwSelBar; /* width of selbar */
int xpLeftMin; /* amt to scroll left of left margin */
int xpRightMax; /* Largest possible screen xp */
int dxpGrayOutside; /* PAGE VIEW: Gray area outside page */
/* dyp */
int dysMinAveLine; /* Lo Avg line size, for scroll,alloc */
int dysMacAveLine; /* Lo Avg line size, for scroll,alloc */
int dypMinWwInit; /* White space above top line */
int ypSubSuper; /* raise/lower amount for subscript/super */
int dypWwMin; /* Min height of window */
int dypPastPage;
int dypPageReveal;
int dypGrayOutside; /* PAGE VIEW: Gray area outside page */
/* end of table of twip-to-pixel constants */
int dypTmInternalLeading; /* internal leading of system font */
#ifdef WIN23
long rgbButtonShadow;
HBRUSH hbrButtonText; /* handle to button text-colored brush */
HBRUSH hbrLitButton;
int dyRuler; /* this is variable under 10A */
int dccStatLine;
int dccIconBar;
int dypOtlPat;
FARPROC lpfnCreateDIBitmap; /* so we only get it under Win 3 */
int dxpFakeTmWidth;
int dypFakeTmHeight;
long rgbButtonFace;
long rgbButtonText;
#endif /* WIN23 */
};
/* These defines are used in shared code; for Opus they are vsci fields */
#define dysMinAveLineSci vsci.dysMinAveLine
#define dysMacAveLineSci vsci.dysMacAveLine
#define dxpMinScrollSci vsci.dxpMinScroll
#define dypBorderFti vfti.dypBorder
#define dxpBorderFti vfti.dxpBorder
#define dypPastPageSci vsci.dypPastPage
#define dypPageRevealSci vsci.dypPageReveal
#define dypMinWwInitSci vsci.dypMinWwInit
#define dxpGrayOutsideSci vsci.dxpGrayOutside
#define dypGrayOutsideSci vsci.dypGrayOutside
#define xaRightMaxSci vsci.xaRightMax
#define xaLeftMinSci vsci.xaLeftMin
#define dxwSelBarSci vsci.dxwSelBar
#define xpRightMaxSci vsci.xpRightMax
#define xpLeftMinSci vsci.xpLeftMin
#define xwMaxSci xpRightMaxSci
#define cxpAutoSci vsci.dxpMinScroll
#define dxaOtlMark (dxaInch / 4)
#define rzOtlPat 9
/* Info about table of twip-to-pixel constants imbedded in struct SCI */
#define brgdxpConvert (offset( SCI, dxpMinScroll ))
#define brgdypConvert (offset( SCI, dysMinAveLine ))
#define cDxpConvert ((brgdypConvert - brgdxpConvert) / sizeof (int))
#define cDypConvert ((offset( SCI, dypTmInternalLeading) - brgdypConvert) / sizeof (int))
/* patterns available in pattern bitmaps */
/* must track structures in initwin.c used by FCreatePatternBitmaps */
#define ipatVertGray 0
#define ipatVertBlack 1
#define ipatHorzGray 0
#define ipatHorzLtGray 1
#define ipatHorzBlack 2
/* size of pattern bitmaps. must be even multiple of all repeat intervals and
of 8. For the horz pattern, it must also be a multiple of 16 and 3 */
#define dxpHbmHorz 576
#define dypHbmVert 360
/* Pattern Line Types, for DrawPatternLine */
#define pltHorz 0x00 /* for clarity in the caller */
#define pltVert 0x01
#define pltOnePixel 0x02 /* limit height/width to one pixel */
#define pltInvert 0x04 /* set if two draws should == no action */
#define pltDouble 0x08 /* Double height/width */
/* following constant is least common multiple of all repeating patterns
used by DrawPatternLine. This is helpful for brush alignment. */
#define lcmPat 3
struct BMC { /* BitMap Cache block for picture display */
struct CA ca;
HBITMAP hbm;
int flm;
long lcb;
};
/* Move Pane Direction */
#define mpdPaneOnly 0
#define mpdTopDown 1
#define mpdBottomUp 2
/* For consequtive mouse scroll. */
/* The following sb's better not be used by Windows. */
#define SB_NIL (-1)
#define SB_MOUSESEL (0x7FFF)
/* rgb values for character colors. Valid pure Windows colors (bz) */
#define rgbBlack (RGB(0, 0, 0))
#define rgbBlue (RGB(0, 0, 255))
#define rgbCyan (RGB(0, 255, 255))
#define rgbGreen (RGB(0, 255, 0))
#define rgbMagenta (RGB(255, 0, 255))
#define rgbRed (RGB(255, 0, 0))
#define rgbYellow (RGB(255, 255, 0))
#define rgbWhite (RGB(255, 255, 255))
#ifdef WIN23
#define rgbLitButton (RGB(224, 224, 224))
#define rgbLtGray (RGB(192, 192, 192))
#define rgbGray (RGB(128, 128, 128))
#endif /* WIN23 */
#define FlmDisplayFromFlags(fDispAsPrint,fPageView,fDraftView) (((fDispAsPrint)||(fPageView))&&!(fDraftView))
+1306
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -0,0 +1,4 @@
#define rmj 1
#define rmm 11
#define rup 2401
#define szVerName ""
+1851
View File
File diff suppressed because it is too large Load Diff
+78
View File
@@ -0,0 +1,78 @@
#define spcDone 98
#define spcAbort 99
#define ilngMax 17
#define cbszLangMax 20
#define cbReplaceWordMax 255
#define cbWordMax 30 /* Maximum size of word strings */
#define cbWordMin 2 /* Minimum size of word strings */
#define udcUpdate 0 /* User Dictionary Code */
#define udcUser 1
#define udcMax 2
struct SPL /* Spell library structure */
{
CHAR stPath[ichMaxFile];
HANDLE hLib;
struct GHD ghdWord; /* structures for passing strings to/from DLL */
struct GHD ghdReplaceWord;
struct GHD ghdT;
HSTACK hstack;
BOOL (FAR PASCAL *lpfnHStackSpell)();
BOOL (FAR PASCAL *lpfnFSpellInit)();
BOOL (FAR PASCAL *lpfnFSpellCleanUp)();
unsigned long (FAR PASCAL *lpfnLLookUpWord)();
void (FAR PASCAL *lpfnGetAlternates)();
BOOL (FAR PASCAL *lpfnFSetDictAux)();
BOOL (FAR PASCAL *lpfnFAddWordToDictAux)();
BOOL (FAR PASCAL *lpfnFDeleteWordFromDictAux)();
BOOL (FAR PASCAL *lpfnFAddWordToCacheAux)();
BOOL (FAR PASCAL *lpfnGhSpellGetrgchCase)();
BOOL (FAR PASCAL *lpfnResetRepeatWord)();
};
#define szUpdateDictDef "STDUSER.DIC"
struct SPV /* Spell pseudo-global variables (on frame) */
{
int fSeeSel;
BOOL fSplCancel;
BOOL fInScanDoc;
BOOL fStartScan;
int LookupError;
BOOL fCancelTerminate;
int mpudcfRO [udcMax];
int mpilngiLB [ilngMax]; /* maps language code to index in list box */
int mpilngfDee [ilngMax];
BOOL fNoSugg;
int StatLdADictFn;
HDLG hDlgSpeller;
CHAR szT[cbWordMax+2];
struct FINDFILE FindFile;
CHAR szUpdateDict[sizeof(szUpdateDictDef)];
};
#define cbchBuffMax 256
#define ccrBuffMax 20
struct SCD /* Scan Doc structure */
{
CP cpScanStart; /* defines overall scan for FScanDoc */
CP cpScanLim; /* defines overall scan for FScanDoc */
CP cpTestWord; /* returned by FGetNextWordFromDoc */
CP cpLimWord; /* returned by FGetNextWordFromDoc */
CHAR szTestWord[cbWordMax+2]; /* returned by FGetNextWordFromDoc */
int fPrompt; /* true if prompt line is used during scan */
int fDirtyDoc; /* set iff doc is dirtied during spell */
CP cpScan; /* cp scan point for FGetNextWordFromDoc */
CP cpScanLocalMac; /* Limit cp for FGetNextWordFromDoc */
BOOL fCheckWrap; /* whether to check wraparound at doc end */
CHAR rgchCase[256]; /* speller array: maps ch to char type bits */
};
NATIVE SpcScanDocNextWord();
NATIVE FGetNextWordFromDoc();
+2
View File
@@ -0,0 +1,2 @@
ResetDC succeeded.
ResetDC succeeded.
+35
View File
@@ -0,0 +1,35 @@
Volume in drive G has no label
Directory of G:\DIFF\OPUS
SORT C 52092 11-06-90 5:28p
1 file(s) 52092 bytes
14966784 bytes free
Volume in drive G has no label
Directory of G:\DIFF\SPIFF\SRC\CMD
SORT C 62269 08-16-91 8:16a
1 file(s) 62269 bytes
14966784 bytes free
Volume in drive G has no label
Directory of G:\DIFF\SPIFF\SRC\MAIN
SORT C 103713 11-07-90 3:23p
1 file(s) 103713 bytes
14958592 bytes free
Volume in drive G has no label
Directory of G:\SRC\OPUS
SORT C 47204 11-06-90 5:27p
1 file(s) 47204 bytes
14966784 bytes free
Volume in drive G has no label
Directory of G:\SRC\SPIFF\SRC\CMD
SORT C 45954 08-16-91 8:16a
1 file(s) 45954 bytes
14966784 bytes free
+1550
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
TNUM FAR PASCAL DAdd(NUM *);
TNUM FAR PASCAL DSub(NUM *);
TNUM FAR PASCAL DMul(NUM *);
TNUM FAR PASCAL DDiv(NUM *);
TNUM FAR PASCAL DNeg(void);
void FAR PASCAL TenTo(int);
void FAR PASCAL DInt(void);
void FAR PASCAL DAbs(void);
VOID FAR PASCAL Dld(NUM *);
VOID FAR PASCAL Dst(NUM *);
int FAR PASCAL Fix(void);
VOID FAR PASCAL DFloat(int);
int FAR PASCAL DCond(void);
VOID FAR PASCAL DClr(void);
VOID FAR PASCAL Pack(char *);
VOID FAR PASCAL Unpack(char *);
int FAR PASCAL DError(int);
+647
View File
@@ -0,0 +1,647 @@
#include "word.h"
DEBUGASSERTSZ /* WIN - bogus macro for assert string */
#include "heap.h"
#include "disp.h"
#include "doc.h"
#include "props.h"
#include "sel.h"
#include "ch.h"
#include "debug.h"
#include "cmd.h"
#include "idd.h"
#include "sdmdefs.h"
#include "sdmver.h"
#include "sdm.h"
#include "sdmtmpl.h"
#include "field.h"
#include "error.h"
#include "rareflag.h"
#include "footnote.hs"
#include "footnote.sdm"
extern struct MWD **hmwdCur;
extern struct WWD **hwwdCur;
extern int wwCur;
extern int vifnd;
extern int vfSeeSel;
extern CHAR rgchEop[];
extern struct MERR vmerr;
extern struct DOD **mpdochdod[];
extern struct SEL selCur;
extern struct CHP vchpStc;
extern struct UAB vuab;
extern struct CA caSect;
extern struct SEP vsepFetch;
extern struct PREF vpref;
extern CHAR szEmpty[];
extern BOOL vfRecording;
extern BOOL fElActive;
extern CP CpFirstBlock();
csconst CHAR szArgs[] = SzSharedKey(" \\# \"\'Page: \'#\'\013\'\"",Args); /* \# "'Page: '#'chCRJ'" */
#define cchArgs (18)
#define cchFtnRefMax 10
#define iagStRef Iag(CABINSERTFTN, hstRef)
csconst CHAR szAtn[] = {
chAtn, '\0'};
/* %%Function:CmdViewRef %%Owner:chic */
CMD CmdViewRef(wk, edc)
int wk;
int edc;
{
BOOL fRecordingSav;
CMD cmd = cmdError;
Assert (PselActive() == &selCur);
InhibitRecorder(&fRecordingSav, fTrue);
if ((!vrf.fVetoViewRef || PdodDoc(selCur.doc)->fShort) &&
((*hmwdCur)->wwLower != wwNil &&
PwwdWw((*hmwdCur)->wwLower)->wk == wk))
{
KillSplit(hmwdCur, fTrue /* fLower */, fFalse /*fAdjustWidth*/);
cmd = cmdOK;
}
else if (!FHasRefs(DocMother(DocBaseWw(wwCur)), edc))
{
ErrorEid(wk == wkFtn ? eidNoFNToShow : eidNoANNToShow,"CmdViewRef");
}
else if (!FReportSplitErr(wk))
{
EnsureSelInWw(fFalse, &selCur);
cmd = FViewFtnAtn(edc) ? cmdOK : cmdError;
}
InhibitRecorder(&fRecordingSav, fFalse);
return cmd;
}
/* %%Function:CmdViewAnnotation %%Owner:chic */
CMD CmdViewAnnotation(pcmb)
CMB *pcmb;
{
Assert(hmwdCur && hwwdCur);
Assert(PdodDoc(selCur.doc)->fAtn || PdodDoc(selCur.doc)->fMother);
return CmdViewRef(wkAtn, edcDrpAtn);
}
/* %%Function:CmdInsAnnotation %%Owner:chic */
CMD CmdInsAnnotation(pcmb)
CMB *pcmb;
{
int doc = selCur.doc;
int docAtn;
struct WWD *pwwdCur;
struct DOD *pdod = PdodDoc(doc);
CP cpT, cpRef = selCur.cpFirst;
CP cpAtn;
int cstcStd;
int iand;
BOOL fAtn, ifld;
struct CA ca, caT;
int cmdRet = cmdOK;
BOOL fRecordingSav;
struct CHP chpText; /* chp for annotation text */
struct CHP chpRef; /* chp for annotation mark in annotation doc */
struct CHP chpRefDoc; /* chp for annotation mark in mother doc - fVanish is true */
struct PAP papText;
struct PLC **hplcatrd;
struct PLC **hplcand;
struct ATRD atrd;
struct FLCD flcd;
CHAR szKeyword [cchMaxFieldKeyword + 1];
Assert(doc != docNil);
/* only allow insert annotation in mother doc or annotation pane */
if (!pdod->fMother && !pdod->fAtn)
{
Beep();
return cmdError;
}
if (FReportSplitErr(wkAtn))
return cmdError;
StartLongOp();
if (fAtn = (pdod = PdodDoc(doc))->fAtn)
{
docAtn = doc;
doc = pdod->doc;
}
/* Get the exact cpFirst of the document, i,e. in case of a block selection.
If in annotataion pane, ignore selCur anyway since always insert at beginning
of annotation text.
*/
if (selCur.fBlock && !pdod->fAtn)
cpRef = CpFirstBlock();
/* get user initials to compose annotation ref mark */
Assert(vpref.stUsrInitl[0] < ichUsrInitlMax);
CopySt(vpref.stUsrInitl, &atrd);
/* Prepare chp desired for reference and pap and chp desired for annotation text.
*/
TurnOffSel(&selCur);
if ((!FStcDefined(doc, stcAtnRef) &&
!FEnsureStcDefined(doc, stcAtnRef, &cstcStd)) ||
(!FStcDefined(doc, stcAtnText) &&
!FEnsureStcDefined(doc, stcAtnText, &cstcStd)))
{
LError:
cmdRet = cmdError;
goto LRet;
}
pdod = PdodDoc(doc);
/* chp and pap are used temporarily by the next line for the reference */
MapStc(pdod, stcAtnRef, &chpRefDoc, &papText);
chpRefDoc.fSpec = fTrue;
chpRef = chpRefDoc;
chpRefDoc.fVanish = fTrue; /* make it hidden text */
MapStc(pdod, stcAtnText, &chpText, &papText);
papText.stc = stcAtnText;
chpText.fRMark = chpRef.fRMark = chpRefDoc.fRMark = PdodMother(doc)->dop.fRevMarking;
if (fAtn)
{
/* in annotation document: insert ref in front of the annotation text */
if (cpRef >= CpMacDocEdit(docAtn))
ErrorEid(eidNotValidForAnn,"CmdInsAnnotation");
else
{
hplcand = PdodDoc(docAtn)->hplcand;
cpAtn = CpPlc( hplcand, IInPlc(hplcand, cpRef));
if (FSetUndoB1(bcmInsAnnotation, uccPaste, PcaPoint(&caT, docAtn, cpAtn)))
{
FInsertRgch(docAtn, cpAtn, SzNear(szAtn), 1, &chpRef, 0);
SetUndoAfter(PcaSetDcp(&caT, docAtn, cpAtn, (CP)1));
}
else
cmdRet = cmdCancelled;
}
goto LRet;
}
if ((docAtn = DocSubEnsure(doc,edcDrpAtn)) == docNil ||
!FSetUndoBefore(bcmInsAnnotation, uccInsert))
{
LNoMem:
cmdRet = cmdNoMemory;
goto LRet;
}
/* no autodelete */
/* insert annotation reference to mother doc at cpRef */
if (!FInsertRgch(doc, cpRef, SzNear(szAtn), 1, &chpRefDoc, 0))
goto LNoMem;
/* correct for dead field */
AssureNestedPropsCorrect(PcaSet(&caT, doc, cpRef, cpRef+1), fTrue);
cpAtn = CpFirstRef(doc, cpRef, &cpT, edcDrpAtn);
/* Insert in docAtn */
/* we now have: vifnd, cpAtn of the next annotation text. Our annotation
should appear in front of this.
Insert eop for a start following cpAtn.
*/
if (!FInsertRgch(docAtn, cpAtn, rgchEop, (int)ccpEol, &chpText, &papText))
goto LNoMem;
/* Update hplcand's and hplcatrd's in both documents */
hplcatrd = PdodDoc(doc)->hplcatrd;
hplcand = PdodDoc(docAtn)->hplcand;
if (!FInsertInPlc(hplcatrd, vifnd, cpRef, &atrd))
goto LNoMem;
if (!FOpenPlc(hplcand, vifnd, 1))
{
FOpenPlc(hplcatrd, vifnd, -1); /* delete what just inserted */
goto LNoMem;
}
PutCpPlc( hplcand, vifnd, cpAtn );
/* cause FInsertRgch is inserting at the
wrong annotation (cpAtn is of the next annotation text) */
PutCpPlc( hplcand, vifnd + 1, CpPlc( hplcand, vifnd + 1) + ccpEol );
iand = vifnd;
/* Insert reference mark in front of the annotation text */
Assert(!chpRef.fVanish);
/* Insert a page field for simplicity in print */
if (!FInsertRgch(docAtn, cpAtn, SzNear(szAtn), 1, &chpRef, 0) ||
!FInsertFieldDocCp(docAtn, cpAtn, fFalse/* fSeparator */))
{
goto LNoMem; /* so we end up with no page field and/or no atn mark */
}
GetFltKeyword(fltPage, szKeyword);
if (!FInsertRgch(docAtn, cpAtn+1, SzNear(szArgs), cchArgs, &chpText, NULL) ||
!FInsertRgch(docAtn, cpAtn+1, szKeyword, CchSz(szKeyword)-1, &chpText, NULL))
goto LNoMem;
ifld = IfldFromDocCp(docAtn, cpAtn, fTrue);
Assert(ifld != ifldNil);
GetIfldFlcd(docAtn, ifld, &flcd);
flcd.flt = fltPage;
flcd.fDirty = fFalse;
flcd.fDiffer = fFalse;
SetFlcdCh(docAtn, &flcd, 0);
/* select insertion point after the reference */
cpRef ++;
SelectIns(&selCur, cpRef);
/* invalidate other references to be renumbered */
cpT = CpPlc( hplcatrd, iand + 1 );
InvalCp( PcaSet( &ca, doc, cpT, CpMacDocEdit(doc)));
cpT = CpPlc( hplcand, iand + 1 );
InvalCp(PcaSet( &ca, docAtn, cpT, CpMacDocEdit(docAtn)));
PushInsSelCur();
NormCp(wwCur, selCur.doc,cpRef, ncpHoriz, 0, selCur.fInsEnd);
InhibitRecorder(&fRecordingSav, fTrue);
FShowFtnAtn( doc, wkAtn ); /* ok if fail */
InhibitRecorder(&fRecordingSav, fFalse);
/* if annotation window exists, make it current and select the end of the
annotation text */
pwwdCur = *hwwdCur;
if (pwwdCur->wk == wkAtn)
{
CP cp;
/* note: wwCur = annotation pane */
/* select in front of terminating eop. Note cpRef points to after the
reference now. */
Assert( (*hmwdCur)->fSplit );
cp = CpFirstRef(doc, cpRef, &cpT,edcDrpAtn) - ccpEop;
SelectIns(&selCur, cp);
vfSeeSel = fTrue;
}
Assert(cpRef > cp0);
SetUndoAfter(PcaSetDcp(&caT, doc, cpRef-1, (CP)1));
LRet:
EndLongOp(fFalse /*fAll*/);
return cmdRet;
}
/* %%Function:FViewFtnAtn %%Owner:chic */
FViewFtnAtn(edcDrp)
int edcDrp;
{ /* View either footnote or annotation */
int doc = selCur.doc;
CP cpRefDoc = selCur.cpFirst;
int wk = (edcDrp == edcDrpFtn ? wkFtn : wkAtn);
CP cp, cpT;
if (FShowFtnAtn(doc, wk))
{
if (PwwdWw((*hmwdCur)->wwActive)->wk == wk)
{
/* note: wwCur = footnote pane or annotaion pane */
/* select in front of footnote or annotation text */
cp = CpFirstRef(doc, cpRefDoc, &cpT, edcDrp);
}
else if ((*hwwdCur)->fPageView)
{
Assert(edcDrp == edcDrpFtn);
if (PdodDoc(doc)->fShort)
{
cp = CpRefFromCpSub(doc, cpRefDoc, edcDrp);
doc = DocMother(doc);
cp = CpMin(CpMacDocEdit(doc), cp);
}
else
{
cp = CpFirstRef(doc, cpRefDoc, &cpT, edcDrp);
doc = PdodDoc(doc)->docFtn;
Assert(doc != docNil);
if (cp == CpMacDocEdit(doc) && (cp > cp0 /* has footnote */))
{
/* in pageview, cpMacDocEdit of footnote is not showing
back up cp into the last footnote */
struct PLC **hplc = PdodDoc(doc)->hplcfnd;
int iLast = IMacPlc(hplc) - 2;
AssertH(hplc);
Assert(iLast >= 0);
cp = CpMin(cp, CpPlc(hplc, iLast));
}
}
if (IpgdPldrFromDocCp(wwCur, doc, cp) == ipgdNil)
return fFalse;
TurnOffSel(&selCur);
selCur.sk = skNil;
selCur.doc = doc;
}
SelectIns(&selCur, cp);
vfSeeSel = fTrue; /* also cause mother doc in sync in idle */
return fTrue;
}
return fFalse;
}
/* %%Function:FShowFtnAtn %%Owner:chic */
FShowFtnAtn(doc, wk)
int doc;
int wk;
{
/*
Kill the lower pane if it is not the same wk pane.
Create wk pane if not splitted.
Move focus to it if wk pane already exist.
*/
struct WWD *pwwdCur;
if ((pwwdCur = PwwdWw(wwCur))->fPageView && wk == wkFtn)
{
if (PdodMother(doc)->dop.fpc == fpcBottomPage)
ScrollPageDye(wwCur, max(0,
pwwdCur->rcePage.yeBottom - pwwdCur->rcwDisp.ywBottom));
return fTrue;
}
else
{
if ((*hmwdCur)->fSplit)
{
int wwLower = (*hmwdCur)->wwLower;
int wkLower = PwwdWw(wwLower)->wk;
struct WWD *pwwd;
struct PLCEDL **hplcedl;
if (wk != wkLower)
KillSplit(hmwdCur, fTrue /*fLower*/, fFalse /*fAdjustWidth*/);
else if (wkLower == wkHdr && wk == wkHdr)
{
RemoveWwDisp(PdrGalley(PwwdWw(wwLower))->doc, wwLower);
AppendWw(doc, wwLower);
FreezeHp();
pwwd = PwwdWw(wwLower);
PdrGalley(pwwd)->cpFirst = cp0;
if ((hplcedl = PdrGalley(pwwd)->hplcedl) != 0)
{
MeltHp(); /* freeing doesn't move heap */
FreeEdls(hplcedl, 0, IMacPlc(hplcedl));
PutIMacPlc(hplcedl, 0);
FreezeHp();
}
MeltHp();
NewCurWw(wwLower, fFalse);
pwwd = PwwdWw(wwLower);
PdrGalley(pwwd)->doc = pwwd->sels.doc = selCur.doc = doc;
TrashWw(wwLower); /* make sure old content get erased */
/* make sure iconbar contents are correct */
SetupIconBarButton(wwLower, DocMother(doc),
PwwdWw(WwOther(wwLower))->sels.cpFirst, PdodDoc(doc)->ihdt);
}
else
NewCurWw(wwLower, fFalse);
}
/* only let a real doc passed to FCreateSplit for creating a header pane */
if (wk != wkHdr)
doc = docNil;
#ifdef DEBUG
else
Assert(PdodDoc(doc)->fDispHdr);
#endif
if (!(*hmwdCur)->fSplit)
{
if (FCanSplit(hmwdCur, wk))
{
pwwdCur = *hwwdCur;
return (FCreateSplit(doc, pwwdCur->ywMac - DyOfRc(&pwwdCur->rcwDisp)/3, wk));
}
else
{
ErrorEid(eidWindowTooSmall,"FShowFtnAtn");
return fFalse;
}
}
}
return fTrue;
}
/* C M D I N S F O O T N O T E */
/* %%Function:CmdInsFootnote %%Owner:chic */
CmdInsFootnote(pcmb)
CMB * pcmb;
{
BOOL fRecordingSav;
int doc = selCur.doc;
BOOL fAuto;
struct DOD *pdod = PdodDoc(doc);
CP cpRef, cpRefNew = selCur.cpFirst;
int tmc;
int cmdRet;
CHAR stRefDia[cchFtnRefMax + 1]; /* reference in dialog box */
/* Only allow insert footnote to mother doc or footnote pane */
if (!pdod->fMother && !pdod->fFtn)
{
Beep();
return cmdError;
}
if (FReportSplitErr(wkFtn))
return cmdError;
/* Get the exact cpFirst of the document, i,e. in case of a block selection.
If in footnote pane, ignore selCur anyway since always insert at beginning
of footnote text.
*/
if (selCur.fBlock && !pdod->fFtn)
cpRefNew = CpFirstBlock();
if (pcmb->fDefaults)
{
/* get proposed values for footnote dialog box */
stRefDia[0] = 0;
fAuto = fTrue;
pdod = PdodDoc(doc);
if (!pdod->fShort && pdod->docFtn != docNil && !selCur.fIns)
{
CpFirstRef(doc, cpRefNew, &cpRef,edcDrpFtn);
Assert(cpRef != cpNil);
if (cpRefNew == cpRef)
{
int cchRef;
cchRef = CchFetchFtnRef(doc, cpRefNew, &stRefDia[1]);
if (stRefDia[1] != chFootnote)
{
stRefDia[0] = cchRef;
fAuto = fFalse;
}
}
}
((CABINSERTFTN *) *pcmb->hcab)->fAuto = fAuto;
FSetCabSt(pcmb->hcab, stRefDia, iagStRef);
/* fMemFail will be true if FSetCabSz fails */
if (vmerr.fMemFail)
return cmdNoMemory;
}
if (pcmb->fDialog)
{
CHAR dlt [sizeof (dltInsertFtn)];
BltDlt(dltInsertFtn, dlt);
switch (tmc = TmcOurDoDlg(dlt, pcmb))
{
#ifdef DEBUG
default:
Assert(fFalse);
return cmdError;
#endif
case tmcCancel:
return cmdCancelled;
case tmcError:
return cmdNoMemory;
case tmcSeparator:
case tmcContSeparator:
case tmcNoticeSeparator:
case tmcOK:
break;
}
}
else
tmc = pcmb->tmc;
if (!pcmb->fAction)
return cmdOK;
/* Cheap hack to keep pane switching and window activation out
of the recorded macro. */
InhibitRecorder(&fRecordingSav, fTrue);
StartLongOp();
if (tmc != tmcOK)
{ /* footnote separator */
int iFtnSepSt;
/* separator button pressed */
Assert(tmc == tmcSeparator || tmc == tmcContSeparator ||
tmc == tmcNoticeSeparator);
iFtnSepSt = tmc - tmcSeparator;
Assert(iFtnSepSt >= 0 && iFtnSepSt <= 2);
if (FOpenHeaderIhtst(iFtnSepSt, fFalse /* fEditHdr */))
cmdRet = cmdOK;
else
{
cmdRet = cmdError;
SetErrorMat(matMem);
}
}
else
{ /* footnote */
/* get values from cab */
GetCabSt(pcmb->hcab, stRefDia, cchFtnRefMax + 1, iagStRef);
fAuto = (stRefDia[0] = CchStripString(&stRefDia[1], stRefDia[0])) == 0;
cmdRet = CmdFootnote1(cpRefNew, fAuto, stRefDia);
}
EndLongOp(fFalse /*fAll*/);
InhibitRecorder(&fRecordingSav, fFalse);
return cmdRet;
}
/* %%Function:FDlgInsertFtn %%Owner:chic */
BOOL FDlgInsertFtn(dlm, tmc, wNew, wOld, wParam)
DLM dlm;
TMC tmc;
WORD wNew, wOld, wParam;
{
CHAR sz [256];
if (fElActive && dlm == dlmInit)
{
EnableTmc(tmcSeparator, fFalse);
EnableTmc(tmcContSeparator, fFalse);
EnableTmc(tmcNoticeSeparator, fFalse);
return fTrue;
}
if (dlm == dlmClick && tmc == tmcFAuto)
{
if (ValGetTmc(tmcFAuto))
/* turn on Auto, blank ref mark string */
SetTmcText(tmcRefMark, szEmpty);
else
{
/* turn off Auto, insert ref mark string */
SetTmcText(tmcRefMark, SzShared("*"));
SetTmcTxs(tmcRefMark, TxsOfFirstLim(0, ichLimLast));
}
}
else if (dlm == dlmChange && tmc == tmcRefMark)
{
GetTmcText(tmcRefMark, sz, sizeof (sz));
/* strip string */
SetTmcVal(tmcFAuto, CchStripString(sz, CchSz(sz)-1 ) == 0);
}
return fTrue;
}
/* %%Function:CmdViewFootnote %%Owner:chic */
CmdViewFootnote (pcmb)
CMB *pcmb;
{
Assert(PdodDoc(selCur.doc)->fFtn || PdodDoc(selCur.doc)->fMother);
Assert(hmwdCur);
return CmdViewRef(wkFtn, edcDrpFtn);
}
/* %%Function:FReportSplitErr %%Owner:chic */
FReportSplitErr(wk)
int wk;
{
if (!(*hmwdCur)->fSplit && !(*hwwdCur)->fPageView && !FCanSplit(hmwdCur, wk))
{
ErrorEid(eidWindowTooSmall, "");
return fTrue;
}
return fFalse;
}
+87
View File
@@ -0,0 +1,87 @@
ifdef DEBUG
; AssertHForNative
; This is to make the general (good handle) case as fast as
; possible. If there is any question, it calls
; AssertHSzLnForNative in debug.c
; %%Function:AssertHForNative %% Owner:BRADV
cProc AssertHForNative,<NEAR>,<>
ParmW h
ParmW mid
ParmW lbl
LocalW pdrfList
cBegin
; for (pdrfList = vpdrfHead; pdrfList != NULL; pdrfList = pdrfList->pdrfNext)
mov bx,[vpdrfHead]
mov ax,[h]
jmp short AHFN02
AHFN01:
mov bx,[bx.pdrfNextDrf]
AHFN02:
errnz <NULL>
or bx,bx
je AHFN05
; if (pdrfList->dr.hplcedl == h)
; {
cmp ax,[bx.drDrf.hplcedlDr]
jne AHFN01
; if (!(*((struct PLC **)h))->fExtBase)
; break;
xchg ax,bx
mov bx,[bx]
test [bx.fExtBasePlc],maskFExtBasePlc
je AHFN05
; Assert (pdrfList->dr.hplcedl == &pdrfList->pplcedl);
xchg ax,bx
lea ax,[bx.pplcedlDrf]
cmp ax,[bx.drDrf.hplcedlDr]
je AHFN03
push ax
push bx
cCall AssertProcForNative,<[mid], [lbl]>
pop bx
pop ax
AHFN03:
; Assert (pdrfList->pplcedl == &pdrfList->dr.plcedl);
lea ax,[bx.drDrf.plcedlDr]
cmp ax,[bx.pplcedlDrf]
je AHFN04
push ax
push bx
cCall AssertProcForNative,<[mid], [lbl]>
pop bx
pop ax
AHFN04:
; return;
jmp short AHFN06
; }
AHFN05:
;if (!FCheckHandle (sbDds, h))
; {
; if (!(h == vsccAbove.hplcedl || *h == &vsccAbove))
; AssertProc(szFile, line );
; }
mov ax,1 ; sbDds
cCall FCheckHandle,<ax,[h]>
or ax,ax
jne AHFN06
mov bx,[h]
cmp bx,[vsccAbove.rgdrWwd.hplcedlDr]
je AHFN06
mov bx,[bx]
cmp bx,dataoffset [vsccAbove]
je AHFN06
cCall AssertProcForNative,<[mid], [lbl]>
AHFN06:
cEnd
endif ;DEBUG
+420
View File
@@ -0,0 +1,420 @@
;
; auxout.asm
;
; written by marc singer
; 30 Aug 85
;
; This code allows a string to be written directly to the aux port
; without having to deal with opening it.
;
; MUST DEFINE AUXOUT TO GET THIS CODE. IT TAKES TOO MUCH DS.
;
;
.xlist
include w2.inc
include cmacros.inc
.list
sBegin DATA
staticB iMsg, 0 ; Only lower byte used
globalW vmsgShowExclude, 118h;
sEnd DATA
sBegin CODE
assumes CS, CODE
assumes DS, DATA
staticB msgMap, 0 ; This defines the label and the NULL message
db 0, 'NULL' ; WM_NULL
dw 0001H
db 'CREA' ; WM_CREATE
dw 0002H
db 'DEST' ; WM_DESTROY
dw 0003H
db 'MOVE' ; WM_MOVE
dw 0004H
db 'SIZW' ; WM_SIZEWAIT
dw 0005H
db 'SIZE' ; WM_SIZE
dw 0006H
db 'ACTI' ; WM_ACTIVATE
dw 0007H
db 'SETF' ; WM_SETFOCUS
dw 0008H
db 'KILF' ; WM_KILLFOCUS
dw 0009H
db 'SVIS' ; WM_SETVISIBLE
dw 000aH
db 'ENAB' ; WM_ENABLE
dw 000bH
db 'SRDW' ; WM_SETREDRAW
dw 000cH
db 'STEX' ; WM_SETTEXT
dw 000dH
db 'GTEX' ; WM_GETTEXT
dw 000eH
db 'GLEN' ; WM_GETTEXTLENGTH
dw 000fH
db 'PAIN' ; WM_PAINT
dw 0010H
db 'CLOS' ; WM_CLOSE
dw 0011H
db 'QEND' ; WM_QUERYENDSESSION
dw 0012H
db 'QUIT' ; WM_QUIT
dw 0013H
db 'QOPN' ; WM_QUERYOPEN
dw 0014H
db 'EBKG' ; WM_ERASEBKGND
dw 0015H
db 'SYCO' ; WM_SYSCOLORCHANGE
dw 0016H
db 'ENDS' ; WM_ENDSESSION
dw 0017H
db 'SYER' ; WM_SYSTEMERROR
dw 0018H
db 'SHOW' ; WM_SHOWWINDOW
dw 0019H
db 'CTLC' ; WM_CTLCOLOR
dw 001aH
db 'WINI' ; WM_WININICHANGE
dw 001bH
db 'DMOD' ; WM_DEVMODECHANGE
dw 001cH
db 'ACAP' ; WM_ACTIVATEAPP
dw 001dH
db 'FONT' ; WM_FONTCHANGE
dw 0081H
db 'NCCR' ; WM_NCCREATE
dw 0082H
db 'NCDE' ; WM_NCDESTROY
dw 0083H
db 'NCCA' ; WM_NCCALCSIZE
dw 0084H
db 'NCHT' ; WM_NCHITTEST
dw 0085H
db 'NCPA' ; WM_NCPAINT
dw 0086H
db 'NCAC' ; WM_NCACTIVATE
dw 0087H
db 'DLGC' ; WM_GETDLGCODE
dw 00a0H
db 'NCMV' ; WM_NCMOUSEMOVE
dw 00a1H
db 'NCLD' ; WM_NCLBUTTONDOWN
dw 00a2H
db 'NCLU' ; WM_NCLBUTTONUP
dw 00a3H
db 'NCLC' ; WM_NCLBUTTONDBLCLK
dw 00a4H
db 'NCRD' ; WM_NCRBUTTONDOWN
dw 00a5H
db 'NCRU' ; WM_NCRBUTTONUP
dw 00a6H
db 'NCRC' ; WM_NCRBUTTONDBLCLK
dw 00a7H
db 'NCMD' ; WM_NCMBUTTONDOWN
dw 00a8H
db 'NCMU' ; WM_NCMBUTTONUP
dw 00a9H
db 'NCMC' ; WM_NCMBUTTONDBLCLK
dw 0100H
db 'KYDN' ; WM_KEYDOWN
dw 0101H
db 'KYUP' ; WM_KEYUP
dw 0102H
db 'CHAR' ; WM_CHAR
dw 0103H
db 'DCHR' ; WM_DEADCHAR
dw 0104H
db 'SYKD' ; WM_SYSKEYDOWN
dw 0105H
db 'SYKU' ; WM_SYSKEYUP
dw 0106H
db 'SYCH' ; WM_SYSCHAR
dw 0107H
db 'SYDC' ; WM_SYSDEADCHAR
dw 0108H
db 'YOMI' ; WM_YOMICHAR
dw 0109H
db 'MVCW' ; WM_MOVECONVERTWINDOW
dw 010AH
db 'CORQ' ; WM_CONVERTREQUEST
dw 010BH
db 'CORE' ; WM_CONVERTRESULT
dw 0110H
db 'IDLG' ; WM_INITDIALOG
dw 0111H
db 'CMMD' ; WM_COMMAND
dw 0112H
db 'SCMD' ; WM_SYSCOMMAND
dw 0113H
db 'TIME' ; WM_TIMER
dw 0114H
db 'HSCR' ; WM_HSCROLL
dw 0115H
db 'VSCR' ; WM_VSCROLL
dw 0116H
db 'IMNU' ; WM_INITMENU
dw 0117H
db 'IPOP' ; WM_INITMENUPOPUP
dw 0118H
db 'SYTM' ; WM_SYSTIMER
dw 0200H
db 'MOUS' ; WM_MOUSEMOVE
dw 0201H
db 'LBDN' ; WM_LBUTTONDOWN
dw 0202H
db 'LBUP' ; WM_LBUTTONUP
dw 0203H
db 'LBCL' ; WM_LBUTTONDBLCLK
dw 0204H
db 'RBDN' ; WM_RBUTTONDOWN
dw 0205H
db 'RBUP' ; WM_RBUTTONUP
dw 0206H
db 'RBCL' ; WM_RBUTTONDBLCLK
dw 0207H
db 'MBDN' ; WM_MBUTTONDOWN
dw 0208H
db 'MBUP' ; WM_MBUTTONUP
dw 0209H
db 'MBCL' ; WM_MBUTTONDBLCLK
dw 0300H
db 'CUT ' ; WM_CUT
dw 0301H
db 'COPY' ; WM_COPY
dw 0302H
db 'PAST' ; WM_PASTE
dw 0303H
db 'CLER' ; WM_CLEAR
dw 0304H
db 'UNDO' ; WM_UNDO
dw 0305H
db 'RFMT' ; WM_RENDERFORMAT
dw 0306H
db 'RAFT' ; WM_RENDERALLFORMATS
dw 0307H
db 'DECL' ; WM_DESTROYCLIPBOARD
dw 0308H
db 'DRCL' ; WM_DRAWCLIPBOARD
dw 0309H
db 'PACL' ; WM_PAINTCLIPBOARD
dw 030aH
db 'VSCL' ; WM_VSCROLLCLIPBOARD
dw 030bH
db 'SICL' ; WM_SIZECLIPBOARD
dw 030cH
db 'CBFT' ; WM_ASKCBFORMATNAME
dw 030dH
db 'CBCH' ; WM_CHANGECBCHAIN
dw 030eH
db 'HSCL' ; WM_HSCROLLCLIPBOARD
dw 0400H
db 'USER' ; WM_USER
dw 0, 0, 0 ; End of table (570 bytes)
; %%Function:ShowMsg %% Owner:BRADV
cProc ShowMsg, <PUBLIC, FAR>, <si, di>
parmDP szMsg
parmW hwnd
parmW message
parmW wParam
parmD lParam
LocalV sz, 28h
cBegin
mov ax, vmsgShowExclude
or ax, ax ; Check for an excluded message
jz allSM
cmp ax, message ; Check if numbers match
jnz allSM
jmp endSM ; Don't display this message
allSM: lea si, sz ; Copy in id of message
mov ch, iMsg
or ch, ch
jnz oneSM ; CrLf on first message
mov ax, 0a0dh
mov [si], ax
add si, 2
oneSM: mov di, szMsg
mov ax, [di]
mov [si], ax
mov al, ' '
mov [si+2], al
mov ax, 771bh ; Esc-w for no autowrap
mov [si+3], ax
add si, 5 ; Move string pointer
; Put in numbers
mov ax, hwnd
mov dx, 2020h ; Fill space, terminate space
call IntToHex
inc si
mov ax, message
call MapMsg
jc trnsSM
call IntToHex
trnsSM: inc si
mov ax, wParam
call IntToHex
inc si
mov dx, 20ffh ; Space fill, hiword of a long
mov ax, SEG_lParam ; Get hiword of lParam
call IntToHex
mov dl, 0 ; Null terminate.
mov ax, OFF_lParam ; Get loword
call IntToHex
cmp ch, 2
jz twoSM ; All but last message get trailing #
mov ax, 0023h
mov [si], ax
twoSM: lea si, sz
cCall WriteToAux ; Show it
; iMsg = (iMsg + 1) % 3
inc ch ; Increment count of messages on line
cmp ch, 3 ; Test if overflow (past 0, 1, 2)
jnz doneSM ; Go and save it
xor ch, ch
jmp doneSM
doneSM: mov iMsg, ch
endSM:
cEnd
; IntToHex
; converts the number in ax into the hex digits it represents.
; The string is written from si to si+4 with dl as the terminator.
; There is a special case for displaying longs so that 0 will be represented
; correctly.
; The side effects are the string being filled and si being incremented
; by four.
IntToHex:
push cx
push di
push bp
push si
mov bx, 4
mov di, dx ; Save current fill characters
cmp dx, 20ffh ; Check if displaying first word of long
jnz oneIH
mov dh, 30h
or ax, ax ; If First word of long and a zero
jnz oneIH ; then just fill with fill characters
mov dh, 20h ; Next word will be space filled.
push dx ; Save it for the caller
jmp fill ; Fill this one
oneIH: push dx ; Save it for the caller
mov dx, di ; Get back the current fill characters
mov di, ax ; Save number in a register
mov [bx+si], dl ; Put in terminating character
mov cl, 4 ; shift count
loopHx: mov ax, di
dec bx
and al, 0fh ; Mask off lower nybble
cmp al, 0ah
jl decml ; Skip additional offset if 0-9
add ax, 'a' - '0' - 0ah
decml: add ax, '0'
mov [bx+si], al ; Save the character
shr di, cl ; Shift to next nybble
jnz loopHx
fill: or bx, bx
jz doneIH ; Quit if no more spaces in string
dec si ; Make bx a count, not an offset
loopFl: mov [bx+si], dh
dec bx
jnz loopFl
doneIH: pop dx ; Get next fill characters
pop si
add si, 4 ; Increment string pointer
pop bp
pop di
pop cx
ret
; MapMsg
; takes the number in ax to be the current message and trys to match
; it with a string from the table. If successful, the string will be
; added and terminated with the character in dl. The carry flag will
; be set if the message translation was successful.
MapMsg:
push ds
push cs
pop ds
lea bx, msgMap ; Get address of start of table
pop ds
loopMM:
cmp cs:[bx], ax ; Test for matching message number
jz copyMM ; Copy the text.
add bx, 6 ; Six bytes to the next message
cmp word ptr cs:[bx+2], 0 ; Null message text ends table
jnz loopMM
failMM: clc ; Failed
ret
copyMM: push ax
mov ax, cs:[bx+2] ; Copy text
mov [si], ax ; into the string.
mov ax, cs:[bx+4]
mov [si+2], ax
mov [si+4], dl ; Terminate
add si, 4
pop ax
clc
cmc ; Set the carry
ret
; %%Function:WriteToAux %% Owner:BRADV
cProc WriteToAux, <NEAR>, <si, di, dx, bp>
cBegin
loopWA: mov dl, [si] ; Get the character
or dl, dl ; Set flags
jz doneWA ; Null character marks end
mov ah,4
int 21h
inc si ; Move to next character
jmp loopWA ; Loop until a null is found
doneWA:
cEnd
; %%Function: %% Owner:BRADV
cProc AuxOut, <FAR, PUBLIC>, <si>
parmDP <sz>
cBegin
mov si, sz ; Put the parameter to WriteToAux in si
cCall WriteToAux ; Then show it.
cEnd
; %%Function:LongToSz %% Owner:BRADV
cProc LongToSz, <FAR, PUBLIC>, <si, di>
parmD <Long>
parmDP <sz>
cBegin
mov si, sz ; Put the pointer to output buffer.
mov dx, 30ffh ; '0' fill, hiword of a long
mov ax, SEG_Long
call IntToHex
mov dl, 0 ; Null terminate.
mov ax, OFF_Long ; Get loword
call IntToHex
cEnd
sEnd CODE
END
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+136
View File
@@ -0,0 +1,136 @@
;NOT USED!!
; CMDLOOK.ASM
; Multiple entry points for DoLooks function
include w2.inc
include noxport.inc
include consts.inc
createSeg cmdlook_PCODE,cmdlook,byte,public,CODE
ifdef DEBUG
midCmdLookn equ 8
endif ; DEBUG
; EXPORTED LABELS
PUBLIC CmdBold
PUBLIC CmdItalic
PUBLIC CmdSmallCaps
PUBLIC CmdHideText
PUBLIC CmdULine
PUBLIC CmdDULine
PUBLIC CmdWULine
PUBLIC CmdSuperscript
PUBLIC CmdSubscript
PUBLIC CmdParaLeft
PUBLIC CmdParaRight
PUBLIC CmdParaCenter
PUBLIC CmdParaBoth
PUBLIC CmdSpace1
PUBLIC CmdSpace15
PUBLIC CmdSpace2
PUBLIC CmdParaClose
PUBLIC CmdParaOpen
; EXTERNAL FUNCTIONS
externFP <DoLooks>
; CODE SEGMENT cmdlook_PCODE
sBegin cmdlook
assumes cs,cmdlook
assumes ds,dgroup
assume es:nothing
assume ss:nothing
CmdBold:
mov ax,ilcdBold
jmp CmdLookCommon
CmdItalic:
mov ax,ilcdItalic
jmp CmdLookCommon
CmdSmallCaps:
mov ax,ilcdSmallCaps
jmp CmdLookCommon
CmdHideText:
mov ax,ilcdVanish
jmp CmdLookCommon
CmdULine:
mov ax,ilcdKulSingle
jmp CmdLookCommon
CmdDULine:
mov ax,ilcdKulDouble
jmp CmdLookCommon
CmdWULine:
mov ax,ilcdKulWord
jmp CmdLookCommon
CmdSuperscript:
mov ax,ilcdSuperscript
jmp CmdLookCommon
CmdSubscript:
mov ax,ilcdSubscript
jmp CmdLookCommon
CmdParaLeft:
mov ax,ilcdParaLeft
jmp CmdLookCommon
CmdParaRight:
mov ax,ilcdParaRight
jmp CmdLookCommon
CmdParaCenter:
mov ax,ilcdParaCenter
jmp CmdLookCommon
CmdParaBoth:
mov ax,ilcdParaBoth
jmp CmdLookCommon
CmdSpace1:
mov ax,ilcdSpace1
jmp CmdLookCommon
CmdSpace15:
mov ax,ilcdSpace15
jmp CmdLookCommon
CmdSpace2:
mov ax,ilcdSpace2
jmp CmdLookCommon
CmdParaClose:
mov ax,ilcdParaClose
jmp CmdLookCommon
CmdParaOpen:
mov ax,ilcdParaOpen
cProc CmdLookCommon,<FAR>,<>
; ax = ilcd
cBegin
mov bx,0
mov cx,0
cCall DoLooks,<ax,bx,cx>
mov ax,cmdOK
cEnd
sEnd cmdlook_PCODE
end
+550
View File
@@ -0,0 +1,550 @@
; consts.inc - constants for hand native
;
; WARNING: these constants MUST be updated in sync with their
; counterparts in the .n files
; Please try to keep this file in alphabetical order
bptr equ byte ptr
wptr equ word ptr
wlo equ word ptr
whi equ 2 + word ptr
bkcNewPage equ 2
bNil equ 0
bpmCp equ 0
bpmFoo equ 1
brclSingle equ 0
brclThick equ 1
brclDouble equ 2
brclShadow equ 3
brcpNone equ 0
brcNone equ 0
brcBox equ 15
brcBar equ 16
brcAbove equ 1
brcBelow equ 2
brcNil equ -1
brcSingle equ 00040h
brcTwoSingle equ 00049h
brcThick equ 00080h
brcDotted equ 00180h
brcHairline equ 001C0h
; from file.h
cbSector equ 512 ; assumed to be = 512 in CachePara
maskSector equ 001FFh
shftSector equ 9 ; assumed to be = 9 in CachePara
cchMaxFile equ 120
cchInsertMax equ 32
cchMaxEntry equ 256
cchMaxRibl equ 256
cchPapxMax equ 502
cchSearchMax equ 257
ccpEop equ 2
ccpSect equ 1
chColumnBreak equ 14
chFieldBegin equ 19
chFieldSeparate equ 20
chFieldEnd equ 21
chFieldMin equ 19
chFieldMax equ 22
chFieldBeginDisp equ 123
chFieldSeparateDisp equ 124
chFieldEndDisp equ 125
chFormula equ 92
chDisplayField equ 17
chTable equ 7
chPicture equ 1
chVisCellEnd equ 0A4H
chDxpMin equ 0
chDxpMax equ 256
chCRJ equ 11
chEol equ 10
chEop equ 10
chFootnote equ 2
chHyphen equ 45
chNil equ (-1)
chNonBreakHyphen equ 30
chNonBreakSpace equ 160
chNonReqHyphen equ 31
chReturn equ 13
chSect equ 12
chSpace equ 32
chTab equ 9
chTFtn equ 3
chTFtnCont equ 4
chVisCRJ equ 000ACh
chVisEop equ 000B6h
chVisSpace equ 000B7h
chVisNonReqHyphen equ 00ACh
chVisNonBreakSpace equ 00B0h
chPubMin equ 145
chPubLQuote equ 145
chPubRQuote equ 146
chPubLDblQuote equ 147
chPubRDblQuote equ 148
chPubBullet equ 149
chPubEmDash equ 150
chPubEnDash equ 151
chPubMax equ 152
chsMac equ 0
chsPC equ 1
chsAnsi equ 2
chsPCA equ 3
clMax equ 07FFFh
clMaxLbs equ 400
clNil equ -1
LO_cpMax equ 0FFFFh
HI_cpMax equ 07FFFh
LO_cpNil equ 0FFFFh
HI_cpNil equ 0FFFFh
LO_cpWarnTooBig equ 00000h
HI_cpWarnTooBig equ 00100h
czaInch equ 1440
czaPoint equ 20
cptInch equ 72
DEFAULT_PITCH equ 0
DEVICEDEFAULT_FONT equ 14
dkGlsy equ 4
dlkEnd equ 1
dlkEndPage equ 2
dlkEndDr equ 4
dlkNil equ 0
docNew equ 1
docNil equ 0
docUndo equ 3
docScrap equ 2
dxaInch equ 1440
dyaPoint equ 20
dxpChVisEach equ 12
dxpChVis equ 24
dypChVis equ 7
edcNone equ 0
eidDocTooBigToSave equ 129
eidCpRollOver equ 130
eidNoMemOperation equ 16
eidSysLock equ 160
eidSysFull equ 161
emkBlank equ 0
emkEndmark equ 1
emkSplat equ 2
fcidNil_LO equ 0ffffh
fcidNil_HI equ 0ffffh
fcSpecEop equ 100
fcSpecNoRoom equ 102
LO_fcMax equ 00000h
HI_fcMax equ 00100h
fcmChars equ 08000h
fcmParseCaps equ 1
fcmProps equ 00080h
fFalse equ 0
fTrue equ 1
ffcSkip equ 0
ffcShow equ 1
ffcDisplay equ 2
ffcBeginGroup equ 3
ffcEndGroup equ 4
ffcWrap equ 5
ffcRestart equ 6
ffeNested equ 1
ffeNoFSpec equ 2
FIXED_PITCH equ 1
flmDisplay equ 0
flmDisplayAsPrint equ 1
flmPrint equ 2
flmRepaginate equ 3
flmIdle equ 4
flmTossPrinter equ 5
fltMin equ 0
fltFormula equ 49
fltMax equ 56
fltSeqLevNum equ 54
fltSeqLevOut equ 52
fmtList equ 5
fnInsert equ 0
fnNil equ 0
fnScratch equ 1
fnSpec equ 0
fnMax equ 50
fpcEndnote equ 0
fpcBottomPage equ 1
fpcBeneathText equ 2
fpcEndDoc equ 3
fvcmFields equ 00100h
fvcmProps equ 00400h
fvcmWw equ 000ffh
fvcInstructions equ 08100h
fvcResults equ 08000h
fvcHiddenVisi equ 08400h
FW_DONTCARE equ 0
FW_THIN equ 100
FW_EXTRALIGHT equ 200
FW_LIGHT equ 300
FW_NORMAL equ 400
FW_MEDIUM equ 500
FW_SEMIBOLD equ 600
FW_BOLD equ 700
FW_EXTRABOLD equ 800
FW_HEAVY equ 900
FW_ULTRALIGHT equ FW_EXTRALIGHT
FW_REGULAR equ FW_NORMAL
FW_DEMIBOLD equ FW_SEMIBOLD
FW_ULTRABOLD equ FW_EXTRABOLD
FW_BLACK equ FW_HEAVY
GMEM_NOT_BANKED equ 01000h
GW_HWNDFIRST equ 0
GW_HWNDLAST equ 1
GW_HWNDNEXT equ 2
GW_HWNDPREV equ 3
GW_OWNER equ 4
GW_CHILD equ 5
hfontSpecNil equ 1
hNil equ 0
hpsDefault equ 20
hpsPosNil equ 128
ibpNil equ -1
ibrcTop equ 0
ibrcLeft equ 1
ibrcBottom equ 2
ibrcRight equ 3
ibrcInside equ 4
ibstFontMax equ 255
ibstFontNil equ ibstFontMax
ibstCourier equ 3
ibstNil equ -1
icoAuto equ 0
icoRTFMax equ 50
ichCapsMax equ 20
ichMaxLine equ 255
ichNil equ 255
ichUsrInitlMax equ 6
idcbChVisCRJ equ 0
idcbChVisTab equ 1
idcbMaxChVis equ 2
idcbOtlMarkPlus equ 0
idcbOtlMarkMinus equ 2
idcbOtlMarkBody equ 4
idrNil equ -1
idrbChVis equ 0
ifceMax equ 32
ifcFkpNil equ 128 ;(512 /*cbSector*/ / sizeof(FC))
ifldNil equ -1
ifmaMax equ 40
ihdtMaxSep equ 6
ihdtNil equ -1
ihdtTFtn equ 6
ilrNil equ -1
iNil equ -1
ipatVertGray equ 0
ipatVertBlack equ 1
ipatHorzGray equ 0
ipatHorzLtGray equ 1
ipatHorzBlack equ 2
iPicMacPict equ 2
irmBarNone equ 0
irmBarLeft equ 1
irmBarRight equ 2
irmBarOutside equ 3
irmPropsNone equ 0
irmPropsBold equ 1
irmPropsItalic equ 2
irmPropsUnder equ 3
irmPropsDblUnder equ 4
irtnAssignLr equ 0
irtnFormPara equ 1
irtnFormChain equ 2
iselsInsertMax equ 4
ispAdjustCp equ 5
ispInsertLine equ 3
ispFieldFormat1 equ 4
ispDisplayFli equ 5
ispFormatLine equ 5
ispLayout3 equ 9
ispLayout4 equ 8
ispWireFont equ 7
itbdMax equ 50
itcMax equ 32
itcxcMax equ 10
itnMax equ 45
jcLeft equ 0
jcCenter equ 1
jcRight equ 2
jcBoth equ 3
jcDecimal equ 3
jcBar equ 4
jcDecTable equ 5
kulNone equ 0
kulSingle equ 1
kulWord equ 2
kulDouble equ 3
kulDotted equ 4
lbcNil equ 0
lbcPageBreakBefore equ 1
lbcEndOfPage equ 2
lbcEndOfSection equ 3
lbcEndOfDoc equ 4
lbcYlLim equ 5
lbcEndOfColumn equ 6
lbcAbort equ 7
LF_FACESIZE equ 32
lmNil equ 0
lmPrint equ 1
lmPreview equ 2
lmFRepag equ 3
lmBRepag equ 4
lmPagevw equ 5
lnnNil equ -1
lrkNormal equ 0
lrkAbs equ 1
lrkAbsHit equ 2
lrkSxs equ 3
lrsNormal equ 0
lrsFrozen equ 1
lrsIgnore equ 2
lvlBody equ 9
lvlUpdate equ 15
maskFNonUser equ 00314h
maskPrqLF equ 003h
maskFVarPitchTM equ 001h
maskFfFfid equ 070h
matNil equ 0
matLow equ 1
matReplace equ 2
matMem equ 3
matDisp equ 4
matFont equ 6
mtyAny equ 000h
mtyNoTimer equ 001h
mtyYield equ 004h
mtyDoBlink equ 008h
mtyAllPeek equ 010h
mtySomePeek equ 020h
mtyMouseMove equ 040h
mtyIdle equ mtyDoBlink OR mtyYield OR mtySomePeek OR mtyMouseMove
mtyUpdateWw equ mtyNoTimer
mtyTyping equ mtyNoTimer OR mtySomePeek
mwMax equ 15
mwNil equ 0
NULL equ 0
nxsHidnSect equ 1
omkNil equ 0
omkPlus equ 1
omkMinus equ 2
omkBody equ 3
paInvert equ 0
paDotted equ 1
pcVMargin equ 0
pcVPage equ 1
pcHColumn equ 0
pcHMargin equ 1
pcHPage equ 2
pisNormal equ 0
pltHorz equ 000h
pltVert equ 001h
pltOnePixel equ 002h
pltInvert equ 004h
pltDouble equ 008h
pnNil equ -1
prmNil equ 0
LO_PATCOPY equ 00021h
HI_PATCOPY equ 000f0h
rdsMain equ 0
rdsPic equ 1
rdsStylesheet equ 4
rdsFonttbl equ 5
rdsColortbl equ 6
rdsPrivate1 equ 8
rdsFldType equ 12
rdsBkmkEnd equ 29
rdsBkmkStart equ 30
rdsGridtbl equ 35
rdsXe equ 36
rdsTc equ 37
risNorm equ 0
risExit equ 1
risB4ContSeq equ 2
risContWord equ 3
risNumScan equ 4
risScanPic equ 5
risB4Private1 equ 6
risB4BinCode equ 7
risBinCode equ 8
risB4SpecXeTc equ 9
risB4TableName equ 10
risScanTableName equ 11
risAfContSeq equ 12
risScanByDest equ 13
risDoPop equ 14
risAddTableName equ 15
rzOtlPat equ 9
sasMin equ 8
sasOK equ 3
sasFull equ 0
sbDds equ 1
sgcPap equ 0
sgcChp equ 1
sgcSep equ 2
sgcPic equ 3
sgcTap equ 4
skNil equ 010h
skBlock equ 008h
skGraphics equ 004h
skSelConst equ 000h
skIns equ 020h
skRows equ 002h
skColumn equ 00Bh
; these spra values are assumed to have these values in ApplyPrlSgc() in fetchn.asm
spraBit equ 0
spraByte equ 1
spraWord equ 2
spraCPlain equ 3
spraCFtc equ 4
spraCKul equ 5
spraCSizePos equ 6
spraSpec equ 7
spraCIco equ 8
spraCHpsInc equ 9
spraCHpsPosAdj equ 10
sprmNoop equ 0
sprmPStcPermute equ 3
sprmPChgTabs equ 23
sprmTDefTable equ 152
sprmCQpsSpace equ 71
sprmPStc equ 2
sprmTDxaGapHalf equ 148
sprmPPc equ 29
sprmCDefault equ 57
sprmMax equ 164 ; keep in sync with value in prm.h!!
stcNormal equ 0
stcStdMin equ 222
stcNil equ 256
SYSTEM_FONT equ 13
tlcNone equ 0
tlcDot equ 1
tlcHyphen equ 2
tlcSingle equ 3
tlcHeavy equ 4
tlcDefault equ tlcNone
tsMax equ 65535
tPos equ 1
tZero equ 0
tNeg equ (-1)
tntNil equ 0
tntHplc equ 1
tntHsttb equ 2
tntAbort equ 3
tntCloseHdrWw equ 4
tntDelBkmk equ 5
udmodNormal equ 0
udmodLastDr equ 1
udmodTable equ 2
udmodNoDisplay equ 3
udmodLimit equ 4
VARIABLE_PITCH equ 2
vcparaAbortMax equ 4
wkHdr equ 04000h
wMatchAny equ 0073Fh
wMatchWhite equ 00777h
wwNil equ 0
wwTemp equ 1
wwPreview equ 2
wwLayout equ 3
wwDocMin equ 5
xaRightMaxSciConst equ (22*dxaInch)
xpNil equ 08000h
xpSplat equ 16384
wwMax equ 30
ylLarge equ 03FFFh
LO_yllLarge equ 0FFFFh
HI_yllLarge equ 07FFFh
ypLarge equ 03FFFh
; ilcds for CmdLookn.asm
ilcdBold equ (0)
ilcdItalic equ (1)
ilcdSmallCaps equ (2)
ilcdVanish equ (3)
ilcdKulSingle equ (4)
ilcdKulWord equ (5)
ilcdKulDouble equ (6)
ilcdSuperscript equ (7)
ilcdSubscript equ (8)
ilcdShowAll equ (9)
ilcdPlainText equ (10)
ilcdStrike equ (11)
ilcdRMark equ (12)
ilcdParaLeft equ (13)
ilcdParaCenter equ (14)
ilcdParaRight equ (15)
ilcdParaBoth equ (16)
ilcdSpace1 equ (17)
ilcdSpace15 equ (18)
ilcdSpace2 equ (19)
ilcdParaClose equ (20)
ilcdParaOpen equ (21)
ilcdParaNormal equ (22)
cmdOK equ 0
mstDbgInt3 equ 1007
+675
View File
@@ -0,0 +1,675 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg dialog1_PCODE,dialog1n,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midDialog1n equ 33 ; module ID, for native asserts
endif
; EXTERNAL FUNCTIONS
ifdef DEBUG
externFP <S_WCompSzSrt>
externFP <AssertProcForNative>
endif ;DEBUG
sBegin data
; EXTERNALS
externW vitr
sEnd data
; CODE SEGMENT _EDIT
sBegin dialog1n
assumes cs,dialog1n
assumes ds,dgroup
assumes ss,dgroup
;#define ch(_i) ((CHAR) (_i))
;
;csconst CHAR mpchordNorm[] = {
mpchordCase:
;/* NUL SOH STX ETX EOT ENQ ACK BEL */
; ch(0), ch(1), ch(2), ch(3), ch(4), ch(5), ch(6), ch(7),
db 000,001,002,003,004,005,006,007
;/* BS HT LF VT FF CR SO SI */
; ch(8), ch(9), ch(10), ch(11), ch(12), ch(13), ch(14), ch(15),
db 008,009,010,011,012,013,014,015
;/* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
; ch(16), ch(17), ch(18), ch(19), ch(20), ch(21), ch(22), ch(23),
db 016,017,018,019,020,021,022,023
;/* CAN EM SUB ESC FS GS RS US */
; ch(24), ch(25), ch(26), ch(27), ch(28), ch(29), ch(30), ch(31),
db 024,025,026,027,028,029,030,031
;/* SPACE ! " # $ % & ' */
; ch(32), ch(33), ch(34), ch(35), ch(36), ch(37), ch(38), ch(39),
db 032,033,034,035,036,037,038,039
;/* ( ) * + , - . / */
; ch(40), ch(41), ch(42), ch(43), ch(44), ch(45), ch(46), ch(47),
db 040,041,042,043,044,045,046,047
;/* 0 1 2 3 4 5 6 7 */
; ch(130), ch(131), ch(132), ch(133), ch(134), ch(135), ch(136), ch(137),
db 130,131,132,133,134,135,136,137
;/* 8 9 : ; < = > ? */
; ch(138), ch(139), ch(48), ch(49), ch(50), ch(51), ch(52), ch(53),
db 138,139,048,049,050,051,052,053
;/* @ A B C D E F G */
; ch(54), ch(140), ch(142), ch(144), ch(146), ch(148), ch(150), ch(152),
db 054,140,142,144,146,148,150,152
;/* H I J K L M N O */
; ch(154), ch(156), ch(158), ch(160), ch(162), ch(164), ch(166), ch(170),
db 154,156,158,160,162,164,166,170
;/* P Q R S T U V W */
; ch(172), ch(174), ch(176), ch(178), ch(181), ch(183), ch(185), ch(187),
db 172,174,176,178,181,183,185,187
;/* X Y Z [ \ ] ^ _ */
; ch(189), ch(191), ch(196), ch(55), ch(56), ch(57), ch(58), ch(59),
db 189,191,196,055,056,057,058,059
;/* ` a b c d e f g */
; ch(60), ch(141), ch(143), ch(145), ch(147), ch(149), ch(151), ch(153),
db 060,141,143,145,147,149,151,153
;/* h i j k l m n o */
; ch(155), ch(157), ch(159), ch(161), ch(163), ch(165), ch(167), ch(171),
db 155,157,159,161,163,165,167,171
;/* p q r s t u v w */
; ch(173), ch(175), ch(177), ch(179), ch(182), ch(184), ch(186), ch(188),
db 173,175,177,179,182,184,186,188
;/* x y z { | } ~ DEL */
; ch(190), ch(193), ch(197), ch(61), ch(62), ch(63), ch(64), ch(65),
db 190,193,197,061,062,063,064,065
;/* 80 81 82 83 84 85 86 87 */
; ch(66), ch(67), ch(68), ch(69), ch(70), ch(71), ch(72), ch(73),
db 066,067,068,069,070,071,072,073
;/* 88 89 8A 8B 8C 8D 8E 8F */
; ch(74), ch(75), ch(76), ch(77), ch(78), ch(79), ch(80), ch(81),
db 074,075,076,077,078,079,080,081
;/* 90 91 92 93 94 95 96 97 */
; ch(82), ch(83), ch(84), ch(85), ch(86), ch(87), ch(88), ch(89),
db 082,083,084,085,086,087,088,089
;/* 98 99 9A 9B 9C 9D 9E 9F */
; ch(90), ch(91), ch(92), ch(93), ch(94), ch(95), ch(96), ch(97),
db 090,091,092,093,094,095,096,097
;/* A0 A1 A2 A3 A4 A5 A6 A7 */
; ch(98), ch(99), ch(100), ch(101), ch(102), ch(103), ch(104), ch(105),
db 098,099,100,101,102,103,104,105
;/* A8 A9 AA AB AC AD AE AF */
; ch(106), ch(107), ch(108), ch(109), ch(110), ch(111), ch(112), ch(113),
db 106,107,108,109,110,111,112,113
;/* B0 B1 B2 B3 B4 B5 B6 B7 */
; ch(114), ch(115), ch(116), ch(117), ch(118), ch(119), ch(120), ch(121),
db 114,115,116,117,118,119,120,121
;/* B8 B9 BA BB BC BD BE BF */
; ch(122), ch(123), ch(124), ch(125), ch(126), ch(127), ch(128), ch(129),
db 122,123,124,125,126,127,128,129
;/* C0 C1 C2 C3 C4 C5 C6 C7 */
; ch(140), ch(140), ch(140), ch(140), ch(140), ch(140), ch(140), ch(144),
db 140,140,140,140,140,140,140,144
;/* C8 C9 CA CB CC CD CE CF */
; ch(148), ch(148), ch(148), ch(148), ch(156), ch(156), ch(156), ch(156),
db 148,148,148,148,156,156,156,156
;/* D0 D1 D2 D3 D4 D5 D6 D7 */
; ch(146), ch(168), ch(170), ch(170), ch(170), ch(170), ch(170), ch(170),
db 146,168,170,170,170,170,170,170
;/* D8 D9 DA DB DC DD DE DF */
; ch(170), ch(183), ch(183), ch(183), ch(183), ch(192), ch(199), ch(180),
db 170,183,183,183,183,192,199,180
;/* E0 E1 E2 E3 E4 E5 E6 E7 */
; ch(141), ch(141), ch(141), ch(141), ch(141), ch(141), ch(141), ch(145),
db 141,141,141,141,141,141,141,145
;/* E8 E9 EA EB EC ED EE EF */
; ch(149), ch(149), ch(149), ch(149), ch(157), ch(157), ch(157), ch(157),
db 149,149,149,149,157,157,157,157
;/* F0 F1 F2 F3 F4 F5 F6 F7 */
; ch(147), ch(169), ch(171), ch(171), ch(171), ch(171), ch(171), ch(171),
db 147,169,171,171,171,171,171,171
;/* F8 F9 FA FB FC FD FE FF */
; ch(171), ch(184), ch(184), ch(184), ch(184), ch(194), ch(198), ch(195)
db 171,184,184,184,184,194,198,195
; };
;#undef ch
rgchCaseScanExcept:
db 0C4h,0C5h,0C6h,0D6h,0D8h,0DEh,0E4h,0E5h,0E6h,0F6h,0F8h,0FEh
rgordCaseScanExcept:
db 0206,0204,0200,0208,0202,0198,0207,0205,0201,0209,0203,0199
;Case insensitive variants for assembler version only
;#define ch(_i) ((CHAR) (_i))
;
;csconst CHAR mpchordNorm[] = {
mpchordNoCase:
;/* NUL SOH STX ETX EOT ENQ ACK BEL */
; ch(0), ch(1), ch(2), ch(3), ch(4), ch(5), ch(6), ch(7),
db 000,001,002,003,004,005,006,007
;/* BS HT LF VT FF CR SO SI */
; ch(8), ch(9), ch(10), ch(11), ch(12), ch(13), ch(14), ch(15),
db 008,009,010,011,012,013,014,015
;/* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
; ch(16), ch(17), ch(18), ch(19), ch(20), ch(21), ch(22), ch(23),
db 016,017,018,019,020,021,022,023
;/* CAN EM SUB ESC FS GS RS US */
; ch(24), ch(25), ch(26), ch(27), ch(28), ch(29), ch(30), ch(31),
db 024,025,026,027,028,029,030,031
;/* SPACE ! " # $ % & ' */
; ch(32), ch(33), ch(34), ch(35), ch(36), ch(37), ch(38), ch(39),
db 032,033,034,035,036,037,038,039
;/* ( ) * + , - . / */
; ch(40), ch(41), ch(42), ch(43), ch(44), ch(45), ch(46), ch(47),
db 040,041,042,043,044,045,046,047
;/* 0 1 2 3 4 5 6 7 */
; ch(130), ch(131), ch(132), ch(133), ch(134), ch(135), ch(136), ch(137),
db 130,131,132,133,134,135,136,137
;/* 8 9 : ; < = > ? */
; ch(138), ch(139), ch(48), ch(49), ch(50), ch(51), ch(52), ch(53),
db 138,139,048,049,050,051,052,053
;/* @ A B C D E F G */
; ch(54), ch(140), ch(142), ch(144), ch(146), ch(148), ch(150), ch(152),
db 054,141,143,145,147,149,151,153
;/* H I J K L M N O */
; ch(154), ch(156), ch(158), ch(160), ch(162), ch(164), ch(166), ch(170),
db 155,157,159,161,163,165,167,171
;/* P Q R S T U V W */
; ch(172), ch(174), ch(176), ch(178), ch(181), ch(183), ch(185), ch(187),
db 173,175,177,179,182,184,186,188
;/* X Y Z [ \ ] ^ _ */
; ch(189), ch(191), ch(196), ch(55), ch(56), ch(57), ch(58), ch(59),
db 190,193,197,055,056,057,058,059
;/* ` a b c d e f g */
; ch(60), ch(141), ch(143), ch(145), ch(147), ch(149), ch(151), ch(153),
db 060,141,143,145,147,149,151,153
;/* h i j k l m n o */
; ch(155), ch(157), ch(159), ch(161), ch(163), ch(165), ch(167), ch(171),
db 155,157,159,161,163,165,167,171
;/* p q r s t u v w */
; ch(173), ch(175), ch(177), ch(179), ch(182), ch(184), ch(186), ch(188),
db 173,175,177,179,182,184,186,188
;/* x y z { | } ~ DEL */
; ch(190), ch(193), ch(197), ch(61), ch(62), ch(63), ch(64), ch(65),
db 190,193,197,061,062,063,064,065
;/* 80 81 82 83 84 85 86 87 */
; ch(66), ch(67), ch(68), ch(69), ch(70), ch(71), ch(72), ch(73),
db 066,067,068,069,070,071,072,073
;/* 88 89 8A 8B 8C 8D 8E 8F */
; ch(74), ch(75), ch(76), ch(77), ch(78), ch(79), ch(80), ch(81),
db 074,075,076,077,078,079,080,081
;/* 90 91 92 93 94 95 96 97 */
; ch(82), ch(83), ch(84), ch(85), ch(86), ch(87), ch(88), ch(89),
db 082,083,084,085,086,087,088,089
;/* 98 99 9A 9B 9C 9D 9E 9F */
; ch(90), ch(91), ch(92), ch(93), ch(94), ch(95), ch(96), ch(97),
db 090,091,092,093,094,095,096,097
;/* A0 A1 A2 A3 A4 A5 A6 A7 */
; ch(98), ch(99), ch(100), ch(101), ch(102), ch(103), ch(104), ch(105),
db 098,099,100,101,102,103,104,105
;/* A8 A9 AA AB AC AD AE AF */
; ch(106), ch(107), ch(108), ch(109), ch(110), ch(111), ch(112), ch(113),
db 106,107,108,109,110,111,112,113
;/* B0 B1 B2 B3 B4 B5 B6 B7 */
; ch(114), ch(115), ch(116), ch(117), ch(118), ch(119), ch(120), ch(121),
db 114,115,116,117,118,119,120,121
;/* B8 B9 BA BB BC BD BE BF */
; ch(122), ch(123), ch(124), ch(125), ch(126), ch(127), ch(128), ch(129),
db 122,123,124,125,126,127,128,129
;/* C0 C1 C2 C3 C4 C5 C6 C7 */
; ch(140), ch(140), ch(140), ch(140), ch(140), ch(140), ch(140), ch(144),
db 141,141,141,141,141,141,141,145
;/* C8 C9 CA CB CC CD CE CF */
; ch(148), ch(148), ch(148), ch(148), ch(156), ch(156), ch(156), ch(156),
db 149,149,149,149,157,157,157,157
;/* D0 D1 D2 D3 D4 D5 D6 D7 */
; ch(146), ch(168), ch(170), ch(170), ch(170), ch(170), ch(170), ch(170),
db 147,169,171,171,171,171,171,171
;/* D8 D9 DA DB DC DD DE DF */
; ch(170), ch(183), ch(183), ch(183), ch(183), ch(192), ch(199), ch(180),
db 171,184,184,184,184,194,198,180
;/* E0 E1 E2 E3 E4 E5 E6 E7 */
; ch(141), ch(141), ch(141), ch(141), ch(141), ch(141), ch(141), ch(145),
db 141,141,141,141,141,141,141,145
;/* E8 E9 EA EB EC ED EE EF */
; ch(149), ch(149), ch(149), ch(149), ch(157), ch(157), ch(157), ch(157),
db 149,149,149,149,157,157,157,157
;/* F0 F1 F2 F3 F4 F5 F6 F7 */
; ch(147), ch(169), ch(171), ch(171), ch(171), ch(171), ch(171), ch(171),
db 147,169,171,171,171,171,171,171
;/* F8 F9 FA FB FC FD FE FF */
; ch(171), ch(184), ch(184), ch(184), ch(184), ch(194), ch(198), ch(195)
db 171,184,184,184,184,194,198,195
; };
;#undef ch
rgchNoCaseScanExcept:
db 0C4h,0C5h,0C6h,0D6h,0D8h,0DEh,0E4h,0E5h,0E6h,0F6h,0F8h,0FEh
rgordNoCaseScanExcept:
db 0207,0205,0201,0209,0203,0199,0207,0205,0201,0209,0203,0199
ifdef DEBUG
cProc N_OrdCh,<PUBLIC,FAR,ATOMIC>,<di>
ParmW chArg
ParmW fCase
ParmW fScan
cBegin
mov al,bptr [chArg]
mov bx,offset [mpchordCase]
cmp [fCase],fFalse
jne OC01
mov bx,offset [mpchordNoCase]
OC01:
cmp [fScan],fFalse
je OC02
push cs
pop es
errnz <offset [rgchCaseScanExcept] - offset [mpchordCase] - 256>
errnz <offset [rgchNoCaseScanExcept] - offset [mpchordNoCase] - 256>
lea di,[bx + 256]
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov cx,12
repne scasb
jne OC02
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov al,cs:[di+12-1]
db 03Dh ;turns next "xlat cs:[bx]" into "cmp ax,immediate"
OC02:
xlat cs:[bx]
OC03:
xor ah,ah
cEnd
endif ;DEBUG
;-------------------------------------------------------------------------
; WCompSzSrt(psz1,psz2,fCase)
;-------------------------------------------------------------------------
;-- Routine: WCompSzSrt(psz1,psz2,fCase)
;-- Description and Usage:
; Alphabetically compares the two null-terminated strings lpsz1 and lpsz2.
; Upper case alpha characters are mapped to lower case iff fCase
; Comparison of non-alpha characters is by ascii code.
; Returns 0 if they are equal, a negative number if lpsz1 precedes lpsz2, and
; a non-zero positive number if lpsz2 precedes lpsz1.
; If 2 strings compare equal, we do an ansi compare and return that value
; so we handle Apple befor apple and strings identical except
; for accents (intl).
; We now set negative values so that prefixes and < are negative but
; distinct, so callers who care about prefix get the info, but
; others can just check < 0.
;-- Arguments:
; psz1, psz2 - pointers to two null-terminated strings to compare
;-- Returns:
; a short - 0 if strings are equal, -2 if psz1 precedes psz2,
; -1 if psz1 is a prefix of psz2,
; and non-zero positive number if psz2 precedes psz1.
;-- Side-effects: none
;-- Bugs:
;-- History:
; 3/14/83 - created (tsr)
;----------------------------------------------------------------------------*/
;WCompSzSrt(psz1,psz2,fCase)
;register PCH psz1;
;register PCH psz2;
;int fCase;
;{
; int ord1;
; int ord2;
; int dch;
; PCH pszOrig1 = psz1;
; PCH pszOrig2 = psz2;
; CHAR FAR *mpchord = vitr.fScandanavian ? mpchordScan : mpchordNorm;
WCSS01:
push di
errnz <offset [rgchCaseScanExcept] - offset [mpchordCase] - 256>
errnz <offset [rgchNoCaseScanExcept] - offset [mpchordNoCase] - 256>
lea di,[bx + 256]
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov cx,12
repne scasb
jne WCSS02
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov al,cs:[di+12-1]
db 03Dh ;turns next "xlat cs:[bx]" into "cmp ax,immediate"
WCSS02:
xlat cs:[bx]
pop di
jmp short WCSS07
WCSS03:
push di
errnz <offset [rgchCaseScanExcept] - offset [mpchordCase] - 256>
errnz <offset [rgchNoCaseScanExcept] - offset [mpchordNoCase] - 256>
lea di,[bx + 256]
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov cx,12
repne scasb
jne WCSS04
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov al,cs:[di+12-1]
db 03Dh ;turns next "xlat cs:[bx]" into "cmp ax,immediate"
WCSS04:
xlat cs:[bx]
pop di
jmp short WCSS08
cProc N_WCompSzSrt,<PUBLIC,FAR,ATOMIC>,<si,di>
ParmW psz1
ParmW psz2
ParmW fCase
cBegin
xor ah,ah
push cs
pop es
mov si,[psz1]
mov di,[psz2]
mov bx,offset [mpchordCase]
cmp [fCase],fFalse
jne WCSS05
mov bx,offset [mpchordNoCase]
WCSS05:
mov dl,[vitr.fScandanavianItr]
or dl,dl
je WCSS06
mov dl,080h
WCSS06:
; /* Note: ChLower used intentionally, rather than ChUpper so that
; French comparisons use the sort table values, not the stripped
; upper case values bz
; */
;
; for (ord1 = mpchord[fCase ? *psz1++ : ChLower(*psz1++)],
; ord2 = mpchord[fCase ? *psz2++ : ChLower(*psz2++)];
; ord1 == ord2;
; ord1 = mpchord[fCase ? *psz1++ : ChLower(*psz1++)],
; ord2 = mpchord[fCase ? *psz2++ : ChLower(*psz2++)])
; {
mov al,[di]
inc di
test al,dl
jne WCSS01
xlat cs:[bx]
WCSS07:
mov dh,al
lodsb
test al,dl
jne WCSS03
xlat cs:[bx]
WCSS08:
cmp al,dh
jne WCSS09
; if (ord1 == '\0')
; {
cmp al,0
jne WCSS06
; psz1 = pszOrig1;
; psz2 = pszOrig2;
; for (ord1=*psz1++, ord2=*psz2++; ord1==ord2; ord1=*psz1++, ord2=*psz2++)
; {
; if (ord1 == '\0')
; return(0);
; }
; break;
; }
xor al,al
mov cx,si
mov si,[psz1]
sub cx,si
mov di,[psz2]
push ds
pop es
repe cmpsb
je WCSS10
mov al,[si-1]
mov dh,[di-1]
; }
WCSS09:
; if ((dch = ord1 - ord2) > 0)
; return dch;
mov dl,al
sub al,dh
ja WCSS10
; else if (ord1 != '\0')
; return -2; /* psz1 < psz2 */
; else
; return -1; /* != but *psz1 == 0; psz1 is a prefix of psz2 */
cmp dl,1
cmc
sbb ax,ax
dec ax
;} /* end of W C o m p S z Srt */
WCSS10:
cEnd
;-------------------------------------------------------------------------
; WCompChCh (ch1, ch2)
;-------------------------------------------------------------------------
;/* W C O M P C H C H */
;/* Compare two characters using the table in this module. Return zero
; if ch1 == ch2, negative if ch1 < ch2, and positive if ch1 > ch2.
;*/
;WCompChCh (ch1, ch2)
;CHAR ch1, ch2;
;
;{
; CHAR FAR *mpchord = vitr.fScandanavian ? mpchordScan : mpchordNorm;
; return mpchord[ch1] - mpchord[ch2];
;}
cProc N_WCompChCh,<PUBLIC,FAR,ATOMIC>,<di>
ParmW ch1
ParmW ch2
cBegin
push cs
pop es
mov bx,offset [mpchordCase]
xor ah,ah
mov al,bptr [ch2]
call WCCC01
mov dx,ax
mov al,bptr [ch1]
call WCCC01
sub ax,dx
cEnd
WCCC01:
cmp [vitr.fScandanavianItr],fFalse
je WCCC02
errnz <offset [rgchCaseScanExcept] - offset [mpchordCase] - 256>
errnz <offset [rgchNoCaseScanExcept] - offset [mpchordNoCase] - 256>
lea di,[bx + 256]
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov cx,12
repne scasb
jne WCCC02
errnz <offset [rgordCaseScanExcept] - offset [rgchCaseScanExcept] - 12>
errnz <offset [rgordNoCaseScanExcept] - offset [rgchNoCaseScanExcept] - 12>
mov al,cs:[di+12-1]
db 03Dh ;turns next "xlat cs:[bx]" into "cmp ax,immediate"
WCCC02:
xlat cs:[bx]
ret
;/* L b c C m p L b o x */
;/* from lbox.h */
;#define lbcEq 0
;#define lbcPrefix 1
;#define lbcLt 2
;#define lbcGt 3
;
;/* Callback compare rtn for sdm listboxes
; Compare two characters using the table in this module.
; Return lbc codes above
;*/
;EXPORT LbcCmpLbox (wUser, pstz1, pstz2)
;WORD wUser;
;CHAR **pstz1;
;CHAR **pstz2;
;{
; int w;
lbcEq equ 0
lbcPrefix equ 1
lbcLt equ 2
lbcGt equ 3
cProc LbcCmpLbox,<PUBLIC,FAR,ATOMIC>,<>
ParmW wUser
ParmW pstz1
ParmW pstz2
cBegin
; w = WCompSzSrt(*pstz1 + 1,*pstz2 + 1, fFalse); /* skip over st size */
mov bx,[pstz1]
mov bx,[bx]
inc bx
push bx
mov bx,[pstz2]
mov bx,[bx]
inc bx
push bx
errnz <fFalse>
xor bx,bx
push bx
ifdef DEBUG
cCall S_WCompSzSrt,<>
else ;not DEBUG
push cs
call near ptr N_WCompSzSrt
endif ;DEBUG
; if (w == 0)
; {
; return (lbcEq);
; }
; else if (w > 0)
; return (lbcGt);
; else if (w == -2)
; return (lbcLt);
; else
; {
; Assert (w == -1);
; return (lbcPrefix);
; }
;}
errnz <lbcEq>
errnz <lbcPrefix - 1>
errnz <lbcLt - 2>
neg ax
ifdef DEBUG
cmp ax,2
jle LCL01
push ax
push bx
push cx
push dx
mov ax,midDialog1n
mov bx,1001
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
LCL01:
or ax,ax
endif ;DEBUG
jge LCL02
mov ax,lbcGt
LCL02:
cEnd
sEnd dialog1n
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+277
View File
@@ -0,0 +1,277 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg disp3_PCODE,disp3,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midDisp3n equ 2 ; module ID, for native asserts
endif
; EXTERNAL FUNCTIONS
ifdef DEBUG
externFP <ScrollDCFP>
else ;!DEBUG
ifdef HYBRID
externFP <ScrollDCPR>
else ;!HYBRID
externFP <ScrollDC>
endif ;!HYBRID
endif ;!DEBUG
externFP <PatBltRc>
externFP <N_CachePara>
externFP <FMsgPresent>
externFP <FSectRc>
externFP <CpFirstTap1>
ifdef DEBUG
externFP <AssertProcForNative, S_CachePara>
endif
sBegin data
;
; /* E X T E R N A L S */
;
externW hwwdCur ; extern struct WWD **hwwdCur;
externW mpwwhwwd ; extern struct WWD **mpwwhwwd[];
externW vpapFetch ; extern struct PAP vpapFetch;
externW caPara ; extern struct CA caPara;
externW selCur ; extern struct SEL selCur;
externW vsci ; extern struct SCI vsci;
externW vmpitccp ; extern CP vmpitccp[];
externW caTap ; extern struct CA caTap;
externW vtapFetch ; extern struct TAP vtapFetch;
; #ifdef DEBUG
ifdef DEBUG
; extern int cHpFreeze;
externW vdbs ; extern struct DBS vdbs;
externW vcaLHRUpd ; extern struct CA vcaLHRUpd;
externW vwwLHRUpd ; extern int vwwLHRUpd;
; #endif /* DEBUG */
endif
sEnd data
; CODE SEGMENT _DISP3
sBegin disp3
assumes cs,disp3
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; ScrollWw(ww, prcScroll, dxp, dyp, prcUpdate, prcClip) GregC
;-------------------------------------------------------------------------
; %%Function:N_ScrollWw %%Owner:BRADV
cProc N_ScrollWw,<PUBLIC,FAR>,<si,di>
ParmW ww
ParmW prcScroll
ParmW dxp
ParmW dyp
ParmW prcUpdate
ParmW prcClip
; /* Windows-specific scrolling function that handles the case of overlapping
; popup windows */
; /* Returns fTrue iff update rect is larger than exposed scroll area
; (due to a popup in the way) */
;
; native ScrollWw( ww, prcScroll, dxp, dyp, prcUpdate, prcClip )
; int ww;
; struct RC *prcScroll;
; int dxp, dyp;
; struct RC *prcUpdate; /* Area to update returned through here */
; struct RC *prcClip;
; {
; struct WWD *pwwd = *mpwwhwwd [ww];
; HDC hdc = pwwd->hdc;
localW hdc
; struct RC rcT;
localV rcT,cbRcMin
cBegin
mov si,[dxp]
mov di,[dyp]
mov bx,[ww]
shl bx,1
mov bx,[bx.mpwwhwwd]
mov bx,[bx]
mov ax,[bx.hdcWwd]
mov [hdc],ax
;
; Assert( !(dxp && dyp) );
ifdef DEBUG
L100:
or si,si
jz SW4
or di,di
jz SW4
mov ax,midDisp3n
mov bx,1001
cCall AssertProcForNative,<ax, bx>
SW4:
endif
;
; if (!FSectRc( prcScroll, prcClip, &rcT))
; return(fFalse);
lea ax,[rcT]
cCall FSectRc,<[prcScroll], [prcClip], ax>
or ax,ax
jz SW14
;
; ScrollDC( hdc, dxp, dyp, (LPRECT)&rcT, (LPRECT)&rcT /*lprcClip*/,
; (HRGN)NULL /*hrgnUpdate*/, (LPRECT)prcUpdate );
push [hdc]
push si
push di
lea ax,[rcT]
push ds
push ax
push ds
push ax
xor ax,ax
push ax
push ds
push [prcUpdate]
ifdef DEBUG
call ScrollDCFP
else ;!DEBUG
ifdef HYBRID
call ScrollDCPR
else ;!HYBRID
call ScrollDC
endif ;!HYBRID
endif ;!DEBUG
;
; /* only blank on horizontal scrolls; on vertical ones, the effect is
; not too noticable and it is a speed win to not blank */
; if (dxp)
or si,si
jz SW6
; PatBltRc( hdc, prcUpdate, vsci.ropErase );
cCall PatBltRc,<[hdc], [prcUpdate], [vsci.HI_ropEraseSci], [vsci.LO_ropEraseSci]>
;
SW6:
SW14:
; }
cEnd
ifdef NOTUSED
;-------------------------------------------------------------------------
; UnionRc( prcDest, prc1, prc2 ) GregC
;-------------------------------------------------------------------------
; %%Function:UnionRc %%Owner:BRADV
cProc UnionRc,<PUBLIC,FAR>,<si,di>
ParmW prcDest
ParmW prc1
ParmW prc2
; /* U N I O N R C */
; /* prcDest gets the smallest rectangle that encloses *prc1 and *prc2. */
; /* Correctly handles empty rects (as defined by FEmptyRc), and the */
; /* case when prcDest == prc1 OR prcDest == prc2 */
; native UnionRc( prcDest, prc1, prc2 )
; struct RC *prcDest;
; struct RC *prc1;
; struct RC *prc2;
; {
cBegin
;
; Assert( prcDest != NULL );
ifdef DEBUG
L200:
cmp [prcDest],0
jnz UR2
mov ax,midDisp3n
mov bx,1002
cCall AssertProcForNative,<ax, bx>
UR2:
endif
;
mov si,[prc1]
mov di,[prcDest]
; if (FEmptyRc( prc1 ))
push si
call far ptr FEmptyRc
or ax,ax
jz UR6
; {
; blt( prc2, prcDest, cwRC );
mov si,[prc2]
UR4:
mov ax,ds
mov es,ax
mov cx,cwRC
rep movsw
jmp short UR16
; }
UR6:
; else if (FEmptyRc( prc2 ))
; {
; blt( prc1, prcDest, cwRC );
; }
push [prc2]
call far ptr FEmptyRc
or ax,ax
jnz UR4
; else
; {
; prcDest->xpLeft = min( prc1->xpLeft, prc2->xpLeft );
mov bx,[prc2]
mov ax,[si.xpLeftRc]
mov cx,[bx.xpLeftRc]
cmp ax,cx
jle UR8
mov ax,cx
UR8:
mov [di.xpLeftRc],ax
; prcDest->ypTop = min( prc1->ypTop, prc2->ypTop );
mov ax,[si.ypTopRc]
mov cx,[bx.ypTopRc]
cmp ax,cx
jle UR10
mov ax,cx
UR10:
mov [di.ypTopRc],ax
; prcDest->xpRight = max( prc1->xpRight, prc2->xpRight );
mov ax,[si.xpRightRc]
mov cx,[bx.xpRightRc]
cmp ax,cx
jge UR12
mov ax,cx
UR12:
mov [di.xpRightRc],ax
; prcDest->ypBottom = max( prc1->ypBottom, prc2->ypBottom );
mov ax,[si.ypBottomRc]
mov cx,[bx.ypBottomRc]
cmp ax,cx
jge UR14
mov ax,cx
UR14:
mov [di.ypBottomRc],ax
; }
UR16:
; }
cEnd
endif ;NOTUSED
sEnd disp3
end
+226
View File
@@ -0,0 +1,226 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg disptbl_PCODE,disptbln,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midDisptbln equ 25 ; module ID, for native asserts
NatPause equ 1
endif
ifdef NatPause
PAUSE MACRO
int 3
ENDM
else
PAUSE MACRO
ENDM
endif
; EXTERNAL FUNCTIONS
externFP <FSetRgchDiff>
ifdef DEBUG
externFP <AssertProcForNative>
endif
sBegin data
;
; /* E X T E R N A L S */
;
externW vfti ; extern struct FTI vfti;
sEnd data
; CODE SEGMENT _disptbln
sBegin disptbln
assumes cs,disptbln
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; WidthHeightFromBrc(brc, grpf)
;-------------------------------------------------------------------------
;HANDNATIVE C_WidthHeightFromBrc(brc, grpf)
;struct BRC brc;
;int grpf;
;{
; int dzp, dz = 0, dxp;
; int fFrameLines, fWidth, fLine;
; %%Function:WidthHeightFromBrc %%Owner:tomsax
PUBLIC N_WidthHeightFromBrc
N_WidthHeightFromBrc:
mov bx,sp
mov cx,[bx+4]
errnz <cbBrcMin - 2>
mov dx,[bx+6]
;We now have brc in dx, grpf in cx
; fFrameLines = grpf & 1;
; fWidth = grpf & 2;
; fLine = grpf & 4;
maskFFrameLinesLocal equ 1
maskFWidthLocal equ 2
maskFLineLocal equ 4
; dzp = fWidth ? dxpBorderFti : dypBorderFti;
;#define dypBorderFti vfti.dypBorder
;#define dxpBorderFti vfti.dxpBorder
mov ax,[vfti.dxpBorderFti]
test cl,maskFWidthLocal
jne WHFB01
mov ax,[vfti.dypBorderFti]
WHFB01:
; if ((int) brc == brcNone && fFrameLines)
; return dzp;
mov bx,ax
errnz <brcNone - 0>
or dx,dx
jne WHFB02
test cl,maskFFrameLinesLocal
jne WHFB10
WHFB02:
; if ((int) brc == brcNone || (int) brc == brcNil)
; return 0;
xor ax,ax
errnz <brcNil - (-1)>
inc dx
je WHFB10
errnz <brcNone - 0>
dec dx
je WHFB10
; /* All the more difficult cases */
; if (!fLine)
; /* brc.dxpSpace is in points - Hungarian name is wrong */
; dz = NMultDiv(brc.dxpSpace,
; fWidth ? vfti.dxpInch : vfti.dypInch,
; cptInch);
test cl,maskFLineLocal
jne WHFB07
push bx ;save dzp
push dx ;save brc
mov ax,[vfti.dxpInchFti]
test cl,maskFWidthLocal
jne WHFB04
mov ax,[vfti.dypInchFti]
WHFB04:
errnz <(dxpSpaceBrc) - 1>
errnz <maskDxpSpaceBrc - 03Eh>
mov dl,dh
and dx,maskDxpSpaceBrc
shr dx,1
imul dx
add ax,cptInch SHR 1
adc dx,0
ifdef DEBUG
;Assert the following idiv will not overflow with a call
;so as not to mess up short jumps.
call WHFB11
endif ;DEBUG
mov bx,cptInch
idiv bx
pop dx ;restore brc
pop bx ;restore dzp
WHFB07:
; if (brc.fShadow)
; dz += fWidth ? dxShadow : dyShadow;
;#define dxShadow dxpBorderFti
;#define dyShadow dypBorderFti
;PAUSE
errnz <(fShadowBrc) - 1>
test dh,maskFShadowBrc
je WHFB08
add ax,bx
WHFB08:
; switch(brc.brcBase)
; {
; case brcSingle:
; return dz + dzp;
; case brcTwoSingle:
; return dz + 3 * dzp;
; case brcThick:
; return dz + 2 * dzp;
; }
; Assert(fFalse);
; return 0;
errnz <maskBrcBaseBrc - 001FFh>
and dh,maskBrcBaseBrc SHR 8
add ax,bx
cmp dx,brcSingle
je WHFB09
add ax,bx
cmp dx,brcThick
je WHFB09
add ax,bx
cmp dx,brcTwoSingle
je WHFB09
ifdef DEBUG
;Assert (fFalse) with a call so as not to mess up short jumps.
call WHFB14
endif ;DEBUG
xor ax,ax
jmp short WHFB10
WHFB09:
; return dz;
WHFB10:
;}
db 0CAh, 004h, 000h ;far ret, pop 4 bytes
ifdef DEBUG
WHFB11:
push ax
push bx
push cx
push dx
or dx,dx
jns WHFB12
neg dx
WHFB12:
cmp dx,cptInch SHR 1
jb WHFB13
mov ax,midDisptbln
mov bx,1001
cCall AssertProcForNative,<ax,bx>
WHFB13:
pop dx
pop cx
pop bx
pop ax
ret
endif ;DEBUG
ifdef DEBUG
WHFB14:
push ax
push bx
push cx
push dx
mov ax,midDisptbln
mov bx,1002
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
ret
endif ;DEBUG
sEnd disptbln
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+269
View File
@@ -0,0 +1,269 @@
.xlist
?USEDS equ 1
?USEBP equ 1
?WIN = 0
include cmacros.inc
.list
;Must be different from eldde_PCODE
createSeg _ELDDE,eldden,byte,public,CODE
ifdef HYBRID
externFP <GlobalLockPR>
externFP <GlobalUnlockPR>
externFP <GlobalFreePR>
else ;!HYBRID
externFP <GlobalLock>
externFP <GlobalUnlock>
externFP <GlobalFree>
endif ;!HYBRID
externFP <DefHookProc>
externFP <UnhookWindowsHook,FreeProcInstance,SetKeyboardState>
externFP <ToAscii>
;
; system queue message structure (same as above only different)
;
SYSMSG STRUC
smMessage dw ?
smParamL dw ?
smParamH dw ?
smTime dd ?
SYSMSG ENDS
; These structures are duplicated in dde.h
EVENT STRUC
wmEv dw ?
vkEv dw ?
EVENT ENDS
EVT STRUC
ieventCur dw ?
ieventMac dw ?
rgevent db (SIZE EVENT) DUP (?)
EVT ENDS
HC_GETNEXT equ 1
HC_SKIP equ 2
WH_JOURNALPLAYBACK equ 1
VK_SHIFT equ 10H
;
; struct DRVDATA definition
;
hevtHeadDrvdata equ [word ptr 00000h]
hrgbKeyStateDrvdata equ [word ptr 00002h]
lpfnPlaybackHookSaveDrvdata equ [word ptr 00004h]
cbDrvdataMin equ 00008h
sBegin eldden
assumes cs,eldden
assumes ds,nothing
assumes ss,nothing
; don't mess with this unless you change the DRVHD declaration in dde.h
; this MUST be the first thing in this segment!
globalW wDataSeg,0
globalW wWinVersion,0
; %%Function:PlaybackHook %%Owner:peterj
cProc PlaybackHook,<PUBLIC,FAR>,<si,di>
ParmW hc
ParmW wParam
ParmD lpsysmsg
cBegin
mov di,hc
cmp di,HC_SKIP
je ph10
cmp di,HC_GETNEXT
je ph10
mov ax,(lpfnPlaybackHookSaveDrvdata)
cCall DefHookProc,<hc, wParam, lpsysmsg, cs:[wDataSeg], ax>
jmp phx1
ph10:
mov es,cs:[wDataSeg]
mov ax,es:[hevtHeadDrvdata]
push ax
ifdef HYBRID
push ds
push ss
pop ds
cCall GlobalLockPR,<ax>
pop ds
else ;!HYBRID
cCall GlobalLock,<ax>
endif ;!HYBRID
push ds
mov ds,dx
mov si,ax
cmp di,HC_SKIP
je ph13
jmp ph20
ph13:
; Handle Skip message
inc [si].ieventCur
mov di,[si].ieventCur
cmp di,[si].ieventMac
jge ph15
jmp ph30
ph15:
; Uninstall windows hook
pop ds
mov ax,WH_JOURNALPLAYBACK
lea bx,[PlaybackHook]
cCall UnhookWindowsHook,<ax, cs, bx>
pop ax
push ax
push ax ;duplicate hevtHead on the stack
ifdef HYBRID
pop ax
push ds
push ss
pop ds
push ax
cCall GlobalUnlockPR;<es:[hevtHeadDrvdata]> args already pushed
pop ds
else ;!HYBRID
cCall GlobalUnlock;<es:[hevtHeadDrvdata]> args already pushed
endif ;!HYBRID
ifdef HYBRID
pop ax
push ds
push ss
pop ds
push ax
cCall GlobalFreePR;<es:[hevtHeadDrvdata]> args already pushed
pop ds
else ;!HYBRID
cCall GlobalFree;<es:[hevtHeadDrvdata]> args already pushed
endif ;!HYBRID
push es
mov es,cs:[wDataSeg]
mov es:[hevtHeadDrvdata],0
mov ax,es:[hrgbKeyStateDrvdata]
pop es
or ax,ax
je Ltemp001
ifdef HYBRID
push ds
push ss
pop ds
cCall GlobalLockPR,<ax>
pop ds
else ;!HYBRID
cCall GlobalLock,<ax>
endif ;!HYBRID
mov cx,ax
or cx,dx
je phx
push dx
push ax ;save hp
cCall SetKeyboardState,<dx, ax>
pop ax
pop dx ;restore hp
; Kludge alert!! For those of us not priviledged to know secret
; windows internals ToAscii (according to Peter Belew) is "NOT
; a part of the Windows API, and should NOT be documented in the
; SDK documentation. It is an INTERNAL Windows function. Its
; output is not a deterministic result of its parameter values,
; since it has an internal state. This means that Microsoft apps,
; as well as others. should not use it."
;
; However, according to Ed Fries of the Excel group the only way
; "reset the lock lights" was to call ToAscii.
;
; Hopefully, SetKeyboardState will take care of the lock lights
; in version 3.00 and we won't need to call it. Calling it as
; it is coded here causes problems under version 3.00. In protect
; mode it causes GP faults and if you aren't under protect mode
; it will smash interrupt vectors.
;
; Don't you love this kludge?
cmp cs:[wWinVersion],00300h
jae ph17 ;Don't call ToAscii if version >= 3.00
mov cx,VK_SHIFT
push cx
xor cx,cx
push cx
push dx
push ax
push cx
push cx
push cx
cCall ToAscii,<>
ph17:
push es
mov es,cs:[wDataSeg]
mov ax,es:[hrgbKeyStateDrvdata]
pop es
push ax
ifdef HYBRID
push ds
push ss
pop ds
cCall GlobalUnlockPR,<ax>
pop ds
else ;!HYBRID
cCall GlobalUnlock,<ax>
endif ;!HYBRID
ifdef HYBRID
pop ax
push ds
push ss
pop ds
push ax
cCall GlobalFreePR;<ax> args already pushed
pop ds
else ;!HYBRID
cCall GlobalFree;<ax> args already pushed
endif ;!HYBRID
push es
mov es,cs:[wDataSeg]
mov es:[hrgbKeyStateDrvdata],0
pop es
Ltemp001:
jmp short phx
ph20:
; Handle Get message
les di,lpsysmsg
mov bx,[si].ieventCur
shl bx,1
shl bx,1
errnz <(SIZE EVENT)-4>
mov ax,[si+rgevent][bx+wmEv]
errnz <smMessage>
stosw
mov ax,[si+rgevent][bx+vkEv]
errnz <smParamL-2>
stosw
mov ax,1
errnz <smParamH-4>
stosw
xor ax,ax
errnz <smTime-6>
stosw
stosw
ph30:
pop ds
ifdef HYBRID
pop ax
push ds
push ss
pop ds
push ax
cCall GlobalUnlockPR;<es:[hevtHeadDrvdata]> args already pushed
pop ds
else ;!HYBRID
cCall GlobalUnlock;<es:[hevtHeadDrvdata]> args already pushed
endif ;!HYBRID
phx:
xor ax,ax
xor dx,dx
phx1:
cEnd
sEnd eldden
end
+106
View File
@@ -0,0 +1,106 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg exp_PCODE,exp,byte,public,CODE
; DEBUGGING DECLARATIONS
; EXTERNAL FUNCTIONS
externFP <CbAllocSb, CbReallocSb, FreeSb, ReloadSb, CbSizeSb>
sBegin data
; EXTERNALS
externW mpsbps
externW sbMac
sEnd data
; CODE SEGMENT _EXP
sBegin exp
assumes cs,exp
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; LPushMacroArgs (qProc, rgw, cw)
;-------------------------------------------------------------------------
; %%Function:LPushMacroArgs %%Owner:bradch
cProc LPushMacroArgs,<PUBLIC,FAR>,<si,di>
ParmD <qProc>
ParmW <rgw>
ParmW <cw>
cBegin
mov di,sp
mov si,[rgw]
mov cx,[cw]
jcxz PMA04
PMA03:
lodsw
push ax
loop PMA03
PMA04:
call dword ptr ([qProc])
mov sp,di
cEnd
;-------------------------------------------------------------------------
; MemUsed (memType)
;
; memType = 1 for conventional, 2 for expanded, 3 for both
;
; Taken directly from Excel's memutil.asm. 8/12/88 TDK.
;-------------------------------------------------------------------------
; %%Function:MemUsed %%Owner:bradch
cProc MemUsed,<PUBLIC,FAR>,<si,di>
ParmW memType
cBegin
xor si,si
xor di,di
mov bx,1
dec bx
mf1a:
inc bx
cmp bx,[sbMac]
jae mfx
shl bx,1
mov cx,[bx+mpsbps]
shr bx,1
jcxz mf1a
push bx
cCall CbSizeSb,<bx>
pop bx
;
; Determine if memory is conventional or expanded
;
mov cl,00000001b ; assume conventional
or dx,dx ; no Emm, must be conventional
jz mf1c
mov cl,00000010b ; mark as expanded
mf1c:
test byte ptr (memType),cl
jz mf1a
add si,ax
adc di,0
jmp mf1a
mfx:
mov ax,si
mov dx,di
cEnd
sEnd exp
end
+501
View File
@@ -0,0 +1,501 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg fetch2_PCODE,fetch2,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midFetch2n equ 24 ; module ID, for native asserts
endif
; EXTERNAL FUNCTIONS
ifdef DEBUG
externFP <ScrollDCFP>
else ;!DEBUG
ifdef HYBRID
externFP <ScrollDCPR>
else ;!HYBRID
externFP <ScrollDC>
endif ;!HYBRID
endif ;!DEBUG
externFP <PatBltRc>
externFP <N_CachePara>
externFP <FMsgPresent>
externFP <FSectRc>
externFP <CpFirstTap1>
externFP <FSetRgchDiff>
ifdef DEBUG
externFP <AssertProcForNative>
externFP <S_CachePara>
endif
sBegin data
;
; /* E X T E R N A L S */
;
externW hwwdCur ; extern struct WWD **hwwdCur;
externW mpwwhwwd ; extern struct WWD **mpwwhwwd[];
externW vpapFetch ; extern struct PAP vpapFetch;
externW caPara ; extern struct CA caPara;
externW selCur ; extern struct SEL selCur;
externW vchpGraySelCur ; extern struct CHP vchpGraySelCur;
externW vpapSelCur ; extern struct PAP vpapSelCur;
externW vpapGraySelCur ; extern struct PAP vpapGraySelCur;
externW vsci ; extern struct SCI vsci;
externW vmpitccp ; extern CP vmpitccp[];
externW caTap ; extern struct CA caTap;
externW vtapFetch ; extern struct TAP vtapFetch;
; #ifdef DEBUG
ifdef DEBUG
; extern int cHpFreeze;
externW vdbs ; extern struct DBS vdbs;
externW vcaLHRUpd ; extern struct CA vcaLHRUpd;
externW vwwLHRUpd ; extern int vwwLHRUpd;
; #endif /* DEBUG */
endif
sEnd data
; CODE SEGMENT _fetch2
sBegin fetch2
assumes cs,fetch2
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; FGetParaState(fAll, fAbortOk)
;-------------------------------------------------------------------------
; %%Function:N_FGetParaState %%Owner:BRADV
cProc N_FGetParaState,<PUBLIC,FAR>,<si,di>
ParmW fAll
ParmW fAbortOK
; /* ****
; * Description: Return properties for the paragraph menu.
; * The current selection nongray para props are left in vpapSelCur and the
; * paragraph attributes in vpapGraySelCur are set to non-zero if that attribute
; * differs from that in the previous paragraph. Up to cparaMax paragraphs
; * will be checked
; *
; * returns fFalse if interrupted, fTrue if complete. If interrupted,
; * selCur paps remain unchanged.
; ** **** */
;
; native FGetParaState(fAll, fAbortOk)
; BOOL fAll;
; BOOL fAbortOk; /* if true, this routine is interruptible */
; {
; /* REVIEW do we want to use fALL ?
; */
;
; /* max number of calls to CachePara */
; #define cparaMax 50
cparaMax equ 50
;
; int cpara = 0;
; struct PAP pap, papGray;
; CP cpNext;
localD cpNext
localW cPara
localW skVar ;fPapInitted in high byte
localV pap,cbPap
localV papGray,cbPap
cBegin
;Assert (fAll == 0 || fAll == 1);
ifdef DEBUG
test [fAll],0FFFEh
jz FGPS01
push ax
push bx
push cx
push dx
mov ax,midFetch2n
mov bx,1004
cCall AssertProcForNative,<ax, bx>
pop dx
pop cx
pop bx
pop ax
FGPS01:
endif ;DEBUG
;Assembler note: we keep !fAll in the high byte of cpara so
;that (fAll || (cpara <= cparaMax)) is really performed as
;!(((!fAll << 8) + cpara) > (fTrue << 8) + cparaMax).
errnz <(cparaMax+1) AND 0FF00h>
mov ax,00100h
xor ah,bptr ([fAll])
mov [cpara],ax
; /* we do some word operations, so be sure sizes are good */
; Assert (!(cbPAPBase % sizeof(int)));
; Assert (!(cbPAP % sizeof(int)));
errnz <cbPAPBase AND 1>
errnz <cbPAPMin AND 1>
; /* gray out everything if no child window up */
push ds
pop es
; if (hwwdCur == hNil)
; {
errnz <hNil>
xor ax,ax
cmp [hwwdCur],ax
jne FGPS02
; /* init gray pap to all gray */
; SetWords(&vpapGraySelCur, 0xFFFF, cwPAP);
mov di,dataoffset [vpapGraySelCur]
dec ax
errnz <cbPAPMin AND 1>
mov cx,cbPAPMin SHR 1
rep stosw
; return (fTrue); /* leave fUpdate bit on */
jmp FGPS14
; }
FGPS02:
; /* init entire local gray pap to all non gray */
; SetWords(&papGray, 0, cwPAP);
lea di,[papGray]
errnz <cbPAPMin AND 1>
mov cx,cbPAPMin SHR 1
rep stosw
; fCol = (selCur.sk == skColumn);
mov al,[selCur.skSel]
and al,maskSkSel
mov [skVar],ax ;also resets fPapInitted in high byte
;#ifdef DEBUG
; if (fCol)
; Assert (selCur.itcFirst >= 0 && selCur.itcLim >= 0);
;#endif /* DEBUG */
ifdef DEBUG
cmp al,skColumn SHL ibitSkSel
jne FGPS04
cmp [selCur.itcFirstSel],0
jl FGPS03
cmp [selCur.itcLimSel],0
jge FGPS04
FGPS03:
push ax
push bx
push cx
push dx
mov ax,midFetch2n
mov bx,1005
cCall AssertProcForNative,<ax, bx>
pop dx
pop cx
pop bx
pop ax
FGPS04:
endif ;DEBUG
; cpNext = selCur.cpFirst;
mov ax,[selCur.LO_cpFirstSel]
mov dx,[selCur.HI_cpFirstSel]
mov [OFF_cpNext],ax
mov [SEG_cpNext],dx
; /* Need to initialize pap for insertion points and one line block
; selections because they don't get inside the following while loop. */
; CachePara (selCur.doc, cpNext);
push [selCur.docSel]
push dx
push ax
ifdef DEBUG
cCall S_CachePara,<>
else ;not DEBUG
cCall N_CachePara,<>
endif ;DEBUG
; blt( &vpapFetch, &pap, cwPAP );
push ds
pop es
mov si,dataoffset [vpapFetch]
lea di,[pap]
errnz <cbPAPMin AND 1>
mov cx,cbPAPMin SHR 1
rep movsw
; while (cpNext < selCur.cpLim &&
; (fAll || (cpara <= cparaMax)))
; {
FGPS06:
mov ax,[OFF_cpNext]
mov dx,[SEG_cpNext]
sub ax,[selCur.LO_cpLimSel]
sbb dx,[selCur.HI_cpLimSel]
jge Ltemp001
;Assembler note: we keep !fAll in the high byte of cpara so
;that (fAll || (cpara <= cparaMax)) is really performed as
;!(((!fAll << 8) + cpara) > (fTrue << 8) + cparaMax).
errnz <(cparaMax+1) AND 0FF00h>
cmp [cpara],(fTrue SHL 8) + cparaMax
ja Ltemp001
; /* interrupted? */
; if ( fAbortOk &&
; /* take heed: FMsgPresent can call CachePara, move the heap, etc */
; FMsgPresent(mtyIdle) )
; {
cmp [fAbortOk],fFalse
je FGPS07
mov ax,mtyIdle
cCall FMsgPresent,<ax>
or ax,ax
jz FGPS07
; return (fFalse);
; }
jmp FGPS15
Ltemp001:
jmp FGPS12
FGPS07:
; if (fCol)
; CpFirstTap(selCur.doc, cpNext);
; cpT = (!fCol) ? cpNext : vmpitccp[selCur.itcFirst];
; /* will make non col case go only once */
; cpLimT = (!fCol) ? cpNext + 1 : vmpitccp[selCur.itcLim];
mov bx,[OFF_cpNext]
mov cx,[SEG_cpNext]
mov ax,1
cwd
add ax,bx
adc dx,cx
cmp bptr ([skVar]),skColumn SHL ibitSkSel
jne FGPS08
;***Begin in line CpFirstTap
; return CpFirstTap1(doc,cpFirst,caTap.doc==doc?vtapFetch.fOutline:fFalse);
mov dx,[selCur.docSel]
cmp dx,[caTap.docCa]
mov al,[vtapFetch.fOutlineTap]
je FGPS073
mov al,fFalse
FGPS073:
and ax,maskFOutlineTap
cCall CpFirstTap1,<dx, cx, bx, ax>
;***End in line CpFirstTap
mov ax,[selCur.itcFirstSel]
shl ax,1
shl ax,1
add ax,dataoffset [vmpitccp]
xchg ax,si
lodsw
xchg ax,bx
lodsw
xchg ax,cx
mov ax,[selCur.itcLimSel]
shl ax,1
shl ax,1
add ax,dataoffset [vmpitccp]
xchg ax,si
lodsw
xchg ax,dx
lodsw
xchg ax,dx
FGPS08:
; while (cpT < cpLimT)
; {
cmp bx,ax
mov si,cx
sbb si,dx
jge FGPS095
push dx
push ax ;save cpLimT
; /* If any props are different, set appropriate flags */
; CachePara (selCur.doc, cpT);
push [selCur.docSel]
push cx
push bx
ifdef DEBUG
cCall S_CachePara,<>
else ;not DEBUG
cCall N_CachePara,<>
endif ;DEBUG
; cpT = caPara.cpLim;
push [caPara.HI_cpLimCa]
push [caPara.LO_cpLimCa]
; if (++cpara == 1)
; blt( &vpapFetch, &pap, cwPAP ); /* save 1st paragraph for compares */
inc bptr ([cpara])
push ds
pop es
mov al,fTrue
xchg al,bptr ([skVar+1])
or al,al ;fPapInitted
jne FGPS09
mov si,dataoffset [vpapFetch]
lea di,[pap]
errnz <cbPAPMin AND 1>
mov cx,cbPapMin SHR 1
rep movsw
;Assembler note: just fall through and perform harmless operations.
;This case only occurs once per call to FGetParaState
FGPS09:
; else if (!vpapFetch.fTtp)
; {
cmp bptr [vpapFetch.fTtpPap],fFalse
jne FGPS093
; /* get base of pap */
; FSetRgwDiff (&pap, &vpapFetch, &papGray,
; cbPAPBase / sizeof (int));
;LN_FSetPapDiff takes an offset in di, cb in cx and performs
;FSetRgchDiff(pap+di, vpapFetch+di, papGray+di, cx);
;ax, bx, cx, dx, si, di are altered.
xor di,di
mov cx,cbPAPBase
call LN_FSetPapDiff
; /* also check in tab tables */
; FSetRgwDiff (pap.rgdxaTab, vpapFetch.rgdxaTab,
; papGray.rgdxaTab, pap.itbdMac);
; /* note chars, not words here */
;LN_FSetPapDiff takes an offset in di, cb in cx and performs
;FSetRgchDiff(pap+di, vpapFetch+di, papGray+di, cx);
;ax, bx, cx, dx, si, di are altered.
mov di,(rgdxaTabPap)
mov cx,[pap.itbdMacPap]
shl cx,1
call LN_FSetPapDiff
; FSetRgchDiff (pap.rgtbd, vpapFetch.rgtbd,
; papGray.rgtbd, pap.itbdMac);
;LN_FSetPapDiff takes an offset in di, cb in cx and performs
;FSetRgchDiff(pap+di, vpapFetch+di, papGray+di, cx);
;ax, bx, cx, dx, si, di are altered.
mov di,(rgtbdPap)
mov cx,[pap.itbdMacPap]
call LN_FSetPapDiff
FGPS093:
pop bx
pop cx ;restore cpT
pop ax
pop dx ;restore cpLimT
; }
; }
jmp FGPS08
FGPS095:
; cpNext = (!fCol) ? caPara.cpLim : caTap.cpLim;
mov si,dataoffset [caPara.LO_cpLimCa]
cmp bptr ([skVar]),skColumn SHL ibitSkSel
jne FGPS10
mov si,dataoffset [caTap.LO_cpLimCa]
FGPS10:
push ds
pop es
lea di,[cpNext]
movsw
movsw
; }
jmp FGPS06
FGPS12:
; /* if we ran out, say everything is gray */
; if (!fAll && cpara > cparaMax)
;Assembler note: we keep !fAll in the high byte of cpara so
;that (fAll || (cpara <= cparaMax)) is really performed as
;!(((!fAll << 8) + cpara) > (fTrue << 8) + cparaMax).
push ds
pop es
mov di,dataoffset [vpapGraySelCur]
mov cx,cbPapMin SHR 1
lea si,[papGray]
errnz <(cparaMax+1) AND 0FF00h>
cmp [cpara],(fTrue SHL 8) + cparaMax
jbe FGPS13
; SetWords(&vpapGraySelCur, 0xFFFF, cwPAP);
mov ax,0ffffh
rep stosw
db 03Dh ;turns next "rep movsw" into "cmp ax,immediate"
FGPS13:
; else /* normal finish */
; blt(&papGray, &vpapGraySelCur, cwPAP);
rep movsw
; blt(&pap, &vpapSelCur, cwPAP);
lea si,[pap]
mov di,dataoffset [vpapSelCur]
mov cx,cbPapMin SHR 1
rep movsw
;
; selCur.fUpdatePap = fFalse;
and [selCur.fUpdatePapSel],NOT maskfUpdatePapSel
; /* if someone besides the ruler called me, set this to
; ensure ruler update at idle */
; selCur.fUpdateRuler = fTrue;
or [selCur.fUpdateRulerSel],maskfUpdateRulerSel
; #ifdef DEBUG /* save selection range and ww for CkLHRUpd debug test */
ifdef DEBUG
; {
; extern struct CA vcaLHRUpd;
; extern int vwwLHRUpd; /* window where selection is shown */
;
; vcaLHRUpd = selCur.ca;
mov si,dataoffset [selCur.caSel]
mov di,dataoffset [vcaLHRUpd]
mov cx,cbCaMin SHR 1
rep movsw
; vwwLHRUpd = selCur.ww;
mov ax,[selCur.wwSel]
mov [vwwLHRUpd],ax
; }
; #endif
endif
; return (fTrue);
FGPS14:
db 0B8h ;turns next "xor ax,ax" into "mov ax,immediate"
FGPS15:
errnz <fFalse>
xor ax,ax
; }
cEnd
;LN_FSetPapDiff takes an offset in di, cb in cx and performs
;FSetRgchDiff(pap+di, vpapFetch+di, papGray+di, cx);
;ax, bx, cx, dx, si, di are altered.
LN_FSetPapDiff:
lea si,[pap+di]
lea bx,[papGray+di]
add di,dataoffset [vpapFetch]
cCall FSetRgchDiff,<si, di, bx, cx>
ret
sEnd fetch2
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+970
View File
@@ -0,0 +1,970 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg fetchtb_PCODE,fetchtbn,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midFetchtbn equ 27 ; module ID, for native asserts
endif
;ifndef NotNatPause
;macro PAUSE
;int 3
;endm
;else
;macro PAUSE
;endm
;endif
; EXTERNAL FUNCTIONS
externFP <FInCa>
externFP <N_WidthHeightFromBrc>
ifdef DEBUG
externFP <AssertProcForNative>
externFP <S_WidthHeightFromBrc>
externFP <S_ItcGetTcx>
endif ; DEBUG
sBegin data
;
; /* E X T E R N A L S */
;
externW vhgrpchr ; extern struct CHR **vhgrpchr;
externW vtcxs ; extern TCXS vtcxs;
externW vfti ; extern FTI vfti;
externW caTap ; extern CA caTap;
externW vtapFetch ; extern TAP vtapFetch;
sEnd data
; CODE SEGMENT _FETCHTBN
sBegin fetchtbn
assumes cs,fetchtbn
assumes ds,dgroup
assumes ss,dgroup
; %%Function:ItcGetTcxCache %%Owner:tomsax
cProc N_ItcGetTcxCache,<PUBLIC,FAR>,<si,di>
ParmW ww
ParmW doc
ParmD cp
ParmW ptap
ParmW itc
ParmW ptcx
LocalW fCache
LocalW itcNext
LocalW itcxc
cBegin
; int 3 ; PAUSE
; fCache = ww != wwNil;
errnz wwNil
mov ax,[ww]
mov [fCache],ax
; if (!FInCa(doc, cp, &vtcxs.ca)
push [doc]
push [SEG_cp]
push [OFF_cp]
mov ax,dataoffset [vtcxs.caTcxs]
push ax
cCall FInCa,<>
xchg ax,cx
jcxz LNotInCache
; || vtcxs.grpfTap != ptap->grpfTap
; int 3 ; PAUSE
mov bx,dataoffset [vtcxs]
mov si,[ptap]
mov ax,[bx.grpfTapTcxs]
cmp ax,[si.grpfTap]
jne LNotInCache
; WIN(|| vtcxs.dxpInch != ww))
mov ax,[vfti.dxpInchFti]
cmp ax,[bx.dxpInchTcxs]
je LInCache
LNotInCache:
; if (!fCache
; int 3 ; PAUSE
mov cx,[fCache]
jcxz LCalcTcx
; || !FInCa(doc, cp, &caTap)
; fCache = fFalse;
; int 3 ; PAUSE
push [doc]
push [SEG_cp]
push [OFF_cp]
mov ax,dataoffset [caTap]
push ax
cCall FInCa,<>
xchg ax,cx
mov [fCache],cx ; set fCache to FInCa(...)
jcxz LCalcTcx
; else
; for (itcxc = 0; itcxc < itcxcMax; itcxc++)
; vtcxs.rgtcxc[itcxc].fValid = fFalse;
; int 3 ; PAUSE
push ds
pop es
mov bx,dataoffset [vtcxs]
mov cx,itcxcMax ; count down for efficiency
mov di,dataoffset [vtcxs.rgtcxcTcxs.fValidTcxc]
xor ax,ax
LClearFValid:
stosw
add di,cbTcxcMin-2
loop LClearFValid
; vtcxs.ca = caTap;
mov si,dataoffset [caTap]
mov di,dataoffset [vtcxs.caTcxs]
errnz <cbCaMin and 1>
mov cx,cbCaMin SHR 1
rep movsw
; vtcxs.grpfTap = vtapFetch.grpfTap;
mov ax,[vtapFetch.grpfTap]
mov [bx.grpfTapTcxs],ax
; Win(vtcxs.dxpInch = vfti.dxpInch;)
mov ax,[vfti.dxpInchFti]
mov [bx.dxpInchTcxs],ax
jmp short LCalcTcx
LInCache:
; int 3 ; PAUSE
; else if (itc < itcxcMax)
cmp [itc],itcxcMax
jge LCalcTcx
; && vtcxs.rgtcxc[itc].fValid)
lea si,[bx.rgtcxcTcxs]
mov ax,cbTcxcMin
mul [itc]
add si,ax
mov cx,[si.fValidTcxc]
jcxz LCalcTcx
; int 3 ; PAUSE
; blt(&vtcxs.rgtcxc[itc], ptcx, sizeof(TCX));
mov ax,[si.itcNextTcxc] ; return value = vtcxs.rgtcxc[itc].itcNext
add si,tcxTcxc
mov di,[ptcx]
errnz <cbTcxMin and 1>
mov cx,cbTcxMin SHR 1
push ds
pop es
rep movsw
jmp short LExitIGC
LCalcTcx:
; int 3 ; PAUSE
mov di,[ww]
mov si,[ptcx]
push di
push [ptap]
push [itc]
push si
ifdef DEBUG
cCall S_ItcGetTcx,<>
else ;not DEBUG
push cs
call near ptr N_ItcGetTcx
endif ;DEBUG
; ax = itcNext
; if (fCache
; int 3 ; PAUSE
mov cx,[fCache]
jcxz LExitIGC
; int 3 ; PAUSE
; && itc < itcxcMax)
cmp [itc],itcxcMax
jge LExitIGC
; int 3 ; PAUSE
push ax ; save itcNext
; blt(ptcx, &vtcxs.rgtcxc[itc].tcx, sizeof(TCX);
; si = ptcx from above
mov di,dataoffset [vtcxs.rgtcxcTcxs.tcxTcxc]
mov ax,cbTcxcMin
mul [itc]
add di,ax
; before the blt, do:
; vtcxs.rgtcxc[itc].itcNext = itcNext;
; vtcxs.rgtcxc[itc].itcNext = fTrue;
pop ax
mov [di.itcNextTcxc-(tcxTcxc)],ax
mov [di.fValidTcxc-(tcxTcxc)],fTrue
errnz <cbTcxMin and 1>
mov cx,cbTcxMin SHR 1
push ds
pop es
rep movsw
LExitIGC:
; return ax = itcNext;
cEnd
;End of ItcGetTcxCache
; #define dxpTtpDr (8*dxpBorderFti)
dxpTtpDrFti equ 8
; NATIVE ItcGetTcx ( ww, ptap, itc, ptcx )
; struct TAP *ptap;
; struct TCX *ptcx;
; {
; struct WWD *pwwd;
; int itcMac;
; int xaFirst, xaLim;
; int itcNext;
; int dxa, dxp; ; native note: these are done with registers
; %%Function:ItcGetTcx %%Owner:tomsax
cProc N_ItcGetTcx,<PUBLIC,FAR>,<si,di>
ParmW ww
ParmW ptap
ParmW itc
ParmW ptcx
LocalW pwwd
LocalW itcMac
LocalW xaFirst
LocalW xaLim
LocalW itcNext
ifdef DEBUG
LocalW fRestarted
endif ; DEBUG
cBegin
; int 3 ; PAUSE
; Debug ( BOOL fRestarted = fFalse; )
ifdef DEBUG
mov [fRestarted],0
endif ; DEBUG
; LRestart:
; Assert ( 0 <= itc && itc <= ptap->itcMac );
mov bx,[ptap]
mov si,[ptcx]
LRestart:
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,[itc]
cmp ax,0
jl IG010
cmp ax,[bx.itcMacTap]
jle IG020
IG010:
mov ax,midFetchtbn
mov bx,241
cCall AssertProcForNative,<ax,bx>
IG020:
pop dx
pop cx
pop bx
pop ax
endif ; DEBUG
; itcMac = ptap->itcMac;
mov ax,[bx.itcMacTap]
mov [itcMac],ax
; xaFirst = ptap->rgdxaCenter[itc];
; itcNext = itc + 1;
lea di,[bx.rgdxaCenterTap]
mov cx,[itc]
mov [itcNext],cx
inc [itcNext]
shl cx,1
add di,cx
mov ax,[di]
mov [xaFirst],ax
; if (itc == itcMac)
; {
; int 3 ; PAUSE
mov di,[itc]
cmp di,[itcMac]
jne LCheckFirstMerged
; /* handle the fTtp cell */
; Assert(itc > 0);
; int 3 ; PAUSE
ifdef DEBUG
push ax
push bx
push cx
push dx
or dx,dx
jge IG030
mov ax,midFetchtbn
mov bx,267
cCall AssertProcForNative,<ax,bx>
IG030:
pop dx
pop cx
pop bx
pop ax
endif ; DEBUG
; ptcx->brcLeft = ptap->rgtc[itc-1].brcRight;
; ptcx->brcRight =
; ptcx->brcTop =
; ptcx->brcBottom = brcNil;
;
; bx = ptap, di = itc
errnz <rgbrcTcx-brcLeftTcx>
errnz <brcLeftTcx+2-brcTopTcx>
errnz <brcTopTcx+2-brcBottomTcx>
errnz <brcBottomTcx+2-brcRightTcx>
mov ax,cbTcMin
mul di
xchg ax,di
mov ax,[bx.di.rgtcTap.brcRightTc-cbTcMin]
push ds
pop es
lea di,[si.rgbrcTcx]
stosw
mov ax,brcNil
stosw
stosw
stosw
; if (ww == wwNil)
; return itcNext;
errnz <wwNil>
mov cx,[ww]
jcxz LTempExitIG
; xaLim = xaFirst+DxaFromDxp(PwwdWw(ww),dxpTtpDr+1+DxFromBrc(ptcx->brcLeft,fTrue)/2);
;copy macro defn here
mov ax,[si.brcLeftTcx]
call near ptr Loc_DxFromBrcFTrue
shr ax,1 ; DxFromBrc/2
mov dx,[vfti.dxpBorderFti]
errnz <dxpTtpDrFti-8>
mov cl,3
shl dx,cl
add ax,dx
inc ax
call near ptr Loc_DxaFromDxp
add ax,[xaFirst]
mov [xaLim],ax
; goto LCalcCellSize; /* skip around border calculation */
; }
jmp LCalcCellSize
; else if ( ptap->rgtc[itc].fFirstMerged )
; {
LCheckFirstMerged:
; bx = ptap, di = itc
mov ax,cbTcMin
mul di
xchg ax,di
test [bx.di.rgtcTap.fFirstMergedTc],maskFFirstMergedTc
je LCheckMerged
; /* the first in a merged series */
; while ( itcNext < itcMac && ptap->rgtc[itcNext].fMerged )
; itcNext++;
; }
;
; native note: the next clever little block assumes that itcNext == itc+1
; and that itc < itcMac
; int 3 ; PAUSE
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,[itc]
inc ax
cmp ax,[itcNext]
jnz IG040
mov ax,[itc]
cmp ax,[itcMac]
jl IG050
IG040:
mov ax,midFetchtbn
mov bx,392
cCall AssertProcForNative,<ax,bx>
IG050:
pop dx
pop cx
pop bx
pop ax
endif ; DEBUG
; bx = ptap, di = itc*cbTcMin
lea di,[bx.di.rgtcTap.fMergedTc]
mov cx,[itcMac]
sub cx,[itc]
; cx == 0 impossible by above assert
ifdef DEBUG
jle IG040 ; make damn sure...
endif ; DEBUG
push ds
pop es
LWhileMerged:
; note this loop can read rgtc[itcMac], but falls through on
; cx == 0 regardless of the random value read.
add di,cbTcMin
test bptr [di],maskFMergedTc
loopne LWhileMerged
sub cx,[itcMac]
neg cx
mov [itcNext],cx
jmp short LSetXaLim
; native note: this allows guys in the neighborhood to do
; short jumps to LRetIG
LTempExitIG:
jmp LRetIG
; else if ( ptap->rgtc[itc].fMerged )
LCheckMerged:
; bx = ptap, di = itc*cbTcMin
test [bx.di.rgtcTap.fMergedTc],maskFMergedTc
jz LSetXaLim
; {
; /* a cell in the middle of merged series, doesn't get displayed */
; xaLim = xaFirst;
; int 3 ; PAUSE
mov ax,[xaFirst]
mov [xaLim],ax
; ptcx->brcTop = ptcx->brcBottom = ptcx->brcLeft = ptcx->brcRight = brcNone;
errnz <rgbrcTcx-brcLeftTcx>
errnz <brcLeftTcx+2-brcTopTcx>
errnz <brcTopTcx+2-brcBottomTcx>
errnz <brcBottomTcx+2-brcRightTcx>
lea di,[si.rgbrcTcx]
mov ax,brcNone
push ds
pop es
stosw
stosw
stosw
stosw
jmp short LCalcCellSize
; goto LCalcCellSize; /* skip around border calculation */
; }
; xaLim = ptap->rgdxaCenter[itcNext];
LSetXaLim:
; bx = ptap
; int 3 ; PAUSE
mov di,[itcNext]
shl di,1
mov ax,[bx.di.rgdxaCenterTap]
mov [xaLim],ax
; /* Get the various border codes.
; /**/
mov ax,cbTcMin
mul [itc]
xchg ax,di
; ptcx->brcTop = ptap->rgtc[itc].brcTop;
; bx = ptap, di = itcNext*cbTcMin
mov cx,[bx.di.rgtcTap.brcTopTc]
mov [si.brcTopTcx],cx
; ptcx->brcBottom = ptap->rgtc[itc].brcBottom;
; bx =ptap, si = ptcx, di = itc*cbTcMin
mov cx,[bx.di.rgtcTap.brcBottomTc]
mov [si.brcBottomTcx],cx
; if ( (ptcx->brcLeft = ptap->rgtc[itc].brcLeft) == brcNone)
; if (itc > 0)
mov cx,[bx.di.rgtcTap.brcLeftTc]
errnz <brcNone>
or di,di
jz LSetBrcLeft
or cx,cx
jnz LSetBrcLeft
; di = itc*cbTcMin
; ptcx->brcLeft = ptap->rgtc[itc-1].brcRight;
mov cx,[bx.di.rgtcTap.brcRightTc-cbTcMin]
LSetBrcLeft:
mov [si.brcLeftTcx],cx
; if (itcNext >= itcMac
mov ax,cbTcMin
mov di,[itcNext]
mul di
xchg ax,di
; assume we want rgtc[itcNext-1].brcRight
mov dx,[bx.di.rgtcTap.brcRightTc-cbTcMin]
cmp ax,[itcMac]
jge LSetBrcRight ; assumption wins
; || (ptcx->brcRight = ptap->rgtc[itcNext].brcLeft) == brcNone)
mov cx,[bx.di.rgtcTap.brcLeftTc]
jcxz LSetBrcRight
; int 3 ; PAUSE
mov dx,cx ; assumption failed, replace with rgtc[itcNext].brcLeft
; ptcx->brcRight = ptap->rgtc[itcNext-1].brcRight;
LSetBrcRight:
mov [si.brcRightTcx],dx
LCalcCellSize:
; if (ww == wwNil)
; return itcNext;
errnz <wwNil>
mov cx,[ww]
jcxz LTempExitIG ; which jumps to LExitIG
; /* Compute the xp's from the xa's. Note that here is where we make
; /* the adjustment for the user's justification code.
; /**/
; pwwd=PwwdWw(ww);
; native note: we don't really need the pwwd
; ptcx->xpCellLeft = DxpFromDxa(pwwd,xaFirst += ptap->dxaAdjust);
; ptcx->xpCellRight = DxpFromDxa(pwwd,xaLim += ptap->dxaAdjust);
; int 3 ; PAUSE
mov cx,[bx.dxaAdjustTap]
mov ax,[xaLim]
add ax,cx
mov [xaLim],ax
push ax ; save away...xaLim + ptap->dxaAdjust
mov ax,[xaFirst]
add ax,cx
mov [xaFirst],ax
call near ptr Loc_DxpFromDxa ; convert xaFirst + ptap->dxaAdjust
mov [si.xpCellLeftTcx],ax
pop ax
call near ptr Loc_DxpFromDxa ; convert xaFirst + ptap->dxaAdjust
mov [si.xpCellRightTcx],ax
; Assert (ptcx->xpCellLeft <= ptcx->xpCellRight);
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,[si.xpCellRightTcx]
cmp ax,[si.xpCellLeftTcx]
jge IG060
mov ax,midFetchtbn
mov bx,483
cCall AssertProcForNative,<ax,bx>
IG060:
pop dx
pop cx
pop bx
pop ax
endif ; DEBUG
; if (itc == itcMac)
mov di,[itc]
cmp di,[itcMac]
jne LMergedCellWidth
; {
; ptcx->xpDrLeft = (ptcx->xpDrRight = DxpFromDxa(pwwd,xaLim)) - dxpTtpDr;
; int 3 ; PAUSE
mov ax,[xaLim]
call near ptr Loc_DxpFromDxa
mov [si.xpDrRightTcx],ax
mov dx,[vfti.dxpBorderFti]
errnz <dxpTtpDrFti-8>
mov cl,3
sal dx,cl
sub ax,dx
mov [si.xpDrLeftTcx],ax
; Assert(ptcx->xpCellLeft+DxFromBrc(ptcx->brcLeft,fTrue)/2 <= ptcx->xpDrLeft);
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,[si.brcLeftTcx]
call near ptr Loc_DxFromBrcFTrue
sar ax,1
add ax,[si.xpCellLeftTcx]
cmp ax,[si.xpDrLeftTcx]
jle IG070
int 3 ; PAUSE
mov ax,midFetchtbn
mov bx,506
cCall AssertProcForNative,<ax,bx>
IG070:
pop dx
pop cx
pop bx
pop ax
endif ; DEBUG
jmp short LSetOutLeft
; }
; else
LMergedCellWidth:
; {
; if (ptap->rgtc[itc].fMerged)
; di = itc, bx = ptap
mov ax,cbTcMin
mul di
xchg ax,di
test [bx.di.rgtcTap.fMergedTc],maskFMergedTc
jz LNormalCellWidth
; {
; ptcx->xpDrLeft = ptcx->xpDrRight = ptcx->xpCellLeft;
; int 3 ; PAUSE
mov ax,[si.xpCellLeftTcx]
errnz <xpDrLeftTcx+2-xpDrRightTcx>
errnz <xpDrRightTcx+2-xpCellRightTcx>
lea di,[si.xpDrLeftTcx]
push ds
pop es
stosw ; ptcx->xpDrLeft =
stosw ; ptcx->xpDrRight =
errnz <xpDrRightTcx+2-xpCellRightTcx>
stosw ; skip over ptcx->xpCellRight = the same thing
; ptcx->dxpOutRight = ptcx->dxpOutLeft = 0;
errnz <xpCellRightTcx+2-dxpOutLeftTcx>
errnz <dxpOutLeftTcx+2-dxpOutRightTcx>
xor ax,ax
stosw
stosw
; goto LExit;
; }
jmp LExitIG
; ptcx->xpDrLeft = DxpFromDxa(pwwd,min(xaLim,xaFirst+ptap->dxaGapHalf));
; ptcx->xpDrRight = DxpFromDxa(pwwd,max(xaFirst,xaLim-ptap->dxaGapHalf));
LNormalCellWidth:
mov ax,[xaFirst]
add ax,[bx.dxaGapHalfTap]
cmp ax,[xaLim]
jle IG080
mov ax,[xaLim]
IG080:
call near ptr Loc_DxpFromDxa
mov [si.xpDrLeftTcx],ax
mov ax,[xaLim]
sub ax,[bx.dxaGapHalfTap]
cmp ax,[xaFirst]
jge IG090
mov ax,[xaFirst]
IG090:
call near ptr Loc_DxpFromDxa
mov [si.xpDrRightTcx],ax
; }
; /* NOTE - for the vertical stripes, we call DxFromBrc with
; /* fDrawDrs=fTrue so that we allocate room for frame lines. This
; /* assumes that dxaGap translates into at least one dxpBorderFti of gap.
; /* NOTE - Split the border down the rgdxaCenter lines so that uneven
; /* borders spill more over onto the left side, quantizing in dxpBorderFti
; /* units.
; /* CLEVERNESS WARNING: The trickery below assumes that
; /* DxFromBrc(brc,fTrue) returns either 1, 2, or 3 times dxpBorderFti.
; /**/
LSetOutLeft:
; ptcx->dxpOutLeft = ptcx->xpDrLeft - ptcx->xpCellLeft;
; if (DxFromBrc(ptcx->brcLeft,fTrue) > dxpBorderFti)
; ptcx->dxpOutLeft -= dxpBorderFti;
mov ax,[si.brcRightTcx]
call near ptr Loc_DxFromBrcFTrue
xchg ax,di ; save for later
mov ax,[si.brcLeftTcx]
call near ptr Loc_DxFromBrcFTrue
mov cx,[vfti.dxpBorderFti]
cmp ax,cx
jg IG100
xor cx,cx
IG100:
neg cx
add cx,[si.xpDrLeftTcx]
sub cx,[si.xpCellLeftTcx]
mov [si.dxpOutLeftTcx],cx
; if (itc < itcMac)
; bx = ptap, di = DxFromBrc(ptcx->brcRight, fTrue);
mov cx,[itc]
sub cx,[itcMac]
jz LSetDxpOutRight
; {
; int dxpT;
; dxpT = DxFromBrc(ptcx->brcRight,fTrue);
; native note: done above, in di
; ptcx->dxpOutRight = ptcx->xpCellRight - ptcx->xpDrRight - dxpT;
mov cx,[si.xpCellRightTcx]
sub cx,[si.xpDrRightTcx]
sub cx,di
; if (dxpT > dxpBorderFti)
; ptcx->dxpOutRight += dxpBorderFti;
cmp di,[vfti.dxpBorderFti]
jle LSetDxpOutRight
add cx,[vfti.dxpBorderFti]
; fall through to next line
; }
LSetDxpOutRight:
; else
; ptcx->dxpOutRight = 0;
mov [si.dxpOutRightTcx],cx
; /* If the user has created a cell without enough room to hold the
; /* border (or potential frame line), shrink the cell.
; /* If this action causes the cell width to become negative,
; /* adjust the tap to make room for a wider cell.
; /**/
;
; /* In order to maintain enough room to draw the borders, we must
; /* maintain the two quantities
; /* xpDrLeft - dxpOutLeft - xpCellLeft
; /* xpCellRight - (xpDrRight + dxpRight)
; /**/
; if (ptcx->dxpOutLeft < 0)
xor dx,dx
cmp [si.dxpOutLeftTcx],dx
jge LCheckOutRight
; {
; ptcx->xpDrLeft -= ptcx->dxpOutLeft;
; int 3 ; PAUSE
mov ax,[si.dxpOutLeftTcx]
sub [si.xpDrLeftTcx],ax
; ptcx->dxpOutLeft = 0;
mov [si.dxpOutLeftTcx],dx
; }
; if (ptcx->dxpOutRight < 0)
LCheckOutRight:
cmp [si.dxpOutRightTcx],dx
jge LCheckDrSides
; {
; ptcx->xpDrRight += ptcx->dxpOutRight;
; int 3 ; PAUSE
mov ax,[si.dxpOutRightTcx]
add [si.xpDrRightTcx],ax
; ptcx->dxpOutRight = 0;
mov [si.dxpOutRightTcx],dx
; }
; if ((dxp = ptcx->xpDrLeft - ptcx->xpDrRight) > 0)
LCheckDrSides:
mov ax,[si.xpDrLeftTcx]
sub ax,[si.xpDrRightTcx]
jle LExitIG
; {
; /* Add one to the adjustment so that dxa/dxp conversion
; /* roundoff can't hose things.
; /**/
; Assert(itc < itcMac);
; native note: for loop below Assert(itcNext <= itcMac);
; int 3 ; PAUSE
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,[itc]
cmp ax,[itcMac]
jge IG110
mov ax,[itcNext]
cmp ax,[itcMac]
jle IG115
IG110:
mov ax,midFetchtbn
mov bx,653
cCall AssertProcForNative,<ax,bx>
IG115:
pop dx
pop cx
pop bx
pop ax
endif ; DEBUG
; dxa = DxaFromDxp(pwwd,dxp+1);
; ax = dxp, bx = ptap
inc ax
call near ptr Loc_DxaFromDxp
; for ( ; itcNext <= itcMac; ++itcNext )
; ptap->rgdxaCenter[itcNext] += dxa;
; native note use "itcNext < itcMac" for term condition.
; ax = dxa
mov di,[itcNext]
mov cx,[itcMac]
sub cx,di
inc cx
ifdef DEBUG
jle IG110 ; Assert if (cx=itcMac+1-itcNext)<= 0
endif ; DEBUG
shl di,1
add di,rgdxaCenterTap
LAdjustRgdxa:
add [bx.di],ax
add di,2
loop LAdjustRgdxa
LAdjustEnd:
; Assert(!fRestarted); /* no infinite loops allowed */
ifdef DEBUG
push ax
push bx
push cx
push dx
mov cx,[fRestarted]
jcxz IG120
mov ax,midFetchtbn
mov bx,709
cCall AssertProcForNative,<ax,bx>
IG120:
pop dx
pop cx
pop bx
pop ax
; Debug ( fRestarted = fTrue; )
mov [fRestarted],fTrue
endif ; DEBUG
; /* it is now easier to re-compute with the adjusted TAP than to try
; /* to figure out how to adjust things correctly
; /**/
; goto LRestart;
; }
jmp LRestart
; LExit:
; Assert (ptcx->dxpOutLeft >= 0 && ptcx->dxpOutRight >= 0);
; Assert (ptcx->xpCellLeft <= ptcx->xpDrLeft - ptcx->dxpOutLeft);
; Assert (ptcx->xpDrLeft <= ptcx->xpDrRight);
; Assert (ptcx->xpDrRight + ptcx->dxpOutRight <= ptcx->xpCellRight);
LExitIG:
ifdef DEBUG
; Assert (ptcx->dxpOutLeft >= 0 && ptcx->dxpOutRight >= 0);
cmp [si.dxpOutLeftTcx],0
jl IG202
cmp [si.dxpOutRightTcx],0
jge IG204
IG202:
mov ax,midFetchtbn
mov bx,743
cCall AssertProcForNative,<ax,bx>
IG204:
; Assert (ptcx->xpCellLeft <= ptcx->xpDrLeft - ptcx->dxpOutLeft);
mov ax,[si.xpDrLeftTcx]
sub ax,[si.dxpOutLeftTcx]
cmp ax,[si.xpCellLeftTcx]
jge IG206
mov ax,midFetchtbn
mov bx,759
cCall AssertProcForNative,<ax,bx>
IG206:
; Assert (ptcx->xpDrLeft <= ptcx->xpDrRight);
mov ax,[si.xpDrRightTcx]
cmp ax,[si.xpDrLeftTcx]
jge IG208
mov ax,midFetchtbn
mov bx,815
cCall AssertProcForNative,<ax,bx>
IG208:
; Assert (ptcx->xpDrRight + ptcx->dxpOutRight <= ptcx->xpCellRight);
mov ax,[si.xpDrRightTcx]
add ax,[si.dxpOutRightTcx]
cmp ax,[si.xpCellRightTcx]
jle IG210
mov ax,midFetchtbn
mov bx,824
cCall AssertProcForNative,<ax,bx>
IG210:
endif ; DEBUG
LRetIG:
; return itcNext;
; }
mov ax,[itcNext]
cEnd
;End of ItcGetTcx
; Local Version of DxaFromDxp and DxpFromDxa
;
; ax = argument, dxa or dxp
; ax gets result, dxp or dxa
; only ax, cx, dx altered
Loc_DxaFromDxp:
db 0A8h ;turns next "stc" into "test al,immediate"
;also clears the carry flag
Loc_DxpFromDxa:
stc
mov cx,dxaInch
mov dx,[vfti.dxpInchFti]
; Assert(vfti.dxpInch != 0)
ifdef DEBUG
pushf
push ax
push bx
push cx
push dx
or dx,dx
jnz IG300
mov ax,midFetchtbn
mov bx,871
cCall AssertProcForNative,<ax,bx>
IG300:
pop dx
pop cx
pop bx
pop ax
popf
endif ; DEBUG
jc IG305
xchg cx,dx
IG305:
push ax ; save the numerator
or ax,ax ; is it negative?
jns IG310
neg ax
IG310:
mul dx ; do the multiply
push cx ; save the denominator
shr cx,1 ; get half of the demoninator to adjust for rounding
add ax,cx ; adjust for possible rounding error
adc dx,0 ; this is really a long addition
pop cx ; restore the demoninator
div cx ; divide
pop cx
or cx,cx ; restore the sign
jns IG315
neg ax
IG315:
ret
; Local Version of DxFromBrc(brc, fTrue)
;
; #define DxFromBrc(brc, fFrameLines) DxyFromBrc(brc, fFrameLines, fTrue)
; #define DxyFromBrc(brc, fFrameLines, fWidth) \
; WidthHeightFromBrc(brc, fFrameLines, fWidth, fFalse)
;
; ax = brc
; ax gets result, dxp or dxa
; only ax, cx, dx, es altered
Loc_DxFromBrcFTrue:
push bx
push ax
mov ax,3
push ax
ifdef DEBUG
cCall S_WidthHeightFromBrc,<>
else ;not DEBUG
cCall N_WidthHeightFromBrc,<>
endif ;DEBUG
pop bx
ret
sEnd fetchtbn
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+418
View File
@@ -0,0 +1,418 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg fieldsp_PCODE,fieldspn,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midFieldspn equ 23 ; module ID, for native asserts
endif ;DEBUG
; EXPORTED LABELS
; EXTERNAL FUNCTIONS
externFP <N_QcpQfooPlcfoo>
externFP <N_PdodDoc>
externFP <CompletelyAdjustHplcCps>
ifdef DEBUG
externFP <AssertProcForNative>
endif ;DEBUG
; EXTERNAL DATA
sBegin data
externW mpdochdod ;extern struct DOD **mpdochdod[];
ifdef DEBUG
externW mpsbps ;extern SB mpsbps[];
endif ;DEBUG
sEnd data
; CODE SEGMENT fieldspn_PCODE
sBegin fieldspn
assumes cs,fieldspn
assumes ds,dgroup
assume es:nothing
assume ss:nothing
;-------------------------------------------------------------------------
; FFillRgwWithSeqLevs(doc, cp, ipad, ifld, hplcpad, hplcfld, rgw)
;-------------------------------------------------------------------------
;NATIVE FFillRgwWithSeqLevs(doc, cp, ipad, ifld, hplcpad, hplcfld, rgw)
;int doc;
;CP cp;
;int ipad;
;int ifld;
;struct PLC **hplcpad;
;struct PLC **hplcfld;
;int *rgw;
;{
; CP cpCur;
; int ipadMac = IMacPlc(hplcpad);
; int ifldMac = IMacPlc(hplcfld);
; struct PAD pad;
; struct FLD fld;
; %%Function:N_FFillRgwWithSeqLevs %%Owner:BRADV
cProc N_FFillRgwWithSeqLevs,<PUBLIC,FAR>,<si,di>
ParmW doc
ParmD cp
ParmW ipad
ParmW ifld
ParmW hplcpad
ParmW hplcfld
ParmW rgw
LocalW LO_qPad
cBegin
;Assembler note: Since we may be running through the entire
;plc anyway, let's unwind the lazy plc optimization and speed
;up the rest of the code.
cCall CompletelyAdjustHplcCps,<[hplcpad]>
cCall CompletelyAdjustHplcCps,<[hplcfld]>
; It is possible that the call later on to QcpQfooPlcfoo for hplcpad
; would force out the sb for hplcfld. This would happen if now
; sbFld was oldest on the LRU list but still swapped in, and sbPad
; was swapped out. In that event ReloadSb would not be called for
; sbFld, the LRU entry would not get updated, and the call to ReloadSb
; for sbPad would swap out sbFld.
; This call to QcpQfooPlcfoo makes that state impossible and so works
; around the LMEM quirk.
; QcpQfooPlcfoo takes hplcfoo in bx, ifoo in si, it returns pplcfoo
; in bx, cbfoo in cx, qcp in es:di, qfoo in es:si.
; if DEBUG it returns hpcp in dx:di, hpfoo in dx:si.
; Changes ax, bx, cx, dx, si, di.
mov bx,[hplcpad]
xor si,si
ifdef DEBUG
mov di,1 ;O.K. to pass ifldMac
endif ;DEBUG
cCall N_QcpQfooPlcfoo,<>
ifdef DEBUG
;Check that es == mpsbps[dx];
call FRWSL13
endif ;DEBUG
; QcpQfooPlcfoo takes hplcfoo in bx, ifoo in si, it returns pplcfoo
; in bx, cbfoo in cx, qcp in es:di, qfoo in es:si.
; if DEBUG it returns hpcp in dx:di, hpfoo in dx:si.
; Changes ax, bx, cx, dx, si, di.
mov bx,[hplcfld]
mov si,[ifld]
ifdef DEBUG
mov di,1 ;O.K. to pass ifldMac
endif ;DEBUG
cCall N_QcpQfooPlcfoo,<>
push es ;save LO_qcpFld
push si ;save HI_qFld
push di ;save HI_qcpFld
ifdef DEBUG
;Check that es == mpsbps[dx];
call FRWSL13
endif ;DEBUG
mov ax,[bx.iMacPlcStr]
neg ax
add [ifld],ax ;ifld now really contains ifld - (*hplcfld)->iMac
; QcpQfooPlcfoo takes hplcfoo in bx, ifoo in si, it returns pplcfoo
; in bx, cbfoo in cx, qcp in es:di, qfoo in es:si.
; if DEBUG it returns hpcp in dx:di, hpfoo in dx:si.
; Changes ax, bx, cx, dx, si, di.
mov bx,[hplcpad]
mov si,[ipad]
ifdef DEBUG
mov di,1 ;O.K. to pass ifldMac
endif ;DEBUG
cCall N_QcpQfooPlcfoo,<>
ifdef DEBUG
;Check that es == mpsbps[dx];
call FRWSL13
endif ;DEBUG
mov ax,[bx.iMacPlcStr]
neg ax
add [ipad],ax ;ipad now really contains ipad - (*hplcpad)->iMac
mov [LO_qPad],si
pop bx ;restore HI_qcpFld
pop si ;restore HI_qFld
pop ds ;restore LO_qcpFld
;ds:si = qFld, ds:bx = qcpFld, es:[LO_qPad] = qPad, es:di = qcpPad
; cpCur = CpPlc(hplcpad, ipad);
mov cx,es:[di]
mov dx,es:[di+2]
; while (ipad < ipadMac && cpCur <= cp)
; {
FRWSL01:
cmp [ipad],0 ;really contains ipad - (*hplcpad)->iMac
jge FRWSL015
cmp [OFF_cp],cx
mov ax,[SEG_cp]
sbb ax,dx
jl FRWSL015
; while (ifld < ifldMac && CpPlc(hplcfld, ifld) < cpCur)
; /* advance to this para */
; ifld++;
dec [ifld] ;cancel following inc [ifld]
jmp short FRWSL03
FRWSL015:
push ss
pop ds ;restore ds
stc ;return fTrue
jmp FRWSL10
;dx:cx = cpCur, ds:si = qFld, ds:bx = qcpFld,
;es:[LO_qPad] = qPad, es:di = qcpPad
FRWSL02:
errnz <cbFldMin - 2>
inc si
inc si
add bx,4
FRWSL03:
inc [ifld] ;really contains ifld - (*hplcfld)->iMac
jge FRWSL04
cmp [bx],cx
mov ax,[bx+2]
sbb ax,dx
jl FRWSL02
FRWSL04:
; cpCur = CpPlc(hplcpad, ipad+1);
;ipad++ is done below in the C version.
;dx:cx = cpCur, ds:si = qFld, ds:bx = qcpFld,
;es:[LO_qPad] = qPad, es:di = qcpPad
inc [ipad] ;really contains ipad - (*hplcpad)->iMac
add [LO_qPad],cbPadMin
add di,4
mov cx,es:[di]
mov dx,es:[di+2]
; while (ifld < ifldMac && CpPlc(hplcfld, ifld) < cpCur)
; {
; GetPlc(hplcfld, ifld++, &fld);
; if (fld.ch == chFieldBegin &&
; (uns)(fld.flt-fltSeqLevOut)<=(fltSeqLevNum - fltSeqLevOut))
; /* this para does have an auto number, count it */
; {
FRWSL05:
cmp [ifld],0 ;really contains ifld - (*hplcfld)->iMac
jge FRWSL01
cmp [bx],cx
mov ax,[bx+2]
sbb ax,dx
jge FRWSL01
inc [ifld] ;really contains ifld - (*hplcfld)->iMac
errnz <cbFldMin - 2>
lodsw
add bx,4
errnz <(chFld) - 0>
errnz <(fltFld) - 1>
and al,maskChFld
ifdef DEBUG
;Make sure we don't carry from al to ah when doing the following
;subtract.
call FRWSL16
endif ;DEBUG
sub ax,(fltSeqLevOut SHL 8) + chFieldBegin
xchg al,ah
cmp ax,fltSeqLevNum - fltSeqLevOut
ja FRWSL05
; GetPlc (hplcpad, ipad, &pad);
;dx:cx = cpCur, ds:si = qFld, ds:bx = qcpFld,
;es:[LO_qPad] = qPad, es:di = qcpPad
; if (pad.lvl == lvlUpdate)
; {
; Assert(fFalse);
; PdodDoc(doc)->fOutlineDirty = fTrue;
; return fFalse;
; }
xchg bx,[LO_qPad]
mov al,es:[bx.lvlPad - cbPadMin]
xchg bx,[LO_qPad]
mov ah,al
and al,maskLvlPad
errnz <maskLvlPad - 0F0h>
cmp al,lvlUpdate SHL 4
je FRWSL08
; if (!pad.fBody && !pad.fInTable)
; {
;dx:cx = cpCur, ds:si = qFld, ds:bx = qcpFld,
;es:[LO_qPad] = qPad, es:di = qcpPad
push bx ;save LO_qcpFld
mov bx,lvlBody SHL 1
and ah,maskFBodyPad + maskFInTablePad
jne FRWSL07
; Assert (pad.lvl < lvlBody && pad.lvl >= 0);
ifdef DEBUG
;Do this assert with a call so as not to mess up short jumps
call FRWSL11
endif ;/* DEBUG */
; rgw [pad.lvl]++;
; SetWords (rgw + pad.lvl + 1, 0, lvlBody - pad.lvl);
; }
push cx ;save LO_cpCur
push di ;save LO_qcpPad
push es ;save HI_qcpPad
errnz <maskLvlPad - 0F0h>
mov cl,3
shr al,cl
sub bx,ax
mov cx,bx
shr cx,1
mov di,[rgw]
xchg ax,bx
lea di,[bx+di+2]
xor ax,ax
push ss
pop es
rep stosw
pop es ;restore HI_qcpPad
pop di ;restore LO_qcpPad
pop cx ;restore LO_cpCur
; else
; rgw [lvlBody]++;
; break;
FRWSL07:
add bx,[rgw]
inc wptr ss:[bx]
pop bx ;restore LO_qcpFld
jmp FRWSL01
; }
; }
;ipad++ is done above in the assembler version.
; ipad++;
; }
FRWSL08:
push ss
pop ds
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,midFieldspn
mov bx,1002
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
endif ;/* DEBUG */
cCall N_PdodDoc,<[doc]>
xchg ax,bx
or [bx.fOutlineDirtyDod],maskFOutlineDirtyDod
;Note that the preceding "or" clears the carry flag
FRWSL10:
; return fTrue;
sbb ax,ax
;}
cEnd
ifdef DEBUG
FRWSL11:
cmp al,lvlBody SHL 4
jb FRWSL12
push ax
push bx
push cx
push dx
push ds
push ss
pop ds
mov ax,midFieldspn
mov bx,1001
cCall AssertProcForNative,<ax,bx>
pop ds
pop dx
pop cx
pop bx
pop ax
FRWSL12:
ret
endif ;/* DEBUG */
ifdef DEBUG
FRWSL13:
push ax
push bx
push cx
push dx
push es ;save es from QcpQfooPlcfoo
mov bx,dx
shl bx,1
mov ax,mpsbps[bx]
mov es,ax
shr ax,1
jc FRWSL14
;Assembler note: There is no way we should have to call ReloadSb here.
; reload sb trashes ax, cx, and dx
; cCall ReloadSb,<>
mov ax,midFieldspn
mov bx,1003
cCall AssertProcForNative,<ax,bx>
FRWSL14:
pop ax ;restore es from QcpQfooPlcfoo
mov bx,es ;compare with es rederived from the SB of QcpQfooPlcfoo
cmp ax,bx
je FRWSL15
mov ax,midFieldspn
mov bx,1004
cCall AssertProcForNative,<ax,bx>
FRWSL15:
pop dx
pop cx
pop bx
pop ax
ret
endif ;/* DEBUG */
ifdef DEBUG
FRWSL16:
cmp al,chFieldBegin
jae FRWSL17
push ax
push bx
push cx
push dx
push ss
pop ds
mov ax,midFieldspn
mov bx,1005
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
FRWSL17:
ret
endif ;/* DEBUG */
sEnd fieldspn_PCODE
end
File diff suppressed because it is too large Load Diff
+787
View File
@@ -0,0 +1,787 @@
; FILEWINN.ASM
; Core native file routines
; =====================================================================
; This file contains DOS access routines.
; These routines are general, simple calls to DOS and
; are likely to be generally useful. They assume /PLM calling
; is used.
; FAR calls are used throughout
;
;
; NOTE: DOSLIB.H CONTAINS A C HEADER DEFINING THE FUNCTIONS IN THIS
; MODULE. IT MUST BE UPDATED WHENEVER A FUNCTION IS ADDED OR AN INTERFACE
; CHANGES
; =====================================================================
.xlist
memS = 1
?WIN = 1
?PLM = 1
?NODATA = 1
?TF = 1
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
ifdef PMWORD
INCL_DOSERRORS = 1
include bseerr.inc
include pmword.inc
endif
.list
; CODE IN THIS MODULE IS APPENDED TO THE PCODE SEGMENT FOR FILEWIN.C
ifdef TESTCODE ; for PMWORD
createSeg _TEXT,filewin,byte,public,CODE
else
createSeg filewin_PCODE,filewin,byte,public,CODE
endif
; DEBUGGING DECLARATIONS
ifdef DEBUG
midFilewinn equ 20 ; module ID, for native asserts
endif
; EXPORTED LABELS
; EXTERNAL FUNCTIONS
ifndef TESTCODE
externFP <ReloadSb>
externFP <ErrorEidProc>
endif
ifdef PMWORD
externFP DosClose
externFP DosRead
externFP DosWrite
externFP DosChgFilePtr
externFP DosGetDateTime
endif
ifdef DEBUG
ifndef TESTCODE
externFP <AssertProcForNative>
endif
endif
; EXTERNAL DATA
sBegin data
ifndef TESTCODE
externW vbptbExt ; extern struct BPTB vbptbExt;
externW vmerr ; extern struct MERR vmerr;
externW vfScratchFile ; extern BOOL vfScratchFile;
externW vibpProtect ; extern int vibpProtect;
externW mpsbps ; extern SB mpsbps[];
endif
sEnd data
; CODE SEGMENT FILEWIN
sBegin filewin
assumes cs,filewin
assumes ds,dgroup
assumes ss,dgroup
ifdef ENABLE ; we use OpenFile instead
;-----------------------------------------------------------------------------
; unsigned FAR WOpenSzFfname( szFfname, openmode )
; PSTR szFfname; int openmode;
;
; Open specified file in specified mode, return a handle or
; the negative of an error code if the open failed
;-----------------------------------------------------------------------------
; %%Function:WOpenSzFfname %%Owner:peterj
cProc WOpenSzFfname, <FAR, PUBLIC>
parmDP <szFfname>
parmB <openmode>
cBegin WOpenSzFfname
mov dx,szFfname
mov al,openmode
mov ah,3dh
int 21h
jnc osfdone
neg ax ; error - return the negative of the error code
osfdone:
cEnd WOpenSzFfname
endif
;-----------------------------------------------------------------------------
; int FAR FCloseDoshnd( doshnd )
;
; Close file given DOS handle, return 0 = error, nonzero = no error
;-----------------------------------------------------------------------------
; %%Function:FCloseDoshnd %%Owner:peterj
cProc FCloseDoshnd, <FAR, PUBLIC>,<si,di>
parmW <doshnd>
cBegin FCloseDoshnd
ifndef PMWORD
mov bx,doshnd
mov ah,3eh
int 21h
mov ax,0000
jc cdhskip ; error, leave a zero in ax
inc ax
else ; PMWORD
cCall DosClose, <doshnd>
or ax, ax
mov ax, 0
jnz cdhskip
inc ax
endif ; PMWORD
cdhskip:
cEnd FCloseDoshnd
;-----------------------------------------------------------------------------
; int CchReadDoshnd ( doshnd, lpchBuffer, bytes )
;
; Read bytes from an open file, place into buffer
; Returns # of bytes read (should be == bytes unless EOF or error)
; If an error occurs, returns the negative of the error code
;-----------------------------------------------------------------------------
; %%Function:CchReadDoshnd %%Owner:peterj
cProc CchReadDoshnd, <FAR, PUBLIC>, <DS,SI,DI>
parmW <doshnd>
parmD <lpchBuffer>
parmW <bytes>
ifdef PMWORD
localW bytesRead
endif ;PMWORD
cBegin CchReadDoshnd
ifndef PMWORD
mov bx,doshnd
lds dx,lpchBuffer
mov cx,bytes
mov ah,3fh
int 21h
jnc crdone
neg ax ; error - return value is the negative of the error code
else ; PMWORD
lea ax, bytesRead
farPtr lpBytesRead, ds, ax
cCall DosRead, <doshnd, SEG_lpchBuffer, OFF_lpchBuffer, bytes, lpBytesRead>
or ax, ax
mov ax, bytesRead
jz crdone
mov ax, -ERROR_ACCESS_DENIED ; only error opus understands
endif ; PMWORD
crdone:
cEnd CchReadDoshnd
;-----------------------------------------------------------------------------
; int CchWriteDoshnd ( doshnd, lpchBuffer, bytes )
;
; Write bytes from an open file, place into buffer
; Returns # of bytes written (should be == bytes unless EOF or error)
; If an error occurs, returns the negative of the error code
; Disk full is not an "error"; detect it by return code != bytes
;-----------------------------------------------------------------------------
; %%Function:CchWriteDoshnd %%Owner:peterj
cProc CchWriteDoshnd, <FAR, PUBLIC>,<DS,SI,DI>
parmW <doshnd>
parmD <lpchBuffer>
parmW <bytes>
ifdef PMWORD
localW bytesWritten
endif ;PMWORD
cBegin CchWriteDoshnd
ifndef PMWORD
mov bx,doshnd
lds dx,lpchBuffer
mov cx,bytes
mov ah,40h
int 21h
jnc cwdone
neg ax ; error: return the negative of the error code
else ;PMWORD
lea ax, bytesWritten
farPtr lpBytesWritten, ds, ax
cCall DosWrite, <doshnd, SEG_lpchBuffer, OFF_lpchBuffer, bytes, lpBytesWritten>
or ax, ax
mov ax, bytesWritten
jz cwdone
mov ax, -ERROR_ACCESS_DENIED ; only error opus understands
endif ;PMWORD
cwdone:
cEnd CchWriteDoshnd
;-----------------------------------------------------------------------------
; long DwSeekDw ( doshnd, dwSeekpos, bSeekfrom )
;
; Seek to requested position in file
; bSeekfrom is: 0 = seek relative to beginning of file
; 1 = seek relative to current pointer location
; 2 = seek relative to end of file
;
; Returns the new location of the read/write pointer (a long)
; If an error occurs, returns the negative of the error code (long)
;-----------------------------------------------------------------------------
; %%Function:DwSeekDw %%Owner:peterj
cProc DwSeekDw, <FAR, PUBLIC>,<si,di>
parmW <doshnd>
parmD <dwSeekpos>
parmB <bSeekfrom>
ifdef PMWORD
localD <dwEndpos>
endif ; PMWORD
cBegin DwSeekDw
ifndef PMWORD
mov bx,doshnd
mov cx,SEG_dwSeekpos
mov dx,OFF_dwSeekpos
mov al,bSeekfrom
mov ah,42h
int 21h
jnc seekdone
neg ax ; Error: return the negative of the error code
mov dx,0ffffH
else ; PMWORD
lea ax, dwEndpos
farPtr lpEndpos, ds, ax
cCall DosChgFilePtr, <doshnd, SEG_dwSeekpos, OFF_dwSeekpos, bSeekfrom, lpEndpos>
or ax, ax
jz seekokay
neg ax
mov dx, 0ffffH
jmp short seekdone
seekokay:
mov ax, OFF_dwEndpos
mov dx, SEG_dwEndpos
endif ; PMWORD
seekdone:
cEnd DwSeekDw
;-----------------------------------------------------------------------------
; int FDoshndIsFile( doshnd ) - determines if doshnd is file or device
;
;-----------------------------------------------------------------------------
; %%Function:FDoshndIsFile %%Owner:peterj
cProc FDoshndIsFile, <FAR, PUBLIC>,<si,di>
parmW <doshnd>
cBegin FDoshndIsFile
mov bx,doshnd
mov ah,44h ; IOCTL Data
mov al,0 ; Get data
int 21h
; preset ax to fFalse
xor ax,ax
; carry set on error
jc FDIFno
; bit 7 of dx set for device
test dl,80h
jnz FDIFno
; it is a file
inc ax
FDIFno:
cEnd FDoshndIsFile
ifndef PMWORD
ifdef DEBUG
;-----------------------------------------------------------------------------
; void CommSzLib( sz ) - put out string to AUX device
; PSTR sz;
;
; For debugging
;-----------------------------------------------------------------------------
; %%Function:CommSzLib %%Owner:peterj
cProc CommSzLib, <FAR, PUBLIC>,<si,di>
parmDP <sz>
cBegin CommSzLib
CommSz1:
mov bx, sz ; if ((dl = *(sz++)) == 0) goto CommSz2
inc sz
mov dl, [bx]
or dl, dl
jz CommSz2
mov ah,4
int 21h
jmp CommSz1
CommSz2:
cEnd CommSzLib
;-----------------------------------------------------------------------------
; CHAR ChFromComm - get char from AUX device
;
; For debugging
;-----------------------------------------------------------------------------
; %%Function:ChFromComm %%Owner:peterj
cProc ChFromComm, <FAR, PUBLIC>,<si,di>
cBegin ChFromComm
mov ah,3
int 21h
xor ah,ah
cEnd ChFromComm
endif ; DEBUG
endif ; PMWORD
ifndef TESTCODE
;-----------------------------------------------------------------------------
; char huge *HpOfBptbExt( ibp )
;-----------------------------------------------------------------------------
PUBLIC HpOfBptbExt
HpOfBptbExt:
mov bx,sp
mov ax,[bx+4]
xor dx,dx
div [vbptbExt.cbpChunkBptb] ; ax = result, dx = remainder
add ax,[vbptbExt.SB_hprgbpExtBptb]
xchg ax,dx
errnz <cbSector - 512>
mov cl,9
shl ax,cl
db 0CAh, 002h, 000h ;far ret, pop 2 bytes
endif ; TESTCODE
;-----------------------------------------------------------------------------
; void OsTime( pTime )
; struct TIME *ptime;
;
; pTime is a pointer to a structure of the form:
; struct {
; char min; Minutes (0-59)
; char hour; Hours (0-23)
; char hsec; Hundredths of seconds (0-99)
; char sec; Seconds (0-59)
; }
;
; Get current time into structure
;-----------------------------------------------------------------------------
; %%Function:OsTime %%Owner:peterj
cProc OsTime, <FAR, PUBLIC>,<si,di>
parmDP <pTime>
ifdef PMWORD
localV <dts>, <size DATETIME>
endif
cBegin OsTime
ifndef PMWORD
mov ah,2ch
int 21h
mov bx,pTime
mov WORD PTR [bx], cx
mov WORD PTR [bx+2], dx
else ; PMWORD
lea ax, dts
farPtr lpdt, ds, ax
cCall DosGetDateTime, <lpdt>
; now move stuff from the os/2 data buffer into the caller's buffer
mov ax,ss
mov es,ax
assumes es,data
mov di, pTime ; es:di has place to move to
mov al, dts.minutes
stosb
mov al, dts.hours
stosb
mov al, dts.hundreths
stosb
mov al, dts.seconds
stosb
endif ; PMWORD
cEnd OsTime
;-----------------------------------------------------------------------------
; void OsDate( pDate )
;
; pDate is a pointer to a structure of the form:
; struct {
; int year; Year (1980 - 2099)
; char month; Month (1-12)
; char day; Day (1-31)
; char dayOfWeek; Week day (0 = Sunday, 6 = Saturday)
; }
;
; Get current date into structure
;-----------------------------------------------------------------------------
; %%Function:OsDate %%Owner:peterj
cProc OsDate, <FAR, PUBLIC>,<si,di>
parmDP <pDate>
ifdef PMWORD
localV <dts>, <size DATETIME>
endif
cBegin OsDate
ifndef PMWORD
mov ah,2ah
int 21h
mov bx,pDate
mov WORD PTR [bx], cx ; year
mov BYTE PTR [bx+2], dh ; month
mov BYTE PTR [bx+3], dl ; day
mov BYTE PTR [bx+4], al ; week day
else ; PMWORD
lea ax, dts
farPtr lpdt, ds, ax
cCall DosGetDateTime, <lpdt>
; now move stuff from the os/2 data buffer into the caller's buffer
mov ax,ss
mov es,ax
assumes es, data
mov di, pDate ; es:di has place to move to
mov ax, dts.year
stosw
mov al, dts.month
stosb
mov al, dts.day
stosb
mov al, dts.weekday
stosb
endif ; PMWORD
cEnd OsDate
ifndef TESTCODE
;-------------------------------------------------------------------------
; IbpLru()
;-------------------------------------------------------------------------
;/* I B P L R U */
;/* Look for least recently used vbptbExt cache page.
;Returns ibp of page.
;If vfScratchFile and scratch file pages
;routine will strive to maintain a fraction of ext buffers clear.
;This means that if there are too many dirty buffers, a dirty one
;will be picked regardless of lru.
;Note: this version will select a clean page over a dirty page unless 50%
;of the pages are dirty.
;*/
;NATIVE IbpLru()
;{
; extern struct MERR vmerr;
; extern BOOL vfScratchFile;
;
; int ibp, ibpLruClean = 0, ibpLruDirty = 0;
; int ibpMac = vbptbExt.ibpMac;
; int cbpsScratchClean = ibpMac;
; int cbpsClean = 0;
; int cbpsDirty = 0;
; int ibpScratch;
; TS ts, tsLruClean, tsLruDirty;
; struct BPS HUGE *hpbps = HpbpsIbp(0);
; TS tsMruBps = vbptbExt.tsMruBps;
cProc N_IbpLru,<PUBLIC,FAR>,<si,di>
LocalW cbpsDirty
OFFBP_cbpsDirty = -2
LocalW ibpLruDirty
OFFBP_ibpLruDirty = -4
LocalW tsLruDirty
OFFBP_tsLruDirty = -6
LocalW cbpsClean
OFFBP_cbpsClean = -8
LocalW ibpLruClean
OFFBP_ibpLruClean = -10
LocalW tsLruClean
OFFBP_tsLruClean = -12
LocalW ibpLru
OFFBP_ibpLru = -14
LocalW ibpScratch
OFFBP_ibpScratch = -16
ifdef DEBUG
LocalV rgchIbpLru,10
endif ;DEBUG
cBegin
; tsLruClean = tsLruDirty = tsMax;
;Note: the assembler ts is really 0FFFFh - (the C ts).
errnz <tsMax - 0FFFFh>
push ds
pop es
xor ax,ax
lea di,[tsLruClean]
errnz <OFFBP_ibpLruClean - OFFBP_tsLruClean - 2>
errnz <OFFBP_cbpsClean - OFFBP_ibpLruClean - 2>
errnz <OFFBP_tsLruDirty - OFFBP_cbpsClean - 2>
errnz <OFFBP_ibpLruDirty - OFFBP_tsLruDirty - 2>
errnz <OFFBP_cbpsDirty - OFFBP_ibpLruDirty - 2>
mov cx,(OFFBP_cbpsDirty - OFFBP_tsLruClean + 2) SHR 1
rep stosw
ifdef DEBUG
push cx
push si
push di
push ds
push es
push cs
pop ds
push ss
pop es
mov si,offset szIbpLru
lea di,[rgchIbpLru]
mov cx,cbSzIbpLru
rep movsb
jmp short IL005
szIbpLru:
db 'IbpLru',0
cbSzIbpLru equ $ - szIbpLru
IL005:
pop es
pop ds
pop di
pop si
pop cx
endif ;DEBUG
mov bx,[vbptbExt.SB_hpmpibpbpsBptb]
shl bx,1
mov ax,[bx.mpsbps]
mov es,ax
shr ax,1
jc IL007
; ReloadSb trashes ax, cx, and dx
cCall ReloadSb,<>
IL007:
mov bx,[vbptbExt.OFF_hpmpibpbpsBptb]
mov di,[vbptbExt.ibpMacBptb]
; Assert(ibpMac >= 5);
ifdef DEBUG
cmp di,5
jge IL008
push ax
push bx
push cx
push dx
mov ax,midFilewinn
mov bx,1001
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
IL008:
endif ;/* DEBUG */
; for (ibp = 0; ibp < ibpMac; ibp++, hpbps++)
; {
xor cx,cx ;clear out ch so we can use jcxz
xor si,si
jmp short IL02
IL01:
inc si
add bx,cbBpsMin
IL02:
cmp si,[vbptbExt.ibpMacBptb]
jae IL04
mov cl,es:[bx.fDirtyBps]
; if (hpbps->fn == fnScratch)
; {
cmp es:[bx.fnBps],fnScratch
jne IL03
; if (!vfScratchFile)
; {
; cbpsScratchClean--;
; continue;
; }
dec di
cmp [vfScratchFile],fFalse
je IL01
inc di
; if (hpbps->fDirty)
; {
; cbpsScratchClean--;
; if (ibp != vibpProtect)
; ibpScratch = ibp;
; }
; }
jcxz IL03
dec di
cmp si,[vibpProtect]
je IL03
mov ax,si
IL03:
;/* normalize time stamps so that the MRU is intMax-1, and the others smaller
;in unsigned arithmetic */
; ts = hpbps->ts - (tsMruBps + 1);
;Note: the assembler ts is really 0FFFFh - (the C ts).
mov dx,[vbptbExt.tsMruBpsBptb]
sub dx,es:[bx.tsBps]
; if (ibp != vibpProtect)
; {
cmp si,[vibpProtect]
je IL01
;/* keep separate tabs on clean and dirty pages so we can choose between them */
; if (hpbps->fDirty)
; {
; cbpsDirty++;
; if (ts <= tsLruDirty)
; {
; tsLruDirty = ts;
; ibpLruDirty = ibp;
; }
; }
; else
; {
; cbpsClean++;
; if (ts <= tsLruClean)
; {
; tsLruClean = ts;
; ibpLruClean = ibp;
; }
; }
; }
push bp
jcxz IL035
add bp,OFFBP_cbpsDirty - OFFBP_cbpsClean
IL035:
inc [cbpsClean]
cmp dx,[tsLruClean]
;Note: Do "jbe" here because the assembler ts is really
;0FFFFh - (the C ts).
jb IL037
mov [tsLruClean],dx
mov [ibpLruClean],si
IL037:
pop bp
; }
jmp short IL01
IL04:
;/* check for no scratch file and buffers almost full (7/8 full) */
; if (cbpsScratchClean < max(ibpMac >> 3, 4))
; {
mov bx,[vbptbExt.ibpMacBptb]
shr bx,1
shr bx,1
shr bx,1
cmp bx,4
jge IL055
mov bx,4
IL055:
cmp di,bx
jae IL07
; if (vfScratchFile)
; {
; Assert (ibpScratch != vibpProtect);
; return ibpScratch;
; }
cmp [vfScratchFile],fFalse
jne IL08
; else
; {
; if (!vmerr.fDiskEmerg)
; {
mov cl,[vmerr.fDiskEmergMerr]
or [vmerr.fDiskEmergMerr],maskfDiskEmergMerr
test cl,maskfDiskEmergMerr
jnz IL07
; ErrorEid(!vmerr.fScratchFileInit ?
; eidSysLock : eidSysFull,"IbpLru");
; }
mov ax,eidSysLock
test [vmerr.fScratchFileInitMerr],maskfScratchFileInitMerr
je IL06
mov ax,eidSysFull
IL06:
push ax
ifdef DEBUG
lea ax,[rgchIbpLru]
push ax
endif ;DEBUG
cCall ErrorEidProc,<>
; vmerr.fDiskEmerg = fTrue;
; }
; }
; if (tsLruClean > tsLruDirty && cbpsDirty > cbpsClean)
; /* only return the dirty page if it is older and there are
; more dirty pages than clean pages */
; {
; Assert (ibpLruDirty != vibpProtect);
; return ibpLruDirty;
; }
; else
; {
; Assert (ibpLruClean != vibpProtect);
; return ibpLruClean;
; }
IL07:
mov ax,[ibpLruClean]
mov dx,[tsLruClean]
cmp dx,[tsLruDirty]
;Note: Do "jae" here because the assembler ts is really
;0FFFFh - (the C ts).
jae IL08
mov dx,[cbpsDirty]
cmp dx,[cbpsClean]
jbe IL08
mov ax,[ibpLruDirty]
IL08:
ifdef DEBUG
cmp ax,[vibpProtect]
jne IL09
push ax
push bx
push cx
push dx
mov ax,midFilewinn
mov bx,1002
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
IL09:
endif ;/* DEBUG */
;}
cEnd
endif ;TESTCODE
sEnd filewin
END
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+237
View File
@@ -0,0 +1,237 @@
; FORMULAN.ASM
; Fetch routines used by Formula
.xlist
memS = 1
?WIN = 1
?PLM = 1
?NODATA = 1
?TF = 1
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
.list
; CODE IN THIS MODULE IS APPENDED TO THE PCODE SEGMENT FOR FORMULA.C
createSeg formula_PCODE,formula,byte,public,CODE
; EXPORTED LABELS
; EXTERNAL FUNCTIONS
externFP <HpsAlter,ApplySprm>
externFP <AnsiLower,MapStcStandard>
externFP <IMacPlc,CpPlc,GetPlc,CpMac2Doc,PutPlc>
externFP <PutPlcLastProc>
externFP <ReloadSb>
externFP <IInPlc,IInPlcRef>
externFP <N_FetchCp,N_PdodDoc>
externNP <LN_IcpInRgcp,LN_LprgcpForPlc>
ifdef DEBUG
externFP <AssertProcForNative,ScribbleProc>
externFP <S_FetchCp>
externFP <PutPlcLastDebugProc>
endif
; EXTERNAL DATA
sBegin data
externW vfEndFetch ; extern BOOL vfEndFetch;
externW mpdochdod ; extern struct DOD **mpdochdod[];
externW vchpFetch ; extern struct CHP vchpFetch;
externW vchpStc ; extern struct CHP vchpStc;
externW vhpchFetch ; extern char HUGE *vhpchFetch;
externW vccpFetch ; extern int vccpFetch;
externW mpfnhfcb ; extern struct FCB **mpfnhfcb[];
externW caPara ; extern struct CA caPara;
externW caSect ; extern struct CA caSect;
externW vsab ; extern struct SAB vsab;
externW vpapFetch ; extern struct PAP vpapFetch;
externW vpapStc ; extern struct PAP vpapStc;
externW vibp ; extern int vibp;
externW vbptbExt ; extern struct BPTB vbptbExt;
externW vstcpMapStc ; extern int vstcpMapStc;
externW vdocPapLast ; extern int vdocPapLast;
externW vfnPapLast ; extern int vfnPapLast;
externW vpnPapLast ; extern int vpnPapLast;
externW vbpapxPapLast ; extern int vbpapxPapLast;
externW mpsbps ; extern SB mpsbps[];
externW vfnPreload ; extern int vfnPreload;
ifdef DEBUG
externW cHpFreeze
externW vdbs
externW wFillBlock
endif
sEnd data
sBegin formula
assumes cs,formula
assumes ds,dgroup
assumes ss,dgroup
;
;-------------------------------------------------------------------------
; ChFetchNonVanish(doc, pcp) GregC
;-------------------------------------------------------------------------
; %%Function:ChFetchNonVanish %%Owner:BRADV
cProc ChFetchNonVanish,<PUBLIC,FAR>,<si,di>
ParmW doc
ParmW pcp
; /* C H F E T C H N O N V A N I S H
;
; Return one character from document skipping vanished runs.
; WARNING: NOT field sensitive.
; */
;
; char ChFetchNonVanish(doc, pcp)
; int doc;
; CP *pcp;
; {
cBegin
; CP cp;
;
; cp = *pcp;
mov bx,[pcp]
mov si,[bx]
mov di,[bx + 2]
; for (;;)
ChFetch2:
; {
; FetchCp(doc, cp, fcmChars | fcmProps);
mov ax,fcmChars OR fcmProps
ifdef DEBUG
cCall S_FetchCp,<[doc],di,si,ax>
else ;not DEBUG
cCall N_FetchCp,<[doc],di,si,ax>
endif ;DEBUG
; if (vchpFetch.fVanish /*|| vchpFetch.fFldVanish*/)
; {
; cp += vccpFetch;
; if (cp >= caPara.cpLim - ccpEop)
; {
; *pcp = caPara.cpLim - ccpEop;
; return (0); /* cause error */
; }
; }
; else
; break;
test [vchpFetch.FVanishChp],maskFVanishChp
; jnz ChFetch7
; test [vchpFetch.FFldVanishChp],maskFFldVanishChp
jz ChFetch8
ChFetch7:
add si,[vccpFetch]
adc di,0
mov ax,[caPara.LO_cpLimCa]
mov dx,[caPara.HI_cpLimCa]
sub ax,ccpEop
sbb dx,0
cmp dx,di
ja ChFetch2
jb ChFetch71
cmp ax,si
ja ChFetch2
ChFetch71:
mov bx,[pcp]
mov [bx],ax
mov [bx + 2],dx
xor ax,ax
jmp ChFetch10
; }
ChFetch8:
; *pcp = cp;
mov bx,[pcp]
mov [bx],si
mov [bx + 2],di
;
; return (vfEndFetch ? 0 : *vhpchFetch);
xor ax,ax
cmp [vfEndFetch],0
jnz ChFetch10
mov bx,whi (vhpchFetch)
shl bx,1
mov ax,[bx.mpsbps]
mov es,ax
shr ax,1
jc ChFetch9
; ReloadSb trashes ax, cx, and dx
cCall ReloadSb,<>
ChFetch9:
ifdef DEBUG
mov ax,[wFillBlock]
mov cx,[wFillBlock]
mov dx,[wFillBlock]
endif ;DEBUG
mov si,wlo (vhpchFetch)
xor ax,ax
; lodsb
lods byte ptr es:[si]
ChFetch10:
; }
cEnd
;
;-------------------------------------------------------------------------
; CpFirstNonBlank(doc, cp) GregC
;-------------------------------------------------------------------------
; %%Function:CpFirstNonBlank %%Owner:BRADV
cProc CpFirstNonBlank,<PUBLIC,FAR>,<si,di>
ParmW doc
ParmD cp
; /* C P F I R S T N O N B L A N K
;
; Return the cp of the first non blank (space and tab are considered blank)
; character after the given cp.
; */
;
; CP CpFirstNonBlank(doc, cp)
; int doc;
; CP cp;
; {
cBegin
; int ch;
;
; while ((ch = ChFetchNonVanish(doc, &cp)) == ' ' || ch == chTab)
; cp++;
mov si,[doc]
lea di,[cp]
jmp short CpFirstNonBlank4
CpFirstNonBlank2:
add [OFF_cp],1
adc [SEG_cp],0
CpFirstNonBlank4:
push si
push di
call far ptr ChFetchNonVanish
cmp al,' '
je CpFirstNonBlank2
cmp al,chTab
je CpFirstNonBlank2
;
; return cp;
mov ax,[OFF_cp]
mov dx,[SEG_cp]
; }
cEnd
sEnd formula
end
+631
View File
@@ -0,0 +1,631 @@
;*------------------------------------------------------------------------
;*
;*
;* Microsoft Word -- Graphics
;*
;* Hand-coded stretch-blt
;*
;*------------------------------------------------------------------------
ifdef PCWORD
include word.inc
AssertDataAsm 'grbitx.asm'
include grconsts.db
include grstruct.db
include grdriver.db
endif
ifdef WIN
include w2.inc
include noxport.inc
include grtiff.inc
ifdef DEBUG
midGrbitx equ 16 ; module ID, for native asserts
endif
endif
createSeg grbit_PCODE,GRBIT,BYTE,PUBLIC,CODE
sBegin GRBIT
assumes cs,grbit
assumes ss,data
assumes ds,data
assumes es,nothing
;-------------------------------------------------------------------------
; StrBltRow(ppc, pbSrc, pbDst)
; PICT *ppc;
; char *pbSrc,
; *pbDst;
;
; Stretch-blts a single row, copying from pbSrc to pbDst.
; Can handle compression or expansion.
;
; WARNING: DS is changed for the duration of this routine.
;
; The comments alongside the code do not really correspond
; to the original C version.
;
; Changes made to this routine should also be made to MonoStrBltRow
; as appropriate.
;-------------------------------------------------------------------------
cProc StrBltRow,<FAR,PUBLIC>,<si,di,ds>
ParmW <ppc> ; PICT *ppc;
ParmW <pbSrc, pbDst> ; char *pbSrc, *pbDst;
LocalW <cplOut, cplIn> ; these are taken right from ppc
LocalW <rgico> ; and put here for faster access
LocalW <cbitRepNorm, wBitDelta>
LocalW <virtSrcMac> ; (ppc->vtExt.h)
LocalW <wRem> ; the current stretchblt remainder
LocalW <ibitSrc> ; current bit in source word
LocalW <ibitDst> ; current bit in dest word
LocalW <virtSrc> ; current source pixel
LocalW <cbitRep> ; # of times to repeat this pixel
LocalW <ibLastPlane> ; cbPlane * 3
ifdef DEBUG
LocalW <cbitReallySent>
endif
;
; %%Function: StrBltRow %%Owner: bobz
;
cBegin StrBltRow
mov si,ppc ; copy stuff over from PICT
mov ax,[si].cplOutPict
mov cplOut,ax
mov ax,[si].cplInPict
mov cplIn,ax
lea ax,[si].rgicoPict
mov rgico,ax
mov ax,[si].cbitRepNormPict
mov cbitRepNorm,ax
mov ax,[si].wBitDeltaPict
mov wBitDelta,ax
mov ax,[si].vtExtPict.hGpoint
mov virtSrcMac,ax
ifdef DEBUG
mov ax,[si].pixExtPict.hGpoint
mov cbitReallySent,ax
endif
xor ax,ax
mov wRem,ax
mov virtSrc,ax
mov cx,[si].cplInPict
mov dx,[si].cbPlanePict ; DX = cbPlane (always)
jmp short SB081
SB080: add ax,dx
SB081: loop SB080
mov ibLastPlane,ax ; offset to last plane
PsFromSb ds,[si].sbBitsPict,bx,dx ; set DS to point to sbBits
assumes ds,nothing
; don't make any assumptions about ax,bx,si,di at this point
mov ibitDst,7
mov ibitSrc,8 ; (this is different from C source)
mov si,pbSrc ; these point into sbBits
mov di,pbDst
SBNextSrc:
mov ax,virtSrc ; for (virtSrc = 0;
cmp ax,virtSrcMac ; virtSrc < ppc->vtExt.h;
jl SB100 ; ++virtSrc)
jmp SBCleanup
SB100:
inc virtSrc
mov cx,cbitRepNorm ; cbitRep = ppc->cbitRepNorm;
mov ax,wRem
add ax,wBitDelta ; wRem += wBitDelta;
mov bx,virtSrcMac
cmp ax,bx ; if (wRem >= ppc->vtExt.h)
jl SB110 ; {
inc cx ; ++cbitRep;
sub ax,bx ; wRem -= ppc->vtExt.h
SB110: ; }
mov cbitRep,cx
mov wRem,ax
dec ibitSrc ; if (ibitSrc-- == 0)
jns SBLoadBits ; {
mov ibitSrc,7 ; ibitSrc = 7; (7 bits left after this)
inc si ; ++pbSrc;
SBLoadBits: ; }
mov cx,cplIn ; ipl = cplIn;
mov bx,ibLastPlane ; ibPlane = ibLastPlane;
xor ax,ax ; ico = 0;
SBLoadLoop: ; while (ipl > 0)
shl byte ptr ds:[si+bx],1 ; {
rcl ax,1 ; LSB of ico = MSB of *(pbSrc+ibPlane);
sub bx,dx ; ibPlane -= cbPlane;
loop SBLoadLoop ; }
dec cbitRep ; if (cbitRep-- > 0)
js SBNextSrc ; {
mov bx,rgico
xlat DGROUP:[bx] ; ico = ppc->rgico;
mov ah,al ; (save away ico)
SBNextDst: ; do {
ifdef DEBUG
dec cbitReallySent
endif
mov bx,cx ; ibPlane = 0;
mov cx,cplOut ; for (ipl = cplOut; ipl > 0; --ipl)
SBStoreLoop: ; {
shr al,1 ; shift LSB into carry
rcl byte ptr ds:[di+bx],1 ; shift carry into LSB of *(pbDst+ibPlane)
add bx,dx ; ibPlane += cbPlane;
loop SBStoreLoop ; }
dec ibitDst ; if (ibitDst-- == 0)
jns SB200 ; {
inc di ; ++pbDst;
mov ibitDst,7 ; ibitDst = 7;
SB200: ; }
mov al,ah ; restore ico
dec cbitRep ; } while (cbitRep-- > 0);
jns SBNextDst
jmp SBNextSrc
SBCleanup:
mov cl,byte ptr ibitDst
cmp cl,7
je SBRet
inc cx ; number of bits to shift left last bytes
mov ax,cplOut
xor bx,bx
SBFixupLoop:
shl byte ptr ds:[di+bx],cl ; shift over remaining bits
add bx,dx ; in last bytes
dec ax
jnz SBFixupLoop
SBRet:
ifdef PCWORD
AssertEQ cbitReallySent,0
endif
ifdef WIN
AssertEQ cbitReallySent,0,midGrbitx,100
endif
cEnd StrBltRow
ifdef NEVER
; Patterns for representing colors on a black and white device
; These patterns were created with pattern.c. The patterns
; are not stored in the standard Chart/Works format, in which
; the 8 bytes of a pattern are stored consecutively.
; Here the bytes from each pattern for a row are stored consecutively;
; that is we have a 2-dimensional byte array, with the major index
; being the row and the minor index being the pattern.
;
; This ordering helps us in the stretchblt; we determine which row table
; to look at once per row, and then use the normalized color
; (from ppc->rgico) as an offset into the selected row table
; when we want to translate a color to a pattern.
labelB <PUBLIC,rgirwicoPat>
ifdef BAYER
db 0000h, 0088h, 0088h, 00aah, 00aah, 00aah, 00aah, 00aah
db 00aah, 00eeh, 00eeh, 00ffh, 00ffh, 00ffh, 00ffh, 00ffh
db 0000h, 0000h, 0000h, 0000h, 0000h, 0044h, 0044h, 0055h
db 0055h, 0055h, 0055h, 0055h, 0055h, 00ddh, 00ddh, 00ffh
db 0000h, 0000h, 0022h, 0022h, 00aah, 00aah, 00aah, 00aah
db 00aah, 00aah, 00bbh, 00bbh, 00ffh, 00ffh, 00ffh, 00ffh
db 0000h, 0000h, 0000h, 0000h, 0000h, 0000h, 0011h, 0011h
db 0055h, 0055h, 0055h, 0055h, 0055h, 0055h, 0077h, 00ffh
db 0000h, 0088h, 0088h, 00aah, 00aah, 00aah, 00aah, 00aah
db 00aah, 00eeh, 00eeh, 00ffh, 00ffh, 00ffh, 00ffh, 00ffh
db 0000h, 0000h, 0000h, 0000h, 0000h, 0044h, 0044h, 0055h
db 0055h, 0055h, 0055h, 0055h, 0055h, 00ddh, 00ddh, 00ffh
db 0000h, 0000h, 0022h, 0022h, 00aah, 00aah, 00aah, 00aah
db 00aah, 00aah, 00bbh, 00bbh, 00ffh, 00ffh, 00ffh, 00ffh
db 0000h, 0000h, 0000h, 0000h, 0000h, 0000h, 0011h, 0011h
db 0055h, 0055h, 0055h, 0055h, 0055h, 0055h, 0077h, 00ffh
else ; course fatting
db 0000h, 0000h, 0000h, 0000h, 0000h, 0000h, 0000h, 0030h
db 00f0h, 00f3h, 00ffh, 00ffh, 00ffh, 00ffh, 00ffh, 00ffh
db 0000h, 0040h, 0060h, 00e0h, 00e0h, 00e0h, 00f0h, 00f0h
db 00f0h, 00f0h, 00f0h, 00f8h, 00f8h, 00f8h, 00f9h, 00ffh
db 0000h, 0040h, 0060h, 00e0h, 00e0h, 00e0h, 00f0h, 00f0h
db 00f0h, 00f0h, 00f0h, 00f8h, 00f8h, 00f8h, 00f9h, 00ffh
db 0000h, 0000h, 0000h, 0000h, 00c0h, 00f0h, 00f0h, 00f0h
db 00f0h, 00f0h, 00f0h, 00f0h, 00fch, 00ffh, 00ffh, 00ffh
db 0000h, 0000h, 0000h, 0000h, 0000h, 0000h, 0000h, 0003h
db 000fh, 003fh, 00ffh, 00ffh, 00ffh, 00ffh, 00ffh, 00ffh
db 0000h, 0004h, 0006h, 000eh, 000eh, 000eh, 000fh, 000fh
db 000fh, 000fh, 000fh, 008fh, 008fh, 008fh, 009fh, 00ffh
db 0000h, 0004h, 0006h, 000eh, 000eh, 000eh, 000fh, 000fh
db 000fh, 000fh, 000fh, 008fh, 008fh, 008fh, 009fh, 00ffh
db 0000h, 0000h, 0000h, 0000h, 000ch, 000fh, 000fh, 000fh
db 000fh, 000fh, 000fh, 000fh, 00cfh, 00ffh, 00ffh, 00ffh
endif ;!BAYER
cbrowPat = ($-rgirwicoPat) / 8 ; size of each row table
endif ;NEVER
assumes cs,grbit
assumes ss,data
assumes ds,data
assumes es,nothing
;-------------------------------------------------------------------------
; MonoStrBltRow(ppc, pbSrc, pbDst, irw, psPat)
; PICT *ppc;
; char *pbSrc, /* get source data from here */
; *pbDst; /* put result here */
; unsigned irw; /* row number */
; WORD psPat; /* physical segment containing dither patterns */
;
; Stretch-blts a single row, copying from pbSrc to pbDst.
; Can handle compression or expansion.
; The output row is a single plane B&W image;
; the input row is a multi-plane color image.
; The colors or gray levels are translated to B&W patterns.
;
; IMPORTANT: The source row is not changed, unless the destination
; happens to overwrite it. This is necessary here since we may stretchblt
; from the same source row to several destination rows.
;
; WARNING: DS is changed for the duration of this routine.
;
; Beware of the differences between StrBltRow and MonoStrBltRow:
; MonoStrBltRow always has only one ouput plane.
; ibitDst is initialized to 8 for MonoStrBltRow and 7 for StrBltRow.
; irw is passed to MonoStrBltRow but not to StrBltRow.
; StrBltRow always destroys the source row; MonoStrBltRow only destroys
; it if the destination overwrites the source.
;
;-------------------------------------------------------------------------
cProc MonoStrBltRow,<FAR,PUBLIC>,<si,di,ds>
ParmW <ppc> ; PICT *ppc;
ParmW <pbSrc, pbDst> ; char *pbSrc, *pbDst;
ParmW <irw> ; unsigned irw;
ParmW <psPat> ; WORD psPat;
LocalW <cplIn> ; these are taken right from ppc
LocalW <cbitRepNorm, wBitDelta> ; and put here for faster access
LocalW <virtSrcMac> ; (ppc->vtExt.h)
LocalW <wRem> ; the current stretchblt remainder
LocalW <ibitSrc> ; current bit in source word
LocalW <ibitDst> ; current bit in dest word
LocalW <virtSrc> ; current source pixel
LocalW <cbitRep> ; # of times to repeat this pixel
LocalW <ibLastPlane> ; cbPlane * cplIn
LocalW <rgpat> ; the row table to use
ifdef DEBUG
LocalW <cbitReallySent>
endif
; %%Function: MonoStrBltRow %%Owner: bobz
;
cBegin MonoStrBltRow
mov si,ppc ; copy stuff over from PICT
ifdef PCWORD
AssertEQ [si].cplOutPict,1 ; single plane output
AssertGT [si].cplInPict,1 ; but color input
endif
ifdef WIN
AssertEQ [si].cplOutPict,1,midGrbitx,200 ; single plane output
AssertGT [si].cplInPict,1,midGrbitx,300 ; but color input
endif
mov ax,[si].cplInPict
mov cplIn,ax
mov ax,[si].cbitRepNormPict
mov cbitRepNorm,ax
mov ax,[si].wBitDeltaPict
mov wBitDelta,ax
mov ax,[si].vtExtPict.hGpoint
mov virtSrcMac,ax
errnz cbRowPat-16
mov bx,irw
and bx,7 ; irw = irw % 8
shl bx,1
shl bx,1
shl bx,1
shl bx,1 ; irw * 16
mov rgpat,bx ; save ptr to row table to use
ifdef DEBUG
mov ax,[si].pixExtPict.hGpoint
mov cbitReallySent,ax
endif
xor ax,ax
mov wRem,ax
mov virtSrc,ax
mov cx,[si].cplInPict
mov dx,[si].cbPlanePict ; DX = cbPlane (always)
jmp short MSB081
MSB080: add ax,dx
MSB081: loop MSB080
mov ibLastPlane,ax ; offset to last plane
PsFromSb ds,[si].sbBitsPict,bx,dx ; set DS to point to sbBits
assumes ds,nothing
mov es,psPat ; get segment containing dither patterns
assumes es,nothing
; don't make any assumptions about ax,bx,si,di at this point
mov ibitDst,8 ; *** this is different from StrBltRow ***
mov ibitSrc,8 ; (this is different from C source)
mov si,pbSrc ; these point into sbBits
mov di,pbDst
MSBNextSrc:
mov ax,virtSrc ; for (virtSrc = 0;
cmp ax,virtSrcMac ; virtSrc < ppc->vtExt.h;
jl MSB100 ; ++virtSrc)
jmp MSBCleanup
MSB100:
inc virtSrc
mov cx,cbitRepNorm ; cbitRep = ppc->cbitRepNorm;
mov ax,wRem
add ax,wBitDelta ; wRem += wBitDelta;
mov bx,virtSrcMac
cmp ax,bx ; if (wRem >= ppc->vtExt.h)
jl MSB110 ; {
inc cx ; ++cbitRep;
sub ax,bx ; wRem -= ppc->vtExt.h
MSB110: ; }
mov cbitRep,cx
mov wRem,ax
dec ibitSrc ; if (ibitSrc-- == 0)
jns MSBLoadBits ; {
mov ibitSrc,7 ; ibitSrc = 7; (7 bits left after this)
inc si ; ++pbSrc;
MSBLoadBits: ; }
mov cx,cplIn ; ipl = cplIn;
mov bx,ibLastPlane ; ibPlane = ibLastPlane;
xor ax,ax ; ico = 0;
MSBLoadLoop: ; while (ipl > 0)
rol byte ptr ds:[si+bx],1 ; {
rcl ax,1 ; LSB of ico = MSB of *(pbSrc+ibPlane);
sub bx,dx ; ibPlane -= cbPlane;
loop MSBLoadLoop ; }
dec cbitRep ; if (cbitRep-- > 0)
js MSBNextSrc ; {
mov bx,rgpat
xlat es:[bx] ; pattern byte = rgpat[ico];
mov cx,ibitDst
ror al,cl ; align pattern so MSB is first bit used
MSBNextDst: ; do {
ifdef DEBUG
dec cbitReallySent
endif
rol al,1 ; shift pattern into carry
rcl byte ptr ds:[di],1 ; shift carry into LSB of *pbDst
loop MSB200 ; if (--ibitDst == 0) {
inc di ; ++pbDst;
mov cl,8 ; ibitDst = 8;
MSB200: ; }
dec cbitRep ; } while (cbitRep-- > 0);
jns MSBNextDst
mov byte ptr ibitDst,cl
jmp MSBNextSrc
MSBCleanup:
mov cl,byte ptr ibitDst
shl byte ptr ds:[di],cl ; shift over remaining bits
mov cl,byte ptr ibitSrc
mov ax,cplIn
MSBCleanLoop:
rol byte ptr ds:[si],cl ; clean up last source byte
add si,dx ; note that we trash SI
dec ax
jnz MSBCleanLoop
MSBRet:
ifdef PCWORD
AssertEQ cbitReallySent,0
endif
ifdef WIN
AssertEQ cbitReallySent,0,midGrbitx,100
endif
cEnd MonoStrBltRow
ifdef NEVER
; This is not being used because the case in which an expansion
; or compression does not occur is extremely rare.
;-------------------------------------------------------------------------
; ColorTransRow(ppc, pbSrc)
; PICT *ppc;
; char *pbSrc;
;
; Translates the colors of a row in a bitmap.
;
; The basic structure is as follows:
;
; For each byte in the row
; Get the most significant bit
; Translate it
; For each of the remaining 7 bits
; Shift in the translated color and shift out the next bit
; Translate the color
; Now we have the last bit, translated
; Stuff it into the byte
; Prepare for next byte
;
;
; Note that we may process more bits than necessary with this method,
; since the main loop works on a byte-by-byte basis.
;
; WARNING: DS is changed for the duration of this routine.
;-------------------------------------------------------------------------
cProc ColorTransRow,<FAR,PUBLIC>,<si,di,ds>
ParmW <ppc> ; PICT *ppc;
ParmW <pbSrc> ; char *pbSrc, *pbDst;
LocalW <cplOut, cplIn> ; these are taken right from ppc
LocalW <rgico> ; and put here for faster access
LocalW <virtSrcMac> ; (ppc->vtExt.h)
LocalW <cbLeft> ; # of bytes remaining
LocalW <cpl> ; max(cplOut, cplIn)
LocalW <cbitCoShift> ; 8 - max(cplIn, cplOut)
LocalW <coMask> ; mask to AND src color with
;
; %%Function: ColorTransRow %%Owner: bobz
;
cBegin ColorTransRow
mov si,ppc ; copy stuff over from PICT
mov cx,[si].cplInPict
mov cplIn,cx
mov ax,1
shl ax,cl
dec ax ; form input color mask
mov coMask,ax
mov ax,[si].cplOutPict
mov cplOut,ax
sub ax,cx ; this is the fancy max(ax,cx)
cwd
not dx
and ax,dx
add ax,cx
mov cpl,ax ; cpl = max(cplIn, cplOut);
lea bx,[si].rgicoPict
mov ax,[si].vtExtPict.hGpoint
mov virtSrcMac,ax
mov ax,[si].cbRowInPict ; (for cbLeft = cbRowIn;
mov cbLeft,ax ; cbLeft > 0; --cbLeft)
mov dx,[si].cbPlanePict ; DX = cbPlane (always)
PsFromSb ds,[si].sbBitsPict,di,bx,dx ; set DS to point to sbBits
assumes ds,nothing
; don't assume anything about the contents of ax,cx,si
mov di,pbSrc
xor ax,ax
mov cx,ax
CTNextByte:
mov si,di
mov cl,byte ptr cplIn ; for each plane
AssertEQ cx,<word ptr cplIn>
CTFirstPix: ; {
shl byte ptr [si],1 ; shift out MSB
rcr ah,1 ; stack 'em up in AH
add si,dx
loop CTFirstPix ; }
mov cl,byte ptr cplIn ; rotate into AL
rol ax,cl
xlat DGROUP:[bx] ; get dest color
mov ch,7 ; for each remaining bit in word
CTNextPix:
mov cl,byte ptr cpl ; for each plane
mov si,di ; {
CTFormPix:
shr al,1 ; this goes in the right side
rcl byte ptr [si],1 ; ...as we shift out
rcr ah,1 ; ...the next bit into AH
add si,dx
dec cl
jnz CTFormPix ; }
mov cl,byte ptr cpl
rol ax,cl ; AL = source color
and al,byte ptr coMask ; strip off extra bits
xlat DGROUP:[bx] ; get dest color
dec ch
jnz CTNextPix
mov cl,byte ptr cplOut ; now stuff last bit in byte
AssertEQ cx,<word ptr cplOut>
mov si,di ; for each plane
CTLastPix: ; {
shr al,1 ; get translated bit
rcl byte ptr [si],1 ; and stuff it in
add si,dx ; }
loop CTLastPix
inc di ; point to next byte
dec cbLeft
jz CTDone
jmp CTNextByte
CTDone:
cEnd ColorTransRow
endif ;NEVER
sEnd GRBIT
END
+120
View File
@@ -0,0 +1,120 @@
STANDARD_OUT equ 1
STANDARD_ERROR equ 2
SCROLL_PAGE equ 7
PAGE_UP_CODE equ 73
ESCAPE_CODE equ 1
SET_CURSOR equ 2
READ_CHAR_ATTR equ 8
; FLAGS IN BIT_FLAGS:
;DASH_V_FLAG equ 8000h
;DASH_N_FLAG equ 4000h
;DASH_C_FLAG equ 2000h
;DASH_L_FLAG equ 1000h
;DASH_F_FLAG equ 0800h
;DASH_H_FLAG equ 0400h
DASH_Y_FLAG equ 0200h
;DASH_E_FLAG equ 0100h
;DASH_S_FLAG equ 0040h
;ONLY_ONE_FILE_FLAG equ 0010h
BOL_SET_FLAG equ 0008h
;WEVE_ALREADY_PRINTED_THE_FILE_NAME_FLAG equ 0004h
GET_MORE_OF_FILE_FLAG equ 0002h
DONE_WITH_THIS_BITMAP_FLAG equ 0001h
;STD_INPUT_FLAG equ 0001h
; FLAGS IN BIT_FLAGS_2:
DASH_B_FLAG equ 4000h
DASH_M_FLAG equ 2000h
DASH_D_FLAG equ 1000h
;DASH_W_FLAG equ 0800h
;DASH_X_FLAG equ 0400h
;DASH_A_FLAG equ 0200h
;DASH_P_FLAG equ 0100h
;PUBLICS_FLAG equ 1
zero equ 0
lf equ 10
cr equ 13
controlz equ 1ah
OR_SYMBOL equ zero+'!'
DTA_SIZE equ 3 ;3 paragraghs
PATH_AND_FILE_NAME_BUFFER_SIZE equ 6 ;paragraghs
BitmapHeader struc
next_bitmap dw 0
bitmap_flags dw 0
anchor_string_offset dw 0
position_in_expression_of_anchor_string dw 0
anchor_string_length_minus_one dw 0
index_of_string_this_bitmap_belongs_to dw 0
BitmapHeader ends
BITMAP_HEADER_LENGTH equ 12
TemplateHeader struc
the_literal_char db 0
literal_char_indicator db 0
asterisk_location db 0
last_template_in_this_bitmap db 0
TemplateHeader ends
TEMPLATE_SIZE equ 32
TS equ TEMPLATE_SIZE
TFB equ type TemplateHeader
;The number of bytes of template info preceding
; The anchor string is written where the next template
; would have been if there was another.
LAST_TEMPLATE equ 088h
LIT_CHAR_INDICATOR equ 0FFh
min_buf_size equ 200 ;in paragraghs (decimal) about 3.2k
max_buf_seg_size equ 0f800h
max_entries equ 30
MAX_X_VALUE equ 30h
BOL_FLAG equ 80h
POSITION_NOT_MEANINGFUL_FLAG equ 40h
ANCHOR_FLAG equ 20h
EXPRESSION_FLAG equ 10h
BRACKET_FLAG equ 08h
NOT_FLAG equ 04h
comment @
flag usage: during template building dh keeps several flags which are stored
at the beginning of the bitmap by GREP.ASM after returning from BUILD_BITMAP.
they are:
80h BOL flag (tells the search routine that "^" begins the expression)
40h position not meaningful flag (indicates use of *,?, or + in the exprssn)
20h anchor flag (tells if there is an anchor string available)
10h expression flag (not set if expression is all literals -- single chars)
08h [ flag (only has meaning inside BUILD_BITMAP)
04h not-flag (only has meaning inside BUILD_BITMAP)
02h unused
01h unused
In GREP.ASM flags are kept in BIT_FLAGS[bp] and BIT_FLAGS_2[bp].
The command line flags in BIT_FLAGS[bp] are:
0200h y case insensitive
The -y flag is used only in template building.
Internal flags of GREP.ASM in BIT_FLAGS[bp] are:
02h Get-more-of-file flag.
01h done with this bitmap, can skip it from now on...
The others are unused.
@
+164
View File
@@ -0,0 +1,164 @@
local_variables macro
local_space = 0
endm
local_word macro var_name
local_space = local_space - 2
var_name = local_space
endm
local_byte macro var_name
local_space = local_space - 1
var_name = local_space
endm
routine_arguments macro
next_arg = 4
endm
word_arg macro xxx
xxx = next_arg
next_arg = next_arg + 2
endm
entry macro routine
ifndef routine
extrn routine :near
endif
dw routine
endm
pbyte macro aname,num
;public aname
ifnb <num>
aname db num dup(?)
else
aname db 0
endif
endm
pword macro aname,num
;public aname
ifnb <num>
ifdef PCODE
aname label word
rept num
dw 0
endm
else
aname dw num dup(?)
endif
else
aname dw 0
endif
endm
pdword macro aname,num
;public aname
ifnb <num>
ifdef PCODE
aname label dword
rept num
dd 0
endm
else
aname dd num dup(?)
endif
else
aname dd 0
endif
endm
pthis macro aname
;public aname
aname equ this byte
endm
pushem macro r1,r2,r3,r4,r5,r6,r7,r8,r9,rA,rB,rC,rD,rE,rF,r10,r11,r12
irp x,<r1,r2,r3,r4,r5,r6,r7,r8,r9,rA,rB,rC,rD,rE,rF,r10,r11,r12>
ifnb <x>
push x
endif
endm
endm
popem macro r1,r2,r3,r4,r5,r6,r7,r8,r9,rA,rB,rC,rD,rE,rF,r10,r11,r12
irp x,<r12,r11,r10,rF,rE,rD,rC,rB,rA,r9,r8,r7,r6,r5,r4,r3,r2,r1>
ifnb <x>
pop x
endif
endm
endm
smov macro x,y
push y
pop x
endm
;-----------------------------------------------------------------------;
; reorganize MACRO ;
; ;
; Leaves the far ptr invariant, but makes 0Fh < offset < 20h. ;
; ;
; Arguments: ;
; Two regs: Segment and Offset to reorganize ;
; Returns: ;
; Reorganized regs ;
; Alters: ;
; AX,CX ;
; Calls: ;
; nothing ;
; History: ;
; ;
; Wed Mar 19, 1986 04:22:15p -by- Wesley O. Rupel [wor] ;
; Wrote it! ;
;-----------------------------------------------------------------------;
reorganize macro segreg,baby_reg
mov ax,000Fh
and ax,baby_reg ;AX now has the lower 4 bits of baby
mov cl,4
shr baby_reg,cl
dec baby_reg
add ax,10h
mov cx,segreg
add cx,baby_reg
mov segreg,cx
mov baby_reg,ax
endm
;-----------------------------------------------------------------------;
; reorganize0 MACRO ;
; ;
; Leaves the far ptr invariant, but makes 0 =< offset < 10h. ;
; ;
; Arguments: ;
; Two regs: Segment and Offset to reorganize ;
; Returns: ;
; Reorganized regs ;
; Alters: ;
; AX,CX ;
; Calls: ;
; nothing ;
; History: ;
; ;
; Wed Mar 19, 1986 04:22:15p -by- Wesley O. Rupel [wor] ;
; Wrote it! ;
;-----------------------------------------------------------------------;
reorganize0 macro segreg,baby_reg
mov ax,000Fh
and ax,baby_reg ;AX now has the lower 4 bits of baby
mov cl,4
shr baby_reg,cl
mov cx,segreg
add cx,baby_reg
mov segreg,cx
mov baby_reg,ax
endm
wHigh equ 2+word ptr ;; upper word (or segment) of a long
wLow equ word ptr ;; lower word (or offset) of a long
+513
View File
@@ -0,0 +1,513 @@
;*------------------------------------------------------------------------
;*
;*
;* Microsoft Word -- Graphics
;*
;* Hand-code versions of C routines
;*
;*------------------------------------------------------------------------
include w2.inc
include noxport.inc
include grtiff.inc
midGrhc equ 17
externFP <ReloadSb>
externFP <N_HpchFromFc>
ifdef DEBUG
externFP <S_HpchFromFc>
externFP <AssertProcForNative>
endif ;DEBUG
createSeg grtiff_PCODE,GRTIFF,BYTE,PUBLIC,CODE
sBegin GRTIFF
assumes cs,GRTIFF
assumes ss,data
assumes ds,data
assumes es,nothing
mpnbb: db 000h,000h,000h,000h
db 0ffh,000h,000h,000h
db 000h,0ffh,000h,000h
db 0ffh,0ffh,000h,000h
db 000h,000h,0ffh,000h
db 0ffh,000h,0ffh,000h
db 000h,0ffh,0ffh,000h
db 0ffh,0ffh,0ffh,000h
db 000h,000h,000h,0ffh
db 0ffh,000h,000h,0ffh
db 000h,0ffh,000h,0ffh
db 0ffh,0ffh,000h,0ffh
db 000h,000h,0ffh,0ffh
db 0ffh,000h,0ffh,0ffh
db 000h,0ffh,0ffh,0ffh
db 0ffh,0ffh,0ffh,0ffh
;-------------------------------------------------------------------------------
; ReadTIFFLine(hpc, hpPlane)
;-------------------------------------------------------------------------------
;ReadTIFFLine(hpc, hpPlane)
;PICT **hpc;
;char HUGE *hpPlane;
;{
; int ibitIn,
; ibIn,
; cbRowFile,
; cbitsSample;
; BYTE b;
; unsigned cb;
;
; %%Function: ReadTIFFLine %%Owner: Bobz
;
cProc ReadTIFFLineNat,<FAR,PUBLIC>,<SI,DI>
parmW hpc
parmD hpPlane
cBegin
;
; ibitIn = ibIn = 0;
; cbRowFile = (*hpc)->tiff.cbRowFile;
; cbitsSample = (*hpc)->tiff.cbitsSample;
; Assembler note: Set ibitIn, ibIn, and cbRowFile later...
mov bx,[hpc]
mov bx,[bx] ;bx = *hpc
mov ax,[bx.tiffPict.cbitsSampleTiff]
; if ((*hpc)->tiff.wCompScheme == Scheme1)
; {
cmp [bx.tiffPict.wCompSchemeTiff],Scheme1
jz Ltemp001
jmp RTL11
Ltemp001:
; if (cbitsSample == 1)
; {
; RgbFromStm(hpPlane, cbRowFile);
; }
cmp ax,1
jnz RTL01
mov di,[OFF_hpPlane]
mov cx,[bx.tiffPict.cbRowFileTiff]
xor si,si ;make sure we initialize pstream
;LN_RgbFromStm blts cx bytes pointed to by the stream
;in ds:si to the hp in hpPlane in es:di.
;ax, bx, cx, si, di, ds, es are altered.
call LN_RgbFromStm
Ltemp002:
jmp RTL16
; else
; {
; char HUGE * hpSave;
; int ipl;
; unsigned bSpecial = 0x80;
; unsigned nb;
; int fFirstNibble = true;
; unsigned cbPlane = (*hpc)->cbPlane;
RTL01:
sub ax,4
jz RTL02
mov al,1
RTL02:
mov dh,1
xor dh,al
mov cx,[bx.vtExtPict.hGpoint]
mov bx,[bx.cbPlanePict]
mov di,[OFF_hpPlane]
mov dl,080H ;set bSpecial
mov ah,1
xor si,si ;make sure we initialize pstream
jmp short RTL06
RTL03:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
jmp short RTL07
RTL04:
push ax
and al,0fh
shl al,1
shl al,1
jmp short RTL08
; while (ibitIn < (*hpc)->vtExt.h)
; {
RTL06:
jcxz Ltemp002
; if (fFirstNibble)
; {
xor ah,dh
test ah,dh
jne RTL04
; b = BFromStm();
; nb = (b & 0xf0) >> 2;
; if (cbitsSample == 4)
; fFirstNibble = false;
; }
test si,001FFh
je RTL03
RTL07:
lodsb
push ax
and al,0f0h
shr al,1
shr al,1 ;si = nb
;Assembler note: the else clause here is done at RTL04
; else
; {
; nb = (b & 0x0f) << 2;
; fFirstNibble = true;
; }
; hpSave = hpPlane;
RTL08:
xor ah,ah
add ax,offset [mpnbb]
push di ;save OFF_hpPlane
push si ;save OFF_hpStream
xchg ax,si
; for (ipl=0; ipl<4; ipl++)
; {
; *hpPlane |= (mpnbb[nb++] & bSpecial);
; hpPlane += cbPlane;
; }
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
; hpPlane = hpSave;
pop si ;restore OFF_hpStream
pop di ;restore OFF_hpPlane
pop ax
; bSpecial >>= 1;
; if (bSpecial == 0)
; {
; bSpecial = 0x80;
; hpPlane++;
; }
; ibitIn++;
; }
; }
; }
dec cx ;ibitIn++
ror dl,1
jnc RTL06
inc di ;hpPlane++;
jmp short RTL06
RTL09:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
jmp short RTL13
RTL10:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
jmp short RTL14
; else
; {
; int w;
; while (ibIn < cbRowFile)
; {
; w = (signed char)BFromTIFF();
RTL11:
mov di,[OFF_hpPlane] ;es:di = lpPlane
mov bx,[bx.tiffPict.cbRowFileTiff]
xor dx,dx ;ibIn = 0;
xor si,si ;make sure we initialize pstream
RTL12:
cmp dx,bx
jge RTL16 ;goto LEntTIFF
test si,001FFh
je RTL09
RTL13:
lodsb ;get w
xchg ax,cx
xor ch,ch
; if (w < 0)
; {
or cl,cl
jge RTL15
; cb = -w+1;
; b = BFromTIFF();
; bltbcx(b, LpFromHp(hpPlane), cb);
; hpPlane += cb;
; ibIn += cb;
; }
neg cl
inc cx
test si,001FFh
je RTL10
RTL14:
lodsb ;get byte after w
add dx,cx ;ibIn+=cb
rep stosb
jmp RTL12
; else
; {
; cb = w+1;
; RgbFromStm(hpPlane, cb);
; hpPlane += cb;
; ibIn += cb;
; }
; }
; }
RTL15:
inc cx
add dx,cx
;LN_RgbFromStm blts cx bytes pointed to by the stream
;in ds:si to the hp in hpPlane in es:di.
;ax, bx, cx, si, di, ds, es are altered.
push bx ;save cbRowFile
call LN_RgbFromStm
pop bx ;restore cbRowFile
jmp short RTL12
;}
RTL16:
push ss
pop ds ;restore sbApp DS
and si,001FFh
je RTL17
sub si,00200h
add [stmGlobal.LO_fcStm],si
adc [stmGlobal.HI_fcStm],0FFFFh
RTL17:
cEnd
;-------------------------------------------------------------------------------
; LN_RgbFromStm
;-------------------------------------------------------------------------------
;LN_RgbFromStm blts cx bytes pointed to by the stream
;in ds:si to the hp in hpPlane in es:di.
;ax, bx, cx, si, di, ds, es are altered.
RFS01:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
mov bx,00200h
test si,001FFh
je RFS02
LN_RgbFromStm:
mov bx,si
neg bx
and bh,001h
RFS02:
mov ax,cx
sub ax,bx
jl RFS03
mov cx,bx
RFS03:
rep movsb
xchg ax,cx
or cx,cx
jg RFS01
ret
;-------------------------------------------------------------------------------
; LN_SetESFromHpPlane
;-------------------------------------------------------------------------------
;Sets es according to hpPlane. Only es is altered.
LN_SetEsFromHpPlane:
push bx
mov bx,[SEG_hpPlane]
;LN_ReloadSb sets ES corresponding to the sb in bx.
;Only bx and es are altered.
call LN_ReloadSb
pop bx
ret
;-------------------------------------------------------------------------------
; LN_SetEsDsSiFromStm
;-------------------------------------------------------------------------------
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
LN_SetEsDsSiFromStm:
push ax
push bx
push cx
push dx
push ss
pop ds ;restore sbApp DS
push [stmGlobal.fnStm]
push [stmGlobal.HI_fcStm]
push [stmGlobal.LO_fcStm]
ifdef DEBUG
cCall S_HpchFromFc
else ;not DEBUG
cCall N_HpchFromFc
endif ;DEBUG
ifdef DEBUG
push ax
push bx
push cx
push dx
xor ax,[stmGlobal.LO_fcStm]
and ax,001FFh
je SDSFS01
mov ax,midGrhc
mov bx,1000 ; label # for native assert
cCall AssertProcForNative, <ax, bx>
SDSFS01:
pop dx
pop cx
pop bx
pop ax
endif ;DEBUG
add [stmGlobal.LO_fcStm],00200h ; increment fc
adc [stmGlobal.HI_fcStm],0
and [stmGlobal.LO_fcStm],0FE00h
;Do this extra LN_SetEsFromHpPlane to avoid an LMEM quirk.
;It is possible that the call later on to ReloadSb for SEG_hpPlane
;would force out the ps for SB_stream. This would happen if now
;SB_stream was oldest on the LRU list but still swapped in, and
;SEG_hpPlane was swapped out. In that event ReloadSb would not
;be called for SB_stream, the LRU entry would not get updated,
;and the call to ReloadSb for SEG_hpPlane would swap out SB_stream.
;Sets es according to hpPlane. Only es is altered.
call LN_SetEsFromHpPlane
xchg ax,si
mov bx,dx
;LN_ReloadSb sets ES corresponding to the sb in bx.
;Only bx and es are altered.
call LN_ReloadSb
push es
;Sets es according to hpPlane. Only es is altered.
call LN_SetEsFromHpPlane
pop ds
pop dx
pop cx
pop bx
pop ax
ret
;-------------------------------------------------------------------------------
; LN_ReloadSb
;-------------------------------------------------------------------------------
;LN_ReloadSb sets ES corresponding to the sb in bx.
;Only bx and es are altered.
LN_ReloadSb:
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,ds
mov bx,ss
cmp ax,bx
je LN_RS01
mov ax,midGrhc
mov bx,1001 ; label # for native assert
cCall AssertProcForNative, <ax, bx>
LN_RS01:
pop dx
pop cx
pop bx
pop ax
endif ;DEBUG
push ax
shl bx,1
mov ax,[bx.mpsbps]
mov es,ax
shr ax,1
jc LN_RS02
push cx
push dx
; ReloadSb trashes ax, cx, and dx
cCall ReloadSb,<>
pop dx
pop cx
LN_RS02:
pop ax
ret
;=========================================================================
;
; UDiv : divide first parm by third parm ( yielding 16 bit result )
;
; int MultDiv(wNumer, wDenom, pRemain)
; int wNumer, wDenom;
; int *pRemain;
; {
; *pRemain = wNumer % wDenom;
; return ( wNumer / wDenom );
; }
;
;=========================================================================
; %%Function: UDiv %%Owner: Bobz
;
cProc UDiv,<FAR,PUBLIC>,<>
ParmW <wNumer, wDenom, pRemain>
cBegin UDiv
xor dx,dx ; DX:AX = numerator
mov ax,[wNumer] ;
mov cx,[wDenom] ; CX = denominator
jcxz UDOv
div cx ; and divide by wDenom
UDret:
mov bx,pRemain ;
mov [bx],dx ; store the remainder
cEnd UDiv
UDOv:
mov ax,0FFFFH
jmp UDret
sEnd GRTIFF
end
+438
View File
@@ -0,0 +1,438 @@
ifdef DEBUG
externFP <AssertProcForNative,ScribbleProc,ShakeHeapSb>
endif ;/* DEBUG */
; *** macros stolen from pc word to support tiff *******
AssertEQ MACRO expr1,expr2,mid,line ; if (expr1 != expr2) halt
LOCAL ok
ifdef DEBUG
push ax ; save ax
mov ax,expr1 ;
cmp ax,expr2 ;
pop ax ; restore ax, doesn't affect flags
je ok ; ok iff compare was zero
push ax
push bx
push cx
push dx
mov ax,mid
mov bx,line
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
endif
ok:
ENDM
AssertGT MACRO expr1,expr2,mid,line ; if (expr1 <= expr2) halt
LOCAL ok
ifdef DEBUG
push ax ; save ax
mov ax,expr1 ;
cmp ax,expr2 ; compared to second
pop ax ; restore ax, doesn't affect flags
jg ok ; ok iff expr1 < expr2
push ax
push bx
push cx
push dx
mov ax,mid
mov bx,line
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
endif
ok:
ENDM
;--------------------------------------------------------------------------
; cassume
; Conditional assume macro. Creates an "assumes" statement only
; if segreg is a segment register
;--------------------------------------------------------------------------
cassume MACRO segreg,segment
irp sr,<es,ds,ss>
ifidni <segreg>,<sr>
assumes <segreg>,<segment>
endif
endm
ENDM
EXPMSG MACRO name
if1
%out Expanding name in-line
endif
ENDM
CallProc MACRO name,parms
cCall <&name>,<&parms>
ENDM
;**************************************************************************
;
; Macros for using SB's
;
; Stolen from cbox's macros.inc, 29 Apr 88
;
;**************************************************************************
externA _sbMax
ifndef dos_asm
externFP ReloadSb
endif
;
; only save reg if in save1 - save4 (used in PsFromSb)
;
PushSelectReg MACRO reg,save1,save2,save3,save4
ifidn <save1>,<reg>
push save1
endif
ifidn <save2>,<reg>
push save2
endif
ifidn <save3>,<reg>
push save3
endif
ifidn <save4>,<reg>
push save4
endif
ENDM
;
; Restore reg if in save1 - save4 (used in PsFromSb)
;
PopSelectReg MACRO reg,save1,save2,save3,save4
ifidn <save1>,<reg>
pop save1
endif
ifidn <save2>,<reg>
pop save2
endif
ifidn <save3>,<reg>
pop save3
endif
ifidn <save4>,<reg>
pop save4
endif
ENDM
;
; Save all registers in save1-4 except reg (used in PsFromSb)
;
PushNReg MACRO reg,save1,save2,save3,save4
ifdif <save1>,<>
ifdif <save1>,<reg>
push save1
endif
endif
ifdif <save2>,<>
ifdif <save2>,<reg>
push save2
endif
endif
ifdif <save3>,<>
ifdif <save3>,<reg>
push save3
endif
endif
ifdif <save4>,<>
ifdif <save4>,<reg>
push save4
endif
endif
ENDM
;
; Restore all registers in save1-4 except reg. (used in PsFromSb)
;
PopNReg MACRO reg,save1,save2,save3,save4
ifdif <save1>,<>
ifdif <save1>,<reg>
pop save1
endif
endif
ifdif <save2>,<>
ifdif <save2>,<reg>
pop save2
endif
endif
ifdif <save3>,<>
ifdif <save3>,<reg>
pop save3
endif
endif
ifdif <save4>,<>
ifdif <save4>,<reg>
pop save4
endif
endif
ENDM
;
; Save any specified registers on the stack.
;
PushReg MACRO save1,save2,save3,save4
ifdif <save1>,<>
push save1
endif
ifdif <save2>,<>
push save2
endif
ifdif <save3>,<>
push save3
endif
ifdif <save4>,<>
push save4
endif
ENDM
;
; Restore the specified registers from the stack.
;
PopReg MACRO save1,save2,save3,save4
ifdif <save1>,<>
pop save1
endif
ifdif <save2>,<>
pop save2
endif
ifdif <save3>,<>
pop save3
endif
ifdif <save4>,<>
pop save4
endif
ENDM
;==========================================================================
; Segmentation macros.
; These macros are used to change the current sb and/or load the
; physical segment (ps). The scratchReg parameter is optional.
; If no scratchReg is specified, an extra push/pop usually is done
; to free up a register to use. If sb != scratchReg, an extra
; register move is usually necessary. An appropriate CMACROS
; "assumes" statement is included.
;==========================================================================
;--------------------------------------------------------------------------
; PsFromSb
; Load the specified segment register with the physical segment
; specified by sb. The special cases of sb == sbDds and sb == sbCur
; are taken into account if the parameter is "sbDds" or "sbCur".
;
; EMM support: if sb is other than sbCur or sbDds, then ReloadSb
; may be called to load a segment. in this case the save registers
; will be pushed to preserve values.
;
; note that if sb is other than sbCur or sbDds you must give
; a scratch register. if you don't have one, then also specify it
; as a save register. in this case, the most efficient call is with
; segreg = es and scratchreg = bx (and obviously, no save registers).
;
; To ensure that 2 segments other than sbCur are resident this macro
; must be used 3 times -- once with one segment, then with the 2nd,
; then again with the first again.
;
; UPDATE: ds does not need to equal ss on entry - ss overide prefix is
; now used to access mpsbps. Since ReloadSb loads es, an extra push
; and pop of es is required if es != segreg. If you want to use
; ds = segreg, it is best to use the macro with es, then set ds = es.
;
; OS/2 support (DOS5 flag): ReloadSb isn't called, since it doesn't
; exist. Just load up the segreg, and get out.
;
;--------------------------------------------------------------------------
PsFromSb MACRO segreg,sb,scratchReg,save1,save2,save3,save4
LOCAL ok
LOCAL ok1
ifidn <sb>,<sbDds> ; if sb == sbDds == 1
ifidn <scratchReg>,<>
errnz <sbDds-1> ; error at assembly if sbDds != 1
mov segreg,ss:mpsbps[2] ; segreg = mpsbps[sbDds]
else
mov scratchReg,ss
mov segreg,scratchReg
endif
cassume segreg,DATA ;
else
ifidn <sb>,<sbCur>
mov segreg,psCur ; segreg = psCur
cassume segreg,NOTHING
else
PushSelectReg ax,save1,save2,save3,save4 ;save ax if in save1-4
ifdif <scratchReg>,<sb>
mov scratchReg,sb
endif
ifdef DEBUG
cmp scratchReg,_sbMax
jb ok1
int 3
ok1:
endif ; DEBUG
shl scratchReg,1
mov segreg,ss:mpsbps[scratchReg] ;segreg = mpsbps[sb]
ifndef DOS5
mov ax,segreg
shr ax,1
jc ok
PushNReg ax,save1,save2,save3,save4 ;save all regs except ax
ifdif <scratchreg>,<bx>
mov bx,scratchreg
endif
ifdif <segreg>,<es>
push es
endif
call ReloadSb
ifdif <segreg>,<es>
mov ax,es
mov segreg,ax
pop es
endif
PopNReg ax,save4,save3,save2,save1 ;restore all regs except ax
ok:
endif ; !DOS5
PopSelectReg ax,save4,save3,save2,save1 ;restore ax if in save1-4
cassume segreg,NOTHING
endif
endif
ENDM
; useful for accessing far pointers, longs, or double words in memory
wHigh equ 2+word ptr ;; upper word (or segment) of a long
wLow equ word ptr ;; lower word (or offset) of a long
bPtr EQU BYTE PTR
; constants - taken from grconsts.db in PC WORD
icoBitMax equ 16
cbRowPat equ icoBitMax
; constants - from grstruct.h compiled with -Si flag
Scheme1 equ 1
; data structures - from grstruct.h compiled with -Si flag
xGpoint equ [word ptr 00000h]
yGpoint equ [word ptr 00002h]
hGpoint equ [word ptr 00000h]
vGpoint equ [word ptr 00002h]
cbGpointMin equ 00004h
; TIFF structure
wCompSchemeTiff equ [word ptr 00000h]
crwStripTiff equ [word ptr 00002h]
fcStripOffsetsTiff equ [dword ptr 00004h]
LO_fcStripOffsetsTiff equ [word ptr 00004h]
HI_fcStripOffsetsTiff equ [word ptr 00006h]
fShortStripOffsetTiff equ [word ptr 00008h]
irwNextTiff equ [word ptr 0000Ah]
fcPrevTiff equ [dword ptr 0000Ch]
LO_fcPrevTiff equ [word ptr 0000Ch]
HI_fcPrevTiff equ [word ptr 0000Eh]
fcTrailTiff equ [dword ptr 00010h]
LO_fcTrailTiff equ [word ptr 00010h]
HI_fcTrailTiff equ [word ptr 00012h]
irwTrailTiff equ [word ptr 00014h]
cbitsSampleTiff equ [word ptr 00016h]
fSwitchBytesTiff equ [word ptr 00018h]
cbRowFileTiff equ [word ptr 0001Ah]
cbTiffMin equ 0001Ch
; PICT structure
ftPict equ [word ptr 00000h]
fnPict equ [word ptr 00002h]
vtOrgPict equ [dword ptr 00004h]
LO_vtOrgPict equ [word ptr 00004h]
HI_vtOrgPict equ [word ptr 00006h]
vtExtPict equ [dword ptr 00008h]
LO_vtExtPict equ [word ptr 00008h]
HI_vtExtPict equ [word ptr 0000Ah]
pixOrgPict equ [dword ptr 0000Ch]
LO_pixOrgPict equ [word ptr 0000Ch]
HI_pixOrgPict equ [word ptr 0000Eh]
pixExtPict equ [dword ptr 00010h]
LO_pixExtPict equ [word ptr 00010h]
HI_pixExtPict equ [word ptr 00012h]
bits0Pict equ [word ptr 00014h]
bits0recPict record fSparePict:12,fReallocPict:1,fGrayDitherPict:1,fColorDitherPict:1,fLSRotatePict:1
cgraphicbytesPict equ [word ptr 00016h]
crwSwathPict equ [word ptr 00018h]
cbSwathMinPict equ [word ptr 0001Ah]
cbRowMinPict equ [word ptr 0001Ch]
iPassPict equ [word ptr 0001Eh]
cplInPict equ [word ptr 00020h]
cplOutPict equ [word ptr 00022h]
cbExtraPict equ [word ptr 00024h]
cbRowInPict equ [word ptr 00026h]
cbRowOutPict equ [word ptr 00028h]
cbPassOutPict equ [word ptr 0002Ah]
sbBitsPict equ [word ptr 0002Ch]
cbBitsPict equ [word ptr 0002Eh]
cbPlanePict equ [word ptr 00030h]
ibInPict equ [word ptr 00032h]
irwInMaxPict equ [word ptr 00034h]
irwOutMaxPict equ [word ptr 00036h]
irwInMicPict equ [word ptr 00038h]
irwOutMicPict equ [word ptr 0003Ah]
irwInMacPict equ [word ptr 0003Ch]
irwOutMacPict equ [word ptr 0003Eh]
irwOutNextPict equ [word ptr 00040h]
smPict equ [word ptr 00042h]
crwRepNormPict equ [word ptr 00044h]
wRowDeltaPict equ [word ptr 00046h]
crwRevRepNormPict equ [word ptr 00048h]
wRevRowDeltaPict equ [word ptr 0004Ah]
cbitRepNormPict equ [word ptr 0004Ch]
wBitDeltaPict equ [word ptr 0004Eh]
sbPatPict equ [word ptr 00050h]
rgicoPict equ [00052h]
hbmPict equ [word ptr 00062h]
dybBmPict equ [word ptr 00064h]
hMDCPict equ [word ptr 00066h]
rcClipPict equ [00068h]
tiffPict equ [00070h]
cbPictMin equ 0008Ch
; STM structure
fnStm equ [word ptr 00000h]
fcStm equ [dword ptr 00002h]
LO_fcStm equ [word ptr 00002h]
HI_fcStm equ [word ptr 00004h]
fcMacStm equ [dword ptr 00006h]
LO_fcMacStm equ [word ptr 00006h]
HI_fcMacStm equ [word ptr 00008h]
cbStmMin equ 0000Ah
; External Data **********************************
sBegin data
extrn _sbMax:ABS
sbMax equ _sbMax
externW sbCur
externW mpsbps
externW psCur
externW stmGlobal
sEnd
+211
View File
@@ -0,0 +1,211 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg index2_PCODE,index2,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midIndex2n equ 34 ; module ID, for native asserts
endif
; EXTERNAL FUNCTIONS
externFP <N_WCompSzSrt>
externFP <ReloadSb>
ifdef DEBUG
externFP <AssertProcForNative>
externFP <S_WCompSzSrt>
endif ;DEBUG
sBegin data
; EXTERNALS
externW mpsbps
; #ifdef DEBUG
ifdef DEBUG
externW vcComps
externW wFillBlock
; #endif /* DEBUG */
endif
sEnd data
; CODE SEGMENT _INDEX2
sBegin index2
assumes cs,index2
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; WCompRgchIndex(hpch1, cch1, hpch2, cch2)
;-------------------------------------------------------------------------
;/* W C O M P R G C H I N D E X */
;/* Routine to compare RGCH1 and RGCH2
; Return:
; 0 if rgch1 = rgch2
; negative if rgch1 < rgch2
; positive if rgch1 > rgch2
; This routine is case-insensitive
; soft hyphens are ignored in the comparison
;*/
; %%Function:WCompRgchIndex %%Owner:BRADV
;HANDNATIVE int WCompRgchIndex(hpch1, cch1, hpch2, cch2)
;char HUGE *hpch1, HUGE *hpch2;
;int cch1, cch2;
;{
; char *pch;
; char HUGE *hpchLim;
; char sz1[cchMaxEntry+2];
; char sz2[cchMaxEntry+2];
cProc N_WCompRgchIndex,<PUBLIC,FAR,ATOMIC>,<si,di>
ParmD hpch1
OFFBP_hpch1 = -4
ParmW cch1
OFFBP_cch1 = -6
ParmD hpch2
OFFBP_hpch2 = -10
ParmW cch2
OFFBP_cch2 = -12
LocalV sz1,<cchMaxEntry+2>
LocalV sz2,<cchMaxEntry+2>
cBegin
; Debug(++vcComps);
ifdef DEBUG
inc [vcComps]
endif ;DEBUG
; Assert(cch1 < cchMaxEntry);
; for (pch = sz1, hpchLim = hpch1 + cch1;
; hpch1 < hpchLim; hpch1++)
; {
; if (*hpch1 != chNonReqHyphen)
; *pch++ = *hpch1;
; }
; *pch = 0;
lea si,[sz1]
push si ;argument for WCompSzSrt
lea di,[hpch1]
call WCRI01
; Assert(cch2 < cchMaxEntry);
; for (pch = sz2, hpchLim = hpch2 + cch2;
; hpch2 < hpchLim; hpch2++)
; {
; if (*hpch2 != chNonReqHyphen)
; *pch++ = *hpch2;
; }
; *pch = 0;
lea si,[sz2]
push si ;argument for WCompSzSrt
lea di,[hpch2]
call WCRI01
; return (WCompSzSrt(sz1, sz2, fFalse /* not case sensitive */));
errnz <fFalse>
xor ax,ax
push ax
ifdef DEBUG
cCall S_WCompSzSrt,<>
else ;not DEBUG
cCall N_WCompSzSrt,<>
endif ;DEBUG
;}
cEnd
WCRI01:
; Assert(cch < cchMaxEntry);
ifdef DEBUG
errnz <OFFBP_hpch1 - OFFBP_cch1 - 2>
errnz <OFFBP_hpch2 - OFFBP_cch2 - 2>
cmp wptr [di+(OFFBP_cch1 - OFFBP_hpch1)],cchMaxEntry
jb WCRI02
push ax
push bx
push cx
push dx
mov ax,midIndex2n
mov bx,1001 ; label # for native assert
cCall AssertProcForNative, <ax, bx>
pop dx
pop cx
pop bx
pop ax
WCRI02:
endif ;DEBUG
; for (pch = sz, hpchLim = hpch + cch;
; hpch < hpchLim; hpch++)
; {
; if (*hpch != chNonReqHyphen)
; *pch++ = *hpch;
; }
mov bx,[di+2] ;get SEG_hpch
shl bx,1
mov ax,mpsbps[bx]
mov es,ax
shr ax,1
jc WCRI03
; reload sb trashes ax, cx, and dx
cCall ReloadSb,<>
ifdef DEBUG
mov ax,[wFillBlock]
mov bx,[wFillBlock]
mov cx,[wFillBlock]
mov dx,[wFillBlock]
endif ;DEBUG
WCRI03:
errnz <OFFBP_hpch1 - OFFBP_cch1 - 2>
errnz <OFFBP_hpch2 - OFFBP_cch2 - 2>
mov cx,[di+(OFFBP_cch1 - OFFBP_hpch1)]
mov di,[di] ;get OFF_hpch
mov al,chNonReqHyphen
WCRI04:
mov dx,di
repne scasb ;look for chNonReqHyphen
push cx
push di
push es
pop ds
push ss
pop es
mov cx,di
mov di,si
mov si,dx
jne WCRI05 ;if we found a chNonReqHyphen, don't copy it
dec cx
WCRI05:
sub cx,dx
rep movsb ;copy up to the chNonReqHyphen or end of rgch
mov si,di
push ds
pop es
push ss
pop ds
pop di
pop cx
or cx,cx ;more characters in rgch?
jne WCRI04 ;yes - look for more chNonReqHyphens
; *pch = 0;
mov bptr [si],0
ret
; End of WCompRgchIndex
sEnd index2
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+76
View File
@@ -0,0 +1,76 @@
; movecmd.asm -- move the command table
?PLM = 1
?WIN = 1
include w2.inc
include cmacros.inc
createSeg initwin_PCODE, INIT, BYTE, PUBLIC, CODE
sBegin INIT
assumes CS, INIT
externB vsytInit
externB vkmpInit
externB vmudInit
externB vsttbMenuBase
externB vsttbMenuRgbst
; %%Function:MoveCmds %%Owner:bradch
cProc MoveCmds, <PUBLIC, FAR>, <di, si, ds>
parmD lpsyt
parmD lpkmp
parmD lpmud
parmD lpsttb
parmD lprgbst
cBegin MoveCmds
push cs
pop ds
; do command table
les di,lpsyt
mov si, initOffset vsytInit
lodsw ; ax = *pSource++ (cw)
mov cx,ax
rep movsw
; now do keymap
les di, lpkmp
mov si, initOffset vkmpInit
lodsw
mov cx,ax
rep movsw
; menu delta
les di,lpmud
mov si,initOffset vmudInit
lodsw
mov cx,ax
rep movsw
; menu string table base
les di,lpsttb
mov si,initOffset vsttbMenuBase
lodsw
mov cx,ax
rep movsw
; menu string table rgbst & strings
les di,lprgbst
mov si,initOffset vsttbMenuRgbst
lodsw
mov cx,ax
rep movsw
cEnd MoveCmds
sEnd INIT
end
+174
View File
@@ -0,0 +1,174 @@
include w2.inc
include noxport.inc
include windows.inc
.list
createSeg initwin_PCODE,natinit,byte,public,CODE
ifdef HYBRID
externFP <DeleteDCPR>
else ;!HYBRID
externFP <DeleteDC>
endif ;!HYBRID
externFP <GetWindowDC, LocalAlloc, LocalFree, GetVersion>
externFP <GetCurPID, GetNumTasks>
externA __ahshift
sBegin data
externW vwWinVersion
externW vfLargeFrameEMS
externW vfSmallFrameEMS
externW vfSingleApp
externW vcbitSegmentShift
sEnd data
sBegin natinit
assumes cs,natinit
assumes ds,dgroup
assumes ss,dgroup
;/* **** +-+utility+-+string **** */
;-----------------------------------------------------------------------------
; FillBytePattern( pb, rgchPat, cchPat, cb ) - fills pb with cb bytes of
; repeating pattern given by { rgchPat, cchPat }
;-----------------------------------------------------------------------------
;%%Function:FillBytePattern %%Owner:PETERJ
cProc FillBytePattern, <FAR, PUBLIC,ATOMIC>, <DI,SI>
parmDP <pb>
parmW <rgchPat>
parmW <cchPat>
parmW <cb>
;/* **** -+-utility-+- **** */
cBegin FillBytePattern
mov ax,ds ; we are filling in the data segment
mov es,ax
cld ; the operation is forward
mov di,[pb]
cmp [cchPat],1 ; interesting, faster, special case
jz LFBP0 ; requires di = pb
LFBP2: mov ax,[cchPat]
mov bx,[cb]
sub ax,bx ; tricky min
cwd
and ax,dx
add ax,bx
mov cx,ax ; cx = min( cchPat, cb );
mov si,[rgchPat] ; pchPat = rgchPat
sub [cb],cx ; cb -= cx
rep movsb ; while (cx--) *pb++ = *pchPat++
cmp [cb],0 ; if (cb != 0) goto LFBP2
jne LFBP2
jmp LFBP1
; requires di = pb
LFBP0:
mov si,[rgchPat] ; while (cb--) *pb++ = rgchPat[0];
mov al,[si]
mov cx,[cb]
rep stosb
LFBP1:
cEnd FillBytePattern
ifdef HYBRID
DeleteDCAddr dd DeleteDCPR
else ;!HYBRID
DeleteDCAddr dd DeleteDC
endif ;!HYBRID
GetWindowDCAddr dd GetWindowDC
;%%Function:GlobalMemInit %%Owner:PETERJ
cProc GlobalMemInit,<PUBLIC,FAR>,<si>
cBegin
;
; Try to grow GDI and USERs local heap so global wires that we
; do later are more likely to be effective.
;
lds bx,cs:[DeleteDCAddr]
mov ax,1000H
mov cx,0A40H
call GrowHeap
lds bx,cs:[GetWindowDCAddr]
mov ax,3420H
mov cx,0010H
call GrowHeap
push ss
pop ds
cEnd
GrowHeap:
cmp byte ptr [bx],0b8h ; look for mov ax, ....
jnz lax
mov ds,[bx+1] ; set DS to GDIs DS
mov bx,LMEM_FIXED + LMEM_NODISCARD + LMEM_NOCOMPACT
push bx
push cx
cCall LocalAlloc,<bx,ax>
mov si,ax
cCall LocalAlloc
or ax,ax
jz la1
cCall LocalFree,<ax>
la1: or si,si
jz lax
cCall LocalFree,<si>
lax: ret
;-----------------------------------------------------------------------------
; BOOL FNativeInit
;
; Perform init tasks best done in native
;-----------------------------------------------------------------------------
; %%Function:FNativeInit %%Owner:PETERJ
cProc FNativeInit, <FAR, PUBLIC>,<si,di>
cBegin FNativeInit
cCall GetNumTasks,<> ; see if MS-DOS Exec is running
mov bx,1
cmp ax,bx
je FNIsingleapp ; opus is only app
dec bx ; some other app is running (esp MS-DOS)
FNIsingleapp:
mov [vfSingleApp],bx
mov [vcbitSegmentShift],__ahshift
mov ah,30h ; get DOS version
int 21h
cmp al,3 ; see if it is the wrong version (< 3)
jl FNIfail
cCall GetVersion,<> ; get WIN version
xchg al,ah ; make non bogus
mov [vwWinVersion],ax
cmp ax,00203h ; see if it is the wrong version (< 2.03)
jl FNIfail ; NOTE: documentation says 2.10,
; so we can bump this up if necessary
xor ax,ax ; see if windows is using LIM 4.0
cCall GetCurPID,<ax,ax> ; puts EMSFlags in dx
test dx,02h ; EMSF_LIM_40
jz FNIok
; kernel is using LIM4.0
; is it using small frame or large frame?
test dx,08h ; EMSF_DATA_ABOVE
jz FNIsmall
mov [vfLargeFrameEMS],1 ; large frame
jmp FNIok
FNIsmall:
mov [vfSmallFrameEMS],1 ; small frame
FNIok:
mov ax,1 ; return success
FNIret:
cEnd FNativeInit
FNIfail:
xor ax,ax ; return failure
jmp FNIret
sEnd natinit
end
+803
View File
@@ -0,0 +1,803 @@
include w2.inc
include noxport.inc
include consts.inc
include windows.inc
errNull equ 0
errDiv0 equ (errNull+7)
errVal equ (errDiv0+8)
errRef equ (errVal+8)
errName equ (errRef+6)
errNum equ (errName+7)
errNa equ (errNum+6)
errMax equ (errNa+5)
errNil equ errMax
createSeg trans,trans,byte,public,CODE
externFP <DADD,DMUL,DSUB,DDIV,DNEG,DINT,SFLOAT,FIX,DDIV2>
externFP <SetSbCur, ReloadSb>
OverErr EQU 0001H ;Overflow error indicator
UnderErr EQU 0002H ;Underflow error indicator
DivBy0 EQU 0004H ;Divide by 0 indicator
TransErr EQU 0008H ;Transcendental error indicator
POLY1 EQU 8000h ; flag for leading 1 in poly
EXPMASK EQU 07FF0h
EXPBIAS EQU 03FF0h
EXPSHFT EQU 4
MANBITS EQU 53
OF_EXP EQU 6
OF_SGN EQU 7
sBegin data
externW mpsbps
externW pdAcc
externW fError
externW AC_HI
externW AC_LO
externB round_flag
externW round_exp
externW f8087
ArgTran DQ ?
TempTran1 DQ ?
TempTran2 DQ ?
TempTran3 DQ ?
SgnTrig DB ? ; sign/cosine flag
ILNinterval DQ 03FF71547652B82FER ; 1/ln(2)
ISQRbase DQ 03FE6A09E667F3BCDR ; 1/sqr(2)
LNXMAX DQ 040862E42FEFA39EER ; 1024*ln(2)-2eps
LNXMIN DQ 0C086232BDD7ABCD1R ; -1022*ln(2)+2eps
ExpC1 DQ 03FE6300000000000R ; ln(2)
ExpC2 DQ 0BF2BD0105C610CA8R
LogATab DW 2
DQ 0BFE94415B356BD29R ;-0.78956112887491257267E+00
DQ 04030624A2016AFEDR ;+0.16383943563021534222E+02
DQ 0C05007FF12B3B59AR ;-0.64124943423745581147E+02
LogBTab DW 3
numOne DQ 03FF0000000000000R ;+0.10000000000000000000E+01
DQ 0C041D5804B67CE0FR ;-0.35667977739034646171E+02
DQ 040738083FA15267ER ;+0.31203222091924532844E+03
DQ 0C0880BFE9C0D9077R ;-0.76949932108494879777E+03
ExpPTab DW 2
DQ 03EF152A46F58DC1CR ;+0.165203300268279130E-04
DQ 03F7C70E46FB3F6E0R ;+0.694360001511792852E-02
DQ 03FD0000000000000R ;+0.249999999999999993E+00
ExpQTab DW 2
DQ 03F403F996FDE3809R ;+0.495862884905441294E-03
DQ 03FAC718E714251B3R ;+0.555538666969001188E-01
numHalf DQ 03FE0000000000000R ;+0.500000000000000000E+00
sEnd data
sBegin trans
assumes cs,trans
assumes ds,dgroup
assumes ss,dgroup
; %%Function:LOGNAT %%Owner:bryanl
cProc LOGNAT,<PUBLIC,NEAR>
LocalQ LOG_LO
LocalQ LOG_HI
cBegin
call ResetSbTrans
mov ax,[si+of_exp] ; save copy of sign:exp:himan
mov bx,ax
AND BX,8000h+expmask ;Taking log of zero?
jg LnPos
mov [ferror],TransErr
jmp LnExit
LnPos:
call LogCore
mov ax,dataOffset AC_HI
cCall DADD,<ax>
lea ax,LOG_HI
cCall DADD,<ax> ; AC = log(x) (normal precision)
LnExit:
cEnd
LogCore:
AND AX,not expmask
OR AX,expbias-(1 shl expshft)
mov [si+of_exp],ax ; Convert DAC to range [.5,1)
XCHG AX,BX
SUB AX,expbias-(1 shl expshft) ; Convert exponent to 16-bit integer
mov cl,expshft
sar ax,cl ; shift to integer
PUSH AX
mov di,dataOffset ArgTran
call dstdi
; At this point AC = Y
mov ax,dataOffset ISQRbase
cCall DSUB,<ax> ;AC < 1/SQR(base)
mov si,[si+of_exp]
call dlddi
or si,si
pop si ; get exponent
mov cl,00010000b ; assume in range AC < 1.0
jg dlog1 ; No - in range
dec si ; and adjust exponent down 1
add word ptr [pdAcc+of_exp],1 shl expshft ; * 2
mov cl,00001000b ; Y >= 1.0 divide adjustment
dlog1:
push cx ; save divide adjustment
call dstdi
cCall SFLOAT,<si> ; AC = XN
mov si,dataOffset TempTran1
mov bx,si
call dst
mov ax,dataOffset ExpC2
cCall DMUL,<ax>
lea bx,LOG_LO
call dst ; LOG_LO = XN*C2
mov bx,si
call dld
mov ax,dataOffset ExpC1
cCall DMUL,<ax>
lea bx,LOG_HI
call dst
mov ax,word ptr [pdAcc+of_exp] ; get exponent
and ax,expmask
shl ax,1 ; shift into highest bits
mov [ROUND_EXP],ax ; set round threshold
call dlddi
mov ax,dataOffset numOne
cCall DSUB,<ax> ; AC = Y-1
pop ax
mov [ROUND_FLAG],al ; set special round flag for divide
cCall DDIV2,<di> ; AC = 2*(Y-1)/(Y+1) (trick divide)
mov bx,dataOffset LogATab
mov cx,dataOffset LogBTab
call z3p_q ; z^3*A(z*z)/B(z*z)
mov ax,dataOffset AC_LO
cCall DADD,<ax>
lea si,LOG_LO
cCall DADD,<si> ; LOG_LO = XN*C2+lo(S)+S*r(S^2)
ret
; %%Function:LN %%Owner:bryanl
cProc LN,<PUBLIC,FAR>,<si,di>
cBegin
cCall LOGNAT
cEnd
;*** EXP - exponential function
; %%Function:ETOX %%Owner:bryanl
cProc ETOX,<PUBLIC,NEAR>
cBegin
call ResetSbTrans
mov di,dataOffset ArgTran ; save X in argtran
call dstdi
call EXPrange ; check for proper range
MOV AX,word ptr [SI+of_exp] ; get exponent
AND AX,expmask ; mask off sign, hi mantissa
CMP AX,expbias-((manbits+1) shl expshft) ; less than 2^(-54)
jae exp1
;
; Return ONE
;
mov bx,dataOffset numOne
call dld
jmp short ExpRet
;
; Return Zero
;
retzero:
mov di,dataOffset pdAcc
push ss
pop es
xor ax,ax
stosw
stosw
stosw
stosw
jmp short ExpRet
;
; Overflow
;
ovrflw2:
pop ax ; toss one more level off stack
ovrflw:
mov [fError],OverErr
jmp short ExpRet
;
; No errors, proceed
;
exp1:
CALL EXPM1
EXPadjust: ; finish up EXP
PUSH AX ; save integer part
mov ax,dataOffset numHalf
cCall DADD,<ax> ; AC = 0.5+g*P(z)/(Q(z)-g*P(z))
POP AX ; restore n
inc ax
mov cl,expshft
sal ax,cl
add word ptr [si+of_exp],ax ; adjust exponent
expRet:
cEnd
EXPM1:
mov di,dataOffset ILNinterval
cCall DMUL,<di> ; x/ln(interval)
mov al,[si+of_sgn] ; get sign
mov [SgnTrig],al
and byte ptr [si+of_sgn],01111111b ; make it positive
mov ax,dataOffset numHalf
cCall DADD,<ax> ; round to nearest int
cCall FIX ; get the int
test [SgnTrig],10000000b ; test the sign
jz expos
neg ax
expos:
call LNreduce ; reduce ARG by ax*LN(2)
EXPM1reduced: ; compute (EXP(X)-1)/2
push ax ; save n
mov bx,dataOffset ExpPTab
mov cx,dataOffset ExpQTab
call p_q
mov si,dataOffset TempTran3 ; point to z
cCall DMUL,<si> ; ac = z*P(z*z)
mov bx,si
call dst ; Temp3 = z*P(z*z)
cCall DNEG ; ac = -z*P(z*z)
mov di,dataOffset TempTran1 ; point to Q(z*z)
cCall DADD,<di> ; ac = Q(z*z)-z*P(z*z)
call dstdi ; Temp1 = ac
mov bx,si
call dld ; ac = z*P(z*z)
cCall DDIV,<di> ; AC = z*P(z*z)/(Q(z*z)-z*P(z*z))
mov si,dataOffset pdAcc ; si = ac
pop ax ; get integer part
ret
LNreduce: ; reduce ARG by LN(2)
push ax ; save n
cCall SFLOAT,<ax> ; XN
mov bx,dataOffset ExpC1
mov cx,dataOffset ExpC2
call REDUCE
pop ax ; get integer part
ret
overflowrange:
mov ax,transOffset ovrflw2 ; overflow on upper limit
jmp short range
EXPrange:
mov bx,transOffset retzero ; standard returns for EXP
mov ax,transOffset ovrflw ; overflow on upper limit
range:
push ax
push bx
mov ax,dataOffset LNXMAX
cCall DSUB,<ax>
cmp byte ptr [si+of_sgn],0
jg rangeax ; overflow on upper limit
mov di,dataOffset ArgTran
call dlddi
mov ax,dataOffset LNXMIN
cCall DSUB,<ax>
cmp byte ptr [si+of_sgn],0 ; check lower limit
jl rangebx
call dlddi
add sp,4 ; clean ax,bx off stack
ret
rangeax:
pop bx
pop ax
pop bx ; toss return address
jmp ax ; return for x > LNXMAX
rangebx:
pop bx
pop ax
pop ax ; toss return address
jmp bx ; return for x < LNXMIN
; %%Function:EXP %%Owner:bryanl
cProc EXP,<PUBLIC,FAR>,<si,di>
cBegin
cCall ETOX
cEnd
;*** SQR - Double precision square root
;
; This routine takes the square root of the number in the accumulator,
; and leaves the result in the accumulator.
;
; Algorithm: x is initially adjusted so that the exponent is even
; (when the exponent is odd the exponent is incremented and the
; mantissa is shifted right one bit). The exponent is then divided
; by two and resaved. A single word estimate of y (the root of
; x) accurate to 5 bits is produced using a wordlength implementation
; of a linear polynomial approximation of sqrt x. Three or four
; Newton-Raphson iterations are then computed as follows:
;
; 1) qa*ya+r1a=xa:0h,ya=(ya+qa)/2
; 2) qa*ya+r1a=xa:xb,ya=(ya+qa)/2
; 3) qa*ya+r1a=xa:xb,qb*ya+r2a=r1a:xc,ya:yb=(ya:yb+qa:qb)/2
; *** iteration 4 implemented with standard divide ***
; 4) qa*ya+r1a=xa:xb,p1a:p1b=qa*yb,
; if p1a<r1a continue
; if p1a=r1a
; if p1b=xc continue else r1a=r1a+ya,qa=qa-1 endif,
; else r1a=r1a+ya,qa=qa-1,p1a:p1b=p1a:p1b-yb endif,
; r1a:r1b=r1a:xc-p1a:p1b,
; qb:ya+r2a=r1a:r1b,p2a:p2b=qb*yb,
; if p2a<r2a continue
; if p2a=r2a
; if p2b=xd continue else r2a=r2a+ya,qb=qb-1 endif,
; else r2a=r2a+ya,qb=qb-1,p2a:p2b=p2a:p2b-yb endif,
; r2a:r2b=r2a:xd-p2a:p2b,
; qc*ya+r3a=r2a:r2b,p3a:p3b=qc*yb,
; if p3a>=r3a then r3a=r3a+ya,qc=qc-1 endif,
; r3a=r3a-p3a,qd*ya+r4a=r3a:0h,
; ya:yb:yc:yd=(ya:yb:0h:0h+qa:qb:qc:qd)/2
; %%Function:SQRT %%Owner:bryanl
cProc SQRT,<PUBLIC,NEAR,ATOMIC>
cBegin
push bp
call ResetSbTrans
mov di,dataOffset TempTran1
MOV AX,[SI+6]
MOV BH,AL ; Save hi mantissa
TEST AX,07FF0h ; Test exponent
jz sqrxv ; Zero - return 0
AND AX,0FFF0h ; Mask off hi mantissa
jns sqr1 ; Negative - error
mov [fError],TransErr ; set transcendental error
sqrxv: jmp sqrx
sqr1:
SUB AX,03FE0h ; Remove excess from exponent
MOV BL,[SI+5]
MOV CX,[SI+3]
MOV DX,[SI+1] ;get first three mantissa words of x
SHL DX,1
RCL CX,1
RCL BX,1
SHL DX,1
RCL CX,1
RCL BX,1
SHL DX,1
RCL CX,1
RCL BX,1
OR BH,080h ;implied leading 1 now explicit
TEST AL,16 ;if exponent is even
JZ EXPEVEN ; bypass adjust
ADD AX,16 ;increment exponent
SHR BX,1
RCR CX,1
RCR DX,1 ;divide mantissa by 2
EXPEVEN:
SAR AX,1 ;divide exponent by 2
ADD AX,03FE0h ; Bias the exponent
MOV [DI+6],AX ; Store exponent of y
CMP BX,0FFFEH ;if mantissa < 0.FFFEh
JB NOTNEARONE1 ; perform main root routine
STC ;otherwise x to become (1+x)/2
JMP SHORT SINGLEDONE ;single precision complete
NOTNEARONE1:
PUSH DX ;save third mantissa word
MOV AX,0AFB1H ;AX=.AFB1h
MUL BX ;DX=.AFB1h*x
MOV BP,057D8H ;BP=.57D8h
ADD BP,DX ;BP=.AFB1h*x+.57D8h
JNC NORMEST ;if y is more than one
MOV BP,0FFFFH ; replace y with .FFFFh
NORMEST:
MOV DX,BX
XOR AX,AX ;load divide regs with xa:0h
DIV BP ;qa*ya+r1a=xa:0h
ADD BP,AX ;ya=ya+qa
RCR BP,1 ;ya=ya/2
MOV DX,BX
MOV AX,CX ;load divide regs with xa:xb
DIV BP ;qa*ya+r1a=xa:xb
STC ;add one to qa for better rounding
ADC BP,AX ;ya=ya+qa
RCR BP,1 ;ya=ya/2
MOV DX,BX
MOV AX,CX ;load divide regs with xa:xb
DIV BP ;qa*ya+r1a=xa:xb
MOV SI,AX ;save qa
POP AX ;load divide regs with r1a:xc
DIV BP ;qb*ya+r2a=r1a:xc
MOV BX,BP
MOV CX,AX ;move qa:qb
;no need to round with floating point operations following
; ADD CX,1 ;add one to qa:qb for better rounding
; ADC BX,SI ;ya:yb=ya:0h+qa:qb
ADD BX,SI ;ya:yb=ya:0h+qa:qb
SINGLEDONE:
;We now have BX:CX = (ya:yb)*2=ya:0h+qa:qb
XOR AX,AX
SHL CX,1
RCL BX,1
RCL AX,1
SHL CX,1
RCL BX,1
RCL AX,1
SHL CX,1
RCL BX,1
RCL AX,1
SHL CX,1
RCL BX,1
RCL AX,1 ;back to IEEE format
OR [DI+6],AL
MOV [DI+4],BX
MOV [DI+2],CX
MOV WORD PTR [DI],0 ;save ya:yb:0h:0h
cCall DDIV,<di> ;accumulator (x)=x/y
cCall DADD,<di> ;accumulator (x)=y+x/y
SUB WORD PTR [pdAcc+of_exp],16 ;accumulator (x)=(y+x/y)/2
sqrx:
pop bp
cEnd
; %%Function:SQR %%Owner:bryanl
cProc SQR,<PUBLIC,FAR>,<si,di>
cBegin
cCall SQRT
cEnd
;*** special common subexpression subroutine for transcendentals
ResetSbTrans:
mov ax,sbDds
cCall SetSbCur,<ax>
mov si,dataOffset pdAcc
ret
;*** reduce - perform high precision reduction
;
; Function:
; compute ac = (x - xn*c1) - xn*c2
;
; Inputs:
; ARG = x
; AC = xn
; BX = c1
; CX = c2
REDUCE:
push bx
push cx
mov si,dataOffset TempTran1
mov bx,si
call dst ; xnT = xn (TempTran1)
cCall DMUL ;,<cx> ; ac = xn*c2
mov bx,dataOffset TempTran2
call dst
mov bx,si
call dld ; ac = xn
cCall DMUL ;,<bx> ; ac = xn*c1
cCall DNEG ; ac = -xn*c1
mov ax,dataOffset ArgTran
cCall DADD,<ax> ; ac = arg-xn*c1
mov ax,dataOffset TempTran2
cCall DSUB,<ax> ; ac = arg-xn*c1-xn*c2
ret
; EVEN:
mov ax,[si+of_exp] ; get exponent and sign
mov ch,al ; save hign mantissa byte
and ax,expmask ; test for 0
jz evenxit ; yes - return even
sub ax,expbias-((7-expshft) shl expshft)
cmp ax,(manbits-1+7-expshft) shl expshft
ja evenxit ; too big - assume even
mov cl,expshft
shr ax,cl
mov cl,al
and cl,7 ; get bit within byte
inc cx ; bump shift count by 1
shr al,1
shr al,1
shr al,1
cbw
mov bx,ax
neg bx ; bx = byte offset
or ch,1 shl expshft ; set implied mantissa bit
xchg [si+of_exp],ch ; swap with memory
mov al,[si+bx+of_exp]
shl al,cl ; bit in 'C', to tell us even or odd
mov [si+of_exp],ch ; restore high mantissa byte
evenxit:
ret
; z2p_q
;
; Function:
; compute z*z*P(z*z)/Q(z*z)
z2p_q:
push cx
call p_q
pop cx
jcxz nodiv
mov ax,dataOffset TempTran1
cCall DDIV,<ax> ; P(z*z)/Q(z*z)
nodiv:
mov di,dataOffset TempTran2
cCall DMUL,<di>
ret
; z3p_q
;
; Function:
; compute z*z*z*P(z*z)/Q(z*z)
z3p_q:
call z2p_q
mov di,dataOffset TempTran3
cCall DMUL,<di> ; ac = z^3*P(z*z)/Q(z*z)
ret
; p_q
;
; Function:
; computes
; z = ac
; zz = z*z
; if Q
; pzz = p(zz)
; ac = q(zz)
; else
; ac = p(zz)
;
; Inputs:
; BX = address of P table
; CX = address of Q table
p_q:
push bx
push cx
mov di,dataOffset TempTran3 ; temp3=z
call dstdi
cCall DMUL,<di>
mov di,dataOffset TempTran2
call dstdi ; temp2 = z*z
pop bx ; get Q table
or bx,bx
jz noq
call poly
mov bx,dataOffset TempTran1
call dst ; TempTran1 = Q(z*z)
mov bx,dataOffset TempTran2
call dld
noq: pop bx
; call poly ; ac = P(z*z)
; ret
;*** POLY - Evaluate DP polynomial
;
; Inputs:
; BX = Address of list of coefficients. First byte in list is number of
; coefficients, followed by the constants ordered from highest
; power to lowest.
; AC = argument.
; Function:
; Evaluate polynomial by Horner's method
; Outputs:
; Result in AC.
; Registers:
; ALL destroyed.
POLY:
push ss
pop es
mov si,dataOffset pdAcc
mov di,dataOffset ArgTran
movsw
movsw
movsw
movsw
mov si,bx ; Point to coefficient table
lodsw ; Number of coefficients
xchg ax,cx ; Count in CX
or cx,cx ; check for implied 1.0 as 1st
jns polymove ; no - normal poly
xor ch,ch ; clear flag so we can count down
push cx ; save count
jmp short polyone ; jump into middle of poly loop
polymove:
mov di,dataOffset pdAcc ; Move first coefficient into AC
movsw
movsw
movsw
movsw
jcxz polyxit
polyloop:
push cx
mov ax,dataOffset ArgTran
cCall DMUL,<ax> ; Multiply by argument
polyone: ; alternate entry for implied 1.0
cCall DADD,<si> ; Add coefficient
pop cx
add si,8 ; Bump to next coefficient
loop polyloop
polyxit:
ret
;
; Load num pointed by AX into pdacc
;
dlddi:
mov bx,di
dld:
mov ax,[bx ]
mov [pdAcc ],ax
mov ax,[bx+2]
mov [pdAcc+2],ax
mov ax,[bx+4]
mov [pdAcc+4],ax
mov ax,[bx+6]
mov [pdAcc+6],ax
ret
;
; Load pdacc into num pointed to by AX
;
dstdi:
mov bx,di
dst:
mov ax,[pdAcc ]
mov [bx ],ax
mov ax,[pdAcc+2]
mov [bx+2],ax
mov ax,[pdAcc+4]
mov [bx+4],ax
mov ax,[pdAcc+6]
mov [bx+6],ax
ret
rgnumKonst DQ 03ff0000000000000R ; 1
DQ 04000000000000000R ; 2
DQ 0bff0000000000000R ; -1
DQ 04024000000000000R ; 10
DQ 04059000000000000R ; 100
DQ 040026bb1bbb55516R ; Ln(10)
DQ 03fe0000000000000R ; 1/2
DQ 0cca8e45e1df3b078R ; large negative for sort (-2*10**60)
; %%Function:DLdC %%Owner:bryanl
cProc DLdC,<PUBLIC,FAR>,<si,di,ds>
ParmW ic
cBegin
mov si, ic
mov cl, 3
shl si, cl
add si, offset rgnumKonst
mov di, dataOffset pdAcc
push ds
pop es
push cs
pop ds
movsw
movsw
movsw
movsw
cEnd
ifdef NOTUSED
; The next two routines are no longer required by the mathpack.
; %%Function:DldHp %%Owner:NOTUSED
cProc DldHp,<PUBLIC,FAR>
; ParmD hp
cBegin nogen
mov bx,sp
push si
mov si,[bx+4] ; get offset of huge pointer
mov bx,[bx+6]
call GetPSfromSB
cld
lods word ptr es:[si]
mov word ptr [pdAcc ],ax
lods word ptr es:[si]
mov word ptr [pdAcc +2],ax
lods word ptr es:[si]
mov word ptr [pdAcc +4],ax
lods word ptr es:[si]
mov word ptr [pdAcc +6],ax
pop si
ret 4
cEnd nogen
; %%Function:DstHp %%Owner:NOTUSED
cProc DstHp,<PUBLIC,FAR>
; ParmD hp
cBegin nogen
mov bx,sp
push si
push di
mov di,[bx+4] ; get offset of huge pointer
mov bx,[bx+6]
call GetPSfromSB
mov si,dataOffset pdAcc
cld
movsw
movsw
movsw
movsw
pop di
pop si
ret 4
cEnd nogen
endif ;NOTUSED
GetPSfromSB:
shl bx,1
mov ax,[mpsbps+bx]
mov es,ax
shr ax,1
jc mrs
MyReloadSB:
push dx
push bx
push cx
cCall ReloadSb,<>
pop cx
pop bx
pop dx
mrs: ret
sEnd trans
end
+216
View File
@@ -0,0 +1,216 @@
savedCS = 4
savedIP = 2
savedBP = 0
savedDS = -2
EMAGIC = 05A4Dh
ERESWDS = 0010h
ENEWHDR = 003Eh
ENEWEXE = 0040h
EXE_HDR STRUC
e_magic DW ? ; magic in same location
e_cblp DW ?
e_cp DW ?
e_crlc DW ?
e_cparhdr DW ?
e_minalloc DW ?
e_maxalloc DW ?
e_ss DW ?
e_sp DW ?
e_csum DW ?
e_cs DW ?
e_ip DW ?
e_lfarlc DW ?
e_ovno DW ?
e_res DW ERESWDS DUP (?)
e_lfanew DD ?
EXE_HDR ENDS
NEMAGIC = 454Eh
NERESBYTES = 0
NEW_EXE STRUC
ne_magic DW ? ; Magic value 'NE'
ne_ver DB ? ; version number
ne_rev DB ? ; revision number
ne_enttab DW ? ; offset to entry table
ne_cbenttab DW ? ; number of bytes in entry table
ne_crc DD ? ; CRC of file
ne_flags DW ? ; flag word
ne_autodata DW ? ; segment number of auto data segment
ne_heap DW ? ; initial size of local heap
ne_stack DW ? ; initial size of stack
ne_csip DD ? ; CS:IP start address
ne_sssp DD ? ; SS:SP initial stack pointer. 0 if
; stack size word non-zero
ne_cseg DW ? ; number of segment in segment table
ne_cmod DW ? ; number of entries in module reference table
ne_cbnrestab DW ? ; number of bytes in non-resident name table
ne_segtab DW ? ; NE relative offset to segment table
ne_rsrctab DW ? ; NE relative offset to resource table
ne_restab DW ? ; NE relative offset to resident name table
ne_modtab DW ? ; NE relative offset to module reference table
ne_imptab DW ? ; NE relative offset to imported name table
ne_nrestab DD ? ; file offset to non-resident name table
ne_cmovent DW ? ; Count of movable entries
ne_align DW ? ; Alignment shift count for segment data
ne_cres DW ? ; Count of resource segments
; Chksum not supported unless ne_psegcsum defined in NEW_EXE structure
ne_psegcsum DW ? ; offset to segment chksums.
ne_pretthunks DW ? ; offset to return thunks
ne_psegrefbytes DW ? ; offset to segment ref. bytes
ne_swaparea DW ? ; Minimum code swap area size
ne_expver DW ? ; Expected Windows version number
NEW_EXE ENDS
ifdef DOS5
ne_mte EQU ne_psegcsum ; DOS 5 MTE handle for this module
endif
NEW_EXE1 STRUC
DW ?
ne_usage DW ?
DW ?
ne_pnextexe DW ?
ne_pautodata DW ?
ne_pfileinfo DW ?
NEW_EXE1 ENDS
NENOTP = 8000h ; Not a process (i.e. a library module)
NENONC = 4000h ; non-conforming
NEIERR = 2000h ; errors in EXE image
NENONRES = 0080h ; Contains non-resident code segments
NEPROT = 0008h ; Runs in protected mode
NEREAL = 0004h ; Runs in real mode
NEINST = 0002h ; multiple instances of auto data segment
NESOLO = 0001h ; single instance of auto data segment
ifdef DOS5
NERESLD = 1000h ; Set if PreloadResources has been called
endif
NEW_SEG STRUC
ns_sector DW ? ; logical sector number in file of start of segment
ns_cbseg DW ? ; number bytes in file
ns_flags DW ? ; segment flags
ns_minalloc DW ? ; minimum number bytes to allocate for segment
NEW_SEG ENDS
NEW_SEG1 STRUC
DB SIZE NEW_SEG DUP (?)
ns_handle DW ? ; Handle to segment (0 if not loaded)
NEW_SEG1 ENDS
NSTYPE = 0007h ; Segment type mask
NSCODE = 0000h ; Code segment
NSDATA = 0001h ; Data segment
NSITER = 0008h ; Iterated segment data
NSMOVE = 0010h ; Moveable segment
NSSHARE = 0020h ; Shareable segment
NSPRELOAD = 0040h ; Preload this segment
NSERONLY = 0080h ; EXECUTE ONLY code/READ ONLY data segment
NSRELOC = 0100h ; Relocation information following segment data
NSDPL = 0C00h ; 286 DPL bits
NSDISCARD = 1000h ; Discard priority bits
NS286DOS = 0EE06h ; These bits only used by 286DOS
NSALIGN = 9 ; Default alignment shift count for seg. data
NSALLOCED = 0002h ; set if ns_handle points to uninitialized mem.
NSLOADED = 0004h ; set if ns_handle points to initialized mem.
NSUSESDATA = 0400h ; set if an entry point in this segment uses
; the automatic data segment of a SOLO library
NEW_RSRC STRUC
rs_align DW ?
NEW_RSRC ENDS
RSORDID = 08000h ; If high bit of rt_id or rn_id set then integer id
RSRC_TYPEINFO STRUC
rt_id DW ?
rt_nres DW ?
rt_proc DD ?
RSRC_TYPEINFO ENDS
RSRC_NAMEINFO STRUC
rn_offset DW ?
rn_length DW ?
rn_flags DW ?
rn_id DW ?
rn_handle DW ?
rn_usage DW ?
RSRC_NAMEINFO ENDS
RNMOVE = 00010h ; Moveable resource
RNPURE = 00020h ; Pure resource (read only)
RNPRELOAD = 00040h ; Preload this resource
RNDISCARD = 01000h ; Discard bit
RNLOADED = 00004h ; True if handler proc return handle
RNUNUSED = 0EF8Bh ; Unused resource flags
ENTFIXED STRUC
entflags DB ?
entoffset DW ?
ENTFIXED ENDS
ENTMOVEABLE STRUC
DB ? ; Entry flags
DB 5 DUP (?) ; sar cs:[xxxx] instruction
entjmpfarop DB ?
entjmpfaroff DW ?
entjmpfarseg DW ?
ENTMOVEABLE ENDS
ENTSWAPPED STRUC
DB ? ; Entry flags
DB 5 DUP (?) ; sar cs:[xxxx] instruction
entintop DB ?
entintvec DB ?
entintsegno DB ?
entintoff DW ?
ENTSWAPPED ENDS
errnz <SIZE ENTMOVEABLE - SIZE ENTSWAPPED>
ENT_UNUSED = 000h
ENT_ABSSEG = 0FEh
ENT_MOVEABLE = 0FFh
ENT_PUBLIC = 001h
ENT_DATA = 002h
INTOPCODE = 0CDh
INTVECTOR = 03Fh
NEW_RLCINFO STRUC
nr_nreloc DW ?
NEW_RLCINFO ENDS
NEW_RLC STRUC
nr_stype DB ?
nr_flags DB ?
nr_soff DW ?
nr_mod DW ?
nr_proc DW ?
NEW_RLC ENDS
nr_segno EQU nr_flags+3
nr_entry EQU nr_proc
NRSTYP = 07h
NRSBYTE = 00h
NRSSEG = 02h
NRSPTR = 03h
NRSOFF = 05h
NRADD = 04h
NRRTYP = 03h
NRRINT = 00h
NRRORD = 01h
NRRNAM = 02h
+21
View File
@@ -0,0 +1,21 @@
; NOXPORT.INC
;
; By including this in an assembly module, certain instructions will be
; omitted from the function header generated by cProc.
;
; This saves code, but will only work for non-exported functions (that
; is, functions not called by Windows)
.xlist
memS = 1
?WIN = 1
?PLM = 1
?DF = 1
?NODATA = 1
?TF = 1
include cmacros.inc
.list
createSeg _DATA,data,word,public,DATA,DGROUP
defGrp DGROUP,DATA
+53
View File
@@ -0,0 +1,53 @@
PushArg MACRO arg_list ;; Push multiple registers
irp x,<arg_list>
push x
endm
ENDM
wo equ word ptr
by equ byte ptr
FDE_OS2 STRUC
wDateCreateFdeOS2 dw ?
wTimeCreateFdeOS2 dw ?
wDateAccessFdeOS2 dw ?
wTimeAccessFdeOS2 dw ?
wDateWriteFdeOS2 dw ?
wTimeWriteFdeOS2 dw ?
OFF_cbFileFdeOS2 dw ? ; The size of
SEG_cbFileFdeOS2 dw ? ; the file.
OFF_cbFileAllocFdeOS2 dw ? ; The space alloc'ed on the
SEG_cbFileAllocFdeOS2 dw ? ; disk to hold the file.
attrFileFdeOS2 dw ?
cchNameFdeOS2 db ?
szNameFdeOS2 db 13 dup (?)
FDE_OS2 ENDS
FDE STRUC
dtaFde DB 21 DUP (0) ;* 21 bytes filler
atrFde DB 0
wTimeWriteFde DW 0
wDateWriteFde DW 0
cbFileFde DD 0
szNameFde DB 13 DUP (0) ;* file name
FDE ENDS
qfs STRUC
idFileSystem dd ? ; Specifies the file-system id'er.
cSectorUnit dd ? ; sectors/cluster
cUnit dd ? ; clusters/drive
cUnitAvail dd ? ; free clusters
cbSect dw ? ; bytes/sector
qfs ENDS
DATETIME STRUC
hours db ?
minutes db ?
seconds db ?
hundreths db ?
day db ?
month db ?
year dw ?
timezone dw ?
weekday db ?
DATETIME ENDS
+308
View File
@@ -0,0 +1,308 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg fetch1_PCODE,prln,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midPrln equ 30 ; module ID, for native asserts
endif
; EXTERNAL FUNCTIONS
ifdef DEBUG
externFP <AssertProcForNative>
endif ;DEBUG
sBegin data
; EXTERNALS
externW dnsprm ; extern struct ESPRM dnsprm[];
externW vchpStc ; extern struct CHP vchpStc;
sEnd data
; CODE SEGMENT _EDIT
sBegin prln
assumes cs,prln
assumes ds,dgroup
assumes ss,dgroup
VFPS_CALL label word
dw VFPS_spraBit
dw VFPS_spraByte
dw VFPS_spraWord
dw VFPS_spraCPlain
dw VFPS_spraCFtc
dw VFPS_spraCKul
dw VFPS_spraCSizePos
dw VFPS_spraSpec
dw VFPS_spraIco
dw VFPS_spraCHpsInc
dw VFPS_spraCHpsPosAdj
;-------------------------------------------------------------------------
; ValFromPropSprm(prgbProps, sprm)
;-------------------------------------------------------------------------
;/* V A L F R O M P R O P S P R M
; returns value of property addressed by prgbProp and sprm as an int */
;
;NATIVE int ValFromPropSprm(prgbProps, sprm)
;char *prgbProps;
;int sprm;
;{
; int val = -1;
; struct ESPRM esprm;
; struct PCVH pcvh;
; %%Function:N_ValFromPropSprm %%Owner:BRADV
PUBLIC N_ValFromPropSprm
N_ValFromPropSprm:
mov bx,sp
push si
push di
mov si,[bx+6]
mov di,[bx+4]
; esprm = dnsprm[sprm];
errnz <cbEsprmMin - 4>
mov bx,di
shl bx,1
shl bx,1
mov cx,[bx.dnsprm]
; switch(esprm.spra)
; {
errnz <(spraEsprm) - 1>
mov bl,ch
and bx,maskspraEsprm
errnz <ibitSpraEsprm>
shl bx,1
; Assert (spra < 11);
ifdef DEBUG
cmp bx,11 SHL 1
jb VFPS01
push ax
push bx
push cx
push dx
mov ax,midPrln
mov bx,1001
cCall AssertProcForNative,<ax, bx>
pop dx
pop cx
pop bx
pop ax
VFPS01:
endif ;DEBUG
errnz <maskbEsprm - 0FEh>
errnz <(bEsprm) - 0>
shr cl,1
xor ch,ch
xor ah,ah
call [bx.VFPS_CALL]
;}
pop di
pop si
db 0CAh, 004h, 000h ;far ret, pop 4 bytes
; case spraWord:
; /* sprm has a word parameter that is stored at b */
; bltb(prgbProps + esprm.b, &val, 2);
; break;
VFPS_spraWord:
add si,cx
lodsw
ret
; case spraByte:
; /* sprm has a byte parameter that is stored at b */
; val = *(prgbProps + esprm.b);
; break;
VFPS_spraByte:
add si,cx
lodsb
ret
; case spraBit:
; /* sprm has byte parameter that is stored at bit b in word 0 */
; /* WARNING: shift in following versions is machine-dependent */
; Win(val = (*(int *)prgbProps & (1<<esprm.b)) ? 1 : 0);
; break;
VFPS_spraBit:
mov al,1
mov dx,ax
shl dx,cl
test [si],dx
jne VFPS02
dec ax
VFPS02:
ret
; case spraCFtc:
; val = ((struct CHP *)prgbProps)->ftc;
; break;
VFPS_spraCFtc:
mov ax,[si.ftcChp]
ret
; case spraCKul:
; val = ((struct CHP *)prgbProps)->kul;
; break;
VFPS_spraCKul:
mov al,[si.kulChp]
and al,maskKulChp
mov cl,ibitKulChp
shr al,cl
ret
; case spraCPlain:
; /* should have done a CachePara prior to this */
; val = !FNeRgw(&vchpStc, prgbProps, cwCHP);
; break;
VFPS_spraCPlain:
push ds
pop es
mov di,dataoffset [vchpStc]
errnz <cbChpMin AND 1>
mov cx,cbChpMin SHR 1
errnz <fFalse>
xor ax,ax
repe cmpsw
jne VFPS03
errnz <fTrue - fFalse - 1>
inc ax
VFPS03:
ret
; case spraCIco:
; val = ((struct CHP *)prgbProps)->ico;
; break;
VFPS_spraIco:
mov al,[si.icoChp]
errnz <maskIcoChp - 00Fh>
and al,maskIcoChp
ret
; default:
VFPS_spraCSizePos:
VFPS_spraSpec:
VFPS_spraCHpsInc:
VFPS_spraCHpsPosAdj:
; switch(sprm)
; {
ifdef DEBUG
test di,0FF00h
je VFPS04
push ax
push bx
push cx
push dx
mov ax,midPrln
mov bx,1002
cCall AssertProcForNative,<ax, bx>
pop dx
pop cx
pop bx
pop ax
VFPS04:
endif ;DEBUG
xchg ax,di
; case sprmCQpsSpace:
; val = ((struct CHP *)prgbProps)->qpsSpace;
; break;
cmp al,sprmCQpsSpace
jne VFPS05
mov al,[si.qpsSpaceChp]
errnz <maskQpsSpaceChp - 03fh>
and al,maskQpsSpaceChp
ret
VFPS05:
; case sprmPStc:
; val = ((struct PAP *)prgbProps)->stc;
; break;
cmp al,sprmPStc
jne VFPS06
errnz <(stcPap) - 0>
lodsb
ret
VFPS06:
; case sprmTDxaGapHalf:
; val = ((struct TAP *)prgbProps)->dxaGapHalf;
; break;
cmp al,sprmTDxaGapHalf
jne VFPS07
mov ax,[si.dxaGapHalfTap]
ret
VFPS07:
; case sprmPPc:
; pcvh.op = 0;
; pcvh.pcVert = ((struct PAP *)prgbProps)->pcVert;
; pcvh.pcHorz = ((struct PAP *)prgbProps)->pcHorz;
; val = pcvh.op;
; break;
cmp al,sprmPPc
jne VFPS08
errnz <maskPcVertPap - 030h>
errnz <maskPcHorzPap - 0C0h>
errnz <(pcVertPap) - (pcHorzPap)>
errnz <maskPcVertPcvh - 030h>
errnz <maskPcHorzPcvh - 0C0h>
errnz <(pcVertPcvh) - (pcHorzPcvh)>
mov al,[si.pcVertPap]
and al,0F0h
ret
VFPS08:
; case sprmCDefault:
; val = (*(int *)prgbProps & 0xff10) == 0 &&
; ((struct CHP *)prgbProps)->kul == kulNone &&
; ((struct CHP *)prgbProps)->ico == icoAuto;
; break;
cmp al,sprmCDefault
jne VFPS10
mov al,fFalse
test wptr [si], 0FF10h
jne VFPS09
errnz <kulNone - 0>
test [si.kulChp],maskKulChp
jne VFPS09
errnz <icoAuto - 0>
test [si.icoChp],maskIcoChp
jne VFPS09
errnz <fTrue - fFalse - 1>
inc ax
VFPS09:
ret
VFPS10:
; }
; break;
; }
;Assembler note: this is val = -1; taken from the frame declaration
mov ax,-1
ret
; return val;
;}
;Assembler note: the return is performed above
; End of ValFromPropSprm
sEnd prln
end
+271
View File
@@ -0,0 +1,271 @@
?PLM = 1
?NODATA = 1
.xlist
include w2.inc
include cmacros.inc
.list
createSeg _FIXED,prof,byte,public,CODE
createSeg _DATA,data,word,public,DATA,DGROUP
defGrp DGROUP,DATA
PROF_INT equ 0FBh
PROF_INT_ADDR equ 4 * PROF_INT
do_prof_int macro function
local not_installd
cmp installed,0
jz not_installd
mov ah,function
int PROF_INT
not_installd:
mov ax,installed
endm
sBegin prof
assumes cs,prof
assume ds:nothing
assume es:nothing
ifdef DEBUG
;-----------------------------------------------------------------------;
; hello_profiler ;
; ;
; Checks if profiler is installed. Int 3 and prof_int will point to ;
; the same segment if it is installed. ;
; ;
; Arguments: ;
; none ;
; Returns: ;
; TRUE if installed ;
; ;
; Mon Aug 25, 1986 05:57:03p -by- Wesley O. Rupel [wesleyr] ;
;-----------------------------------------------------------------------;
assume ds:nothing
assume es:nothing
installed dw 0
; %%Function:hello_profiler %%Owner:BRADV
cProc hello_profiler,<FAR, PUBLIC>,<ds>
cBegin
xor ax,ax
mov ds,ax
mov ax,ds:[2 + 4 * 3]
cmp ax,ds:[2 + PROF_INT_ADDR]
mov ax,0 ; xor would alter flags
jnz not_installed
inc ax
not_installed:
mov cs:installed,ax
cEnd
;-----------------------------------------------------------------------;
; start_recording ;
; stop_recording ;
; clear_buffers ;
; write_buffers ;
; swap_int_9 ;
; ;
; Does nothing if hello_profiler has not been called and returned TRUE. ;
; ;
; Arguments: ;
; None ;
; Returns: ;
; TRUE if profiler installed and hello_profiler has been done. ;
; Alters: ;
; AX ;
; ;
; Mon Aug 18, 1986 02:13:09p -by- Wesley O. Rupel [wor] ;
;-----------------------------------------------------------------------;
; %%Function:start_recording %%Owner:BRADV
cProc start_recording,<FAR, PUBLIC>,<>
cBegin
do_prof_int 0
cEnd
;-----------------------------------------------------------------------;
; %%Function:stop_recording %%Owner:BRADV
cProc stop_recording,<FAR, PUBLIC>,<>
cBegin
do_prof_int 1
cEnd
;-----------------------------------------------------------------------;
; %%Function:clear_buffers %%Owner:BRADV
cProc clear_buffers,<FAR, PUBLIC>,<>
cBegin
do_prof_int 2
cEnd
;-----------------------------------------------------------------------;
; %%Function:write_buffers %%Owner:BRADV
cProc write_buffers,<FAR, PUBLIC>,<>
cBegin
do_prof_int 3
cEnd
;-----------------------------------------------------------------------;
; %%Function:set_timer_rate %%Owner:BRADV
cProc set_timer_rate,<FAR, PUBLIC>,<>
ParmB timer_rate
cBegin
mov al,timer_rate
do_prof_int 6
cEnd
;-----------------------------------------------------------------------;
; get_buffer_location ;
; ;
; Arguments: ;
; None ;
; Returns: ;
; DX:AX = FAR PTR to CS:IP buffer. ;
; Alters: ;
; AX ;
; ;
; Mon Aug 18, 1986 02:13:09p -by- Wesley O. Rupel [wor] ;
;-----------------------------------------------------------------------;
; %%Function:get_buffer_location %%Owner:BRADV
cProc get_buffer_location,<FAR, PUBLIC>,<>
cBegin
cmp installed,0
jz not_nstalled
mov ah,4
int PROF_INT
not_nstalled:
cEnd
public calibrate_prof
;-----------------------------------------------------------------------;
; calibrate_prof ;
; ;
; This is a good routine to profile to verify that the profiler is ;
; working correctly. The number of hits should be proportional to the ;
; label number. Thus prof_label_6 should get 6 times as many hits as ;
; prof_label_1. ;
; Allowing other interrupts to occur while this is being profiled would ;
; throw off the exact timing, thus they will be masked out. ;
; ;
; Arguments: ;
; none ;
; Returns: ;
; nothing ;
; Alters: ;
; nothing ;
; Calls: ;
; disable_other_ints ;
; enable_other_ints ;
; History: ;
; ;
; Tue Oct 14, 1986 06:52:32p -by- Wesley O. Rupel [wesleyr] ;
; Wrote it! ;
;-----------------------------------------------------------------------;
n_loops macro number
; %%Function:prof_label_&number %%Owner:BRADV
public prof_label_&number
prof_label_&number&:
rept number
loop $
endm
endm
rest macro
jmp $ + 2
endm
assume ds:nothing
assume es:nothing
; %%Function:calibrate_prof %%Owner:BRADV
cProc calibrate_prof,<FAR, PUBLIC>,<cx>
cBegin
call disable_other_ints
count = 0
xor cx,cx
rept 9 ; 9 is about right for prof -t4 (on 8Mhz AT)
count = count + 1
n_loops %count
endm
public end_loop_of_loops
end_loop_of_loops:
call enable_other_ints
cEnd
; %%Function:disable_other_ints %%Owner:BRADV
public disable_other_ints
;-----------------------------------------------------------------------;
; disable_other_ints ;
; ;
; Wed Oct 15, 1986 09:55:23a -by- Wesley O. Rupel [wesleyr] ;
; Wrote it! ;
;-----------------------------------------------------------------------;
assume ds:nothing
assume es:nothing
master_state db ?
slave_state db ?
disable_other_ints proc near
cli
push ax
in al,021h
rest
mov cs:master_state,al
in al,0A1h
rest
mov cs:slave_state,al
mov al,0FBh ; allow only IRQ 2 on master 8259
out 21h,al
rest
mov al,0FEh ; allow only IRQ 0 on slave 8259
out 0A1h,al
pop ax
sti
ret
disable_other_ints endp
; %%Function:enable_other_ints %%Owner:BRADV
public enable_other_ints
;-----------------------------------------------------------------------;
; enable_other_ints ;
; ;
; Wed Oct 15, 1986 10:05:45a -by- Wesley O. Rupel [wesleyr] ;
; Wrote it! ;
;-----------------------------------------------------------------------;
assume ds:nothing
assume es:nothing
enable_other_ints proc near
push ax
cli
mov al,cs:master_state
out 21h,al
rest
mov al,cs:slave_state
out 0A1h,al
pop ax
sti
ret
enable_other_ints endp
endif ; DEBUG for whole module
sEnd code
end
+97
View File
@@ -0,0 +1,97 @@
TITLE profctl - profiler on/off control routines
include w2.inc
include cmacros.inc
ifdef PAUSEPROFILER
sBegin DATA
cBackTrace dw 1
sEnd
endif ;PAUSEPROFILER
sBegin CODE
assumes cs,CODE
assumes ds,DATA
assumes es,NOTHING
; %%Function:StartProfiler %%Owner:BRADV
cProc StartProfiler,<PUBLIC, FAR>
ParmW cFrames
ParmD lpszFilename
cBegin
push seg_lpszFilename
push off_lpszFilename
mov ax,cFrames
ifdef PAUSEPROFILER
mov cBacktrace,ax
endif ;PAUSEPROFILER
push ax
mov ax,30 ; start command
push ax
call StartStopProf
add sp,8
cEnd
ifdef PAUSEPROFILER
; %%Function:PauseProfiler %%Owner:BRADV
cProc PauseProfiler,<PUBLIC, FAR>
ParmW fPause
cBegin
xor dx,dx
cmp fPause,dx
jnz pp100
push dx
push dx
push cBacktrace ; last backtrace value
mov ax,30 ; start = 30
push ax
call StartStopProf
add sp,8
jmp short pp200
pp100:
mov ax,32 ; pause = 32
push ax
call StartStopProf
add sp,2
pp200:
cEnd
endif ;PAUSEPROFILER
; %%Function:StopProfiler %%Owner:BRADV
cProc StopProfiler,<PUBLIC, FAR>
cBegin
mov ax,31 ; 31 = stop
push ax
call StartStopProf
add sp,2
cEnd
StartStopProf:
pop ax
push cs
push ax
xor ax,ax
mov es,ax
mov ax,es:[000eh] ; Get segment down there.
mov es,ax
cmp word ptr es:[0100h],'S' + 'E' * 256
jnz sspexit
cmp word ptr es:[0109h],'P' + 'R' * 256
jnz sspexit
jmp dword ptr es:[00fch] ; go to the profiler.
sspexit:
ret
sEnd CODE
END
+397
View File
@@ -0,0 +1,397 @@
PAGE 58,82
; REVIEW: How to make intra-module calls NEAR?
;
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg prompt_PCODE,prompt,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midPromptn equ 9 ; module ID, for native asserts
endif
; EXTERNAL FUNCTIONS
externFP <AdjustPrompt>
externFP <PopToHppr>
ifdef DEBUG
externFP <AssertProcForNative>
endif ;DEBUG
sBegin data
; EXTERNALS
externW vhpprPRPrompt
sEnd data
; CODE SEGMENT _PROMPT
sBegin prompt
assumes cs,prompt
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; ProgressReportPercent (hppr, lLow, lHigh, l, plNext)
;-------------------------------------------------------------------------
;/* P R O G R E S S R E P O R T P E R C E N T */
;native ProgressReportPercent (hppr, lLow, lHigh, l, plNext)
;struct PPR **hppr;
;long lLow, lHigh, l, *plNext;
;{
; int wPartitions = 100 / pppr->nIncr;
; if (hppr == hNil) return;
; wPartitions = 100 / pppr->nIncr;
; %%Function:ProgressReportPercent %%Owner:BRADV
cProc ProgressReportPercent,<PUBLIC,FAR>,<si,di>
ParmW <hppr>
ParmD <lLow>
ParmD <lHigh>
ParmD <l>
ParmW <plNext>
LocalW wPartitions
LocalW nIncr
cBegin
mov ax,100
mov bx,hppr
cmp bx,0
je PRPTemp1
mov bx,[bx] ; bx = pppr
mov cx,[bx.nIncrPpr]
mov nIncr,cx
div cl
mov wPartitions,ax
; Assert (100 % pppr->nIncr == 0);
ifdef DEBUG
call PRP08
endif ;/* DEBUG */
; ChangeProgressReport (hppr, (l-lLow)*wPartitions
; +(lHigh-lLow)>>1/(lHigh-lLow)(*hppr)->nIncr);
mov bx,OFF_lLow
mov dx,SEG_lLow
mov cx,OFF_l
mov ax,SEG_l
sub cx,bx
sbb ax,dx
;we now have (l-lLow) in ax:cx
mov si,OFF_lHigh
mov di,SEG_lHigh
sub si,bx
sbb di,dx
;we now have (lHigh-lLow) in di:si
; Assert (lHigh-lLow > 0);
ifdef DEBUG
call PRP10
endif ;/* DEBUG */
mul wPartitions
xchg ax,cx
mov bx,dx
mul wPartitions
add dx,cx
adc bx,0
;we now have (l-lLow)*wPartitions in bx:dx:ax
push di
push si
shr di,1
rcr si,1
add ax,si
adc dx,di
adc bx,0
pop si
pop di
;we now have (l-lLow)*wPartitions+(lHigh-lLow)>>1 in bx:dx:ax
;perform long division with shifts and adds
mov cx,16
PRP04:
shl ax,1
rcl dx,1
rcl bx,1
PRP05:
inc ax
sub dx,si
sbb bx,di
jnc PRP06
dec ax
add dx,si
adc bx,di
PRP06:
loop PRP04
;we now have ((l-lLow)*wPartitions+(lHigh-lLow)>>1)/(lHigh-lLow) in ax
mul nIncr
push hppr
push ax
call far ptr ChangeProgressReport
; if (plNext != NULL)
cmp plNext,NULL
PRPTemp1:
je PRP07
; *plNext = ((lHigh-lLow)*((*hppr)->nLast/(*hppr)->nIncr+1)
; -(lHigh-lLow)>>1+(wPartitions-1))/wPartitions+lLow;
mov bx,hppr
mov bx,[bx] ; bx = pppr
mov ax,[bx.nLastPpr]
div bptr (nIncr)
inc ax
xchg ax,cx
mov ax,di
mul cx
xchg ax,bx
mov ax,si
mul cx
;we now have (lHigh-lLow)*(pppr->nLast/pppr->nIncr+1) in (bx+dx:ax)
mov cx,wPartitions
dec cx
add ax,cx
adc bx,dx
shr di,1
rcr si,1
sub ax,si
sbb bx,di
;we now have (lHigh-lLow)*(pppr->nLast/pppr->nIncr+1)
; -(lHigh-lLow)>>1+(wPartitions-1) in bx:ax
inc cx
xchg ax,bx
xor dx,dx
div cx
xchg ax,bx
div cx
;we now have ((lHigh-lLow)*(pppr->nLast/pppr->nIncr+1)
; -(lHigh-lLow)>>1+(wPartitions-1))/wPartitions in bx:ax
mov cx,SEG_lLow
mov dx,OFF_lLow
add ax,dx
adc bx,cx
;we now have the result in bx:ax
mov si,plNext
mov [si],ax
mov [si+2],bx
PRP07:
;}
cEnd
; Assert (100 % pppr->nIncr == 0);
ifdef DEBUG
PRP08:
or ah,ah
je PRP09
push ax
push bx
push cx
push dx
mov ax,midPromptn
mov bx,1001
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
PRP09:
ret
endif ;/* DEBUG */
; Assert (lHigh-lLow > 0);
ifdef DEBUG
PRP10:
push si
or si,di
jne PRP11
push ax
push bx
push cx
push dx
mov ax,midPromptn
mov bx,1003
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
PRP11:
pop si
ret
endif ;/* DEBUG */
;-------------------------------------------------------------------------
; ChangeProgressReport (hppr, nNew)
;-------------------------------------------------------------------------
;/* C H A N G E P R O G R E S S R E P O R T */
;native ChangeProgressReport (hppr, nNew)
;struct PPR **hppr;
;unsigned nNew;
;{
; struct PPR *pppr;
; unsigned nIncr;
; CHAR rgch [6], *pch;
; int cch;
; %%Function:ChangeProgressReport %%Owner:BRADV
cProc ChangeProgressReport,<PUBLIC,FAR>,<di,si>
ParmW <hppr>
ParmW <nNew>
LocalW nIncr
LocalV rgch,6
cBegin
; if (hppr == hNil) return;
; if (hppr != vhpprPRPrompt)
; PopToHppr(hppr);
;
; pppr = *hppr;
; nIncr = pppr->nIncr;
mov bx,hppr
cmp bx, 0
je CPRTemp1
cmp bx,vhpprPRPrompt
je CPR07
push bx
cCall PopToHppr,<hppr>
pop bx
CPR07:
mov si,[bx] ; si = pppr
mov cx,[si.nIncrPpr]
; Assert (pppr->cch <= 6 && pppr->cch > 0);
ifdef DEBUG
mov ax,[si.cchPpr]
cmp ax,6
jg CPR01
cmp ax,0
jg CPR01b
CPR01:
push ax
push bx
push cx
push dx
mov ax,midPromptn
mov bx,1004
cCall AssertProcForNative,<ax,bx>
pop dx
pop cx
pop bx
pop ax
CPR01b:
endif ;/* DEBUG */
;
; if (nIncr != 1)
; nNew = (((nNew + nIncr/2) / nIncr) * nIncr);
mov ax,nNew
push cx
shr cx,1
add ax,cx
pop cx
cwd
div cx
mul cx
; if (nNew > pppr->nLast)
; {
cmp ax,[si.nLastPpr]
CPRTemp1:
je CPR06
; pppr->nLast = nNew;
mov [si.nLastPpr],ax
; pch = &rgch[6];
lea di,rgch+5
; cch = pppr->cch;
mov cx,[si.cchPpr]
; do
; {
push ss
pop es
; *(--pch) = '0' + nNew%10;
; nNew /= 10;
; cch--;
; } while (nNew && cch);
;
; while (cch--)
; *(--pch) = ' ';
mov bx,10
mov dx,ax
; dx = nNew, cx = cch, di = pch, bx = 10
std
mov al,'0'
CPR03:
or dx,dx
je CPR04
mov ax,dx
xor dx,dx
div bx
add dx,'0'
xchg ax,dx
CPR04:
stosb
mov al,' '
loop CPR03
cld
inc di
; Assert (&rgch[6] - pch == pppr->cch);
ifdef DEBUG
push ax
push bx
push cx
push dx
lea dx,rgch+6
sub dx,di
cmp dx,[si.cchPpr]
je CPR05
mov ax,midPromptn
mov bx,1006
cCall AssertProcForNative,<ax,bx>
CPR05:
pop dx
pop cx
pop bx
pop ax
endif ;/* DEBUG */
ifdef WIN23
; AdjustPrompt (pppr->ich, pppr->cch, pppr->xp, pch);
cCall AdjustPrompt,<[si.ichPpr],[si.cchPpr],[si.xpPpr], di>
else
; AdjustPrompt (pppr->ich, pppr->cch, pch);
cCall AdjustPrompt,<[si.ichPpr],[si.cchPpr],di>
endif
; }
CPR06:
;}
cEnd
sEnd prompt
end
+29
View File
@@ -0,0 +1,29 @@
; 07/04/89 - Put comment in here so that ownership of module can be
; determined since there is no usage of cproc or public in module
; %%Function:QPlc %%Owner:BRADV
; expect pplc in bx, return HpOfHq(hqplce) in es:di, bx is not altered.
; ax, cx, dx trashed
lea di,[bx.rgcpPlc]
push ds
pop es
test [bx.fExternalPlc],maskFExternalPlc
je QPLC2
push bx
mov di,[bx.LO_hqplcePlc]
mov bx,[bx.HI_hqplcePlc]
shl bx,1
mov ax,mpsbps[bx]
mov es,ax
shr ax,1
jc QPLC1
; reload sb trashes ax, cx, and dx
cCall ReloadSb,<>
QPLC1:
mov di,es:[di]
pop bx
QPLC2:
ifdef DEBUG
mov ax,[wFillBlock]
mov cx,[wFillBlock]
mov dx,[wFillBlock]
endif ;DEBUG
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+974
View File
@@ -0,0 +1,974 @@
page 58,82
;
; stacktrace using BP. Go through BP chain, attempting to find calls to
; current procedure and displaying name (if it exists symbolicly) and
; arguments.
;
include noxport.inc
include newexe.inc
SEGI STRUC ;* result of GetCodeInfo
sectorSegi DW ? ; logical sector number in file of start of segment
cbFileSegi DW ? ; number bytes in file
flagsSegi DW ? ; segment flags
cbRamSegi DW ? ; minimum number bytes to allocate for segment
hSegi DW ? ; Handle to segment (0 if not loaded)
cbAlignSegi DW ? ; Alignment shift count for segment data
SEGI ENDS
PCODE_HEADER struc
ph_code db 3 dup(?)
ph_enMacReg db ?
ph_snReg dw ?
ph_rReg dw ?
ph_mpenbpc dw ?
PCODE_HEADER ends
sBegin DATA
staticB segiT,<SIZE SEGI DUP (?)> ;* SEGI buffer for GetCodeInfo
sEnd DATA
createSeg _RIP,rip,byte,public,CODE
PUBLIC StackTrace
externFP <FGetSegSymb, FFindSeg, FGetSymbol>
externFP <GetSnMac, FGetPcodeSegName, FGetConstSymb>
externFP <HOpenOutFile, DwSeekDw, CchWriteDoshnd, FCloseDoshnd>
externFP <HOpenDbgScreen>
externFP <GetCodeInfo,GlobalHandle>
externA $q_snMacReal
sBegin data
externW SymDef
externW $q_mpsnpfn
externW vpszStackTrace1
externW vpszStackTrace2
fDoingRIP dw 0 ; currently in process of ripping...
sEnd DATA
; CODE SEGMENT _RIP
sBegin rip
assumes cs,rip
assumes ds,dgroup
assumes ss,dgroup
csCurrent equ bp-8 ; Most recent CS during backtrace
bpCurrent equ bp-10 ; Most recent BP during backtrace
bpLast equ bp-12 ; Most recent BP during backtrace
fPcodeFrame equ bp-14 ; TRUE == Pcode frame
RetSeg equ bp-16 ; return segment from frame
RetOffset equ bp-18 ; return offset from frame
SnMac equ bp-20 ; count of pcode segments
pBuff equ bp-22 ; pointer into buffer
BuffStart equ bp-(24+80) ; buffer start
SymFile equ bp-(104+66) ; sym file name
hOutFile equ bp-172 ; dos handle for output file
chOutBuff equ bp-174 ; buffer for a char to output
pArgStart equ bp-176 ; pointer to start of args
pArgEnd equ bp-178 ; pointer to end of args
pLocalStart equ bp-180 ; pointer to start of locals
pLocalEnd equ bp-182 ; pointer to end of locals
cPcodeArgs equ bp-184 ; count of pcode args
fPrintDbgScr equ bp-186 ; print chars to the aux port?
fThunk equ bp-188 ; true iff last far ret was a thunk address
hDbgScreen equ bp-190 ; dos handle for debug screen
fNextFrameNat equ bp-192 ; true iff switching from pcode to native
cbLocalsMax equ 194
;* * * String pool
szSnMsg: DB "pcode : sn = ", 0
szBpcMsg: DB " bpc = ", 0
szBadBP DB 0dh, 0ah, "Illegal Frame Pointer = ", 0
szNoStack DB 0dh, 0ah, "Not enough stack to run RIP code", 0dh, 0ah, 0
szArg DB " Args:", 0dh, 0ah, 0
szLocal DB " Locals:", 0dh, 0ah, 0
StackTrace proc far
cmp ss:[fDoingRIP],0 ; are we currently ripping?
jz traceinit ; no - skip
ret ; yes - just return
traceinit:
mov ax,sp ; check to see if we have enough
sub ax,cbLocalsMax ; stack to run the RIP code
cmp ax,ss:[0ah]
ja traceinit2
mov bx,offset szNoStack ; send message about out of stack space
push cs
pop es
call PrintSz
ret
traceinit2:
mov ss:[fDoingRIP],1 ; indicate we are currently ripping
INC BP ; setup a standard frame
PUSH BP
MOV BP,SP
PUSH DS
PUSH DI
PUSH SI
SUB SP,cbLocalsMax ; save room for locals...
push ss ; set ds = frame seg
pop ds
; init locals
mov word ptr [fPrintDbgScr],1 ; indicate printing to the debug screen OK
call HOpenDbgScreen ; enable printing to the debug screen?
mov [hDbgScreen],ax ; save handle to debug screen
cmp ax,-1 ; legal handle?
jne traceinit3 ; yes - skip
mov word ptr [fPrintDbgScr],0 ; indicate printing to the debug screen not OK
traceinit3:
mov bx,[bp] ; init past the DoStackTrace proc
and bl,0feh
mov [bpLast],bx
mov word ptr [fPcodeFrame],1 ; start out in pcode mode
mov word ptr [fThunk],0 ; clear thunk hit flag
mov bx,[bx]
and bl,0feh
mov [bpCurrent],bx
mov [csCurrent],cs
mov ax,0
mov [pArgStart],ax
mov [pArgEnd],ax
mov [pLocalStart],ax
mov [pLocalEnd],ax
mov [fNextFrameNat],ax
call GetSnMac
mov [SnMac],ax
call HOpenOutFile ; open the output file
mov [hOutFile],ax ; save returned file handle
cmp ax,-1 ; was the file opened?
je traceinit4 ; no - skip
push ax ; handle of file to seek in
xor ax,ax ; offset to seek to
push ax
push ax
mov ax,2 ; seek to end of file
push ax
call DwSeekDw
test dx,8000h ; error?
jz traceinit4 ; no - skip
lea bx,[hOutFile]
call CloseOutFile ; yes - close the file
traceinit4:
call doutcrlf
call doutcrlf
mov bx,[vpszStackTrace1] ; get Stack Trace Message
push ss
pop es
call PrintSz
call doutcrlf
mov bx,[vpszStackTrace2] ; state info
push ss ; point es to local vars area
pop es
call PrintSz
call doutcrlf
call doutcrlf
traceloop:
mov bx,[bpCurrent]
mov [bpLast],bx
mov bx,[bx] ; get previous bp
and bl,0feh ; strip off near/far flag
mov [bpCurrent],bx ; and save it
or bx,bx ; end of frames?
jnz traceloop2 ; no - skip
jmp endtrace ; yes - quit
traceloop2:
cmp bx,[bpLast] ; is this OK?
jbe traceloop4 ; no - skip
lea ax,[BuffStart] ; get address of start of strings
mov [pBuff],ax ; and save it
cmp bx,word ptr ds:[0ah] ; below stack min?
jb traceloop4
cmp bx,word ptr ds:[0eh] ; or above stack max?
jbe traceloop6
traceloop4:
jmp badbp
traceloop6:
cmp word ptr [fPcodeFrame],0 ; were we in a pcode frame?
jz traceloop8 ; no - skip
cmp word ptr [fNextFrameNat],0 ; native code in this frame?
jz traceloop7 ; no - skip
mov word ptr [fPcodeFrame],0 ; yes - indicate native code
mov word ptr [fNextFrameNat],0 ; clear flag
jmp traceloop8 ; skip
traceloop7:
test byte ptr [bx],1 ; are we switching to native?
jz traceloop8 ; no - skip
mov word ptr [fNextFrameNat],1 ; yes - indicate native code in next frame
mov bx,[bpLast] ; check for return sn == snMac
mov ax,[bx+4]
and ax,7fffh
cmp ax,[snMac]
jz traceloop ; yes - skip to next frame
traceloop8:
call GetRetAddr ; get next return address
mov [RetOffset],ax ; save address for later...
mov [RetSeg],dx
cmp word ptr [fPcodeFrame],0 ; are we in a pcode frame?
jz traceloop10 ; no - skip
call PrintPcodeAddress ; yes - print sn:bpc
jmp traceloop34
traceloop10:
cmp word ptr [fThunk],0 ; is this a short ret to a swapped segment?
jz traceloop11 ; no - skip
push dx ; yes - pass the segment number
lea bx,[SymFile] ; pass the address to save the sym file name
push bx
push [pBuff] ; pass the address to save the seg name
call FGetSegSymb ; get the segment symbol
jmp traceloop18
traceloop11:
;* * See if a Windows thunk
mov es,[RetSeg] ; get seg and offset of return
mov bx,[RetOffset]
cmp word ptr es:[bx],INTVECTOR shl 8 OR INTOPCODE
jne traceloop16
cmp byte ptr es:[bx+2],0
jne traceloop16
xor cx,cx
mov cl,es:[bx+3] ; get segment number
jcxz traceloop16 ; not thunk if == 0
traceloop12:
add bx,4 ; Scan forwards for end of table
cmp word ptr es:[bx],0
jnz traceloop12
mov es,word ptr es:[bx+2] ; Got it, recover EXE header address
cmp word ptr es:[ne_magic],NEMAGIC ; Is it a new exe header?
jne traceloop16 ; No, then cant be return thunk.
push cx ; save segment number
mov [csCurrent],cx
mov word ptr [fThunk],1 ; indicate hit a thunk
mov bx,es:[ne_restab] ; get pointer to stModuleName
mov cl,es:[bx] ; get length of module name
lea di,[SymFile] ; get the address to save the sym file name
traceloop14:
inc bx ; point to next char
mov al,es:[bx] ; get a char
mov [di],al ; save it
inc di
loop traceloop14
mov word ptr [di],'s.' ; save .sym on end of module name
mov word ptr [di+2],'my'
mov byte ptr [di+4],0
mov bx,[bpLast] ; get pointer to frame
mov bx,[bx-2] ; get "real" return offset
mov [RetOffset],bx ; and save it
lea bx,[SymFile] ; pass the address to save the sym file name
push bx
push [pBuff] ; pass the address to save the seg name
call FGetSegSymb ; get the segment symbol
jmp traceloop18
traceloop16:
push [RetSeg] ; pass the segment to look up
lea bx,[SymFile] ; pass the address to save the sym file name
push bx
push [pBuff] ; pass the address to save the seg name
call FFindSeg ; find the segment
traceloop18:
or ax,ax ; successful?
jnz traceloop20 ; yes - skip
call PrintSegOff ; no - just print segment:offset
jmp traceloop34
traceloop20:
mov bx,[pBuff] ; get the pointer to the buffer
dec bx
traceloop22:
inc bx ; point to next char
cmp byte ptr [bx],0 ; end of string?
jnz traceloop22 ; no - loop
mov byte ptr [bx],':' ; yes - save seperator in string
inc bx ; point to where to put offset symbol
mov [pBuff],bx ; and save it
push [RetOffset] ; pass the offset to lookup
push [pBuff] ; pass the place to put the offset symbol
call FGetSymbol ; get the symbol
or ax,ax ; successful?
jnz traceloop24 ; yes - skip
call PrintSegOff ; no - just print segment:offset
jmp traceloop34
traceloop24:
;* * before printing : compare with special names : RetToolbox? RetNative?
mov bx,[pBuff] ; get the pointer to the buffer
;* * possibly "RetNative?" (sure it's ugly - but fast & simple)
cmp word ptr [bx],"eR"
jne traceloop26
cmp word ptr [bx+2],"Nt"
jne traceloop26
cmp word ptr [bx+4],"ta"
jne traceloop26
cmp word ptr [bx+6],"vi"
jne traceloop26
cmp byte ptr [bx+8],"e"
jne traceloop26
cmp byte ptr [bx+9],"0"
jb traceloop26
cmp byte ptr [bx+9],"3"
ja traceloop26
cmp byte ptr [bx+10],0
je traceloop28
traceloop26:
;* * possibly "RetToolbox?"
cmp word ptr [bx],"eR"
jne traceloop30
cmp word ptr [bx+2],"Tt"
jne traceloop30
cmp word ptr [bx+4],"oo"
jne traceloop30
cmp word ptr [bx+6],"bl"
jne traceloop30
cmp word ptr [bx+8],"xo"
jne traceloop30
cmp byte ptr [bx+10],"0"
jb traceloop30
cmp byte ptr [bx+10],"3"
ja traceloop30
cmp byte ptr [bx+11],0
jne traceloop30
;* * Start of Pcode frame
traceloop28:
mov word ptr [fPcodeFrame],1
mov word ptr [fThunk],0 ; clear thunk hit flag
jmp traceloop40 ; skip to next frame...
traceloop30:
lea bx,[SymFile] ; point to sym file name
traceloop32:
inc bx ; point to next char
cmp byte ptr [bx],'.' ; at file extension yet?
jne traceloop32 ; no - loop
mov byte ptr [bx],0 ; yes - end string here
mov dx,bx ; and save for a moment
lea bx,[SymFile] ; point to sym file name
push ss ; point es to local vars area
pop es
call PrintSz ; print the map name
mov bx,dx ; point to where we ended the string
mov byte ptr [bx],'.' ; restore the extension
mov al,'!' ; seperator between map name and seg name
call dout
lea bx,[BuffStart] ; point to seg and symbol names
push ss ; point es to local vars area
pop es
call PrintSz ; print the map name
mov cx,[RetOffset] ; get offset
sub cx,[SymDef] ; calc offset from start of proc
jcxz traceloop34 ; skip if no offset
mov al,'+' ; seperator between symbol name and offset
call dout
mov ax,cx ; output the offset
call dout16
traceloop34:
cmp word ptr [fPcodeFrame],0 ; pcode frame?
jz traceloop36 ; no - skip
cmp word ptr [fNextFrameNat],0 ; is this really a native frame?
jnz traceloop36 ; yes - skip
call SetupPcodeArgs ; yes - setup to print pcode locals and args
jmp traceloop38
traceloop36:
call SetupNatArgs ; setup to print native locals and args
traceloop38:
call PrintArgs ; print this frame's locals and args
call doutcrlf ; output a carrage return line feed
traceloop40:
jmp traceloop ; and loop and loop and...
badbp:
mov bx,offset szBadBP ; print bad BP message
push cs
pop es
call PrintSz
mov ax,[bpLast]
call dout16
call doutcrlf
endtrace:
lea bx,[hOutFile]
call CloseOutFile ; close the output file
lea bx,[hDbgScreen]
call CloseOutFile ; close the debug screen
sub bp,0006
mov sp,bp
pop si
pop di
pop ds
pop bp
dec bp
mov ss:[fDoingRIP],0 ; indicate we are not currently ripping
ret
stacktrace endp
;
; GetRetAddr - peeks at frame to get return address
;
; enter:
; exit: dx:ax = return address
;
GetRetAddr:
mov bx,[bpLast]
mov ax,[bx+2] ; get offset part of ret addr
mov dx,[bx+4] ; get segment part
test byte ptr [bx],1 ; near or far frame?
jz getnearaddr
;
; far frame
;
mov [csCurrent],dx ; remember current CS
mov word ptr [fThunk],0 ; clear thunk hit flag
ret
getnearaddr:
test byte ptr [fPcodeFrame],0ffh
jz near_native
;* * Pcode return
and dh,07fh ;* strip fValue bit
ret
near_native:
mov dx,[csCurrent] ; use current CS
ret
;
; Print return address in form:
;
; <segment>:<offset>
;
PrintSegOff:
mov ax,[RetSeg]
call dout16
mov al,":"
call dout
mov ax,[RetOffset]
call dout16
ret
;* * Special Pcode routines
;* print Pcode address
PrintPcodeAddress:
mov word ptr [cPcodeArgs],0 ; init count of pcode args
mov bx,offset szSnMsg ; print sn message
push cs
pop es
call PrintSz
mov ax,[RetSeg] ; get sn
push ax ; save for call to FGetPcodeSegName
call dout16
push [pBuff] ; point to buffer
call FGetPcodeSegName
or ax,ax ; seg name found?
jz PrintPcode2 ; no - skip
mov al," " ; print seg name
call dout
mov al," "
call dout
mov al,"("
call dout
push ds
pop es
mov bx,[pBuff]
call PrintSz
mov al,")"
call dout
PrintPcode2:
mov bx,offset szBpcMsg ; print bpc message
push cs
pop es
call PrintSz
mov ax,[RetOffset] ; get bpc
call dout16
mov bx,[RetSeg] ; get sn
push bx
call near ptr GetPsOfSn ; get physical address of pcode seg
or ax,ax ; swapped out?
jnz PrintPcode4 ; no - skip
jmp PrintPcode12 ; yes - exit
PrintPcode4:
mov es,ax ; in memory - put seg in es
mov bx,offset ph_mpenbpc ; point to mpenbpc table
xor cx,cx
mov cl,es:[ph_enMacReg] ; get count of procs
mov dx,0 ; init proc counter
PrintPcode6:
mov ax,es:[bx] ; get the next entry point
cmp ax,[RetOffset] ; is this one past the one we want?
ja PrintPcode8 ; yes - skip
inc bx ; point to next entry
inc bx
inc dx ; bump proc counter
loop PrintPcode6 ; and loop
PrintPcode8:
mov bx,es:[bx-2] ; save start of the proc
push bx
mov al,es:[bx-1] ; get seg code byte
and ax,001fh ; strip off all but count of args
mov [cPcodeArgs],ax
dec dx ; set proc number back
mov dh,[RetSeg] ; get seg in dh, proc # in dl
push dx
lea bx,[SymFile] ; get pointer to sym file name
mov [bx],'po' ; and save 'opus.sym' in it
mov [bx+2],'su'
mov [bx+4],'s.'
mov [bx+6],'my'
mov byte ptr [bx+8],0
push bx
push [pBuff] ; point to buffer
call FGetConstSymb
pop dx ; get back start of proc offset
or ax,ax ; OK?
jz PrintPcode12 ; no - exit
mov al,' ' ; seperator between map name and seg name
call dout
mov al,' ' ; seperator between map name and seg name
call dout
mov al,'(' ; seperator between map name and seg name
call dout
lea bx,[BuffStart] ; point to seg and symbol names
push ss ; point es to local vars area
pop es
call PrintSz ; print the map name
mov cx,[RetOffset] ; get offset
sub cx,dx ; calc offset from start of proc
dec cx
dec cx
jcxz PrintPcode10 ; skip if no offset
mov al,'+' ; seperator between symbol name and offset
call dout
mov ax,cx ; output the offset
call dout16
PrintPcode10:
mov al,')' ; seperator between map name and seg name
call dout
PrintPcode12:
ret
PrintArgs:
push [fPrintDbgScr] ; save flag
mov word ptr [fPrintDbgScr], 0 ; don't print args to the aux port
call doutcrlf
mov bx,offset szArg ; point to args string
push cs ; point es to local vars area
pop es
call PrintSz ; print the string
mov si,-2
mov bx,[pArgStart] ; point to start of args
mov cx,bx
sub cx,[pArgEnd] ; calc cb to print
cmp cx,0
jns PrintArgs2 ; skip if don't need to fix increment
mov si,2
neg cx
PrintArgs2:
call DumpMem ; dump the args
mov bx,offset szLocal ; point to locals string
push cs ; point es to local vars area
pop es
call PrintSz ; print the map name
mov si,-2
mov bx,[pLocalStart] ; point to start of locals
mov cx,bx
sub cx,[pLocalEnd] ; calc cb to print
cmp cx,0
jns PrintArgs4 ; skip if don't need to fix increment
mov si,2
neg cx
PrintArgs4:
call DumpMem ; dump the locals
pop [fPrintDbgScr] ; restore flag
xor ax,ax ; clear pointers
mov [pArgStart],ax
mov [pArgEnd],ax
mov [pLocalStart],ax
mov [pLocalEnd],ax
ret
DumpMem:
shr cx,1 ; make into cwDump
jcxz DumpMem6 ; exit if nothing to print
jmp DumpMem3
DumpMem2:
cmp dl,8 ; done with this line?
jb DumpMem4 ; no - skip
call doutcrlf
DumpMem3:
mov al,' '
call dout
call dout
call dout
call dout
mov dl,0
DumpMem4:
mov ax,[bx] ; get a word
call dout16
mov al,' ' ; seperator between numbers
call dout
call dout
add bx,si ; point to next word
inc dl ; bump counter
loop DumpMem2 ; loop until all words printed
call doutcrlf
DumpMem6:
ret
SetupPcodeArgs:
mov ax,[bpCurrent] ; set pArgStart and pArgEnd
dec ax
dec ax
mov [pArgStart],ax
mov cx,[cPcodeArgs]
shl cx,1
sub ax,cx
mov [pArgEnd],ax
mov [pLocalStart],ax ; set pLocalStart and pLocalEnd
mov ax,[bpLast]
add ax,4
mov [pLocalEnd],ax
ret
SetupNatArgs:
mov ax,[bpCurrent] ; set pArgStart and pArgEnd
mov bx,ax
add ax,4
test word ptr [bx],0001h
jz SetupNat2
add ax,2
SetupNat2:
mov [pArgStart],ax
mov bx,[bx]
and bl,0feh
sub bx,4
cmp bx,-4
jne SetupNat4
mov bx,ax
SetupNat4:
mov [pArgEnd],bx
mov ax,[bpCurrent] ; set pLocalStart and pLocalEnd
sub ax,8
mov [pLocalStart],ax
mov ax,[bpLast]
add ax,8
mov [pLocalEnd],ax
ret
;*
;* PrintSz : ES:BX = "sz" string
;*
;* print string
PrintSz:
push ax ; save regs
PrintSz2:
mov al,es:[bx] ; get a char
inc bx ; point to next char
cmp al,0 ; end of string?
jz PrintSz4 ; yes - exit
call dout ; output the char
jmp PrintSz2 ; loop
PrintSz4:
pop ax
ret
MakeHexDigit:
add al,'0'
cmp al,'9'
jbe MakeHex2
add al,'A' - '0' - 10
MakeHex2:
ret
; print out a 16 bit unsigned in 4 hex digit format
dout16:
push bx ; save environment
push cx
mov bx,ax ; val saved in bx
mov al,ah
mov cl,4
shr al,cl
call MakeHexDigit
call dout
mov al,bh
and al,0fh
call MakeHexDigit
call dout
mov al,bl
mov cl,4
shr al,cl
call MakeHexDigit
call dout
mov al,bl
and al,0fh
call MakeHexDigit
call dout
pop cx ; restore environment
pop bx
ret
; print out a carrage return line feed pair
doutcrlf:
mov al,0dh
call dout
mov al,0ah
call dout
ret
; print out a char
dout:
push bx ; save environment
cmp word ptr [fPrintDbgScr],0 ; print to the debug screen?
jz dout2 ; no - skip
lea bx,[hDbgScreen] ; get handle of debug screen to print to
call doutfile
dout2:
lea bx,[hOutFile] ; get handle of file to print to
call doutfile
pop bx ; restore environment
ret
; print out a char to the opened file
doutfile:
cmp [bx],0ffffh ; exit if file not open
je doutfile4
push ax ; save environment
push cx
push dx
push bx
push [bx] ; pass file handle
lea bx,[chOutBuff]
push ss
push bx
mov [bx],al
mov ax,1
push ax
call CchWriteDoshnd
test ax,8000h
jz doutfile2
pop bx ; close this file if error
push bx
call CloseOutFile
doutfile2:
pop bx ; restore environment
pop dx
pop cx
pop ax
doutfile4:
ret
; close the output file
CloseOutFile:
cmp [bx],0ffffh
je CloseOut2
push ax ; save environment
push cx
push dx
push bx
push [bx]
call FCloseDoshnd
pop bx
mov [bx],0ffffh
pop dx ; restore environment
pop cx
pop ax
CloseOut2:
ret
;********** GetPsOfSn **********
;* entry : sn = Pcode segment #
;* * find physical segment of Pcode segment (if resident)
;* exit : AX = ps (or 0 if not resident)
; %%Function:GetPsOfSn %%Owner:BRADV
cProc GetPsOfSn, <NEAR, ATOMIC>
ParmW sn
cBegin GetPsOfSn
XOR AX,AX ;* return zero if segMac
MOV BX,sn
CMP BX,$q_snMacReal
JAE get_ps_end
SHL BX,1 ;* Make into word pointer
SHL BX,1 ;* DWORD ptr
ADD BX,OFFSET DGROUP:$q_mpsnpfn ;* DS:BX => table
PUSH WORD PTR [BX+2] ;* segment
PUSH WORD PTR [BX] ;* offset (lpthunk on stack)
MOV BX,OFFSET DGROUP:segiT ;* address of buffer
cCall GetCodeInfo,<DS,BX> ;* lpthunk, lpsegi
OR AX,AX
JZ get_ps_end ;* error - assume non-resident
;* * good segment info, see if segment resident
MOV AX,segiT.hSegi ;* handle or ps if fixed
TEST AX,1
JNZ get_ps_end ;* ax = ps
cCall GlobalHandle,<ax> ;* get handle info
MOV AX,DX ;* ps (or 0 if not loaded)
get_ps_end:
cEnd GetPsOfSn
sEnd rip
END
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+81
View File
@@ -0,0 +1,81 @@
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg sttb_PCODE,sttb,byte,public,CODE
; DEBUGGING DECLARATIONS
; EXTERNAL FUNCTIONS
sBegin data
; EXTERNALS
sEnd data
; CODE SEGMENT _STTB
sBegin sttb
assumes cs,sttb
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; AddDcbToLprgbst(lpbstFirst, ibstMac, dcb, bstThreshold)
;-------------------------------------------------------------------------
;AddDcbToLprgbst(lpbstFirst, ibstMac, dcb, bstThreshold)
;int far *lpbstFirst;
;int ibstMac;
;int dcb;
;int bstThreshold;
;{
; int far *lpbst = lpbstFirst;
;
; for (ibst = 0; ibst < ibstMac; ibst++, lpbst++)
; {
; if (*lpbst >= bstThreshold)
; *lpbst += dcb;
; }
;}
; %%Function:AddDcbToLprgbst %%Owner:BRADV
cProc AddDcbToLprgbst,<PUBLIC,FAR,ATOMIC>,<>
ParmD lpbstFirst
ParmW ibstMac
ParmW dcb
ParmW bstThreshold
cBegin
mov cx,[ibstMac]
jcxz ADTL04
mov dx,[dcb]
les bx,[lpbstFirst]
mov ax,[bstThreshold]
or ax,ax
je ADTL03
ADTL01:
cmp es:[bx],ax
jb ADTL02
add es:[bx],dx
ADTL02:
inc bx
inc bx
loop ADTL01
jmp short ADTL04
ADTL03:
add es:[bx],dx
inc bx
inc bx
loop ADTL03
ADTL04:
cEnd
; End of AddDcbToLprgbst
sEnd sttb
end
+20
View File
@@ -0,0 +1,20 @@
; W2.INC
;
; Standard include file for all opus assembly files.
; (Parallels w2.n).
;
ifdef DEBUG
PROFILE=1
endif
ifdef PROFILE
ifndef ?USEBP
; Enable PROFILING of native routines
?PROFILE = 1
endif
endif
+792
View File
@@ -0,0 +1,792 @@
;*************************************************************************
;
; WINDOWS.INC - Windows assembly language structures & constants
;
;*************************************************************************
;
; Conditional Block includes: (True states)
; NOTEXT - don't include TextMetric struc & text drawing modes & stock objs.
; NORASTOPS - don't include binary and ternary raster ops.
; NOVK - don't include virtual key definitions
; NOMB - don't include message box definitions
; NOWM - don't include window messages
;
;
FALSE = 0
TRUE = 1
NULL = 0
;*******************************************************************
;
; Rectangle
;
;*******************************************************************
RECT struc
rcLeft dw ?
rcTop dw ?
rcRight dw ?
rcBottom dw ?
RECT ends
;*******************************************************************
;
; Window Class structure
;
;*******************************************************************
WNDCLASS struc
clsStyle dw ? ; class style
clsLpfnWndProc dd ?
clsCbClsExtra dw ?
clsCbWndExtra dw ?
clsHInstance dw ? ; instance handle
clsHIcon dw ? ; class icon handle
clsHCursor dw ? ; class cursor handle
clsHbrBackground dw ? ; class background brush
clsLpszMenuName dd ? ; menu name
clsLpszClassName dd ? ; far ptr to class name
WNDCLASS ends
IFNDEF NOTEXT
TEXTMETRIC struc
tmHeight dw ?
tmAscent dw ?
tmDescent dw ?
tmIntLeading dw ?
tmExtLeading dw ?
tmAveCharWidth dw ?
tmMaxCharWidth dw ?
tmWeight dw ?
tmItalic db ?
tmUnderlined db ?
tmStruckOut db ?
tmFirstChar db ?
tmLastChar db ?
tmDefaultChar db ?
tmBreakChar db ?
tmPitch db ?
tmCharSet db ?
tmOverhang dw ?
tmAspectX dw ?
tmAspectY dw ?
TEXTMETRIC ends
;
; Text Drawing modes
;
TRANSPARENT = 1
OPAQUE = 2
;
; Stock Logical Objects
;
WHITE_BRUSH = 0
LTGRAY_BRUSH = 1
GRAY_BRUSH = 2
DKGRAY_BRUSH = 3
BLACK_BRUSH = 4
HOLLOW_BRUSH = 5
WHITE_PEN = 6
BLACK_PEN = 7
NULL_PEN = 8
DOT_MARKER = 9
OEM_FIXED_FONT = 10
ANSI_FIXED_FONT = 11
ANSI_VAR_FONT = 12
ENDIF
;
ANSI_CHARSET = 0
OEM_CHARSET = 255
;
; styles for CombineRgn
;
RGN_AND = 1
RGN_OR = 2
RGN_XOR = 3
RGN_DIFF = 4
RGN_COPY = 5
;
; Predefined cursor & icon IDs
;
IDC_ARROW = 32512
IDC_IBEAM = 32513
IDC_WAIT = 32514
IDC_CROSS = 32515
IDC_UPARROW = 32516
IDC_SIZE = 32640
IDC_ICON = 32641
IDI_APPLICATION = 32512
IDI_HAND = 32513
IDI_QUESTION = 32514
IDI_EXCLAMATION = 32515
IDI_ASTERISK = 32516
;
; Scroll bar constants
;
SB_HORZ = 0
SB_VERT = 1
;
; Scroll Commands
;
SB_LINEUP = 0
SB_LINEDOWN = 1
SB_PAGEUP = 2
SB_PAGEDOWN = 3
SB_THUMBPOSITION = 4
SB_THUMBTRACK = 5
;
; MessageBox type flags
;
IFNDEF NOMB
MB_OK = 0000H
MB_OKCANCEL = 0001H
MB_ABORTRETRYIGNORE = 0002H
MB_YESNOCANCEL = 0003H
MB_ICONHAND = 0010H
MB_ICONQUESTION = 0020H
MB_ICONEXCLAMATION = 0030H
MB_ICONASTERISK = 0040H
MB_DEFBUTTON1 = 0000H
MB_DEFBUTTON2 = 0100H
MB_DEFBUTTON3 = 0200H
MB_APPLMODAL = 0000H
MB_SYSTEMMODAL = 1000H
;
; Conventional dialog box and message box command IDs
;
IDOK = 1
IDCANCEL = 2
IDABORT = 3
IDRETRY = 4
IDIGNORE = 5
IDYES = 6
IDNO = 7
;
; Flags for OpenFile
;
OF_REOPEN = 8000H
OF_EXIST = 4000H
OF_PROMPT = 2000H
OF_CREATE = 1000H
OF_CANCEL = 0800H
TF_FORCEDRIVE = 80H
OPENSTRUC STRUC
opLen db ?
opDisk db ?
opXtra dw ?
opDate dw ?
opTime dw ?
opFile db 120 dup (?)
OPENSTRUC ENDS
;
; DrawText format flags
;
DT_LEFT = 00H
DT_CENTER = 01H
DT_RIGHT = 02H
DT_TOP = 00H
DT_VCENTER = 04H
DT_BOTTOM = 08H
DT_WORDBREAK = 10H
DT_SINGLELINE = 20H
DT_EXPANDTABS = 40H
DT_TABSTOP = 80H
ENDIF
;
; Memory manager flags
;
LMEM_FIXED = 00h
LMEM_MOVEABLE = 02h
LMEM_NOCOMPACT = 10h
LMEM_NODISCARD = 20h
LMEM_ZEROINIT = 40h
LMEM_DISCARDABLE= 0F00h
LHND = LMEM_MOVEABLE+LMEM_ZEROINIT
LPTR = LMEM_FIXED+LMEM_ZEROINIT
GMEM_FIXED = 00h
GMEM_MOVEABLE = 02h
GMEM_ZEROINIT = 40h
GMEM_DISCARDABLE= 0F00h
GMEM_SHARE = 1000h
GMEM_LOCKCOUNT = 00FFh
GHND = GMEM_MOVEABLE+GMEM_ZEROINIT
GPTR = GMEM_FIXED+GMEM_ZEROINIT
; Virtual Keys, Standard Set
IFNDEF NOVK
VK_LBUTTON = 01H
VK_RBUTTON = 02H
VK_CANCEL = 03H
VK_BACK = 08H
VK_TAB = 09H
VK_CLEAR = 0cH
VK_RETURN = 0dH
VK_SHIFT = 10H
VK_CONTROL = 11H
VK_MENU = 12H
VK_PAUSE = 13H
VK_CAPITAL = 14H
VK_ESCAPE = 1bH
VK_SPACE = 20H
VK_PRIOR = 21H
VK_NEXT = 22H
VK_END = 23H
VK_HOME = 24H
VK_LEFT = 25H
VK_UP = 26H
VK_RIGHT = 27H
VK_DOWN = 28H
; VK_A thru VK_Z are the same as their ASCII equivalents: 'A' thru 'Z'
; VK_0 thru VK_9 are the same as their ASCII equivalents: '0' thru '0'
VK_PRINT = 2aH
VK_EXECUTE = 2bH
VK_INSERT = 2dH
VK_DELETE = 2eH
VK_HELP = 2fH
VK_NUMPAD0 = 60H
VK_NUMPAD1 = 61H
VK_NUMPAD2 = 62H
VK_NUMPAD3 = 63H
VK_NUMPAD4 = 64H
VK_NUMPAD5 = 65H
VK_NUMPAD6 = 66H
VK_NUMPAD7 = 67H
VK_NUMPAD8 = 68H
VK_NUMPAD9 = 69H
VK_MULTIPLY = 6AH
VK_ADD = 6BH
VK_SEPARATER = 6CH
VK_SUBTRACT = 6DH
VK_DECIMAL = 6EH
VK_DIVIDE = 6FH
VK_F1 = 70H
VK_F2 = 71H
VK_F3 = 72H
VK_F4 = 73H
VK_F5 = 74H
VK_F6 = 75H
VK_F7 = 76H
VK_F8 = 77H
VK_F9 = 78H
VK_F10 = 79H
VK_F11 = 7aH
VK_F12 = 7bH
VK_F13 = 7cH
VK_F14 = 7dH
VK_F15 = 7eH
VK_F16 = 7fH
ENDIF
;*************************************************************************
;
; Misc structures & constants
;
;*************************************************************************
IFNDEF NOMST
POINT struc
ptX dw ?
ptY dw ?
POINT ends
BITMAP STRUC
bmType DW ?
bmWidth DW ?
bmHeight DW ?
bmWidthBytes DW ?
bmPlanes DB ?
bmBitsPixel DB ?
bmBits DQ ?
BITMAP ENDS
WNDSTRUC struc
WSwndStyle dd ?
WSwndID dw ?
WSwndText dw ?
WSwndParent dw ?
WSwndInstance dw ?
WSwndClassProc dd ?
WNDSTRUC ends
;
; Message structure
;
MSGSTRUCT struc
msHWND dw ?
msMESSAGE dw ?
msWPARAM dw ?
msLPARAM dd ?
msTIME dd ?
msPT dd ?
MSGSTRUCT ends
NEWPARMS struc
nprmHwnd dw ?
nprmCmd db ?
NEWPARMS ends
ENDIF
PAINTSTRUCT STRUC
PShdc DW ?
PSfErase DW ?
PSrcPaint DB size RECT dup(?)
PSfRestore DW ?
PSfIncUpdate DW ?
PSrgbReserved DB 16 dup(?)
PAINTSTRUCT ENDS
;
; ShowWindow commands
;
HIDE_WINDOW = 0
SHOW_OPENWINDOW = 1
SHOW_ICONWINDOW = 2
;
; PostError constants
;
WARNING = 0 ; command codes
MINOR_ERROR = 1
FATAL_ERROR = 2
IGNORE = 0 ; response codes
RETRY = 1
ABORT = 2
; GDI-related constants & commands
;
ERRORREGION = 0
NULLREGION = 1
SIMPLEREGION = 2
COMPLEXREGION = 3
;/* GDI Background Modes */
;
TRANSPARENT = 1
OPAQUE = 2
ETO_GRAYED equ 1
ETO_OPAQUE equ 2
ETO_CLIPPED equ 4
IFNDEF NORASTOPS
;
; Binary raster ops
;
R2_BLACK = 1
R2_NOTMERGEPEN = 2
R2_MASKNOTPEN = 3
R2_NOTCOPYPEN = 4
R2_MASKPENNOT = 5
R2_NOT = 6
R2_XORPEN = 7
R2_NOTMASKPEN = 8
R2_MASKPEN = 9
R2_NOTXORPEN = 10
R2_NOP = 11
R2_MERGENOTPEN = 12
R2_COPYPEN = 13
R2_MERGEPENNOT = 14
R2_MERGEPEN = 15
R2_WHITE = 16
;
; Ternary raster ops
;
SRCCOPY_L = 0020h ;dest=source
SRCCOPY_H = 00CCh
SRCPAINT_L = 0086h ;dest=source OR dest
SRCPAINT_H = 00EEh
SRCAND_L = 00C6h ;dest=source AND dest
SRCAND_H = 0088h
SRCINVERT_L = 0046h ;dest= source XOR dest
SRCINVERT_H = 0066h
SRCERASE_L = 0328h ;dest= source AND (not dest )
SRCERASE_H = 0044h
NOTSRCCOPY_L = 0008h ;dest= (not source)
NOTSRCCOPY_H = 0033h
NOTSRCERASE_L = 00A6h ;dest= (not source) AND (not dest)
NOTSRCERASE_H = 0011h
MERGECOPY_L = 00CAh ;dest= (source AND pattern)
MERGECOPY_H = 00C0h
MERGEPAINT_L = 0226h ;dest= (source AND pattern) OR dest
MERGEPAINT_H = 00BBh
PATCOPY_L = 0021h ;dest= pattern
PATCOPY_H = 00F0h
PATPAINT_L = 0A09h ;DPSnoo
PATPAINT_H = 00FBh
PATINVERT_L = 0049h ;dest= pattern XOR dest
PATINVERT_H = 005Ah
DSTINVERT_L = 0009h ;dest= (not dest)
DSTINVERT_H = 0055h
BLACKNESS_L = 0042h ;dest= BLACK
BLACKNESS_H = 0000h
WHITENESS_L = 0062h ;dest= WHITE
WHITENESS_H = 00FFh
;
; StretchBlt modes
;
BLACKONWHITE = 1
WHITEONBLACK = 2
COLORONCOLOR = 3
;
; PolyFill modes
;
ALTERNATE = 1
WINDING = 2
ENDIF
;
; Menu flags for Change/Check/Enable MenuItem
;
MF_CHANGE = 0080h
MF_INSERT = 0000h
MF_APPEND = 0100h
MF_DELETE = 0200h
MF_BYPOSITION = 0400h
MF_BYCOMMAND = 0000h
MF_GRAYED = 0001h
MF_DISABLED = 0002h
MF_ENABLED = 0000h
MF_CHECKED = 0008h
MF_BITMAP = 0004h
MF_STRING = 0000h
MF_POPUP = 0010h
MF_DIVIDER = 0020h
MF_BREAK = 0040h
;
; System Menu Command Values
;
SC_SIZE = 0F000H
SC_MOVE = 0F010H
SC_ICON = 0F020H
SC_ZOOM = 0F030H
SC_NEXTWINDOW = 0F040H
SC_PREVWINDOW = 0F050H
SC_CLOSE = 0F060H
SC_VSCROLL = 0F070H
SC_HSCROLL = 0F080H
SC_DUPLICATE = 0F090H
SC_MOUSEMENU = 0F100H
SC_KEYMENU = 0F110H
;
; Window State Messages
;
IFNDEF NOWM
WM_STATE = 0000H
WM_NULL = 0000H
WM_CREATE = 0001H
WM_DESTROY = 0002H
WM_QUERYDESTROY = 0003H
WM_MOVE = 0003H
WM_SYNCSIZE = 0004H
WM_SIZEWAIT = 0004H
WM_SIZE = 0005H
WM_ACTIVATE = 0006H
WM_SETFOCUS = 0007H
WM_KILLFOCUS = 0008H
WM_SETVISIBLE = 0009H
WM_ENABLE = 000AH
WM_SETREDRAW = 000BH
WM_SETTEXT = 000CH
WM_GETTEXT = 000DH
WM_GETTEXTLENGTH = 000EH
WM_PAINT = 000FH
WM_CLOSE = 0010H
WM_QUERYQUIT = 0011H
WM_QUERYENDSESSION = 0011H
WM_QUIT = 0012H
WM_QUERYOPEN = 0013H
WM_ERASEBKGND = 0014H
WM_SYSCOLORCHANGE = 0015H
WM_ENDSESSION = 0016H
WM_SYSTEMERROR = 0017H
WM_SHOWWINDOW = 0018H
WM_CTLCOLOR = 0019H
WM_WININICHANGE = 001AH
WM_DEVMODECHANGE = 001BH
WM_ACTIVATEAPP = 001CH
WM_FONTCHANGE = 001DH
WM_TIMECHANGE = 001EH
WM_CANCELMODE = 001FH
WM_SETCURSOR = 0020H
WM_MOUSEACTIVATE = 0021H
WM_CHILDACTIVATE = 0022H
WM_QUEUESYNC = 0023H
WM_GETMINMAXINFO = 0024H
WM_OTHERWINDOWDESTROY = 0025H
WM_PAINTICON = 0026H
WM_ICONERASEBKGND = 0027H
WM_NEXTDLGCTL = 0028H
WM_QUERYDEFPROC = 0080H
WM_NCCREATE = 0081H
WM_NCDESTROY = 0082H
WM_NCCALCSIZE = 0083H
WM_NCHITTEST = 0084H
WM_NCPAINT = 0085H
WM_NCACTIVATE = 0086H
WM_GETDLGCODE = 0087H
WM_ENDDIALOG = 0088H
WM_NCMOUSEMOVE = 00A0H
WM_NCLBUTTONDOWN = 00A1H
WM_NCLBUTTONUP = 00A2H
WM_NCLBUTTONDBLCLK = 00A3H
WM_NCRBUTTONDOWN = 00A4H
WM_NCRBUTTONUP = 00A5H
WM_NCRBUTTONDBLCLK = 00A6H
WM_KEYFIRST = 0100H
WM_KEYDOWN = 0100H
WM_KEYUP = 0101H
WM_CHAR = 0102H
WM_DEADCHAR = 0103H
WM_SYSKEYDOWN = 0104H
WM_SYSKEYUP = 0105H
WM_SYSCHAR = 0106H
WM_SYSDEADCHAR = 0107H
WM_KEYLAST = 0107H
WM_YOMICHAR = 0108H
WM_MOVECONVERTWINDOW = 0109H
WM_CONVERTREQUEST = 010AH
WM_CONVERTRESULT = 010BH
WM_INITDIALOG = 0110H
WM_COMMAND = 0111H
WM_SYSCOMMAND = 0112H
WM_TIMER = 0113H
WM_HSCROLL = 0114H
WM_VSCROLL = 0115H
WM_INITMENU = 0116H
WM_INITMENUPOPUP = 0117H
WM_SYSTIMER = 0118H
WM_DOQUIT = 0119H
WM_DOSETWINDOWPOS = 011AH
WM_DOSUSPEND = 011BH
WM_DOMINIMIZE = 011CH
WM_DOMAXIMIZE = 011DH
WM_DOACTIVATE = 011EH
WM_MENUSELECT = 011FH
WM_MENUCHAR = 0120H
WM_ENTERIDLE = 0121H
WM_MOUSEFIRST = 0200H
WM_MOUSEMOVE = 0200H ; mouse related stuff
WM_LBUTTONDOWN = 0201H
WM_LBUTTONUP = 0202H
WM_LBUTTONDBLCLK = 0203H
WM_RBUTTONDOWN = 0204H
WM_RBUTTONUP = 0205H
WM_RBUTTONDBLCLK = 0206H
WM_MBUTTONDOWN = 0207H
WM_MBUTTONUP = 0208H
WM_MBUTTONDBLCLK = 0209H
WM_MOUSELAST = 0209H
; clipboard messages
WM_CUT = 0300H
WM_COPY = 0301H
WM_PASTE = 0302H
WM_CLEAR = 0303H
WM_UNDO = 0304H
WM_RENDERFORMAT = 0305H
WM_RENDERALLFORMATS = 0306H
WM_DESTROYCLIPBOARD = 0307H
WM_DRAWCLIPBOARD = 0308H
WM_PAINTCLIPBOARD = 0309H
WM_VSCROLLCLIPBOARD = 030AH
WM_SIZECLIPBOARD = 030BH
WM_ASKCBFORMATNAME = 030CH
WM_CHANGECBCHAIN = 030DH
WM_HSCROLLCLIPBOARD = 030EH
WM_DDE_FIRST = 03E0H
WM_DDE_INITIATE = (WM_DDE_FIRST+0)
WM_DDE_TERMINATE = (WM_DDE_FIRST+1)
WM_DDE_ADVISE = (WM_DDE_FIRST+2)
WM_DDE_UNADVISE = (WM_DDE_FIRST+3)
WM_DDE_ACK = (WM_DDE_FIRST+4)
WM_DDE_DATA = (WM_DDE_FIRST+5)
WM_DDE_REQUEST = (WM_DDE_FIRST+6)
WM_DDE_POKE = (WM_DDE_FIRST+7)
WM_DDE_EXECUTE = (WM_DDE_FIRST+8)
WM_DDE_LAST = (WM_DDE_FIRST+8)
WM_CBTINIT = 03F0H ;/* CBT initialization message */
WM_CBTTERM = 03F1H ;/* CBT terminating; resume normal mode */
WM_CBTNEWWND = 03F2H ;/* new window being created */
WM_CBTSEMEV = 03F3H ;/* semantic event sent to CBT */
WM_HELP = 03F8H ;/* WinHelp context message */
; private window messages start here
WM_USER = 0400H
BM_GETCHECK = WM_USER + 0
BM_SETCHECK = WM_USER + 1
BM_GETSTATE = WM_USER + 2
BM_SETSTATE = WM_USER + 3
BM_SETSTYLE = WM_USER + 4
LB_ADDSTRING = WM_USER + 1
LB_INSERTSTRING = WM_USER + 2
LB_DELETESTRING = WM_USER + 3
LB_REPLACESTRING = WM_USER + 4
LB_RESETCONTENT = WM_USER + 5
LB_SETSEL = WM_USER + 6
LB_SETCURSEL = WM_USER + 7
LB_GETSEL = WM_USER + 8
LB_GETCURSEL = WM_USER + 9
LB_GETTEXT = WM_USER + 10
LB_GETTEXTLEN = WM_USER + 11
LB_GETCOUNT = WM_USER + 12
LB_SELECTSTRING = WM_USER + 13
LB_DIR = WM_USER + 14
LB_MSGMAX = WM_USER + 15
CBM_GETHLBOX = WM_USER + 34 ;/* Return handle to lbox */
CBM_GETHEDIT = WM_USER + 35 ;/* Return handle to edit */
CBM_SETTEXT = WM_USER + 38 ;/* SetText of CBox */
CBM_GETTEXT = WM_USER + 39 ;/* GetText of CBox */
CBM_COMPLETE = WM_USER + 40
CBM_SELECTSTRING = WM_USER + 41
CBM_SHOWLBOX = WM_USER + 42
CBM_HIDELBOX = WM_USER + 43
CBM_LBOXKILLFOCUS = WM_USER + 32
CBM_LBOXSETFOCUS = WM_USER + 33
CBM_ENTER = WM_USER + 36
CBM_ESC = WM_USER + 37
EM_GETSEL = WM_USER + 0
EM_SETSEL = WM_USER + 1
EM_GETRECT = WM_USER + 2
EM_SETRECT = WM_USER + 3
EM_SETRECTNP = WM_USER + 4
EM_SCROLL = WM_USER + 5
EM_LINESCROLL = WM_USER + 6
EM_GETMODIFY = WM_USER + 8
EM_SETMODIFY = WM_USER + 9
EM_GETLINECOUNT = WM_USER + 10
EM_LINEINDEX = WM_USER + 11
EM_SETHANDLE = WM_USER + 12
EM_GETHANDLE = WM_USER + 13
EM_GETTHUMB = WM_USER + 14
EM_LINELENGTH = WM_USER + 17
EM_REPLACESEL = WM_USER + 18
EM_SETFONT = WM_USER + 19
EM_GETLINE = WM_USER + 20
EM_LIMITTEXT = WM_USER + 21
EM_CANUNDO = WM_USER + 22
EM_UNDO = WM_USER + 23
EM_FMTLINES = WM_USER + 24
EM_LINEFROMCHAR = WM_USER + 25
EM_SETWORDBREAK = WM_USER + 26
TM_SETBMP = WM_USER + 55
BM_ACCEL = WM_USER + 100
ENDIF ; NOWM
; Size message commands
SIZENORMAL = 0
SIZEICONIC = 1
SIZEFULLSCREEN = 2
SIZEZOOMSHOW = 3
SIZEZOOMHIDE = 4
; identifiers for the WM_SHOWWINDOW message
SW_PARENTCLOSING = 1
SW_OTHERZOOM = 2
SW_PARENTOPENING = 3
SW_OTHERUNZOOM = 4
;
; Key state masks for mouse messages
;
MK_LBUTTON = 0001h
MK_RBUTTON = 0002h
MK_SHIFT = 0004h
MK_CONTROL = 0010h
;
; Class styles
;
CS_VREDRAW = 0001h
CS_HREDRAW = 0002h
CS_KEYCVTWINDOW = 0004H
CS_DBLCLKS = 0008h
CS_OEMCHARS = 0010h
CS_OWNDC = 0020h
CS_CLASSDC = 0040h
CS_PARENTDC = 0080h
CS_NOKEYCVT = 0100h
CS_SAVEBITS = 0800h
CS_NOCLOSE = 0200h
CS_BYTEALIGNCLIENT = 1000h
CS_BYTEALIGNWINDOW = 2000h
;
; Windows styles (the high words)
;
WS_TILED = 0000h
WS_POPUP = 8000h
WS_CHILD = 4000h
WS_ICONIC = 2000h
WS_VISIBLE = 1000h
WS_DISABLED = 0800h
WS_CLIPSIBLINGS = 0400h
WS_CLIPCHILDREN = 0200h
WS_BORDER = 0080h
WS_CAPTION = 0040h
WS_VSCROLL = 0020h
WS_HSCROLL = 0010h
WS_SYSMENU = 0008h
WS_SIZEBOX = 0004H
WS_HREDRAW = 0002h
WS_VREDRAW = 0001h
WS_TILEDWINDOW = WS_TILED + WS_BORDER + WS_CAPTION + WS_SYSMENU + WS_SIZEBOX
WS_POPUPWINDOW = WS_POPUP + WS_BORDER
WS_CHILDWINDOW = WS_CHILD
;
; predefined clipboard formats
;
CF_TEXT = 1
CF_BITMAP = 2
CF_METAFILE = 3
CF_BINARY = 4
CF_SYLK = 5
CF_DIF = 6
CF_OEMTEXT = 7
CF_OWNERDISPLAY = 80h ; owner display
CF_DSPTEXT = 81h ; display text
CF_DSPBITMAP = 82h ; display bitmap
CF_DSPMETAFILE = 83h ; display metafile
;
; Private clipboard format range
;
CF_PRIVATEFIRST = 200h ; Anything in this range doesn't
CF_PRIVATELAST = 2ffh ; get GlobalFree'd
CF_GDIOBJFIRST = 300h ; Anything in this range gets
CF_GDIOBJLAST = 3ffh ; DeleteObject'ed
MAKEINTRESOURCE MACRO a
mov ax,a
xor dx,dx
ENDM
;
; Predefined resource types
;
RT_CURSOR = 1 ; must be passed through MAKEINTRESOURCE
RT_BITMAP = 2
RT_ICON = 3
RT_MENU = 4
RT_DIALOG = 5
RT_STRING = 6
RT_FONTDIR = 7
RT_FONT = 8
+37
View File
@@ -0,0 +1,37 @@
ifndef OPUS
?QC = 1
memM = 1
?PLM = 1
?WIN = 0
?TF = 0
?DF = 0
.xlist
include hcmacros.inc
include pcode.inc
include macros.inc
.list
else
.xlist
memS = 1
?WIN = 1
?PLM = 1
?NODATA = 1
?TF = 1
include w2.inc
include noxport.inc
.list
endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Extra declarations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cpMax equ 07fffffffh
seg_cpMax equ 7fffh
off_cpMax equ 0ffffh
dcpMax equ 0ff00h
fcNil equ 0ffffffffh
seg_fcNil equ 0ffffh
off_fcNil equ 0ffffh
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More