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

Vgr

  • No life
  • *
  • Posts: 1536
  • Making noise since 2011
    • View Profile
Re: Battles playing at 60fps
« Reply #150 on: 2011-12-03 20:32:03 »
As far as I can tell, S files aren't G-Zipped. I can tell you already that limit break animations aren't stored in the **DA files of the 3D models. Or maybe it isn't decrypted yet, but if it's really in the **DA file, then there's still somwthing preventing use from accessing them.

Aali

  • No life
  • *
  • Posts: 1120
    • View Profile
Re: Battles playing at 60fps
« Reply #151 on: 2011-12-03 21:08:32 »
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

The Western Guy ...

  • Fast newbie
  • *
  • Posts: 7
    • View Profile
Re: Battles playing at 60fps
« Reply #152 on: 2011-12-11 02:42:34 »
I apologize for bad english, don't be too hard to me.

Thing is, I am searching forums up and down for graphical improvement mods for FF VII. I got the english version of the game (even thought I am german ;), so version compatibility is no problem) and installed loads of patches and mods that already enhanced the vision (Aali Custom Driver included). While looking for decent character battle models that I could insert into the game (I am not unfamiliar with computers, just in case you ask ;)), I found this thread and read it, since the title implied it was/is possible  to change the FPS-rate in battle screen - a point relevant to my interests.

What I learned so far is that it's possible to change the FPS-rate by modifying some offset values within the acutal executable file. Just for a check I hex-dumped the file and went to the OP's offsets. The look fine, but unfortunately it was just shown how to set the FPS-rate to 60, whereas that is just to much for me. Having a rate about 15, I am quite content with having 30 frames per second, but neither of you have made any notice about the right values.

So I started calculations on my own: implying that changing i.e. a value from 2E to 5E means that this could either be a factor or a simple value. E is 14, to make it round with 15 I thought 1 Frame is additionally added to the maximal limit of frames per second. The change from 2E to 5E is 0x30 or (3*16)^1+(0*16)^0=48, and adding those to the given 15 FPS means 63 FPS at all, at least for one value - correct me if I got this wrong.

So I figured out that all I've got to do is to sum up until I reached the wanted rate (might be 32 as well) and be good with it, and using the upper calculation I guess is +11, summing up to a total of 0x2E*0x10=0x3E to increase the FPS-rate, right?

Also I'd like to know the values so that the camara and the models are neither to fast nor to slow. I don't need a special installer, just the values and edit them manualls.

Covarrfetch'd

  • Covarr-Let
  • Global moderator
  • No life
  • *
  • Posts: 2681
  • I'm the best.
    • View Profile
Re: Battles playing at 60fps
« Reply #153 on: 2011-12-11 02:57:20 »
Also I'd like to know the values so that the camara and the models are neither to fast nor to slow. I don't need a special installer, just the values and edit them manualls.
Fixing the camera/animations isn't simply a matter of changing a few values. They run at one frame per frame. The only way to slow them down to work with a higher framerate is to actually CREATE the new frames of animation, or the new camera positions.

The Western Guy ...

  • Fast newbie
  • *
  • Posts: 7
    • View Profile
Re: Battles playing at 60fps
« Reply #154 on: 2011-12-11 10:12:29 »
Sorry if I got this wrong, but I've seen this video (http://www.youtube.com/watch?v=rx3DHs4iMzA) in which the camera took a way longer than usual to display the scene, so I guessed, with combining the changes, it's possible to generally set the FPS in battle mode to a decent value without screwing up the animations, the camera movements or alike.

