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

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Battles playing at 60fps
« on: 2010-06-17 04:13:55 »
Project Goal

To get Final Fantasy 7 battles playing at 60 frames per second.


Current Completion Progress

Model animations updated... 0% (Kimera needs a bit of tweaking first)

Limit Break animations updated... 0% (Need to find where these are stored.  Potentially within .s files)

Camera animations updated... 80% (still may be a few instances of the camera being handled elsewhere)

Texture animations updated... 10% (Aali seems to have decompiled the .s data, but that information has yet to be harnessed)

Tifa, Cait's limit slots, battle square slots updated... 25% (DLPB will probably knock this out shortly)



Important Information
In order to get the game running battles at 60fps, the following values need to be hex edited in the ff7.exe:
0x3BF506 from 2E to 5E, 0x3BF50E from 2C to 5C, and 0x3BF516 from 2E to 5E.

.S Files Dump
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


Proof of Concept Videos
http://www.youtube.com/watch?v=D6ziBsBNSfI
http://www.youtube.com/watch?v=rx3DHs4iMzA

I found a few values in the exe which make the items on the menu smoother.  So far I have only found the side menu values but with Kranmer I am guessing the rest (like Gil Box) can also be found.  Have a go yourself:

FF7.exe
Edit address 002C8EA0 to 50
Edit address 002C8EAB to 12

Then open the menu and pay attention to the side menu (other values need altering to make it look perfect but this should give you a good idea)
« Last Edit: 2012-07-12 02:44:50 by Obesebear »

DLPB

  • No life
  • *
  • Posts: 4999
  • Karma: 80
  • The Mighty Arms of Atlas
    • View Profile
Re: Running FF7 at 60fps
« Reply #1 on: 2010-06-17 04:36:01 »
if you have gone from 15 to 60 shouldn't that be 4X faster?

edit.

Let me know how you get on....I would be surprised if it was possible to change it all to 60 fps and get everything working without some major changes, but maybe it isn't working like I expect....
« Last Edit: 2010-06-17 04:37:41 by seif »

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #2 on: 2010-06-17 04:51:58 »
Well I added 3 duplicate frames after each change in animation, but it seemed a little too slow.  Granted that could very likely be from watching everything else move insanely fast, so I changed it to 2 instead.  Not sure if it's too fast or slow.   We can get it perfect later :)

The camera also moves too fast, but I think Proud Clod is able to mess with that, so no problem there.   SFX plays at normal speed, the only problem I've found so far is the texture animations play too fast :(.   So we either need to learn how to edit the .s files, or hope that someone finds a way to force them to play at normal operating speed.

I'll be pretty surprised as well.  Besides being tedious there has to be a reason no one did this before.

« Last Edit: 2010-06-17 05:07:45 by obesebear »

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3573
  • Karma: 16
  • GUI Master :P
    • View Profile
Re: Running FF7 at 60fps
« Reply #3 on: 2010-06-17 05:23:39 »
Just looked into it. Made the fps 45 and obesebear's redone animations look good at this speed. So definately need more animation frames for 60fps.

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #4 on: 2010-06-17 05:52:23 »
Yeah my bad, watching everything move so fast while I experimented with it messed me up.   Adding 3 duplicate frames for every change in animation looks perfect at 60 fps.

To increase the speed to 60 fps change 0x3BF506 from 2E to 5E, 0x3BF50E from 2C to 5C, and 0x3BF516 from 2E to 5E.


--Edited for correct values and changes--
« Last Edit: 2010-06-18 07:36:56 by obesebear »

Gemini

  • Insane poster
  • *
  • Posts: 262
  • Karma: 6
  • Not learner's Guru
    • View Profile
    • Devil Hackers
Re: Running FF7 at 60fps
« Reply #5 on: 2010-06-17 09:44:13 »
Instead of redoing all animations (which is a terrible idea, IMHO), just take the interpolation algorithm and make it output 3 more intermediate frames. There you go, 60 fps battles with a lot less work and way smoother animation. :evil:

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #6 on: 2010-06-17 16:46:16 »
Instead of redoing all animations (which is a terrible idea, IMHO), just take the interpolation algorithm and make it output 3 more intermediate frames. There you go, 60 fps battles with a lot less work and way smoother animation. :evil:
Ah, the interpolation algorithm.  I have no idea what or where that is.

Aali

  • No life
  • *
  • Posts: 1161
  • Karma: 28
    • View Profile
Re: Running FF7 at 60fps
« Reply #7 on: 2010-06-17 16:57:12 »
Interpolation algorithm? It's right next to the full-3d field scenes.

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #8 on: 2010-06-17 18:29:45 »
I hate you both

Gemini

  • Insane poster
  • *
  • Posts: 262
  • Karma: 6
  • Not learner's Guru
    • View Profile
    • Devil Hackers
Re: Running FF7 at 60fps
« Reply #9 on: 2010-06-17 18:29:54 »
Good luck finding that.

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #10 on: 2010-06-18 07:43:28 »
So who here would like to check out Kimera's source code and try to incorporate the very same interpolation algorithm Gemini is talking about? 
It is possible to manually move all the bones to make the animation smooth, but time consuming doesn't even begin to describe it, and unfortunately my programming classes don't start until next semester.

ice_cold513

  • Insane poster
  • *
  • Posts: 493
  • Karma: 1
    • View Profile
Re: Running FF7 at 60fps
« Reply #11 on: 2010-06-18 09:54:17 »
I will ask Borde about it, next time i see him online if you guys like. He maybe to busy to do anything but he might tell you where or if it can be done

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3573
  • Karma: 16
  • GUI Master :P
    • View Profile
