!pr1
!lm12
!rm75
Patching Applesoft for Garbage-Collection Indicator
                                        ...........Lee Meador

I wanted to know when (how often and how long) Applesoft was doing garbage collection.  The following patch will cause an inverse "!" to placed in the lower right hand corner of the screen whenever garbage collection takes place.

It is a little tricky to patch Applesoft, since it is in ROM!  The first step is to copy the ROMs into the language card RAM space (any slot 0 RAM card will do).  If you have an old Apple II with Integer BASIC on the mother board, you can do this by booting the DOS 3.3 Master.  Otherwise, here are the steps:

!lm+5
]CALL-151
*C081 C081
*D000<D000.FFFFM
!lm-5

Next you need to place some code inside the Applesoft image in the RAM card.  I chose to place the new code on top of the HFIND subroutine at $F5CB.  (The code from $F5CB through $F5FF is never used by Applesoft.)  Here is the routine I put there:

!lm+5
PATCH  PHA
       LDA #$21        INVERSE "!"
       STA $7F7        BOTTOM RIGHT CORNER
       PLA
       JSR GARBAG
       PHA
       LDA #$A0        BLANK BACK ON SCREEN CORNER
       STA $7F7
       PLA
       RTS
!lm-5

You also need to patch the existing "JSR GARBAG" inside Applesoft to jump to this new code.  Here are the patches in hex:

!lm+5
*C083 C083         write enable RAM card
*E47B:CB F5
*F5CB:48 A9 21 8D F7
*F5D0:07 68 20 84 E4 48 A9 A0
*F5E0:8D F7 07 68 60
*C080              write protect RAM card
*control-C
]run your program
!lm-5

Here is a little Applesoft program which generates a lot of garbage strings so you can see the patch in action:

!lm+5
100 DIM A$(100)
110 FOR I = 1 TO 100
120 FOR J = 1 TO 200 : A$(I) = A$(I) + "B" : NEXT
130 PRINT I, : NEXT
!lm-5

Try running the program with different HIMEM values, to see the different effects.
