Monday, September 26, 2011

Pixel Shaders in Genesis, GBA, GBC Emulation

If you've looked at any of the amazing pixel shaders available for bsnes, such as the collaborative CRT shader from cgwg and DOLLS or Themaister's dot-n-bloom, you may have wanted to use them with other systems, such as Sega Genesis or Gameboy Advance. Well, now you can! Update (10/03/2011): now it works with Final Burn Alpha, as well. Update (10/5/2011): I'm adding download links for Windows binaries of the various libraries, when possible.

Themaister wrote some "hacky" wrappers around Genesis Plus GX, Visualboy Advance and Gambatte that route their APIs to match up with that of libsnes. That means any frontend for libsnes, such as Themaister's own SSNES, can now serve as a frontend for these excellent emulators. Thus, any features of the frontend, such as SSNES' real-time rewind and FFMPEG-powered video dumping capabilities, get baked in automatically. This also extends SSNES' badass GGPO-style netplay to all of these systems (where applicable, of course).

If you're using Ubuntu or another Debian-based distro, you can get precompiled binaries from my PPA repo. Other *nixes can compile them from source. The only dependencies are git (not even totally necessary if you manually download the source via http), a compiler that supports C++98 or higher (gcc-3.4 and up, IIRC) and zlib (in Debian-based distros, it's the zlib1g-dev package).

So, open a terminal and type:

For Genesis Plus GX:
git clone https://github.com/twinaphex/genesis-next
cd megadrive-next/src/libsnes
make

Download Windows libsnes-genesisplusgx binaries
(you may need to rename zlib.dll to libz-1.dll for it to work)

For Visualboy Advance (vba):
git clone git://github.com/Themaister/gba-next.git
cd trunk/platform/libsnes
make

For Gambatte:
git clone git://github.com/Themaister/gambatte-libsnes.git --branch libsnes
cd gambatte-libsnes/libgambatte/libsnes
make

For Final Burn Alpha (fba):
git clone git://github.com/twinaphex/fba-next-slim.git
cd fba-next-slim/src/burner/libsnes
make

Download Windows libsnes-fba binaries

The resulting libraries will all be called libsnes.so. In my packages, the libraries are named according to the emulator (libsnes-*.so) so you can have them all peacefully coexist.

One thing to be aware of: SSNES-Phoenix's file browser will filter out non-SNES extensions, so you'll have to manually type the filenames unless/until Themaister does anything about it.

Screenshots (dot-n-bloom shader is used for the GBC and GBA screenshots, CRT is used for Genesis and FBA):


Monday, September 19, 2011

SSF4AE - doshu's ULSM Tutorial

Here's a more or less basic tutorial about how I built my Ultra Light Stage mod. The aspects that I won't cover are basic Gimp/Photoshop manipulations, building your own BGM selection and how to convert a TRN stage to any other stage. If need be, those aspects can all be learned quickly either by reading the SSFIV/AE wikis, by searching the net, or simply by thinking on your own and doing try/errors.
Also, the first part of the tutorial is way more detailed (both in text and pictures) than the last ones, since I wrote it a while back to explain how the Training stage edit works on the polycount forums.

Since I build my mod, a lot of progress has been made in the field of custom Training stage's templates, so instead of blindly followind this tutorial entirely, you should probably just take the parts you need and try to build even better stages than I did (not so hard IMO :p).

Finally, I have to insist that I'm (or was) a total n00b in modding, and that this tutorial might include some really weird and/or not efficient methods for expert modders. I'm repeating myself here, but better safe than sorry^^. Anyway, if you have a better way of doing things, share it! This tutorial will then hopefully be updated ;).

Ok, let's start with an overview of the needed tools (find those in the wiki and/or with google) :

  • SF4 Assets Explorer
  • The Gimp + dds mod
  • SFIVAM
  • hexadecimal editor HxD
  • Ryu's Classic Training Stage mod by hunterk