I understand that there have been some problems for nearly one year with the scenes - i.e. that the camera itself is too fast. Barret does his big shot, the camera changes the angle to detailed mode for him, but it's too fast. It's already pointed at the opponent when Barret is aiming for the shot, and in the end you see him performing the shot from far. Obviously it's because the camera (with 60 frames instead of 15) thinks that Barret has displayed all detail-frames in his animation and is now going to perform the actual shot. But the camera calculates with wrong values - let's say there are 3 seconds with 15 frames per second for the animation, and the camera displays them with 60 frames, then it will take all those frames, squeeze them in 0.75 seconds and shows them. As seen in the video, it's possible to tell the camera NOT to squeeze those frames, so the animations were run 'normally' while the cam was too slow. I don't know if increasing the FPS but decreasing the camera movements and animations at the same factor would result in a normally run battle with just more FPS then before, but it's worth a shot, isn't it? (Note: I take it the battle in the video was NOT made by increasing the actual animation frames - sorry if this is the magic behind ;)).
« Last Edit: 2011-12-11 13:58:27 by The Western Guy ... »

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #155 on: 2011-12-11 14:03:13 »
What NFITC1 did was increase the amount of frames in each animation so it will look proper at 60fps. While this does work for most things so far there are some aspects of the game that we have not been able to increase as of yet. You also need to increase the amount of frames that each models animations have or else they look like they are 4x faster. NFITC1, Obesebear, and I have been working on this. Have patience. It will be ready when it is.

The Western Guy ...

  • Fast newbie
  • *
  • Posts: 7
    • View Profile
Re: Battles playing at 60fps
« Reply #156 on: 2011-12-11 14:38:13 »
Hey, I just wanted to know what's the status of the project and how to change the FPS limit, I didn't push you for anything. ;) Just keep doing it - I can hardly force you to something I am just to lazy too although I might have the needed skills. Take your time, for Eidos and Square didn't for the PC version. ;)

But there still is an open question: was I right with my calculation? I wouldn't test it 'cause I use Linux when browsing the internet, and I simply don't wanna restart with the probability of screwing up my game.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #157 on: 2011-12-11 14:47:19 »
Honestly I could not tell you as I was told those values by Aali. I am not very good with hexadecimal math.

The Western Guy ...

  • Fast newbie
  • *
  • Posts: 7
    • View Profile
Re: Battles playing at 60fps
« Reply #158 on: 2011-12-11 14:54:22 »
A shame ... well, I guess then I gonna have to test it by myself, like some kind of contribution to the project, OK?

Alright, guys, here is what I have figured out so far.

The first value at 0x3BF506 is for the direct battle speed. It controls how much frames of the acutal battle are displayed in one second. Untill further instructions, this value has to be set very carefully, as an 'overdose' will result in "battle on crack". I set this value from 2E to 31, and it's an HUGE improvement, considering that it's just testing.

The second and third value are unknown to me. Didn't matter what I changed, it had no sightable effect on the game. I then installed IDA to see if I could interpret the byte sequences associated with this values (if you wanna try it on your own, the postion of the whole block is loaded in address 0x007C0B00. There are three 8 byte values, persumingly doubles - the first value is 1.5, the second 1.12 and the third one 1.5 again, but don't ask me how the games interprets this values as frame limiters), but my machine code skills are not good enough for this one. Perharbs it's the minimal frames border?

Anyway, it's still possible to improve the battle screen. As I wrote, if you set the first value to something like 31 or 33, you get 20 frames instead of 15 without the game running too weird.

I hope you guys can use it ...
« Last Edit: 2011-12-11 21:13:17 by The Western Guy ... »

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #159 on: 2011-12-13 14:28:48 »
Hmm. I wonder if the unknown values have to do with menu speed. I will have to take a look at this when i have time.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #160 on: 2012-02-23 04:12:03 »
Hmm. I wonder if the unknown values have to do with menu speed. I will have to take a look at this when i have time.
Surely you've had time by now :P


I still really want to get into this.  I'm getting married next week, and following the honeymoon is Spring Break, so hopefully that will bring about some free time.  If not, this will be my last school semester for a while, so either way the models' animations should be finished before the end of the year.  And who knows, with help from intelligent/ingenuitive people like SL, Western Guy, DLPB, Aali, and NFITC1... maybe this whole thing could see the light of day before Christmas.

LeonhartGR

  • No life
  • *
  • Posts: 1072
  • ~Whatever...~
    • View Profile
Re: Battles playing at 60fps
« Reply #161 on: 2012-02-23 12:44:55 »
I'd love to play in 60 fps :P

