DS-Homebrew / nds-bootstrap

Boot an nds file
https://wiki.ds-homebrew.com/nds-bootstrap/
GNU General Public License v3.0
1.19k stars 75 forks source link

Issue with E type cheat code #746

Open ahezard opened 5 years ago

ahezard commented 5 years ago

Your console

Tell us which console you are using:

CFW and configuration

Tell us which CFW do you have:

DSi:

3DS/2DS:

nds-bootstrap version

Tell us which versions you are using:

Your device

Tell us which card you are using:

If this issue only affects a certain game, which game is it?

all games should be affected but not all of them of this type of cheat code

Expected behaviour

Nothing I try to run with an E code works at all, it just crashes on startup. The same codes work on my flash card (R4i Gold 3DS RTS fecking whatever alphabet soup). E is for patching memory en-masse, you supply an initial address and how many bytes you're patching, then just fill out the bytes sequentially, without supplying an address each time.

Simple example code to demonstrate: E2001234 00000010 DEADBEEF DEADBABE DEB0D1ED F00DFEED

This code has the same result as the longform equivalent: 02001234 DEADBEEF 02001238 DEADBABE 0200123C DEB0D1ED 02001240 F00DFEED

I can think of at least one "major" code that uses the E codetype, the button hack for Star Fox Command, since it's a long ASM hack. It would probably improve cheat compatibility quite a bit to support it. And I've been using them in widescreen hacks.

Actual behaviour

E code should work (works in NitroHax)

Steps to reproduce

OK, so I just wrote a super quick E code for Mario Kart DS (USA) and confirmed it works fine on NitroHax with my retail card. Testing on nds-bootstrap now and ... looks like a crash on startup. Dual white screens. Here's the code if it's helpful for testing:

920775D0 00001555 E20775D0 00000004 00002AAA 00000000 D2000000 00000000 920789BC 00001555 E20789BC 00000004 00002AAA 00000000 D2000000 00000000

It just crunches all 3D elements to half-width, just wanted something I could easily see working.

Other notes

reported by Vague Rant user on discord

ahezard commented 4 years ago

It could be linked to the fact that we ignore the CHEAT_ENGINE_RELOCATE and CHEAT_ENGINE_HOOK mechanism that is present in NitroHax

See NitroHax code https://github.com/ahezard/NitroHax3DS/blob/702fd140f5c0c1e2d11e819bccf854228bab3364/BootLoader/source/cheat.c

define CHEAT_ENGINE_RELOCATE 0xCF000001

define CHEAT_ENGINE_HOOK 0xCF000002

if (cheatData[0] == CHEAT_ENGINE_RELOCATE) { cheatWord1 = cheatData++; cheatWord2 = cheatData++; cheatEngineLocation = (u32*)cheatWord2; }

if (cheatData[0] == CHEAT_ENGINE_HOOK) { cheatWord1 = cheatData++; cheatWord2 = cheatData++; hookLocation = (u32*)cheatWord2; }

And wood does a strange thing with E type code : https://github.com/ahezard/wood3ds/blob/9cb22d2378a201fc7238f9457e48c4e749acfba7/akloader/arm9/source/patches_ar.cpp

else if(code==0xE0000000) { if(custom_asm) { code=0xC2000000; //Modify E code dbg_printf("Custom Asm detected and modified to work.\n"); } }

ahezard commented 4 years ago

it could be link with the alignment because E code are custom asm executable

ahezard commented 4 years ago

MKDS 0x0E Code Type Codes:

ahezard commented 4 years ago

Commit 8a72ce8 partially fixed the issue at least

ahezard commented 4 years ago

Some code still does not work while they work using NitroHax : Mario Kart DS screen swap code

ahezard commented 4 years ago

Screen Swap 5203809C E1D100B0 - 32-bit Conditional (if equal to) 0203809C E51FF004 - Execute if condition is met 020380A0 02000000 D0000000 00000000 52000000 E7FFDEFF - 32-bit Conditional (if equal to) E2000000 00000034 - Executed if condition is met E92D5FFF E5910000 E3800902 E59F3014 E1530004 1A000000 E3C00902 E5810000 E8BD5FFF E59FF004 022CC554 04000304 020380A8 00000000 D2000000 00000000

RocketRobz commented 3 years ago

With heap shrink removed, some of the E-type cheats should work now.