; WSV.AZM ; Gaspari's changes to Wordstar 4.0 10-15-87 ; Assemble with Z80MR. Overlay the hex file with DDT. ; This overlay to WS for the Northstar Advantage provides ; on-screen underline & bold using a new bios routine. ; See end of this file for DOC and WARNING. USORG EQU 0F400H ; start of Northstar Advantage USER.ASM ; (F400 for N* floppy cpm) HCONF EQU USORG+148H ; location of conout status flag in high mem HCONO EQU HCONF+1 ; location of conout routine in high memory ; ************************************************* ; PART I - VIDATT CODE INSIDE WORDSTAR ; ************************************************* ORG 03C1H ; my code for video attributes VIDATT: LD A,C ; get the attr into A OR A ; see if zero JR NZ,VSET ; if non-zero, then skip reset LD HL,USORG+203H ; RESET ROUTINE LD (USORG+10),HL ; this resets CONSOUT in bios LD C,2 ; this resets inverse video LD E,2 ; output a ^B character (02h) CALL 5 RET ; return from VIDATT after reset VSET: AND 01111000B ; see if bits 3,4,5,6 are set JR Z,VMRK ; if not, do the "mark" ; otherwise, do the "repl" VREP: ; replace bios conout RES 2,A ; don't mark (inverse vid) LD (HCONF),A ; save the VIDATT status byte LD HL,VCONO ; get addr of replacement conout LD (USORG+10),HL ; point CONOUT to my new code RET ; return from VIDATT VMRK: ; mark with inverse video LD C,2 LD E,1 ; output ^A (01h) to set inv video CALL 5 RET ; return from VIDATT ; **************************************************** ; PART Ia - REPLACEMENT CONOUT ROUTINE ; **************************************************** ; note that as much as possible is here ; in low memory, only the absolute necessity ; is placed in high mem where room is scarce. VCONO: CALL USORG+203H ; first do the conout we replaced LD A,(HCONF) ; then get the status byte OR A ; if high mem status byte is zero RET Z ; then return LD HL,(USORG+21EH) ; otherwise get addr of current cursor LD B,H LD H,L LD L,B ; invert H and L DEC H ; point back at char we just sent out BIT 5,A ; see if superscript JR Z,VNS ; if not, skip this RES 4,A ; if yes, turn off subsc LD (HCONF),A VNS: LD D,10 ; 10 is a commonly used constant JP HCONO ; & go to high mem to modify it VREF EQU $ ; VIDATT must end before 0441h ; ************************************************************* ; PART II - WORDSTAR INITIAL START-UP DEFAULTS ; ************************************************************* ORG 0446h ; length of long delay (at start-up)? DW 400 ; about one/half second (was 2000) ORG 080Ch ; page number printed? DB 0 ; not at start-up ORG 083Bh ; help level at start-up? DB 2 ; set to 2 ORG 086Ch ; VIDATT attribute for ruler line? DB 2 ; (bit 2 = inverse video) ORG 0857h ; "Insert" on or off at start-up? DB 0 ; OFF ORG 0858h ; Print controls shown at start (^O^D)? DB 0 ; NO ORG 0380h ; code for cursor ON JP 045Bh ; (manual says this is faster) ORG 0383h ; code for cursor OFF JP 0463h ; (after cursor ON patch) ORG 045Bh ; start of MORPAT user patch area LD C,2 ; code for cursor ON LD E,18H ; ^X for cursor ON CALL 5 RET LD C,2 ; code for cursor OFF LD E,19H ; ^Y for cursor OFF CALL 5 RET ; ************************************************************* ; PART III - SET UP THE HIGH MEMORY PORTION OF CONOUT ; ************************************************************* ORG 0100H ; at the start of WS 4.0.... JP LOADCODE ; jmp to end of WS to run code below ORG 2200H ; at end of WS 4.0.... LOADCODE: ; load the bold & underline code LD DE,HCONO ; spot in BIOS to put this code LD HL,NCONO ; point to data we'll put there LD BC,NSIZE ; size of code block to be moved LDIR ; JP 1D00h ; return back to WORDSTAR M10 EQU -10 ; constant = -10 ; **************************************************** ; PART IIIa - CODE THAT MOVES TO HIGH MEMORY ; **************************************************** NCONO: ; this code becomes HCONO after moved LD A,80H ; map video memory onto OUT (0A0H),A ; 0000h to 8000h LD A,81H OUT (0A1H),A LD A,(HCONF) ; get the status flag BIT 6,A ; see if bit 6 is set JR Z,NBOLD ; if zero, jmp to not bold LD C,D ; counter for the 10 bytes per char NXTM: ; ROUTINE TO MAKE BOLD LD A,(HL) ; get first byte of the char into A LD B,A ; put into B also RLA ; shift left the version in A OR B ; combine it with its image in B LD (HL),A ; & put it back in display memory INC HL ; point to next byte DEC C ; & continue JR NZ,NXTM LD BC,M10 ; put -10 into BC ADD HL,BC ; set HL to its orig value NBOLD: LD A,(HCONF) BIT 3,A ; see if bit 3 is set JR Z,NUNDR ; if zero, jmp to not undrline LD B,9 ; ROUTINE TO ADD UNDERLINE NXTU: INC L ; HL points to top of 10 bytes DEC B ; inc L to point to bottom byte JR NZ,NXTU ; point to last byte of char LD (HL),0FFH ; put a line (FF) into video memory LD BC,M10+1 ; Put -9 into BC ADD HL,BC ; reset L to its orig value NUNDR: LD A,(HCONF) BIT 5,A ; see if bit 5 set JR Z,NSUPR ; if not, jmp to not superscript LD C,D ; counter for 10 bytes of display NXTV: ; ROUTINE TO MAKE SUPERSCRIPT LD A,(HL) ; get top byte DEC L ; go up 3 rows DEC L DEC L LD (HL),A ; put data there INC L ; go down 4 rows INC L INC L INC L DEC C JR NZ,NXTV ; and repeat XOR A ; get a zero DEC L ; point to bottom byte LD (HL),A ; put zero there DEC L ; point to 2nd from bottom LD (HL),A ; put zero there DEC L ; point to 3rd from bottom LD (HL),A NSUPR: LD A,(HCONF) BIT 4,A ; see if subscript JR Z,NSUBS ; if not, jmp to not subscript LD C,D ; prepare to point to *bottom* byte VSR: INC L ; of the 10 byte char display DEC C JR NZ,VSR LD C,D ; counter for 10 bytes of display NXTT: ; ROUTINE TO MAKE SUBSCRIPT LD A,(HL) ; get the bottom byte INC L ; go down 2 rows INC L LD (HL),A ; put byte there DEC L ; go up 3 rows DEC L DEC L DEC C JR NZ,NXTT ; continue XOR A ; get a zero INC L ; point to top row LD (HL),A INC L ; point to row 2 LD (HL),A DEC L ; reset HL to top row NSUBS: LD A,1 ; reset to normal memory OUT (0A0H),A ; (remove display memory LD A,2 ; from 0000 to 8000h) OUT (0A1H),A RET ; return from VCONO ; (done with high memory) NSIZE EQU $-NCONO ; the size of code segment to move NREF EQU HCONO+NSIZE ; reference - end of code in BIOS END ; end WSV.AZM 10-15-87 The following documentation will be ignored by the assembler due to the "END" statement above. There are several things to note for this patch. First, since it deals with hardware specific display memory and since it deals with a specific pixel arrangement, this code is unique to the Northstar Advantage. The concepts are, of course, general and may be applied to other cpm computers. The locations in memory are critical!! Because Northstar maps the display memory onto 0000h to 8000h, any in-line program code must be above this area because it becomes invisible immediately after display memory becomes visible. Because of this, a portion of the conout code is placed in the lower bios (USER.ASM) area. That way, after the display memory is mapped in, the operational program code is still available. However, space in high memory is at a premium, and I've already modified USER.ASM extensively in order to get the function key codes up there. Finding room up there is a challenge. One possibility (which was tested and works) is to use the space reserved for the hard disk hooks (F5BA to F600). This works for a floppy system, BUT obviously won't work on a hard disk system. Another possibility is to use the available space in USER.ASM from F515 to F5B9 for the high memory conout code and not use the WSF.AZM function key overlay. Obviously, another method would be to use WSF but define less function keys and then place this conout code before F1BC and after the end of the function key patch. The method used here is to use MORPAT (inside Wordstar) for the function key definitions and then use the addresses from F518 to F5B9 for the HCONO high memory conout code. The disadvantage to this solution is that MORPAT is so useful that it would be nice for it to remain available for other good patch ideas. This version as released is set for a USERORG of F400h which is the standard Northstar Advantage floppy cpm start of USER.ASM. F400h start of USER.ASM (Northstar bios) F517h end of revised USER14.AZM lower bios F518h to F547 is unused at present F548h start of HCONO revised conout code F5B9h end of HCONO revised conout code F5BAh to F5FF is reserved for hard disk hooks F600h upper bios (fixed by Northstar)