Author Topic: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2  (Read 3851 times)

0 Members and 1 Guest are viewing this topic.

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3467
How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2

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:

   // Note:
// Thanks Mr.Conle ! The function prototype of this version had been improved!
   bool Patching(NeoResultBlock *pBlock)
   {
      // demo code here!
      char c[256];
      wsprintf (c, "OK, The ROM buffer add is 0x%x, size:%d save size:%d arg:%s",
         pBlock->romBuffer, pBlock->romBufferLength, pBlock->saveAllocationSize, pBlock->arguments);
      MessageBox(NULL, c, "Plug Message", MB_OK|MB_ICONINFORMATION);
      return true;
   }
   void Release(){
      delete this;
   }

private:
};

and the pointer parameter inside Patching () is define as NeoResultBlock struct:

struct NeoResultBlock
{
   void* romBuffer;      // points to the loaded and decoded buffer without header . Just how it is before you add it to the cart filesystem.
   char* arguments;      // the configuration arguments. Set it to NULL if there are no arguments.

   int romBufferLength;    // the length of the rom starting from the header
   int saveAllocationSize; // saveAllocationSize is the save size selected in the list view
                     // 0        - no save
                     // 8       - 8kbit
                     // 32   - 32 kbit
                     // 128   - 128kbit
                     // -1      - 24C01
};

Here arguments is a string contains some optional arguments as below, most of these argument are obtain from app by user setting.

-r(optional) stands for Region ( EUROPE / ASIA / FRANCE / JAPAN / USA / BRAZIL / HONGKONG )
-d(optional) stands for IO device ( JOYPAD , JOYPAD6 ,RS232C ...and more )
-c(optional) stands for checksum fix ( 1 or 0 )
-h(optional) stands for Copyright fix ( 1 or 0)
-f(optional) stands for common FIXES : Fixes copyright and checksum <- This will fix many "not working" reports
-a(optional) stands for add game genie code
-s(optional) stands for suffix means the type of rom


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.

now can support ALMOST plugin arguments !  ~sm-42.gif~
In my world,have 0 and 1 only ......Matrix World......

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2095
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #1 on: October 15, 2009, 04:49:34 AM »
Excellent , now i will start working on the plugin !

Just two questions :

Quote
-s(optional) stands for suffix means the type of rom
.BIN , .SMD , .001 , .008  ...right ?


Also , do you want me to add support for "24C02" , "24C08" , "24C16" , "24C65" (Acclaim/CM mappers)
?

There are only a few games that need this eeprom type...Like Micro machines..
But i know how to detect all types...

-edited-
No change in the interface is needed if i implement these types since the md myth flashcart already supports eeprom, so i will just map all these eeprom mappers to 24C01 and hopefuly they will work fine. I just need to know if you want this...

-edited-
Also i know a good way to detect if a rom is broken and not supported by your loader. I will implement this too so the user will know if the ROM has passed all checks with 99%+ success rate...

I will try to make the plugin as stable as possible & fix some common issues that result in "bad burn".  ~sm-42.gif~
« Last Edit: October 15, 2009, 08:56:00 AM by Conle »

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #2 on: October 15, 2009, 06:43:36 PM »
 -s(optional) stands for suffix means the type of rom

means the file name suffix added from disk, for example, file name as "Double Dragon.sms" will be "-s sms"; ::sm-21.gif::

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3467
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #3 on: October 16, 2009, 12:06:57 AM »
we just need support one eeprom mode --- 24c01

and i think we should add one option for the save,here is my suggestion:

before:
-s(optional) stands for suffix means the type of rom

now:
-n(optional) stands for suffix means the type of rom
-s(optional) stands for the save type, included 8K,32K,128K,24C01

any idea?
In my world,have 0 and 1 only ......Matrix World......

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #4 on: October 16, 2009, 12:25:45 AM »
hi,
the save type value already define in saveAllocationSize of NeoResultBlock struct:
   int saveAllocationSize; // saveAllocationSize is the save size selected in the list view
                     // 0        - no save
                     // 8       - 8kbit
                     // 32   - 32 kbit
                     // 128   - 128kbit
                     // -1      - 24C01

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2095
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #5 on: October 16, 2009, 12:54:16 AM »
-s(optional) stands for suffix means the type of rom

means the file name suffix added from disk, for example, file name as "Double Dragon.sms" will be "-s sms"; ::sm-21.gif::

Thanks , i just wasn't sure about the supported extensions...!


we just need support one eeprom mode --- 24c01

Okay , i will map all 24C## eeprom modes to 24C01.If the mode is not 24C01 it will show a warning
to the user that it will be mapped to 24C01.

-n(optional) stands for suffix means the type of rom
Its fine , but we're not going to need it for now because the MD MYTH will send the rom buffer directly.
But we might need this in a feature version

-s(optional) stands for the save type, included 8K,32K,128K,24C01

The plugin will calculate the save type , and it will be returned in NeoResultStructure in
saveAllocationSize.

Then , before you burn the rom to the cart , you can put a switch() and set the save type using this
variable.

The plugin will verify if the rom needs 24C01 eeprom mode or included memory.

This is the plugin process ->

1.Validate input
2.Parse arguments --if there are
3.Execute arguments
4.Check if the rom is broken
5.Calculate the save type and return it to pBlock->saveAllocationSize

Md myth process before burning ->
1.
Set pBlock->romBuffer = loaded rom buffer
Set pBlock->romBufferLength = loaded rom buffer length
Set pBlock->arguments
Set pBlock->saveAllocationSize = 0

2. Send pBlock to my plugin

3. Get the result , and place a switch for the saveAllocationSize

