Homebrew HzMod - old3DS screen streaming

  • Thread starter Sono
  • Start date
  • Views 247,477
  • Replies 573
  • Likes 102

What should be HorizonModule renamed to?

  • HzMod

    Votes: 11 50.0%
  • HzModule

    Votes: 8 36.4%
  • HzProc

    Votes: 2 9.1%
  • HzDbg

    Votes: 1 4.5%
  • HzDebug

    Votes: 0 0.0%

  • Total voters
    22
  • Poll closed .

yonaikerlol

Active Member
Newcomer
Joined
Feb 7, 2018
Messages
36
Trophies
0
Age
19
Location
Venezuela
Website
github.com
XP
130
Country
Venezuela

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary

Oh that... if I get a chance to get out of bed I'll upload the latest source with LagSync and 3D support, but if you need my assistance then you'll have to wait until I recover (assuming I survive).

If you need this desperately fast then you could compile turbojpeg yourself (should be included in the repo, can't check from phone), and place it in inc/lib/libturbojpeg.a and inc/include/*.h
 

yonaikerlol

Active Member
Newcomer
Joined
Feb 7, 2018
Messages
36
Trophies
0
Age
19
Location
Venezuela
Website
github.com
XP
130
Country
Venezuela
Oh that... if I get a chance to get out of bed I'll upload the latest source with LagSync and 3D support, but if you need my assistance then you'll have to wait until I recover (assuming I survive).

If you need this desperately fast then you could compile turbojpeg yourself (should be included in the repo, can't check from phone), and place it in inc/lib/libturbojpeg.a and inc/include/*.h

Sure, I'm not in a hurry, you better.
 
  • Like
Reactions: Sono

yonaikerlol

Active Member
Newcomer
Joined
Feb 7, 2018
Messages
36
Trophies
0
Age
19
Location
Venezuela
Website
github.com
XP
130
Country
Venezuela
I'm very sorry for being late, I uploaded a zipped source as it is, I hope there are instructions in it, I can't check, I just zipped everything except the build directories.

https://puu.sh/BDkgg/3b28ae0b44.zip

Now I get this error:

Code:
[CX] main.cpp
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp: In destructor ‘bufsoc::~bufsoc()’:
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:152:9: error: ‘closesocket’ was not declared in this scope
         closesocket(sock);
         ^~~~~~~~~~~
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:152:9: note: suggested alternative: ‘socket’
         closesocket(sock);
         ^~~~~~~~~~~
         socket
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp: In function ‘int main(int, char**)’:
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:770:21: error: ‘closesocket’ was not declared in this scope
                     closesocket(sock);
                     ^~~~~~~~~~~
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:770:21: note: suggested alternative: ‘socket’
                     closesocket(sock);
                     ^~~~~~~~~~~
                     socket
/home/yonaikerlol/Escritorio/HorizonScreen/Makefile:139: recipe for target 'main.o' failed
make[1]: *** [main.o] Error 1
Makefile:115: recipe for target 'build_PC_' failed
make: *** [build_PC_] Error 2
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary
Now I get this error:

Code:
[CX] main.cpp
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp: In destructor ‘bufsoc::~bufsoc()’:
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:152:9: error: ‘closesocket’ was not declared in this scope
         closesocket(sock);
         ^~~~~~~~~~~
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:152:9: note: suggested alternative: ‘socket’
         closesocket(sock);
         ^~~~~~~~~~~
         socket
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp: In function ‘int main(int, char**)’:
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:770:21: error: ‘closesocket’ was not declared in this scope
                     closesocket(sock);
                     ^~~~~~~~~~~
/home/yonaikerlol/Escritorio/HorizonScreen/soos/main.cpp:770:21: note: suggested alternative: ‘socket’
                     closesocket(sock);
                     ^~~~~~~~~~~
                     socket
/home/yonaikerlol/Escritorio/HorizonScreen/Makefile:139: recipe for target 'main.o' failed
make[1]: *** [main.o] Error 1
Makefile:115: recipe for target 'build_PC_' failed
make: *** [build_PC_] Error 2

Oh right, I forgot that I'm not able to access Linux since my MacBook board got fried (and my new laptop has no BIOS support), so I accidently made the program work on Windows-only by accidently using functions which are only present on Windows. Don't worry though, it's not that different from the old source, and there is so few that a find-and-replace should fix it.

For this case, just replace closesocket with close
 

yonaikerlol

Active Member
Newcomer
Joined
Feb 7, 2018
Messages
36
Trophies
0
Age
19
Location
Venezuela
Website
github.com
XP
130
Country
Venezuela
Oh right, I forgot that I'm not able to access Linux since my MacBook board got fried (and my new laptop has no BIOS support), so I accidently made the program work on Windows-only by accidently using functions which are only present on Windows. Don't worry though, it's not that different from the old source, and there is so few that a find-and-replace should fix it.

For this case, just replace closesocket with close

Done.
Already compile it, the error was in the turbojpeg library, I had to install it as: libturbojpeg

But now these two doubts arise:
How do I turn off the LED?
And how do I see the other screen of the 3DS?

n745jzt.png
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary
Done.
Already compile it, the error was in the turbojpeg library, I had to install it as: libturbojpeg

But now these two doubts arise:
How do I turn off the LED?
And how do I see the other screen of the 3DS?

n745jzt.png

You can't turn off the LEDs, it's *baked* into the HzMod binary on the 3DS-side. I didn't design any config option to disable this because nobody was annoyed by it as far as I know, so I was never bothered of adding such optionality.
However, there are no sanity checks in the binary, so you could patch HzMod itself (at runtime or via armips) to return from the LED routine instead of setting the LED color

As for the other screen, you have two options:
- you install an old binary (from early-mid 2017 (source for this particular build was an intermediate source between two commits, so it has no source left, only the compiled .cia)) and backport some bugs (lol backporting bugs :rofl2:) for it to function correctly
- you install an old binary and use the HorizonScreen which came with it in the .zip/.tar.lzma, but you'll have to suffer from the super extreme screen tearing which will cause motion sickness and headache

Edit: if you plan on using the latest HzScreen source then you can just uncomment the bottom-screen related stuff and adjust some arrays and variables using the old source
 
Last edited by Sono,
  • Like
Reactions: yonaikerlol

yonaikerlol

Active Member
Newcomer
Joined
Feb 7, 2018
Messages
36
Trophies
0
Age
19
Location
Venezuela
Website
github.com
XP
130
Country
Venezuela
You can't turn off the LEDs, it's *baked* into the HzMod binary on the 3DS-side. I didn't design any config option to disable this because nobody was annoyed by it as far as I know, so I was never bothered of adding such optionality.
However, there are no sanity checks in the binary, so you could patch HzMod itself (at runtime or via armips) to return from the LED routine instead of setting the LED color

As for the other screen, you have two options:
- you install an old binary (from early-mid 2017 (source for this particular build was an intermediate source between two commits, so it has no source left, only the compiled .cia)) and backport some bugs (lol backporting bugs :rofl2:) for it to function correctly
- you install an old binary and use the HorizonScreen which came with it in the .zip/.tar.lzma, but you'll have to suffer from the super extreme screen tearing which will cause motion sickness and headache

Oh, Ok, but I realized that when turning off the 3DS, and turning it on again, the LED is still on, then I wonder, is the HorizonM server on the 3DS powered on 24/7?
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary
Oh, Ok, but I realized that when turning off the 3DS, and turning it on again, the LED is still on, then I wonder, is the HorizonM server on the 3DS powered on 24/7?

That is an oversight in the MCU's firmware on old3DS models (includes 2DS). Due to undefined behavior nobody knows what values will be set in the RAM and the hardware pins of the MCU (documented very hazily on the manufacturer's documentations), so upon turning on the CPUs and other stuff the LEDs will have the color which got stuck in the hardware. The reason it takes so long for the LEDs to turn black on reboot because it's Home Menu which clears the LED state to zero, which due to how bloated it is, takes a while.

On new3DS systems the LED state is cleared to zero upon powering up the CPUs by the MCU's firmware itself, so that's why doesn't affect them.

HzMod runs on the ARM11 CPU (the main application and system processor, whereas ARM9 is the "security" processor which handles stuff like SD/NAND, crypto, and backwards compatibility in hardware for DSi mode) which is unpowered when the 3DS is turned off. The only thing which is constantly running is the MCU (which actually has a lot of purposes, mostly known for handling the power and HOME buttons (and wifi button on original old3DS), other power management, keeping track of time, controlling the power to the LCDs and the CPUs, etc.), but that has a low power mode for when the 3DS is turned off, so it shouldn't be a concern about wasting power.

HzMod itself has a "low power state" where all it does is check 20 times a second for incoming connections and handle them and start/stop streaming, and handle the START+SELECT combo to be able to kill it even if the network thread were to freeze/crash. While HzMod is running it's significantly taxing the hardware because the hardware is not designed to be streaming stuff to be captured via software.


> tl;dr. HzMod doesn't run until you open it, it doesn't consume too much power while it's idling, but tries to suck out the most power out of the hardware as possible to maintain a balance between game performance and streaming performance (however this is not configurable from any interface, is not adaptive, and requires manual configuration per-game via a configuration packet) <
 
Last edited by Sono,
  • Like
Reactions: yonaikerlol

yonaikerlol

Active Member
Newcomer
Joined
Feb 7, 2018
Messages
36
Trophies
0
Age
19
Location
Venezuela
Website
github.com
XP
130
Country
Venezuela
That is an oversight in the MCU's firmware on old3DS models (includes 2DS). Due to undefined behavior nobody knows what values will be set in the RAM and the hardware pins of the MCU (documented very hazily on the manufacturer's documentations). It takes so long for the LEDs to turn black on reboot because Home Menu clears the LED state to zero using the Power-Time Management service which in turn tells the mcu sysmodule to tell the MCU to turn the notification LED off.

