Post subject: Famtasia fix - 60 fps
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
This weeked I played around with Famtasia in the debugger a bit, and managed to hack it into running at 60fps. The good news is that the current batch of .fmvs seems to play back just fine at 60. The bad news is that it causes the cpu to max out when it first starts but it eventually sorts itself out. Also, this fix is Windows-only at the moment. I would be much obliged if someone could provide hosting for the patched file. I'm sure there are others who would like to try using it. [EDIT by Bisqwit: not an announcement anymore]
Post subject: Re: Famtasia fix - 60 fps
Joined: 3/22/2004
Posts: 95
blip wrote:
This weeked I played around with Famtasia in the debugger a bit, and managed to hack it into running at 60fps.
How much data needs changed? If it's not much, can you just make a list of hex values you changed, and which version you used?
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Sure. Doing it this way might be a tad error-prone though. First, make a copy of your current FAMTASIA.EXE (version 5.1, size 393,216). Then open it up in your favorite hex editor. (a free one can be found here) Set bytes at offset $196ff to e6 06 00 00 f7 ea eb 15 Set bytes at offset $28042 to e6 06 00 00 f7 ea eb 15 Set the byte at offset $28087 to 01 Set bytes at offset $28097 to 01 b8 e6 06 00 00 Set bytes at offset $280ac to eb 03 90 Set bytes at offset $280b9 to eb 0e 90 Set the byte at offset $28113 to 01 Good luck!
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
Well thx for the tips It works well for me.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
I didn't verify these instructions yet, but in case you don't have a hex editor, here's a program you can compile that will do the job for you.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
    FILE *fp = fopen("FAMTASIA.EXE", "rb+");
    if(!fp) { perror("FAMTASIA.EXE"); return -1; }
    fseek(fp, 0x196FF,SEEK_SET); fwrite("\xe6\6\0\0\xf7\xea\xeb\x15", 8,1, fp);
    fseek(fp, 0x28042,SEEK_SET); fwrite("\xe6\6\0\0\xf7\xea\xeb\x15", 8,1, fp);
    fseek(fp, 0x28087,SEEK_SET); fwrite("\1", 1, 1, fp);
    fseek(fp, 0x28097,SEEK_SET); fwrite("\1\xb8\xe6\6\0\0", 6,1, fp);
    fseek(fp, 0x280AC,SEEK_SET); fwrite("\xeb\3\x90", 3,1,fp);
    fseek(fp, 0x280B9,SEEK_SET); fwrite("\xeb\xe\x90", 3,1,fp);
    fseek(fp, 0x28113,SEEK_SET); fwrite("\1", 1, 1, fp);
    puts("done");
    fclose(fp);
    return 0;
}
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Thank you very much blip - this really seems to work! I upgraded this topic to an announcement.
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Bisqwit wrote:
Thank you very much blip - this really seems to work!
My pleasure. :) I really wish I could fix the CPU spike at the beginning... Is anyone else having this problem?
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
blip wrote:
I really wish I could fix the CPU spike at the beginning... Is anyone else having this problem?
Yes, it happens, but it happens always anyway on the regular version too. It's because famtasia is estimating the machine speed, or something. Another problem I noticed is that the sound seems to be significantly lagged when using 10% speed in the patched version. But maybe it's tolerable anyway. Can you think of any side effects caused by your code?
Former player
Joined: 3/9/2004
Posts: 484
Location: ­­
http://babyamy.tripod.com/grinto/famtasia.exe I've uploaded the modified EXE file for anyone who can't work the hex editor. Please copy the link and paste it into the address bar to get it to download.
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Bisqwit wrote:
I noticed is that the sound seems to be significantly lagged when using 10% speed in the patched version.
This is very likely a rounding error. It might be fixable, if it's enough of a problem.
Bisqwit wrote:
Can you think of any side effects caused by your code?
I modified the computations used by Famtasia to calculate timing. The functionality between versions *should* be exactly the same. (I hope!)
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Bladegash wrote:
I've uploaded the modified EXE file for anyone who can't work the hex editor.
Thanks for doing this. But there's a problem :(
Comparing FAMTASIA_patched.EXE and famtasia_bladegash.exe...
Compare error at OFFSET 28087
file1 = 1
file2 = 0
Compare error at OFFSET 28112
file1 = FA
file2 = 1
Compare error at OFFSET 28113
file1 = 1
file2 = 3
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Looks like someone didn't patch properly... here
Joined: 3/22/2004
Posts: 95
Although I haven't tested it, thus far it looks sound. Thanks blip; what a nice hack.. :)
Former player
Joined: 3/19/2004
Posts: 710
Location: USA
So does it matter which one we use to record? Are movies made at 60 fps playable in the regular famtasia?
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Bob Whoops wrote:
So does it matter which one we use to record? Are movies made at 60 fps playable in the regular famtasia?
All of them work in all of them.
Former player
Joined: 3/9/2004
Posts: 484
Location: ­­
Oops, the link above now contains the properly fixed EXE. I guess I really should have quadruple checked!
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Next task: Increase the scanline count from 224 to the full 240. Definitely a lot harder to do. :-( [Edit: Task completed - no need to reply this message]
Joined: 3/22/2004
Posts: 95
It's been discovered that the following AVIs are *significantly* slower than their FMV counterparts: arkanoid-timeattack-warpless-genisto solstice-timeattackv8-exim supermariobros1-timeattack-ryosuke zelda-timeattack-sleepzteam You can test this for yourself by downloading an FMV and an AVI, and then running the two simultaneously. You'll find that the above AVIs will quickly fall out of synch with the FMV. Furthermore, PhilC re-encoded supermariobros2-timeattack-genisto with the 60fps hack, and noticed that there was a slow-down of approximately 10 seconds. Given that each of these movies was made after the 60fps patch became available, I suspect that perhaps displaying the additional frames *and* recording is what may be causing the slowdown. Thus, for AVI recording, it may be better to return to the unhacked Famtasia (or experiment with the 240 line hack, but without the 60fps hack). :( (I should note that Bladegash also suggested turning on frameskip as a means of countering the slowdown)
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
It seems so. Damn. I'll try setting frameskip=2 (no auto) when I resample the movies. If the Zelda video still goes wrong, I'll record it with the regular version.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
I like this version a lot. I haven't even had any desync problems yet with Rockman1. Used to have lots of them with the standard version.
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
In anyone else having problems running 60fps in Fullscreen? I am.
Do Not Talk About Feitclub http://www.feitclub.com
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
Bisqwit wrote:
I like this version a lot. I haven't even had any desync problems yet with Rockman1. Used to have lots of them with the standard version.
Maybe for some games but for Battletoads in 2 player that's not the case it seems.
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
feitclub wrote:
In anyone else having problems running 60fps in Fullscreen? I am.
Can you give more info on what's going wrong? Is it freezing up? Is it not running? Is it running but not running at 60fps?
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
blip wrote:
feitclub wrote:
In anyone else having problems running 60fps in Fullscreen? I am.
Can you give more info on what's going wrong? Is it freezing up? Is it not running? Is it running but not running at 60fps?
When I switch to Fullscreen, the picture disappears. All I get is a black screen and my mouse pointer. If I press Esc, I can see (part of) the menu bar. The sound continues, so i know the emulator is still emulating. But I can't see anything. Fullscreen works in regular Famtasia on my computer, for the record. And I still can't get 240 to work properly at any size.
Do Not Talk About Feitclub http://www.feitclub.com
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Blip, I'm little in understanding, but to me it seems like in this patch you replaced this formula: (a/3) * 5000 / b with this: (a * 1766) / b Why did you use 1766 (0x6E6) anyway? 1666 (0x682) is nearer... Could it have been better to replace it with: a*5000 / 3 / b ? In assembly, it would be changing this
  mov edx, [ecx + 0x18]
  mov eax, 0x55555556
  imul edx
  mov eax, edx
  shr eax, 0x1f
  add edx, eax 
  lea eax, [edx + edx*4]
  lea eax, [eax + eax*4]
  lea eax, [eax + eax*4]
  lea eax, [eax + eax*4]
  shl eax, 3
  cdq
  idiv dword [ecx + 0x14]
to this
  mov edx, [ecx + 0x18]   
  mov eax, 5000
  imul edx
  push ecx
   mov ecx, 3
   idiv ecx  
  pop ecx    
  cdq
  idiv dword [ecx + 0x14]
Am I mistaken? Or even better, a*5000 / (b*3) which would be:
  mov edx, [ecx + 0x18]                           
  mov eax, 5000
  imul edx
  push ecx
   mov ecx, [ecx + 0x14]
   lea ecx, [ecx + ecx*2]
   idiv ecx
  pop ecx
(assuming [ecx + 0x14] is never bigger than 0x55555555.)