Author Topic: Battles playing at 60fps  (Read 30456 times)

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #175 on: 2012-04-11 17:08:04 »
Well quaternions is a bust so far, but I have implemented some other things to help interpolate the models.

- Kimera detects problem rotations and notes them in a log file for manual tweaking
- Kimera interpolates all animations in the model with one click

All in all the interpolation seems to be about 99% accurate, which is fine with me as it cuts down immensely on the time needed to redo the models. I will start redoing the animations soon. The nice thing about these is it does not matter if you use the standard model or a redone one the animations should still work (assuming people do not mess with bones).

NFITC1, you should get to work on increasing the wait time for the texture effects, we will need them soon.

NFITC1

  • No life
  • *
  • Posts: 1909
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battles playing at 60fps
« Reply #176 on: 2012-04-12 13:52:08 »
Trying to even FIND where the animation scripts are handled is going to be tough. I'm not really sure where to start.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #177 on: 2012-04-12 14:10:58 »
Perhaps akari could help with this. He has much of the exe decoded.

NFITC1

  • No life
  • *
  • Posts: 1909
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battles playing at 60fps
« Reply #178 on: 2012-04-12 20:12:19 »
Yeah. Just a pointer to one animation opcode handler would be enough for me to find the rest. I got to thinking about some other things though. I don't do graphics very often so forgive me if this sounds stupid. This might be a graphic driver question and best be resolved there. Aali might be able to help too.
I think Akari is tired of me asking him questions every time I can't find a function or trace a value.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #179 on: 2012-04-12 23:56:28 »
Yeah. Just a pointer to one animation opcode handler would be enough for me to find the rest. I got to thinking about some other things though. I don't do graphics very often so forgive me if this sounds stupid. This might be a graphic driver question and best be resolved there. Aali might be able to help too.
I think Akari is tired of me asking him questions every time I can't find a function or trace a value.


Well, there is this from Aali



I wrote these tools to help me read and edit .s files, maybe you can put them to good use. Simply adding more frames to the animations just caused it to cut out early when I tried it but maybe you can figure that out.

sptdump.c: .s file -> text format
Code: [Select]
#include <stdio.h>
#include "spt.h"

int main(int argc, char *argv[])
{
   FILE *f;
   struct spt_header header;
   int i;
   int j;
   
   if(argc < 2)
   {
      printf("usage: sptdump <file>\n");
      exit(1);
   }
   
   f = fopen(argv[1], "rb");
   
   fread(&header, sizeof(header), 1, f);
   
   printf("File type: %p\n", header.file_type);
   printf("Version: %p\n", header.version);
   printf("Number of SPT entries: %i\n", header.num_spt_entries);
   
   printf("\n");
   
   for(i = 0; i < header.num_spt_entries; i++)
   {
      struct spt_entry entry;
     
      fread(&entry, sizeof(entry), 1, f);
     
      printf(" SPT Entry %i: %p, %i\n", i, entry.field_0, entry.num_spt_struc_183);
     
      for(j = 0; j < entry.num_spt_struc_183; j++)
      {
         struct spt_struc_183 struc_183;
         
         fread(&struc_183, sizeof(struc_183), 1, f);
         
         printf("  %i: %p %5i %5i %5i %5i %5i %5i 0x%04x %3u %3u %3u %3u\n", j, struc_183.flags, struc_183.x, struc_183.y, struc_183.field_8, struc_183.field_A, struc_183.texture_page, (struc_183.field_E & 0x3F) << 4, struc_183.field_E >> 6, struc_183.w1, struc_183.w2, struc_183.h1, struc_183.h2);
      }
   }
   
   return 0;
}

sptbuilder.c: text format -> .s file
Code: [Select]
#include <stdio.h>
#include <string.h>
#include "spt.h"

const char file_type[] = "File type: ";
const char version[] = "Version: ";
const char num_spt_entries[] = "Number of SPT entries: ";

