To use the USB Gecko.. please add these three files into your project!
Then add usbgecko to your uses clause.

It should read like: "uses SysUtils, ...., usbgecko;" then

you can also open usbgecko.pas, most functions are documented so you can try to check them out.
usbgecko.pas also contains a compiler directive:

{$DEFINE DYNAMIC}

It's usually set meaning it is connected to the FTDI driver (the USB Gecko driver) dynamically.. 
if the driver crashes (which happens quite often if you crash your Wii) you can completely
disconnect from the driver and reload it. If you want to use static linking.. simply change that
line to:

{$UNDEF DYNAMIC}


usbgecko.pas exports the following structures for Wii data:

-----

type TWiiStatus=(wsRunning,wsPaused,wsBreakpoint,wsLoader,wsUnknown);

type TWiiLanguage=(wlNoOverride,wlJapanese,wlEnglish,wlGerman,wlFrench,
 wlSpanish,wlItalian,wlDutch,wlChineseSimplified,wlChineseTraditional,
 wlKorean);
type TWiiPatches=(wpNoPatches,wpPAL60,wpVIDTV,wpPAL60VIDTV,wpNTSC,wpNTSCVIDTV);

-----

TWiiStatus is used if you want to check whether you're game is either running, paused, in
a breakpoint or well.. probably crashed. The other two structures are interesting for game
startup - you can override the language using TWiiLanguage and you can decide whether to
apply certain patches on startup using TWiiPatches (see gecko OS for details on these
patches)!

Then you'll get 3 handy function you'll need for Wii handling as the Wii is big-endian:

//General byte swap functions for
function BSwap(Input:Cardinal):Cardinal; //32 bit integers
function BSwap16(Input:Word):Word;       //16 bit integers
function BSwap64(Input:int64):int64;     //64 bit integers

THese functions turn big-endian integers into little-endian for you. They are written in
x86 assembly and thus perform high-speed swapping.

THe main export you'll get however is the TUSBGecko class. The public datas of this class
are:

-----

      function VersionRequest:Byte;
      function Connect:boolean;
      function WiiStatus:TWiiStatus;
     procedure Disconnect;
      function RareCommand(id:byte):integer;
      function Reconnect:boolean;
     procedure Dump(startdump,enddump:Cardinal;saveStream:TStream);
     procedure Poke(address,value:Cardinal);
     procedure Poke16(address:Cardinal;extvalue:Word);
     procedure Poke8(address:Cardinal;extvalue:Byte);
     procedure Upload(address,length:Cardinal;sendStream:TStream);
     procedure SendRegs(sendStream:TStream);
     procedure SendCheats(sendStream:TStream);
     procedure Pause;
     procedure Resume;
     procedure Hook(pause:boolean;language:TWiiLanguage;patch:TWiiPatches);
     procedure Step;
      function Peek(address:Cardinal):Cardinal;
     procedure CancelBreakpoints;
     procedure BreakpointR(address:Cardinal;aligned:boolean);
     procedure BreakpointW(address:Cardinal;aligned:boolean);
     procedure BreakpointRW(address:Cardinal;aligned:boolean);
     procedure BreakpointX(address:Cardinal);
      function BreakpointHit:boolean;
     procedure GetRegisters(strm:TStream);
     procedure SendFail;
     procedure Screenshot(output:TBitmap);
   constructor Create;
    destructor Destroy;
      property Connected:boolean;
      property onNewChunk:TOnChunkTransfer;

----

I guess.. Knockout.. I'll therefore slowly explain these functions in order on how you probably
will use them:

1. constructor Create;
Use this constructor to initialize the class.

2. destructor Destroy;
Opposite.. use this.. to free it!

3. function Connect:boolean;
Allows you to connect to the USBGecko hardware

4. procedure Disconnect;
And disconnect!

5. function Reconnect:boolean;
Kinda like Disconnect and Reconnect in one.

6. procedure Hook(pause:boolean;language:TWiiLanguage;patch:TWiiPatches);
This function allows you to start a game. YOu can override the language and you can apply
patches. All values have default values:
- pause = false:  the game immediately starts normally
- language = wlNoOverride: use console language
- patch = wpNoPatches: Do not apply any patches

7. procedure Dump(startdump,enddump:Cardinal;saveStream:TStream);
Dump data from memory.. your memory area begins at startdump and ends at enddump.. data is
stored to a stream.


=====
Okay, we're ready for a very basic example: a function which starts the game waits like 20
seconds and dumps mem1:

 Gecko:=TUSBGecko.Create; //Create
 Gecko.Connect; //Connect to USB Gecko
 Gecko.Hook(false,wlFrench); //Start the game and force it to French
 Sleep(20000); //Wait 20 seconds
 Stream:=TFileStream.Create('dump.bin',fmCreate);
 Gecko.Dump($80000000,$81800000,Stream); //Dump mem 1 to the filestream
 Gecko.Disconnect; //we're done, disconnect
 FreeAndNil(Stream);
 FreeAndNil(Gecko);
=====

