JazzJackrabbit Community Forums  

Go Back   JazzJackrabbit Community Forums > Open Forums > General Jazz Jackrabbit Talk

Reply
 
Thread Tools
Old July 17th, 2017, 06:23 AM   #1
Simon
JCF Member
 
 
Join Date: Dec 2016
Location: Germany
Reputation: Simon is doing well so far
Vanilla physics in Plus (Speedrun mode? Open-source part of Plus?)

Hi,

Vanilla JJ2 crashes in Wine between levels often. Plus fixes that crash and works as it should, very good work.

Problem: Plus changes the physics in singleplayer, making speedruns incomparable between Plus and Vanilla. Plus removes some boss quick-kills, removes the bitchslap damage boost in Victorian Secret, etc. What to do?
  • Plus gets a speedrun mode: Medium difficulty with vanilla physics. We wouldn't even need a timer for now. Still, this is work for the devs to make extra UI and special-case the physics.
  • Plus becomes partly open-sourced, so I can learn from that and compile a JJ2 patch that fixes Vanilla's crashes between levels, but doesn't touch physics. Violet wouldn't like Plus entirely open-sourced, mainly to limit multiplayer cheating, and I respect that decision.
  • Make a compelling argument that all runners should migrate to Plus? But for comparing runs over the years, this is the worst option. Plus should fix future physics bugs as appropriate.
  • Declare wontfix because speedrunners on Linux are a minority? After all, Vanilla doesn't crash on Windows this often.
Compared with other speedrunners, my JJ2 times are lousy: I haven't attempted Spaz runs at all, my Jazz run is 29 minutes compared to Binary's 19:40.

Shtrudel has been learning the Jazz run and that sparked my interest again. Even before, I've had the itch several times to run Jazz 2, but didn't do it because I'd have to choose between crashes and physics differences. Shtrudel considers learning the run on Plus, not on Vanilla like everybody else, merely to compare with me.

-- Simon
Simon is offline   Reply With Quote
Old July 17th, 2017, 09:37 AM   #2
Stijn
Administrator
 
 
Join Date: Mar 2001
Reputation: Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold
Quote:
Originally Posted by Simon View Post
Declare wontfix because speedrunners on Linux are a minority? After all, Vanilla doesn't crash on Windows this often.
Realistically, I think this is what will happen. I expect the category of "speedrunners on Linux" isn't much bigger than yourself, to be honest. Of the options you list, a "speedrun mode" is the best solution, but it is a lot of work and for most people there would be very little difference with running vanilla JJ2.

If dual-booting Windows is not an option for you, maybe you could run Windows in a virtual machine and then run JJ2 on it? That would probably be the easiest way out of this.
Stijn is offline   Reply With Quote
Old July 18th, 2017, 07:21 AM   #3
Robo4900
JCF Member
The Almighty Tallest
 
 
Join Date: Sep 2011
Location: Dimension C-137
His suggestion could be added to an expanded version of quirks mode?

VMs rarely work for this. I tried running Jazz 2 via VM in Linux a little while ago when I was thinking of primarily switching to Ubuntu. Performance was awful, maybe not even 15fps.
__________________
Robo4900 is offline   Reply With Quote
Old July 18th, 2017, 07:33 AM   #4
Stijn
Administrator
 
 
Join Date: Mar 2001
Reputation: Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold
Quote:
Originally Posted by Robo4900 View Post
His suggestion could be added to an expanded version of quirks mode?
Sure, but that's just another way of phrasing "speedrun mode", not a way to make that less work to implement :P

The thing is that this would require JJ2+ to offer two versions for a variety of physics subroutines, the buggy vanilla version and the better plus version. That's obviously more work to maintain, and it feels silly re-implementing buggy behaviour that has already been patched out, usually for good reason. In some cases the old behaviour may be relatively easy to get back, if it's still in the code somewhere and relatively isolated, but that won't be the case for all physics patches.

It's not necessarily difficult, it's just a fair bit of work. Maybe it will happen! There's an issue for it in the JJ2+ issue tracker already, in fact. But the cost/benefit analysis for this one, for this particular reason, isn't very favourable.
Stijn is offline   Reply With Quote
Old July 19th, 2017, 12:38 AM   #5
Simon
JCF Member
 
 
Join Date: Dec 2016
Location: Germany
Reputation: Simon is doing well so far
Quote:
Realistically, I think [declare wontfix] is what will happen. I expect the category of "speedrunners on Linux" isn't much bigger than yourself, to be honest.
Very reasonable -- I've focussed on other games in the meantime. If this issue becomes wontfix, I'll continue and lay aside the Jazz 2 itch for some years.

I've discussed this issue with Violet 6 months ago. Since this issue wasn't mentioned in the Plus 5.5 release notes, I'd like insight on the recent planning, thus this thread.

Quote:
Maybe it will happen! There's an issue for it in the JJ2+ issue tracker already, in fact.
I'll certainly follow the culture, even if I don't run!

Quote:
not a way to make that less work to implement :P
Ideally, it would be my work.