int main(int argc, char *argv[])
{
   FILE *f;
   FILE *of;
   struct spt_header header;
   int i;
   int j;
   char line[4096];
   
   if(argc < 3)
   {
      printf("usage: sptbuilder <infile> <outfile>\n");
      exit(1);
   }
   
   f = fopen(argv[1], "r");
   
   of = fopen(argv[2], "wb");
   
   if(!f)
   {
      perror("input file");
      exit(1);
   }
   
   if(!of)
   {
      perror("output file");
      exit(1);
   }
     
   while(1)
   {
      fgets(line, sizeof(line), f);
     
      printf("%s", line);
     
      if(!strncmp(line, file_type, sizeof(file_type) - 1)) sscanf(strstr(&line[sizeof(file_type)], "x") + 1, "%hhx", &header.file_type);
      else if(!strncmp(line, version, sizeof(version) - 1)) sscanf(strstr(&line[sizeof(version)], "x") + 1, "%hhx", &header.version);
      else if(!strncmp(line, num_spt_entries, sizeof(num_spt_entries) - 1)) sscanf(&line[sizeof(num_spt_entries) - 1], "%i", &header.num_spt_entries);
      else break;
   }
   
   printf("Done parsing headers\n");
   
   header.field_2 = 0;
   
   fwrite(&header, sizeof(header), 1, of);
   
   for(i = 0; i < header.num_spt_entries; i++)
   {
      struct spt_entry entry;
     
      printf("Parsing SPT entry %i\n", i);
     
      fgets(line, sizeof(line), f);
     
      printf("%s", line);
     
      strtok(line, ":,");
     
      sscanf(strstr(strtok(0, ":,"), "x") + 1, "%hx", &entry.field_0);
      sscanf(strtok(0, ":,"), "%hi", &entry.num_spt_struc_183);
     
      fwrite(&entry, sizeof(entry), 1, of);
     
      for(j = 0; j < entry.num_spt_struc_183; j++)
      {
         struct spt_struc_183 struc_183;
         int tmp1;
         int tmp2;
         
         printf("%i\n", j);
         
         fgets(line, sizeof(line), f);
         
         printf("%s\n", strtok(line, ":"));
         
         //printf("%s\n", strtok(0, ":"));
         
         sscanf(strstr(strtok(0, ":"), "x") + 1, "%x %5hi %5hi %5hi %5hi %5hi %5i %p %3hhi %3hhi %3hhi %3hhi", &struc_183.flags, &struc_183.x, &struc_183.y, &struc_183.field_8, &struc_183.field_A, &struc_183.texture_page, &tmp1, &tmp2, &struc_183.w1, &struc_183.w2, &struc_183.h1, &struc_183.h2);
         
         struc_183.field_E = tmp2 << 6;
         struc_183.field_E |= tmp1 >> 4;
         
         fwrite(&struc_183, sizeof(struc_183), 1, of);
      }
   }
   
   fclose(of);
   
   return 0;
}

spt.h: data structures used in both programs
Code: [Select]
#ifndef _SPT_H_
#define _SPT_H_

struct spt_header
{
   unsigned char file_type;
   unsigned char version;
   unsigned short field_2;
   unsigned int num_spt_entries;
} __attribute__((__packed__));

struct spt_entry
{
   unsigned short field_0;
   unsigned short num_spt_struc_183;
} __attribute__((__packed__));

struct spt_struc_183
{
   unsigned int flags;
   short x;
   short y;
   short field_8;
   short field_A;
   unsigned short texture_page;
   short field_E;
   unsigned char w1;
   unsigned char w2;
   unsigned char h1;
   unsigned char h2;
} __attribute__((__packed__));

#endif


Of course that's all Greek to me.

LeonhartGR

  • No life
  • *
  • Posts: 1064
  • ~Whatever...~
    • View Profile
Re: Battles playing at 60fps
« Reply #180 on: 2012-04-13 02:22:44 »
Of course that's all Greek to me.

I'm Greek but still can't read it... :mrgreen:

kranmer

  • Freak
  • *
  • Posts: 699
    • View Profile
Re: Battles playing at 60fps
« Reply #181 on: 2012-04-13 10:42:30 »
Of course that's all Greek to me.
Well it appears to be C, it should be easy to compile to EXE with a compiler like Mingw,
try installing mingw and msys (both free programs) to the default directory of C:\Mingw
then run mingw from your startmenu and you should get a command box, then copy and paste all the text in those code boxes into TXT files and use the filenames provided sptdump.c,sptbuilder.c,spt.h
then put these 3 files into your
C:\MinGW\msys\1.0\home\USERNAME
folder.
Then in the command line type
GCC -c sptdump.c -o sptdump.o
then press enter then type
GCC sptdump.o -o sptdump.exe

then you will have sptdump.exe then do this for sptbuilder

GCC -c sptbuilder.c -o sptbuilder.o
press enter then
GCC sptbuilder.o -o sptbuilder.exe

then you will have sptbuilder.exe and sptdump.exe files. And that should do it. hope this helps.
NOTE: in the line C:\MinGW\msys\1.0\home\USERNAME where it says USERNAME it should your windows username, so for me its Kram since i log into windows with that username.

LeonhartGR

  • No life
  • *
  • Posts: 1064
  • ~Whatever...~
    • View Profile
