⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snes_ntsc.txt

📁 linux下的任天堂模拟器代码。供大家参考。
💻 TXT
字号:
snes_ntsc 0.2.2: SNES NTSC Video Filter---------------------------------------Author  : Shay Green <gblargg@gmail.com>Website : http://www.slack.net/~ant/Forum   : http://groups.google.com/group/blargg-sound-libsLicense : GNU Lesser General Public License (LGPL)Language: C or C++Overview--------To perform NTSC filtering, first allocate memory for a snes_ntsc_t objectand call snes_ntsc_init(), then call snes_ntsc_blit() to performfiltering. By default, snes_ntsc_blit() reads and writes pixels in 16-bitRGB. You can call snes_ntsc_init() at any time to change image parameters.Image Parameters----------------Many image parameters can be adjusted and presets are provided forcomposite video, S-video, RGB, and monochrome. Most are floating-pointvalues with a general range of -1.0 to 1.0, where 0 is normal. The rangesare adjusted so that one parameter at an extreme (-1 or +1) and the restat zero shouldn't result in any internal overflow (garbage pixels).Setting multiple parameters to their extreme can produce garbage. Putanother way, the state space defined by all parameters within the range -1to +1 is not fully usable, but some extreme corners are very useful so Idon't want to reduce the parameter ranges.The sharpness and resolution parameters have similar effects. Resolutionaffects how crisp pixels are. Sharpness merely enhances the edges byincreasing contrast, which makes things brighter at the edges. Artifactssets how much "junk" is around the edges where colors and brightnesschange in the image, where -1 completely eliminates them. Bleed affectshow much colors blend together and the artifact colors at the edges ofpixels surrounded by black.Image Size----------For proper aspect ratio, the image generated by the library must bedoubled vertically.Use the SNES_NTSC_OUT_WIDTH() and SNES_NTSC_IN_WIDTH() macros to convertbetween input and output widths that the blitter uses. For example, if youare blitting an image 256 pixels wide, use SNES_NTSC_OUT_WIDTH( 256 ) tofind out how many output pixels are written per row. Another example, useSNES_NTSC_IN_WIDTH( 640 ) to find how many input pixels will fit within640 output pixels. The blitter rounds the input width down in some cases,so the requested width might not be possible. Use SNES_NTSC_IN_WIDTH(SNES_NTSC_OUT_WIDTH( in_width ) ) to find what a given in_width would berounded down to.Burst Phase-----------The burst_phase parameter to snes_ntsc_blit() should generally togglevalues between frames, i.e. 0 on first call to snes_ntsc_blit(), 1 onsecond call, 0 on third call, 1 on fourth, etc. If merge_fields is enabled(see below), you should always pass 0.If you're using snes_ntsc_blit() to do partial screen updates, burst_phaseshould be calculated as (burst_phase + row) % 3, where row is the startingrow (0 through 239). For example, if burst_phase is 1 for the currentframe and you make two calls to snes_ntsc_blit() to blit rows 0 to 100,then rows 101 to 239, for the first call you should pass 1 forburst_phase, and for the second call you should pass 0 for burst_phase: (1+ 101) % 3 = 0.Flickering----------The displayed image toggles between two different pixel artifact patternsat a steady rate, making it appear stable. For an emulator to duplicatethis effect, its frame rate must match the host monitor's refresh rate, itmust be synchronizing to the refresh (vsync), and it must not be skippingany frames. If any of these don't hold, the image will probably flickermuch more than it would on a TV. It is important that you play around withthese factors to get a good feel for the issue, and document it clearlyfor end-users, otherwise they will have difficulty getting an authenticimage.The library includes a partial workaround for this issue, for the caseswhere all the conditions can't be met. When merge_fields is set to 1,snes_ntsc_blit() does the equivalent of blitting the image twice with thetwo different phases and then mixes them together, but without anyperformance impact. The result is similar to what you'd see if themonitor's refresh rate were the same as the emulator's. It does reduce theshimmer effect when scrolling, so it's not a complete solution to therefresh rate issue.The merge_fields option is also useful when taking a screenshot. If youcapture without merge_fields set to 1, you'll only get the even or oddartifacts, which will make the image look more grainy than when theemulator is running. Again, play around with this to get an idea of thedifference. It might be best to simply allow the user to choose when toenable this option.Note that when you have merge_fields set to 1, you should always pass 0for the burst_phase parameter to snes_ntsc_blit(). If you don't, you'llstill get some flicker.Custom Blitter--------------You can write your own blitter, allowing customization of how SNES pixelsare obtained, the format of output pixels (15, 16, or 32-bit RGB),optimizations for your platform, and additional effects like efficientscanline doubling during blitting.Macros are included in snes_ntsc.h for writing your blitter so that your codecan be carried over without changes to improved versions of the library.The default blitters at the end of snes_ntsc.c show how to use the macros.Contact me for further assistance.Limitations-----------The library's horizontal rescaling is too wide by about 3% in order toallow a much more optimal implementation. This means that a 256 pixel wideconsole image should appear as 581 output pixels, but with this libraryappears as 602 output pixels. TV aspect ratios probably vary by this muchanyway. If you really need unscaled output, contact me and I'll see aboutadding it.Input pixels are converted to 13-bit RGB (4 bits red, 5 bits green, 4 bitsblue) to reduce memory usage from 16MB to 4MB. Contact me if you'd likethis reduction made optional.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -