Hacking NDSTokyoTrim

shorty606

Member
OP
Newcomer
Joined
Feb 27, 2009
Messages
13
Trophies
0
XP
2
Country
Hi,
I don't mean to upset anyone with what I'm about to say. I've been looking into how the NDS files work, especially trimming. I know that in the header of the NDS file the size of the ROM is located. I then got a game I know uses Wi-Fi and compared a normal non-trimmed version to a Trimmed (using TokyoTrim). The wifi game that was trimmed with TokyoTrim was missing the extra 136 bytes over the normal rom size that is needed to remain Wifi. That's what I've come to understand anyway, that any wifi game needs 136 bytes over the normal size specified in the header if it is WiFi.

Can someone please help me, am I wrong in this? Does TokyoTrimmer work correctly on wifi games? and if so, what am i missing?

Thanks in advance
smile.gif
 

Vomitman57

Member
Newcomer
Joined
Mar 2, 2009
Messages
5
Trophies
0
XP
50
Country
United States
What the hell is tokyo trim?

Don't the trimers just delete the empty space that is not used?

And since nds cards are non re-writable, how could the game use extra memory?
 

Ferrariman

Hip-Flop and cRap
Member
Joined
Dec 9, 2007
Messages
3,350
Trophies
0
Location
Canader.
XP
152
Country
Canada
Vomitman57 said:
What the hell is tokyo trim?

Don't the trimers just delete the empty space that is not used?

And since nds cards are non re-writable, how could the game use extra memory?
Do you notice how roms take up 8, 16, 32, 64, 128, 25 6 MB of memory? They don't really take up that much, and trimmers take out excess memory.
 

shorty606

Member
OP
Newcomer
Joined
Feb 27, 2009
Messages
13
Trophies
0
XP
2
Country
Game Carts come in block sizes say 16MB 32 MB etc. if a game is 12MB it is put onto a 16MB cart and padded with extra usless data to make it 16MB. You can normally take the extra info out without a problem. However, some wifi games need this extra space to work. From my tests, TokyoTrim (which is a trimmer and removes the extra space) does not appear to be leaving this wifi data in. I have triple checked it and it is not doing it. My program is not registering trimmed games as Wifi once trimmed with TokyoTrim.
 

TrolleyDave

Philosolosophising
Former Staff
Joined
Jan 1, 2007
Messages
7,761
Trophies
1
Age
52
Location
Wales, UK
XP
933
Country
shorty606 said:
Game Carts come in block sizes say 16MB 32 MB etc. if a game is 12MB it is put onto a 16MB cart and padded with extra usless data to make it 16MB. You can normally take the extra info out without a problem. However, some wifi games need this extra space to work. From my tests, TokyoTrim (which is a trimmer and removes the extra space) does not appear to be leaving this wifi data in. I have triple checked it and it is not doing it. My program is not registering trimmed games as Wifi once trimmed with TokyoTrim.

Not all games that use wifi have the block after the end of the rom, some of them have it stored in the rom itself. If you just check for data after the end of the rom size value that's a rock solid way to do it.
 

shorty606

Member
OP
Newcomer
Joined
Feb 27, 2009
Messages
13
Trophies
0
XP
2
Country
That's the thing, the data after the rom is all FF on the wifi game, this means it uses that doesn't it? otherwise it would be 00
 

TrolleyDave

Philosolosophising
Former Staff
Joined
Jan 1, 2007
Messages
7,761
Trophies
1
Age
52
Location
Wales, UK
XP
933
Country
shorty606 said:
That's the thing, the data after the rom is all FF on the wifi game, this means it uses that doesn't it? otherwise it would be 00

No, some roms are padded with $00 and some are padded with $FF. Both values mean blank data, if it goes $FF and then another value other than $FF or $00 in those 136 bytes then it's wifi data. I'm not the greatest coder so there's probably a more efficient way of doing it but here's the function I wrote for checking if a rom has wifi data at the end. I use it in my manager and my trimmer and it hasn't caused any problems, or at least none that anyone's told me about.

CODEFunction NDS_HasWifiBlock(NDSRom : NDS_RomType) : Boolean;
Var
ÂÂF : File Of Byte;
ÂÂTmpByte : Byte;
ÂÂTmpInt : Int64;
Begin
ÂÂFileMode := 0;
ÂÂAssignFile(F,NDSRom.RomFileName);
ÂÂ{$I-}
ÂÂReset(F);
ÂÂ{$I+}
ÂÂIf IOResult = 0 Then
ÂÂBegin
ÂÂÂÂFileMode := 2;
ÂÂÂÂTmpInt := NDSRom.RomHeader^.NDSR_ROMSize;
ÂÂÂÂIf FileSize(F) > TmpInt Then
ÂÂÂÂBegin
ÂÂÂÂÂÂSeek(F,TmpInt + 2);
ÂÂÂÂÂÂRead(F,TmpByte);
ÂÂÂÂEnd
ÂÂÂÂElse
ÂÂÂÂÂÂTmpByte := $FF;
ÂÂÂÂCloseFile(F);
ÂÂEnd
ÂÂElse
ÂÂÂÂTmpByte := $00;
ÂÂNDS_HasWifiBlock := (TmpByte $FF) And (TmpByte $00);
End;
 

shorty606

Member
OP
Newcomer
Joined
Feb 27, 2009
Messages
13
Trophies
0
XP
2
Country
Two coders that think alike! I use records too! and I've used a very similar approach to detecting wifi, but it still seems to be giving errors. I will look through my code and compare it to yours to see what I'm doing wrong
smile.gif
Thanks!!
biggrin.gif
 

shorty606

Member
OP
Newcomer
Joined
Feb 27, 2009
Messages
13
Trophies
0
XP
2
Country
I think the problem I was having was with the ROMS i was using! As you said, some have the code already stored inside it and not at the end, I only have one Rom that I was testing my program against that actually has this wifi data at the end and so the others roms which I also thought had it, where giving me false readings because they didn't. My code was scarily similar to your own. Thanks again!
 

TrolleyDave

Philosolosophising
Former Staff
Joined
Jan 1, 2007
Messages
7,761
Trophies
1
Age
52
Location
Wales, UK
XP
933
Country
shorty606 said:
I think the problem I was having was with the ROMS i was using! As you said, some have the code already stored inside it and not at the end, I only have one Rom that I was testing my program against that actually has this wifi data at the end and so the others roms which I also thought had it, where giving me false readings because they didn't. My code was scarily similar to your own. Thanks again!

No probs at all mate, glad I could help! Another good tip I've got for trimming, although you probably already do it, is to use he truncate file command to clip the data off. It makes trimming pretty much instant.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: @Psionic Roshambo, Wonder if there are Super FX repro carts too, no?