GTK/X11 Port (aka Linux/UNIX GUI)

This is for people involved in the developement of Snes9x, or SNES emulators in general.
BUG REPORTS BELONG IN TECH SUPPORT/BUG TRACKING!
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Re: GTK/X11 Port (aka Linux/UNIX GUI)

Post by BearOso »

D-- wrote:

Code: Select all

/usr/bin/ld: non-dynamic relocations refer to dynamic symbol area
The compile (or one of its dependencies) looks to be missing the -fPIC compiler flag. Inconsistent usage of -fPIC can apparently cause this error on MIPS.

The first thing to try is to compile Snes9x GTK with -fPIC. AFAIK, apt-get doesn't pick up environment CFLAGS, so you'll either have to build the source directly with -fPIC in your CFLAGS, or add CFLAGS="-fPIC" in front of the configure invocation in debian/rules.

If that doesn't work, one of your libraries might be non-relocatable. Did you get all of your dependencies from the official repositories, or are some of them hand-compiled or non-official?
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

Ezekiel000 wrote: But I am getting a segfault when I try to load a saved state.
I know of this bug, and I'm mostly sure that this is in the core, not in the port code. A backtrace would be helpful if you know how to make one, but since you're using the binary deb it's probably more trouble than it's worth. I'll try to look into it some more.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

Just a note: I'm going to try to get everything into either Launchpad or Google Code over the next few days so fixes and such are more available without having a roll a new release every time.
D--
Snes9x White Belt
Posts: 11
Joined: Mon Feb 09, 2009 10:11 am
Location: Beijing, China

Post by D-- »

