!pr1
RAMWORKS Compatible Auxiliary MOVE Routine.....Harvey Brown
                              Spirit River, Alberta, CANADA

The MOVE routine inside the Apple //c and //e ROM transfers data conveniently to and from the auxiliary 48K area, but it does not work with the upper 16K area.  Also, it does not work with the extra banks of RAM available in cards such as the RAMWORKS from Applied Engineering.

I needed that ability, so I wrote my own MOVE subroutine.  Mine uses the page at $200 in main RAM as a buffer, to simplify the movement code.  If you want to move from an arbitrary bank to another arbitrary bank, my program will require you to use $200 in main RAM as an intermediate buffer.  (Somewhat like stopping at Chicago on your way from Toronto to Dallas.)  My program also assumes you are always moving exactly 256 bytes (one page).  This simplifies the code and the calling sequence, and is probably a reasonable restriction.

The program begins by copying itself into every bank you are using.  The bank numbers must be assembled in to the list in lines 1800-1870.  Notice that I use bank number $FF to signal the main RAM, and banks from $00 up to signal the banks of Auxiliary RAM.  This code needs to reside in the same location in every bank that will be switched on, because when you move from an auxiliary bank to the main RAM that auxiliary bank will be set up so that all RAM reads come from it.  This includes reads for the program, so the program had better be there.

Once the program has been initialized, you can JSR MOVE (or JSR $C03 if you want to use a "frozen" entry point) to move a page.  At the time of the JSR MOVE, you should have the high byte of the Auxiliary RAM address in the A-register, and the bank number in the X-register.  Set carry (SEC opcode) to indicate moving from main $200, or clear carry (CLC opcode) to indicate moving into main $200.  Thinking in terms of a ramdisk application, SEC for a write or CLC for a read.

Warning:  my program assumes you are calling from a program that runs with the Applesoft ROM selected (see line 1780).  If you plan to run it with RAM selected in the upper 16K, you will have to make appropriate changes.  You could save the status of the LCRAM and LCBANK soft switches ($C012 and $C011 respectively) before changing them.  These partially indicate the status of the $C08x switches.  You can tell whether RAM or ROM was selected, and restore the proper one after MOVE is finished.  You can also tell which $D000 bank was selected.  However, you cannot tell whether the RAM was write-enabled or not; also, you cannot tell if it was in the special mode in which you read ROM and write RAM.
