Name: AllocRAMBlock
Address: G0$5009

Function: Allocates a 64Kb bank of Wheels' expansion RAM for a program to use.

Pass: Bank number ($01-$fe) in r6L.

Uses:
ramExpSize
($88c3).
bit masking tables at $522d-34.
expansion RAM's BAM workspace at $5045-64.
RAM BAM checksum at $5024.

Return: .X = $00 (no error.), .X=$06 (BAD_BAM).

Destroyed: .A, .X, & .Y

Synopsis: This routine allocates memory in 64Kb banks in Wheels' expansion RAM by marking the RAM BAM workspace wherever appropriate. You cannot pass a value (in r6L) of $00 and the last bank of Wheels' expansion RAM as they are already allocated by the operating system. Similiarly, you cannot pass a value exceeding the last bank of Wheels' expansion RAM, i.e., passing a bank number of $80 when the Wheels' expansion RAM consists of a 2Mb REU. You cannot allocate an already allocated bank. In those cases of errors, the routine will return .X with a BAD_BAM error value.

Once a valid bank number has been passed, the routine will clear a bit in the corresponding RAM BAM entry to '0', indicating that this bank is now allocated for a program use. The RAM BAM's checksum value is recomputed and stored at $5024.

See Also: AllocAllRAM, FreeRAMBlock, RamBlkAlloc.

EOF