On new3DS systems the LED state is cleared to zero upon reboot, so that's why doesn't affect them.

HzMod runs on the ARM11 CPU (the main application and system processor, whereas ARM9 is the "security" processor which handles stuff like SD/NAND, crypto, and backwards compatibility in hardware for DSi mode) which is unpowered when the 3DS is turned off. The only thing which is constantly running is the MCU (which actually has a lot of purposes, mostly known for handling the power and HOME buttons (and wifi button on original old3DS), other power management, keeping track of time, controlling the power to the LCDs and the CPUs, etc.), but that has a low power mode for when the 3DS is turned off, so it shouldn't be a concern about wasting power.

HzMod itself has a "low power state" where all it does is check 20 times a second for incoming connections and handle them and start/stop streaming, and hangle the START+SELECT combo to be able to kill it even if the network thread were to freeze/crash. While HzMod is running it's significantly taxing the hardware because the hardware is not designed to be streaming stuff to be captured via software.


> tl;dr. HzMod doesn't run until you open it, it doesn't consume too much power while it's idling, but tries to suck out the most power out of the hardware as possible to maintain a balance between game performance and streaming performance (however this is not configurable from any interface, is not adaptive, and requires manual configuration per-game) <

Wow, Thanks for the explanation, i believe that understand.

Thanks for all your help.
 
  • Like