Quick overview of the whole process :
  • extract Ryu's Classic Training Stage's dds and observe how it's made
  • build your own dds from whatever art you find that seems fine (but do not forget to get the author's authorization if you want to share your work!)
  • do the hex magic
  • inject the dds : the stage is done!
  • build the 3 preview pics'dds : big, medium and small size
  • build the 2 kind of presentation text : Stage Select and pre-versus screen
  • inject the whole thing into the appropriate files
  • mute that annoying announcer !
  1. Building your own stage
    1. Basic explanations
      Ok, so here's a bit of explanation on how it works. As you'll see, it really needs only basic picture editing skill, and not anything fancy.

      First, let's look at the "cube" limitations : the edges (this stage was done by hunterk).
      [IMG]

      As you can see, all the vertical sides of the cube are filled with the same part of the texture, making it "loop" when it reaches the end. The same with the floor/ceiling. In practice, it doesn't show that much, except when performing some Ultra's like Ryu's Metsu Shoryuken.
      But what is important here, is that because of that loop, the more the left and right sides of the texture looks alike, the less it will be apparent in the stage. In this case, it's almost "invisible".
      Secondly, here's the kind of file the stage's texture is made of:
      [IMG]

      Basically, the "floor" part is upside, then comes a thin black line, and the the main background. What is important here for "good" results, is that the floor looks as much as possible like one, as it does from all the above examples (and in the WIP preview screenshot). If the original jpg image's "floor" isn't "straight", or is filled with different objects and such, the result might be awkward (or not, it depends).

      For example, let's first show the results from the 2 pictures above:
      [IMG]

      All in all, except the crappy resolution problem, those stages look "good" : the floor is “floory”, and the edges of the texture look alike, so it should be pretty "invisible" while playing.

      Let's finish the basic explanations with a "difficult" file to work from (at least for my skills)
      [IMG]


      That's it for the basic explanations.
    2. Choosing some art and building a dds from it
      Basically, you'll want to work from a picture as high def as possible, even if the dds will only be 1280*800. Also, the scene should ideally be pretty empty in the “front”, thus allowing you to easily build the floor of your stage. It is possible to work from more difficult material, but I'll leave it to you to find how, explaining it here would be long and tedious.

      For my part, I worked mostly on feeling. Just look at the picture, copy whatever part you want to make the floor of without thinking too much about proportions, copy and paste it as a new image, then resize that new image at 1280*237. That's pretty much it for the floor.
      Return to the original picture, select the other part of it (Ctrl-I should do the trick if your previous selection was still active), copy paste as new image, then resize to 1280*553. That's it for the wall.
      Create a new black backgrounded 1280*800 image, copy paste the floor into it, position it up (using the arrows make it a breeze to do, no pixel precision needed). Do the same for the wall, except you position it down. There should be around 10 pixels left black in between.
      Flip the image horizontally (Image → Transform), then save as a .dds (just name the file whatever .dds when saving). Don't bother about the compression, it's not needed.
      Before injecting the newly created dds file, you need to make it the exact same size as the original one. To do that, just open both the original and the new dds file into your hex editor, and do the following :
      - on the original file : Ctrl-A ; End ; Ctrl-E ; choose 2EE080 ; Ctrl-C
      - on the new file : Ctrl-A ; End ; Ctrl-V ; Ctrl-S

      That should do the trick. Basically, you're copying what bytes are missing in the new file from the original one. All the files I created were always 2EE070 sections long, that's how you get the 2EE080 number. Should your file be a different size than that, you will have the adapt this number to that size so that both files are the same size at the end. This method doesn't work with new files bigger than the original though... (see how I'm a n00b in hex editing? Pretty n00bish I must admit, but it works! I have an idea why it does work, but I'll gladly hear some real explanation^^).

      A last word about applying filters on the dds befrore injecting it. The ingame look of the stage you built won't be exactly the same as the dds' look, so you might want to try and apply some filters. Here are the ones I used so far:
      - unsharpen: used mostly for high definition material, like most of the stage of the ULSM. I used it twice on each dds.
      - cartoon: used in combination with "Van Gogh" to make low definition material look ok-ish ingame
      Don't hesitate to try other filters too!

      Ok, you're good to inject to file into the .emz and test out your newly build stage!
  2. Editing the Stage Select screen
    [IMG]
    This part is really easy, but quite time consuming. I'll first specify the particularities of each kind of file needed for the Stage Select screen (dds resolution : actual picture resolution (ratio) / type of compression needed):
    - big preview picture: 1024*512 / 710*377 (1.88) / BC2/DXT3; the BLD stage needs a 1024*1024 resolution file (adapt the actual picture size accordingly)
    small preview picture: 128*128 / 116*89 (1.30) / BC1/DXT1

    Then the pre-versus screen:
    - medium preview picture: 512*256 / 336*214 (1.57) / BC1/DXT1; BLD, KOR, AFX need a 256*256 image, adapt the actual picture size accordingly

    And for the text in both screen (up left for the Stage Select screen, up right for the pre-versus'):
    - 256*128 or 512*128 / Comic Sans MS Bold 34 (Place) and Arial Bold 36 (Stage name) / BC2/DXT3

    To avoid you the pain of figuring out which stage's text needs which resolution, here's the list of the stages needing a 256*128 dds: AFR, RVR, AFX, VIE, JPN, VCN.

    Another time consuming task is figuring which files you need to edit, so here's the list:
  • \ressource\ui\stage_select\stage_select.emz: for every big/small preview picture and Stage Select screen's text. Finding the small ones is easy, since the entry name corresponds to the stage name. The big picture/text is much more difficult to find, so here's a list to help you out (pic/pic/txt/txt; I guess you have to inject the new pic and text twice, in both entries, I haven't tried to do it at only one place...):
        • BLD: I30 / I3E / I8A / I98
        • IND: I33 / I41 / I8D / I9B
        • KOR: I36 / I44 / I90 / I9E
        • AFX: I39 / I47 / I93 / IA1
        • LBX: I3C / I4A / I96 / IA4
        • USA: I3F / I4D / I99 / IA7
        • CHN: I42 / I50 / I9C / IAA
        • RUS: I45 / I53 / I9F / IAD
        • BRA: I48 / I56 / IA2 / IB0
        • AFR: I4B / I59 / IA5 / IB3
        • VIE: I4E / I5C / IA8 / IB6
        • JPN: I51 / I5F / IAB / IB9
        • EUR: I54 / I62 / IAE / IBC
        • SCO: I57 / I65 / IB1 / IBF
        • JPX: I5A / I68 / IB4 / IC2
        • LAB: I5D / I6B / IB7 / IC5
        • RVR: I60 / I6E / IBA / IC8
        • VCN: I63 / I71 / IBD / ICB
        • CNX: I66 / I74 / IC0 / ICE
        • BRX: I69 / I77 / IC3 / ID1
        • VNX: I6C / I7A / IC6 / ID4
        • TRN: I6F / I7D / IC9 / ID7
  • \ressource\ui\versus\versus\img#.emb.emz, where # is between 0 and 3: for everything pre-versus screen related. The entries are self explanatory, with JPN_name for the text part, and stage_JPN for the medium preview picture. Just take a look to find out which stage is where (the text and the picture entries can be in different files). Also, img3.emb.emz contains Boxer's name, so if you're using a JPN character's name mod, be sure to swap the original (Balrog) with is counterpart (M. Bison, to be found in some other file).
And finally, though I won't go through the hassle of explaining Gimp's image editing manipulations (a small hint about it though, be sure to use the game's original files as models for the shapes, especially for the small preview image; that way the result will fit perfectly into the game's screen), I'll throw a word about the halo thing around the text.
At first, I followed this tutorial. The result was good, but I came around a faster and better looking method after a while: follow all the steps until before applying the first Gaussian filter, then do a select all (CTRL-A), and apply directly a 10 point Gaussian filter. That way, you only have to apply one filter with one setting, removing the need to change the settings from 5 to 10 points every time. Finally, just follow the end steps of the linked tutorial.

Ok, now you're set, all that's left is to inject all of your files one by one into the game's files. A long and boring process if you're doing every stage at once, but the result is really worth it!
One last word about this part of the process: don't pay attention if the SF4 assets explorer preview looks messed up, it doesn't affect the in game result.
[IMG]

  1. Mute the announcer
    This is quite easy:
  • open \ressource\ui\sound\se\VERSUS_SE.csb with SSFIVAM
  • extract everything in a temporary folder ("unpack" command)
  • hexedit the files containing the sounds you want to delete by selecting all and replacing the data with zeros (listen to the files in AM beforehand, to found out the name of the sounds you want to delete)
  • then inject all the files inside the original file ("replace content with..." command)

    There may be a better way, but that one worked great for me^^.
And that's it for the ULSM tutorial!

SSF4AE - Swapping Static Objects with sloth86's Tools

Swapping static objects with sloth86's tools.
copyright sensibeat

sloth86's toolshttp://aemods.pbworks.com/w/page/42053948/aetools#Sloth86sModelSwapTools

piecemonteeSF4explorerV0.37b.exehttp://sf4viewer.sourceforge.net/

With this method you can only swap static objects assigned to 1 bone.

First chose a .obj you want to swap:


Chose a character and extract the full model as a .obj with sf4explorer:


You'll have to edit the model in your 3D editor to fit the character:


¤ More infos about that part here: http://filthypants.blogspot.com/2009/08/beginners-guide-to-sf4-model-editing.html

¤ To open the .obj in 3ds max you may need to open it and save it in misfit model 3d first.

Now you have your model in place save it and open EMG2SMD.exe:

I want to swap my cap with zangief's hairs (15th #EMG -as viewed in sf4explorer-)

Open the smd in notepad and look for the number of the bone you want to link your object to:

in that case I want to link to the "head bone": #6.

¤ More infos on smd here: http://developer.valvesoftware.com/wiki/Studiomdl_Data

Now you can use OBJ2EMG.exe:

¤ To use a .obj from 3ds max in OBJ2EMG you may need to open it and save it in misfit model 3d first.

Then use EMGSWAP.exe:


We aren't done yet, it needs some textures (diffusion+normal map dds):

¤ See other tutorials to add dds to your col.emb and nml.emb...

Then use DDSREFEDIT32.exe (I renamed former new.emo to ZGF_01.obj.emo before this step):


That looks OK in sf4explorer:


Let's test in game:


edit:
I thought the bone ID# was in hexadecimal in the smb... it's in decimal sorry for the confusion, I erased that part.
You actually need to write it in hexadecimal when you do it manually, we'll see that in another tutorial...

edit 2: I knew I forgot something...

I didn't linked any material features in the .emm to my "mcap"

2 ways to do it:
1) the lazy way: edit the obj.emo in hexadecimal and change "mcap" by a material that could do the trick like "shoes" or "pants"

2) using NanjouJ's matedit tool, replacing an unused material (in that case "hair") by "mcap" and the features you want to use on it.
http://aemods.pbworks.com/w/page/42053948/aetools#NanjouJsMaterialsTool
UPDATE: use sloth86's EMMEdit instead. It's much easier.

Here's the final result with material features added (no more weird reflections):

Friday, September 16, 2011

Reinstalling GRUB2

This has come up a million times (every time I reinstall Windows, in fact), and every time I have to search around online and try to remember how to do it. I figured this most recent time that I would just go ahead and write a blog post about it and be done with it, so here it is.

According to this handy page from the Ubuntu community documentation, there are a couple of ways to skin this particular cat. The one that worked best for me was to take an Alternate CD that I already had on-hand, boot into it, and choose 'Repair an Existing Installation' (or something like that) at the first splash screen (the one where you can check the CD integrity, run memtest, etc.).

Once it gets started, run through the options choosing the default keyboard layout, time zone, etc. When it asks you to choose a root, accompanied by a list of all of the HDD partitions, it appears you may choose any of them (I chose /dev/sda5 on this particular machine, which has Win7 in a primary partition and Ubuntu spread across 3 logical partitions). Then, once it kicks you to a command prompt, type:
sudo grub-install /dev/sda
That's it.

Other easy options that I didn't try include booting into a LiveCD session, then installing and running the boot-repair package (it didn't even show up in the apt-cache when I searched for it, so YMMV). In the program, choose the "First Repair" option and then reboot without the CD in the drive. A GRUB splash should show up proposing both Ubuntu and Windows.