8. procedure Pause;
   procedure Resume;
Pause game, resume game, does that need an explanation?

9. procedure Upload(address,length:Cardinal;sendStream:TStream);
opposite of Dump.. explain where to send stream contents to  - you do not need to send the
complete stream! THe length parameter tells it what to send!

10. function Peek(address:Cardinal):Cardinal;
Read a 32 bit value!

11. procedure Poke(address,value:Cardinal);
    procedure Poke16(address:Cardinal;extvalue:Word);
    procedure Poke8(address:Cardinal;extvalue:Byte);
Poke data in the game memory. For Speed reasons the new USBGecko has seperated functions
for 32 bit poking, 16 bit and 8 bit.

12. procedure BreakpointR(address:Cardinal;aligned:boolean);
    procedure BreakpointW(address:Cardinal;aligned:boolean);
    procedure BreakpointRW(address:Cardinal;aligned:boolean);
Set data breakpoints of read, write or read/write type. If aligned is true you can only bp
addresses good to 8 bytes (meaning a hit on 817F8000  would be also good for 817F8004). If
aligned is false (default), then it will only break on exact addresses. Please note that
the USBGecko.pas class will not wait until a breakpoint has hit!

13. procedure BreakpointX(address:Cardinal);
Same like data breakpoints, except it's an execute breakpoint and alignment is useless.

14. function BreakpointHit:boolean;
This function returns true if a break point has just hit.

15. procedure SendRegs(sendStream:TStream);
    procedure GetRegisters(strm:TStream);
These function allow to send modified registers and receive them. Please note that you can
receive floatng point registers but you cannot send them (for security reasons).

16. procedure CancelBreakpoints;
During waiting for a breakpoint you shouldn't use other functions (yet you can). You can
however always cancel breakpoints!

17. procedure Step;
Also for breakpoints.. once a bp has hit. You can use this command to stop into the next
instruction.

18. procedure SendFail;
Sometimes the Wii crashes.. but wait.. maybe it does not.. just send some Fails to it and
SOMETIMES the Gecko recovers (SendFail sends a command to the Gecko which is intended to reset
everything - if a game just halted.. you might be able to recover).

19. procedure Screenshot(output:TBitmap);
Just take a screenshot and store it into a Bitmap. Widescreen is not respected, however 480p
is.

20. function VersionRequest:Byte;
The Gecko software has a version identifier. If you receive 0 you have an old version. 80+ means:
new!

21. function WiiStatus:TWiiStatus;
Requests the Wii status - like if the game is running or not - or whether you're stil in the loader.

22. procedure SendCheats(sendStream:TStream);
Sends a stream of cheat codes. They need to be stored in hex.

23. function RareCommand(id:byte):integer;
Only use this command if you know what you're doing. It sends a pure byte of data to the

24. property Connected:boolean;
Just check whether you're connected to the gecko or not. Read-only!

=================

During dumps, cheat uploads or regular uploads the USBGecko.pas also sends status updates:

property onNewChunk:TOnChunkTransfer;

type TOnChunkTransfer=procedure(current,finl,bytestrans,memrange:integer;lastfail:boolean) of object;

so you can do something like Gecko.onNewChunk=NewChunk;

procedure NuwChunk(current,final,bytestransferred,memoryrange:integer;lastfail:boolean);
begin

end;

current=which chunk am I transferring
finl = how many chunks do we have (-1)
bytestrans = How many bytes are transferred
memrange = How many do I have to transfer
lastfail = Did the last package have a transfer error?

======================

Several functions may also raise Exceptions - the exceptions types are:

type EUSBGeckoException=class(Exception) //General exception - check the message to get details
end;

type ECheatStreamException=class(Exception) //Sending cheats exceptions
end;

type ERegStreamException=class(Exception) //Sending registers exception
end;




=========================


FAQ:


1. Is the usbgecko.pas the same which is used by the WiiRd console?
-Yes, it is not stripped down or anything!

2. How come the WiiRd console offers more commands, such as "gamename" or "multipoke".
-The WiiRd console is an implementation of usbgecko.pas - thus it uses the commands usbgecko.pas
exports and puts them into its own structure. That means WiiRd is no better than usbgecko.pas!
It is just using special commands - multipoke is nothing else but a row of multiple poke
commands while gamename just dumps 80000000 to 80000006 and shows that data as a string.
There is no special magic in WiiRd - all communication goes via usbgecko.pas .

3. What's the difference between static and dynamic linking?
-When you statically link against the FTDI driver (FTDId2xx.dll) WiiRd will not be able to
start if the DLL is not availible. Additionally in case it crashed or has a stack erorr,
you need to restart your application/WiiRd. When you're dynamically linked, instructions
are sent a little slower but all mentioned disadvantages vanish: your application can warn
if the file does not exist and it can dynamically load and unload it - meaning if your stack is
an unfixable disaster, simply unload it and reload it - WiiRd for example unloads ftdid2xx.dll
after every errror message - so you might have already assumed: WiiRd is dynamically linked!