Well it took me all night but I got it to link. Problem is there is no video or sound output, though the frameskip says it is pretending to do something. :( Tried all three video output methods.
Ezekiel000
Snes9x White Belt
Posts: 12
Joined: Sat Feb 07, 2009 7:08 pm

Post by Ezekiel000 »

BearOso wrote:
Ezekiel000 wrote: But I am getting a segfault when I try to load a saved state.
I know of this bug, and I'm mostly sure that this is in the core, not in the port code. A backtrace would be helpful if you know how to make one, but since you're using the binary deb it's probably more trouble than it's worth. I'll try to look into it some more.
Sorry I have no idea how to do a backtrace. I can have a go if you tell me how with the deb version or would I have to compile it myself?

Any ideas on the reason for the screen fading to black?
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

D-- wrote:Well it took me all night but I got it to link. Problem is there is no video or sound output, though the frameskip says it is pretending to do something. :( Tried all three video output methods.
Could you clarify? What do you mean by "frameskip says it is pretending to do something?" I would think no video or sound means it's not actually running the game.
Ezekiel000 wrote: Sorry I have no idea how to do a backtrace. I can have a go if you tell me how with the deb version or would I have to compile it myself?

Any ideas on the reason for the screen fading to black?
Don't worry about the backtrace, it would be way too much work if you don't already know how to generate one.

The screen fading to black is definitely the fault of the power manager not respecting the X screensaver blocking request. Are you using a joystick, or is it still doing this when using the keyboard as a control?
Ezekiel000
Snes9x White Belt
Posts: 12
Joined: Sat Feb 07, 2009 7:08 pm

Post by Ezekiel000 »

I only use a PS2 joypad with a usb converter, I don't touch the keyboard at all.
D--
Snes9x White Belt
Posts: 11
Joined: Mon Feb 09, 2009 10:11 am
Location: Beijing, China

Post by D-- »

BearOso wrote:
D-- wrote:Well it took me all night but I got it to link. Problem is there is no video or sound output, though the frameskip says it is pretending to do something. :( Tried all three video output methods.
Could you clarify? What do you mean by "frameskip says it is pretending to do something?" I would think no video or sound means it's not actually running the game.
I would think that too, but enabled frameskip display. It showed the frameskip change as I adjusted the speed of my cpu, sliding down from 60/60 to around 12/60 at 200Hz. It also updated the status bar with the ROM's internal name.
Ezekiel000
Snes9x White Belt
Posts: 12
Joined: Sat Feb 07, 2009 7:08 pm

Post by Ezekiel000 »

That sounds like a good solution but couldn't you instead of just making the system think your pressing a key every 20 seconds why not link it to the joypad input? so that every time you press a button on the joypad it does whatever is assigned to the button and also sends a fake key press? and as you said only while snes9x is the selected window.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

D-- wrote:I would think that too, but enabled frameskip display. It showed the frameskip change as I adjusted the speed of my cpu, sliding down from 60/60 to around 12/60 at 200Hz. It also updated the status bar with the ROM's internal name.
Does this happen with all ROMs, then? I can reproduce a few cases of this exact situation where the game is waiting on the APU state, and it will never continue if it can't read it (e.g. Super Metroid). Can you try toggling the options under Preferences->Emulation->Accuracy and the "Volume envelope height reading" option in Preferences->Sound, and resetting after each one to see if you can get it to continue?
byuu wrote:You certainly could. But I know I wouldn't want the screen saver activating if I had a game loaded, but was reading a walk-through manual or getting a drink.

Probably a good idea to let it go to sleep if there's no cart loaded, the emu is paused or the power is off.
I actually allowed both methods. By default, joypad events would reset the screensaver, but there is an option to disable it entirely.

Code: Select all

  //XResetScreenSaver() does not work 
XResetScreenSaver is what I'm using, and, for one reason or another, it actually does work for me. Faking a keypress does seem more foolproof, though. Thanks, byuu, I do think I'll borrow your solution.
D--
Snes9x White Belt
Posts: 11
Joined: Mon Feb 09, 2009 10:11 am
Location: Beijing, China

Post by D-- »

Total failure. I tried it with Dragon Quest I&II, Lufia, Super Mario World. Tested every video renderer (shouldn't software be guaranteed?) and every sound sample option. I also tried toggling the one you told me to.

Absolutely no change.

Possibly worth noting, something is seriously wrong during the compile of hq2x. It takes roughly half an hour (more than all the rest of snes9x * 2) and balloons to using more than 600MB RAM at points. In fact, I couldn't even compile snes9x until I upgraded from 512M to 1G RAM. bsnes and mednafen both include hq2x, but neither suffers from this problem.

I switched to using ./configure && make which made -fPIC no longer needed. But that has not resolved any of these other problems.

Apparantly snes9x-gtk really does not like a mipsel 64-bit environment.

Almost all my packages come from lenny except a few provided by Lemote to fix hardware bugs. Only snes9x is having these problems. I can build and run bsnes (slowly) and mednafen, as well as plenty of games.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

D-- wrote:Total failure. I tried it with Dragon Quest I&II, Lufia, Super Mario World. Tested every video renderer (shouldn't software be guaranteed?) and every sound sample option. I also tried toggling the one you told me to.

Absolutely no change.

Possibly worth noting, something is seriously wrong during the compile of hq2x. It takes roughly half an hour (more than all the rest of snes9x * 2) and balloons to using more than 600MB RAM at points. In fact, I couldn't even compile snes9x until I upgraded from 512M to 1G RAM. bsnes and mednafen both include hq2x, but neither suffers from this problem.

I switched to using ./configure && make which made -fPIC no longer needed. But that has not resolved any of these other problems.

Apparantly snes9x-gtk really does not like a mipsel 64-bit environment.

Almost all my packages come from lenny except a few provided by Lemote to fix hardware bugs. Only snes9x is having these problems. I can build and run bsnes (slowly) and mednafen, as well as plenty of games.
Does the original unix snes9x work? If it does, then there's probably some platform define that's not being enabled correctly. From what you're saying, it actually looks like port code is working correctly. If you're getting a frame display, then the S9x core loop is being hit and generating video output. All the video renderers ARE working, as they're outputting the frame rate display. What is probably messed up is how the port initializes or compiles the core, which causes the core to hit an infinite loop in the emulated instructions somewhere.
D--
Snes9x White Belt
Posts: 11
Joined: Mon Feb 09, 2009 10:11 am
Location: Beijing, China

Post by D-- »

I'll try real snes9x in a bit. The one packaged by Debian segfaults like many lenny packages.

Edit: Fantastic. Original snes9x does the same thing as snes9x-gtk with the default ./configure. I guess it's not as portable as the team thinks it is. That means bsnes (at 20 fps) is the only SNES emulator functioning on MIPS.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

D-- wrote:I'll try real snes9x in a bit. The one packaged by Debian segfaults like many lenny packages.

Edit: Fantastic. Original snes9x does the same thing as snes9x-gtk with the default ./configure. I guess it's not as portable as the team thinks it is. That means bsnes (at 20 fps) is the only SNES emulator functioning on MIPS.
It might be an endian issue. In the file port.h:

Code: Select all

if defined(__i386__) || defined(__i486__) || defined(__i586__) ||     defined(__x86_64__) || defined(__WIN32__) || defined(__alpha__)
#define LSB_FIRST
#define FAST_LSB_WORD_ACCESS
#else
#define MSB_FIRST
#endif
It might be setting MSB_FIRST for your architecture. Can you see if it works by changing the second line to:

Code: Select all

 defined(__x86_64__) || defined(__WIN32__) || defined(__alpha__) || defined(__MIPSEL__)
D--
Snes9x White Belt
Posts: 11
Joined: Mon Feb 09, 2009 10:11 am
Location: Beijing, China

Post by D-- »

Making progress, but now I find the XVideo driver is broke.

Image

It's hard to show you the problem since there's no way to screenshot the Xv layer. But in this picture of the King's room in DQI&II, the colors are inverted. The blue outside is orange, and the king and all his red carpet are blue.

Sounds like inverted byte ordering, right? Well when I check that option, the outside turns the wrong shade of blue and everything else is a magenta mess.

Edit: byuu figured out it was because you're writing 15-bit color on my 16-bit display. We disabled RGB and it worked, but would be nice to get that back to fix chroma. Sound is also doing this weird thing where it keeps speeding up and slowing down. Tried all three cores but the problem seems present everywhere. Is it a throttling issue? I notice the fps varying a bit, but honestly it performs almost the same whether clocked at 498MHz or 796MHz.

Code: Select all

d@medan:~$ xvinfo
X-Video Extension version 2.2
screen #0
  Adaptor #0: "Silicon Motion Lynx Series Video Engine"
    number of ports: 1
    port base: 60
    operations supported: PutImage 
    supported visuals:
      depth 16, visualID 0x22
      depth 16, visualID 0x23
      depth 16, visualID 0x24
      depth 16, visualID 0x25
    number of attributes: 2
      "XV_BRIGHTNESS" (range 0 to 255)
              client settable attribute
              client gettable attribute (current value is 0)
      "XV_COLORKEY" (range 0 to 16777215)
              client settable attribute
              client gettable attribute (current value is 2110)
    number of encodings: 18
      encoding ID #0: "pal-composite-0"
        size: 704 x 576
        rate: 0.020000
      encoding ID #1: "ntsc-composite-0"
        size: 704 x 480
        rate: 0.016683
      encoding ID #2: "secam-composite-0"
        size: 7040 x 576
        rate: 0.020000
      encoding ID #3: "pal-composite-1"
        size: 704 x 576
        rate: 0.020000
      encoding ID #4: "ntsc-composite-1"
        size: 704 x 480
        rate: 0.016683
      encoding ID #5: "secam-composite-1"
        size: 7040 x 576
        rate: 0.020000
      encoding ID #6: "pal-composite-2"
        size: 704 x 576
        rate: 0.020000
      encoding ID #7: "ntsc-composite-2"
        size: 704 x 480
        rate: 0.016683
      encoding ID #8: "secam-composite-2"
        size: 7040 x 576
        rate: 0.020000
      encoding ID #9: "pal-composite-3"
        size: 704 x 576
        rate: 0.020000
      encoding ID #10: "ntsc-composite-3"
        size: 704 x 480
        rate: 0.016683
      encoding ID #11: "secam-composite-3"
        size: 7040 x 576
        rate: 0.020000
      encoding ID #12: "pal-svideo-0"
        size: 704 x 576
        rate: 0.020000
      encoding ID #13: "ntsc-svideo-0"
        size: 704 x 480
        rate: 0.016683
      encoding ID #14: "secam-svideo-0"
        size: 7040 x 576
        rate: 0.020000
      encoding ID #15: "pal-svideo-1"
        size: 704 x 576
        rate: 0.020000
      encoding ID #16: "ntsc-svideo-1"
        size: 704 x 480
        rate: 0.016683
      encoding ID #17: "secam-svideo-1"
        size: 7040 x 576
        rate: 0.020000
D--
Snes9x White Belt
Posts: 11
Joined: Mon Feb 09, 2009 10:11 am
Location: Beijing, China

Post by D-- »

in snes9x-gtk-1.51.64/gtk/src/gtk_display_driver_xv.cpp line 500

Code: Select all

                bytes_per_pixel = (bpp == 15) ? 2 : bpp >> 3;

                this->rshift = get_inv_shift (formats[i].red_mask, bpp);
                this->gshift = get_inv_shift (formats[i].green_mask, bpp);
                this->bshift = get_inv_shift (formats[i].blue_mask, bpp);

                /* on big-endian Xv still seems to like LSB order */
                if (config->force_inverted_byte_order)
                    S9xSetEndianess (ENDIAN_MSB);
                else
                    S9xSetEndianess (ENDIAN_LSB);
to

Code: Select all

                bytes_per_pixel = (bpp == 15) ? 2 : bpp >> 3;

                this->bshift = get_inv_shift (formats[i].red_mask, bpp);
                this->gshift = get_inv_shift (formats[i].green_mask, bpp);
                this->rshift = get_inv_shift (formats[i].blue_mask, bpp);

                /* on big-endian Xv still seems to like LSB order */
                if (config->force_inverted_byte_order)
                    S9xSetEndianess (ENDIAN_MSB);
                else
                    S9xSetEndianess (ENDIAN_LSB);
Sorry, it looks like your later attempt at flipping is never triggered when bpp = 16. This fixed the Xvideo driver on SiliconMotion compatible video cards (specifically LynxEM 712).
Post Reply