R4itool from lifehackerhansol

Tradegirl2011

Member
OP
Newcomer
Joined
Jan 17, 2020
Messages
8
Trophies
0
Age
43
XP
113
Country
Switzerland
Hi.

I tried to compile the R4itool for from @lifehackerhansol to get rid off the timebomb from the original kernel from my r4i-sdhc,com card.

unfortunately i get a warning during the compiling and the resulting binary seems to work, but when it is done with patching the r4.dat the "fixed" r4.dat doesn't boot the kernel.

following is the commandline from my test environment (linux mint):

1st error (fixed by renaming DES.h to des.h):
Code:
test@test-VirtualBox:~/r4itool-lifehackerhansol$ make
  CC      source/DES.c
source/DES.c:27:10: fatal error: des.h: No such file or directory
   27 | #include "des.h"
      |          ^~~~~~~
compilation terminated.
make: *** [Makefile:151: build/source/DES.c.o] Error 1

2nd error/warning:
Code:
test@test-VirtualBox:~/r4itool-lifehackerhansol$ make
  CC      source/DES.c
  CXX     source/Main.cpp
In file included from source/Main.cpp:1:
include/R4i.hpp:18:43: warning: attribute ignored in declaration of ‘struct r4i::SecretArea’ [-Wattributes]
   18 | alignas(2) struct __attribute__((packed)) SecretArea {
      |                                           ^~~~~~~~~~
include/R4i.hpp:18:43: note: attribute for ‘struct r4i::SecretArea’ must follow the ‘struct’ keyword
  CXX     source/R4i.cpp
In file included from source/R4i.cpp:5:
include/R4i.hpp:18:43: warning: attribute ignored in declaration of ‘struct r4i::SecretArea’ [-Wattributes]
   18 | alignas(2) struct __attribute__((packed)) SecretArea {
      |                                           ^~~~~~~~~~
include/R4i.hpp:18:43: note: attribute for ‘struct r4i::SecretArea’ must follow the ‘struct’ keyword
source/R4i.cpp: In function ‘r4i::u32 r4i::genAreaChk(r4i::u16, r4i::u16, r4i::u16)’:
source/R4i.cpp:205:24: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘r4i::u32’ {aka ‘unsigned int’} [-Wformat=]
  205 |   sprintf(buffer, "%08lx", (static_cast<u32>(arm7chk) << 16) | arm9chk);
      |                    ~~~~^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                        |                                     |
      |                        long unsigned int                     r4i::u32 {aka unsigned int}
      |                    %08x
  LD      r4itool-lifehackerhansol
 

Apache Thunder

I have cameras in your head!
Member
Joined
Oct 7, 2007
Messages
4,432
Trophies
3
Age
36
Location
Levelland, Texas
Website
www.mariopc.co.nr
XP
6,800
Country
United States
Try moving "alignas(2)" to the right of struct for SecretArea instead of the left where it is currently. That seemed to fix that warning (on Windows anyways)

Should look like this now:


Code:
struct alignas(2) __attribute__((packed)) SecretArea {
  u32 magic;
  u16 arm9chk;
  u16 arm7chk;
  u16 ldrchk;
  u32 areachk;
  u32 dldiOffset;
};


As for the other warning, it shouldn't be breaking things for you as that just impacts console display. But you can fix that easily too:

Code:
sprintf(buffer, "%08lx", (static_cast<long unsigned int>(arm7chk) << 16) | arm9chk);

Just cast it as the thing it wants. :P

Going to see if the patcher actually works for me now. Last time recall having the issue with the compiled build not producing a working result so maybe this was my issue too. :P

EDIT: It still hangs on loading for me. I think this just doesn't work on 4.1 version of R4.dat currently. :(
 
Last edited by Apache Thunder,

Tradegirl2011

Member
OP
Newcomer
Joined
Jan 17, 2020
Messages
8
Trophies
0
Age
43
XP
113
Country
Switzerland
Code:
struct alignas(2) __attribute__((packed)) SecretArea {
  u32 magic;
  u16 arm9chk;
  u16 arm7chk;
  u16 ldrchk;
  u32 areachk;
  u32 dldiOffset;
};

unfortunately the compiler no longer works for me with your changes.
I'm getting lots of errors now.


EDIT: @Apache Thunder : have you ever tried to build the r4itool from github kynex7510/r4itool?
i managed to compile it under windows a few weeks ago, but the tool also didn't work for me.
the output "r4-fixed.dat" was identical to the input "r4.dat".
 
Last edited by Tradegirl2011,

Apache Thunder

I have cameras in your head!
Member
Joined
Oct 7, 2007
Messages
4,432
Trophies
3
Age
36
Location
Levelland, Texas
Website
www.mariopc.co.nr
XP
6,800
Country
United States
The only thing it changed on mine is this:

1713216799859.png


Does the same thing as the lifehackerhansol build so no change on my end other then that it does alter the file unlike for you for some reason. I'm surprised it compiled. I used to have issues compiling cmake stuff. :P

I did have to comment out this code in R4i.hpp. It complained about comparison reduces to (20 == 18):

Code:
static_assert(sizeof(SecretArea) == 0x12, "Invalid SecretArea size!");
 

Tradegirl2011

Member
OP
Newcomer
Joined
Jan 17, 2020
Messages
8
Trophies
0
Age
43
XP
113
Country
Switzerland
For Windows i used the build tools from visual studio 2022 and compiled it with cmake in cli.
I did not have to change any of the files. :unsure:

unfortunately, the tool/tools doesn't seem to work for some reason.
 

Apache Thunder

I have cameras in your head!
Member
Joined
Oct 7, 2007
Messages
4,432
Trophies
3
Age
36
Location
Levelland, Texas
Website
www.mariopc.co.nr
XP
6,800
Country
United States
For me I ran cmake from console to build from cmake txt file then ran make after that....At some point I had to put it into VS but it seems i don't need to do that now. I think the real issue is the tool only works on an older version of the R4i kernel so it needs to be reworked for the updated ones. :(
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • TwoSpikedHands @ TwoSpikedHands:
    I just found out that the EU version is better in literally every way, better sound quality, better lighting, and there's even a patch someone made to make the text look nicer
  • TwoSpikedHands @ TwoSpikedHands:
    Do I restart now using what i've learned on the EU version since it's a better overall experience? or do I continue with the US version since that is what ive been using, and if someone decides to play my hack, it would most likely be that version?
  • Sicklyboy @ Sicklyboy:
    @TwoSpikedHands, I'll preface this with the fact that I know nothing about the game, but, I think it depends on what your goals are. Are you trying to make a definitive version of the game? You may want to refocus your efforts on the EU version then. Or, are you trying to make a better US version? In which case, the only way to make a better US version is to keep on plugging away at that one ;)
  • Sicklyboy @ Sicklyboy:
    I'm not familiar with the technicalities of the differences between the two versions, but I'm wondering if at least some of those differences are things that you could port over to the US version in your patch without having to include copyrighted assets from the EU version
  • TwoSpikedHands @ TwoSpikedHands:
    @Sicklyboy I am wanting to fully change the game and bend it to my will lol. I would like to eventually have the ability to add more characters, enemies, even have a completely different story if i wanted. I already have the ability to change the tilemaps in the US version, so I can basically make my own map and warp to it in game - so I'm pretty far into it!
  • TwoSpikedHands @ TwoSpikedHands:
    I really would like to make a hack that I would enjoy playing, and maybe other people would too. swapping to the EU version would also mean my US friends could not legally play it
  • TwoSpikedHands @ TwoSpikedHands:
    I am definitely considering porting over some of the EU features without using the actual ROM itself, tbh that would probably be the best way to go about it... but i'm sad that the voice acting is so.... not good on the US version. May not be a way around that though
  • TwoSpikedHands @ TwoSpikedHands:
    I appreciate the insight!
  • The Real Jdbye @ The Real Jdbye:
    @TwoSpikedHands just switch, all the knowledge you learned still applies and most of the code and assets should be the same anyway
  • The Real Jdbye @ The Real Jdbye:
    and realistically they wouldn't

    be able to play it legally anyway since they need a ROM and they probably don't have the means to dump it themselves
  • The Real Jdbye @ The Real Jdbye:
    why the shit does the shitbox randomly insert newlines in my messages
  • Veho @ Veho:
    It does that when I edit a post.
  • Veho @ Veho:
    It inserts a newline in a random spot.
  • The Real Jdbye @ The Real Jdbye:
    never had that i don't think
  • Karma177 @ Karma177:
    do y'all think having an sd card that has a write speed of 700kb/s is a bad idea?
    trying to restore emunand rn but it's taking ages... (also when I finished the first time hekate decided to delete all my fucking files :wacko:)
  • The Real Jdbye @ The Real Jdbye:
    @Karma177 that sd card is 100% faulty so yes, its a bad idea
  • The Real Jdbye @ The Real Jdbye:
    even the slowest non-sdhc sd cards are a few MB/s
  • Karma177 @ Karma177:
    @The Real Jdbye it hasn't given me any error trying to write things on it so I don't really think it's faulty (pasted 40/50gb+ folders and no write errors)
  • DinohScene @ DinohScene:
    run h2testw on it
    +1
  • DinohScene @ DinohScene:
    when SD cards/microSD write speeds drop below a meg a sec, they're usually on the verge of dying
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Samsung SD format can sometimes fix them too
  • Purple_Heart @ Purple_Heart:
    yes looks like an faulty sd
  • Purple_Heart @ Purple_Heart:
    @Psionic Roshambo i may try that with my dead sd cards
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    It's always worth a shot
    Psionic Roshambo @ Psionic Roshambo: It's always worth a shot