Author Topic: SuperN64 Plugin v1.0.0.9  (Read 12340 times)

0 Members and 1 Guest are viewing this topic.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
SuperN64 Plugin v1.0.0.9
« on: February 09, 2010, 07:12:21 PM »
SuperN64 toolset v1.0.0.9
 ::sm-08.gif::



-Features of the plugin-

-Supports madmonkey's opensource programmer
-Is able to detect and make compatible any image (v64/n64/z64)
-Is able to calculate and fix the CRC
-Supports 100% MupenPlus's GoodN64 database with custom exporter for fast access
-Can detect the save type automatically ( using GoodN64 exported db or if not
found it has build in lexer library than can detect the type automatically using
search patterns)
-Is able to detect the CIC type of any rom and any region
-Supports  IPS/APS patching
-Advanced callback system.The plugin can report the progress(in 0 ~ 100% format) and the
active task name of any internal task.
-The core is written in portable C using utilities and tools
coded from scratch without using a single 3rd party library(except for md5)
-Read/Writes in a single file in medium size blocks for fast proccessing.
-Region patching(Supports all countries and test modes like mpal)
-MFC IDLE Loop thread syncing


-How to use the plugin-


Available script commands:

IMPORT_SRC <- IPS/APS patches ( NOT READY YET )
SOURCE_FILE <- Pass this file for PATCHING
DESTINATION_FILE <- Destination file (BURN THIS ONE!)
FIX_CRC <- Will calculate & patch the CRC

FORCE_REGION <- Override rom region settings
See "NEO_SN64Engine_Types.h" for the available strings ->

Code: [Select]
static const char* NEON64_REGION_STRING_TABLE[] =
{
"Default\0",
"Germany\0",
"French\0",
"Italian\0",
"Europe\0",
"Spanish\0",
"Australia\0",
"XPAL\0",
"Mode7\0",
"USA\0",
"Japan\0"
};

enum NEON64_Region
{
NEON64_REGION_DEFAULT = 0,
NEON64_REGION_GERMANY,
NEON64_REGION_FRENCH,
NEON64_REGION_ITALIAN,
NEON64_REGION_EUROPE,
NEON64_REGION_SPANISH,
NEON64_REGION_AUSTRALIA,
NEON64_REGION_XPAL,
NEON64_REGION_MODE7,
NEON64_REGION_USA,
NEON64_REGION_JAPAN,
NEON64_REGION_COUNT
};



How to "compile" scripts(VERY IMPORTANT or scripts will not run!):

1. Include "SN64PLUG_ScriptCompiler\\NEON64_PlugScriptCompiler.hpp"

2. To compile a single command set, do this:

Quote
CNEON64_ScriptCompiler cmp;

//First arg = identifier , second arg = value
cmp.clear();//reset previews code
cmp.compile("SOURCE_FILE","c:\\game.n64");
cmp.compile("DESTINATION_FILE","c:\\game_patched.n64");
cmp.compile("FORCE_REGION","Mode7");

//Accessing:
cmp.getCodePtr()
cmp.getCodeLength()


How to run scripts and updating stats dynamically:

Code: [Select]
#include "..\\PlugBase.h"

//Realtime stats from the plugin
void realtimeStats(NEON64DynamicStatsBlock* dsBlock)
{
if(!dsBlock)
return;

if(dsBlock->taskNameNeedsUpdate)
MessageBox(NULL,dsBlock->currentTaskName,"TASK CHANGED!",MB_OK);

if(dsBlock->romGoodNameNeedsUpdate)
MessageBox(NULL,dsBlock->romGoodName,"GoodN64 name CHANGED!",MB_OK);

if(dsBlock->progressNeedsUpdate)
progressbar->SetPos(dsBlock->progress);
}

..........

NEON64ResultBlock block;

block.actionScript = cmp.getCodePtr();
block.actionScriptLength = cmp.getCodeLength();
block.myDynaStatsCB = realtimeStats;

if(plugin->Patching(&block))
All good;
else
Failed;

Save type is : block.saveType (see NEO_SN64Engine_Types.h for more)
Boot chip is : block.bootChip (see NEO_SN64Engine_Types.h for more)

Patched file to burn :  the one specified in argument "DESTINATION_FILE"(Very important!)

Code: [Select]
enum NEON64_SaveType
{
    NEON64_SAVE_CARD = 0x1,
    NEON64_SAVE_EEPROM_4K,
    NEON64_SAVE_EEPROM_16K,
    NEON64_SAVE_SRAM_32K,
    NEON64_SAVE_FLASHRAM_1M,
    NEON64_SAVE_CONTROLLERPACK,
    NEON64_SAVE_NONE
};

