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 >
Text File  |  1994-03-21  |  44KB  |  2,285 lines

  1. ;ALTER v1.02. Module contains Exit program, load font, save font and edit character
  2. ;commands.
  3. ;
  4. ;----
  5. EXIT:
  6. ;----
  7. ;
  8.     CALL    HIVOFF        ;Exit program menu.
  9.     CALL    VERPROMPT    ;Redraw all options in true video etc. etc. etc.
  10.     CALL    HIVON
  11.     CALL    CHEKPL3
  12.     CALL    Z,PL3EXP
  13.     CALL    CHEKPCW
  14.     CALL    Z,PCWEXP    ;Print "EXIT" or "BREAK" or "ESC" in inverse video.
  15.     CALL    CHEKCPC
  16.     CALL    Z,CPCEXP
  17.     LD    D,2
  18.     CALL    PRINAT
  19.     LD    DE,CCB
  20.     CALL    OPCCB
  21. EXIT1:    LD    HL,XMENU    ;Are you sure N/Y?
  22.     CALL    MENU        ;(So you have to move the bar to confirm).
  23.     LD    A,B
  24.     OR    A
  25.     LD    A,C
  26.     JR    NZ,EXIT1
  27.     CALL    CLRMENU
  28.     CP    1
  29.     JP    Z,MAINMEN    ;If abandoned, go back to main menu.
  30.     LD    DE,SCRUNI    ;De-initialise screen.
  31.     CALL    PRINT
  32.     CALL    CURON
  33.     LD    DE,SIGNOFF    ;Sign off.
  34.     CALL    PRINT
  35.     LD    SP,(STAKSTO)    ;Retrieve SP.
  36.     JP    WBOOT        ;Warm boot.
  37. ;
  38. PL3EXP:    LD    HL,OX3
  39.     LD    (CCB),HL
  40.     LD    HL,18
  41.     LD    (CCB+2),HL    ;Calculate address & position of message for +3.
  42.     LD    A,OX3-OE3+2    ;Message reads "BREAK=Leave"
  43.     LD    (XMENU+1),A
  44.     LD    E,OX3-OE3
  45.     RET
  46. ;
  47. PCWEXP:    LD    HL,OX1
  48.     LD    (CCB),HL
  49.     LD    HL,18
  50.     LD    (CCB+2),HL    ;Message reads "EXIT=Leave"
  51.     LD    A,OX1-OE1+2
  52.     LD    (XMENU+1),A
  53.     LD    E,OX1-OE1
  54.     RET
  55. ;
  56. CPCEXP:    LD    HL,OX0
  57.     LD    (CCB),HL
  58.     LD    HL,18
  59.     LD    (CCB+2),HL    ;Message reads "ESC=Leave"
  60.     LD    A,OX0-OE0+2
  61.     LD    (XMENU+1),A
  62.     LD    E,OX0-OE0
  63.     RET
  64. ;
  65.     DSEG
  66. XMENU:    DEFB    3,0,13,2
  67.     DEFB    'Are you sure?'
  68.     DEFB    'No           N',0,0
  69.     DEFB    'Yes          Y',0,0
  70. LMENU:    DEFB    3,0,15,2
  71.     DEFB    'Loading options'
  72.     DEFB    'Abandon loadingA',0,0
  73.     DEFB    'Entire font    E',0,0
  74.     DEFB    'Between markersB',0,0
  75. CATMENU:
  76.     DEFB    3,0,15,2
  77.     DEFB    'Catalogue disc?'
  78.     DEFB    'Yes            Y',0,0
  79.     DEFB    'No             N',0,0
  80. LOADING:
  81.     DEFB    'Loading.$'
  82. LL1:    DEFB    'Loading new character set file:         '
  83.     DEFB    '                                        $'
  84. LL2:    DEFB    'Press EXIT or STOP to cancel loading    '
  85.     DEFB    '                                        $'
  86. LL3:    DEFB    'Press BREAK or ^C to cancel loading     '
  87.     DEFB    '                                        $'
  88. LL4:    DEFB    'Press ESC or ^C to cancel loading       '
  89.     DEFB    '                                        $'
  90. CCB:    DEFW    0,0
  91.  
  92. QFCB:    DEFB    0,'???????????'
  93.     DEFS    23    ;*.*
  94.     CSEG
  95. ;
  96. ;---
  97. LOAD:
  98. ;---
  99. ;
  100.     CALL    HIVOFF
  101.     CALL    GETDISK    ;Save current drive while disks are reset.
  102.     LD    (CURDISK),A
  103.     LD    C,0DH
  104.     CALL    FDOS
  105.     LD    A,(CURDISK)    ;Restore current drive
  106.     LD    E,A
  107.     CALL    SETDISK
  108.     CALL    RFONT        ;Read font into main memory.
  109.     LD    DE,8000H
  110.     LD    HL,0C000H    ;Move font to loading buffer, so that if
  111.     LD    BC,1000H    ; file doesn't cover all of it, the rest  
  112.     LDIR            ;isn't corrupted.
  113.     CALL    VERPROMPT
  114.     CALL    HIVON
  115.     CALL    GENLP        ;Part of printing the information lines
  116.     LD    D,2
  117.     CALL    PRINAT
  118.     LD    DE,CCB        ;Print information lines
  119.     CALL    OPCCB
  120.     LD    A,(FFLG)    ;If there are markers, add an extra
  121.     OR    A        ;option to the "Are you sure?" menu - 
  122.     LD    A,2        ;"Load between Markers".
  123.     JR    Z,LOADX1
  124.     LD    A,3
  125. LOADX1:    LD    (LMENU+3),A
  126.     LD    HL,LMENU
  127.     CALL    MENU
  128.     CALL    CUROFF
  129.     LD    A,B    ;If abandoned, quit.
  130.     OR    A
  131.     JR    Z,LOK1
  132. LQUIT:    LD    A,' '    ;Abandon loading - set file to "No file."
  133.     LD    (FCB+1),A
  134.     CALL    CLRMENU    ;Clear current menu.
  135.     JP    MAINMEN    ;Leave.
  136. ;
  137. LOK1:    LD    A,C
  138.     CALL    CLRMENU
  139.     CP    1
  140.     JP    Z,MAINMEN    ;Option 1 - "Abandon" - treat similarly.
  141.     DEC    A
  142.     DEC    A
  143.     LD    (LOADOPT),A    ;1 for "between markers" else 0.
  144. ;
  145. ; CONFIRMED: LOAD WAS SELECTED.
  146. ;
  147. LOAD2:    CALL    LOADPROMPT    ;Draw information lines
  148.     LD    DE,DMA
  149.     CALL    SETDMA    ;Set DMA to 0080H.
  150.     LD    DE,QFCB
  151.     LD    C,11H    ;Find *.*
  152.     CALL    FDOS
  153.     INC    A
  154.     JP    Z,NOFILES    ;"No files found" actions
  155.     LD    HL,CATMENU
  156.     LD    A,1    ;Catalogue Y/N?
  157.     CALL    MENU
  158.     LD    A,B
  159.     OR    A    ;Aborted?
  160.     JP    NZ,LQUIT
  161.     CALL    CLRMENU
  162.     DEC    C
  163.     LD    A,1
  164.     JP    NZ,NOCAT    ;No catalogue requested.
  165.     CALL    PW1    ;Please wait.
  166.     CALL    HIVOFF
  167.     LD    DE,0300H    ;Print in main window.
  168.     CALL    PRINAT
  169.     LD    DE,QFCB    ;*.*
  170.     LD    C,11H
  171.     CALL    FDOS    ;find *.*
  172.     LD    C,A
  173.     XOR    A    ;C=coded address of filename.
  174. DIRLOOP:
  175.     INC     A    ;A=no. of files printed.
  176.     PUSH    AF
  177.     LD    A,C
  178.     ADD    A,A    ;*2
  179.     ADD    A,A    ;*4
  180.     ADD    A,A    ;*8
  181.     ADD    A,A    ;*16
  182.     ADD    A,A    ;*32
  183.     LD    HL,DMA    ;+DMA
  184.     PUSH    DE
  185.     LD    E,A
  186.     LD    D,0
  187.     ADD    HL,DE
  188.     POP    DE
  189.     CALL    OPFCB3    ;Print filename at HL.
  190.     POP    AF
  191.     CP    50    ;If 50 filenames printed, wait for a keypress
  192.     CALL    Z,PAGE    ;and then continue.
  193.     LD    B,4    ;4 spaces between files.
  194.     LD    E,' '
  195.     CALL    STRING$
  196.     LD    DE,QFCB
  197.     LD    C,12H    ;Find next file
  198.     CALL    FDOS
  199.     LD    C,A
  200.     INC    A    ;No next file?
  201.     JR    NZ,DIRLOOP
  202.     CALL    ANYKEY    ;Press any key.
  203.     CALL    DIRCLEAR
  204.     LD    HL,LMENU    ;Menu to clear if STOP/EXIT pressed
  205.     CP    3        ;Was the key from ANYKEY STOP or EXIT?
  206.     JP    Z,LQUIT
  207.     CP    1BH
  208.     JP    Z,LQUIT
  209.     LD    A,1
  210. ;
  211. NOCAT:    CALL    PW0        ;Take away "Please wait"
  212.     LD    HL,ASKFMENU    ;Ask: Load a file or catalogue a different drive
  213.     CALL    MENU
  214.     DEC    B
  215.     JP    Z,LQUIT        ;1,2 or 3. Abandoned.
  216.     DEC    B
  217.     JP    Z,LQUIT
  218.     DEC    B
  219.     JP    Z,LQUIT
  220.     DEC    B        ;Return code B=4. Input was made, DE points to it.  
  221.     JR    Z,PARSEF
  222.     CP    1
  223.     JR    Z,NOCAT
  224.     CALL    CLRMENU
  225.     LD    A,1
  226.     LD    HL,DIFMENU
  227.     JP    NOF0    ;Catalogue different drive.
  228. ;
  229. PARSEF:    POP    AF
  230. ;DE POINTS TO FILENAME BUFFER
  231.     INC    DE
  232.     LD    A,(DE)    ;A=length of filename
  233.     LD    C,A
  234.     LD    B,0    ;BC=length
  235.     INC    DE
  236.     PUSH    DE
  237.     PUSH    DE
  238.     POP    HL
  239.     ADD    HL,BC    ;HL POINTS TO END OF FILENAME.
  240.     LD    (HL),' '    ;End-of-filename marker.
  241.     POP    HL
  242.     LD    (CCB),HL    ;CCB is also used as PFCB for "parse filename".
  243.     LD    HL,FCB
  244.     LD    (CCB+2),HL
  245.     LD    DE,CCB
  246.     LD    C,152    ;PARSE THE FILENAME
  247.     CALL    FDOS
  248.     INC    HL
  249.     LD    A,H    ;If HL=0FFFFh, bad filename.
  250.     OR    L
  251.     CALL    Z,BLEEP    ;BAD FILENAME
  252.     JP    Z,NOCAT
  253.     LD    HL,ASKFMENU    ;Clear the menu.
  254.     CALL    CLRMENU
  255. ;
  256. ;FILENAME ENTERED.
  257. ;
  258. SCANF:    LD    DE,0126H    ;Print the new FCB in the information lines.
  259.     CALL    PRINAT
  260.     CALL    HIVON
  261.     CALL    OPFCB0
  262.     LD    C,11H    ;Search for it.
  263.     CALL    FCBDOS
  264.     INC    A
  265.     JP    NZ,LOAD3    ;If found, continue
  266.     LD    HL,SCANFAIL
  267.     CALL    MENU    ;An "alert" menu. File not found.
  268.     JP    LQUIT
  269. ;
  270. LOAD3:    CALL    PW1    ;Please wait.
  271.     LD    HL,08000H    ;Load at 8000H.
  272.     LD    (LOADADD),HL
  273.     LD    D,10H    ;16 records
  274.     CALL    CHEKPL3
  275.     JR    NZ,LOAD3A    ;or on the +3, 32 records.
  276.     LD    D,20H
  277. LOAD3A:    LD    A,D
  278.     LD    (NUMRECS),A
  279.     LD    C,0FH    ;OPEN FILE TO READ.
  280.     CALL    FCBDOS
  281.     INC    A
  282.     JP    NZ,LOAD4
  283.     LD    HL,CANTOPEN    ;Can't open it (possibly password protected)
  284.     CALL    MENU        ;Alert menu.
  285.     JP    LQUIT
  286. ;
  287. LOAD4:    LD    DE,(LOADADD)    ;Set DMA to current load address.
  288.     CALL    SETDMA
  289.     LD    HL,80H    ;Increment load address.
  290.     ADD    HL,DE
  291.     LD    (LOADADD),HL
  292. ;
  293.     CALL    CON6    ;WAS THERE A KEYPRESS?
  294.     CP    3    ;^C?
  295.     JP    Z,CANLOAD
  296.     CP    1BH    ;Exit?
  297.     JP    Z,CANLOAD
  298. ;
  299.     LD    C,14H    ;READ SEQUENTIAL.
  300.     CALL    FCBDOS
  301.     OR    A
  302.     JP    NZ,LOADERR    ;If an error found, file is too short.
  303.     LD    A,(NUMRECS)
  304.     DEC    A
  305.     LD    (NUMRECS),A    ;Count down until all records loaded.
  306.     JR    NZ,LOAD4
  307. ;
  308. ; Font loaded successfully
  309. ;
  310. LOAD5:    LD    C,10H    ;CLOSE FILE
  311.     CALL    FCBDOS
  312.     LD    A,(LOADOPT)    ;Load between markers, or all chars?
  313.     OR    A
  314.     JR    Z,LOAD5A    ;All chars.
  315.     LD    A,(FBEGIN)
  316.     LD    L,A
  317.     LD    H,0
  318.     ADD    HL,HL    ;*2
  319.     ADD    HL,HL    ;*4
  320.     ADD    HL,HL    ;*8
  321.     CALL    ASHL
  322.     PUSH    HL    ;HL=START OFFSET
  323.     PUSH    HL
  324.     LD    C,A
  325.     LD    A,(FEND)
  326.     SUB    C
  327.     INC    A    ;NO. OF CHARS
  328.     LD    L,A
  329.     LD    H,0
  330.     ADD    HL,HL
  331.     ADD    HL,HL
  332.     ADD    HL,HL    ;HL=Number of bytes.
  333.     LD    C,L
  334.     LD    B,H
  335.     POP    DE
  336.     LD    HL,0C000H    ;Calculate destination address.
  337.     ADD    HL,DE
  338.     POP    DE
  339.     PUSH    HL    ;STACKED=DEST ADDR.
  340.     LD    HL,08000H
  341.     ADD    HL,DE    ;HL=SOURCE
  342.     POP    DE
  343.     JR    LOAD5B    ;HL,DE,BC for LDIR
  344. ;
  345. LOAD5A:    LD    HL,08000H
  346.     LD    DE,0C000H    ;Standard HL,DE,BC for entire font.
  347.     LD    BC,1000H
  348. LOAD5B:    LDIR
  349.     CALL    WFONT    ;Write font to memory.
  350.     CALL    PW0
  351.     CALL    ANYKEY    ;Press a key.
  352.     CALL    PRFONT    ;Print font.
  353.     JP    MAINMEN    ;Main menu.
  354. ;
  355. CANLOAD:
  356.     LD    A,' '
  357.     LD    (FCB+1),A    ;Loading cancelled. Set to "No file."
  358.     JP    MAINMEN
  359. ;
  360. LOADERR:
  361.     CP    1
  362.     JP    Z,LOADEOF    ;Error in loading. Read past EOF?
  363.     LD    HL,LEMENU
  364.     CALL    MENU    ;No. Serious error.
  365.     JP    LQUIT1
  366. ;
  367. LOADEOF:
  368.     LD    HL,LFMENU    ;Read past EOF. Not a fatal error; the user
  369.     CALL    MENU    ;can ignore this and load only what there is.
  370.     CALL    CLRMENU
  371.     LD    A,B
  372.     OR    A
  373.     JP    NZ,LQUIT1
  374.     LD    A,C
  375.     CP    2
  376.     JP    Z,LQUIT1
  377.     LD    HL,LFMENU
  378.     CALL    CLRMENU
  379.     JP    LOAD5
  380. ;
  381. LQUIT1:    LD    C,10H    ;Close file and quit.
  382.     CALL    FCBDOS
  383.     LD    HL,LFMENU
  384.     JP    LQUIT
  385. ;
  386. GENLP:    LD    HL,OL3
  387.     LD    (CCB),HL
  388.     LD    HL,11
  389.     LD    (CCB+2),HL    ;Calculate positions of messages.
  390.     LD    A,OL3-OE3-2
  391.     LD    (LMENU+1),A
  392.     DEC    A
  393.     LD    (CATMENU+1),A
  394.     LD    E,OL3-OE3
  395.     RET
  396. ;
  397. LOADPROMPT:
  398.     LD    DE,45    ;PRINT "LOADING" ON TOP LINE
  399.     CALL    PRINAT
  400.     CALL    HIVON
  401.     LD    DE,LOADING
  402.     CALL    PRINT
  403.     LD    DE,0100H    ;Print "Loading file:"
  404.     CALL    PRINAT
  405.     LD    DE,LL1
  406.     CALL    PRINT
  407.     LD    DE,0200H    ;Print "Press EXIT or STOP to cancel" (version dependent)
  408.     CALL    PRINAT
  409.     LD    DE,LL2
  410.     CALL    CHEKPCW
  411.     JP    Z,PRINT
  412.     LD    DE,LL3
  413.     CALL    CHEKPL3
  414.     JP    Z,PRINT
  415.     LD    DE,LL4
  416.     JP    PRINT
  417. ;
  418. PAGE:    CALL    PW0    ;Wait for a key, then clear directory window.
  419.     CALL    ANYKEY
  420.     CALL    DIRCLEAR
  421.     CALL    PW1
  422.     CALL    HIVOFF
  423.     LD    DE,0300H
  424.     CALL    PRINAT
  425.     XOR    A    ;No files printed this page.
  426.     RET
  427. ;
  428. NOFILES:
  429.     LD    HL,NOFMENU    ;No files found.
  430. NOF0:    LD    (HLSTORE),HL
  431. NOF0A:    LD    HL,(HLSTORE)
  432.     CALL    MENU
  433.     DEC    B
  434.     JP    Z,LQUIT
  435.     DEC    B
  436.     JP    Z,LQUIT
  437.     DEC    B    ;CANCEL, EXIT or STOP.
  438.     JP      Z,LQUIT
  439.     DEC    B    ;Input made.
  440.     JP    Z,NOF1    ;In this menu, input must be made for options 1 & 2.
  441.     CP    3    ;Option 3 allows no input; it's "Abandon loading".
  442.     CALL    NZ,BLEEP
  443.     JP    NZ,NOF0A
  444.     PUSH    AF
  445.     JP    LQUIT
  446. ;
  447. NOF1:    POP    AF
  448.     CP    1    ;DIFFERENT DISC.
  449.     JP    NZ,NOF2
  450.     INC    DE
  451.     LD    A,(DE)    ;A=length of input.
  452.     OR    A
  453.     CALL    Z,BLEEP    ;If zero, bleep & ask again.
  454.     JP    Z,NOF0A
  455.     INC    DE
  456.     LD    A,(DE)    ;Get drive letter.
  457.     CALL    UPCASEA
  458.     CP    'A'    ;Drives A..P acceptable.
  459.     CALL    C,BLEEP
  460.     JP    C,NOF0A    ;Ask again.
  461.     CP    'Q'
  462.     CALL    NC,BLEEP
  463.     JP    NC,NOF0A
  464.     CALL    CLRMENU    ;Clear the menu - drive letter acceptable.
  465.     SUB    'A'
  466.     LD    E,A
  467.     CALL    SETDISK
  468.     LD    (CURDISK),A    ;Set disk & store as current disk number.
  469.     JP    LOAD2
  470. ;
  471. NOF2:    INC    DE    ;CHANGE USER NUMBER
  472.     CALL    PARSEUSER
  473.     LD    E,A
  474.     LD    A,2
  475. ;
  476. ; USER NUMBER NOW IN E.
  477. ;
  478.     CALL    C,BLEEP    ;NOT A NUMBER
  479.     JP    C,NOF0A
  480.     LD    C,20H
  481.     LD    D,0    ;Set user number.
  482.     CALL    FDOS
  483.     LD    HL,NOFMENU    ;Clear menu and search this area.
  484.     CALL    CLRMENU
  485.     JP    LOAD2
  486. ;
  487.     DSEG
  488. NOFMENU:
  489.     DEFB    3,0,12H,3
  490.     DEFB    '  No files found  '
  491.     DEFB    'Different Drive:_ D',81H,10H
  492.     DEFB    'Different User:__ U',82H,0FH
  493.     DEFB    'Abandon loading   A',0,0
  494. ;
  495. ;The 81H means input allowed, 1 character max.
  496. ;The 10H is the left offset of the input.
  497. ;
  498. DIFMENU:
  499.     DEFB    3,0,15,2
  500.     DEFB    'Select another '
  501.     DEFB    'Drive:_        D',81H,06H
  502.     DEFB    'User number:__ U',82H,0CH
  503. ASKFMENU:
  504.     DEFB    3,25,30,2
  505.     DEFB    '        Load options          '
  506.     DEFB    'Enter Filename:______________ E',8EH,0FH
  507.     DEFB    'Catalogue a different drive   C',0,0
  508. SCANFAIL:
  509.     DEFB    6,32,16,1
  510.     DEFB    ' File not found '
  511.     DEFB    'Cancel operationC',0,0
  512. CANTOPEN:
  513.     DEFB    6,32,16,1
  514.     DEFB    'Cannot open file'
  515.     DEFB    'Cancel operationC',0,0
  516. LEMENU:
  517.     DEFB    6,32,16,1
  518.     DEFB    '   Read error   '
  519.     DEFB    'Cancel operationC',0,0
  520. LFMENU:
  521.     DEFB    5,28,35,2
  522.     DEFB    '       Unexpected End-of-File      '
  523.     DEFB    'Ignore error and load what there isI',0,0
  524.     DEFB    'Cancel operation                   C',0,0
  525. LOADADD:
  526.     DEFW    08000H    ;Load at 08000H
  527. NUMRECS:
  528.     DEFB    10H
  529. SMENU:    DEFB    3,0,24,2
  530.     DEFB    '       Save options:    '
  531.     DEFB    'Return to main menu     R',0,0
  532.     DEFB    'New name:______________ N',8EH,9
  533.     DEFB    'Use '
  534. SDISK:    DEFB    '_:'
  535. SFILE:    DEFB    '________.'
  536. STYPE:    DEFB    '___      U',0,0
  537. CURDISK:
  538.     DEFB    0
  539.     CSEG
  540. ;
  541. GETDISK:
  542.     PUSH    BC    ;Get current disk drive in A. 0=A: etc.
  543.     PUSH    DE
  544.     PUSH    HL
  545.     LD    C,19H
  546.     CALL    FDOS
  547.     POP    HL
  548.     POP    DE
  549.     POP    BC
  550.     RET
  551. ;
  552. SETDISK:
  553.     PUSH    AF    ;Set drive in E to be current. 0=A: etc.
  554.     PUSH    BC
  555.     PUSH    DE
  556.     PUSH    HL
  557.     LD    C,0EH
  558.     CALL    FDOS
  559.     POP    HL
  560.     POP    DE
  561.     POP    BC
  562.     POP    AF
  563.     RET
  564. ;
  565. ;----
  566. SAVE:
  567. ;----
  568.     CALL    HIVOFF
  569.     CALL    GETDISK
  570.     LD    (CURDISK),A    ;Preserve current drive whilst resetting disks.
  571.     LD    C,0DH
  572.     CALL    FDOS
  573.     LD    A,(CURDISK)
  574.     LD    E,A
  575.     CALL    SETDISK
  576.     CALL    VERPROMPT    ;Usual - un-highlight all options
  577.     CALL    HIVON
  578.     CALL    GENSP    ;Highlight "save"
  579.     LD    D,2
  580.     CALL    PRINAT
  581.     LD    DE,CCB
  582.     CALL    OPCCB    ;Print highlight.
  583.     LD    A,(FCB)
  584.     AND    0FH    ;Calculate drive to save to.
  585.     JP    NZ,SAV0
  586.     CALL    GETDISK    ;Move current file to menu option "Use FILENAME.TYP".
  587.     INC    A
  588. SAV0:    ADD    A,'@'
  589.     LD    (SDISK),A    ;Drive (letter) - put this in the menu option.
  590.     LD    B,8
  591.     LD    HL,FCB+1    ;Move filename to menu option
  592.     LD    DE,SFILE    ;LDIR is not used because all characters
  593. SLOOP1:    LD    A,(HL)    ;are converted to 7-bit on the way.
  594.     RES    7,A
  595.     LD    (DE),A
  596.     INC    HL
  597.     INC    DE
  598.     DJNZ    SLOOP1
  599.     LD    HL,FCB+9
  600.     LD    DE,STYPE    ;Similarly for filetype.
  601.     LD    B,3
  602. SLOOP2:    LD    A,(HL)
  603.     RES    7,A
  604.     LD    (DE),A
  605.     INC    HL
  606.     INC    DE
  607.     DJNZ    SLOOP2
  608.     LD    HL,SMENU+3
  609.     LD    A,(FCB+1)
  610.     CP    ' '    ;DO WE HAVE A CURRENT FILE?
  611.     LD    A,2
  612.     JP    Z,SOK0    ;If there is no current file, alter the number
  613.     LD    A,3    ;of menu options so that the third (use x:filename.typ)
  614. SOK0:    LD    (HL),A    ;does not appear.
  615. SMEN0:    LD    HL,SMENU
  616.     CALL    MENU
  617.     DEC    B
  618.     JR    Z,SQUIT
  619.     DEC    B
  620.     JR    Z,SQUIT    ;EXIT or STOP = abandon, as usual.
  621.     DEC    B
  622.     JR    NZ,SOK1
  623. SQUIT:    CALL    HIVOFF    ;Quit saving.
  624.     CALL    CLRMENU
  625.     JP    MAINMEN
  626. ;
  627. SOK1:    DEC    C    ;Option 1 => abandon.
  628.     JP    Z,SQUIT
  629.     PUSH    AF
  630.     PUSH    DE
  631.     CALL    SAVEPROMPT    ;If saving is confirmed, print the "saving file:" etc.
  632.                 ;into the information lines.
  633. ;
  634. ; CONFIRMED: WE ARE SAVING.
  635. ;
  636.     POP    DE
  637.     POP    AF
  638.     CP    3
  639.     JP    Z,FCBOK    ;If option 3 (use x:filename.typ) was used, we know the
  640.     INC    DE    ;FCB is OK.
  641.     LD    A,(DE)
  642.     LD    C,A    ;Otherwise, a new FCB was input. Parse it.
  643.     LD    B,0
  644.     INC    DE
  645.     PUSH    DE    ;As for "load", put a space at the end of the FCB.
  646.     PUSH    DE
  647.     POP    HL
  648.     ADD    HL,BC    ;HL POINTS TO END OF FILENAME.
  649.     LD    (HL),' '    ;FILENAME DELIMITER
  650.     POP    HL
  651.     LD    (CCB),HL
  652.     LD    HL,FCB
  653.     LD    (CCB+2),HL
  654.     LD    DE,CCB
  655.     LD    C,152    ;PARSE THE FILENAME
  656.     CALL    FDOS
  657.     INC    HL
  658.     LD    A,H
  659.     OR    L
  660.     CALL    Z,BLEEP    ;BAD FILENAME
  661.     JP    Z,SMEN0
  662. FCBOK:    LD    DE,0124H
  663.     CALL    PRINAT    ;Print the FCB at the top of the screen.
  664.     CALL    HIVON
  665.     CALL    OPFCB0
  666.     CALL    HIVOFF
  667.     LD    HL,SMENU
  668.     CALL    CLRMENU
  669.     LD    C,11H    ;SEARCH FOR FILE
  670.     CALL    FCBDOS
  671.     INC    A
  672.     JP    Z,SAVE2    ;If the file doesn't exist, skip this.
  673.     LD    A,1
  674.     LD    HL,FILEXISTS    ;If the file exists, ask for further
  675.     CALL    MENU    ;instructions.
  676.     LD    A,B
  677.     OR    A
  678.     JP    NZ,SQUIT    ;If EXIT, STOP or "Abandon" selected, abandon.
  679.     LD    A,C
  680.     CP    2
  681.     JP    Z,SQUIT
  682.     CALL    CLRMENU
  683.     LD    C,13H    ;Try to delete the file.
  684.     CALL    FCBDOS
  685.     INC    A
  686.     JP    NZ,DEL2    ;OK?
  687. CANTD:    LD    HL,CANTDEL    ;No. File can't be deleted. Print the alert
  688.     CALL    MENU    ;message and leave.
  689.     CALL    CLRMENU
  690.     JP    MAINMEN
  691. ;
  692. DEL2:    LD    HL,FCB+12    ;Blank out the FCB and see if the file
  693.     LD    DE,FCB+13    ;is present on disc.
  694.     LD    BC,22
  695.     LD    (HL),0
  696.     LDIR
  697.     LD    C,11H
  698.     CALL    FCBDOS    ;If it is present, deletion was unsuccessful.
  699.     INC    A
  700.     JP    NZ,CANTD
  701. ;
  702. SAVE2:    CALL    PW1
  703.     LD    D,10H    ;CPC/PCW - 10 recs
  704.     CALL    CHEKPL3
  705.     JR    NZ,SAVE2A    ;+3 - 20 recs
  706.     LD    D,20H
  707. SAVE2A:    LD    A,D
  708.     LD    (NUMRECS),A
  709.     LD    HL,0C000H    ;Save from 0C000H.
  710.     LD    (LOADADD),HL    ;(LOADADD used for economy).
  711.     CALL    RFONT
  712.     LD    HL,FCB+12
  713.     LD    DE,FCB+13    ;Blank the FCB
  714.     LD    BC,22    ;Otherwise, the file may be corrupted.
  715.     LD    (HL),0
  716.     LDIR
  717.     LD    C,16H
  718.     CALL    FCBDOS    ;Create and open the file.
  719.     INC    A
  720.     JP    NZ,SAVE3    ;FILE OPEN?
  721.     LD    HL,CANTMAKE    ;If not, alert and leave.
  722.     CALL    MENU
  723.     CALL    CLRMENU
  724.     JP    MAINMEN
  725. ;
  726. SAVE3:    LD    DE,(LOADADD)
  727.     CALL    SETDMA
  728.     LD    HL,80H    ;Increment DMA.
  729.     ADD    HL,DE
  730.     LD    (LOADADD),HL
  731. ;
  732.     CALL    CON6    ;WAS THERE A KEYPRESS?
  733.     CP    3    ;^C?
  734.     JP    Z,CANSAVE
  735.     CP    1BH    ;EXIT?
  736.     JP    Z,CANSAVE
  737. ;
  738.     LD    C,15H    ;WRITE SEQUENTIAL.
  739.     CALL    FCBDOS
  740.     OR    A
  741.     JP    NZ,SAVERR
  742.     LD    A,(NUMRECS)    ;Count down until finished.
  743.     DEC    A
  744.     LD    (NUMRECS),A
  745.     JR    NZ,SAVE3
  746. ;
  747. ; Font saved successfully
  748. ;
  749. SAVE4:    LD    C,10H    ;CLOSE FILE
  750.     CALL    FCBDOS
  751.     CALL    PW0
  752.     CALL    ANYKEY    ;Press a key; return to main menu.
  753.     JP    MAINMEN
  754. ;
  755. SAVERR:    LD    HL,DISKFULL    ;Error: disk is full.
  756.     CALL    MENU
  757.     CALL    CLRMENU
  758. CANSAVE:
  759.     LD    C,10H
  760.     CALL    FCBDOS    ;Erase partially-saved file.
  761.     LD    C,13H
  762.     CALL    FCBDOS
  763.     JP    MAINMEN
  764. ;
  765. GENSP:    LD    HL,OS3
  766.     LD    (CCB),HL
  767.     LD    HL,11
  768.     LD    (CCB+2),HL    ;Calculate screen addresses for messages
  769.     LD    A,OS3-OE3-3    ;and menus.
  770.     LD    (SMENU+1),A
  771.     DEC    A
  772.     LD    (CATMENU+1),A
  773.     LD    E,OS3-OE3
  774.     RET
  775. ;
  776. SAVEPROMPT:
  777.     LD    DE,45    ;PRINT "SAVING" ON TOP LINE
  778.     CALL    PRINAT
  779.     CALL    HIVON
  780.     LD    DE,SAVING
  781.     CALL    PRINT
  782.     LD    DE,0100H    ;Print "saving file:" on middle line.
  783.     CALL    PRINAT
  784.     LD    DE,SL1
  785.     CALL    PRINT
  786.     LD    DE,0200H
  787.     CALL    PRINAT    ;Print "Press EXIT or STOP to cancel" 
  788.     LD    DE,SL2    ;(machine dependent)
  789.     CALL    CHEKPCW
  790.     JP    Z,PRINT
  791.     CALL    CHEKPL3
  792.     LD    DE,SL3
  793.     JP    Z,PRINT
  794.     LD    DE,SL4
  795.     JP    PRINT
  796. ;
  797.     DSEG
  798. SL1:    DEFB    'Saving character set to file:           '
  799.     DEFB    '                                        $'
  800. SL2:    DEFB    'Press EXIT or STOP to cancel saving     '
  801.     DEFB    '                                        $'
  802. SL3:    DEFB    'Press BREAK or ^C to cancel saving      '
  803.     DEFB    '                                        $'
  804. SL4:    DEFB    'Press ESC or ^C to cancel saving        '
  805.     DEFB    '                                        $'
  806.  
  807. FILEXISTS:
  808.     DEFB    5,32,16,2
  809.     DEFB    '   File exists  '
  810.     DEFB    'Delete it       D',0,0
  811.     DEFB    'Cancel operationC',0,0
  812. SAVING:    DEFB    'Saving.$'
  813. CANTDEL:
  814.     DEFB    6,31,18,1
  815.     DEFB    'Cannot delete file'
  816.     DEFB    'Cancel operation  C',0,0
  817. CANTMAKE:
  818.     DEFB    6,27,26,1
  819.     DEFB    'Directory full or disk R/O'
  820.     DEFB    'Cancel operation          C',0,0
  821. DISKFULL:
  822.     DEFB    6,32,16,1
  823.     DEFB    '    Disk full   '
  824.     DEFB    'Cancel operationC',0,0
  825.  
  826. CHAROK:    DEFB    0    ;Flag: has a character been selected?
  827. MYCHAR:    DEFB    0    ;Current character number.
  828. EDPROMPT:
  829.     DEFB    'Editing.$'
  830. EDSTATUS:
  831. ;                1...5...10...15...20...25...30...35...40
  832.     DEFB    'Editing character no.                  U'
  833.     DEFB    'se cursor keys to move, SPACE set point $'
  834. EDKEYS:    DEFB    '1=Get character '
  835. EDOPT2:    DEFB    '2=Reflect '
  836. EDOPT3:    DEFB    '3=Rotate '
  837. EDOPT4:    DEFB    '4=Move '
  838. EDOPT5:    DEFB    '5=Options '
  839. EDOPT6:    DEFB    'ENTER=Finished '
  840. EDOPT7:    DEFB    'STOP=Abandon $'
  841. EDKPL3:    DEFB    '1=Get character '
  842. EDPL32:    DEFB    '2=Reflect 3=Rotate 4=Move 5=Options ENTER=Finished '
  843. EDPL37:    DEFB    '^C=Abandon   $'
  844. SIZMENU:
  845.     DEFB    3,0,5,2,'Size?LargeL',0,0,'SmallS',0,0
  846. SELMENU:
  847.     DEFB    3,0,21,4
  848.     DEFB    '  Make selection by  '
  849.     DEFB    'Typing Character:_   T',81H,11H
  850.     DEFB    'ASCII number:___     A',83H,0DH
  851.     DEFB    'From characters chartF',0,0
  852.     DEFB    'OK - Continue        O',0,0
  853. SELM1:    DEFB    3,0,21,4
  854.     DEFB    ' Select character by '
  855.     DEFB    'Typing Character:'
  856. SELMT:    DEFB    '_   T',81H,11H
  857.     DEFB    'ASCII number:'
  858. SELMA:    DEFB    '___     A',83H,0DH
  859.     DEFB    'From characters chartF',0,0
  860.     DEFB    'OK - Continue        O',0,0
  861. EDSTO:    DEFW    0    ;Stack pointer store while editing.
  862. EDWIDE:    DEFB    0    ;Width of character being edited (bits).
  863.     CSEG
  864. ;
  865. EDIT:    LD    (EDSTO),SP    ;Stack pointer
  866.     XOR    A
  867.     LD    (SIZMENU+1),A    ;Character size menu appears at LH edge for editing.
  868.     LD    (CHAROK),A    ;No current satisfactory character.
  869.     LD    DE,45
  870.     CALL    PRINAT    ;Print "Editing" on top line.
  871.     CALL    HIVON
  872.     LD    DE,EDPROMPT
  873.     CALL    PRINT
  874.     LD    DE,0100H    ;Status line ("Editing character no. xx" etc.)
  875.     CALL    PRINAT
  876.     LD    DE,EDSTATUS
  877.     CALL    PRINT
  878.     CALL    HIVOFF
  879.     CALL    VERPROMPT
  880.     LD    DE,0200H
  881.     CALL    PRINAT    ;For 3rd line, print "E=Edit" inverse, others not
  882.     CALL    HIVON    ;(as usual).
  883.     LD    HL,17
  884.     LD    (CCB+2),HL
  885.     LD    HL,OE3
  886.     LD    (CCB),HL
  887.     LD    DE,CCB
  888.     CALL    OPCCB
  889.     CALL    CHEKPL3
  890.     JP    NZ,ED2
  891.     LD    HL,SIZMENU    ;If using a +3, ask which character size to use.
  892.     CALL    MENU
  893.     CALL    CLRMENU
  894.     LD    A,B
  895.     OR    A
  896.     JR    Z,ED1
  897. EQUIT:    CALL    DIRCLEAR    ;Abandon edit; redraw font.
  898.     CALL    IFP3BIG
  899.     CALL    Z,EMPBOX
  900.     CALL    PRFONT
  901.     LD    SP,(EDSTO)    ;Retrieve SP.
  902.     JP    MAINMEN
  903. ;
  904. ED1:    LD    A,C
  905.     DEC    A    ;SMALL =>A=1 ELSE A=0
  906.     ADD    A,A    ;A=A*2
  907.     ADD    A,A    ;A=A*4
  908.     ADD    A,A    ;A=A*8
  909.     ADD    A,30H    ;A=PL3 SET NO.
  910.     LD    (PL3SET),A
  911. ;
  912. ED2:    CALL    GETCHNO    ;Get character number in MYCHAR.
  913.     JP    NC,EQUIT
  914.     CALL    DIRCLEAR
  915.     LD    A,(MYCHAR)    ;CHARACTER NUMBER
  916.     CALL    CHARGET
  917.     CALL    CHARBAK    ;Back up current pattern.
  918.     CALL    HIVON
  919.     CALL    EDVPR    ;Print editing keys on bottom line.
  920.     LD    DE,0116H
  921.     CALL    PRINAT
  922.     LD    A,(MYCHAR)    ;Print character number on info. lines.
  923.     CALL    OPINT
  924.     LD    A,8
  925.     LD    (EDWIDE),A    ;WIDTH OF CHARACTER. 8 FOR NORMAL, 5 FOR MINI +3
  926.     CALL    CHEKPL3
  927.     JR    NZ,ED3
  928.     LD    A,(PL3SET)
  929.     CP    30H
  930.     JR    Z,ED3
  931.     LD    A,5
  932.     LD    (EDWIDE),A
  933. ED3:    CALL    CHEKPL3
  934.     JR    NZ,ED5    ;If not using a +3, skip this.
  935.     LD    E,' '    ;Else, print on the information line
  936.     CALL    OPCHAR    ;which size of character (large/small) is being used.
  937.     LD    DE,LSM    ;"Large size"
  938.     LD    A,(EDWIDE)
  939.     CP    8
  940.     CALL    Z,PRINT
  941.     LD    DE,SSM    ;"Small size"
  942.     CALL    NZ,PRINT
  943. ED5:    CALL    EDDRAW    ;Draw edit windows
  944.     CALL    IMAGBOX
  945.     XOR    A
  946.     LD    (EDX),A    ;Set edit cursor to 0,0.
  947.     LD    (EDY),A
  948.     CALL    REDRAW    ;REDRAW redraws the contents (only) of both windows.
  949. EDLOOP:            ;There is a similar subroutine REMAKE which redraws both
  950.             ;the windows and their contents.
  951.  
  952.     CALL    PLCUR    ;Place edit cursor.
  953.     CALL    CON6
  954.     OR    A    ;Wait for keypress.
  955.     JR    Z,EDLOOP
  956.     CP    UA    ;Up.
  957.     JP    Z,EDUP
  958.     CP    DA    ;Down.
  959.     JP    Z,EDDOWN
  960.     CP    LA    ;Left.
  961.     JP    Z,EDLT
  962.     CP    RA    ;Right.
  963.     JP    Z,EDRT
  964.     CP    ' '    ;Flip a dot.
  965.     JP    Z,EDDOT
  966.     CP    03H    ;STOP (abandon)
  967.     JP    Z,EQUIT1
  968.     CP    0DH    ;ENTER (finished)
  969.     JP    Z,EFIN1
  970.     CP    '1'    ;1=Get character
  971.     JP    Z,OPTION1
  972.     CP    '2'    ;2=Reflect
  973.     JP    Z,OPTION2
  974.     CP    '3'    ;3=Rotate
  975.     JP    Z,OPTION3
  976.     CP    '4'    ;4=Move
  977.     JP    Z,OPTION4
  978.     CP    '5'    ;5=Options.
  979.     JP    Z,OPTION5
  980.     JP    EDLOOP    ;Others ignored.
  981. ;
  982. EDDOT:    CALL    BW    ;BW - get current dot in Carry flag.
  983.     JP    C,RESDOT
  984. SETDOT:    CALL    BW0    ;Get dot position in byte.
  985.     LD    B,A    ;C=byte, rotated so the bit has rotated off the left.
  986.     INC    B    ;B=position for DOTPUT.
  987.     SCF        ;Carry=desired status.
  988. DOTPUT:    EX    AF,AF'
  989. DP1:    EX    AF,AF'
  990.     RR    C    ;Using AF' for all other purposes, and
  991.     EX    AF,AF'    ;only bringing in AF for the actual rotation.
  992.     DJNZ    DP1
  993.     LD    (HL),C    ;Save byte.
  994.     LD    A,(MYCHAR)
  995.     CALL    CHARPUT    ;Reprint the character
  996.     CALL    REDRAW
  997.     JP    EDLOOP
  998. ;
  999. RESDOT:    CALL    BW0
  1000.     LD    B,A    ;As SETDOT, but carry flag clear.
  1001.     INC    B
  1002.     SCF
  1003.     CCF
  1004.     JR    DOTPUT
  1005. ;
  1006. BW:    PUSH    BC    ;Check if current bit is black or white.
  1007.     PUSH    DE
  1008.     PUSH    HL
  1009.     CALL    BW0
  1010.     POP    HL
  1011.     POP    DE
  1012.     POP    BC
  1013.     RET
  1014.  
  1015. BW0:    LD    A,(EDY)
  1016.     LD    E,A
  1017.     LD    D,0
  1018.     LD    HL,CHARBUF    ;DE=Y offset.
  1019.     ADD    HL,DE
  1020.     LD    C,(HL)
  1021.     LD    A,(EDX)
  1022.     LD    B,A    ;B=X offset.
  1023.     INC    B
  1024.     EX    AF,AF'
  1025. BW1:    EX    AF,AF'    ;Rotate bit into carry flag, using
  1026.     RL    C    ;AF' for flagging the DJNZ.
  1027.     EX    AF,AF'
  1028.     DJNZ    BW1
  1029.     EX    AF,AF'
  1030.     RET        ;THE BIT WE WANT IS IN THE CARRY FLAG.
  1031. ;
  1032. EDUP:    LD    A,(EDY)    ;Move up. If at top line, ignore.
  1033.     OR    A
  1034.     JP    Z,EDLOOP
  1035.     PUSH    AF
  1036.     CALL    UNPLCUR    ;Remove cursor.
  1037.     POP    AF
  1038.     DEC    A
  1039.     LD    (EDY),A    ;Replace cursor.
  1040.     CALL    PLCUR
  1041.     JP    EDLOOP
  1042. ;
  1043. EDDOWN:    LD    A,(EDY)    ;As EDUP, but down.
  1044.     CP    7
  1045.     JP    Z,EDLOOP
  1046.     PUSH    AF
  1047.     CALL    UNPLCUR
  1048.     POP    AF
  1049.     INC    A
  1050.     LD    (EDY),A
  1051.     CALL    PLCUR
  1052.     JP    EDLOOP
  1053. ;
  1054. EDLT:    LD    A,(EDX)    ;Left.
  1055.     OR    A
  1056.     JP    Z,EDLOOP
  1057.     PUSH    AF
  1058.     CALL    UNPLCUR
  1059.     POP    AF
  1060.     DEC    A
  1061.     LD    (EDX),A
  1062.     CALL    PLCUR
  1063.     JP    EDLOOP
  1064. ;
  1065. EDRT:    LD    A,(EDWIDE)    ;As EDLT, but right. Since the char. is
  1066.     LD    B,A    ;either 5 bit or 8 bit, a fixed comparison
  1067.     DEC    B    ;can't be used; the max. value is held in B.
  1068.     LD    A,(EDX)
  1069.     CP    B
  1070.     JP    NC,EDLOOP
  1071.     PUSH    AF
  1072.     CALL    UNPLCUR
  1073.     POP    AF
  1074.     INC    A
  1075.     LD    (EDX),A
  1076.     CALL    PLCUR
  1077.     JP    EDLOOP
  1078. ;
  1079. PLCUR:    LD    A,(EDX)    ;Place the edit cursor.
  1080.     LD    E,1FH
  1081.     ADD    A,E
  1082.     LD    E,A    ;Add X & Y offsets to convert cursor
  1083.     LD    A,(EDY)    ;coordinates into screen coordinates.
  1084.     LD    D,05H
  1085.     ADD    A,D
  1086.     LD    D,A
  1087.     CALL    PRINAT
  1088.     CALL    BW    ;Is the cursor on a black or white dot?
  1089.     JP    CURDOT    ;Print cursor at current screen coordinates.
  1090. ;
  1091. UNPLCUR:
  1092.     CALL    PLCUR    ;Move to current cursor coordinates
  1093.     LD    E,8    ;Backspace
  1094.     CALL    OPCHAR
  1095.     CALL    BW    ;Overprint with a dot.
  1096.     JP    DOT
  1097. ;
  1098. OPTION1:
  1099.     CALL    HIVOFF    ;Option 1 - get character.
  1100.     LD    DE,0200H+EDOPT2-EDKEYS
  1101.     CALL    PRINAT
  1102.     CALL    CHEKPCW    ;Do the usual highlighting business.
  1103.     LD    DE,EDOPT2
  1104.     CALL    Z,PRINT    ;This time, reprint the rest of the line
  1105.     LD    DE,EDPL32    ;in true video, since 1=Get character is at
  1106.     CALL    NZ,PRINT    ;the beginning.
  1107.     LD    A,(MYCHAR)
  1108.     LD    (TEMPCHR),A    ;Save current character number.
  1109.     CALL    GETCHNO
  1110.     LD    HL,SELM1    ;Get character number
  1111.     CALL    CLRMENU        ;Clear number selection menu.
  1112.     JR    NC,ENDOPT1    ;If abandoned, go back to edit.
  1113.     LD    A,(MYCHAR)    ;Get pattern of new char.
  1114.     CALL    CHARGET
  1115. ENDOPT1:
  1116.     LD    A,(TEMPCHR)
  1117.     LD    (MYCHAR),A    ;Restore true number.
  1118. ENDOPT:    LD    A,(MYCHAR)    ;Move current pattern to font & redraw.
  1119.     CALL    CHARPUT
  1120.     CALL    REDRAW
  1121.     CALL    HIVON
  1122.     CALL    EDVPR    ;Information lines back in inverse video.
  1123.     JP    EDLOOP
  1124. ;
  1125.     DSEG
  1126. TEMPCHR:
  1127.     DEFB    0    ;Temporary byte store.
  1128.     CSEG
  1129. ;
  1130. OPTION2:
  1131.     CALL    HIVOFF    ;Reflect, almost exactly as WHREFLECT.
  1132.     CALL    EDVPR
  1133.     CALL    HIVON
  1134.     LD    HL,EDOPT2
  1135.     LD    (CCB),HL
  1136.     LD    HL,9
  1137.     LD    (CCB+2),HL
  1138.     LD    DE,0200H+EDOPT2-EDKEYS
  1139.     CALL    PRINAT
  1140.     LD    DE,CCB
  1141.     CALL    OPCCB
  1142.     LD    A,13
  1143.     LD    (OPT2MENU+1),A
  1144.     LD    A,1
  1145.     LD    HL,OPT2MENU
  1146.     CALL    MENU
  1147.     CALL    CLRMENU
  1148.     LD    A,B
  1149.     OR    A
  1150.     JP    NZ,EF2
  1151.     LD    A,C
  1152.     CP    1
  1153.     JP    NZ,OPT2MV
  1154.     CALL    REFH    ;Just CALL, because only one character.
  1155.     JP    ENDOPT
  1156. ;
  1157. OPT2MV:    CALL    REFV
  1158.     JP    ENDOPT
  1159. ;
  1160. REFH:    LD    HL,CHARBUF    ;REFLECT CHAR. HORIZONTALLY
  1161.     LD    E,8
  1162. OPT2L1:    LD    B,8
  1163.     LD    A,(HL)
  1164. OPT2L2:    RRA        ;MIRROR A BYTE
  1165.     RL    C
  1166.     DJNZ    OPT2L2
  1167.     LD    A,(EDWIDE)
  1168.     CP    5
  1169.     JR    NZ,OPT2J1
  1170.     RL    C
  1171.     RL    C    ;Compensate for 5-bit chars.
  1172.     RL    C
  1173. OPT2J1:    LD    (HL),C
  1174.     INC    HL
  1175.     DEC    E
  1176.     JR    NZ,OPT2L1
  1177.     RET
  1178. ;
  1179. REFV:    LD    DE,CHARBUF    ;Reflect vertically.
  1180.     LD    HL,CHARBUF+7
  1181.     LD    B,4
  1182. OPT2L3:    LD    C,(HL)
  1183.     LD    A,(DE)
  1184.     LD    (HL),A
  1185.     LD    A,C
  1186.     LD    (DE),A
  1187.     DEC    HL
  1188.     INC    DE
  1189.     DJNZ    OPT2L3
  1190.     RET
  1191. ;
  1192.     DSEG
  1193. OPT2MENU:
  1194.     DEFB    3,13,12,2
  1195.     DEFB    ' Reflection '
  1196.     DEFB    'HorizontallyH',0,0
  1197.     DEFB    'Vertically  V',0,0
  1198. OPT3MENU:
  1199.     DEFB    3,22,13,2
  1200.     DEFB    '  Rotation   '
  1201.     DEFB    'Clockwise    C',0,0
  1202.     DEFB    'AnticlockwiseA',0,0
  1203. OPT4MENU:
  1204.     DEFB    3,32,5,4
  1205.     DEFB    'Move:'
  1206.     DEFB    'Up   U',0,0
  1207.     DEFB    'Down D',0,0
  1208.     DEFB    'Left L',0,0
  1209.     DEFB    'RightR',0,0
  1210. OPT5MENU:
  1211.     DEFB    3,38,17,7
  1212.     DEFB    '  Miscellaneous  '
  1213.     DEFB    'Invert           I',0,0
  1214.     DEFB    'Preset patterns  P',0,0
  1215.     DEFB    'Scratchpad       S',0,0
  1216.     DEFB    'Bold             B',0,0
  1217.     DEFB    'Doublestrike     D',0,0
  1218.     DEFB    'Italic           T',0,0
  1219.     DEFB    'Outline          O',0,0
  1220. OPT5M1:    DEFB    3,38,17,5
  1221.     DEFB    ' Preset patterns '
  1222.     DEFB    'Blank            B',0,0
  1223.     DEFB    'Grey             G',0,0
  1224.     DEFB    'AND speckled     A',0,0
  1225.     DEFB    'OR speckled      O',0,0
  1226.     DEFB    'XOR speckled     X',0,0
  1227. OPT5M2:    DEFB    3,38,18,2
  1228.     DEFB    ' Scratchpad empty '
  1229.     DEFB    'Save to pad       S',0,0
  1230.     DEFB    'Quit              Q',0,0
  1231. OPT5M3:    DEFB    3,38,18,6
  1232.     DEFB    ' Scratchpad menu  '
  1233.     DEFB    'Save to pad       S',0,0
  1234.     DEFB    'Restore from pad  R',0,0
  1235.     DEFB    'AND with pad      A',0,0
  1236.     DEFB    'OR with pad       O',0,0
  1237.     DEFB    'XOR with pad      X',0,0
  1238.     DEFB    'Empty pad         E',0,0
  1239.     CSEG
  1240. ;
  1241. OPTION3:
  1242.     CALL    HIVOFF    ;As WHROTATE, for a single character.
  1243.     CALL    EDVPR
  1244.     CALL    HIVON
  1245.     LD    HL,EDOPT3
  1246.     LD    (CCB),HL
  1247.     LD    HL,8
  1248.     LD    (CCB+2),HL
  1249.     LD    DE,0200H+EDOPT3-EDKEYS
  1250.     CALL    PRINAT
  1251.     LD    DE,CCB
  1252.     CALL    OPCCB
  1253.     LD    A,(EDWIDE)
  1254.     CP    5
  1255.     JP    Z,OPT3X5
  1256.     LD    A,22
  1257.     LD    (OPT3MENU+1),A
  1258.     LD    A,1
  1259.     LD    HL,OPT3MENU
  1260.     CALL    MENU
  1261.     CALL    CLRMENU
  1262.     LD    A,B
  1263.     OR    A
  1264.     JP    NZ,REMAKE
  1265.     DEC    C
  1266.     JP    Z,CLOCK
  1267.     CALL    ANTI
  1268.     JP    REMAKE
  1269. ;
  1270. ;ROTATE ANTICLOCKWISE.
  1271.     DSEG
  1272. DESTBUF:
  1273.     DEFS    8
  1274.     CSEG
  1275. ;
  1276. ANTI:    LD    C,8    ;Rotate into a destination area.
  1277.     LD    DE,DESTBUF
  1278. ACL0:    LD    HL,CHARBUF
  1279.     LD    B,8
  1280. ACL1:    RR    (HL)    ;TOPMOST BIT IN CARRY
  1281.     RLA        ;MOVE TO A
  1282.     INC    HL
  1283.     DJNZ    ACL1    ;Take the topmost bit from each byte, and
  1284.     LD    (DE),A    ;send it all to one byte. Put this in the
  1285.     INC    DE    ;destination buffer, and repeat with the
  1286.     DEC    C    ;new topmost bits.
  1287.     JR    NZ,ACL0
  1288. ENDACL:    LD    DE,CHARBUF
  1289.     LD    HL,DESTBUF    ;Move back to character pattern area.
  1290.     LD    BC,8
  1291.     LDIR
  1292.     RET
  1293. ;
  1294. CLOCK:    CALL    CLOCKWISE    ;Rotate clockwise.
  1295.     JP    REMAKE    ;REMAKE not REDRAW because the clockwise/anticlockwise menu
  1296.             ;impinges upon the edit window.
  1297. ;
  1298. CLOCKWISE:
  1299.     LD    C,8
  1300.     LD    DE,DESTBUF+7
  1301. CL0:    LD    HL,CHARBUF
  1302.     LD    B,8
  1303. CL1:    RR    (HL)    ;LOWEST BIT IN CARRY
  1304.     RRA        ;MOVE TO A
  1305.     INC    HL
  1306.     DJNZ    CL1    ;As ANTI, but the other way.
  1307.     LD    (DE),A
  1308.     DEC    DE
  1309.     DEC    C
  1310.     JR    NZ,CL0
  1311.     JR    ENDACL
  1312. ;
  1313. OPT3X5:    CALL    REFV    ;"Rotate" for 5x8 character.
  1314.     CALL    REFH
  1315.     JP    REMAKE
  1316. ;
  1317. OPTION4:
  1318.     CALL    HIVOFF    ;Move. As for WHMOVE.
  1319.     CALL    EDVPR
  1320.     CALL    HIVON
  1321.     LD    HL,EDOPT4
  1322.     LD    (CCB),HL
  1323.     LD    HL,6
  1324.     LD    (CCB+2),HL
  1325.     LD    DE,0200H+EDOPT4-EDKEYS
  1326.     CALL    PRINAT
  1327.     LD    DE,CCB
  1328.     CALL    OPCCB
  1329.     LD    A,1
  1330.     LD    HL,OPT4MENU
  1331.     CALL    MENU
  1332.     CALL    CLRMENU
  1333.     LD    A,B
  1334.     OR    A
  1335.     JP    NZ,REMAKE
  1336.     DEC    C
  1337.     JP    Z,MOVUP
  1338.     DEC    C
  1339.     JP    Z,MOVDN    ;DOWN
  1340.     DEC    C
  1341.     JP    Z,MOVLT    ;LEFT
  1342.     CALL    MRT
  1343.     JP    REMAKE
  1344. ;
  1345. MRT:    LD    A,(EDWIDE)
  1346.     CP    5
  1347.     JP    Z,MOVRT5
  1348.     LD    B,8
  1349.     LD    HL,CHARBUF
  1350. MOVRT1:    RRC    (HL)    ;For 8-bits
  1351.     INC    HL
  1352.     DJNZ    MOVRT1
  1353.     RET
  1354. ;
  1355. MOVRT5:    LD    B,8
  1356.     LD    HL,CHARBUF    ;for 5-bits.
  1357. MOVRT6:    LD    A,(HL)
  1358.     LD    C,A    ;C IS 7,6,5,4,3,-,-,-
  1359.     SRL    C    ;C IS -,7,6,5,4,3,-,-
  1360.     SRL    C    ;C IS -,-,7,6,5,4,3,-
  1361.     SRL    C    ;C IS -,-,-,7,6,5,4,3
  1362.     SRL    C    ;C IS -,-,-,-,7,6,5,4   3 IN CARRY
  1363.     RR    A    ;A IS 3,7,6,5,4,3,-,-
  1364.     LD    (HL),A
  1365.     INC    HL
  1366.     DJNZ    MOVRT6
  1367.     RET
  1368. ;
  1369. MOVUP:    CALL    MUP
  1370.     JP    REMAKE
  1371. ;
  1372. MUP:    LD    A,(CHARBUF)    ;Move up.
  1373.     PUSH    AF
  1374.     LD    BC,7
  1375.     LD    HL,CHARBUF+1
  1376.     LD    DE,CHARBUF
  1377.     LDIR
  1378.     POP    AF
  1379.     LD    (CHARBUF+7),A
  1380.     RET
  1381. ;
  1382. MOVDN:    CALL    MDN
  1383.     JP    REMAKE
  1384. ;
  1385. MDN:    LD    A,(CHARBUF+7)    ;Move down.
  1386.     PUSH    AF
  1387.     LD    BC,7
  1388.     LD    HL,CHARBUF+6
  1389.     LD    DE,CHARBUF+7
  1390.     LDDR
  1391.     POP    AF
  1392.     LD    (CHARBUF),A
  1393.     RET
  1394. ;
  1395. MOVLT:    CALL    MLT
  1396.     JP    REMAKE
  1397. ;
  1398. MLT:    LD    A,(EDWIDE)
  1399.     CP    5
  1400.     JP    Z,MOVLT5
  1401.     LD    B,8
  1402.     LD    HL,CHARBUF    ;Move left 8 bits.
  1403. MOVLT1:    RLC    (HL)
  1404.     INC    HL
  1405.     DJNZ    MOVLT1
  1406.      RET
  1407. ;
  1408. MOVLT5:    LD    B,8
  1409.     LD    HL,CHARBUF
  1410. MOVLT6:    LD    A,(HL)    ;Move left 5 bits.
  1411.     LD    C,A
  1412.     SRL    C    ;C IS -,7,6,5,4,3,-,-
  1413.     SRL    C    ;C IS -,-,7,6,5,4,3,-
  1414.     SRL    C    ;C IS -,-,-,7,6,5,4,3
  1415.     RL    A    ;BIT 7 IS NOW IN CARRY FLAG.
  1416.     RL    C    ;C IS -,-,7,6,5,4,3,7
  1417.     SLA    C    ;C IS -,7,6,5,4,3,7,-
  1418.     SLA    C    ;C IS 7,6,5,4,3,7,-,-
  1419.     SLA    C    ;C IS 6,5,4,3,7,-,-,-
  1420.     LD    (HL),C
  1421.     INC    HL
  1422.     DJNZ    MOVLT6
  1423.     RET
  1424. ;
  1425. OPTION5:
  1426.     CALL    HIVOFF    ;Miscellaneous options
  1427.     CALL    EDVPR    ;as WHOPT.
  1428.     CALL    HIVON
  1429.     LD    HL,EDOPT5
  1430.     LD    (CCB),HL
  1431.     LD    HL,9
  1432.     LD    (CCB+2),HL
  1433.     LD    DE,0200H+EDOPT5-EDKEYS
  1434.     CALL    PRINAT
  1435.     LD    DE,CCB
  1436.     CALL    OPCCB
  1437. OPT5X1:    LD    A,1
  1438.     LD    HL,OPT5MENU
  1439.     CALL    MENU
  1440.     CALL    CLRMENU
  1441.     LD    A,B
  1442.     OR    A
  1443.     JP    NZ,REMAKE
  1444.     LD    A,C
  1445.     CP    1
  1446.     JR    Z,OPT5A
  1447.     CP    4
  1448.     JR    Z,OPT5BLD
  1449.     CP    5
  1450.     JR    Z,OPT5DBL
  1451.     CP    6
  1452.     JR    Z,OPT5ITA
  1453.     CP    7
  1454.     JR    Z,OPT5OUT
  1455.     CP    2
  1456.     JP    NZ,OPT5C
  1457.     LD    HL,OPT5M1
  1458.     LD    A,1
  1459.     CALL    MENU
  1460.     CALL    CLRMENU
  1461.     LD    A,B
  1462.     OR    A
  1463.     JR    NZ,OPT5X1
  1464.     LD    A,C
  1465.     CP    1
  1466.     JP    NZ,OPT5D
  1467.     CALL    WHBLANK
  1468. REMAKE:    CALL    EDDRAW
  1469.     CALL    IMAGBOX
  1470.     JP    ENDOPT
  1471. ;
  1472. OPT5A:    CALL    INVBUF
  1473.     JR    REMAKE
  1474. ;
  1475. OPT5BLD:    CALL    BLDBUF
  1476.     JR    REMAKE
  1477. ;
  1478. OPT5DBL:    CALL    DBLBUF
  1479.     JR    REMAKE
  1480. ;
  1481. OPT5ITA:    CALL    ITABUF
  1482.     JR    REMAKE
  1483. ;
  1484. OPT5OUT:    CALL    OUTBUF
  1485.     JR    REMAKE
  1486. ;
  1487. INVBUF:    LD    B,8
  1488.     LD    HL,CHARBUF
  1489. OPT5B:    LD    A,(HL)
  1490.     CPL
  1491.     LD    (HL),A
  1492.     INC    HL
  1493.     DJNZ    OPT5B
  1494.     RET
  1495. ;
  1496. BLDBUF:    LD    HL,CHARBUF
  1497.     LD    B,8
  1498. BLDB1:    LD    A,(HL)
  1499.     SRL    A
  1500.     OR    (HL)
  1501.     LD    (HL),A
  1502.     INC    HL
  1503.     DJNZ    BLDB1
  1504.     RET
  1505. ;
  1506. DBLBUF:    LD    HL,CHARBUF
  1507.     LD    B,7
  1508.     LD    C,(HL)
  1509.     INC    HL
  1510. DBLB1:    LD    A,(HL)
  1511.     OR    C
  1512.     LD    C,(HL)
  1513.     LD    (HL),A
  1514.     INC    HL
  1515.     DJNZ    DBLB1
  1516.     RET
  1517. ;
  1518.  
  1519. ITABUF:    LD    A,(EDWIDE)
  1520.     CP    5
  1521.     CALL    Z,PRUNE5
  1522.     LD    HL,CHARBUF
  1523.     SRL    (HL)
  1524.     SRL    (HL)
  1525.     INC    HL
  1526.     SRL    (HL)
  1527.     INC    HL
  1528.     SRL    (HL)
  1529.     INC    HL
  1530.     INC    HL
  1531.     INC    HL
  1532.     SLA    (HL)
  1533.     INC    HL
  1534.     SLA    (HL)
  1535.     INC    HL
  1536.     SLA    (HL)
  1537.     SLA    (HL)
  1538.     RET
  1539.  
  1540. OUTBUF:    LD    HL,CHARBUF
  1541.     LD    DE,OUTPAD
  1542.     LD    BC,8
  1543.     LDIR
  1544.     XOR    A
  1545.     LD    (CHARBUF),A
  1546.     CALL    MUP
  1547.     LD    HL,CHARBUF
  1548.     LD    B,8
  1549. OUTBUF1:    SLA    (HL)
  1550.     INC    HL
  1551.     DJNZ    OUTBUF1
  1552.     CALL    BLDBUF
  1553.     CALL    BLDBUF
  1554.     CALL    DBLBUF
  1555.     CALL    DBLBUF
  1556.     LD    HL,OUTPAD
  1557.     LD    DE,CHARBUF
  1558.     CALL    BUFXOR
  1559.     RET
  1560.  
  1561.     DSEG
  1562. OUTPAD:    DEFS    8
  1563.     CSEG
  1564. ;
  1565. PRUNE5:    LD    HL,CHARBUF
  1566.     LD    B,8
  1567. PRUNE6:    LD    A,(HL)
  1568.     AND    0F8H
  1569.     LD    (HL),A
  1570.     INC    HL
  1571.     DJNZ    PRUNE5
  1572.     RET
  1573. ;
  1574. OPT5C:    LD    A,(PADFLG)
  1575.     OR    A    ;0=> PAD IN USE
  1576.     JR    Z,OPT5C1
  1577.     LD    HL,OPT5M2
  1578.     LD    A,1
  1579.     CALL    MENU
  1580.     CALL    CLRMENU
  1581.     LD    A,B
  1582.     OR    A
  1583.     JP    NZ,OPT5X1
  1584.     DEC    C
  1585.     JP    NZ,OPT5X1
  1586. OPT5C0:    CALL    PADSAV
  1587.     XOR    A
  1588.     LD    (PADFLG),A
  1589.     JP    REMAKE
  1590. ;
  1591. OPT5C1:    LD    HL,OPT5M3
  1592.     LD    A,1
  1593.     CALL    MENU
  1594.     CALL    CLRMENU
  1595.     LD    A,B
  1596.     OR    A
  1597.     JP    NZ,OPT5X1
  1598.     LD    A,C
  1599.     CP    1
  1600.     JR    Z,OPT5C0
  1601.     LD    HL,REMAKE
  1602.     PUSH    HL
  1603.     CP    2
  1604.     JP    Z,PADRES
  1605.     LD    HL,PAD
  1606.     LD    DE,CHARBUF
  1607.     CP    3
  1608.     JP    Z,BUFAND
  1609.     CP    4
  1610.     JP    Z,BUFOR
  1611.     CP    5
  1612.     JP    Z,BUFXOR
  1613.     XOR    A
  1614.     INC    A
  1615.     LD    (PADFLG),A
  1616.     RET
  1617. ;
  1618. OPT5D:    LD    HL,REMAKE
  1619.     PUSH    HL
  1620.     LD    HL,SPECBUF
  1621.     LD    DE,CHARBUF
  1622.     CP    3
  1623.     JP    Z,BUFAND
  1624.     CP    4
  1625.     JP    Z,BUFOR
  1626.     CP    5
  1627.     JP    Z,BUFXOR
  1628.     LD    BC,8
  1629.     LDIR
  1630.     RET
  1631. ;
  1632.     DSEG    ;Bitmap for speckled pattern.
  1633. SPECBUF:
  1634.     DEFB    85,170,85,170,85,170,85,170
  1635.     CSEG
  1636. ;
  1637. BUFAND:    LD    A,0A6H    ;Code for AND (HL)
  1638.     JR    BUFGEN
  1639. ;
  1640. BUFOR:    LD    A,0B6H    ;Code for OR (HL)
  1641. BUFGEN:    LD    (ORAD),A
  1642.     LD    B,8
  1643. BUFG1:    LD    A,(DE)
  1644. ORAD:    OR    (HL)    ;Code changes depending on routine.
  1645.     LD    (DE),A
  1646.     INC    HL
  1647.     INC    DE
  1648.     DJNZ    BUFG1
  1649.     RET
  1650. ;
  1651. BUFXOR:    LD    A,0AEH    ;Code for XOR (HL)
  1652.     JR    BUFGEN
  1653. ;
  1654. FNTAND:    LD    A,0A6H    ;As BUFAND, BUFOR, BUFXOR but on the
  1655.     JR    FNTGEN    ;entire font.
  1656. ;
  1657. FNTOR:    LD    A,0B6H
  1658.     JR    FNTGEN
  1659. ;
  1660. FNTXOR:    LD    A,0AEH
  1661. FNTGEN:    LD    (XORAD),A
  1662.     LD    BC,800H
  1663.     LD    DE,0C000H    ;Font
  1664.     LD    HL,08800H    ;Font scratchpad
  1665. FNTG1:    LD    A,(DE)
  1666. XORAD:    XOR    (HL)
  1667.     LD    (DE),A
  1668.     INC    HL
  1669.     INC    DE
  1670.     DEC    BC
  1671.     LD    A,B
  1672.     OR    C
  1673.     JR    NZ,FNTG1
  1674.     JP    WHMAKE    ;REMAKE, for whole font options.
  1675. ;
  1676. EDVPR:    PUSH    AF    ;Draw machine-dependent key listing.
  1677.     PUSH    DE
  1678.     LD    DE,0200H
  1679.     CALL    PRINAT
  1680.     CALL    CHEKPCW
  1681.     LD    DE,EDKEYS    ;PCW version.
  1682.     CALL    Z,PRINT
  1683.     LD    DE,EDKPL3    ;Other version.
  1684.     CALL    NZ,PRINT
  1685.     POP    DE
  1686.     POP    AF
  1687.     RET
  1688. ;
  1689. REDRAW:    PUSH    AF    ;Redraw contents of windows.
  1690.     PUSH    BC
  1691.     PUSH    DE
  1692.     PUSH    HL
  1693.     LD    DE,051FH    ;Coordinates of edit window.
  1694.     PUSH    DE
  1695.     LD    C,8    ;Height of window
  1696.     LD    HL,CHARBUF
  1697. REDR1:    POP    DE
  1698.     CALL    PRINAT
  1699.     INC    D
  1700.     PUSH    DE
  1701.     LD    A,(EDWIDE)    ;Width of window.
  1702.     LD    B,A
  1703.     LD    A,(HL)    ;Current byte.
  1704.     INC    HL
  1705. REDR2:    RLA        ;Current bit.
  1706.     CALL    DOT    ;Draw it.
  1707.     DJNZ    REDR2
  1708.     DEC    C
  1709.     JR    NZ,REDR1
  1710.     POP    DE
  1711.     CALL    HIVOFF
  1712.     LD    A,(MYCHAR)    ;Redraw contents of samples window.
  1713.     CALL    IFP3BIG
  1714.     JP    Z,REDR2A    ;+3 big chars have a different samples routine.
  1715.     LD    DE,052DH
  1716.     CALL    PRINAT
  1717.     LD    E,A
  1718.     CALL    ANYCHAR    ;Print character by itself.
  1719. REDR2B:    LD    DE,072BH
  1720.     PUSH    DE
  1721.     LD    C,6    ;Print a 5x6 (or if +3 big, 3x6) set of chars.
  1722. REDR3:    POP    DE
  1723.     CALL    PRINAT
  1724.     INC    D    ;Increase Y-coordinate - next line.
  1725.     PUSH    DE
  1726.     LD    E,A
  1727.     CALL    IFP3BIG    ;For +3, print the characters.
  1728.     CALL    Z,OPBIG5
  1729.     JR    Z,REDR4A
  1730.     LD    B,5    ;5 characters side by side.
  1731. REDR4:    CALL    ANYCHAR
  1732.     DJNZ    REDR4
  1733. REDR4A:    DEC    C
  1734.     JR    NZ,REDR3
  1735.     POP    BC
  1736.     POP    HL
  1737.     POP    DE
  1738.     POP    BC
  1739.     POP    AF
  1740.     RET
  1741. ;
  1742. REDR2A:    LD    DE,042EH    ;For +3, the actual window must be made
  1743.     CALL    PRINAT    ;slightly bigger. Extend it to the right.
  1744.     LD    E,GTL
  1745.     CALL    OPCHAR
  1746.     LD    E,GTRC
  1747.     CALL    OPCHAR
  1748.     LD    DE,052DH    ;Middle line.
  1749.     CALL    PRINAT
  1750.     LD    E,A
  1751.     CALL    OPBIG    ;Print the actual character.
  1752.     LD    E,GRL
  1753.     CALL    OPCHAR
  1754.     LD    DE,062EH
  1755.     CALL    PRINAT
  1756.     LD    E,GTL
  1757.     CALL    OPCHAR
  1758.     LD    E,GTRJ
  1759.     CALL    OPCHAR
  1760.     JP    REDR2B
  1761. ;
  1762. IFP3BIG:
  1763.     CALL    CHEKPL3    ;If not +3, not +3 big.
  1764.     RET    NZ
  1765.     PUSH    BC    ;Preserve A but not F.
  1766.     LD    C,A
  1767.     LD    A,(PL3SET)    ;If +3 char. set is at 3000h, big set.
  1768.     CP    30H
  1769.     LD    A,C
  1770.     POP    BC
  1771.     RET
  1772. ;
  1773. CURDOT:    LD    E,128    ;DRAW THE CURSOR DOT.
  1774.     JR    DOT1
  1775. DOT:    LD    E,144
  1776. DOT1:    CALL    C,HIVON    ;DRAW A NORMAL DOT.
  1777.     CALL    NC,HIVOFF
  1778.     JP    OPCHAR
  1779. ;
  1780. EDDRAW:    CALL    HIVOFF        ;DRAW THE GRAPHICS WINDOW
  1781.     LD    DE,041EH
  1782.     PUSH    DE
  1783.     CALL    PRINAT
  1784.     LD    E,GTLC
  1785.     CALL    OPCHAR
  1786.     LD    A,(EDWIDE)    ;Either 5 wide or 8 wide.
  1787.     LD    B,A
  1788.     LD    E,GTL
  1789.     CALL    STRING$
  1790.     LD    E,GTRC    ;Top line.
  1791.     CALL    OPCHAR
  1792.     LD    C,8    ;8 middle lines.
  1793. EDD1:    POP    DE
  1794.     INC    D    ;Increment Y-coordinate.
  1795.     PUSH    DE
  1796.     CALL    PRINAT
  1797.     LD    E,GLL    ;LH line.
  1798.     CALL    OPCHAR
  1799.     LD    B,A
  1800.     LD    E,144    ;Blank dots.
  1801.     CALL    STRING$
  1802.     LD    E,GRL
  1803.     CALL    OPCHAR    ;RH line - for Amstrads, identical to LH line.
  1804.     DEC    C
  1805.     JR    NZ,EDD1
  1806.     POP    DE
  1807.     INC    D
  1808.     CALL    PRINAT
  1809.     LD    E,GBLC    ;Bottom line.
  1810.     CALL    OPCHAR
  1811.     LD    B,A
  1812.     LD    E,GBL
  1813.     CALL    STRING$
  1814.     LD    E,GBRC
  1815.     CALL    OPCHAR
  1816.     RET
  1817. ;
  1818. IMAGBOX:
  1819.     LD    DE,042AH    ;Draw samples box.
  1820.     CALL    PRINAT
  1821.     PUSH    DE
  1822.     LD    DE,IBTL    ;Top line.
  1823.     CALL    PRINT
  1824.     POP    DE
  1825.     INC    D
  1826.     CALL    PRINAT
  1827.     PUSH    DE
  1828.     LD    DE,IB2L    ;2nd line.
  1829.     CALL    PRINT
  1830.     POP    DE
  1831.     INC    D
  1832.     CALL    PRINAT
  1833.     PUSH    DE
  1834.     LD    DE,IB3L    ;3rd line.
  1835.     CALL    PRINT
  1836.     LD    B,6    ;6 intermediate lines.
  1837. IB1:    POP    DE
  1838.     INC    D
  1839.     CALL    PRINAT
  1840.     PUSH    DE
  1841.     LD    DE,IB4L
  1842.     CALL    PRINT
  1843.     DJNZ    IB1
  1844.     POP    DE
  1845.     INC    D
  1846.     CALL    PRINAT
  1847.     LD    DE,IB5L    ;bottom line.
  1848.     CALL    PRINT
  1849.     RET
  1850. ;
  1851.     DSEG
  1852. IBTL:    DEFB    '  ',GTLC,GTL,GTRC,'  $'
  1853. IB2L:    DEFB    '  ',GLL,' ',GRL,'  $'
  1854. IB3L:    DEFB    GTLC,GTL,GTLJ,GTL,GTRJ,GTL,GTRC,'$'
  1855. IB4L:    DEFB    GLL,'     ',GRL,'$'
  1856. IB5L:    DEFB    GBLC,GBL,GBL,GBL,GBL,GBL,GBRC,'$'
  1857. SSM:    DEFB    'Small size$'
  1858. LSM:    DEFB    'Large size$'
  1859. EDX:    DEFB    0    ;Cursor X & Y.
  1860. EDY:    DEFB    0
  1861. EFMENU:    DEFB    3,EDOPT6-EDKEYS,13,2
  1862.     DEFB    'Are you sure?'
  1863.     DEFB    'Yes          Y',0,0
  1864.     DEFB    'No           N',0,0
  1865. EQMENU:    DEFB    3,65,13,2
  1866.     DEFB    'Are you sure?'
  1867.     DEFB    'Yes          Y',0,0
  1868.     DEFB    'No           N',0,0
  1869.     CSEG
  1870. ;
  1871. EFIN1:    CALL    HIVOFF    ;Highlight as usual. This is similar to WHFIN.
  1872.     CALL    EDVPR
  1873.     LD    DE,0200H+EDOPT6-EDKEYS
  1874.     CALL    HIVON
  1875.     CALL    PRINAT
  1876.     LD    HL,EDOPT6
  1877.     LD    (CCB),HL
  1878.     LD    HL,EDOPT7-EDOPT6-1
  1879.     LD    (CCB+2),HL
  1880.     LD    DE,CCB
  1881.     CALL    OPCCB
  1882.     LD    HL,EFMENU
  1883.     CALL    MENU
  1884.     CALL    CLRMENU
  1885.     LD    A,B
  1886.     OR    A
  1887.     JP    NZ,EF2
  1888.     LD    A,C
  1889.     CP    1
  1890.     JP    Z,EQUIT
  1891. EF2:    CALL    HIVON
  1892.     CALL    EDVPR
  1893.     JP    EDLOOP
  1894.  
  1895. EQUIT1:    CALL    HIVOFF    ;Quit edit. As for WHQUIT.
  1896.     CALL    EDVPR
  1897.     CALL    HIVON
  1898.     LD    DE,0243H
  1899.     CALL    PRINAT
  1900.     LD    DE,EDOPT7
  1901.     CALL    CHEKPCW
  1902.     CALL    Z,PRINT
  1903.     LD    DE,EDPL37
  1904.     CALL    NZ,PRINT
  1905.     LD    HL,EQMENU
  1906.     CALL    MENU
  1907.     CALL    CLRMENU
  1908.     LD    A,B
  1909.     OR    A
  1910.     JR    NZ,EF2
  1911.     DEC    C
  1912.     JP    NZ,EF2
  1913. ;
  1914. EQUIT3:    CALL    CHARRES
  1915.     LD    A,(MYCHAR)    ;Get character as it was on entry.
  1916.     CALL    CHARPUT
  1917.     JP    EQUIT
  1918. ;
  1919. GETCHNO:
  1920.     LD    HL,SELMENU    ;Get character no. in MYCHAR.
  1921.     LD    DE,SELM1
  1922.     LD    BC,SELM1-SELMENU
  1923.     LDIR        ;Move menu template to current menu area
  1924.     LD    A,1    ;(since the subroutine alters menu text).
  1925. ED2A:    LD    HL,SELM1
  1926.     CALL    MENU
  1927.     LD    A,B
  1928.     DEC    B    ;"CAN"
  1929.     JP    Z,ENDGC
  1930.     DEC    B    ;"EXIT"
  1931.     JP    Z,ENDGC
  1932.     DEC    B    ;"STOP"
  1933.     JP    Z,ENDGC
  1934.     LD    A,C
  1935.     CP    4    ;WAS "OK" SELECTED?
  1936.     JP    Z,CHKSEL
  1937.     CP    3    ;WAS "SELECT FROM SCREEN" SELECTED?
  1938.     JP    Z,SELSCR
  1939.     LD    C,A
  1940.     LD    A,B
  1941.     OR    A    ;If 0 (ENTER) pressed on an input option,
  1942.     LD    A,C    ;ignore it.
  1943.     JR    Z,ED2A
  1944.     CP    1
  1945.     JP    Z,ED4    ;A NUMBER HAS BEEN INPUT. PARSE IT.
  1946.     INC    DE
  1947.     LD    A,(DE)
  1948.     LD    C,A    ;LD BC,A
  1949.     LD    B,0
  1950.     PUSH    DE
  1951.     LD    H,D    ;HL=DE
  1952.     LD    L,E
  1953.     INC    HL
  1954.     ADD    HL,BC    ;ADD    HL,A
  1955.     LD    (HL),'$'    ;Number is terminated by $.
  1956.     POP    HL
  1957.     INC    HL
  1958.     LD    A,(HL)        ;If '&' parse as hex, not decimal
  1959.     CP    '&'
  1960.     JR    Z,GCHEX
  1961.     CALL    PARSENUM
  1962. GCHEX1:    LD    A,2
  1963.     CALL    C,BLEEP    ;If carry set, not a number.
  1964.     JP    C,ED2A
  1965.     LD    A,E
  1966.     LD    (MYCHAR),A    ;Set character number.
  1967.     CALL    UPDCHR    ;Put this in the menu.
  1968.     LD    A,0FFH
  1969.     LD    (CHAROK),A    ;A selection has been made.
  1970.     JP    ED2A4
  1971. ;
  1972. GCHEX:    INC    HL
  1973.     CALL    PARSEHEX
  1974.     JR    GCHEX1
  1975. ;
  1976. ED4:    INC    DE
  1977.     LD    A,(DE)    ;Was a character typed at all?
  1978.     OR    A
  1979.     JP    Z,ED2A
  1980.     LD    A,255    ;A selection has been made.
  1981.     LD    (CHAROK),A
  1982.     INC    DE
  1983.     LD    A,(DE)    ;Move character no. to MYCHAR.
  1984.     LD    (MYCHAR),A
  1985.     CALL    UPDCHR    ;Update character in menu.
  1986.     JP    ED2A4
  1987. ;
  1988. UPDCHR:    PUSH    AF
  1989.     LD    A,(MYCHAR)
  1990.     CP    20H    ;If character is printable put it in the menu.
  1991.     JR    NC,UPD1
  1992.     LD    A,' '    ;otherwise put a space.
  1993. UPD1:    LD    (SELMT),A
  1994.     LD    A,(MYCHAR)    ;Put the ASCII number in the menu.
  1995.     PUSH    BC        ;As OPINT but the number isn't printed.
  1996.     PUSH    DE
  1997.     PUSH    HL
  1998.     LD    HL,SELMA
  1999.     LD    E,100
  2000.     CALL    DIVAE
  2001.     LD    E,10
  2002.     CALL    DIVAE
  2003.     LD    E,1
  2004.     CALL    DIVAE
  2005.     POP    HL
  2006.     POP    DE
  2007.     POP    BC
  2008.     POP    AF
  2009.     RET
  2010. ;
  2011. DIVAE:    LD    D,A    ;Divide A by E, result in (HL), HL->HL+1
  2012.     LD    B,8
  2013.     XOR    A    ;Routine from Michael Keys' book, "PCW machine code"
  2014. DIVAE1:    SLA    D
  2015.     RLA
  2016.     CP    E
  2017.     JR    C,DIVAE2
  2018.     SUB    E
  2019.     INC    D
  2020. DIVAE2:    DJNZ    DIVAE1
  2021.     PUSH    AF
  2022.     LD    A,30H
  2023.     ADD    A,D
  2024.     LD    (HL),A
  2025.     INC    HL
  2026.     POP    AF
  2027.     RET
  2028. ;
  2029. SELSCR:    CALL    IFP3BIG    ;Select the character by pointing at it in the box at the bottom of the screen.
  2030.     CALL    Z,VBFONT
  2031.     CALL    SELCHR    ;SELECT THE CHARACTER.
  2032.     LD    A,3
  2033.     JP    NC,ED2A    ;ABANDONED
  2034.     CALL    UPDCHR
  2035.     LD    A,255    ;Set to OK.
  2036.     LD    (CHAROK),A
  2037. ED2A4:    LD    A,4    ;Jump to option 4.
  2038.     LD    HL,SELM1
  2039.     JP    ED2A
  2040. ;
  2041. CHKSEL:    LD    A,(CHAROK)    ;If a character has been input, leave.
  2042.     OR    A    ;otherwise, ignore.
  2043.     JR    Z,ED2A4
  2044.     SCF
  2045.     RET
  2046. ;
  2047. ENDGC:    SCF
  2048.     CCF
  2049.     RET
  2050. ;
  2051. SELCHR:    CALL    ARROWS    ;Select character from chart.
  2052.             ;1. Draw arrows.
  2053.             ;2. Movement key actions:
  2054. SELCHR1:
  2055.     CALL    CON6
  2056.     CP    LA
  2057.     CALL    Z,SELLA    ;Left
  2058.     CP    RA
  2059.     CALL    Z,SELRA    ;Right
  2060.     CP    UA
  2061.     CALL    Z,SELUA    ;Up
  2062.     CP    DA
  2063.     CALL    Z,SELDA    ;Down
  2064.             ;3. If CR, selection made OK.
  2065.     CP    0DH
  2066.     JP    Z,SELMADE
  2067.             ;4. If Stop or EXIT, abandoned.
  2068.     CP    03H
  2069.     CALL    Z,DIRCLEAR
  2070.     JP    Z,SELQUIT
  2071.     CP    ESC
  2072.     CALL    Z,DIRCLEAR
  2073.     JP    Z,SELQUIT
  2074. ;
  2075. ;UNRECOGNISED KEY!
  2076. ;
  2077.     JR    SELCHR1
  2078. ;
  2079. ; MOVEMENT KEY MANAGER:
  2080. ;   A. CHECK BOUNDS
  2081. ;   B. IF ACCEPTABLE, UNDRAW ARROWS & CHANGE POSITION
  2082. SELUA:    PUSH    AF
  2083.     LD    A,(CHY)    ;Prospective new Y.
  2084.     DEC    A
  2085.     JR    SELDA1
  2086. ;
  2087. SELDA:    PUSH    AF
  2088.     LD    A,(CHY)    ;Prospective new Y.
  2089.     INC    A
  2090. SELDA1:    CALL    VBOUNDS
  2091.     JR    NC,SELEND    ;If not within bounds, quit.
  2092.     CALL    ARRDEL    ;Remove arrows.
  2093.     LD    (CHY),A    ;Set new Y.
  2094.     CALL    ARROWS    ;Redraw arrows.
  2095.     JR    SELEND
  2096. ;
  2097. SELLA:    PUSH    AF
  2098.     LD    A,(CHX)    ;Left.
  2099.     DEC    A    ;Each char. takes 2 screen locations.
  2100.     DEC    A
  2101. SELLA1:    CALL    HBOUNDS
  2102.     JR    NC,SELEND    ;If not within bounds, quit
  2103.     CALL    ARRDEL    ;Remove, set new Y, redraw.
  2104.     LD    (CHX),A
  2105.     CALL    ARROWS
  2106. SELEND:    POP    AF
  2107.     RET
  2108. ;
  2109. SELRA:    PUSH    AF
  2110.     LD    A,(CHX)    ;Right.
  2111.     INC    A
  2112.     INC    A
  2113.     JR    SELLA1
  2114. ;
  2115. VBOUNDS:
  2116.     CP    15    ;CARRY SET => GOOD BOUNDARIES
  2117.     JR    C,INVB
  2118.     CP    21    ;Vertical boundaries, 15-21.
  2119.     JR    Z,VB1    ;Line 21 is short, so if X is too big,
  2120.     RET    C    ;the cursor can't go onto it.
  2121. INVB:    SCF
  2122.     CCF
  2123.     RET
  2124. HBOUNDS:
  2125.     PUSH    BC    ;Horizontal boundaries are 1-76
  2126.     LD    B,A
  2127.     LD    A,(CHY)
  2128.     CP    21    ;But if on line 21, special provision.
  2129.     LD    A,B
  2130.     POP    BC
  2131.     JR    Z,HB1
  2132.     CP    1
  2133.     JR    C,INVB
  2134.     CP      77
  2135.     RET    C
  2136.     JR    INVB
  2137. ;
  2138. HB1:    CP    56    ;Max. X is 55 on line 21.
  2139.     RET    C
  2140.     JR    INVB
  2141. ;
  2142. VB1:    PUSH    BC
  2143.     LD    B,A
  2144.     LD    A,(CHX)    ;If above Max. X, invalid coordinates.
  2145.     CP    56
  2146.     LD    A,B
  2147.     POP    BC
  2148.     RET    C
  2149.     JR    INVB
  2150. ;
  2151. ARROWS:    PUSH    AF    ;Draw arrows round the chosen character.
  2152.     PUSH    BC
  2153.     PUSH    DE
  2154.     PUSH    HL
  2155.     LD    DE,(CHX)
  2156.     CALL    PRINAT
  2157.     CALL    HIVON
  2158.     CALL    ARR1
  2159.     CALL    HIVOFF
  2160.     POP    HL
  2161.     POP    DE
  2162.     POP    BC
  2163.     POP    AF
  2164.     RET
  2165. ;
  2166. ARRDEL:    PUSH    AF    ;Remove arrows from chosen character.
  2167.     PUSH    BC
  2168.     PUSH    DE
  2169.     PUSH    HL
  2170.     LD    DE,(CHX)
  2171.     CALL    PRINAT
  2172.     CALL    HIVOFF
  2173.     CALL    IFP3BIG    ;If big character, then
  2174.     JP    Z,ARRDELB    ;Delete arrows from a big character
  2175.     LD    DE,C3$    ;Remove character & backspace.
  2176.     CALL    PRINT
  2177.     CALL    WHATCHAR    ;Calculate character number from cursor pos.
  2178.     LD    E,A
  2179.     CALL    IFFSET    ;If there was a marker, print the underlines.
  2180.     CALL    Z,MARK
  2181.     CALL    NZ,NOMARK
  2182. ARRDL1:    POP    HL
  2183.     POP    DE
  2184.     POP    BC
  2185.     POP    AF
  2186.     RET
  2187. ;
  2188. ARRDELB:
  2189.     CALL    WHATCHAR    ;Get big char. number
  2190.     LD    E,A
  2191.     CALL    IFFSET    ;If there was a marker, underlines.
  2192.     CALL    Z,RVBIG    ;Else, no underline.
  2193.     CALL    NZ,OPBIG
  2194.     JR    ARRDL1
  2195. ;
  2196. ARR1:    CALL    IFP3BIG    ;Draw arrows. Normally, an arrow
  2197.     JP    Z,ARR1B    ;setup is an inverse video box, with
  2198.     CALL    WHATCHAR    ;arrows ->C<- pointing at char.
  2199.     LD    E,A    ;If char is marked, it is =>C<=.
  2200.     CALL    IFFSET    ;Big characters are just drawn in inverse video.
  2201.     LD    E,12    ;12 is normal arrow, 252 is marker arrow
  2202.     JR    NZ,ARR1A    ;(both point right).
  2203.     LD    E,252
  2204. ARR1A:    CALL    ANYCHAR
  2205.     LD    E,A
  2206.     CALL    ANYCHAR    ;Print the character itself.
  2207.     CALL    IFFSET
  2208.     LD    E,11    ;11 is normal left arrow, 253 marker arrow.
  2209.     JR    NZ,ARR1C
  2210.     LD    E,253
  2211. ARR1C:    CALL    ANYCHAR
  2212.     RET
  2213. ;
  2214. ARR1B:    CALL    WHATCHAR    ;Print big character in inverse video.
  2215.     LD    E,A
  2216.     CALL    IFFSET
  2217.     CALL    Z,RVBIG
  2218.     CALL    NZ,OPBIG    ;Marked big characters retain their underline.
  2219.     RET
  2220. ;
  2221. WHATCHAR:
  2222. ;A=(X-1)/2+38*(Y-15)
  2223.     PUSH    DE
  2224.     PUSH    BC
  2225.     LD    A,(CHX)    ;A=X
  2226.     DEC    A    ;A=X-1
  2227.     SRL    A    ;A=(X-1)/2
  2228.     LD    B,A    ;B=(X-1)/2
  2229.     LD    A,(CHY)    ;A=Y
  2230.     SUB    15    ;A=Y-15
  2231.     ADD    A,A     ;A=2*(Y-15)
  2232.     LD    C,A    ;C=2*(Y-15)
  2233.     ADD    A,A    ;A=4*(Y-15)
  2234.     LD    D,A    ;D=4*(Y-15)
  2235.     ADD    A,A    ;A=8*(Y-15)
  2236.     ADD    A,A    ;A=16*(Y-15)
  2237.     ADD    A,A    ;A=32*(Y-15)
  2238.     ADD    A,D    ;A=36*(Y-15)
  2239.     ADD    A,C    ;A=38*(Y-15)
  2240.     ADD    A,B    ;A=38*(Y-15)+(X-1)/2
  2241.     POP    BC
  2242.     POP    DE
  2243.     RET
  2244. ;
  2245. SELMADE:
  2246.     CALL    WHATCHAR    ;Selection has been made. Flag it & return.
  2247.     LD    (MYCHAR),A
  2248.     CALL    ARRDEL
  2249.     SCF        ;FLAG OK.
  2250.     RET
  2251. ;
  2252. SELQUIT:
  2253.     CALL    ARRDEL    ;Delete arrows & quit.
  2254.     SCF
  2255.     CCF
  2256.     RET
  2257. ;
  2258. EMPBOX:    LD    DE,0F01H    ;Empty the font box
  2259.     LD    B,7
  2260. EMP1:    CALL    PRINAT
  2261.     PUSH    DE
  2262.     LD    DE,SPACES+2    ;(overprint it with spaces)
  2263.     CALL    PRINT
  2264.     POP    DE
  2265.     INC    D
  2266.     DJNZ    EMP1
  2267.     RET
  2268. ;
  2269.     DSEG
  2270. CHX:    DEFB    1
  2271. CHY:    DEFB    15    ;X & Y for characters chart cursor.
  2272.  
  2273. SPACES:    DEFB    '                                        '
  2274.     DEFB    '                                        ',CR,LF,'$'
  2275. FBEGIN:    DEFB    0    ;First marker
  2276. FEND:    DEFB    0    ;2nd marker
  2277. FFLG:    DEFB    0    ;
  2278. LOADOPT:
  2279.     DEFB    0    ;Loading options
  2280. CPDFLG:    DEFB    0FFH    ;Character scratchpad flag 0FFH empty 0 full.
  2281. C3$:    DEFB    '   ',8,8,8,'$'
  2282.             ;Delete 3 characters to right.
  2283.     CSEG
  2284. ;
  2285. ;END OF THIS MODULE.