Re: Battles playing at 60fps
« Reply #182 on: 2012-04-13 11:52:18 »
Well it appears to be C, it should be easy to compile to EXE with a compiler like Mingw...

Well I was just kidding... my response was sarcastic because I'm totally irrelevant with programming  ;D
I noted this down as a tutorial... really interesting though. It might be useful sometime. Thanks!

~edit~ I downloaded the get-inst exe. I noticed it contains msys, do I have to install msys separately? I guess not.

Oh and I love sourceforge. In the past I have acquired some free user created educational software for my students...

~edit~ Ok I made it... lol. Though I don't know what to use them for... it was quite fun following your instructions :P
« Last Edit: 2012-04-13 12:36:07 by Leonhart7413 »

NFITC1

  • No life
  • *
  • Posts: 1909
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battles playing at 60fps
« Reply #183 on: 2012-04-13 13:13:56 »
Well, there is this from Aali

I would guess (and I could be wrong on this) that even though he added more frames, there might still be a framecount inside the animation that just cuts it off prematurely. If that's the case then exe modding might not be enough. I'll still look into it.

Of course that's all Greek to me.

Because it's not self-documented.

Code: [Select]
   short field_8;
   short field_A;
   short field_E;
   unsigned char w1;
   unsigned char w2;
   unsigned char h1;
   unsigned char h2;

What is any of that?! The variable names can be 256 characters long for a reason and this ain't it. >:(

No offense, Aali. You're obviously a good enough programmer to create a graphics driver (more than I can do), but your code's nomenclature doesn't lend itself to third-party ease-of-use.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #184 on: 2012-04-20 03:40:29 »
So I had some free time tonight and decided to clean up the Archives a bit when I stumbled across this,  http://forums.qhimm.com/index.php?topic=8882.msg115841#msg115841 Now, I'm not sure if Timu is positive about what he's talking about.  But those animations definitely look like they're running at 60fps.   If Akari is able to do this with the PSX data... Could we not then take that same data ourselves and simply convert it to the PC format and replace what we already have?


It would save a ton of time messing with those damn gimbal locks, not to mention actually making the animation smooth instead of us having to make guesses between 180 and 360.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #185 on: 2012-04-20 14:50:50 »
Interesting idea, but it is most likely generated in real time. The other option would be for me to get my hands on his code and see if i could port it and shove it into kimera.

Hellbringer616

  • No life
  • *
  • Posts: 1765
    • View Profile
Re: Battles playing at 60fps
« Reply #186 on: 2012-04-20 15:10:20 »

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #187 on: 2012-05-10 04:44:12 »
OK so check this out.  I was watching the youtube video again, and when it came time for Braver I got to thinking.  If you listen and watch closely, it seems like his movements are sync'd with the animation.  I wonder if you slow them both down if the animation will slow down..

Borde

  • Freak
  • *
  • Posts: 864
    • View Profile
Re: Battles playing at 60fps
« Reply #188 on: 2012-05-15 17:04:51 »
I added animation interpolation to Kimera, so at least the field and battle character animations (save for the limit breaks) should now be possible to set at 60 FPS. Unfortunately, I don't know about all the rest.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #189 on: 2012-05-15 17:19:00 »
I added animation interpolation to Kimera, so at least the field and battle character animations (save for the limit breaks) should now be possible to set at 60 FPS. Unfortunately, I don't know about all the rest.
Any hypothesis at all what's going on with the limit breaks?   Could it potentially be linked to the length of the sound effect being played?

Borde

  • Freak
  • *
  • Posts: 864
    • View Profile
Re: Battles playing at 60fps
« Reply #190 on: 2012-05-15 17:41:20 »
Unfortuanately, I must confess I'm complety at a loss here Obesebear. It would seem reasonable for limit break animations to be stored togheter with the other battle animations, but as long as I know, noone around here has found a trace about them. My information could be outdated, though, I've been away for quiet a while.

I don't think animation length can be automatically adjusted by the game engine. All other animations have a fixed framerate. But then again, who knows.

NFITC1

  • No life
  • *
  • Posts: 1909
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battles playing at 60fps
« Reply #191 on: 2012-05-15 20:35:01 »
Unfortuanately, I must confess I'm complety at a loss here Obesebear. It would seem reasonable for limit break animations to be stored togheter with the other battle animations, but as long as I know, noone around here has found a trace about them. My information could be outdated, though, I've been away for quiet a while.

I don't think animation length can be automatically adjusted by the game engine. All other animations have a fixed framerate. But then again, who knows.