enum NEON64_BootChip
{
    NEON64_CIC_6101 = 0x1,
    NEON64_CIC_6102,
    NEON64_CIC_6103,
    NEON64_CIC_6105 = 5,
    NEON64_CIC_6106
};



Special thanks
Dr.Neo & ShivenYu (cart sample + plugin interface)
ChillyWilly(For lots of info on the MD internals  )
Madmonkey for reports & suggestions on the SuperMD plugin
Sanni for his great help on the testing part of SuperN64 plugin


 ::sm-22.gif::

ShivenYu if you have any questions just ask , also checkout "SN64PLUG_Host"
in the source package.

 ~sm-37.gif~
« Last Edit: June 18, 2010, 05:06:38 PM by Conle »

Offline sanni

  • Moderator
  • Hero Member
  • *****
  • Posts: 502
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #1 on: February 10, 2010, 05:03:06 AM »
I really like how you keep us updated with your progress. Thank you very much for all your efforts. :)

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #2 on: February 10, 2010, 01:22:21 PM »
You're welcome , and thanks for your contributions in the testing part! :)

All those who have contributed to the project will be mentioned in the "about box" of SuperN64 DEBUG host app in the next full-featured version just like in SuperMD plugin + host.

 ~sm-37.gif~

Offline Infrid

  • Jr. Member
  • **
  • Posts: 66
    • rcp64::nintendo64 machine
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #3 on: February 10, 2010, 06:42:25 PM »
good job! :D
RCP64 :: Nintendo 64 Machine

Offline ronaldo_76

  • Full Member
  • ***
  • Posts: 196
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #4 on: February 10, 2010, 06:57:47 PM »
very nice job conle.  ;D

thanks for all the time you invest...  ???

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #5 on: February 13, 2010, 12:57:03 PM »
Changes since the first release:

v1.0.0.7 -> v1.0.0.8:

(optimizations)Now the plugin does all tasks in one single pass(while reading each block) resulting
in the fastest possible buffered patching we can get.
8)

(updates)Updated lex's phrase generation and its getting to the max
possible success rate for non-goodn64 roms.

(updates)A final update in NEO_SN64Engine_DynaStatsShared

(changes)Small additions to n64_image , md5_io

(todo)APS/IPS patching
« Last Edit: February 13, 2010, 12:59:04 PM by Conle »

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #6 on: March 10, 2010, 05:40:00 PM »
great job, conle!  ... i am late :-\
i has refer to the demo code and make the programmer to support n64 plugin,
by now  i just call the plugin->Patching() when a game adding, then judging the result to select the savetype and cic option, but not patch the rom file to burn. is it "outputRom.bin" the  patch rom to burn?

There's a little problem about the save type,  the programmer's save options doesn't map to your NEON64_SaveType:

enum NEON64_SaveType
{
    NEON64_SAVE_CARD = 0x1,   < - > N64_CARD
    NEON64_SAVE_EEPROM_4K,   < - > N64_EEPROM_4K
    NEON64_SAVE_EEPROM_16K,   < - >    N64_EEPROM_16K
    NEON64_SAVE_SRAM_32K,           < - >    N64_SRAM_32K
    NEON64_SAVE_FLASHRAM_1M,   < - > N64_FLASH_128K
    NEON64_SAVE_CONTROLLERPACK, < - >   ?
    NEON64_SAVE_NONE                  < - >   ?
};

how to  map the last two type? any modify?

Please download update and test, for i have no environment to test too much.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #7 on: March 10, 2010, 08:01:55 PM »
Hey ShivenYu , good to see you back.  ~sm-42.gif~


Quote
is it "outputRom.bin" the  patch rom to burn?
Yes the "outputrom.bin" is the patched one!You must burn this rom.

Its the one that you specify in the script :
Code: [Select]
cmp.compile("SOURCE_FILE","c:\\game.n64"); <-- source
cmp.compile("DESTINATION_FILE","c:\\game_patched.n64");  <-- this is the desination
cmp.compile("FORCE_REGION","Mode7");

Quote
how to  map the last two type? any modify?

NEON64_SAVE_NONE   = means that the game does not contain save.
it will work with "N64_CARD" flag too.

NEON64_SAVE_CONTROLLERPACK = controller pack save.Most games use this ,
it will work with "N64_CARD" flag too.


Quote

Please download update and test, for i have no environment to test too much.

I will test it in few hours and i will post back. :)
By the way , in 1-2days i will release v1.0.0.8  ::sm-24.gif::
« Last Edit: March 10, 2010, 08:04:14 PM by Conle »

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #8 on: March 11, 2010, 08:53:00 AM »

Its the one that you specify in the script :
Code: [Select]
cmp.compile("SOURCE_FILE","c:\\game.n64"); <-- source
cmp.compile("DESTINATION_FILE","c:\\game_patched.n64");  <-- this is the desination
cmp.compile("FORCE_REGION","Mode7");


