[net.micro.cbm] Turning BASIC ROM into RAM...

KOCYAN@BLUE.RUTGERS.EDU (05/06/86)

From: KOCYAN@BLUE.RUTGERS.EDU

  

   On the Commodore 64, is it possible to turn the BASIC ROM between addresses
$A000 and $BFFF into RAM, and yet keep the BASIC routines there so that they
can be modified?
   I've tried changing the data-direction-register (location $0000), but that
didn't seem to help at all.
   Any advise would be greatly appreciated.  Thanks in advance.

                                        Rob.

-------

prindle@nadc (05/06/86)

From: prindle@NADC

This is very easy.  All you have to do is copy BASIC ROM to RAM first (just
peek each location between a000 and bfff, and poke with the same value -
poke address,peek(address)  ), then flip the LORAM bit in memory byte 1.  It
is done, you are now running BASIC out of RAM - modify at your own risk, prefer-
rably flipping back to ROM BASIC while doing modifications to the RAM version.
Frank Prindle
Prindle@NADC.arpa

daveh@cbmvax.cbm.UUCP (Dave Haynie) (05/06/86)

In article <2167@caip.RUTGERS.EDU> KOCYAN@BLUE.RUTGERS.EDU writes:
>   On the Commodore 64, is it possible to turn the BASIC ROM between addresses
>$A000 and $BFFF into RAM, and yet keep the BASIC routines there so that they
>can be modified?
>   I've tried changing the data-direction-register (location $0000), but that
>didn't seem to help at all.
>   Any advise would be greatly appreciated.  Thanks in advance.

What you want to do here is to first copy the BASIC ROM into the RAM 
underneath.  You can do this by PEEKing every location, then POKEing it
right back -- any writes to the ROM location "bleed through" to RAM.
Once this is done, use the register at 1, not the data direction register,
to turn off BASIC.
-- 

Dave Haynie    {caip,inhp4,allegra,seismo}!cbmvax!daveh
               "There, beyond the bounds of your weak imagination
                Lie the noble towers of my city, bright and gold"
								-Genesis

lishka@puff.UUCP (Christopher Lishka) (05/06/86)

In article <2167@caip.RUTGERS.EDU>, KOCYAN@BLUE.RUTGERS.EDU writes:
> From: KOCYAN@BLUE.RUTGERS.EDU
> 
>    On the Commodore 64, is it possible to turn the BASIC ROM between addresses
> $A000 and $BFFF into RAM, and yet keep the BASIC routines there so that they
> can be modified?
>    I've tried changing the data-direction-register (location $0000), but that
> didn't seem to help at all.
>    Any advise would be greatly appreciated.  Thanks in advance.

	Yes, it is possible to do this.  However, the Ram that lies beneath the
BASIC Rom is empty...i.e. if you flip out BASIC ROM you have nothing below it
to tell the machine what to do!

	The solution is pretty simple...before you flip out the BASIC Rom, make
sure you copy the Rom to Ram.  This will work by just peeking and poking
because of a funny quirk (which was intentional) in the c-64: when there is Rom
on top of Ram, any peek to a location in tha area yeilds what is in Rom;
however, if you poke to the same location the value will be stored in the Ram
underneath the Rom, even though you can't 'see' it while the Rom is still
there.

	The practical value of this nifty trick is that you can transfer any
Rom to the Ram beneath it (and there is Ram beneath ALL Rom on the c-64)
by just:

	a) making sure that Rom is flipped in

	b) performing the following operation in BASIC (although this will
	   work in PASCAL and C and ML):

	   poke x, peek(x): rem x is memory location

