LNW80 M2 memory switch info

Based on the article below, I reconstructed the memory switching capabilities of the LNW80 Model II.

port 31d, 1Fh
bit off             on
1   ROM 0h-3700h    RAM 0h-3700h
2   Enable intr.    Disable interrupts
7   Wr.En.0h-2FFFh  Write Disable 0h-2FFFh  (ROM Area)

From: http://www.research.digital.com/SRC/personal/mann/trs80/doc/misnote3.txt

      The  following  is  an interesting letter from  Jeffrey  McLean
concerning EDAS used with the LNW-80 Model II.
     "...I discovered that EDAS would not work properly with it. When
ever  I  would press the SHIFT @ key to pause a listing, the  program
would abort to the LDOS Ready prompt with the massage, 'SYS ERROR'. I
traced  this  problem to the fact that the LNW ROM has NOP's  in  the
place of the @CTL vector. Since the LNW-80 model II has the option of
RAM  in the address space from zero to X'3700', I wrote a program  to
move  the ROM to RAM and patch it up. I am enclosing a copy  of  that
program; you may want to pass it along if any one contacts you with a
similar problem."
      When  I  looked at the program, I commented to Jeffrey  that  I
thought the program should have a DI before switching out the ROM and
an  EI  after  restoring everything to normal with the  patched  low-
memory  RAM.  Jeff said, "There are no DI or EI instructions  in  the
program because they are not needed. When I select RAM, I output a  6
decimal to the memory management port, 31 decimal. This sets bits one
and two. According to LNW documentation, setting bit one of this port
will  enable RAM from zero to X'3700'. Setting bit two will turn  off
the  maskable interrupts. I've tested this; it works.   Later  on,  I
output  a  130 decimal, which sets bits one and seven and resets  bit
two. Bit seven write protects the RAM from zero to X'2FFF'.
      Jeff also added code to put a jump to the DEBUG entry point  in
the  NMI vector at 66H. He says it is extremely useful when debugging
assembly  language programs. This could be deleted from the  code  if
you do not want it.     i
     ; LNW80II/ASM
     ; This program was written by Jeffrey McLean.
     ; Revised on February 3, 1984
     ; This program will move the ROM of the LNW 80 model two
     ; to RAM and then patch it so that EDAS (and probably
     ; many other programs) will work on it.
     @EXIT EQU   402DH
     @ABORT      EQU      4030H
     @DSPLY      EQU      4467H
     HIGH$ EQU   4049H
     DEBUG EQU   400FH
           ORG   5200H
     START XOR   A
           OUT   (31),A   ;Make sure ROM is switched in.
           OUT   (254),A  ;Turn off reverse video
           LD    A,(HIGH$+1)
           CP    90H
           JR    NC,CONT1
           LD    HL,MESSAGE
           CALL  @DSPLY
           JP    @ABORT
     CONT1 LD    SP,(HIGH$)
           LD    HL,0
           LD    DE,EOP
           LD    BC,30O0H
           PUSH  HL
           PUSH  DE
           PUSH  BC
           LDIR           ;Copy ROM to user memory
           POP   BC
           POP   HL
           POP   DE
           LD    A,6
           OUT   (31),A   ;Select RAM from 0 to 12K
           LDIR           ;Move ROM into RAM at 0 to 12K
     ; Patch the ROM so EDAS will work correctly.
     ; Fix the @CTL vector
           LD    HL,FIX
           LD    DE,23H
           LD    BC,5
           LDIR     ; Fix the initialization for level two basic
           LD    DE,87H
           LD    B,2
     LOOP1 LD    A,(HL)
           LD    (DE),A
           INC   HL
           INC   DE
           DJNZ  LOOP1
           LD    DE,8FH
           LD    A,(HL)
           LD    (DE),A
           INC   HL
           LD    DE,66H
           LD    BC,LENGTH
           LD    A,130
           OUT   (31),A
           JP    @EXIT
     MESSAGE     DB       'Insufficient memory to fix ROM!',13
     FIX   OB    OC5H,6,4,18H,1EH,2DH,1,OC3H
     LEN1  EI
           JP    DEBUG
     LENGTH      EQU      $-LEN1
     EOP   EQU   $
           END   START