; ; NOTE: Due to the length of the filenames of the various support files ; updates provided by the original author will have a filetype ; that consists of 3 digits (0-9) ... these digits represent the ; version (first digit) and the revision (last two digits) numbers ; of the file. It is suggested that others follow this course... ; This file must be RENAMED to BYEMX.MAC ... it is intended that ; this file be assembled with M80 - Simon Ewins ; ; ; ; BYEMX.MAC EMX Remote CP/M System Executive ; ; v2.35 - 09/08/84 added LUX check. jumps to the LUX V4.00 removal ; routine which removes LUX, then chains back to ; BYEMX again. - Mark Howard ; ; v2.34 - 08/21/84 Added code to support the total time on-line on ; each day found in version 3.12 of EMX.MAC. The ; time used at sign-off is stored in the user's ; record and subtracted from time allowed by the ; EMX.MAC pgm at the next signon unless the date ; has changed. also carried v2.33 mod a little ; further by eliminating any check at all for ; whether this was Sysop or not. ; - Simon Ewins ; ; v2.33 - 08/17/84 Deleted the check for user record # 0 since the ; likelihood that the sysop will remain in record ; # 0 with the sort routines for emxmnt v1.33 are ; not very high and the code was somewhat redun- ; dant anyway, with the check of the REENTR byte ; doing the same thing..... ; - Simon Ewins ; ; ; v2.32 - 07/30/84 Updated code to be compatable with v3.00 of ; EMX... basicly just a slight reorganization. ; - Simon Ewins ; ; v2.31 - 07/16/84 Added parameter passing logic for suppressing ; VMSG in EMXBYE. - Mark Howard ; ; v2.30 - 07/02/84 Fixed Invalid Logon message for SYSOP. Also ; eliminated logic for carrier lost and timeout ; error chains from EMXBYE. This caused unreli- ; able system performance. Overtime, Time-out and ; carrier loss now handled only by EMXBYE, so user ; maintenance is not done. ; - Mark Howard ; ; v2.22 - 06/10/84 Added code to allow address of the ASCII logon ; string to be found in header. ; - Mark Howard ; ; v2.21 - 06/13/84 Changed remote check to read REENTR byte. Also ; changed logoff message to print location. ; - Mark Howard ; ; v2.20 - 06/10/84 The original, written in z80 code for assembly ; with M80 and L80, for use with EMXBYE and the ; EMX message system developed by Simon Ewins of ; Toronto, Ont., Canada ; ; Written by: Mark Howard - SYSOP ; CNY Technical RCP/M ; Syracuse, NY (315) 437-4890 ; ;----------------------------------------------------------------------- ; ; This program is used to chain to the EMXBYE remote CP/M program. ; ; 1) The local or remote user types "BYE", loading this program. ; If the REENTR byte is 1, the program assumes the BYE request ; is from remote, and attempts to perform a logoff procedure ; updating several parameters in the user file, then chaining ; to EMXBYE. If the REENTR byte is not 1, the request is ; assumed to be a local one, which causes a direct chain to ; EMXBYE. ; ; NOTE: This file MUST be linked to EMXSUBS.REL.... ; ; DEST EQU 2000H ; Relocated code destination, EMXBYE is ; Loaded beneath this address for execution ; If your BYE is greater than 8k, increase ; .Z80 ASEG ORG 100H ; ; JP START ; Jump around the header and subs VER:: DB 2 ; Version ; VERR:: DB 35 ; Revision ; .XLIST ; INCLUDE EMXHDR.MAC ; Header information (switches, etc.) INCLUDE GETTIM.MAC ; Clock routines ; VERDAT: DB ' as of 09/08/84',0 ; START: ; ; First thing we do is check for LUX V4.xx. If LUX is present, jump ; directly to the removal routine, which will then chain back to BYE via ; a submit process. ; LD HL,(6) ; Get the BDOS address LD DE,3 ; Offset to the possible LUX indicator ADD HL,DE ; HL has address of indicator LD DE,TSTLUX ; LUX test string LD B,6 ; Bytes to test CALL MATCH ; Do they match? CP 0 JR NZ,START1 ; No, continue with program LD HL,(6) ; Yes, LUX is present, remove it. LD DE,12 ; Offset to removal routine ADD HL,DE JP (HL) ; Jump to it ;... ; START1: LD A,0CDH ; Disable ctrl-c's LD (0),A ; LD SP,STACK ; Use our own stack LD A,0C3H ; Patch ERROR in EMXSUBS to prevent chain loop LD (ERROR),A LD HL,BYERROR ; Address of local error handler LD (ERROR+1),HL LD A,(SYSDRV) ; System files are here LD E,A LD C,LOGDRV CALL BDOS ; Log to the drive LD A,(SYSUSR) LD E,A LD C,LOGUSR ; Log to the user area CALL BDOS ; ; Is BYE request from local console (Sysop), or remote? This is done by ; looking at the REENTR byte. ; LD A,(REENTR) ; Get the reentry flag CP 1 ; Is it 1? JP NZ,LOCAL ; If not, it's zero, or garbage, so local ; ; Valid user is on system, and has typed BYE. Signoff the user and per- ; form his maintenance. ; MAINT: LD HL,USERS ; Address the filename CALL OPEN ; Open the file LD HL,USRLEN ; Set the record size LD (RRSZ),HL LD HL,(USREC) ; Reget the user record no. in hl CALL GET ; Get record into buffer CALL CLOSE ; And close the file ; ; Update the fields ; LD HL,(UPLOADS) ; Number. of uploads total LD (UPLDST),HL ; For totals PUSH HL ; Save them EX DE,HL ; De = no. of uploads this session LD HL,(UPLDSF) ; Get last no. of uploads EX DE,HL ; Hl = uplds this session, de = previous CALL SUBHL LD (UPLODS),HL ; Save for logoff POP HL LD (UPLDSF),HL ; Update the random buffer LD HL,(DNLOADS) ; No. of downloads total LD (DNLDST),HL ; For totals PUSH HL ; Save them EX DE,HL ; Put in de LD HL,(DNLDSF) ; Get last downloads EX DE,HL ; HL = this, DE = previous CALL SUBHL LD (DNLODS),HL ; Save for logoff POP HL LD (DNLDSF),HL ; Update the random buffer directly LD A,(TCODE) ; Get the current terminal ID LD (TRMCDEF),A ; Update terminal type LD A,(NULLS) LD (NNULLF),A ; Update no. of nulls LD A,(BSPEED) LD (BDCDEF),A ; Update baud rate byte ; ; Determine the logon, logoff, and elapsed time ; LD HL,LOGSTR ; Get address of logon time LD DE,ONTIM ; Point to where to put it LD BC,8 ; Number of bytes LDIR ; Move them CALL GETTIM ; Get the current time LD HL,TIME ; Point to the time string LD DE,OFFTIM ; Where to put it LD BC,8 LDIR ; Move it CALL CALCTIM ; Calculate the elapsed time LD HL,ELPTIM ; Get binary minutes CALL GETBIN ; Hours (as minutes) in A LD E,A ; By multiplying by 60 LD D,0 LD L,60 LD H,0 CALL MLDL LD A,L PUSH AF ; Save it LD HL,ELPTIM+3 ; Point to minutes CALL GETBIN ; Get minutes (binary in a) POP BC ; Restore hours (as minutes) ADD A,B ; Get total minutes in-line LD B,A ; Hold that thought... LD A,(TOTTMEF) ; Get current time used ADD A,B ; Add this session and resave ... LD (TOTTMEF),A ; Place in user's record ; ; Rewrite the record ; LD HL,WRTLOC ; Tell EMXBYE we're writing to disk LD (HL),1 LD HL,USERS ; Reopen the file CALL OPEN LD HL,USRLEN LD (RRSZ),HL LD HL,(USREC) CALL PUT ; Replace the record CALL CLOSE ; Close the file LD HL,WRTLOC LD (HL),0 ; Reset disk indicator ; ; Now print the session statistics ; CALL PRINT DB CR,LF,'Session Statistics' DB CR,LF DB CR,LF,'User ............. ',0 LD HL,UNAMEF LD B,30 ; Max chars to print CALL PRINTL CALL PRINT DB CR,LF,'Logon ............ ',0 LD HL,ONTIM CALL PRINTM CALL PRINT DB CR,LF,'Logoff ........... ',0 LD HL,OFFTIM CALL PRINTM CALL PRINT DB CR,LF,'Connect time ..... ',0 LD HL,ELPTIM CALL PRINTM CALL PRINT DB CR,LF,'Uploads .......... ',0 LD HL,(UPLODS) CALL PB2ASC CALL PRINT DB CR,LF,'Upload Total ..... ',0 LD HL,(UPLDST) CALL PB2ASC CALL PRINT DB CR,LF,'Downloads ........ ',0 LD HL,(DNLODS) CALL PB2ASC CALL PRINT DB CR,LF,'Download Total ... ',0 LD HL,(DNLDST) CALL PB2ASC CALL PRINT DB CR,LF,LF DB 'Thanks for calling ',0 LD HL,LOCSTR CALL PRINTM LD HL,UNAMEF CALL PRINTS CALL PRINT DB '.',CR,LF,LF,0 JP RELOC ; Go chain to EMXBYE ;..... ; ; This is the local (SYSOP) signon procedure ; LOCAL: LD A,' ' ; Reset the chain flag LD (FCB+1),A CALL PRINT ; Print all the neat stuff DB CR,LF,'EMX Remote CP/M System Executive' DB CR,LF,'Version ',0 LD HL,(VER) ; L=version, h=revision CALL PVER ; Print the version LD HL,VERDAT ; And the date CALL PRINTM CALL PRINT DB CR,LF,'Active on ',0 CALL GETTIM ; Read the current date and time LD HL,DATE CALL PRINTM CALL PRINT DB ' at ',0 LD HL,TIME CALL PRINTM CALL PRINT DB CR,LF,0 ; ; Relocate the .COM file loader to high memory, and jump to it to load ; the BYE program for execution. ; RELOC: LD BC,PEND-EXBYE+1 ; Number of bytes to move LD DE,DEST+PEND-EXBYE ; End of relocated code LD HL,SOURCE+PEND-EXBYE ; End of source code LDDR ; Load it INC DE PUSH DE ; De = first location LD HL,FBYE ; Point to the chain filename LD DE,COMFCB+1 ; Where to put it ; FNLP: LD C,(HL) ; Bytes to put LD B,0 INC HL ; Bump from poi'lg LDIR ; Load it RET ; Ret to the load routine ;..... ; ; ---------------- local subroutines ------------------- ; BYERROR:CALL FERR ; This is error trap from EMXSUBS DB CR,LF,'+ EMXSUBS error, aborting +',7,CR,LF,'$' ; FERR: POP DE LD C,9 CALL BDOS JP 0 ;..... ; ; Calculate the elapsed time - from TIMEDIF.ASM by S. Kluger ; CALCTIM:LD HL,ONTIM+6 ; Point to start time secs CALL GETBIN ; Get binary LD D,A ; Save it LD HL,OFFTIM+6 ; Stop time secs CALL GETBIN LD E,0 ; Reset the borrow flag SUB D ; Subtract JR NC,SKBS ; Skip if no borrow DEC E ; Else make e = ff ADD A,60 ; Make mod 60 ; SKBS:: LD HL,ELPTIM+7 ; Point to elapsed time seconds CALL STORA LD HL,ONTIM+3 CALL GETBIN LD D,A LD HL,OFFTIM+3 CALL GETBIN INC E ; If not borrow JR NZ,SKBM1 ; Then skip INC D ; Else add borrowed value ; SKBM1: LD E,0 SUB D JR NC,SKBM2 ; Skip if no borrow DEC E ADD A,60 ; Make mod 60 ; SKBM2: LD HL,ELPTIM+4 CALL STORA ; Store it LD HL,ONTIM CALL GETBIN LD D,A LD HL,OFFTIM CALL GETBIN INC E JR NZ,SKBH1 INC D ; SKBH1: SUB D JR NC,SKBH2 ADD A,24 ; Add 24 hrs ; SKBH2: LD HL,ELPTIM+1 JR STORA ; GETBIN: LD A,(HL) ; Get tens AND 0FH LD B,A ; Save XOR A LD C,10 ; Set up multiplier ; MUL: ADD A,C DEC B JR NZ,MUL LD B,A ; Save tens INC HL ; Point to units LD A,(HL) AND 0FH ADD A,B ; Add tens RET ; Return value in ac ;..... ; STORA: LD B,-1 ; TLP: INC B SUB 10 JR NC,TLP ADD A,10 OR 30H LD (HL),A DEC HL LD A,30H ADD A,B LD (HL),A RET ;..... ; TSTLUX: DB 'LUX v4' BYESTR: DB 'BYE' UPLODS: DW 0000 UPLDST: DW 0000 DNLODS: DW 0000 DNLDST: DW 0000 ONTIM: DB '00:00:00',0 OFFTIM: DB '00:00:00',0 ELPTIM: DB '00:00:00',0 ; DS 128 ; Stack area ; STACK EQU $ ; ; The following code is relocated to hi memory, and executed ; SOURCE EQU $ ; Boundary memory marker ; OFFSET EQU DEST-SOURCE ; Relocation offset ; ; The following code is moved to "dest" and executed ; EXBYE EQU $+OFFSET LD SP,HISTK ; Use a new stack CALL LODCOM ; Load the .com file CP '*' ; Was it successful? JP NZ,100H ; Execute the .com file ; ABORT EQU $+OFFSET CALL ERRXIT DB CR,LF,'+ Unable to load BYE program +',7,CR,LF,0 ; ; Load the .COM file ; LODCOM EQU $+OFFSET LD HL,COMFCB+12 ; Init the fcb LD B,21 ; No. of bytes to zero ; ZLOOP EQU $+OFFSET ; LD (HL),0 INC HL DJNZ ZLOOP-OFFSET LD DE,COMFCB CALL OPENFIL LD A,'*' ; For error return RET Z ; LD HL,DEST ; Destination of this module LD DE,-80H ; Last address alowable for load ADD HL,DE PUSH HL ; Save on the stack LD DE,80H ; TPA-80h LD BC,0 ; Record counter PUSH BC ; Save counter... PUSH DE ; And current load address ; GLOOP EQU $+OFFSET ; POP DE ; Get tpa address LD HL,80H ; Point to next address to load ADD HL,DE POP BC ; Get record counter POP DE ; Get memory limit, check for overrun PUSH DE ; Resave for next iteration LD A,E SUB L LD A,D ; Only the carry needed SBC A,H JR NC,SIZEOK-OFFSET ; Cy = out of memory CALL ERRXIT ; So print the message DB '+ BYE: not enough TPA +',7,CR,LF,'$' ; SIZEOK EQU $+OFFSET ; INC BC ; Bump the record counter PUSH BC ; And save it PUSH HL ; Save tpa address EX DE,HL ; Untangle registers LD C,SETDMA ; Tell bdos where to put record CALL BDOS LD HL,COMFCB ; Now point to com fcb EX DE,HL LD C,14H CALL BDOS ; And read the record into tpa OR A ; JR Z,GLOOP-OFFSET ; A = 0 if more to read ; POP BC ; Unjunk stack POP BC ; This is our record counter POP HL ; More junk LD A,B ; Check for zero OR C JP Z,ABORT ; We should have read something LD DE,80H ; We did, reset dma to 80h LD C,SETDMA JP BDOS ; And return via bdos ; ERRXIT EQU $+OFFSET ; POP DE ; Get address of message in d LD C,9 ; CALL BDOS ; Print it... JP 0 ; OPENFIL EQU $+OFFSET ; LD C,0FH ; Now open the file CALL BDOS ; INC A ; Should be non-zero RET ; ; COMFCB EQU $+OFFSET ; DB 0 DB ' COM' ; PEND EQU $+OFFSET ; End of relocated code ; ; These areas are not intialized ; DS 21 ; Rest of .COM FCB DS 60 ; HISTK EQU $+OFFSET ; ENDMARK EQU $+OFFSET ; ! ignore error ; END