home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
ftp.demon.co.uk-pub-cpm
/
amstrad
/
setfontz.arc
/
ALTER12B.Z80
< prev
next >
Wrap
Text File
|
1994-03-21
|
44KB
|
2,285 lines
;ALTER v1.02. Module contains Exit program, load font, save font and edit character
;commands.
;
;----
EXIT:
;----
;
CALL HIVOFF ;Exit program menu.
CALL VERPROMPT ;Redraw all options in true video etc. etc. etc.
CALL HIVON
CALL CHEKPL3
CALL Z,PL3EXP
CALL CHEKPCW
CALL Z,PCWEXP ;Print "EXIT" or "BREAK" or "ESC" in inverse video.
CALL CHEKCPC
CALL Z,CPCEXP
LD D,2
CALL PRINAT
LD DE,CCB
CALL OPCCB
EXIT1: LD HL,XMENU ;Are you sure N/Y?
CALL MENU ;(So you have to move the bar to confirm).
LD A,B
OR A
LD A,C
JR NZ,EXIT1
CALL CLRMENU
CP 1
JP Z,MAINMEN ;If abandoned, go back to main menu.
LD DE,SCRUNI ;De-initialise screen.
CALL PRINT
CALL CURON
LD DE,SIGNOFF ;Sign off.
CALL PRINT
LD SP,(STAKSTO) ;Retrieve SP.
JP WBOOT ;Warm boot.
;
PL3EXP: LD HL,OX3
LD (CCB),HL
LD HL,18
LD (CCB+2),HL ;Calculate address & position of message for +3.
LD A,OX3-OE3+2 ;Message reads "BREAK=Leave"
LD (XMENU+1),A
LD E,OX3-OE3
RET
;
PCWEXP: LD HL,OX1
LD (CCB),HL
LD HL,18
LD (CCB+2),HL ;Message reads "EXIT=Leave"
LD A,OX1-OE1+2
LD (XMENU+1),A
LD E,OX1-OE1
RET
;
CPCEXP: LD HL,OX0
LD (CCB),HL
LD HL,18
LD (CCB+2),HL ;Message reads "ESC=Leave"
LD A,OX0-OE0+2
LD (XMENU+1),A
LD E,OX0-OE0
RET
;
DSEG
XMENU: DEFB 3,0,13,2
DEFB 'Are you sure?'
DEFB 'No N',0,0
DEFB 'Yes Y',0,0
LMENU: DEFB 3,0,15,2
DEFB 'Loading options'
DEFB 'Abandon loadingA',0,0
DEFB 'Entire font E',0,0
DEFB 'Between markersB',0,0
CATMENU:
DEFB 3,0,15,2
DEFB 'Catalogue disc?'
DEFB 'Yes Y',0,0
DEFB 'No N',0,0
LOADING:
DEFB 'Loading.$'
LL1: DEFB 'Loading new character set file: '
DEFB ' $'
LL2: DEFB 'Press EXIT or STOP to cancel loading '
DEFB ' $'
LL3: DEFB 'Press BREAK or ^C to cancel loading '
DEFB ' $'
LL4: DEFB 'Press ESC or ^C to cancel loading '
DEFB ' $'
CCB: DEFW 0,0
QFCB: DEFB 0,'???????????'
DEFS 23 ;*.*
CSEG
;
;---
LOAD:
;---
;
CALL HIVOFF
CALL GETDISK ;Save current drive while disks are reset.
LD (CURDISK),A
LD C,0DH
CALL FDOS
LD A,(CURDISK) ;Restore current drive
LD E,A
CALL SETDISK
CALL RFONT ;Read font into main memory.
LD DE,8000H
LD HL,0C000H ;Move font to loading buffer, so that if
LD BC,1000H ; file doesn't cover all of it, the rest
LDIR ;isn't corrupted.
CALL VERPROMPT
CALL HIVON
CALL GENLP ;Part of printing the information lines
LD D,2
CALL PRINAT
LD DE,CCB ;Print information lines
CALL OPCCB
LD A,(FFLG) ;If there are markers, add an extra
OR A ;option to the "Are you sure?" menu -
LD A,2 ;"Load between Markers".
JR Z,LOADX1
LD A,3
LOADX1: LD (LMENU+3),A
LD HL,LMENU
CALL MENU
CALL CUROFF
LD A,B ;If abandoned, quit.
OR A
JR Z,LOK1
LQUIT: LD A,' ' ;Abandon loading - set file to "No file."
LD (FCB+1),A
CALL CLRMENU ;Clear current menu.
JP MAINMEN ;Leave.
;
LOK1: LD A,C
CALL CLRMENU
CP 1
JP Z,MAINMEN ;Option 1 - "Abandon" - treat similarly.
DEC A
DEC A
LD (LOADOPT),A ;1 for "between markers" else 0.
;
; CONFIRMED: LOAD WAS SELECTED.
;
LOAD2: CALL LOADPROMPT ;Draw information lines
LD DE,DMA
CALL SETDMA ;Set DMA to 0080H.
LD DE,QFCB
LD C,11H ;Find *.*
CALL FDOS
INC A
JP Z,NOFILES ;"No files found" actions
LD HL,CATMENU
LD A,1 ;Catalogue Y/N?
CALL MENU
LD A,B
OR A ;Aborted?
JP NZ,LQUIT
CALL CLRMENU
DEC C
LD A,1
JP NZ,NOCAT ;No catalogue requested.
CALL PW1 ;Please wait.
CALL HIVOFF
LD DE,0300H ;Print in main window.
CALL PRINAT
LD DE,QFCB ;*.*
LD C,11H
CALL FDOS ;find *.*
LD C,A
XOR A ;C=coded address of filename.
DIRLOOP:
INC A ;A=no. of files printed.
PUSH AF
LD A,C
ADD A,A ;*2
ADD A,A ;*4
ADD A,A ;*8
ADD A,A ;*16
ADD A,A ;*32
LD HL,DMA ;+DMA
PUSH DE
LD E,A
LD D,0
ADD HL,DE
POP DE
CALL OPFCB3 ;Print filename at HL.
POP AF
CP 50 ;If 50 filenames printed, wait for a keypress
CALL Z,PAGE ;and then continue.
LD B,4 ;4 spaces between files.
LD E,' '
CALL STRING$
LD DE,QFCB
LD C,12H ;Find next file
CALL FDOS
LD C,A
INC A ;No next file?
JR NZ,DIRLOOP
CALL ANYKEY ;Press any key.
CALL DIRCLEAR
LD HL,LMENU ;Menu to clear if STOP/EXIT pressed
CP 3 ;Was the key from ANYKEY STOP or EXIT?
JP Z,LQUIT
CP 1BH
JP Z,LQUIT
LD A,1
;
NOCAT: CALL PW0 ;Take away "Please wait"
LD HL,ASKFMENU ;Ask: Load a file or catalogue a different drive
CALL MENU
DEC B
JP Z,LQUIT ;1,2 or 3. Abandoned.
DEC B
JP Z,LQUIT
DEC B
JP Z,LQUIT
DEC B ;Return code B=4. Input was made, DE points to it.
JR Z,PARSEF
CP 1
JR Z,NOCAT
CALL CLRMENU
LD A,1
LD HL,DIFMENU
JP NOF0 ;Catalogue different drive.
;
PARSEF: POP AF
;DE POINTS TO FILENAME BUFFER
INC DE
LD A,(DE) ;A=length of filename
LD C,A
LD B,0 ;BC=length
INC DE
PUSH DE
PUSH DE
POP HL
ADD HL,BC ;HL POINTS TO END OF FILENAME.
LD (HL),' ' ;End-of-filename marker.
POP HL
LD (CCB),HL ;CCB is also used as PFCB for "parse filename".
LD HL,FCB
LD (CCB+2),HL
LD DE,CCB
LD C,152 ;PARSE THE FILENAME
CALL FDOS
INC HL
LD A,H ;If HL=0FFFFh, bad filename.
OR L
CALL Z,BLEEP ;BAD FILENAME
JP Z,NOCAT
LD HL,ASKFMENU ;Clear the menu.
CALL CLRMENU
;
;FILENAME ENTERED.
;
SCANF: LD DE,0126H ;Print the new FCB in the information lines.
CALL PRINAT
CALL HIVON
CALL OPFCB0
LD C,11H ;Search for it.
CALL FCBDOS
INC A
JP NZ,LOAD3 ;If found, continue
LD HL,SCANFAIL
CALL MENU ;An "alert" menu. File not found.
JP LQUIT
;
LOAD3: CALL PW1 ;Please wait.
LD HL,08000H ;Load at 8000H.
LD (LOADADD),HL
LD D,10H ;16 records
CALL CHEKPL3
JR NZ,LOAD3A ;or on the +3, 32 records.
LD D,20H
LOAD3A: LD A,D
LD (NUMRECS),A
LD C,0FH ;OPEN FILE TO READ.
CALL FCBDOS
INC A
JP NZ,LOAD4
LD HL,CANTOPEN ;Can't open it (possibly password protected)
CALL MENU ;Alert menu.
JP LQUIT
;
LOAD4: LD DE,(LOADADD) ;Set DMA to current load address.
CALL SETDMA
LD HL,80H ;Increment load address.
ADD HL,DE
LD (LOADADD),HL
;
CALL CON6 ;WAS THERE A KEYPRESS?
CP 3 ;^C?
JP Z,CANLOAD
CP 1BH ;Exit?
JP Z,CANLOAD
;
LD C,14H ;READ SEQUENTIAL.
CALL FCBDOS
OR A
JP NZ,LOADERR ;If an error found, file is too short.
LD A,(NUMRECS)
DEC A
LD (NUMRECS),A ;Count down until all records loaded.
JR NZ,LOAD4
;
; Font loaded successfully
;
LOAD5: LD C,10H ;CLOSE FILE
CALL FCBDOS
LD A,(LOADOPT) ;Load between markers, or all chars?
OR A
JR Z,LOAD5A ;All chars.
LD A,(FBEGIN)
LD L,A
LD H,0
ADD HL,HL ;*2
ADD HL,HL ;*4
ADD HL,HL ;*8
CALL ASHL
PUSH HL ;HL=START OFFSET
PUSH HL
LD C,A
LD A,(FEND)
SUB C
INC A ;NO. OF CHARS
LD L,A
LD H,0
ADD HL,HL
ADD HL,HL
ADD HL,HL ;HL=Number of bytes.
LD C,L
LD B,H
POP DE
LD HL,0C000H ;Calculate destination address.
ADD HL,DE
POP DE
PUSH HL ;STACKED=DEST ADDR.
LD HL,08000H
ADD HL,DE ;HL=SOURCE
POP DE
JR LOAD5B ;HL,DE,BC for LDIR
;
LOAD5A: LD HL,08000H
LD DE,0C000H ;Standard HL,DE,BC for entire font.
LD BC,1000H
LOAD5B: LDIR
CALL WFONT ;Write font to memory.
CALL PW0
CALL ANYKEY ;Press a key.
CALL PRFONT ;Print font.
JP MAINMEN ;Main menu.
;
CANLOAD:
LD A,' '
LD (FCB+1),A ;Loading cancelled. Set to "No file."
JP MAINMEN
;
LOADERR:
CP 1
JP Z,LOADEOF ;Error in loading. Read past EOF?
LD HL,LEMENU
CALL MENU ;No. Serious error.
JP LQUIT1
;
LOADEOF:
LD HL,LFMENU ;Read past EOF. Not a fatal error; the user
CALL MENU ;can ignore this and load only what there is.
CALL CLRMENU
LD A,B
OR A
JP NZ,LQUIT1
LD A,C
CP 2
JP Z,LQUIT1
LD HL,LFMENU
CALL CLRMENU
JP LOAD5
;
LQUIT1: LD C,10H ;Close file and quit.
CALL FCBDOS
LD HL,LFMENU
JP LQUIT
;
GENLP: LD HL,OL3
LD (CCB),HL
LD HL,11
LD (CCB+2),HL ;Calculate positions of messages.
LD A,OL3-OE3-2
LD (LMENU+1),A
DEC A
LD (CATMENU+1),A
LD E,OL3-OE3
RET
;
LOADPROMPT:
LD DE,45 ;PRINT "LOADING" ON TOP LINE
CALL PRINAT
CALL HIVON
LD DE,LOADING
CALL PRINT
LD DE,0100H ;Print "Loading file:"
CALL PRINAT
LD DE,LL1
CALL PRINT
LD DE,0200H ;Print "Press EXIT or STOP to cancel" (version dependent)
CALL PRINAT
LD DE,LL2
CALL CHEKPCW
JP Z,PRINT
LD DE,LL3
CALL CHEKPL3
JP Z,PRINT
LD DE,LL4
JP PRINT
;
PAGE: CALL PW0 ;Wait for a key, then clear directory window.
CALL ANYKEY
CALL DIRCLEAR
CALL PW1
CALL HIVOFF
LD DE,0300H
CALL PRINAT
XOR A ;No files printed this page.
RET
;
NOFILES:
LD HL,NOFMENU ;No files found.
NOF0: LD (HLSTORE),HL
NOF0A: LD HL,(HLSTORE)
CALL MENU
DEC B
JP Z,LQUIT
DEC B
JP Z,LQUIT
DEC B ;CANCEL, EXIT or STOP.
JP Z,LQUIT
DEC B ;Input made.
JP Z,NOF1 ;In this menu, input must be made for options 1 & 2.
CP 3 ;Option 3 allows no input; it's "Abandon loading".
CALL NZ,BLEEP
JP NZ,NOF0A
PUSH AF
JP LQUIT
;
NOF1: POP AF
CP 1 ;DIFFERENT DISC.
JP NZ,NOF2
INC DE
LD A,(DE) ;A=length of input.
OR A
CALL Z,BLEEP ;If zero, bleep & ask again.
JP Z,NOF0A
INC DE
LD A,(DE) ;Get drive letter.
CALL UPCASEA
CP 'A' ;Drives A..P acceptable.
CALL C,BLEEP
JP C,NOF0A ;Ask again.
CP 'Q'
CALL NC,BLEEP
JP NC,NOF0A
CALL CLRMENU ;Clear the menu - drive letter acceptable.
SUB 'A'
LD E,A
CALL SETDISK
LD (CURDISK),A ;Set disk & store as current disk number.
JP LOAD2
;
NOF2: INC DE ;CHANGE USER NUMBER
CALL PARSEUSER
LD E,A
LD A,2
;
; USER NUMBER NOW IN E.
;
CALL C,BLEEP ;NOT A NUMBER
JP C,NOF0A
LD C,20H
LD D,0 ;Set user number.
CALL FDOS
LD HL,NOFMENU ;Clear menu and search this area.
CALL CLRMENU
JP LOAD2
;
DSEG
NOFMENU:
DEFB 3,0,12H,3
DEFB ' No files found '
DEFB 'Different Drive:_ D',81H,10H
DEFB 'Different User:__ U',82H,0FH
DEFB 'Abandon loading A',0,0
;
;The 81H means input allowed, 1 character max.
;The 10H is the left offset of the input.
;
DIFMENU:
DEFB 3,0,15,2
DEFB 'Select another '
DEFB 'Drive:_ D',81H,06H
DEFB 'User number:__ U',82H,0CH
ASKFMENU:
DEFB 3,25,30,2
DEFB ' Load options '
DEFB 'Enter Filename:______________ E',8EH,0FH
DEFB 'Catalogue a different drive C',0,0
SCANFAIL:
DEFB 6,32,16,1
DEFB ' File not found '
DEFB 'Cancel operationC',0,0
CANTOPEN:
DEFB 6,32,16,1
DEFB 'Cannot open file'
DEFB 'Cancel operationC',0,0
LEMENU:
DEFB 6,32,16,1
DEFB ' Read error '
DEFB 'Cancel operationC',0,0
LFMENU:
DEFB 5,28,35,2
DEFB ' Unexpected End-of-File '
DEFB 'Ignore error and load what there isI',0,0
DEFB 'Cancel operation C',0,0
LOADADD:
DEFW 08000H ;Load at 08000H
NUMRECS:
DEFB 10H
SMENU: DEFB 3,0,24,2
DEFB ' Save options: '
DEFB 'Return to main menu R',0,0
DEFB 'New name:______________ N',8EH,9
DEFB 'Use '
SDISK: DEFB '_:'
SFILE: DEFB '________.'
STYPE: DEFB '___ U',0,0
CURDISK:
DEFB 0
CSEG
;
GETDISK:
PUSH BC ;Get current disk drive in A. 0=A: etc.
PUSH DE
PUSH HL
LD C,19H
CALL FDOS
POP HL
POP DE
POP BC
RET
;
SETDISK:
PUSH AF ;Set drive in E to be current. 0=A: etc.
PUSH BC
PUSH DE
PUSH HL
LD C,0EH
CALL FDOS
POP HL
POP DE
POP BC
POP AF
RET
;
;----
SAVE:
;----
CALL HIVOFF
CALL GETDISK
LD (CURDISK),A ;Preserve current drive whilst resetting disks.
LD C,0DH
CALL FDOS
LD A,(CURDISK)
LD E,A
CALL SETDISK
CALL VERPROMPT ;Usual - un-highlight all options
CALL HIVON
CALL GENSP ;Highlight "save"
LD D,2
CALL PRINAT
LD DE,CCB
CALL OPCCB ;Print highlight.
LD A,(FCB)
AND 0FH ;Calculate drive to save to.
JP NZ,SAV0
CALL GETDISK ;Move current file to menu option "Use FILENAME.TYP".
INC A
SAV0: ADD A,'@'
LD (SDISK),A ;Drive (letter) - put this in the menu option.
LD B,8
LD HL,FCB+1 ;Move filename to menu option
LD DE,SFILE ;LDIR is not used because all characters
SLOOP1: LD A,(HL) ;are converted to 7-bit on the way.
RES 7,A
LD (DE),A
INC HL
INC DE
DJNZ SLOOP1
LD HL,FCB+9
LD DE,STYPE ;Similarly for filetype.
LD B,3
SLOOP2: LD A,(HL)
RES 7,A
LD (DE),A
INC HL
INC DE
DJNZ SLOOP2
LD HL,SMENU+3
LD A,(FCB+1)
CP ' ' ;DO WE HAVE A CURRENT FILE?
LD A,2
JP Z,SOK0 ;If there is no current file, alter the number
LD A,3 ;of menu options so that the third (use x:filename.typ)
SOK0: LD (HL),A ;does not appear.
SMEN0: LD HL,SMENU
CALL MENU
DEC B
JR Z,SQUIT
DEC B
JR Z,SQUIT ;EXIT or STOP = abandon, as usual.
DEC B
JR NZ,SOK1
SQUIT: CALL HIVOFF ;Quit saving.
CALL CLRMENU
JP MAINMEN
;
SOK1: DEC C ;Option 1 => abandon.
JP Z,SQUIT
PUSH AF
PUSH DE
CALL SAVEPROMPT ;If saving is confirmed, print the "saving file:" etc.
;into the information lines.
;
; CONFIRMED: WE ARE SAVING.
;
POP DE
POP AF
CP 3
JP Z,FCBOK ;If option 3 (use x:filename.typ) was used, we know the
INC DE ;FCB is OK.
LD A,(DE)
LD C,A ;Otherwise, a new FCB was input. Parse it.
LD B,0
INC DE
PUSH DE ;As for "load", put a space at the end of the FCB.
PUSH DE
POP HL
ADD HL,BC ;HL POINTS TO END OF FILENAME.
LD (HL),' ' ;FILENAME DELIMITER
POP HL
LD (CCB),HL
LD HL,FCB
LD (CCB+2),HL
LD DE,CCB
LD C,152 ;PARSE THE FILENAME
CALL FDOS
INC HL
LD A,H
OR L
CALL Z,BLEEP ;BAD FILENAME
JP Z,SMEN0
FCBOK: LD DE,0124H
CALL PRINAT ;Print the FCB at the top of the screen.
CALL HIVON
CALL OPFCB0
CALL HIVOFF
LD HL,SMENU
CALL CLRMENU
LD C,11H ;SEARCH FOR FILE
CALL FCBDOS
INC A
JP Z,SAVE2 ;If the file doesn't exist, skip this.
LD A,1
LD HL,FILEXISTS ;If the file exists, ask for further
CALL MENU ;instructions.
LD A,B
OR A
JP NZ,SQUIT ;If EXIT, STOP or "Abandon" selected, abandon.
LD A,C
CP 2
JP Z,SQUIT
CALL CLRMENU
LD C,13H ;Try to delete the file.
CALL FCBDOS
INC A
JP NZ,DEL2 ;OK?
CANTD: LD HL,CANTDEL ;No. File can't be deleted. Print the alert
CALL MENU ;message and leave.
CALL CLRMENU
JP MAINMEN
;
DEL2: LD HL,FCB+12 ;Blank out the FCB and see if the file
LD DE,FCB+13 ;is present on disc.
LD BC,22
LD (HL),0
LDIR
LD C,11H
CALL FCBDOS ;If it is present, deletion was unsuccessful.
INC A
JP NZ,CANTD
;
SAVE2: CALL PW1
LD D,10H ;CPC/PCW - 10 recs
CALL CHEKPL3
JR NZ,SAVE2A ;+3 - 20 recs
LD D,20H
SAVE2A: LD A,D
LD (NUMRECS),A
LD HL,0C000H ;Save from 0C000H.
LD (LOADADD),HL ;(LOADADD used for economy).
CALL RFONT
LD HL,FCB+12
LD DE,FCB+13 ;Blank the FCB
LD BC,22 ;Otherwise, the file may be corrupted.
LD (HL),0
LDIR
LD C,16H
CALL FCBDOS ;Create and open the file.
INC A
JP NZ,SAVE3 ;FILE OPEN?
LD HL,CANTMAKE ;If not, alert and leave.
CALL MENU
CALL CLRMENU
JP MAINMEN
;
SAVE3: LD DE,(LOADADD)
CALL SETDMA
LD HL,80H ;Increment DMA.
ADD HL,DE
LD (LOADADD),HL
;
CALL CON6 ;WAS THERE A KEYPRESS?
CP 3 ;^C?
JP Z,CANSAVE
CP 1BH ;EXIT?
JP Z,CANSAVE
;
LD C,15H ;WRITE SEQUENTIAL.
CALL FCBDOS
OR A
JP NZ,SAVERR
LD A,(NUMRECS) ;Count down until finished.
DEC A
LD (NUMRECS),A
JR NZ,SAVE3
;
; Font saved successfully
;
SAVE4: LD C,10H ;CLOSE FILE
CALL FCBDOS
CALL PW0
CALL ANYKEY ;Press a key; return to main menu.
JP MAINMEN
;
SAVERR: LD HL,DISKFULL ;Error: disk is full.
CALL MENU
CALL CLRMENU
CANSAVE:
LD C,10H
CALL FCBDOS ;Erase partially-saved file.
LD C,13H
CALL FCBDOS
JP MAINMEN
;
GENSP: LD HL,OS3
LD (CCB),HL
LD HL,11
LD (CCB+2),HL ;Calculate screen addresses for messages
LD A,OS3-OE3-3 ;and menus.
LD (SMENU+1),A
DEC A
LD (CATMENU+1),A
LD E,OS3-OE3
RET
;
SAVEPROMPT:
LD DE,45 ;PRINT "SAVING" ON TOP LINE
CALL PRINAT
CALL HIVON
LD DE,SAVING
CALL PRINT
LD DE,0100H ;Print "saving file:" on middle line.
CALL PRINAT
LD DE,SL1
CALL PRINT
LD DE,0200H
CALL PRINAT ;Print "Press EXIT or STOP to cancel"
LD DE,SL2 ;(machine dependent)
CALL CHEKPCW
JP Z,PRINT
CALL CHEKPL3
LD DE,SL3
JP Z,PRINT
LD DE,SL4
JP PRINT
;
DSEG
SL1: DEFB 'Saving character set to file: '
DEFB ' $'
SL2: DEFB 'Press EXIT or STOP to cancel saving '
DEFB ' $'
SL3: DEFB 'Press BREAK or ^C to cancel saving '
DEFB ' $'
SL4: DEFB 'Press ESC or ^C to cancel saving '
DEFB ' $'
FILEXISTS:
DEFB 5,32,16,2
DEFB ' File exists '
DEFB 'Delete it D',0,0
DEFB 'Cancel operationC',0,0
SAVING: DEFB 'Saving.$'
CANTDEL:
DEFB 6,31,18,1
DEFB 'Cannot delete file'
DEFB 'Cancel operation C',0,0
CANTMAKE:
DEFB 6,27,26,1
DEFB 'Directory full or disk R/O'
DEFB 'Cancel operation C',0,0
DISKFULL:
DEFB 6,32,16,1
DEFB ' Disk full '
DEFB 'Cancel operationC',0,0
CHAROK: DEFB 0 ;Flag: has a character been selected?
MYCHAR: DEFB 0 ;Current character number.
EDPROMPT:
DEFB 'Editing.$'
EDSTATUS:
; 1...5...10...15...20...25...30...35...40
DEFB 'Editing character no. U'
DEFB 'se cursor keys to move, SPACE set point $'
EDKEYS: DEFB '1=Get character '
EDOPT2: DEFB '2=Reflect '
EDOPT3: DEFB '3=Rotate '
EDOPT4: DEFB '4=Move '
EDOPT5: DEFB '5=Options '
EDOPT6: DEFB 'ENTER=Finished '
EDOPT7: DEFB 'STOP=Abandon $'
EDKPL3: DEFB '1=Get character '
EDPL32: DEFB '2=Reflect 3=Rotate 4=Move 5=Options ENTER=Finished '
EDPL37: DEFB '^C=Abandon $'
SIZMENU:
DEFB 3,0,5,2,'Size?LargeL',0,0,'SmallS',0,0
SELMENU:
DEFB 3,0,21,4
DEFB ' Make selection by '
DEFB 'Typing Character:_ T',81H,11H
DEFB 'ASCII number:___ A',83H,0DH
DEFB 'From characters chartF',0,0
DEFB 'OK - Continue O',0,0
SELM1: DEFB 3,0,21,4
DEFB ' Select character by '
DEFB 'Typing Character:'
SELMT: DEFB '_ T',81H,11H
DEFB 'ASCII number:'
SELMA: DEFB '___ A',83H,0DH
DEFB 'From characters chartF',0,0
DEFB 'OK - Continue O',0,0
EDSTO: DEFW 0 ;Stack pointer store while editing.
EDWIDE: DEFB 0 ;Width of character being edited (bits).
CSEG
;
EDIT: LD (EDSTO),SP ;Stack pointer
XOR A
LD (SIZMENU+1),A ;Character size menu appears at LH edge for editing.
LD (CHAROK),A ;No current satisfactory character.
LD DE,45
CALL PRINAT ;Print "Editing" on top line.
CALL HIVON
LD DE,EDPROMPT
CALL PRINT
LD DE,0100H ;Status line ("Editing character no. xx" etc.)
CALL PRINAT
LD DE,EDSTATUS
CALL PRINT
CALL HIVOFF
CALL VERPROMPT
LD DE,0200H
CALL PRINAT ;For 3rd line, print "E=Edit" inverse, others not
CALL HIVON ;(as usual).
LD HL,17
LD (CCB+2),HL
LD HL,OE3
LD (CCB),HL
LD DE,CCB
CALL OPCCB
CALL CHEKPL3
JP NZ,ED2
LD HL,SIZMENU ;If using a +3, ask which character size to use.
CALL MENU
CALL CLRMENU
LD A,B
OR A
JR Z,ED1
EQUIT: CALL DIRCLEAR ;Abandon edit; redraw font.
CALL IFP3BIG
CALL Z,EMPBOX
CALL PRFONT
LD SP,(EDSTO) ;Retrieve SP.
JP MAINMEN
;
ED1: LD A,C
DEC A ;SMALL =>A=1 ELSE A=0
ADD A,A ;A=A*2
ADD A,A ;A=A*4
ADD A,A ;A=A*8
ADD A,30H ;A=PL3 SET NO.
LD (PL3SET),A
;
ED2: CALL GETCHNO ;Get character number in MYCHAR.
JP NC,EQUIT
CALL DIRCLEAR
LD A,(MYCHAR) ;CHARACTER NUMBER
CALL CHARGET
CALL CHARBAK ;Back up current pattern.
CALL HIVON
CALL EDVPR ;Print editing keys on bottom line.
LD DE,0116H
CALL PRINAT
LD A,(MYCHAR) ;Print character number on info. lines.
CALL OPINT
LD A,8
LD (EDWIDE),A ;WIDTH OF CHARACTER. 8 FOR NORMAL, 5 FOR MINI +3
CALL CHEKPL3
JR NZ,ED3
LD A,(PL3SET)
CP 30H
JR Z,ED3
LD A,5
LD (EDWIDE),A
ED3: CALL CHEKPL3
JR NZ,ED5 ;If not using a +3, skip this.
LD E,' ' ;Else, print on the information line
CALL OPCHAR ;which size of character (large/small) is being used.
LD DE,LSM ;"Large size"
LD A,(EDWIDE)
CP 8
CALL Z,PRINT
LD DE,SSM ;"Small size"
CALL NZ,PRINT
ED5: CALL EDDRAW ;Draw edit windows
CALL IMAGBOX
XOR A
LD (EDX),A ;Set edit cursor to 0,0.
LD (EDY),A
CALL REDRAW ;REDRAW redraws the contents (only) of both windows.
EDLOOP: ;There is a similar subroutine REMAKE which redraws both
;the windows and their contents.
CALL PLCUR ;Place edit cursor.
CALL CON6
OR A ;Wait for keypress.
JR Z,EDLOOP
CP UA ;Up.
JP Z,EDUP
CP DA ;Down.
JP Z,EDDOWN
CP LA ;Left.
JP Z,EDLT
CP RA ;Right.
JP Z,EDRT
CP ' ' ;Flip a dot.
JP Z,EDDOT
CP 03H ;STOP (abandon)
JP Z,EQUIT1
CP 0DH ;ENTER (finished)
JP Z,EFIN1
CP '1' ;1=Get character
JP Z,OPTION1
CP '2' ;2=Reflect
JP Z,OPTION2
CP '3' ;3=Rotate
JP Z,OPTION3
CP '4' ;4=Move
JP Z,OPTION4
CP '5' ;5=Options.
JP Z,OPTION5
JP EDLOOP ;Others ignored.
;
EDDOT: CALL BW ;BW - get current dot in Carry flag.
JP C,RESDOT
SETDOT: CALL BW0 ;Get dot position in byte.
LD B,A ;C=byte, rotated so the bit has rotated off the left.
INC B ;B=position for DOTPUT.
SCF ;Carry=desired status.
DOTPUT: EX AF,AF'
DP1: EX AF,AF'
RR C ;Using AF' for all other purposes, and
EX AF,AF' ;only bringing in AF for the actual rotation.
DJNZ DP1
LD (HL),C ;Save byte.
LD A,(MYCHAR)
CALL CHARPUT ;Reprint the character
CALL REDRAW
JP EDLOOP
;
RESDOT: CALL BW0
LD B,A ;As SETDOT, but carry flag clear.
INC B
SCF
CCF
JR DOTPUT
;
BW: PUSH BC ;Check if current bit is black or white.
PUSH DE
PUSH HL
CALL BW0
POP HL
POP DE
POP BC
RET
BW0: LD A,(EDY)
LD E,A
LD D,0
LD HL,CHARBUF ;DE=Y offset.
ADD HL,DE
LD C,(HL)
LD A,(EDX)
LD B,A ;B=X offset.
INC B
EX AF,AF'
BW1: EX AF,AF' ;Rotate bit into carry flag, using
RL C ;AF' for flagging the DJNZ.
EX AF,AF'
DJNZ BW1
EX AF,AF'
RET ;THE BIT WE WANT IS IN THE CARRY FLAG.
;
EDUP: LD A,(EDY) ;Move up. If at top line, ignore.
OR A
JP Z,EDLOOP
PUSH AF
CALL UNPLCUR ;Remove cursor.
POP AF
DEC A
LD (EDY),A ;Replace cursor.
CALL PLCUR
JP EDLOOP
;
EDDOWN: LD A,(EDY) ;As EDUP, but down.
CP 7
JP Z,EDLOOP
PUSH AF
CALL UNPLCUR
POP AF
INC A
LD (EDY),A
CALL PLCUR
JP EDLOOP
;
EDLT: LD A,(EDX) ;Left.
OR A
JP Z,EDLOOP
PUSH AF
CALL UNPLCUR
POP AF
DEC A
LD (EDX),A
CALL PLCUR
JP EDLOOP
;
EDRT: LD A,(EDWIDE) ;As EDLT, but right. Since the char. is
LD B,A ;either 5 bit or 8 bit, a fixed comparison
DEC B ;can't be used; the max. value is held in B.
LD A,(EDX)
CP B
JP NC,EDLOOP
PUSH AF
CALL UNPLCUR
POP AF
INC A
LD (EDX),A
CALL PLCUR
JP EDLOOP
;
PLCUR: LD A,(EDX) ;Place the edit cursor.
LD E,1FH
ADD A,E
LD E,A ;Add X & Y offsets to convert cursor
LD A,(EDY) ;coordinates into screen coordinates.
LD D,05H
ADD A,D
LD D,A
CALL PRINAT
CALL BW ;Is the cursor on a black or white dot?
JP CURDOT ;Print cursor at current screen coordinates.
;
UNPLCUR:
CALL PLCUR ;Move to current cursor coordinates
LD E,8 ;Backspace
CALL OPCHAR
CALL BW ;Overprint with a dot.
JP DOT
;
OPTION1:
CALL HIVOFF ;Option 1 - get character.
LD DE,0200H+EDOPT2-EDKEYS
CALL PRINAT
CALL CHEKPCW ;Do the usual highlighting business.
LD DE,EDOPT2
CALL Z,PRINT ;This time, reprint the rest of the line
LD DE,EDPL32 ;in true video, since 1=Get character is at
CALL NZ,PRINT ;the beginning.
LD A,(MYCHAR)
LD (TEMPCHR),A ;Save current character number.
CALL GETCHNO
LD HL,SELM1 ;Get character number
CALL CLRMENU ;Clear number selection menu.
JR NC,ENDOPT1 ;If abandoned, go back to edit.
LD A,(MYCHAR) ;Get pattern of new char.
CALL CHARGET
ENDOPT1:
LD A,(TEMPCHR)
LD (MYCHAR),A ;Restore true number.
ENDOPT: LD A,(MYCHAR) ;Move current pattern to font & redraw.
CALL CHARPUT
CALL REDRAW
CALL HIVON
CALL EDVPR ;Information lines back in inverse video.
JP EDLOOP
;
DSEG
TEMPCHR:
DEFB 0 ;Temporary byte store.
CSEG
;
OPTION2:
CALL HIVOFF ;Reflect, almost exactly as WHREFLECT.
CALL EDVPR
CALL HIVON
LD HL,EDOPT2
LD (CCB),HL
LD HL,9
LD (CCB+2),HL
LD DE,0200H+EDOPT2-EDKEYS
CALL PRINAT
LD DE,CCB
CALL OPCCB
LD A,13
LD (OPT2MENU+1),A
LD A,1
LD HL,OPT2MENU
CALL MENU
CALL CLRMENU
LD A,B
OR A
JP NZ,EF2
LD A,C
CP 1
JP NZ,OPT2MV
CALL REFH ;Just CALL, because only one character.
JP ENDOPT
;
OPT2MV: CALL REFV
JP ENDOPT
;
REFH: LD HL,CHARBUF ;REFLECT CHAR. HORIZONTALLY
LD E,8
OPT2L1: LD B,8
LD A,(HL)
OPT2L2: RRA ;MIRROR A BYTE
RL C
DJNZ OPT2L2
LD A,(EDWIDE)
CP 5
JR NZ,OPT2J1
RL C
RL C ;Compensate for 5-bit chars.
RL C
OPT2J1: LD (HL),C
INC HL
DEC E
JR NZ,OPT2L1
RET
;
REFV: LD DE,CHARBUF ;Reflect vertically.
LD HL,CHARBUF+7
LD B,4
OPT2L3: LD C,(HL)
LD A,(DE)
LD (HL),A
LD A,C
LD (DE),A
DEC HL
INC DE
DJNZ OPT2L3
RET
;
DSEG
OPT2MENU:
DEFB 3,13,12,2
DEFB ' Reflection '
DEFB 'HorizontallyH',0,0
DEFB 'Vertically V',0,0
OPT3MENU:
DEFB 3,22,13,2
DEFB ' Rotation '
DEFB 'Clockwise C',0,0
DEFB 'AnticlockwiseA',0,0
OPT4MENU:
DEFB 3,32,5,4
DEFB 'Move:'
DEFB 'Up U',0,0
DEFB 'Down D',0,0
DEFB 'Left L',0,0
DEFB 'RightR',0,0
OPT5MENU:
DEFB 3,38,17,7
DEFB ' Miscellaneous '
DEFB 'Invert I',0,0
DEFB 'Preset patterns P',0,0
DEFB 'Scratchpad S',0,0
DEFB 'Bold B',0,0
DEFB 'Doublestrike D',0,0
DEFB 'Italic T',0,0
DEFB 'Outline O',0,0
OPT5M1: DEFB 3,38,17,5
DEFB ' Preset patterns '
DEFB 'Blank B',0,0
DEFB 'Grey G',0,0
DEFB 'AND speckled A',0,0
DEFB 'OR speckled O',0,0
DEFB 'XOR speckled X',0,0
OPT5M2: DEFB 3,38,18,2
DEFB ' Scratchpad empty '
DEFB 'Save to pad S',0,0
DEFB 'Quit Q',0,0
OPT5M3: DEFB 3,38,18,6
DEFB ' Scratchpad menu '
DEFB 'Save to pad S',0,0
DEFB 'Restore from pad R',0,0
DEFB 'AND with pad A',0,0
DEFB 'OR with pad O',0,0
DEFB 'XOR with pad X',0,0
DEFB 'Empty pad E',0,0
CSEG
;
OPTION3:
CALL HIVOFF ;As WHROTATE, for a single character.
CALL EDVPR
CALL HIVON
LD HL,EDOPT3
LD (CCB),HL
LD HL,8
LD (CCB+2),HL
LD DE,0200H+EDOPT3-EDKEYS
CALL PRINAT
LD DE,CCB
CALL OPCCB
LD A,(EDWIDE)
CP 5
JP Z,OPT3X5
LD A,22
LD (OPT3MENU+1),A
LD A,1
LD HL,OPT3MENU
CALL MENU
CALL CLRMENU
LD A,B
OR A
JP NZ,REMAKE
DEC C
JP Z,CLOCK
CALL ANTI
JP REMAKE
;
;ROTATE ANTICLOCKWISE.
DSEG
DESTBUF:
DEFS 8
CSEG
;
ANTI: LD C,8 ;Rotate into a destination area.
LD DE,DESTBUF
ACL0: LD HL,CHARBUF
LD B,8
ACL1: RR (HL) ;TOPMOST BIT IN CARRY
RLA ;MOVE TO A
INC HL
DJNZ ACL1 ;Take the topmost bit from each byte, and
LD (DE),A ;send it all to one byte. Put this in the
INC DE ;destination buffer, and repeat with the
DEC C ;new topmost bits.
JR NZ,ACL0
ENDACL: LD DE,CHARBUF
LD HL,DESTBUF ;Move back to character pattern area.
LD BC,8
LDIR
RET
;
CLOCK: CALL CLOCKWISE ;Rotate clockwise.
JP REMAKE ;REMAKE not REDRAW because the clockwise/anticlockwise menu
;impinges upon the edit window.
;
CLOCKWISE:
LD C,8
LD DE,DESTBUF+7
CL0: LD HL,CHARBUF
LD B,8
CL1: RR (HL) ;LOWEST BIT IN CARRY
RRA ;MOVE TO A
INC HL
DJNZ CL1 ;As ANTI, but the other way.
LD (DE),A
DEC DE
DEC C
JR NZ,CL0
JR ENDACL
;
OPT3X5: CALL REFV ;"Rotate" for 5x8 character.
CALL REFH
JP REMAKE
;
OPTION4:
CALL HIVOFF ;Move. As for WHMOVE.
CALL EDVPR
CALL HIVON
LD HL,EDOPT4
LD (CCB),HL
LD HL,6
LD (CCB+2),HL
LD DE,0200H+EDOPT4-EDKEYS
CALL PRINAT
LD DE,CCB
CALL OPCCB
LD A,1
LD HL,OPT4MENU
CALL MENU
CALL CLRMENU
LD A,B
OR A
JP NZ,REMAKE
DEC C
JP Z,MOVUP
DEC C
JP Z,MOVDN ;DOWN
DEC C
JP Z,MOVLT ;LEFT
CALL MRT
JP REMAKE
;
MRT: LD A,(EDWIDE)
CP 5
JP Z,MOVRT5
LD B,8
LD HL,CHARBUF
MOVRT1: RRC (HL) ;For 8-bits
INC HL
DJNZ MOVRT1
RET
;
MOVRT5: LD B,8
LD HL,CHARBUF ;for 5-bits.
MOVRT6: LD A,(HL)
LD C,A ;C IS 7,6,5,4,3,-,-,-
SRL C ;C IS -,7,6,5,4,3,-,-
SRL C ;C IS -,-,7,6,5,4,3,-
SRL C ;C IS -,-,-,7,6,5,4,3
SRL C ;C IS -,-,-,-,7,6,5,4 3 IN CARRY
RR A ;A IS 3,7,6,5,4,3,-,-
LD (HL),A
INC HL
DJNZ MOVRT6
RET
;
MOVUP: CALL MUP
JP REMAKE
;
MUP: LD A,(CHARBUF) ;Move up.
PUSH AF
LD BC,7
LD HL,CHARBUF+1
LD DE,CHARBUF
LDIR
POP AF
LD (CHARBUF+7),A
RET
;
MOVDN: CALL MDN
JP REMAKE
;
MDN: LD A,(CHARBUF+7) ;Move down.
PUSH AF
LD BC,7
LD HL,CHARBUF+6
LD DE,CHARBUF+7
LDDR
POP AF
LD (CHARBUF),A
RET
;
MOVLT: CALL MLT
JP REMAKE
;
MLT: LD A,(EDWIDE)
CP 5
JP Z,MOVLT5
LD B,8
LD HL,CHARBUF ;Move left 8 bits.
MOVLT1: RLC (HL)
INC HL
DJNZ MOVLT1
RET
;
MOVLT5: LD B,8
LD HL,CHARBUF
MOVLT6: LD A,(HL) ;Move left 5 bits.
LD C,A
SRL C ;C IS -,7,6,5,4,3,-,-
SRL C ;C IS -,-,7,6,5,4,3,-
SRL C ;C IS -,-,-,7,6,5,4,3
RL A ;BIT 7 IS NOW IN CARRY FLAG.
RL C ;C IS -,-,7,6,5,4,3,7
SLA C ;C IS -,7,6,5,4,3,7,-
SLA C ;C IS 7,6,5,4,3,7,-,-
SLA C ;C IS 6,5,4,3,7,-,-,-
LD (HL),C
INC HL
DJNZ MOVLT6
RET
;
OPTION5:
CALL HIVOFF ;Miscellaneous options
CALL EDVPR ;as WHOPT.
CALL HIVON
LD HL,EDOPT5
LD (CCB),HL
LD HL,9
LD (CCB+2),HL
LD DE,0200H+EDOPT5-EDKEYS
CALL PRINAT
LD DE,CCB
CALL OPCCB
OPT5X1: LD A,1
LD HL,OPT5MENU
CALL MENU
CALL CLRMENU
LD A,B
OR A
JP NZ,REMAKE
LD A,C
CP 1
JR Z,OPT5A
CP 4
JR Z,OPT5BLD
CP 5
JR Z,OPT5DBL
CP 6
JR Z,OPT5ITA
CP 7
JR Z,OPT5OUT
CP 2
JP NZ,OPT5C
LD HL,OPT5M1
LD A,1
CALL MENU
CALL CLRMENU
LD A,B
OR A
JR NZ,OPT5X1
LD A,C
CP 1
JP NZ,OPT5D
CALL WHBLANK
REMAKE: CALL EDDRAW
CALL IMAGBOX
JP ENDOPT
;
OPT5A: CALL INVBUF
JR REMAKE
;
OPT5BLD: CALL BLDBUF
JR REMAKE
;
OPT5DBL: CALL DBLBUF
JR REMAKE
;
OPT5ITA: CALL ITABUF
JR REMAKE
;
OPT5OUT: CALL OUTBUF
JR REMAKE
;
INVBUF: LD B,8
LD HL,CHARBUF
OPT5B: LD A,(HL)
CPL
LD (HL),A
INC HL
DJNZ OPT5B
RET
;
BLDBUF: LD HL,CHARBUF
LD B,8
BLDB1: LD A,(HL)
SRL A
OR (HL)
LD (HL),A
INC HL
DJNZ BLDB1
RET
;
DBLBUF: LD HL,CHARBUF
LD B,7
LD C,(HL)
INC HL
DBLB1: LD A,(HL)
OR C
LD C,(HL)
LD (HL),A
INC HL
DJNZ DBLB1
RET
;
ITABUF: LD A,(EDWIDE)
CP 5
CALL Z,PRUNE5
LD HL,CHARBUF
SRL (HL)
SRL (HL)
INC HL
SRL (HL)
INC HL
SRL (HL)
INC HL
INC HL
INC HL
SLA (HL)
INC HL
SLA (HL)
INC HL
SLA (HL)
SLA (HL)
RET
OUTBUF: LD HL,CHARBUF
LD DE,OUTPAD
LD BC,8
LDIR
XOR A
LD (CHARBUF),A
CALL MUP
LD HL,CHARBUF
LD B,8
OUTBUF1: SLA (HL)
INC HL
DJNZ OUTBUF1
CALL BLDBUF
CALL BLDBUF
CALL DBLBUF
CALL DBLBUF
LD HL,OUTPAD
LD DE,CHARBUF
CALL BUFXOR
RET
DSEG
OUTPAD: DEFS 8
CSEG
;
PRUNE5: LD HL,CHARBUF
LD B,8
PRUNE6: LD A,(HL)
AND 0F8H
LD (HL),A
INC HL
DJNZ PRUNE5
RET
;
OPT5C: LD A,(PADFLG)
OR A ;0=> PAD IN USE
JR Z,OPT5C1
LD HL,OPT5M2
LD A,1
CALL MENU
CALL CLRMENU
LD A,B
OR A
JP NZ,OPT5X1
DEC C
JP NZ,OPT5X1
OPT5C0: CALL PADSAV
XOR A
LD (PADFLG),A
JP REMAKE
;
OPT5C1: LD HL,OPT5M3
LD A,1
CALL MENU
CALL CLRMENU
LD A,B
OR A
JP NZ,OPT5X1
LD A,C
CP 1
JR Z,OPT5C0
LD HL,REMAKE
PUSH HL
CP 2
JP Z,PADRES
LD HL,PAD
LD DE,CHARBUF
CP 3
JP Z,BUFAND
CP 4
JP Z,BUFOR
CP 5
JP Z,BUFXOR
XOR A
INC A
LD (PADFLG),A
RET
;
OPT5D: LD HL,REMAKE
PUSH HL
LD HL,SPECBUF
LD DE,CHARBUF
CP 3
JP Z,BUFAND
CP 4
JP Z,BUFOR
CP 5
JP Z,BUFXOR
LD BC,8
LDIR
RET
;
DSEG ;Bitmap for speckled pattern.
SPECBUF:
DEFB 85,170,85,170,85,170,85,170
CSEG
;
BUFAND: LD A,0A6H ;Code for AND (HL)
JR BUFGEN
;
BUFOR: LD A,0B6H ;Code for OR (HL)
BUFGEN: LD (ORAD),A
LD B,8
BUFG1: LD A,(DE)
ORAD: OR (HL) ;Code changes depending on routine.
LD (DE),A
INC HL
INC DE
DJNZ BUFG1
RET
;
BUFXOR: LD A,0AEH ;Code for XOR (HL)
JR BUFGEN
;
FNTAND: LD A,0A6H ;As BUFAND, BUFOR, BUFXOR but on the
JR FNTGEN ;entire font.
;
FNTOR: LD A,0B6H
JR FNTGEN
;
FNTXOR: LD A,0AEH
FNTGEN: LD (XORAD),A
LD BC,800H
LD DE,0C000H ;Font
LD HL,08800H ;Font scratchpad
FNTG1: LD A,(DE)
XORAD: XOR (HL)
LD (DE),A
INC HL
INC DE
DEC BC
LD A,B
OR C
JR NZ,FNTG1
JP WHMAKE ;REMAKE, for whole font options.
;
EDVPR: PUSH AF ;Draw machine-dependent key listing.
PUSH DE
LD DE,0200H
CALL PRINAT
CALL CHEKPCW
LD DE,EDKEYS ;PCW version.
CALL Z,PRINT
LD DE,EDKPL3 ;Other version.
CALL NZ,PRINT
POP DE
POP AF
RET
;
REDRAW: PUSH AF ;Redraw contents of windows.
PUSH BC
PUSH DE
PUSH HL
LD DE,051FH ;Coordinates of edit window.
PUSH DE
LD C,8 ;Height of window
LD HL,CHARBUF
REDR1: POP DE
CALL PRINAT
INC D
PUSH DE
LD A,(EDWIDE) ;Width of window.
LD B,A
LD A,(HL) ;Current byte.
INC HL
REDR2: RLA ;Current bit.
CALL DOT ;Draw it.
DJNZ REDR2
DEC C
JR NZ,REDR1
POP DE
CALL HIVOFF
LD A,(MYCHAR) ;Redraw contents of samples window.
CALL IFP3BIG
JP Z,REDR2A ;+3 big chars have a different samples routine.
LD DE,052DH
CALL PRINAT
LD E,A
CALL ANYCHAR ;Print character by itself.
REDR2B: LD DE,072BH
PUSH DE
LD C,6 ;Print a 5x6 (or if +3 big, 3x6) set of chars.
REDR3: POP DE
CALL PRINAT
INC D ;Increase Y-coordinate - next line.
PUSH DE
LD E,A
CALL IFP3BIG ;For +3, print the characters.
CALL Z,OPBIG5
JR Z,REDR4A
LD B,5 ;5 characters side by side.
REDR4: CALL ANYCHAR
DJNZ REDR4
REDR4A: DEC C
JR NZ,REDR3
POP BC
POP HL
POP DE
POP BC
POP AF
RET
;
REDR2A: LD DE,042EH ;For +3, the actual window must be made
CALL PRINAT ;slightly bigger. Extend it to the right.
LD E,GTL
CALL OPCHAR
LD E,GTRC
CALL OPCHAR
LD DE,052DH ;Middle line.
CALL PRINAT
LD E,A
CALL OPBIG ;Print the actual character.
LD E,GRL
CALL OPCHAR
LD DE,062EH
CALL PRINAT
LD E,GTL
CALL OPCHAR
LD E,GTRJ
CALL OPCHAR
JP REDR2B
;
IFP3BIG:
CALL CHEKPL3 ;If not +3, not +3 big.
RET NZ
PUSH BC ;Preserve A but not F.
LD C,A
LD A,(PL3SET) ;If +3 char. set is at 3000h, big set.
CP 30H
LD A,C
POP BC
RET
;
CURDOT: LD E,128 ;DRAW THE CURSOR DOT.
JR DOT1
DOT: LD E,144
DOT1: CALL C,HIVON ;DRAW A NORMAL DOT.
CALL NC,HIVOFF
JP OPCHAR
;
EDDRAW: CALL HIVOFF ;DRAW THE GRAPHICS WINDOW
LD DE,041EH
PUSH DE
CALL PRINAT
LD E,GTLC
CALL OPCHAR
LD A,(EDWIDE) ;Either 5 wide or 8 wide.
LD B,A
LD E,GTL
CALL STRING$
LD E,GTRC ;Top line.
CALL OPCHAR
LD C,8 ;8 middle lines.
EDD1: POP DE
INC D ;Increment Y-coordinate.
PUSH DE
CALL PRINAT
LD E,GLL ;LH line.
CALL OPCHAR
LD B,A
LD E,144 ;Blank dots.
CALL STRING$
LD E,GRL
CALL OPCHAR ;RH line - for Amstrads, identical to LH line.
DEC C
JR NZ,EDD1
POP DE
INC D
CALL PRINAT
LD E,GBLC ;Bottom line.
CALL OPCHAR
LD B,A
LD E,GBL
CALL STRING$
LD E,GBRC
CALL OPCHAR
RET
;
IMAGBOX:
LD DE,042AH ;Draw samples box.
CALL PRINAT
PUSH DE
LD DE,IBTL ;Top line.
CALL PRINT
POP DE
INC D
CALL PRINAT
PUSH DE
LD DE,IB2L ;2nd line.
CALL PRINT
POP DE
INC D
CALL PRINAT
PUSH DE
LD DE,IB3L ;3rd line.
CALL PRINT
LD B,6 ;6 intermediate lines.
IB1: POP DE
INC D
CALL PRINAT
PUSH DE
LD DE,IB4L
CALL PRINT
DJNZ IB1
POP DE
INC D
CALL PRINAT
LD DE,IB5L ;bottom line.
CALL PRINT
RET
;
DSEG
IBTL: DEFB ' ',GTLC,GTL,GTRC,' $'
IB2L: DEFB ' ',GLL,' ',GRL,' $'
IB3L: DEFB GTLC,GTL,GTLJ,GTL,GTRJ,GTL,GTRC,'$'
IB4L: DEFB GLL,' ',GRL,'$'
IB5L: DEFB GBLC,GBL,GBL,GBL,GBL,GBL,GBRC,'$'
SSM: DEFB 'Small size$'
LSM: DEFB 'Large size$'
EDX: DEFB 0 ;Cursor X & Y.
EDY: DEFB 0
EFMENU: DEFB 3,EDOPT6-EDKEYS,13,2
DEFB 'Are you sure?'
DEFB 'Yes Y',0,0
DEFB 'No N',0,0
EQMENU: DEFB 3,65,13,2
DEFB 'Are you sure?'
DEFB 'Yes Y',0,0
DEFB 'No N',0,0
CSEG
;
EFIN1: CALL HIVOFF ;Highlight as usual. This is similar to WHFIN.
CALL EDVPR
LD DE,0200H+EDOPT6-EDKEYS
CALL HIVON
CALL PRINAT
LD HL,EDOPT6
LD (CCB),HL
LD HL,EDOPT7-EDOPT6-1
LD (CCB+2),HL
LD DE,CCB
CALL OPCCB
LD HL,EFMENU
CALL MENU
CALL CLRMENU
LD A,B
OR A
JP NZ,EF2
LD A,C
CP 1
JP Z,EQUIT
EF2: CALL HIVON
CALL EDVPR
JP EDLOOP
EQUIT1: CALL HIVOFF ;Quit edit. As for WHQUIT.
CALL EDVPR
CALL HIVON
LD DE,0243H
CALL PRINAT
LD DE,EDOPT7
CALL CHEKPCW
CALL Z,PRINT
LD DE,EDPL37
CALL NZ,PRINT
LD HL,EQMENU
CALL MENU
CALL CLRMENU
LD A,B
OR A
JR NZ,EF2
DEC C
JP NZ,EF2
;
EQUIT3: CALL CHARRES
LD A,(MYCHAR) ;Get character as it was on entry.
CALL CHARPUT
JP EQUIT
;
GETCHNO:
LD HL,SELMENU ;Get character no. in MYCHAR.
LD DE,SELM1
LD BC,SELM1-SELMENU
LDIR ;Move menu template to current menu area
LD A,1 ;(since the subroutine alters menu text).
ED2A: LD HL,SELM1
CALL MENU
LD A,B
DEC B ;"CAN"
JP Z,ENDGC
DEC B ;"EXIT"
JP Z,ENDGC
DEC B ;"STOP"
JP Z,ENDGC
LD A,C
CP 4 ;WAS "OK" SELECTED?
JP Z,CHKSEL
CP 3 ;WAS "SELECT FROM SCREEN" SELECTED?
JP Z,SELSCR
LD C,A
LD A,B
OR A ;If 0 (ENTER) pressed on an input option,
LD A,C ;ignore it.
JR Z,ED2A
CP 1
JP Z,ED4 ;A NUMBER HAS BEEN INPUT. PARSE IT.
INC DE
LD A,(DE)
LD C,A ;LD BC,A
LD B,0
PUSH DE
LD H,D ;HL=DE
LD L,E
INC HL
ADD HL,BC ;ADD HL,A
LD (HL),'$' ;Number is terminated by $.
POP HL
INC HL
LD A,(HL) ;If '&' parse as hex, not decimal
CP '&'
JR Z,GCHEX
CALL PARSENUM
GCHEX1: LD A,2
CALL C,BLEEP ;If carry set, not a number.
JP C,ED2A
LD A,E
LD (MYCHAR),A ;Set character number.
CALL UPDCHR ;Put this in the menu.
LD A,0FFH
LD (CHAROK),A ;A selection has been made.
JP ED2A4
;
GCHEX: INC HL
CALL PARSEHEX
JR GCHEX1
;
ED4: INC DE
LD A,(DE) ;Was a character typed at all?
OR A
JP Z,ED2A
LD A,255 ;A selection has been made.
LD (CHAROK),A
INC DE
LD A,(DE) ;Move character no. to MYCHAR.
LD (MYCHAR),A
CALL UPDCHR ;Update character in menu.
JP ED2A4
;
UPDCHR: PUSH AF
LD A,(MYCHAR)
CP 20H ;If character is printable put it in the menu.
JR NC,UPD1
LD A,' ' ;otherwise put a space.
UPD1: LD (SELMT),A
LD A,(MYCHAR) ;Put the ASCII number in the menu.
PUSH BC ;As OPINT but the number isn't printed.
PUSH DE
PUSH HL
LD HL,SELMA
LD E,100
CALL DIVAE
LD E,10
CALL DIVAE
LD E,1
CALL DIVAE
POP HL
POP DE
POP BC
POP AF
RET
;
DIVAE: LD D,A ;Divide A by E, result in (HL), HL->HL+1
LD B,8
XOR A ;Routine from Michael Keys' book, "PCW machine code"
DIVAE1: SLA D
RLA
CP E
JR C,DIVAE2
SUB E
INC D
DIVAE2: DJNZ DIVAE1
PUSH AF
LD A,30H
ADD A,D
LD (HL),A
INC HL
POP AF
RET
;
SELSCR: CALL IFP3BIG ;Select the character by pointing at it in the box at the bottom of the screen.
CALL Z,VBFONT
CALL SELCHR ;SELECT THE CHARACTER.
LD A,3
JP NC,ED2A ;ABANDONED
CALL UPDCHR
LD A,255 ;Set to OK.
LD (CHAROK),A
ED2A4: LD A,4 ;Jump to option 4.
LD HL,SELM1
JP ED2A
;
CHKSEL: LD A,(CHAROK) ;If a character has been input, leave.
OR A ;otherwise, ignore.
JR Z,ED2A4
SCF
RET
;
ENDGC: SCF
CCF
RET
;
SELCHR: CALL ARROWS ;Select character from chart.
;1. Draw arrows.
;2. Movement key actions:
SELCHR1:
CALL CON6
CP LA
CALL Z,SELLA ;Left
CP RA
CALL Z,SELRA ;Right
CP UA
CALL Z,SELUA ;Up
CP DA
CALL Z,SELDA ;Down
;3. If CR, selection made OK.
CP 0DH
JP Z,SELMADE
;4. If Stop or EXIT, abandoned.
CP 03H
CALL Z,DIRCLEAR
JP Z,SELQUIT
CP ESC
CALL Z,DIRCLEAR
JP Z,SELQUIT
;
;UNRECOGNISED KEY!
;
JR SELCHR1
;
; MOVEMENT KEY MANAGER:
; A. CHECK BOUNDS
; B. IF ACCEPTABLE, UNDRAW ARROWS & CHANGE POSITION
SELUA: PUSH AF
LD A,(CHY) ;Prospective new Y.
DEC A
JR SELDA1
;
SELDA: PUSH AF
LD A,(CHY) ;Prospective new Y.
INC A
SELDA1: CALL VBOUNDS
JR NC,SELEND ;If not within bounds, quit.
CALL ARRDEL ;Remove arrows.
LD (CHY),A ;Set new Y.
CALL ARROWS ;Redraw arrows.
JR SELEND
;
SELLA: PUSH AF
LD A,(CHX) ;Left.
DEC A ;Each char. takes 2 screen locations.
DEC A
SELLA1: CALL HBOUNDS
JR NC,SELEND ;If not within bounds, quit
CALL ARRDEL ;Remove, set new Y, redraw.
LD (CHX),A
CALL ARROWS
SELEND: POP AF
RET
;
SELRA: PUSH AF
LD A,(CHX) ;Right.
INC A
INC A
JR SELLA1
;
VBOUNDS:
CP 15 ;CARRY SET => GOOD BOUNDARIES
JR C,INVB
CP 21 ;Vertical boundaries, 15-21.
JR Z,VB1 ;Line 21 is short, so if X is too big,
RET C ;the cursor can't go onto it.
INVB: SCF
CCF
RET
HBOUNDS:
PUSH BC ;Horizontal boundaries are 1-76
LD B,A
LD A,(CHY)
CP 21 ;But if on line 21, special provision.
LD A,B
POP BC
JR Z,HB1
CP 1
JR C,INVB
CP 77
RET C
JR INVB
;
HB1: CP 56 ;Max. X is 55 on line 21.
RET C
JR INVB
;
VB1: PUSH BC
LD B,A
LD A,(CHX) ;If above Max. X, invalid coordinates.
CP 56
LD A,B
POP BC
RET C
JR INVB
;
ARROWS: PUSH AF ;Draw arrows round the chosen character.
PUSH BC
PUSH DE
PUSH HL
LD DE,(CHX)
CALL PRINAT
CALL HIVON
CALL ARR1
CALL HIVOFF
POP HL
POP DE
POP BC
POP AF
RET
;
ARRDEL: PUSH AF ;Remove arrows from chosen character.
PUSH BC
PUSH DE
PUSH HL
LD DE,(CHX)
CALL PRINAT
CALL HIVOFF
CALL IFP3BIG ;If big character, then
JP Z,ARRDELB ;Delete arrows from a big character
LD DE,C3$ ;Remove character & backspace.
CALL PRINT
CALL WHATCHAR ;Calculate character number from cursor pos.
LD E,A
CALL IFFSET ;If there was a marker, print the underlines.
CALL Z,MARK
CALL NZ,NOMARK
ARRDL1: POP HL
POP DE
POP BC
POP AF
RET
;
ARRDELB:
CALL WHATCHAR ;Get big char. number
LD E,A
CALL IFFSET ;If there was a marker, underlines.
CALL Z,RVBIG ;Else, no underline.
CALL NZ,OPBIG
JR ARRDL1
;
ARR1: CALL IFP3BIG ;Draw arrows. Normally, an arrow
JP Z,ARR1B ;setup is an inverse video box, with
CALL WHATCHAR ;arrows ->C<- pointing at char.
LD E,A ;If char is marked, it is =>C<=.
CALL IFFSET ;Big characters are just drawn in inverse video.
LD E,12 ;12 is normal arrow, 252 is marker arrow
JR NZ,ARR1A ;(both point right).
LD E,252
ARR1A: CALL ANYCHAR
LD E,A
CALL ANYCHAR ;Print the character itself.
CALL IFFSET
LD E,11 ;11 is normal left arrow, 253 marker arrow.
JR NZ,ARR1C
LD E,253
ARR1C: CALL ANYCHAR
RET
;
ARR1B: CALL WHATCHAR ;Print big character in inverse video.
LD E,A
CALL IFFSET
CALL Z,RVBIG
CALL NZ,OPBIG ;Marked big characters retain their underline.
RET
;
WHATCHAR:
;A=(X-1)/2+38*(Y-15)
PUSH DE
PUSH BC
LD A,(CHX) ;A=X
DEC A ;A=X-1
SRL A ;A=(X-1)/2
LD B,A ;B=(X-1)/2
LD A,(CHY) ;A=Y
SUB 15 ;A=Y-15
ADD A,A ;A=2*(Y-15)
LD C,A ;C=2*(Y-15)
ADD A,A ;A=4*(Y-15)
LD D,A ;D=4*(Y-15)
ADD A,A ;A=8*(Y-15)
ADD A,A ;A=16*(Y-15)
ADD A,A ;A=32*(Y-15)
ADD A,D ;A=36*(Y-15)
ADD A,C ;A=38*(Y-15)
ADD A,B ;A=38*(Y-15)+(X-1)/2
POP BC
POP DE
RET
;
SELMADE:
CALL WHATCHAR ;Selection has been made. Flag it & return.
LD (MYCHAR),A
CALL ARRDEL
SCF ;FLAG OK.
RET
;
SELQUIT:
CALL ARRDEL ;Delete arrows & quit.
SCF
CCF
RET
;
EMPBOX: LD DE,0F01H ;Empty the font box
LD B,7
EMP1: CALL PRINAT
PUSH DE
LD DE,SPACES+2 ;(overprint it with spaces)
CALL PRINT
POP DE
INC D
DJNZ EMP1
RET
;
DSEG
CHX: DEFB 1
CHY: DEFB 15 ;X & Y for characters chart cursor.
SPACES: DEFB ' '
DEFB ' ',CR,LF,'$'
FBEGIN: DEFB 0 ;First marker
FEND: DEFB 0 ;2nd marker
FFLG: DEFB 0 ;
LOADOPT:
DEFB 0 ;Loading options
CPDFLG: DEFB 0FFH ;Character scratchpad flag 0FFH empty 0 full.
C3$: DEFB ' ',8,8,8,'$'
;Delete 3 characters to right.
CSEG
;
;END OF THIS MODULE.