Name: RamBlkAlloc
Address: G0$5012

Function: Allocates banks in Wheels' expansion RAM for program use.

Pass:
r2L
=# of contiguous 64Kb banks needed.
r3L=0 for the Wheels OS to select a bank or # of desired starting bank in Wheels' expansion RAM.

Uses: r2, r3, r6, r9L
bit masking tables at $522d-34.
expansion RAM's BAM homespace at $5045-64.
RAM BAM checksum at $5024.
temporary space at $52c7.

Return:
r3L
=Start # of 64Kb bank that was just allocated.
.X=0 if no error. Otherwise, .X=INSUFF_SPACE if ram allocation was not successful.

Destroyed: .A, .X, .Y.

Synopsis: This routine is similar to the AllocRAMBlock routine, except that this can allocate a bunch of contiguous 64Kb banks in succession in Wheels' expansion RAM memory. Make sure that the program will free these same banks upon exiting, because the Wheels OS will leave these banks alone and will not allow other programs to allocate these same banks.

While you can specify a starting 64Kb bank of expansion RAM prior to calling this routine, the routine will search for the next available 64Kb bank of expansion RAM if the desired starting bank is already in use. Just like AllocRAMBlock, it will mark a contiguous area in Wheels' expansion RAM memory as allocated by marking a value of '0' in the corresponding BAM entries in the expansion RAM BAM workspace. The RAM BAM's checksum value is recomputed and stored at $5024.

See Also: AllocAllRAM, AllocRAMBlock, FreeRAMBlock.

EOF