I thought limit break animations were contained with the magic animations. Pushing some magic anims beyond a certain number seemed to support that theory. Their effects range from 00h - 4Eh. I don't know where these are stored, but it doesn't seem like they're stored in the animation of the actors themselves. They're likely in the magic.lgp somewhere and made to specifically reference bones of the actor.

Borde

  • Freak
  • *
  • Posts: 864
    • View Profile
Re: Battles playing at 60fps
« Reply #192 on: 2012-05-15 21:21:28 »
Mmmm... that's interesting. There sure are a lot of files in magic.lgp that clearly reference limit breaks, but mostly tex, p and rsd files. There are also some s files which I don't have a clue what may contain. Is there any information about them?

Corigne

  • Fast newbie
  • *
  • Posts: 23
  • PM me if you need extra hands on a project!
    • View Profile
    • Fireheart Inc
Re: [WIP] Running all of FF7 at 60fps
« Reply #193 on: 2012-05-16 02:47:52 »
If FF7 can use all your CPU's power, I think you need a new PC. :P

Kidding aside, that's really not a good argument to avoid this option.

Most games do this, any modern game is going to use every CPU cycle it needs to run the game full speed. Assuming the game is using VSync\frame limiting, it will only stop consuming CPU cycles once the desired 60fps has been reached.

If you remove the limiting(ie, no VSync\frame limiting), it will allow the FPS to go beyond 60fps, and it will keep increasing as long as you have CPU power to spare, using all of your CPU power. (Unless of course the programmers added some additional code to keep it under control. By checking FPS vs. CPU usage percentage, but I doubt many, if any do this.)

So it's a bit hard to give you an accurate answer here, but the bottom line is this, if you have a problem with a game using all your CPU cycles, use VSync, or any built in frame limiter the game may have, or else it will.

I hope that explained it, it's kind of a tricky question.

----

As for the rest of the questions.

A game loop is just a loop in the games code, this loop usually updates all the games individual parts. (We are ignoring multithreading, etc,. For simplicities sake.)

These parts include, renderers, physics, controls, sound, etc,. (AKA, game logic.)

Loops work like this.

Loop Start
 Do Something
 Do Something Else
Loop End -> Return to Loop Start, Repeat.

(This process is a loop iteration, ie, going from loop start to loop finish, is one loop iteration.)

Now, in most games, you will not want everything updating every single loop iteration.

So you do this.

Loop Start
 Counter+= 1; // Count Iterations
 Update Sound // Updates Every Iteration
 
 if (Counter >= 2)
 {
   Update Animations
   Counter = 0; // Reset Counter
  }
 
Loop End

That would make animations skip a frame(this is called frame skipping), and animate every other frame. (As opposed to every frame like sound in the example above.)

Using mathematical formulas, you can control when animations get updated, and keep them at the desired speed, no matter how many FPS you are getting.

(FPS is the amount of loop iterations that occur within a single second. A loop iteration is also known as a frame, thus the term frames per second.)

I hope that's more clear.

----

As for benefits, think about loading, if everything is capped at so many iterations per second, say 30 iterations(ie, 30fps), loading is also capped. So the game loads textures, and such, slower than it could.

By locking animations, and unlocking other stuff, you can make the game load faster, and process other stuff faster, while still animating at a fixed rate. (This is great for loading, and processing input, anything you want happening as fast as possible.)

In FF7's case, you can expect faster save times, faster area transitions, smoother overall feel, more responsive controls, and probably no more hitching, stuttering, etc,. (No matter what mods, or resolution you are running, ie, FF7 is NOT that demanding of a game compared to modern games.)

Sorry about the novel, this is why I was being somewhat vague to begin with, it's rather complex.

--

Edit:

@Seif, you are correct, I was just offering a solution that was better than padding all the animations, figuring out how to slow down the camera, slowing down menu's, etc, etc,.

Btw, I also recommend this method for another reason. Think about it, the game is running at super speed @60fps, correct? (I saw the video, it looked pretty fast.)

So, do you think padding animations will fix scripted events? NPC's will move from point A to point B at super speed, regardless of animation padding, so it will have normal speed animation(with padding), but still move at super speed(on their scripted paths), so it won't look right at all.

Seif was right on with the frame based stuff, there is a lot more to fix than you guys are taking into account. So, if you're going to do it, you might as well go all out, and basically fix the port. (Which is what I'm suggesting, and explaining.)

Seif was also right about some things not being designed to work that way, so you will still have figure out some stuff on your own, basically, add what I suggested, then see what's still working wrong, and fix it. (I would tell you if I knew, but I've never re-ported FF7 via hacking b4, so I don't know the specifics, sorry.)

