ROM Hack Suggestion The Pinball Arcade - Flip-Grip Support (software patch)

tabzer

etymological and/or pedantic
OP
Member
Joined
Feb 15, 2019
Messages
3,567
Trophies
1
Age
38
XP
2,747
Country
Japan
UPDATE: Thanks to @Hazerou , we finally have a simple solution to this. This cheat (attached) will allow you flip the screen. Just make sure you have airplane mode turned on with bluetooth enabled in the switch config.

Below is the OP:


The Flip Grip is a handheld grip that allows for vertical gaming, ideal for SHMUPS, Pinball, and various arcade games. However, one of the ideal pinball games to play on it, The Pinball Arcade, does not support it. While The Pinball Arcade supports vertical mode, it only handles it in one direction, and that direction is the opposite of that which is compatible with the Flip Grip. It's upside-down!

I'm very interested in making a patch, whether it be an NRO or a /Title/ patch. I really don't know where to begin, but even if there was a homebrew app that could be developed that could help in display reversing/mirroring, it could be applied to this kind of situation.

I don't know where to start, but I would really appreciate advice about where one could start, and ideas of the easiest way to implement this.
 

Attachments

  • pinballarcadeflipgrip.zip
    723 bytes · Views: 61
Last edited by tabzer,
  • Like
Reactions: c411um

tabzer

etymological and/or pedantic
OP
Member
Joined
Feb 15, 2019
Messages
3,567
Trophies
1
Age
38
XP
2,747
Country
Japan
I ended up extracting the contents of romfs.bin, and I ended up with a bunch of *.rez and *.bnsh files. The rez files seem to be encrypted by Farsight's propriety, and it's looking like a dead end. Resources I looked up have found a way to roughly decode, but are unable to encode, so a layeredfs approach would be unfeasable?

I'm wondering if I can just tell a system module to flip the screen, on all output, while toggled. Anyone with a clue would be a great help.
 

tabzer

etymological and/or pedantic
OP
Member
Joined
Feb 15, 2019
Messages
3,567
Trophies
1
Age
38
XP
2,747
Country
Japan
I'd guess it would need a game-specific code patch, if someone can disassemble and find the code that deals with the screen rotation.

I was able to extract the romfs.bin, but I get a bunch of encrypted rez and bnsh files, which seem to use Farsight's propriety encoding. People have found a way to decrypt, shoddily, but no way to encrypt. So even if we were able to locate the line we would need to change, we would not be able to re-encode it for use.

Personally, a game patch would be ideal, but seems impossible without an elusive algorithm at this point. So this brings us to another option, and that is general system homebrew. My experience with it is little, but I am confident that I could use something that is already developed as a template.

A couple references to what we would possibly utilize:

https://switchbrew.org/wiki/Nvnflinger_services

Or maybe:

https://github.com/switchbrew/libnx/blob/master/nx/include/switch/display/types.h


enum {
/* flip source image horizontally (around the vertical axis) */
HAL_TRANSFORM_FLIP_H = 0x01,
/* flip source image vertically (around the horizontal axis)*/
HAL_TRANSFORM_FLIP_V = 0x02,
/* rotate source image 90 degrees clockwise */
HAL_TRANSFORM_ROT_90 = 0x04,
/* rotate source image 180 degrees */
HAL_TRANSFORM_ROT_180 = 0x03,
/* rotate source image 270 degrees clockwise */
HAL_TRANSFORM_ROT_270 = 0x07,
};


At this point, I don't know if types.h is already included in the switch or if I would have to call it for some sort of persistence module of some kind. At this point, I would prefer just a nro homebrew solution that could toggle a patch into HOS until it is toggled off again, but I don't know if this would require a kip as well.

Any references to homebrew projects that already, successfully, manipulate video in this sort of manner would be great for establishing framework and being efficient. I don't want to try making something that already exists, either, so it is possible that a solution already exists.

This is progressive, and I wish I was more knowledgeable of these subjects, but I'll adapt and any input would be greatly appreciated. Anybody who is more skilled and has the time to spare could encouragingly take the lead.
 
Last edited by tabzer,
  • Like
Reactions: Deleted User

masagrator

The patches guy
Member
Joined
Oct 14, 2018
Messages
5,143
Trophies
2
XP
9,156
Country
Poland
I have it, but it's encrypted. Do you know how to decrypt/re-encrypt it?
exefs is not encrypted. Only compressed. But for disassembling you don't need to decompress it, because Switch Loaders for Ghidra and IDA will do it automatically.

