Here is the list of steps needed to use Jam plugins in custom programs/demos:

1. Load tune

Load it from file to memory in standard way.

2. Load plugin

This one is a bit tricky. Firstly you have to check current machine, load the proper plugin somewhere into the memory. DSP type is only usable on Falcon030, cpu based plugins will work on any Atari ST/STe/TT/Falcon030. If not, send complaints to plugin author ;).

3. Relocate plugin

After that loaded plugin needs to be relocated. Plugins are PRG's, and all the code is program counter relative with program base at $0 address. If we want to use it, we have to change this program base to place where the plugin is loaded.

Here is the code that will do all the dirty work:

C function declaration (reloc.h)
void relocateProgram(void *prgPtr);


m68k relocation routine(reloc_m68k.s)
XDEF    _relocateProgram

ph_branch       EQU $00           ; Start branch in header    [Headerinfos]
ph_tlen         EQU $04-2         ; Lenght of TEXT segment
ph_dlen         EQU $08-2         ; Length DATA segment
ph_blen         EQU $0C-2         ; Length  BSS segment
ph_slen         EQU $10-2         ; Length  Symbol table
ph_res1         EQU $14-2         ; reserved
ph_res2         EQU $18-2         ;     
ph_flag         EQU $1C-2         ; 
ph_len          EQU ph_flag+2

_relocateProgram:
        move.l  4(sp),a0
        move.l  ph_tlen(A0),D0      
        add.l   ph_dlen(A0),D0      
        add.l   ph_slen(A0),D0      
        lea     ph_len(A0,D0.l),A1  
        lea     ph_len(A0),A0       
        move.l  A0,D0               
        move.l  (A1)+,D1            ; First relocated word (32 Bit Offset)
        beq.b   end_rel             ; =0 => no relocation
        adda.l  D1,A0               
        add.l   D0,(A0)             
        moveq   #0,D1               
        moveq   #1,D2               
rel_loop: 
        move.b  (A1)+,D1            
        beq    end_rel              
        cmp.b   D2,D1               
        beq.b   add_254             
        adda.l  D1,A0               
        add.l   D0,(A0)             
        bra.b   rel_loop            
add_254: 
        lea     254(A0),A0          ; 254 Bytes offset
        bra.b   rel_loop            
end_rel:        
        rts



page:2/8