Reactions: Sono

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary
Wow, Thanks for the explanation, i believe that understand.

Thanks for all your help.

Yeah sorry, I made it way too technical, so I edited it to be easily understandable and maintain a balance between necessary and unnecessary details.

As for a build with multiscreen support, I think this build should have it:

2017/05/06: https://puu.sh/BDKZo/326b408194.lzma
2017/06/23: https://puu.sh/BDKZV/e547aac719.zip

Around 2017 older builds were better and had a bit more performance, but had horrible compatibility compared to the latest version. However, multi-screen support butchers the performance completely.

Speaking about multiscreen support, I'm not sure about the HzScreen source I gave to you, but multiscreen support might be partially removed (even though some code may be still present in the comments, I think it's completely nuked from the source due to a rewrite I'm working on). If you can't re-add multiscreen support yourself then ask me, but it will take a very long time because I can't really dev nowdays.

As for doing multiscreen, you need to set the screen mode according to this bitfield:
0 - streaming off (why would you do this? :rofl2:)
1 - top screen
2 - bottom screen
3 - top and bottom screen "interlaced"
4 - invalid, top screen 3D
5 - top screen in 3D in left-right mode
6 - invalid, top screen 3D and bottom screen
7 - invalid, not enough RAM, all 3 framebuffers
anything above 8 is just repetition due to the bits not being used (though don't set it higher than 5 because certain versions have memory leaks in them)


As for the earlier mentioned "performance balance"; I don't know about your programming skills, but I'll write it down in case someone lurking here wants to follow along wants to actually do it:

There is a magic configuration block ID 0xFF which controls this performance balance. The values are in I think miliseconds, and can range from 1 to 254.
A value of 0 is the default, and that means no delay on new3DS, and a hardcoded delay for old3DS as a fallback to allow some CPU time to the games too without making them stutter too much.
A value of 0xFF should be VSync, but in some early version where this was added (late 2017 probably, might be even early 2018, I'm 97% certain it's not present in the above two builds) it was implemented badly and could sometimes cause the whole system to softlock or crash a sysmodule.
This config block was only added for the (partially scrapped but still accessible) InputRedirection patch to allow enough CPU time for the InputRedirection packets to make it to the 3DS without causing too much lag or latency.
 
  • Like
Reactions: yonaikerlol

thekarter104

Well-Known Member
Member
Joined
Mar 28, 2013
Messages
1,987
Trophies
1
XP
3,015
Country
United States
Nice to see this probject alive and well. I remember when I tried this out first. I think it only had multiscreen support because it had both screens visible when I tried it out, and the FPS was horrible.
I expect lag from an old 3DS for sure, not to mention I also had a borked laptop to try it out with ^^

I'll try this out sometime again.
 
  • Like
Reactions: Sono

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary
Nice to see this probject alive and well. I remember when I tried this out first. I think it only had multiscreen support because it had both screens visible when I tried it out, and the FPS was horrible.
I expect lag from an old 3DS for sure, not to mention I also had a borked laptop to try it out with ^^

I'll try this out sometime again.

It's as alive as me and my original Zelda old3DS multiplied. The secret™ rewrite is getting worked on slower than EU-->USA migration documents. But yeah, I still give partial support to the people who need it in most cases.

But yeah, that must have been a hell of an old version which streamed the entire thing completely uncompressed and it didn't even cause major motion sickness due to how awfully slow it was with its ~0.2-2FPS.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary
Is it possible to swap the top screen with the bottom one? (in the latest release) If so, how?

The latest release doesn't even support the bottom screen. It was removed due to the extra few bytes of code being just big enough to kill the performance just by existing. However I plan to re-add it in the rewrite.
 

plug313

Well-Known Member
Member
Joined
Jun 27, 2016
Messages
163
Trophies
0
Age
29
XP
622
Country
any way to use this to steam to my TV? that'd be sweet. my TV supports screen sharing. I don't have a PC but I have a Galaxy Note8 :) thanks in advance
edit: New 3DS running latest Luma btw
 