One of the reasons why separate GPU's exist.  All the extra calculation needed to take advantage of graphic enhancement and calculations for VSync and the like use the GPU's cycles, thus freeing up the CPU for non-video calculations. (which as was said before means "If FF7 takes 100% of your cpu, you need a new computer.")

On an interesting side note, TES V: Skyrim actually uses the cpu to calculate shadows separate of the GPU.  I thought that was interesting.

Also, in regards to the limit files... most of them can be found in magic.lgp (I know it's been said but I'm confirming that I've seen them there).  I'm having a hard time locating braver myself, as others have been.  However, my time right now has been limited.  Is there anything else that needs to be worked out on this that I might be able to assist with? I would most definitely enjoy a 60 FPS battle sequence.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #194 on: 2012-05-16 03:20:24 »
Mmmm... that's interesting. There sure are a lot of files in magic.lgp that clearly reference limit breaks, but mostly tex, p and rsd files. There are also some s files which I don't have a clue what may contain. Is there any information about them?
I want to think that someone discovered that s files are indeed animation files.  But I couldn't tell you who found out or begin to point you in the right direction of it.


Corigne, NFITC1 is still working on getting the images to display at 60fps.  Since Borde figured out the interpolation of animations, I'd say those are our two current biggest hurdles to having a "quality" battle at a high frame rate.

Corigne

  • Fast newbie
  • *
  • Posts: 23
  • PM me if you need extra hands on a project!
    • View Profile
    • Fireheart Inc
Re: Battles playing at 60fps
« Reply #195 on: 2012-05-16 03:39:53 »
Ah, I see. I'll see if I can be of any use then.

Cheers.

NFITC1

  • No life
  • *
  • Posts: 1909
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battles playing at 60fps
« Reply #196 on: 2012-05-16 12:07:25 »
Mmmm... that's interesting. There sure are a lot of files in magic.lgp that clearly reference limit breaks, but mostly tex, p and rsd files. There are also some s files which I don't have a clue what may contain. Is there any information about them?

I believe Akari has/had info on those s files. I'm not sure where that went, though.

What I believe I've figured out about the textures is that the graphics driver handles them. The executable passes an animation index and the graphics driver is actually the one reading the associated files and doing things with them. I've only been looking through the exe for op handlers like the camera scripts are doing. I think I can say with certainty that what is needed is in the graphics driver which I have yet to do any reversing of. I might make a fresh install today specifically for reversing that.

@Corigne: I believe the rules state to not block quote large posts like that. You can quote it, but trim it down to only what you're commenting about. Especially from a two year old post.

Aali

  • No life
  • *
  • Posts: 1120
    • View Profile
Re: Battles playing at 60fps
« Reply #197 on: 2012-05-16 15:30:01 »
I would guess (and I could be wrong on this) that even though he added more frames, there might still be a framecount inside the animation that just cuts it off prematurely. If that's the case then exe modding might not be enough. I'll still look into it.

Because it's not self-documented.

Code: [Select]
   short field_8;
   short field_A;
   short field_E;
   unsigned char w1;
   unsigned char w2;
   unsigned char h1;
   unsigned char h2;

What is any of that?! The variable names can be 256 characters long for a reason and this ain't it. >:(

No offense, Aali. You're obviously a good enough programmer to create a graphics driver (more than I can do), but your code's nomenclature doesn't lend itself to third-party ease-of-use.

Haha, saw this very entertaining post just now.

1. It's not documented because I don't know what it means. If I had more descriptive names I would have used them but I don't.
2. The programs don't really need to be modified, short of a complete rewrite into a proper tool. (The functionality is all there to allow you to atleast run some tests and come to the same conclusion I did, modifying .s files is not very useful on its own)
3. If you don't want to use it, fine, you don't have to be a d*ck about it.

NFITC1

  • No life
  • *
  • Posts: 1909
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battles playing at 60fps
« Reply #198 on: 2012-05-17 01:03:51 »
Haha, saw this very entertaining post just now.

...
3. If you don't want to use it, fine, you don't have to be a d*ck about it.

LOL. I honestly didn't mean to offend you. I should have wrapped that statement in sarcasm tags, but I thought it was more obvious than it turned out to be. I'll give credit to whom it is due and you deserve quite a lot for what you've done. :)
I understand the undocumented variable problem. I've come across that a lot while trying to read Akari's code and I'm sure he has the same issues trying to figure out what is what.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #199 on: 2012-05-30 14:06:42 »
Just an update from my side.  I finished all the playable characters (except the frog) but have also been tackling many household projects like repainting and bathroom remodeling.  Give me about a week and I should have enough time to go through all the characters.