welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Using

Fri Nov 30, 2012 6:31 pm

SNES9X-SDL-v1.53
There are various solutions to SNES emulation available for the RPi, some have been discussed fully within the Forum (Retroarch, snes9x-sdl v1.39) whilst others haven’t. Unfortunately, one of the common principles in emulation is “compromise” whether it be for performance, compatibility or ease of use. This version runs “Fullspeed”, although, it DOES make “liberal” use of frameskip to attain this performance (It’s only actually rendering about 12-15 frames of the 60FPS*). However, this can be “tinkered” with, see below for more information! Sound performance is excellent and it will run ANY game enhanced by use of an “On Cart” additional processor (e.g. SuperFX - StarFox/StarWing), of which there were MANY variations!
* 60FPS = Frames Per Second (NTSC frame refresh speed (PAL is 50 FPS))

For an “Almost” FULL SPEED/FULL FRAMERATE solution see palerider’s excellent guide on snes9x-sdl v1.39 here -
http://www.raspberrypi.org/phpBB3/viewt ... 78&t=23272
NB This will NOT run SuperFX and certain DSP games!!! (But DOES run Super Mario Kart (DSP-1 Assisted)) AND has other limitations (A more complicated set up etc)

SNES9X-SDL v1.53 - Compiled using 2012-09-18-wheezy-raspbian, RPi is 256MEG and over clocked to 900MHz
Source Code - snes9x-sdl-master.tar.gz*
Dependencies - sdl1.2-dev
Additional Files Required - Game ROMS

*Download Here - https://github.com/domaemon/snes9x-sdl
(Just Click on the “ZIP” Image with a Cloud at the top to download as a Zip file)

