unit MMC;
{**************************************************************************}
{                                                                          }
{    This C DLL header file first (automatic) conversion generated by:     }
{    HeadConv 4.0 (c) 2000 by Bob Swart (aka Dr.Bob - www.drbob42.com)     }
{      Final Delphi-Jedi (Darth) command-line units edition                }
{                                                                          }
{    Generated Date: 2006-06-10                                            }
{    Generated Time: 오전 8:30:17                                              }
{                                                                          }
{**************************************************************************}

interface
uses
{$IFDEF WIN32}
  Windows;
{$ELSE}
  Wintypes, WinProcs;
{$ENDIF}


{=> d:\진행작업\지스트작업\include\MMC.H <=}


{+// }
{//////////////////////////////////////////////////////////////////////////////// }
{/// }
{/// File Name : mmc.h }
{/// }
{/// Author : Autonics R&D Center YSD }
{/// www.autonics.co.kr }
{/// }
{//////////////////////////////////////////////////////////////////////////////// }
{= }
{$IFNDEF __MMC_H__}
{$DEFINE __MMC_H__}


{$IFDEF __cplusplus}
{$ENDIF}

const
  MAX_CARD = 16;


const
  WR0 = $00;
const
  WR1 = $02;
const
  WR2 = $04;
const
  WR3 = $06;
const
  WR4 = $08;
const
  WR5 = $0a;
const
  WR6 = $0c;
const
  WR7 = $0e;

const
  RR0 = $00;
const
  RR1 = $02;
const
  RR2 = $04;
const
  RR3 = $06;
const
  RR4 = $08;
const
  RR5 = $0a;
const
  RR6 = $0c;
const
  RR7 = $0e;

{$IFDEF __MC8041P__}
const
  RID = $10; {// card id address (for MC8041P)}
{$ENDIF}

{$IFDEF __PMC2ISA__}
const
  RDD = $10; {// user data address (for PMC-2ISA)}
{$ENDIF}


var
  OpenCard_N: function(no: Integer; 
                       isr)(var void): VOID (; 
                       base_addr: Integer; 
                       size: Integer; 
                       irq: Integer): THandle cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var
  CloseCard_N: function(no: Integer): Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var
  CloseCard_all: function: Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var
  InW_N: function(no: Integer; 
                  iocc: Word): Word cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var
  OutW_N: procedure(no: Integer; 
                    iocc: Word; 
                    data: Integer) cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var
  _hookIRQ: function(no: Integer; 
                     isr)(var void): VOID (): Integer cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var
  ValidString: function: PChar cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var
  GetAxes: function: Integer cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 


{$IFDEF __cplusplus}
{$ENDIF}

{$ENDIF /* !defined(__MMC_H__)*/}

var
  DLLLoaded: Boolean { is DLL (dynamically) loaded already? }
    {$IFDEF WIN32} = False; {$ENDIF}

implementation

var
  SaveExit: pointer;
  DLLHandle: THandle;
{$IFNDEF MSDOS}
  ErrorMode: Integer;
{$ENDIF}

  procedure NewExit; far;
  begin
    ExitProc := SaveExit;
    FreeLibrary(DLLHandle)
  end {NewExit};

procedure LoadDLL;
begin
  if DLLLoaded then Exit;
{$IFNDEF MSDOS}
  ErrorMode := SetErrorMode($8000{SEM_NoOpenFileErrorBox});
{$ENDIF}
  DLLHandle := LoadLibrary('MMC.DLL');
  if DLLHandle >= 32 then
  begin
    DLLLoaded := True;
    SaveExit := ExitProc;
    ExitProc := @NewExit;
    @OpenCard_N := GetProcAddress(DLLHandle,'OpenCard_N');
  {$IFDEF WIN32}
    Assert(@OpenCard_N <> nil);
  {$ENDIF}
    @CloseCard_N := GetProcAddress(DLLHandle,'CloseCard_N');
  {$IFDEF WIN32}
    Assert(@CloseCard_N <> nil);
  {$ENDIF}
    @CloseCard_all := GetProcAddress(DLLHandle,'CloseCard_all');
  {$IFDEF WIN32}
    Assert(@CloseCard_all <> nil);
  {$ENDIF}
    @InW_N := GetProcAddress(DLLHandle,'InW_N');
  {$IFDEF WIN32}
    Assert(@InW_N <> nil);
  {$ENDIF}
    @OutW_N := GetProcAddress(DLLHandle,'OutW_N');
  {$IFDEF WIN32}
    Assert(@OutW_N <> nil);
  {$ENDIF}
    @_hookIRQ := GetProcAddress(DLLHandle,'_hookIRQ');
  {$IFDEF WIN32}
    Assert(@_hookIRQ <> nil);
  {$ENDIF}
    @ValidString := GetProcAddress(DLLHandle,'ValidString');
  {$IFDEF WIN32}
    Assert(@ValidString <> nil);
  {$ENDIF}
    @GetAxes := GetProcAddress(DLLHandle,'GetAxes');
  {$IFDEF WIN32}
    Assert(@GetAxes <> nil);
  {$ENDIF}
  end
  else
  begin
    DLLLoaded := False;
    { Error: MMC.DLL could not be loaded !! }
  end;
{$IFNDEF MSDOS}
  SetErrorMode(ErrorMode)
{$ENDIF}
end {LoadDLL};

begin
  LoadDLL;
end.
