GetOneDoc  START    PSYCHODATA
*****************************************************************************
*
*          Handle GetBundle(Handle insanity);
*
* This bastard uses all the intellegence that Mark and I could muster to
* parse some really nasty insanity cooked up by Andy (who is now out of my
* will)
*
* Marc W Wolfgram 10/19/91  1:27:14
*****************************************************************************
*
           pha                          fake out the stack for two pointers
           pha
           pha
           pha
           phb
           phk
           phd                                                1 1 1 1
           tsc                                         dp+7 9 1 3 5 7
           tcd                          frame done: dpbRTLpntrpntrhndl

           ldx      17
           lda      15
           phx
           pha
           _HLock                       ours...

           pha                          result
           pha
           PushLong #18                 header size
           PushWord >edResID
           PushWord #$8018              locked, nocross, nospecial
           PushLong #0
           _NewHandle
           bcs      memerr              123456789abcd
           phd                          dphndldpbRTLpntr
           tsc
           tcd
           ldy      #2
           lda      [3]
           sta      13
           lda      [3],y
           sta      15                  deref done to target pointer
           pld                          back to our dp w/target hndl on stack

           ldy      #2
           lda      [15]
           sta      11
           lda      [15],y
           sta      13                  deref done to source pointer

           ldy      #16
           phy
headerloop lda      [11],y              insanity
           sta      [7],y
           dey
           dey
           bpl      headerloop          std bundle header copied

           ply                          index to count of onedocs
           lda      [7],y
           sta      numdocs             FYI pushlong (4 * numdocs) + 18
           stz      numdocs+2
           asl      numdocs
           rol      numdocs+2
           asl      numdocs
           rol      numdocs+2           onedocs * 4 = handle array size
           clc
           lda      numdocs
           adc      #18
           tax
           lda      numdocs+2
           adc      #0
           pha
           phx                          total bundle handle size on stack
           lda      7,s                 sizehndldpbRLT...
           pha
           lda      7,s
           pha                          handle on the stack too
           _SetHandleSize
           bcc      headerdone
memerr     lda      1,s
           ora      3,s
           beq      memerr1
           _DisposeHandle
           lda      #0
           pha
           pha
memerr1    bra      decompose

headerdone iny                            we have the header stuff + enough
           iny                            memory at the end for a onedoc
           sta      docHidx               handle array... to be continued!




decompose  ply                          hndldpbRTLpntrpntrhndl
           plx
           pld
           pla
           sta      11,s
           pla
           sta      11,s
           pla
           pla
           pla
           pla
           plb
           tya
           rtl

numdocs    ds       4
docHidx    ds       2

           END
