Following is a quote from my RamWorks manual. -- Paul R. Santa-Maria Ann Arbor, Michigan USA paulrsm@ameritech.net RamWorks III & RamWorks basic User's Manual v1.0 Chapter 8: RamWorks Auxiliary Memory (pages 53-55) * For Programmers Only... Because RamWorks is completely compatible with the Apple Extended 80 Column card, the purpose of this chapter is to describe only the feature which is unique to RamWorks, extended auxiliary memory. This material is definitely intended for assembly language programmers. Information concerning the access and control of the 80 column firmware, screen features, and auxiliary memory can be found in the Apple //e Reference Manual. Warning: Don't attempt to use the auxiliary memory directly from an interpreter such as BASIC or Pascal. These interpreters use certain portions of main memory that, when switched to auxiliary memory can cause your program and the interpreter to "bomb". * Bank Switching The 6502 microprocessor has the address capability of only 64 kilobytes. In order to address more memory, use "bank switching," a feature built in to the Apple //e's firmware. Soft switches control whether the 6502 addresses the 64K bank of main memory or the single 64K bank of auxiliary memory available with the Extended 80 Column card. In order to use more than just 64K of auxiliary memory, RamWorks combines this bank switching technique with its own firmware feature called, "the bank select register." The bank select register determines which of 48 possible 64K banks of auxiliary memory the 6502 addresses. The bank select register is mapped into the //e's memory space at location $C073 (49267). The programmer can select one of 48 valid banks by writing the bank number into this location. (Chapter 7 provides the bank numbers for various memory configurations.) Once you make the bank selection, soft switches built into the //e firmware function as they normally would. This allows data transfer from main memory to auxiliary memory and vice versa. Data transfers between banks of auxiliary memory must be done in two stages. The data transfers to main memory first and then from main memory to the desired bank(s). You can also transfer, one byte at a time, using the Accumulator. Bank 0 in RamWorks always contains the text information for the 80 column display and the graphics information for the double high resolution display. This bank must be active whenever the program updates the display screen. Only Bank 0 contains the video information. This feature, unique to RamWorks, eliminates a screen flicker problem inherent with some other brands of memory cards when they access other banks. The bank select register is initialized to zero on a power-up, but not after a reset. Please refer to the programming suggestion in "Reset Vector". The location of the bank select register is also shared with the system. Writing to the bank select register will also trigger the paddle strobe, used to read the paddle inputs. To insure the paddles are read correctly, wait at least 3 milliseconds after changing banks before starting the paddle read routine. You cannot read the contents of the bank select register. The program must keep track of the current bank number in a reserved location within each bank. * Programming Suggestions Interrupts Programmers should note that RamWorks has multiple interrupt vectors. Since the interrupt vector is located at $FFFE, each auxiliary bank of memory contains an interrupt vector. Auxiliary memory may be switched in when an interrupt occurs; therefore, you should prepare routines that use auxiliary memory to disable or process interrupts. You should disable interrupts in programs which do not use them. Please refer to the Apple //e Reference Manual for details on how to handle interrupts. Reset Vector All programs should start by initializing the bank register to 0 (video bank). Since RamWorks cannot detect a hardware reset, the software should be able to handle a reset by storing a 0 in the bank register. The following assembly language subroutine intercepts the reset soft vector at $3F2-$3F3 and changes it to point to the new reset routine. *Store off old reset soft vector LDA $3F2 STA $300 ;IN $300.301 LDA $3F3 STA $301 *Set reset vector to point to $302 LDA #$02 STA $3F2 ;($3F2 -> $302) LDA #$03 STA $3F3 EOR #$A5 ;Inits new validity check byte STA $3F4 *Reset routine LDA #$A9 ;LDA #0 STA $302 LDA #$0 STA $303 LDA #$8D ;STA $C073 STA $304 LDA #$73 STA $305 LDA #$C0 STA $306 LDA #$6C ;JMP ($300) STA $307 LDA #$00 STA $308 LDA #$30 STA $309 Available Banks The following subroutine will find all valid banks, determine the size of RamWorks memory, and save the results into BankTbl. BankTbl will have the number of 64K banks found, followed by the table of valid bank numbers. Keep in mind that the bank numbers are not necessarily linear. For example: 'BankTbl:08 00 01 02 03 04 05 06 07'indicates a 512K RamWorks containing banks 0 through 7. BankSel EQU $C073 MaxMem EQU 3*16 ;Maximum desired, 3 megabytes in this example *Write bank number to each bank STA $C009 ;Store in alternate zero page LDY #$7F ;Valid banks range $00 to $7F FindBanks STY BankSel ;Go through each bank STY $00 ;Store the bank number TYA EOR #$FF STA $01 ;Second self-check DEY BPL FindBanks *Read them back to find valid banks and save in table LDA #$00 TAY TAX FindThem STY BankSel ;Search through all banks STA BankSel+3 CPY $00 BNE NotOne ;Check bank number TYA EOR #$FF CMP $01 ;Check second double-check BNE NotOne INX TYA ;Found valid bank-save in table STA BankTbl,X CPX #MaxMem ;Found all banks to be used BCS Done NotOne INY ;Go through all valid bank ranges BPL FindThem *Ending routine Done LDA #$00 ;Reset to video bank STA BankSel STA $C008 STX BankTbl ;Size of Ram card LDA #$FF STA BankTbl+1,X ;Mark end of table JMP Continue BankTbl DS MaxMem+2 Continue EQU *