NDS ROM and Cheat Database Algorithms

Discussion in 'NDS - Flashcarts and Accessories' started by blow_fly98, Dec 28, 2009.

Dec 28, 2009
  1. blow_fly98
    OP

    Newcomer blow_fly98 Member

    Joined:
    Jun 4, 2008
    Messages:
    23
    Country:
    Australia
    I figured I wanted to do something about the R4 firmware not being to display all the cheats...


    IDEA
    To make a cheat database that contains only cheats for all commercial NDS ROMs on a flash cart!
    Not only will it save space, but it will stop angry R4 owners bashing their heads at why the cheats for Yugioh don't show up!
    And maybe then people would not need to use YSMenu (Not saying YSMenu is bad. YSMenu is awesome! [​IMG] ) to have all the cheats show up but suddenly realise they need to format their MicroSD card!

    And to do all that:
    Make a program!!!
    Some fundamental steps:[*]Loop through each NDS ROM (i.e. files with the extension ".nds") found on the flashcard[*]Determine whether the ROM is comercial or homebrew[*]If it is commercial, add its game ID to the listAnd then:[*]Load an Action Replay XML file (most likely Narin's Cheat Database)[*]Search the XML for the games whose game ID is in the list of game IDs made previously[*]Copy the cheat section for those games (and also the header of the original XML file which contains the name and other information etc.) from the original XML file into a new XML file[*]Encode the new XML file into a cheat database

    PROBLEM
    [*]I do not know how to determine whether an NDS ROM is commercial or homebrew WITHOUT USING 3RD PARTY TOOLS (i.e. using PURE CODE)[*]I do not know how to determine the game ID of a commercial NDS ROM WITHOUT USING 3RD PARTY TOOLS (i.e. using PURE CODE)[*]I do not know how to encode an Action Replay XML file into a cheat database WITHOUT USING 3RD PARTY TOOLS (i.e. using PURE CODE)

    I REALLY don't want to have to use AutoIt and run the NDS Header Tool and R4CCE.
    And think about it: if someone gives the algorithms, they will be public UNTIL THE END OF TIME and there will suddenly be an outburst of NDS programs (no, really [​IMG] ).​

    For this project I will be using VB.NET code ONLY.

    NB: I am only requesting help for the algorithms. NOTHING ELSE.
     
  2. Rayder

    Former Staff Rayder Mostly lurking lately....

    Joined:
    Jan 14, 2007
    Messages:
    6,613
    Location:
    USA
    Country:
    United States
  3. Hatsu

    Banned Hatsu Someone's been killing, eh?

    Joined:
    Oct 19, 2009
    Messages:
    2,143
    Location:
    __________________ Warn: 50%
    Country:
    Australia
    Cheat discussion should stay in the Cheat Forum.
     
  4. blow_fly98
    OP

    Newcomer blow_fly98 Member

    Joined:
    Jun 4, 2008
    Messages:
    23
    Country:
    Australia
  5. twiztidsinz

    Member twiztidsinz Taiju Yamada Fan

    Joined:
    Dec 23, 2008
    Messages:
    4,981
    Country:
    United States
    How is the second part of the game ID calculated?
    First four is right at the start of ROM, address C I believe, and the next 8 are a partial CRC I believe but how do you calculate it?
     
  6. blow_fly98
    OP

    Newcomer blow_fly98 Member

    Joined:
    Jun 4, 2008
    Messages:
    23
    Country:
    Australia
    Get the first 512 (0x200) bytes of the file [0x00000000 - 0x000001FF]
    Calculate the CRC32
    Do a bitwise NOT (or substract the CRC32 from 0xFFFFFFFF)
     
    bobmcjr likes this.
  7. twiztidsinz

    Member twiztidsinz Taiju Yamada Fan

    Joined:
    Dec 23, 2008
    Messages:
    4,981
    Country:
    United States
    Awesome! Thanks.

    But one small correction, 1FF = 511, so it's the first 512bytes not 200 [​IMG]
     
  8. vergessen

    Newcomer vergessen Advanced Member

    Joined:
    Apr 5, 2007
    Messages:
    85
    Country:
    United States
    200 is correct if speaking hex, 0x200 spans 512
     
  9. vergessen

    Newcomer vergessen Advanced Member

    Joined:
    Apr 5, 2007
    Messages:
    85
    Country:
    United States
    example code.

    Code:
    #!/usr/bin/python
    
    from sys import argv
    fromÂÂzlib import crc32
    
    def gameid(arg):
    ÂÂÂÂinfile = open(arg, 'rb')
    ÂÂÂÂcrcdata = infile.read(0x200)
    ÂÂÂÂcrc = "%X" % (~crc32(crcdata) & 0xFFFFFFFF)
    ÂÂÂÂinfile.seek(0x00C)
    ÂÂÂÂid = infile.read(4)
    ÂÂÂÂinfile.close()
    ÂÂÂÂreturn ("%s %s" % (id, crc))
    
    if __name__ == "__main__":
    ÂÂÂÂfor x in argv[1:]:
    ÂÂÂÂÂÂÂÂprint (gameid(x))
     

Share This Page