How does this C++ .h stuff convert to D2 code

Hi,

This is some code from a .h file which I'm having problems with. I'm
trying to use a dll that has a com object in it. If you see something
that's wrong please tell me. Thanks in advance.

unit exec6502;

interface

uses Windows, OLE2;

//
//  processor status (regP) flags
//
const
C_FLAG = $01;
Z_FLAG = $02;
I_FLAG = $04;
D_FLAG = $08;
B_FLAG = $10;
R_FLAG = $20;
V_FLAG = $40;
N_FLAG = $80;

// #define C_FLAG   0x01
// #define Z_FLAG   0x02
// #define I_FLAG   0x04
// #define D_FLAG   0x08
// #define B_FLAG   0x10
// #define R_FLAG   0x20
// #define V_FLAG   0x40
// #define N_FLAG   0x80

// struct EXEC6502_CONTEXT
// {
//      WORD regPC;
//      BYTE regA, regX, regY, regS, regP;
// ];

type
EXEC6502_CONTEXT = record
  regPC : short;
  regA : byte;
  regX : byte;
  regY : byte;
  regS : byte;
  regP : byte;
end; // of EXEC6502 structure

const
// #define MF_READ_DIRECT    0x00000001
MF_READ_DIRECT = $00000001;
// #define MF_WRITE_DIRECT   0x00000002
MF_WRITE_DIRECT = $00000002;
// #define MF_READ_ILLEGAL   0x00000004
MF_READ_ILLEGAL = $00000004;
// #define MF_WRITE_ILLEGAL  0x00000008
MF_WRITE_ILLEGAL = $00000008;
// #define MF_ADJUST_ADDRESS 0x00000010
MF_ADJUST_ADDRESS = $00000010;
// #define MF_RESERVED       0xFFFFFFE0
MF_RESERVED = $FFFFFFE0;

???????
//typedef BYTE (*EXEC6502_MEMREAD_PROC)(WORD);
????????
//typedef void (*EXEC6502_MEMWRITE_PROC)(WORD, BYTE);

// struct EXEC6502_MEM_DESCRIPTOR
// {
//      DWORD dwAddrMin;
//      DWORD dwAddrMax;
//      DWORD dwFlags;
//      EXEC6502_MEMREAD_PROC pfnRead;
//      EXEC6502_MEMWRITE_PROC pfnWrite;
// };
type
EXEC6502_MEM_DESCRIPTOR = record
  dwAddrMin : integer;
  dwAddrMax : integer;
  dwfFlags : integer;
  pfnRead : EXEC6502_MEMREAD_PROC;  // not sure about these 2
  pfnWrite : EXEC_MEMWRITE_PROC;
  //
end;

I'm lost with these defines. 8-(
// #define BEGIN_MEMORY_MAP(nm) static const EXEC6502_MEM_DESCRIPTOR
(nm)[] = {
// #define MEMORY_MAP_ENTRY { 0, 0, 0, 0, 0 }
// #define END_MEMORY_MAP { 0, 0, 0, (EXEC6502_READ_PROC)0xFFFFFFFF, 0 }

Quote
};

// struct EXEC6502_CREATE
// {
//      DWORD dwFlags;
//     CLSID clsid;
//      LPBYTE rgbMemory;
//      const EXEC6502_MEM_DESCRIPTOR *pmd;
// };
type
EXEC6502_CREATE = record
  dwFlags : integer;
  clsid : TCLSID;   // not sure on this what happens to const
  rgbMemory : ^byte;  // not sure on this one
  // clueless on last one here is a stab
  pmd : EXEC6502_MEM_DESCRIPTOR;
end; // of EXEC6502_CREATE

// struct IExec6502 : IUnknown
// {
//      virtual void GetContext(EXEC6502_CONTEXT &ctx) = 0;
//      virtual void SetContext(const EXEC6502_CONTEXT &ctx) = 0;
//      virtual void Reset() = 0;
//      virtual int  Exec(int cCycles) = 0;
//      virtual int  Nmi() = 0;
//      virtual int  Irq() = 0;
// };

What happens to the 0 initialization? I'm certain I messed this section
up. 8-)

IExec6502 = class(IUnknown)
public // is this neccesary??
    function GetContext( ctx : EXEC6502_CONTEXT) ; virtual;
    function SetContext( ctx : EXEC6502_CONTEXT) ; virtual;
    // on both of these i'm not certain what to do with the
    // setting to zero part as well as &ctx
    function Reset; virtual;
    function Exec( cCycles : integer) ; virtual;
    function Nmi ; virtual;
    function Irq ; virtual;
end;

????????
// #ifndef EXEC6502_API
// #define EXEC6502_API extern "C" __declspec(dllimport)
// #endif

// EXEC6502_API HRESULT EclCreate6502(EXEC6502_CREATE &cs, IExec6502
*&pExec);
// EXEC6502_API int EclDasm6502(LPTSTR S, const BYTE *A, unsigned long
PC);

function EclCreate6502(var cs : EXEC6502_CREATE, var pExec : IExec6502);
HRESULT
function EclDasm6502(s : PAnsiChar; a : ^byte, PC : cardinal);

// #endif // _EXEC6502_H_

implementation

end.

Thanks again,

Sasha