1. Can be compiled from Console or a Terminal within “X”
2. Make sure you have the RAM split set up attributing ALL the RAM to the ARM (Use the config (sudo raspi-config))
3. Compile as ROOT (Set up a root password for this if you haven’t already! (sudo passwd root)
4. Install libsdl1.2-dev dependencies (apt-get install libsdl1.2-dev)
Now just CD into the directory where you uncompressed the source code, then the sdl folder and Type -
./configure --enable-debug (The program WILL fail to compile if you DO NOT use this! (It runs out of memory). The executable will be a BIGGER file, but will allow it to compile within the RPi’s RAM limitations)
make
make install (Optional, DOES NOT give a significant performance increase from Terminal/Console (i.e. Not in X), but DOES allow running FULLSCREEN from Console without any alterations to configuration files)
5. Exit ROOT
6. Now start the executable so it sets up all the correct folders Type -
./snes9x-sdl (Hopefully it will give you a message telling you it’s set these up!)
7. Open “File Manager”
8. There should now be a hidden folder .snes9x (If you cannot see it, right click on your mouse and tick the “Show Hidden” Box)
9. Put any ROMS you have in the appropriate folder (rom)
10. Now from a Terminal Type -
./snes9x-sdl “Name of ROM (With extention i.e. .zip, .smc etc)” “OPTION” e.g. -
./snes9x-sdl smw.zip -displayframerate
In this case - Runs Super Mario World (I changes the name for ease of typing!) and shows framerate/frameskip

FRAMESKIP ADJUSTMENT
As mentioned previously, snes9x-sdl-v1.53 makes “liberal” use of frameskip (the actual amount of frames being rendered) to attain 60FPS* performance. Unfortunately this does have a negative effect, REDUCING ANIMATION FRAMES (For instance in Super Mario World Mario resembles “MR BENN” occasionally when running! Example - http://www.youtube.com/watch?feature=pl ... h_U#t=573s
The “auto” settings can be overridden manually by adding “--frameskip (NUMBER)” to the command line. This is where the “compromise” comes in, adjusting framerate against frames rendered to get the best overall performance. It is also dependant on the game being emulated (Due to the complexities of the calculations required) so for instance F-Zero requires a greater use of frameskip than say Super Mario World to run at 60FPS (Rendering as many frames as possible)! Personally, I have found 3-5 works best for “MOST” games so add -
e.g. -frameskip 4 to the command line

CONTROLS
For a FULL description of the Controls and Options see the “readme_unix.html” file in the Unix/Docs Folder

The default key mapping for joypad 1 is as follows:
U or Up - Up direction
J or Down - Down direction
H or Left - Left direction
K or Right - Right direction
D - A button
C - B button
S - X button
X - Y button
A - L button
Z - R button
Space - Select button
Return - Start button
"The list of things I have heard now contains everything!"

User avatar
edwinsage
Posts: 13
Joined: Thu Dec 06, 2012 2:03 am
Location: Kalamazoo

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Fri Dec 14, 2012 7:08 pm

I've found it useful to make a larger swapfile when building programs, to avoid out-of-memory errors. Usually I leave swap off, but I bet this will help for building without debugging:

Code: Select all

sudo dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
sudo mkswap /swapfile1
sudo chown root:root /swapfile1
sudo chmod 0600 /swapfile1
sudo swapon /swapfile1
The Art of Unix Programming: http://faqs.org/docs/artu/

User avatar
edwinsage
Posts: 13
Joined: Thu Dec 06, 2012 2:03 am
Location: Kalamazoo

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Fri Dec 14, 2012 11:17 pm

Well, I built it without the --enable-debug flag and it seemed to work, though I forgot that the hq2x filter takes FOREVER to build using SD card swapfiles. I've got a suspicion that something went wrong though.

Issues:
"make: *** No rule to make target `install'. Stop." -- Weird. Not sure why this wouldn't work.
Loading roms from the console doesn't seem to work. The first rom I tried (Super Metroid) just made the screen turn black. Other roms didn't even do that; it just displayed a message about sound buffer size and then did nothing, just hung.
Running the program didn't set up any folders, but I already had a .snes9x folder. I can see that it wrote to a file for Super Metroid. I tried deleting the folder and running again, but it did not re-create it.

the make command exited rather unceremoniously, though without errors. I'm wondering if it died silently in the middle of things somehow. Last line displayed during build was this:

Code: Select all

g++ -I. -I.. -I../apu/ -I../unzip/ -I../jma/ -I../filter/ -o snes9x-sdl ../apu/apu.o ../apu/SNES_SPC.o ../apu/SNES_SPC_misc.o ../apu/SNES_SPC_state.o ../apu/SPC_DSP.o ../apu/SPC_Filter.o ../bsx.o ../c4.o ../c4emu.o ../cheats.o ../cheats2.o ../clip.o ../conffile.o ../controls.o ../cpu.o ../cpuexec.o ../cpuops.o ../crosshairs.o ../dma.o ../dsp.o ../dsp1.o ../dsp2.o ../dsp3.o ../dsp4.o ../fxinst.o ../fxemu.o ../gfx.o ../globals.o ../logger.o ../memmap.o ../movie.o ../obc1.o ../ppu.o ../reader.o ../sa1.o ../sa1cpu.o ../screenshot.o ../sdd1.o ../sdd1emu.o ../seta.o ../seta010.o ../seta011.o ../seta018.o ../snapshot.o ../snes9x.o ../spc7110.o ../srtc.o ../tile.o ../filter/2xsai.o ../filter/blit.o ../filter/epx.o ../filter/hq2x.o ../filter/snes_ntsc.o sdlmain.o sdlinput.o sdlvideo.o sdlaudio.o ../loadzip.o ../unzip/ioapi.o ../unzip/unzip.o ../jma/7zlzma.o ../jma/crc32.o ../jma/iiostrm.o ../jma/inbyte.o ../jma/jma.o ../jma/lzma.o ../jma/lzmadec.o ../jma/s9x-jma.o ../jma/winout.o -lm -lz -lpng -L/usr/lib/arm-linux-gnueabihf -lSDL
So my only question, before I take the time to try building again, is it really critical to run 'make' as root? I did not, as I'm used to building as user and installing as root.
The Art of Unix Programming: http://faqs.org/docs/artu/

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sat Dec 15, 2012 9:43 am

edwinsage
Sounds like it didn't build properly! If you used a previous .snes9X folder it MAY be incorrect! (That's why on starting you only get a "Blank" screen. you could try adding the path to prove it! e.g. -

snes9X “folder name”/”game name”.zip (Or check/change the configuration file to make sure it’s “looking in the right place”)

For instance I haven’t, as yet, "Installed" SNES9X as I am currently using TWO versions v1.39 AND v1.53 (v1.39 uses a DIFFERENT file structure!), and I generally DON'T until I'm happy with its operation/use (There are exceptions, FBZX DOESNT produce an "executable" so you HAVE to make an install!)

With regards to privileges, in a previous Thread, I outlined my logic for its use (When somebody questioned its use rather than “SUDO”) this was in my GnGeo “Guide” -

“Yes, a good point! However, I have found SOME programs are problematic with the "sudo" suffix (Mame and Mess for instance). If I recall correctly root MAY have been needed to move the Bios files! Also, it is meant to be a “Beginners Guide”, when getting to grips with Linux myself I was slightly confused by the whole issue of user/root/sudo commands. Personally, I find it easier to think of Linux: ROOT (Super User) = MSDOS: Administrator; and structure my usage in a similar fashion (Maybe I’m showing my age! My programming background is with MOS 6502 Assembler back in the early 80’s where structure is EVERYTHING!). Anyway, thanks’ for the comment it may help people using the Guide!”

However, as you stated, MOST Emulators DO NOT seem to have an issue with compiling under “user” privileges or “sudo”, (But you WILL have to be “ROOT” to make an install (As there is a fundamental change to the O/S and File Structure!)), but I like to keep a “standard” approach for the reasons stated above! (This is however changing, many of my early works were cut/edit/paste's from the GnGeo/AdvMAME "Guides")

Hope that Helps!

Just one Last Thing, although your

"sudo dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
sudo mkswap /swapfile1
sudo chown root:root /swapfile1
sudo chmod 0600 /swapfile1
sudo swapon /swapfile1"

solution is clever ,(I DONT claim to be an "EXPERT" on Linux myself!), as I have stated before, my guides are for "Beginners", --enable-debug is a simpler solution!
"The list of things I have heard now contains everything!"

User avatar
Jompa89
Posts: 6
Joined: Sat Dec 29, 2012 1:46 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sat Dec 29, 2012 10:36 pm

When running "make" i get this error:

Code: Select all

g++ -I. -I.. -I../apu/ -I../unzip/ -I../jma/ -I../filter/ -c -O3 -fomit-frame-pointer -fno-exceptions -fno-rtti -pedantic -Wall -W -Wno-unused-parameter -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DZLIB -DUNZIP_SUPPORT -DJMA_SUPPORT -DHAVE_LIBPNG -DHAVE_MKSTEMP -DHAVE_STRINGS_H -DHAVE_SYS_IOCTL_H -DHAVE_STDINT_H -DRIGHTSHIFT_IS_SAR  ../filter/hq2x.cpp -o ../filter/hq2x.o
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
make: *** [../filter/hq2x.o] Error 4
Norwegian politics student and Linux enthusiast.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sun Dec 30, 2012 10:23 am

Jompa89
It looks like the compiler ran out of memory! Don’t forget, when configuring add the line -

./configure --enable-debug

I received a 512MEG RPi for Christmas and have started a NEW CARD using the 2012-10-28-wheezy-raspbian Image (The OLDER O/S wasn’t addressing the EXTRA Memory!). I have noted in other threads the need to change certain values/compile parameters depending in the O/S Image being used (For instance AdvMESS and AdvMENU WON’T compile using GCC 4.7! (It WAS needed for 2012-09-18-wheezy-raspbian)). As I continue setting up the new Image I will amend/note the changes and add my findings to the other Emulator “Guide’s” I have written, keep a look out for the updates on the Forum!
"The list of things I have heard now contains everything!"

User avatar
Jompa89
Posts: 6
Joined: Sat Dec 29, 2012 1:46 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sun Dec 30, 2012 10:45 am

I did run "./configure --enable-debug" but it happened anyway. I installed Raspbian from the 2012-12-16 image, so I don't know if that is affected by what you are mentioning. Should I just wait for a revised version or do you think there is something I can do to make it work now?
Norwegian politics student and Linux enthusiast.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sun Dec 30, 2012 11:00 am

Jompa89
I do know (Have read within the forum) there have been varying degrees of problems with that Image! (Some users are reporting AdvMAME DOESN’T WORK!). Try using an “Older” Raspbian O/S version! Link Below -

http://downloads.raspberrypi.org/images/raspbian/
"The list of things I have heard now contains everything!"

User avatar
Jompa89
Posts: 6
Joined: Sat Dec 29, 2012 1:46 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sun Dec 30, 2012 11:05 am

Which one will work best with this guide?
Norwegian politics student and Linux enthusiast.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sun Dec 30, 2012 11:10 am

Jompa89
"SNES9X-SDL v1.53 - Compiled using 2012-09-18-wheezy-raspbian, RPi is 256MEG and over clocked to 900MHz"
"The list of things I have heard now contains everything!"

User avatar
Jompa89
Posts: 6
Joined: Sat Dec 29, 2012 1:46 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sun Dec 30, 2012 11:39 am

Thanks, I'll try that :)
Norwegian politics student and Linux enthusiast.

User avatar
neobusy
Posts: 18
Joined: Mon Dec 03, 2012 11:24 am

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Mon Dec 31, 2012 11:42 am

Just built it on a 512meg pi and I have some feedback:

- Remember to change into the SDL directory. I accidentally built the unix one. Doh!

- you can compile it without debug, but you need swap - you can simplify the commands abit:

Code: Select all

sudo dd if=/dev/zero of=/swapfile1 bs=1MB count=512
sudo mkswap ./swapfile1
sudo swapon ./swapfile1
To demystify dd for you:
if means input file - we just want a file full of zeros so we take a system device as source which always returns zero
of is output file, this is our file we want to create
bs stands for blocksize, in this case we want 512 times 1 mb, which is 512 mb :)

It's still compiling, I''ll play around with command line options and report back, what works best for me!

badman12345
Posts: 33
Joined: Thu Feb 14, 2013 3:00 am

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Sat Feb 16, 2013 6:08 am

I can't seem to get my joystick to work with this at all... I try with forcing like so
-port1 pad1
And no luck.

Same when run without the -port option... nothing...

On startup, it does say
"Port 1: Pad #1"
...
Logitech Logitech Dual Action
4-axis 12-buttons 0-balls 1-hats

but it doesn't work....

Anyone else experiencing this?

tmielcarz
Posts: 6
Joined: Wed Jan 14, 2015 6:12 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Thu Feb 12, 2015 7:52 pm

badman12345 wrote:I can't seem to get my joystick to work with this at all... I try with forcing like so
-port1 pad1
And no luck.

Same when run without the -port option... nothing...

On startup, it does say
"Port 1: Pad #1"
...
Logitech Logitech Dual Action
4-axis 12-buttons 0-balls 1-hats

but it doesn't work....

Anyone else experiencing this?
I have the same problem with gamepad. Anyone managed it ?

ksari
Posts: 1
Joined: Wed Jun 24, 2015 3:07 pm

Re: SNES9X-SDL-v1.53 - A "Beginners Guide" to Compiling/Usin

Wed Jun 24, 2015 3:14 pm

tmielcarz wrote:
badman12345 wrote:I can't seem to get my joystick to work with this at all... I try with forcing like so
-port1 pad1
And no luck.

Same when run without the -port option... nothing...

On startup, it does say
"Port 1: Pad #1"
...
Logitech Logitech Dual Action
4-axis 12-buttons 0-balls 1-hats

but it doesn't work....

Anyone else experiencing this?
I have the same problem with gamepad. Anyone managed it ?
I managed to get the gamepad working by changing the line

Code: Select all

/***** Joystick starts *****/
#if 0
to

Code: Select all

/***** Joystick starts *****/
#if 1
in the file sdl/sdlinput.cpp before compiling. I found this on another forum but unfortunately can't remember where exactly.
Copying /sdl/docs/snes9x-sdl.conf to ~/.snes9x/snes9x.conf and editing where needed got all the buttons correctly mapped.

Return to “Gaming”