From a94c996dd7eb7f218c7f43f6597a8a6d2da0bb26 Mon Sep 17 00:00:00 2001 From: zeromus <zeromus@users.sf.net> Date: Tue, 27 May 2008 00:51:31 +0000 Subject: [PATCH] fix for 'jerky' rendering in final fantasy by changing emu to properly use startscanline and endscanline. removed author stuff from record and replay dialogs --- src/driver.h | 2 +- src/drivers/win/main.cpp | 13 +++++-------- src/drivers/win/main.h | 17 +++++----------- src/drivers/win/replay.cpp | 27 ++----------------------- src/drivers/win/res.rc | Bin 153062 -> 152780 bytes src/drivers/win/video.cpp | 39 +++++++++++++++++++------------------ src/drivers/win/window.cpp | 18 ++++++++--------- src/drivers/win/window.h | 1 - src/fceu.h | 9 +++++++-- src/input.cpp | 2 +- src/movie.cpp | 2 +- 11 files changed, 50 insertions(+), 80 deletions(-) diff --git a/src/driver.h b/src/driver.h index 0535b3ad..fa7a3bef 100644 --- a/src/driver.h +++ b/src/driver.h @@ -207,7 +207,7 @@ typedef struct std::string name_of_rom_used; } MOVIE_INFO; -void FCEUI_SaveMovie(char *fname, uint8 flags, const char* metadata); +void FCEUI_SaveMovie(char *fname, uint8 flags); void FCEUI_LoadMovie(char *fname, bool read_only, int _stopframe); void FCEUI_StopMovie(void); int FCEUI_IsMovieActive(void); diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index 9351ab54..9a81efb9 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -127,7 +127,6 @@ HRESULT ddrval; static char TempArray[2048]; -int totallines = 0; static int exiting = 0; static volatile int moocow = 0; @@ -141,6 +140,11 @@ extern int frame_display, input_display; int soundo = 1; +int srendlinen = 8; +int erendlinen = 231; +int srendlinep = 0; +int erendlinep = 239; + //mbg 6/30/06 - indicates that the main loop should close the game as soon as it can int closeGame = 0; @@ -299,16 +303,9 @@ int BlockingCheck() return exiting ? 0 : 1; } -void FixFL() -{ - FCEUI_GetCurrentVidSystem(&srendline, &erendline); - totallines = erendline - srendline + 1; -} - void UpdateRendBounds() { FCEUI_SetRenderedLines(srendlinen, erendlinen, srendlinep, erendlinep); - FixFL(); } /** diff --git a/src/drivers/win/main.h b/src/drivers/win/main.h index 23321535..bbe01e6a 100644 --- a/src/drivers/win/main.h +++ b/src/drivers/win/main.h @@ -72,21 +72,15 @@ extern int soundvolume; extern int soundquality; static uint8 cpalette[192]; -//mbg 5/7/08 - I changed the ntsc settings to match pal. -//this is more for precision emulation, instead of entertainment, which is what fceux is all about nowadays -//static int srendlinen = 8; -//static int erendlinen = 231; -static int srendlinen = 0; -static int erendlinen = 239; -static int srendlinep = 0; -static int erendlinep = 239; +extern int srendlinen; +extern int erendlinen; +extern int srendlinep; +extern int erendlinep; static int ntsccol = 0, ntsctint, ntschue; -extern int totallines; - //mbg merge 7/17/06 did these have to be unsigned? -static int srendline, erendline; +//static int srendline, erendline; static int changerecursive=0; @@ -105,7 +99,6 @@ extern HRESULT ddrval; extern int windowedfailed; extern uint32 goptions; -void FixFL(); void DoFCEUExit(); void ShowAboutBox(); int BlockingCheck(); diff --git a/src/drivers/win/replay.cpp b/src/drivers/win/replay.cpp index fcb10d89..724da859 100644 --- a/src/drivers/win/replay.cpp +++ b/src/drivers/win/replay.cpp @@ -131,20 +131,6 @@ void UpdateReplayDialog(HWND hwndDlg) sprintf(tmp, "%lu", info.rerecord_count); SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT), tmp); // rerecord - { - //// convert utf8 metadata to windows widechar - //WCHAR wszMeta[MOVIE_MAX_METADATA]; - //if(MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, metadata, -1, wszMeta, MOVIE_MAX_METADATA)) - //{ - // if(wszMeta[0]) - // SetWindowTextW(GetDlgItem(hwndDlg,IDC_LABEL_AUTHORINFO), wszMeta); // metadata - // else - // SetWindowTextW(GetDlgItem(hwndDlg,IDC_LABEL_AUTHORINFO), L"(this movie has no author info)"); // metadata - //} - - SetDlgItemTextW(hwndDlg,IDC_LABEL_AUTHORINFO,L"Temporarily non-functional"); - } - EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),(info.read_only)? FALSE : TRUE); // disable read-only checkbox if the file access is read-only SendDlgItemMessage(hwndDlg,IDC_CHECK_READONLY,BM_SETCHECK,info.read_only ? BST_CHECKED : (ReplayDialogReadOnlyStatus ? BST_CHECKED : BST_UNCHECKED), 0); @@ -214,8 +200,7 @@ void UpdateReplayDialog(HWND hwndDlg) { SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_LENGTH),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_FRAMES),""); - //SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT),""); - SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_AUTHORINFO),""); + SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),""); SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_RECORDEDFROM),"Nothing (invalid movie)"); @@ -336,8 +321,6 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP } MOVIE_INFO info; - char metadata[MOVIE_MAX_METADATA]; - char rom_name[MAX_PATH]; memset(&info, 0, sizeof(info)); @@ -549,7 +532,6 @@ void FCEUD_MovieReplayFrom(void) pal_emulation = FCEUI_GetCurrentVidSystem(0,0); UpdateCheckedMenuItems(); - FixFL(); SetMainWindowStuff(); RefreshThrottleFPS(); } @@ -708,7 +690,6 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP { LONG lIndex = SendDlgItemMessage(hwndDlg, IDC_COMBO_RECORDFROM, CB_GETCURSEL, 0, 0); p->szFilename = GetRecordPath(hwndDlg); - GetDlgItemTextW(hwndDlg,IDC_EDIT_AUTHORINFO,p->metadata,MOVIE_MAX_METADATA); p->recordFrom = (int)lIndex; if(lIndex>=3) p->szSavestateFilename = GetSavePath(hwndDlg); @@ -755,10 +736,6 @@ void FCEUD_MovieRecordTo() if(DialogBoxParam(fceu_hInstance, "IDD_RECORDINP", hAppWnd, RecordDialogProc, (LPARAM)&p)) { - // turn WCHAR into UTF8 - char meta[MOVIE_MAX_METADATA << 2]; - WideCharToMultiByte(CP_UTF8, 0, p.metadata, -1, meta, sizeof(meta), NULL, NULL); - if(p.recordFrom >= 3) { // attempt to load the savestate @@ -780,7 +757,7 @@ void FCEUD_MovieRecordTo() uint8 flags = 0; if(p.recordFrom == 0) flags = MOVIE_FLAG_FROM_POWERON; - FCEUI_SaveMovie(p.szFilename, flags, meta); + FCEUI_SaveMovie(p.szFilename, flags); } if(p.szFilename) diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 2e26e13b8ec09ecdf4273b82ab6bc8904b5f7fc2..e1b5a4b0825eacb1e6c2c286d835bf789363969d 100644 GIT binary patch delta 405 zcmXX?&nrY>6uqYzG18<dW-%6@S8B-O&71cO3#s`F{Md++X`)en#b7tdUm%~{l^VrD zC=2yUDNBV=>?Afyh-U_oDc^f^>)h|&^PSV_-fsm?HUsl}xDCRv?}Cs%DN0TKQA$&a z#!1jLP0$z(DI8ZQXp%-%PpQ2-WfhL95;UVWg61frxa|M@_aj3i9_L~QHOh;DNR2@T zC8$}UPI1*^WRfX6j>57p6|$E@$Y1+f$ddItT`V3@Yv*5}0Va3dAR-U1v=s-!XHs0o zwk_WOL{->QR=Q`|>KPi|+vNHz8aVGD^RMQ`0t`NU!#Q_8!_Ti9sN>xNDmYn0)Mt>z zV?`X4w|V*m$KH{KDRJ53C1I6hR^A*}a_$4`Fr<@g=fO{CN@=)hY?WpT9uZ;PfhP3@ ozZ7THocqFuefy1WNc~ZhPp6f9`Gci0_Yf_-wu%~izJ%f4Uv|WP+W-In delta 396 zcmZutO-lk%6urkO&4@`Uiav;%Rg014spB|BU<FZ&jJ}|SM9`vb^as-Z!h_x)s72%= zB6zF7)&;HF1zC%hl4gim(Q^#i#D&ZKI`^J?Zcl?RXTj_xiaO%*Ne9=2U-RiQ)q{(N zc1Db1Vny@q%FHVaz~$xHX<j&K6NNH{;R@8j_;%hedMoG)B*;_<ORx&KH#;Okbr`&K zXLP&dwz|qk$rZVK^z-c3=+PUVMX`ctWQI0qofc@BR%wyaG_N9)Y-Jw8Lnpm0F>=IM z2oattjVOGF=&WK~a}-y*imQO5Mw>~!iX9|*_;^j8zhe?wLKSmm%n7T8L6upY<!yOb z!+xt5e#C%Oj7^BWKi+ZgvgLUuuD>xQw?1Hj7c+*Zg>EVe=?1zc{(r%tmN4vB0+*W0 Qnor~!xPdK~K5?-511w5$2mk;8 diff --git a/src/drivers/win/video.cpp b/src/drivers/win/video.cpp index 84abf9d6..1315e9df 100644 --- a/src/drivers/win/video.cpp +++ b/src/drivers/win/video.cpp @@ -21,6 +21,7 @@ #include "video.h" #include "../../drawing.h" #include "gui.h" +#include "../../fceu.h" static int RecalcCustom(void); void InputScreenChanged(int fs); @@ -261,7 +262,7 @@ int SetVideoMode(int fs) ddsdback.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN; ddsdback.dwWidth=256 * specmul; - ddsdback.dwHeight=240 * specmul; + ddsdback.dwHeight=FSettings.TotalScanlines() * specmul; /* If the blit hardware can't stretch, assume it's cheap(and slow) @@ -346,7 +347,7 @@ int SetVideoMode(int fs) ddsdback.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN; ddsdback.dwWidth=256 * specmul; //vmodes[vmod].srect.right; - ddsdback.dwHeight=240 * specmul; //vmodes[vmod].srect.bottom; + ddsdback.dwHeight=FSettings.TotalScanlines() * specmul; //vmodes[vmod].srect.bottom; if(!(caps.dwCaps&DDCAPS_BLTSTRETCH)) ddsdback.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY; @@ -465,7 +466,7 @@ static void BlitScreenWindow(unsigned char *XBuf) srect.top=srect.left=0; srect.right=VNSWID * specialmul; - srect.bottom=totallines * specialmul; + srect.bottom=FSettings.TotalScanlines() * specialmul; if(PaletteChanged==1) { @@ -487,10 +488,10 @@ static void BlitScreenWindow(unsigned char *XBuf) ScreenLoc=(unsigned char*)ddsdback.lpSurface; //mbg merge 7/17/06 added cst if(veflags&1) { - memset(ScreenLoc,0,pitch*240); + memset(ScreenLoc,0,pitch*ddsdback.dwHeight); veflags&=~1; } - Blit8ToHigh(XBuf+srendline*256+VNSCLIP,ScreenLoc, VNSWID, totallines, pitch,specialmul,specialmul); + Blit8ToHigh(XBuf+FSettings.FirstSLine*256+VNSCLIP,ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,specialmul,specialmul); IDirectDrawSurface7_Unlock(lpDDSBack, NULL); @@ -557,7 +558,7 @@ static void BlitScreenFull(uint8 *XBuf) srect.top=0; srect.left=0; srect.right=VNSWID * specmul; - srect.bottom=totallines * specmul; + srect.bottom=FSettings.TotalScanlines() * specmul; if(vmodes[vmod].flags&VMDF_STRFS) { @@ -568,8 +569,8 @@ static void BlitScreenFull(uint8 *XBuf) } else { - drect.top=(vmodes[vmod].y-(totallines*vmodes[vmod].yscale))>>1; - drect.bottom=drect.top+(totallines*vmodes[vmod].yscale); + drect.top=(vmodes[vmod].y-(FSettings.TotalScanlines()*vmodes[vmod].yscale))>>1; + drect.bottom=drect.top+(FSettings.TotalScanlines()*vmodes[vmod].yscale); drect.left=(vmodes[vmod].x-VNSWID*vmodes[vmod].xscale)>>1; drect.right=drect.left+VNSWID*vmodes[vmod].xscale; } @@ -711,20 +712,20 @@ static void BlitScreenFull(uint8 *XBuf) if(vmodes[vmod].special) ScreenLoc += (vmodes[vmod].drect.left*(bpp>>3)) + ((vmodes[vmod].drect.top)*pitch); else - ScreenLoc+=((vmodes[vmod].x-VNSWID)>>1)*(bpp>>3)+(((vmodes[vmod].y-totallines)>>1))*pitch; + ScreenLoc+=((vmodes[vmod].x-VNSWID)>>1)*(bpp>>3)+(((vmodes[vmod].y-FSettings.TotalScanlines())>>1))*pitch; } if(bpp>=16) { - Blit8ToHigh(XBuf+srendline*256+VNSCLIP,(uint8*)ScreenLoc, VNSWID, totallines, pitch,specmul,specmul); //mbg merge 7/17/06 added cast + Blit8ToHigh(XBuf+FSettings.FirstSLine*256+VNSCLIP,(uint8*)ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,specmul,specmul); //mbg merge 7/17/06 added cast } else { - XBuf+=srendline*256+VNSCLIP; + XBuf+=FSettings.FirstSLine*256+VNSCLIP; if(vmodes[vmod].special) - Blit8To8(XBuf,(uint8*)ScreenLoc, VNSWID, totallines, pitch,vmodes[vmod].xscale,vmodes[vmod].yscale,0,vmodes[vmod].special); //mbg merge 7/17/06 added cast + Blit8To8(XBuf,(uint8*)ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,vmodes[vmod].xscale,vmodes[vmod].yscale,0,vmodes[vmod].special); //mbg merge 7/17/06 added cast else - Blit8To8(XBuf,(uint8*)ScreenLoc, VNSWID, totallines, pitch,1,1,0,0); //mbg merge 7/17/06 added cast + Blit8To8(XBuf,(uint8*)ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,1,1,0,0); //mbg merge 7/17/06 added cast } } @@ -826,7 +827,7 @@ static int RecalcCustom(void) cmode->xscale=1; } } - if(totallines*cmode->yscale>cmode->y) + if(FSettings.TotalScanlines()*cmode->yscale>cmode->y) { if(cmode->special) { @@ -841,12 +842,12 @@ static int RecalcCustom(void) } cmode->srect.left=VNSCLIP; - cmode->srect.top=srendline; + cmode->srect.top=FSettings.FirstSLine; cmode->srect.right=256-VNSCLIP; - cmode->srect.bottom=erendline+1; + cmode->srect.bottom=FSettings.LastSLine+1; - cmode->drect.top=(cmode->y-(totallines*cmode->yscale))>>1; - cmode->drect.bottom=cmode->drect.top+totallines*cmode->yscale; + cmode->drect.top=(cmode->y-(FSettings.TotalScanlines()*cmode->yscale))>>1; + cmode->drect.bottom=cmode->drect.top+FSettings.TotalScanlines()*cmode->yscale; cmode->drect.left=(cmode->x-(VNSWID*cmode->xscale))>>1; cmode->drect.right=cmode->drect.left+VNSWID*cmode->xscale; @@ -864,7 +865,7 @@ static int RecalcCustom(void) FCEUD_PrintError("Horizontal resolution is too low."); return(0); } - if(cmode->y<totallines && !(cmode->flags&VMDF_STRFS)) + if(cmode->y<FSettings.TotalScanlines() && !(cmode->flags&VMDF_STRFS)) { FCEUD_PrintError("Vertical resolution must not be less than the total number of drawn scanlines."); return(0); diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index b721cf46..de7c7f61 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -32,6 +32,7 @@ #include "input.h" #include "video.h" #include "../../input.h" +#include "../../fceu.h" #include "memwatch.h" #include "ppuview.h" @@ -113,7 +114,7 @@ void CalcWindowSize(RECT *al) al->left = 0; al->right = VNSWID * winsizemulx; al->top = 0; - al->bottom = totallines * winsizemuly; + al->bottom = FSettings.TotalScanlines() * winsizemuly; AdjustWindowRectEx(al, GetWindowLong(hAppWnd, GWL_STYLE), @@ -475,8 +476,6 @@ void ALoad(char *nameo) UpdateCheckedMenuItems(); - FixFL(); - SetMainWindowStuff(); AddRecentFile(nameo); @@ -577,7 +576,7 @@ void GetMouseData(uint32 *md) RECT t; GetClientRect(hAppWnd, &t); md[0] = md[0] * VNSWID / (t.right ? t.right : 1); - md[1] = md[1] * totallines / (t.bottom ? t.bottom : 1); + md[1] = md[1] * FSettings.TotalScanlines() / (t.bottom ? t.bottom : 1); } else { @@ -588,7 +587,7 @@ void GetMouseData(uint32 *md) md[0] += VNSCLIP; } - md[1] += srendline; + md[1] += FSettings.FirstSLine; md[2] = ((mouseb == MK_LBUTTON) ? 1 : 0) | (( mouseb == MK_RBUTTON ) ? 2 : 0); } @@ -928,7 +927,6 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) FCEUI_SetVidSystem(pal_emulation); RefreshThrottleFPS(); UpdateCheckedMenuItems(); - FixFL(); // DoVideoConfigFix(); SetMainWindowStuff(); break; @@ -1218,11 +1216,11 @@ void FixWXY(int pref) if(!pref) { - winsizemuly = winsizemulx * 256 / 240 * 3 / 4 * saspectw / saspecth; + winsizemuly = winsizemulx * 256 / FSettings.TotalScanlines() * 3 / 4 * saspectw / saspecth; } else { - winsizemulx = winsizemuly * 240 / 256 * 4 / 3 * saspecth / saspectw; + winsizemulx = winsizemuly * FSettings.TotalScanlines() / 256 * 4 / 3 * saspecth / saspectw; } } if(winspecial) @@ -1352,7 +1350,7 @@ int CreateMainWindow() MainWindow_wndx, MainWindow_wndy, 256, - 240, /* X,Y ; Width, Height */ + FSettings.TotalScanlines(), /* X,Y ; Width, Height */ NULL, fceumenu, fceu_hInstance, @@ -1444,7 +1442,7 @@ int GetClientAbsRect(LPRECT lpRect) else { lpRect->right = point.x + VNSWID * winsizemulx; - lpRect->bottom = point.y + totallines * winsizemuly; + lpRect->bottom = point.y + FSettings.TotalScanlines() * winsizemuly; } return 1; } diff --git a/src/drivers/win/window.h b/src/drivers/win/window.h index e012feee..ec742369 100644 --- a/src/drivers/win/window.h +++ b/src/drivers/win/window.h @@ -10,7 +10,6 @@ struct CreateMovieParameters char* szFilename; // on Dialog creation, this is the default filename to display. On return, this is the filename that the user chose. int recordFrom; // 0 = "Power-On", 1 = "Reset", 2 = "Now", 3+ = savestate file in szSavestateFilename char* szSavestateFilename; - WCHAR metadata[MOVIE_MAX_METADATA]; }; static int EnableBackgroundInput = 0; diff --git a/src/fceu.h b/src/fceu.h index bb495c31..107ade2c 100644 --- a/src/fceu.h +++ b/src/fceu.h @@ -70,13 +70,18 @@ typedef struct { int SoundVolume; int GameGenie; - //Current first and last rendered scanlines. + //the currently selected first and last rendered scanlines. int FirstSLine; int LastSLine; - //Driver code(user)-specified first and last rendered scanlines. + + //the number of scanlines in the currently selected configuration + int TotalScanlines() { return LastSLine - FirstSLine + 1; } + + //Driver-supplied user-selected first and last rendered scanlines. //Usr*SLine[0] is for NTSC, Usr*SLine[1] is for PAL. int UsrFirstSLine[2]; int UsrLastSLine[2]; + int SnapName; uint32 SndRate; int soundq; diff --git a/src/input.cpp b/src/input.cpp index 783fe66d..27f65d54 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -753,7 +753,7 @@ static void CommandStateLoad(void) static void CommandMovieRecord(void) { - FCEUI_SaveMovie(0, 0, 0); + FCEUI_SaveMovie(0, 0); } static void CommandMovieReplay(void) diff --git a/src/movie.cpp b/src/movie.cpp index 37954079..25bb81c4 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -500,7 +500,7 @@ static void openRecordingMovie(const char* fname) //begin recording a new movie -void FCEUI_SaveMovie(char *fname, uint8 flags, const char* metadata) +void FCEUI_SaveMovie(char *fname, uint8 flags) { assert(fname);