After you have copied the range you want (with a loop), just flip out the Rom
and...VOILA!  You now have what was in Rom encoded in Ram, just waiting to be
changed! (Isn't this fun?)  

	Anyways, this can be done with the KERNAL and character sets too.  To
flip in/out the Rom you need to poke to location 1 in memory...consult your
handy reference manual for more details (I don't have mine here with me).  If
you have any other problems, just email to me (using reply or the addresses 
below...hopefully they'll work).


		lishka@rsch.wisc.edu

			or

		talcott!uwvax!puff.wisc.edu!lishka@rsch.wisc.edu

			or
	
		uwvax!puff.wisc.edu!lishka@rsch.wisc.edu


p.s. my apologies if those pathes don't work...I'm still trying to desperately
     make sense out of this mailing sytem (and I don't have any documentation)
-- 
				Chri Lishka
				U.W. Madison

	-my views are not my own; rather, they are those of my pets.

brown@nicmad.UUCP (05/07/86)

In article <2167@caip.RUTGERS.EDU> KOCYAN@BLUE.RUTGERS.EDU writes:
>From: KOCYAN@BLUE.RUTGERS.EDU
>   On the Commodore 64, is it possible to turn the BASIC ROM between addresses
>$A000 and $BFFF into RAM, and yet keep the BASIC routines there so that they
>can be modified?
>   I've tried changing the data-direction-register (location $0000), but that
>didn't seem to help at all.
>   Any advise would be greatly appreciated.  Thanks in advance.

Basically you PEEK all of the addresses and then POKE them back to the same
addresses.  In the C64, when you POKE ROM, it is placed into RAM.  Then you
can set the register bits to turn off BASIC.  Check the 'Programmer's Reference
Guide' for correct bit changing.

The net result is that you are now running BASIC out of RAM, allowing you to
change things.
-- 

              ihnp4------\
            harvard-\     \
Mr. Video      seismo!uwvax!nicmad!brown
              topaz-/     /
             decvax------/

hsgj@batcomputer.TN.CORNELL.EDU (Dan Green) (05/07/86)

In article <2167@caip.RUTGERS.EDU> KOCYAN@BLUE.RUTGERS.EDU writes:
>From: KOCYAN@BLUE.RUTGERS.EDU
>   On the Commodore 64, is it possible to turn the BASIC ROM between addresses
>$A000 and $BFFF into RAM, and yet keep the BASIC routines there so that they
>can be modified?
>   I've tried changing the data-direction-register (location $0000), but that
>didn't seem to help at all.
>   Any advise would be greatly appreciated.  Thanks in advance.
>                                        Rob.

I am sure there will be many responses, but...  First thing you do is copy
the ROM to RAM by yourself.  In basic it would be something like:
   FOR I = 40960 TO 40960+8192: POKE I, PEEK(I): NEXT I
What this does is copy the BASIC ROM to the RAM that is sitting underneath
it.  Then you do the poke in location $0000 to turn off the BASIC ROM.  Now
you have BASIC running out of RAM, and can modify/trash any routines you
want to just by poking into $a000-$booo or by twiddling with a monitor.
-- 
Dan Green    Bitnet:  hsgj@cornella
---------    UUCP:    {decvax,ihnp4,allegra,vax135}!cornell!batcomputer!hsgj
             Arpa:    hsgj@batcomputer.tn.cornell.edu

joels@tekred.UUCP (Joel Swank) (05/08/86)

In article <2167@caip.RUTGERS.EDU>, KOCYAN@BLUE.RUTGERS.EDU writes:
> From: KOCYAN@BLUE.RUTGERS.EDU
> 
>   
> 
>    On the Commodore 64, is it possible to turn the BASIC ROM between addresses
> $A000 and $BFFF into RAM, and yet keep the BASIC routines there so that they
> can be modified?
>    I've tried changing the data-direction-register (location $0000), but that
> didn't seem to help at all.
>    Any advise would be greatly appreciated.  Thanks in advance.
> 
>                                         Rob.
> 
   First copy all of BASIC ($A000-$BFFF) to itself. This makes a copy in
the RAM underneath. Then set bit 0 of location 1 (LORAM) to zero. BASIC
is then running from the RAM. To switch back, set the bit back.
 REF: C-64 Pgmrs. Guide page 260-268.

 Joel Swank
 Tektronix, Redmond, Oregon

marc@reed.UUCP (Marc Leonard) (05/09/86)

In article <904@puff.UUCP> lishka@puff.UUCP (Christopher Lishka) writes:
>In article <2167@caip.RUTGERS.EDU>, KOCYAN@BLUE.RUTGERS.EDU writes:
>> From: KOCYAN@BLUE.RUTGERS.EDU
>> 
>>   On the Commodore 64, is it possible to turn the BASIC ROM between addresses
>> $A000 and $BFFF into RAM, and yet keep the BASIC routines there so that they
>> can be modified?
>
>	Yes, it is possible to do this.  However, the Ram that lies beneath the
>BASIC Rom is empty...i.e. if you flip out BASIC ROM you have nothing below it
>to tell the machine what to do!
>
>	The solution is pretty simple...before you flip out the BASIC Rom, make
>sure you copy the Rom to Ram....
>(and there is Ram beneath ALL Rom on the c-64)

Sorry if this question is out of place, but the discussion fits, so:
   Is is possible to do this trick with Apple ][e ROM?

              Marc Leonard   {ihnp4,decvax,uw-beaver}!tektronix!reed!marc