--------------------- MERGED ---------------------------

And IMO after digging in files I think game is not rotating screen. Only what is rotated is camera.

In some files you can get start positions x, y, z. It's possible that there is also somewhere degrees or radians.
 
  • Like
Reactions: tabzer

tabzer

etymological and/or pedantic
OP
Member
Joined
Feb 15, 2019
Messages
3,567
Trophies
1
Age
38
XP
2,747
Country
Japan
Well. I'm completely lost at what to do with Ghidra. Brand new to me. I've managed to install the Addubz's Switch loader, and I'm in the process of importing/analyzing "main" "rtld" and "sdk". main.npdm was binary and I didn't know what language to choose for it.

I don't know the code, but when playing the game, the main menu and sub menus allow you to change the rotation of the screen by pressing "-" on the controller. I don't think there is a "camera" for the menus, but I could be wrong.
 

masagrator

The patches guy
Member
Joined
Oct 14, 2018
Messages
5,143
Trophies
2
XP
9,156
Country
Poland
Well. I'm completely lost at what to do with Ghidra. Brand new to me. I've managed to install the Addubz's Switch loader, and I'm in the process of importing/analyzing "main" "rtld" and "sdk". main.npdm was binary and I didn't know what language to choose for it.

I don't know the code, but when playing the game, the main menu and sub menus allow you to change the rotation of the screen by pressing "-" on the controller. I don't think there is a "camera" for the menus, but I could be wrong.
You need only main to disassemble. In this case nothing else matters
 
  • Like
Reactions: tabzer

tabzer

etymological and/or pedantic
OP
Member
Joined
Feb 15, 2019
Messages
3,567
Trophies
1
Age
38
XP
2,747
Country
Japan
I get many warns and some errors and a lot of unresolvable variables and it is a bit discouraging. Even if I am able to guess at what functions are supposed to do, how would I go about to create a working patch?
 

masagrator

The patches guy
Member
Joined
Oct 14, 2018
Messages
5,143
Trophies
2
XP
9,156
Country
Poland
Create a .ips file with name that is buildid of main.
You can find it in offset 0x40 of main, 16 bytes.
(screens are based on Dragon Quest XI S Demo)
Green underline is what you need to copy to filename
upload_2019-8-25_10-45-18.png
So I got
Code:
A7578001B492C2028B722995F3ECA71F.ips
Then in hex editor start with IPS32 at the beginning of file
upload_2019-8-25_10-46-12.png
For example I'm changing this
upload_2019-8-25_10-48-53.png
to this
upload_2019-8-25_11-0-52.png
I changed two last lines of GetOperationMode
Code:
      7104abb7e8 e0030032    mov        w0,#0x1
      7104abb7ec c0035fd6    ret
