Page 2 of 3

VBA2 progress

Posted: Sun Jan 03, 2010 9:40 am
by spacy51

GBA has no mode 7 (only 5 modes)

 

as far is I know now, it supports rotation & scaling, but only in 2D

 

EDIT: hm, looking at F-zero (uses mode 2), I wonder how they did that effect of the layer being laid out to the back

And where does the sky come from???


VBA2 progress

Posted: Sun Jan 03, 2010 12:00 pm
by spacy51

I just uploaded the code for creating the picture of a mode1 rotation/scaling BG

 

Edit:

Creating pictures out of every mode is now supported. The bitmap modes were extremely easy, just some lines of code.

What's missing now are the window features and sprites.


VBA2 progress

Posted: Mon Jan 04, 2010 2:58 pm
by Squall Leonhart

mode 7 is simulated using 2 layers of mode 2.


VBA2 progress

Posted: Fri Jan 08, 2010 3:44 pm
by spacy51

Here's a screenshot from the current version. I added a window that can display each BG seperately and even export it to PNG. Qt is amazing by allowing to do that in just 5 lines of code. (Qt even exports the alpha channel)

 

The left (main) window uses the old VBA's graphics emulation code with an OpenGL accelerated QPainter-drawn Widget.

 

The right (debug) window uses my new GBA graphics emulation class.

 

Both windows are fed using my display driver architecture.


VBA2 progress

Posted: Fri Jan 08, 2010 5:49 pm
by mudlord

Very nicely done. We need to get in touch. There needs to be a way to scale that LLE output.

 

That HLE output is quite good. You just need to work on layering the other BG's as textures it seems.


VBA2 progress

Posted: Fri Jan 08, 2010 6:02 pm
by spacy51

I will need some weeks to finish off the preprocessing, that debug window helps me in verifying my code.


VBA2 progress

Posted: Thu Jan 14, 2010 1:16 pm
by Exophase

EDIT: hm, looking at F-zero (uses mode 2), I wonder how they did that effect of the layer being laid out to the back
And where does the sky come from???

 

The projection effect is accomplished by changing the affine transformation step values throughout the frame, up to every scanline. This is usually done with HDMA but you can do it with HIRQs.

 

I don't know specifically about the sky in F-Zero X right now, but the part above the horizon line is often accomplished by changing the screen mode in the middle of the screen and using a normal text BG for it - that's how Mario Kart does it. It can also be done with sprites, or by changing the affine parameters to point to it (but this is a lot trickier to manage). In mode 1 you can use one of the text BGs on top of the affine one.

 

Rendering the entire screen at once is going to give you massive compatibility problems. As you can see from from the two examples in this post alone a lot of games change what's on the screen while it's being drawn. Games use it for lots of other things too, like color gradients and wavy scrolling.

 

That's why emulators of just about every 2D platform use per-line renderers instead of per-frame ones. In fact, in some ways per-frame is slower because you're working with frame sized buffers instead of line sized ones. This applies to priority combining and alpha blending. You'll end up with a lot more L1 misses.

 

One of the big speed hits from typical line based renderers vs frame based ones is that they will check every sprite every line to see if it should be drawn. You can improve upon this approach by caching which sprites are on which lines are on then only changing this if OAM has been modified before the line. Usually OAM is only modified in vblank so you end up recreating the table once per frame instead of once per line. Even the few games that perform sprite multiplexing only do so a few times per frame.

 

I've mentioned these things in another thread, but I think that trying to do the layer compositing in OpenGL is just asking for trouble. You're not going to be able to correctly emulate blending so easily (or mosaic, but I think most people don't really care about mosaic anyway). The only way I can think of doing it is with a relatively complex depth peeling approach that would require at least three passes. OBJ windows are also going to be pretty problematic.

 

Caching the backgrounds into bitmaps (correct me if this is not what you're doing) might also prove a little unpleasant - basically, what is your strategy for dealing with modifications to them? Do you plan to recreate the entire background when any part of the map is modified? Or just a part of it? Unfortunately, in OpenGL modifying textures can be slow, even if it's just a part of it (sometimes especially if it's just a part of it). An even bigger issue is what happens when the tiles themselves are modified, since it can be expensive to track where in a map a tile is being used. You may end up having to re-cache every map any time any tile is modified. Some games modify tiles to animate them, and if you recache the entire maps you'll end up with something that's probably substantially slower than a full software renderer. Oh yeah, forgot about palette modifications, another common per-frame mod. I guess you're basically going to be stuck recaching the whole map a lot no matter what. Layers are at least 256x256, already a decent amount more than the work rendering them to 240x160, but they can be up to 512x512. Affine maps at up to 1024x1024 are quite a bit worse, although there you do save on not having to transform them.

 

One more comment: if you found the bitmap modes extremely easy then you're probably not emulating them completely. I say this because the bitmaps are affine transformed like the affine layers in modes 1 and 2.


VBA2 progress

Posted: Fri Jan 15, 2010 6:58 am
by spacy51

Wow, sounds like I have a problem.


VBA2 progress

Posted: Fri Jan 15, 2010 1:40 pm
by Exophase

You should have taken the comments on this matter that I posted several months ago more to heart [img]<fileStore.core_Emoticons>/emoticons/wink.png[/img]/emoticons/wink@2x.png 2x" width="20" height="20" />

 

It's possible to emulate all of GBA video using shaders, but it'd require some damn complex ones with lots of texture lookups and multiple passes. A DS scener by the name of WolfgangSt is currently writing a DS emulator (or at least he was, haven't seen any public updates in a few months) that renders in hardware. But it's still very incomplete, and I told him a lot of the same things I told you. At any rate, he's doing very little caching, meaning that he fetches tile maps and paletted pixels using shader code. This means that rendering a quad with that shader results in it actually rendering those pixels from a layer like a DS would. Raster effects weren't a problem because it could render a line at a time this way. But I still don't know how he intends on handling blending or OBJ windows.

 

I think that you should step back and determine what your basic high level goals are. If your main goal is something faster than VBA's current renderer then that's very attainable. If you want something cleaner then you're probably going to have to make a compromise somewhere. If you want it on harder so that you can tie in shader effects at an earlier stage of the rendering pipeline then you're probably not going to get it.


VBA2 progress

Posted: Sun Jan 31, 2010 5:39 pm
by spacy51

I disabled the new graphics code for now and use the old code.

 

Anyway, I noticed the new Qt 4.6 SDK now offers sound input/output classes (platform independent), so VBA2 now blurts out some noise. It seems kind of right already, but I have to further work on the timing.

 

EDIT:

I am so happy, sound output is finally not stuttering anymore.

I even read Qt's source code and all, but I think the cause was just that the audio engine calls reset and resume too early at the beginning.

I found out that the windows implementation of the QAudioOutput class uses the WaveOutOpen() function from the Windows API. The is supported since Windows 98.