home *** CD-ROM | disk | FTP | other *** search
- ;****************************************************
- ;* ENTER2.ASM *
- ;* A program to store 127 character text lines *
- ;* in a sequential file. Text is entered using *
- ;* standard editing keys, entry terminated by a *
- ;* CR. CR with no text entry ends program. *
- ;* *
- ;* Modified from ENTER.ASM written by David *
- ;* Brown which was based on a program from *
- ;* THE SOLE OF CP/M. Modified so it would work *
- ;* as intended by Noel Nyman. Released to the *
- ;* public domain as part of FREBASE2. *
- ;****************************************************
- ;
- ; TERMINAL SPECIFIC COMMANDS FOR ADM31 (Commodore C-128)
- ;
- openf equ 15 ;open file
- makef equ 22 ;make file
- reads equ 10 ;read console buffer
- writer equ 21 ;write sequential record
- readr equ 20 ;read sequential record
- prints equ 9 ;print string
- closef equ 16 ;close file
- conout equ 02 ;console out
- bdos equ 05 ;operating system entry
- fcb equ 5ch ;file control block
- dma equ 80h ;dma buffer
- ;
- space equ 32 ;space character
- lf equ 10 ;line feed
- cr equ 13 ;carriage return
- null equ 00
- ;
- ;screen format codes
- ;
- esc equ 27 ;escape
- eqls equ 61 ;ascii for '='
- base equ 32 ;base for all row/col references
- rvs equ 71 ;reverse code
- on equ 52 ;ascii '4' turns reverse on
- off equ 48 ;ascii '0' turns reverse off
- clrsc equ 42 ;ascii '*' clears screen
- ;
- org 100h ;start of TPA
- ;
- ;open file named in fcb
- ;
- mvi c,openf ;open file
- lxi d,fcb
- call bdos
- inr a ;change 255 to zero
- jnz start ;file exists
- ;
- ;file does not exist, try to create it
- ;
- mvi c,makef
- lxi d,fcb
- call bdos
- inr a ;change 255 to zero
- jnz start ;file created
- ;
- ;if we get here, disk directory is full
- ;
- mvi c,prints
- lxi d,dirfull ;print 'directory full' message
- call bdos
- ret ;exit to CP/M
-
- ;display main screen
- ;
- start:
- mvi c,prints
- lxi d,mainscr
- call bdos
- ;
- ;read to end of file
- ;
- readend:
- mvi c,readr ;read record
- lxi d,fcb
- call bdos
- ora a ;end of file?
- jz readend ;no, read another record
- ;
- ;print text boundary prompt
- ;
- mvi c,prints
- lxi d,prompt
- call bdos
- ;
- ;initialize buffer, fill with spaces, add '0' end-of-record marker
- ;
- lxi h,dma ;dma address in hl
- mvi b,127 ;buffer size
- loop:
- mvi m,space ;store space character in dma
- inx h ;127 times
- dcr b
- jnz loop
- mvi m,null ;add '0' at end
- ;
- ;read characters into buffer from keyboard
- ;
- mvi a,127 ;dma buffer size
- sta dma-2 ;max count
- mvi c,reads ;read keyboard
- lxi d,dma-2
- call bdos
- ;
- ;fall through to here after carriage return
- ;
- lda dma-1 ;number of characters in buffer
- ora a ;no characters?
- jz exit ;yes, exit program
- ;
- ;write record to disk
- ;
- mvi c,writer
- lxi d,fcb
- call bdos
- ;
- ;close file
- ;
- mvi c,closef
- lxi d,fcb
- call bdos
- jmp readend ;get another entry
- ;
- ;end program
- ;
- exit:
- mvi c,prints
- lxi d,clear ;clear screen
- call bdos
- mvi c,closef ;close file
- lxi d,fcb
- call bdos
- ret ;back to CP/M
- ;
- dirfull:
- db 'Directory Full'
- db cr,lf,'$'
- ;
- ;main screen
- ;
- mainscr:
- db esc,clrsc ;clear screen
- db esc,eqls,base,base+23 ;row 0, col 22
- db esc,rvs,on ;reverse on
- db ' F r e e B a s e III '
- db esc,rvs,off ;reverse off
- db esc,eqls,base+2,base+24 ;row 2, col 23
- db ' DATA ENTRY PROGRAM'
- db cr,lf,cr,lf
-
- db 'Type whatever you like, 127 characters maximum'
- db cr,lf,cr,lf,cr,lf,cr,lf
- db cr,lf,cr,lf,cr,lf,cr,lf
- db ' =============================='
- db '==============='
- db cr,lf,cr,lf
- db ' Press RETURN After Record is Entered'
- db cr,lf
- db ' Press RETURN Alone to EXIT'
- db cr,lf,cr,lf
- db ' To Search for Information, Enter: '
- db cr,lf
- db ' A>SEARCH [D:] filename.type information'
- db cr,lf
- db ' ============================='
- db '===================='
- db '$'
- ;
- prompt:
- db esc,eqls,base+7,base ;row 7, col 0
- db '[-----------------------------'
-
- db '------------------------------------------------- '
- db '-------------------------------------------------]'
- db cr,lf
- db ' End 2nd Line Here ^'
- db esc,eqls,base+6,base+1 ;row 6, col 1
- db cr,lf,'[$'
- ;
- clear:
- db esc,clrsc,'$' ;clear screen
- ;