OK, conle, i will change to burn the destination rom  setting by:
cmp.compile("DESTINATION_FILE","c:\\game_patched.n64");  <-- this is the desination

and
cmp.compile("FORCE_REGION","Mode7");   <- is it the region (original, Mode7, Europe...) select by user from the operation interface?

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #9 on: March 11, 2010, 11:10:48 AM »
OK, conle, i will change to burn the destination rom  setting by:
cmp.compile("DESTINATION_FILE","c:\\game_patched.n64");  <-- this is the desination
Don't forget , for vista/windows7 read + write support set the DESTINATION_FILE variable inside Neo2 ultra menu directory
for example :  c:\\neo2 ultra path\\temp\\n64_patched.z64

cmp.compile("FORCE_REGION","Mode7");   <- is it the region (original, Mode7, Europe...) select by user from the operation interface?

Yes that is corrent , you need an option combobox.You can use the indexes directly.Also don't forget "IMPORT_SRC"
for aps/ips patches.

Here is a good example :

Code: [Select]
//Realtime stats from the plugin
void realtimeStats(NEON64DynamicStatsBlock* dsBlock)
{
   if(!dsBlock)
      return;

   if(dsBlock->taskNameNeedsUpdate)
      MessageBox(NULL,dsBlock->currentTaskName,"TASK CHANGED!",MB_OK);

   if(dsBlock->romGoodNameNeedsUpdate)
      MessageBox(NULL,dsBlock->romGoodName,"GoodN64 name CHANGED!",MB_OK);

   if(dsBlock->progressNeedsUpdate)
      progressbar->SetPos(dsBlock->progress);
}

Code: [Select]
//Add the region list when creating the form
::onInitilize()
{
for(int i = 0; i < NEON64_REGION_COUNT; i++)
form->regionList->add( NEON64_REGION_STRING_TABLE[i] );
}

Code: [Select]
CNEON64_ScriptCompiler cmp;
NEON64ResultBlock block;

