Search found 323 matches

by blargg
Sat Mar 04, 2006 2:44 am
Forum: Development
Topic: Simple Hires Blitter
Replies: 5
Views: 4309

Simple Hires Blitter

Byuu has mentioned that my NTSC filter handles the SNES 512-width graphics mode ("hires") well compared to the other ones in bsnes. There's nothing special my filter is doing; it just shifts the odd pixels 1/2 a unit to the right and mixes that with the even pixels. The following code does...
by blargg
Sat Mar 04, 2006 12:27 am
Forum: Development
Topic: Optimal RGB Mix/Clamped Add/Sub
Replies: 52
Views: 40734

Now to work color halve into there, heh. Eh? If you halve the intermediate sum, it's impossible for it to overflow. :) I can see how it would be necessary for the subtract clamped operation. Once I post that we can work that out. And is it just the BBTech skin/my browser, or is it lame for hyperlin...
by blargg
Sat Mar 04, 2006 12:14 am
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

I wrote a bit about how the filter works: A SNES pixel's effect is spread out on the TV screen, due to the way NTSC encoding and decoding work. At some point I realized that the NTSC operation was linear , which meant that the result of running two adjacent pixels A and B through the NTSC filter is ...
by blargg
Fri Mar 03, 2006 9:26 pm
Forum: Development
Topic: Optimal RGB Mix/Clamped Add/Sub
Replies: 52
Views: 40734

Wow, as I was going to write the page describing clamped add, I came up with a new, much simpler algorithm that's 3 operations less than before. It came out similar to the RGB mixing algorithm (and sinamas' version above): Adding RGB Pixels With Clamping sum = x + y; low_bits = (x ^ y) & 0x0421;...
by blargg
Fri Mar 03, 2006 7:03 pm
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

Until I write a complete description, I'll only summarize. NTSC represents luma (brightness basically) by the amplitude of the video signal. It represents chroma (color) by adding a ~3.58 MHz waveform to the luma signal, whose phase is the hue and amplitude is the saturation. In the TV the signal is...
by blargg
Fri Mar 03, 2006 6:35 am
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

Hmm, so this is supposed to 'emulate' how a TV would look? So if I were going to use my vid cards video output to a TV I would want to leave this filter off? It emulates both the artifacts inherent in the SNES NTSC composite output circuitry and the way an NTSC TV decodes the signal. TV output card...
by blargg
Thu Mar 02, 2006 10:39 pm
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

Ok, this might not be accurate, due to something that you probably don't realise (not many people seem to.) Most consoles (NES and SNES included) never output odd and even frames (unless, of course, they have a setting for interlaced mode). Every single frame output is in fact an even frame. This i...
by blargg
Thu Mar 02, 2006 6:23 pm
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

When the background scrolls at certain speeds, flicker and/or color anomalies appear, or become more apparent. This is exactly what happens on NTSC. If you've ever played the NES on an NTSC television, it's much more apparent there. I'll try to explain. Each pixel of some color can appear three dif...
by blargg
Wed Mar 01, 2006 4:55 am
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

Okay, if NTSC really must be in there, it's gonna have to be a completely vertical dot pattern, like the Atari 2600 and Apple ][ used back in the day... I should know; I own a Genesis! Me too, I always hated how crappy the Sega Genesis pixels looked (same for Master System, and even TI 99/4A was th...
by blargg
Wed Mar 01, 2006 1:36 am
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

Here is all you need to change to have it use source pixels in 15-bit RGB format instead of BGR: /* snes_ntsc.c line 341 */ /* Use SNES source pixels in 15-bit RGB format rather BGR */ int ir = entry >> 8 & 0x1E; int ig = entry >> 4 & 0x1F; int ib = entry << 1 & 0x1E;
by blargg
Tue Feb 28, 2006 10:07 pm
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

A quick question about this filter. It can only read from a 15-bit buffer? ZSNES currently has a 16-bit buffer it renders to. Apparently you solved this issue, but for reference, it can easily be modified to use a different input format (and for that matter, output format). It only uses 13 bits fro...
by blargg
Tue Feb 28, 2006 2:49 am
Forum: Development
Topic: Optimal RGB Mix/Clamped Add/Sub
Replies: 52
Views: 40734

Optimal RGB Mix/Clamped Add/Sub

I'm working on some tutorials about efficient algorithms for packed RGB mixing and add/subtract with clamping, which might be helpful for implementing the graphics operations in a SNES emulator. So far I've written one for mixing: Mixing Packed RGB Pixels Efficiently low_bits = (X ^ Y) & 0x0421;...
by blargg
Tue Feb 28, 2006 1:34 am
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

