Author Topic: Replay logging  (Read 8106 times)

zaqrack

  • Administrator
  • Addicted to spam
  • *****
  • Posts: 4527
    • View Profile
    • ZakStunts
Re: Replay logging
« Reply #45 on: February 09, 2013, 02:15:05 PM »
DAMN YOU CHINA for blocking youtube AND my VPN. :(
I hope I can check the video soon.

zaqrack

  • Administrator
  • Addicted to spam
  • *****
  • Posts: 4527
    • View Profile
    • ZakStunts
Re: Replay logging
« Reply #46 on: February 09, 2013, 02:25:10 PM »
DAMN YOU CHINA for blocking youtube AND my VPN. :(
I hope I can check the video soon.

some DNS hacking helped :) AWESOME work!!!

CTG

  • Spam, egg, spam, spam, bacon and spam
  • *
  • Posts: 20046
  • Psycho
    • View Profile
    • UnskilledStunts Championship
Re: Replay logging
« Reply #47 on: February 09, 2013, 02:25:39 PM »
DAMN YOU CHINA

Beware, Zak McKracken, the Chinese CIA (how do they call it anyway?) is watching you! :D

It's the MicroMachines version of Gutix' ZCT 70 replay.

dreadnaut

  • Helen`s Lover
  • **
  • Posts: 636
    • View Profile
    • chezDreadnaut
Re: Replay logging
« Reply #48 on: February 09, 2013, 07:39:57 PM »
Dumping Stunts' memory with dosbox's debugger, I seem to find the gear/surface string at 0000:37684 consistently, which would place the player vector at 375C6.

Could it be easier to dump data inside dosbox?
« Last Edit: February 09, 2013, 07:49:52 PM by dreadnaut »

Duplode

  • Moderator
  • Considering trying out spam
  • *****
  • Posts: 3430
  • Through the astral door - to soar
    • View Profile
    • The Southern Cross Stunts Trophy
Re: Replay logging
« Reply #49 on: February 09, 2013, 07:50:37 PM »
Could it be easier to dump data inside dosbox?

It probably is if you, unlike me, know how to operate a DOS debugger properly  :D The problem with DOSBox's debugger is that there seems to be no way to dump a running log of a location in memory while the game plays. I imagine that a more sophisticated debugger should be able to do that, though for me it was quicker to use the scanmem hack given the aforementioned ignorance. (And please do tell us if you know a better tool, or how to make one!)

Dumping Stunts' memory with dosbox's debugger, I seem to find the gear/surface string at 0000:37684 consistently.

Indeed; that kind of shows up in scanmem too - in my tests the final three digits of the 64-bit address I get with it appear to be always 694 due to, I believe, contingent facts about how DOSBox allocates memory.
« Last Edit: February 09, 2013, 07:54:06 PM by Duplode »

dreadnaut

  • Helen`s Lover
  • **
  • Posts: 636
    • View Profile
    • chezDreadnaut
Re: Replay logging
« Reply #50 on: February 09, 2013, 08:02:08 PM »
It probably is if you, unlike me, know how to operate a DOS debugger properly  :D
So far from reality, I've never used it before! It took me half an hour to get a dump of the memory and just as much to find the saved file! :P

I was thinking more of a dos TSR program, dumping the contents of the correct memory location to disk. However, I don't have much experience in writing those either. At that point, it might be easier to modify dosbox and add the feature.*

* quick look at the code: no, it's probably not :D
« Last Edit: February 09, 2013, 08:08:37 PM by dreadnaut »

dstien

  • Moderator
  • Stunts Master
  • *****
  • Posts: 160
    • View Profile
    • Stunts Tools
Re: Replay logging
« Reply #51 on: February 10, 2013, 04:56:18 AM »
Now that's just awfully awesome! 8)

I tried another approach at dumping the data, and ended up with a restunts based tool. It's in the repo as repldump. It basically initializes the game engine with a replay, steps through each frame, performs update_gamestate(), and dumps the entire 1120 byte gamestate structure to a file for every iteration.



Usage
Put the attached repldump.exe in your Stunts folder and run repldump.exe replname in a 16-bit DOS environment, such as DOSBox. The replay must be located in the same folder, and the file extension must not be included in the command. The program will then read replname.rpl and write replname.bin. The result file has the following format:
Code: [Select]
uint16 numFrames;
uint8 gamestate[numFrames][1120];

I also attached an example C program for parsing this file. Take the struct declarations with a grain of salt. I suspect that some of the field names are at best misleading. But all in all this info should enable us to compute penalty time, detect DNF, provide analysis, and maybe find the cause of some bizarre bugs.

Duplode

  • Moderator
  • Considering trying out spam
  • *****
  • Posts: 3430
  • Through the astral door - to soar
    • View Profile
    • The Southern Cross Stunts Trophy
Re: Replay logging
« Reply #52 on: February 10, 2013, 08:51:19 AM »
Whoa! :o

The post above is the most important in this thread by far. For those of you not familiar with the restunts technical context: the innocent-looking tools attached to it aren't just a way to extract the coordinates in two simple steps, getting rid of all the annoying hacks I had been using. Rather, what you can see above is, for the first time ever, the game engine being used to run a replay outside of Stunts. Dstien hinted at some of the possibilities that opens above and elsewhere. In particular, earlier I said "The tools described above likely won't be convenient to use for a while". Now that "while" might get significantly shorter ;)

Three cheers for Dstien! Next to him, I'm just a pipsqueak.  :)
« Last Edit: February 10, 2013, 08:54:41 AM by Duplode »

zaqrack

  • Administrator
  • Addicted to spam
  • *****
  • Posts: 4527
    • View Profile
    • ZakStunts
Re: Replay logging
« Reply #53 on: February 10, 2013, 10:50:43 AM »
we live in exciting times!  :o

CTG

  • Spam, egg, spam, spam, bacon and spam
  • *
  • Posts: 20046
  • Psycho
    • View Profile
    • UnskilledStunts Championship
Re: Replay logging
« Reply #54 on: February 10, 2013, 12:13:53 PM »
The day of my real retirement is getting closer and closer.

Friker

  • Otto's Student
  • **
  • Posts: 385
    • View Profile
Re: Replay logging
« Reply #55 on: February 10, 2013, 12:35:57 PM »
... the game engine being used to run a replay outside of Stunts ...

I just didn't want to tell it loud.

Ok, this means some simulating can be applied...

dreadnaut

  • Helen`s Lover
  • **
  • Posts: 636
    • View Profile
    • chezDreadnaut
Re: Replay logging
« Reply #56 on: February 10, 2013, 02:05:11 PM »
Brilliant job dstien!

First feature requests then ;D  Dump only the last state of the simulation, and maybe dump to stdout so I can pipe it into other programs.

I'd also like to point out how great this thread is, how it started simple and to the point
Is there a possibility to make an automatic statistic program? Only with reading the replay?
how it was there all along
How much code from restunts is reusable? Could the replay engine (i.e., the fast forward button) be used to run replays?
and how high it soared in less than a week!


edit: also, at least on windows the program could run in the standard 16bit environment, without dosbox; the only issue is that it switches to graphics mode. Would it be possible to make it a console program?
« Last Edit: February 10, 2013, 02:39:06 PM by dreadnaut »

BonzaiJoe

  • Spam, egg, spam, spam, bacon and spam
  • *
  • Posts: 5081
    • View Profile
    • Purple
Re: Replay logging
« Reply #57 on: February 10, 2013, 05:45:06 PM »
The day of my real retirement is getting closer and closer.

Unlike other future events?
But we can't be quite sure.


CTG

  • Spam, egg, spam, spam, bacon and spam
  • *
  • Posts: 20046
  • Psycho
    • View Profile
    • UnskilledStunts Championship
Re: Replay logging
« Reply #58 on: February 10, 2013, 05:49:26 PM »
The day of my real retirement is getting closer and closer.

Unlike other future events?

There's the point. ;D

(retirement is not a necessary one)

dstien

  • Moderator
  • Stunts Master
  • *****
  • Posts: 160
    • View Profile
    • Stunts Tools
Re: Replay logging
« Reply #59 on: February 10, 2013, 11:22:11 PM »
First feature requests then ;D  Dump only the last state of the simulation, and maybe dump to stdout so I can pipe it into other programs.

edit: also, at least on windows the program could run in the standard 16bit environment, without dosbox; the only issue is that it switches to graphics mode. Would it be possible to make it a console program?
Do you run a pre-Vista 32-bit OS? Didn't expect it to run natively on any platform released in this century. ;D

The reason why the program acts a little flaky is because I chose to link it to entirely unmodified original Stunts code to ensure there were no possible regressions from our ported code. The main stunts initialization function does a whole lot of stuff besides loading data. Like changing the video mode and hooking up interrupt callbacks. To halt the program after closing the output file handle I just invoke Stunt's fatal_error() function to unwind it all. I plan to add another build target so that we can use repldump with both stock code and our ported code, then we can easily test the restunts code automatically by comparing the output from the two programs. This will also enable us to use a ported init function that sets up only the bare minimum for a properly behaving command line program and implement more features. There's a lot of code that remains to be ported, so the build target will remain 16-bit DOS only for the foreseeable future.

Once we've got a clearer view of the gamestate content, and I don't think that will take Duplode long, we could probably set up a web service that takes care of the processing and parsing so that phpStunts don't need to depend on an x86 hypervisor and little-endian data parsing. :)