Thursday, September 15, 2011

Windows 8 Dev Preview on Lenovo X61 Tablet

I downloaded Microsoft's Windows 8 Developer Preview the other day and decided to try it out on my Lenovo X61 tablet PC. NOTE: This is an older X61, running the Centrino Pro chipset (an older Core2 series chipset). For newer models, you might need to run Windows Update after installing to enable pen/touch input (thanks to reader taytor head for the info).

The trackpoint/eraserhead/navigation nipple/whatever works fine from the get-go, but the middle-button mousewheel emulation does not. It's easily fixed, though, by downloading and installing the driver from Lenovo. After this easy fix, though, I started running into some problems.

First off, my Centrino Pro chipset (Intel Mobile GM965 Express) graphics driver wasn't recognized by default, and every time I tried to install it manually, it failed with an error claiming that the chipset wasn't valid for the driver.

Knowing this to be false, I went and downloaded another copy of the driver from CNET (looks to be a Dell driver, based on some files contained within the driver package). This driver's installation utility failed with an error about an unsupported operating system, which I dealt with by right-clicking on it and going to the 'Compatibility' tab and choosing Windows Vista (no Service Packs) as the compatibility target. After that, the installer ran just fine. Now I have Aero and transparency and everything.

Out of the box, the system recognizes my stylus and allows for pen input and screen calibration. However, I wanted a few features that are only available from the official Wacom driver, so I downloaded it and tried to install it. The installation went fine, but upon reboot, the system no longer recognized my stylus at all. When I went to the control panels and clicked on the Wacom driver panel, it choked and failed with an error about how there were no compatible interfaces found on the system.... Luckily, after uninstalling the driver from my Programs list and uninstalling the drivers from the device manager, all is well again, though I'm stuck with the generic, MS driver.

