PROGRAMMING: MEMOTECH MTX Panel Copy by A F Wilson

         Extracted from page 26 of Popular Computing Weekly, 
         26 June-2 July 1987 and page 31 3-9 July 1987

         One of the best features of the Memotech MTX series computers
         is their built in assembler/disassembler, the Panel. Unfortunately,
         the one thing missing from it is the ability to dump the contents
         thereof, to a printer. This program remedies that problem.

         (1) For SDX Users

         Type in listing,then type GOTO 100 <RET>. This will autosave 
         the program to disc as "PANEL.COD" . To use the program,just 
         type USER LOAD "PANEL.COD" <RET>. This will reload the program 
         back into memory. Therefore when you enter PANEL ,function keys
         F5-F8,are now initialized (see later for meanings).

         (2) For SDX/FDX CP/M Users

         As in (1),except replace the references to USER with DISC.

         (3) For Tape Users

         As in (1),except remove the references to USER. To load use 
         LOAD "PANELCOD".

         You should now have on disc or tape a program called PANEL.COD 
         or PANELCOD . This program is interrupt driven and is at top 
         of free memory,therefore it won't be overwritten. However,when 
         the computer is reset,the PANEL extension location at #FA9E is 
         reset,and this subroutine will become invisible to the 
         Operating System and PANEL. As the program is still in memory 
         at the desired location,#B007,you simply re-initialize it with 
         RAND USR(45063).
          
         The screen is divided up into three key areas: the 
         disassembly,the registers and the Hexdump at the bottom of the 
         screen. This PANEL extension allows you get a hardcopy of the 
         whole PANEL screen (F5) ,the disassembly & registers (F6),the 
         disassembly only (F7) and the hexdump only (F8).
         See fiigure below for a snapshot of the panel whole screen.


         10 CODE

         4007 JPANEL:LD A,#C3          ;SET PANEL EXTENSION WITH
         4009        LD (#FA9E),A      ;JP #B012.
         400C        LD HL,#B012       ;
         400F        LD (#FA9F),HL     ; 
         4012 PSTART:LD A,(#FD7D)      ;WHAT WAS THE LAST KEYPRESS.
         4015        CP #84            ;CHECK TO SEE IF IT ONE OF
         4017        JR Z,F5           ;THE FOLLOWING OPTIONS.
         4019        CP #85            ;
         401B        JR Z,F6           ;
         401D        CP #86            ;
         401F        JR Z,F7           ;
         4021        CP #87            ;
         4023        JR Z,F8           ;
         4025        RET NZ            ;RET TO PANEL EDITOR,NO MATCH.
         4026 F5:    LD HL,7168        ;START OF PANEL SCREEN IN VRAM.
         4029        LD DE,960         ;LENGTH OF SCREEN TO BE PRINTED
         402C        LD A,40           ;SET PRINTER COLUMN WIDTH.
         402E        JR START          ;GOTO DUMP START.
         4030 F6:    LD HL,7168        ;
         4033        LD DE,520         ;
         4036        LD A,40           ;
         4038        JR START          ;
         403A F7:    LD HL,7168        ;
         403D        LD DE,338         ;
         4040        XOR A             ; ZERO COUNTER AT
         4041        LD (#B0B5),A      ; COUNT.
         4044        LD A,26           ;
         4046        JR START          ;
         4048 F8:    LD HL,7848        ;
         404B        LD DE,240         ;
         404E        LD A,40           ;
         4050        JR START          ;
         4052 START: LD (#B0B1),HL     ;STORE AT SCRNST.
         4055        LD (#B0B3),DE     ;STORE AT LENPAN.
         4059        LD (#B0B5),A      ;STORE AT COL.
         405C        PUSH HL           ;
         405D SEPSON:LD HL,#B0AB       ;POINT TO LINEFEED (LF) DATA.
         4060        LD C,6            ;6 CODES TO BE SENT TO PRINTER.
         4062 POUT:  LD B,(HL)         ;SEND THE CODES FOR LF AND COL
         4063        CALL #0CE3        ;WIDTH TO INITIALISE THE 
         4066        INC HL            ;PRINTER.
         4067        DEC C             ;
         4068        JR NZ,POUT        ;
         406A        LD DE,(#B0B3)     ;SIZE OF SCREEN TO BE PRINTED.
         406E VDPSET:POP HL            ;POP HL TO AF DEALS WITH
         406F        PUSH AF           ;SETTING THE GRAPHICS (VDP)
         4070        LD A,L            ;PROCESSOR TO THE CORRECT ROW
         4071        OUT (2),A         ;OF THE SCREEN.
         4073        LD A,H            ;THIS IS CALLED ONCE FOR F5,F6
         4074        AND #3F           ;,F8 ONLY AS THESE SCREENS ARE
         4076        OUT (2),A         ;40 COLS WIDE AND WE CAN USE
         4078        POP AF            ;AUTOINCREMENTOR.F7 CALLS THIS
                                       ;EVERY ROW,AS SCRN WIDTH IS 26.
         4079 PSEND: IN A,(1)          ;FETCH ASCII CHARACTER FROM THE
         407B        LD B,A            ;SCREEN AND PASS TO ROM CALL 
         407C        CALL #0CE3        ;VIA REGISTER B ONLY.
         407F        DEC DE            ;DECREMENT MAIN COUNTER.
         4080        LD A,D            ;CHECK TO SEE IF DE=0.
         4081        OR E              ;
         4082        JR Z,END          ;IF DE=0 THEN STOP PRINTING.
         4084        LD A,(#B0B0)      ;CHECK IF F7 SELECTED.
         4087        AND A             ;
         4088        CP 26             ;
         408A        JR NZ,PSEND       ;IF NOT F7,KEEP READING.
         408C        LD A,(COUNT)      ;UPDATE ROW COLUMN COUNTER
         408F        AND A             ;AND CHECK TO SEE IF END OF
         4090        INC A             ;ROW YET.
         4091        LD (#B0B5),A      ;
         4094        LD B,A            ;
         4095        LD A,(#B0B0)      ;
         4098        CP B              ;
         4099        JR Z,UPDVDP       ;UPDATE VDP ROW COUNTER.
         409B        JR PSEND          ;NOT AT LINE END YET.
         409D UPDVDP:PUSH DE           ;MOVE VDP ON BY 40 (SCREEN
         409E        LD DE,40          ;WIDTH).
         40A1        ADC HL,DE         ;
         40A3        POP DE            ;
         40A4        PUSH HL           ;
         40A5        XOR A             ;
         40A6        LD (#B0B5),A      ;ZERO F7 COL COUNTER.
         40A9        JR VDPSET         ;
         40AB LF:    DB 27,"A",16      ;SET PRINTER SPACING.
         40AE        DB 27,"Q"         ;SET COLUMN
         40B0 COL:   DS 1              ;WIDTH.
         40B1 SCRNST:DS 2              ;#B0B1
         40B3 LENPAN:DS 2              ;#B0B3
         40B5 COUNT: DS 1              ;#B0B5
         40B6 END:   LD B,13           ;SEND CR.
         40B8        CALL #0CE3        ;
         40BB        LD B,10           ;SEND LF.
         40BD        CALL #0CE3        ;
         40C0        RET               ;RETURN TO PANEL EDITOR.

         20 CODE

         MOVECODE: LD HL,#4007         ;(OR #8007) START OF CODE.
                   LD DE,#B007         ;NEW LOCATION IN MEMORY.
                   LD BC,186           ;LENGTH OF CODE TO MOVE.
                   LDIR                ;MOVE IT
                   RET                 ;

         30  RETURN
         100 USER SAVE "PANEL.COD"
         110 GOSUB 20
         120 RAND USR(45063)
         130 NEW


         Notes:
	
	 The following was not included in the published listing even 
         though referenced.

         Figure: example of PANEL screen

         8007        LD HL,#FAA4      
         800A        LD DE,#FAA5       AF 0000 F3
         800D        LD BC,#000C       BC 0000 F3
         8010        XOR A             DE 0000 F3
         8011        LD (HL),A         HL 0000 F3
         8012        LDIR              IX 0000 F3
         8015        LD HL,#FA9E       IY 0000 F3
         8018        LD (HL),#C7       SP 0000 F3
         801A        RET               PC 0000 F3
         801B        RET               

             
              8000: 1B 00 01 00 C2 13 00 21
              8008: A4 FA 11 A5 FA 01 0C 00
              8010: AF 77 ED 80 21 9F FA 36
              8018: etc.