[comp.sys.apple] Bankswitching

Xc60039@PORTLAND.BITNET (03/09/87)

  I was wondering if anyone could tell me a simple
way to do bankswitching.  I presently own a unenhanced
][e with 128K.  I'd like to know if the sequence of
opperations to bank switching can be inserted in the
beginning of a basic program or if opperation has to
be incorporated into its own program, which must be
run before running the basic program.  I relize that
basic is a memory consuming language, but I really don't
know too much about binary to make a decent program.
  Also, sometimes my programs have 'blown up' and reverted
into code of some sort .... a bunch of symbols and lower
case lettering.  Is there anyway that the program can be
recovered, assuming that the file has not been saved. Is
there anyway that I can interpret this code?

                         Sincerly,
                              Douglas

schaker@merlin.UUCP (03/11/87)

In article <8703091250.aa19002@SPARK.BRL.ARPA> Xc60039@PORTLAND.BITNET writes:
>
>I'd like to know if the sequence of
>opperations to bank switching can be inserted in the
>beginning of a basic program or if opperation has to
>be incorporated into its own program, which must be
>run before running the basic program.

As far as I know, bankswitching a basic program will kill your program.
I would assume you'd have to write the code in assembler, then CALL the
appropriate area.  The problem is still that the stack has to be saved,
along with any other memory you might be using.  Essentially, all the
bankswitching has to be done in assembler.  The //e programmers reference
manual and ROM routines has the necessary info.   I can mail/post some of
the information, if you'd like.

>  Also, sometimes my programs have 'blown up' and reverted
>into code of some sort .... a bunch of symbols and lower
>case lettering.  Is there anyway that the program can be
>recovered, assuming that the file has not been saved.

Don't know.  Need more info.  Are you fooling with any of the memory from
$800 on?  If so, you might've killed your BASIC program.  It is possible
to reset the loading address, tho.  It's also possible to recover a program
that has been NEWed.  I'm at work and don't remember any of this off hand,
but if you or anyone else reading this wants the info, mail me and
I will reply.


-------------------------------------------------------
Stefan Chakerian        schaker@merlin.unm.edu        |  Take it easy.
                        decvax!unmvax!schaker@merlin  |
USnail: P.O. Box 4741   BITNET: schaker@unmb          |  If it's easy,
Albuquerque,NM  87196   CIS: 74365,231                |  take it twice!
-------------------------------------------------------

JEL@PSUVM.BITNET.UUCP (03/12/87)

Original note:

>  I was wondering if anyone could tell me a simple
>way to do bankswitching.  I presently own a unenhanced
>][e with 128K.  I'd like to know if the sequence of
>operations to bank switching can be inserted in the
>beginning of a basic program or if operation has to
>be incorporated into its own program, which must be
>run before running the basic program.  I realize that
>basic is a memory consuming language, but I really don't
>know too much about binary to make a decent program.

The built in Applesoft ROM's are incapable of using the bank
switched memory.  This is because when you switch to a new bank,
the Applesoft ROM is switched out.  Therefore, you can only do bank
switching from machine language.  I think I have heard of versions
of BASIC that have the necessary routines to allow bank switching.
Maybe directly, or more likely, as a means of storing large arrays.
You might also want to consider using the 128K as a RAM card, and
storing things there.  This CAN be done from Applesoft, I think.
I don't use ProDOS, so I can't really tell you much about this.
ProDOS may be smart enuf to locate some of it's code in the extra
banks, I'm not sure.  If it isn't, I think there are versions that
do, and would also give you more main bank memory useable from
Applesoft.

>  Also, sometimes my programs have 'blown up' and reverted
>into code of some sort .... a bunch of symbols and lower
>case lettering.  Is there anyway that the program can be
>recovered, assuming that the file has not been saved. Is
>there anyway that I can interpret this code?

This is a prime example of why you should always save a program before
you run it.  It is usually a lesson learned the hard way.  If you've been
playing with your bank switches, chances are, that just switching back to
the main bank will restore your program.  Either that, or maybe if you're
playing with POKE, you may have overwritten the area in memory that
stores your program.  This is almost always $800 up to HIMEM.  In large
programs, there is also the danger of overwriting either the program, or
it's data storage if you use the hires graphics pages.  If you think this
might be happening, use HGR2, and set himem at $3FFF, just below the
storage area for HGR2.  HGR1 starts at $2000, so you would have even less
space for prog/data if you were to set himem there.  If you're REALLY
desperate for space, I suppose you could use PEEK's and POKE's to
directly use the space between the end of HGR2 ($5FFF) and HIMEM.

Hope this helps...

- Jon
------------------------------------------------------------------------------
What good are deadlines if you don't use them?
     (I suppose I should put a dead - line at the beginning for the lineater?)
------------------------------------------------------------------------------

ranger@ecsvax.UUCP (Rick N. Fincher) (03/18/87)

Try reading Gary Little's book, Inside the Apple IIe.  It has a dis-
cussion of bank switching and has a short program that runs a BOasic program
in each bank simultaneously.  It is a very useful book, available at
most bookstores that carry Apple II books.

Rick Fincher
ranger@ecsvax