library delphi_template; uses SysUtils, Classes; type FSetSize = procedure(rom: ppchar; size:pInteger; newSize: Integer); stdcall; type FPGetRom = procedure(rom: PPChar; size: pInteger; crc: pchar; patch:Integer; resize:FSetSize); stdcall; type FPLaunchEmulatorFile = procedure(f:pchar); stdcall; type FPLaunchEmulatorCRC = procedure(crc:PCHAR); stdcall; type TFunction=record getRom: FPGetRom; launchEmulatorFile: FPLaunchEmulatorFile; launchEmulatorCRC: FPLaunchEmulatorCRC; end; type PGame = ^TGame; TGame = record nextGame: PGame; crc: PChar; name: PChar; named: PChar; num: Integer; size: Integer; location:PChar; save: PChar; publisher: PChar; sourceRom: PChar; end; {$R *.res} var _functions: TFunction; procedure initPlugin(functions: TFunction; dir:pchar); stdcall; begin _functions := functions; end; function getName : pchar; stdcall; begin result := 'delphi_sample'; end; function getAuthor : pchar; stdcall; begin result := 'Replouf66'; end; function getVersion : pchar; stdcall; begin result := '1.0'; end; function getSDKVersion : pchar; stdcall; begin result := '0.1'; end; function getSmallComment : pchar; stdcall; begin result := 'Extract rom to current directory'; end; procedure setSize(rom: ppchar; size:pInteger; newSize:Integer); stdcall; begin {This procedure is called by the module for resize a rom. You need to do this procedure for receive patched rom.} ReallocMem(rom^, newSize); size^ := newSize; end; function inPopupMenuHave: pchar; stdcall; begin {This function is called for create popupMenu in the list of game} result := 'popupMenu1'+#0+'popupMenu2'+#0#0; end; procedure onPopupMenuHaveClick(act:Integer; game:PGame); stdcall; var F: TFileStream; rom, tmp2: pchar; size: Integer; buffer: array[0..1023] of char; k, s:Integer; tmp: PGame; begin {the first popupMenu have the action "0", the second "1", ...} tmp := game; while tmp <> nil do begin new(rom); if act = 1 then // popuMenu1 _functions.getRom(@rom, @size, tmp^.crc, 0, @setSize) // get the rom patched by the modules. else // popuMenu2 _functions.getRom(@rom, @size, tmp^.crc, -1, @setSize); // get the rom not patched by the module. F := TFileStream.Create(game.named + '.gba', fmCreate, fmShareDenyWrite); s := size; k := sizeOf(buffer); tmp2 := rom; while s > 0 do begin if s < k then k := s; strMove(buffer, tmp2, k); inc(tmp2, k); dec(s, k); F.Write(buffer, k); end; F.Free; FreeMem(rom); tmp := tmp^.nextGame; // here we select the next rom for extract it. end; end; exports initPlugin, inPopupMenuHave, getName, getAuthor, getVersion, getSDKVersion, getSmallComment, setSize, onPopupMenuHaveClick; begin end.