TITLE "VIDQ - Vlib 4.1" NAME ('VIDQ') ;================================================================= ; Copyright (C) 1989 by Harold F. Bower. Permission granted to ; Alpha Systems Corp. to distribute with The Libraries, Version 4 ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Date : 21 Mar 89 ; Version : 1.0 ; Module : VIDQ ; Abstract: This module contains the routine CLRPDM which removes ; one or all Pull-Down Menu headings. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC CLRPDM ; ..from VLIB Get.. EXT @MBUFF, @PDMBF ; Constants LINLEN EQU 132 ; Maximum allowable line length IDLEN EQU 6 ; Length of ID Block data .Z80 CSEG ;=============================================================== ; CLRPDM - Clear one or all Pull-Down Menu selections ; Entry: A = Menu Number to Clear (0=Clear All) ; Exit : A <> 0, Zero Flag Clear (NZ) if Successful ; A = 0, Zero Flag Set (Z) if Entry Not Found ; Uses : AF ; Special Requirements: None ;=============================================================== CLRPDM: PUSH HL ; Save regs PUSH DE PUSH BC OR A ; Clear All? JR Z,CLRALL ; ..jump if so DEC A ; Make Menu # 0..9 CP 10 ; Is it a legal Menu Number? JR NC,BAD ; ..jump error if not LD (SELCHR),A ; Save Menu # - 1 ADD A,A ; *2 Calculate offset into table LD C,A ADD A,A ; *4 ADD A,C ; *6 LD C,A LD B,0 ; Set for 16-bit offset LD HL,@MBUFF ; ..point to Menu Buffer ADD HL,BC ; Index into pointer array LD A,(HL) ; Get pointer value INC HL OR (HL) ; Does an entry exist? DEC HL JR Z,OKEXIT ; ..jump w/good status if already gone PUSH HL ; ..save ID Block Ptr for later ; Get length of Menu Bar section to delete. ; Exit with 16-bit value in BC. Correct ptr at @PDMBF+0 INC HL ; Advance to Item Name length INC HL LD A,(HL) ; ..and get it DEC HL ; Back down to start DEC HL ADD A,4 ; Add the four trailing spaces LD C,A ; Set for exit conditions LD B,0 LD A,(@PDMBF) ; Get current ptr byte SUB C ; ..and subtract amount to delete LD (@PDMBF),A LD A,(SELCHR) ; Get Selection # LD E,(HL) ; Load Destination of Bar Move INC HL LD D,(HL) DEC HL PUSH DE ; Save and destination addr ; Compensate Menu Bar pointer for deletion width ; Enter with HL --> Menu ID Block, A = Menu #-1, BC = Deletion length FIXUP: CP 9 ; Are we at the end? JR NC,FIXDON ; ..exit if so LD DE,IDLEN ; Advance to next entry ADD HL,DE LD E,(HL) ; Get menu bar pointer INC HL LD D,(HL) PUSH BC ; Shuffle regs and check validity LD B,A LD A,D OR E ; Anything used? LD A,B POP BC JR Z,FIXDON ; ..exit if not EX DE,HL ; Put in right regs OR A SBC HL,BC ; Subtract deleted length EX DE,HL LD (HL),D ; ..and store new value DEC HL LD (HL),E INC A ; ..and advance Menu # JR FIXUP ; Loop FIXDON: POP HL ; Restore dest addr to HL LD DE,@PDMBF ; Point to first char in Bar INC DE ;== PUSH HL OR A ; Subtract SBC HL,DE LD A,LINLEN SUB L ; A Now has length from present to end POP HL ; Restore dest addr LD E,L LD D,H ; ..copy to DE ADD HL,BC ; Add to len for Source addr SUB C ; Subtract delete len from remaining LD C,A LDIR ; ..and crunch the Menu bar EX DE,HL LD (HL),0 ; Null-terminate Menu Bar text POP HL ; Restore ID Block # Addr LD A,(SELCHR) ; Get selection back (0..9) CP 9 ; Is it the last? JR C,CLRMID ; ..jump if not CLRIT: LD B,IDLEN CLRIT0: LD (HL),0 ; Fill w/Nulls INC HL DJNZ CLRIT0 ; ..loop til done OKEXIT: DEFB 0F6H ; Set OK Status with "OR 0AFH" w/next BAD: XOR A ; Set Bad status if enter here POP BC ; Restore regs POP DE POP HL RET CLRALL: LD HL,@PDMBF ; Start clearing here LD B,LINLEN+1+60 ; ..for Entire Line+EOL+Item Table Len JR CLRIT0 ; ...clear and exit CLRMID: EX DE,HL ; Put Block Addr in DE LD HL,IDLEN ADD HL,DE ; Source Addr now in HL CLRMLP: LD BC,IDLEN LDIR ; Move 5 bytes INC A ; Set pointer to next CP 9 ; Pointing to last one? JR C,CLRMLP ; ..loop if not EX DE,HL ; Put last Block Addr in HL JR CLRIT ; Else clear last and exit DSEG SELCHR: DEFS 1 ; Menu Selection - 1 END