Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Time to put my hypothesis to test. Who wants to check if this works?
#include <stdio.h>                                                  
#include <stdlib.h>                                                 
static FILE*fp;                                                     
static void Put(unsigned p,char*s,unsigned n)
{
    fseek(fp,p,SEEK_SET); fwrite(s,n,1,fp); 
}    
int main(void)
{
    fp = fopen("FAM60.EXE", "rb+");
    if(!fp) { perror("FAM60.EXE"); return -1; }
    
    Put(0x196FF, "\x88\x13\0\0", 4); /* mov a,5000 */
    Put(0x28042, "\x88\x13\0\0", 4);                 
    Put(0x28099, "\x88\x13\0\0", 4);                 
                                                     
    Put(0x19705, "\x51\x8B\x49\x14", 4); /* push c,mov c */
    Put(0x1970E, "\x59\xEB\x0E",     3); /* pop c,jmp */   
                                                        
    Put(0x28048, "\x8B\x0D\xD4\xDC\x46\x00", 6); /* mov c,x */
    Put(0x280A5, "\x8B\x0D\xD4\xDC\x46\x00", 6);              
                                                              
    Put(0x19709, "\x8D\x0C\x49\xF7\xF9", 5); /* lea,idiv */   
    Put(0x2804E, "\x8D\x0C\x49\xF7\xF9", 5);
    Put(0x280AB, "\x8D\x0C\x49\xF7\xF9", 5);            
    
    Put(0x28053, "\xEB\x10", 2); /* jmp */
    Put(0x280B0, "\x90",     1); /* nop */
    Put(0x280B9, "\xBB\1\0\0\0\xEB\x0F", 7); /* mov b, jmp */
    
    Put(0x28087, "\1", 1);
    Put(0x28097, "\1", 1);
    Put(0x28113, "\1", 1);

    puts("done");
    fclose(fp);               
}
I can't test it very carefully right now, but it seems to work. I'm interested whether it fixes the timing problem. As a zip file: https://files.tasvideos.org/bisqwit/fam60.zip
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
People should uncheck the topmost draw setting in display settings.Otherwise games will lag.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Works fine on my 230 MHz laptop. :)
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
I tested it now at my home computer - Athlon XP 2000 with Wine. No unstability problems. I tested Rockman, Double Dragon 2 and Super Mario Bros. All were fluent, no speed correction messages. However, it seems like the timing is still incorrect. Michael Fried's SMB1 run lasted about 4:55 on this new 60fps version. <Player1> lets send that 4:55 to Twin Galaxies and they get mad :D Nevertheless, I like this 60 fps feature a lot and will be using it for all my Famtasia recordings from this on. It makes even extremely low speeds like 5% to 20% very usable and allows frame-level refinements. I don't even need autofire anymore :)
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Bisqwit wrote:
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...
The formula is timer_interval = (1766 * frame_skip) / execution_speed I chose 1766 so that the emulator would set the timer every 17msec, instead of 16msec, based on the erroneus assumption that the minimum timer interval useable was 16msec. I've since found out that there's no restriction on the minimum timer interval in windows. Either constant used in the equation (1666 or 1766) gives roughly the same timing error at 60fps; 1766 runs slightly too slow and 1666 runs slightly too fast. The timer actually needs to be firing every 16.6667 msecs. I'm working on a new patch that reworks the timer code, to take into account the fractional part of the timer interval. The new patch should be much more accurate at 60fps. Also, I *think* the CPU spike is related to the messages that show up on the bottom of the screen, "movie stopped", etc. But I need to verify this.
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
feitclub wrote:
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.
I've never seen this behavior, so I'm not sure I can help. :( Any more info you could provide might be helpful. What happens when you run in windowed mode? Are you running win98 or xp?
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
We're waiting this normal speed patch with impatience :)
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
Windowed mode works fine for me. I'm not positive, but the 60fps version looks nicer than the regular version, so I'm pretty sure something is happening. I'm using Windows Millenium Edition
Do Not Talk About Feitclub http://www.feitclub.com
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
I've just completed the new 60fps patch. The good news: . fixes the playback rate at 60fps. I tested this against sleepzteam's zelda run and linnom's batman run, timing them at 26:55 and 10:17 respectively, which I think is correct. . fixes the cpu lock-up (yay!) . fixes the screen size miscalculation for 3x magnification Now for the bad news: . causes audbible "popping" in the audio Unfortunately, the sound "popping" glitch might be difficult to fix even if I did have the source code, so I might not manage to fix this for a while. Now for the patch. You should apply this to an unmodified FAMTASIA.EXE.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	struct {
		unsigned long offset;
		int length;
		char* data;
	} patch[]= {
		/* 60 fps patch */
		{ 0x00200,    1, "\x40" },
		{ 0x27c59,    5, "\xe9\x63\x03\x00\x00" },
		{ 0x1975a,    1, "\x00" },
		{ 0x196ff,    8, "\x82\x06\x00\x00\xf7\xea\xeb\x15" },
		{ 0x27fbc, 0xd0, "\
\xe9\xcb\x01\x00\x00\xa0\x84\xe5\x46\x00\x84\xc0\x74\x08\x31\xdb\
\x89\x1d\x78\x7a\x46\x00\x8a\x25\xd0\x89\x44\x00\x84\xe4\x0f\x85\
\xd5\x01\x00\x00\x84\xc0\x0f\x84\x7e\xfc\xff\xff\x52\xa1\xd4\xdc\
\x46\x00\x3b\x05\x38\x3b\x47\x00\x74\x14\x31\xd2\x89\x15\x34\x3b\
\x47\x00\xa3\x38\x3b\x47\x00\xff\xd6\xa3\x3c\x3b\x47\x00\x8b\x1d\
\xd4\xdc\x46\x00\xb8\x83\x06\x00\x00\xf7\x2d\xd8\xdc\x46\x00\xf7\
\xf3\x85\xd2\x74\x13\x03\x15\x34\x3b\x47\x00\x39\xda\x7c\x03\x40\
\x29\xda\x89\x15\x34\x3b\x47\x00\x03\x05\x3c\x3b\x47\x00\xa3\x3c\
\x3b\x47\x00\x50\xff\xd6\x89\xc2\x58\x29\xd0\x7f\x05\xb8\x01\x00\
\x00\x00\xa3\x98\xda\x46\x00\xa3\x14\x7c\x46\x00\x6a\x00\x6a\x00\
\x68\x20\x88\x42\x00\x6a\x00\x50\xff\x15\xbc\x12\x44\x00\xa3\x78\
\x7a\x46\x00\xa1\x98\xda\x46\x00\xf7\x2d\x50\x23\x47\x00\xbb\xe8\
\x03\x00\x00\xf7\xf3\xa3\xb8\x0e\x47\x00\x5a\xe9\xda\xfb\xff\xff" },
		{ 0x30010,    1, "\xc3" },

		/* 240 scanlines patch */
		{ 0x1ff0d, 1, "\xf0" }, { 0x1f352, 1, "\xf0" }, { 0x1f2e6, 1, "\xf0" }, { 0x1f389, 1, "\xef" },
		{ 0x1f2f1, 1, "\xf0" }, { 0x1f34e, 1, "\x3d" }, { 0x1f2e2, 1, "\x3d" }, { 0x1ff31, 1, "\xe0" },
		{ 0x46920, 1, "\x10" }, { 0x1f5cd, 1, "\xf0" }, { 0x1f5d8, 1, "\x3d" }, { 0x1f617, 1, "\xf0" },
		{ 0x1f60c, 1, "\xf0" }, { 0x1f608, 1, "\x3d" }, { 0x1f1ad, 1, "\x3d" }, { 0x1f1b2, 1, "\x3c" },
		{ 0x1f6e0, 1, "\xf0" }, { 0x1f6dc, 1, "\x3d" }, { 0x1f71d, 1, "\xf0" }, { 0x1f460, 1, "\xf0" },
		{ 0x1f478, 1, "\xf0" }, { 0x2705d, 1, "\xd0" },

		{ 0, 0, 0 }
	};

    FILE *fp = fopen("FAMTASIA.EXE", "rb+");
    if(!fp) { perror("FAMTASIA.EXE"); return -1; }

	int i;
	for(i=0; patch[i].offset; ++i)
	{
		fseek(fp, patch[i].offset, SEEK_SET);
		fwrite(patch[i].data, 1, patch[i].length, fp);
	}

	return 0;
}
Edit: I fogrot to mention that this patch completely removes the auto-frame skip functionality from Famtasia. If you want 60fps, you'll have to manually set frame skip to 1 by hand-editing your famtasia.ini file. Look for the line "Occupation=3" and set it to 1. If people find this a nuisance I can easily hard-code the frame skip to be 1.
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
Wow good work Blip maybe you're next project should be that there will be no more desync in the movies. That will be a great help.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Phil wrote:
Wow good work Blip maybe you're next project should be that there will be no more desync in the movies. That will be a great help.
Soon Blip will be coding his own NES emulator ;) Thanks Blip, I'll test this one.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Sorry to say but it doesn't work properly. After a while, it started going like an inchworm. Normal speed, lag, normal speed, lag, normal speed, lag...
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Bisqwit wrote:
Sorry to say but it doesn't work properly. After a while, it started going like an inchworm. Normal speed, lag, normal speed, lag, normal speed, lag...
Maybe I should check your version against mine. Is there a way I can get your copy?
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
blip wrote:
Is there a way I can get your copy?
https://files.tasvideos.org/bisqwit/blip.zip Includes the exe and ini files.
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Bisqwit wrote:
blip wrote:
Is there a way I can get your copy?
https://files.tasvideos.org/bisqwit/blip.zip Includes the exe and ini files.
They're the same of course. I was afraid of that. It's a shot in the dark, but you could try applying these changes: $272e2 : e9 8e 04 00 00 Otherwise, I don't know what to say. :(
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
blip wrote:
I've just completed the new 60fps patch. Now for the bad news: . causes audbible "popping" in the audio
Personally, I'd rather watch "imperfect" Famtasia than trade a few extra frames for faulty audio. But good luck with future hacks.
Do Not Talk About Feitclub http://www.feitclub.com
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
It's not "few extra frames". It's 66% of the motion. Motion looks much smoother with the 60 Hz patch. Difference like between diashow and cinefilm :) (And also, making the movies is now a *lot* easier and more accurate because it displays every frame.)
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Well, the choice seems to be between inaccurate playback but accruate sound, or accurate playback and inaccurate sound (presuming famtasia would be nice enough to behave the same on everybody's machine :P ). There are good reasons why each version acts like it does. Anyhow, if you want to remove the CPU spike from the original 60fps patch, this sinlge byte fix should hopefully do the trick: $30010 : c3
Former player
Joined: 3/13/2004
Posts: 1118
Location: Kansai, JAPAN
Hey, I'm down with 60fps, but I'm not going to sacrifice audio to get it. I've got the earlier hack, and I enjoy it.
Do Not Talk About Feitclub http://www.feitclub.com
Editor, Reviewer, Experienced player (979)
Joined: 4/17/2004
Posts: 3109
Location: Sweden
Well, the movies could be coded audio and video separately. Audio 60 fps and sound from the 20 fps version. More work, though... Anyway, I think this is incredible. I haven't seen anyone hacking executables byte by byte, ever. Hat's off for blip.
Active player (276)
Joined: 4/20/2004
Posts: 219
Location: Japan,Tokyo
Thanks blip You have very good hack skills I hope you hack it into running non-999%-Limit tips Windows Occupation slider enabled $5268f:50 when you change a slider ,a refresh-rate also changes simultaneously Therefore, it uses to set Occupation to 1.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
I have no popping noise in this version, but the audio has still problems. I recorded the new Mega Man 4 movie with this version for testing, and the audio goes too fast. It's perfectly synced in the beginning, but at 10 minutes it's already a second or two ahead the video. None of the previous patches had this problem. Wonder if I can just finetune the magic multiplier to get the right rate... At 1766 it was too slow, and at 5000/3 it was too fast. Maybe if I change it to 5200/3 or something...
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
Well, I finally managed to fix the sound glitch in the new 60 fps patch. Bisqwit, please test this new version on your machine. I think I fixed the problem you were experiencing.
		/* 60 fps patch B (fixed) */
		{ 0x00200,    1, "\x44" },
		{ 0x27c59,    5, "\xe9\x63\x03\x00\x00" },
		{ 0x1975a,    1, "\x00" },
		{ 0x196ff,    8, "\x82\x06\x00\x00\xf7\xea\xeb\x15" },
		{ 0x27d44,    5, "\xeb\x03" },
		{ 0x27fbc, 0xf5, "\
\xe9\xcb\x01\x00\x00\xa0\x84\xe5\x46\x00\x84\xc0\x74\x08\x31\xdb\
\x89\x1d\x78\x7a\x46\x00\x8a\x25\xd0\x89\x44\x00\x84\xe4\x0f\x85\
\xd5\x01\x00\x00\x84\xc0\x0f\x84\x7e\xfc\xff\xff\x52\xa1\xd4\xdc\
\x46\x00\x3b\x05\x38\x3b\x47\x00\x74\x1a\x31\xd2\x89\x15\x34\x3b\
\x47\x00\x89\x15\x40\x3b\x47\x00\xa3\x38\x3b\x47\x00\xff\xd6\xa3\
\x3c\x3b\x47\x00\x8b\x1d\xd4\xdc\x46\x00\xb8\x83\x06\x00\x00\xf7\
\x2d\xd8\xdc\x46\x00\xf7\xf3\x85\xd2\x74\x13\x03\x15\x34\x3b\x47\
\x00\x39\xda\x7c\x03\x40\x29\xda\x89\x15\x34\x3b\x47\x00\xa3\x98\
\xda\x46\x00\xa3\x14\x7c\x46\x00\x50\x03\x05\x3c\x3b\x47\x00\xa3\
\x3c\x3b\x47\x00\x50\xff\xd6\x89\xc2\x58\x29\xd0\x7f\x05\xb8\x01\
\x00\x00\x00\x6a\x00\x6a\x00\x68\x20\x88\x42\x00\x6a\x00\x50\xff\
\x15\xbc\x12\x44\x00\xa3\x78\x7a\x46\x00\x58\xf7\x2d\x50\x23\x47\
\x00\xbb\xd0\x07\x00\x00\xf7\xf3\x85\xd2\x74\x13\x03\x15\x40\x3b\
\x47\x00\x39\xda\x7c\x03\x40\x29\xda\x89\x15\x40\x3b\x47\x00\x01\
\xc0\xa3\xb8\x0e\x47\x00\x66\xc7\x05\x40\x23\x47\x00\x00\x00\x5a\
\xe9\xb5\xfb\xff\xff" },
finalfighter wrote:
tips Windows Occupation slider enabled $5268f:50
Thanks for the tip, finalfighter, but it didnt work for me. :( The slider remained broken. I noticed that you can change the frameskip from the "Speed Configuration" dialog box, just by typing a number next to the "Refresh" option, so you don't have to hand-edit the .ini file after all. Still, I don't really like including "instructions" with my releases; I'd like it to run at 60fps by default. What do others think of this?
Joined: 4/15/2004
Posts: 81
Location: Swe- Krstd
holy shit blip.. are you some kind of serious hacker o_O
// ZtanZ
Joined: 4/11/2004
Posts: 155
Location: Fairfax, VA, USA
ZtanZ wrote:
holy shit blip.. are you some kind of serious hacker o_O
Let's wait and see if it works first. ^_^