for(int x = 0; x < romCount; x++)
{
cmp.clear();//reset previews code

//source
cmp.compile("SOURCE_FILE",form->romList->getString[x]);

//destination
cmp.compile("DESTINATION_FILE","c:\\neo2 ultra menu\\temp\\n64_pathed.z64");

//region
if(isValidRange(form->regionList->itemIndex))
cmp.compile("FORCE_REGION",form->regionList[x]->getString[form->regionList[x]->itemIndex]);

//IPS/APS patch
if(form->patchList[x]->itemIndex > -1  && form->patchList[x]>itemIndex < form->patchList[x]->itemCount)
{
if(lengthOfString(form->patchList[x]->getString[form->patchList[x]->itemIndex] > 0 )
cmp.compile("IMPORT_SRC",form->patchList[x]->getString[form->patchList[x]->itemIndex]);
}

//Run script!
block.actionScript = cmp.getCodePtr();
block.actionScriptLength = cmp.getCodeLength();
block.myDynaStatsCB = realtimeStats;

if(plugin->Patching(&block))
{
Save type is : block.saveType (see NEO_SN64Engine_Types.h for more)
Boot chip is : block.bootChip (see NEO_SN64Engine_Types.h for more)
Patched file to burn :  the one specified in argument "DESTINATION_FILE"
}
else
   Failed;

}

Based on this :
Code: [Select]
static const char* NEON64_REGION_STRING_TABLE[] =
{
   "Default\0",
   "Germany\0",
   "French\0",
   "Italian\0",
   "Europe\0",
   "Spanish\0",
   "Australia\0",
   "XPAL\0",
   "Mode7\0",
   "USA\0",
   "Japan\0"
};

enum NEON64_Region
{
   NEON64_REGION_DEFAULT = 0,
   NEON64_REGION_GERMANY,
   NEON64_REGION_FRENCH,
   NEON64_REGION_ITALIAN,
   NEON64_REGION_EUROPE,
   NEON64_REGION_SPANISH,
   NEON64_REGION_AUSTRALIA,
   NEON64_REGION_XPAL,
   NEON64_REGION_MODE7,
   NEON64_REGION_USA,
   NEON64_REGION_JAPAN,
   NEON64_REGION_COUNT
};



By the way ,if you need to get the current path , you can include some of my functions that i use in the plugin when you create the form:

Code: [Select]
#define PATH_SEPARATOR '\\'
#include <iostream>

std::string getModulePath()
{
static char rst[ 1024 ];
std::string s = std::string( rst, GetModuleFileName( NULL, rst + 0, 1024 ) );

int i = s.length() , start = 0;

const std::size_t find = s.find(':');

if(find != std::string::npos)
start = (int)find;
else
start = 0;

while(i-- > start)
{
if( s[i] == PATH_SEPARATOR)
{
s = s.substr(0,i+1);
break;
}
   }

   return s;
}

std::wstring getModulePathW()
{
   static w_chart rst[ 1024 ];
   std::wstring s = std::wstring( rst, GetModuleFileNameW( NULL, rst + 0, 1024 ) );

int i = s.length() , start = 0;

const std::size_t find = s.find(':');

if(find != std::string::npos)
start = (int)find;
else
start = 0;

while(i-- > start)
{
if( s[i] == PATH_SEPARATOR)
{
s = s.substr(0,i+1);
break;
}
   }

   return s;
}

static std::string appPath = "";
//or static std::wstring appPath = ""; for wide charset

.. ::onInitialize()

appPath = getModulePath();
//or appPath = getModulePathW(); for wide charset


Then you can do :
Code: [Select]
cmp.compile("DESTINATION_FILE",std::string(appPath + "temp\\n64_patched.z64").c_str());

And the rom to burn will be in : Neo2 ultra menu base folder\temp\n64_patched.z64

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #10 on: March 11, 2010, 11:20:06 AM »
One thing i forgot.
ShivenYu , when you embed the plugin , don't forget to include the database folders that are next to the binary DLL. Especially "plugInfoDB".

I have made an exporter for mupen plus's goodn64 romset and that is required.
By the way , the plugin supports even non-goodn64 roms , using complex phrase/word patterns.

PS:
The binaries can be found here :
http://www.neoflash.com/forum/index.php?action=dlattach;topic=5998.0;attach=2368

PS2:
Where do i put the plugin to test it ? ~sm-40.gif~
« Last Edit: March 11, 2010, 11:22:17 AM by Conle »

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3826
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #11 on: March 11, 2010, 12:59:06 PM »
hi colne, he will embed your plugin, then upload to our FTP, so u can download it to test directly, more info please PM him.  ~sm-45.gif~
In my world,have 0 and 1 only ......Matrix World......

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #12 on: March 11, 2010, 01:50:00 PM »
PS2:
Where do i put the plugin to test it ? ~sm-40.gif~

like MD plugin, just copy the whole N64 folder inside your binaries packet to the menu directory, for example to: C:\NEO2 Ultra Menu\Plug_In\N64
and, update several files from previous upload: Neo2Client.exe, Neo2Menu.dll, AdvSet.ini.
then ok.

Offline SivenYu

  • Neo MOD
  • Jr. Member
  • *
  • Posts: 95
Re: SuperN64 Plugin v1.0.0.7 & patching engine
« Reply #13 on: March 11, 2010, 02:19:04 PM »
hi, conle, what's IPS/APS patch? as the code:

   //IPS/APS patch
   if(form->patchList
  • ->itemIndex > -1  && form->patchList
  • >itemIndex < form->patchList
  • ->itemCount)

   {
      if(lengthOfString(form->patchList
  • ->getString[form->patchList
  • ->itemIndex] > 0 )

         cmp.compile("IMPORT_SRC",form->patchList
  • ->getString[form->patchList
  • ->itemIndex]);

   }

how about the patchList
  • should be? is it like MD plugin's IPS? -- let user to select a disk file and pass the path to plugin? maybe you can add the sample code to the SN64PLUGHOST.exe project. thanks!

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SuperN64 Plugin v1.0.0.8 & patching engine
« Reply #14 on: March 11, 2010, 06:01:16 PM »
hi, conle, what's IPS/APS patch? as the code:

   //IPS/APS patch
   if(form->patchList
  • ->itemIndex > -1  && form->patchList
  • >itemIndex < form->patchList
  • ->itemCount)

   {
      if(lengthOfString(form->patchList
  • ->getString[form->patchList
  • ->itemIndex] > 0 )

         cmp.compile("IMPORT_SRC",form->patchList
  • ->getString[form->patchList
  • ->itemIndex]);

   }

how about the patchList
  • should be? is it like MD plugin's IPS? -- let user to select a disk file and pass the path to plugin? maybe you can add the sample code to the SN64PLUGHOST.exe project. thanks!
Yes its the same function as MD's IPS :)

Here i have just uploaded quickly v1.0.0.8 with binaries & source :
http://www.neoflash.com/forum/index.php?action=dlattach;topic=5998.0;attach=2409
http://www.neoflash.com/forum/index.php?action=dlattach;topic=5998.0;attach=2410

Basically you just have to pass IMPORT_SRC command with the patch file(*.aps/*.ips) as argument.

Code: [Select]
cmp.compile("IMPORT_SRC",patchFile.c_str());


If you need more info PM me    ~sm-42.gif~

edit : ShivenYu , check your PM box      :D
« Last Edit: March 11, 2010, 06:30:14 PM by Conle »