4.Write rom with the calculated save type ---the numbers will be "round"
like 8 , 32 , 128 , -1.


By the way the new design of Neo2 ultra menu looks very nice , and i suggest to have "common fix"
ticked by default.

And about genie code , its a encoded game-genie string , and will be used by the plugin to
patch the region-locked roms with 68K CPU instructions.


any idea?

I think it would make users happy if you support IPS patches.Some games have been translated
and their IPS patches are available. My plugin can install these patches to the rom buffer.

Maybe replace "param2" with "IPS patch" and allow the user to select an ips file.


By the way , i will provide a full demo app and all the sources with the plugin so you can see how it works and maybe modify it if you don't need something.
« Last Edit: October 16, 2009, 01:00:16 AM by Conle »

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3467
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #6 on: October 16, 2009, 02:47:55 AM »
Quote
I think it would make users happy if you support IPS patches.Some games have been translated
and their IPS patches are available. My plugin can install these patches to the rom buffer.

Maybe replace "param2" with "IPS patch" and allow the user to select an ips file.

good idea,will do it soon  :)
In my world,have 0 and 1 only ......Matrix World......

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2095
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #7 on: October 17, 2009, 04:26:36 PM »
Dr.Neo , which is the plugin that i can replace with mine? I need to test the build on the MD MYTH PROGRAMER but i can't find any related plugin  ~sm-31.gif~

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3467
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #8 on: October 18, 2009, 10:35:19 PM »
Conle, please rename your plugin to "PlugDemo.dll" and copy it to C:\NEO2 Ultra Menu, then you can test it.

and we have put one demo plugin in the source code pack too, the file name is "PlugDemo.dll"
In my world,have 0 and 1 only ......Matrix World......

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #9 on: October 19, 2009, 12:13:44 AM »
Yes, put your plugIn dll to this path: C:\NEO2 Ultra Menu\Plug_In\MD,  then the menu app will call them one by one at the time before burning.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2095
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #10 on: October 19, 2009, 02:00:03 AM »
Thanks Dr.Neo & SivenYu. I had to uninstall & install back the new MD MY PROGRAMMER 2.86
because when i installed the update by selecting "repair" it doesn't replace files and
directories.

About the plugin ... Im nearly done for the 1st version i did some burns and it seems to
be working fine.I just need to confirm the dumps now.

In the first release there wont be support for IPS and GameGenie codes but will be available
soon.


Dr.Neo , the arguments will need a small change to suppot large paths for IPS/GameGenie.

Its very simple. The parser expects all sub arguments in "".
Also to add multiple strings into new arguments you must put ";".

For example , this :
"-r EUROPE ASIA USA -f 1"

Now should be:
"-r "Europe;ASIA;USA" -f "1" "


Or if you want i can change the integer parsing to this ->
"-r "Europe;ASIA;USA" -f 1 "

Instead ->

"-r "Europe;ASIA;USA" -f "1" "



But i prefer the first , because you can do something like this :

Code: [Select]
inline void appendCommand(std::string& buf,const char cmd,const std::string& arg)
{
buf += " -";
buf += cmd;
buf += " \"";
buf += arg;
buf += "\"";
}

inline void appendCommand(std::string& buf,const char cmd,const char arg)
{
buf += " -";
buf += cmd;
buf += " \"";
buf += arg;
buf += "\"";
}

if( checksum.checked)
    appendCommand(argList,'c','1');

Now you can copy buf.c_str() to arguments




Because we must also support large file paths with spaces[ ' ' ] and non alpha chars [ '-' ...] .

The parser works like this :

->if no arguments
---->Push OP_DOC , OP_SAV , OP_CPH , OP_CRC
----> return

->skip white space
->Detect command switch "-"
->move 1 byte
->switch command()
---->Fetch Int type or string type
---->Generate final symbols
---->skip garbage characters
---->Validate rules
---->Make byte code from input
---->Push byte code and arguments --(if there are)-- to the stack
->Repeat for all
---->Save byte code and return


Then the plugin sends all the code to the "virtual machine" , and runs all the
code.It works almost just like a cpu virtual machine.


By the way , SivenYu , you are a member of Neoteam ? Because you always answer all questions with details
 ::sm-22.gif::  ~sm-42.gif~
« Last Edit: October 19, 2009, 02:24:02 AM by Conle »

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3467
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #11 on: October 19, 2009, 02:23:14 AM »
ok,do it now  ::sm-17.gif::
In my world,have 0 and 1 only ......Matrix World......

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2095
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #12 on: October 19, 2009, 02:28:16 AM »
Excellent  ~sm-36.gif~ .
Later today i will write some basic documentation & i will verify the dumps.

The first version might be ready in a day or 2 but without IPS and GameGenie support for now. Because i need to change something in the VC6 port of the framework.

All the sources will be included of course...
« Last Edit: October 19, 2009, 02:31:43 AM by Conle »

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #13 on: October 19, 2009, 03:39:49 AM »
Thanks Conle, you are great! You are our role model, i am a support in neoteam. and in addition, we are all enthusiastic about the NEO.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2095
Re: How to make a Plug-In patch for MD of NEO2 Ultra Menu Application V2
« Reply #14 on: October 19, 2009, 01:12:25 PM »
Thanks Conle, you are great! You are our role model, i am a support in neoteam. and in addition, we are all enthusiastic about the NEO.

Now it makes sense how you know all these  :D  ~sm-36.gif~

About the plugin , the release is coming very soon. Its just a matter of 2 - 3 days max.~sm-37.gif~
« Last Edit: October 19, 2009, 01:14:09 PM by Conle »