I know that nobody else needs this. It would be egregious to demand so much work and maintenance from others. Plus caters to multiplayer and their own physics, this issue doesn't fit.

I can't patch Vanilla without at least the basic bugfixes open-sourced. I'm a programmer, but I've never hijacked execution and injected methods into binaries. I know where Vanilla crashes in the disassembly. My binary-patching is feeble -- overwriting the instruction with nops makes Vanilla unbootable, and I didn't have other ideas.

The gist: I want exactly one bug in Vanilla patched, the crash between levels. I'd be open to learn how exactly Plus does that. Would the Plus devs share knowledge?

-- Simon
Simon is offline   Reply With Quote
Old July 19th, 2017, 01:07 AM   #6
Sir Ementaler
JCF Member
Currently sadistically consuming marshmallows
 
 
Join Date: Feb 2010
Location: Fridge
Reputation: Sir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to all
Send a message via Skype™ to Sir Ementaler
There are several crashes between levels that I recall but I believe the most prominent cause on Linux to be related to music playback. JJ2 uses parallel threads incorrectly and, as far as I could tell, assumes that one will finish its work in time for the other to have it available. Multiple Linux users reported that disabling music in the game options reduces or completely eliminates crashes; although this was said about JJ2+ before this fix rather than about vanilla JJ2.

Because the error is related to how multithreading was designed in that part of code, a proper fix would be fairly complicated. The fix I wrote for it is essentially an equivalent of duct tape; it doesn't look great, or work great, but at least the hole is gone until a better solution is in place. I can try to help you adapt it to vanilla JJ2 but first please provide the address your crash occurs at to confirm that's it.
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.
Sir Ementaler is offline   Reply With Quote
Old July 19th, 2017, 01:28 AM   #7
Simon
JCF Member
 
 
Join Date: Dec 2016
Location: Germany
Reputation: Simon is doing well so far
Hah, thanks for the offer. I run in vanilla 1.23.

Between levels, there is a chance to crash at 0x004a2a72 by reading from 0x0.

During levels, exiting the entire program by Alt+F4 can again crash at 0x004a2a72 by reading from 0x0.

-- Simon
Simon is offline   Reply With Quote
Old July 19th, 2017, 03:17 AM   #8
Sir Ementaler
JCF Member
Currently sadistically consuming marshmallows
 
 
Join Date: Feb 2010
Location: Fridge
Reputation: Sir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to allSir Ementaler is a name known to all
Send a message via Skype™ to Sir Ementaler
Yeah, that's the address. The line of Assembly that crashes your game is mov ecx, [eax]. It accesses whatever eax is pointing at, and eax is previously loaded from a variable that, presumably, another thread is supposed to write to. JJ2 doesn't correctly test whether this already happened or not, so sometimes it's null, hence the attempt to read from 0x0. Thus the proper solution would probably be to create a lock to prevent JJ2 from entering that part until the other thread is finished.

We're not going to be doing that. It's complex and, in code we don't entirely understand, has a lot of room for error. What JJ2+ does is simply test whether the pointer is null and not perform any of the following actions if so. This is a moderately good solution but it also means injecting more code than there's room for. It works for us because we have a setup where we can perform jumps from JJ2 code to our own and back, but it's not easy to do otherwise. You can't insert additional bytes in the middle of the executable without breaking everything, so it may not be a viable solution for you.

You could easily always terminate execution of the function early but this would probably be exactly equivalent to just disabling your music output altogether. Alternatively you could delay the execution of this function more but it wouldn't be guaranteed to eliminate crashes, only make them more sparse. I'll get back to you if I find a solution that's more worthwhile.
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.
Sir Ementaler is offline   Reply With Quote
Old July 19th, 2017, 07:03 AM   #9
WhiteBlaster
JCF Member
The keeper of the sacred gun, the White Blaster.
 
 
Join Date: Apr 2008
Location: Home, Italy, Earth, Solar System, Milky Way, Universe Delta.
Curious coincidence, I have been working on similar stuff lately. I've been working on a project that needed injecting a considerable amount of code inside some functions in the JJ2 executable. I COULD have used the spare space at the end of the code section, but that space would have exhausted anyway in the end, jumping all over the place isn't healthy cache-wise, and the compiler used for JJ2 is apparently pretty crummy given the results; so I figured I could optimize the code myself by hand, compressing the existing functions and inserting my own stuff in it.
I'd say that over time I became rather proficient at it; like, with the keyboard state processing routine I managed to save about 47% of the space, while preserving original functionality (hopefully) and without hammering down performance too much.

Just saying that, if you need a hand with this kind of stuff in JJ2+, I'd be happy to contribute.

P.S.: Hi guys, long time no see.
__________________
Mercatura musicae delenda est.

There is a flame untamed
Deep in my heart
Unyielding, pure Ain Soph
'tis measureless
Our right divine:

Aspire to all horizons
To seek nature ov things
Retreat within yourself
To find the primal breath

Behemoth - Transmigrating Beyond Realms ov Amenti
WhiteBlaster is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -8. The time now is 08:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
JCF © 2001-Infinity Jazz2Online