home *** CD-ROM | disk | FTP | other *** search
/ Old Hackers Atari User Group Newsletter / Old_Hackers_Atari_User_Group_Newsletter_OHJA92A.atr / gbankswi.txt < prev    next >
Text File  |  2023-02-26  |  4KB  |  1 lines

  1. Banking Made Easy or, Should You Use¢DEPOSIT Instead of POKE to Access¢Banked Memory?¢¢by Anthony Ramos¢¢You 130XE and RAMBO XL owners know¢how great those 16K memory banks are¢for a RAM disk.  They're also very¢handy when it's time to use¢Atariwriter Plus, and other software¢that uses them to your advantage. ¢But what about when you want to roll¢up your sleeves and use them¢yourself?  You can't just POKE around¢as though it's a continous chunk of¢memory.  The "hhh*LVd" disk reading¢string won't do the job either.  But¢here's some information you can¢really bank on, from Mapping the¢Atari:¢¢When a bank is opened for access, it¢appears through an "access window" in¢the main memory, at locations¢16384-32767.  If you enable bank¢switching, you cause the normal RAM¢in this area to be replaced by the¢bank you've chosen.  You can¢configure the system to one of four¢modes: both processors using main¢memory, CPU (6502 main processor)¢using banked RAM, video (ANTIC) using¢banked RAM, or both using banked¢memory.  In all cases, the only¢memory affected is the area¢16384-32767.¢¢In CPU extended RAM mode, only the¢CPU accesses the extra memory.  All¢ANTIC cycles operate in the main 64K¢memory.  This means you can use the¢extended memory for programs and¢data, while using the main bank for¢display lists and screen data.¢¢In the video extended RAM mode, all¢ANTIC references to the area¢16384-32767 will be directed to the¢secondary bank; all CPU references¢will occur in the main bank.  This¢allows you to access the entire RAM¢memory for programs and data in the¢main area, while locating display¢lists and screen data in the¢secondary bank.¢In the general extended RAM mode,¢both the CPU and ANTIC process in the¢bank switched memory, and the main¢area in 16384-32767 is not used at¢all.¢¢Location 54017 controls which bank is¢accessed, and by which processors. ¢Default at powerup is both chips¢using main memory, or compatibility¢mode.  To access the banks, POKE¢54017 with 193+(Mode*16)+(Bank*4),¢with the modes and banks as follows:¢¢Mode 0: both chips access banked¢memory;¢Mode 1: CPU accesses main memory,¢ANTIC accesses banked memory;¢Mode 2: CPU accesses banked memory,¢ANTIC accesses main memory; and¢Mode 3: both chips access main memory¢(Compatibility mode).¢¢Bank 0: first bank;¢Bank 1: second bank;¢Bank 2: third bank; and¢Bank 3: fourth bank.¢¢An example: If you plan to use the¢banked memory for a character set,¢you must first load it in using the¢6502 main processor.  Poke 54017 with¢193+16*2+0 to access bank one.  Then¢use the familiar POKEs to 852-853 and¢856-857 and "hhh*LVd" to load the set¢into the area 16384-32767.  Now POKE¢54017 with 193+1*16 to make ANTIC¢access the banked area while the 6502¢uses main memory as usual, and POKE¢756, address/256 of your set.  Make¢sure that any statement which affects¢location 54017 is not in the area¢16384-32767, or the computer will¢crash.  You can check the memory¢location of a BASIC statement with¢the line PRINT ADR(" ").  The book¢"Mapping the Atari" goes into more¢detail.¢¢If you don't want to get this¢involved, here are some machine¢language strings which give you the¢same power over the banks that you¢are accustomed to with the "straight"¢memory.  Remember, though, that these¢commands will alter or completely¢erase the RAM disk if present.¢¢When you power up the computer, the¢banks are not clear, but full of¢garbage data.  BCLEAR fills all four¢banks with zeros for a fresh start. ¢BPOKE and BPEEK work like POKE and¢PEEK, except you access the banks¢like a continous block of memory¢locations from 0-65535.  These¢routines take care of the¢bank-switching location 54017, but¢they must not reside in the area¢16384-32767.  Put the lines at the¢top of your program and you will have¢no problem;  type PRINT BPOKE, BPEEK,¢BCLEAR if you want to make sure. ¢They can even be compiled, with one¢catch:  under the TURBO BASIC¢compiler, the screen jitters when the¢banks are accessed.¢¢From a technical standpoint, the¢130XE has only twice the addressable¢memory of the older 800XL.  But as a¢programmer, you actually have over¢three times more usable RAM.  An¢Atari BASIC program which manipulates¢the extra 64K creates quite a¢powerful computing package.  And you¢can take that to the bank.¢¢-------------------------------------¢--¢¢This article was downloaded from the¢ACEC BBS in November, 1989¢