So from first column delete "71" and add to offset 0x100 (0x04abb7e8 + 0x100 = 0x04abb8e8). Copy first one (because they are next to each other, we don't need two separate offsets) to the hex editor next to IPS32
upload_2019-8-25_11-3-28.png
after thay you need to specify with two bytes how many bytes you want to overwrite. In this example we got 8 bytes, so we write "00 08"
upload_2019-8-25_11-5-31.png
next you copy modified instructions (second column) one after another
upload_2019-8-25_11-6-40.png
and at the end of file you write "EEOF"
upload_2019-8-25_11-7-6.png
and your patch is ready. Just put it to atmosphere\exefs_patches\*your_folder_name*\
If you want to add another bytes to overwrite, just start with new offset+byte size+bytes to overwrite
IPS32 should be only one and only at the beginning of file, EEOF also only one, but only at the end of file
 
Last edited by masagrator,
  • Like
Reactions: tabzer

tabzer

etymological and/or pedantic
OP
Member
Joined
Feb 15, 2019
Messages
3,567
Trophies
1
Age
38
XP
2,747
Country
Japan
@masagrator, thank you very much for the write up. I wonder how you were able to come to the conclusion that GetOperationMode was your target. I also wonder how you know about making changes to it.

Anyway, I am looking through the exefs/main (one that I was able to create from base+update) and I found this:


undefined8 InitScreenDisplayMode(void)

{
int iVar1;
int iVar2;

iVar1 = dxScreenWidth();
iVar2 = dxScreenWidth();
iVar2 = iVar2 - (int)((float)iVar1 * 0.89999998);
if (iVar2 < 0) {
iVar2 = iVar2 + 1;
}
displaySafeArea = iVar2 >> 1;
DAT_711441a354 = dxScreenWidth();
DAT_711441a354 = DAT_711441a354 - (iVar2 >> 1);
iVar1 = dxScreenHeight();
iVar2 = dxScreenHeight();
iVar2 = iVar2 - (int)((float)iVar1 * 0.85000002);
if (iVar2 < 0) {
iVar2 = iVar2 + 1;
}
DAT_711441a350 = iVar2 >> 1;
DAT_711441a358 = dxScreenHeight();
DAT_711441a358 = DAT_711441a358 - (iVar2 >> 1);
if (gHiDef == 0) {
displaySafeArea = displaySafeArea + 0x28;
DAT_711441a354 = DAT_711441a354 + -0x28;
}
DAT_711441a36c = 0x3f6000003f666666;
iVar2 = dxScreenWidth();
DAT_711441a364 = (int)((float)iVar2 * (float)DAT_711441a36c);
iVar2 = dxScreenHeight();
DAT_711441a368 = (int)((float)iVar2 * DAT_711441a36c._4_4_);
iVar2 = dxScreenWidth();
displaySafeArea = iVar2 - DAT_711441a364 >> 1;
DAT_711441a354 = displaySafeArea + DAT_711441a364;
iVar2 = dxScreenHeight();
DAT_711441a350 = iVar2 - DAT_711441a368 >> 1;
if (screenBuffer == (ushort *)0x0) {
clipRight = 0x1000;
clipBottom = 0x1000;
}
else {
clipRight = (uint)*screenBuffer;
clipBottom = (uint)screenBuffer[1];
}
destinationBitmap = screenBuffer;
DAT_711441a358 = DAT_711441a350 + DAT_711441a368;
DAT_711441a35c = DAT_711441a354 + displaySafeArea >> 1;
DAT_711441a360 = DAT_711441a350 + DAT_711441a368 + DAT_711441a350 >> 1;
clipLeft = 0;
clipTop = 0;
return 1;
}



Also found this:


undefined8 ScreenChangeDisplayMode(void)

{
ushort uVar1;
int iVar2;
ushort uVar3;
float fVar4;

iVar2 = Render_GetOrientationDevice();
if (iVar2 == 1) {
uVar1 = 0x438;
uVar3 = 0x780;
}
else {
iVar2 = Render_GetOrientationDevice();
if (iVar2 != 0) goto LAB_71001e283c;
uVar1 = 0x780;
uVar3 = 0x438;
}
*screenBuffer = uVar3;
screenBuffer[1] = uVar1;
LAB_71001e283c:
DAT_711441a36c = 0x3f6000003f666666;
fVar4 = (float)NEON_ucvtf((uint)*screenBuffer);
DAT_711441a364 = (int)(fVar4 * 0.89999998);
fVar4 = (float)NEON_ucvtf((uint)screenBuffer[1]);
DAT_711441a368 = (int)(fVar4 * 0.87500000);
displaySafeArea = (int)((uint)*screenBuffer - DAT_711441a364) >> 1;
DAT_711441a354 = displaySafeArea + DAT_711441a364;
destinationBitmap = screenBuffer;
DAT_711441a350 = (int)((uint)screenBuffer[1] - DAT_711441a368) >> 1;
DAT_711441a35c = DAT_711441a354 + displaySafeArea >> 1;
DAT_711441a358 = DAT_711441a350 + DAT_711441a368;
DAT_711441a360 = DAT_711441a358 + DAT_711441a350 >> 1;
if (screenBuffer == (ushort *)0x0) {
clipRight = 0x1000;
clipBottom = 0x1000;
}
else {
clipRight = (uint)*screenBuffer;
clipBottom = (uint)screenBuffer[1];
}
clipTop = 0;
clipLeft = 0;
uVar1 = dxScreenWidth();
*screenBuffer = uVar1;
uVar1 = dxScreenHeight();
screenBuffer[1] = uVar1;
return 1;
}



It looks like one of these might have something to do with what I am trying to change. I still don't know what to do with it quite yet. If I can figure out how to make an edit and test something, then maybe I can see if I am on the right track. So far, I was thinking if we can change some positive values to negative values, and vice-versa, we can manipulate the image to coming out in the opposite direction.

I included screenshots to show that the "camera" calls could be referencing to the camera angels available mid-game. Both horizontal/landscape and vertical/portrait mode might have their own sets of cameras that can be changed in the middle of the game.

Also, it shows on the main menu that pressing "-" at any time will change the screen orientation, in game, and in menu, so I believe that's activating ScreenChangeDisplayMode.
 

Attachments

  • 2019082519592800-108DA6E05325922F287961A5E45D868A.jpg
    2019082519592800-108DA6E05325922F287961A5E45D868A.jpg
    242.2 KB · Views: 130
  • 2019082519593500-108DA6E05325922F287961A5E45D868A.jpg
    2019082519593500-108DA6E05325922F287961A5E45D868A.jpg
    217.8 KB · Views: 132
  • 2019082520014100-108DA6E05325922F287961A5E45D868A.jpg
    2019082520014100-108DA6E05325922F287961A5E45D868A.jpg
    357.7 KB · Views: 175
  • 2019082520014200-108DA6E05325922F287961A5E45D868A.jpg
    2019082520014200-108DA6E05325922F287961A5E45D868A.jpg
    366.9 KB · Views: 137
  • 2019082520015600-108DA6E05325922F287961A5E45D868A.jpg
    2019082520015600-108DA6E05325922F287961A5E45D868A.jpg
    443 KB · Views: 118
  • 2019082520015700-108DA6E05325922F287961A5E45D868A.jpg
    2019082520015700-108DA6E05325922F287961A5E45D868A.jpg
    436.2 KB · Views: 162
Last edited by tabzer,

tabzer

etymological and/or pedantic
OP
Member
Joined
Feb 15, 2019
Messages
3,567
Trophies
1
Age
38
XP
2,747
Country
Japan
I also am seeing references to "NSW_Tatemode" with tate being the vertical/portrait mode.


void Render_SetOrientationEngine(int iParm1)

{
if (iParm1 == 1) {
NSW_TateMode = 0;
}
else {
if (iParm1 == 0) {
NSW_TateMode = 1;
}
}
DAT_7100923710 = iParm1;
ScreenChangeDisplayMode();
return;
}

 
  • Like
Reactions: wicksand420

cruz1383

Member
Newcomer
Joined
Nov 18, 2016
Messages
17
Trophies
0
Age
39
XP
215
Country
United States
Dude i had this same problem. i love the flip grip. i got an easy solution for you and i have been using it for several months now with no issues. grab a dremel tool and take down that little tab on the left side of the flip grip. took me 10 sec to take it down and now the switch fits in both orientations like i said i have used it for months now with no heat issues or any other issues.
 
Last edited by cruz1383,
  • Like
Reactions: tabzer

Instandhaltung

I feel it. I feel the cosmos!
Member
Joined
Aug 4, 2016
Messages
239
Trophies
0
Age
34
XP
1,697
Country
Germany
Dude i had this same problem. i love the flip grip. i got an easy solution for you and i have been using it for several months now with no issues. grab a dremel tool and take down that little tab on the left side of the flip grip. took me 10 sec to take it down and now the switch fits in both orientations like i said i have used it for months now with no heat issues or any other issues.

But isn't it a security measure to avoid that the switch falls out? I don't think that this might be a good idea...
 

cruz1383

Member
Newcomer
Joined
Nov 18, 2016
Messages
17
Trophies
0
Age
39
XP
215
Country
United States
i have done this and havent had the switch come out at all. i mean if your swinging the switch or flinging it it might come out but with normal use it hasnt came out even with my 5 year old playing and messing with it, it hasnt came out and messed anything up. so unless your crazier then a 5 year old when you play pinball lol (dont see that happening) plus the 4 little felt pads that are on the flip grip do a really good job at holding the switch and not let it go anywhere.
 
Last edited by cruz1383,

Instandhaltung

I feel it. I feel the cosmos!
Member
Joined
Aug 4, 2016
Messages
239
Trophies
0
Age
34
XP
1,697
Country
Germany
i have done this and havent had the switch come out at all. i mean if your swinging the switch or flinging it it might come out but with normal use it hasnt came out even with my 5 year old playing and messing with it, it hasnt came out and messed anything up. so unless your crazier then a 5 year old when you play pinball lol (dont see that happening) plus the 4 little felt pads that are on the flip grip do a really good job at holding the switch and not let it go anywhere.

Well, pinball can be nerve wracking sometimes :) . Anyways maybe we should try to find a software solution anyways, and if everything else fails, i might just partially destroy my flip grip :cry:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    T @ TheRealDeanMeTn: ok