******************************************************************************
* long SetResAccess(word fileID, word depth);
* word EndResAccess(long resaccessvalue);  [fidL fidH depL depH]
* word SetResFile(word fileID, word depth);
******************************************************************************
*                                       stack A  X  Y  1 2 3 4 5 6 7 8 9
SetResAccess START

           PushWord #0                  result space
           _GetCurResourceFile          (old fileID on stack)
           bcs      SRA_err
           PushWord #0                  result space
           lda      8,S                 Arg: depth
           pha
           _SetResourceFileDepth        (old depth on stack)
           lda     10,S                 Arg: fileID
           pha
           _SetCurResourceFile
           bcc      SRA_End             br: no error

           pla                           normalize stack
SRA_err    lda      #0                    zero acc
           pha                            null returned depth
           sta      3,S                   null returned fileID

SRA_End    pla                          depth
           plx                          fileID

           lda      2,S                 decompose stack frame
           sta      6,S
           pla
           sta      3,S
           pla

           tya                          set a/x return
           rtl

SetResFile   Entry
EndResAccess Entry                                        1 2 3 4 5 6 7
           LDA      4,S
           PHA
           pha
           _SetResourceFileDepth
           pla
           lda      6,s
           pha
           _SetCurResourceFile
           TAY
           LDA      2,S
           sta      6,s
           pla
           sta      3,s
           pla
           tya
           rtl
           END
