****************************************************
*                                                  *
*       PowerPacker library glue code              *
*       (for Lattice C)                            *
*                                                  *
*       Copyright (c) 1990 by Nico François        *
*                                                  *
****************************************************

*********************************************************************
*                                                                   *
*    To assemble the SMALL_CODE version USE:                        *
*      ASM -oLIB:ppSCglue.o -iINCLUDE: -dSMALL_CODE latticeglue.asm *
*                                                                   *
*    To assemble the LARGE_CODE version USE:                        *
*      ASM -oLIB:ppLCglue.o -iINCLUDE: -dLARGE_CODE latticeglue.asm *
*                                                                   *
*    To use link with 'LIB:ppSCglue.o' or 'LIB:ppLCglue.o'          *
*                                                                   *
*    (based on ARP glue code, thanks arp :-)                        *
*                                                                   *
*********************************************************************

         IFND LIBRARIES_POWERPACKER_LIB_I
         include "libraries/powerpacker_lib.i"
         ENDC

* First some macros

GLUEDEF  MACRO
         XDEF _\1
_\1:
THIS_LIB SET _LVO\1           ; Set the offset to call
         ENDM

*
*        Set SMALL_CODE=1 for a4 addressing...
*        Set LARGE_CODE=1 for absolute addressing...
*        if neither, just cause an error...
*

CALLPP  MACRO
        move.l a6,-(a7)         ; Save a6...
        IFD SMALL_CODE
        move.l _PPBase(a4),a6   ; If a4 addressing....
        ENDC
        IFD LARGE_CODE
        move.l _PPBase,a6       ; If not a4 addressing...
        ENDC
        IFND SMALL_CODE
        IFND LARGE_CODE
        moveq.l #12323,a0       ; Cause an error!
        ENDC
        ENDC
        jsr THIS_LIB(a6)
        move.l (a7)+,a6
        ENDM

* Now for the actual glue routines

        XREF _PPBase

        SECTION "PPGlue",CODE

*    ULONG ppLoadData (char *, ULONG, ULONG, UBYTE **, ULONG *, BOOL (*)());
*    D0                A0      D0     D1     A1        A2       A3

        GLUEDEF ppLoadData
        movem.l a2/a3,-(a7)
        move.l  8+4(a7),a0
        movem.l 8+8(a7),d0/d1/a1/a2/a3
        CALLPP
        movem.l (a7)+,a2/a3
        rts

*    ULONG ppCalcChecksum (char *);
*    D0                    A0

        GLUEDEF ppCalcChecksum
        move.l 4(a7),a0
        CALLPP
        rts

*    ULONG ppCalcPasskey (char *);
*    D0                   A0

        GLUEDEF ppCalcPasskey
        move.l 4(a7),a0
        CALLPP
        rts

*    void ppDecrypt (UBYTE *, ULONG, ULONG);
*                    A0       D0     D1

        GLUEDEF ppDecrypt
        move.l  4(a7),a0
        movem.l 8(a7),d0/d1
        CALLPP
        rts

*    BOOL ppGetPassword (struct Screen *, UBYTE *, ULONG, ULONG);
*    D0                  A0               A1       D0     D1

        GLUEDEF ppGetPassword
        movem.l 4(a7),a0/a1
        movem.l 12(a7),d0/d1
        CALLPP
        rts

*    void ppDecrunchBuffer (UBYTE *, UBYTE *, ULONG *, ULONG);
*                           A0       A1       A2       D0

        GLUEDEF ppDecrunchBuffer
        move.l a2,-(a7)
        movem.l 4+4(a7),a0/a1/a2
        move.l  4+16(a7),d0
        CALLPP
        bra.s PopA2rts

*    BOOL ppGetString (struct Screen *, UBYTE *, ULONG, char *);
*    D0                A0               A1       D0     A2

        GLUEDEF ppGetString
        move.l a2,-(a7)
        movem.l 4+4(a7),a0/a1
        movem.l 4+12(a7),d0/a2
        CALLPP
PopA2rts:
        move.l (a7)+,a2
        rts

*    BOOL ppGetLong (struct Screen *, ULONG *, char *);
*    D0              A0               A1       A2

        GLUEDEF ppGetLong
        move.l a2,-(a7)
        movem.l 4+4(a7),a0/a1/a2
        CALLPP
        bra.s PopA2rts

        END
