/* ** WINDOWS - Simple but Elegant Window Functions ** (Datalight, Lattice, CI86, Microsoft, Borland ** Zortech, Mix PowerC, Manx AZTEC C, WATCOM) ** ** Copyright (c) 1984 - 1990 - Philip A. Mongelluzzo ** All rights reserved. ** ** Revision History in reverse order: ** ** The following changes were incorporated in the 02.15.90 release: ** ** 01.10.90 - WCVLIB.ASM created. This file contains the assembly ** language routines for WATCOM 7.0. Previous versions of ** WATCOM should use MSVLIB.ASM. ** ** 01.05.89 - Physical windows wider than 80 columns were not ** working correctly. Thanks to all who reported this ** problem. (wn_actic.c, wn_sup.c, windows.c, wn_init.c). ** The constant "4096" was not removed in wn_savres. It ** does not impact the physical sceen size logic but does ** allow the code of those who have "tinkered" with video ** pages to continue to work. ** ** 12.22.89 - Re-assembled all assembly language routines to insure ** that wni_mxcols, wni_mxrows, and wni_mxneed were being ** used correctly. ** ** 11.30.89 - ZORTECH 2.0 Support. Please note that ZORLIB version ** 2.0 can not create a usable LWIN.LIB. Microsoft's LIB ** works fine and should be used. ZORTECH has been notified ** of the problem. ** ** 11.24.89 - jeesh... One line exploding windows exploded again! ** This time we got the gremlin!! Tnx to Michael Canfield ** for suppling the test case. ** ** (11.15.89) ** ** ** 10.28.89 - Modified wn_title to insure ALL compiliers process ** hex values that are imbedded into the title properly. ** (e.g. "Hello \xcd There!") ** Thanks to Don Wahl for pointing out the discrepancy. ** ** 10.25.89 - It would appear that the PC/PC_CLONE BIOS can not deal ** with scrolling single line windows. wn_insrow() was taught ** to erase single line windows and avoid using the ** BIOS for this special case. This problem does not exist ** on AT or PC/2 class machines. Thanks to Harold Jackson ** for reporting the problem. ** ** 10.24.89 - Eliminated a potential multiple cursor problem with ** the mouse cursor when a window is being saved/restored ** with an active mouse. Tip of the hat to Steve Thatcher ** of Attachmate. ** ** 10.20.89 - Corrected a bug in wn_open to allow 1 line exploding ** windows to function properly. Thanks to John F. La Fleur ** for reporting the problem. ** ** wn_puts was not handling borderless windows properly. ** Thanks to Tim Keane for reporting the problem. ** ** Lattice Version 6.0 Support ** ** 09.27.89 - Logic was added to wn_input to insure that user supplied ** non null editing buffers are the same lenth as their masks! ** This logic will prevent garbage from appearing when ** wn_input is called to peform data entry with a prefilled ** value in the user buffer (ubuff). ** ** 09.05.89 - The forms package now treats the ESCcape ** like most common applications do. That is to say that it ** causes the current operation to cease. Current ** Window BOSS users please note that this feature can ** be disabled by removing the code in wn_frmget that contains ** "ESC.001" as part of the comments. ** ** 09.05.89 - Added 1st character sensitivity to the sample popup menu ** code. ** NOTE ** -> For menu's that have different 1st ** character picks. ** ** (08.25.89) ** ** ** 08.23.89 - Exploding window opens were failing on SOME ** adapters. Even size exploding windows were ** failing. Corrected! ** Thanks to Richard Allen for his assistance. ** ** The following changes were incorporated in the 07.01.89 release: ** ** 06.17.89 - Lattice 3.41!! ... The version release race is on! ** ** 05.29.89 - Mix Power C 1.30 Support. ** ** 05.25.89 - Added wn_gutext and wn_gltext. Get upper case only ** and lower case only text functions. Thanks to ** Charlie Munao for the suggestion. Improved code 6/6/89. ** ** 05.23.89 - wn_frmcls now sets the form pointer to the form being ** closed to NFRM and the individual field pointers to ** NFLD. This should help those who attempt to dectect ** if a form/field is active. ** ** 05.10.89 - wn_close now sets the window pointer to the window ** being closed to WNLPTR. This should help those who ** attempt to detect if a window is open. ** ** - Moved definition of FAR MEMORY marcos from "wn_sup.c" ** and "wn_activ.c" to "windows.h". ** ** 05.06.89 - By popular request... WN_FRMGET now displays both the ** field prompt and data entry mask for all fields prior ** to accepting input for the 1st field. Accomplished by ** introducing "wni_frmflg" which is used/tested by ** all the data entry functions, wn_input, and wn_frmget. ** ** 05.05.89 - Exploding window logic was tweeked to provide smoother ** explosions. ** ** 05.04.89 - Incorporated support for user defined PHYSICAL screen ** size. New globals: wni_mxrows, wni_mxcols, wni_mxneed. ** Globals are defined in "windows.c" and are referenced in ** "windows.h". The globals are max rows, max cols, and max ** memory required to save a *complete* screen image (rows * ** col * 2). A new version of wn_init, wn_psinit has be ** provided to properly set the globals. Refer to the manual ** for a complete discussion. The defaults are 25, 80, and ** 4000. Usefull for applications and/or systems that run ** in 43 line EGA or 50 line VGA mode. Since The BOSS ** assumes the screen size to be fixed, wn_psinit must be ** called before ANY windows are opened. ** ** 04.30.89 - v_kstat now returns TRUE rather than (-1). This conforms ** to the constant in "windows.h". Thanks to Clive Basson ** at Infostat! ** ** - wns_dput (internal routine) was modified to call ** wns_savres for all writes. This will improve ** normal screen output (speed) in most cases. ** ** - wns_drow (internal routine) now calls wns_savres ** for all writes. This will improve normal screen ** output (speed) in most cases. ** ** - wn_title now calls wn_dput to write title for ** faster title writes. ** ** 04.15.89 - wn_gulong corrected to use common "%lu" .vs. "%U" ** ** 04.05.89 - Watcom 7.0 Support. Tip of the hat to the folks at ** the Watcom Compiler factory... Once again, they proved ** that you can release a MAJOR upgrade without breaking ** anybody's hard work (code). ** ** 04.04.89 - Lattice 3.4X support. (LC3) Tip of the hat to ** William Hinkle & Jon Martin (UNISYS) for thier comments, ** suggestions and support. ** ** - Float/Double promotion & demotion caused wn_gfloat ** trouble. Resolved with #if LC3 in wn_gfloat. (LC3) ** ** - windows.h was modified to eliminate warnings ** about undefined control blocks and include ** stdlib.h for proper memory allocation ** prototypes. (LC3) ** ** - Fixed LCP.BAT, APMODEL.BAT, and ADMODE.BAT (LC3) ** ** - Eliminated *true* unreferenced variables. (LC3) ** ** 03.11.89 - Quick C Version 2.0 support. ** ** 03.10.89 - wn_frmopn/cls was tweeked to be a bit smarter about ** memory allocation & deallocation. Tip of the hat ** to Barry Roomberg & Peter Spreadborough. This ** solves the *very* random "NULL POINTER" message ** on exit. ** ** The following changes were incorporated in the 02.01.89 release: ** ** 02.01.89 - Mouse support, get double, get unsigned long, ** get password, left justify string, right justify string ** center string, delete leading and/or trailing blanks. ** Files: wn_mouse.c, wn_string.c, wn_gpword.c ** Files: wn_gdouble.c, wn_gulong.c ** ** 12.26.88 - wn_restore was modified to allow for those who like to ** diddle with a "wn_save"d screen image. This also ** corrected a potential problem with restoring saved ** images. Thanks to Mike Blaszczak for reporting the ** conflict. ** ** 08.01.88 - added #if __TURBOC__ to windows.c ** ** The following changes were incorporated in the 08.15.88 release: ** ** 07.24.88 - wn_puts() was not fixing up color attributes on mono ** systems - corrected. ** ** 07.10.88 - AZTEC "C" support. Thanks to Dexter McCloud for his ** assistance. ** ** - help() has been modified to be compatiable with ** AZTEC. Please take note as format of the ".hlp" file ** has changed. Refer to Intelc.hlp for examples. ** ** 07.03.88 - WATCOM "C" support. ** ** - smartened up wn_frmopn() & wn_frmcls() to avoid ** possible NULL Pointer Assignments. ** ** - cleaned up pointer conversion warnings in wn_activate, ** wn_close, wn_open, wn_restore, wn_save. defined ** WNLPTR in windows.h. ** ** - eliminated various warning messages during compilation, ** Lattice still complains for no valid reason on a few ** modules. ** ** - wns_alloc now use runtime routines allocating memory ** in the large model, dos routines in small code models. ** ** - wns_alloc allocates and immediately frees all available ** memory in the small data memory models before allocating far ** memory. This eliminates memory mgmt clashes for some ** compilers. ** ** - eliminated the need for "peek.c" ** ** 06.29.88 - Corrected wn_activate to always fixup the cursor ** display for the activated window. Thanks to ** John P. Toscano for reporting the problem. ** ** 06.12.88 - Functions in wn_activate & wn_sup that call _vidblt ** and xferdata were taught how to deal with variable ** offsets from wns_alloc. ** ** The following changes were incorporated in the 06.01.88 release: ** ** 06.01.88 - Incoporated data entry routines! ** ** Smartened up wn_puts on border detection. ** ** 05.14.88 - Added: wn_putc (window put character) ** wn_putca (window put character & attribute) ** Both can be found in the WN_PUTS.C file. ** ** 05.10.88 - wn_dmode was now properly sets PAINT & FLASH modes for ** EGA video adapters - Thanks to Mike Gross from ** West Germany ** ** The following changes were incorporated in the 05.06.88 release: ** ** 05.06.88 - Support for MIX Power C added. - Tip of the hat to ** Bob Lewis for his assistance. ** ** 04.27.88 - The declaration of _stklen was removed from BOSSDEMO.C, ** this will keep Turbo C happy. ** ** 03.22.88 - wn_activate ability to detect window overlap and ** handle borderless windows was improved. ** ** 03.22.88 - popup was taught how to handle text on the 0th line. ** ** 03.19.88 - v_spage was loading BH instead of AL. Thanks to ** Ross Schaach (TRAX, Corp.) ** ** 02.10.88 - wn_gets was modified to insure that charcters being ** echoed stay within the window borders. Thanks to ** Dave McCracken for the suggestion. ** ** 01.14.88 - static declarations of filbuf and showpage were removed ** in help.c ** ** The following changes were incorporated in the 11.20.87 release: ** ** 11.13.87 - Microsoft Ver 5.0 & Quick C Support ** ** 09.21.87 - wn_activate was occasionally incorrectly determining ** window overlap. Thanks to the folks at Datalight ** and Marden Marshall for reporting the problem and supplying ** test cases. ** ** 09.17.87 - wn_init() and wn_exit() were modified to work around ** Turbo C's inability to handing allocating far memory ** in the large model. ** ** 09.07.87 - wns_push(), wns_pop(), wn_activate(), wn_move(), ** wns_image(), and wns_blt() were modified to use a table ** of global segments, offsets, and pointers. ** This was done to support the wn_init() and wn_exit() ** functions. ** ** wn_init() and wn_exit() added. wn_init() must be the ** first window fucntion called and it must only be called ** once. It works in conjucntion with wn_exit() to insure ** that the screen image on application entry is restored ** to the "T" on application exit. wn_exit() must be the ** last window function called. One can not be used without ** the other. Both should be used but are neither are ** required. ** ** 09.05.87 - wn_delrow was calling v_locate with args reversed ** causing the wrong section of the screen to be cleared ** on single line borderless windows. Thanks to Paul ** Stephenson of Rockwell International for reporting both ** the problem and the cure. ** ** 09.03.87 - All assembler routines in DLVLIB.ASM now save/restore ** the SI & DI registers. Datalight 3.10 and later ** specific. The -w and -p command line parameters must ** be used when compiling The Window BOSS source code ** under Datalight 3.10 and later. ** ** The following changes were incorporated in the 08.22.87 release: ** ** 08.10.87 - Added wns_dmode() to set the display mode. ** wns_dmode(PAINT) sets the window display mode to paint ** style, wn_dmode(FLASH) sets the display mode to ** flash style. This function eliminates the need to set ** wn_sbit and wns_mtflg to produce the desired effects. ** ** 07.17.87 - wn_puts() & wn_putsa() perform simple range checking to ** insure that the string being displayed is/stays within ** the target window. ** ** 06.22.87 - Let's "C" specific code removed. Support will continue ** for previous versions but Mark William's products will ** not be supported in this or future releases. This ** action is being as the result of compiler limitations. ** ** 06.17.87 - wn_activate now does INSTANT screen updates. Ditto ** for wn_move. wn_mtype() returns 1 for EGA. ** BLAZING screen updates on EGAs. ** ** 06.07.87 - wns_wtext() was incorrectely computing the offset for ** windows with wn_wrap enabled! ** ** The following changes were incorporated in the 06.04.87 release: ** ** 06.03.87 - Support for BORLAND Turbo C!! ** ** The following changes were incorporated in the 05.12.87 release: ** ** 05.12.87 - wns_text was incorrectly compensating for single line ** borderless windows (Attachmate follow up). ** ** 05.04.87 - EXPLODING windows are now supported!! Simply add 800 to ** the video page when calling wn_open()! ** ** - Calls of the form wn_insrow(wn,0) and wn_delrow(wn,0) ** caused the border to be klobbered. wn_insrow() and ** wn_delrow() were taught about borders. ** ** 03.31.87 - wn_printf [wns_wtext()] was incorrectly displaying graphics ** characters. Thanks to Mark MacGee for reporting the problem. ** ** 03.23.87 - Attachmate reported that wn_gets was doing funny things ** on single line bordered windows on PCs and PC clones but ** was fine on ATs and AT clones! It would appear that the ** PC/PC_CLONE BIOS can not deal with scrolling single line ** windows. wn_delrow() was taught to erase single line ** windows and avoid using the BIOS for this special case. ** ** 03.19.87 - Argh!! Datalight elected to use M_I86 as a predefined ** equate. References to M_I86 were changed to ** MSCV3 | MSCV4. (Datalight 3.XX) ** ** The following changes were incorporated in the 03.15.87 release: ** ** 03.01.87 - wn_activate was incorrectly computing the coordinates of ** unbordered windows. Thanks to Peter Fletcher for reporting ** the problem and supplying a solution. ** ** 01.22.87 - wn_dborder() was using the wrong attribute (wn-style, ** instead of wn->bstyle). Thanks to Peter Partch for ** reporting the problem and supplying a solution. ** ** 01.06.87 - wn_activate was not walking through the current linked ** list of windows. In rare cases this would cause two ** windows to be considered non-overlapping when in fact ** they were. Thanks to Robert Klotz for reporting the ** problem. ** ** The following changes were incorporated in the 01.01.87 release: ** ** 12.19.86 - Removed a needless call to wn_err(wn,"wn_printf") in ** wn_title(). ** ** 12.16.86 - Improved centering logic for window titles. ** Thanks to Steve Liberty for suggesting the change. ** ** 12.14.86 - Incorporated compiler specific equates in windows.h. ** ** 12.13.86 - wns_mtype() returns 0 for mode 3, 2 for mode 0 or 2, ** and 7 for mode 7. (Internal Use - This change allowed ** for the prevention of blue on black characters when ** the video mode is 2 and a color monitor is in use. ** (wns_fixc & wns_mtype). ** ** - BASIC support for Mark Williams "Lets C". ** ** - Tightend free() checks in wn_activate, wn_close, and ** wn_restore. ** ** 12.12.86 - wn_puts() was not adding the original physical cursor ** location to the logical cursor location. ** Thanks to Marek Glowacki for reporting the problem. ** ** 12.10.86 - Allow v_locate() to position the cursor slightly off ** the screen. Previous limit was (24,79) current limit ** is (25,80) which is just beyond the edge of the screen. ** This was done to insure that hidden cursors remain out ** of view. ** ** - Improved cursor handling when wn_dmaflg = FALSE. ** ** 12.09.86 - Taught wn_activate to honor cursor position of window ** being activated. This will insure the cursor is always ** in the right logical and physical position. ** More cosmetic enhancement than logic error correction. ** ** The following changes were incorporated in the 12.01.86 release: ** ** 11.28.86 - Reverse video attribute was not being set correctly ** on MGAs - corrected. ** ** 11.19.86 - wn_dborder was incorrectly computing the row offset. ** Thanks to Steve Thatcher for reporting the problem. ** ** 11.16.86 - Added ".smeth" member to window control block. This ** member defines the scrolling method to be used in ** the window. It can be set to BIOS or DMAS, the default ** is DMAS. ** ** - All routines that reference wn_activate will return ** NULL if the window could not be activated. This is ** usually due to a lack of free memory. ** ** The following changes were incorporated in the 11.14.86 release: ** ** 11.13.86 - Closing windows in random order when exiting "sometimes" ** produced null pointer assignment error messages or ** incorrect screen images - corrected. ** ** - wn_natrib() was not storing the newly defined window ** attribute in the window control block - corrected. ** ** 11.09.86 - Support for Datalight C added. ** ** 11.02.86 - v_border() added. Allows color of border area to be ** set on CGAs with color monitors. ** ** 11.01.86 - wn_fixcsr was not adding the original physical cursor ** location to the logical cursor location. ** Thanks to Bill Harts for reporting the problem. ** ** - wn_puts was computing the virtual cursor location ** incorrectly. Thanks to Eric Lundstrom! ** ** - Logic to dectect null strings was incorporated into ** _vidblt. This will prevent 64k worth of trash from ** being blitted to the video ram. ** ** 10.30.86 - All references to MSC in "windows.h" were changed ** to M_I86. This forces "windows.fns" to be included ** under Microsoft C. This change was also applied to ** "windows.c". ** ** 10.26.86 - Full float, long, etc. support for wn_printf in ** all Lattice versions. Microsoft 3.XX is the only ** one in the dark ages. ** ** 10.23.86 - Tip of the hat to Russ Thackson for the improved ** overlaping window detection technique incorporated ** in wn_activate(). ** ** The following changes were incorporated in the 10.22.86 release: ** ** 10.22.86 - wn_activate() was causing unnecessary window ** thrashing on non-overlapping windows. Corrected. ** ** The following changes were incorporated in the 10.10.86 release: ** ** 09.27.86 - Tiled windows are now supported! wn_activate() added. ** ** - wn_gets() was not calling wns_err - corrected. This ** was not a bug, just continued support for wild pointer ** checks. ** ** 09.25.86 - New logic for vidblt(). Fast mode now works on color ** without causing snow or flicker!! Video updates now ** occur at the fastest possible speed! The effect of ** wn_sbit now conforms exactly to the description in the ** manual. ** ** - wn_printf (CI86) now has full float support. Thanks ** to Rob Sullivan for reporting the CI86 problem. Lattice ** and MSC Version 3.0 are the only hold outs for full ** wn_print support. MSC Version 3.0 support will never ** be incorporated. If you are using MSC Version 3.00 ** you will have to upgrade to Version 4.XX. The price ** of the update is well worth it. Version 4.00 is a ** work of art! Lattice support will be delayed until ** Lattice gets around to supporting vsprintf() as ** defined by the evolving ANSI standard. ** ** 09.17.86 - seperate modules to decrease memory overhead. ** ** - link list support (wn_open,wn_close,WINDOWPTR struct) ** This is the ground work for tiled window support. ** ** 09.02.86 - use registers in wns_savres() for speed (MSC). ** ** The following changes were incorporated in the 08.30.86 release: ** ** 08.28.86 - wn_gets was delclared as (char *) but returning ** (void). Corrected to return (char *). ** ** 08.27.86 - wns_wtext() was not correctly handling borderless ** windows. Corrected. ** ** - wn_printf() was not correctly handing cases such as: ** wn_printf(wn,"%s %d %f %d\n", "text", 2, 2.2, 5); ** The window boss now supports a complete implementation ** of printf formatting under Microsoft C Version 4.00. ** All other compilers and versions support an INTEGER only ** wn_printf. This will be corrected in a future release. ** ** 08.16.86 - Added wn_gets(). Get string in window with validation. ** ** The following chages were incorporated in the 06.02.86 release. ** ** 06.02.86 - v_smode was using bh instead of ah. Corrected. ** Thanks to Rob Rainwater!! ** ** 05.26.86 - Added wn_natrib. Set new window attribute NOW! ** ** 05.25.86 - Corrected a potential problem with a couple of the routies ** in MSVLIB.ASM. Registers SI & DI were being used but not ** being saved. This "may" cause spurious probles with "C" ** programs that use register variables. Microsoft C 3.0 only. ** ** - wn_titla was not calling wns_fixc. Corrected. ** ** 05.24.86 - Added wn_titla. write window title with attributes. ** ** 05.10.86 - wn_putsa was not calling wns_fixc. This caused problems ** when CGA was in mode bw80 but putsa was called with a ** valid color atrib. ** ** The following changes were incororated in the 05.08.86 release. ** ** 05.07.86 - Additions for Microsoft "C" version 3.0 ** ** 05.05.86 - wn_printf fix for lattice version 3.0. ** ** 04.25.86 - Added support for handling backspace, delete, & BELL ** characters correctly (wns_wtext). ** ** Incorporated v_wtty in vlib.asm. ** ** Initial Release.. ** ** 01.24.86 - Initial release with a bit of a false start thanks to ** Microsoft's Lib. ** */