home *** CD-ROM | disk | FTP | other *** search
- ;
- ; v1.15
- ;
- ; Sends to a disk file any comments as entered by a remote user. Limited
- ; editing. For use with EMX313.MAC
- ;
- ; (c)1984 Simon J. Ewins
- ;
- .Z80
- ASEG
- ORG 100H
- ;
- JP START
- ;
- VER:: DB 1
- VERR:: DB 15
- ;
- INCLUDE EMXHDR.MAC
- INCLUDE GETTIM.MAC
- ;
- DSKFIL::DB 'SYSOP.EMX',0,0,0,0
- ;
- ; Special open file whose name pointed to by HL register
- ;
- SPOPEN::PUSH IY
- PUSH IX
- CALL BFCB ; HL->filename
- LD DE,FCB ; Point to file name
- LD C,15 ; Open function
- CALL BDOS ; Do it
- POP IX
- POP IY
- CP 0FFH ; Errors?
- RET NZ ; Nope....
- ; ; yep, so....... create file
- PUSH IY
- PUSH IX
- LD DE,FCB ; Point to file name
- LD C,22
- CALL BDOS ; Make new file
- POP IX
- POP IY
- CP 0FFH ; Errors?
- JR NZ,INIT ; Nope....
- CALL PRINT
- DB CR,LF,LF
- DB '++ FATAL ERROR IN CREATING NEW FILE ++'
- DB CR,LF,LF,0
- JP EXIT
- ;.....
- ;
- INIT::
- ;
- INIFLG EQU $+1
- ;
- LD A,0 ; In-code modification
- OR A
- RET Z ; If still 0 then not SYSOP.EMX open call
- LD HL,1 ; Set next record to write
- LD (RNDBUF),HL ; Into random buffer
- LD HL,64 ; Size of record(s)
- LD (RRSZ),HL ; Set in place
- LD HL,0 ; This record we're writing
- CALL PUT ; Write it
- CALL CLOSE ; Close file
- LD HL,DSKFIL
- JP SPOPEN ; Go open it again with the record # set
- ;
- ;-----------------------------------------------------------------------
- ;
- START:: LD A,0CDH
- LD (0),A ; Disable ^c
- LD HL,0
- ADD HL,SP
- LD (CCPSTK),HL ; Save ccp stack pointer
- LD SP,STACK ; Set up local stack
- ;
- ; Get the end address of the file and store for buffer use
- ;
- CALL ENDEMX
- LD (MSG),HL
- ;
- ; Set to drive where SYSOP.EMX is located
- ;
- LD A,(SYSDRV)
- LD E,A
- LD C,LOGDRV
- CALL BDOS
- ;
- ; And to user area where SYSOP.EMX is located
- ;
- LD A,(SYSUSR)
- LD E,A
- LD C,LOGUSR
- CALL BDOS
- ;
- ; Patch error:: so it jumps to exit instead of running BYE
- ;
- LD A,0C3H ; Jump
- LD (ERROR),A
- LD HL,EXIT ; To exit
- LD (ERROR+1),HL
- ;
- CALL PRINT
- DB CR,LF,LF
- DB 'SYSOP v',0
- LD HL,(VER) ; H=revision, l=version
- CALL PVER ; Show version number
- CALL PRINT
- DB CR,LF,LF
- DB 'Comments entered here are not readable by anyone else:',0
- ;
- ;-----------------------------------------------------------------------
- ;
- ; Based on routines from EMX.MAC by Simon J. Ewins
- ;
- ; (c)1984 -- All rights reserved.
- ;
- ;-----------------------------------------------------------------------
- ;
- LD HL,LASTCAL ; Get last caller file
- CALL SPOPEN
- LD HL,LSTLEN
- LD (RRSZ),HL ; Set record size
- LD HL,0 ; Record number
- CALL GET ; Get record
- LD HL,RNDBUF
- LD DE,LSTCLR
- LD BC,LSTLEN
- LDIR ; Move this caller's info to memory
- CALL CLOSE
- JP ENTER
- ;
- LINES:: DB 0
- ;
- WARN:: PUSH BC
- PUSH HL
- PUSH DE
- CALL PRINT
- DB CR,LF
- DB '--> 15 lines. Last line next...'
- DB CR,LF,LF,0
- POP DE
- POP HL
- POP BC
- RET
- ;
- ENTER:: CALL PRINT
- DB CR,LF,LF
- DB 'Enter up to 16 lines '
- DB 'with 2 carriage returns to end.',CR,LF
- DB 'The date, time and your name '
- DB 'will be added as a last line.',CR,LF
- DB LF,'Enter text:'
- DB CR,LF,LF,0
- LD IY,(MSG)
- LD B,16
- ;
- ENTLP:: PUSH BC
- LD A,17
- SUB B
- PUSH AF
- CP 10
- JP NC,EPNUM
- CALL PRINT
- DB ' ',0
- ;
- EPNUM:: LD H,0
- POP AF
- LD L,A
- CALL PB2ASC
- CALL PRINT
- DB '> ',0
- LD B,64 ; Input length
- LD C,0 ; No caps forced
- XOR A ; Allow echo
- LD D,1 ; Want word-wrap at 53rd character
- CALL INPUT ; Get line
- CP 0
- JP Z,ENTDON
- PUSH IY
- POP DE
- LD BC,64
- LDIR
- PUSH DE
- POP IY
- CALL PRINT
- DB CR,LF,0
- POP BC
- LD A,17
- SUB B
- LD (LINES),A
- CP 15
- CALL Z,WARN
- ;
- ENTCNT::DJNZ ENTLP
- CALL PRINT
- DB CR,LF
- DB '--> 16 lines entered.',0
- ;
- ENTDON::LD A,(LINES)
- OR A
- JP Z,EXIT ; If nothing entered then abort
- ;
- CALL PRINT
- DB CR,LF
- DB 'Edit, List, Save, Continue, Quit: ',0
- LD B,1
- LD C,20H
- XOR A
- LD D,A
- CALL INPUT
- LD A,(HL)
- CP 'E'
- JP Z,EDIT
- CP 'S'
- JP Z,SAVE
- CP 'L'
- JP Z,LIST
- CP 'C'
- JP Z,CONT
- CP 'Q'
- JP Z,EXIT
- JP ENTDON
- ;
- CONT:: CALL PRINT
- DB CR,LF,LF
- DB 'Continuing at line ',0
- LD A,(LINES)
- INC A
- CP 17
- JP NC,NOCNT
- LD H,0
- LD L,A
- CALL PB2ASC
- CALL PRINT
- DB '.',CR,LF,LF,0
- POP BC ; Reset line count
- INC B
- JP ENTCNT
- ;
- NOCNT:: LD H,0
- LD L,A
- CALL PB2ASC
- CALL PRINT
- DB ' not allowed.... 16 line maximum.',0
- JP ENTDON
- ;
- LIST:: CALL PRINT
- DB CR,LF,LF,0
- LD A,(LINES)
- LD B,A
- LD HL,(MSG)
- ;
- LSTLP:: PUSH BC
- PUSH HL
- PUSH HL
- LD A,(LINES)
- SUB B
- PUSH AF
- CP 9
- JP NC,PNUM
- CALL PRINT
- DB ' ',0
- ;
- PNUM:: LD H,0
- POP AF
- LD L,A
- INC HL ; Make base 1
- CALL PB2ASC
- CALL PRINT
- DB '> ',0
- LD B,64
- POP HL
- CALL PRINTL
- CALL PRINT
- DB CR,LF,0
- LD DE,64
- POP HL
- ADD HL,DE
- POP BC
- DJNZ LSTLP
- JP ENTDON
- ;
- SAVE:: LD A,(LINES) ; Bump # lines by one for 'from' info
- INC A
- LD (LINES),A
- CALL PRINT
- DB CR,LF,LF
- DB 'Wait...',0
- LD A,1
- LD (WRTLOC),A
- LD (INIFLG),A ; Set flag for this routine calling
- LD HL,DSKFIL
- CALL SPOPEN ; Open file for comments
- LD HL,64
- LD (RRSZ),HL ; Set record size
- LD HL,0 ; Get record number
- CALL GET
- LD HL,(RNDBUF) ; Is first 2 bytes of record 0
- PUSH HL ; Save this comment's record number
- LD A,(LINES)
- LD D,0
- LD E,A
- ADD HL,DE ; New number for next comment
- LD (RNDBUF),HL ; Store it
- LD HL,0 ; Record number
- CALL PUT ; And write it
- ;
- ;
- ; And finally, write each 64 byte line to sequential records
- ;
- WRITE:: POP HL ; Get starting record number back
- LD (RRNO),HL
- LD IY,(MSG) ; Point to message
- LD A,(LINES)
- DEC A ; Less one because of 'from' line
- LD B,A ; Set up counter
- ;
- WRTLP:: PUSH BC
- PUSH IY
- POP HL
- LD DE,RNDBUF
- LD BC,64
- LDIR
- PUSH HL
- POP IY
- LD HL,(RRNO)
- CALL PUT
- LD HL,(RRNO)
- INC HL
- LD (RRNO),HL
- POP BC
- DJNZ WRTLP
- XOR A
- LD HL,RNDBUF
- LD (HL),A
- LD DE,RNDBUF+1
- LD BC,63
- LDIR ; Clear random buffer
- LD HL,LSTCLR
- LD DE,RNDBUF
- LD BC,64
- LDIR ; Add line with caller's name
- CALL GETTIM ; Get date and time
- LD HL,TIME
- LD DE,RNDBUF
- LD BC,8
- LDIR ; Move time string into place
- LD HL,DATE
- INC DE
- LD BC,8
- LDIR ; And date
- LD HL,(RRNO)
- CALL PUT ; Write last line
- CALL CLOSE ; All done
- XOR A
- LD (WRTLOC),A
- CALL PRINT
- DB CR,LF,LF
- DB 'Returning to CP/M....'
- DB CR,LF,LF,0
- JP EXIT
- ;.....
- ;
- ; Edit the line asked for by retyping entire line
- ;
- EDIT:: CALL PRINT
- DB CR,LF,LF
- DB 'Edit which line? ',0
- LD B,2
- XOR A
- LD C,A
- LD D,A
- CALL INPUT ; Get input
- CP 0 ; Any?
- JP Z,ENTDON ; No
- LD B,0 ; Preset tens amount
- CP 2 ; Need to calc tens?
- JP NZ,EDIT1 ; No
- LD A,(HL) ; Get digit
- SUB 30H ; Make it a number
- INC HL ; Point to second digit
- LD DE,10 ; Mult digit by 10
- PUSH HL
- LD H,0
- LD L,A
- CALL MLDL ; Mult
- LD A,L
- POP HL
- LD B,A ; Tens amount in 'B'
- ;
- EDIT1:: LD A,(HL) ; Get units digit
- SUB 30H ; Make it a number
- ADD A,B ; Add to tens (if any)
- LD B,A
- LD A,(LINES) ; Okay?
- CP B
- JP C,EDIT ; No, greater than # lines entered
- LD A,B ; Get back number
- CP 17 ; Legal #?
- JP NC,EDIT ; No
- LD HL,64 ; Ok, so get line length
- DEC A ; Adjust line number to base 0
- LD E,A ; For array
- LD D,0
- CALL MLDL ; Offset
- EX DE,HL ; To de
- LD HL,(MSG) ; And add to msg pointer
- AND A ; Clear carry
- ADD HL,DE ; Add 'em
- PUSH HL
- CALL PRINT
- DB CR,LF,LF
- DB 'Line is now:'
- DB CR,LF,0
- LD B,64
- POP HL ; Pointer
- PUSH HL ; Save it
- CALL PRINTL ; Show line
- CALL PRINT
- DB CR,LF
- DB 'Enter new line or <return> to leave the same:'
- DB CR,LF,0
- LD B,64
- XOR A
- LD C,A
- LD D,A
- CALL INPUT
- CP 0
- JP Z,EDIT
- POP DE ; Point to line in array
- LD BC,64
- LDIR ; Move new line in place
- JP ENTDON
- ;
- EXIT:: CALL PRINT
- DB CR,LF,0
- LD A,0C3H
- LD (0),A
- LD HL,(CCPSTK) ; Ready for 'soft' return
- LD SP,HL ; If we are done and going
- RET ; Directly to cp/m
- ;
- ; Stack area
- ;
- DS 128
- ;
- STACK:: DW 0H
- CCPSTK::DW 0H ; Stack storage
- MSG:: DW 0 ; Message storage
- ;
- END