Hacking NDS ROM and Cheat Database Algorithms

blow_fly98

Member
OP
Newcomer
Joined
Jun 4, 2008
Messages
23
Trophies
0
Age
28
XP
243
Country
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!
yay.gif
) 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
dry.gif
).​

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

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

twiztidsinz

Taiju Yamada Fan
Member
Joined
Dec 23, 2008
Messages
4,979
Trophies
0
Website
Visit site
XP
220
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?
 

blow_fly98

Member
OP
Newcomer
Joined
Jun 4, 2008
Messages
23
Trophies
0
Age
28
XP
243
Country
Get the first 512 (0x200) bytes of the file [0x00000000 - 0x000001FF]
Calculate the CRC32
Do a bitwise NOT (or substract the CRC32 from 0xFFFFFFFF)
 
  • Like
Reactions: bobmcjr

twiztidsinz

Taiju Yamada Fan
Member
Joined
Dec 23, 2008
Messages
4,979
Trophies
0
Website
Visit site
XP
220
Country
United States
blow_fly98 said:
Get the first 200 bytes of the file [0x00000000 - 0x000001FF]
Calculate the CRC32
Do a bitwise NOT (or substract the CRC32 from 0xFFFFFFFF)
Awesome! Thanks.

But one small correction, 1FF = 511, so it's the first 512bytes not 200
tongue.gif
 

vergessen

Well-Known Member
Newcomer
Joined
Apr 5, 2007
Messages
85
Trophies
0
XP
69
Country
United States
twiztidsinz said:
blow_fly98 said:
Get the first 200 bytes of the file [0x00000000 - 0x000001FF]
Calculate the CRC32
Do a bitwise NOT (or substract the CRC32 from 0xFFFFFFFF)
Awesome! Thanks.

But one small correction, 1FF = 511, so it's the first 512bytes not 200
tongue.gif

200 is correct if speaking hex, 0x200 spans 512
 

vergessen

Well-Known Member
Newcomer
Joined
Apr 5, 2007
Messages
85
Trophies
0
XP
69
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))
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: With uremum