; ; v1.1 by Simon Ewins 07/21/84 ; ; Updated for EMX v3.00 07/30/84 ; ; This is the EMX GETTIM module for those that do not have a hardware ; clock on their system..... ; ; This code will probably need a bit of tweaking by each user as it is ; for the most part untested. ; ; Wherever it is important that a label be exactly as it is here a com- ; ment to that effect will be included. ; ; ALL labels MUST be followed by 2 colons so that l80 can find them. ; ; This file will read the INDEX.EMX file each time a new caller arrives, ; as well as at various times throughout the program. If the caller has ; not signed on yet then the date is read from the INDEX file and stored ; in BYE (or other safe (high?) memory and used when re-entering EMX or ; when using Sysop or other EMX utilities. ; ; For this routine to work you MUST supply the base address of a 9 byte ; storage area for the ASCII date string. The string will be in the ; form of mm/dd/yy followed by a null. ; ; To set the date into the system each day, I would suggest that the ; small BASIC routine in EMX-xxx.DOC be used. This BASIC program reads ; the current date from the INDEX.EMX file and stores a new one entered ; by the Sysop. This GETTIM routine then uses that as the current date ; for system updating and adding to messages left on the system. ; ; The time-string returned is xx:xx:xx followed by a null..... ; ; Obviously the date will have to be changed in the above mentioned man- ; ner every day at midnight in order to keep all in order! ; ;----------------------------------------------------------------------- ; LOCDTE EQU 0FFFFH-9 ; You MUST supply the address here that ; is the base of a 9 byte string in ; 'safe' memory somewhere. ; ;----------------------------------------------------------------------- ; .Z80 ; MUST be here ; TIME:: DB 'xx:xx:xx',0 ; MUST be here DATE:: DB 'mm/dd/yy',0 ; MUST be here BDATE:: DB 0,0,0 ; MUST be here BTIME:: DB 0,0,0 ; MUST be here ; GETTIM:: ; MUST be here ; LD A,(REENTR) ; Get the address of the byte that flags ; whether a caller has signed on yet ; get the value of the byte at that ; address CP 1 ; If 1 then caller is already logged in ; and is re-entering the EMX message ; system since GETTIM is called right ; after setting the local stack and ; before any file activity. The re- ; sult of this test will determine if ; we have the date stored already or ; not. JP Z,GTNORD ; Already read date so don't do it again ; ; We get the date by reading the first three bytes of the INDEX.EMX file ; and then converting them to an 8 byte ASCII date string..... ; LD HL,INDEX ; Point to the name of the index file CALL OPEN ; Open the file LD HL,NDXLEN ; Length of the record LD (RRSZ),HL ; Place it in random file param block LD HL,0 ; We want record # 0 CALL GET ; Get record # 0 CALL CLOSE ; Close the file LD IX,RNDBUF ; The start of the date field in the ; Random file buffer LD IY,DATE ; Point to local buffer ; ; Convert the binary date to a string.... ; LD A,(IX) ; Get month CP 10 ; Always less than 20! JR NC,S1 ; If > 9 then set 1 into tens postion ; S0:: ADD A,30H ; Make month ASCII PUSH AF ; Save it LD A,'0' ; Stuff a '0' into tens position LD (IY),A ; First position POP AF ; Get back units LD (IY+1),A ; Store it JR DAY ; Do the day of the month next ; S1:: PUSH AF ; Save month LD A,'1' ; Get a '1' LD (IY),A ; Store it POP AF ; Get back month SUB 10 ; Strip tens ADD A,'0' ; Make it ascii LD (IY+1),A ; Store it ; DAY:: LD A,(IX+1) ; Get day CP 10 ; Less than 10? JR C,S0D ; Yes CP 20 ; Less than 20? JR C,S1D ; Yes CP 30 ; Less than 30? JR C,S2D ; Yes PUSH AF ; Must be 3x so save LD A,'3' ; Get a '3' LD (IY+3),A ; Store in days tens space POP AF ; Get units back SUB 30 ; Strip tens ADD A,'0' ; Make ASCII LD (IY+4),A ; Store it JR YEAR ; Go do year ; S2D:: PUSH AF ; Save day LD A,'2' ; Get a '2' LD (IY+3),A ; Store in tens space POP AF ; Get units (+20) back SUB 20 ; Strip tens ADD A,'0' ; Make ascii LD (IY+4),A ; Store it JR YEAR ; Go do year ; S1D:: PUSH AF ; Save day LD A,'1' ; Get a '1' LD (IY+3),A ; Store tens POP AF ; Get day (+10) back SUB 10 ; Strip tens ADD A,'0' ; Make it ascii LD (IY+4),A ; Store it JR YEAR ; S0D:: PUSH AF ; Save day LD A,'0' ; Store '0' in tens LD (IY+3),A ; Store it POP AF ; Get day back ADD A,'0' ; Make it ascii LD (IY+4),A ; Store units ; YEAR:: LD A,'8' ; Change to a 9 in 1990 (!) LD (IY+6),A ; Store in tens position LD A,(IX+2) ; Get year SUB 80 ; Strip tens ADD A,'0' ; Make ascii LD (IY+7),A ; Store units ; ; Now just move it to safe memory area.... ; LD HL,DATE LD DE,LOCDTE LD BC,9 ; Move all bytes LDIR ; ; Now we exit! ; JR GTOUT ; ; When a user re-enters EMX or runs SYSOP or BYEMX etc. we only need to ; get the date stored in 'safe' memory when the caller first logged in. ; GTNORD::LD HL,LOCDTE ; Point to string saved at sign-on LD DE,DATE ; And the E-MX area for it LD BC,9 ; Might as well move the null too LDIR ; GTOUT:: RET ; Finished with routine ; Time is now a dummy string ; And date is set into place ; ; end