Sorry, I meant that those were the changes I made to the algorithm, which are in the code above; Nestopia uses the old, slower algorithm. At this point, if someone's going to make it go faster, it'll be by rewriting the main blitter loop to use SIMD instructions (MMX/SSE/AltiVec/etc.). I'll gladly a...
by blargg
Tue Feb 28, 2006 12:45 am
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

Yes, it's based on the filter code I wrote for the NES, which the author of Nestopia used (with some minor modifications). The NES and SNES have the same pixel timing, so the code is very similar. It's had a couple of rewrites since the Nestopia version, converting it from floating-point to integer ...
by blargg
Mon Feb 27, 2006 8:46 pm
Forum: Development
Topic: SNES NTSC Composite Video Filter
Replies: 280
Views: 225852

SNES NTSC Composite Video Filter

I've written a blitter/filter for use in a Super NES emulator that simulates the NTSC composite video signal and TV's decoding of it. It's written in C and has a BSD-style license. It accepts 15-bit BGR SNES pixels and outputs to 16-bit RGB pixels. Here's its output expanded to 3x with scanline dark...
by blargg
Mon Jan 23, 2006 10:53 am
Forum: Emulators
Topic: Nestopia 1.39
Replies: 374
Views: 239627

Yep, tried NTSC mode, a few nitpicks: Actually NES graphics on NTSC would have passive zigzaggy dot patterns An example would help, particularly of what you mean by "passive". I haven't seen Nestopia in action so I don't know whether it does things differently than the NTSC emulation code...
by blargg
Mon Jul 18, 2005 9:01 am
Forum: Development
Topic: SPC-700 Noise Algorithm?
Replies: 2
Views: 3823

Ouch, it really is that simple :). I must have messed up the sign-extension when I was trying endless tricky variations of the algorithm I posted. Now Chrono Trigger - Beach sounds exactly the same as on a SNES. Thanks!
by blargg
Sun Jul 17, 2005 12:13 pm
Forum: Development
Topic: SPC-700 Noise Algorithm?
Replies: 2
Views: 3823

SPC-700 Noise Algorithm?

Has the SPC-700 noise algorithm been determined exactly? A while back I examined it and found it used a similar algorithm as the NES 2A03 sound chip, with some modifications to give it a multi-bit output. I never found an exact algorithm, only something fairly close. Anomie's DSP draft covers the fe...
by blargg
Mon Jul 04, 2005 4:34 am
Forum: Development
Topic: SPC700
Replies: 41
Views: 39509

Use the code posted by anomie or me to find out the result of DIV for particular values. Neither implementation invokes undefined behavior (no division by zero), even when x = 0. As far as the behavior of DIV for cases where the result isn't mathematically defined or won't fit within the 9 bit quoti...
by blargg
Sun Jul 03, 2005 1:41 am
Forum: Development
Topic: SPC700
Replies: 41
Views: 39509

By the way, I ran the iterative division algorithm posted by anomie side-by-side with the one I validated and in all cases it generated the same result. It's more like what is probably done in hardware, with the 9 calculation iterations and perhaps a few more for setup corresponding to the 12 (?) pr...
by blargg
Sat Jul 02, 2005 6:23 pm
Forum: Development
Topic: SPC700
Replies: 41
Views: 39509

Would you mind explaining what's with the black magic when y >= x * 2? It's the simplest algorithm that matches the results I observed for DIV :). I don't know why (I haven't studied hardware division much). The result follows a fairly simple pattern for AY going from $0000 to $ffff for different v...
by blargg
Sat Jul 02, 2005 5:09 pm
Forum: Development
Topic: SPC700
Replies: 41
Views: 39509

DIV Instruction Validator

I finally wrote a fairly thorough validation of the DIV instruction and tested it on my SNES and an emulator using the code below. The test is built as an SPC file. It executes DIV YA,X for all 16 million values of Y, A, and X and checks the result in A and Y, and the overflow flag. It takes about 1...
by blargg
Thu Jun 30, 2005 1:59 pm
Forum: Development
Topic: SPC700
Replies: 41
Views: 39509

I did some SPC CPU reverse-engineering last year and have some of the results. Of interest might be the DIV raw data and the algorithm I came up with. http://www.io.com/~greens/temp/blargg-spc700-2004.10.zip I also did some testing of the test register ($F1), finding that some settings slow down the...