62h PK$SETP set current pack
Input A register - Non-zero if a pack change is to be reported as an error.
B register - Controls which pack to select.
Output A register - Pack type.
X register - Pack size in 8k units or garbage for Pack A (the internal RAM).
Description

Sets current pack as the contents of B register. Sets up the operating system to access the current pack.

This routine must be run before calling any further pack routines if the packs have been turned off or the slots modified in any way (ie. by a user machine code program).

This routine operates in two distinct ways:

If B register is 0 (for Pack A - internal RAM) then

  1. Set PKA_PKID to point to ID string in PKT_ID for current slot.
  2. Set current pack to RAM by setting PKB_CURP=0. If packs are on (PKB_CPAK<>$FF) then set PKB_CPAK=0 and leave slots in there current state, if not then leave PKB_CPAK=$FF.
  3. Set the current RAM file address to 0, ie. PKW_CMAD=0.
  4. Always returns success.

If B register is between 1 and 3 (pack A - D) then

  1. Set PKA_PKID to point to ID string in PKT_ID for current slot.
  2. If PKB_CPAK=$FF then power up all the slots. If PKB_CPAK<>$FF then it is assumed the slots are powered up. Sets PKB_CURP=PKB_CPAK=current pack
  3. Check the battery voltage. If it is low then return battery low error.
  4. Log on the current slot. The logon procedure is as follows:
    • Read first byte of pack. (Known as the ID byte of the pack)
    • If zero then return with no pack in slot error and set first byte of ID string to 0.
    • If $FF then blow to $7f, work out size and type of pack then save ID string to pack.
    • If blowing first byte fails or saving ID string fails then attempt to blow first byte to zero and return with write pack error.
    • If, when checking pack size, the pack is not completely blank then return with pack not blank error.
    • If the ID byte is valid then compare first 10 bytes on pack with the ID string in RAM. If this has changed update ID string in RAM. Report pack changed error only if A register was non-zero.
    • If the ID byte is invalid return with unkown pack type error and set the first byte in the ID string in RAM to $FF.
  5. Sets the current pack address to 0 and sets PKB_HPAD=0 and PKW_CPAD=0.
  6. Leaves the slots in the following condition even if an error is reported.
    • Slots are powered up.
    • Current slot is selected (Current SS_B is low).
    • SOE_B is low.
    • SPGM_B is high.
    • SCLK is low.
    • SMR is low.

    The only exception to this is the battery low error. When this is returned the slots are left in an indeterminate state.

If any error occurs (except no pack) then the first byte of the current ID string in RAM is set to $FF.In the case of a no pack error this byte is set to zero. In either case all other bytes of the ID string are invalid.

Example To access slot 1
        CLRA                    ; Pack changed error not required
        LDAB    #PAKB          ; Access slot 1 (upper side slot)
        OS      PK$SETP
        BCS     ERROR           ; Report error
Errors 246 - no pack in slot
245 - write pack error
242 - pack has changed
243 - selected an invalid pack
194 - battery too low
240 - unknown pack type
244 - attempt to write to read only pack
241 - pack not blank