NFITC1

  • No life
  • *
  • Posts: 1910
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battles playing at 60fps
« Reply #162 on: 2012-02-23 14:12:20 »
Ah.

I guess the next question is there any ways you can increase the wait times for texture effects?

This is the next thing I'd like to tackle. I'd imagine it'd be very similar to the camera delays that I created.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #163 on: 2012-02-26 14:15:57 »
I have about 60 battle models converted right now. I just wish i still had the source code for my modified kimera. Would have made everything so much easier.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #164 on: 2012-04-01 16:25:50 »
Shameless double post!

No folks, this project is not dead. I am currently in the process of rewriting the modifications to kimera and making it a bit easier in the process to convert the models. I hope to keep everyone more informed on progress.

xLostWingx

  • Freak
  • *
  • Posts: 691
  • xLostWingX M.Ed., Ed.S., NCSP
    • View Profile
    • FFVII Lost Wing Mod/Hacks
Re: Battles playing at 60fps
« Reply #165 on: 2012-04-01 21:25:58 »
Good luck.  This project is a big deal.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #166 on: 2012-04-01 21:48:38 »
Shameless double post!

No folks, this project is not dead. I am currently in the process of rewriting the modifications to kimera and making it a bit easier in the process to convert the models. I hope to keep everyone more informed on progress.
C'mon, everyone knows it's april fools day.

Covarrfetch'd

  • Covarr-Let
  • Global moderator
  • No life
  • *
  • Posts: 2681
  • I'm the best.
    • View Profile
Re: Battles playing at 60fps
« Reply #167 on: 2012-04-01 22:09:46 »
C'mon, everyone knows it's april fools day.
Good thing he's been talking about it in the IRC for like 3 days, then.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #168 on: 2012-04-02 15:33:55 »
Ha ha. No it was not an april fools joke. I have been working on the kimera source. I can convert the euler angles to quaternions but I am unable to properly convert them back to euler. If I am not able to get this working then I will have to use the old shortest angle method. If i have to do this I will most likely put in some sort of detection for the gimbal lock error so the user can manually fix these problem areas before doing the second interpolation. Or I may be able to program something where it looks at the next frame after the keyframe to try and detect if the rotation was correctly done.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #169 on: 2012-04-03 21:30:11 »
Double post ftw!

Timu has put a bit of time into this and has written up an algorithm that also takes a look at the preceding and post keyframes to try and detect the proper direction. I have it into the program and it seems to work nicely, just need to clean up a few niggling bugs, such as at the first and last frames of the animation. Then testing to follow. The making it more automated.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #170 on: 2012-04-04 00:55:24 »
awww yeah.  no need to convert to quaternions then?  Nice

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #171 on: 2012-04-04 13:51:55 »
Well quaternions would be the ultimate solution. It can interpolate directly between two points without any of the problems associated with euler angles. But it is not much use if i cannot get them to convert correctly. I have PM'd borde to see if he can give me a hand, but until then I will work on the other solution.

sl1982

  • Administrator
  • No life
  • *
  • Posts: 3537
  • GUI Master :P
    • View Profile
Re: Battles playing at 60fps
« Reply #172 on: 2012-04-05 20:00:45 »
Minor / Major update:

I am sure only Obesebear will be excited by this but i can now convert to and from euler and quaternion with no loss of information.

Next step: slerp interpolation

DragonNinja

  • Freak
  • *
  • Posts: 735
  • I never asked for this!
    • View Profile
Re: Battles playing at 60fps
« Reply #173 on: 2012-04-05 21:15:35 »
Get you and your fancy words.

Obesebear

  • Global moderator
  • No life
  • *
  • Posts: 2911
  • King of Model Importing
    • View Profile
    • Modders Haven
Re: Battles playing at 60fps
« Reply #174 on: 2012-04-06 04:21:42 »
Minor / Major update:

I am sure only Obesebear will be excited by this but i can now convert to and from euler and quaternion with no loss of information.

Next step: slerp interpolation
I consider that a definite major update.  This shall be a very happy easter indeed!