Mike_IronFist

Member
Newcomer
Joined
Oct 13, 2018
Messages
10
Trophies
0
Age
33
XP
124
Country
United States
any way to use this to steam to my TV? that'd be sweet. my TV supports screen sharing. I don't have a PC but I have a Galaxy Note8 :) thanks in advance
edit: New 3DS running latest Luma btw
When you say you don't have a "PC," do you mean you don't have a computer at all? Or just that you don't have a Windows machine? Because HzMod's HorizonScreen client runs fine under Wine on Linux/Mac and for NitroCFW there's a Mac app. if you just want to stream "directly" to your TV, though, I'm afraid that's not a possibility right now. Both solutions rely on somewhat specialized apps on the computer side of things to receive and interpret the data being received from the 3DS.
 
  • Like
Reactions: plug313

lordzombies

Member
Newcomer
Joined
Nov 11, 2017
Messages
10
Trophies
0
Age
34
Location
UK
XP
79
Country
United Kingdom
so im at step 5 and im on windows 10,
so my only option is open powershell window here
i type in commands and it cant find horizonscreen-pc

using N3DSXL, wanted to use so i could stream VC games that NTR cant handle.

HorizonScreen-PC : The term 'HorizonScreen-PC' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ HorizonScreen-PC 192.168.0.89
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HorizonScreen-PC:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
 
Last edited by lordzombies,

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,334
Country
Hungary
so im at step 5 and im on windows 10,
so my only option is open powershell window here
i type in commands and it cant find horizonscreen-pc

using N3DSXL, wanted to use so i could stream VC games that NTR cant handle.

HorizonScreen-PC : The term 'HorizonScreen-PC' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ HorizonScreen-PC 192.168.0.89
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HorizonScreen-PC:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I hate that they replaced cmd with PS...

Anyways, for PowerShell you just prepend .\

17cb9b8cb7.png
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: Your dad still got laid +1