Other than those hiccups, everything seems to be working well. The system is overtly similar to Windows 7, only with sharp corners and a little less transparency everywhere. Window borders are more opaque now, and they no longer have the Vista-style reflection/glare effects.

The 'ribbon' menu style has been adopted throughout the system and, while I don't really like it, I suspect it will grow on me, much like it did when introduced to Office 2007.

Before my video driver was installed, the Metro UI was horribly slow and took several seconds to transition to and from the traditional desktop view. However, with the driver installed, everything is snappy and attractive.

At this point, the Metro UI is sort of useless and is just a glorified launcher, but MS intends to have the launcher squares configurable and with live updates (i.e., your buddies list will update with who is online, the weather application will show live weather, etc.). However, applications will have to be written especially for the Metro UI using a new API, and MS intends to charge developers 30% of revenue for Metro apps, just like Apple does with their App Store.

If you have any questions about Windows 8 in general or its use on this computer, specifically, drop me a comment.

Tuesday, September 13, 2011

CCSM Locale Not Supported Error

My HTPC's compizconfig-settings-manager (ccsm) started failing to launch whenever I clicked on the link, so I tried to run it from the terminal to see what was up. When I did, I saw that it was coughing up this error:

(ccsm:8581): Gtk-WARNING **: Locale not supported by C library.
        Using the fallback 'C' locale.
Info: No sexy-python package found, don't worry it's optional.
Traceback (most recent call last):
  File "/usr/bin/ccsm", line 38, in 
    import ccm
  File "/usr/lib/python2.5/site-packages/ccm/__init__.py", line 1, in 
    from ccm.Conflicts import *
  File "/usr/lib/python2.5/site-packages/ccm/Conflicts.py", line 26, in 
    from ccm.Constants import *
  File "/usr/lib/python2.5/site-packages/ccm/Constants.py", line 72, in 
    locale.setlocale(locale.LC_ALL, "")
  File "/usr/lib/python2.5/locale.py", line 476, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
Turns out the fix is pretty simple. Just open up a terminal and type:

LC_All=en_US.utf8
Lang=en_US.utf8
ccsm

one after another.

Unfortunately, this fix doesn't seem to stick, so you have to do it every time you want to launch.

Analytics Tracking Footer