Author Topic: How to make a NEO2 Plugin  (Read 6591 times)

0 Members and 1 Guest are viewing this topic.

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3827
How to make a NEO2 Plugin
« on: October 11, 2009, 08:07:27 PM »
How to make a NEO2 Plugin

How to make a Plug-In patch for MD of NEO2 Ultra Menu Application

This note will explain in detail how to make plug-in for the MD of NEO2 Ultra Menu. First, we know that the plug-in is a DLL type use by Neo2Client.exe. When the app launch up, it will enumerate all of the plug-in dll located in the special folder” C:\NEO2 Ultra Menu\ Plug_In\MD”. Then, when MD game rom adds, the app will the all these plug-in dll in order, passing the rom file path as a parameters. So the Third-party plug-in providers can do any pretreatment befor the rom add to MD cartridge.

The following shows how to make a plug-in DLL in VC6:

1. first, setup a dll project:
 



2. Use the default option, this is a dll support MFC.
 



3. Derivative a sub-class from CPlugBase, CPlugBase declare in “PlugBase.h”,  then you can add your patch work inside the function of Patching(), which will be call by the main app.

class CMyPlug : public CPlugBase 
{
public:
   CMyPlug(){
   };

   virtual ~CMyPlug(){
   };

public:


   void Patching(LPCTSTR szRomPath){
      char c[256];
      wsprintf (c, "This ROM path is %s", szRomPath);
      MessageBox(NULL, c, "Plug Message", MB_OK|MB_ICONINFORMATION);
   }

   void Release(){
      delete this;
   }

private:
};


4. Add a export function as:

BOOL WINAPI Plug_CreateObject(void ** pobj){
   *pobj = new CMyPlug;
   return *pobj != NULL;
}

5. OK, there's only so much. Copy the dll to the destination after compile finish, then try you great job! More details can look at the demo source.
In my world,have 0 and 1 only ......Matrix World......

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: How to make a NEO2 Plugin
« Reply #1 on: October 11, 2009, 09:49:50 PM »
Great, now i will start doing my rom patching plugin  ~sm-42.gif~

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3827
Re: How to make a NEO2 Plugin
« Reply #2 on: October 11, 2009, 09:52:36 PM »
Great, now i will start doing my rom patching plugin  ~sm-42.gif~

cheers!   ~sm-35.gif~
In my world,have 0 and 1 only ......Matrix World......

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: How to make a NEO2 Plugin
« Reply #3 on: October 12, 2009, 01:32:41 PM »
I will contribute to the thread too!

Here is how you can test your plugins ->

Code: [Select]
//neo alloc function pointer wrapper
typedef BOOL (WINAPI * IMPORT_ADDRESS) (void **);

HMODULE module = LoadLibrary ("PlugDemo.dll");

if (module == NULL)
{
MessageBox("Can't load plugdemo.dll",":(",MB_OK);
return ;
}

IMPORT_ADDRESS allocAddr = (IMPORT_ADDRESS)GetProcAddress (module, "Plug_CreateObject");

if (allocAddr == NULL)
{
MessageBox("Can't locate alloc address in plugdemo.dll",":(",MB_OK);
return  ;
}

CMyPlug* p;

if(!allocAddr((void**)(&p)))
MessageBox("Memory alloc function address failed!",":(",MB_OK);
else
       {
p->Patching("c:\\myrom.bin");
                p->Release()
       }

FreeLibrary(module);

 ::sm-12.gif:: O0O O0O O0O

By the way Dr.Neo , can we add more functions to the plugin? or we are only stricted to Patching()? My plugin for example will need a "SetMode( lpcstr arguments or bit flags)" or similar function because my framework has complex functionality  ~sm-34.gif~.

Or another idea :
How about making Patching() to take 2 arguments? 1 for the rom file , and another for aguments...

Then the NEO myth programmer can use the plugins like this :

plugin->Patching(rom file name , "-append BIN -setIO J6 ...more")
« Last Edit: October 12, 2009, 02:05:03 PM by Conle »

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3827
Re: How to make a NEO2 Plugin
« Reply #4 on: October 12, 2009, 03:13:14 PM »
ok,it's our new aim  ~sm-37.gif~
In my world,have 0 and 1 only ......Matrix World......

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: How to make a NEO2 Plugin
« Reply #5 on: October 12, 2009, 03:44:59 PM »
ok,it's our new aim  ~sm-37.gif~

Excellent !!!! ~sm-42.gif~ ,
i will start working on the plugin later today ... assuming that there will be 2 arguments.... ::sm-10.gif::