Re: Running FF7 at 60fps
« Reply #12 on: 2010-06-20 05:42:35 »
I will ask Borde about it, next time i see him online if you guys like. He maybe to busy to do anything but he might tell you where or if it can be done

Don't worry about it. I took care of it.

edit: Here is a video if anyone is interested of the battles running in 60fps. Fraps does drop the frames down a bit when recording but you get the idea. Interpolated animations were created with a modified version of kimera i made.

http://www.youtube.com/watch?v=D6ziBsBNSfI
« Last Edit: 2010-06-27 01:33:12 by sl1982 »

Covarr

  • Covarr-Let
  • Global moderator
  • No life
  • *
  • Posts: 3054
  • Karma: 35
  • I'm not your babysitter.
    • View Profile
Re: Running FF7 at 60fps
« Reply #13 on: 2010-06-27 21:12:54 »
Interpolated animations look nice, but the thing still looks really fast and on crack.

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #14 on: 2010-06-27 21:23:50 »
Interpolated animations look nice, but the thing still looks really fast and on crack.
We need to alter the texture animations and interpolate the camera animations as well.

Any luck on the 360 / 180 problem?

Quote from: Borde
As for the interpolation problem, rotations are allways so troublesome. Specially when using euler angles to represent them, just like FF7 does. I'm not completly sure if this would work, but what I had in mind for the interpolation was converting the rotations to quaternions, interpolate them (suposedly, interpolation is the strong point of that representation) and then convert them back to euler angles.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3573
  • Karma: 16
  • GUI Master :P
    • View Profile
Re: Running FF7 at 60fps
« Reply #15 on: 2010-06-27 21:32:55 »
Yeah, we are not able to adjust the camera or speed of the effect animations yet. And we cannot find the animation for braver to increase the frames.

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #16 on: 2010-06-27 21:49:22 »
Ah, I forgot a bit of it...   He also thinks that the missing animations are simply placeholders.  So no idea with braver :/

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3573
  • Karma: 16
  • GUI Master :P
    • View Profile
Re: Running FF7 at 60fps
« Reply #17 on: 2010-06-27 21:51:55 »
Hmm, thats no good.

hotdog963al

  • Crazy poster
  • *
  • Posts: 215
  • Karma: 1
  • Anti-Weeaboo
    • View Profile
    • Perl
Re: Running FF7 at 60fps
« Reply #18 on: 2010-07-02 11:42:49 »
edit: Here is a video if anyone is interested of the battles running in 60fps. Fraps does drop the frames down a bit when recording but you get the idea. Interpolated animations were created with a modified version of kimera i made.

http://www.youtube.com/watch?v=D6ziBsBNSfI
Holy crap, FF7 @ Smooth 60FPS would blow my mind. I think... this is the best PC hack I've seen so far!

obesebear

  • Administrator
  • No life
  • *
  • Posts: 2927
  • Karma: 7
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Running FF7 at 60fps
« Reply #19 on: 2010-07-02 15:36:16 »
Jeff, I don't know you'll have to experiment.

hotdog, 60fps isn't all fun and games.  We're just working on the battle and it's been quite a pain.  Hopefully we can get the bugs ironed out, figure out how to interpolate the camera animation frames, and hack into the texture animations.  Even then there are still some animations (braver) that we can't seem to increase the frames on.   And if we can't increase all animations to 60fps... well it doesn't really seem worth completing.

Hellbringer616

  • No life
  • *
  • Posts: 1829
  • Karma: 3
    • View Profile
Re: Running FF7 at 60fps
« Reply #20 on: 2010-07-02 18:31:03 »
That battle looked fantastic, Very fluid.

If even the just the battles could be made at 60FPS i'd be happy

Kudistos Megistos

  • Banned
  • No life
  • *
  • Posts: 3967
  • Karma: 2
    • View Profile
Re: Running FF7 at 60fps
« Reply #21 on: 2010-07-02 18:42:24 »
That battle looked fantastic, Very fluid.

If even the just the battles could be made at 60FPS i'd be happy

The movements do look pretty smooth.

I'd say that, as long as everything in battle can be increased to 60fps, the improvement it would make to the way the game looks would be almost as significant as the improvement we get from remodeling and texturing. That increased framerate really does make a big difference. Let's hope that the problems can be ironed out.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3573
  • Karma: 16
  • GUI Master :P
    • View Profile
Re: Running FF7 at 60fps
« Reply #22 on: 2010-07-02 19:12:18 »
I am sure it can be done. 1st thing is to talk to NFITC1 and see if i cant figure out how the camera works in the game. If we can get this sorted out we are 75% there.

hotdog963al

  • Crazy poster
  • *
  • Posts: 215
  • Karma: 1
  • Anti-Weeaboo
    • View Profile
    • Perl
Re: Running FF7 at 60fps
« Reply #23 on: 2010-07-05 09:58:51 »
Jeff, I don't know you'll have to experiment.

hotdog, 60fps isn't all fun and games.  We're just working on the battle and it's been quite a pain.  Hopefully we can get the bugs ironed out, figure out how to interpolate the camera animation frames, and hack into the texture animations.  Even then there are still some animations (braver) that we can't seem to increase the frames on.   And if we can't increase all animations to 60fps... well it doesn't really seem worth completing.
Still, it's a very worthwhile mod to work on I think!

Timber

  • Insane poster
  • *
  • Posts: 365
  • Karma: 0
    • View Profile
Re: Running FF7 at 60fps
« Reply #24 on: 2010-07-06 13:44:54 »
I agree, this would be an amazing improvement.